Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 1k/build.profiles
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ lz4=v1.10.0
sample-assets=v3.0.0-alpha22
live2d-core=5.5
openxr=release-1.1.61
tracy=v0.13.1
# --- endregion
3 changes: 3 additions & 0 deletions 1k/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
},
"live2d-core": {
"sources": { "origin": "https://github.com/axmolengine/live2d-axmol/releases/download/prebuilt/live2d-core-${ver}.zip" }
},
"tracy": {
"sources": { "origin": "https://github.com/wolfpld/tracy.git" }
}
},
"devtools": {
Expand Down
15 changes: 15 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option(AX_WITH_WEBP "Build with internal webp support" ON)
option(AX_WITH_CLIPPER2 "Build with internal Clipper2 support" ON)
option(AX_WITH_POLY2TRI "Build with internal poly2tri support" ON)
option(AX_WITH_FASTLZ "Build with internal fastlz support" ON)
option(AX_WITH_TRACY "Build with internal Tracy support" ON)

option(AX_WITH_CURL "Build with internal curl support" ON)
option(AX_WITH_UNZIP "Build with internal unzip support" ON)
Expand Down Expand Up @@ -424,6 +425,20 @@ if(WIN32 AND AX_GLES_PROFILE)
endif()
endif()

# tracy
if(AX_PROFILER_BACKEND STREQUAL "TRACY")
set(AX_WITH_TRACY ON CACHE BOOL "" FORCE)
else()
set(AX_WITH_TRACY OFF CACHE BOOL "" FORCE)
endif()

if(AX_WITH_TRACY)
_1kfetch(tracy)
set(TRACY_ENABLE ON CACHE BOOL "" FORCE)
set(TRACY_ON_DEMAND ON CACHE BOOL "" FORCE)
ax_add_3rd(${tracy_SOURCE_DIR} TARGETS TracyClient)
endif()

# yasio
ax_add_3rd(yasio)

Expand Down
5 changes: 5 additions & 0 deletions 3rdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@
- Version: 2.30
- License: MIT

## tracy
- [![Upstream](https://img.shields.io/github/v/release/wolfpld/tracy?label=Upstream)](https://github.com/wolfpld/tracy)
- Version: 0.13.1
- License: BSD-3-Clause

## unzip (minizip-1.2)
- Upstream: https://github.com/simdsoft/mz12
- Version: 1.2, with bugfixs & improvements
Expand Down
2 changes: 2 additions & 0 deletions axmol/2d/ActionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ ssize_t ActionManager::getNumberOfRunningActions() const
// main loop
void ActionManager::update(float dt)
{
AX_PROFILER_ZONE_SCOPED;

for (auto actionIt = _targets.begin(); actionIt != _targets.end();)
{
auto elt = &actionIt->second;
Expand Down
3 changes: 3 additions & 0 deletions axmol/2d/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ THE SOFTWARE.
#include "axmol/renderer/Shaders.h"
#include "axmol/rhi/ProgramState.h"
#include "axmol/rhi/GraphicsCore.h"
#include "axmol/base/Profiling.h"

namespace ax
{
Expand Down Expand Up @@ -1069,6 +1070,8 @@ void Sprite::updateTransform()
// draw
void Sprite::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
{
AX_PROFILER_ZONE_SCOPED;

if (_texture == nullptr || _texture->getRHITexture() == nullptr)
return;

Expand Down
7 changes: 7 additions & 0 deletions axmol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ option(AX_UPDATE_BUILD_VERSION "Update build version" ON)
option(AX_DISABLE_GLES2 "Whether disable GLES2 support" OFF)
option(AX_CORE_PROFILE "Whether strip deprecated features" ON)

set(AX_PROFILER_BACKEND "NONE" CACHE STRING "Profiling backend")
set_property(CACHE AX_PROFILER_BACKEND PROPERTY STRINGS NONE TRACY)

# default value for axmol extensions modules to Build
# total supported extensions count: 13
# extensions dependicies: COCOSTUDIO may depend on spine & dragonBones if they are present in buildset
Expand Down Expand Up @@ -570,6 +573,10 @@ if(_simdc_defines)
endif()
endif()

# profiling configuration
ax_apply_profiler_backend(${_AX_CORE_LIB} PUBLIC)
message(STATUS "AX_PROFILER_BACKEND=${AX_PROFILER_BACKEND}")

# 3rd libs
add_subdirectory(${_AX_ROOT}/3rdparty ${ENGINE_BINARY_PATH}/3rdparty)
target_link_libraries(${_AX_CORE_LIB} 3rdparty)
Expand Down
3 changes: 3 additions & 0 deletions axmol/audio/AudioEngineImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "axmol/base/Scheduler.h"
#include "axmol/base/Utils.h"
#include "axmol/base/WeakPtr.h"
#include "axmol/base/Profiling.h"

#if AX_TARGET_PLATFORM == AX_PLATFORM_IOS || AX_TARGET_PLATFORM == AX_PLATFORM_MAC
# import <AVFoundation/AVFoundation.h>
Expand Down Expand Up @@ -1005,6 +1006,8 @@ void AudioEngineImpl::setFinishCallback(AudioId audioID, const std::function<voi

void AudioEngineImpl::update(float /*dt*/)
{
AX_PROFILER_ZONE_SCOPED;

std::lock_guard<std::recursive_mutex> lck(_threadMutex);
_updatePlayers(false);
}
Expand Down
7 changes: 7 additions & 0 deletions axmol/base/Director.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ THE SOFTWARE.
#include "axmol/base/FPSImages.h"
#include "axmol/base/Scheduler.h"
#include "axmol/base/Macros.h"
#include "axmol/base/Profiling.h"
#include "axmol/base/EventDispatcher.h"
#include "axmol/base/CustomEvent.h"
#include "axmol/base/Logging.h"
Expand Down Expand Up @@ -1372,6 +1373,8 @@ void Director::activate(SetIntervalReason reason)

_axmol_thread_id = std::this_thread::get_id();

AX_PROFILER_THREAD_NAME("MainThread");

Application::getInstance()->setAnimationInterval(_animationInterval);

// fix issue #3509, skip one fps to avoid incorrect time calculation.
Expand Down Expand Up @@ -1443,6 +1446,8 @@ void Director::renderFrame()
if (!_active) [[unlikely]]
return;

AX_PROFILER_ZONE_SCOPED;

const auto canRender = _renderer->beginFrame();

// calculate "global" dt
Expand Down Expand Up @@ -1534,6 +1539,8 @@ void Director::renderFrame()
}

_poolManager->getCurrentPool()->clear();

AX_PROFILER_FRAME_MARK;
}

void Director::renderFrame(float dt)
Expand Down
3 changes: 3 additions & 0 deletions axmol/base/EventDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "axmol/scene/Camera.h"
#include "axmol/scene/Node.h"
#include "axmol/2d/ProtectedNode.h"
#include "axmol/base/Profiling.h"

#define DUMP_LISTENER_ITEM_PRIORITY_INFO 0

Expand Down Expand Up @@ -944,6 +945,8 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners,

void EventDispatcher::dispatchEvent(Event* event, bool forced)
{
AX_PROFILER_ZONE_SCOPED;

if (!_isEnabled && !forced)
return;

Expand Down
2 changes: 2 additions & 0 deletions axmol/base/JobSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "axmol/base/JobSystem.h"
#include "axmol/base/Logging.h"
#include "axmol/base/Profiling.h"
#include "yasio/thread_name.hpp"

#include <queue>
Expand Down Expand Up @@ -149,6 +150,7 @@ class JobExecutor
workers.emplace_back([this, thread_data] {
thread_data->init();
yasio::set_thread_name(thread_data->name());
AX_PROFILER_THREAD_NAME(thread_data->name());
for (;;)
{
std::function<void(JobThreadData*)> task;
Expand Down
8 changes: 8 additions & 0 deletions axmol/base/Profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,11 @@ extern bool kProfilerCategoryParticles;
/// @}

} // namespace ax

#if defined(AX_PROFILER_BACKEND_TRACY)
# include "axmol/base/ProfilingBackendTracy.h"
#elif defined(AX_PROFILER_BACKEND_NONE)
# include "axmol/base/ProfilingBackendNoop.h"
#else
# error "No valid profiling backend selected"
#endif
36 changes: 36 additions & 0 deletions axmol/base/ProfilingBackendNoop.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/****************************************************************************
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).

https://axmol.dev/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

#pragma once

/**
* No-op profiling backend.
*
* Maps Axmol profiling macros to no-op implementations.
*/

#define AX_PROFILER_ZONE_SCOPED
#define AX_PROFILER_ZONE_SCOPED_N(...)
#define AX_PROFILER_FRAME_MARK
#define AX_PROFILER_THREAD_NAME(...)
38 changes: 38 additions & 0 deletions axmol/base/ProfilingBackendTracy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/****************************************************************************
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).

https://axmol.dev/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

#pragma once

/**
* Tracy profiling backend.
*
* Maps Axmol profiling macros to the native Tracy API.
*/

#include <tracy/Tracy.hpp>

#define AX_PROFILER_ZONE_SCOPED ZoneScoped
#define AX_PROFILER_ZONE_SCOPED_N(name) ZoneScopedN(name)
#define AX_PROFILER_FRAME_MARK FrameMark
#define AX_PROFILER_THREAD_NAME(name) tracy::SetThreadName(name)
2 changes: 2 additions & 0 deletions axmol/base/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,8 @@ void Scheduler::resumeTargets(const std::set<void*>& targetsToResume)
// main loop
void Scheduler::update(float dt)
{
AX_PROFILER_ZONE_SCOPED;

// active waitlist
if (!_waitList.empty())
activeWaitList();
Expand Down
3 changes: 3 additions & 0 deletions axmol/physics/2d/PhysicsWorld2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
# include "axmol/base/EventDispatcher.h"
# include "axmol/base/CustomEvent.h"
# include "axmol/base/JobSystem.h"
# include "axmol/base/Profiling.h"
# include "box2d/constants.h"

namespace ax
Expand Down Expand Up @@ -502,6 +503,8 @@ void PhysicsWorld2D::setSubsteps(int steps)

void PhysicsWorld2D::stepSimulation(float delta)
{
AX_PROFILER_ZONE_SCOPED;

// Skip simulation if step is too small
if (delta < FLT_EPSILON)
return;
Expand Down
2 changes: 2 additions & 0 deletions axmol/physics/3d/PhysicsWorld3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
# include "axmol/physics/3d/Rigidbody3D.h"
# include "axmol/renderer/Renderer.h"
# include "axmol/scene/Scene.h"
# include "axmol/base/Profiling.h"

# include <Jolt/Core/Factory.h>
# include <Jolt/Core/IssueReporting.h>
Expand Down Expand Up @@ -354,6 +355,7 @@ void PhysicsWorld3D::debugDraw(Renderer* renderer)

void PhysicsWorld3D::stepSimulation(float dt)
{
AX_PROFILER_ZONE_SCOPED;

for (auto* actor : _physicsActors)
actor->preSimulate();
Expand Down
3 changes: 3 additions & 0 deletions axmol/renderer/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "axmol/rhi/axmol-rhi.h"
#include "axmol/rhi/RenderTarget.h"
#include "axmol/rhi/GraphicsCore.h"
#include "axmol/base/Profiling.h"

namespace ax
{
Expand Down Expand Up @@ -406,6 +407,8 @@ void Renderer::doVisitRenderQueue(const std::vector<RenderCommand*>& renderComma

void Renderer::render()
{
AX_PROFILER_ZONE_SCOPED;

// TODO: setup camera or MVP
_isRendering = true;

Expand Down
3 changes: 3 additions & 0 deletions axmol/renderer/TextureCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ THE SOFTWARE.
#include "axmol/base/Utils.h"
#include "axmol/base/NinePatchImageParser.h"
#include "axmol/rhi/GraphicsCore.h"
#include "axmol/base/Profiling.h"

using namespace std;

Expand Down Expand Up @@ -463,6 +464,8 @@ Texture2D* TextureCache::addImage(std::string_view path, bool autoGenMipmaps)

Texture2D* TextureCache::addImage(std::string_view path, PixelFormat renderFormat, bool autoGenMipmaps)
{
AX_PROFILER_ZONE_SCOPED;

Texture2D* texture = nullptr;
Image* image = nullptr;
// Split up directory and filename
Expand Down
4 changes: 4 additions & 0 deletions axmol/scene/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ THE SOFTWARE.
#include "axmol/base/text_utils.h"
#include "axmol/renderer/Renderer.h"
#include "axmol/scene/SceneCompositor.h"
#include "axmol/base/Profiling.h"

#if defined(AX_ENABLE_PHYSICS_2D)
# include "axmol/physics/2d/PhysicsWorld2D.h"
Expand Down Expand Up @@ -211,6 +212,7 @@ void Scene::setDebugCamera(Camera* camera)

void Scene::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags)
{
AX_PROFILER_ZONE_SCOPED;
Node::visit(renderer, parentTransform, parentFlags);
}

Expand Down Expand Up @@ -287,6 +289,8 @@ void Scene::setFixedDeltaTime(float fixedStep)

void Scene::tick(float deltaTime)
{
AX_PROFILER_ZONE_SCOPED;

if (_fixedUpdateEnabled)
{
// apply time scale and clamp to avoid huge dt spikes
Expand Down
Loading