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

Handle invalid shaders #1

Open
fralonra opened this issue Oct 30, 2022 · 4 comments
Open

Handle invalid shaders #1

fralonra opened this issue Oct 30, 2022 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@fralonra
Copy link
Owner

fralonra commented Oct 30, 2022

Issues

Currently invalid shader input would panic at device.create_shader_module:

let fs_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {

Thus makes the whole program to crash.

The approaches I've tried

  • use device.on_uncaptured_error to catch it:
    // device.on_uncaptured_error(|err| {

    However it would continuously generate errors and block the main thread:
[wgpu_core::present] No work has been submitted for this frame
[wgshadertoy::context] Validation Err

Helps needed

I'm glad to hear useful infomation about how to handle invalid shaders. Thanks a lot!

@fralonra fralonra added the help wanted Extra attention is needed label Oct 30, 2022
@fralonra
Copy link
Owner Author

fralonra commented Nov 16, 2022

Currently I skip the naga check, and use error scopes to capture validation error:
22705e4

@andrewbaxter
Copy link

I had a typo and mine output an error to the terminal and exited... I assume this is the same issue:

[2024-08-17T04:54:06Z ERROR wgshadertoy::core] Validation error: "Validation Error\n\nCaused by:\n    In Device::create_shader_module\n      note: label = `Shader`\n    \nShader 'Shader' parsing error: no definition in scope for identifier: 'cenetered_coord'\n   ┌─ wgsl:19:17\n   │\n19 │     return vec4(cenetered_coord.x / u.resolution.x, centered_coord.y / u.resolution.y, 0., 1.0);\n   │                 ^^^^^^^^^^^^^^^ unknown identifier\n\n\n    no definition in scope for identifier: 'cenetered_coord'\n"

@fralonra
Copy link
Owner Author

I had a typo and mine output an error to the terminal and exited... I assume this is the same issue:

[2024-08-17T04:54:06Z ERROR wgshadertoy::core] Validation error: "Validation Error\n\nCaused by:\n    In Device::create_shader_module\n      note: label = `Shader`\n    \nShader 'Shader' parsing error: no definition in scope for identifier: 'cenetered_coord'\n   ┌─ wgsl:19:17\n   │\n19 │     return vec4(cenetered_coord.x / u.resolution.x, centered_coord.y / u.resolution.y, 0., 1.0);\n   │                 ^^^^^^^^^^^^^^^ unknown identifier\n\n\n    no definition in scope for identifier: 'cenetered_coord'\n"

Looks like the shader is missing the definition for cenetered_coord

@andrewbaxter
Copy link

Ah yeah, thank you, of course, but the risk of a typo in your code shouldn't be a crash and a loss of all code. I assumed that was what this issue was about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants