Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/webgpu/api/validation/createPipelineLayout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,32 @@ g.test('bind_group_layouts,set_pipeline_with_null_bind_group_layouts')
}
}
});

g.test('immediate_data_size')
.desc(
`
Test that creating a pipeline layout with immediateSize validates:
- immediateSize must be a multiple of 4.
- immediateSize must be <= device.limits.maxImmediateSize.
`
)
.fn(t => {
const maxImmediateSize = t.device.limits.maxImmediateSize ?? 64;

Comment on lines +525 to +526
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The test uses a fallback value of 64 for maxImmediateSize when it's undefined, but this might not match the actual spec default. The test should either skip when maxImmediateSize is not defined (similar to how the init method checks for support), or use the actual spec-defined default value if there is one.

Suggested change
const maxImmediateSize = t.device.limits.maxImmediateSize ?? 64;
const maxImmediateSize = t.device.limits.maxImmediateSize;
if (maxImmediateSize === undefined) {
t.skip('maxImmediateSize limit is not supported on this device.');
return;
}

Copilot uses AI. Check for mistakes.
const kTestSizes = [0, 4, maxImmediateSize, maxImmediateSize + 4, 1, 2, 3, 5];

for (const size of kTestSizes) {
const descriptor = {
bindGroupLayouts: [],
immediateSize: size,
};

const isMultipleOf4 = size % 4 === 0;
const isWithinLimit = size <= maxImmediateSize;
const shouldSucceed = isMultipleOf4 && isWithinLimit;

t.expectValidationError(() => {
t.device.createPipelineLayout(descriptor);
}, !shouldSucceed);
}
});
Comment on lines +516 to +543
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The test validates immediateSize constraints but doesn't test edge cases like negative values, NaN, or Infinity. While these may be caught by TypeScript, runtime validation should still be tested for robustness, especially since JavaScript allows these values.

Copilot uses AI. Check for mistakes.
Loading