bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.17k stars 3.57k forks source link

Graphics related crash attempting to run examples - 0xc000041d #4834

Open SamPruden opened 2 years ago

SamPruden commented 2 years ago

Bevy version

0.7 and main.

Operating system & version

Windows 10

What you did

Run the examples - clear_color in this case.

What you expected to happen

Not go boom

What actually happened

2022-05-24T15:52:47.918188Z ERROR wgpu_hal::vulkan::instance: enumerate_adapters: Initialization of a object has failed
2022-05-24T15:52:48.268776Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GT 635M", vendor: 4318, device: 3555, device_type: DiscreteGpu, backend: Dx12 }
error: process didn't exit successfully: `target\debug\examples\clear_color.exe` (exit code: 0xc000041d)

Additional information

This is a pretty old laptop with a pretty old GPU, but in theory both Vulkan and DX12 should work fine on the NVIDIA card, I think. I don't think either should work on the integrated Intel card (HD Graphics 4000), which is DX11.2.

I actually did sort of get Bevy working when I was first setting this laptop up. Before I properly installed drivers (using Windows defaults I believe) Bevy did run! But at something like 5FPS for trivial examples, release build. I didn't investigate that properly at the time because I assumed it was a driver issue that would be fixed when I installed them, but alas.

I don't know if this needs to be filed here or in wgpu directly, so LMK if I should post there too.

bjorn3 commented 2 years ago

That status code is STATUS_FATAL_USER_CALLBACK_EXCEPTION. Could you try getting a backtrace using a debugger to find where the crash occurs? Also do wgpu examples work? If not this should definitively be filled at wgpu, otherwise keeping it here until we know who is to blame is fine.

SamPruden commented 2 years ago

Also do wgpu examples work?

Good test, I should have thought of that. No, they don't.

[2022-05-24T16:47:25Z ERROR wgpu_hal::vulkan::instance] enumerate_adapters: Initialization of a object has failed
AdapterInfo { name: "NVIDIA GeForce GT 635M", vendor: 4318, device: 3555, device_type: DiscreteGpu, backend: Dx12 }

I'll see what I can get out of debugging and file an issue over there. I'll let you decide whether to close this, but I'll come back and link to the wgpu issue here when I've filed it.

SamPruden commented 2 years ago

WGPU issue posted: https://github.com/gfx-rs/wgpu/issues/2692

I've tracked it back to Vulkan itself returning VK_ERROR_INITIALIZATION_FAILED. I don't know enough about low level graphics to know where to go from there.

One thing that I don't fully understand is the nature of the error.

2022-05-24T15:52:47.918188Z ERROR wgpu_hal::vulkan::instance: enumerate_adapters: Initialization of a object has failed
2022-05-24T15:52:48.268776Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GT 635M", vendor: 4318, device: 3555, device_type: DiscreteGpu, backend: Dx12 }
error: process didn't exit successfully: `target\debug\examples\clear_color.exe` (exit code: 0xc000041d)

Is it claiming a Vulkan error has successfully fallen back to DX12? It shows the DX12 device, but then the process exits unexpectedly.

~I said that I'm seeing the same thing on the WGPU examples, but actually that's not quite right. The ERROR and INFO lines are reported the same, but WGPU then exits successfully, whereas Bevy crashes. I assumed that the ERROR was the culprit and therefore it's a WGPU issue, but if it's actually falling back to DX12 successfully, then maybe Bevy shouldn't be crashing here?~

Actually WGPU will crash identically if I try to actually render something to screen with it. Ignore the above, sorry.

I can do further debugging if needed.

hoshino111 commented 2 years ago

HD Graphics 4000 only support DX11 and does not fully support Vulkan api. See here. And 635M doesn't seem to fully support vulkan api, but it should fully support DX12 in some GPU variants. See https://developer.nvidia.com/vulkan-driver. Have you tried updating the driver or tried updating vulkan version ?

SamPruden commented 2 years ago

Yeah I'm aware the Intel card shouldn't be able to run any of this.

dxdiag shows DirectX12 support.

I'm running the latest driver (which is old, 2018) and both vulkaninfo and https://github.com/skeeto/vulkan-test showed Vulkan support.

I've been messing with drivers (no luck so far) since my earlier messages so I can't retest, but I'm 99% sure everything said Vulkan should work.

SamPruden commented 2 years ago

I need to get around to trying a DX12 instance manually though - weirdly I haven't done that yet. Shouldn't it fall back automatically if Vulkan isn't available anyway, though?

SamPruden commented 2 years ago

Actually I kept notes! This was my vulkaninfo output:

Instance Extensions:
====================
Instance Extensions     count = 11
        VK_EXT_debug_report                 : extension revision  9
        VK_EXT_display_surface_counter      : extension revision  1
        VK_KHR_get_physical_device_properties2: extension revision  1
        VK_KHR_get_surface_capabilities2    : extension revision  1
        VK_KHR_surface                      : extension revision 25
        VK_KHR_win32_surface                : extension revision  6
        VK_KHX_device_group_creation        : extension revision  1
        VK_KHR_external_fence_capabilities  : extension revision  1
        VK_KHR_external_memory_capabilities : extension revision  1
        VK_KHR_external_semaphore_capabilities: extension revision  1
        VK_NV_external_memory_capabilities  : extension revision  1

I assumed that means that Vulkan should work, although I suppose it's not explicit.

The listed Vulkan API version was 1.0.65.

hoshino111 commented 2 years ago

Shouldn't it fall back automatically if Vulkan isn't available anyway, though?

I also think it should be, but I've never tried it 😕.

SamPruden commented 2 years ago

Intuitively, the error behaviour does sort of look like an "Is Vulkan available?" check is returning true, but actual Vulkan isn't working. I suppose this could easily be a driver bug for an old card that was originally pre-Windows 10 and maybe not updated well or something.