gfx-rs/wgpu-rs

Metal Validation Error using arrays in out parameters (wgpu-0.7)

cs-cordero opened this issue · 2 comments

Hello,

I am currently trying to upgrade from wgpu-0.6 to wgpu-0.7, and I'm coming up against some shader-related issues while trying to call Device::create_render_pipeline. Some folks on the Rust Community Discord suggested to me to ask about it here. (https://discord.com/channels/273534239310479360/335502453371961344/819799389974691860)

Here is a paste of my Vertex Shader: https://pastebin.com/vwzvAvwB

Here is the error message given to me:

[2021-03-12T04:58:35Z DEBUG naga::proc::validator] var GlobalVariable { name: Some(""), class: Storage, binding: Some(Resource { group: 1, binding: 0 }), ty: Handle(7), init: None, interpolation: None, storage_access: LOAD | STORE }
[2021-03-12T04:58:35Z DEBUG naga::proc::validator] var GlobalVariable { name: Some("gl_InstanceIndex"), class: Input, binding: Some(BuiltIn(InstanceIndex)), ty: Handle(9), init: None, interpolation: None, storage_access: (empty) }
[2021-03-12T04:58:35Z DEBUG naga::proc::validator] var GlobalVariable { name: Some("vertex_tangent"), class: Input, binding: Some(Location(3)), ty: Handle(2), init: None, interpolation: None, storage_access: (empty) }
[2021-03-12T04:58:35Z DEBUG naga::proc::validator] var GlobalVariable { name: Some("vertex_bitangent"), class: Input, binding: Some(Location(4)), ty: Handle(2), init: None, interpolation: None, storage_access: (empty) }
[2021-03-12T04:58:35Z DEBUG naga::proc::validator] var GlobalVariable { name: Some("vertex_normal"), class: Input, binding: Some(Location(2)), ty: Handle(2), init: None, interpolation: None, storage_access: (empty) }
[2021-03-12T04:58:35Z DEBUG naga::proc::validator] var GlobalVariable { name: Some(""), class: Uniform, binding: Some(Resource { group: 3, binding: 1 }), ty: Handle(13), init: None, interpolation: None, storage_access: (empty) }
[2021-03-12T04:58:35Z DEBUG naga::proc::validator] var GlobalVariable { name: Some("fragment_directional_lights_color"), class: Output, binding: Some(Location(2)), ty: Handle(16), init: None, interpolation: None, storage_access: (empty) }
wgpu error: Validation Error

Caused by:
    In Device::create_shader_module
      note: label = `Default Vertex Shader`
    Global variable Handle(7) 'fragment_directional_lights_color' is invalid: InvalidType


thread 'main' panicked at 'Handling wgpu errors as fatal by default', /Users/ccordero/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.7.0/src/backend/direct.rs:1896:5

...backtrace ellided...

[2021-03-12T04:58:35Z ERROR gfx_backend_metal::command] Command buffer not released properly!
[2021-03-12T04:58:35Z TRACE winit::platform_impl::platform::window] Dropping `UnownedWindow` (0x7fac8660cef0)

Process finished with exit code 101

This shader worked fine before the wgpu-0.7 upgrade, and I'm not sure how to fix this. Is this a bug or is there a workaround?

kvark commented

You can work around by making sure that the relevant ShaderModuleDescriptor::flags does not have VALIDATION flag in it, for now. In the meantime, I filed gfx-rs/naga#567 for a proper fix in Naga validator.

kvark commented

This is fixed upstream, and wgpu-rs is already using it