@@ -590,6 +590,7 @@ function rendererWebGPU(p5, fn) {
590590 shader . _uniformBufferGroups . push ( {
591591 group : group . group ,
592592 binding : group . binding ,
593+ cacheKey : group . group + ',' + group . binding ,
593594 varName : group . varName ,
594595 structType : group . structType ,
595596 uniforms : groupUniforms ,
@@ -1413,7 +1414,7 @@ function rendererWebGPU(p5, fn) {
14131414 uniformBufferInfo . offset += Math . ceil ( bufferGroup . size / this . uniformBufferAlignment ) * this . uniformBufferAlignment ;
14141415
14151416 // Make a shallow copy so that we keep track of the last offset for this uniform
1416- this . _uniformBuffersForBinding . set ( bufferGroup . binding , { ...uniformBufferInfo } ) ;
1417+ this . _uniformBuffersForBinding . set ( bufferGroup . cacheKey , { ...uniformBufferInfo } ) ;
14171418 currentShader . _cachedBindGroup [ bufferGroup . group ] = undefined ;
14181419 } else {
14191420 // Bind uniforms to a binding-specific buffer, which may be cached for performance
@@ -1444,15 +1445,15 @@ function rendererWebGPU(p5, fn) {
14441445 bufferGroup . currentBuffer = bufferInfo ;
14451446 }
14461447
1447- this . _uniformBuffersForBinding . set ( bufferGroup . binding , bufferInfo ) ;
1448+ this . _uniformBuffersForBinding . set ( bufferGroup . cacheKey , bufferInfo ) ;
14481449 }
14491450 }
14501451
14511452 // Bind sampler/texture uniforms and uniform buffers
14521453 for ( const [ group , entries ] of currentShader . _groupEntries ) {
14531454 const bgEntries = entries . map ( entry => {
14541455 // Check if this is a uniform buffer binding
1455- const uniformBufferInfo = this . _uniformBuffersForBinding . get ( entry . binding ) ;
1456+ const uniformBufferInfo = this . _uniformBuffersForBinding . get ( group + ',' + entry . binding ) ;
14561457 if ( uniformBufferInfo && entry . bufferGroup ) {
14571458 return {
14581459 binding : entry . binding ,
@@ -1482,13 +1483,17 @@ function rendererWebGPU(p5, fn) {
14821483 entries : bgEntries ,
14831484 } ) ;
14841485 }
1485- currentShader . _cachedBindGroup [ group ] = bindGroup ;
1486+ const dynamicEntryOffsets = entries
1487+ . map ( e => e . bufferGroup && this . _uniformBuffersForBinding . get ( e . bufferGroup . cacheKey ) )
1488+ . filter ( b => b ?. dynamic )
1489+ . map ( b => b . lastOffset ) ;
1490+ if ( dynamicEntryOffsets . length === 0 ) {
1491+ currentShader . _cachedBindGroup [ group ] = bindGroup ;
1492+ }
14861493 passEncoder . setBindGroup (
14871494 group ,
14881495 bindGroup ,
1489- entries . map ( e => e . bufferGroup && this . _uniformBuffersForBinding . get ( e . binding ) )
1490- . filter ( b => b ?. dynamic )
1491- . map ( b => b . lastOffset )
1496+ dynamicEntryOffsets ,
14921497 ) ;
14931498 }
14941499
0 commit comments