1
1
import { assert } from '../../../../../common/util/util.js' ;
2
2
import { kTextureSampleCounts } from '../../../../capability_info.js' ;
3
- import { kTextureFormatInfo } from '../../../../format_info.js' ;
3
+ import { getColorRenderAlignment , getColorRenderByteCost } from '../../../../format_info.js' ;
4
4
import { align } from '../../../../util/math.js' ;
5
5
6
6
import {
@@ -10,30 +10,26 @@ import {
10
10
makeLimitTestGroup ,
11
11
} from './limit_utils.js' ;
12
12
13
- const kFormatsToUseBySize : GPUTextureFormat [ ] = [
13
+ const kFormatsToUseBySize = [
14
14
'rgba32uint' ,
15
15
'rgba16uint' ,
16
16
'rgba8unorm' ,
17
17
'rg8unorm' ,
18
18
'r8unorm' ,
19
- ] ;
19
+ ] as const ;
20
20
21
- const kInterleaveFormats : GPUTextureFormat [ ] = [
22
- 'rgba16uint' ,
23
- 'rg16uint' ,
24
- 'rgba8unorm' ,
25
- 'rg8unorm' ,
26
- 'r8unorm' ,
27
- ] ;
21
+ const kInterleaveFormats = [ 'rgba16uint' , 'rg16uint' , 'rgba8unorm' , 'rg8unorm' , 'r8unorm' ] as const ;
22
+
23
+ const kFormatsUsedInTest = [ ...kFormatsToUseBySize , ...kInterleaveFormats ] as const ;
24
+ type FormatUsedInTest = ( typeof kFormatsUsedInTest ) [ number ] ;
28
25
29
- function getAttachments ( interleaveFormat : GPUTextureFormat , testValue : number ) {
26
+ function getAttachments ( interleaveFormat : FormatUsedInTest , testValue : number ) {
30
27
let bytesPerSample = 0 ;
31
28
const targets : GPUColorTargetState [ ] = [ ] ;
32
29
33
- const addTexture = ( format : GPUTextureFormat ) => {
34
- const info = kTextureFormatInfo [ format ] ;
30
+ const addTexture = ( format : FormatUsedInTest ) => {
35
31
const newBytesPerSample =
36
- align ( bytesPerSample , info . colorRender ! . alignment ) + info . colorRender ! . byteCost ;
32
+ align ( bytesPerSample , getColorRenderAlignment ( format ) ) + getColorRenderByteCost ( format ) ;
37
33
if ( newBytesPerSample > testValue ) {
38
34
return false ;
39
35
}
@@ -70,12 +66,13 @@ function getDescription(
70
66
let offset = 0 ;
71
67
return targets
72
68
. map ( ( { format } ) => {
73
- const info = kTextureFormatInfo [ format ] ;
74
- offset = align ( offset , info . colorRender ! . alignment ) ;
75
- const s = `// ${ format . padEnd ( 11 ) } (offset: ${ offset . toString ( ) . padStart ( 2 ) } , align: ${
76
- info . colorRender ! . alignment
77
- } , size: ${ info . colorRender ! . byteCost } )`;
78
- offset += info . colorRender ! . byteCost ;
69
+ const alignment = getColorRenderAlignment ( format as FormatUsedInTest ) ;
70
+ const byteCost = getColorRenderByteCost ( format as FormatUsedInTest ) ;
71
+ offset = align ( offset , alignment ) ;
72
+ const s = `// ${ format . padEnd ( 11 ) } (offset: ${ offset
73
+ . toString ( )
74
+ . padStart ( 2 ) } , align: ${ alignment } , size: ${ byteCost } )`;
75
+ offset += byteCost ;
79
76
return s ;
80
77
} )
81
78
. join ( '\n ' ) ;
@@ -86,7 +83,7 @@ function getDescription(
86
83
function getPipelineDescriptor (
87
84
device : GPUDevice ,
88
85
actualLimit : number ,
89
- interleaveFormat : GPUTextureFormat ,
86
+ interleaveFormat : FormatUsedInTest ,
90
87
sampleCount : number ,
91
88
testValue : number
92
89
) : { pipelineDescriptor : GPURenderPipelineDescriptor ; code : string } | undefined {
0 commit comments