Skip to content
Closed
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: 0 additions & 1 deletion .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Ignore third-party headers that crash the parser
src/include/wisdom/util/xxhash.h
docs/*
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Configure CMake
run: cmake --preset win-msvc-release

- name: Build
run: cmake --build --preset win-msvc-release

Expand Down
45 changes: 44 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,50 @@ jobs:
shell: pwsh
run: |
$format = '${{ github.event.inputs.format }}'
.\package.ps1 -Format $format -Clean -OutputDir './artifacts'
.\package.ps1 -Format $format -Configuration both -Clean -OutputDir './artifacts'

- name: Validate package contents
shell: pwsh
run: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
$format = '${{ github.event.inputs.format }}'

if ($format -in @('nuget', 'all')) {
$nugetPackage = Get-ChildItem -Path artifacts/*.nupkg | Select-Object -First 1
if (-not $nugetPackage) {
throw "NuGet package was not generated."
}

$nugetArchive = [System.IO.Compression.ZipFile]::OpenRead($nugetPackage.FullName)
try {
$hasAgility = $nugetArchive.Entries | Where-Object { $_.FullName -match '(?i)D3D12Core\.dll|d3d12SDKLayers\.dll|d3dx12/' }
if ($hasAgility) {
throw "NuGet package must not include Agility SDK files."
}
}
finally {
$nugetArchive.Dispose()
}
}

if ($format -in @('zip', 'all')) {
$zipPackage = Get-ChildItem -Path artifacts/*.zip | Select-Object -First 1
if (-not $zipPackage) {
throw "ZIP package was not generated."
}

$zipArchive = [System.IO.Compression.ZipFile]::OpenRead($zipPackage.FullName)
try {
$hasCore = $zipArchive.Entries | Where-Object { $_.FullName -match '(?i)D3D12Core\.dll' }
$hasLayers = $zipArchive.Entries | Where-Object { $_.FullName -match '(?i)d3d12SDKLayers\.dll' }
if (-not $hasCore -or -not $hasLayers) {
throw "ZIP package must include Agility SDK runtime files (D3D12Core.dll and d3d12SDKLayers.dll)."
}
}
finally {
$zipArchive.Dispose()
}
}

- name: Upload NuGet Package
uses: actions/upload-artifact@v4
Expand Down
44 changes: 41 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,45 @@ jobs:
- name: Build and Package
shell: pwsh
run: |
.\package.ps1 -Format all -Clean -OutputDir './artifacts'
.\scripts\package.ps1 -Format all -Configuration both -Clean -OutputDir './artifacts'

- name: Validate package contents
shell: pwsh
run: |
Add-Type -AssemblyName System.IO.Compression.FileSystem

$nugetPackage = Get-ChildItem -Path artifacts/*.nupkg | Select-Object -First 1
if (-not $nugetPackage) {
throw "NuGet package was not generated."
}

$nugetArchive = [System.IO.Compression.ZipFile]::OpenRead($nugetPackage.FullName)
try {
$nugetHasAgility = $nugetArchive.Entries | Where-Object { $_.FullName -match '(?i)D3D12Core\.dll|d3d12SDKLayers\.dll|d3dx12/' }
if ($nugetHasAgility) {
throw "NuGet package must not include Agility SDK files."
}
}
finally {
$nugetArchive.Dispose()
}

$zipPackage = Get-ChildItem -Path artifacts/*.zip | Select-Object -First 1
if (-not $zipPackage) {
throw "ZIP package was not generated."
}

$zipArchive = [System.IO.Compression.ZipFile]::OpenRead($zipPackage.FullName)
try {
$zipHasCore = $zipArchive.Entries | Where-Object { $_.FullName -match '(?i)D3D12Core\.dll' }
$zipHasLayers = $zipArchive.Entries | Where-Object { $_.FullName -match '(?i)d3d12SDKLayers\.dll' }
if (-not $zipHasCore -or -not $zipHasLayers) {
throw "ZIP package must include Agility SDK runtime files (D3D12Core.dll and d3d12SDKLayers.dll)."
}
}
finally {
$zipArchive.Dispose()
}

- name: Upload NuGet Package
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -262,13 +300,13 @@ jobs:
uses: lukka/get-cmake@latest

- name: Configure CMake (Debug)
run: cmake --preset linux-gcc-debug-lib -DWISDOM_VULKAN_HEADER_PATH=${{ github.workspace }}/vulkan-headers/include
run: cmake --preset linux-gcc-debug-lib -DWISDOM_VULKAN_HEADER_PATH=${{ github.workspace }}/vulkan-headers/include -DCMAKE_UNITY_BUILD=ON

- name: Build (Debug)
run: cmake --build --preset linux-gcc-debug-lib

- name: Configure CMake (Release)
run: cmake --preset linux-gcc-lib -DWISDOM_VULKAN_HEADER_PATH=${{ github.workspace }}/vulkan-headers/include
run: cmake --preset linux-gcc-lib -DWISDOM_VULKAN_HEADER_PATH=${{ github.workspace }}/vulkan-headers/include -DCMAKE_UNITY_BUILD=ON

- name: Build (Release)
run: cmake --build --preset linux-gcc-lib
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,4 @@ FodyWeavers.xsd

# Package artifacts
/artifacts/
/tests/integration/cmake/extracted/
43 changes: 21 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,24 @@ include(GenerateExportHeader)
include(cmake/functions.cmake)
wisdom_detect_platform()

# Determine which options to use by default
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13"
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "16")
set(LOCAL_USE_FMTLIB TRUE)
else()
set(LOCAL_USE_FMTLIB FALSE)
endif()

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(WTOP ON)
else()
set(WTOP OFF)
endif()

# Options
option(WISDOM_USE_FMT "Build Wisdom with fmtlib" ${LOCAL_USE_FMTLIB})
option(WISDOM_FORCE_VULKAN "Force Vulkan support" OFF)
option(WISDOM_BUILD_EXAMPLES "Build the example project." ${WTOP})
option(WISDOM_BUILD_TESTS "Build the tests." ${WTOP})
option(WISDOM_BUILD_STATIC "Build the static lib." ON)
option(WISDOM_BUILD_SHARED "Build the dynamic lib." ON)
option(WISDOM_BUILD_PLATFORM "Build unified platform extension library." ON)
option(WISDOM_BUILD_DOCS "Build the documentation." OFF)
option(WISDOM_USE_AGILITY_SDK "Download and use DirectX 12 Agility SDK." OFF)
option(WISDOM_USE_CONAN "Use Conan to manage dependencies. Only for library builds." OFF)

# DXC deployment options
set(WISDOM_DXC_PATH
""
CACHE PATH "Path to custom DXC installation (optional)")
set(WISDOM_VULKAN_HEADER_PATH
""
CACHE PATH "Path to custom Vulkan Headers (optional)")
Expand All @@ -55,7 +43,6 @@ message(
WISDOM_VULKAN: ${WISDOM_VULKAN}
WISDOM_VULKAN_VERSION: ${WISDOM_VULKAN_VERSION}
WISDOM_DX12: ${WISDOM_DX12}
WISDOM_USE_FMT: ${WISDOM_USE_FMT}
WISDOM_VERSION: ${WISDOM_VERSION}
WISDOM_PLATFORM: ${WISDOM_PLATFORM}

Expand All @@ -65,13 +52,10 @@ message(
WISDOM_BUILD_STATIC: ${WISDOM_BUILD_STATIC}
WISDOM_BUILD_SHARED: ${WISDOM_BUILD_SHARED}
WISDOM_BUILD_PLATFORM: ${WISDOM_BUILD_PLATFORM}
WISDOM_USE_AGILITY_SDK: ${WISDOM_USE_AGILITY_SDK}
WISDOM_USE_CONAN: ${WISDOM_USE_CONAN}

WISDOM_VULKAN_HEADER_PATH: ${WISDOM_VULKAN_HEADER_PATH}

DXC Configuration:
Custom Path: ${WISDOM_DXC_PATH}
Executable: ${DXC_EXECUTABLE}
")
WISDOM_VULKAN_HEADER_PATH: ${WISDOM_VULKAN_HEADER_PATH}")

if(WISDOM_BUILD_EXAMPLES AND WISDOM_BUILD_TESTS)
add_subdirectory(generator)
Expand Down Expand Up @@ -105,4 +89,19 @@ configure_package_config_file(
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/wisdom-config-version.cmake
${CMAKE_CURRENT_BINARY_DIR}/wisdom-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wisdom)
include(cmake/install/nuget.cmake)

# Set up package metadata
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VENDOR "Agrael")
set(CPACK_NUGET_PACKAGE_AUTHORS "Agrael")
set(CPACK_PACKAGE_DESCRIPTION "A Low-level thin multiplatform and extensible Graphics API layer over Vulkan and DX12")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://agrael1.github.io/Wisdom/")
set(CPACK_NUGET_PACKAGE_REPOSITORY_URL "https://github.com/Agrael1/Wisdom.git")
set(CPACK_NUGET_PACKAGE_ICON "favicon.png") # pulled from installed files
set(CPACK_NUGET_PACKAGE_REPOSITORY_TYPE git)
set(CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION "MIT")
set(CPACK_NUGET_PACKAGE_README "README.md") # pulled from installed files
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_LIST_DIR}/cmake/install/cpack-options.cmake")

include(CPack)
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Vulkan library is loaded dynamically, so it is not required to have Vulkan SDK i
- `WISDOM_BUILD_STATIC=ON` build static library version.
- `WISDOM_BUILD_SHARED=ON` build shared/dynamic library version.
- `WISDOM_BUILD_PLATFORM=ON` build unified platform extension library.
- `WISDOM_USE_AGILITY_SDK=OFF` download and build with Agility SDK instead of Windows SDK, this allows using latest DirectX 12 features on older Windows versions, but requires additional setup and dependencies. Default is `OFF`, which uses Windows SDK that comes with the system and DirectX-Headers.
- `WISDOM_BUILD_DOCS=OFF` build documentation with Doxygen, default is dependent on whether you are building the library as a top project (ON) or as a part/dep for other (OFF)

- `WISDOM_DXC_PATH="Path/to/dxc"` use system DXC compiler instead of the one provided with the library (default uses the one provided)
Expand All @@ -115,8 +116,8 @@ To link library simply use `target_link_libraries(${YOUR_TARGET} PUBLIC wis::wis

Available targets are:

- `wis::wisdom | wis::wisdom-headers` - functional library
- `wis::platform | wis::wisdom-platform-headers` - platform specific extensions (Surface)
- `wis::wisdom | wis::wisdom-headers | wis::wisdom-shared` - functional library
- `wis::platform | wis::wisdom-platform-headers | wis::wisdom-platform-shared` - platform specific extensions (Surface)

There is also Conan package available for consumption, it can't be loaded to Conan Center yet,
but you can add it manually by downloading the repo and executing `conan create .` command in the root of the repository.
Expand Down
63 changes: 28 additions & 35 deletions cmake/deps.cmake
Original file line number Diff line number Diff line change
@@ -1,44 +1,37 @@
include(FetchContent)
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
set(CPM_DONT_UPDATE_MODULE_PATH ON)
set(GET_CPM_FILE "${CMAKE_CURRENT_LIST_DIR}/deps/get_cpm.cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Set CPM source cache
if (NOT CPM_SOURCE_CACHE)
set(CPM_SOURCE_CACHE "${CMAKE_CURRENT_BINARY_DIR}/_deps_cache")
endif ()
# Block CPM if already using Conan, otherwise fetch dependencies using CPM
if(NOT WISDOM_USE_CONAN)
include(FetchContent)
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
set(CPM_DONT_UPDATE_MODULE_PATH ON)
set(GET_CPM_FILE "${CMAKE_CURRENT_LIST_DIR}/deps/get_cpm.cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Set CPM source cache
if (NOT CPM_SOURCE_CACHE)
set(CPM_SOURCE_CACHE "${CMAKE_CURRENT_BINARY_DIR}/_deps_cache")
endif ()


if (NOT EXISTS ${GET_CPM_FILE})
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
"${GET_CPM_FILE}"
)
endif ()
include(${GET_CPM_FILE})
if (NOT EXISTS ${GET_CPM_FILE})
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
"${GET_CPM_FILE}"
)
endif ()
include(${GET_CPM_FILE})
endif()

if (WISDOM_WINDOWS)
include(${CMAKE_CURRENT_LIST_DIR}/deps/deps_win.cmake)
if (WISDOM_USE_CONAN) # This prevents accidental blockade of Agility SDK
find_package(D3D12MemoryAllocator CONFIG QUIET)
if (NOT D3D12MemoryAllocator_FOUND)
message(FATAL_ERROR "D3D12MemoryAllocator not found. Please install it using Conan or disable WISDOM_USE_CONAN.")
endif()
else()
include(${CMAKE_CURRENT_LIST_DIR}/deps/deps_win.cmake)
endif()
endif ()

# Use fmtlib
if (WISDOM_USE_FMT)
find_package(fmt CONFIG QUIET)
if (fmt_FOUND)
message("fmtlib found, skipping download.")
else ()
message("Loading latest fmtlib...")
CPMAddPackage(
NAME fmt
GITHUB_REPOSITORY fmtlib/fmt
GIT_TAG 12.1.0)
endif ()
endif ()

# DXCompiler for HLSL compilation
include(${CMAKE_CURRENT_LIST_DIR}/deps/dxc.cmake)

# Vulkan dependencies
if (WISDOM_VULKAN)
include(${CMAKE_CURRENT_LIST_DIR}/deps/deps_vulkan.cmake)
Expand Down
47 changes: 30 additions & 17 deletions cmake/deps/deps_vulkan.cmake
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
if (NOT vkma_SOURCE_DIR)
CPMAddPackage(
NAME vkma
GITHUB_REPOSITORY GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
GIT_TAG v3.3.0
DOWNLOAD_ONLY TRUE
)
set(vkma_SOURCE_DIR ${vkma_SOURCE_DIR} CACHE INTERNAL "")
else ()
message("Vulkan Memory Allocator found, skipping download.")
endif ()
if (WISDOM_USE_CONAN)
find_package(VulkanMemoryAllocator CONFIG QUIET)
if (NOT VulkanMemoryAllocator_FOUND)
message(FATAL_ERROR "Vulkan Memory Allocator not found. Please install it using Conan or disable WISDOM_USE_CONAN.")
endif()
else()
if (NOT vkma_SOURCE_DIR)
CPMAddPackage(
NAME vkma
GITHUB_REPOSITORY GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
GIT_TAG v3.3.0
DOWNLOAD_ONLY TRUE
)
set(vkma_SOURCE_DIR ${vkma_SOURCE_DIR} CACHE INTERNAL "")
else ()
message("Vulkan Memory Allocator found, skipping download.")
endif ()
endif()

# Generate a cpp file that includes the implementation
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/vma.cpp)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/vma.cpp
"#define VMA_IMPLEMENTATION\n#include \"vk_mem_alloc.h\"\n")
endif ()

add_library(vkma STATIC ${vkma_SOURCE_DIR}/include/vk_mem_alloc.h ${CMAKE_CURRENT_BINARY_DIR}/vma.cpp)
target_link_libraries(vkma PUBLIC Vulkan::Headers)
add_library(vkma STATIC ${CMAKE_CURRENT_BINARY_DIR}/vma.cpp)
target_compile_definitions(
vkma PRIVATE VK_NO_PROTOTYPES VMA_STATIC_VULKAN_FUNCTIONS=0
VMA_DYNAMIC_VULKAN_FUNCTIONS=0)

if (WISDOM_WINDOWS)
target_compile_definitions(vkma PUBLIC VK_USE_PLATFORM_WIN32_KHR
VMA_EXTERNAL_MEMORY_WIN32)
endif (WISDOM_WINDOWS)

target_include_directories(
vkma PUBLIC $<BUILD_INTERFACE:${vkma_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/vkma>)
set_target_properties(vkma PROPERTIES
CXX_STANDARD 20
DEBUG_POSTFIX d
Expand All @@ -44,5 +48,14 @@ install(
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(DIRECTORY ${vkma_SOURCE_DIR}/include/
if (WISDOM_USE_CONAN)
# Conan already links Vulkan::Headers
target_link_libraries(vkma PUBLIC GPUOpen::VulkanMemoryAllocator)
else()
target_link_libraries(vkma PUBLIC Vulkan::Headers)
target_include_directories(
vkma PUBLIC $<BUILD_INTERFACE:${vkma_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/vkma>)
install(DIRECTORY ${vkma_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vkma)
endif()
Loading
Loading