Преглед на файлове

Enhanced Tracy profiler CMake configuration. Add separate build configuration.

Michael Ragazzon преди 5 години
родител
ревизия
5587544f01

+ 20 - 0
CMake/Modules/FindTracy.cmake

@@ -0,0 +1,20 @@
+# - Try to find Tracy
+# Once done, this will define
+#
+#  TRACY_FOUND - system has Tracy
+#  TRACY_INCLUDE_DIR - the Tracy include directory
+
+set(TRACY_DIR "" CACHE PATH "Parent directory of Tracy library")
+
+find_path(TRACY_INCLUDE_DIR Tracy.hpp PATHS ${TRACY_DIR} $ENV{TRACY_DIR} PATH_SUFFIXES tracy)
+
+set(TRACY_FOUND "NO")
+if(TRACY_INCLUDE_DIR)
+	message(STATUS "Found Tracy ${TRACY_INCLUDE_DIR}...")
+	mark_as_advanced(TRACY_DIR TRACY_INCLUDE_DIR)
+	set(TRACY_FOUND "YES")
+elseif(Tracy_FIND_REQUIRED)
+	 message(FATAL_ERROR "Required library Tracy not found! Install the library and try again. If the library is already installed, set the missing variables manually in cmake.")
+else()
+	message(STATUS "Library Tracy not found...")
+endif()

+ 26 - 2
CMakeLists.txt

@@ -108,6 +108,10 @@ if(NOT DEFINED ENV{SFML_ROOT})
 	set(ENV{SFML_ROOT} "${PROJECT_SOURCE_DIR}/Dependencies")
 	set(ENV{SFML_ROOT} "${PROJECT_SOURCE_DIR}/Dependencies")
 endif()
 endif()
 
 
