Skip to content

Operation tests for setImmediates#4558

Open
shaoboyan091 wants to merge 1 commit intogpuweb:mainfrom
shaoboyan091:immediate-operation
Open

Operation tests for setImmediates#4558
shaoboyan091 wants to merge 1 commit intogpuweb:mainfrom
shaoboyan091:immediate-operation

Conversation

@shaoboyan091
Copy link
Contributor

Implement operation tests for setImmediates in ComputePassEncoder, RenderPassEncoder, and RenderBundleEncoder.

  • Add basic execution tests for scalar, vector, and struct types.
  • Add tests for partial updates and multiple updates (using range verification).
  • Add tests for pipeline switching (compatible and incompatible).
  • Add tests for large data (maxImmediateSize) with range verification.
  • Add tests for TypedArray arguments with offsets.
  • Add tests for mixing render pass and bundle execution.

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.

@github-actions
Copy link

github-actions bot commented Jan 12, 2026

Results for build job (at 509b754):

+webgpu:api,operation,command_buffer,programmable,immediate:basic_execution:* - 39 cases, 39 subcases (~1/case)
+webgpu:api,operation,command_buffer,programmable,immediate:update_data:* - 3 cases, 3 subcases (~1/case)
+webgpu:api,operation,command_buffer,programmable,immediate:pipeline_switch:* - 2 cases, 2 subcases (~1/case)
+webgpu:api,operation,command_buffer,programmable,immediate:use_max_immediate_size:* - 3 cases, 3 subcases (~1/case)
+webgpu:api,operation,command_buffer,programmable,immediate:typed_array_arguments:* - 33 cases, 33 subcases (~1/case)
+webgpu:api,operation,command_buffer,programmable,immediate:multiple_updates_before_draw_or_dispatch:* - 3 cases, 3 subcases (~1/case)
+webgpu:api,operation,command_buffer,programmable,immediate:render_pass_and_bundle_mix:* - 1 cases, 1 subcases (~1/case)
+webgpu:api,operation,command_buffer,programmable,immediate:render_bundle_isolation:* - 1 cases, 1 subcases (~1/case)
-TOTAL: 285993 cases, 2344970 subcases
+TOTAL: 286078 cases, 2345055 subcases

Implement operation tests for setImmediates in ComputePassEncoder,
RenderPassEncoder, and RenderBundleEncoder.

- Add basic execution tests for scalar, vector, and struct types.
- Add tests for partial updates and multiple updates (using range verification).
- Add tests for pipeline switching (no inheritance).
- Add tests for large data (maxImmediateSize) with range verification.
- Add tests for TypedArray arguments with offsets.
- Add tests for mixing render pass and bundle execution.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a 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 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.params(u => u.combine('encoderType', kProgrammableEncoderTypes))
.fn(t => {
const { encoderType } = t.params;
const maxImmediateSize = t.device.limits.maxImmediateSize!;
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The maxImmediateSize limit can be undefined even when supportsImmediateData() returns true. The test should check if maxImmediateSize is defined and skip the test if it's not, similar to how validation tests handle this case. Without this check, the test will fail with a TypeError when trying to divide undefined by 4.

Suggested change
const maxImmediateSize = t.device.limits.maxImmediateSize!;
const maxImmediateSize = t.device.limits.maxImmediateSize;
if (maxImmediateSize === undefined) {
t.skip('maxImmediateSize limit is undefined');
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines +761 to +762
// Output size: 2 draws * 2 u32s * 4 bytes = 16 bytes.
const pipeline = createPipeline(t, 'render pass', wgslDecl, wgslUsage, 16) as GPURenderPipeline;
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The immediateSize parameter should be 8 bytes (vec2<u32> = 2 * 4 bytes), not 16 bytes. The comment at line 761 confuses the output buffer size with the immediate data size. The immediate data structure is vec2<u32>, which only requires 8 bytes of immediate storage.

Suggested change
// Output size: 2 draws * 2 u32s * 4 bytes = 16 bytes.
const pipeline = createPipeline(t, 'render pass', wgslDecl, wgslUsage, 16) as GPURenderPipeline;
// Output buffer size: 2 draws * 2 u32s * 4 bytes = 16 bytes. Immediate data (vec2<u32>) = 8 bytes.
const pipeline = createPipeline(t, 'render pass', wgslDecl, wgslUsage, 8) as GPURenderPipeline;

Copilot uses AI. Check for mistakes.
Comment on lines +47 to +50
{
binding: 0,
visibility: GPUShaderStage.COMPUTE | GPUShaderStage.FRAGMENT,
buffer: { type: 'storage' },
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The tests use storage buffers in fragment shaders but don't check if this is supported in compatibility mode. Similar tests in this directory (programmable_state_test.ts:18-34) include a check for maxStorageBuffersInFragmentStage in compatibility mode. Consider adding a similar check in the test initialization or as a beforeAllSubcases hook to skip tests when storage buffers in fragment stage are not available.

Copilot uses AI. Check for mistakes.
Comment on lines +463 to +464
const pipelineA = createPipeline(t, encoderType, wgslDecl, wgslUsage, 16);
const pipelineB = createPipeline(t, encoderType, wgslDecl, wgslUsage, 16);
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The PR description mentions testing "pipeline switching (compatible and incompatible)" but the pipeline_switch test only tests compatible pipelines (both pipelineA and pipelineB have the same immediateSize of 16 bytes). Consider adding test cases for switching between pipelines with different immediate layouts to verify that immediate data is correctly reset or handled when switching to an incompatible pipeline.

Copilot uses AI. Check for mistakes.
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.

1 participant