Skip to content

Conversation

@shaoboyan091
Copy link
Contributor

@shaoboyan091 shaoboyan091 commented Dec 31, 2025

Adds pipeline_immediate.spec.ts to validate immediate data usage in RenderPassEncoder, ComputePassEncoder, and RenderBundleEncoder.

Tests cover:

  • Required immediate data slots are set.
  • Unused variables do not require slots.
  • Pipeline creation fails if shader immediate size exceeds layout limit.
  • RenderBundle execution invalidates pipeline and immediate data state.

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

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 2 out of 2 changed files in this pull request and generated 5 comments.


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

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Results for build job (at bdeb595):

+webgpu:api,validation,encoding,programmable,pipeline_immediate:required_slots_set:* - 161 cases, 161 subcases (~1/case)
+webgpu:api,validation,encoding,programmable,pipeline_immediate:unused_variable:* - 12 cases, 12 subcases (~1/case)
+webgpu:api,validation,encoding,programmable,pipeline_immediate:overprovisioned_immediate_data:* - 6 cases, 6 subcases (~1/case)
+webgpu:api,validation,encoding,programmable,pipeline_immediate:render_bundle_execution_state_invalidation:* - 1 cases, 2 subcases (~2/case)
-TOTAL: 285744 cases, 2344468 subcases
+TOTAL: 285924 cases, 2344649 subcases

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 2 out of 2 changed files in this pull request and generated 3 comments.


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

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 2 out of 2 changed files in this pull request and generated 2 comments.


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

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 2 out of 2 changed files in this pull request and generated 2 comments.


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

@kainino0x
Copy link
Collaborator

Sorry, bit swamped. Should be able to review tomorrow.

`;
break;
case 'struct_padding':
kRequiredSize = 64;
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
kRequiredSize = 64;
kRequiredSize = 40;

Copy link
Contributor Author

@shaoboyan091 shaoboyan091 Jan 16, 2026

Choose a reason for hiding this comment

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

Done. And it indeed caught a bug in implementation! Tint calculated whole immediate block struct size as the immediate block size. And it doesn't get rid of tail padding bytes so it triggers validation report wrong fail due to it. (report used more bytes than layout required)

Adds `pipeline_immediate.spec.ts` to validate immediate data usage in
RenderPassEncoder, ComputePassEncoder, and RenderBundleEncoder.

Tests cover:
- Required immediate data slots are set.
- Unused variables do not require slots.
- Pipeline creation fails if shader immediate size exceeds layout limit.
- RenderBundle execution invalidates pipeline and immediate data state.
setImmediates(16, 16);
} else if (scenario === 'multiple_variables') {
// v1: struct S {u32} (size 4, align 4) -> offset 0
// v2: vec2<u32> (size 8, align 8) -> offset 8
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought the two immediate blocks were treated totally independently and so v2 would be at offset 0, and whatever data is in the immediates would get aliased by the two stages with different types.

I was thinking it would work like:

struct S1 { a: u32, x: u32 };       // slots used: 1100 0000
struct S2 { a: f32, y: vec4<f32> }; // slots used: 1000 1111
// so the slots required to be set are:            1100 1111

If this is wrong then I'll need to understand a bit better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First, I think the code comment here is incorrect. You understand is correct. They should be treated independently.
And I think the proposed case is better than what I want to do(padding bytes in fragment overlap with required bytes in vertex). Thanks!

@shaoboyan091 shaoboyan091 marked this pull request as draft January 21, 2026 05:19
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