Skip to content

Commit 7c72f2a

Browse files
committed
Refact api/operation/command_buffer/* for texture formats
Issue gpuweb#4181 Issue gpuweb#4178
1 parent 3d17e72 commit 7c72f2a

File tree

9 files changed

+67
-76
lines changed

9 files changed

+67
-76
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ API operations tests for clearBuffer.
33
`;
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
6-
import { GPUTest } from '../../../gpu_test.js';
6+
import { AllFeaturesMaxLimitsGPUTest } from '../../../gpu_test.js';
77

8-
export const g = makeTestGroup(GPUTest);
8+
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);
99

1010
g.test('clear')
1111
.desc(

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const description = 'copyBufferToBuffer operation tests';
22

33
import { makeTestGroup } from '../../../../common/framework/test_group.js';
4-
import { GPUTest } from '../../../gpu_test.js';
4+
import { AllFeaturesMaxLimitsGPUTest } from '../../../gpu_test.js';
55

6-
export const g = makeTestGroup(GPUTest);
6+
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);
77

88
g.test('single')
99
.desc(

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

+8-15
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class F extends TextureTestMixin(AllFeaturesMaxLimitsGPUTest) {
8080
srcCopyLevel: number,
8181
dstCopyLevel: number
8282
): void {
83-
this.skipIfTextureFormatNotSupportedDeprecated(srcFormat, dstFormat);
83+
this.skipIfTextureFormatNotSupported(srcFormat, dstFormat);
8484

8585
// If we're in compatibility mode and it's a compressed texture
8686
// then we need to render the texture to test the results of the copy.
@@ -919,10 +919,6 @@ g.test('color_textures,compressed,non_array')
919919
.combine('srcCopyLevel', [0, 2])
920920
.combine('dstCopyLevel', [0, 2])
921921
)
922-
.beforeAllSubcases(t => {
923-
const { srcFormat, dstFormat } = t.params;
924-
t.skipIfCopyTextureToTextureNotSupportedForFormat(srcFormat, dstFormat);
925-
})
926922
.fn(t => {
927923
const {
928924
dimension,
@@ -933,6 +929,7 @@ g.test('color_textures,compressed,non_array')
933929
srcCopyLevel,
934930
dstCopyLevel,
935931
} = t.params;
932+
t.skipIfCopyTextureToTextureNotSupportedForFormat(srcFormat, dstFormat);
936933
const { blockWidth: srcBlockWidth, blockHeight: srcBlockHeight } =
937934
getBlockInfoForColorTextureFormat(srcFormat);
938935
const { blockWidth: dstBlockWidth, blockHeight: dstBlockHeight } =
@@ -1070,10 +1067,6 @@ g.test('color_textures,compressed,array')
10701067
.combine('srcCopyLevel', [0, 2])
10711068
.combine('dstCopyLevel', [0, 2])
10721069
)
1073-
.beforeAllSubcases(t => {
1074-
const { srcFormat, dstFormat } = t.params;
1075-
t.skipIfCopyTextureToTextureNotSupportedForFormat(srcFormat, dstFormat);
1076-
})
10771070
.fn(t => {
10781071
const {
10791072
dimension,
@@ -1085,6 +1078,7 @@ g.test('color_textures,compressed,array')
10851078
dstCopyLevel,
10861079
} = t.params;
10871080
t.skipIfTextureFormatNotSupported(srcFormat, dstFormat);
1081+
t.skipIfCopyTextureToTextureNotSupportedForFormat(srcFormat, dstFormat);
10881082

10891083
const { blockWidth: srcBlockWidth, blockHeight: srcBlockHeight } =
10901084
getBlockInfoForColorTextureFormat(srcFormat);
@@ -1353,10 +1347,8 @@ g.test('copy_multisampled_color')
13531347
texture can only be 1.
13541348
`
13551349
)
1356-
.beforeAllSubcases(t => {
1357-
t.skipIf(t.isCompatibility, 'multisample textures are not copyable in compatibility mode');
1358-
})
13591350
.fn(t => {
1351+
t.skipIf(t.isCompatibility, 'multisample textures are not copyable in compatibility mode');
13601352
const textureSize = [32, 16, 1] as const;
13611353
const kColorFormat = 'rgba8unorm';
13621354
const kSampleCount = 4;
@@ -1544,11 +1536,12 @@ g.test('copy_multisampled_depth')
15441536
.params(u =>
15451537
u.combine('format', kDepthStencilFormats).filter(t => isDepthTextureFormat(t.format))
15461538
)
1547-
.beforeAllSubcases(t => {
1548-
t.skipIf(t.isCompatibility, 'multisample textures are not copyable in compatibility mode');
1549-
})
15501539
.fn(t => {
15511540
const { format } = t.params;
1541+
1542+
t.skipIf(t.isCompatibility, 'multisample textures are not copyable in compatibility mode');
1543+
t.skipIfTextureFormatNotSupported(format);
1544+
15521545
const textureSize = [32, 16, 1] as const;
15531546
const kSampleCount = 4;
15541547

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

+30-47
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import {
4848
kTextureDimensions,
4949
} from '../../../capability_info.js';
5050
import {
51-
kTextureFormatInfo,
5251
kDepthStencilFormats,
5352
kColorTextureFormats,
5453
depthStencilBufferTextureCopySupported,
@@ -58,8 +57,14 @@ import {
5857
ColorTextureFormat,
5958
RegularTextureFormat,
6059
isCompressedTextureFormat,
60+
isDepthTextureFormat,
61+
isStencilTextureFormat,
62+
getBlockInfoForTextureFormat,
63+
getBlockInfoForColorTextureFormat,
64+
canCopyToAllAspectsOfTextureFormat,
65+
canCopyFromAllAspectsOfTextureFormat,
6166
} from '../../../format_info.js';
62-
import { GPUTest, TextureTestMixin } from '../../../gpu_test.js';
67+
import { AllFeaturesMaxLimitsGPUTest, TextureTestMixin } from '../../../gpu_test.js';
6368
import { checkElementsEqual } from '../../../util/check_contents.js';
6469
import { align } from '../../../util/math.js';
6570
import { physicalMipSizeFromTexture } from '../../../util/texture/base.js';
@@ -124,7 +129,7 @@ const kMethodsToTest = [
124129
const dataGenerator = new DataArrayGenerator();
125130
const altDataGenerator = new DataArrayGenerator();
126131

127-
class ImageCopyTest extends TextureTestMixin(GPUTest) {
132+
class ImageCopyTest extends TextureTestMixin(AllFeaturesMaxLimitsGPUTest) {
128133
/**
129134
* This is used for testing passing undefined members of `GPUTexelCopyBufferLayout` instead of actual
130135
* values where possible. Passing arguments as values and not as objects so that they are passed
@@ -1020,12 +1025,12 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
10201025
arrayLayerCount: 1,
10211026
}),
10221027
};
1023-
if (kTextureFormatInfo[stencilTextureFormat].depth) {
1028+
if (isDepthTextureFormat(stencilTextureFormat)) {
10241029
depthStencilAttachment.depthClearValue = 0;
10251030
depthStencilAttachment.depthLoadOp = 'clear';
10261031
depthStencilAttachment.depthStoreOp = 'store';
10271032
}
1028-
if (kTextureFormatInfo[stencilTextureFormat].stencil) {
1033+
if (isStencilTextureFormat(stencilTextureFormat)) {
10291034
depthStencilAttachment.stencilLoadOp = 'load';
10301035
depthStencilAttachment.stencilStoreOp = 'store';
10311036
}
@@ -1102,7 +1107,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
11021107
copyMipLevel: number,
11031108
initialData: Float32Array
11041109
): void {
1105-
assert(!!kTextureFormatInfo[depthFormat].depth);
1110+
assert(!!isDepthTextureFormat(depthFormat));
11061111

11071112
const inputTexture = this.createTextureTracked({
11081113
size: copySize,
@@ -1177,12 +1182,12 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
11771182
mipLevelCount: 1,
11781183
}),
11791184
};
1180-
if (kTextureFormatInfo[depthFormat].depth) {
1185+
if (isDepthTextureFormat(depthFormat)) {
11811186
depthStencilAttachment.depthClearValue = 0.0;
11821187
depthStencilAttachment.depthLoadOp = 'clear';
11831188
depthStencilAttachment.depthStoreOp = 'store';
11841189
}
1185-
if (kTextureFormatInfo[depthFormat].stencil) {
1190+
if (isStencilTextureFormat(depthFormat)) {
11861191
depthStencilAttachment.stencilLoadOp = 'load';
11871192
depthStencilAttachment.stencilStoreOp = 'store';
11881193
}
@@ -1343,7 +1348,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
13431348
* This is a helper function used for filtering test parameters
13441349
*/
13451350
function formatCanBeTested({ format }: { format: ColorTextureFormat }): boolean {
1346-
return kTextureFormatInfo[format].color.copyDst && kTextureFormatInfo[format].color.copySrc;
1351+
return canCopyToAllAspectsOfTextureFormat(format) && canCopyFromAllAspectsOfTextureFormat(format);
13471352
}
13481353

