@@ -8,20 +8,23 @@ import {
8
8
kTextureDimensions ,
9
9
} from '../../../capability_info.js' ;
10
10
import {
11
- kTextureFormatInfo ,
12
- kRegularTextureFormats ,
13
- kCompressedTextureFormats ,
14
- kDepthStencilFormats ,
15
- textureDimensionAndFormatCompatible ,
16
- depthStencilFormatAspectSize ,
17
- DepthStencilFormat ,
18
11
ColorTextureFormat ,
12
+ DepthStencilFormat ,
13
+ depthStencilFormatAspectSize ,
14
+ getBaseFormatForTextureFormat ,
15
+ getBlockInfoForColorTextureFormat ,
19
16
isCompressedTextureFormat ,
20
- viewCompatibleDeprecated ,
21
- RegularTextureFormat ,
17
+ isDepthTextureFormat ,
22
18
isRegularTextureFormat ,
19
+ isStencilTextureFormat ,
20
+ kCompressedTextureFormats ,
21
+ kDepthStencilFormats ,
22
+ kRegularTextureFormats ,
23
+ RegularTextureFormat ,
24
+ textureDimensionAndFormatCompatible ,
25
+ textureFormatsAreViewCompatible ,
23
26
} from '../../../format_info.js' ;
24
- import { GPUTest , TextureTestMixin } from '../../../gpu_test.js' ;
27
+ import { AllFeaturesMaxLimitsGPUTest , TextureTestMixin } from '../../../gpu_test.js' ;
25
28
import { checkElementsEqual } from '../../../util/check_contents.js' ;
26
29
import { align } from '../../../util/math.js' ;
27
30
import { physicalMipSize } from '../../../util/texture/base.js' ;
@@ -32,20 +35,17 @@ import { findFailedPixels } from '../../../util/texture/texture_ok.js';
32
35
33
36
const dataGenerator = new DataArrayGenerator ( ) ;
34
37
35
- class F extends TextureTestMixin ( GPUTest ) {
38
+ class F extends TextureTestMixin ( AllFeaturesMaxLimitsGPUTest ) {
36
39
GetInitialDataPerMipLevel (
37
40
dimension : GPUTextureDimension ,
38
41
textureSize : Required < GPUExtent3DDict > ,
39
42
format : ColorTextureFormat ,
40
43
mipLevel : number
41
44
) : Uint8Array {
42
45
const textureSizeAtLevel = physicalMipSize ( textureSize , format , dimension , mipLevel ) ;
43
- const bytesPerBlock = kTextureFormatInfo [ format ] . color . bytes ;
44
- const blockWidthInTexel = kTextureFormatInfo [ format ] . blockWidth ;
45
- const blockHeightInTexel = kTextureFormatInfo [ format ] . blockHeight ;
46
+ const { bytesPerBlock, blockWidth, blockHeight } = getBlockInfoForColorTextureFormat ( format ) ;
46
47
const blocksPerSubresource =
47
- ( textureSizeAtLevel . width / blockWidthInTexel ) *
48
- ( textureSizeAtLevel . height / blockHeightInTexel ) ;
48
+ ( textureSizeAtLevel . width / blockWidth ) * ( textureSizeAtLevel . height / blockHeight ) ;
49
49
50
50
const byteSize = bytesPerBlock * blocksPerSubresource * textureSizeAtLevel . depthOrArrayLayers ;
51
51
return dataGenerator . generateView ( byteSize ) ;
@@ -121,9 +121,7 @@ class F extends TextureTestMixin(GPUTest) {
121
121
dimension ,
122
122
srcCopyLevel
123
123
) ;
124
- const bytesPerBlock = kTextureFormatInfo [ srcFormat ] . color . bytes ;
125
- const blockWidth = kTextureFormatInfo [ srcFormat ] . blockWidth ;
126
- const blockHeight = kTextureFormatInfo [ srcFormat ] . blockHeight ;
124
+ const { bytesPerBlock, blockWidth, blockHeight } = getBlockInfoForColorTextureFormat ( srcFormat ) ;
127
125
const srcBlocksPerRow = srcTextureSizeAtLevel . width / blockWidth ;
128
126
const srcBlockRowsPerImage = srcTextureSizeAtLevel . height / blockHeight ;
129
127
this . device . queue . writeTexture (
@@ -208,7 +206,7 @@ class F extends TextureTestMixin(GPUTest) {
208
206
align ( dstBlocksPerRow * bytesPerBlock , 4 ) ;
209
207
210
208
if ( isCompressedTextureFormat ( dstTexture . format ) && this . isCompatibility ) {
211
- assert ( viewCompatibleDeprecated ( this . isCompatibility , srcFormat , dstFormat ) ) ;
209
+ assert ( textureFormatsAreViewCompatible ( this . device , srcFormat , dstFormat ) ) ;
212
210
// compare by rendering. We need the expected texture to match
213
211
// the dstTexture so we'll create a texture where we supply
214
212
// all of the data in JavaScript.
@@ -576,7 +574,7 @@ class F extends TextureTestMixin(GPUTest) {
576
574
} ) ;
577
575
const bindGroup = this . GetBindGroupForT2TCopyWithDepthTests ( bindGroupLayout , copySize [ 2 ] ) ;
578
576
579
- const hasStencil = kTextureFormatInfo [ sourceTexture . format ] . stencil ;
577
+ const hasStencil = isStencilTextureFormat ( sourceTexture . format ) ;
580
578
const encoder = this . device . createCommandEncoder ( ) ;
581
579
for ( let srcCopyLayer = 0 ; srcCopyLayer < copySize [ 2 ] ; ++ srcCopyLayer ) {
582
580
const renderPass = encoder . beginRenderPass ( {
@@ -625,7 +623,7 @@ class F extends TextureTestMixin(GPUTest) {
625
623
size : copySize ,
626
624
usage : GPUTextureUsage . RENDER_ATTACHMENT | GPUTextureUsage . COPY_SRC ,
627
625
} ) ;
628
- const hasStencil = kTextureFormatInfo [ destinationTexture . format ] . stencil ;
626
+ const hasStencil = isStencilTextureFormat ( destinationTexture . format ) ;
629
627
const encoder = this . device . createCommandEncoder ( ) ;
630
628
for ( let dstCopyLayer = 0 ; dstCopyLayer < copySize [ 2 ] ; ++ dstCopyLayer ) {
631
629
// If the depth value is not expected, the color of outputColorTexture will remain Red after
@@ -790,8 +788,8 @@ g.test('color_textures,non_compressed,non_array')
790
788
. combine ( 'srcFormat' , kRegularTextureFormats )
791
789
. combine ( 'dstFormat' , kRegularTextureFormats )
792
790
. filter ( ( { srcFormat, dstFormat } ) => {
793
- const srcBaseFormat = kTextureFormatInfo [ srcFormat ] . baseFormat ;
794
- const dstBaseFormat = kTextureFormatInfo [ dstFormat ] . baseFormat ;
791
+ const srcBaseFormat = getBaseFormatForTextureFormat ( srcFormat ) ;
792
+ const dstBaseFormat = getBaseFormatForTextureFormat ( dstFormat ) ;
795
793
return (
796
794
srcFormat === dstFormat ||
797
795
( srcBaseFormat !== undefined &&
@@ -885,8 +883,8 @@ g.test('color_textures,compressed,non_array')
885
883
. combine ( 'srcFormat' , kCompressedTextureFormats )
886
884
. combine ( 'dstFormat' , kCompressedTextureFormats )
887
885
. filter ( ( { srcFormat, dstFormat } ) => {
888
- const srcBaseFormat = kTextureFormatInfo [ srcFormat ] . baseFormat ;
889
- const dstBaseFormat = kTextureFormatInfo [ dstFormat ] . baseFormat ;
886
+ const srcBaseFormat = getBaseFormatForTextureFormat ( srcFormat ) ;
887
+ const dstBaseFormat = getBaseFormatForTextureFormat ( dstFormat ) ;
890
888
return (
891
889
srcFormat === dstFormat ||
892
890
( srcBaseFormat !== undefined &&
@@ -924,10 +922,6 @@ g.test('color_textures,compressed,non_array')
924
922
. beforeAllSubcases ( t => {
925
923
const { srcFormat, dstFormat } = t . params ;
926
924
t . skipIfCopyTextureToTextureNotSupportedForFormat ( srcFormat , dstFormat ) ;
927
- t . selectDeviceOrSkipTestCase ( [
928
- kTextureFormatInfo [ srcFormat ] . feature ,
929
- kTextureFormatInfo [ dstFormat ] . feature ,
930
- ] ) ;
931
925
} )
932
926
. fn ( t => {
933
927
const {
@@ -939,10 +933,10 @@ g.test('color_textures,compressed,non_array')
939
933
srcCopyLevel,
940
934
dstCopyLevel,
941
935
} = t . params ;
942
- const srcBlockWidth = kTextureFormatInfo [ srcFormat ] . blockWidth ;
943
- const srcBlockHeight = kTextureFormatInfo [ srcFormat ] . blockHeight ;
944
- const dstBlockWidth = kTextureFormatInfo [ dstFormat ] . blockWidth ;
945
- const dstBlockHeight = kTextureFormatInfo [ dstFormat ] . blockHeight ;
936
+ const { blockWidth : srcBlockWidth , blockHeight : srcBlockHeight } =
937
+ getBlockInfoForColorTextureFormat ( srcFormat ) ;
938
+ const { blockWidth : dstBlockWidth , blockHeight : dstBlockHeight } =
939
+ getBlockInfoForColorTextureFormat ( dstFormat ) ;
946
940
947
941
t . DoCopyTextureToTextureTest (
948
942
dimension ,
@@ -977,8 +971,8 @@ g.test('color_textures,non_compressed,array')
977
971
. combine ( 'srcFormat' , kRegularTextureFormats )
978
972
. combine ( 'dstFormat' , kRegularTextureFormats )
979
973
. filter ( ( { srcFormat, dstFormat } ) => {
980
- const srcBaseFormat = kTextureFormatInfo [ srcFormat ] . baseFormat ;
981
- const dstBaseFormat = kTextureFormatInfo [ dstFormat ] . baseFormat ;
974
+ const srcBaseFormat = getBaseFormatForTextureFormat ( srcFormat ) ;
975
+ const dstBaseFormat = getBaseFormatForTextureFormat ( dstFormat ) ;
982
976
return (
983
977
srcFormat === dstFormat ||
984
978
( srcBaseFormat !== undefined &&
@@ -1050,8 +1044,8 @@ g.test('color_textures,compressed,array')
1050
1044
. combine ( 'srcFormat' , kCompressedTextureFormats )
1051
1045
. combine ( 'dstFormat' , kCompressedTextureFormats )
1052
1046
. filter ( ( { srcFormat, dstFormat } ) => {
1053
- const srcBaseFormat = kTextureFormatInfo [ srcFormat ] . baseFormat ;
1054
- const dstBaseFormat = kTextureFormatInfo [ dstFormat ] . baseFormat ;
1047
+ const srcBaseFormat = getBaseFormatForTextureFormat ( srcFormat ) ;
1048
+ const dstBaseFormat = getBaseFormatForTextureFormat ( dstFormat ) ;
1055
1049
return (
1056
1050
srcFormat === dstFormat ||
1057
1051
( srcBaseFormat !== undefined &&
@@ -1079,10 +1073,6 @@ g.test('color_textures,compressed,array')
1079
1073
. beforeAllSubcases ( t => {
1080
1074
const { srcFormat, dstFormat } = t . params ;
1081
1075
t . skipIfCopyTextureToTextureNotSupportedForFormat ( srcFormat , dstFormat ) ;
1082
- t . selectDeviceOrSkipTestCase ( [
1083
- kTextureFormatInfo [ srcFormat ] . feature ,
1084
- kTextureFormatInfo [ dstFormat ] . feature ,
1085
- ] ) ;
1086
1076
} )
1087
1077
. fn ( t => {
1088
1078
const {
@@ -1094,10 +1084,12 @@ g.test('color_textures,compressed,array')
1094
1084
srcCopyLevel,
1095
1085
dstCopyLevel,
1096
1086
} = t . params ;
1097
- const srcBlockWidth = kTextureFormatInfo [ srcFormat ] . blockWidth ;
1098
- const srcBlockHeight = kTextureFormatInfo [ srcFormat ] . blockHeight ;
1099
- const dstBlockWidth = kTextureFormatInfo [ dstFormat ] . blockWidth ;
1100
- const dstBlockHeight = kTextureFormatInfo [ dstFormat ] . blockHeight ;
1087
+ t . skipIfTextureFormatNotSupported ( srcFormat , dstFormat ) ;
1088
+
1089
+ const { blockWidth : srcBlockWidth , blockHeight : srcBlockHeight } =
1090
+ getBlockInfoForColorTextureFormat ( srcFormat ) ;
1091
+ const { blockWidth : dstBlockWidth , blockHeight : dstBlockHeight } =
1092
+ getBlockInfoForColorTextureFormat ( dstFormat ) ;
1101
1093
1102
1094
t . DoCopyTextureToTextureTest (
1103
1095
dimension ,
@@ -1260,10 +1252,6 @@ g.test('copy_depth_stencil')
1260
1252
) ;
1261
1253
} )
1262
1254
)
1263
- . beforeAllSubcases ( t => {
1264
- const { format } = t . params ;
1265
- t . selectDeviceForTextureFormatOrSkipTestCase ( format ) ;
1266
- } )
1267
1255
. fn ( t => {
1268
1256
const {
1269
1257
format,
@@ -1273,6 +1261,7 @@ g.test('copy_depth_stencil')
1273
1261
srcCopyBaseArrayLayer,
1274
1262
dstCopyBaseArrayLayer,
1275
1263
} = t . params ;
1264
+ t . skipIfTextureFormatNotSupported ( format ) ;
1276
1265
1277
1266
const copySize : [ number , number , number ] = [
1278
1267
srcTextureSize . width >> srcCopyLevel ,
@@ -1299,7 +1288,7 @@ g.test('copy_depth_stencil')
1299
1288
} ) ;
1300
1289
1301
1290
let initialStencilData : undefined | Uint8Array = undefined ;
1302
- if ( kTextureFormatInfo [ format ] . stencil ) {
1291
+ if ( isStencilTextureFormat ( format ) ) {
1303
1292
initialStencilData = t . GetInitialStencilDataPerMipLevel ( srcTextureSize , format , srcCopyLevel ) ;
1304
1293
t . InitializeStencilAspect (
1305
1294
sourceTexture ,
@@ -1309,7 +1298,7 @@ g.test('copy_depth_stencil')
1309
1298
copySize
1310
1299
) ;
1311
1300
}
1312
- if ( kTextureFormatInfo [ format ] . depth ) {
1301
+ if ( isDepthTextureFormat ( format ) ) {
1313
1302
t . InitializeDepthAspect ( sourceTexture , format , srcCopyLevel , srcCopyBaseArrayLayer , copySize ) ;
1314
1303
}
1315
1304
@@ -1329,7 +1318,7 @@ g.test('copy_depth_stencil')
1329
1318
) ;
1330
1319
t . queue . submit ( [ encoder . finish ( ) ] ) ;
1331
1320
1332
- if ( kTextureFormatInfo [ format ] . stencil ) {
1321
+ if ( isStencilTextureFormat ( format ) ) {
1333
1322
assert ( initialStencilData !== undefined ) ;
1334
1323
t . VerifyStencilAspect (
1335
1324
destinationTexture ,
@@ -1339,7 +1328,7 @@ g.test('copy_depth_stencil')
1339
1328
copySize
1340
1329
) ;
1341
1330
}
1342
- if ( kTextureFormatInfo [ format ] . depth ) {
1331
+ if ( isDepthTextureFormat ( format ) ) {
1343
1332
t . VerifyDepthAspect (
1344
1333
destinationTexture ,
1345
1334
format ,
@@ -1552,22 +1541,25 @@ g.test('copy_multisampled_depth')
1552
1541
texture can only be 1.
1553
1542
`
1554
1543
)
1544
+ . params ( u =>
1545
+ u . combine ( 'format' , kDepthStencilFormats ) . filter ( t => isDepthTextureFormat ( t . format ) )
1546
+ )
1555
1547
. beforeAllSubcases ( t => {
1556
1548
t . skipIf ( t . isCompatibility , 'multisample textures are not copyable in compatibility mode' ) ;
1557
1549
} )
1558
1550
. fn ( t => {
1551
+ const { format } = t . params ;
1559
1552
const textureSize = [ 32 , 16 , 1 ] as const ;
1560
- const kDepthFormat = 'depth24plus' ;
1561
1553
const kSampleCount = 4 ;
1562
1554
1563
1555
const sourceTexture = t . createTextureTracked ( {
1564
- format : kDepthFormat ,
1556
+ format,
1565
1557
size : textureSize ,
1566
1558
usage : GPUTextureUsage . COPY_SRC | GPUTextureUsage . RENDER_ATTACHMENT ,
1567
1559
sampleCount : kSampleCount ,
1568
1560
} ) ;
1569
1561
const destinationTexture = t . createTextureTracked ( {
1570
- format : kDepthFormat ,
1562
+ format,
1571
1563
size : textureSize ,
1572
1564
usage : GPUTextureUsage . COPY_DST | GPUTextureUsage . RENDER_ATTACHMENT ,
1573
1565
sampleCount : kSampleCount ,
@@ -1596,7 +1588,7 @@ g.test('copy_multisampled_depth')
1596
1588
layout : 'auto' ,
1597
1589
vertex : vertexState ,
1598
1590
depthStencil : {
1599
- format : kDepthFormat ,
1591
+ format,
1600
1592
depthCompare : 'always' ,
1601
1593
depthWriteEnabled : true ,
1602
1594
} ,
@@ -1613,6 +1605,10 @@ g.test('copy_multisampled_depth')
1613
1605
depthClearValue : 0.0 ,
1614
1606
depthLoadOp : 'clear' ,
1615
1607
depthStoreOp : 'store' ,
1608
+ ...( isStencilTextureFormat ( format ) && {
1609
+ stencilLoadOp : 'clear' ,
1610
+ stencilStoreOp : 'store' ,
1611
+ } ) ,
1616
1612
} ,
1617
1613
} ) ;
1618
1614
renderPassForInit . setPipeline ( renderPipelineForInit ) ;
@@ -1651,7 +1647,7 @@ g.test('copy_multisampled_depth')
1651
1647
targets : [ { format : kColorFormat } ] ,
1652
1648
} ,
1653
1649
depthStencil : {
1654
- format : kDepthFormat ,
1650
+ format,
1655
1651
depthCompare : 'equal' ,
1656
1652
depthWriteEnabled : false ,
1657
1653
} ,
@@ -1686,6 +1682,10 @@ g.test('copy_multisampled_depth')
1686
1682
view : destinationTexture . createView ( ) ,
1687
1683
depthLoadOp : 'load' ,
1688
1684
depthStoreOp : 'store' ,
1685
+ ...( isStencilTextureFormat ( format ) && {
1686
+ stencilLoadOp : 'clear' ,
1687
+ stencilStoreOp : 'store' ,
1688
+ } ) ,
1689
1689
} ,
1690
1690
} ) ;
1691
1691
renderPassForVerify . setPipeline ( renderPipelineForVerify ) ;
@@ -1698,3 +1698,11 @@ g.test('copy_multisampled_depth')
1698
1698
exp : { R : 0.0 , G : 1.0 , B : 0.0 , A : 1.0 } ,
1699
1699
} ) ;
1700
1700
} ) ;
1701
+
1702
+ g . test ( 'copy_multisampled_stencil' )
1703
+ . desc (
1704
+ `
1705
+ Validate the correctness of copyTextureToTexture() with multisampled stencil formats.
1706
+ `
1707
+ )
1708
+ . unimplemented ( ) ;
0 commit comments