@@ -91,6 +91,7 @@ class F extends ValidationTest {
9191 sampleCount ?: number ;
9292 depthStencil ?: GPUDepthStencilState ;
9393 fragmentShaderCode ?: string ;
94+ noFragment ?: boolean ;
9495 } = { }
9596 ) : GPURenderPipelineDescriptor {
9697 const defaultTargets : GPUColorTargetState [ ] = [ { format : 'rgba8unorm' } ] ;
@@ -103,6 +104,7 @@ class F extends ValidationTest {
103104 kTextureFormatInfo [ targets [ 0 ] ? targets [ 0 ] . format : 'rgba8unorm' ] . sampleType ,
104105 4
105106 ) ,
107+ noFragment = false ,
106108 } = options ;
107109
108110 return {
@@ -115,13 +117,15 @@ class F extends ValidationTest {
115117 } ) ,
116118 entryPoint : 'main' ,
117119 } ,
118- fragment : {
119- module : this . device . createShaderModule ( {
120- code : fragmentShaderCode ,
121- } ) ,
122- entryPoint : 'main' ,
123- targets,
124- } ,
120+ fragment : noFragment
121+ ? undefined
122+ : {
123+ module : this . device . createShaderModule ( {
124+ code : fragmentShaderCode ,
125+ } ) ,
126+ entryPoint : 'main' ,
127+ targets,
128+ } ,
125129 layout : this . getPipelineLayout ( ) ,
126130 primitive : { topology } ,
127131 multisample : { count : sampleCount } ,
@@ -174,7 +178,45 @@ g.test('basic_use_of_createRenderPipeline')
174178 t . doCreateRenderPipelineTest ( isAsync , true , descriptor ) ;
175179 } ) ;
176180
177- g . test ( 'at_least_one_color_state_is_required' )
181+ g . test ( 'create_vertex_only_pipeline_with_without_depth_stencil_state' )
182+ . desc (
183+ `Test creating vertex-only render pipeline. A vertex-only render pipeline have no fragment
184+ state (and thus have no color state), and can be create with or without depth stencil state.`
185+ )
186+ . params ( u =>
187+ u
188+ . combine ( 'isAsync' , [ false , true ] )
189+ . beginSubcases ( )
190+ . combine ( 'depthStencilFormat' , [
191+ 'depth24plus' ,
192+ 'depth24plus-stencil8' ,
193+ 'depth32float' ,
194+ '' ,
195+ ] as const )
196+ . combine ( 'haveColor' , [ false , true ] )
197+ )
198+ . fn ( async t => {
199+ const { isAsync, depthStencilFormat, haveColor } = t . params ;
200+
201+ let depthStencilState : GPUDepthStencilState | undefined ;
202+ if ( depthStencilFormat === '' ) {
203+ depthStencilState = undefined ;
204+ } else {
205+ depthStencilState = { format : depthStencilFormat } ;
206+ }
207+
208+ // Having targets or not should have no effect in result, since it will not appear in the
209+ // descriptor in vertex-only render pipeline
210+ const descriptor = t . getDescriptor ( {
211+ noFragment : true ,
212+ depthStencil : depthStencilState ,
213+ targets : haveColor ? [ { format : 'rgba8unorm' } ] : [ ] ,
214+ } ) ;
215+
216+ t . doCreateRenderPipelineTest ( isAsync , true , descriptor ) ;
217+ } ) ;
218+
219+ g . test ( 'at_least_one_color_state_is_required_for_complete_pipeline' )
178220 . params ( u => u . combine ( 'isAsync' , [ false , true ] ) )
179221 . fn ( async t => {
180222 const { isAsync } = t . params ;
0 commit comments