Skip to content

Commit

Permalink
Merge pull request AtomicGameEngine#1531 from rokups/feature/easy_pro…
Browse files Browse the repository at this point in the history
…filer

easy_profiler integration
  • Loading branch information
JoshEngebretson authored Jun 29, 2017
2 parents 64e3ed2 + bedf501 commit 0c52b46
Show file tree
Hide file tree
Showing 131 changed files with 27,924 additions and 691 deletions.
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@

- Ken Paulson (https://github.com/MuffinManKen)

- Rokas Kupstys (https://github.com/rokups)

### Contribution Copyright and Licensing

Atomic Game Engine contribution copyrights are held by their authors. Each author retains the copyright to their contribution and agrees to irrevocably license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`. Please see `CONTRIBUTING.md` for more details.
Expand Down
10 changes: 8 additions & 2 deletions Build/CMake/Modules/AtomicCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,16 @@ endmacro()
macro(setup_executable)
cmake_parse_arguments(ARG "PRIVATE;TOOL;NODEPS" "" "" ${ARGN})
check_source_files()

add_executable(${TARGET_NAME} ${ARG_UNPARSED_ARGUMENTS} ${SOURCE_FILES})

setup_target()
if (ARG_TOOL)
if (DEFINED ATOMIC_TOOL_DIR)
set (TOOL_DIR ${ATOMIC_TOOL_DIR})
else ()
set (TOOL_DIR ${ATOMIC_SOURCE_DIR}/Artifacts/Build/${TARGET_NAME})
endif ()
set_property(TARGET ${TARGET_NAME} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${TOOL_DIR})
endif ()
endmacro()

# Macro for replacing substrings in every variable specified in the list.
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ include(AtomicGit)
include(AtomicUtils)
include(AtomicCommon)

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set (ATOMIC_RELEASE_OFF OFF)
set (ATOMIC_RELEASE_ON ON)
else ()
set (ATOMIC_RELEASE_OFF ON)
set (ATOMIC_RELEASE_ON OFF)
endif ()

add_definitions(-DATOMIC_ROOT_SOURCE_DIR="${ATOMIC_SOURCE_DIR}" -DATOMIC_ROOT_BUILD_DIR="${CMAKE_BINARY_DIR}")

if (NOT DEFINED ATOMIC_DEV_BUILD)
Expand Down
49 changes: 49 additions & 0 deletions Script/AtomicNET/AtomicNET/Core/Profiler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace AtomicEngine
{
public partial class Profiler : AObject
{
public static void Block(string name, Action block, uint color = 0xffffecb3,
ProfilerBlockStatus status = ProfilerBlockStatus.ON,
[CallerFilePath] string file = "",
[CallerLineNumber] int line = 0)
{
#if ATOMIC_PROFILING
var profiler = AtomicNET.Context.GetProfiler();
if (profiler != null)
csi_Atomic_Profiler_BeginBlock(profiler, name, file, line, color, (byte)status);
#endif
block();
#if ATOMIC_PROFILING
if (profiler != null)
csi_Atomic_Profiler_EndBlock(profiler);
#endif
}

public static void BeginBlock(string name, uint color = 0xffffecb3,
ProfilerBlockStatus status = ProfilerBlockStatus.ON,
[CallerFilePath] string file = "",
[CallerLineNumber] int line = 0)
{
var profiler = AtomicNET.Context.GetProfiler();
if (profiler != null)
csi_Atomic_Profiler_BeginBlock(profiler, name, file, line, color, (byte)status);
}

public static void EndBlock()
{
var profiler = AtomicNET.Context.GetProfiler();
if (profiler != null)
csi_Atomic_Profiler_EndBlock(profiler);
}

[DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern void csi_Atomic_Profiler_BeginBlock(IntPtr self, string name, string file, int line, uint argb, byte status);

[DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern void csi_Atomic_Profiler_EndBlock(IntPtr self);
}
}
7 changes: 4 additions & 3 deletions Script/AtomicNET/AtomicNETProject.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"name": "AtomicNET",
"atomicNET" : true,
"outputType" : "Library",
"defineConstants" : ["ATOMIC_PROFILING"],
"rootNamespace" : "AtomicEngine",
"assemblyName" : "AtomicNET",
"assemblyOutputPath" : "..\\..\\$ATOMIC_CONFIG$\\Portable\\",
Expand All @@ -44,7 +45,7 @@
"assemblyDocFile" : true,
"platforms" : ["desktop"],
"outputType" : "Library",
"defineConstants" : ["ATOMIC_DESKTOP"],
"defineConstants" : ["ATOMIC_DESKTOP", "ATOMIC_PROFILING"],
"rootNamespace" : "AtomicGameEngine",
"assemblyName" : "AtomicNET",
"assemblyOutputPath" : "..\\..\\$ATOMIC_CONFIG$\\Desktop\\",
Expand Down Expand Up @@ -87,7 +88,7 @@
"atomicNET" : true,
"platforms" : ["android"],
"outputType" : "Library",
"defineConstants" : ["ATOMIC_ANDROID"],
"defineConstants" : ["ATOMIC_ANDROID", "ATOMIC_PROFILING"],
"rootNamespace" : "AtomicGameEngine",
"assemblyName" : "AtomicNET",
"assemblyOutputPath" : "..\\..\\$ATOMIC_CONFIG$\\Android\\",
Expand All @@ -113,7 +114,7 @@
"platforms" : ["ios"],
"outputType" : "Library",
"projectTypeGuids" :[ "8FFB629D-F513-41CE-95D2-7ECE97B6EEEC", "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC" ],
"defineConstants" : ["ATOMIC_IOS"],
"defineConstants" : ["ATOMIC_IOS", "ATOMIC_PROFILING"],
"rootNamespace" : "AtomicGameEngine",
"assemblyName" : "AtomicNET",
"assemblyOutputPath" : "..\\..\\$ATOMIC_CONFIG$\\iOS\\",
Expand Down
6 changes: 3 additions & 3 deletions Script/AtomicNET/AtomicProject.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"name": "$ATOMIC_PROJECT_NAME$.Desktop",
"platforms" : ["desktop"],
"outputType" : "Exe",
"defineConstants" : ["ATOMIC_DESKTOP"],
"defineConstants" : ["ATOMIC_DESKTOP", "ATOMIC_PROFILING"],
"rootNamespace" : "",
"assemblyName" : "$ATOMIC_PROJECT_NAME$",
"assemblyOutputPath" : "$ATOMIC_PROJECT_ROOT$\\AtomicNET\\$ATOMIC_CONFIG$\\Bin\\Desktop",
Expand All @@ -60,7 +60,7 @@
"name": "$ATOMIC_PROJECT_NAME$.Android",
"platforms" : ["android"],
"outputType" : "Library",
"defineConstants" : ["ATOMIC_ANDROID"],
"defineConstants" : ["ATOMIC_ANDROID", "ATOMIC_PROFILING"],
"rootNamespace" : "",
"assemblyName" : "$ATOMIC_PROJECT_NAME$",
"projectTypeGuids" : ["EFBA0AD7-5A72-4C68-AF49-83D382785DCF", "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"],
Expand Down Expand Up @@ -89,7 +89,7 @@
"name": "$ATOMIC_PROJECT_NAME$.iOS",
"platforms" : ["ios"],
"outputType" : "Exe",
"defineConstants" : ["ATOMIC_IOS"],
"defineConstants" : ["ATOMIC_IOS", "ATOMIC_PROFILING"],
"rootNamespace" : "",
"assemblyName" : "$ATOMIC_PROJECT_NAME$",
"projectGuid" : "071BD84E-7518-11E6-C78E-005056C00008",
Expand Down
8 changes: 7 additions & 1 deletion Script/Packages/Atomic/Core.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"<Atomic/Graphics/Renderer.h>",
"<Atomic/Metrics/Metrics.h>"
],
"classes" : ["Context", "Object", "AtomicBuildInfo", "Time"],
"classes" : ["Context", "Object", "AtomicBuildInfo", "Time", "Profiler"],
"classes_rename" : {
"Object" : "AObject"
},
Expand All @@ -28,6 +28,9 @@
"CSharp" : {
"Object" : {
"UnsubscribeFromAllEvents" : []
},
"Profiler": {
"EndBlock" : []
}
}
},
Expand All @@ -45,6 +48,9 @@
"subscribeToEvent(sender:AObject, eventType:string, callback:(data: any) => void);",
"subscribeToEvent(eventMetaData:Atomic.EventMetaData);",
"subscribeToEvent(sender:AObject, eventMetaData:Atomic.EventMetaData);"
],
"Profiler" : [
"beginBlock(name:string, filename:string, line:number, argb?:number, status?:Atomic.ProfilerBlockStatus );"
]
},
"haxe_decl" : {
Expand Down
11 changes: 4 additions & 7 deletions Source/Atomic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ elseif (ATOMIC_DATABASE_ODBC)
endif ()

if (WIN32)
option (ATOMIC_D3D11 "Use DirectX 11" OFF)
option (ATOMIC_OPENGL "Use OpenGL" OFF)
if (ATOMIC_D3D11) # DirectX 11
file (GLOB GRAPHICS_IMPL_SOURCE Graphics/Direct3D11/*.cpp Graphics/Direct3D11/*.h)
elseif (ATOMIC_OPENGL) # OpenGL
Expand Down Expand Up @@ -125,8 +127,6 @@ elseif (LINUX)
target_link_libraries (Atomic pthread GLEW GL dl)
target_compile_definitions(Atomic PUBLIC -DATOMIC_PLATFORM_LINUX=1)
elseif (WIN32)
option (ATOMIC_D3D11 "Use DirectX 11" ON)
option (ATOMIC_OPENGL "Use OpenGL" OFF)
target_compile_definitions (Atomic PUBLIC -DATOMIC_PLATFORM_WINDOWS=1)
target_link_libraries (Atomic user32 gdi32 winmm imm32 ole32 oleaut32 version uuid Ws2_32)
if (ATOMIC_D3D11) # DirectX 11
Expand Down Expand Up @@ -177,9 +177,9 @@ if (NOT WEB)
target_link_libraries (Atomic libcurl Civetweb kNet)
endif()

option (ATOMIC_PROFILING "Enable profiler" ON)
if (ATOMIC_PROFILING)
target_compile_definitions (Atomic PUBLIC -DATOMIC_PROFILING=1)
target_link_libraries (Atomic easy_profiler)
endif ()

option (ATOMIC_LOGGING "Enable logging" ON)
Expand Down Expand Up @@ -241,10 +241,7 @@ if ($ENV{ATOMIC_BUILD_DIST})
endif ()

if (MSVC)
target_compile_options(Atomic PUBLIC "$<$<CONFIG:Debug>:${ATOMIC_MSVC_RUNTIME}d>")
target_compile_options(Atomic PUBLIC "$<$<CONFIG:Release>:${ATOMIC_MSVC_RUNTIME}>")
target_compile_options(Atomic PUBLIC "$<$<CONFIG:RelWithDebInfo>:${ATOMIC_MSVC_RUNTIME}>")
target_compile_options(Atomic PUBLIC "$<$<CONFIG:MinSizeRel>:${ATOMIC_MSVC_RUNTIME}>")
target_compile_options(Atomic PUBLIC $<$<CONFIG:Debug>:${ATOMIC_MSVC_RUNTIME}d> $<$<NOT:$<CONFIG:Debug>>:${ATOMIC_MSVC_RUNTIME}>)
endif ()

if (UNIX OR MINGW)
Expand Down
22 changes: 3 additions & 19 deletions Source/Atomic/Core/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#include "../Precompiled.h"

#include "../Core/Context.h"
#include "../Core/EventProfiler.h"
// ATOMIC BEGIN
#include "../Core/Profiler.h"
// ATOMIC END
#include "../IO/Log.h"

#ifndef MINI_URHO
Expand Down Expand Up @@ -446,30 +448,12 @@ void Context::RemoveEventReceiver(Object* receiver, Object* sender, StringHash e

void Context::BeginSendEvent(Object* sender, StringHash eventType)
{
#ifdef ATOMIC_PROFILING
if (EventProfiler::IsActive())
{
EventProfiler* eventProfiler = GetSubsystem<EventProfiler>();
if (eventProfiler)
eventProfiler->BeginBlock(eventType);
}
#endif

eventSenders_.Push(sender);
}

void Context::EndSendEvent()
{
eventSenders_.Pop();

#ifdef ATOMIC_PROFILING
if (EventProfiler::IsActive())
{
EventProfiler* eventProfiler = GetSubsystem<EventProfiler>();
if (eventProfiler)
eventProfiler->EndBlock();
}
#endif
}

}
45 changes: 0 additions & 45 deletions Source/Atomic/Core/EventProfiler.cpp

This file was deleted.

Loading

0 comments on commit 0c52b46

Please sign in to comment.