@luma.gl/engine 9.4.0-alpha.2 → 9.4.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6790,14 +6790,22 @@ var ShaderPassRenderer = class {
6790
6790
  }
6791
6791
  }
6792
6792
  renderToScreen(options) {
6793
- const outputTexture = this.renderToTexture(options);
6793
+ return this.encodeToScreen(this.device.commandEncoder, options);
6794
+ }
6795
+ /**
6796
+ * Records the shader-pass chain and presentation into a caller-owned command encoder.
6797
+ * The encoder must belong to this renderer's device and have no active pass. This method does
6798
+ * not finish or submit the encoder.
6799
+ */
6800
+ encodeToScreen(commandEncoder, options) {
6801
+ const outputTexture = this.encodeToTexture(commandEncoder, options);
6794
6802
  if (!outputTexture) {
6795
6803
  return false;
6796
6804
  }
6797
6805
  const framebuffer = this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
6798
6806
  this.textureModel.setProps({ backgroundTexture: outputTexture });
6799
- this.textureModel.predraw(this.device.commandEncoder);
6800
- const renderPass = this.device.beginRenderPass({
6807
+ this.textureModel.predraw(commandEncoder);
6808
+ const renderPass = commandEncoder.beginRenderPass({
6801
6809
  id: "shader-pass-renderer-to-screen",
6802
6810
  framebuffer,
6803
6811
  clearDepth: false
@@ -6810,6 +6818,17 @@ var ShaderPassRenderer = class {
6810
6818
  * @returns null if the the sourceTexture has not yet been loaded
6811
6819
  */
6812
6820
  renderToTexture(options) {
6821
+ return this.encodeToTexture(this.device.commandEncoder, options);
6822
+ }
6823
+ /**
6824
+ * Records the shader-pass chain into a caller-owned command encoder.
6825
+ * The encoder must belong to this renderer's device and have no active pass. This method does
6826
+ * not finish or submit the encoder.
6827
+ */
6828
+ encodeToTexture(commandEncoder, options) {
6829
+ if (commandEncoder.device !== this.device) {
6830
+ throw new Error("ShaderPassRenderer command encoder must belong to the renderer device");
6831
+ }
6813
6832
  const { sourceTexture } = options;
6814
6833
  if (sourceTexture instanceof DynamicTexture && !sourceTexture.isReady) {
6815
6834
  return null;
@@ -6822,9 +6841,9 @@ var ShaderPassRenderer = class {
6822
6841
  this.resetHistory();
6823
6842
  }
6824
6843
  this.textureModel.setProps({ backgroundTexture: originalTexture });
6825
- this.textureModel.predraw(this.device.commandEncoder);
6844
+ this.textureModel.predraw(commandEncoder);
6826
6845
  const sourceFramebuffer = getSeedFramebuffer(this.swapFramebuffers, originalTexture);
6827
- const seedRenderPass = this.device.beginRenderPass({
6846
+ const seedRenderPass = commandEncoder.beginRenderPass({
6828
6847
  id: "shader-pass-renderer-seed-source",
6829
6848
  framebuffer: sourceFramebuffer,
6830
6849
  clearColor: [0, 0, 0, 1],
@@ -6837,7 +6856,7 @@ var ShaderPassRenderer = class {
6837
6856
  let frameSucceeded = false;
6838
6857
  try {
6839
6858
  for (const passRenderer of this.passRenderers) {
6840
- passRenderer.initializeHistoryTargets(originalTexture, this.textureModel);
6859
+ passRenderer.initializeHistoryTargets(originalTexture, this.textureModel, commandEncoder);
6841
6860
  for (const execution of passRenderer.subPassExecutions) {
6842
6861
  const outputName = execution.output || "previous";
6843
6862
  const outputFramebuffer = outputName === "previous" ? getNextPreviousFramebuffer(this.swapFramebuffers, previousFramebuffer) : passRenderer.getOutputFramebuffer(outputName);
@@ -6851,12 +6870,12 @@ var ShaderPassRenderer = class {
6851
6870
  });
6852
6871
  const resolvedUniforms = resolveExecutionUniforms(this.shaderInputs, execution, options.uniforms || {});
6853
6872
  execution.subPassRenderer.prepare({
6854
- commandEncoder: this.device.commandEncoder,
6873
+ commandEncoder,
6855
6874
  bindings: resolvedBindings,
6856
6875
  textureScale: calculateTextureScale(resolvedBindings["sourceTexture"] || previousTexture, outputTexture),
6857
6876
  uniforms: resolvedUniforms
6858
6877
  });
6859
- const renderPass = this.device.beginRenderPass({
6878
+ const renderPass = commandEncoder.beginRenderPass({
6860
6879
  id: "shader-pass-renderer-run-pass",
6861
6880
  framebuffer: outputFramebuffer,
6862
6881
  clearColor: [0, 0, 0, 1],
@@ -6919,7 +6938,7 @@ var PassRenderer = class {
6919
6938
  renderTarget.writtenThisFrame = false;
6920
6939
  }
6921
6940
  }
6922
- initializeHistoryTargets(originalTexture, textureModel) {
6941
+ initializeHistoryTargets(originalTexture, textureModel, commandEncoder) {
6923
6942
  for (const renderTarget of Object.values(this.renderTargets)) {
6924
6943
  if (renderTarget.spec.lifetime !== "history" || renderTarget.historyInitialized) {
6925
6944
  continue;
@@ -6930,8 +6949,8 @@ var PassRenderer = class {
6930
6949
  };
6931
6950
  if (initialize === "original") {
6932
6951
  textureModel.setProps({ backgroundTexture: originalTexture });
6933
- textureModel.predraw(this.device.commandEncoder);
6934
- const renderPass = this.device.beginRenderPass({
6952
+ textureModel.predraw(commandEncoder);
6953
+ const renderPass = commandEncoder.beginRenderPass({
6935
6954
  id: `${renderTarget.name}-initialize-history`,
6936
6955
  framebuffer: historyFramebuffer,
6937
6956
  clearColor: [0, 0, 0, 0],
@@ -6940,7 +6959,7 @@ var PassRenderer = class {
6940
6959
  textureModel.draw(renderPass);
6941
6960
  renderPass.end();
6942
6961
  } else {
6943
- const renderPass = this.device.beginRenderPass({
6962
+ const renderPass = commandEncoder.beginRenderPass({
6944
6963
  id: `${renderTarget.name}-clear-history`,
6945
6964
  framebuffer: historyFramebuffer,
6946
6965
  clearColor: initialize.clearColor,