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

Test usage field of GPUTextureViewDescriptor #3954

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

vonture
Copy link

@vonture vonture commented Sep 18, 2024

Add variants of existing view format writing tests to cover end2end inherited and minimal view usage.

Add validation tests for texture view creation with usage and texture view usage compatability in render passes/bind groups.

fixes: #3953


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.)
  • 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.

Add variants of existing view format writing tests to cover end2end
inherited and minimal view usage.

Add validation tests for texture view creation with usage and texture
view usage compatability in render passes/bind groups.
@vonture vonture marked this pull request as ready for review September 25, 2024 20:43
@@ -280,6 +299,7 @@ Read values from color array in the shader, and write it to the texture view via
- x= every texture format
- x= sampleCount {1, 4} if valid
- x= every possible view write method (see above)
- x= inherited or minal texture view usage
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- x= inherited or minal texture view usage
- x= inherited or minimal texture view usage

@@ -291,7 +311,8 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone
.combine('method', kTextureViewWriteMethods)
.combine('format', kRegularTextureFormats)
.combine('sampleCount', [1, 4])
.filter(({ format, method, sampleCount }) => {
.combine('viewUsageMethod', kTextureViewUsageMethods)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: move combine after filter, since the filter doesn't need this parameter. (it's a bit more efficient because the filter will have to run over fewer items)

t.skipIfTextureFormatNotUsableAsStorageTexture(format);
}
if (textureUsage & GPUTextureUsage.RENDER_ATTACHMENT && info.color && !info.colorRender) {
t.skip(`Texture with ${format} is not usable as a render attachment`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: These can be skipped at param building time (using filter) rather than here, which reduces the total number of tests.

(Someday the texture format info should depend on the device, but right now we only test base-level devices in most tests.)

});
renderPassEncoder.end();

const success = viewUsage === 0 || viewUsage & GPUTextureUsage.RENDER_ATTACHMENT;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: success won't be a boolean, which is slightly weird. Either check the value directly
(viewUsage & GPUTextureUsage.RENDER_ATTACHMENT) !== 0
or cast to boolean
!!(viewUsage & GPUTextureUsage.RENDER_ATTACHMENT) or
Boolean(viewUsage & GPUTextureUsage.RENDER_ATTACHMENT)

)
.params(u =>
u
.combine('usage', ['color-attachment', ...kTextureBindingTypes] as const)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: usage isn't a GPUTextureUsage, probably should be named something like bindingType

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.

Add tests for the usage field of GPUTextureViewDescriptor
2 participants