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

Unable to handle shader compilation errors #2130

Closed
Herschel opened this issue Oct 30, 2021 · 6 comments · Fixed by #5410
Closed

Unable to handle shader compilation errors #2130

Herschel opened this issue Oct 30, 2021 · 6 comments · Fixed by #5410
Labels
area: api Issues related to API surface type: enhancement New feature or request

Comments

@Herschel
Copy link
Contributor

wgpu currently has no API to inspect errors when compiling a shader module. On desktop, Device::create_shader_module will panic on error. On web, the different browsers will print out error info to the console, but execution continues, and errors will usually occur later during pipeline creation with the errored ShaderModule objects.

The WebGPU spec requires a GPUShaderModule.compilationInfo() method that should return any errors generated during compilation.

Ideally, either:

  • change Device::create_shader_module to idiomatically return a Result,
  • or match the spec and add a ShaderModule::compilation_info method. The user can then inspect this info and return an error as appropriate.
@kvark
Copy link
Member

kvark commented Oct 30, 2021

create_shader_module follows the same logic as all the other methods that could fail - it triggers the error on the device. The default handler panics, but you can set your own handler -

fn device_on_uncaptured_error(

compilation_info isn't implemented yet, and we definitely need this.

As for Result, we need to land @pythonesque work first and then see.

@kvark kvark added area: api Issues related to API surface type: enhancement New feature or request labels Oct 30, 2021
@Herschel
Copy link
Contributor Author

Thanks for the tip about onUncapturedError! Unfortunately looks like it's a TODO on wgpu web backend.

@michael-brennan2005
Copy link

Sorry if this isn't the right etiquette, but is there any current work being done to implement compilation_info? This is presenting an obstacle to the renderer I'm working on currently.

@Wumpf
Copy link
Member

Wumpf commented Aug 6, 2023

not that I know of no. But there's also some movement on the Naga side on how errors should be handled #4429

@stefnotch
Copy link
Contributor

I would love to take on this issue.

@stefnotch
Copy link
Contributor

stefnotch commented Apr 1, 2024

The PR for this is up at #5410, and am happily awaiting reviews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants