Skip to content

Commit 76efa04

Browse files
committed
Additional coverage in copy_within_same_texture test
1 parent 2e418e2 commit 76efa04

File tree

1 file changed

+57
-10
lines changed

1 file changed

+57
-10
lines changed

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

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -645,40 +645,87 @@ Test that copyTextureToTexture copy boxes must be in range of the subresource.
645645
}
646646
});
647647

648+
g.test('copy_within_same_texture_non_2d')
649+
.desc(
650+
`
651+
Test that it is an error to use copyTextureToTexture from a 1D or 3D texture to itself.`
652+
)
653+
.paramsSubcasesOnly(u =>
654+
u //
655+
.combine('dimension', ['1d', '3d'])
656+
.expand('height', p => [p.dimension === '1d' ? 1 : 16])
657+
.expand('depthOrArrayLayers', p => [p.dimension === '1d' ? 1 : 4])
658+
)
659+
.fn(t => {
660+
const { dimension, height, depthOrArrayLayers } = t.params;
661+
const width = 16;
662+
663+
const testTexture = t.createTextureTracked({
664+
size: { width, height },
665+
dimension,
666+
format: 'rgba8unorm',
667+
usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.COPY_DST,
668+
});
669+
670+
t.testCopyTextureToTexture(
671+
{ texture: testTexture, origin: { x: 0, y: 0, z: 0 } },
672+
{ texture: testTexture, origin: { x: 0, y: 0, z: 0 } },
673+
{ width, height, depthOrArrayLayers },
674+
'FinishError'
675+
);
676+
});
677+
648678
g.test('copy_within_same_texture')
649679
.desc(
650680
`
651-
Test that it is an error to use copyTextureToTexture from one subresource to itself.
681+
Test that it is an error to use copyTextureToTexture from one subresource of a 2D texture to itself.
652682
- for various starting source/destination array layers.
653683
- for various copy sizes in number of array layers
654-
655-
TODO: Extend to check the copy is allowed between different mip levels.
656-
TODO: Extend to 1D and 3D textures.`
684+
- for various source/destination mip levels.`
657685
)
658686
.paramsSubcasesOnly(u =>
659687
u //
660688
.combine('srcCopyOriginZ', [0, 2, 4])
661689
.combine('dstCopyOriginZ', [0, 2, 4])
662690
.combine('copyExtentDepth', [1, 2, 3])
691+
.combine('srcCopyMipLevel', [0, 1])
692+
.combine('dstCopyMipLevel', [0, 1])
663693
)
664694
.fn(t => {
665-
const { srcCopyOriginZ, dstCopyOriginZ, copyExtentDepth } = t.params;
695+
const { srcCopyOriginZ, dstCopyOriginZ, copyExtentDepth, srcCopyMipLevel, dstCopyMipLevel } =
696+
t.params;
697+
698+
const textureDim = 16;
699+
const copyDim = srcCopyMipLevel === 1 || dstCopyMipLevel === 1 ? 8 : 16;
666700

667701
const kArrayLayerCount = 7;
702+
const kMipLevelCount = 2;
668703

669704
const testTexture = t.createTextureTracked({
670-
size: { width: 16, height: 16, depthOrArrayLayers: kArrayLayerCount },
705+
size: { width: textureDim, height: textureDim, depthOrArrayLayers: kArrayLayerCount },
706+
mipLevelCount: kMipLevelCount,
671707
format: 'rgba8unorm',
672708
usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.COPY_DST,
673709
});
674710

675-
const isSuccess =
711+
const layersDisjoint =
676712
Math.min(srcCopyOriginZ, dstCopyOriginZ) + copyExtentDepth <=
677713
Math.max(srcCopyOriginZ, dstCopyOriginZ);
714+
const differentMipLevel = srcCopyMipLevel !== dstCopyMipLevel;
715+
const isSuccess = layersDisjoint || differentMipLevel;
716+
678717
t.testCopyTextureToTexture(
679-
{ texture: testTexture, origin: { x: 0, y: 0, z: srcCopyOriginZ } },
680-
{ texture: testTexture, origin: { x: 0, y: 0, z: dstCopyOriginZ } },
681-
{ width: 16, height: 16, depthOrArrayLayers: copyExtentDepth },
718+
{
719+
texture: testTexture,
720+
origin: { x: 0, y: 0, z: srcCopyOriginZ },
721+
mipLevel: srcCopyMipLevel,
722+
},
723+
{
724+
texture: testTexture,
725+
origin: { x: 0, y: 0, z: dstCopyOriginZ },
726+
mipLevel: dstCopyMipLevel,
727+
},
728+
{ width: copyDim, height: copyDim, depthOrArrayLayers: copyExtentDepth },
682729
isSuccess ? 'Success' : 'FinishError'
683730
);
684731
});

0 commit comments

Comments
 (0)