Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use open source PIX runtime instead of NuGet pre-build. #133

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions docs/release-logs/0.4.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
- 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))
Expand Down
9 changes: 7 additions & 2 deletions src/Backends/DirectX12/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -89,9 +88,15 @@ 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(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")
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)
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
60 changes: 14 additions & 46 deletions src/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,10 @@
"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",
"LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
},
{
Expand All @@ -57,14 +47,17 @@
}
},
{
"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",
"LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
},
{
Expand All @@ -74,20 +67,9 @@
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "windows-x86-test",
"inherits": "windows",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"LITEFX_BUILD_TESTS": "ON"
"LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "ON"
}
},
{
Expand All @@ -102,41 +84,27 @@
}
},
{
"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",
"LITEFX_BUILD_SUPPORT_DEBUG_MARKERS": "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": [
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@
64 changes: 64 additions & 0 deletions src/Modules/overlay-ports/winpixeventruntime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>" "$<INSTALL_INTERFACE:include/>"
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)
41 changes: 16 additions & 25 deletions src/Modules/overlay-ports/winpixeventruntime/portfile.cmake
Original file line number Diff line number Diff line change
@@ -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)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
4 changes: 4 additions & 0 deletions src/Modules/overlay-ports/winpixeventruntime/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The package WinPixEventRuntime provides CMake targets:

find_package(WinPixEventRuntime REQUIRED)
target_link_libraries(main PRIVATE microsoft::WinPixEventRuntime)
Loading