Skip to content

Commit

Permalink
WGSL texture builtins all stages
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 committed Oct 8, 2024
1 parent 046a7fa commit 2a86881
Show file tree
Hide file tree
Showing 8 changed files with 982 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
kDepthStencilFormats,
kEncodableTextureFormats,
} from '../../../../../format_info.js';
import { kShaderStages } from '../../../../validation/decl/util.js';

import {
appendComponentTypeForFormatToTextureType,
Expand Down Expand Up @@ -83,6 +84,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kTestableColorFormats)
.filter(t => isFillable(t.format))
.combine('minFilter', ['nearest', 'linear'] as const)
Expand All @@ -98,7 +100,8 @@ Parameters:
skipIfNeedsFilteringAndIsUnfilterableOrSelectDevice(t, t.params.minFilter, t.params.format);
})
.fn(async t => {
const { format, C, samplePoints, addressModeU, addressModeV, minFilter, offset } = t.params;
const { format, C, samplePoints, stage, addressModeU, addressModeV, minFilter, offset } =
t.params;

// We want at least 4 blocks or something wide enough for 3 mip levels.
const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 4, format });
Expand Down Expand Up @@ -137,14 +140,23 @@ Parameters:
});
const textureType = appendComponentTypeForFormatToTextureType('texture_2d', format);
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 @@ -169,6 +181,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kTestableColorFormats)
.filter(t => isFillable(t.format))
.combine('minFilter', ['nearest', 'linear'] as const)
Expand All @@ -182,7 +195,7 @@ Parameters:
skipIfNeedsFilteringAndIsUnfilterableOrSelectDevice(t, t.params.minFilter, t.params.format);
})
.fn(async t => {
const { format, C, samplePoints, addressMode, minFilter } = t.params;
const { format, C, stage, samplePoints, addressMode, minFilter } = t.params;

const viewDimension: GPUTextureViewDimension = 'cube';
const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
Expand Down Expand Up @@ -225,14 +238,23 @@ Parameters:
dimension: viewDimension,
};
const textureType = appendComponentTypeForFormatToTextureType('texture_cube', format);
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 Down Expand Up @@ -266,6 +288,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kTestableColorFormats)
.filter(t => isFillable(t.format))
.combine('minFilter', ['nearest', 'linear'] as const)
Expand All @@ -282,7 +305,8 @@ Parameters:
skipIfNeedsFilteringAndIsUnfilterableOrSelectDevice(t, t.params.minFilter, t.params.format);
})
.fn(async t => {
const { format, samplePoints, C, A, addressModeU, addressModeV, minFilter, offset } = t.params;
const { format, stage, samplePoints, C, A, addressModeU, addressModeV, minFilter, offset } =
t.params;

// We want at least 4 blocks or something wide enough for 3 mip levels.
const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 4, format });
Expand Down Expand Up @@ -326,14 +350,23 @@ Parameters:
});
const textureType = appendComponentTypeForFormatToTextureType('texture_2d_array', format);
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 Down Expand Up @@ -361,6 +394,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kTestableColorFormats)
.filter(t => isFillable(t.format))
.combine('minFilter', ['nearest', 'linear'] as const)
Expand All @@ -376,7 +410,7 @@ Parameters:
skipIfNeedsFilteringAndIsUnfilterableOrSelectDevice(t, t.params.minFilter, t.params.format);
})
.fn(async t => {
const { format, C, A, samplePoints, addressMode, minFilter } = t.params;
const { format, C, A, stage, samplePoints, addressMode, minFilter } = t.params;

const viewDimension: GPUTextureViewDimension = 'cube-array';
const size = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
Expand Down Expand Up @@ -421,14 +455,23 @@ Parameters:
dimension: viewDimension,
};
const textureType = appendComponentTypeForFormatToTextureType('texture_cube_array', format);
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 @@ -454,6 +497,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kDepthStencilFormats)
// filter out stencil only formats
.filter(t => isDepthTextureFormat(t.format))
Expand All @@ -467,7 +511,7 @@ Parameters:
.combine('offset', [false, true] as const)
)
.fn(async t => {
const { format, samplePoints, addressModeU, addressModeV, minFilter, offset } = t.params;
const { format, stage, samplePoints, addressModeU, addressModeV, minFilter, offset } = t.params;

// We want at least 4 blocks or something wide enough for 3 mip levels.
const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 4, format });
Expand Down Expand Up @@ -503,14 +547,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 @@ -529,6 +582,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kDepthStencilFormats)
// filter out stencil only formats
.filter(t => isDepthTextureFormat(t.format))
Expand All @@ -540,7 +594,7 @@ Parameters:
.combine('addressMode', ['clamp-to-edge', 'repeat', 'mirror-repeat'] as const)
)
.fn(async t => {
const { format, samplePoints, addressMode, minFilter } = t.params;
const { format, stage, samplePoints, addressMode, minFilter } = t.params;

const viewDimension: GPUTextureViewDimension = 'cube';
const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
Expand Down Expand Up @@ -580,14 +634,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);
});
Expand Down Expand Up @@ -616,6 +679,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kDepthStencilFormats)
// filter out stencil only formats
.filter(t => isDepthTextureFormat(t.format))
Expand All @@ -634,7 +698,8 @@ Parameters:
skipIfNeedsFilteringAndIsUnfilterableOrSelectDevice(t, t.params.minFilter, t.params.format);
})
.fn(async t => {
const { format, samplePoints, A, addressModeU, addressModeV, minFilter, offset } = t.params;
const { format, stage, samplePoints, A, addressModeU, addressModeV, minFilter, offset } =
t.params;

// We want at least 4 blocks or something wide enough for 3 mip levels.
const [width, height] = chooseTextureSize({ minSize: 8, minBlocks: 4, format });
Expand Down Expand Up @@ -675,14 +740,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 @@ -704,6 +778,7 @@ Parameters:
)
.params(u =>
u
.combine('stage', kShaderStages)
.combine('format', kDepthStencilFormats)
// filter out stencil only formats
.filter(t => isDepthTextureFormat(t.format))
Expand All @@ -719,7 +794,7 @@ Parameters:
t.skipIfTextureViewDimensionNotSupported('cube-array');
})
.fn(async t => {
const { format, A, samplePoints, addressMode, minFilter } = t.params;
const { format, A, stage, samplePoints, addressMode, minFilter } = t.params;

const viewDimension: GPUTextureViewDimension = 'cube-array';
const size = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
Expand Down Expand Up @@ -761,14 +836,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);
});
Loading

0 comments on commit 2a86881

Please sign in to comment.