@@ -645,40 +645,90 @@ 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 (
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+
648681g . test ( 'copy_within_same_texture' )
649682 . desc (
650683 `
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.
652685- for various starting source/destination array layers.
653686- 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.`
657688 )
658689 . paramsSubcasesOnly ( u =>
659690 u //
660691 . combine ( 'srcCopyOriginZ' , [ 0 , 2 , 4 ] )
661692 . combine ( 'dstCopyOriginZ' , [ 0 , 2 , 4 ] )
662693 . combine ( 'copyExtentDepth' , [ 1 , 2 , 3 ] )
694+ . combine ( 'srcCopyMipLevel' , [ 0 , 1 ] )
695+ . combine ( 'dstCopyMipLevel' , [ 0 , 1 ] )
663696 )
664697 . 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 ;
666703
667704 const kArrayLayerCount = 7 ;
705+ const kMipLevelCount = 2 ;
668706
669707 const testTexture = t . createTextureTracked ( {
670- size : { width : 16 , height : 16 , depthOrArrayLayers : kArrayLayerCount } ,
708+ size : { width : textureDim , height : textureDim , depthOrArrayLayers : kArrayLayerCount } ,
709+ mipLevelCount : kMipLevelCount ,
671710 format : 'rgba8unorm' ,
672711 usage : GPUTextureUsage . COPY_SRC | GPUTextureUsage . COPY_DST ,
673712 } ) ;
674713
675- const isSuccess =
714+ const layersDisjoint =
676715 Math . min ( srcCopyOriginZ , dstCopyOriginZ ) + copyExtentDepth <=
677716 Math . max ( srcCopyOriginZ , dstCopyOriginZ ) ;
717+ const differentMipLevel = srcCopyMipLevel !== dstCopyMipLevel ;
718+ const isSuccess = layersDisjoint || differentMipLevel ;
719+
678720 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 } ,
682732 isSuccess ? 'Success' : 'FinishError'
683733 ) ;
684734 } ) ;
0 commit comments