sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 639 forks source link

SharpDX + MonoGame + Mono x64 #587

Open ArcoMul opened 9 years ago

ArcoMul commented 9 years ago

Hi,

I am trying to run MonoGame on top of Mono x64 on Windows. I get an error in SharpDX though that the creation of SwapChain fails with an invalid call.

To exclude MonoGame I managed to reproduce the error in one of the SharpDX Samples (Direct3D11, MiniCube). The error it gives is pasted below.

This error occurs with both SharpDX 2.5.1 (version MonoGame uses) and the latest 2.6.3 release.

Are there any known issues related to memory alignment with x64? Or with COM Interop in x64? The only thing I could fine is that someone is working on x64 alignment issues for Direct3D12: https://github.com/sharpdx/SharpDX/commit/070fa52de8828c8fdcc8f2cd468fd37b085cda87

...
'mono.exe' (Win32): Loaded 'C:\Windows\System32\atidxx64.dll'. Cannot find or open the PDB file.
'mono.exe' (Win32): Loaded 'C:\Windows\System32\d3d11_2sdklayers.dll'. Cannot find or open the PDB file.
DXGI ERROR: IDXGIFactory::CreateSwapChain: Too many buffers. [ MISCELLANEOUS ERROR #4: ]
First-chance exception at 0x00007FFE79EE8B9C in mono.exe: Microsoft C++ exception: _com_error at memory location 0x000000F47D4ECE70.
First-chance exception at 0x00007FFE79EE8B9C in mono.exe: Microsoft C++ exception: _com_error at memory location 0x000000F47D4ECE70.
The thread 0x202c has exited with code 0 (0x0).
'mono.exe' (Win32): Unloaded 'C:\Windows\System32\atidxx64.dll'
'mono.exe' (Win32): Unloaded 'C:\Windows\System32\atiuxp64.dll'
'mono.exe' (Win32): Unloaded 'C:\Windows\System32\aticfx64.dll'

Unhandled Exception:
SharpDX.SharpDXException: HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: The application made a call that is invalid. Either the parameters of the call or the state of some object was incorrect.
Enable the D3D debug layer in order to see details via debug messages.

  at SharpDX.Result.CheckError () [0x00000] in <filename unknown>:0 
  at SharpDX.Direct3D11.D3D11.CreateDeviceAndSwapChain (SharpDX.DXGI.Adapter adapterRef, DriverType driverType, IntPtr software, DeviceCreationFlags flags, SharpDX.Direct3D.FeatureLevel[] featureLevelsRef, Int32 featureLevels, Int32 sDKVersion, SharpDX.DXGI.SwapChainDescription& swapChainDescRef, SharpDX.DXGI.SwapChain& swapChainOut, SharpDX.Direct3D11.Device& deviceOut, SharpDX.Direct3D.FeatureLevel& featureLevelRef, SharpDX.Direct3D11.DeviceContext& immediateContextOut) [0x00000] in <filename unknown>:0 
  at SharpDX.Direct3D11.Device.CreateWithSwapChain (SharpDX.DXGI.Adapter adapter, DriverType driverType, DeviceCreationFlags flags, SharpDX.Direct3D.FeatureLevel[] featureLevels, SwapChainDescription swapChainDescription, SharpDX.Direct3D11.Device& device, SharpDX.DXGI.SwapChain& swapChain) [0x00000] in <filename unknown>:0 
  at SharpDX.Direct3D11.Device.CreateWithSwapChain (DriverType driverType, DeviceCreationFlags flags, SwapChainDescription swapChainDescription, SharpDX.Direct3D11.Device& device, SharpDX.DXGI.SwapChain& swapChain) [0x00000] in <filename unknown>:0 
  at MiniCube.Program.Main () [0x00000] in <filename unknown>:0 
The thread 0x1c0c has exited with code 1 (0x1).
The thread 0x19f0 has exited with code 1 (0x1).
The program '[8868] mono.exe' has exited with code 1 (0x1).
xoofx commented 9 years ago

Never tested with x64 Mono but there could be some problem. Could you try the latest 3.0.0 version as I remember that I slightly changed the packing attribute for structures (dev package on main web site)

ArcoMul commented 9 years ago

I'm not able to build the latest version, seems like it can't find the Windows 10 SDK?

image

xoofx commented 9 years ago

To compile with latest 3.0 you need to have Windows SDK 10069 installed.

Also I tried to run a sample with Mono (I guess x86) on Windows and it is crashing on an invalid IL. Don't have time to dig into this but it seems that Mono is currently broken with SharpDX assemblies.