Skip to content

Commit 4e6618d

Browse files
Merge remote-tracking branch 'upstream/master' into hermes-integration
# Conflicts: # CMakeLists.txt
2 parents ce4c0eb + b6ecf80 commit 4e6618d

68 files changed

Lines changed: 2242 additions & 943 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-uwp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
build:
16-
runs-on: windows-latest
16+
runs-on: windows-2022
1717
timeout-minutes: 30
1818
steps:
1919
- uses: actions/checkout@v5

.github/workflows/build-win32-shader.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
build:
13-
runs-on: windows-latest
13+
runs-on: windows-2022
1414
timeout-minutes: 30
1515
steps:
1616
- uses: actions/checkout@v5

.github/workflows/build-win32.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121

2222
jobs:
2323
build:
24-
runs-on: windows-latest
24+
runs-on: windows-2022
2525
timeout-minutes: 60
2626
steps:
2727
- uses: actions/checkout@v5

.github/workflows/test-install-win32.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
test-install:
8-
runs-on: windows-latest
8+
runs-on: windows-2022
99
timeout-minutes: 30
1010
steps:
1111
- uses: actions/checkout@v5

Apps/HeadlessScreenshotApp/Win32/App.cpp

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -127,41 +127,37 @@ int main()
127127
// Create a render target texture for the output.
128128
winrt::com_ptr<ID3D11Texture2D> outputTexture = CreateD3DRenderTargetTexture(d3dDevice.get());
129129

130-
std::promise<void> addToContext{};
130+
// Close the script-load frame.
131+
deviceUpdate.Finish();
132+
device.FinishRenderingCurrentFrame();
133+
134+
// Open a new frame for `startup` so the JS-side resource creation and
135+
// startup() call run in the same frame as the wait that observes them.
136+
device.StartRenderingCurrentFrame();
137+
deviceUpdate.Start();
138+
131139
std::promise<void> startup{};
132140

