|
|
@@ -425,7 +425,8 @@ class WebGPUBackend extends Backend {
|
|
|
renderContextData.descriptor = descriptor;
|
|
|
renderContextData.encoder = encoder;
|
|
|
renderContextData.currentPass = currentPass;
|
|
|
- renderContextData.currentSets = { attributes: {} };
|
|
|
+ renderContextData.currentSets = { attributes: {}, pipeline: null, index: null };
|
|
|
+ renderContextData.renderBundles = [];
|
|
|
|
|
|
//
|
|
|
|
|
|
@@ -450,9 +451,8 @@ class WebGPUBackend extends Backend {
|
|
|
const renderContextData = this.get( renderContext );
|
|
|
const occlusionQueryCount = renderContext.occlusionQueryCount;
|
|
|
|
|
|
- if ( renderContextData.renderBundles !== undefined && renderContextData.renderBundles.length > 0 ) {
|
|
|
+ if ( renderContextData.renderBundles.length > 0 ) {
|
|
|
|
|
|
- renderContextData.registerBundlesPhase = false;
|
|
|
renderContextData.currentPass.executeBundles( renderContextData.renderBundles );
|
|
|
|
|
|
}
|
|
|
@@ -834,19 +834,7 @@ class WebGPUBackend extends Backend {
|
|
|
const renderContextData = this.get( context );
|
|
|
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
|
const currentSets = renderContextData.currentSets;
|
|
|
-
|
|
|
- const renderObjectData = this.get( renderObject );
|
|
|
-
|
|
|
- const { bundleEncoder, renderBundle, lastPipelineGPU } = renderObjectData;
|
|
|
-
|
|
|
- if ( renderContextData.registerBundlesPhase === true && bundleEncoder !== undefined && lastPipelineGPU === pipelineGPU ) {
|
|
|
-
|
|
|
- renderContextData.renderBundles.push( renderBundle );
|
|
|
- return;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- const passEncoderGPU = this.renderer._currentRenderBundle ? this.createBundleEncoder( context, renderObject ) : renderContextData.currentPass;
|
|
|
+ const passEncoderGPU = renderContextData.currentPass;
|
|
|
|
|
|
// pipeline
|
|
|
|
|
|
@@ -984,15 +972,6 @@ class WebGPUBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( this.renderer._currentRenderBundle ) {
|
|
|
-
|
|
|
- const renderBundle = passEncoderGPU.finish();
|
|
|
- renderObjectData.lastPipelineGPU = pipelineGPU;
|
|
|
- renderObjectData.renderBundle = renderBundle;
|
|
|
- renderObjectData.bundleEncoder = passEncoderGPU;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// cache key
|
|
|
@@ -1078,6 +1057,7 @@ class WebGPUBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// textures
|
|
|
|
|
|
createSampler( texture ) {
|
|
|
@@ -1266,9 +1246,39 @@ class WebGPUBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
- createBundleEncoder( renderContext, renderObject ) {
|
|
|
+ beginBundle( renderContext ) {
|
|
|
+
|
|
|
+ const renderContextData = this.get( renderContext );
|
|
|
+
|
|
|
+ renderContextData._currentPass = renderContextData.currentPass;
|
|
|
+ renderContextData._currentSets = renderContextData.currentSets;
|
|
|
+
|
|
|
+ renderContextData.currentSets = { attributes: {}, pipeline: null, index: null };
|
|
|
+ renderContextData.currentPass = this.pipelineUtils.createBundleEncoder( renderContext );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ finishBundle( renderContext, bundle ) {
|
|
|
+
|
|
|
+ const renderContextData = this.get( renderContext );
|
|
|
+
|
|
|
+ const bundleEncoder = renderContextData.currentPass;
|
|
|
+ const bundleGPU = bundleEncoder.finish();
|
|
|
+
|
|
|
+ this.get( bundle ).bundleGPU = bundleGPU;
|
|
|
+
|
|
|
+ // restore render pass state
|
|
|
+
|
|
|
+ renderContextData.currentSets = renderContextData._currentSets;
|
|
|
+ renderContextData.currentPass = renderContextData._currentPass;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ addBundle( renderContext, bundle ) {
|
|
|
+
|
|
|
+ const renderContextData = this.get( renderContext );
|
|
|
|
|
|
- return this.pipelineUtils.createBundleEncoder( renderContext, renderObject );
|
|
|
+ renderContextData.renderBundles.push( this.get( bundle ).bundleGPU );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -1472,7 +1482,7 @@ class WebGPUBackend extends Backend {
|
|
|
if ( renderContext.stencil ) descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
|
|
|
|
renderContextData.currentPass = encoder.beginRenderPass( descriptor );
|
|
|
- renderContextData.currentSets = { attributes: {} };
|
|
|
+ renderContextData.currentSets = { attributes: {}, pipeline: null, index: null };
|
|
|
|
|
|
}
|
|
|
|