From a4f83c55a688b391cd7408ddc13e660f0632f57d Mon Sep 17 00:00:00 2001 From: Stone Tickle Date: Tue, 29 Sep 2020 11:00:06 +0900 Subject: [PATCH 1/4] Add Wayland build option --- profiler/build/unix/build.mk | 9 +++++++++ profiler/src/NativeWindow.cpp | 12 +++++++++++- profiler/src/main.cpp | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/profiler/build/unix/build.mk b/profiler/build/unix/build.mk index 1e945445..f58c8193 100644 --- a/profiler/build/unix/build.mk +++ b/profiler/build/unix/build.mk @@ -3,6 +3,15 @@ CXXFLAGS := $(CFLAGS) -std=c++17 DEFINES += -DIMGUI_IMPL_OPENGL_LOADER_GL3W INCLUDES := $(shell pkg-config --cflags glfw3 freetype2 capstone) -I../../../imgui -I../../libs/gl3w LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl + +DISPLAY_SERVER := X11 +libwayland_client := $(shell pkg-config --libs --silence-errors wayland-client) +ifeq ($(.SHELLSTATUS),0) + DISPLAY_SERVER := WAYLAND + LIBS += $(libwayland_client) +endif +CXXFLAGS += -D"DISPLAY_SERVER_$(DISPLAY_SERVER)" + PROJECT := Tracy IMAGE := $(PROJECT)-$(BUILD) diff --git a/profiler/src/NativeWindow.cpp b/profiler/src/NativeWindow.cpp index 79ac0f60..94031cdc 100644 --- a/profiler/src/NativeWindow.cpp +++ b/profiler/src/NativeWindow.cpp @@ -6,7 +6,13 @@ # define GLFW_EXPOSE_NATIVE_WIN32 # include #elif defined __linux__ -# define GLFW_EXPOSE_NATIVE_X11 +# ifdef DISPLAY_SERVER_X11 +# define GLFW_EXPOSE_NATIVE_X11 +# elif defined DISPLAY_SERVER_WAYLAND +# define GLFW_EXPOSE_NATIVE_WAYLAND +# else +# error "unsupported linux display server" +# endif # include #endif @@ -17,7 +23,11 @@ void* GetMainWindowNative() #ifdef _WIN32 return (void*)glfwGetWin32Window( s_glfwWindow ); #elif defined __linux__ +# ifdef DISPLAY_SERVER_X11 return (void*)glfwGetX11Window( s_glfwWindow ); +# elif defined DISPLAY_SERVER_WAYLAND + return (void*)glfwGetWaylandWindow( s_glfwWindow ); +# endif #else return nullptr; #endif diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index f453defc..1d88caa2 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -244,7 +244,9 @@ int main( int argc, char** argv ) // Setup window glfwSetErrorCallback(glfw_error_callback); if( !glfwInit() ) return 1; +#ifndef DISPLAY_SERVER_WAYLAND glfwWindowHint(GLFW_VISIBLE, 0); +#endif glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); From b424bb488160fc15a9aae838147a233ceb8b3083 Mon Sep 17 00:00:00 2001 From: Stone Tickle Date: Thu, 1 Oct 2020 19:52:51 +0900 Subject: [PATCH 2/4] fix Wayland window transparency https://github.com/glfw/glfw/issues/1434 --- profiler/src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 1d88caa2..43872d0e 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -244,7 +244,9 @@ int main( int argc, char** argv ) // Setup window glfwSetErrorCallback(glfw_error_callback); if( !glfwInit() ) return 1; -#ifndef DISPLAY_SERVER_WAYLAND +#ifdef DISPLAY_SERVER_WAYLAND + glfwWindowHint(GLFW_ALPHA_BITS, 0); +#else glfwWindowHint(GLFW_VISIBLE, 0); #endif glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); From e2c5d372550eb3acd966b351f9dd016f1f4384c2 Mon Sep 17 00:00:00 2001 From: Stone Tickle Date: Fri, 2 Oct 2020 10:55:31 +0900 Subject: [PATCH 3/4] make wayland strictly on demand --- profiler/build/unix/build.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/profiler/build/unix/build.mk b/profiler/build/unix/build.mk index f58c8193..8df65ae9 100644 --- a/profiler/build/unix/build.mk +++ b/profiler/build/unix/build.mk @@ -5,11 +5,12 @@ INCLUDES := $(shell pkg-config --cflags glfw3 freetype2 capstone) -I../../../img LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl DISPLAY_SERVER := X11 -libwayland_client := $(shell pkg-config --libs --silence-errors wayland-client) -ifeq ($(.SHELLSTATUS),0) + +ifdef TRACY_USE_WAYLAND DISPLAY_SERVER := WAYLAND - LIBS += $(libwayland_client) + LIBS += $(shell pkg-config --libs wayland-client) endif + CXXFLAGS += -D"DISPLAY_SERVER_$(DISPLAY_SERVER)" PROJECT := Tracy From 36e13668c0a37d0e86cf6f912f0af209baffd309 Mon Sep 17 00:00:00 2001 From: Stone Tickle Date: Fri, 2 Oct 2020 11:00:52 +0900 Subject: [PATCH 4/4] mention TRACY_USE_WAYLAND in the manual --- manual/techdoc.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manual/techdoc.tex b/manual/techdoc.tex index edb1f138..1d6f2e5a 100644 --- a/manual/techdoc.tex +++ b/manual/techdoc.tex @@ -141,6 +141,8 @@ The \texttt{debug.mk} and \texttt{release.mk} files only set a few of the optimi In the header of the \texttt{build.mk} file you can find definitions of the resulting executable name, list of used libraries, required include paths, etc. Most of the file is boilerplate required to extract build dependencies, or pass the appropriate flags to compiler and linker. +By default, the profiler uses X11 on Linux. If you would like to support Wayland instead, set the environment variable \texttt{TRACY\_USE\_WAYLAND} before running make. + \section{Client part} The client portion of Tracy is basically a queue. Application threads are producing queue items through the instrumentation macros and a dedicated profiler thread consumes the items to send them over the network, to the server.