Skip to content

Commit 2d48810

Browse files
committed
Fix usages of textureDimensionAndFormatCompatible.
All of these usages were wrong as they need the device to know if a dimension and format are compatible since extensions enable 3d dimension with compressed textures. So, rename textureDimensionAndFormatCompatible to textureFormatAndDimensionAndPossiblyCompatible to let a test filter out formats that can't possibly be used with certain dimensions. Then, for each test, call t.skipIfTextureFormatAndDimensionNotCompatible which checks the extensions. Further, a few tests needed fixing. copyTextureToTexture validation tests needed to handle 3d compress texture size limits correctly. createTexture needed to not skip 3d compressed textures layout_related needed to pass dimension to createAlignedTexture and also, several tests had dimension as a test parameter but didn't seem to be using it anywhere so added it into at least texture creation on those tests. expectTextureToMatchByRendering needed to handle 3d textures texture_zero tests were mostly indirectly affected by changes to texture_zero_init_test.ts. Nothing interesting changed in this PR but the params there are extremely convoluted and I didn't bother to decode exactly what is going on in detail. I did glance over them and I think they aren't skipping compressed textures.
1 parent b2d0fd8 commit 2d48810

18 files changed

+206
-123
lines changed

src/webgpu/api/operation/command_buffer/copyTextureToTexture.spec.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
kDepthStencilFormats,
2222
kRegularTextureFormats,
2323
RegularTextureFormat,
24-
textureDimensionAndFormatCompatible,
24+
textureFormatAndDimensionPossiblyCompatible,
2525
textureFormatsAreViewCompatible,
2626
} from '../../../format_info.js';
2727
import { AllFeaturesMaxLimitsGPUTest } from '../../../gpu_test.js';
@@ -82,6 +82,9 @@ class F extends AllFeaturesMaxLimitsGPUTest {
8282
dstCopyLevel: number
8383
): void {
8484
this.skipIfTextureFormatNotSupported(srcFormat, dstFormat);
85+
this.skipIfCopyTextureToTextureNotSupportedForFormat(srcFormat, dstFormat);
86+
this.skipIfTextureFormatAndDimensionNotCompatible(srcFormat, dimension);
87+
this.skipIfTextureFormatAndDimensionNotCompatible(dstFormat, dimension);
8588

8689
// If we're in compatibility mode and it's a compressed texture
8790
// then we need to render the texture to test the results of the copy.
@@ -802,8 +805,8 @@ g.test('color_textures,non_compressed,non_array')
802805
.combine('dimension', kTextureDimensions)
803806
.filter(
804807
({ dimension, srcFormat, dstFormat }) =>
805-
textureDimensionAndFormatCompatible(dimension, srcFormat) &&
806-
textureDimensionAndFormatCompatible(dimension, dstFormat)
808+
textureFormatAndDimensionPossiblyCompatible(dimension, srcFormat) &&
809+
textureFormatAndDimensionPossiblyCompatible(dimension, dstFormat)
807810
)
808811
.beginSubcases()
809812
.expandWithParams(p => {
@@ -979,8 +982,8 @@ g.test('color_textures,non_compressed,array')
979982
.combine('dimension', ['2d', '3d'] as const)
980983
.filter(
981984
({ dimension, srcFormat, dstFormat }) =>
982-
textureDimensionAndFormatCompatible(dimension, srcFormat) &&
983-
textureDimensionAndFormatCompatible(dimension, dstFormat)
985+
textureFormatAndDimensionPossiblyCompatible(dimension, srcFormat) &&
986+
textureFormatAndDimensionPossiblyCompatible(dimension, dstFormat)
984987
)
985988
.beginSubcases()
986989
.combine('textureSize', [
@@ -1071,11 +1074,6 @@ g.test('color_textures,compressed,array')
10711074
srcCopyLevel,
10721075
dstCopyLevel,
10731076
} = t.params;
1074-
t.skipIfTextureFormatNotSupported(srcFormat, dstFormat);
1075-
t.skipIfCopyTextureToTextureNotSupportedForFormat(srcFormat, dstFormat);
1076-
t.skipIfTextureFormatAndDimensionNotCompatible(srcFormat, dimension);
1077-
t.skipIfTextureFormatAndDimensionNotCompatible(dstFormat, dimension);
1078-
10791077
const { blockWidth: srcBlockWidth, blockHeight: srcBlockHeight } =
10801078
getBlockInfoForColorTextureFormat(srcFormat);
10811079
const { blockWidth: dstBlockWidth, blockHeight: dstBlockHeight } =

src/webgpu/api/operation/command_buffer/image_copy.spec.ts

+19-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {
4747
kDepthStencilFormats,
4848
kColorTextureFormats,
4949
depthStencilBufferTextureCopySupported,
50-
textureDimensionAndFormatCompatible,
50+
textureFormatAndDimensionPossiblyCompatible,
5151
depthStencilFormatAspectSize,
5252
DepthStencilFormat,
5353
ColorTextureFormat,
@@ -1218,7 +1218,9 @@ bytes in copy works for every format.
12181218
.combine('format', kColorTextureFormats)
12191219
.filter(formatCanBeTested)
12201220
.combine('dimension', kTextureDimensions)
1221-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
1221+
.filter(({ dimension, format }) =>
1222+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
1223+
)
12221224
.beginSubcases()
12231225
.combineWithParams(kRowsPerImageAndBytesPerRowParams.paddings)
12241226
.expandWithParams(p => {
@@ -1240,7 +1242,8 @@ bytes in copy works for every format.
12401242
initMethod,
12411243
checkMethod,
12421244
} = t.params;
1243-
t.skipIfTextureFormatNotSupported(t.params.format);
1245+
t.skipIfTextureFormatNotSupported(format);
1246+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
12441247
const info = getBlockInfoForTextureFormat(format);
12451248
// For CopyB2T and CopyT2B we need to have bytesPerRow 256-aligned,
12461249
// to make this happen we align the bytesInACompleteRow value and multiply
@@ -1321,7 +1324,9 @@ works for every format with 2d and 2d-array textures.
13211324
.combine('format', kColorTextureFormats)
13221325
.filter(formatCanBeTested)
13231326
.combine('dimension', kTextureDimensions)
1324-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
1327+
.filter(({ dimension, format }) =>
1328+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
1329+
)
13251330
.beginSubcases()
13261331
.combineWithParams(kOffsetsAndSizesParams.offsetsAndPaddings)
13271332
.combine('copyDepth', kOffsetsAndSizesParams.copyDepth) // 2d and 2d-array textures
@@ -1352,6 +1357,7 @@ works for every format with 2d and 2d-array textures.
13521357
rowsPerImageEqualsCopyHeight,
13531358
} = t.params;
13541359
t.skipIfTextureFormatNotSupported(format);
1360+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
13551361

13561362
// Skip test cases designed for special cases coverage on compatibility mode to save run time.
13571363
if (!(t.isCompatibility && (format === 'r8snorm' || format === 'rg8snorm'))) {
@@ -1420,7 +1426,9 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
14201426
.combine('format', kColorTextureFormats)
14211427
.filter(formatCanBeTested)
14221428
.combine('dimension', kTextureDimensions)
1423-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
1429+
.filter(({ dimension, format }) =>
1430+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
1431+
)
14241432
.beginSubcases()
14251433
.combine('originValueInBlocks', [0, 7, 8])
14261434
.combine('copySizeValueInBlocks', [0, 7, 8])
@@ -1444,6 +1452,7 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
14441452
checkMethod,
14451453
} = t.params;
14461454
t.skipIfTextureFormatNotSupported(format);
1455+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
14471456
const info = getBlockInfoForColorTextureFormat(format);
14481457

14491458
let originBlocks = [1, 1, 1];
@@ -1581,7 +1590,9 @@ TODO: Make a variant for depth-stencil formats.
15811590
.combine('format', kColorTextureFormats)
15821591
.filter(formatCanBeTested)
15831592
.combine('dimension', ['2d', '3d'] as const)
1584-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
1593+
.filter(({ dimension, format }) =>
1594+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
1595+
)
15851596
.beginSubcases()
15861597
.combineWithParams([
15871598
// origin + copySize = texturePhysicalSizeAtMipLevel for all coordinates, 2d texture */
@@ -1641,6 +1652,8 @@ TODO: Make a variant for depth-stencil formats.
16411652
checkMethod,
16421653
} = t.params;
16431654
t.skipIfTextureFormatNotSupported(format);
1655+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
1656+
16441657
const info = getBlockInfoForColorTextureFormat(format);
16451658

16461659
const origin = {

src/webgpu/api/operation/resource_init/check_texture/texture_zero_init_test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { kTextureAspects, kTextureDimensions } from '../../../../capability_info
88
import { GPUConst } from '../../../../constants.js';
99
import {
1010
kUncompressedTextureFormats,
11-
textureDimensionAndFormatCompatible,
11+
textureFormatAndDimensionPossiblyCompatible,
1212
UncompressedTextureFormat,
1313
EncodableTextureFormat,
1414
isColorTextureFormat,
@@ -480,7 +480,7 @@ export const kTestParams = kUnitCaseParamsBuilder
480480
])
481481
// [3] compressed formats
482482
.combine('format', kUncompressedTextureFormats)
483-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
483+
.filter(({ dimension, format }) => textureFormatAndDimensionPossiblyCompatible(dimension, format))
484484
.beginSubcases()
485485
.combine('aspect', kTextureAspects)
486486
.unless(({ readMethod, format, aspect }) => {

src/webgpu/api/operation/resource_init/texture_zero.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ g.test('uninitialized_texture_is_zero')
4242
.params(kTestParams)
4343
.fn(t => {
4444
t.skipIfTextureFormatNotSupportedForTest(t.params);
45+
t.skipIfTextureFormatAndDimensionNotCompatible(t.params.format, t.params.dimension);
4546

4647
const usage = getRequiredTextureUsage(
4748
t.params.format,

src/webgpu/api/validation/createTexture.spec.ts

+32-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
kRegularTextureFormats,
1313
kFeaturesForFormats,
1414
filterFormatsByFeature,
15-
textureDimensionAndFormatCompatible,
15+
textureFormatAndDimensionPossiblyCompatible,
1616
getBlockInfoForTextureFormat,
1717
isTextureFormatMultisampled,
1818
isTextureFormatColorRenderable,
@@ -53,11 +53,15 @@ g.test('zero_size_and_usage')
5353
'usage',
5454
] as const)
5555
// Filter out incompatible dimension type and format combinations.
56-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
56+
.filter(({ dimension, format }) =>
57+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
58+
)
5759
)
5860
.fn(t => {
5961
const { dimension, zeroArgument, format } = t.params;
6062
t.skipIfTextureFormatNotSupported(format);
63+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
64+
6165
const info = getBlockInfoForTextureFormat(format);
6266

6367
const size = [info.blockWidth, info.blockHeight, 1];
@@ -141,13 +145,16 @@ g.test('mipLevelCount,format')
141145
.beginSubcases()
142146
.combine('mipLevelCount', [1, 2, 3, 6, 7])
143147
// Filter out incompatible dimension type and format combinations.
144-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
148+
.filter(({ dimension, format }) =>
149+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
150+
)
145151
.combine('largestDimension', [0, 1, 2])
146152
.unless(({ dimension, largestDimension }) => dimension === '1d' && largestDimension > 0)
147153
)
148154
.fn(t => {
149155
const { dimension, format, mipLevelCount, largestDimension } = t.params;
150156
t.skipIfTextureFormatNotSupported(format);
157+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
151158
const info = getBlockInfoForTextureFormat(format);
152159

153160
// Compute dimensions such that the dimensions are in range [17, 32] and aligned with the
@@ -325,7 +332,9 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
325332
return usageSet;
326333
})
327334
// Filter out incompatible dimension type and format combinations.
328-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
335+
.filter(({ dimension, format }) =>
336+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
337+
)
329338
.unless(({ usage, format, mipLevelCount, dimension }) => {
330339
return (
331340
((usage & GPUConst.TextureUsage.RENDER_ATTACHMENT) !== 0 &&
@@ -340,6 +349,7 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
340349
.fn(t => {
341350
const { dimension, sampleCount, format, mipLevelCount, arrayLayerCount, usage } = t.params;
342351
t.skipIfTextureFormatNotSupported(format);
352+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
343353
if ((usage & GPUConst.TextureUsage.RENDER_ATTACHMENT) !== 0) {
344354
t.skipIfTextureFormatNotUsableAsRenderAttachment(format);
345355
}
@@ -416,11 +426,14 @@ g.test('texture_size,default_value_and_smallest_size,uncompressed_format')
416426
.beginSubcases()
417427
.combine('size', [[1], [1, 1], [1, 1, 1]])
418428
// Filter out incompatible dimension type and format combinations.
419-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
429+
.filter(({ dimension, format }) =>
430+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
431+
)
420432
)
421433
.fn(t => {
422434
const { dimension, format, size } = t.params;
423435
t.skipIfTextureFormatNotSupported(format);
436+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
424437

425438
const descriptor: GPUTextureDescriptor = {
426439
size,
@@ -439,9 +452,12 @@ g.test('texture_size,default_value_and_smallest_size,compressed_format')
439452
)
440453
.params(u =>
441454
u
442-
// Compressed formats are invalid for 1D and 3D.
443-
.combine('dimension', [undefined, '2d'] as const)
455+
// Compressed formats are invalid for 1D.
456+
.combine('dimension', [undefined, '2d', '3d'] as const)
444457
.combine('format', kCompressedTextureFormats)
458+
.filter(({ dimension, format }) =>
459+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
460+
)
445461
.beginSubcases()
446462
.expandWithParams(p => {
447463
const { blockWidth, blockHeight } = getBlockInfoForTextureFormat(p.format);
@@ -458,6 +474,7 @@ g.test('texture_size,default_value_and_smallest_size,compressed_format')
458474
.fn(t => {
459475
const { dimension, format, size, _success } = t.params;
460476
t.skipIfTextureFormatNotSupported(format);
477+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
461478

462479
const descriptor: GPUTextureDescriptor = {
463480
size,
@@ -770,6 +787,7 @@ g.test('texture_size,3d_texture,uncompressed_format')
770787
.fn(t => {
771788
const { format, sizeVariant } = t.params;
772789
t.skipIfTextureFormatNotSupported(format);
790+
t.skipIfTextureFormatAndDimensionNotCompatible(format, '3d');
773791
const maxTextureDimension3D = t.device.limits.maxTextureDimension3D;
774792
const size = sizeVariant.map(variant => t.makeLimitVariant('maxTextureDimension3D', variant));
775793

@@ -945,13 +963,10 @@ g.test('texture_size,3d_texture,compressed_format')
945963
];
946964
})
947965
)
948-
.beforeAllSubcases(t => {
949-
// Compressed formats are not supported in 3D in WebGPU v1 because they are complicated but not very useful for now.
950-
t.skip('Compressed 3D texture is not supported');
951-
})
952966
.fn(t => {
953967
const { format, sizeVariant } = t.params;
954968
t.skipIfTextureFormatNotSupported(format);
969+
t.skipIfTextureFormatAndDimensionNotCompatible(format, '3d');
955970
const info = getBlockInfoForTextureFormat(format);
956971

957972
const maxTextureDimension3D = t.device.limits.maxTextureDimension3D;
@@ -974,7 +989,8 @@ g.test('texture_size,3d_texture,compressed_format')
974989
size[1] % info.blockHeight === 0 &&
975990
size[0] <= maxTextureDimension3D &&
976991
size[1] <= maxTextureDimension3D &&
977-
size[2] <= maxTextureDimension3D;
992+
size[2] <= maxTextureDimension3D &&
993+
textureDimensionAndFormatCompatibleForDevice(t.device, '3d', format);
978994

979995
t.expectValidationError(() => {
980996
t.createTextureTracked(descriptor);
@@ -994,11 +1010,14 @@ g.test('texture_usage')
9941010
.combine('usage0', kTextureUsages)
9951011
.combine('usage1', kTextureUsages)
9961012
// Filter out incompatible dimension type and format combinations.
997-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
1013+
.filter(({ dimension, format }) =>
1014+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
1015+
)
9981016
)
9991017
.fn(t => {
10001018
const { dimension, format, usage0, usage1 } = t.params;
10011019
t.skipIfTextureFormatNotSupported(format);
1020+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
10021021
const info = getBlockInfoForTextureFormat(format);
10031022

10041023
const size = [info.blockWidth, info.blockHeight, 1];

src/webgpu/api/validation/encoding/cmds/copyTextureToTexture.spec.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
kAllTextureFormats,
99
kCompressedTextureFormats,
1010
kDepthStencilFormats,
11-
textureDimensionAndFormatCompatible,
11+
textureFormatAndDimensionPossiblyCompatible,
1212
getBlockInfoForTextureFormat,
1313
getBaseFormatForTextureFormat,
1414
canCopyFromAllAspectsOfTextureFormat,
@@ -757,7 +757,9 @@ TODO: Express the offsets in "block size" so as to be able to test non-4x4 compr
757757
u
758758
.combine('format', kCompressedTextureFormats)
759759
.combine('dimension', kTextureDimensions)
760-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
760+
.filter(({ dimension, format }) =>
761+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
762+
)
761763
.beginSubcases()
762764
.combine('copyBoxOffsets', [
763765
{ x: 0, y: 0, z: 0, width: 0, height: 0, depthOrArrayLayers: -2 },
@@ -779,6 +781,7 @@ TODO: Express the offsets in "block size" so as to be able to test non-4x4 compr
779781
const { format, dimension, copyBoxOffsets, srcCopyLevel, dstCopyLevel } = t.params;
780782

781783
t.skipIfTextureFormatNotSupported(format);
784+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
782785
t.skipIfCopyTextureToTextureNotSupportedForFormat(format);
783786

784787
const { blockWidth, blockHeight } = getBlockInfoForTextureFormat(format);
@@ -828,8 +831,12 @@ TODO: Express the offsets in "block size" so as to be able to test non-4x4 compr
828831
Math.min(srcSizeAtLevel.height, dstSizeAtLevel.height) + copyBoxOffsets.height - copyOrigin.y,
829832
0
830833
);
831-
const copyDepth =
832-
kTextureSize.depthOrArrayLayers + copyBoxOffsets.depthOrArrayLayers - copyOrigin.z;
834+
const copyDepth = Math.max(
835+
Math.min(srcSizeAtLevel.depthOrArrayLayers, dstSizeAtLevel.depthOrArrayLayers) +
836+
copyBoxOffsets.depthOrArrayLayers -
837+
copyOrigin.z,
838+
0
839+
);
833840

834841
const isSuccessForCompressedFormats =
835842
copyOrigin.x % blockWidth === 0 &&

src/webgpu/api/validation/image_copy/buffer_related.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
getBlockInfoForSizedTextureFormat,
88
isDepthOrStencilTextureFormat,
99
kSizedTextureFormats,
10-
textureDimensionAndFormatCompatible,
10+
textureFormatAndDimensionPossiblyCompatible,
1111
} from '../../../format_info.js';
1212
import { kResourceStates } from '../../../gpu_test.js';
1313
import { kImageCopyTypes } from '../../../util/texture/layout.js';
@@ -160,7 +160,9 @@ Test that bytesPerRow must be a multiple of 256 for CopyB2T and CopyT2B if it is
160160
.combine('format', kSizedTextureFormats)
161161
.filter(formatCopyableWithMethod)
162162
.combine('dimension', kTextureDimensions)
163-
.filter(({ dimension, format }) => textureDimensionAndFormatCompatible(dimension, format))
163+
.filter(({ dimension, format }) =>
164+
textureFormatAndDimensionPossiblyCompatible(dimension, format)
165+
)
164166
.beginSubcases()
165167
.combine('bytesPerRow', [undefined, 0, 1, 255, 256, 257, 512])
166168
.combine('copyHeightInBlocks', [0, 1, 2, 3])
@@ -188,6 +190,7 @@ Test that bytesPerRow must be a multiple of 256 for CopyB2T and CopyT2B if it is
188190
const { method, dimension, format, bytesPerRow, copyHeightInBlocks, _textureHeightInBlocks } =
189191
t.params;
190192
t.skipIfTextureFormatNotSupported(format);
193+
t.skipIfTextureFormatAndDimensionNotCompatible(format, dimension);
191194

192195
const info = getBlockInfoForSizedTextureFormat(format);
193196

0 commit comments

Comments
 (0)