@@ -6,15 +6,18 @@ import { makeTestGroup } from '../../../../../common/framework/test_group.js';
6
6
import { getGPU } from '../../../../../common/util/navigator_gpu.js' ;
7
7
import { assert } from '../../../../../common/util/util.js' ;
8
8
import { kCanvasTextureFormats } from '../../../../capability_info.js' ;
9
- import { kAllTextureFormats , kTextureFormatInfo } from '../../../../format_info.js' ;
9
+ import {
10
+ getBlockInfoForTextureFormat ,
11
+ getRequiredFeatureForTextureFormat ,
12
+ isDepthOrStencilTextureFormat ,
13
+ isTextureFormatPossiblyStorageReadable ,
14
+ isTextureFormatPossiblyUsableAsColorRenderAttachment ,
15
+ kOptionalTextureFormats ,
16
+ } from '../../../../format_info.js' ;
10
17
import { kAllCanvasTypes , createCanvas } from '../../../../util/create_elements.js' ;
11
- import { ValidationTest } from '../../validation_test.js' ;
18
+ import { UniqueFeaturesAndLimitsValidationTest } from '../../validation_test.js' ;
12
19
13
- export const g = makeTestGroup ( ValidationTest ) ;
14
-
15
- const kOptionalTextureFormats = kAllTextureFormats . filter (
16
- t => kTextureFormatInfo [ t ] . feature !== undefined
17
- ) ;
20
+ export const g = makeTestGroup ( UniqueFeaturesAndLimitsValidationTest ) ;
18
21
19
22
g . test ( 'texture_descriptor' )
20
23
. desc (
@@ -29,15 +32,14 @@ g.test('texture_descriptor')
29
32
. beforeAllSubcases ( t => {
30
33
const { format, enable_required_feature } = t . params ;
31
34
32
- const formatInfo = kTextureFormatInfo [ format ] ;
33
35
if ( enable_required_feature ) {
34
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
36
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
35
37
}
36
38
} )
37
39
. fn ( t => {
38
40
const { format, enable_required_feature } = t . params ;
39
41
40
- const formatInfo = kTextureFormatInfo [ format ] ;
42
+ const formatInfo = getBlockInfoForTextureFormat ( format ) ;
41
43
t . shouldThrow ( enable_required_feature ? false : 'TypeError' , ( ) => {
42
44
t . createTextureTracked ( {
43
45
format,
@@ -60,15 +62,14 @@ g.test('texture_descriptor_view_formats')
60
62
. beforeAllSubcases ( t => {
61
63
const { format, enable_required_feature } = t . params ;
62
64
63
- const formatInfo = kTextureFormatInfo [ format ] ;
64
65
if ( enable_required_feature ) {
65
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
66
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
66
67
}
67
68
} )
68
69
. fn ( t => {
69
70
const { format, enable_required_feature } = t . params ;
70
71
71
- const formatInfo = kTextureFormatInfo [ format ] ;
72
+ const formatInfo = getBlockInfoForTextureFormat ( format ) ;
72
73
t . shouldThrow ( enable_required_feature ? false : 'TypeError' , ( ) => {
73
74
t . createTextureTracked ( {
74
75
format,
@@ -92,9 +93,8 @@ g.test('texture_view_descriptor')
92
93
. beforeAllSubcases ( t => {
93
94
const { format, enable_required_feature } = t . params ;
94
95
95
- const formatInfo = kTextureFormatInfo [ format ] ;
96
96
if ( enable_required_feature ) {
97
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
97
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
98
98
}
99
99
} )
100
100
. fn ( t => {
@@ -107,7 +107,7 @@ g.test('texture_view_descriptor')
107
107
// has a chance to validate that the view and texture formats aren't compatible.
108
108
const textureFormat = enable_required_feature ? format : 'rgba8unorm' ;
109
109
110
- const formatInfo = kTextureFormatInfo [ format ] ;
110
+ const formatInfo = getBlockInfoForTextureFormat ( format ) ;
111
111
const testTexture = t . createTextureTracked ( {
112
112
format : textureFormat ,
113
113
size : [ formatInfo . blockWidth , formatInfo . blockHeight , 1 ] as const ,
@@ -144,9 +144,8 @@ g.test('canvas_configuration')
144
144
. beforeAllSubcases ( t => {
145
145
const { format, enable_required_feature } = t . params ;
146
146
147
- const formatInfo = kTextureFormatInfo [ format ] ;
148
147
if ( enable_required_feature ) {
149
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
148
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
150
149
}
151
150
} )
152
151
. fn ( t => {
@@ -235,19 +234,19 @@ g.test('storage_texture_binding_layout')
235
234
. params ( u =>
236
235
u
237
236
. combine ( 'format' , kOptionalTextureFormats )
238
- . filter ( t => ! ! kTextureFormatInfo [ t . format ] . color ?. storage )
237
+ . filter ( t => isTextureFormatPossiblyStorageReadable ( t . format ) )
239
238
. combine ( 'enable_required_feature' , [ true , false ] )
240
239
)
241
240
. beforeAllSubcases ( t => {
242
241
const { format, enable_required_feature } = t . params ;
243
242
244
- const formatInfo = kTextureFormatInfo [ format ] ;
245
243
if ( enable_required_feature ) {
246
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
244
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
247
245
}
248
246
} )
249
247
. fn ( t => {
250
248
const { format, enable_required_feature } = t . params ;
249
+ t . skipIfTextureFormatNotUsableAsStorageTexture ( format ) ;
251
250
252
251
t . shouldThrow ( enable_required_feature ? false : 'TypeError' , ( ) => {
253
252
t . device . createBindGroupLayout ( {
@@ -277,19 +276,19 @@ g.test('color_target_state')
277
276
u
278
277
. combine ( 'isAsync' , [ false , true ] )
279
278
. combine ( 'format' , kOptionalTextureFormats )
280
- . filter ( t => ! ! kTextureFormatInfo [ t . format ] . colorRender )
279
+ . filter ( t => isTextureFormatPossiblyUsableAsColorRenderAttachment ( t . format ) )
281
280
. combine ( 'enable_required_feature' , [ true , false ] )
282
281
)
283
282
. beforeAllSubcases ( t => {
284
283
const { format, enable_required_feature } = t . params ;
285
284
286
- const formatInfo = kTextureFormatInfo [ format ] ;
287
285
if ( enable_required_feature ) {
288
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
286
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
289
287
}
290
288
} )
291
289
. fn ( t => {
292
290
const { isAsync, format, enable_required_feature } = t . params ;
291
+ t . skipIfTextureFormatNotUsableAsRenderAttachment ( format ) ;
293
292
294
293
t . doCreateRenderPipelineTest (
295
294
isAsync ,
@@ -333,15 +332,14 @@ g.test('depth_stencil_state')
333
332
u
334
333
. combine ( 'isAsync' , [ false , true ] )
335
334
. combine ( 'format' , kOptionalTextureFormats )
336
- . filter ( t => ! ! ( kTextureFormatInfo [ t . format ] . depth || kTextureFormatInfo [ t . format ] . stencil ) )
335
+ . filter ( t => isDepthOrStencilTextureFormat ( t . format ) )
337
336
. combine ( 'enable_required_feature' , [ true , false ] )
338
337
)
339
338
. beforeAllSubcases ( t => {
340
339
const { format, enable_required_feature } = t . params ;
341
340
342
- const formatInfo = kTextureFormatInfo [ format ] ;
343
341
if ( enable_required_feature ) {
344
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
342
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
345
343
}
346
344
} )
347
345
. fn ( t => {
@@ -395,19 +393,19 @@ g.test('render_bundle_encoder_descriptor_color_format')
395
393
. params ( u =>
396
394
u
397
395
. combine ( 'format' , kOptionalTextureFormats )
398
- . filter ( t => ! ! kTextureFormatInfo [ t . format ] . colorRender )
396
+ . filter ( t => isTextureFormatPossiblyUsableAsColorRenderAttachment ( t . format ) )
399
397
. combine ( 'enable_required_feature' , [ true , false ] )
400
398
)
401
399
. beforeAllSubcases ( t => {
402
400
const { format, enable_required_feature } = t . params ;
403
401
404
- const formatInfo = kTextureFormatInfo [ format ] ;
405
402
if ( enable_required_feature ) {
406
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
403
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
407
404
}
408
405
} )
409
406
. fn ( t => {
410
407
const { format, enable_required_feature } = t . params ;
408
+ t . skipIfTextureFormatNotUsableAsRenderAttachment ( format ) ;
411
409
412
410
t . shouldThrow ( enable_required_feature ? false : 'TypeError' , ( ) => {
413
411
t . device . createRenderBundleEncoder ( {
@@ -426,15 +424,14 @@ g.test('render_bundle_encoder_descriptor_depth_stencil_format')
426
424
. params ( u =>
427
425
u
428
426
. combine ( 'format' , kOptionalTextureFormats )
429
- . filter ( t => ! ! ( kTextureFormatInfo [ t . format ] . depth || kTextureFormatInfo [ t . format ] . stencil ) )
427
+ . filter ( t => isDepthOrStencilTextureFormat ( t . format ) )
430
428
. combine ( 'enable_required_feature' , [ true , false ] )
431
429
)
432
430
. beforeAllSubcases ( t => {
433
431
const { format, enable_required_feature } = t . params ;
434
432
435
- const formatInfo = kTextureFormatInfo [ format ] ;
436
433
if ( enable_required_feature ) {
437
- t . selectDeviceOrSkipTestCase ( formatInfo . feature ) ;
434
+ t . selectDeviceOrSkipTestCase ( getRequiredFeatureForTextureFormat ( format ) ) ;
438
435
}
439
436
} )
440
437
. fn ( t => {
0 commit comments