@@ -48,7 +48,6 @@ import {
48
48
kTextureDimensions ,
49
49
} from '../../../capability_info.js' ;
50
50
import {
51
- kTextureFormatInfo ,
52
51
kDepthStencilFormats ,
53
52
kColorTextureFormats ,
54
53
depthStencilBufferTextureCopySupported ,
@@ -58,8 +57,14 @@ import {
58
57
ColorTextureFormat ,
59
58
RegularTextureFormat ,
60
59
isCompressedTextureFormat ,
60
+ isDepthTextureFormat ,
61
+ isStencilTextureFormat ,
62
+ getBlockInfoForTextureFormat ,
63
+ getBlockInfoForColorTextureFormat ,
64
+ canCopyToAllAspectsOfTextureFormat ,
65
+ canCopyFromAllAspectsOfTextureFormat ,
61
66
} from '../../../format_info.js' ;
62
- import { GPUTest , TextureTestMixin } from '../../../gpu_test.js' ;
67
+ import { AllFeaturesMaxLimitsGPUTest , TextureTestMixin } from '../../../gpu_test.js' ;
63
68
import { checkElementsEqual } from '../../../util/check_contents.js' ;
64
69
import { align } from '../../../util/math.js' ;
65
70
import { physicalMipSizeFromTexture } from '../../../util/texture/base.js' ;
@@ -124,7 +129,7 @@ const kMethodsToTest = [
124
129
const dataGenerator = new DataArrayGenerator ( ) ;
125
130
const altDataGenerator = new DataArrayGenerator ( ) ;
126
131
127
- class ImageCopyTest extends TextureTestMixin ( GPUTest ) {
132
+ class ImageCopyTest extends TextureTestMixin ( AllFeaturesMaxLimitsGPUTest ) {
128
133
/**
129
134
* This is used for testing passing undefined members of `GPUTexelCopyBufferLayout` instead of actual
130
135
* values where possible. Passing arguments as values and not as objects so that they are passed
@@ -1020,12 +1025,12 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
1020
1025
arrayLayerCount : 1 ,
1021
1026
} ) ,
1022
1027
} ;
1023
- if ( kTextureFormatInfo [ stencilTextureFormat ] . depth ) {
1028
+ if ( isDepthTextureFormat ( stencilTextureFormat ) ) {
1024
1029
depthStencilAttachment . depthClearValue = 0 ;
1025
1030
depthStencilAttachment . depthLoadOp = 'clear' ;
1026
1031
depthStencilAttachment . depthStoreOp = 'store' ;
1027
1032
}
1028
- if ( kTextureFormatInfo [ stencilTextureFormat ] . stencil ) {
1033
+ if ( isStencilTextureFormat ( stencilTextureFormat ) ) {
1029
1034
depthStencilAttachment . stencilLoadOp = 'load' ;
1030
1035
depthStencilAttachment . stencilStoreOp = 'store' ;
1031
1036
}
@@ -1102,7 +1107,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
1102
1107
copyMipLevel : number ,
1103
1108
initialData : Float32Array
1104
1109
) : void {
1105
- assert ( ! ! kTextureFormatInfo [ depthFormat ] . depth ) ;
1110
+ assert ( ! ! isDepthTextureFormat ( depthFormat ) ) ;
1106
1111
1107
1112
const inputTexture = this . createTextureTracked ( {
1108
1113
size : copySize ,
@@ -1177,12 +1182,12 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
1177
1182
mipLevelCount : 1 ,
1178
1183
} ) ,
1179
1184
} ;
1180
- if ( kTextureFormatInfo [ depthFormat ] . depth ) {
1185
+ if ( isDepthTextureFormat ( depthFormat ) ) {
1181
1186
depthStencilAttachment . depthClearValue = 0.0 ;
1182
1187
depthStencilAttachment . depthLoadOp = 'clear' ;
1183
1188
depthStencilAttachment . depthStoreOp = 'store' ;
1184
1189
}
1185
- if ( kTextureFormatInfo [ depthFormat ] . stencil ) {
1190
+ if ( isStencilTextureFormat ( depthFormat ) ) {
1186
1191
depthStencilAttachment . stencilLoadOp = 'load' ;
1187
1192
depthStencilAttachment . stencilStoreOp = 'store' ;
1188
1193
}
@@ -1343,7 +1348,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
1343
1348
* This is a helper function used for filtering test parameters
1344
1349
*/
1345
1350
function formatCanBeTested ( { format } : { format : ColorTextureFormat } ) : boolean {
1346
- return kTextureFormatInfo [ format ] . color . copyDst && kTextureFormatInfo [ format ] . color . copySrc ;
1351
+ return canCopyToAllAspectsOfTextureFormat ( format ) && canCopyFromAllAspectsOfTextureFormat ( format ) ;
1347
1352
}
1348
1353
1349
1354
export const g = makeTestGroup ( ImageCopyTest ) ;
@@ -1421,11 +1426,6 @@ bytes in copy works for every format.
1421
1426
return kRowsPerImageAndBytesPerRowParams . copySizes ;
1422
1427
} )
1423
1428
)
1424
- . beforeAllSubcases ( t => {
1425
- const info = kTextureFormatInfo [ t . params . format ] ;
1426
- t . skipIfTextureFormatNotSupportedDeprecated ( t . params . format ) ;
1427
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
1428
- } )
1429
1429
. fn ( t => {
1430
1430
const {
1431
1431
bytesPerRowPadding,
@@ -1438,7 +1438,8 @@ bytes in copy works for every format.
1438
1438
initMethod,
1439
1439
checkMethod,
1440
1440
} = t . params ;
1441
- const info = kTextureFormatInfo [ format ] ;
1441
+ t . skipIfTextureFormatNotSupported ( t . params . format ) ;
1442
+ const info = getBlockInfoForTextureFormat ( format ) ;
1442
1443
// For CopyB2T and CopyT2B we need to have bytesPerRow 256-aligned,
1443
1444
// to make this happen we align the bytesInACompleteRow value and multiply
1444
1445
// bytesPerRowPadding by 256.
@@ -1536,11 +1537,6 @@ works for every format with 2d and 2d-array textures.
1536
1537
. combine ( 'rowsPerImageEqualsCopyHeight' , [ true , false ] as const )
1537
1538
. unless ( p => p . dimension === '1d' && p . copyDepth !== 1 )
1538
1539
)
1539
- . beforeAllSubcases ( t => {
1540
- const info = kTextureFormatInfo [ t . params . format ] ;
1541
- t . skipIfTextureFormatNotSupportedDeprecated ( t . params . format ) ;
1542
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
1543
- } )
1544
1540
. fn ( t => {
1545
1541
const {
1546
1542
offsetInBlocks,
@@ -1553,6 +1549,7 @@ works for every format with 2d and 2d-array textures.
1553
1549
copyWidth,
1554
1550
rowsPerImageEqualsCopyHeight,
1555
1551
} = t . params ;
1552
+ t . skipIfTextureFormatNotSupported ( format ) ;
1556
1553
1557
1554
// Skip test cases designed for special cases coverage on compatibility mode to save run time.
1558
1555
if ( ! ( t . isCompatibility && ( format === 'r8snorm' || format === 'rg8snorm' ) ) ) {
@@ -1567,9 +1564,9 @@ works for every format with 2d and 2d-array textures.
1567
1564
}
1568
1565
}
1569
1566
1570
- const info = kTextureFormatInfo [ format ] ;
1567
+ const info = getBlockInfoForColorTextureFormat ( format ) ;
1571
1568
1572
- const offset = offsetInBlocks * info . color . bytes ;
1569
+ const offset = offsetInBlocks * info . bytesPerBlock ;
1573
1570
const copyHeight = 3 ;
1574
1571
const copySize = {
1575
1572
width : copyWidth * info . blockWidth ,
@@ -1578,7 +1575,7 @@ works for every format with 2d and 2d-array textures.
1578
1575
} ;
1579
1576
let textureHeight = 4 * info . blockHeight ;
1580
1577
let rowsPerImage = rowsPerImageEqualsCopyHeight ? copyHeight : copyHeight + 1 ;
1581
- const bytesPerRow = align ( copyWidth * info . color . bytes , 256 ) ;
1578
+ const bytesPerRow = align ( copyWidth * info . bytesPerBlock , 256 ) ;
1582
1579
1583
1580
if ( dimension === '1d' ) {
1584
1581
copySize . height = 1 ;
@@ -1634,11 +1631,6 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
1634
1631
. combine ( 'coordinateToTest' , [ 0 , 1 , 2 ] as const )
1635
1632
. unless ( p => p . dimension === '1d' && p . coordinateToTest !== 0 )
1636
1633
)
1637
- . beforeAllSubcases ( t => {
1638
- const info = kTextureFormatInfo [ t . params . format ] ;
1639
- t . skipIfTextureFormatNotSupportedDeprecated ( t . params . format ) ;
1640
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
1641
- } )
1642
1634
. fn ( t => {
1643
1635
const {
1644
1636
originValueInBlocks,
@@ -1649,7 +1641,8 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
1649
1641
initMethod,
1650
1642
checkMethod,
1651
1643
} = t . params ;
1652
- const info = kTextureFormatInfo [ format ] ;
1644
+ t . skipIfTextureFormatNotSupported ( format ) ;
1645
+ const info = getBlockInfoForColorTextureFormat ( format ) ;
1653
1646
1654
1647
let originBlocks = [ 1 , 1 , 1 ] ;
1655
1648
let copySizeBlocks = [ 2 , 2 , 2 ] ;
@@ -1685,7 +1678,7 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
1685
1678
] as const ;
1686
1679
1687
1680
const rowsPerImage = copySizeBlocks [ 1 ] ;
1688
- const bytesPerRow = align ( copySizeBlocks [ 0 ] * info . color . bytes , 256 ) ;
1681
+ const bytesPerRow = align ( copySizeBlocks [ 0 ] * info . bytesPerBlock , 256 ) ;
1689
1682
1690
1683
const dataSize = dataBytesForCopyOrFail ( {
1691
1684
layout : { offset : 0 , bytesPerRow, rowsPerImage } ,
@@ -1727,7 +1720,7 @@ function* generateTestTextureSizes({
1727
1720
_mipSizeInBlocks : Required < GPUExtent3DDict > ;
1728
1721
} ) : Generator < [ number , number , number ] > {
1729
1722
assert ( dimension !== '1d' ) ; // textureSize[1] would be wrong for 1D mipped textures.
1730
- const info = kTextureFormatInfo [ format ] ;
1723
+ const info = getBlockInfoForColorTextureFormat ( format ) ;
1731
1724
1732
1725
const widthAtThisLevel = _mipSizeInBlocks . width * info . blockWidth ;
1733
1726
const heightAtThisLevel = _mipSizeInBlocks . height * info . blockHeight ;
@@ -1834,11 +1827,6 @@ TODO: Make a variant for depth-stencil formats.
1834
1827
] )
1835
1828
. expand ( 'textureSize' , generateTestTextureSizes )
1836
1829
)
1837
- . beforeAllSubcases ( t => {
1838
- const info = kTextureFormatInfo [ t . params . format ] ;
1839
- t . skipIfTextureFormatNotSupportedDeprecated ( t . params . format ) ;
1840
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
1841
- } )
1842
1830
. fn ( t => {
1843
1831
const {
1844
1832
copySizeInBlocks,
@@ -1850,7 +1838,8 @@ TODO: Make a variant for depth-stencil formats.
1850
1838
initMethod,
1851
1839
checkMethod,
1852
1840
} = t . params ;
1853
- const info = kTextureFormatInfo [ format ] ;
1841
+ t . skipIfTextureFormatNotSupported ( format ) ;
1842
+ const info = getBlockInfoForColorTextureFormat ( format ) ;
1854
1843
1855
1844
const origin = {
1856
1845
x : originInBlocks . x * info . blockWidth ,
@@ -1965,9 +1954,9 @@ function CopyMethodSupportedWithDepthStencilFormat(
1965
1954
) : boolean {
1966
1955
{
1967
1956
return (
1968
- ( aspect === 'stencil-only' && ! ! kTextureFormatInfo [ format ] . stencil ) ||
1957
+ ( aspect === 'stencil-only' && isStencilTextureFormat ( format ) ) ||
1969
1958
( aspect === 'depth-only' &&
1970
- ! ! kTextureFormatInfo [ format ] . depth &&
1959
+ isDepthTextureFormat ( format ) &&
1971
1960
copyMethod === 'CopyT2B' &&
1972
1961
depthStencilBufferTextureCopySupported ( 'CopyT2B' , format , aspect ) )
1973
1962
) ;
@@ -2002,10 +1991,6 @@ aspect and copyTextureToBuffer() with depth aspect.
2002
1991
} )
2003
1992
. combine ( 'mipLevel' , [ 0 , 2 ] )
2004
1993
)
2005
- . beforeAllSubcases ( t => {
2006
- const info = kTextureFormatInfo [ t . params . format ] ;
2007
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
2008
- } )
2009
1994
. fn ( t => {
2010
1995
const {
2011
1996
format,
@@ -2018,6 +2003,7 @@ aspect and copyTextureToBuffer() with depth aspect.
2018
2003
copyDepth,
2019
2004
mipLevel,
2020
2005
} = t . params ;
2006
+ t . skipIfTextureFormatNotSupported ( format ) ;
2021
2007
const bytesPerBlock = depthStencilFormatAspectSize ( format , aspect ) ;
2022
2008
const rowsPerImage = copyHeightInBlocks + rowsPerImagePadding ;
2023
2009
@@ -2093,13 +2079,10 @@ copyTextureToBuffer() with depth aspect.
2093
2079
. combine ( 'copyDepth' , kOffsetsAndSizesParams . copyDepth )
2094
2080
. combine ( 'mipLevel' , [ 0 , 2 ] )
2095
2081
)
2096
- . beforeAllSubcases ( t => {
2097
- const info = kTextureFormatInfo [ t . params . format ] ;
2098
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
2099
- } )
2100
2082
. fn ( t => {
2101
2083
const { format, copyMethod, aspect, offsetInBlocks, dataPaddingInBytes, copyDepth, mipLevel } =
2102
2084
t . params ;
2085
+ t . skipIfTextureFormatNotSupported ( format ) ;
2103
2086
const bytesPerBlock = depthStencilFormatAspectSize ( format , aspect ) ;
2104
2087
const initialDataOffset = offsetInBlocks * bytesPerBlock ;
2105
2088
const copySize = [ 3 , 3 , copyDepth ] as const ;
0 commit comments