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

textureLoad and textureStore need bounds checks #1080

Closed
4 of 5 tasks
jimblandy opened this issue Jul 12, 2021 · 5 comments · Fixed by #1889
Closed
4 of 5 tasks

textureLoad and textureStore need bounds checks #1080

jimblandy opened this issue Jul 12, 2021 · 5 comments · Fixed by #1889
Labels
area: back-end Outputs of shader conversion lang: GLSL OpenGL Shading Language

Comments

@jimblandy
Copy link
Member

jimblandy commented Jul 12, 2021

For several of our back ends, the implementations of WGSL's textureStore and textureLoad exhibit undefined behavior if coordinates, array indices, sample indices in multisampled texels, or mip levels are out of bounds. This means that, to prevent undefined behavior on the web, Naga must be able to inject bounds checks into the generated code when used by WebGPU.

This can probably use the same IndexBoundsCheckPolicy enum as used for array/vector/matrix accesses now. However, Naga should let clients control the image bounds check policy separately: some devices can check image bounds themselves, presumably more efficiently than Naga can, and in those cases we should leave it to the driver.

Back ends needing work (add specific issues / PRs as filed):

  • glsl
  • hlsl
  • msl
  • spv
  • wgsl
@jimblandy jimblandy added the area: back-end Outputs of shader conversion label Jul 12, 2021
@jimblandy
Copy link
Member Author

Note incoming changes to WGSL about how this should behave:
https://github.com/gpuweb/gpuweb/pull/1906/files

@teoxoy teoxoy added this to the WGSL Specification V1 milestone Apr 30, 2022
@jimblandy
Copy link
Member Author

MSL implemented in #1730.
HLSL bounds checks are handled by the platform.

@jimblandy
Copy link
Member Author

I have no plans to implement this for WGSL or GLSL. Implementing bounds checks for a back end takes me quite a while, and I want to focus most of my attention on what Firefox needs.

@jimblandy
Copy link
Member Author

@cwfitzgerald points out that we can say that WGSL is covered, because it effectively passes through the bounds checks implemented by whatever back end it targets.

@teoxoy teoxoy added the lang: GLSL OpenGL Shading Language label Apr 30, 2022
@jimblandy
Copy link
Member Author

@JCapucho has expressed a willingness to work on the GLSL back end, so let's leave this bug open until that's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: back-end Outputs of shader conversion lang: GLSL OpenGL Shading Language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants