Skip to content

Commit 33dc628

Browse files
committed
Add immediate size validation tests for pipeline layout creation.
immediateSize attribute is used for pipeline layout creation. It requires immediateSize must be a multiple of 4 and immediateSize must be smaller or equal to maxImmediateSize.
1 parent eb9091d commit 33dc628

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

0 Bytes
Binary file not shown.

src/webgpu/api/validation/createPipelineLayout.spec.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ TODO: review existing tests, write descriptions, and make sure tests are complet
66

77
import { AllFeaturesMaxLimitsGPUTest } from '../.././gpu_test.js';
88
import { makeTestGroup } from '../../../common/framework/test_group.js';
9-
import { count, range } from '../../../common/util/util.js';
9+
import { getGPU } from '../../../common/util/navigator_gpu.js';
10+
import { count, range, supportsImmediateData } from '../../../common/util/util.js';
1011
import {
1112
bufferBindingTypeInfo,
1213
getBindingLimitForBindingType,
@@ -512,3 +513,48 @@ g.test('bind_group_layouts,set_pipeline_with_null_bind_group_layouts')
512513
}
513514
}
514515
});
516+
517+
g.test('immediate_data_size')
518+
.desc(
519+
`
520+
Test that creating a pipeline layout with immediateSize validates:
521+
- immediateSize must be a multiple of 4.
522+
- immediateSize must be <= device.limits.maxImmediateSize.
523+
`
524+
)
525+
.params(u => u.combine('immediateSize', [0, 4, 'max', 'exceedLimits', 1, 2, 3, 5] as const))
526+
.fn(t => {
527+
if (!supportsImmediateData(getGPU(t.rec))) {
528+
t.skip('Immediate data not supported');
529+
return;
530+
}
531+
532+
const maxImmediateSize = t.device.limits.maxImmediateSize!;
533+
534+
const { immediateSize: sizeVariant } = t.params;
535+
let size: number;
536+
switch (sizeVariant) {
537+
case 'max':
538+
size = maxImmediateSize;
539+
break;
540+
case 'exceedLimits':
541+
size = maxImmediateSize + 4;
542+
break;
543+
default:
544+
size = sizeVariant;
545+
break;
546+
}
547+
548+
const descriptor = {
549+
bindGroupLayouts: [],
550+
immediateSize: size,
551+
};
552+
553+
const isMultipleOf4 = size % 4 === 0;
554+
const isWithinLimit = size <= maxImmediateSize;
555+
const shouldSucceed = isMultipleOf4 && isWithinLimit;
556+
557+
t.expectValidationError(() => {
558+
t.device.createPipelineLayout(descriptor);
559+
}, !shouldSucceed);
560+
});

0 commit comments

Comments
 (0)