13491354
export const g = makeTestGroup(ImageCopyTest);
@@ -1421,11 +1426,6 @@ bytes in copy works for every format.
14211426
return kRowsPerImageAndBytesPerRowParams.copySizes;
14221427
})
14231428
)
1424-
.beforeAllSubcases(t => {
1425-
const info = kTextureFormatInfo[t.params.format];
1426-
t.skipIfTextureFormatNotSupportedDeprecated(t.params.format);
1427-
t.selectDeviceOrSkipTestCase(info.feature);
1428-
})
14291429
.fn(t => {
14301430
const {
14311431
bytesPerRowPadding,
@@ -1438,7 +1438,8 @@ bytes in copy works for every format.
14381438
initMethod,
14391439
checkMethod,
14401440
} = t.params;
1441-
const info = kTextureFormatInfo[format];
1441+
t.skipIfTextureFormatNotSupported(t.params.format);
1442+
const info = getBlockInfoForTextureFormat(format);
14421443
// For CopyB2T and CopyT2B we need to have bytesPerRow 256-aligned,
14431444
// to make this happen we align the bytesInACompleteRow value and multiply
14441445
// bytesPerRowPadding by 256.
@@ -1536,11 +1537,6 @@ works for every format with 2d and 2d-array textures.
15361537
.combine('rowsPerImageEqualsCopyHeight', [true, false] as const)
15371538
.unless(p => p.dimension === '1d' && p.copyDepth !== 1)
15381539
)
1539-
.beforeAllSubcases(t => {
1540-
const info = kTextureFormatInfo[t.params.format];
1541-
t.skipIfTextureFormatNotSupportedDeprecated(t.params.format);
1542-
t.selectDeviceOrSkipTestCase(info.feature);
1543-
})
15441540
.fn(t => {
15451541
const {
15461542
offsetInBlocks,
@@ -1553,6 +1549,7 @@ works for every format with 2d and 2d-array textures.
15531549
copyWidth,
15541550
rowsPerImageEqualsCopyHeight,
15551551
} = t.params;
1552+
t.skipIfTextureFormatNotSupported(format);
15561553

15571554
// Skip test cases designed for special cases coverage on compatibility mode to save run time.
15581555
if (!(t.isCompatibility && (format === 'r8snorm' || format === 'rg8snorm'))) {
@@ -1567,9 +1564,9 @@ works for every format with 2d and 2d-array textures.
15671564
}
15681565
}
15691566

1570-
const info = kTextureFormatInfo[format];
1567+
const info = getBlockInfoForColorTextureFormat(format);
15711568

1572-
const offset = offsetInBlocks * info.color.bytes;
1569+
const offset = offsetInBlocks * info.bytesPerBlock;
15731570
const copyHeight = 3;
15741571
const copySize = {
15751572
width: copyWidth * info.blockWidth,
@@ -1578,7 +1575,7 @@ works for every format with 2d and 2d-array textures.
15781575
};
15791576
let textureHeight = 4 * info.blockHeight;
15801577
let rowsPerImage = rowsPerImageEqualsCopyHeight ? copyHeight : copyHeight + 1;
1581-
const bytesPerRow = align(copyWidth * info.color.bytes, 256);
1578+
const bytesPerRow = align(copyWidth * info.bytesPerBlock, 256);
15821579

15831580
if (dimension === '1d') {
15841581
copySize.height = 1;
@@ -1634,11 +1631,6 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
16341631
.combine('coordinateToTest', [0, 1, 2] as const)
16351632
.unless(p => p.dimension === '1d' && p.coordinateToTest !== 0)
16361633
)
1637-
.beforeAllSubcases(t => {
1638-
const info = kTextureFormatInfo[t.params.format];
1639-
t.skipIfTextureFormatNotSupportedDeprecated(t.params.format);
1640-
t.selectDeviceOrSkipTestCase(info.feature);
1641-
})
16421634
.fn(t => {
16431635
const {
16441636
originValueInBlocks,
@@ -1649,7 +1641,8 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
16491641
initMethod,
16501642
checkMethod,
16511643
} = t.params;
1652-
const info = kTextureFormatInfo[format];
1644+
t.skipIfTextureFormatNotSupported(format);
1645+
const info = getBlockInfoForColorTextureFormat(format);
16531646

16541647
let originBlocks = [1, 1, 1];
16551648
let copySizeBlocks = [2, 2, 2];
@@ -1685,7 +1678,7 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
16851678
] as const;
16861679

16871680
const rowsPerImage = copySizeBlocks[1];
1688-
const bytesPerRow = align(copySizeBlocks[0] * info.color.bytes, 256);
1681+
const bytesPerRow = align(copySizeBlocks[0] * info.bytesPerBlock, 256);
16891682

16901683
const dataSize = dataBytesForCopyOrFail({
16911684
layout: { offset: 0, bytesPerRow, rowsPerImage },
@@ -1727,7 +1720,7 @@ function* generateTestTextureSizes({
17271720
_mipSizeInBlocks: Required<GPUExtent3DDict>;
17281721
}): Generator<[number, number, number]> {
17291722
assert(dimension !== '1d'); // textureSize[1] would be wrong for 1D mipped textures.
1730-
const info = kTextureFormatInfo[format];
1723+
const info = getBlockInfoForColorTextureFormat(format);
17311724

17321725
const widthAtThisLevel = _mipSizeInBlocks.width * info.blockWidth;
17331726
const heightAtThisLevel = _mipSizeInBlocks.height * info.blockHeight;
@@ -1834,11 +1827,6 @@ TODO: Make a variant for depth-stencil formats.
18341827
])
18351828
.expand('textureSize', generateTestTextureSizes)
18361829
)
1837-
.beforeAllSubcases(t => {
1838-
const info = kTextureFormatInfo[t.params.format];
1839-
t.skipIfTextureFormatNotSupportedDeprecated(t.params.format);
1840-
t.selectDeviceOrSkipTestCase(info.feature);
1841-
})
18421830
.fn(t => {
18431831
const {
18441832
copySizeInBlocks,
@@ -1850,7 +1838,8 @@ TODO: Make a variant for depth-stencil formats.
18501838
initMethod,
18511839
checkMethod,
18521840
} = t.params;
1853-
const info = kTextureFormatInfo[format];
1841+
t.skipIfTextureFormatNotSupported(format);
1842+
const info = getBlockInfoForColorTextureFormat(format);
18541843

18551844
const origin = {
18561845
x: originInBlocks.x * info.blockWidth,
@@ -1965,9 +1954,9 @@ function CopyMethodSupportedWithDepthStencilFormat(
19651954
): boolean {
19661955
{
19671956
return (
1968-
(aspect === 'stencil-only' && !!kTextureFormatInfo[format].stencil) ||
1957+
(aspect === 'stencil-only' && isStencilTextureFormat(format)) ||
19691958
(aspect === 'depth-only' &&
1970-
!!kTextureFormatInfo[format].depth &&
1959+
isDepthTextureFormat(format) &&
19711960
copyMethod === 'CopyT2B' &&
19721961
depthStencilBufferTextureCopySupported('CopyT2B', format, aspect))
19731962
);
@@ -2002,10 +1991,6 @@ aspect and copyTextureToBuffer() with depth aspect.
20021991
})
20031992
.combine('mipLevel', [0, 2])
20041993
)
2005-
.beforeAllSubcases(t => {
2006-
const info = kTextureFormatInfo[t.params.format];
2007-
t.selectDeviceOrSkipTestCase(info.feature);
2008-
})
20091994
.fn(t => {
20101995
const {
20111996
format,
@@ -2018,6 +2003,7 @@ aspect and copyTextureToBuffer() with depth aspect.
20182003
copyDepth,
20192004
mipLevel,
20202005
} = t.params;
2006+
t.skipIfTextureFormatNotSupported(format);
20212007
const bytesPerBlock = depthStencilFormatAspectSize(format, aspect);
20222008
const rowsPerImage = copyHeightInBlocks + rowsPerImagePadding;
20232009

@@ -2093,13 +2079,10 @@ copyTextureToBuffer() with depth aspect.
20932079
.combine('copyDepth', kOffsetsAndSizesParams.copyDepth)
20942080
.combine('mipLevel', [0, 2])
20952081
)
2096-
.beforeAllSubcases(t => {
2097-
const info = kTextureFormatInfo[t.params.format];
2098-
t.selectDeviceOrSkipTestCase(info.feature);
2099-
})
21002082
.fn(t => {
21012083
const { format, copyMethod, aspect, offsetInBlocks, dataPaddingInBytes, copyDepth, mipLevel } =
21022084
t.params;
2085+
t.skipIfTextureFormatNotSupported(format);
21032086
const bytesPerBlock = depthStencilFormatAspectSize(format, aspect);
21042087
const initialDataOffset = offsetInBlocks * bytesPerBlock;
21052088
const copySize = [3, 3, copyDepth] as const;

src/webgpu/api/operation/command_buffer/queries/occlusionQuery.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
} from '../../../../../common/util/util.js';
2929
import { kMaxQueryCount } from '../../../../capability_info.js';
3030
import { DepthStencilFormat } from '../../../../format_info.js';
31-
import { GPUTest } from '../../../../gpu_test.js';
31+
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
3232

3333
const kRequiredQueryBufferOffsetAlignment = 256;
3434
const kBytesPerQuery = 8;
@@ -252,7 +252,7 @@ class QueryStarterRenderBundle implements QueryStarter {
252252
}
253253
}
254254

255-
class OcclusionQueryTest extends GPUTest {
255+
class OcclusionQueryTest extends AllFeaturesMaxLimitsGPUTest {
256256
createVertexBuffer(data: TypedArrayBufferView) {
257257
return this.makeBufferWithContents(data, GPUBufferUsage.VERTEX);
258258
}

src/webgpu/api/operation/command_buffer/render/dynamic_state.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ TODO:
1414
`;
1515

1616
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
17-
import { GPUTest } from '../../../../gpu_test.js';
17+
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
1818

19-
export const g = makeTestGroup(GPUTest);
19+
export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

src/webgpu/api/operation/command_buffer/render/state_tracking.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Equivalent tests for viewport/scissor/blend/reference are in render/dynamic_stat
66
`;
77

88
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
9-
import { GPUTest, TextureTestMixin } from '../../../../gpu_test.js';
9+
import { AllFeaturesMaxLimitsGPUTest, TextureTestMixin } from '../../../../gpu_test.js';
1010
import { TexelView } from '../../../../util/texture/texel_view.js';
1111

12-
class VertexAndIndexStateTrackingTest extends TextureTestMixin(GPUTest) {
12+
class VertexAndIndexStateTrackingTest extends TextureTestMixin(AllFeaturesMaxLimitsGPUTest) {
1313
GetRenderPipelineForTest(arrayStride: number): GPURenderPipeline {
1414
return this.device.createRenderPipeline({
1515
layout: 'auto',

0 commit comments

Comments
 (0)