summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/shader_module/entry_point.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/shader_module/entry_point.spec.ts')
-rw-r--r--dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/shader_module/entry_point.spec.ts117
1 files changed, 117 insertions, 0 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/shader_module/entry_point.spec.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/shader_module/entry_point.spec.ts
new file mode 100644
index 0000000000..9729b69547
--- /dev/null
+++ b/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/shader_module/entry_point.spec.ts
@@ -0,0 +1,117 @@
+export const description = `
+This tests entry point validation of compute/render pipelines and their shader modules.
+
+The entryPoint in shader module include standard "main" and others.
+The entryPoint assigned in descriptor include:
+- Matching case (control case)
+- Empty string
+- Mistyping
+- Containing invalid char, including space and control codes (Null character)
+- Unicode entrypoints and their ASCIIfied version
+
+TODO:
+- Test unicode normalization (gpuweb/gpuweb#1160)
+- Fine-tune test cases to reduce number by removing trivially similiar cases
+`;
+
+import { makeTestGroup } from '../../../../common/framework/test_group.js';
+import { kDefaultVertexShaderCode, getShaderWithEntryPoint } from '../../../util/shader.js';
+import { ValidationTest } from '../validation_test.js';
+
+export const g = makeTestGroup(ValidationTest);
+
+const kEntryPointTestCases = [
+ { shaderModuleEntryPoint: 'main', stageEntryPoint: 'main' },
+ { shaderModuleEntryPoint: 'main', stageEntryPoint: '' },
+ { shaderModuleEntryPoint: 'main', stageEntryPoint: 'main\0' },
+ { shaderModuleEntryPoint: 'main', stageEntryPoint: 'main\0a' },
+ { shaderModuleEntryPoint: 'main', stageEntryPoint: 'mian' },
+ { shaderModuleEntryPoint: 'main', stageEntryPoint: 'main ' },
+ { shaderModuleEntryPoint: 'main', stageEntryPoint: 'ma in' },
+ { shaderModuleEntryPoint: 'main', stageEntryPoint: 'main\n' },
+ { shaderModuleEntryPoint: 'mian', stageEntryPoint: 'mian' },
+ { shaderModuleEntryPoint: 'mian', stageEntryPoint: 'main' },
+ { shaderModuleEntryPoint: 'mainmain', stageEntryPoint: 'mainmain' },
+ { shaderModuleEntryPoint: 'mainmain', stageEntryPoint: 'foo' },
+ { shaderModuleEntryPoint: 'main_t12V3', stageEntryPoint: 'main_t12V3' },
+ { shaderModuleEntryPoint: 'main_t12V3', stageEntryPoint: 'main_t12V5' },
+ { shaderModuleEntryPoint: 'main_t12V3', stageEntryPoint: '_main_t12V3' },
+ { shaderModuleEntryPoint: 'séquençage', stageEntryPoint: 'séquençage' },
+ { shaderModuleEntryPoint: 'séquençage', stageEntryPoint: 'sequencage' },
+];
+
+g.test('compute')
+ .desc(
+ `
+Tests calling createComputePipeline(Async) with valid vertex stage shader and different entryPoints,
+and check that the APIs only accept matching entryPoint.
+`
+ )
+ .params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))
+ .fn(async t => {
+ const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
+ const descriptor: GPUComputePipelineDescriptor = {
+ layout: 'auto',
+ compute: {
+ module: t.device.createShaderModule({
+ code: getShaderWithEntryPoint('compute', shaderModuleEntryPoint),
+ }),
+ entryPoint: stageEntryPoint,
+ },
+ };
+ const _success = shaderModuleEntryPoint === stageEntryPoint;
+ t.doCreateComputePipelineTest(isAsync, _success, descriptor);
+ });
+
+g.test('vertex')
+ .desc(
+ `
+Tests calling createRenderPipeline(Async) with valid vertex stage shader and different entryPoints,
+and check that the APIs only accept matching entryPoint.
+`
+ )
+ .params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))
+ .fn(async t => {
+ const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
+ const descriptor: GPURenderPipelineDescriptor = {
+ layout: 'auto',
+ vertex: {
+ module: t.device.createShaderModule({
+ code: getShaderWithEntryPoint('vertex', shaderModuleEntryPoint),
+ }),
+ entryPoint: stageEntryPoint,
+ },
+ };
+ const _success = shaderModuleEntryPoint === stageEntryPoint;
+ t.doCreateRenderPipelineTest(isAsync, _success, descriptor);
+ });
+
+g.test('fragment')
+ .desc(
+ `
+Tests calling createRenderPipeline(Async) with valid fragment stage shader and different entryPoints,
+and check that the APIs only accept matching entryPoint.
+`
+ )
+ .params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))
+ .fn(async t => {
+ const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
+ const descriptor: GPURenderPipelineDescriptor = {
+ layout: 'auto',
+ vertex: {
+ module: t.device.createShaderModule({
+ code: kDefaultVertexShaderCode,
+ }),
+ entryPoint: 'main',
+ },
+ fragment: {
+ module: t.device.createShaderModule({
+ code: getShaderWithEntryPoint('fragment', shaderModuleEntryPoint),
+ }),
+ entryPoint: stageEntryPoint,
+ targets: [{ format: 'rgba8unorm' }],
+ },
+ };
+ const _success = shaderModuleEntryPoint === stageEntryPoint;
+ t.doCreateRenderPipelineTest(isAsync, _success, descriptor);
+ });