Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit 44c20af

Browse files
committed
Reduce restrictions on the type of device required.
- Removed explicitly specified Feature Level 11.1 - Fallback to WARP device if Hardware device not available - Direct2D Fallback to Software rendering if hardware not available.
1 parent eb73ec4 commit 44c20af

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/Captura.Windows/Imaging/Direct2D/Direct2DEditorSession.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using Captura.Models;
3+
using SharpDX;
34
using SharpDX.Direct2D1;
45
using SharpDX.Direct3D;
56
using SharpDX.Direct3D11;
@@ -10,7 +11,6 @@
1011
using Device = SharpDX.Direct3D11.Device;
1112
using Factory = SharpDX.DirectWrite.Factory;
1213
using Factory1 = SharpDX.Direct2D1.Factory1;
13-
using FeatureLevel = SharpDX.Direct3D.FeatureLevel;
1414
using PixelFormat = SharpDX.Direct2D1.PixelFormat;
1515

1616
namespace DesktopDuplication
@@ -49,9 +49,16 @@ public Direct2DEditorSession(int Width, int Height, IPreviewWindow PreviewWindow
4949
{
5050
_previewWindow = PreviewWindow;
5151

52-
Device = new Device(DriverType.Hardware,
53-
DeviceCreationFlags.BgraSupport,
54-
FeatureLevel.Level_11_1);
52+
try
53+
{
54+
Device = new Device(DriverType.Hardware,
55+
DeviceCreationFlags.BgraSupport);
56+
}
57+
catch (SharpDXException)
58+
{
59+
Device = new Device(DriverType.Warp,
60+
DeviceCreationFlags.BgraSupport);
61+
}
5562

5663
StagingTexture = new Texture2D(Device, new Texture2DDescription
5764
{
@@ -90,10 +97,7 @@ public Direct2DEditorSession(int Width, int Height, IPreviewWindow PreviewWindow
9097

9198
var pixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Ignore);
9299

93-
var renderTargetProps = new RenderTargetProperties(pixelFormat)
94-
{
95-
Type = RenderTargetType.Hardware
96-
};
100+
var renderTargetProps = new RenderTargetProperties(pixelFormat);
97101

98102
using (var surface = DesktopTexture.QueryInterface<Surface>())
99103
{

0 commit comments

Comments
 (0)