-
Notifications
You must be signed in to change notification settings - Fork 938
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
Comments
Line 314 in 5f1b3e5
As for |
Thanks for the tip about |
Sorry if this isn't the right etiquette, but is there any current work being done to implement |
not that I know of no. But there's also some movement on the Naga side on how errors should be handled #4429 |
I would love to take on this issue. |
The PR for this is up at #5410, and am happily awaiting reviews |
What I'm using, based on the comments in this thread, is // Set up error handling. By using `on_uncaptured_error()`, create_shader_module()
// will return instead of exiting.
let shader_err: Arc<Mutex<Option<wgpu::Error>>> = Arc::new(Mutex::new(None));
{
let shader_err = Arc::clone(&shader_err);
device.on_uncaptured_error(Box::new(move |err| {
*shader_err.lock().unwrap() = Some(err);
}));
}
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some(&shader_path.display().to_string()),
source: wgpu::ShaderSource::Wgsl(Cow::Owned(shader_src)),
});
if let Some(err) = shader_err.lock().unwrap().take() {
let comp_info = pollster::block_on(shader.get_compilation_info());
Err(comp_info)
} else {
Ok(shader)
} This returns a |
You should use |
I tried that, but it didn't work for me. It does work on the main thread, but not in the thread that calls a notify-rs callback. Edit: Seems related to #5375. Code
Error message
|
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 erroredShaderModule
objects.The WebGPU spec requires a
GPUShaderModule.compilationInfo()
method that should return any errors generated during compilation.Ideally, either:
Device::create_shader_module
to idiomatically return aResult
,ShaderModule::compilation_info
method. The user can then inspect this info and return an error as appropriate.The text was updated successfully, but these errors were encountered: