@@ -72,6 +72,11 @@ const _cullModes = [
7272 'front' // CULLFACE_FRONT
7373] ;
7474
75+ const _frontFace = [
76+ 'ccw' , // FRONTFACE_CCW
77+ 'cw' // FRONTFACE_CW
78+ ] ;
79+
7580const _stencilOps = [
7681 'keep' , // STENCILOP_KEEP
7782 'zero' , // STENCILOP_ZERO
@@ -107,7 +112,7 @@ class CacheEntry {
107112}
108113
109114class WebgpuRenderPipeline extends WebgpuPipeline {
110- lookupHashes = new Uint32Array ( 14 ) ;
115+ lookupHashes = new Uint32Array ( 15 ) ;
111116
112117 constructor ( device ) {
113118 super ( device ) ;
@@ -141,11 +146,12 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
141146 * @param {boolean } stencilEnabled - Whether stencil is enabled.
142147 * @param {StencilParameters } stencilFront - The stencil state for front faces.
143148 * @param {StencilParameters } stencilBack - The stencil state for back faces.
149+ * @param {number } frontFace - The front face.
144150 * @returns {GPURenderPipeline } Returns the render pipeline.
145151 * @private
146152 */
147153 get ( primitive , vertexFormat0 , vertexFormat1 , ibFormat , shader , renderTarget , bindGroupFormats , blendState ,
148- depthState , cullMode , stencilEnabled , stencilFront , stencilBack ) {
154+ depthState , cullMode , stencilEnabled , stencilFront , stencilBack , frontFace ) {
149155
150156 Debug . assert ( bindGroupFormats . length <= 3 ) ;
151157
@@ -177,6 +183,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
177183 lookupHashes [ 11 ] = stencilEnabled ? stencilFront . key : 0 ;
178184 lookupHashes [ 12 ] = stencilEnabled ? stencilBack . key : 0 ;
179185 lookupHashes [ 13 ] = ibFormat ?? 0 ;
186+ lookupHashes [ 14 ] = frontFace ;
180187 const hash = hash32Fnv1a ( lookupHashes ) ;
181188
182189 // cached pipeline
@@ -206,7 +213,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
206213 const cacheEntry = new CacheEntry ( ) ;
207214 cacheEntry . hashes = new Uint32Array ( lookupHashes ) ;
208215 cacheEntry . pipeline = this . create ( primitiveTopology , ibFormat , shader , renderTarget , pipelineLayout , blendState ,
209- depthState , vertexBufferLayout , cullMode , stencilEnabled , stencilFront , stencilBack ) ;
216+ depthState , vertexBufferLayout , cullMode , stencilEnabled , stencilFront , stencilBack , frontFace ) ;
210217
211218 // add to cache
212219 if ( cacheEntries ) {
@@ -313,7 +320,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
313320 }
314321
315322 create ( primitiveTopology , ibFormat , shader , renderTarget , pipelineLayout , blendState , depthState , vertexBufferLayout ,
316- cullMode , stencilEnabled , stencilFront , stencilBack ) {
323+ cullMode , stencilEnabled , stencilFront , stencilBack , frontFace ) {
317324
318325 const wgpu = this . device . wgpu ;
319326
@@ -330,7 +337,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
330337
331338 primitive : {
332339 topology : primitiveTopology ,
333- frontFace : 'ccw' ,
340+ frontFace : _frontFace [ frontFace ] ,
334341 cullMode : _cullModes [ cullMode ]
335342 } ,
336343
0 commit comments