+if(NOT DEFINED ENV{TRACY_DIR})
+	set(ENV{TRACY_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
+endif()
+
 #===================================
 #===================================
 # Plaform specific global hacks ====
 # Plaform specific global hacks ====
 #===================================
 #===================================
@@ -178,9 +182,29 @@ if( NO_THIRDPARTY_CONTAINERS )
 	message("-- No third-party containers will be used: Make sure to #define RMLUI_NO_THIRDPARTY_CONTAINERS before including RmlUi in your project.")
 	message("-- No third-party containers will be used: Make sure to #define RMLUI_NO_THIRDPARTY_CONTAINERS before including RmlUi in your project.")
 endif()
 endif()
 
 
-option(ENABLE_TRACY_PROFILING "Enable tracy profiling, requires that Tracy is placed in Dependencies/tracy." OFF)
+option(ENABLE_TRACY_PROFILING "Enable profiling with Tracy. It is recommended to place source files in Dependencies/tracy." OFF)
 if( ENABLE_TRACY_PROFILING )
 if( ENABLE_TRACY_PROFILING )
-	add_definitions(-DRMLUI_ENABLE_PROFILING)
+	find_package(Tracy REQUIRED)
+
+	include_directories(${TRACY_INCLUDE_DIR})
+
+	if( CMAKE_CONFIGURATION_TYPES )
+		list(APPEND CMAKE_CONFIGURATION_TYPES Tracy)
+		list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
+		set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
+			"Add the configurations that we need"
+			FORCE)
+		set(CMAKE_C_FLAGS_TRACY "${CMAKE_CXX_FLAGS_RELEASE} -DRMLUI_ENABLE_PROFILING")
+		set(CMAKE_CXX_FLAGS_TRACY "${CMAKE_CXX_FLAGS_RELEASE} -DRMLUI_ENABLE_PROFILING")
+		set(CMAKE_EXE_LINKER_FLAGS_TRACY "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
+		set(CMAKE_SHARED_LINKER_FLAGS_TRACY "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
+		message("-- Tracy profiling enabled in configuration 'Tracy'.")
+	else()
+		message("-- Tracy profiling enabled.")
+		add_definitions(-DRMLUI_ENABLE_PROFILING)
+	endif()
+elseif( CMAKE_CONFIGURATION_TYPES )
+	list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES Tracy)
 endif()
 endif()
 
 
 option(DISABLE_RTTI_AND_EXCEPTIONS "Build with rtti and exceptions disabled." OFF)
 option(DISABLE_RTTI_AND_EXCEPTIONS "Build with rtti and exceptions disabled." OFF)

+ 0 - 3
Include/RmlUi/Core/Platform.h

@@ -32,9 +32,6 @@
 #if defined __WIN32__ || defined _WIN32
 #if defined __WIN32__ || defined _WIN32
 	#define RMLUI_PLATFORM_WIN32
 	#define RMLUI_PLATFORM_WIN32
 	#define RMLUI_PLATFORM_NAME "win32"
 	#define RMLUI_PLATFORM_NAME "win32"
-	#if !defined(__MINGW32__)
-		#pragma warning(disable:4355)
-	#endif
 #elif defined __APPLE_CC__
 #elif defined __APPLE_CC__
 	#define RMLUI_PLATFORM_UNIX
 	#define RMLUI_PLATFORM_UNIX
 	#define RMLUI_PLATFORM_MACOSX
 	#define RMLUI_PLATFORM_MACOSX

+ 28 - 28
Include/RmlUi/Core/Profiling.h

@@ -33,49 +33,49 @@
 #ifdef RMLUI_ENABLE_PROFILING
 #ifdef RMLUI_ENABLE_PROFILING
 
 
 #define TRACY_ENABLE
 #define TRACY_ENABLE
-#include "../../../Dependencies/tracy/Tracy.hpp"
+#include <Tracy.hpp>
 
 
-#define RMLUI_ZoneNamed(x,y)       ZoneNamed(x,y)
-#define RMLUI_ZoneNamedN(x,y,z)    ZoneNamedN(x,y,z)
-#define RMLUI_ZoneNamedC(x,y,z)    ZoneNamedC(x,y,z)
-#define RMLUI_ZoneNamedNC(x,y,z,w) ZoneNamedNC(x,y,z,w)
+#define RMLUI_ZoneNamed(varname, active)                 ZoneNamed(varname, active)
+#define RMLUI_ZoneNamedN(varname, name, active)          ZoneNamedN(varname, name, active)
+#define RMLUI_ZoneNamedC(varname, color, active)         ZoneNamedC(varname, color, active)
+#define RMLUI_ZoneNamedNC(varname, name, color, active)  ZoneNamedNC(varname, name, color, active)
 
 
-#define RMLUI_ZoneScoped           ZoneScoped
-#define RMLUI_ZoneScopedN(x)       ZoneScopedN(x)
-#define RMLUI_ZoneScopedC(x)       ZoneScopedC(x)
-#define RMLUI_ZoneScopedNC(x,y)    ZoneScopedNC(x,y)
+#define RMLUI_ZoneScoped                 ZoneScoped
+#define RMLUI_ZoneScopedN(name)          ZoneScopedN(name)
+#define RMLUI_ZoneScopedC(color)         ZoneScopedC(color)
+#define RMLUI_ZoneScopedNC(name, color)  ZoneScopedNC(name, color)
 
 
-#define RMLUI_ZoneText(x,y)        ZoneText(x,y)
-#define RMLUI_ZoneName(x,y)        ZoneName(x,y)
+#define RMLUI_ZoneText(txt, size)        ZoneText(txt, size)
+#define RMLUI_ZoneName(txt, size)        ZoneName(txt, size)
 
 
-#define RMLUI_TracyPlot(name,val)  TracyPlot(name,val)
+#define RMLUI_TracyPlot(name,val)        TracyPlot(name, val)
 
 
-#define RMLUI_FrameMark            FrameMark
-#define RMLUI_FrameMarkNamed(x)    FrameMarkNamed(x)
-#define RMLUI_FrameMarkStart(x)    FrameMarkStart(x)
-#define RMLUI_FrameMarkEnd(x)      FrameMarkEnd(x)
+#define RMLUI_FrameMark                  FrameMark
+#define RMLUI_FrameMarkNamed(name)       FrameMarkNamed(name)
+#define RMLUI_FrameMarkStart(name)       FrameMarkStart(name)
+#define RMLUI_FrameMarkEnd(name)         FrameMarkEnd(name)
 
 
 #else
 #else
 
 
-#define RMLUI_ZoneNamed(x,y)
-#define RMLUI_ZoneNamedN(x,y,z)
-#define RMLUI_ZoneNamedC(x,y,z)
-#define RMLUI_ZoneNamedNC(x,y,z,w)
+#define RMLUI_ZoneNamed(varname, active)
+#define RMLUI_ZoneNamedN(varname, name, active)
+#define RMLUI_ZoneNamedC(varname, color, active)
+#define RMLUI_ZoneNamedNC(varname, name, color, active)
 
 
 #define RMLUI_ZoneScoped
 #define RMLUI_ZoneScoped
-#define RMLUI_ZoneScopedN(x)
-#define RMLUI_ZoneScopedC(x)
-#define RMLUI_ZoneScopedNC(x,y)
+#define RMLUI_ZoneScopedN(name)
+#define RMLUI_ZoneScopedC(color)
+#define RMLUI_ZoneScopedNC(name, color)
 
 
-#define RMLUI_ZoneText(x,y)
-#define RMLUI_ZoneName(x,y)
+#define RMLUI_ZoneText(txt, size)
+#define RMLUI_ZoneName(txt, size)
 
 
 #define RMLUI_TracyPlot(name,val)
 #define RMLUI_TracyPlot(name,val)
 
 
 #define RMLUI_FrameMark
 #define RMLUI_FrameMark
-#define RMLUI_FrameMarkNamed(x)
-#define RMLUI_FrameMarkStart(x)
-#define RMLUI_FrameMarkEnd(x)
+#define RMLUI_FrameMarkNamed(name)
+#define RMLUI_FrameMarkStart(name)
+#define RMLUI_FrameMarkEnd(name)
 
 
 #endif
 #endif
 
 

+ 1 - 0
Samples/shell/include/win32/IncludeWindows.h

@@ -36,6 +36,7 @@
 #define UNICODE
 #define UNICODE
 #define _UNICODE
 #define _UNICODE
 #define WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
 
 
 #include <windows.h>
 #include <windows.h>
 
 

+ 2 - 0
Source/Core/ConvolutionFilter.cpp

@@ -72,6 +72,8 @@ float* ConvolutionFilter::operator[](int kernel_y_index)
 
 
 void ConvolutionFilter::Run(byte* destination, const Vector2i destination_dimensions, const int destination_stride, const ColorFormat destination_color_format, const byte* source, const Vector2i source_dimensions, const Vector2i source_offset) const
 void ConvolutionFilter::Run(byte* destination, const Vector2i destination_dimensions, const int destination_stride, const ColorFormat destination_color_format, const byte* source, const Vector2i source_dimensions, const Vector2i source_offset) const
 {
 {
+	RMLUI_ZoneScopedNC("ConvFilter::Run", 0xd6bf49);
+
 	const float initial_opacity = (operation == FilterOperation::Erosion ? FLT_MAX : 0.f);
 	const float initial_opacity = (operation == FilterOperation::Erosion ? FLT_MAX : 0.f);
 
 
 	const Vector2i kernel_radius = (kernel_size - Vector2i(1)) / 2;
 	const Vector2i kernel_radius = (kernel_size - Vector2i(1)) / 2;

+ 4 - 0
Source/Core/Element.cpp

@@ -176,7 +176,11 @@ Element::~Element()
 
 
 void Element::Update(float dp_ratio)
 void Element::Update(float dp_ratio)
 {
 {
+#ifdef RMLUI_ENABLE_PROFILING
+	auto name = GetAddress(false, false);
 	RMLUI_ZoneScoped;
 	RMLUI_ZoneScoped;
+	RMLUI_ZoneText(name.c_str(), name.size());
+#endif
 
 
 	OnUpdate();
 	OnUpdate();
 
 

+ 2 - 1
Source/Core/Profiling.cpp

@@ -30,7 +30,8 @@
 #include "../../Include/RmlUi/Core/Profiling.h"
 #include "../../Include/RmlUi/Core/Profiling.h"
 
 
 #ifdef RMLUI_ENABLE_PROFILING
 #ifdef RMLUI_ENABLE_PROFILING
-#include "../Dependencies/tracy/TracyClient.cpp"
+#include <TracyClient.cpp>
+#include <memory>
 
 
 // Overload global new and delete for memory inspection
 // Overload global new and delete for memory inspection
 void* operator new(std::size_t n)
 void* operator new(std::size_t n)