Skip to content

Commit 2663a2a

Browse files
authored
Prep for testing compressed 3d sliced texture formats (#4359)
1 parent 29b64be commit 2663a2a

7 files changed

Lines changed: 34 additions & 17 deletions

File tree

src/webgpu/format_info.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { keysOf } from '../common/util/data_tables.js';
33
import { assert, unreachable } from '../common/util/util.js';
44

55
import { align } from './util/math.js';
6+
import { getTextureDimensionFromView } from './util/texture/base.js';
67
import { ImageCopyType } from './util/texture/layout.js';
78

89
//
@@ -1895,6 +1896,21 @@ export function textureDimensionAndFormatCompatibleForDevice(
18951896
return textureDimensionAndFormatCompatible(dimension, format);
18961897
}
18971898

1899+
/**
1900+
* Returns true iff a texture can be used with the provided GPUTextureViewDimension
1901+
*/
1902+
export function textureViewDimensionAndFormatCompatibleForDevice(
1903+
device: GPUDevice,
1904+
dimension: GPUTextureViewDimension,
1905+
format: GPUTextureFormat
1906+
): boolean {
1907+
return textureDimensionAndFormatCompatibleForDevice(
1908+
device,
1909+
getTextureDimensionFromView(dimension),
1910+
format
1911+
);
1912+
}
1913+
18981914
/**
18991915
* Check if two formats are view format compatible.
19001916
*/

src/webgpu/shader/execution/expression/call/builtin/textureSample.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ import {
3636
isPotentiallyFilterableAndFillable,
3737
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable,
3838
getTextureTypeForTextureViewDimension,
39-
isSupportedViewFormatCombo,
4039
vec1,
4140
generateTextureBuiltinInputs1D,
41+
skipIfTextureViewAndFormatNotCompatibleForDevice,
4242
} from './texture_utils.js';
4343

4444
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);
@@ -339,7 +339,6 @@ Parameters:
339339
.combine('format', kAllTextureFormats)
340340
.filter(t => isPotentiallyFilterableAndFillable(t.format))
341341
.combine('dim', ['3d', 'cube'] as const)
342-
.filter(t => isSupportedViewFormatCombo(t.format, t.dim))
343342
.combine('filt', ['nearest', 'linear'] as const)
344343
.filter(t => t.filt === 'nearest' || isTextureFormatPossiblyFilterableAsTextureF32(t.format))
345344
.combine('modeU', kShortAddressModes)
@@ -363,6 +362,7 @@ Parameters:
363362
offset,
364363
} = t.params;
365364
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format);
365+
skipIfTextureViewAndFormatNotCompatibleForDevice(t, format, viewDimension);
366366

367367
const size = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
368368
const descriptor: GPUTextureDescriptor = {

src/webgpu/shader/execution/expression/call/builtin/textureSampleBias.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import {
3232
chooseTextureSize,
3333
isPotentiallyFilterableAndFillable,
3434
getTextureTypeForTextureViewDimension,
35-
isSupportedViewFormatCombo,
3635
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable,
36+
skipIfTextureViewAndFormatNotCompatibleForDevice,
3737
} from './texture_utils.js';
3838

3939
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);
@@ -167,7 +167,6 @@ Parameters:
167167
.combine('format', kAllTextureFormats)
168168
.filter(t => isPotentiallyFilterableAndFillable(t.format))
169169
.combine('dim', ['3d', 'cube'] as const)
170-
.filter(t => isSupportedViewFormatCombo(t.format, t.dim))
171170
.combine('filt', ['nearest', 'linear'] as const)
172171
.filter(t => t.filt === 'nearest' || isTextureFormatPossiblyFilterableAsTextureF32(t.format))
173172
.combine('modeU', kShortAddressModes)
@@ -191,6 +190,7 @@ Parameters:
191190
offset,
192191
} = t.params;
193192
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format);
193+
skipIfTextureViewAndFormatNotCompatibleForDevice(t, format, viewDimension);
194194

195195
const size = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
196196
const descriptor: GPUTextureDescriptor = {

src/webgpu/shader/execution/expression/call/builtin/textureSampleGrad.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import {
2323
generateTextureBuiltinInputs3D,
2424
getTextureTypeForTextureViewDimension,
2525
isPotentiallyFilterableAndFillable,
26-
isSupportedViewFormatCombo,
2726
kCubeSamplePointMethods,
2827
kSamplePointMethods,
2928
kShortAddressModes,
3029
kShortAddressModeToAddressMode,
3130
kShortShaderStages,
3231
SamplePointMethods,
3332
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable,
33+
skipIfTextureViewAndFormatNotCompatibleForDevice,
3434
TextureCall,
3535
vec2,
3636
vec3,
@@ -162,7 +162,6 @@ Parameters:
162162
.combine('format', kAllTextureFormats)
163163
.filter(t => isPotentiallyFilterableAndFillable(t.format))
164164
.combine('dim', ['3d', 'cube'] as const)
165-
.filter(t => isSupportedViewFormatCombo(t.format, t.dim))
166165
.combine('filt', ['nearest', 'linear'] as const)
167166
.filter(t => t.filt === 'nearest' || isTextureFormatPossiblyFilterableAsTextureF32(t.format))
168167
.combine('modeU', kShortAddressModes)
@@ -187,6 +186,7 @@ Parameters:
187186
offset,
188187
} = t.params;
189188
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format);
189+
skipIfTextureViewAndFormatNotCompatibleForDevice(t, format, viewDimension);
190190

191191
const size = chooseTextureSize({ minSize: 8, minBlocks: 2, format, viewDimension });
192192
const descriptor: GPUTextureDescriptor = {

src/webgpu/shader/execution/expression/call/builtin/textureSampleLevel.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import {
2525
getDepthOrArrayLayersForViewDimension,
2626
getTextureTypeForTextureViewDimension,
2727
isPotentiallyFilterableAndFillable,
28-
isSupportedViewFormatCombo,
2928
kCubeSamplePointMethods,
3029
kSamplePointMethods,
3130
kShortAddressModes,
3231
kShortAddressModeToAddressMode,
3332
kShortShaderStages,
3433
SamplePointMethods,
3534
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable,
35+
skipIfTextureViewAndFormatNotCompatibleForDevice,
3636
TextureCall,
3737
vec2,
3838
vec3,
@@ -385,7 +385,6 @@ Parameters:
385385
.combine('format', kAllTextureFormats)
386386
.filter(t => isPotentiallyFilterableAndFillable(t.format))
387387
.combine('dim', ['3d', 'cube'] as const)
388-
.filter(t => isSupportedViewFormatCombo(t.format, t.dim))
389388
.combine('filt', ['nearest', 'linear'] as const)
390389
.filter(t => t.filt === 'nearest' || isTextureFormatPossiblyFilterableAsTextureF32(t.format))
391390
.combine('mode', kShortAddressModes)
@@ -406,6 +405,7 @@ Parameters:
406405
offset,
407406
} = t.params;
408407
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format);
408+
skipIfTextureViewAndFormatNotCompatibleForDevice(t, format, viewDimension);
409409

410410
const [width, height] = chooseTextureSize({ minSize: 32, minBlocks: 2, format, viewDimension });
411411
const depthOrArrayLayers = getDepthOrArrayLayersForViewDimension(viewDimension);
@@ -496,7 +496,6 @@ baseMipLevel, lodMinClamp, and lodMaxClamp, with an dwithout filtering.
496496
.combine('format', kAllTextureFormats)
497497
.filter(t => isPotentiallyFilterableAndFillable(t.format))
498498
.combine('dim', ['3d', 'cube'] as const)
499-
.filter(t => isSupportedViewFormatCombo(t.format, t.dim))
500499
.combine('filt', ['nearest', 'linear'] as const)
501500
.filter(t => t.filt === 'nearest' || isTextureFormatPossiblyFilterableAsTextureF32(t.format))
502501
.beginSubcases()
@@ -522,6 +521,7 @@ baseMipLevel, lodMinClamp, and lodMaxClamp, with an dwithout filtering.
522521
lodMinClamp,
523522
} = t.params;
524523
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format);
524+
skipIfTextureViewAndFormatNotCompatibleForDevice(t, format, viewDimension);
525525

526526
const [width, height] = chooseTextureSize({ minSize: 32, minBlocks: 2, format, viewDimension });
527527
const depthOrArrayLayers = getDepthOrArrayLayersForViewDimension(viewDimension);

src/webgpu/shader/execution/expression/call/builtin/texture_utils.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import {
2222
convertPerTexelComponentToResultFormat,
2323
createTextureWithRandomDataAndGetTexels,
2424
graphWeights,
25-
isSupportedViewFormatCombo,
2625
makeRandomDepthComparisonTexelGenerator,
2726
queryMipLevelMixWeightsForDevice,
2827
readTextureToTexelViews,
28+
skipIfTextureViewAndFormatNotCompatibleForDevice,
2929
texelsApproximatelyEqual,
3030
} from './texture_utils.js';
3131

@@ -47,12 +47,12 @@ g.test('createTextureWithRandomDataAndGetTexels_with_generator')
4747
u
4848
.combine('format', kDepthStencilFormats)
4949
.combine('viewDimension', ['2d', '2d-array', 'cube', 'cube-array'] as const)
50-
.filter(t => isSupportedViewFormatCombo(t.format, t.viewDimension))
5150
)
5251
.fn(async t => {
5352
const { format, viewDimension } = t.params;
5453
t.skipIfTextureFormatNotSupported(format);
5554
t.skipIfTextureViewDimensionNotSupported(viewDimension);
55+
skipIfTextureViewAndFormatNotCompatibleForDevice(t, format, viewDimension);
5656
// choose an odd size (9) so we're more likely to test alignment issue.
5757
const size = chooseTextureSize({ minSize: 9, minBlocks: 4, format, viewDimension });
5858
t.debug(`size: ${size.map(v => v.toString()).join(', ')}`);
@@ -86,7 +86,6 @@ g.test('readTextureToTexelViews')
8686
{ srcFormat: 'stencil8', texelViewFormat: 'stencil8' },
8787
] as const)
8888
.combine('viewDimension', ['1d', '2d', '2d-array', '3d', 'cube', 'cube-array'] as const)
89-
.filter(t => isSupportedViewFormatCombo(t.srcFormat, t.viewDimension))
9089
.combine('sampleCount', [1, 4] as const)
9190
.unless(
9291
t =>
@@ -97,6 +96,7 @@ g.test('readTextureToTexelViews')
9796
.fn(async t => {
9897
const { srcFormat, texelViewFormat, viewDimension, sampleCount } = t.params;
9998
t.skipIfTextureViewDimensionNotSupported(viewDimension);
99+
skipIfTextureViewAndFormatNotCompatibleForDevice(t, srcFormat, viewDimension);
100100
if (sampleCount > 1) {
101101
t.skipIfTextureFormatNotMultisampled(srcFormat);
102102
}

src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
isSintOrUintFormat,
1818
isStencilTextureFormat,
1919
kEncodableTextureFormats,
20+
textureViewDimensionAndFormatCompatibleForDevice,
2021
} from '../../../../../format_info.js';
2122
import { GPUTest } from '../../../../../gpu_test.js';
2223
import {
@@ -79,14 +80,14 @@ export const kSampleTypeInfo = {
7980
},
8081
} as const;
8182

82-
// MAINTENANCE_TODO: Stop excluding sliced compressed 3d formats.
83-
export function isSupportedViewFormatCombo(
83+
export function skipIfTextureViewAndFormatNotCompatibleForDevice(
84+
t: GPUTest,
8485
format: GPUTextureFormat,
8586
viewDimension: GPUTextureViewDimension
8687
) {
87-
return !(
88-
(isCompressedTextureFormat(format) || isDepthOrStencilTextureFormat(format)) &&
89-
(viewDimension === '3d' || viewDimension === '1d')
88+
t.skipIf(
89+
!textureViewDimensionAndFormatCompatibleForDevice(t.device, viewDimension, format),
90+
`format: ${format} does not support viewDimension: ${viewDimension}`
9091
);
9192
}
9293

0 commit comments

Comments
 (0)