11import { kUnitCaseParamsBuilder } from '../../../../../common/framework/params_builder.js' ;
22import { makeTestGroup } from '../../../../../common/framework/test_group.js' ;
3- import { keysOf } from '../../../../../common/util/data_tables.js' ;
43import { getGPU } from '../../../../../common/util/navigator_gpu.js' ;
54import { assert , range , reorder , ReorderOrder } from '../../../../../common/util/util.js' ;
65import { kLimitInfo , kTextureFormatInfo } from '../../../../capability_info.js' ;
@@ -9,45 +8,30 @@ import { align } from '../../../../util/math.js';
98
109type GPUSupportedLimit = keyof GPUSupportedLimits ;
1110
12- const CreatePipelineTypes = {
13- createRenderPipeline : true ,
14- createRenderPipelineWithFragmentStage : true ,
15- createComputePipeline : true ,
16- } ;
17- export type CreatePipelineType = keyof typeof CreatePipelineTypes ;
18- export const kCreatePipelineTypes = keysOf ( CreatePipelineTypes ) ;
11+ export const kCreatePipelineTypes = [
12+ 'createRenderPipeline' ,
13+ 'createRenderPipelineWithFragmentStage' ,
14+ 'createComputePipeline' ,
15+ ] as const ;
16+ export type CreatePipelineType = typeof kCreatePipelineTypes [ number ] ;
1917
20- const RenderEncoderTypes = {
21- render : true ,
22- renderBundle : true ,
23- } ;
24- export type RenderEncoderType = keyof typeof RenderEncoderTypes ;
25- export const kRenderEncoderTypes = keysOf ( RenderEncoderTypes ) ;
18+ export const kRenderEncoderTypes = [ 'render' , 'renderBundle' ] as const ;
19+ export type RenderEncoderType = typeof kRenderEncoderTypes [ number ] ;
2620
27- const EncoderTypes = {
28- compute : true ,
29- render : true ,
30- renderBundle : true ,
31- } ;
32- export type EncoderType = keyof typeof EncoderTypes ;
33- export const kEncoderTypes = keysOf ( EncoderTypes ) ;
21+ export const kEncoderTypes = [ 'compute' , 'render' , 'renderBundle' ] as const ;
22+ export type EncoderType = typeof kEncoderTypes [ number ] ;
3423
35- const BindGroupTests = {
36- sameGroup : true ,
37- differentGroups : true ,
38- } ;
39- export type BindGroupTest = keyof typeof BindGroupTests ;
40- export const kBindGroupTests = keysOf ( BindGroupTests ) ;
41-
42- const BindingCombinations = {
43- vertex : true ,
44- fragment : true ,
45- vertexAndFragmentWithPossibleVertexStageOverflow : true ,
46- vertexAndFragmentWithPossibleFragmentStageOverflow : true ,
47- compute : true ,
48- } ;
49- export type BindingCombination = keyof typeof BindingCombinations ;
50- export const kBindingCombinations = keysOf ( BindingCombinations ) ;
24+ export const kBindGroupTests = [ 'sameGroup' , 'differentGroups' ] as const ;
25+ export type BindGroupTest = typeof kBindGroupTests [ number ] ;
26+
27+ export const kBindingCombinations = [
28+ 'vertex' ,
29+ 'fragment' ,
30+ 'vertexAndFragmentWithPossibleVertexStageOverflow' ,
31+ 'vertexAndFragmentWithPossibleFragmentStageOverflow' ,
32+ 'compute' ,
33+ ] as const ;
34+ export type BindingCombination = typeof kBindingCombinations [ number ] ;
5135
5236export function getPipelineTypeForBindingCombination ( bindingCombination : BindingCombination ) {
5337 switch ( bindingCombination ) {
@@ -232,20 +216,12 @@ export function getPerStageWGSLForBindingCombinationStorageTextures(
232216 ) ;
233217}
234218
235- const LimitModes = {
236- defaultLimit : true ,
237- adapterLimit : true ,
238- } ;
239- export type LimitMode = keyof typeof LimitModes ;
240- export const kLimitModes = keysOf ( LimitModes ) ;
219+ export const kLimitModes = [ 'defaultLimit' , 'adapterLimit' ] as const ;
220+ export type LimitMode = typeof kLimitModes [ number ] ;
241221export type LimitsRequest = Record < string , LimitMode > ;
242222
243- export const MaximumTestValues = {
244- atLimit : true ,
245- overLimit : true ,
246- } ;
247- export type MaximumTestValue = keyof typeof MaximumTestValues ;
248- export const kMaximumTestValueKeys = keysOf ( MaximumTestValues ) ;
223+ export const kMaximumTestValues = [ 'atLimit' , 'overLimit' ] as const ;
224+ export type MaximumTestValue = typeof kMaximumTestValues [ number ] ;
249225
250226export function getMaximumTestValue ( limit : number , testValue : MaximumTestValue ) {
251227 switch ( testValue ) {
@@ -256,22 +232,17 @@ export function getMaximumTestValue(limit: number, testValue: MaximumTestValue)
256232 }
257233}
258234
259- export const MinimumTestValues = {
260- atLimit : true ,
261- underLimit : true ,
262- } ;
263- export type MinimumTestValue = keyof typeof MinimumTestValues ;
264- export const kMinimumTestValueKeys = keysOf ( MinimumTestValues ) ;
265-
266- export const MaximumLimitValueTests = {
267- atDefault : true ,
268- underDefault : true ,
269- betweenDefaultAndMaximum : true ,
270- atMaximum : true ,
271- overMaximum : true ,
272- } ;
273- export type MaximumLimitValueTest = keyof typeof MaximumLimitValueTests ;
274- export const kMaximumLimitValueTestKeys = keysOf ( MaximumLimitValueTests ) ;
235+ export const kMinimumTestValues = [ 'atLimit' , 'underLimit' ] as const ;
236+ export type MinimumTestValue = typeof kMinimumTestValues [ number ] ;
237+
238+ export const kMaximumLimitValueTests = [
239+ 'atDefault' ,
240+ 'underDefault' ,
241+ 'betweenDefaultAndMaximum' ,
242+ 'atMaximum' ,
243+ 'overMaximum' ,
244+ ] as const ;
245+ export type MaximumLimitValueTest = typeof kMaximumLimitValueTests [ number ] ;
275246
276247export function getLimitValue (
277248 defaultLimit : number ,
@@ -292,15 +263,14 @@ export function getLimitValue(
292263 }
293264}
294265
295- export const MinimumLimitValueTests = {
296- atDefault : true ,
297- overDefault : true ,
298- betweenDefaultAndMinimum : true ,
299- atMinimum : true ,
300- underMinimum : true ,
301- } ;
302- export type MinimumLimitValueTest = keyof typeof MinimumLimitValueTests ;
303- export const kMinimumLimitValueTestKeys = keysOf ( MinimumLimitValueTests ) ;
266+ export const kMinimumLimitValueTests = [
267+ 'atDefault' ,
268+ 'overDefault' ,
269+ 'betweenDefaultAndMinimum' ,
270+ 'atMinimum' ,
271+ 'underMinimum' ,
272+ ] as const ;
273+ export type MinimumLimitValueTest = typeof kMinimumLimitValueTests [ number ] ;
304274
305275export function getDefaultLimit ( limit : GPUSupportedLimit ) : number {
306276 return ( kLimitInfo as Record < string , { default : number } > ) [ limit ] . default ;
@@ -332,12 +302,12 @@ const kMinimumLimits = new Set<GPUSupportedLimit>([
332302 * Adds the default parameters to a limit test
333303 */
334304export const kMaximumLimitBaseParams = kUnitCaseParamsBuilder
335- . combine ( 'limitTest' , kMaximumLimitValueTestKeys )
336- . combine ( 'testValueName' , kMaximumTestValueKeys ) ;
305+ . combine ( 'limitTest' , kMaximumLimitValueTests )
306+ . combine ( 'testValueName' , kMaximumTestValues ) ;
337307
338308export const kMinimumLimitBaseParams = kUnitCaseParamsBuilder
339- . combine ( 'limitTest' , kMinimumLimitValueTestKeys )
340- . combine ( 'testValueName' , kMinimumTestValueKeys ) ;
309+ . combine ( 'limitTest' , kMinimumLimitValueTests )
310+ . combine ( 'testValueName' , kMinimumTestValues ) ;
341311
342312export class LimitTestsImpl extends GPUTestBase {
343313 _adapter : GPUAdapter | null = null ;
0 commit comments