Skip to content

Commit

Permalink
Test varients of textureSample and textureSampleCompare w/wo offset
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Mar 15, 2024
1 parent 5cfb3c7 commit 9810c44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Validation tests for the ${builtin}() builtin.
* test textureSample offset parameter must be correct type
* test textureSample offset parameter must be a const-expression
* test textureSample offset parameter must be between -8 and +7 inclusive
* test textureSample not usable in a compute or vertex shader
note: uniformity validation is covered in src/webgpu/shader/validation/uniformity/uniformity.spec.ts
`;
Expand Down Expand Up @@ -124,14 +125,14 @@ Validates that only incorrect array_index arguments are rejected by ${builtin}
)
)
.fn(t => {
const { textureType, arrayIndexType, value } = t.params;
const { textureType, arrayIndexType, value, offset } = t.params;
const arrayIndexArgType = kValuesTypes[arrayIndexType];
const args = [arrayIndexArgType.create(value)];
const { coordsArgType, offsetArgType } = kValidTextureSampleParameterTypes[textureType];

const coordWGSL = coordsArgType.create(0).wgsl();
const arrayWGSL = args.map(arg => arg.wgsl()).join(', ');
const offsetWGSL = offsetArgType ? `, ${offsetArgType.create(0).wgsl()}` : '';
const offsetWGSL = offset ? `, ${offsetArgType!.create(0).wgsl()}` : '';

const code = `
@group(0) @binding(0) var s: sampler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Validation tests for the ${builtin}() builtin.
* test textureSampleCompare offset parameter must be correct type
* test textureSampleCompare offset parameter must be a const-expression
* test textureSampleCompare offset parameter must be between -8 and +7 inclusive
* test textureSample not usable in a compute or vertex shader
note: uniformity validation is covered in src/webgpu/shader/validation/uniformity/uniformity.spec.ts
`;
Expand Down Expand Up @@ -118,14 +119,14 @@ Validates that only incorrect array_index arguments are rejected by ${builtin}
)
)
.fn(t => {
const { textureType, arrayIndexType, value } = t.params;
const { textureType, arrayIndexType, value, offset } = t.params;
const arrayIndexArgType = kValuesTypes[arrayIndexType];
const args = [arrayIndexArgType.create(value)];
const { coordsArgType, offsetArgType } = kValidTextureSampleCompareParameterTypes[textureType];

const coordWGSL = coordsArgType.create(0).wgsl();
const arrayWGSL = args.map(arg => arg.wgsl()).join(', ');
const offsetWGSL = offsetArgType ? `, ${offsetArgType.create(0).wgsl()}` : '';
const offsetWGSL = offset ? `, ${offsetArgType!.create(0).wgsl()}` : '';

const code = `
@group(0) @binding(0) var s: sampler_comparison;
Expand Down Expand Up @@ -162,7 +163,7 @@ Validates that only incorrect depth_ref arguments are rejected by ${builtin}
)
)
.fn(t => {
const { textureType, depthRefType, value } = t.params;
const { textureType, depthRefType, value, offset } = t.params;
const depthRefArgType = kValuesTypes[depthRefType];
const args = [depthRefArgType.create(value)];
const { coordsArgType, hasArrayIndexArg, offsetArgType } =
Expand All @@ -171,7 +172,7 @@ Validates that only incorrect depth_ref arguments are rejected by ${builtin}
const coordWGSL = coordsArgType.create(0).wgsl();
const arrayWGSL = hasArrayIndexArg ? ', 0' : '';
const depthRefWGSL = args.map(arg => arg.wgsl()).join(', ');
const offsetWGSL = offsetArgType ? `, ${offsetArgType.create(0).wgsl()}` : '';
const offsetWGSL = offset ? `, ${offsetArgType!.create(0).wgsl()}` : '';

const code = `
@group(0) @binding(0) var s: sampler_comparison;
Expand Down

0 comments on commit 9810c44

Please sign in to comment.