bevyengine / bevy

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

ID3D12CommandQueue errors cause blank screen and error spam #14936

Open redstonerti opened 2 months ago

redstonerti commented 2 months ago

Bevy version: 0.14.1

Relevant system information: Windows 11 Laptop with Ryzen 7 7840HS CPU, 780M intergrated graphics and 7700S GPU

If you cannot get Bevy to build or run on your machine, please include:

cargo 1.80.1 (376290515 2024-07-16) OS Name: Microsoft Windows 11 Pro Version: 10.0.22631 Build 22631 (23H2) If your bug is rendering-related, copy the adapter info that appears when you run Bevy.

AdapterInfo { name: "AMD Radeon(TM) RX 7700S", vendor: 4098, device: 29824, device_type: DiscreteGpu, driver: "AMD proprietary driver", driver_info: "23.40.18.02 (LLPC)", backend: Vulkan }

Here is the code:

use bevy::prelude::*;
struct Graph3DPlugin;
#[derive(Resource)]
struct Frames(u32);
impl Plugin for Graph3DPlugin {
    fn build(&self, app: &mut App) {
        app.insert_resource(Frames(0))
            .add_systems(Update, exit_system);
    }
}
fn main() {
    App::new()
        .add_plugins((DefaultPlugins, Graph3DPlugin))
        .run();
}
fn exit_system(
    mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
    mut frames: ResMut<Frames>,
) {
    frames.0 += 1;
    if frames.0 == 3 {
        app_exit_events.send(AppExit::Success);
    }
}

And here is the error: https://pastebin.com/bxT4nCTH

P.S. The reason it exits after 3 frames is because otherwise the error spam would fill the console up so much that I couldn't copy the adapter info.

I also tried a bunch of wgpu examples including halmark and they worked just fine: https://github.com/gfx-rs/wgpu/tree/trunk/wgpu-hal

What went wrong

I wanted to learn how to make a 3D graph, so I started out with the 3D Shapes WebGL example and removed all objects except the cube. It worked fine on my PC, but when I moved the project to my laptop everything started to break. I got a blank screen with a bunch of errors spammed in the console and it would close after a few frames. I then removed everything except the boilerplate code for a new bevy project and it stopped closing on its own but continued spamming errors.

Bevy is unusable for me right now, and I would really like to do some coding so any help would be appreciated!

alice-i-cecile commented 2 months ago

For ease of searching, here are the errors:

ERROR wgpu_hal::auxil::dxgi::exception: ID3D12CommandQueue::ExecuteCommandLists: Using ClearRenderTargetView on Command List (0x00000209A96D5D80:'Unnamed ID3D12GraphicsCommandList Object'): Resource state (0x11DF8960: D3D12_RESOURCESTATE[COMMON|PRESENT]) of resource (0x00000209A96950F0:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a render target. Expected State Bits (all): 0x11DF8940: D3D12_RESOURCE_STATE_RENDER_TARGET, Actual State: 0x11DF8920: D3D12_RESOURCESTATE[COMMON|PRESENT], Missing State: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE] 2024-08-27T06:51:28.653611Z

ERROR present_frames: wgpu_hal::auxil::dxgi::exception: ID3D12CommandQueue::Present: Resource state (0x130F2E70: D3D12_RESOURCE_STATE_RENDER_TARGET) of resource (0x00000209A96950F0:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a INITIAL|PRESENT. Expected State Bits (all): 0x130F2E50: D3D12_RESOURCESTATE[COMMON|PRESENT], Actual State: 0x130F2E30: D3D12_RESOURCE_STATE_RENDER_TARGET, Missing State: 0x0: D3D12_RESOURCESTATE[COMMON|PRESENT]. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]

redstonerti commented 2 months ago

UPDATE: Tested on bevy 0.13.2 and all I got was a bunch of errors, on bevy 0.14.1, it also crashes. https://streamable.com/f8fe93

alice-i-cecile commented 2 months ago

Are your graphics drivers up to date? This sort of issue is often a driver bug.

redstonerti commented 2 months ago

Are your graphics drivers up to date? This sort of issue is often a driver bug.

