@@ -6,9 +6,12 @@ import { makeTestGroup } from '../../../../common/framework/test_group.js';
6
6
import { assert } from '../../../../common/util/util.js' ;
7
7
import { kTextureDimensions } from '../../../capability_info.js' ;
8
8
import {
9
- kTextureFormatInfo ,
10
9
kSizedTextureFormats ,
11
10
textureDimensionAndFormatCompatible ,
11
+ getBlockInfoForTextureFormat ,
12
+ isDepthOrStencilTextureFormat ,
13
+ getBlockInfoForSizedTextureFormat ,
14
+ getBlockInfoForColorTextureFormat ,
12
15
} from '../../../format_info.js' ;
13
16
import { align } from '../../../util/math.js' ;
14
17
import {
@@ -58,7 +61,7 @@ Test that rowsPerImage must be at least the copy height (if defined).
58
61
const { rowsPerImage, copyHeightInBlocks, copyDepth, dimension, size, method } = t . params ;
59
62
60
63
const format = 'rgba8unorm' ;
61
- const copyHeight = copyHeightInBlocks * kTextureFormatInfo [ format ] . blockHeight ;
64
+ const copyHeight = copyHeightInBlocks * getBlockInfoForTextureFormat ( format ) . blockHeight ;
62
65
63
66
const texture = t . createTextureTracked ( {
64
67
size,
@@ -162,26 +165,19 @@ Test the computation of requiredBytesInCopy by computing the minimum data size f
162
165
// If the format is a depth/stencil format, its copy size must equal to subresource's size.
163
166
// So filter out depth/stencil cases where the rounded-up texture size would be different from the copy size.
164
167
. filter ( ( { format, copyWidthInBlocks, copyHeightInBlocks, copyDepth } ) => {
165
- const info = kTextureFormatInfo [ format ] ;
166
168
return (
167
- ( ! info . depth && ! info . stencil ) ||
169
+ ! isDepthOrStencilTextureFormat ( format ) ||
168
170
( copyWidthInBlocks > 0 && copyHeightInBlocks > 0 && copyDepth > 0 )
169
171
) ;
170
172
} )
171
173
. unless ( p => p . dimension === '1d' && ( p . copyHeightInBlocks > 1 || p . copyDepth > 1 ) )
172
174
. expand ( 'offset' , p => {
173
- const info = kTextureFormatInfo [ p . format ] ;
174
- if ( info . depth || info . stencil ) {
175
+ if ( isDepthOrStencilTextureFormat ( p . format ) ) {
175
176
return [ p . _offsetMultiplier * 4 ] ;
176
177
}
177
- return [ p . _offsetMultiplier * info . color . bytes ] ;
178
+ return [ p . _offsetMultiplier * getBlockInfoForSizedTextureFormat ( p . format ) . bytesPerBlock ] ;
178
179
} )
179
180
)
180
- . beforeAllSubcases ( t => {
181
- const info = kTextureFormatInfo [ t . params . format ] ;
182
- t . skipIfTextureFormatNotSupportedDeprecated ( t . params . format ) ;
183
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
184
- } )
185
181
. fn ( t => {
186
182
const {
187
183
offset,
@@ -194,7 +190,8 @@ Test the computation of requiredBytesInCopy by computing the minimum data size f
194
190
dimension,
195
191
method,
196
192
} = t . params ;
197
- const info = kTextureFormatInfo [ format ] ;
193
+ t . skipIfTextureFormatNotSupported ( format ) ;
194
+ const info = getBlockInfoForSizedTextureFormat ( format ) ;
198
195
199
196
// In the CopyB2T and CopyT2B cases we need to have bytesPerRow 256-aligned,
200
197
// to make this happen we align the bytesInACompleteRow value and multiply
@@ -248,16 +245,15 @@ Test that rowsPerImage has no alignment constraints.
248
245
. beginSubcases ( )
249
246
. expand ( 'rowsPerImage' , texelBlockAlignmentTestExpanderForRowsPerImage )
250
247
// Copy height is info.blockHeight, so rowsPerImage must be equal or greater than it.
251
- . filter ( ( { rowsPerImage, format } ) => rowsPerImage >= kTextureFormatInfo [ format ] . blockHeight )
248
+ . filter (
249
+ ( { rowsPerImage, format } ) =>
250
+ rowsPerImage >= getBlockInfoForSizedTextureFormat ( format ) . blockHeight
251
+ )
252
252
)
253
- . beforeAllSubcases ( t => {
254
- const info = kTextureFormatInfo [ t . params . format ] ;
255
- t . skipIfTextureFormatNotSupportedDeprecated ( t . params . format ) ;
256
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
257
- } )
258
253
. fn ( t => {
259
254
const { rowsPerImage, format, method } = t . params ;
260
- const info = kTextureFormatInfo [ format ] ;
255
+ t . skipIfTextureFormatNotSupported ( format ) ;
256
+ const info = getBlockInfoForSizedTextureFormat ( format ) ;
261
257
262
258
const size = { width : info . blockWidth , height : info . blockHeight , depthOrArrayLayers : 1 } ;
263
259
const texture = t . createTextureTracked ( {
@@ -293,14 +289,10 @@ Test the alignment requirement on the linear data offset (block size, or 4 for d
293
289
. beginSubcases ( )
294
290
. expand ( 'offset' , texelBlockAlignmentTestExpanderForOffset )
295
291
)
296
- . beforeAllSubcases ( t => {
297
- const info = kTextureFormatInfo [ t . params . format ] ;
298
- t . skipIfTextureFormatNotSupportedDeprecated ( t . params . format ) ;
299
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
300
- } )
301
292
. fn ( t => {
302
293
const { format, offset, method } = t . params ;
303
- const info = kTextureFormatInfo [ format ] ;
294
+ t . skipIfTextureFormatNotSupported ( format ) ;
295
+ const info = getBlockInfoForSizedTextureFormat ( format ) ;
304
296
305
297
const size = { width : info . blockWidth , height : info . blockHeight , depthOrArrayLayers : 1 } ;
306
298
const texture = t . createTextureTracked ( {
@@ -311,10 +303,10 @@ Test the alignment requirement on the linear data offset (block size, or 4 for d
311
303
312
304
let success = false ;
313
305
if ( method === 'WriteTexture' ) success = true ;
314
- if ( info . depth || info . stencil ) {
306
+ if ( isDepthOrStencilTextureFormat ( format ) ) {
315
307
if ( offset % 4 === 0 ) success = true ;
316
308
} else {
317
- if ( offset % info . color . bytes === 0 ) success = true ;
309
+ if ( offset % info . bytesPerBlock === 0 ) success = true ;
318
310
}
319
311
320
312
t . testRun ( { texture } , { offset, bytesPerRow : 256 } , size , {
@@ -348,7 +340,7 @@ Test that bytesPerRow, if specified must be big enough for a full copy row.
348
340
. combine ( 'copyDepth' , [ 1 , 2 ] )
349
341
. unless ( p => p . dimension === '1d' && ( p . copyHeightInBlocks > 1 || p . copyDepth > 1 ) )
350
342
. expandWithParams ( p => {
351
- const info = kTextureFormatInfo [ p . format ] ;
343
+ const info = getBlockInfoForSizedTextureFormat ( p . format ) ;
352
344
// We currently have a built-in assumption that for all formats, 128 % bytesPerBlock === 0.
353
345
// This assumption ensures that all division below results in integers.
354
346
assert ( 128 % info . bytesPerBlock === 0 ) ;
@@ -366,7 +358,7 @@ Test that bytesPerRow, if specified must be big enough for a full copy row.
366
358
bytesPerRow : 256 ,
367
359
widthInBlocks : 256 / info . bytesPerBlock ,
368
360
copyWidthInBlocks : 256 / info . bytesPerBlock - 1 ,
369
- _success : ! ( info . stencil || info . depth ) ,
361
+ _success : ! isDepthOrStencilTextureFormat ( p . format ) ,
370
362
} ,
371
363
// Unaligned bytesPerRow should not work unless the method is 'WriteTexture'.
372
364
{
@@ -398,11 +390,6 @@ Test that bytesPerRow, if specified must be big enough for a full copy row.
398
390
] ;
399
391
} )
400
392
)
401
- . beforeAllSubcases ( t => {
402
- const info = kTextureFormatInfo [ t . params . format ] ;
403
- t . skipIfTextureFormatNotSupportedDeprecated ( t . params . format ) ;
404
- t . selectDeviceOrSkipTestCase ( info . feature ) ;
405
- } )
406
393
. fn ( t => {
407
394
const {
408
395
method,
@@ -414,7 +401,8 @@ Test that bytesPerRow, if specified must be big enough for a full copy row.
414
401
copyDepth,
415
402
_success,
416
403
} = t . params ;
417
- const info = kTextureFormatInfo [ format ] ;
404
+ t . skipIfTextureFormatNotSupported ( format ) ;
405
+ const info = getBlockInfoForSizedTextureFormat ( format ) ;
418
406
419
407
// We create an aligned texture using the widthInBlocks which may be different from the
420
408
// copyWidthInBlocks. This allows us to test scenarios where the two may be different.
@@ -462,9 +450,9 @@ Test that the offset cannot be larger than the linear data size (even for an emp
462
450
const { offsetInBlocks, dataSizeInBlocks, method } = t . params ;
463
451
464
452
const format = 'rgba8unorm' ;
465
- const info = kTextureFormatInfo [ format ] ;
466
- const offset = offsetInBlocks * info . color . bytes ;
467
- const dataSize = dataSizeInBlocks * info . color . bytes ;
453
+ const info = getBlockInfoForColorTextureFormat ( format ) ;
454
+ const offset = offsetInBlocks * info . bytesPerBlock ;
455
+ const dataSize = dataSizeInBlocks * info . bytesPerBlock ;
468
456
469
457
const texture = t . createTextureTracked ( {
470
458
size : { width : 4 , height : 4 , depthOrArrayLayers : 1 } ,
0 commit comments