Skip to content

Restore layerIndex parameter on deprecated ExternalTexture::AddToContextAsync#1757

Merged
bghgary merged 2 commits into
BabylonJS:masterfrom
bghgary:restore-addtocontextasync-layerindex
Jun 12, 2026
Merged

Restore layerIndex parameter on deprecated ExternalTexture::AddToContextAsync#1757
bghgary merged 2 commits into
BabylonJS:masterfrom
bghgary:restore-addtocontextasync-layerindex

Conversation

@bghgary

@bghgary bghgary commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

[Created by Copilot on behalf of @bghgary]

#1646 kept AddToContextAsync as a deprecated shim but dropped its optional layerIndex parameter:

  • Before: Napi::Promise AddToContextAsync(Napi::Env, std::optional<uint16_t> layerIndex = {}) const;
  • After: Napi::Promise AddToContextAsync(Napi::Env) const;

So callers passing a layer index (e.g. AddToContextAsync(env, 1)) no longer compile. This restores the parameter and forwards it to CreateForJavaScript (keeping [[deprecated]]), plus a test (AddToContextAsyncWithLayerIndex) covering the two-argument form on a 3-layer array texture.

…extAsync

PR BabylonJS#1646 deprecated AddToContextAsync in favor of the synchronous
CreateForJavaScript, but the retained shim dropped the optional
layerIndex parameter. That broke backwards compatibility for existing
callers that pass a layer index (e.g. AddToContextAsync(env, 1)) -- they
no longer compile.

Restore the parameter on the deprecated shim and forward it to
CreateForJavaScript, so both AddToContextAsync(env) and
AddToContextAsync(env, layerIndex) compile and behave as before. The
deprecation is retained to keep steering consumers toward
CreateForJavaScript.

Add a unit test (AddToContextAsyncWithLayerIndex) exercising the
two-argument form against a 3-layer array texture.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 12, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores backward compatibility for Babylon::Plugins::ExternalTexture::AddToContextAsync by reintroducing the optional layerIndex parameter on the deprecated shim and forwarding it to CreateForJavaScript, plus adds a unit test that exercises the two-argument call form on an array texture.

Changes:

  • Re-add std::optional<uint16_t> layerIndex to deprecated AddToContextAsync and forward it to CreateForJavaScript.
  • Update the public header docs to describe layer-slice behavior for the shim.
  • Add a unit test covering AddToContextAsync(env, layerIndex) on a 3-layer array texture.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Plugins/ExternalTexture/Source/ExternalTexture_Shared.h Restores the deprecated shim’s layerIndex parameter and forwards it to CreateForJavaScript.
Plugins/ExternalTexture/Include/Babylon/Plugins/ExternalTexture.h Restores the public API signature (with default arg) and documents layer-slice behavior.
Apps/UnitTests/Source/Tests.ExternalTexture.cpp Adds a new unit test for the two-argument AddToContextAsync call.

Comment thread Apps/UnitTests/Source/Tests.ExternalTexture.cpp Outdated
Per review feedback: std::future::wait() returns even when the promise
rejected (set_exception also makes the future ready), so the test could
pass on rejection. Use EXPECT_NO_THROW(...get()) which rethrows on
rejection so it fails the test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bghgary bghgary enabled auto-merge (squash) June 12, 2026 16:25
@bghgary bghgary merged commit fe380a7 into BabylonJS:master Jun 12, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants