FNA-XNA / FNA3D

FNA3D - 3D Graphics Library for FNA
http://fna-xna.github.io/
Other
287 stars 48 forks source link

Latest FNA3D dll crashes on graphics device creation and destruction #140

Closed YTN0 closed 2 years ago

YTN0 commented 2 years ago

Running the latest DLL, FNA3D crashes with the following message on graphics device creation (in D3D11 mode):

Exception thrown: read access violation. output was nullptr.

Using a debug version of the DLL, Visual Studio is pointing to the following: FNA3D.dll!D3D11_PLATFORM_CreateSwapChain(D3D11Renderer renderer, FNA3D_PresentationParameters pp) Line 5412 C

It appears to be this block of code:

IDXGIOutput_FindClosestMatchingMode(
    output,
    &swapchainBufferDesc,
    &swapchainDesc.BufferDesc,
    (IUnknown*) renderer->device
);

This problem is occurring on my laptop which has dual GPUs viz. an integrated Intel UHD 620 and an MX150. The graphics driver is set to auto select. If I force the MX150 driver, then things work. If I leave it on auto-select or pick the UHD 620, it crashes.

FYI, the same DLL appears to works on my Dell with only an UHD 620 GPU, so I suspect this issue is somehow related to multi-gpus and picking an adapter.

If I change to using Vulkan, launching the app works fine, however, it crashes on exit when calling FNA3D.FNA3D_DestroyDevice(GLDevice);

I get an "access violation reading location xyz" error, which is pointing to this line: FNA3D.dll!ShaderResources_DeactivateDescriptorSet(ShaderResources * shaderResources, unsigned int index) Line 5667 C

Note, the Vulkan crash on exit occurs on both the single GPU laptop and the dual GPU laptop.

flibitijibibo commented 2 years ago

@bartwe

bartwe commented 2 years ago

Do you perhaps know if you have different directx11 feature_level support per gpu ?

flibitijibibo commented 2 years ago

Oh also @thatcosmonaut will care about the Vulkan part

bartwe commented 2 years ago

Ok managed to reproduce.

Two issues, the main one is that while it finds the right gpu, enumerating the outputs on that gpu doesn't produce any as those are connected to the low power gpu normally. the other is that it uses D3D_IID_IDXGIAdapter instead of D3D_IID_IDXGIAdapter1 which i have a patch for.

The first issue i'm asking for more information from devs with more experience

bartwe commented 2 years ago

Ok gathered more information, and they recommend calling MonitorFromWindow , finding the IDXGIOutput from all of them with that HWINDOW and using that one.

flibitijibibo commented 2 years ago

Latest fnalibs has #141, this should be re-tested. (Also we still need to figure out the Vulkan crash.)

thatcosmonaut commented 2 years ago

Looking into Vulkan, it's a weird one because I can't repro this on any of my test cases and I also haven't touched the descriptor set cacheing system in about 9 months.

flibitijibibo commented 2 years ago

It's possibly just something from an early exit; hybrid native/managed debug info from the host system will probably work best here. I'm not able to make this happen either, so we'll see how the latest FNA3D works.

flibitijibibo commented 2 years ago

Latest FNA3D should be tested - a bunch of work went into the CreateDevice checks and what order the create calls are done.

flibitijibibo commented 2 years ago

Did we get to the bottom of this one? I may need to disable the modern DXGI path if this still isn't working for hybrid setups.

bartwe commented 2 years ago

Ad far as i'm aware this was resolved in https://github.com/FNA-XNA/FNA3D/pull/141

flibitijibibo commented 2 years ago

Got it - @YTN0, we'll need a response within the next 72 hours if this is not the case.