-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[naga] Support textureSampleBaseClampToEdge()
for texture2d
#7709
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
[naga] Support textureSampleBaseClampToEdge()
for texture2d
#7709
Conversation
b25453c
to
466e9b8
Compare
133ad63
to
b27265b
Compare
6df8c7c
to
9103208
Compare
9103208
to
05da8d1
Compare
textureSampleBaseClampToEdge()
for texture2d
05da8d1
to
b71a0e2
Compare
@jamienicol This is a bit dumb, but does b71a0e2 look okay to you? The MSL backend has no obligations here, since it's a validation error, but I just felt it would be nicer for the MSL backend to die instead of quietly misbehaving. |
@jimblandy I don't mind it at all. I wouldn't want to go hugely out of the way to repeat validation in the backends, but that is simple enough. Personally I'd prefer an assertion to returning an error: if we hit that case there's a bug somewhere and I'd rather we know about it via crash reports than users just suffering in silence. But I might be in the minority of preferring crashes to errors. |
Any reason to limit that to MSL rather than doing it for all backends? or was that just as an example? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like @jimblandy is ramping up on review now, so I won't drive a full review myself, but I'll comment on some things I noticed before I left on vacation and now.
It'd make sense for all backends. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts so far:
Did the same thing for HLSL in 2fb382c. Slightly different approach for SPIRV as the implementation is different. In theory it should be able to handle other sample flags, except for the level which must be zero. So I've added a check for that alone - I don't think the backends should be in the business of repeating validation in its entirety - rather they should make a reasonable effort to ensure their own constraints are satisfied. |
Yes, 100%. Backends are allowed to panic and misbehave when validation is buggy. My wanting to tighten up these matches was just opportunistic: it seemed like a small change might save someone some debugging time in he future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deno part LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
2fb382c
to
77129a0
Compare
Oops, this needs #7804. Sorry for pushing my rebase prematurely. |
Adds a new flag to the IR indicating when image sample coordinates are to be clamped. Adds wgsl-in support for parsing and lowering to IR. Validation ensures this flag is only used when sampling a 2D non-arrayed sampled texture, without offset, gather, or depth comparison. This matches the WGSL requirements, with the exception of supporting `texture_external` textures, which will follow in a later patch. SPIRV, HLSL, and Metal backends are supported so far, with GLSL left for a follow up. (In GLSL the texture will simply be sampled without the coordinates being clamped.) It may seem unfortunate to have to handle this separately for each backend, and indeed it would have been possible to implement this simply in the WGSL frontend. However, future patches will add support for using textureSampleBaseClampToEdge() with external textures, which will actually have to be handled by each backend. This patch is laying the groundwork for that.
… execution tests to CTS test list
77129a0
to
19e825f
Compare
Adds a new flag to the IR indicating when image sample coordinates are to be clamped. Adds wgsl-in support for parsing and lowering to IR. Validation ensures this flag is only used when sampling a 2D non-arrayed sampled texture, without offset, gather, or depth comparison. This matches the WGSL requirements, with the exception of supporting
texture_external
textures, which will follow in a later patch.SPIRV, HLSL, and Metal backends are supported so far, with GLSL left for a follow up. (In GLSL the texture will simply be sampled without the coordinates being clamped.)
It may seem unfortunate to have to handle this separately for each backend, and indeed it would have been possible to implement this simply in the WGSL frontend. However, future patches will add support for using textureSampleBaseClampToEdge() with external textures, which will actually have to be handled by each backend. This patch is laying the groundwork for that.
Connections
Part of #4386
Fixes #7539
Depends on #7804 (for texturesample CTS tests to pass on Mac)
Testing
Added snapshot test
Makes these CTS tests pass
Squash or Rebase?
Rebase
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.