Add texture_1d support to textureSampleLevel#4406
Conversation
| * t The sampled or depth texture to sample. | ||
| * s The sampler type. | ||
| * coords The texture coordinates used for sampling. | ||
| * level The mip level, clamped to 0. |
There was a problem hiding this comment.
Will clamped to 0 be part of the spec? Do I need to do something about it in the CTS and Tint implementation?
There was a problem hiding this comment.
FYI Here's my naive thoughts regarding the spec: https://github.com/gpuweb/gpuweb/compare/main...beaufortfrancois:gpuweb:textureSampleLevel1d?expand=1
There was a problem hiding this comment.
I think "clamped to zero" would fall out of the generic mip level selection rules that apply to all textures. That said, I'm struggling to find exactly where that is written down in either the WGSL or API specs.
As for Tint, I don't think you need to do anything special, as I believe the backend APIs already do The Right Thing (i.e. clamp).
Ideally CTS would test out-of-bounds mip levels to ensure this is the case, but if we're not already doing this for other textures then that would be a separate issue.
There was a problem hiding this comment.
This test tests out-of-bounds mip levels. I'm not sure the comment is needed. Whatever number of mips the texture is, the test will test out of bounds mip levels.
There was a problem hiding this comment.
I've updated it and used same prose as the other tests for level
c969e78 to
5814f41
Compare
| * t The sampled or depth texture to sample. | ||
| * s The sampler type. | ||
| * coords The texture coordinates used for sampling. | ||
| * level The mip level, clamped to 0. |
There was a problem hiding this comment.
I think "clamped to zero" would fall out of the generic mip level selection rules that apply to all textures. That said, I'm struggling to find exactly where that is written down in either the WGSL or API specs.
As for Tint, I don't think you need to do anything special, as I believe the backend APIs already do The Right Thing (i.e. clamp).
Ideally CTS would test out-of-bounds mip levels to ensure this is the case, but if we're not already doing this for other textures then that would be a separate issue.
| t.skipIfTextureFormatAndDimensionNotCompatible(format, '1d'); | ||
| skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format); | ||
|
|
||
| // We want at least 4 blocks or something wide enough for 3 mip levels. |
There was a problem hiding this comment.
This comment seems inaccurate since we're only testing a single level here?
There was a problem hiding this comment.
maybe leave it? If 1d textures ever support mip levels nothing needs to change here. We'd just change chooseTextureSize. It's not technically inaccurate. We're choosing a size that could support at least 3 mip levels. We're not actually making 3 mip levels.
There was a problem hiding this comment.
I'll leave it then.
| t.skipIfTextureFormatAndDimensionNotCompatible(format, '1d'); | ||
| skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format); | ||
|
|
||
| // We want at least 4 blocks or something wide enough for 3 mip levels. |
There was a problem hiding this comment.
maybe leave it? If 1d textures ever support mip levels nothing needs to change here. We'd just change chooseTextureSize. It's not technically inaccurate. We're choosing a size that could support at least 3 mip levels. We're not actually making 3 mip levels.
| * t The sampled or depth texture to sample. | ||
| * s The sampler type. | ||
| * coords The texture coordinates used for sampling. | ||
| * level The mip level, clamped to 0. |
There was a problem hiding this comment.
This test tests out-of-bounds mip levels. I'm not sure the comment is needed. Whatever number of mips the texture is, the test will test out of bounds mip levels.
| mipmapFilter: minFilter, | ||
| }; | ||
|
|
||
| const calls: TextureCall<vec1>[] = generateTextureBuiltinInputs1D(50, { |
There was a problem hiding this comment.
I think this code needs the mipLevel code to match the 2d code. Both in the call to genearteTextureBuiltinInputs1D and in the return code. That's what makes it test out of bounds mip levels. It doesn't exist in textureSample test because texture sample test chooses mip levels by derivatives.
There was a problem hiding this comment.
Done. Thanks for catching this!
As discussed in gpuweb/gpuweb#5001 (comment), this PR adds tests in the CTS for texture_1d support to textureSampleLevel. This is to make sure this actually works as intended as we're implementing in Tint with https://issues.chromium.org/382514673
Requirements for PR author:
.unimplemented()./** documented */and new helper files are found inhelper_index.txt.Requirements for reviewer sign-off:
When landing this PR, be sure to make any necessary issue status updates.