Thanks for the tip! I upgraded to the latest graphics drivers and it no longer crashes, and when running in release mode, I also get no errors. Unfortunately, for some reason, when I run in debug mode I still get error spam:

https://pastebin.com/KrCPnvLu

alice-i-cecile commented 2 months ago

Okay, that's good to hear! I'm not personally able to debug much further, but I appreciate your investigations so far.

redstonerti commented 1 month ago

It's been almost a month and this issue still persists. I tried running the async_compute example in both release mode and debug mode and I get the errors only in debug mode.

I also removed all drivers and did a factory reset before reinstalling them.

https://github.com/user-attachments/assets/16e5cd86-3b7e-4eb7-8bb6-4a5a9a325fe9

2024-09-22T12:22:24.635838Z ERROR wgpu_hal::auxil::dxgi::exception: ID3D12CommandQueue::ExecuteCommandLists: Using ClearRenderTargetView on Command List (0x00000247903D4E60:'Unnamed ID3D12GraphicsCommandList Object'): Resource state (0xA96F9320: D3D12_RESOURCE_STATE_[COMMON|PRESENT]) of resource (0x00000247903C8E40:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a render target.  Expected State Bits (all): 0xA96F9300: D3D12_RESOURCE_STATE_RENDER_TARGET, Actual State: 0xA96F92E0: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Missing State: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]   

2024-09-22T12:22:24.644697Z ERROR wgpu_hal::auxil::dxgi::exception: ID3D12CommandQueue::ExecuteCommandLists: Using IDXGISwapChain::Present on Command List (0x0000024790350B20:'Internal DXGI CommandList'): Resource state (0xAE33E9B0: D3D12_RESOURCE_STATE_RENDER_TARGET) of resource (0x00000247903C8E40:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a PRESENT_SOURCE.  Expected State Bits (all): 0xAE33E990: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Actual State: 0xAE33E970: D3D12_RESOURCE_STATE_RENDER_TARGET, Missing State: 0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]
NoFr1ends commented 2 weeks ago

Having the same issue with the latest amd driver:

2024-10-29T19:17:43.397067Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Education", kernel: "22631", cpu: "AMD Ryzen 9 5900X 12-Core Processor", core_count: "12", memory: "63.9 GiB" }
2024-10-29T19:17:43.579929Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon RX 7900 GRE", vendor: 4098, device: 29772, device_type: DiscreteGpu, driver: "AMD proprietary driver", driver_info: "24.10.1 (LLPC)", backend: Vulkan }

getting the following messages:

2024-10-29T19:18:17.057828Z ERROR wgpu_hal::auxil::dxgi::exception: ID3D12CommandQueue::ExecuteCommandLists: Using ClearRenderTargetView on Command List (0x0000027A5B660360:'Unnamed ID3D12GraphicsCommandList Object'): Resource state (0x630FE960: D3D12_RESOURCE_STATE_[COMMON|PRESENT]) of resource (0x0000027A
5B5DC930:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a render target.  Expected State Bits (all): 0x630FE940: D3D12_RESOURCE_STATE_RENDER_TARGET, Actual State: 0x630FE920: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Missing State: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]
2024-10-29T19:18:17.059024Z ERROR wgpu_hal::auxil::dxgi::exception: ID3D12CommandQueue::ExecuteCommandLists: Using IDXGISwapChain::Present on Command List (0x0000027A5B55A470:'Internal DXGI CommandList'): Resource state (0x630FE960: D3D12_RESOURCE_STATE_RENDER_TARGET) of resource (0x0000027A5B5DC930:'Unname
d ID3D12Resource Object') (subresource: 0) is invalid for use as a PRESENT_SOURCE.  Expected State Bits (all): 0x630FE940: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Actual State: 0x630FE920: D3D12_RESOURCE_STATE_RENDER_TARGET, Missing State: 0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]

Sample is working fine tho, its just unusable with that console spam

alice-i-cecile commented 2 weeks ago

Can you try to reproduce this on wgpu alone and file an issue there? This is largely an upstream bug, although it's not clear if its wgpu's responsibility or a faulty graphics driver.

NoFr1ends commented 2 weeks ago

found this one in wgpu: https://github.com/gfx-rs/wgpu/issues/4247