bevyengine / bevy

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

ID3D12CommandQueue errors cause blank screen and error spam #14936

Open redstonerti opened 2 weeks ago

redstonerti commented 2 weeks 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 weeks 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 weeks 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 weeks ago

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

redstonerti commented 2 weeks 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 weeks ago

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