Skip to content

Commit

Permalink
default entry points to shader modules
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed Nov 24, 2023
1 parent b37df1c commit 2f0b86e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 26 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@types/serve-index": "^1.9.3",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@webgpu/types": "^0.1.38",
"@webgpu/types": "^0.1.40",
"ansi-colors": "4.1.3",
"babel-plugin-add-header-comment": "^1.0.3",
"babel-plugin-const-enum": "^1.2.0",
Expand Down
85 changes: 67 additions & 18 deletions src/webgpu/api/validation/shader_module/entry_point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ TODO:
`;

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { kDefaultVertexShaderCode, getShaderWithEntryPoint } from '../../../util/shader.js';
import {
kDefaultVertexShaderCode,
getShaderWithEntryPoint,
TShaderStage,
} from '../../../util/shader.js';
import { ValidationTest } from '../validation_test.js';

export const g = makeTestGroup(ValidationTest);
Expand Down Expand Up @@ -43,23 +47,38 @@ const kEntryPointTestCases = [
g.test('compute')
.desc(
`
Tests calling createComputePipeline(Async) with valid vertex stage shader and different entryPoints,
Tests calling createComputePipeline(Async) with valid compute stage shader and different entryPoints,
and check that the APIs only accept matching entryPoint.
`
)
.params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))
.params(u =>
u
.combine('isAsync', [true, false])
.combine('provideEntryPoint', [true, false])
.combine('shaderModuleStage', ['compute', 'vertex', 'fragment'] as TShaderStage[])
.combineWithParams(kEntryPointTestCases)
)
.fn(t => {
const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
const {
isAsync,
provideEntryPoint,
shaderModuleStage,
shaderModuleEntryPoint,
stageEntryPoint,
} = t.params;
const entryPoint = provideEntryPoint ? stageEntryPoint : undefined;
const descriptor: GPUComputePipelineDescriptor = {
layout: 'auto',
compute: {
module: t.device.createShaderModule({
code: getShaderWithEntryPoint('compute', shaderModuleEntryPoint),
code: getShaderWithEntryPoint(shaderModuleStage, shaderModuleEntryPoint),
}),
entryPoint: stageEntryPoint,
entryPoint,
},
};
const _success = shaderModuleEntryPoint === stageEntryPoint;
const _success =
shaderModuleStage === 'compute' &&
(!provideEntryPoint || shaderModuleEntryPoint === stageEntryPoint);
t.doCreateComputePipelineTest(isAsync, _success, descriptor);
});

Expand All @@ -70,19 +89,34 @@ Tests calling createRenderPipeline(Async) with valid vertex stage shader and dif
and check that the APIs only accept matching entryPoint.
`
)
.params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))
.params(u =>
u
.combine('isAsync', [true, false])
.combine('provideEntryPoint', [true, false])
.combine('shaderModuleStage', ['compute', 'vertex', 'fragment'] as TShaderStage[])
.combineWithParams(kEntryPointTestCases)
)
.fn(t => {
const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
const {
isAsync,
provideEntryPoint,
shaderModuleStage,
shaderModuleEntryPoint,
stageEntryPoint,
} = t.params;
const entryPoint = provideEntryPoint ? stageEntryPoint : undefined;
const descriptor: GPURenderPipelineDescriptor = {
layout: 'auto',
vertex: {
module: t.device.createShaderModule({
code: getShaderWithEntryPoint('vertex', shaderModuleEntryPoint),
code: getShaderWithEntryPoint(shaderModuleStage, shaderModuleEntryPoint),
}),
entryPoint: stageEntryPoint,
entryPoint,
},
};
const _success = shaderModuleEntryPoint === stageEntryPoint;
const _success =
shaderModuleStage === 'vertex' &&
(!provideEntryPoint || shaderModuleEntryPoint === stageEntryPoint);
t.doCreateRenderPipelineTest(isAsync, _success, descriptor);
});

Expand All @@ -93,25 +127,40 @@ Tests calling createRenderPipeline(Async) with valid fragment stage shader and d
and check that the APIs only accept matching entryPoint.
`
)
.params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))

.params(u =>
u
.combine('isAsync', [true, false])
.combine('provideEntryPoint', [true, false])
.combine('shaderModuleStage', ['compute', 'vertex', 'fragment'] as TShaderStage[])
.combineWithParams(kEntryPointTestCases)
)
.fn(t => {
const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
const {
isAsync,
provideEntryPoint,
shaderModuleStage,
shaderModuleEntryPoint,
stageEntryPoint,
} = t.params;
const entryPoint = provideEntryPoint ? stageEntryPoint : undefined;
const descriptor: GPURenderPipelineDescriptor = {
layout: 'auto',
vertex: {
module: t.device.createShaderModule({
code: kDefaultVertexShaderCode,
}),
entryPoint: 'main',
},
fragment: {
module: t.device.createShaderModule({
code: getShaderWithEntryPoint('fragment', shaderModuleEntryPoint),
code: getShaderWithEntryPoint(shaderModuleStage, shaderModuleEntryPoint),
}),
entryPoint: stageEntryPoint,
entryPoint,
targets: [{ format: 'rgba8unorm' }],
},
};
const _success = shaderModuleEntryPoint === stageEntryPoint;
const _success =
shaderModuleStage === 'fragment' &&
(!provideEntryPoint || shaderModuleEntryPoint === stageEntryPoint);
t.doCreateRenderPipelineTest(isAsync, _success, descriptor);
});

0 comments on commit 2f0b86e

Please sign in to comment.