Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeating rendering error in debug console but rendering works. #9975

Open
Retrodad0001 opened this issue Sep 30, 2023 · 11 comments
Open

Repeating rendering error in debug console but rendering works. #9975

Retrodad0001 opened this issue Sep 30, 2023 · 11 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior S-Blocked This cannot move forward until something else changes

Comments

@Retrodad0001
Copy link

Bevy version

0.11

[Optional] Relevant system information

If your bug is rendering-related, copy the adapter info that appears when you run Bevy.

GPU - AMD Radeon RX 5700 - Primary/Discrete
VRAM - 8176 MB - GDDR6 1750 MHz
Graphics - AMD Radeon RX 5700
Graphics Manufacturer - Powered by AMD
Usable Memory Size - 8176 MB
Core Clock - 1725 MHz
Total Memory Bandwidth - 448 GByte/s
Device ID - 731F
Revision ID - C4
Vendor ID - 1002
SubSystem ID - 04E4
SubSystem Vendor ID - 1043
Bus Type - PCI Express 4.0
Current Bus Settings - PCI Express 4.0 x16
Driver Version - 23.20.11.04-230921a-396203C-AMD-Software-Adrenalin-Edition
AMD Windows Driver Version - 31.0.22011.4008
Direct3D API Version - 12.1
Vulkan™ API Version - 1.3.262
OpenCL™ API Version - 2.0
OpenGL® API Version - 4.6
Direct3D® Driver Version - 9.14.10.01526
Vulkan™ Driver Version - 2.0.283
OpenCL® Driver Version - 31.0.22011.4008
OpenGL® Driver Version - 23.09.230729_569461f
2D Driver Version - 8.1.1.1634
UI Version - 2023.0921.2013.1996
AMD Audio Driver Version - 10.0.1.30
Driver Provider - Advanced Micro Devices, Inc.
Windows Edition - Windows 11 Professional (64 bit)
Windows Version - 22H2

What you did

1 Just run the game.

What went wrong

The debug console is repeatingly logging an error, but the application is still working.

The error text:
2023-09-30T05:55:03.499324Z ERROR wgpu_hal::auxil::dxgi::exception: ID3D12CommandQueue::ExecuteCommandLists: Using IDXGIS
wapChain::Present on Command List (0x000001E5CE313540:'Internal DXGI CommandList'): Resource state (0xD84FF0C0: D3D12_RES
OURCE_STATE_RENDER_TARGET) of resource (0x000001E5CE3703C0:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid f
or use as a PRESENT_SOURCE. Expected State Bits (all): 0xD84FF0A0: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Actual State:
0xD84FF080: D3D12_RESOURCE_STATE_RENDER_TARGET, Missing State: 0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]

Additional information

I have 2 pc's only on 1 with the same code I get this error only on 1 pc. The crazy thing is that I get this error most of the time, not always. The other pc has a different setup. I have this issue with many bevy versions, but I don't know if this is a bevy issue. I have this for a long time, even when and updated the AMD drivers at least 5 times.

image

@Retrodad0001 Retrodad0001 added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Sep 30, 2023
@IceSentry
Copy link
Contributor

This is caused by this wgpu bug: gfx-rs/wgpu#3959

For now, you can fix it by forcing it to use Vulkan:

    App::new()
        .add_plugins(DefaultPlugins.set(RenderPlugin {
            wgpu_settings: WgpuSettings {
                backends: Some(Backends::VULKAN),
                ..default()
            },
        }))
        .run();

@IceSentry IceSentry added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Sep 30, 2023
@Retrodad0001
Copy link
Author

It works thanks

@mnmaita
Copy link
Member

mnmaita commented Nov 11, 2023

Updating for Bevy 0.12:

    App::new()
        .add_plugins(DefaultPlugins.set(RenderPlugin {
            wgpu_settings: WgpuSettings {
                backends: Some(Backends::VULKAN),
                ..default()
            },
        }))
        .run();

For me, this also worked to get rid of the noisy warnings:

    App::new()
        .add_plugins(DefaultPlugins.set(RenderPlugin {
            wgpu_settings: WgpuSettings {
                backends: Some(Backends::DX12),
                ..default()
            },
        }))
        .run();

