Skip to content

buffer_view CTS#4652

Open
alan-baker wants to merge 2 commits into
gpuweb:mainfrom
alan-baker:buffer-view
Open

buffer_view CTS#4652
alan-baker wants to merge 2 commits into
gpuweb:mainfrom
alan-baker:buffer-view

Conversation

@alan-baker

@alan-baker alan-baker commented May 30, 2026

Copy link
Copy Markdown
Contributor

buffer_view validation and execution CTS tests.

Issue: #


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.
  • Test descriptions are accurate and complete.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Tests avoid over-parameterization (see case count report).

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

* Validation of buffer type and related builtin functions
* Tests for
  * bufferLength
  * bufferView
  * bufferArrayView
@alan-baker alan-baker requested review from dneto0 and jrprice May 30, 2026 20:09
@github-actions

Copy link
Copy Markdown

Results for build job (at dd3cfe0):

+webgpu:api,validation,dispatch:shader_required_buffer_size:* - 19 cases, 76 subcases (~4/case)
+webgpu:shader,execution,expression,call,builtin,bufferArrayView:array_length:* - 78 cases, 832 subcases (~11/case)
+webgpu:shader,execution,expression,call,builtin,bufferArrayView:array_length,functions:* - 78 cases, 1170 subcases (~15/case)
+webgpu:shader,execution,expression,call,builtin,bufferArrayView:read_layout:* - 35 cases, 604 subcases (~17/case)
+webgpu:shader,execution,expression,call,builtin,bufferArrayView:write_layout:* - 35 cases, 604 subcases (~17/case)
+webgpu:shader,execution,expression,call,builtin,bufferArrayView:read:* - 4 cases, 744 subcases (~186/case)
+webgpu:shader,execution,expression,call,builtin,bufferArrayView:write:* - 4 cases, 1224 subcases (~306/case)
+webgpu:shader,execution,expression,call,builtin,bufferLength:sized_buffer:* - 5 cases, 120 subcases (~24/case)
+webgpu:shader,execution,expression,call,builtin,bufferLength:unsized_buffer:* - 5 cases, 80 subcases (~16/case)
+webgpu:shader,execution,expression,call,builtin,bufferLength:max_size_buffer:* - 6 cases, 6 subcases (~1/case)
+webgpu:shader,execution,expression,call,builtin,bufferView:array_length:* - 78 cases, 832 subcases (~11/case)
+webgpu:shader,execution,expression,call,builtin,bufferView:array_length,functions:* - 78 cases, 1542 subcases (~20/case)
+webgpu:shader,execution,expression,call,builtin,bufferView:read_layout:* - 35 cases, 604 subcases (~17/case)
+webgpu:shader,execution,expression,call,builtin,bufferView:write_layout:* - 35 cases, 604 subcases (~17/case)
+webgpu:shader,execution,expression,call,builtin,bufferView:read:* - 4 cases, 856 subcases (~214/case)
+webgpu:shader,execution,expression,call,builtin,bufferView:write:* - 4 cases, 1224 subcases (~306/case)
-webgpu:shader,validation,decl,let:type:* - 21 cases, 21 subcases (~1/case)
-webgpu:shader,validation,decl,let:initializer:* - 10 cases, 10 subcases (~1/case)
 [snip - full report in action logs]
-TOTAL: 281361 cases, 2323132 subcases
+TOTAL: 282684 cases, 2338877 subcases

@alan-baker alan-baker marked this pull request as ready for review June 17, 2026 15:20

@dneto0 dneto0 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.

only partway reviewed

});

const buffer = t.createBufferTracked({
size: t.params.valid ? testcase.size : testcase.size - 4,

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 had to look up why this uses "- 4".
It comes from the fact that the buffer binding size in createBindGroup must be a multiple of 4. That's just a familiarity thing for me.

No request for change.

binding_type: 'read-only-storage',
requires: ['buffer_view'],
},
};

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 needs test cases for:

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.

uh, I think my request is nonsense because the size param has to be a const-expression. (!)

requires: ['buffer_view'],
},
};

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.

Also, the bufferArrayView cases less rich than the bufferView cases.

Interesting ones missing for bufferArrayView

  • compute max value across multiple uses in a shader
  • multiple uses in the shader, but only pay attention to the ones statically used by the shader in the pipeline

): boolean {
if (size === 0) {
// bufferView case
return offset + (type.arrayOffset ?? 0) + type.stride < bufferSize;

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.

Should this be less-than-or-equal?
Also on line 45.

}
}

export function calculateArrayLength(

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.

Worth saying this returns the element count. That's a bit less ambiguous

decls: `@group(0) @binding(0) var<storage> b : buffer;`,
},
buffer_sized: {
code: `let x = buffer<128> = b;`,

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.

typo: first = should be :

code: `let x : ptr<uniform, buffer<64>> = &b;`,
valid: false,
decls: `@group(0) @binding(0) var<uniform> b : buffer<128>;`,
},

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.

another case:

  • workgroup sized buffer with override size, assign its address to ptr-workgr-sized-buffer but mismatched override identifier.

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