Skip to content

Add texture_1d support to textureSampleLevel#4406

Merged
beaufortfrancois merged 3 commits into
mainfrom
textureSampleLevel-1d
Jun 20, 2025
Merged

Add texture_1d support to textureSampleLevel#4406
beaufortfrancois merged 3 commits into
mainfrom
textureSampleLevel-1d

Conversation

@beaufortfrancois

Copy link
Copy Markdown
Collaborator

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

image

Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.) It works with Chromium patched with https://dawn-review.googlesource.com/c/dawn/+/247034
  • Test have be tested with compatibility mode validation enabled and behave as expected. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located in the test tree.
  • Test descriptions allow a reader to "read only the test plans and evaluate coverage completeness", and accurately reflect the test code.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Helpers and types promote readability and maintainability.

When landing this PR, be sure to make any necessary issue status updates.

@beaufortfrancois beaufortfrancois requested a review from jrprice June 17, 2025 12:27
* 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will clamped to 0 be part of the spec? Do I need to do something about it in the CTS and Tint implementation?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it and used same prose as the other tests for level

@jrprice jrprice left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me but I'm not familiar with the texture execution testing framework.

@greggman could you please take a quick look and see if this looks sound?

* 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems inaccurate since we're only testing a single level here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it then.

@jrprice jrprice requested a review from greggman June 17, 2025 18:33
t.skipIfTextureFormatAndDimensionNotCompatible(format, '1d');
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format);

// We want at least 4 blocks or something wide enough for 3 mip levels.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks for catching this!

@beaufortfrancois beaufortfrancois merged commit 2a8d4a8 into main Jun 20, 2025
1 check passed
@beaufortfrancois beaufortfrancois deleted the textureSampleLevel-1d branch June 20, 2025 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants