Skip to content

Commit

Permalink
Add option to explicitly toggle debug marker support.
Browse files Browse the repository at this point in the history
  • Loading branch information
crud89 committed Jul 10, 2024
1 parent 69191d0 commit 1465c3b
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Within the cache variables, you can override the build options, LiteFX exports.
- `LITEFX_BUILD_VULKAN_BACKEND` (default: `ON`): builds the Vulkan 🌋 backend (requires [LunarG Vulkan SDK](https://vulkan.lunarg.com/) 1.3.204.1 or later to be installed on your system).
- `LITEFX_BUILD_DX12_BACKEND` (default: `ON`): builds the DirectX 12 ❎ backend.
- `LITEFX_BUILD_DEFINE_BUILDERS` (default: `ON`): enables the [builder architecture](https://github.com/crud89/LiteFX/wiki/Builders) for backends.
- `LITEFX_BUILD_SUPPORT_DEBUG_MARKERS` (default: `OFF`): implements support for setting debug regions on device queues.
- `LITEFX_BUILD_WITH_GLM` (default: `ON`): adds [glm](https://glm.g-truc.net/0.9.9/index.html) converters to math types. †
- `LITEFX_BUILD_WITH_DIRECTX_MATH` (default: `ON`): adds [DirectX Math](https://github.com/microsoft/DirectXMath) converters to math types. †
- `LITEFX_BUILD_HLSL_SHADER_MODEL` (default: `6_5`): specifies the default HLSL shader model.
Expand Down
13 changes: 4 additions & 9 deletions src/Backends/DirectX12/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,10 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME}
)

# Link PIX runtime, if available.
IF("pix-support" IN_LIST VCPKG_MANIFEST_FEATURES)
FIND_PACKAGE(WinPixEventRuntime CONFIG)

IF(WinPixEventRuntime_FOUND)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE Microsoft::WinPixEventRuntime)
ELSE()
MESSAGE(WARNING "PIX runtime was not found and will not be linked.")
ENDIF(WinPixEventRuntime_FOUND)
ENDIF("pix-support" IN_LIST VCPKG_MANIFEST_FEATURES)
IF(LITEFX_BUILD_WITH_PIX_RUNTIME)
FIND_PACKAGE(WinPixEventRuntime CONFIG REQUIRED)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE Microsoft::WinPixEventRuntime)
ENDIF(LITEFX_BUILD_WITH_PIX_RUNTIME)

# Add shader modules.
ADD_SHADER_LIBRARY(${PROJECT_NAME}.Shaders SOURCE_FILE "shader_resources.hpp" NAMESPACE "LiteFX::Backends::DirectX12::Shaders")
Expand Down
4 changes: 2 additions & 2 deletions src/Backends/DirectX12/include/litefx/backends/dx12.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ namespace LiteFX::Rendering::Backends {
/// <inheritdoc />
QueueType type() const noexcept override;

#if !defined(NDEBUG) && defined(_WIN64)
#if defined(LITEFX_BUILD_SUPPORT_DEBUG_MARKERS) && defined(LITEFX_BUILD_WITH_PIX_RUNTIME)
public:
/// <inheritdoc />
void beginDebugRegion(const String& label, const Vectors::ByteVector3& color = { 128_b, 128_b, 128_b }) const noexcept override;
Expand All @@ -1264,7 +1264,7 @@ namespace LiteFX::Rendering::Backends {

/// <inheritdoc />
void setDebugMarker(const String& label, const Vectors::ByteVector3& color = { 128_b, 128_b, 128_b }) const noexcept override;
#endif // !defined(NDEBUG) && defined(_WIN64)
#endif // defined(LITEFX_BUILD_SUPPORT_DEBUG_MARKERS) && defined(LITEFX_BUILD_WITH_PIX_RUNTIME)

public:
/// <inheritdoc />
Expand Down
4 changes: 2 additions & 2 deletions src/Backends/DirectX12/src/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ QueueType DirectX12Queue::type() const noexcept
return m_impl->m_type;
}

#if !defined(NDEBUG) && defined(_WIN64)
#if defined(LITEFX_BUILD_SUPPORT_DEBUG_MARKERS) && defined(LITEFX_BUILD_WITH_PIX_RUNTIME)
void DirectX12Queue::beginDebugRegion(const String& label, const Vectors::ByteVector3& color) const noexcept
{
::PIXBeginEvent(this->handle().Get(), PIX_COLOR(color.x(), color.y(), color.z()), label.c_str());
Expand All @@ -126,7 +126,7 @@ void DirectX12Queue::setDebugMarker(const String& label, const Vectors::ByteVect
{
::PIXSetMarker(this->handle().Get(), PIX_COLOR(color.x(), color.y(), color.z()), label.c_str());
}
#endif // !defined(NDEBUG) && defined(_WIN64)
#endif // defined(LITEFX_BUILD_SUPPORT_DEBUG_MARKERS) && defined(LITEFX_BUILD_WITH_PIX_RUNTIME)

QueuePriority DirectX12Queue::priority() const noexcept
{
Expand Down
4 changes: 2 additions & 2 deletions src/Backends/Vulkan/include/litefx/backends/vulkan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ namespace LiteFX::Rendering::Backends {
/// <inheritdoc />
QueueType type() const noexcept override;

#ifndef NDEBUG
#ifdef LITEFX_BUILD_SUPPORT_DEBUG_MARKERS
public:
/// <inheritdoc />
void beginDebugRegion(const String& label, const Vectors::ByteVector3& color = { 128_b, 128_b, 128_b }) const noexcept override;
Expand All @@ -1273,7 +1273,7 @@ namespace LiteFX::Rendering::Backends {

/// <inheritdoc />
void setDebugMarker(const String& label, const Vectors::ByteVector3& color = { 128_b, 128_b, 128_b }) const noexcept override;
#endif
#endif // LITEFX_BUILD_SUPPORT_DEBUG_MARKERS

public:
/// <inheritdoc />
Expand Down
4 changes: 2 additions & 2 deletions src/Backends/Vulkan/src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class VulkanBackend::VulkanBackendImpl : public Implement<VulkanBackend> {
m_extensions.push_back(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME);
#endif // LITEFX_BUILD_DIRECTX_12_BACKEND

#ifndef NDEBUG
#if defined(LITEFX_BUILD_SUPPORT_DEBUG_MARKERS) || !defined(NDEBUG)
// Debugging extension should be guaranteed to be available.
m_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
#endif // NDEBUG
#endif // defined(LITEFX_BUILD_SUPPORT_DEBUG_MARKERS) || !defined(NDEBUG)
}

#ifndef NDEBUG
Expand Down
4 changes: 2 additions & 2 deletions src/Backends/Vulkan/src/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ QueueType VulkanQueue::type() const noexcept
return m_impl->m_type;
}

#ifndef NDEBUG
#ifdef LITEFX_BUILD_SUPPORT_DEBUG_MARKERS
void VulkanQueue::beginDebugRegion(const String& label, const Vectors::ByteVector3& color) const noexcept
{
VkDebugUtilsLabelEXT labelInfo {
Expand All @@ -150,7 +150,7 @@ void VulkanQueue::setDebugMarker(const String& label, const Vectors::ByteVector3

::vkQueueInsertDebugUtilsLabel(this->handle(), &labelInfo);
}
#endif
#endif // LITEFX_BUILD_SUPPORT_DEBUG_MARKERS

QueuePriority VulkanQueue::priority() const noexcept
{
Expand Down
12 changes: 8 additions & 4 deletions src/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"VCPKG_MANIFEST_FEATURES": "pix-support"
"VCPKG_MANIFEST_FEATURES": "pix-support",
"LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
},
{
Expand All @@ -56,7 +57,8 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"LITEFX_BUILD_TESTS": "ON",
"VCPKG_MANIFEST_FEATURES": "pix-support"
"VCPKG_MANIFEST_FEATURES": "pix-support",
"LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
},
{
Expand All @@ -67,7 +69,8 @@
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
"CMAKE_BUILD_TYPE": "Debug",
"LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
},
{
Expand All @@ -90,7 +93,8 @@
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"LITEFX_BUILD_TESTS": "ON"
"LITEFX_BUILD_TESTS": "ON",
"LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
}
],
Expand Down
2 changes: 2 additions & 0 deletions src/Core/config.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

#cmakedefine LITEFX_BUILD_WITH_GLM
#cmakedefine LITEFX_BUILD_WITH_DIRECTX_MATH
#cmakedefine LITEFX_BUILD_WITH_PIX_RUNTIME

#cmakedefine LITEFX_BUILD_DEFINE_BUILDERS
#cmakedefine LITEFX_BUILD_SUPPORT_DEBUG_MARKERS

#define LITEFX_CXX_VERSION @CMAKE_CXX_STANDARD@
9 changes: 8 additions & 1 deletion src/cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ OPTION(LITEFX_BUILD_VULKAN_BACKEND "Builds the Vulkan backend." ON)
OPTION(LITEFX_BUILD_DIRECTX_12_BACKEND "Builds the DirectX 12 backend." ON)

OPTION(LITEFX_BUILD_DEFINE_BUILDERS "Defines builder types to allow to use builder syntax in applications." ON)
OPTION(LITEFX_BUILD_SUPPORT_DEBUG_MARKERS "Implements support for setting debug markers on device queues." OFF)

OPTION(LITEFX_BUILD_EXAMPLES "When set to OFF, no samples will be built, regardless of their individual option." ON)
OPTION(LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER "Add code to samples to load PIX GPU capture library when starting with --dx-load-pix=1 command line argument." ON)
Expand All @@ -33,4 +34,10 @@ IF(NOT MSVC OR (MSVC AND MSVC_VERSION LESS 1910))
IF(LITEFX_BUILD_DIRECTX_12_BACKEND OR LITEFX_BUILD_WITH_DIRECTX_MATH)
MESSAGE(WARNING "DirectX features may only be working with Visual Studio 2017 or newer.")
ENDIF(LITEFX_BUILD_DIRECTX_12_BACKEND OR LITEFX_BUILD_WITH_DIRECTX_MATH)
ENDIF(NOT MSVC OR (MSVC AND MSVC_VERSION LESS 1910))
ENDIF(NOT MSVC OR (MSVC AND MSVC_VERSION LESS 1910))

IF("pix-support" IN_LIST VCPKG_MANIFEST_FEATURES)
SET(LITEFX_BUILD_WITH_PIX_RUNTIME ON CACHE BOOL "Link DirectX 12 backend against PIX runtime (required for debug marker support).")
ELSE()
SET(LITEFX_BUILD_WITH_PIX_RUNTIME OFF CACHE BOOL "Link DirectX 12 backend against PIX runtime (required for debug marker support).")
ENDIF("pix-support" IN_LIST VCPKG_MANIFEST_FEATURES)

0 comments on commit 1465c3b

Please sign in to comment.