diff --git a/filament/CMakeLists.txt b/filament/CMakeLists.txt index 4fe1c604017..82e336215dd 100644 --- a/filament/CMakeLists.txt +++ b/filament/CMakeLists.txt @@ -308,6 +308,11 @@ if (FILAMENT_ENABLE_MULTIVIEW) add_definitions(-DFILAMENT_ENABLE_MULTIVIEW) endif() +# Whether to force the profiling mode. +if (FILAMENT_FORCE_PROFILING_MODE) + add_definitions(-DFILAMENT_FORCE_PROFILING_MODE) +endif() + # ================================================================================================== # Definitions # ================================================================================================== diff --git a/filament/backend/src/opengl/OpenGLDriver.cpp b/filament/backend/src/opengl/OpenGLDriver.cpp index 676b539be7e..79580fc7c46 100644 --- a/filament/backend/src/opengl/OpenGLDriver.cpp +++ b/filament/backend/src/opengl/OpenGLDriver.cpp @@ -106,17 +106,29 @@ // set to the desired debug level (for internal debugging [Default: None]) #define DEBUG_MARKER_LEVEL DEBUG_MARKER_NONE +// Override the debug markers if we are forcing profiling mode +#if defined(FILAMENT_FORCE_PROFILING_MODE) +# undef DEBUG_GROUP_MARKER_LEVEL +# undef DEBUG_MARKER_LEVEL + +# define DEBUG_GROUP_MARKER_LEVEL DEBUG_GROUP_MARKER_NONE +# define DEBUG_MARKER_LEVEL DEBUG_MARKER_PROFILE +#endif + #if DEBUG_MARKER_LEVEL == DEBUG_MARKER_PROFILE # define DEBUG_MARKER() # define PROFILE_MARKER(marker) PROFILE_SCOPE(marker); # if DEBUG_GROUP_MARKER_LEVEL != DEBUG_GROUP_MARKER_NONE -# error PROFILING is exclusive; group markers must be disabled. +# error PROFILING is exclusive; group markers must be disabled. +# endif +# ifndef NDEBUG +# error PROFILING is meaningless in DEBUG mode. # endif #elif DEBUG_MARKER_LEVEL > DEBUG_MARKER_NONE # define DEBUG_MARKER() DebugMarker _debug_marker(*this, __func__); # define PROFILE_MARKER(marker) DEBUG_MARKER() # if DEBUG_MARKER_LEVEL & DEBUG_MARKER_PROFILE -# error PROFILING is exclusive; all other debug features must be disabled. +# error PROFILING is exclusive; all other debug features must be disabled. # endif #else # define DEBUG_MARKER() diff --git a/filament/backend/src/vulkan/VulkanConstants.h b/filament/backend/src/vulkan/VulkanConstants.h index 79b388a7136..ac07debda70 100644 --- a/filament/backend/src/vulkan/VulkanConstants.h +++ b/filament/backend/src/vulkan/VulkanConstants.h @@ -98,6 +98,12 @@ #define FVK_DEBUG_FLAGS 0 #endif +// Override the debug flags if we are forcing profiling mode +#if defined(FILAMENT_FORCE_PROFILING_MODE) +#undef FVK_DEBUG_FLAGS +#define FVK_DEBUG_FLAGS (FVK_DEBUG_PROFILING) +#endif + #define FVK_ENABLED(flags) (((FVK_DEBUG_FLAGS) & (flags)) == (flags)) // Group marker only works only if validation or debug utils is enabled since it uses @@ -133,6 +139,10 @@ static_assert(FVK_ENABLED(FVK_DEBUG_VALIDATION)); #if FVK_DEBUG_FLAGS == FVK_DEBUG_PROFILING + #ifndef NDEBUG + #error PROFILING is meaningless in DEBUG mode. + #endif + #define FVK_SYSTRACE_CONTEXT() #define FVK_SYSTRACE_START(marker) #define FVK_SYSTRACE_END()