@@ -5,19 +5,21 @@ copyTextureToTexture tests.
5
5
import { makeTestGroup } from '../../../../../common/framework/test_group.js' ;
6
6
import { kTextureUsages , kTextureDimensions } from '../../../../capability_info.js' ;
7
7
import {
8
- kTextureFormatInfo ,
9
8
kAllTextureFormats ,
10
9
kCompressedTextureFormats ,
11
10
kDepthStencilFormats ,
12
- kFeaturesForFormats ,
13
- filterFormatsByFeature ,
14
11
textureDimensionAndFormatCompatible ,
12
+ getBlockInfoForTextureFormat ,
13
+ getBaseFormatForTextureFormat ,
14
+ canCopyFromAllAspectsOfTextureFormat ,
15
+ canCopyToAllAspectsOfTextureFormat ,
16
+ ColorTextureFormat ,
15
17
} from '../../../../format_info.js' ;
16
18
import { kResourceStates } from '../../../../gpu_test.js' ;
17
19
import { align , lcm } from '../../../../util/math.js' ;
18
- import { ValidationTest } from '../../validation_test.js' ;
20
+ import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js' ;
19
21
20
- class F extends ValidationTest {
22
+ class F extends AllFeaturesMaxLimitsValidationTest {
21
23
TestCopyTextureToTexture (
22
24
source : GPUTexelCopyTextureInfo ,
23
25
destination : GPUTexelCopyTextureInfo ,
@@ -45,13 +47,11 @@ class F extends ValidationTest {
45
47
format : GPUTextureFormat ,
46
48
mipLevel : number
47
49
) : Required < GPUExtent3DDict > {
50
+ const { blockWidth, blockHeight } = getBlockInfoForTextureFormat ( format ) ;
48
51
const virtualWidthAtLevel = Math . max ( textureSize . width >> mipLevel , 1 ) ;
49
52
const virtualHeightAtLevel = Math . max ( textureSize . height >> mipLevel , 1 ) ;
50
- const physicalWidthAtLevel = align ( virtualWidthAtLevel , kTextureFormatInfo [ format ] . blockWidth ) ;
51
- const physicalHeightAtLevel = align (
52
- virtualHeightAtLevel ,
53
- kTextureFormatInfo [ format ] . blockHeight
54
- ) ;
53
+ const physicalWidthAtLevel = align ( virtualWidthAtLevel , blockWidth ) ;
54
+ const physicalHeightAtLevel = align ( virtualHeightAtLevel , blockHeight ) ;
55
55
56
56
switch ( dimension ) {
57
57
case '1d' :
@@ -118,9 +118,7 @@ g.test('texture,device_mismatch')
118
118
{ srcMismatched : true , dstMismatched : false } ,
119
119
{ srcMismatched : false , dstMismatched : true } ,
120
120
] as const )
121
- . beforeAllSubcases ( t => {
122
- t . selectMismatchedDeviceOrSkipTestCase ( undefined ) ;
123
- } )
121
+ . beforeAllSubcases ( t => t . usesMismatchedDevice ( ) )
124
122
. fn ( t => {
125
123
const { srcMismatched, dstMismatched } = t . params ;
126
124
@@ -358,28 +356,26 @@ Test the formats of textures in copyTextureToTexture must be copy-compatible.
358
356
)
359
357
. params ( u =>
360
358
u
361
- . combine ( 'srcFormatFeature' , kFeaturesForFormats )
362
- . combine ( 'dstFormatFeature' , kFeaturesForFormats )
363
- . beginSubcases ( )
364
- . expand ( 'srcFormat' , ( { srcFormatFeature } ) =>
365
- filterFormatsByFeature ( srcFormatFeature , kAllTextureFormats )
366
- )
367
- . expand ( 'dstFormat' , ( { dstFormatFeature } ) =>
368
- filterFormatsByFeature ( dstFormatFeature , kAllTextureFormats )
369
- )
359
+ . combine ( 'srcFormat' , kAllTextureFormats )
360
+ . filter ( t => canCopyFromAllAspectsOfTextureFormat ( t . srcFormat ) )
361
+ . combine ( 'dstFormat' , kAllTextureFormats )
362
+ . filter ( t => canCopyToAllAspectsOfTextureFormat ( t . dstFormat ) )
363
+ . filter ( t => {
364
+ const srcInfo = getBlockInfoForTextureFormat ( t . srcFormat ) ;
365
+ const dstInfo = getBlockInfoForTextureFormat ( t . dstFormat ) ;
366
+ return (
367
+ srcInfo . blockWidth === dstInfo . blockWidth && srcInfo . blockHeight === dstInfo . blockHeight
368
+ ) ;
369
+ } )
370
370
)
371
- . beforeAllSubcases ( t => {
372
- const { srcFormatFeature, dstFormatFeature } = t . params ;
373
- t . selectDeviceOrSkipTestCase ( [ srcFormatFeature , dstFormatFeature ] ) ;
374
- } )
375
371
. fn ( t => {
376
372
const { srcFormat, dstFormat } = t . params ;
377
373
378
- t . skipIfTextureFormatNotSupportedDeprecated ( srcFormat , dstFormat ) ;
379
- t . skipIfCopyTextureToTextureNotSupportedForFormatDeprecated ( srcFormat , dstFormat ) ;
374
+ t . skipIfTextureFormatNotSupported ( srcFormat , dstFormat ) ;
375
+ t . skipIfCopyTextureToTextureNotSupportedForFormat ( srcFormat , dstFormat ) ;
380
376
381
- const srcFormatInfo = kTextureFormatInfo [ srcFormat ] ;
382
- const dstFormatInfo = kTextureFormatInfo [ dstFormat ] ;
377
+ const srcFormatInfo = getBlockInfoForTextureFormat ( srcFormat ) ;
378
+ const dstFormatInfo = getBlockInfoForTextureFormat ( dstFormat ) ;
383
379
384
380
const textureSize = {
385
381
width : lcm ( srcFormatInfo . blockWidth , dstFormatInfo . blockWidth ) ,
@@ -400,8 +396,10 @@ Test the formats of textures in copyTextureToTexture must be copy-compatible.
400
396
} ) ;
401
397
402
398
// Allow copy between compatible format textures.
403
- const srcBaseFormat = kTextureFormatInfo [ srcFormat ] . baseFormat ?? srcFormat ;
404
- const dstBaseFormat = kTextureFormatInfo [ dstFormat ] . baseFormat ?? dstFormat ;
399
+ const srcBaseFormat =
400
+ getBaseFormatForTextureFormat ( srcFormat as ColorTextureFormat ) ?? srcFormat ;
401
+ const dstBaseFormat =
402
+ getBaseFormatForTextureFormat ( dstFormat as ColorTextureFormat ) ?? dstFormat ;
405
403
const isSuccess = srcBaseFormat === dstBaseFormat ;
406
404
407
405
t . TestCopyTextureToTexture (
@@ -448,13 +446,10 @@ Note: this is only tested for 2D textures as it is the only dimension compatible
448
446
. combine ( 'srcCopyLevel' , [ 1 , 2 ] )
449
447
. combine ( 'dstCopyLevel' , [ 0 , 1 ] )
450
448
)
451
- . beforeAllSubcases ( t => {
452
- const { format } = t . params ;
453
- t . selectDeviceOrSkipTestCase ( kTextureFormatInfo [ format ] . feature ) ;
454
- } )
455
449
. fn ( t => {
456
450
const { format, copyBoxOffsets, srcTextureSize, dstTextureSize, srcCopyLevel, dstCopyLevel } =
457
451
t . params ;
452
+ t . skipIfTextureFormatNotSupported ( format ) ;
458
453
const kMipLevelCount = 3 ;
459
454
460
455
const srcTexture = t . createTextureTracked ( {
@@ -704,12 +699,9 @@ Test the validations on the member 'aspect' of GPUTexelCopyTextureInfo in CopyTe
704
699
. combine ( 'sourceAspect' , [ 'all' , 'depth-only' , 'stencil-only' ] as const )
705
700
. combine ( 'destinationAspect' , [ 'all' , 'depth-only' , 'stencil-only' ] as const )
706
701
)
707
- . beforeAllSubcases ( t => {
708
- const { format } = t . params ;
709
- t . selectDeviceOrSkipTestCase ( kTextureFormatInfo [ format ] . feature ) ;
710
- } )
711
702
. fn ( t => {
712
703
const { format, sourceAspect, destinationAspect } = t . params ;
704
+ t . skipIfTextureFormatNotSupported ( format ) ;
713
705
714
706
const kTextureSize = { width : 16 , height : 8 , depthOrArrayLayers : 1 } ;
715
707
@@ -783,14 +775,13 @@ TODO: Express the offsets in "block size" so as to be able to test non-4x4 compr
783
775
. combine ( 'srcCopyLevel' , [ 0 , 1 , 2 ] )
784
776
. combine ( 'dstCopyLevel' , [ 0 , 1 , 2 ] )
785
777
)
786
- . beforeAllSubcases ( t => {
787
- const { format } = t . params ;
788
- t . selectDeviceOrSkipTestCase ( kTextureFormatInfo [ format ] . feature ) ;
789
- t . skipIfCopyTextureToTextureNotSupportedForFormat ( format ) ;
790
- } )
791
778
. fn ( t => {
792
779
const { format, dimension, copyBoxOffsets, srcCopyLevel, dstCopyLevel } = t . params ;
793
- const { blockWidth, blockHeight } = kTextureFormatInfo [ format ] ;
780
+
781
+ t . skipIfTextureFormatNotSupported ( format ) ;
782
+ t . skipIfCopyTextureToTextureNotSupportedForFormat ( format ) ;
783
+
784
+ const { blockWidth, blockHeight } = getBlockInfoForTextureFormat ( format ) ;
794
785
795
786
const kTextureSize = {
796
787
width : 15 * blockWidth ,
@@ -840,14 +831,11 @@ TODO: Express the offsets in "block size" so as to be able to test non-4x4 compr
840
831
const copyDepth =
841
832
kTextureSize . depthOrArrayLayers + copyBoxOffsets . depthOrArrayLayers - copyOrigin . z ;
842
833
843
- const texelBlockWidth = kTextureFormatInfo [ format ] . blockWidth ;
844
- const texelBlockHeight = kTextureFormatInfo [ format ] . blockHeight ;
845
-
846
834
const isSuccessForCompressedFormats =
847
- copyOrigin . x % texelBlockWidth === 0 &&
848
- copyOrigin . y % texelBlockHeight === 0 &&
849
- copyWidth % texelBlockWidth === 0 &&
850
- copyHeight % texelBlockHeight === 0 ;
835
+ copyOrigin . x % blockWidth === 0 &&
836
+ copyOrigin . y % blockHeight === 0 &&
837
+ copyWidth % blockWidth === 0 &&
838
+ copyHeight % blockHeight === 0 ;
851
839
852
840
{
853
841
const isSuccess =
0 commit comments