Skip to content

Commit

Permalink
Add textureSampleCompare/Level WGSL tests (gpuweb#3984)
Browse files Browse the repository at this point in the history
The tests fill depth textures with random values
except, if the comparision mode is 'equal' or 'not-equal'
then we only put 0.0, 0.6, 1.0 in the texture. depthRef
for all tests are 0.0, 0.5, or 1.0 so the comparisons
should produce valid tests.
  • Loading branch information
greggman authored and teoxoy committed Oct 25, 2024
1 parent 61f57b6 commit a3dedef
Show file tree
Hide file tree
Showing 5 changed files with 796 additions and 147 deletions.
2 changes: 0 additions & 2 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,6 @@
"webgpu:shader,execution,expression,call,builtin,textureSampleCompareLevel:3d_coords:*": { "subcaseMS": 10.301 },
"webgpu:shader,execution,expression,call,builtin,textureSampleCompareLevel:arrayed_2d_coords:*": { "subcaseMS": 705.100 },
"webgpu:shader,execution,expression,call,builtin,textureSampleCompareLevel:arrayed_3d_coords:*": { "subcaseMS": 622.700 },
"webgpu:shader,execution,expression,call,builtin,textureSampleCompareLevel:control_flow:*": { "subcaseMS": 2.202 },
"webgpu:shader,execution,expression,call,builtin,textureSampleCompareLevel:stage:*": { "subcaseMS": 7.901 },
"webgpu:shader,execution,expression,call,builtin,textureSampleGrad:sampled_2d_coords:*": { "subcaseMS": 82.401 },
"webgpu:shader,execution,expression,call,builtin,textureSampleGrad:sampled_3d_coords:*": { "subcaseMS": 309.101 },
"webgpu:shader,execution,expression,call,builtin,textureSampleGrad:sampled_array_2d_coords:*": { "subcaseMS": 352.900 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
generateTextureBuiltinInputs2D,
kCubeSamplePointMethods,
kSamplePointMethods,
makeRandomDepthComparisonTexelGenerator,
TextureCall,
vec2,
vec3,
Expand Down Expand Up @@ -87,15 +88,17 @@ Parameters:
const { format, samplePoints, A, addressModeU, addressModeV, minFilter, compare, offset } =
t.params;

const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 4, format });
const depthOrArrayLayers = 4;
const viewDimension = '2d-array';
const size = chooseTextureSize({ minSize: 8, minBlocks: 4, format, viewDimension });

const descriptor: GPUTextureDescriptor = {
format,
size: { width, height, depthOrArrayLayers },
size,
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor, {
generator: makeRandomDepthComparisonTexelGenerator(descriptor, compare),
});
const sampler: GPUSamplerDescriptor = {
addressModeU,
addressModeV,
Expand Down Expand Up @@ -184,7 +187,9 @@ Parameters:
size,
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor, {
generator: makeRandomDepthComparisonTexelGenerator(descriptor, compare),
});
const sampler: GPUSamplerDescriptor = {
addressModeU: addressMode,
addressModeV: addressMode,
Expand Down Expand Up @@ -267,13 +272,15 @@ Parameters:
.fn(async t => {
const { format, C, samplePoints, addressMode, compare, minFilter, offset } = t.params;

const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 4, format });
const size = chooseTextureSize({ minSize: 8, minBlocks: 4, format });
const descriptor: GPUTextureDescriptor = {
format,
size: { width, height },
size,
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor, {
generator: makeRandomDepthComparisonTexelGenerator(descriptor, compare),
});
const sampler: GPUSamplerDescriptor = {
addressModeU: addressMode,
addressModeV: addressMode,
Expand Down Expand Up @@ -344,16 +351,17 @@ Parameters:
const { format, samplePoints, addressMode, minFilter, compare } = t.params;

const viewDimension: GPUTextureViewDimension = 'cube';
const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
const depthOrArrayLayers = 6;
const size = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });

const descriptor: GPUTextureDescriptor = {
format,
...(t.isCompatibility && { textureBindingViewDimension: viewDimension }),
size: { width, height, depthOrArrayLayers },
size,
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor, {
generator: makeRandomDepthComparisonTexelGenerator(descriptor, compare),
});
const sampler: GPUSamplerDescriptor = {
addressModeU: addressMode,
addressModeV: addressMode,
Expand Down
Loading

0 comments on commit a3dedef

Please sign in to comment.