Skip to content

Commit

Permalink
wgsl: Add AF select execution tests
Browse files Browse the repository at this point in the history
Fixes #3076
  • Loading branch information
zoddicus committed Oct 19, 2023
1 parent 6696b0e commit 6fb3e20
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/webgpu/shader/execution/expression/call/builtin/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,30 @@ import {
vec2,
vec3,
vec4,
abstractFloat,
TypeAbstractFloat,
} from '../../../../../util/conversion.js';
import { run, CaseList, allInputSources } from '../../expression.js';

import { builtin } from './builtin.js';
import { abstractBuiltin, builtin } from './builtin.js';

export const g = makeTestGroup(GPUTest);

function makeBool(n: number) {
return bool((n & 1) === 1);
}

type scalarKind = 'b' | 'f' | 'h' | 'i' | 'u';
type scalarKind = 'b' | 'af' | 'f' | 'h' | 'i' | 'u';

const dataType = {
b: {
type: TypeBool,
constructor: makeBool,
},
af: {
type: TypeAbstractFloat,
constructor: abstractFloat,
},
f: {
type: TypeF32,
constructor: f32,
Expand All @@ -72,13 +78,14 @@ g.test('scalar')
.params(u =>
u
.combine('inputSource', allInputSources)
.combine('component', ['b', 'f', 'h', 'i', 'u'] as const)
.combine('component', ['b', 'af', 'f', 'h', 'i', 'u'] as const)
.combine('overload', ['scalar', 'vec2', 'vec3', 'vec4'] as const)
)
.beforeAllSubcases(t => {
if (t.params.component === 'h') {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
}
t.skipIf(t.params.component === 'af' && t.params.inputSource !== 'const');
})
.fn(async t => {
const componentType = dataType[t.params.component as scalarKind].type;
Expand Down Expand Up @@ -133,7 +140,7 @@ g.test('scalar')

await run(
t,
builtin('select'),
t.params.component !== 'af' ? builtin('select') : abstractBuiltin('select'),
[overload.type, overload.type, TypeBool],
overload.type,
t.params,
Expand All @@ -147,13 +154,14 @@ g.test('vector')
.params(u =>
u
.combine('inputSource', allInputSources)
.combine('component', ['b', 'f', 'h', 'i', 'u'] as const)
.combine('component', ['b', 'af', 'f', 'h', 'i', 'u'] as const)
.combine('overload', ['vec2', 'vec3', 'vec4'] as const)
)
.beforeAllSubcases(t => {
if (t.params.component === 'h') {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
}
t.skipIf(t.params.component === 'af' && t.params.inputSource !== 'const');
})
.fn(async t => {
const componentType = dataType[t.params.component as scalarKind].type;
Expand Down Expand Up @@ -236,7 +244,7 @@ g.test('vector')

await run(
t,
builtin('select'),
t.params.component !== 'af' ? builtin('select') : abstractBuiltin('select'),
[tests.dataType, tests.dataType, tests.boolType],
tests.dataType,
t.params,
Expand Down

0 comments on commit 6fb3e20

Please sign in to comment.