Skip to content

Commit

Permalink
CMake support for using latest WARP and D3D12 (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn authored Oct 12, 2024
1 parent 106830e commit 6adc26f
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
interval: weekly
65 changes: 63 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

cmake_minimum_required (VERSION 3.20)
cmake_minimum_required (VERSION 3.21)

project (dxcapsviewer
DESCRIPTION "DirectX Capabilities Viewer"
Expand All @@ -10,6 +10,12 @@ project (dxcapsviewer

option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)

option(BUILD_WITH_NEW_WARP "Use the WARP package on NuGet" OFF)
set(DIRECTX_WARP_VERSION 1.0.13)

option(BUILD_WITH_NEW_DX12 "Use the DirectX 12 Agility SDK Binaries" OFF)
set(DIRECTX_DX12_VERSION 1.614.1)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -59,7 +65,7 @@ find_package(directx-headers CONFIG QUIET)
if(directx-headers_FOUND)
message(STATUS "Using DirectX-Headers package")
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectX-Headers)
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS USING_D3D12_AGILITY_SDK)
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS)
endif()

if(MSVC)
Expand Down Expand Up @@ -141,3 +147,58 @@ endif()
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})

install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})


if(WIN32)
if(${DIRECTX_ARCH} STREQUAL "x86")
set(NUGET_ARCH win32)
else()
set(NUGET_ARCH ${DIRECTX_ARCH})
endif()

if(BUILD_WITH_NEW_WARP)
message(STATUS "Downloading Microsoft.Direct3D.WARP...")
set(DIRECTX_WARP_ARCHIVE "${CMAKE_BINARY_DIR}/Microsoft.Direct3D.WARP.${DIRECTX_WARP_VERSION}.zip")
file(DOWNLOAD "https://www.nuget.org/api/v2/package/Microsoft.Direct3D.WARP/${DIRECTX_WARP_VERSION}/"
${DIRECTX_WARP_ARCHIVE}
EXPECTED_HASH SHA512=9f5e480947cbdd433f46ffd1a00805db5b8545938867c4a2becf1b49d85dd58234914c45caf3b84686dfd642e9d655f1df56d05a065f5ddc551bf6f1aed58162
)

file(ARCHIVE_EXTRACT INPUT ${DIRECTX_WARP_ARCHIVE} DESTINATION "${CMAKE_BINARY_DIR}/temp" PATTERNS *${NUGET_ARCH}*dll *${NUGET_ARCH}*pdb)

file(GLOB_RECURSE DXBINS "${CMAKE_BINARY_DIR}/temp/*.dll" $<IF:$<CONFIG:DEBUG>,"${CMAKE_BINARY_DIR}/temp/*.pdb">)

