Skip to content

Commit

Permalink
WGSL texture builtins all stages (#3986)
Browse files Browse the repository at this point in the history
Test texture builtins on all stages. Previously
only the fragment stage was tested.

Note: Some of these are expected to fail on Intel Mac
because in compute shaders, Intel Mac doesn't do
bilinear interpolation between mip levels. At least
not if not using argument buffers.
  • Loading branch information
greggman authored Oct 9, 2024
1 parent 046a7fa commit d48c080
Show file tree
Hide file tree
Showing 10 changed files with 1,057 additions and 349 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
isEncodableTextureFormat,
kDepthStencilFormats,
} from '../../../../../format_info.js';
import { kShaderStages } from '../../../../validation/decl/util.js';

import {
checkCallResults,
Expand Down Expand Up @@ -67,6 +68,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kDepthStencilFormats)
// filter out stencil only formats
.filter(t => isDepthTextureFormat(t.format))
Expand All @@ -85,8 +87,17 @@ Parameters:
t.skipIfTextureFormatNotSupported(t.params.format);
})
.fn(async t => {
const { format, samplePoints, A, addressModeU, addressModeV, minFilter, compare, offset } =
t.params;
const {
format,
stage,
samplePoints,
A,
addressModeU,
addressModeV,
minFilter,
compare,
offset,
} = t.params;

const viewDimension = '2d-array';
const size = chooseTextureSize({ minSize: 8, minBlocks: 4, format, viewDimension });
Expand Down Expand Up @@ -116,7 +127,7 @@ Parameters:
arrayIndex: { num: texture.depthOrArrayLayers, type: A },
depthRef: true,
offset,
hashInputs: [format, samplePoints, A, addressModeU, addressModeV, minFilter, offset],
hashInputs: [stage, format, samplePoints, A, addressModeU, addressModeV, minFilter, offset],
}).map(({ coords, arrayIndex, depthRef, offset }) => {
return {
builtin: 'textureGatherCompare',
Expand All @@ -130,14 +141,23 @@ Parameters:
});
const textureType = 'texture_depth_2d_array';
const viewDescriptor = {};
const results = await doTextureCalls(t, texture, viewDescriptor, textureType, sampler, calls);
const results = await doTextureCalls(
t,
texture,
viewDescriptor,
textureType,
sampler,
calls,
stage
);
const res = await checkCallResults(
t,
{ texels, descriptor, viewDescriptor },
textureType,
sampler,
calls,
results
results,
stage
);
t.expectOK(res);
});
Expand All @@ -160,6 +180,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kDepthStencilFormats)
// filter out stencil only formats
.filter(t => isDepthTextureFormat(t.format))
Expand All @@ -176,7 +197,7 @@ Parameters:
t.skipIfTextureViewDimensionNotSupported('cube-array');
})
.fn(async t => {
const { format, A, samplePoints, addressMode, minFilter, compare } = t.params;
const { format, A, stage, samplePoints, addressMode, minFilter, compare } = t.params;

const viewDimension: GPUTextureViewDimension = 'cube-array';
const size = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
Expand Down Expand Up @@ -207,7 +228,7 @@ Parameters:
textureBuiltin: 'textureGatherCompare',
arrayIndex: { num: texture.depthOrArrayLayers / 6, type: A },
depthRef: true,
hashInputs: [format, samplePoints, addressMode, minFilter],
hashInputs: [stage, format, samplePoints, addressMode, minFilter],
}).map(({ coords, depthRef, arrayIndex }) => {
return {
builtin: 'textureGatherCompare',
Expand All @@ -222,14 +243,23 @@ Parameters:
dimension: viewDimension,
};
const textureType = 'texture_depth_cube_array';
const results = await doTextureCalls(t, texture, viewDescriptor, textureType, sampler, calls);
const results = await doTextureCalls(
t,
texture,
viewDescriptor,
textureType,
sampler,
calls,
stage
);
const res = await checkCallResults(
t,
{ texels, descriptor, viewDescriptor },
textureType,
sampler,
calls,
results
results,
stage
);
t.expectOK(res);
});
Expand All @@ -256,6 +286,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kDepthStencilFormats)
// filter out stencil only formats
.filter(t => isDepthTextureFormat(t.format))
Expand All @@ -270,7 +301,7 @@ Parameters:
.combine('offset', [false, true] as const)
)
.fn(async t => {
const { format, C, samplePoints, addressMode, compare, minFilter, offset } = t.params;
const { format, C, stage, samplePoints, addressMode, compare, minFilter, offset } = t.params;

const size = chooseTextureSize({ minSize: 8, minBlocks: 4, format });
const descriptor: GPUTextureDescriptor = {
Expand All @@ -297,7 +328,7 @@ Parameters:
descriptor,
offset,
depthRef: true,
hashInputs: [format, C, samplePoints, addressMode, minFilter, compare, offset],
hashInputs: [stage, format, C, samplePoints, addressMode, minFilter, compare, offset],
}).map(({ coords, depthRef, offset }) => {
return {
builtin: 'textureGatherCompare',
Expand All @@ -309,14 +340,23 @@ Parameters:
});
const textureType = 'texture_depth_2d';
const viewDescriptor = {};
const results = await doTextureCalls(t, texture, viewDescriptor, textureType, sampler, calls);
const results = await doTextureCalls(
t,
texture,
viewDescriptor,
textureType,
sampler,
calls,
stage
);
const res = await checkCallResults(
t,
{ texels, descriptor, viewDescriptor },
textureType,
sampler,
calls,
results
results,
stage
);
t.expectOK(res);
});
Expand All @@ -336,6 +376,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kDepthStencilFormats)
// filter out stencil only formats
.filter(t => isDepthTextureFormat(t.format))
Expand All @@ -348,7 +389,7 @@ Parameters:
.combine('compare', kCompareFunctions)
)
.fn(async t => {
const { format, samplePoints, addressMode, minFilter, compare } = t.params;
const { format, stage, samplePoints, addressMode, minFilter, compare } = t.params;

const viewDimension: GPUTextureViewDimension = 'cube';
const size = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
Expand Down Expand Up @@ -378,7 +419,7 @@ Parameters:
descriptor,
depthRef: true,
textureBuiltin: 'textureGatherCompare',
hashInputs: [format, samplePoints, addressMode, minFilter, compare],
hashInputs: [stage, format, samplePoints, addressMode, minFilter, compare],
}).map(({ coords, depthRef }) => {
return {
builtin: 'textureGatherCompare',
Expand All @@ -391,14 +432,23 @@ Parameters:
dimension: viewDimension,
};
const textureType = 'texture_depth_cube';
const results = await doTextureCalls(t, texture, viewDescriptor, textureType, sampler, calls);
const results = await doTextureCalls(
t,
texture,
viewDescriptor,
textureType,
sampler,
calls,
stage
);
const res = await checkCallResults(
t,
{ texels, descriptor, viewDescriptor },
textureType,
sampler,
calls,
results
results,
stage
);
t.expectOK(res);
});
Loading

0 comments on commit d48c080

Please sign in to comment.