Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Apps/Playground/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ target_link_libraries(Playground
PRIVATE Console
PRIVATE ExternalTexture
PRIVATE GraphicsDevice
PRIVATE NativeTracing
PRIVATE NativeCapture
PRIVATE NativeEncoding
PRIVATE NativeEngine
Expand Down
2 changes: 2 additions & 0 deletions Apps/Playground/Scripts/experience.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const imageCapture = false;
const imageTracking = false;
const readPixels = false;

// BABYLON.Tools.PerformanceLogLevel = BABYLON.Tools.PerformanceConsoleLogLevel;

function CreateBoxAsync(scene) {
BABYLON.Mesh.CreateBox("box1", 0.2, scene);
return Promise.resolve();
Expand Down
3 changes: 3 additions & 0 deletions Apps/Playground/iOS/LibNativeBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import <Babylon/Plugins/NativeEngine.h>
#import <Babylon/Plugins/NativeInput.h>
#import <Babylon/Plugins/NativeOptimizations.h>
#import <Babylon/Plugins/NativeTracing.h>
#import <Babylon/Plugins/NativeXr.h>
#import <Babylon/Polyfills/Blob.h>
#import <Babylon/Polyfills/Canvas.h>
Expand Down Expand Up @@ -88,6 +89,8 @@ - (void)init:(MTKView*)view screenScale:(float)inScreenScale width:(int)inWidth

Babylon::Polyfills::XMLHttpRequest::Initialize(env);

Babylon::Plugins::NativeTracing::Initialize(env);

Babylon::Plugins::NativeCamera::Initialize(env);

Babylon::Plugins::NativeEncoding::Initialize(env);
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ FetchContent_Declare(AndroidExtensions
GIT_REPOSITORY https://github.com/BabylonJS/AndroidExtensions.git
GIT_TAG 66520bff9b57030b67894a4934d18ad7e161ba6f)
FetchContent_Declare(arcana.cpp
GIT_REPOSITORY https://github.com/microsoft/arcana.cpp.git
GIT_TAG c726dbe58713eda65bfb139c257093c43479b894)
GIT_REPOSITORY https://github.com/ryantrem/arcana.cpp.git
GIT_TAG c117bfda6fc855e8e63f6bfb8cf1b66d51026dcb)
FetchContent_Declare(arcore-android-sdk
GIT_REPOSITORY https://github.com/google-ar/arcore-android-sdk.git
GIT_TAG 98cb803de5482fb2b36effe8be3b5a0d3b726976)
Expand All @@ -36,8 +36,8 @@ FetchContent_Declare(ios-cmake
GIT_REPOSITORY https://github.com/leetal/ios-cmake.git
GIT_TAG 4.5.0)
FetchContent_Declare(JsRuntimeHost
GIT_REPOSITORY https://github.com/BabylonJS/JsRuntimeHost.git
GIT_TAG 7964539e733a5cd2cbae7e0155f5391d64a9d45d)
GIT_REPOSITORY https://github.com/ryantrem/JsRuntimeHost.git
GIT_TAG 476b464efc2df8b6b03ed856f2fa4bc703dcde75)
FetchContent_Declare(SPIRV-Cross
GIT_REPOSITORY https://github.com/BabylonJS/SPIRV-Cross.git
GIT_TAG 6abfcf066d171e9ade7604d91381ebebe4209edc)
Expand Down
1 change: 1 addition & 0 deletions Plugins/NativeTracing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target_include_directories(NativeTracing PUBLIC "Include")
target_link_libraries(NativeTracing
PUBLIC napi
PRIVATE JsRuntimeInternal
PRIVATE Foundation
PRIVATE arcana)

set_property(TARGET NativeTracing PROPERTY FOLDER Plugins)
Expand Down
16 changes: 7 additions & 9 deletions Plugins/NativeTracing/Source/NativeTracing.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
#include <Babylon/Plugins/NativeTracing.h>
#include <Babylon/JsRuntime.h>
#include <napi/pointer.h>
#include <arcana/tracing/trace_region.h>
#include <optional>
#include <Babylon/PerfTrace.h>

namespace
{
Napi::Value StartPerformanceCounter(const Napi::CallbackInfo& info)
{
const std::string name{info[0].As<Napi::String>().Utf8Value()};
auto* traceRegion = new std::optional<arcana::trace_region>(name.c_str());
return Napi::Pointer<std::optional<arcana::trace_region>>::Create(info.Env(), traceRegion, Napi::NapiPointerDeleter(traceRegion));
return Babylon::PerfTrace::Handle::ToNapi(info.Env(), Babylon::PerfTrace::Trace(name.c_str()));
}

void EndPerformanceCounter(const Napi::CallbackInfo& info)
{
info[0].As<Napi::Pointer<std::optional<arcana::trace_region>>>().Get()->reset();
Babylon::PerfTrace::Handle::FromNapi(info[0]);
}

void EnablePerformanceTracing(const Napi::CallbackInfo&)
void EnablePerformanceTracing(const Napi::CallbackInfo& info)
{
arcana::trace_region::enable();
const auto level = (info.Length() > 0 && info[0].As<Napi::Number>().Int32Value()) ? Babylon::PerfTrace::Level::Log : Babylon::PerfTrace::Level::Mark;
Babylon::PerfTrace::SetLevel(level);
}

void DisablePerformanceTracing(const Napi::CallbackInfo&)
{
arcana::trace_region::disable();
Babylon::PerfTrace::SetLevel(Babylon::PerfTrace::Level::None);
}
}

Expand Down