133141
// Create an external texture for the render target texture and pass it to
134142
// the `startup` JavaScript function.
135-
loader.Dispatch([externalTexture = Babylon::Plugins::ExternalTexture{outputTexture.get()}, &addToContext, &startup](Napi::Env env) {
136-
auto jsPromise = externalTexture.AddToContextAsync(env);
137-
addToContext.set_value();
138-
139-
auto jsOnFulfilled = Napi::Function::New(env, [&startup](const Napi::CallbackInfo& info) {
140-
auto nativeTexture = info[0];
141-
info.Env().Global().Get("startup").As<Napi::Function>().Call(
142-
{
143-
nativeTexture,
144-
Napi::Value::From(info.Env(), WIDTH),
145-
Napi::Value::From(info.Env(), HEIGHT),
146-
});
147-
startup.set_value();
148-
});
149-
150-
jsPromise = jsPromise.Get("then").As<Napi::Function>().Call(jsPromise, {jsOnFulfilled}).As<Napi::Promise>();
151-
152-
CatchAndLogError(jsPromise);
143+
loader.Dispatch([externalTexture = Babylon::Plugins::ExternalTexture{outputTexture.get()}, &startup](Napi::Env env) {
144+
auto nativeTexture = externalTexture.CreateForJavaScript(env);
145+
env.Global().Get("startup").As<Napi::Function>().Call(
146+
{
147+
nativeTexture,
148+
Napi::Value::From(env, WIDTH),
149+
Napi::Value::From(env, HEIGHT),
150+
});
151+
startup.set_value();
153152
});
154153

155-
// Wait for `AddToContextAsync` to be called.
156-
addToContext.get_future().wait();
154+
// Wait for `startup` to finish.
155+
startup.get_future().wait();
157156

158-
// Render a frame so that `AddToContextAsync` will complete.
157+
// Close the startup frame.
159158
deviceUpdate.Finish();
160159
device.FinishRenderingCurrentFrame();
161160

162-
// Wait for `startup` to finish.
163-
startup.get_future().wait();
164-
165161
struct Asset
166162
{
167163
const char* Name;

Apps/ModuleLoadTest/Source/App.Win32.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ namespace ModuleLoadTest
129129
"dxil.dll",
130130
// VS Start-Without-Debugging launch environment
131131
"kernel.appcore.dll",
132+
// Ambient shell/appcore DLL pulled in transitively (e.g. via
133+
// windows.storage.dll / DComp) on some Windows images such as the
134+
// GitHub windows-2022 runner; not introduced by BabylonNative.
135+
"twinapi.appcore.dll",
132136
};
133137
for (const auto& prefix : kPrefixes)
134138
{

Apps/Playground/Scripts/config.json

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,9 +1568,7 @@
15681568
"title": "Particles",
15691569
"playgroundId": "#G3ZYFU#7",
15701570
"renderCount": 100,
1571-
"referenceImage": "particles.png",
1572-
"excludeFromAutomaticTesting": true,
1573-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
1571+
"referenceImage": "particles.png"
15741572
},
15751573
{
15761574
"title": "PBRMetallicRoughnessMaterial",
@@ -1842,16 +1840,14 @@
18421840
{
18431841
"title": "Instances with color buffer",
18441842
"playgroundId": "#YPABS1#91",
1845-
"excludeFromAutomaticTesting": true,
1846-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
18471843
"referenceImage": "instancecolors.png"
18481844
},
18491845
{
18501846
"title": "Prepass SSAO + particles",
18511847
"playgroundId": "#65MUMZ#47",
18521848
"renderCount": 50,
18531849
"excludeFromAutomaticTesting": true,
1854-
"reason": "Test crashes or hangs on Babylon Native",
1850+
"reason": "SSAO2 blur post-process shader fails to compile on desktop GL (samples uniform used as int loop bound); unrelated to instancing.",
18551851
"referenceImage": "prepass-ssao-particles.png"
18561852
},
18571853
{
@@ -2694,8 +2690,6 @@
26942690
"title": "halo-particle-system",
26952691
"playgroundId": "#2441BU#1",
26962692
"renderCount": 20,
2697-
"excludeFromAutomaticTesting": true,
2698-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up.",
26992693
"referenceImage": "halo-particle-system.png"
27002694
},
27012695
{
@@ -2710,8 +2704,6 @@
27102704
"title": "particle-system-with-custom-nme-shader",
27112705
"playgroundId": "#DMLLV2",
27122706
"renderCount": 5,
2713-
"excludeFromAutomaticTesting": true,
2714-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up.",
27152707
"referenceImage": "particle-system-with-custom-nme-shader.png"
27162708
},
27172709
{
@@ -4106,9 +4098,7 @@
41064098
"title": "Particles - Basic Properties - Color",
41074099
"playgroundId": "#0K3AQ2#3786",
41084100
"renderCount": 120,
4109-
"referenceImage": "particles-basic-color.png",
4110-
"excludeFromAutomaticTesting": true,
4111-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4101+
"referenceImage": "particles-basic-color.png"
41124102
},
41134103
{
41144104
"title": "Particles - Basic Properties - Speed",
@@ -4138,9 +4128,7 @@
41384128
"title": "Particles - Basic Properties - Direction",
41394129
"playgroundId": "#0K3AQ2#3814",
41404130
"renderCount": 120,
4141-
"referenceImage": "particles-basic-direction.png",
4142-
"excludeFromAutomaticTesting": true,
4143-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4131+
"referenceImage": "particles-basic-direction.png"
41444132
},
41454133
{
41464134
"title": "Particles - Basic Properties - Direction - Gravity",
@@ -4158,9 +4146,7 @@
41584146
"title": "Particles - Basic Properties - Emit Rate - Fast",
41594147
"playgroundId": "#0K3AQ2#3823",
41604148
"renderCount": 120,
4161-
"referenceImage": "particles-basic-emit-rate-fast.png",
4162-
"excludeFromAutomaticTesting": true,
4163-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4149+
"referenceImage": "particles-basic-emit-rate-fast.png"
41644150
},
41654151
{
41664152
"title": "Particles - Basic Properties - Emission Limits",
@@ -4184,9 +4170,7 @@
41844170
"title": "Particles - Change - Size",
41854171
"playgroundId": "#0K3AQ2#3841",
41864172
"renderCount": 120,
4187-
"referenceImage": "particles-basic-change-size.png",
4188-
"excludeFromAutomaticTesting": true,
4189-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4173+
"referenceImage": "particles-basic-change-size.png"
41904174
},
41914175
{
41924176
"title": "Particles - Change - Size 2",
@@ -4198,17 +4182,13 @@
41984182
"title": "Particles - Change - Color",
41994183
"playgroundId": "#0K3AQ2#3847",
42004184
"renderCount": 120,
4201-
"referenceImage": "particles-basic-change-color.png",
4202-
"excludeFromAutomaticTesting": true,
4203-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4185+
"referenceImage": "particles-basic-change-color.png"
42044186
},
42054187
{
42064188
"title": "Particles - Change - Color 2",
42074189
"playgroundId": "#0K3AQ2#3851",
42084190
"renderCount": 120,
4209-
"referenceImage": "particles-basic-change-color-2.png",
4210-
"excludeFromAutomaticTesting": true,
4211-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4191+
"referenceImage": "particles-basic-change-color-2.png"
42124192
},
42134193
{
42144194
"title": "Particles - Change - Speed",
@@ -4268,9 +4248,7 @@
42684248
"title": "Particles - Change - Lifetime",
42694249
"playgroundId": "#0K3AQ2#3885",
42704250
"renderCount": 120,
4271-
"referenceImage": "particles-basic-change-lifetime.png",
4272-
"excludeFromAutomaticTesting": true,
4273-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4251+
"referenceImage": "particles-basic-change-lifetime.png"
42744252
},
42754253
{
42764254
"title": "Particles - Change - Lifetime 2",
@@ -4288,25 +4266,19 @@
42884266
"title": "Particles - Emitters - Point",
42894267
"playgroundId": "#WLX2I2#7",
42904268
"renderCount": 120,
4291-
"referenceImage": "particles-emitters-point.png",
4292-
"excludeFromAutomaticTesting": true,
4293-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4269+
"referenceImage": "particles-emitters-point.png"
42944270
},
42954271
{
42964272
"title": "Particles - Emitters - Box",
42974273
"playgroundId": "#WLX2I2#8",
42984274
"renderCount": 120,
4299-
"referenceImage": "particles-emitters-box.png",
4300-
"excludeFromAutomaticTesting": true,
4301-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4275+
"referenceImage": "particles-emitters-box.png"
43024276
},
43034277
{
43044278
"title": "Particles - Emitters - Sphere",
43054279
"playgroundId": "#WLX2I2#9",
43064280
"renderCount": 120,
4307-
"referenceImage": "particles-emitters-sphere.png",
4308-
"excludeFromAutomaticTesting": true,
4309-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4281+
"referenceImage": "particles-emitters-sphere.png"
43104282
},
43114283
{
43124284
"title": "Particles - Emitters - Directed Sphere",
@@ -4324,9 +4296,7 @@
43244296
"title": "Particles - Emitters - Cylinder",
43254297
"playgroundId": "#WLX2I2#12",
43264298
"renderCount": 120,
4327-
"referenceImage": "particles-emitters-cylinder.png",
4328-
"excludeFromAutomaticTesting": true,
4329-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4299+
"referenceImage": "particles-emitters-cylinder.png"
43304300
},
43314301
{
43324302
"title": "Particles - Emitters - Directed Cylinder",
@@ -4346,9 +4316,7 @@
43464316
"title": "Particles - Emitters - Directed Cone",
43474317
"playgroundId": "#WLX2I2#17",
43484318
"renderCount": 120,
4349-
"referenceImage": "particles-emitters-directed-cone.png",
4350-
"excludeFromAutomaticTesting": true,
4351-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up."
4319+
"referenceImage": "particles-emitters-directed-cone.png"
43524320
},
43534321
{
43544322
"title": "Particles - Emitters - Mesh",
@@ -4458,8 +4426,6 @@
44584426
"title": "Particles - Attractors",
44594427
"playgroundId": "#DEZ79M#73",
44604428
"renderCount": 240,
4461-
"excludeFromAutomaticTesting": true,
4462-
"reason": "Pixel diff after #1691 instance-data stride fix; not stride-related, needs follow-up.",
44634429
"referenceImage": "particles-attractors.png"
44644430
},
44654431
{

Apps/Playground/Shared/Diagnostics.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "Diagnostics.h"
22

3+
#include <bx/bx.h>
34
#include <bx/debug.h>
45
#include <bx/error.h>
56
#include <bx/platform.h>
@@ -110,6 +111,57 @@ namespace
110111
std::_Exit(3);
111112
}
112113
#endif
114+
115+
// bx routes BOTH BX_ASSERT failures and the Windows SEH top-level
116+
// exception filter (bx::installExceptionHandler) through its assert
117+
// handler. bx's built-in default writes the banner only to
118+
// bx::getDebugOut() (OutputDebugString), which is invisible in a console /
119+
// CI run, and then tears the process down via TerminateProcess -- so the
120+
// native callstack never reaches the log and atexit (the finish line)
121+
// never runs. Route it through DumpFailure instead, which writes to stderr
122+
// (captured by CI), then exit deterministically with code 3 like the other
123+
// hard-failure handlers above.
124+
bool OnBxAssert(const bx::Location& location, uint32_t skip, const char* format, va_list args)
125+
{
126+
// Guard against re-entry if formatting/stack-walking itself faults.
127+
// Returning false here would tell bx to *continue* past the failed
128+
// assert / propagate the exception, i.e. keep running in an
129+
// already-failing state. Instead fail fast deterministically: skip the
130+
// (faulting) formatting path, emit a minimal marker, and exit.
131+
static std::atomic<bool> s_inHandler{false};
132+
bool expected = false;
133+
if (!s_inHandler.compare_exchange_strong(expected, true))
134+
{
135+
std::fputs("\n--- BN: CRASH (re-entrant) ---\n", stderr);
136+
std::fflush(stderr);
137+
Diagnostics::SetExitCode(3);
138+
Diagnostics::PrintFinishLine();
139+
std::_Exit(3);
140+
}
141+
142+
// bx's exception-handler call sites (SEH filter, pure-call) pass
143+
// UINT32_MAX as the line and a synthetic file ("Exception Handler");
144+
// real BX_ASSERT sites pass an actual file/line.
145+
const bool isException = (location.line == UINT32_MAX);
146+
Diagnostics::DumpFailureV(
147+
isException ? "CRASH" : "ASSERT",
148+
isException ? nullptr : location.filePath,
149+
isException ? 0 : static_cast<int>(location.line),
150+
skip,
151+
format,
152+
args);
153+
154+
#if defined(_MSC_VER)
155+
if (::IsDebuggerPresent())
156+
{
157+
bx::debugBreak();
158+
}
159+
#endif
160+
161+
Diagnostics::SetExitCode(3);
162+
Diagnostics::PrintFinishLine();
163+
std::_Exit(3);
164+
}
113165
}
114166

115167
namespace Diagnostics
@@ -124,6 +176,10 @@ namespace Diagnostics
124176

125177
bx::installExceptionHandler();
126178

179+
// Route bx asserts + the SEH top-level exception filter to DumpFailure
180+
// (stderr-visible) instead of bx's OutputDebugString-only default.
181+
bx::setAssertHandler(&OnBxAssert);
182+
127183
#if defined(_MSC_VER)
128184
// Route assert() to stderr instead of UCRT's modal dialog. Covers the
129185
// direct assert() codepath; _CrtSetReportMode below covers _CRT_*.

0 commit comments

Comments
 (0)