@luma.gl/engine 9.4.0-alpha.2 → 9.4.0-alpha.4
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/animation-loop/make-animation-loop.d.ts +9 -1
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +20 -4
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/compute/computation.d.ts +3 -0
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +23 -9
- package/dist/compute/computation.js.map +1 -1
- package/dist/dist.dev.js +67 -20
- package/dist/dist.min.js +8 -8
- package/dist/index.cjs +68 -20
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/model.d.ts +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.d.ts +13 -1
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +31 -12
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/package.json +2 -2
- package/src/animation-loop/make-animation-loop.ts +32 -5
- package/src/compute/computation.ts +25 -12
- package/src/index.ts +1 -0
- package/src/model/model.ts +1 -1
- package/src/passes/shader-pass-renderer.ts +43 -12
package/dist/index.cjs
CHANGED
|
@@ -785,7 +785,11 @@ __publicField(AnimationLoop, "defaultAnimationLoopProps", {
|
|
|
785
785
|
var import_core3 = require("@luma.gl/core");
|
|
786
786
|
function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
787
787
|
let renderLoop = null;
|
|
788
|
-
const device = (props == null ? void 0 : props.device) || import_core3.luma.createDevice({
|
|
788
|
+
const device = (props == null ? void 0 : props.device) || import_core3.luma.createDevice({
|
|
789
|
+
id: "animation-loop",
|
|
790
|
+
adapters: props == null ? void 0 : props.adapters,
|
|
791
|
+
createCanvasContext: true
|
|
792
|
+
});
|
|
789
793
|
const animationLoop = new AnimationLoop({
|
|
790
794
|
...props,
|
|
791
795
|
device,
|
|
@@ -802,13 +806,25 @@ function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
|
802
806
|
return null;
|
|
803
807
|
}
|
|
804
808
|
},
|
|
805
|
-
onRender
|
|
806
|
-
|
|
809
|
+
onRender(animationProps) {
|
|
810
|
+
var _a;
|
|
811
|
+
renderLoop == null ? void 0 : renderLoop.onRender(animationProps);
|
|
812
|
+
(_a = props == null ? void 0 : props.onAfterRender) == null ? void 0 : _a.call(props, animationProps, renderLoop);
|
|
813
|
+
},
|
|
814
|
+
onFinalize(animationProps) {
|
|
815
|
+
try {
|
|
816
|
+
renderLoop == null ? void 0 : renderLoop.onFinalize(animationProps);
|
|
817
|
+
} finally {
|
|
818
|
+
renderLoop = null;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
807
821
|
});
|
|
822
|
+
const templateAnimationLoop = animationLoop;
|
|
823
|
+
templateAnimationLoop.getAnimationLoopTemplate = () => renderLoop;
|
|
808
824
|
animationLoop.getInfo = () => {
|
|
809
825
|
return this.AnimationLoopTemplateCtor.info;
|
|
810
826
|
};
|
|
811
|
-
return
|
|
827
|
+
return templateAnimationLoop;
|
|
812
828
|
}
|
|
813
829
|
function setError(device, error) {
|
|
814
830
|
var _a;
|
|
@@ -6790,14 +6806,22 @@ var ShaderPassRenderer = class {
|
|
|
6790
6806
|
}
|
|
6791
6807
|
}
|
|
6792
6808
|
renderToScreen(options) {
|
|
6793
|
-
|
|
6809
|
+
return this.encodeToScreen(this.device.commandEncoder, options);
|
|
6810
|
+
}
|
|
6811
|
+
/**
|
|
6812
|
+
* Records the shader-pass chain and presentation into a caller-owned command encoder.
|
|
6813
|
+
* The encoder must belong to this renderer's device and have no active pass. This method does
|
|
6814
|
+
* not finish or submit the encoder.
|
|
6815
|
+
*/
|
|
6816
|
+
encodeToScreen(commandEncoder, options) {
|
|
6817
|
+
const outputTexture = this.encodeToTexture(commandEncoder, options);
|
|
6794
6818
|
if (!outputTexture) {
|
|
6795
6819
|
return false;
|
|
6796
6820
|
}
|
|
6797
6821
|
const framebuffer = this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
|
|
6798
6822
|
this.textureModel.setProps({ backgroundTexture: outputTexture });
|
|
6799
|
-
this.textureModel.predraw(
|
|
6800
|
-
const renderPass =
|
|
6823
|
+
this.textureModel.predraw(commandEncoder);
|
|
6824
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
6801
6825
|
id: "shader-pass-renderer-to-screen",
|
|
6802
6826
|
framebuffer,
|
|
6803
6827
|
clearDepth: false
|
|
@@ -6810,6 +6834,17 @@ var ShaderPassRenderer = class {
|
|
|
6810
6834
|
* @returns null if the the sourceTexture has not yet been loaded
|
|
6811
6835
|
*/
|
|
6812
6836
|
renderToTexture(options) {
|
|
6837
|
+
return this.encodeToTexture(this.device.commandEncoder, options);
|
|
6838
|
+
}
|
|
6839
|
+
/**
|
|
6840
|
+
* Records the shader-pass chain into a caller-owned command encoder.
|
|
6841
|
+
* The encoder must belong to this renderer's device and have no active pass. This method does
|
|
6842
|
+
* not finish or submit the encoder.
|
|
6843
|
+
*/
|
|
6844
|
+
encodeToTexture(commandEncoder, options) {
|
|
6845
|
+
if (commandEncoder.device !== this.device) {
|
|
6846
|
+
throw new Error("ShaderPassRenderer command encoder must belong to the renderer device");
|
|
6847
|
+
}
|
|
6813
6848
|
const { sourceTexture } = options;
|
|
6814
6849
|
if (sourceTexture instanceof DynamicTexture && !sourceTexture.isReady) {
|
|
6815
6850
|
return null;
|
|
@@ -6822,9 +6857,9 @@ var ShaderPassRenderer = class {
|
|
|
6822
6857
|
this.resetHistory();
|
|
6823
6858
|
}
|
|
6824
6859
|
this.textureModel.setProps({ backgroundTexture: originalTexture });
|
|
6825
|
-
this.textureModel.predraw(
|
|
6860
|
+
this.textureModel.predraw(commandEncoder);
|
|
6826
6861
|
const sourceFramebuffer = getSeedFramebuffer(this.swapFramebuffers, originalTexture);
|
|
6827
|
-
const seedRenderPass =
|
|
6862
|
+
const seedRenderPass = commandEncoder.beginRenderPass({
|
|
6828
6863
|
id: "shader-pass-renderer-seed-source",
|
|
6829
6864
|
framebuffer: sourceFramebuffer,
|
|
6830
6865
|
clearColor: [0, 0, 0, 1],
|
|
@@ -6837,7 +6872,7 @@ var ShaderPassRenderer = class {
|
|
|
6837
6872
|
let frameSucceeded = false;
|
|
6838
6873
|
try {
|
|
6839
6874
|
for (const passRenderer of this.passRenderers) {
|
|
6840
|
-
passRenderer.initializeHistoryTargets(originalTexture, this.textureModel);
|
|
6875
|
+
passRenderer.initializeHistoryTargets(originalTexture, this.textureModel, commandEncoder);
|
|
6841
6876
|
for (const execution of passRenderer.subPassExecutions) {
|
|
6842
6877
|
const outputName = execution.output || "previous";
|
|
6843
6878
|
const outputFramebuffer = outputName === "previous" ? getNextPreviousFramebuffer(this.swapFramebuffers, previousFramebuffer) : passRenderer.getOutputFramebuffer(outputName);
|
|
@@ -6851,12 +6886,12 @@ var ShaderPassRenderer = class {
|
|
|
6851
6886
|
});
|
|
6852
6887
|
const resolvedUniforms = resolveExecutionUniforms(this.shaderInputs, execution, options.uniforms || {});
|
|
6853
6888
|
execution.subPassRenderer.prepare({
|
|
6854
|
-
commandEncoder
|
|
6889
|
+
commandEncoder,
|
|
6855
6890
|
bindings: resolvedBindings,
|
|
6856
6891
|
textureScale: calculateTextureScale(resolvedBindings["sourceTexture"] || previousTexture, outputTexture),
|
|
6857
6892
|
uniforms: resolvedUniforms
|
|
6858
6893
|
});
|
|
6859
|
-
const renderPass =
|
|
6894
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
6860
6895
|
id: "shader-pass-renderer-run-pass",
|
|
6861
6896
|
framebuffer: outputFramebuffer,
|
|
6862
6897
|
clearColor: [0, 0, 0, 1],
|
|
@@ -6919,7 +6954,7 @@ var PassRenderer = class {
|
|
|
6919
6954
|
renderTarget.writtenThisFrame = false;
|
|
6920
6955
|
}
|
|
6921
6956
|
}
|
|
6922
|
-
initializeHistoryTargets(originalTexture, textureModel) {
|
|
6957
|
+
initializeHistoryTargets(originalTexture, textureModel, commandEncoder) {
|
|
6923
6958
|
for (const renderTarget of Object.values(this.renderTargets)) {
|
|
6924
6959
|
if (renderTarget.spec.lifetime !== "history" || renderTarget.historyInitialized) {
|
|
6925
6960
|
continue;
|
|
@@ -6930,8 +6965,8 @@ var PassRenderer = class {
|
|
|
6930
6965
|
};
|
|
6931
6966
|
if (initialize === "original") {
|
|
6932
6967
|
textureModel.setProps({ backgroundTexture: originalTexture });
|
|
6933
|
-
textureModel.predraw(
|
|
6934
|
-
const renderPass =
|
|
6968
|
+
textureModel.predraw(commandEncoder);
|
|
6969
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
6935
6970
|
id: `${renderTarget.name}-initialize-history`,
|
|
6936
6971
|
framebuffer: historyFramebuffer,
|
|
6937
6972
|
clearColor: [0, 0, 0, 0],
|
|
@@ -6940,7 +6975,7 @@ var PassRenderer = class {
|
|
|
6940
6975
|
textureModel.draw(renderPass);
|
|
6941
6976
|
renderPass.end();
|
|
6942
6977
|
} else {
|
|
6943
|
-
const renderPass =
|
|
6978
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
6944
6979
|
id: `${renderTarget.name}-clear-history`,
|
|
6945
6980
|
framebuffer: historyFramebuffer,
|
|
6946
6981
|
clearColor: initialize.clearColor,
|
|
@@ -7354,15 +7389,28 @@ var _Computation = class {
|
|
|
7354
7389
|
dispatch(computePass, x, y, z) {
|
|
7355
7390
|
try {
|
|
7356
7391
|
this._logDrawCallStart();
|
|
7357
|
-
this.
|
|
7358
|
-
this.pipeline.setBindings(this.bindings);
|
|
7359
|
-
computePass.setPipeline(this.pipeline);
|
|
7360
|
-
computePass.setBindings({});
|
|
7392
|
+
this._setPipeline(computePass);
|
|
7361
7393
|
computePass.dispatch(x, y, z);
|
|
7362
7394
|
} finally {
|
|
7363
7395
|
this._logDrawCallEnd();
|
|
7364
7396
|
}
|
|
7365
7397
|
}
|
|
7398
|
+
/** Dispatches a GPU-written workgroup count from an indirect buffer. */
|
|
7399
|
+
dispatchIndirect(computePass, indirectBuffer, indirectOffset = 0) {
|
|
7400
|
+
try {
|
|
7401
|
+
this._logDrawCallStart();
|
|
7402
|
+
this._setPipeline(computePass);
|
|
7403
|
+
computePass.dispatchIndirect(indirectBuffer, indirectOffset);
|
|
7404
|
+
} finally {
|
|
7405
|
+
this._logDrawCallEnd();
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
_setPipeline(computePass) {
|
|
7409
|
+
this.pipeline = this._updatePipeline();
|
|
7410
|
+
this.pipeline.setBindings(this.bindings);
|
|
7411
|
+
computePass.setPipeline(this.pipeline);
|
|
7412
|
+
computePass.setBindings({});
|
|
7413
|
+
}
|
|
7366
7414
|
// Update fixed fields (can trigger pipeline rebuild)
|
|
7367
7415
|
// Update dynamic fields
|
|
7368
7416
|
/**
|