Skip to content

Commit

Permalink
wgsl: f16 built-in execution test for select
Browse files Browse the repository at this point in the history
This PR add execution test for f16 built-in `select`.

Issue: gpuweb#1248
  • Loading branch information
jzm-intel committed Aug 1, 2023
1 parent fa8f784 commit f5a82c4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/webgpu/shader/execution/expression/call/builtin/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import {
TypeVec,
TypeBool,
TypeF32,
TypeF16,
TypeI32,
TypeU32,
f32,
f16,
i32,
u32,
False,
Expand All @@ -39,7 +41,7 @@ function makeBool(n: number) {
return bool((n & 1) === 1);
}

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

const dataType = {
b: {
Expand All @@ -50,6 +52,10 @@ const dataType = {
type: TypeF32,
constructor: f32,
},
h: {
type: TypeF16,
constructor: f16,
},
i: {
type: TypeI32,
constructor: i32,
Expand All @@ -66,9 +72,14 @@ g.test('scalar')
.params(u =>
u
.combine('inputSource', allInputSources)
.combine('component', ['b', 'f', 'i', 'u'] as const)
.combine('component', ['b', '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'] });
}
})
.fn(async t => {
const componentType = dataType[t.params.component as scalarKind].type;
const cons = dataType[t.params.component as scalarKind].constructor;
Expand Down Expand Up @@ -136,9 +147,14 @@ g.test('vector')
.params(u =>
u
.combine('inputSource', allInputSources)
.combine('component', ['b', 'f', 'i', 'u'] as const)
.combine('component', ['b', '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'] });
}
})
.fn(async t => {
const componentType = dataType[t.params.component as scalarKind].type;
const cons = dataType[t.params.component as scalarKind].constructor;
Expand Down

0 comments on commit f5a82c4

Please sign in to comment.