File tree 2 files changed +34
-4
lines changed
2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -1326,7 +1326,8 @@ class WebGPUBackend extends Backend {
1326
1326
// pipeline
1327
1327
1328
1328
const pipelineGPU = this . get ( pipeline ) . pipeline ;
1329
- passEncoderGPU . setPipeline ( pipelineGPU ) ;
1329
+
1330
+ this . pipelineUtils . setPipeline ( passEncoderGPU , pipelineGPU ) ;
1330
1331
1331
1332
// bind groups
1332
1333
@@ -1422,7 +1423,7 @@ class WebGPUBackend extends Backend {
1422
1423
const setPipelineAndBindings = ( passEncoderGPU , currentSets ) => {
1423
1424
1424
1425
// pipeline
1425
- passEncoderGPU . setPipeline ( pipelineGPU ) ;
1426
+ this . pipelineUtils . setPipeline ( passEncoderGPU , pipelineGPU ) ;
1426
1427
currentSets . pipeline = pipelineGPU ;
1427
1428
1428
1429
// bind groups
@@ -1653,8 +1654,8 @@ class WebGPUBackend extends Backend {
1653
1654
1654
1655
} else {
1655
1656
1656
- // Regular single camera rendering
1657
- if ( renderContextData . currentPass ) {
1657
+ // Regular single camera rendering
1658
+ if ( renderContextData . currentPass ) {
1658
1659
1659
1660
// Handle occlusion queries
1660
1661
if ( renderContextData . occlusionQuerySet !== undefined ) {
Original file line number Diff line number Diff line change @@ -36,6 +36,35 @@ class WebGPUPipelineUtils {
36
36
*/
37
37
this . backend = backend ;
38
38
39
+ /**
40
+ * A Weak Map that tracks the active pipeline for render or compute passes.
41
+ *
42
+ * @private
43
+ * @type {WeakMap<(GPURenderPassEncoder|GPUComputePassEncoder),(GPURenderPipeline|GPUComputePipeline)> }
44
+ */
45
+ this . _activePipelines = new WeakMap ( ) ;
46
+
47
+ }
48
+
49
+ /**
50
+ * Sets the given pipeline for the given pass. The method makes sure to only set the
51
+ * pipeline when necessary.
52
+ *
53
+ * @param {(GPURenderPassEncoder|GPUComputePassEncoder) } pass - The pass encoder.
54
+ * @param {(GPURenderPipeline|GPUComputePipeline) } pipeline - The pipeline.
55
+ */
56
+ setPipeline ( pass , pipeline ) {
57
+
58
+ const currentPipeline = this . _activePipelines . get ( pass ) ;
59
+
60
+ if ( currentPipeline !== pipeline ) {
61
+
62
+ pass . setPipeline ( pipeline ) ;
63
+
64
+ this . _activePipelines . set ( pass , pipeline ) ;
65
+
66
+ }
67
+
39
68
}
40
69
41
70
/**
You can’t perform that action at this time.
0 commit comments