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

wgpu::Device::create_shader_module() panics on trivial SPIRV input #2658

Open
curldivergence opened this issue May 14, 2022 · 1 comment
Open
Labels
area: validation Issues related to validation, diagnostics, and error handling external: upstream Issues happening in lower level APIs or platforms type: enhancement New feature or request

Comments

@curldivergence
Copy link

Hi! Not sure if I should create this issue here or in naga repo, please let me know if I should recreate it there.
Anyway, when I compile a trivial GLSL shader

#version 330

void main()
{
}

to spirv using glslangValidator, creating a shader module panics with the following callstack:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UnsupportedBuiltIn(5)', C:\Users\andrew\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.12.0\src\backend\direct.rs:1022:45
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\/library\core\src\panicking.rs:143
   2: core::result::unwrap_failed
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\/library\core\src\result.rs:1749
   3: enum$<core::result::Result<naga::Module,enum$<naga::front::spv::error::Error> > >::unwrap<naga::Module,enum$<naga::front::spv::error::Error> >
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\library\core\src\result.rs:1065
   4: wgpu::backend::direct::impl$3::device_create_shader_module
             at C:\Users\andrew\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.12.0\src\backend\direct.rs:1022
   5: wgpu::Device::create_shader_module
             at C:\Users\andrew\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.12.0\src\lib.rs:1705
   6: brdf_playground::BrdfPlayground::init
             at .\src\main.rs:231
   7: brdf_playground::main
             at .\src\main.rs:421
   8: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\library\core\src\ops\function.rs:227

Here is human-readable SPIRV dump (via -H command arg):

// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 6

                              Capability Shader
               1:             ExtInstImport  "GLSL.std.450"
                              MemoryModel Logical GLSL450
                              EntryPoint Vertex 4  "main"
                              Source GLSL 330
                              Name 4  "main"
               2:             TypeVoid
               3:             TypeFunction 2
         4(main):           2 Function None 3
               5:             Label
                              Return
                              FunctionEnd

Output of glslangValidator.exe -v is

Glslang Version: 10:11.8.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 11.8.0
GLSL Version: 4.60 glslang Khronos. 11.8.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 10
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

Repro steps

  1. Write a trivial GLSL shader
  2. Compile it using glslangValidator.exe, full command line is
glslangValidator.exe -S vert test.glsl -o  test.vert.spv -G -e "main"
  1. Try to create a shader module from it using
let vs_shader = device.create_shader_module(&include_spirv!("../shaders/test.vert.spv"));
  1. Observe the mentioned panic.

Expected vs observed behavior
I'm not sure I'd expect such a shader to produce a shader module without any errors (initially I wrote a simple, but non-empty shader and reduced the repro case to the trivial one), but

  • I'd expect that something that is required would be missing, but the error tells about something being unsupported (which is surprising in such a trivial example)
  • I'd expect an error to be more descriptive since currently I have no clue what exactly is not supported

Platform
OS: Windows 11
wgpu version: 0.12

Thanks!

@cwfitzgerald
Copy link
Member

I believe the issue is the version of GLSL you're using, try 440 -> 460 and it should work. We could definitely improve the error on this one.

@cwfitzgerald cwfitzgerald added type: bug Something isn't working external: upstream Issues happening in lower level APIs or platforms area: correctness We're behaving incorrectly area: validation Issues related to validation, diagnostics, and error handling type: enhancement New feature or request and removed area: correctness We're behaving incorrectly type: bug Something isn't working labels Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: validation Issues related to validation, diagnostics, and error handling external: upstream Issues happening in lower level APIs or platforms type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants