I am renovating a project I wrote before which had some Direct2D content using SharpDX. Then I moved to Silk.NET and encountered a strange problem. I can't use the CreateBitmapFromDxgiSurface method (hr=0x80070002). I think this should not be a problem with my environment configuration? Because it can still be used normally in SharpDX.
SharpDX version:
using D2D = SharpDX.Direct2D1;
using D3D = SharpDX.Direct3D;
using D3D11 = SharpDX.Direct3D11;
using DXGI = SharpDX.DXGI;
D3D11.Device _d3d11_Device;
DXGI.Device _dxgi_Device;
D2D.Device _d2d_Device;
DXGI.SwapChain _swapChain;
D2D.DeviceContext _d2d_DeviceContext;
D3D11.Device.CreateWithSwapChain (
D3D.DriverType.Hardware,
D3D11.DeviceCreationFlags.BgraSupport,
new DXGI.SwapChainDescription {
ModeDescription = new DXGI.ModeDescription {
RefreshRate = new DXGI.Rational (60, 1),
Format = DXGI.Format.B8G8R8A8_Unorm,
},
SampleDescription = new DXGI.SampleDescription (1, 0),
Usage = DXGI.Usage.RenderTargetOutput,
BufferCount = 1,
OutputHandle = handle,
IsWindowed = true,
},
out _d3d11_Device,
out _swapChain);
_dxgi_Device = _d3d11_Device.QueryInterface<D3D11.Device1> ().QueryInterface<DXGI.Device> ();
_d2d_Device = new D2D.Device (_dxgi_Device);
_d2d_DeviceContext = new D2D.DeviceContext (_d2d_Device, D2D.DeviceContextOptions.EnableMultithreadedOptimizations);
_d2d_DeviceContext.Target = new D2D.Bitmap1 (_d2d_DeviceContext, DXGI.Surface.FromSwapChain (_swapChain, 0));
This makes me very strange because new D2D.Bitmap1 (_d2d_DeviceContext, DXGI.Surface.FromSwapChain (_swapChain, 0)); in SharpDX also uses CreateBitmapFromDxgiSurface, but it cannot be used in Silk.NET.
Moving this to a discussion until we have evidence that this is a Silk.NET bug. At a guess this is an incorrect porting of implicit behaviour in SharpDX.
I am renovating a project I wrote before which had some Direct2D content using SharpDX. Then I moved to Silk.NET and encountered a strange problem. I can't use the CreateBitmapFromDxgiSurface method (hr=0x80070002). I think this should not be a problem with my environment configuration? Because it can still be used normally in SharpDX.
SharpDX version:
Silk.NET version:
This makes me very strange because
new D2D.Bitmap1 (_d2d_DeviceContext, DXGI.Surface.FromSwapChain (_swapChain, 0));
in SharpDX also usesCreateBitmapFromDxgiSurface
, but it cannot be used in Silk.NET.