Skip to content

Commit bfaa250

Browse files
authored
Add more perf tracing (#1572)
- Update JSRuntimeHost to latest (includes perf tracing for ScriptLoader) - Add trace regions for CreateProgram and LoadTexture - Update BJS to the latest which has support for routing JS side perf tracing to native - Disable perf tracing by default in the experience.js script - Enable perf tracing in native for the iOS Playground app so we can pick up and test the ScriptLoader perf traces (since we can't wait for JS code to enable perf tracing if we want to see ScriptLoader timing 😀)
1 parent 4c76fc4 commit bfaa250

File tree

7 files changed

+63
-66
lines changed

7 files changed

+63
-66
lines changed

Apps/Playground/Scripts/experience.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const cameraTexture = false;
1919
const imageCapture = false;
2020
const imageTracking = false;
2121
const readPixels = false;
22-
const logPerf = true;
22+
const logPerf = false;
2323

2424
if (logPerf) {
2525
BABYLON.Tools.PerformanceLogLevel = BABYLON.Tools.PerformanceConsoleLogLevel;
@@ -53,22 +53,22 @@ const scene = new BABYLON.Scene(engine);
5353

5454
CreateBoxAsync(scene).then(function () {
5555
//CreateSpheresAsync(scene).then(function () {
56-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Box/glTF/Box.gltf").then(function () {
57-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoxTextured/glTF/BoxTextured.gltf").then(function () {
58-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Suzanne/glTF/Suzanne.gltf").then(function () {
59-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Avocado/glTF/Avocado.gltf").then(function () {
60-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoomBox/glTF/BoomBox.gltf").then(function () {
61-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Sponza/glTF/Sponza.gltf").then(function () {
62-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BrainStem/glTF/BrainStem.gltf").then(function () {
63-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/FlightHelmet/glTF/FlightHelmet.gltf").then(function () {
64-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/EnvironmentTest/glTF/EnvironmentTest.gltf").then(function () {
65-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoxAnimated/glTF/BoxAnimated.gltf").then(function () {
66-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/AnimatedMorphCube/glTF/AnimatedMorphCube.gltf").then(function () {
67-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/RiggedSimple/glTF/RiggedSimple.gltf").then(function () {
68-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/stevk/glTF-Asset-Generator/skins/Output/Animation_Skin/Animation_Skin_01.gltf").then(function () {
69-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/RiggedFigure/glTF/RiggedFigure.gltf").then(function () {
70-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMan/glTF/CesiumMan.gltf").then(function () {
71-
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/ClearCoatTest/glTF/ClearCoatTest.gltf").then(function () {
56+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Box/glTF/Box.gltf").then(function () {
57+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoxTextured/glTF/BoxTextured.gltf").then(function () {
58+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Suzanne/glTF/Suzanne.gltf").then(function () {
59+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Avocado/glTF/Avocado.gltf").then(function () {
60+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoomBox/glTF/BoomBox.gltf", scene).then(function () {
61+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Sponza/glTF/Sponza.gltf").then(function () {
62+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BrainStem/glTF/BrainStem.gltf").then(function () {
63+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/FlightHelmet/glTF/FlightHelmet.gltf").then(function () {
64+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/EnvironmentTest/glTF/EnvironmentTest.gltf").then(function () {
65+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoxAnimated/glTF/BoxAnimated.gltf").then(function () {
66+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/AnimatedMorphCube/glTF/AnimatedMorphCube.gltf").then(function () {
67+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/RiggedSimple/glTF/RiggedSimple.gltf").then(function () {
68+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/stevk/glTF-Asset-Generator/skins/Output/Animation_Skin/Animation_Skin_01.gltf").then(function () {
69+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/RiggedFigure/glTF/RiggedFigure.gltf").then(function () {
70+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMan/glTF/CesiumMan.gltf").then(function () {
71+
//BABYLON.AppendSceneAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/ClearCoatTest/glTF/ClearCoatTest.gltf").then(function () {
7272
BABYLON.Tools.Log("Loaded");
7373

7474
// This creates and positions a free camera (non-mesh)

Apps/Playground/iOS/LibNativeBridge.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import <Babylon/Polyfills/Window.h>
1717
#import <Babylon/Polyfills/XMLHttpRequest.h>
1818
#import <Babylon/DebugTrace.h>
19+
#import <Babylon/PerfTrace.h>
1920
#import <optional>
2021

2122
std::optional<Babylon::Graphics::Device> device{};
@@ -59,6 +60,7 @@ - (void)init:(MTKView*)view screenScale:(float)inScreenScale width:(int)inWidth
5960

6061
Babylon::DebugTrace::EnableDebugTrace(true);
6162
Babylon::DebugTrace::SetTraceOutput([](const char* trace) { NSLog(@"%s", trace); });
63+
Babylon::PerfTrace::SetLevel(Babylon::PerfTrace::Level::Mark);
6264

6365
Babylon::Graphics::Configuration graphicsConfig{};
6466
graphicsConfig.Window = view;

Apps/UnitTests/JavaScript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"watch": "webpack -watch"
88
},
99
"dependencies": {
10-
"babylonjs": "^8.37.0",
11-
"babylonjs-materials": "^8.37.0",
10+
"babylonjs": "^8.37.1",
11+
"babylonjs-materials": "^8.37.1",
1212
"chai": "^5.2.0",
1313
"jsc-android": "^241213.1.0",
1414
"mocha": "^11.1.0",

Apps/package-lock.json

Lines changed: 33 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Apps/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"getNightly": "node scripts/getNightly.js"
1010
},
1111
"dependencies": {
12-
"babylonjs": "^8.37.0",
13-
"babylonjs-gltf2interface": "^8.37.0",
14-
"babylonjs-gui": "^8.37.0",
15-
"babylonjs-loaders": "^8.37.0",
16-
"babylonjs-materials": "^8.37.0",
17-
"babylonjs-serializers": "^8.37.0",
12+
"babylonjs": "^8.37.1",
13+
"babylonjs-gltf2interface": "^8.37.1",
14+
"babylonjs-gui": "^8.37.1",
15+
"babylonjs-loaders": "^8.37.1",
16+
"babylonjs-materials": "^8.37.1",
17+
"babylonjs-serializers": "^8.37.1",
1818
"jsc-android": "^241213.1.0",
1919
"v8-android": "^7.8.2"
2020
}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ FetchContent_Declare(ios-cmake
3737
GIT_TAG 4.5.0)
3838
FetchContent_Declare(JsRuntimeHost
3939
GIT_REPOSITORY https://github.com/BabylonJS/JsRuntimeHost.git
40-
GIT_TAG 76f2c8f224855b53196f4fde691a9f4c08c8b8aa)
40+
GIT_TAG b3dbf370caf560fb5b93936efd4cdf4e990d4d0a)
4141
FetchContent_Declare(SPIRV-Cross
4242
GIT_REPOSITORY https://github.com/BabylonJS/SPIRV-Cross.git
4343
GIT_TAG 6abfcf066d171e9ade7604d91381ebebe4209edc)

Plugins/NativeEngine/Source/NativeEngine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ namespace Babylon
999999

10001000
std::unique_ptr<ProgramData> NativeEngine::CreateProgramInternal(const std::string vertexSource, const std::string fragmentSource)
10011001
{
1002+
arcana::trace_region region{"NativeEngine::CreateProgramInternal"};
10021003
const ShaderCompiler::BgfxShaderInfo* shaderInfo{};
10031004
ShaderCompiler::BgfxShaderInfo bgfxShaderInfo{};
10041005
if (ShaderCacheImpl::GetImpl())
@@ -1436,6 +1437,7 @@ namespace Babylon
14361437

14371438
arcana::make_task(arcana::threadpool_scheduler, *m_cancellationSource,
14381439
[dataSpan, generateMips, invertY, srgb, texture, cancellationSource{m_cancellationSource}]() {
1440+
arcana::trace_region loadRegion{"NativeEngine::LoadTexture"};
14391441
bimg::ImageContainer* image{ParseImage(Graphics::DeviceContext::GetDefaultAllocator(), dataSpan)};
14401442
image = PrepareImage(Graphics::DeviceContext::GetDefaultAllocator(), image, invertY, srgb, generateMips);
14411443
LoadTextureFromImage(texture, image, srgb);

0 commit comments

Comments
 (0)