Skip to content

Commit

Permalink
apply feedback to textureSample.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Mar 14, 2024
1 parent 1af8d6d commit baf0644
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ Validates that only incorrect array_index arguments are rejected by ${builtin}
u
.combine('textureType', kTextureTypes)
// filter out types with no array_index
.filter(
({ textureType }) => !!kValidTextureSampleParameterTypes[textureType].hasArrayIndexArg
)
.filter(t => !!kValidTextureSampleParameterTypes[t.textureType].hasArrayIndexArg)
.combine('arrayIndexType', keysOf(kValuesTypes))
.beginSubcases()
.combine('value', [-9, -8, 0, 7, 8])
Expand Down Expand Up @@ -145,10 +143,7 @@ Validates that only incorrect offset arguments are rejected by ${builtin}
u
.combine('textureType', kTextureTypes)
// filter out types with no offset
.filter(
({ textureType }) =>
kValidTextureSampleParameterTypes[textureType].offsetArgType !== undefined
)
.filter(t => !!kValidTextureSampleParameterTypes[t.textureType].offsetArgType)
.combine('offsetType', keysOf(kValuesTypes))
.beginSubcases()
.combine('value', [-9, -8, 0, 7, 8])
Expand Down Expand Up @@ -191,10 +186,7 @@ Validates that only non-const offset arguments are rejected by ${builtin}
.combine('textureType', kTextureTypes)
.combine('varType', ['c', 'u', 'l'])
// filter out types with no offset
.filter(
({ textureType }) =>
kValidTextureSampleParameterTypes[textureType].offsetArgType !== undefined
)
.filter(t => !!kValidTextureSampleParameterTypes[t.textureType].offsetArgType)
)
.fn(t => {
const { textureType, varType } = t.params;
Expand All @@ -204,15 +196,14 @@ Validates that only non-const offset arguments are rejected by ${builtin}
const coordWGSL = coordsArgType.create(0).wgsl();
const arrayWGSL = hasArrayIndexArg ? ', 0' : '';
const offsetWGSL = `${offsetArgType}(${varType})`;
const castWGSL = offsetArgType!.elementType.toString();

const code = `
@group(0) @binding(0) var s: sampler;
@group(0) @binding(1) var t: ${textureType};
@group(0) @binding(2) var<uniform> u: ${offsetArgType};
@fragment fn fs(@builtin(position) p: vec4f) -> @location(0) vec4f {
const c = 1;
let l = ${offsetArgType}(${castWGSL}(p.x));
let l = ${offsetArgType!.create(0).wgsl()};
let v = textureSample(t, s, ${coordWGSL}${arrayWGSL}, ${offsetWGSL});
return vec4f(0);
}
Expand Down

0 comments on commit baf0644

Please sign in to comment.