Skip to content

Commit

Permalink
Initialize repository from local
Browse files Browse the repository at this point in the history
  • Loading branch information
vs-shirokii committed Aug 3, 2024
1 parent f6ca972 commit b052df5
Show file tree
Hide file tree
Showing 250 changed files with 36,615 additions and 7,748 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ DisableFormat: 'false'
FixNamespaceComments: 'false'
IncludeBlocks: Regroup
IndentCaseLabels: 'true'
IndentPPDirectives: BeforeHash
IndentPPDirectives: None
IndentWidth: '4'
IndentWrappedFunctionNames: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Expand All @@ -63,7 +63,7 @@ SpacesInCStyleCastParentheses: 'true'
SpacesInContainerLiterals: 'true'
SpacesInParentheses: 'true'
SpacesInSquareBrackets: 'true'
Standard: Cpp11
Standard: Latest
TabWidth: '4'
UseTab: Never
IndentExternBlock: NoIndent
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
copy Include/RTGL1/RTGL1.h final/include/RTGL1/RTGL1.h
mkdir final/ovrd
copy Tools/BlueNoise_LDR_RGBA_128.ktx2 final/ovrd/BlueNoise_LDR_RGBA_128.ktx2
copy Tools/DirtMask.ktx2 final/ovrd/DirtMask.ktx2
copy Tools/SceneBuildWarning.ktx2 final/ovrd/SceneBuildWarning.ktx2
copy Tools/CreateKTX2.py final/ovrd/CreateKTX2.py
mkdir final/ovrd/shaders
copy Build/shaders/*.spv final/ovrd/shaders
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "Source/glm"]
path = Source/glm
url = https://github.com/g-truc/glm
[submodule "Source/DX12"]
path = Source/DX12
url = https://github.com/microsoft/DirectX-Headers.git
103 changes: 55 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE )
include(CheckIPOSupported)
check_ipo_supported()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)

# Vulkan
message(STATUS "Adding Vulkan. VulkanSDK: $ENV{VULKAN_SDK}")
find_package(Vulkan REQUIRED)
add_library(Vulkan INTERFACE)
target_include_directories(Vulkan INTERFACE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(Vulkan INTERFACE ${Vulkan_LIBRARIES})
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF)

set(PublicHeaders
Include/RTGL1/RTGL1.h
Expand Down Expand Up @@ -75,13 +69,15 @@ set(Sources
"Source/RgException.cpp"
"Source/Bloom.cpp"
"Source/Sharpening.cpp"
"Source/DLSS.cpp"
"Source/DLSS2.cpp"
"Source/DLSS3_DX12.cpp"
"Source/HaltonSequence.cpp"
"Source/LensFlares.cpp"
"Source/DecalManager.cpp"
"Source/EffectBase.cpp"
"Source/LightGrid.cpp"
"Source/FSR2.cpp"
"Source/FSR3_DX12.cpp"
"Source/Stb/stb_image.cpp"
"Source/Stb/stb_image_write.cpp"
"Source/ImageLoaderDev.cpp"
Expand All @@ -96,8 +92,10 @@ set(Sources
"Source/TextureExporter.cpp"
"Source/TextureMeta.cpp"
"Source/VulkanDevice_Dev.cpp"
"Source/JsonParser.cpp"
"Source/SceneMeta.cpp"
"Source/Fluid.cpp"
"Source/DX12_Swapchain.cpp"
"Source/DX12_Vulkan.cpp"
)


Expand Down Expand Up @@ -130,8 +128,8 @@ option(RG_WITH_SURFACE_WAYLAND "Build with Wayland VkSurfaceKHR support" OFF)
option(RG_WITH_SURFACE_XCB "Build with Xcb VkSurfaceKHR support" OFF)
option(RG_WITH_SURFACE_XLIB "Build with Xlib VkSurfaceKHR support" OFF)

option(RG_WITH_NVIDIA_DLSS "Build RTGL1 with Nvidia DLSS" OFF)
option(RG_WITH_IMGUI "Build RTGL1 with ImGui debug windows" ON)
option(RG_WITH_DX12 "Build RTGL1 with DX12 features" ON)

option(RG_WITH_EXAMPLES "Build with examples executable" ON)

Expand Down Expand Up @@ -174,6 +172,26 @@ if (RG_WITH_SURFACE_XLIB)
endif()


# Vulkan
message(STATUS "Adding Vulkan. VulkanSDK: $ENV{VULKAN_SDK}")
find_package(Vulkan REQUIRED)
add_library(Vulkan INTERFACE)
target_include_directories(Vulkan INTERFACE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(Vulkan INTERFACE ${Vulkan_LIBRARIES})


# DirectX 12
if (RG_WITH_DX12)
message(STATUS "RG_WITH_DX12 enabled")
add_definitions(-DRG_USE_DX12)
set(D3D12_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
find_package(D3D12 REQUIRED)
add_library(D3D12 INTERFACE)
target_include_directories(D3D12 INTERFACE "Source/DX12/include/directx")
target_link_libraries(D3D12 INTERFACE ${D3D12_LIBRARIES})
endif()


# Imgui
if (RG_WITH_IMGUI)
message(STATUS "RG_WITH_IMGUI enabled")
Expand Down Expand Up @@ -207,13 +225,24 @@ add_library(RayTracedGL1 SHARED
${KTXSources}
${PublicHeaders}
)
set(LibraryName "RTGL1")
add_definitions(-DRG_LIBRARY_NAME="${LibraryName}")
set_target_properties(RayTracedGL1 PROPERTIES
OUTPUT_NAME RTGL1
OUTPUT_NAME ${LibraryName}
)
set_target_properties(RayTracedGL1 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY $<IF:$<CONFIG:Debug>,${CMAKE_SOURCE_DIR}/Build/bin/debug,${CMAKE_SOURCE_DIR}/Build/bin>
)
target_include_directories(RayTracedGL1 PUBLIC "Include")


# Vulkan
target_link_libraries(RayTracedGL1 PUBLIC Vulkan)

# DirectX
if (RG_WITH_DX12)
target_link_libraries(RayTracedGL1 PRIVATE D3D12)
endif()

# GLM
target_include_directories(RayTracedGL1 PRIVATE Source/glm)
Expand All @@ -223,48 +252,25 @@ target_include_directories(RayTracedGL1 PRIVATE "Source/KTX/include")
target_include_directories(RayTracedGL1 PRIVATE "Source/KTX/include" "Source/KTX/other_include" "Source/KTX/lib/basisu/zstd")

# DLSS
if (RG_WITH_NVIDIA_DLSS)
message(STATUS "RG_WITH_NVIDIA_DLSS enabled")
add_definitions(-DRG_USE_NVIDIA_DLSS)

if (DEFINED ENV{DLSS_SDK_PATH})
message(STATUS "Found DLSS SDK: $ENV{DLSS_SDK_PATH}")
target_include_directories(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/include")
if (WIN32)
add_definitions(-DNV_WINDOWS)
if (BUILD_TYPE STREQUAL "DEBUG")
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d_dbg.lib")
else()
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d.lib")
endif()
target_include_directories(RayTracedGL1 PRIVATE "Source/Streamline/include")
if (DEFINED ENV{DLSS_SDK_PATH})
message(STATUS "Found Native DLSS SDK: $ENV{DLSS_SDK_PATH}")
target_include_directories(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/include")
add_definitions(-DRG_USE_NATIVE_DLSS2)
if (WIN32)
if (BUILD_TYPE STREQUAL "DEBUG")
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d_dbg.lib")
else()
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Linux_x86_64/libnvsdk_ngx.a")
target_link_libraries(RayTracedGL1 PRIVATE ${CMAKE_DL_LIBS})
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d.lib")
endif()
else()
message(FATAL_ERROR
"Can't find DLSS_SDK_PATH environment variable. "
"Please, provide the path to https://github.com/NVIDIA/DLSS, to configure the library")
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Linux_x86_64/libnvsdk_ngx.a")
target_link_libraries(RayTracedGL1 PRIVATE ${CMAKE_DL_LIBS})
endif()
endif()

# Vulkan
target_link_libraries(RayTracedGL1 PUBLIC Vulkan)
target_include_directories(RayTracedGL1 PUBLIC "Include")

# FSR2
target_include_directories(RayTracedGL1 PRIVATE "Source/FSR2/include" )
if (WIN32)
if (BUILD_TYPE STREQUAL "DEBUG")
target_link_libraries(RayTracedGL1 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Source/FSR2/win32/ffx_fsr2_api_x64d.lib" )
target_link_libraries(RayTracedGL1 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Source/FSR2/win32/ffx_fsr2_api_vk_x64d.lib" )
else()
target_link_libraries(RayTracedGL1 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Source/FSR2/win32/ffx_fsr2_api_x64.lib" )
target_link_libraries(RayTracedGL1 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Source/FSR2/win32/ffx_fsr2_api_vk_x64.lib" )
endif()
else()
message(FATAL_ERROR "On non-WIN32, please, provide static libraries of FSR2 or disable FSR2")
endif()

# Debug windows - ImGui
if (RG_WITH_IMGUI)
Expand All @@ -275,8 +281,11 @@ if (RG_WITH_IMGUI)
endif()

# Json parser - glaze
add_library(GlazeWrapper STATIC "Source/JsonParser.cpp")
add_subdirectory(Source/glaze)
target_link_libraries(RayTracedGL1 PRIVATE glaze::glaze)
target_include_directories(GlazeWrapper PRIVATE "Include")
target_link_libraries(GlazeWrapper PRIVATE glaze::glaze)
target_link_libraries(RayTracedGL1 PRIVATE GlazeWrapper)

if (RG_WITH_EXAMPLES)
message(STATUS "RG_WITH_EXAMPLES enabled")
Expand All @@ -292,12 +301,10 @@ if (RG_WITH_EXAMPLES)
endif()

# VS hot-reload - disabled because of glaze
if (false)
if (MSVC AND WIN32 AND NOT MSVC_VERSION VERSION_LESS 142)
target_link_options(RayTracedGL1 PRIVATE $<$<CONFIG:Debug>:/INCREMENTAL>)
target_compile_options(RayTracedGL1 PRIVATE $<$<CONFIG:Debug>:/ZI>)

target_link_options(RtglExample PRIVATE $<$<CONFIG:Debug>:/INCREMENTAL>)
target_compile_options(RtglExample PRIVATE $<$<CONFIG:Debug>:/ZI>)
endif()
endif()
115 changes: 115 additions & 0 deletions D3D12Config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# ==============================================================================
# LLVM Release License
# ==============================================================================
# University of Illinois/NCSA
# Open Source License
#
# Copyright (c) 2003-2015 University of Illinois at Urbana-Champaign.
# All rights reserved.
#
# Developed by:
#
# LLVM Team
#
# University of Illinois at Urbana-Champaign
#
# http://llvm.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal with
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimers.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimers in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the names of the LLVM Team, University of Illinois at
# Urbana-Champaign, nor the names of its contributors may be used to
# endorse or promote products derived from this Software without specific
# prior written permission.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
# SOFTWARE.
#
# ==============================================================================
# Copyrights and Licenses for Third Party Software Distributed with LLVM:
# ==============================================================================
# The LLVM software contains code written by third parties. Such software will
# have its own individual LICENSE.TXT file in the directory in which it appears.
# This file will describe the copyrights, license, and restrictions which apply
# to that code.
#
# The disclaimer of warranty in the University of Illinois Open Source License
# applies to all code in the LLVM Distribution, and nothing in any of the
# other licenses gives permission to use the names of the LLVM Team or the
# University of Illinois to endorse or promote products derived from this
# Software.

# Find the Win10 SDK path.
if ("$ENV{WIN10_SDK_PATH}$ENV{WIN10_SDK_VERSION}" STREQUAL "" )
get_filename_component(WIN10_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE CACHE)
if (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
set (WIN10_SDK_VERSION ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
else()
# CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION may not be defined if, for example,
# the Ninja generator is used instead of Visual Studio. Attempt to retrieve the
# most recent SDK version from the list of paths under "${WIN10_SDK_PATH}/Include/".
file(GLOB sdk_dirs RELATIVE "${WIN10_SDK_PATH}/Include/" "${WIN10_SDK_PATH}/Include/10.*")
if (sdk_dirs)
list(POP_BACK sdk_dirs WIN10_SDK_VERSION)
endif()
unset(sdk_dirs)
endif()
elseif(TRUE)
set (WIN10_SDK_PATH $ENV{WIN10_SDK_PATH})
set (WIN10_SDK_VERSION $ENV{WIN10_SDK_VERSION})
endif ("$ENV{WIN10_SDK_PATH}$ENV{WIN10_SDK_VERSION}" STREQUAL "" )

# WIN10_SDK_PATH will be something like C:\Program Files (x86)\Windows Kits\10
# WIN10_SDK_VERSION will be something like 10.0.14393 or 10.0.14393.0; we need the
# one that matches the directory name.

if (IS_DIRECTORY "${WIN10_SDK_PATH}/Include/${WIN10_SDK_VERSION}.0")
set(WIN10_SDK_VERSION "${WIN10_SDK_VERSION}.0")
endif (IS_DIRECTORY "${WIN10_SDK_PATH}/Include/${WIN10_SDK_VERSION}.0")


# Find the d3d12 and dxgi include path, it will typically look something like this.
# C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um\d3d12.h
# C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared\dxgi1_4.h
find_path(D3D12_INCLUDE_DIR # Set variable D3D12_INCLUDE_DIR
d3d12.h # Find a path with d3d12.h
HINTS "${WIN10_SDK_PATH}/Include/${WIN10_SDK_VERSION}/um"
DOC "path to WIN10 SDK header files"
HINTS
)

find_path(DXGI_INCLUDE_DIR # Set variable DXGI_INCLUDE_DIR
dxgi1_4.h # Find a path with dxgi1_4.h
HINTS "${WIN10_SDK_PATH}/Include/${WIN10_SDK_VERSION}/shared"
DOC "path to WIN10 SDK header files"
HINTS
)
set(D3D12_INCLUDE_DIRS ${D3D12_INCLUDE_DIR} ${DXGI_INCLUDE_DIR})

# List of D3D libraries
set(D3D12_LIBRARIES d3d12.lib dxgi.lib d3dcompiler.lib)

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set D3D12_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(D3D12 DEFAULT_MSG
D3D12_INCLUDE_DIRS D3D12_LIBRARIES)

mark_as_advanced(D3D12_INCLUDE_DIRS D3D12_LIBRARIES)
Loading

0 comments on commit b052df5

Please sign in to comment.