-
Notifications
You must be signed in to change notification settings - Fork 100
Validate setImmediates API in different encoder types #4515
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR adds comprehensive validation tests for the setImmediates API across different encoder types (compute pass, render pass, render bundle). The tests validate interpretation of TypedArray data offsets/sizes, alignment requirements, arithmetic overflow handling, and bounds checking.
- Adds validation tests for
setImmediatesAPI covering interpretation, alignment, overflow, and bounds scenarios - Tests validate that data offset and size are interpreted as bytes (not elements) for TypedArrays
- Updates
@webgpu/typespackage from version 0.1.66 to 0.1.67 to support the new API
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/webgpu/api/validation/encoding/cmds/setImmediates.spec.ts | New test file implementing comprehensive validation tests for the setImmediates API across different encoder types |
| package.json | Updates @webgpu/types dependency to version 0.1.67 |
| package-lock.json | Updates package lock file to reflect new @webgpu/types version with corresponding integrity hashes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6f03310 to
44d19ed
Compare
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.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
18d7d95 to
8afc31a
Compare
This PR adding validation tests to cover setImmediates API in different
encoder types (compute pass, render pass, render bundle) by covering:
* Interpretation:
- Passing a TypedArray the data offset and size is not given in elements.
* Alignment:
- rangeOffset is not a multiple of 4 bytes.
- content size, converted to bytes, is not a multiple of 4 bytes.
* Arithmetic overflow
- rangeOffset + contentSize is overflow
* Bounds:
- dataOffset + size (in bytes) exceeds the content data size.
- rangeOffset + size (in bytes) exceeds the maxImmdiateSize.
8afc31a to
d20b18f
Compare
Co-authored-by: Copilot <[email protected]>
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.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
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.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }); | ||
|
|
||
| g.test('overflow') | ||
| .desc('Tests that rangeOffset + contentSize exceeds Number.MAX_SAFE_INTEGER.') |
Copilot
AI
Dec 8, 2025
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.
In the description, there's a grammatical issue. The description should read "Tests that rangeOffset + contentSize do not exceed Number.MAX_SAFE_INTEGER" or "Tests the case when rangeOffset + contentSize exceeds Number.MAX_SAFE_INTEGER" to be clearer about what is being validated. Currently "exceeds" suggests the test is checking that overflow occurs, but based on the test logic, it should be preventing overflow.
| .desc('Tests that rangeOffset + contentSize exceeds Number.MAX_SAFE_INTEGER.') | |
| .desc('Tests that rangeOffset + contentSize do not exceed Number.MAX_SAFE_INTEGER.') |
| - rangeOffset is not a multiple of 4 bytes. | ||
| - content size, converted to bytes, is not a multiple of 4 bytes. | ||
| * Arithmetic overflow | ||
| - rangeOffset + contentSize is overflow |
Copilot
AI
Dec 8, 2025
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.
Grammar issue: "is overflow" is incorrect. Should be "overflows" or "causes overflow".
| - rangeOffset + contentSize is overflow | |
| - rangeOffset + contentSize overflows |
| .desc( | ||
| 'Tests that rangeOffset + contentSize is greater than maxImmediateSize and contentSize is larger than data size.' |
Copilot
AI
Dec 8, 2025
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.
Grammar issue: "contentSize" is singular, so it should be "is larger" not "are larger".
| { | ||
| offset: 8, | ||
| contentByteSize: kMaxSafeMultipleOf8, | ||
| _rangeValid: true, | ||
| _contentValid: false, | ||
| }, | ||
| ] as const) | ||
| ) | ||
| .fn(t => { | ||
| const { encoderType, offset, contentByteSize, _rangeValid, _contentValid } = t.params; | ||
| const data = new Uint8Array(t.device.limits.maxImmediateSize); | ||
|
|
||
| const { encoder, validateFinish } = t.createEncoder(encoderType); | ||
|
|
||
| const doSetImmediates = () => { | ||
| encoder.setImmediates(offset, data, 0, contentByteSize); |
Copilot
AI
Dec 8, 2025
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.
The overflow test creates a Uint8Array with size maxImmediateSize, but the overflow test case attempts to use contentByteSize: kMaxSafeMultipleOf8 (approximately 9e15). This will throw a RangeError due to accessing data beyond the array bounds (lines 163-170 in the out_of_bounds test also validate this scenario), not due to arithmetic overflow of rangeOffset + contentSize.
The test expects a RangeError (due to _contentValid: false), but this conflates two different validation errors: data bounds checking vs arithmetic overflow checking. The _rangeValid: true parameter suggests the range validation should pass, but since a RangeError is thrown earlier for bounds checking, the validateFinish(_rangeValid) call never actually validates the overflow behavior.
Consider separating these concerns: use a sufficiently large data array for the overflow test, or adjust the test to properly distinguish between bounds errors and overflow errors.
This PR adding validation tests to cover setImmediates API in different encoder types (compute pass, render pass, render bundle) by covering:
Issue: #
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.