Skip to content

Commit

Permalink
Update for RavEngine changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravbug committed Sep 2, 2024
1 parent e98e30a commit a400f1a
Show file tree
Hide file tree
Showing 120 changed files with 47,036 additions and 12,133 deletions.
131 changes: 73 additions & 58 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ if (RGL_ENABLE_WEBGPU)
set(RGL_WEBGPU_AVAILABLE ON CACHE INTERNAL "RGL WebGPU")
endif()

if (RGL_RUNTIME_COMPILATION)
set(RGL_RUNTIME_COMPILER_LIB "librglc")
endif()

if (CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64")
set(RGL_DISABLE_VK ON CACHE INTERNAL "")
endif()
Expand All @@ -66,6 +62,13 @@ else()
set(ST_ENABLE_WGSL OFF CACHE INTERNAL "")
endif()
set(ST_ENABLE_TEST OFF CACHE INTERNAL "")
if((WIN32 AND NOT WINDOWS_STORE) AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/deps/ShaderTranspiler/deps/DirectXShaderCompiler/CMakeLists.txt")
message("Building DXC from source")
set(ST_BUNDLED_DXC ON)
else()
message("Not building DXC from source")
set(ST_BUNDLED_DXC OFF)
endif()
add_subdirectory(deps/ShaderTranspiler EXCLUDE_FROM_ALL)
file(GLOB_RECURSE LIBRGLC_SOURCES "tools/librglc/*.cpp" "tools/librglc/*.hpp")
add_library(librglc ${LIBRGLC_SOURCES})
Expand Down Expand Up @@ -95,57 +98,80 @@ if (RGL_ENABLE_RGLC)
)
endif()

find_package(Vulkan)

if(CMAKE_SYSTEM_NAME MATCHES "WindowsStore" OR RGL_DISABLE_VK OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "Emscripten")
if(WINDOWS_STORE OR RGL_DISABLE_VK OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "Emscripten")
set(VK_FORCE_DISABLED ON)
else()
set(VK_FORCE_DISABLED OFF)
endif()

if (NOT VK_FORCE_DISABLED AND Vulkan_FOUND)


set(VK_LIBS ${Vulkan_LIBRARIES} VulkanMemoryAllocator)
if (NOT VK_FORCE_DISABLED)
add_subdirectory(deps/volk EXCLUDE_FROM_ALL)
target_compile_definitions(volk PUBLIC NOMINMAX=1)

# Get our vendored headers
set(VK_INCLUDE deps/VulkanMemoryAllocator/include deps/Vulkan-Headers/include deps/Vulkan-Utility-Libraries/include)
set(VK_INCLUDE deps/Vulkan-Headers/include deps/Vulkan-Utility-Libraries/include)
target_include_directories(volk PUBLIC ${VK_INCLUDE})
if (LINUX)
target_compile_definitions(volk PRIVATE VK_USE_PLATFORM_XLIB_KHR VK_USE_PLATFORM_WAYLAND_KHR)
elseif(ANDROID)
target_compile_definitions(volk PRIVATE VK_USE_PLATFORM_ANDROID_KHR)
elseif(WIN32 OR WINDOWS_STORE)
target_compile_definitions(volk PRIVATE VK_USE_PLATFORM_WIN32_KHR)
endif()

target_compile_definitions(${PROJECT_NAME} PUBLIC RGL_VK_AVAILABLE=1)
target_compile_definitions(${PROJECT_NAME} PUBLIC RGL_VK_AVAILABLE=1 )
set(RGL_VK_AVAILABLE ON CACHE INTERNAL "RGL Vulkan")
set(VMA_STATIC_VULKAN_FUNCTIONS ON)
add_subdirectory(deps/VulkanMemoryAllocator EXCLUDE_FROM_ALL)
target_include_directories(VulkanMemoryAllocator PUBLIC ${Vulkan_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PUBLIC ${Vulkan_INCLUDE_DIRS}) # so that library users get the vk paths if applicable
target_compile_features(VulkanMemoryAllocator PUBLIC cxx_std_20)
target_compile_definitions(VulkanMemoryAllocator INTERFACE VMA_STATIC_VULKAN_FUNCTIONS=0 VMA_DYNAMIC_VULKAN_FUNCTIONS=0)

target_link_libraries(${PROJECT_NAME}
PUBLIC
volk
PRIVATE
GPUOpen::VulkanMemoryAllocator
)

set_target_properties(VulkanMemoryAllocator volk PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries")
if (TARGET loader-opt)
set_target_properties(loader-opt loader-unknown-chain PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries")
endif()
if(RGL_USE_MINIVKSDK)
set_target_properties(vulkan vvl VkLayer_utils loader_asm_gen_files PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries")
endif()
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC RGL_VK_AVAILABLE=0)
set(RGL_VK_AVAILABLE OFF CACHE INTERNAL "RGL Vulkan")
endif()

if(MSVC AND NOT RGL_DISABLE_DX)
add_subdirectory(deps/DirectX-Headers EXCLUDE_FROM_ALL)
set(DX12_LIBRARIES "d3d12.lib" "DirectX-Headers" "DirectX-Guids" "dxgi.lib" "d3dcompiler.lib" "D3D12MemoryAllocator" "DirectXTK12")
target_compile_definitions(${PROJECT_NAME} PUBLIC RGL_DX12_AVAILABLE=1)

set(RGL_DX12_AVAILABLE ON CACHE INTERNAL "RGL DX12")
add_subdirectory("deps/D3D12MemoryAllocator" EXCLUDE_FROM_ALL)
set(BUILD_XAUDIO_WIN10 OFF CACHE INTERNAL "")
add_subdirectory("deps/DirectXTK12" EXCLUDE_FROM_ALL)

set_target_properties("DirectX-Guids" "DirectXTK12" PROPERTIES
FOLDER "${RGL_IDE_ROOT}/Libraries"
)
target_include_directories(${PROJECT_NAME} PUBLIC "deps/DirectXTK12/Inc")

# PIX stuff

add_subdirectory(deps/PixEvents-cmake)
set(PIXLIB $<$<NOT:$<CONFIG:release>>:WinPixEventRuntime>)

set_target_properties("WinPixEventRuntime" "WinPixEventRuntime_ETW" "PixDecoder" PROPERTIES
FOLDER "${RGL_IDE_ROOT}/Libraries/"
)
set_target_properties("WinPixEventRuntime" "WinPixEventRuntime_ETW" "PixDecoder" "DirectX-Guids" "DirectXTK12" DirectX-Headers PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries/")

target_link_libraries(${PROJECT_NAME}
PRIVATE
d3d12.lib
DirectX-Headers
DirectX-Guids
dxgi.lib
d3dcompiler.lib
D3D12MemoryAllocator
DirectXTK12
$<$<NOT:$<CONFIG:release>>:WinPixEventRuntime>
)

set_target_properties(D3D12MemoryAllocator PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries")
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC RGL_DX12_AVAILABLE=0)
set(RGL_DX12_AVAILABLE OFF CACHE INTERNAL "RGL DX12")
Expand All @@ -158,6 +184,13 @@ if(APPLE)
find_library(METAL_LIB Metal REQUIRED)
find_library(QZC_LIB QuartzCore REQUIRED)
set(RGL_MTL_AVAILABLE ON CACHE INTERNAL "RGL Metal")

target_link_libraries(${PROJECT_NAME}
PRIVATE
${FOUNDATION_LIB}
${METAL_LIB}
${QZC_LIB}
)
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC RGL_MTL_AVAILABLE=0)
set(RGL_MTL_AVAILABLE OFF CACHE INTERNAL "RGL Metal")
Expand All @@ -169,23 +202,17 @@ else()
target_compile_definitions(${PROJECT_NAME} PUBLIC RGL_WEBGPU_AVAILABLE=0)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE
${VK_LIBS}
${DX12_LIBRARIES}
${FOUNDATION_LIB}
${METAL_LIB}
${QZC_LIB}
${X11_LIBRARIES}
${RGL_RUNTIME_COMPILER_LIB}
${PIXLIB}
SPIRV-Reflect
)

if (APPLE)
target_include_directories(${PROJECT_NAME} PRIVATE "tools/librglc/include/")
if (RGL_RUNTIME_COMPILATION)
target_compile_definitions(${PROJECT_NAME} PRIVATE "RGL_CAN_RUNTIME_COMPILE")
target_link_libraries(${PROJECT_NAME} PRIVATE librglc)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE SPIRV-Reflect ${X11_LIBRARIES})

if (APPLE)
target_include_directories(${PROJECT_NAME} PRIVATE "tools/librglc/include/")
if (RGL_RUNTIME_COMPILATION)
target_compile_definitions(${PROJECT_NAME} PRIVATE "RGL_CAN_RUNTIME_COMPILE")
endif()
endif()

set(AFTERMATH_DIR "AftermathSDK")
Expand All @@ -211,6 +238,8 @@ target_include_directories(${PROJECT_NAME}
"include"
)

target_compile_definitions(${PROJECT_NAME} PUBLIC NOMINMAX=1)

set_target_properties("RGL" ${rglc_exe} "librglc" PROPERTIES
FOLDER "${RGL_IDE_ROOT}"
XCODE_GENERATE_SCHEME ON
Expand All @@ -224,7 +253,7 @@ set_target_properties("libtint" "tint_diagnostic_utils" PROPERTIES
)
endif()

set_target_properties("GenericCodeGen" "glslang" "MachineIndependent" "OGLCompiler" "OSDependent" "SPIRV" "SPVRemapper" "glslang-default-resource-limits" PROPERTIES
set_target_properties("GenericCodeGen" "glslang" "OGLCompiler" "MachineIndependent" "OSDependent" "SPIRV" "SPVRemapper" "glslang-default-resource-limits" PROPERTIES
FOLDER "${RGL_IDE_ROOT}/Libraries/glslang"
)

Expand All @@ -237,12 +266,12 @@ set_target_properties(

set_target_properties(
"spirv-cross-core"
"spirv-cross-glsl" "spirv-cross-hlsl" "spirv-cross-msl" "spirv-cross-reflect" "spirv-cross-cpp" "spirv-cross-util" "HLSL"
"spirv-cross-glsl" "spirv-cross-hlsl" "spirv-cross-msl" "spirv-cross-reflect" "spirv-cross-cpp" "spirv-cross-util"
PROPERTIES
FOLDER "${RGL_IDE_ROOT}/Libraries/SPIRV-Cross"
)

if(ST_BUNDLED_DXC)
if(ST_BUNDLED_DXC AND NOT WINDOWS_STORE)
function(dxc_set_for_dir DIR)
get_property(TGTS DIRECTORY "${DIR}" PROPERTY BUILDSYSTEM_TARGETS)
set_target_properties(
Expand All @@ -259,20 +288,6 @@ if(ST_BUNDLED_DXC)
dxc_set_for_dir("${CMAKE_CURRENT_LIST_DIR}/deps/ShaderTranspiler/deps/DirectXShaderCompiler")
endif()

if (RGL_VK_AVAILABLE)
set_target_properties(VulkanMemoryAllocator PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries")
if (TARGET loader-opt)
set_target_properties(loader-opt loader-unknown-chain PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries")
endif()
if(RGL_USE_MINIVKSDK)
set_target_properties(vulkan vvl VkLayer_utils loader_asm_gen_files PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries")
endif()
endif()
if (RGL_DX12_AVAILABLE)
set_target_properties(D3D12MemoryAllocator PROPERTIES FOLDER "${RGL_IDE_ROOT}/Libraries")
endif()


if (NOT RGL_SKIP_BACKEND_CHECK)
if (RGL_VK_AVAILABLE OR RGL_DX12_AVAILABLE OR RGL_MTL_AVAILABLE OR RGL_WEBGPU_AVAILABLE)
else()
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ RavEngine Graphics Library - a thin RHI for Vulkan, DirectX12, and Metal
- Windows 10+ (Arm64 + x86_64)
- Windows 10+ UWP (Arm64 + x86_64)
- Linux
- Android (x86, x86_64, arm, arm64)
- WebAssembly (WIP)

### Getting Started
Expand Down
14 changes: 0 additions & 14 deletions deps/DirectX-Headers/Android.bp

This file was deleted.

60 changes: 43 additions & 17 deletions deps/DirectX-Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
cmake_minimum_required(VERSION 3.10.2)
project(DirectX-Headers
LANGUAGES CXX
VERSION 1.606.4
VERSION 1.613.1
)

include(CTest)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
enable_testing()

# It's useful to know if you are a top level project or not, if your project is
# being consumed via add_subdirectory
Expand All @@ -32,19 +33,12 @@ include(GNUInstallDirs)
# Enables consumers to add this library as a link target to automatically add
# these include directories, regardless of whether this is referenced via subdirectory
# or from an installed location
add_library(DirectX-Headers INTERFACE)
target_include_directories(DirectX-Headers SYSTEM INTERFACE
add_library(DirectX-Headers STATIC src/d3dx12_property_format_table.cpp)
target_include_directories(DirectX-Headers SYSTEM PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

# For non-Windows targets, also add the WSL stubs to the include path
if (NOT WIN32)
target_include_directories(DirectX-Headers SYSTEM INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/wsl/stubs>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsl/stubs>"
)
endif()
target_include_directories(DirectX-Headers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/directx)

add_library(Microsoft::DirectX-Headers ALIAS DirectX-Headers)

Expand All @@ -53,6 +47,20 @@ target_link_libraries(DirectX-Guids PRIVATE DirectX-Headers)

add_library(Microsoft::DirectX-Guids ALIAS DirectX-Guids)

# For non-Windows targets, also add the WSL stubs to the include path
if (NOT WIN32)
target_include_directories(DirectX-Headers SYSTEM PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/wsl/stubs>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsl/stubs>"
)
elseif((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
# MinGW has RPC headers which define old versions, and complain if D3D
# headers are included before the RPC headers, since D3D headers were
# generated with new MIDL and "require" new RPC headers.
target_compile_options(DirectX-Headers PRIVATE "-D__REQUIRED_RPCNDR_H_VERSION__=475")
target_compile_options(DirectX-Guids PRIVATE "-D__REQUIRED_RPCNDR_H_VERSION__=475")
endif()

if (DXHEADERS_INSTALL)
# Install the targets
install(TARGETS DirectX-Headers DirectX-Guids
Expand Down Expand Up @@ -81,12 +89,30 @@ if (DXHEADERS_INSTALL)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/directx-headers-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/directx-headers-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/directx-headers/cmake)
endif()

# Create pkg-config file
include(cmake/JoinPaths.cmake)
# from: https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files
join_paths(DIRECTX_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
join_paths(DIRECTX_LIBDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/DirectX-Headers.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/DirectX-Headers.pc" @ONLY)

# Install the pkg-config file
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DirectX-Headers.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

if (DXHEADERS_BUILD_TEST)
add_subdirectory(test)
endif()

if (DXHEADERS_BUILD_GOOGLE_TEST)
add_subdirectory(googletest)
if (BUILD_TESTING)
if (DXHEADERS_BUILD_TEST)
add_subdirectory(test)
endif()

if (DXHEADERS_BUILD_GOOGLE_TEST)
# We do not want to install GoogleTest when packaging DirectX-Headers.
set(INSTALL_GTEST OFF)
add_subdirectory(googletest)
endif()
endif()
Loading

0 comments on commit a400f1a

Please sign in to comment.