file(MAKE_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")

foreach(FILE ${DXBINS})
get_filename_component(FILENAME ${FILE} NAME)
file(COPY_FILE ${FILE} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${FILENAME}")
endforeach(FILE)

file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/temp")
endif()

if (BUILD_WITH_NEW_DX12)
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_D3D12_AGILITY_SDK)

message(STATUS "Downloading Microsoft.Direct3D.D3D12...")
set(DIRECTX_DX12_ARCHIVE "${CMAKE_BINARY_DIR}/Microsoft.Direct3D.D3D12.${DIRECTX_DX12_VERSION}.zip")
file(DOWNLOAD "https://www.nuget.org/api/v2/package/Microsoft.Direct3D.D3D12/${DIRECTX_DX12_VERSION}/"
${DIRECTX_DX12_ARCHIVE}
EXPECTED_HASH SHA512=05baa55231684ab10a3e905c9b85ce78f04ade9360f7de84a06bbae3bfc3123bcccaa563647a25e151cc759106bc19e37740ef78563592d28e3a723fd744b42f
)

file(ARCHIVE_EXTRACT INPUT ${DIRECTX_DX12_ARCHIVE} DESTINATION "${CMAKE_BINARY_DIR}/temp" PATTERNS *${NUGET_ARCH}*dll *${NUGET_ARCH}*exe *${NUGET_ARCH}*pdb)

file(GLOB_RECURSE DXBINS "${CMAKE_BINARY_DIR}/temp/*.dll" "${CMAKE_BINARY_DIR}/temp/*.exe" $<IF:$<CONFIG:DEBUG>,"${CMAKE_BINARY_DIR}/temp/*.pdb">)

file(MAKE_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/D3D12")

foreach(FILE ${DXBINS})
get_filename_component(FILENAME ${FILE} NAME)
file(COPY_FILE ${FILE} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/D3D12//${FILENAME}")
endforeach(FILE)

file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/temp")
endif()
endif()
22 changes: 16 additions & 6 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
}
},

{
"name": "NuGet",
"cacheVariables": {
"BUILD_WITH_NEW_WARP": true,
"BUILD_WITH_NEW_DX12": true
},
"hidden": true
},
{
"name": "VCPKG",
"cacheVariables": {
Expand All @@ -102,11 +110,11 @@
{ "name": "arm64ec-Debug" , "description": "MSVC for ARM64EC (Debug)", "inherits": [ "base", "ARM64EC", "Debug", "MSVC" ], "environment": { "CXXFLAGS": "/arm64EC" } },
{ "name": "arm64ec-Release", "description": "MSVC for ARM64EC (Release)", "inherits": [ "base", "ARM64EC", "Release", "MSVC" ], "environment": { "CXXFLAGS": "/arm64EC" } },

{ "name": "x64-Debug-VCPKG" , "description": "MSVC for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "MSVC", "VCPKG" ] },
{ "name": "x64-Release-VCPKG" , "description": "MSVC for x64 (Release)", "inherits": [ "base", "x64", "Release", "MSVC", "VCPKG" ] },
{ "name": "x86-Debug-VCPKG" , "description": "MSVC for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "MSVC", "VCPKG" ] },
{ "name": "x86-Release-VCPKG" , "description": "MSVC for x86 (Release)", "inherits": [ "base", "x86", "Release", "MSVC", "VCPKG" ] },
{ "name": "arm64-Debug-VCPKG" , "description": "MSVC for ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "MSVC", "VCPKG" ] },
{ "name": "x64-Debug-VCPKG" , "description": "MSVC for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "MSVC", "VCPKG", "NuGet" ] },
{ "name": "x64-Release-VCPKG" , "description": "MSVC for x64 (Release)", "inherits": [ "base", "x64", "Release", "MSVC", "VCPKG", "NuGet" ] },
{ "name": "x86-Debug-VCPKG" , "description": "MSVC for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "MSVC", "VCPKG", "NuGet" ] },
{ "name": "x86-Release-VCPKG" , "description": "MSVC for x86 (Release)", "inherits": [ "base", "x86", "Release", "MSVC", "VCPKG", "NuGet" ] },
{ "name": "arm64-Debug-VCPKG" , "description": "MSVC for ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "MSVC", "VCPKG", "NuGet" ] },
{ "name": "arm64-Release-VCPKG", "description": "MSVC for ARM64 (Release)", "inherits": [ "base", "ARM64", "Release", "MSVC", "VCPKG" ] },
{ "name": "arm64ec-Debug-VCPKG" , "description": "MSVC for ARM64EC (Debug)", "inherits": [ "base", "ARM64EC", "Debug", "MSVC", "VCPKG" ], "environment": { "CXXFLAGS": "/arm64EC" }, "cacheVariables": { "VCPKG_TARGET_TRIPLET": "arm64ec-windows" } },
{ "name": "arm64ec-Release-VCPKG", "description": "MSVC for ARM64EC (Release)", "inherits": [ "base", "ARM64EC", "Release", "MSVC", "VCPKG" ], "environment": { "CXXFLAGS": "/arm64EC" }, "cacheVariables": { "VCPKG_TARGET_TRIPLET": "arm64ec-windows" } },
Expand All @@ -123,6 +131,8 @@
{ "name": "x86-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "-m32" } },
{ "name": "x86-Release-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Release)", "inherits": [ "base", "x86", "Release", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "-m32" } },
{ "name": "arm64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for AArch64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },
{ "name": "arm64-Release-Clang-VCPKG", "description": "Clang/LLVM for AArch64 (Release)", "inherits": [ "base", "ARM64", "Release", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }
{ "name": "arm64-Release-Clang-VCPKG", "description": "Clang/LLVM for AArch64 (Release)", "inherits": [ "base", "ARM64", "Release", "Clang", "VCPKG" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } },

{ "name": "x64-Analyze" , "description": "MSVC for x64 (Debug) using /analyze", "inherits": [ "base", "x64", "Debug", "MSVC" ], "cacheVariables": { "ENABLE_CODE_ANALYSIS": true } }
]
}
32 changes: 28 additions & 4 deletions dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
// Define for some debug output
//#define EXTRA_DEBUG

#ifdef USING_D3D12_AGILITY_SDK
extern "C"
{
// Used to enable the "Agility SDK" components
__declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_SDK_VERSION;
__declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\";
}
#endif

//-----------------------------------------------------------------------------

// This mask is only needed for Direct3D 10.x/11 where some devices had 'holes' in the feature support.
Expand Down Expand Up @@ -4514,6 +4523,17 @@ namespace
auto d3d12opts16 = GetD3D12Options<D3D12_FEATURE_D3D12_OPTIONS16, D3D12_FEATURE_DATA_D3D12_OPTIONS16>(pDevice);
#endif

#if defined(NTDDI_WIN11_GE) || defined(USING_D3D12_AGILITY_SDK)
auto d3d12opts17 = GetD3D12Options<D3D12_FEATURE_D3D12_OPTIONS17, D3D12_FEATURE_DATA_D3D12_OPTIONS17>(pDevice);
auto d3d12opts18 = GetD3D12Options<D3D12_FEATURE_D3D12_OPTIONS18, D3D12_FEATURE_DATA_D3D12_OPTIONS18>(pDevice);
auto d3d12opts19 = GetD3D12Options<D3D12_FEATURE_D3D12_OPTIONS19, D3D12_FEATURE_DATA_D3D12_OPTIONS19>(pDevice);
auto d3d12opts20 = GetD3D12Options<D3D12_FEATURE_D3D12_OPTIONS20, D3D12_FEATURE_DATA_D3D12_OPTIONS20>(pDevice);
#endif

#if defined(NTDDI_WIN11_DT) || defined(USING_D3D12_AGILITY_SDK)
auto d3d12opts21 = GetD3D12Options<D3D12_FEATURE_D3D12_OPTIONS21, D3D12_FEATURE_DATA_D3D12_OPTIONS21>(pDevice);
#endif

if (!pPrintInfo)
{
LVLINE("Feature Level", FLName(fl));
Expand Down Expand Up @@ -4570,10 +4590,12 @@ namespace
LVYESNO("Triangle fans primitives", d3d12opts15.TriangleFanSupported);
LVYESNO("Dynamic IB strip-cut support", d3d12opts15.DynamicIndexBufferStripCutSupported);
LVYESNO("Dynamic depth bias support", d3d12opts16.DynamicDepthBiasSupported);
LVYESNO("GPU upload heap support", d3d12opts16.GPUUploadHeapSupported);
#endif

#if defined(NTDDI_WIN10_CU)
LVYESNO("GPU upload heap support", d3d12opts16.GPUUploadHeapSupported);
#if defined(NTDDI_WIN11_GE) || defined(USING_D3D12_AGILITY_SDK)
LVYESNO("Non-normalized coordinate samplers", d3d12opts17.NonNormalizedCoordinateSamplersSupported);
LVYESNO("Manual write tracking res", d3d12opts17.ManualWriteTrackingResourceSupported);
#endif
}
else
Expand Down Expand Up @@ -4632,10 +4654,12 @@ namespace
PRINTYESNO("Triangle fan primitives", d3d12opts15.TriangleFanSupported);
PRINTYESNO("Dynamic IB strip-cut support", d3d12opts15.DynamicIndexBufferStripCutSupported);
PRINTYESNO("Dynamic depth bias support", d3d12opts16.DynamicDepthBiasSupported);
PRINTYESNO("GPU upload heap support", d3d12opts16.GPUUploadHeapSupported);
#endif

#if defined(NTDDI_WIN10_CU)
PRINTYESNO("GPU upload heap support", d3d12opts16.GPUUploadHeapSupported);
#if defined(NTDDI_WIN11_GE) || defined(USING_D3D12_AGILITY_SDK)
PRINTYESNO("Non-normalized coordinate samplers", d3d12opts17.NonNormalizedCoordinateSamplersSupported);
PRINTYESNO("Manual write tracking res", d3d12opts17.ManualWriteTrackingResourceSupported);
#endif
}

Expand Down

0 comments on commit 6adc26f

Please sign in to comment.