@@ -645,40 +645,90 @@ Test that copyTextureToTexture copy boxes must be in range of the subresource.
645
645
}
646
646
} ) ;
647
647
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 (
656
+ 'dimension' ,
657
+ kTextureDimensions . filter ( d => d !== '2d' )
658
+ )
659
+ . expand ( 'height' , p => [ p . dimension === '1d' ? 1 : 16 ] )
660
+ . expand ( 'depthOrArrayLayers' , p => [ p . dimension === '1d' ? 1 : 4 ] )
661
+ )
662
+ . fn ( t => {
663
+ const { dimension, height, depthOrArrayLayers } = t . params ;
664
+ const width = 16 ;
665
+
666
+ const testTexture = t . createTextureTracked ( {
667
+ size : { width, height } ,
668
+ dimension,
669
+ format : 'rgba8unorm' ,
670
+ usage : GPUTextureUsage . COPY_SRC | GPUTextureUsage . COPY_DST ,
671
+ } ) ;
672
+
673
+ t . testCopyTextureToTexture (
674
+ { texture : testTexture , origin : { x : 0 , y : 0 , z : 0 } } ,
675
+ { texture : testTexture , origin : { x : 0 , y : 0 , z : 0 } } ,
676
+ { width, height, depthOrArrayLayers } ,
677
+ 'FinishError'
678
+ ) ;
679
+ } ) ;
680
+
648
681
g . test ( 'copy_within_same_texture' )
649
682
. desc (
650
683
`
651
- Test that it is an error to use copyTextureToTexture from one subresource to itself.
684
+ Test that it is an error to use copyTextureToTexture from one subresource of a 2D texture to itself.
652
685
- for various starting source/destination array layers.
653
686
- 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.`
687
+ - for various source/destination mip levels.`
657
688
)
658
689
. paramsSubcasesOnly ( u =>
659
690
u //
660
691
. combine ( 'srcCopyOriginZ' , [ 0 , 2 , 4 ] )
661
692
. combine ( 'dstCopyOriginZ' , [ 0 , 2 , 4 ] )
662
693
. combine ( 'copyExtentDepth' , [ 1 , 2 , 3 ] )
694
+ . combine ( 'srcCopyMipLevel' , [ 0 , 1 ] )
695
+ . combine ( 'dstCopyMipLevel' , [ 0 , 1 ] )
663
696
)
664
697
. fn ( t => {
665
- const { srcCopyOriginZ, dstCopyOriginZ, copyExtentDepth } = t . params ;
698
+ const { srcCopyOriginZ, dstCopyOriginZ, copyExtentDepth, srcCopyMipLevel, dstCopyMipLevel } =
699
+ t . params ;
700
+
701
+ const textureDim = 16 ;
702
+ const copyDim = srcCopyMipLevel === 1 || dstCopyMipLevel === 1 ? 8 : 16 ;
666
703
667
704
const kArrayLayerCount = 7 ;
705
+ const kMipLevelCount = 2 ;
668
706
669
707
const testTexture = t . createTextureTracked ( {
670
- size : { width : 16 , height : 16 , depthOrArrayLayers : kArrayLayerCount } ,
708
+ size : { width : textureDim , height : textureDim , depthOrArrayLayers : kArrayLayerCount } ,
709
+ mipLevelCount : kMipLevelCount ,
671
710
format : 'rgba8unorm' ,
672
711
usage : GPUTextureUsage . COPY_SRC | GPUTextureUsage . COPY_DST ,
673
712
} ) ;
674
713
675
- const isSuccess =
714
+ const layersDisjoint =
676
715
Math . min ( srcCopyOriginZ , dstCopyOriginZ ) + copyExtentDepth <=
677
716
Math . max ( srcCopyOriginZ , dstCopyOriginZ ) ;
717
+ const differentMipLevel = srcCopyMipLevel !== dstCopyMipLevel ;
718
+ const isSuccess = layersDisjoint || differentMipLevel ;
719
+
678
720
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 } ,
721
+ {
722
+ texture : testTexture ,
723
+ origin : { x : 0 , y : 0 , z : srcCopyOriginZ } ,
724
+ mipLevel : srcCopyMipLevel ,
725
+ } ,
726
+ {
727
+ texture : testTexture ,
728
+ origin : { x : 0 , y : 0 , z : dstCopyOriginZ } ,
729
+ mipLevel : dstCopyMipLevel ,
730
+ } ,
731
+ { width : copyDim , height : copyDim , depthOrArrayLayers : copyExtentDepth } ,
682
732
isSuccess ? 'Success' : 'FinishError'
683
733
) ;
684
734
} ) ;
0 commit comments