Looks like explicitly setting the backend makes the warnings go away. Check this issue out for some more context.

@juzi5201314
Copy link

juzi5201314 commented Nov 14, 2023

Hey, this problem also occurs on bevy0.12.0+Intel Arc a750. Using vulkan on other graphics cards is a temporary solution, but due to #8037, intel graphics cards cannot run properly on vulkan, which is very embarrassing.

@TheAeroHead
Copy link

For me, the above workaround did not work as the wgpusettings field is no longer part of RenderPlugin. This code worked for me:

use bevy::prelude::*;
use bevy::render::*;
use bevy::render::settings::*;

fn main() {
    App::new()
          .add_plugins(SamplePlugin)
          .run();
}

pub struct SamplePlugin;

impl Plugin for SamplePlugin {
	fn build(&self, app: &mut App) {
		app.add_plugins(DefaultPlugins.set(WindowPlugin {
			primary_window: Some(Window {
				resolution: (640.0, 480.0).into(),
				title: "Sample".to_string(),
				..default()
			}),
			..default()
		})
		.set(RenderPlugin {
                        render_creation: RenderCreation::Automatic(WgpuSettings {
				device_label: Some(std::borrow::Cow::Borrowed("device_gpu")),
				backends:Some(Backends::DX12),
				power_preference: PowerPreference::HighPerformance,
				priority: WgpuSettingsPriority::Functionality,
				features: WgpuFeatures::empty(),
				disabled_features: None,
				limits: WgpuLimits::default(),
				constrained_limits: Some(WgpuLimits::default()),
				dx12_shader_compiler: Dx12Compiler::Fxc
			})
               }));
	}
}

I used Some(std::borrow::Cow::Borrowed("device_gpu")) to create a Clone-on-write string with the name "device_gpu" with a lifetime for the length of the program. I don't understand Cows all that well, but this is a handy article.
I used Some(Backends::DX12) to explicitly set the Backendto DirectX 12.
I used PowerPreference::HighPerformance to ensure the discrete GPU is used if available (docs).
I used WgpuSettingsPriority::Functionality to cover the maximum features and limits of the adapter and backend (WgpuSettingsPriority).
I used None for the features and disabled_features as this only deals with non-default features. Since we can't currently determine which features are needed, I didn't add any additional features (WgpuFeatures).
I used WgpuLimits::default() to cover the most use cases (Wgpulimits)
I used Dx12Compiler::Fxc since is the default option from the enum. Cargo complained when I tried to use Dxc.

@TheAeroHead
Copy link

A simpler version of the above code can be:

use bevy::prelude::*;
use bevy::render::*;
use bevy::render::settings::*;

fn main() {
    App::new()
          .add_plugins(SamplePlugin)
          .run();
}

pub struct SamplePlugin;

impl Plugin for SamplePlugin {
	fn build(&self, app: &mut App) {
		app.add_plugins(DefaultPlugins.set(RenderPlugin {
                        render_creation: RenderCreation::Automatic(WgpuSettings {
				backends:Some(Backends::DX12),
                                ..default()
               			})
		}));
	}
}

@james7132
Copy link
Member

For those following this issue, this is upstreamed at gfx-rs/wgpu#4247.

Marking this as blocked on a wgpu release to fix.

@james7132 james7132 added the S-Blocked This cannot move forward until something else changes label Mar 23, 2024
@Sw1ndlers
Copy link

Updated for bevy 13.2

App::new()
    .add_plugins(DefaultPlugins.set(RenderPlugin {
        render_creation: RenderCreation::Automatic(WgpuSettings {
            backends: Some(Backends::VULKAN),
            ..default()
        }),
        ..default()
    }))
    .run();

@Retrodad0001
Copy link
Author

How can this be done in bevy version 0.14.x?

@part-time-nerd
Copy link

@Retrodad0001 I Tested on 0.14.1: the 0.13.2 snippet posted above will work

@brianjosephwalters
Copy link

Another way to set the backend is by using an environment variable, such as WGPU_BACKEND=dx12 (For me, using dx12 fixed the issue.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior S-Blocked This cannot move forward until something else changes
Projects
None yet
Development

No branches or pull requests

9 participants