1
- import { ColorTextureFormat , kTextureFormatInfo } from '../../../format_info.js' ;
1
+ import { ColorTextureFormat , getTextureFormatType } from '../../../format_info.js' ;
2
2
import {
3
3
getFragmentShaderCodeWithOutput ,
4
4
getPlainTypeInfo ,
5
5
kDefaultVertexShaderCode ,
6
6
} from '../../../util/shader.js' ;
7
- import { ValidationTest } from '../validation_test.js' ;
7
+ import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js' ;
8
8
9
9
export type ColorTargetState = GPUColorTargetState & { format : ColorTextureFormat } ;
10
10
11
11
const values = [ 0 , 1 , 0 , 1 ] ;
12
- export class CreateRenderPipelineValidationTest extends ValidationTest {
12
+ export function getDescriptorForCreateRenderPipelineValidationTest (
13
+ device : GPUDevice ,
14
+ options : {
15
+ primitive ?: GPUPrimitiveState ;
16
+ targets ?: ColorTargetState [ ] ;
17
+ multisample ?: GPUMultisampleState ;
18
+ depthStencil ?: GPUDepthStencilState ;
19
+ fragmentShaderCode ?: string ;
20
+ noFragment ?: boolean ;
21
+ fragmentConstants ?: Record < string , GPUPipelineConstantValue > ;
22
+ } = { }
23
+ ) : GPURenderPipelineDescriptor {
24
+ const {
25
+ primitive = { } ,
26
+ targets = [ { format : 'rgba8unorm' } ] as const ,
27
+ multisample = { } ,
28
+ depthStencil,
29
+ fragmentShaderCode = getFragmentShaderCodeWithOutput ( [
30
+ {
31
+ values,
32
+ plainType : getPlainTypeInfo (
33
+ getTextureFormatType ( targets [ 0 ] ? targets [ 0 ] . format : 'rgba8unorm' )
34
+ ) ,
35
+ componentCount : 4 ,
36
+ } ,
37
+ ] ) ,
38
+ noFragment = false ,
39
+ fragmentConstants = { } ,
40
+ } = options ;
41
+
42
+ return {
43
+ vertex : {
44
+ module : device . createShaderModule ( {
45
+ code : kDefaultVertexShaderCode ,
46
+ } ) ,
47
+ entryPoint : 'main' ,
48
+ } ,
49
+ fragment : noFragment
50
+ ? undefined
51
+ : {
52
+ module : device . createShaderModule ( {
53
+ code : fragmentShaderCode ,
54
+ } ) ,
55
+ entryPoint : 'main' ,
56
+ targets,
57
+ constants : fragmentConstants ,
58
+ } ,
59
+ layout : device . createPipelineLayout ( { bindGroupLayouts : [ ] } ) ,
60
+ primitive,
61
+ multisample,
62
+ depthStencil,
63
+ } ;
64
+ }
65
+
66
+ export class CreateRenderPipelineValidationTest extends AllFeaturesMaxLimitsValidationTest {
13
67
getDescriptor (
14
68
options : {
15
69
primitive ?: GPUPrimitiveState ;
@@ -21,46 +75,7 @@ export class CreateRenderPipelineValidationTest extends ValidationTest {
21
75
fragmentConstants ?: Record < string , GPUPipelineConstantValue > ;
22
76
} = { }
23
77
) : GPURenderPipelineDescriptor {
24
- const {
25
- primitive = { } ,
26
- targets = [ { format : 'rgba8unorm' } ] as const ,
27
- multisample = { } ,
28
- depthStencil,
29
- fragmentShaderCode = getFragmentShaderCodeWithOutput ( [
30
- {
31
- values,
32
- plainType : getPlainTypeInfo (
33
- kTextureFormatInfo [ targets [ 0 ] ? targets [ 0 ] . format : 'rgba8unorm' ] . color . type
34
- ) ,
35
- componentCount : 4 ,
36
- } ,
37
- ] ) ,
38
- noFragment = false ,
39
- fragmentConstants = { } ,
40
- } = options ;
41
-
42
- return {
43
- vertex : {
44
- module : this . device . createShaderModule ( {
45
- code : kDefaultVertexShaderCode ,
46
- } ) ,
47
- entryPoint : 'main' ,
48
- } ,
49
- fragment : noFragment
50
- ? undefined
51
- : {
52
- module : this . device . createShaderModule ( {
53
- code : fragmentShaderCode ,
54
- } ) ,
55
- entryPoint : 'main' ,
56
- targets,
57
- constants : fragmentConstants ,
58
- } ,
59
- layout : this . getPipelineLayout ( ) ,
60
- primitive,
61
- multisample,
62
- depthStencil,
63
- } ;
78
+ return getDescriptorForCreateRenderPipelineValidationTest ( this . device , options ) ;
64
79
}
65
80
66
81
getPipelineLayout ( ) : GPUPipelineLayout {
0 commit comments