@@ -2,14 +2,16 @@ import {
2
2
depthStencilFormatCopyableAspects ,
3
3
DepthStencilFormat ,
4
4
SizedTextureFormat ,
5
- kTextureFormatInfo ,
6
5
isCompressedTextureFormat ,
6
+ getBlockInfoForTextureFormat ,
7
+ isDepthOrStencilTextureFormat ,
8
+ canCopyFromAllAspectsOfTextureFormat ,
7
9
} from '../../../format_info.js' ;
8
10
import { align } from '../../../util/math.js' ;
9
11
import { ImageCopyType } from '../../../util/texture/layout.js' ;
10
- import { ValidationTest } from '../validation_test.js' ;
12
+ import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js' ;
11
13
12
- export class ImageCopyTest extends ValidationTest {
14
+ export class ImageCopyTest extends AllFeaturesMaxLimitsValidationTest {
13
15
testRun (
14
16
textureCopyView : GPUTexelCopyTextureInfo ,
15
17
textureDataLayout : GPUTexelCopyBufferLayout ,
@@ -105,7 +107,7 @@ export class ImageCopyTest extends ValidationTest {
105
107
origin : Required < GPUOrigin3DDict > = { x : 0 , y : 0 , z : 0 } ,
106
108
dimension : Required < GPUTextureDimension > = '2d'
107
109
) : GPUTexture {
108
- const info = kTextureFormatInfo [ format ] ;
110
+ const info = getBlockInfoForTextureFormat ( format ) ;
109
111
const alignedSize = {
110
112
width : align ( Math . max ( 1 , size . width + origin . x ) , info . blockWidth ) ,
111
113
height : align ( Math . max ( 1 , size . height + origin . y ) , info . blockHeight ) ,
@@ -209,17 +211,16 @@ interface WithFormatAndMethod extends WithFormat {
209
211
210
212
// This is a helper function used for expanding test parameters for offset alignment, by spec
211
213
export function texelBlockAlignmentTestExpanderForOffset ( { format } : WithFormat ) {
212
- const info = kTextureFormatInfo [ format ] ;
213
- if ( info . depth || info . stencil ) {
214
+ if ( isDepthOrStencilTextureFormat ( format ) ) {
214
215
return valuesToTestDivisibilityBy ( 4 ) ;
215
216
}
216
217
217
- return valuesToTestDivisibilityBy ( kTextureFormatInfo [ format ] . bytesPerBlock ) ;
218
+ return valuesToTestDivisibilityBy ( getBlockInfoForTextureFormat ( format ) . bytesPerBlock ! ) ;
218
219
}
219
220
220
221
// This is a helper function used for expanding test parameters for texel block alignment tests on rowsPerImage
221
222
export function texelBlockAlignmentTestExpanderForRowsPerImage ( { format } : WithFormat ) {
222
- return valuesToTestDivisibilityBy ( kTextureFormatInfo [ format ] . blockHeight ) ;
223
+ return valuesToTestDivisibilityBy ( getBlockInfoForTextureFormat ( format ) . blockHeight ) ;
223
224
}
224
225
225
226
// This is a helper function used for expanding test parameters for texel block alignment tests on origin and size
@@ -230,11 +231,11 @@ export function texelBlockAlignmentTestExpanderForValueToCoordinate({
230
231
switch ( coordinateToTest ) {
231
232
case 'x' :
232
233
case 'width' :
233
- return valuesToTestDivisibilityBy ( kTextureFormatInfo [ format ] . blockWidth ) ;
234
+ return valuesToTestDivisibilityBy ( getBlockInfoForTextureFormat ( format ) . blockWidth ) ;
234
235
235
236
case 'y' :
236
237
case 'height' :
237
- return valuesToTestDivisibilityBy ( kTextureFormatInfo [ format ] . blockHeight ) ;
238
+ return valuesToTestDivisibilityBy ( getBlockInfoForTextureFormat ( format ) . blockHeight ) ;
238
239
239
240
case 'z' :
240
241
case 'depthOrArrayLayers' :
@@ -244,18 +245,17 @@ export function texelBlockAlignmentTestExpanderForValueToCoordinate({
244
245
245
246
// This is a helper function used for filtering test parameters
246
247
export function formatCopyableWithMethod ( { format, method } : WithFormatAndMethod ) : boolean {
247
- const info = kTextureFormatInfo [ format ] ;
248
- if ( info . depth || info . stencil ) {
248
+ if ( isDepthOrStencilTextureFormat ( format ) ) {
249
249
const supportedAspects : readonly GPUTextureAspect [ ] = depthStencilFormatCopyableAspects (
250
250
method ,
251
251
format as DepthStencilFormat
252
252
) ;
253
253
return supportedAspects . length > 0 ;
254
254
}
255
255
if ( method === 'CopyT2B' ) {
256
- return info . color . copySrc ;
256
+ return canCopyFromAllAspectsOfTextureFormat ( format ) ;
257
257
} else {
258
- return info . color . copyDst ;
258
+ return canCopyFromAllAspectsOfTextureFormat ( format ) ;
259
259
}
260
260
}
261
261
@@ -264,8 +264,7 @@ export function getACopyableAspectWithMethod({
264
264
format,
265
265
method,
266
266
} : WithFormatAndMethod ) : GPUTextureAspect {
267
- const info = kTextureFormatInfo [ format ] ;
268
- if ( info . depth || info . stencil ) {
267
+ if ( isDepthOrStencilTextureFormat ( format ) ) {
269
268
const supportedAspects : readonly GPUTextureAspect [ ] = depthStencilFormatCopyableAspects (
270
269
method ,
271
270
format as DepthStencilFormat
0 commit comments