diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt index ab997e8..8c4ffb9 100644 --- a/src/engine/CMakeLists.txt +++ b/src/engine/CMakeLists.txt @@ -25,5 +25,9 @@ target_link_libraries(FGLEngine PUBLIC Vulkan::Vulkan glfw glm FGLImGui Tracy::T target_include_directories(FGLEngine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..) set_target_properties(FGLEngine PROPERTIES COMPILE_FLAGS ${FGL_FLAGS}) -target_compile_definitions(FGLEngine PRIVATE TRACY_ENABLE=1) -target_compile_definitions(FGLEngine PRIVATE ENABLE_IMGUI=1) +string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_UPPER_BUILD_TYPE) +if (CMAKE_UPPER_BUILD_TYPE STREQUAL "DEBUG") + target_compile_definitions(FGLEngine PRIVATE ENABLE_IMGUI=1) +else () + target_compile_definitions(FGLEngine PRIVATE ENABLE_IMGUI=0) +endif () diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index c620201..820469b 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -40,7 +40,7 @@ namespace fgl::engine { using namespace fgl::literals::size_literals; initGlobalStagingBuffer( 256_MiB ); -#ifdef ENABLE_IMGUI +#if ENABLE_IMGUI initImGui(); #endif loadGameObjects(); @@ -138,11 +138,8 @@ namespace fgl::engine draw_parameter_buffers[ frame_index ], m_renderer.getGBufferDescriptor( frame_index ) }; -#ifdef TRACY_ENABLE #if TRACY_ENABLE auto& tracy_ctx { frame_info.tracy_ctx }; - -#endif #endif CameraInfo current_camera_info { .projection = camera.getProjectionMatrix(), @@ -151,7 +148,7 @@ namespace fgl::engine camera_info[ frame_index ] = current_camera_info; -#ifdef ENABLE_IMGUI +#if ENABLE_IMGUI { ZoneScopedN( "ImGui recording" ); ImGui_ImplVulkan_NewFrame(); @@ -331,12 +328,10 @@ namespace fgl::engine m_entity_renderer.pass( frame_info ); -#ifdef ENABLE_IMGUI +#if ENABLE_IMGUI { -#ifdef TRACY_ENABLE #if TRACY_ENABLE TracyVkZone( tracy_ctx, command_buffer, "ImGui Rendering" ); -#endif #endif ImGui_ImplVulkan_RenderDrawData( data, command_buffer ); } @@ -344,10 +339,8 @@ namespace fgl::engine m_renderer.endSwapchainRendererPass( command_buffer ); -#ifdef TRACY_ENABLE #if TRACY_ENABLE TracyVkCollect( frame_info.tracy_ctx, command_buffer ); -#endif #endif m_renderer.endFrame(); @@ -516,7 +509,7 @@ namespace fgl::engine EngineContext::~EngineContext() { -#ifdef ENABLE_IMGUI +#if ENABLE_IMGUI cleanupImGui(); #endif } diff --git a/src/engine/Renderer.cpp b/src/engine/Renderer.cpp index dd4f0b1..8fc5d3e 100644 --- a/src/engine/Renderer.cpp +++ b/src/engine/Renderer.cpp @@ -50,7 +50,6 @@ namespace fgl::engine != vk::Result::eSuccess ) throw std::runtime_error( "Failed to allocate command buffers" ); -#ifdef TRACY_ENABLE #if TRACY_ENABLE m_tracy_ctx.resize( SwapChain::MAX_FRAMES_IN_FLIGHT ); @@ -62,7 +61,6 @@ namespace fgl::engine m_tracy_ctx[ i ] = TracyVkContext( phy_dev, dev, Device::getInstance().graphicsQueue(), m_command_buffer[ i ] ); } -#endif #endif } diff --git a/src/engine/Renderer.hpp b/src/engine/Renderer.hpp index 792a031..6169d10 100644 --- a/src/engine/Renderer.hpp +++ b/src/engine/Renderer.hpp @@ -61,7 +61,7 @@ namespace fgl::engine TracyVkCtx getCurrentTracyCTX() const { -#ifdef TRACY_ENABLE +#if TRACY_ENABLE return m_tracy_ctx[ current_frame_idx ]; #else return nullptr;