From 62982860b7cab66dfc666d19927302290ba99798 Mon Sep 17 00:00:00 2001
From: Carsten Rudolph <18394207+crud89@users.noreply.github.com>
Date: Wed, 3 Jul 2024 13:41:33 +0200
Subject: [PATCH 1/4] Fix overlay port to use open sourced version of pix
runtime.
---
src/Backends/DirectX12/CMakeLists.txt | 2 +-
.../winpixeventruntime/CMakeLists.txt | 64 +++++++++++++++++++
.../winpixeventruntime/portfile.cmake | 41 +++++-------
.../overlay-ports/winpixeventruntime/usage | 4 ++
.../winpixeventruntime/vcpkg.json | 25 ++++++--
.../winpixeventruntime/win32compat.patch | 39 +++++++++++
.../winpixeventruntime-config.cmake.in | 24 -------
7 files changed, 142 insertions(+), 57 deletions(-)
create mode 100644 src/Modules/overlay-ports/winpixeventruntime/CMakeLists.txt
create mode 100644 src/Modules/overlay-ports/winpixeventruntime/usage
create mode 100644 src/Modules/overlay-ports/winpixeventruntime/win32compat.patch
delete mode 100644 src/Modules/overlay-ports/winpixeventruntime/winpixeventruntime-config.cmake.in
diff --git a/src/Backends/DirectX12/CMakeLists.txt b/src/Backends/DirectX12/CMakeLists.txt
index 38e735294..51bf84a76 100644
--- a/src/Backends/DirectX12/CMakeLists.txt
+++ b/src/Backends/DirectX12/CMakeLists.txt
@@ -11,7 +11,7 @@ MESSAGE(STATUS "Initializing: ${PROJECT_NAME}...")
FIND_PACKAGE(directx-headers CONFIG REQUIRED)
FIND_PACKAGE(directx-agility-sdk CONFIG REQUIRED)
FIND_PACKAGE(d3d12-memory-allocator CONFIG REQUIRED)
-FIND_PACKAGE(winpixeventruntime CONFIG REQUIRED)
+FIND_PACKAGE(WinPixEventRuntime CONFIG REQUIRED)
FIND_PACKAGE(directx-dxc CONFIG REQUIRED)
# Collect header & source files.
diff --git a/src/Modules/overlay-ports/winpixeventruntime/CMakeLists.txt b/src/Modules/overlay-ports/winpixeventruntime/CMakeLists.txt
new file mode 100644
index 000000000..d4f83d884
--- /dev/null
+++ b/src/Modules/overlay-ports/winpixeventruntime/CMakeLists.txt
@@ -0,0 +1,64 @@
+cmake_minimum_required(VERSION 3.20)
+project(WinPixEventRuntime LANGUAGES CXX)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+# Run message compiler for ETW manifest.
+# Note: this naturally requries msvc toolset.
+add_custom_target(PixEtw
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_SOURCE_DIR}/intermediates/"
+ COMMAND mc "${CMAKE_SOURCE_DIR}/runtime/lib/PixEtw.man" -um -P ETW_EVENT -r "${CMAKE_SOURCE_DIR}/intermediates/" -h "${CMAKE_SOURCE_DIR}/intermediates/"
+)
+
+# Define library project
+add_library(WinPixEventRuntimeLib STATIC
+ "runtime/lib/BlockAllocator.h"
+ "runtime/lib/pch.h"
+ "runtime/lib/ThreadData.h"
+ "runtime/lib/ThreadedWorker.h"
+ "runtime/lib/Threads.h"
+ "runtime/lib/WinPixEventRuntime.h"
+ "runtime/lib/Worker.h"
+
+ "runtime/lib/BlockAllocator.cpp"
+ "runtime/lib/ThreadData.cpp"
+ "runtime/lib/ThreadedWorker.cpp"
+ "runtime/lib/Threads.cpp"
+ "runtime/lib/WinPixEventRuntime.cpp"
+ "runtime/lib/pch.cpp"
+
+ "runtime/lib/PixEtw.man"
+)
+
+# TODO: Use vcpkg to resolve WIL.
+target_include_directories(WinPixEventRuntimeLib
+ PUBLIC "include/"
+ PRIVATE "intermediates/" "third_party/wil/include/" "${CMAKE_SOURCE_DIR}/"
+)
+target_precompile_headers(WinPixEventRuntimeLib PRIVATE "runtime/lib/pch.h")
+target_compile_definitions(WinPixEventRuntimeLib PUBLIC "USE_PIX" "USE_PIX_ON_ALL_ARCHITECTURES") # TODO: For DEBUG builds, define DBG macro.
+add_dependencies(WinPixEventRuntimeLib PixEtw)
+
+# Define dynamic runtime library.
+add_library(WinPixEventRuntime SHARED
+ "runtime/dll/desktop/WinPixEventRuntime.def"
+
+ "runtime/dll/shared/WinPixEventRuntime.shared.cpp"
+ "runtime/dll/shared/WinDllMain.cpp"
+)
+
+target_link_libraries(WinPixEventRuntime PRIVATE WinPixEventRuntimeLib)
+target_include_directories(WinPixEventRuntime
+ PUBLIC "$" "$"
+ PRIVATE "runtime/" "intermediates/" "third_party/wil/include/" "${CMAKE_SOURCE_DIR}/"
+)
+
+set_target_properties(WinPixEventRuntime PROPERTIES
+ PUBLIC_HEADER "include/PIXEvents.h;include/PIXEventsCommon.h;include/PIXEventsLegacy.h;include/pix3.h;include/pix3_win.h"
+)
+
+# Define install targets.
+install(TARGETS WinPixEventRuntime EXPORT WinPixEventRuntime)
+export(TARGETS WinPixEventRuntime NAMESPACE Microsoft:: FILE WinPixEventRuntimeConfig.cmake)
+install(EXPORT WinPixEventRuntime DESTINATION "${CMAKE_INSTALL_PREFIX}/share/cmake" NAMESPACE Microsoft:: FILE WinPixEventRuntimeConfig.cmake)
\ No newline at end of file
diff --git a/src/Modules/overlay-ports/winpixeventruntime/portfile.cmake b/src/Modules/overlay-ports/winpixeventruntime/portfile.cmake
index e1aa2a5f9..a497c3851 100644
--- a/src/Modules/overlay-ports/winpixeventruntime/portfile.cmake
+++ b/src/Modules/overlay-ports/winpixeventruntime/portfile.cmake
@@ -1,30 +1,21 @@
-vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION}
-vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
-
-vcpkg_download_distfile(ARCHIVE
- URLS "https://www.nuget.org/api/v2/package/WinPixEventRuntime/${VERSION}"
- FILENAME "winpixeventruntime.${VERSION}.zip"
- SHA512 f33d55a8bb731e404370f75756fd41470b5c4eda12f18f5642cdda8d6bde054ea7aa4e78b6074a0fcb707bd5f026ec75d0245bb2328ec9f93fdfaffde4fdcf09
-)
-
-vcpkg_extract_source_archive(
- PACKAGE_PATH
- ARCHIVE ${ARCHIVE}
- NO_REMOVE_ONE_LEVEL
+set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO Microsoft/PixEvents
+ REF 3a7e70dde7bf54f02f9d2e9dd6d3350c6cfb962f
+ SHA512 91b7a2f8c83d8e848ec89866e8f30092a1e49f5d327fd5dd972bdb6f8848cef28fd135f6304df0811241a95f379089853edf98c451dc680fc6d7838a8be8edd1
+ HEAD_REF main
+ PATCHES win32compat.patch
)
-file(INSTALL "${PACKAGE_PATH}/include/WinPixEventRuntime/pix3.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
-file(INSTALL "${PACKAGE_PATH}/include/WinPixEventRuntime/pix3_win.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
-file(INSTALL "${PACKAGE_PATH}/include/WinPixEventRuntime/PIXEvents.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
-file(INSTALL "${PACKAGE_PATH}/include/WinPixEventRuntime/PIXEventsCommon.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
-
-file(INSTALL "${PACKAGE_PATH}/bin/${VCPKG_TARGET_ARCHITECTURE}/WinPixEventRuntime.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
-
-file(COPY "${PACKAGE_PATH}/bin/${VCPKG_TARGET_ARCHITECTURE}/WinPixEventRuntime.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
-file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug")
-file(COPY "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug")
+vcpkg_cmake_configure(SOURCE_PATH ${SOURCE_PATH})
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(CONFIG_PATH share/cmake/)
-file(INSTALL "${PACKAGE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
-configure_file("${CMAKE_CURRENT_LIST_DIR}/winpixeventruntime-config.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/${PORT}-config.cmake" COPYONLY)
\ No newline at end of file
+file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
\ No newline at end of file
diff --git a/src/Modules/overlay-ports/winpixeventruntime/usage b/src/Modules/overlay-ports/winpixeventruntime/usage
new file mode 100644
index 000000000..6b572bc5e
--- /dev/null
+++ b/src/Modules/overlay-ports/winpixeventruntime/usage
@@ -0,0 +1,4 @@
+The package WinPixEventRuntime provides CMake targets:
+
+ find_package(WinPixEventRuntime REQUIRED)
+ target_link_libraries(main PRIVATE microsoft::WinPixEventRuntime)
\ No newline at end of file
diff --git a/src/Modules/overlay-ports/winpixeventruntime/vcpkg.json b/src/Modules/overlay-ports/winpixeventruntime/vcpkg.json
index 12238956e..fad7d9ab1 100644
--- a/src/Modules/overlay-ports/winpixeventruntime/vcpkg.json
+++ b/src/Modules/overlay-ports/winpixeventruntime/vcpkg.json
@@ -1,9 +1,20 @@
{
- "name": "winpixeventruntime",
- "version": "1.0.220810001",
- "description": "Allows applications to be instrumented with marker events, for use with Microsoft PIX.",
- "homepage": "https://devblogs.microsoft.com/pix/winpixeventruntime/",
- "documentation": "https://devblogs.microsoft.com/pix/winpixeventruntime/",
- "license": null,
- "supports": "(windows & (x64 | arm64)) & !uwp & !staticcrt"
+ "name": "winpixeventruntime",
+ "version": "1.0.240308001",
+ "description": "Allows applications to be instrumented with marker events, for use with Microsoft PIX.",
+ "homepage": "https://devblogs.microsoft.com/pix/winpixeventruntime/",
+ "documentation": "https://devblogs.microsoft.com/pix/winpixeventruntime/",
+ "license": "MIT",
+ "supports": "windows & !uwp",
+ "dependencies": [
+ "directx-headers",
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ]
}
\ No newline at end of file
diff --git a/src/Modules/overlay-ports/winpixeventruntime/win32compat.patch b/src/Modules/overlay-ports/winpixeventruntime/win32compat.patch
new file mode 100644
index 000000000..173713ea1
--- /dev/null
+++ b/src/Modules/overlay-ports/winpixeventruntime/win32compat.patch
@@ -0,0 +1,39 @@
+diff --git a/runtime/lib/ThreadData.cpp b/runtime/lib/ThreadData.cpp
+index 4e11668..18fa4d5 100644
+--- a/runtime/lib/ThreadData.cpp
++++ b/runtime/lib/ThreadData.cpp
+@@ -42,8 +42,10 @@ namespace WinPixEventRuntime
+
+ PIXEventsThreadInfo* ThreadData::GetPixEventsThreadInfo()
+ {
++#if DBG
+ // This is our thread info that's only meant to be used by this thread.
+ assert(m_threadId == std::this_thread::get_id());
++#endif
+
+ if (m_isEnabled)
+ {
+@@ -85,8 +87,10 @@ namespace WinPixEventRuntime
+
+ uint64_t ThreadData::ReplaceBlock(std::optional const& eventTime)
+ {
++#if DBG
+ // This is our thread info that's only meant to be used by this thread.
+ assert(m_threadId == std::this_thread::get_id());
++#endif
+
+ if (auto oldBlock = Flush(eventTime))
+ {
+diff --git a/runtime/lib/WinPixEventRuntime.cpp b/runtime/lib/WinPixEventRuntime.cpp
+index d8d6bb8..463bd23 100644
+--- a/runtime/lib/WinPixEventRuntime.cpp
++++ b/runtime/lib/WinPixEventRuntime.cpp
+@@ -158,7 +158,7 @@ namespace WinPixEventRuntime
+ //
+
+
+-UINT64 PIXEventsReplaceBlock(PIXEventsThreadInfo* threadInfo, bool getEarliestTime) noexcept
++UINT64 WINAPI PIXEventsReplaceBlock(PIXEventsThreadInfo* threadInfo, bool getEarliestTime) noexcept
+ {
+ std::optional eventTime;
+ if (getEarliestTime)
diff --git a/src/Modules/overlay-ports/winpixeventruntime/winpixeventruntime-config.cmake.in b/src/Modules/overlay-ports/winpixeventruntime/winpixeventruntime-config.cmake.in
deleted file mode 100644
index 02ffd5209..000000000
--- a/src/Modules/overlay-ports/winpixeventruntime/winpixeventruntime-config.cmake.in
+++ /dev/null
@@ -1,24 +0,0 @@
-get_filename_component(_winpixeventruntime_root "${CMAKE_CURRENT_LIST_FILE}" PATH)
-get_filename_component(_winpixeventruntime_root "${_winpixeventruntime_root}" PATH)
-get_filename_component(_winpixeventruntime_root "${_winpixeventruntime_root}" PATH)
-
-set(_winpixeventruntime_root_lib "${_winpixeventruntime_root}/lib/WinPixEventRuntime.lib")
-if (EXISTS "${_winpixeventruntime_root_lib}")
-
- add_library(Microsoft::WinPixEventRuntime SHARED IMPORTED)
- set_target_properties(Microsoft::WinPixEventRuntime PROPERTIES
- IMPORTED_LOCATION "${_winpixeventruntime_root}/bin/WinPixEventRuntime.dll"
- IMPORTED_IMPLIB "${_winpixeventruntime_root_lib}"
- INTERFACE_INCLUDE_DIRECTORIES "${_winpixeventruntime_root}/include"
- IMPORTED_LINK_INTERFACE_LANGUAGES "C")
-
- set(winpixeventruntime_FOUND TRUE)
-
-else()
-
- set(winpixeventruntime_FOUND FALSE)
-
-endif()
-
-unset(_winpixeventruntime_root_lib)
-unset(_winpixeventruntime_root)
\ No newline at end of file
From e04850127e3d09ab197218974c06adbf18dc48f6 Mon Sep 17 00:00:00 2001
From: Carsten Rudolph <18394207+crud89@users.noreply.github.com>
Date: Wed, 3 Jul 2024 13:50:10 +0200
Subject: [PATCH 2/4] Add note regarding PIX runtime update.
---
docs/release-logs/0.4.1.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/release-logs/0.4.1.md b/docs/release-logs/0.4.1.md
index 99f45a753..5f848e860 100644
--- a/docs/release-logs/0.4.1.md
+++ b/docs/release-logs/0.4.1.md
@@ -46,7 +46,7 @@
**🌋 Vulkan:**
-- Raise minimum Vulkan SDK version to 1.3.204.1. ([See PR #86](https://github.com/crud89/LiteFX/pull/86) and [See PR #88](https://github.com/crud89/LiteFX/pull/88))
+- Raise minimum Vulkan SDK version to 1.3.204.1. ([See PR #86](https://github.com/crud89/LiteFX/pull/86) and [PR #88](https://github.com/crud89/LiteFX/pull/88))
- `VK_EXT_debug_utils` is now enabled by default for the Vulkan backend in debug builds. ([See PR #82](https://github.com/crud89/LiteFX/pull/82))
- Images are now implicitly transitioned during transfer operations. ([See PR #93](https://github.com/crud89/LiteFX/pull/93))
- Command buffers no longer share a command pool, improving multi-threading behavior. ([See PR #112](https://github.com/crud89/LiteFX/pull/112))
@@ -60,7 +60,7 @@
**❎ DirectX 12:**
-- Use official PIX event runtime for DX12 x64 debug builds. ([See PR #82](https://github.com/crud89/LiteFX/pull/82))
+- Use official PIX event runtime for DX12 debug builds. ([See PR #82](https://github.com/crud89/LiteFX/pull/82) and ([PR #133](https://github.com/crud89/LiteFX/pull/133))
- Switch D3D12 runtime to DirectX Agility SDK. ([See PR #95](https://github.com/crud89/LiteFX/pull/95))
- Add support for enhanced barriers. ([See PR #97](https://github.com/crud89/LiteFX/pull/97))
- Raise minimum required feature level to 12.1. ([See PR #122](https://github.com/crud89/LiteFX/pull/122))
From 69191d04d46203c39dc3da245a4459acac1ca0ed Mon Sep 17 00:00:00 2001
From: Carsten Rudolph <18394207+crud89@users.noreply.github.com>
Date: Thu, 4 Jul 2024 10:14:47 +0200
Subject: [PATCH 3/4] Don't link vcpkg for x86 builds and make it an optional
feature.
---
docs/release-logs/0.4.1.md | 2 +-
src/Backends/DirectX12/CMakeLists.txt | 14 ++++-
src/CMakePresets.json | 59 ++++---------------
.../winpixeventruntime/vcpkg.json | 3 +-
src/vcpkg.json | 10 +++-
5 files changed, 34 insertions(+), 54 deletions(-)
diff --git a/docs/release-logs/0.4.1.md b/docs/release-logs/0.4.1.md
index 5f848e860..ed4cc3bf2 100644
--- a/docs/release-logs/0.4.1.md
+++ b/docs/release-logs/0.4.1.md
@@ -60,7 +60,7 @@
**❎ DirectX 12:**
-- Use official PIX event runtime for DX12 debug builds. ([See PR #82](https://github.com/crud89/LiteFX/pull/82) and ([PR #133](https://github.com/crud89/LiteFX/pull/133))
+- Link PIX event runtime for DX12 x64 builds by default. ([See PR #82](https://github.com/crud89/LiteFX/pull/82) and ([PR #133](https://github.com/crud89/LiteFX/pull/133))
- Switch D3D12 runtime to DirectX Agility SDK. ([See PR #95](https://github.com/crud89/LiteFX/pull/95))
- Add support for enhanced barriers. ([See PR #97](https://github.com/crud89/LiteFX/pull/97))
- Raise minimum required feature level to 12.1. ([See PR #122](https://github.com/crud89/LiteFX/pull/122))
diff --git a/src/Backends/DirectX12/CMakeLists.txt b/src/Backends/DirectX12/CMakeLists.txt
index 51bf84a76..b7151317e 100644
--- a/src/Backends/DirectX12/CMakeLists.txt
+++ b/src/Backends/DirectX12/CMakeLists.txt
@@ -11,7 +11,6 @@ MESSAGE(STATUS "Initializing: ${PROJECT_NAME}...")
FIND_PACKAGE(directx-headers CONFIG REQUIRED)
FIND_PACKAGE(directx-agility-sdk CONFIG REQUIRED)
FIND_PACKAGE(d3d12-memory-allocator CONFIG REQUIRED)
-FIND_PACKAGE(WinPixEventRuntime CONFIG REQUIRED)
FIND_PACKAGE(directx-dxc CONFIG REQUIRED)
# Collect header & source files.
@@ -89,9 +88,20 @@ TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
# Link project dependencies.
TARGET_LINK_LIBRARIES(${PROJECT_NAME}
PUBLIC LiteFX.Core LiteFX.Math LiteFX.Rendering LiteFX.AppModel Microsoft::DirectX-Headers Microsoft::DirectX-Guids dxgi Microsoft::DirectXAgilitySDK Microsoft::DirectXShaderCompiler Microsoft::DXIL
- PRIVATE unofficial::d3d12-memory-allocator Microsoft::WinPixEventRuntime
+ PRIVATE unofficial::d3d12-memory-allocator
)
+# 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)
+
# Add shader modules.
ADD_SHADER_LIBRARY(${PROJECT_NAME}.Shaders SOURCE_FILE "shader_resources.hpp" NAMESPACE "LiteFX::Backends::DirectX12::Shaders")
ADD_SHADER_MODULE(${PROJECT_NAME}.Blit SOURCE "shaders/blit.hlsl" LANGUAGE HLSL TYPE COMPUTE COMPILE_AS DXIL SHADER_MODEL ${LITEFX_BUILD_HLSL_SHADER_MODEL} COMPILER DXC LIBRARY ${PROJECT_NAME}.Shaders)
diff --git a/src/CMakePresets.json b/src/CMakePresets.json
index 6c2442b47..abb87df61 100644
--- a/src/CMakePresets.json
+++ b/src/CMakePresets.json
@@ -29,20 +29,9 @@
"value": "x64",
"strategy": "external"
},
- "cacheVariables": {
- "CMAKE_BUILD_TYPE": "Debug"
- }
- },
- {
- "name": "windows-x64-test",
- "inherits": "windows",
- "architecture": {
- "value": "x64",
- "strategy": "external"
- },
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
- "LITEFX_BUILD_TESTS": "ON"
+ "VCPKG_MANIFEST_FEATURES": "pix-support"
}
},
{
@@ -53,18 +42,21 @@
"strategy": "external"
},
"cacheVariables": {
- "CMAKE_BUILD_TYPE": "Release"
+ "CMAKE_BUILD_TYPE": "Release",
+ "VCPKG_MANIFEST_FEATURES": "pix-support"
}
},
{
- "name": "windows-x64-publish",
+ "name": "windows-x64-test",
"inherits": "windows",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
- "CMAKE_BUILD_TYPE": "Release"
+ "CMAKE_BUILD_TYPE": "Debug",
+ "LITEFX_BUILD_TESTS": "ON",
+ "VCPKG_MANIFEST_FEATURES": "pix-support"
}
},
{
@@ -78,18 +70,6 @@
"CMAKE_BUILD_TYPE": "Debug"
}
},
- {
- "name": "windows-x86-test",
- "inherits": "windows",
- "architecture": {
- "value": "x86",
- "strategy": "external"
- },
- "cacheVariables": {
- "CMAKE_BUILD_TYPE": "Debug",
- "LITEFX_BUILD_TESTS": "ON"
- }
- },
{
"name": "windows-x86-release",
"inherits": "windows",
@@ -102,41 +82,26 @@
}
},
{
- "name": "windows-x86-publish",
+ "name": "windows-x86-test",
"inherits": "windows",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
- "CMAKE_BUILD_TYPE": "Release"
+ "CMAKE_BUILD_TYPE": "Debug",
+ "LITEFX_BUILD_TESTS": "ON"
}
}
],
"buildPresets": [
- {
- "name": "windows-x64-release",
- "configurePreset": "windows-x64-release"
- },
- {
- "name": "windows-x64-debug",
- "configurePreset": "windows-x64-debug"
- },
- {
- "name": "windows-x86-release",
- "configurePreset": "windows-x86-release"
- },
- {
- "name": "windows-x86-debug",
- "configurePreset": "windows-x86-debug"
- },
{
"name": "windows-x86-publish",
- "configurePreset": "windows-x86-publish"
+ "configurePreset": "windows-x86-release"
},
{
"name": "windows-x64-publish",
- "configurePreset": "windows-x64-publish"
+ "configurePreset": "windows-x64-release"
}
],
"testPresets": [
diff --git a/src/Modules/overlay-ports/winpixeventruntime/vcpkg.json b/src/Modules/overlay-ports/winpixeventruntime/vcpkg.json
index fad7d9ab1..ddf96e2d2 100644
--- a/src/Modules/overlay-ports/winpixeventruntime/vcpkg.json
+++ b/src/Modules/overlay-ports/winpixeventruntime/vcpkg.json
@@ -5,9 +5,8 @@
"homepage": "https://devblogs.microsoft.com/pix/winpixeventruntime/",
"documentation": "https://devblogs.microsoft.com/pix/winpixeventruntime/",
"license": "MIT",
- "supports": "windows & !uwp",
+ "supports": "windows & x64 & !uwp",
"dependencies": [
- "directx-headers",
{
"name": "vcpkg-cmake",
"host": true
diff --git a/src/vcpkg.json b/src/vcpkg.json
index 3a60cbc4e..50ce0ac55 100644
--- a/src/vcpkg.json
+++ b/src/vcpkg.json
@@ -21,8 +21,14 @@
"spirv-reflect",
"vulkan-memory-allocator",
"d3d12-memory-allocator",
- "winpixeventruntime",
"directx-agility-sdk",
"directx-dxc"
- ]
+ ],
+ "features": {
+ "pix-support": {
+ "description": "Adds support for PIX runtime in the DirectX 12 backend.",
+ "supports": "windows & x64",
+ "dependencies": [ "winpixeventruntime" ]
+ }
+ }
}
From e42e4d2f69cfa56da34e8217b7698a00c6ce57df Mon Sep 17 00:00:00 2001
From: Carsten Rudolph <18394207+crud89@users.noreply.github.com>
Date: Wed, 10 Jul 2024 12:06:44 +0200
Subject: [PATCH 4/4] Add option to explicitly toggle debug marker support.
---
README.md | 1 +
src/Backends/DirectX12/CMakeLists.txt | 13 ++++---------
.../DirectX12/include/litefx/backends/dx12.hpp | 4 ++--
src/Backends/DirectX12/src/queue.cpp | 4 ++--
.../Vulkan/include/litefx/backends/vulkan.hpp | 4 ++--
src/Backends/Vulkan/src/backend.cpp | 4 ++--
src/Backends/Vulkan/src/queue.cpp | 4 ++--
src/CMakePresets.json | 15 +++++++++------
src/Core/config.tmpl | 2 ++
src/cmake/Options.cmake | 9 ++++++++-
10 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
index 6376d1fe3..725ed01d7 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/src/Backends/DirectX12/CMakeLists.txt b/src/Backends/DirectX12/CMakeLists.txt
index b7151317e..10b9c9ae5 100644
--- a/src/Backends/DirectX12/CMakeLists.txt
+++ b/src/Backends/DirectX12/CMakeLists.txt
@@ -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")
diff --git a/src/Backends/DirectX12/include/litefx/backends/dx12.hpp b/src/Backends/DirectX12/include/litefx/backends/dx12.hpp
index 366ab4e7d..ce9c50852 100644
--- a/src/Backends/DirectX12/include/litefx/backends/dx12.hpp
+++ b/src/Backends/DirectX12/include/litefx/backends/dx12.hpp
@@ -1254,7 +1254,7 @@ namespace LiteFX::Rendering::Backends {
///
QueueType type() const noexcept override;
-#if !defined(NDEBUG) && defined(_WIN64)
+#if defined(LITEFX_BUILD_SUPPORT_DEBUG_MARKERS) && defined(LITEFX_BUILD_WITH_PIX_RUNTIME)
public:
///
void beginDebugRegion(const String& label, const Vectors::ByteVector3& color = { 128_b, 128_b, 128_b }) const noexcept override;
@@ -1264,7 +1264,7 @@ namespace LiteFX::Rendering::Backends {
///
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:
///
diff --git a/src/Backends/DirectX12/src/queue.cpp b/src/Backends/DirectX12/src/queue.cpp
index 1e0e326c3..0dc4c16bb 100644
--- a/src/Backends/DirectX12/src/queue.cpp
+++ b/src/Backends/DirectX12/src/queue.cpp
@@ -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());
@@ -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
{
diff --git a/src/Backends/Vulkan/include/litefx/backends/vulkan.hpp b/src/Backends/Vulkan/include/litefx/backends/vulkan.hpp
index 30c7109f7..d5a3f84ef 100644
--- a/src/Backends/Vulkan/include/litefx/backends/vulkan.hpp
+++ b/src/Backends/Vulkan/include/litefx/backends/vulkan.hpp
@@ -1263,7 +1263,7 @@ namespace LiteFX::Rendering::Backends {
///
QueueType type() const noexcept override;
-#ifndef NDEBUG
+#ifdef LITEFX_BUILD_SUPPORT_DEBUG_MARKERS
public:
///
void beginDebugRegion(const String& label, const Vectors::ByteVector3& color = { 128_b, 128_b, 128_b }) const noexcept override;
@@ -1273,7 +1273,7 @@ namespace LiteFX::Rendering::Backends {
///
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:
///
diff --git a/src/Backends/Vulkan/src/backend.cpp b/src/Backends/Vulkan/src/backend.cpp
index e919f3b64..90c6c3172 100644
--- a/src/Backends/Vulkan/src/backend.cpp
+++ b/src/Backends/Vulkan/src/backend.cpp
@@ -43,10 +43,10 @@ class VulkanBackend::VulkanBackendImpl : public Implement {
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
diff --git a/src/Backends/Vulkan/src/queue.cpp b/src/Backends/Vulkan/src/queue.cpp
index c9dc4e51c..438c1d83f 100644
--- a/src/Backends/Vulkan/src/queue.cpp
+++ b/src/Backends/Vulkan/src/queue.cpp
@@ -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 {
@@ -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
{
diff --git a/src/CMakePresets.json b/src/CMakePresets.json
index abb87df61..380fe79e2 100644
--- a/src/CMakePresets.json
+++ b/src/CMakePresets.json
@@ -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"
}
},
{
@@ -42,8 +43,7 @@
"strategy": "external"
},
"cacheVariables": {
- "CMAKE_BUILD_TYPE": "Release",
- "VCPKG_MANIFEST_FEATURES": "pix-support"
+ "CMAKE_BUILD_TYPE": "Release"
}
},
{
@@ -56,7 +56,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"
}
},
{
@@ -67,7 +68,8 @@
"strategy": "external"
},
"cacheVariables": {
- "CMAKE_BUILD_TYPE": "Debug"
+ "CMAKE_BUILD_TYPE": "Debug",
+ "LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
},
{
@@ -90,7 +92,8 @@
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
- "LITEFX_BUILD_TESTS": "ON"
+ "LITEFX_BUILD_TESTS": "ON",
+ "LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
}
],
diff --git a/src/Core/config.tmpl b/src/Core/config.tmpl
index b11f69a24..b9d9ac3b7 100644
--- a/src/Core/config.tmpl
+++ b/src/Core/config.tmpl
@@ -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@
\ No newline at end of file
diff --git a/src/cmake/Options.cmake b/src/cmake/Options.cmake
index 091a84592..52c5dec1e 100644
--- a/src/cmake/Options.cmake
+++ b/src/cmake/Options.cmake
@@ -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)
@@ -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))
\ No newline at end of file
+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)
\ No newline at end of file