@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/dist.dev.js CHANGED
@@ -9231,14 +9231,22 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9231
9231
  }
9232
9232
  }
9233
9233
  renderToScreen(options) {
9234
- const outputTexture = this.renderToTexture(options);
9234
+ return this.encodeToScreen(this.device.commandEncoder, options);
9235
+ }
9236
+ /**
9237
+ * Records the shader-pass chain and presentation into a caller-owned command encoder.
9238
+ * The encoder must belong to this renderer's device and have no active pass. This method does
9239
+ * not finish or submit the encoder.
9240
+ */
9241
+ encodeToScreen(commandEncoder, options) {
9242
+ const outputTexture = this.encodeToTexture(commandEncoder, options);
9235
9243
  if (!outputTexture) {
9236
9244
  return false;
9237
9245
  }
9238
9246
  const framebuffer = this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
9239
9247
  this.textureModel.setProps({ backgroundTexture: outputTexture });
9240
- this.textureModel.predraw(this.device.commandEncoder);
9241
- const renderPass = this.device.beginRenderPass({
9248
+ this.textureModel.predraw(commandEncoder);
9249
+ const renderPass = commandEncoder.beginRenderPass({
9242
9250
  id: "shader-pass-renderer-to-screen",
9243
9251
  framebuffer,
9244
9252
  clearDepth: false
@@ -9251,6 +9259,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9251
9259
  * @returns null if the the sourceTexture has not yet been loaded
9252
9260
  */
9253
9261
  renderToTexture(options) {
9262
+ return this.encodeToTexture(this.device.commandEncoder, options);
9263
+ }
9264
+ /**
9265
+ * Records the shader-pass chain into a caller-owned command encoder.
9266
+ * The encoder must belong to this renderer's device and have no active pass. This method does
9267
+ * not finish or submit the encoder.
9268
+ */
9269
+ encodeToTexture(commandEncoder, options) {
9270
+ if (commandEncoder.device !== this.device) {
9271
+ throw new Error("ShaderPassRenderer command encoder must belong to the renderer device");
9272
+ }
9254
9273
  const { sourceTexture } = options;
9255
9274
  if (sourceTexture instanceof DynamicTexture && !sourceTexture.isReady) {
9256
9275
  return null;
@@ -9263,9 +9282,9 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9263
9282
  this.resetHistory();
9264
9283
  }
9265
9284
  this.textureModel.setProps({ backgroundTexture: originalTexture });
9266
- this.textureModel.predraw(this.device.commandEncoder);
9285
+ this.textureModel.predraw(commandEncoder);
9267
9286
  const sourceFramebuffer = getSeedFramebuffer(this.swapFramebuffers, originalTexture);
9268
- const seedRenderPass = this.device.beginRenderPass({
9287
+ const seedRenderPass = commandEncoder.beginRenderPass({
9269
9288
  id: "shader-pass-renderer-seed-source",
9270
9289
  framebuffer: sourceFramebuffer,
9271
9290
  clearColor: [0, 0, 0, 1],
@@ -9278,7 +9297,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9278
9297
  let frameSucceeded = false;
9279
9298
  try {
9280
9299
  for (const passRenderer of this.passRenderers) {
9281
- passRenderer.initializeHistoryTargets(originalTexture, this.textureModel);
9300
+ passRenderer.initializeHistoryTargets(originalTexture, this.textureModel, commandEncoder);
9282
9301
  for (const execution of passRenderer.subPassExecutions) {
9283
9302
  const outputName = execution.output || "previous";
9284
9303
  const outputFramebuffer = outputName === "previous" ? getNextPreviousFramebuffer(this.swapFramebuffers, previousFramebuffer) : passRenderer.getOutputFramebuffer(outputName);
@@ -9296,7 +9315,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9296
9315
  options.uniforms || {}
9297
9316
  );
9298
9317
  execution.subPassRenderer.prepare({
9299
- commandEncoder: this.device.commandEncoder,
9318
+ commandEncoder,
9300
9319
  bindings: resolvedBindings,
9301
9320
  textureScale: calculateTextureScale(
9302
9321
  resolvedBindings["sourceTexture"] || previousTexture,
@@ -9304,7 +9323,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9304
9323
  ),
9305
9324
  uniforms: resolvedUniforms
9306
9325
  });
9307
- const renderPass = this.device.beginRenderPass({
9326
+ const renderPass = commandEncoder.beginRenderPass({
9308
9327
  id: "shader-pass-renderer-run-pass",
9309
9328
  framebuffer: outputFramebuffer,
9310
9329
  clearColor: [0, 0, 0, 1],
@@ -9369,7 +9388,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9369
9388
  renderTarget.writtenThisFrame = false;
9370
9389
  }
9371
9390
  }
9372
- initializeHistoryTargets(originalTexture, textureModel) {
9391
+ initializeHistoryTargets(originalTexture, textureModel, commandEncoder) {
9373
9392
  for (const renderTarget of Object.values(this.renderTargets)) {
9374
9393
  if (renderTarget.spec.lifetime !== "history" || renderTarget.historyInitialized) {
9375
9394
  continue;
@@ -9380,8 +9399,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9380
9399
  };
9381
9400
  if (initialize === "original") {
9382
9401
  textureModel.setProps({ backgroundTexture: originalTexture });
9383
- textureModel.predraw(this.device.commandEncoder);
9384
- const renderPass = this.device.beginRenderPass({
9402
+ textureModel.predraw(commandEncoder);
9403
+ const renderPass = commandEncoder.beginRenderPass({
9385
9404
  id: `${renderTarget.name}-initialize-history`,
9386
9405
  framebuffer: historyFramebuffer,
9387
9406
  clearColor: [0, 0, 0, 0],
@@ -9390,7 +9409,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
9390
9409
  textureModel.draw(renderPass);
9391
9410
  renderPass.end();
9392
9411
  } else {
9393
- const renderPass = this.device.beginRenderPass({
9412
+ const renderPass = commandEncoder.beginRenderPass({
9394
9413
  id: `${renderTarget.name}-clear-history`,
9395
9414
  framebuffer: historyFramebuffer,
9396
9415
  clearColor: initialize.clearColor,