gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 549 forks source link

Resize failed with code 887A0001 #3481

Open tuanzijiang opened 3 years ago

tuanzijiang commented 3 years ago

Short info header:

Running the cube example which works fine except when I try to resize the window. It gives me the following error: [2020-11-17T14:08:20Z ERROR gfx_window_dxgi] Resize failed with code 887A0001 [2020-11-17T14:08:20Z ERROR gfx_app] Resize failed: The RTV cannot be changed due to the references to it existing image

kvark commented 3 years ago

I'm sorry, gfx pre-ll is long deprecated by now.

tuanzijiang commented 3 years ago

Do you have any suggestions? The description of the error is "The RTV cannot be changed due to the references to it existing." How to remove the reference to it? @kvark

tuanzijiang commented 3 years ago

I try the 'quad' example in the master branch. It gives me the following error: thread 'main' panicked at 'called Result::unwrap() on an Err value: InitializationFailed', examples\quad/main.rs:241:18

image

tuanzijiang commented 3 years ago

I try the 'quad' example with another device. It works fine. However, when I resize the window, it panic and I get an error code '887A0001'. It is the same as the 'cube' example in the 'pre-ll' branch

image

kvark commented 3 years ago

@tuanzijiang could you try running wgpu-rs cube example with "WGPU_BACKEND=dx11" environment?

Do you have any suggestions? The description of the error is "The RTV cannot be changed due to the references to it existing." How to remove the reference to it?

Unfortunately, it's not straightforward. You'd need to check the views created from the back buffer resource through the code, and see which of them are still alive by the time you resize. The most efficient way to check who holds the views is putting a breakpoint on the data representing the internal reference count of the view object. @cwfitzgerald has kindly described it in https://github.com/gfx-rs/gfx/wiki/Debugging-D3D#com

tangmi commented 3 years ago

@tuanzijiang I recall that this resize events on dx11 never quite worked for me on any of the pre-ll examples. I vaguely recall that you need to release any references to the main_color and main_depth textures before trying to call the resize code (I think it was update_views in gfx_window_dxgi?).

For all other errors, you may be able to install the Windows 10 Graphics Tools to get the D3D11 Debug Layer, which should get picked up by gfx_device_dx11 (relevant code in debug.rs and its usages in lib.rs) and should turn the 0x887A0001 (DXGI_ERROR_INVALID_CALL) into a more detailed message about exactly what API call went wrong. Note I've observed this sometimes just doesn't work for some errors, so your mileage may vary...

I'd highly recommend using something like wgpu-rs instead of pre-ll gfx, if that's possible for your project!