Gfx: Panic in gfx-backend-dx12 `write_descriptor_sets()` when calling `wgpu::Device::create_bind_group`

Created on 28 Apr 2020  Â·  2Comments  Â·  Source: gfx-rs/gfx

Short info header:

  • GFX version: v0.5.0
  • OS: Windows 10 x64
  • GPU: AMD Radeon(TM) RX Vega 10 Graphics

I'm trying to build and run rawrscope. When I run it, it calls wgpu which calls gfx-rs in DX12 mode. When I run rawrscope (the application), during startup, it calls wgpu::Device::create_bind_group, causing gfx-backend-dx12 to panic from an assertion error.

Call stack (innermost last):

  • wgpu create_bind_group
  • wgpu-native wgpu_device_create_bind_group
  • wgpu-core device_create_bind_group
  • gfx-rs write_descriptor_sets fails an assertion with the following error:
  WARN@wgpu_core::instance  Missing features: VERTEX_STORES_AND_ATOMICS | FRAGMENT_STORES_AND_ATOMICS
  WARN@wgpu_core::instance  max_bind_groups limit is missing
  WARN@wgpu_core::device  Surface does not support present mode: IMMEDIATE, falling back to FIFO
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`', <::std::macros::panic macros>:5:6
stack backtrace:

...trimmed

  13: std::panicking::begin_panic_fmt
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550\/src\libstd\panicking.rs:332
  14: gfx_backend_dx12::device::{{impl}}::write_descriptor_sets<alloc::vec::Vec<gfx_hal::pso::descriptor::DescriptorSetWrite<gfx_backend_dx12::Backend, core::iter::sources::Once<gfx_hal::pso::descriptor::Descriptor<gfx_backend_dx12::Backend>>>>,core::iter::sour
             at <::std::macros::panic macros>:5
  15: wgpu_core::hub::Global<wgpu_core::hub::IdentityManagerFactory>::device_create_bind_group<wgpu_core::hub::IdentityManagerFactory,gfx_backend_dx12::Backend>
             at C:\Users\nyanpasu\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-core-0.5.2\src\device\mod.rs:1206
  16: wgpu::Device::create_bind_group
             at C:\Users\nyanpasu\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.5.0\src\lib.rs:736
  17: rawrscope::render::Renderer::new
             at .\src\render.rs:104

I don't know what Git revision that gfx-rs v0.5.0 matches. I think it's one of the assertions in function https://github.com/gfx-rs/gfx/blob/fdfe887f5afab7ca057e3e824817d0bcdcf794ba/src/backend/dx12/src/device.rs#L2816

The panic message doesn't say which assertion is the issue.

Cloning gfx and overriding gfx-backend-dx12 locally broke because it referenced local gfx, whereas wgpu referenced Cargo gfx, and there were 2 copies of gfx traits. Instead I created a copy of local .cargo/.../gfx-backend-dx12 and labelled each assert_eq!() with a string. I found that the following line is failing:

https://github.com/gfx-rs/gfx/blob/fdfe887f5afab7ca057e3e824817d0bcdcf794ba/src/backend/dx12/src/device.rs#L2894-L2895

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: SRV size % 4 != 0', <::std::macros::panic macros>:5:6

Feedback

  • When you push releases of gfx/etc. to crates.io, crates.io doesn't say which git tag was used, and the releases aren't tagged on Github. I still don't know which revision matches. I feel this caused some difficulties for me debugging this issue.
  • Git-cloned gfx-backend-dx12 references local filesystem gfx. Is this intentional?
  • The assert_eq! panic message/backtrace doesn't say which line caused the error, due to some symbol mishaps. It doesn't specify the expressions of the 2 arguments, only the values. Combined, these issues made it impossible to find which assertion failed, until I modified gfx-backend-dx12 locally.
  • A very similar message showed up on the gfx.rs/webgpu gitter last year, but no bug report was filed. However this error is at a different line number (which has no assertion now) and has different left/right values. It may be a good idea to make the errors better by adding more metadata (like left/right expressions, or textual comments).
DirectX-12 easy bug medium

All 2 comments

Hi 👋 thanks for reporting this bug!

When you push releases of gfx/etc. to crates.io, crates.io doesn't say which git tag was used, and the releases aren't tagged on Github.

We use branches per release, e.g. https://github.com/gfx-rs/gfx/tree/hal-0.5 matches 0.5 releases of gfx.

Git-cloned gfx-backend-dx12 references local filesystem gfx. Is this intentional?

Yeah this is intentional – the gfx repo is a workspace where crates reference each other locally (instead of referencing crates.io directly).

The assert_eq! panic message/backtrace doesn't say which line caused the error, due to some symbol mishaps.

It may be a good idea to make the errors better by adding more metadata (like left/right expressions, or textual comments).

Agreed, it would be great to add messages to most (or all) asserts to make it clear what they're checking.

https://github.com/chiptunecafe/rawrscope/issues/14

The developer replied with the following message:

I think there's definitely value in keeping the issue open on the gfx repo just so that we can get better assert messages, but my issue here is that the docs are kinda unclear on what is and isn't allowed. In this case, I was _really_ lazily handling the scenario of the line storage buffer being empty by just creating a buffer with a single zero byte in it, but the DX12 backend seems to want the buffer lengths to be multiples of 4 bytes.

This crash was avoided in commit https://github.com/chiptunecafe/rawrscope/commit/e1969ca074129b46ca781a6a724aeb91ea3b37dc

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjadczak picture mjadczak  Â·  4Comments

grovesNL picture grovesNL  Â·  3Comments

kvark picture kvark  Â·  5Comments

kvark picture kvark  Â·  4Comments

Limeth picture Limeth  Â·  3Comments