Reputation:
So I try to create a SwapChain1 in SharpDX.
Here is the Code:
SwapChainDescription1 desc = new()
{
Width = toSetSize.Value.Width,
Height = toSetSize.Value.Height,
Format = Format.R8G8B8A8_UNorm,
Stereo = false,
SampleDescription = new SampleDescription(1, 0),
Usage = Usage.BackBuffer | Usage.RenderTargetOutput,
BufferCount = 1,
Scaling = Scaling.Stretch,
SwapEffect = SwapEffect.Discard
};
SwapChainFullScreenDescription scd = new SwapChainFullScreenDescription()
{
RefreshRate = new Rational(60, 1),
Scaling = DisplayModeScaling.Stretched,
Windowed = false
};
using (var dxgiDevice2 = device.QueryInterface<SharpDX.DXGI.Device2>())
using (var dxgiAdapter = dxgiDevice2.Adapter)
using (var dxgiFactory2 = dxgiAdapter.GetParent<SharpDX.DXGI.Factory2>())
{
res = new SwapChain1(dxgiAdapter.GetParent<SharpDX.DXGI.Factory2>(), device, Window.Handle, ref desc, scd);
return res;
}
my issue is, this code throws a AccessViolationException with the Attempted to read or write corrupted memory stuff.
What am i doing wrong?
How can i fix this?
I tried:
Changing the Parameters inside of "desc" and "scd"
Edit: So i got a step further, seemingly factory.NativePointer was IntPtr.Zero, i have updated the code, hope this helps...
Edit2: Okay one step closer, again, i enabled Debugging from native code and got this:
Exception called at 0x759CE292 in Demo.exe: Microsoft C++ Exception: _com_error at location 0x0297C5B8.
Exception called at 0x6BA81D22 (dxgi.dll) in Demo.exe: 0xC0000005: Access violation at position 0x000000B8.
Untranslated (german):
Ausnahme ausgelöst bei 0x759CE292 in Demo.exe: Microsoft C++-Ausnahme: _com_error bei Speicherort 0x0297C5B8.
Ausnahme ausgelöst bei 0x6BA81D22 (dxgi.dll) in Demo.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x000000B8.
Upvotes: 0
Views: 88