Skip to content

Commit

Permalink
Preparations for Lighting (#31)
Browse files Browse the repository at this point in the history
Add FidelityFX SDK
Integrate it with engine
Add functions for using CACAO
  • Loading branch information
Pursche committed Jun 14, 2024
1 parent eeac087 commit 2ece720
Show file tree
Hide file tree
Showing 1,502 changed files with 914,915 additions and 6 deletions.
1 change: 1 addition & 0 deletions Dependencies/Dependencies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local dependencies =
"typesafe/typesafe.lua",
"utfcpp/utfcpp.lua",
"luau/luau.lua",
"FidelityFX-SDK/FidelityFX.lua",
}

for k,v in pairs(dependencies) do
Expand Down
46 changes: 46 additions & 0 deletions Dependencies/FidelityFX-SDK/FidelityFX.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local dependencies = { "vulkan" }

local function SetupLib()
local basePath = path.getabsolute("FidelityFX-SDK/", Engine.dependencyDir)
local dependencies = { "vulkan" }
local defines = { "_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS", "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS" }

ProjectTemplate("FidelityFX", "StaticLib", nil, Engine.binDir, dependencies, defines)

local sourceDir = path.getabsolute("FidelityFX/sdk/src", basePath)
local includeDir =
{
path.getabsolute("FidelityFX/sdk/include/", basePath),
path.getabsolute("FidelityFX/sdk/permutations/", basePath),
path.getabsolute("FidelityFX/sdk/src/components", basePath),
path.getabsolute("FidelityFX/sdk/src/backends/shared", basePath),
path.getabsolute("FidelityFX/sdk/src/shared", basePath),
}

local files =
{
sourceDir .. "/**.cpp",
sourceDir .. "/**.h",
basePath .. "/FidelityFX/sdk/include/**.h"
}
AddFiles(files)
AddIncludeDirs(includeDir)

AddDefines("FFX_CACAO")

end
SetupLib()

local function Include()
local basePath = path.getabsolute("FidelityFX-SDK/", Engine.dependencyDir)
local includeDir = {
path.getabsolute("FidelityFX/sdk/include/", basePath),
path.getabsolute("FidelityFX/sdk/src/backends/shared", basePath),
}
AddIncludeDirs(includeDir)

AddDefines("FFX_CACAO")

AddLinks("FidelityFX")
end
CreateDep("fidelityfx", Include, dependencies)
208 changes: 208 additions & 0 deletions Dependencies/FidelityFX-SDK/FidelityFX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# This file is part of the FidelityFX SDK.
#
# Copyright (C) 2023 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files(the “Software”), to deal
# in 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 :
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# 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
# AUTHORS 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 IN
# THE SOFTWARE.

cmake_minimum_required(VERSION 3.17)

if (NOT DEFINED BUILD_TYPE)
message(FATAL_ERROR "No BUILD_TYPE specified!)")
endif()

if (FFX_API STREQUAL CAULDRON)
set(SOLUTION_NAME "FidelityFX SDK")
else()
set(SOLUTION_NAME "FidelityFX Native SDK")
endif()

project ("${SOLUTION_NAME}" VERSION 1.0.0 LANGUAGES C CXX)
message(STATUS "Building FidelityFX SDK")

# Pull in common definitions and functions
list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
include(common)
include(sample)

# Configuration setup
set(CMAKE_GENERATOR_PLATFORM x64)

if (CMAKE_GENERATOR_PLATFORM STREQUAL x64)
message(STATUS "Creating sample configs ...")
createConfig(DX12 DebugDX12 DEBUG)
createConfig(VK DebugVK DEBUG)
createConfig(DX12 ReleaseDX12 RELEASE)
createConfig(VK ReleaseVK RELEASE)
set(CMAKE_CONFIGURATION_TYPES "DebugDX12;DebugVK;ReleaseDX12;ReleaseVK")
message(STATUS "Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")

# Set compile definitions as well
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:DebugDX12>:_DX12 _WIN>
$<$<CONFIG:DebugVK>:_VK _WIN>
$<$<CONFIG:ReleaseDX12>:_DX12 _WIN _RELEASE>
$<$<CONFIG:ReleaseVK>:_VK _WIN _RELEASE>
NOMINMAX
)
else()
message(FATAL_ERROR "Requested architecture not yet supported!)")
endif()

# Ouput exe to bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT})
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BIN_OUTPUT} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )

# Setup various FFX build options - but clear them out first
unset(FFX_ALL CACHE)
unset(FFX_FSR CACHE)
unset(FFX_FSR1 CACHE)
unset(FFX_FSR2 CACHE)
unset(FFX_SPD CACHE)
unset(FFX_CACAO CACHE)
unset(FFX_LPM CACHE)
unset(FFX_BLUR CACHE)
unset(FFX_VRS CACHE)
unset(FFX_CAS CACHE)
unset(FFX_DOF CACHE)
unset(FFX_LENS CACHE)
unset(FFX_PARALLEL_SORT CACHE)
unset(FFX_DENOISER CACHE)
unset(FFX_SSSR CACHE)
unset(FFX_CLASSIFIER CACHE)
unset(FFX_HYBRIDSHADOWS CACHE)
unset(FFX_HYBRIDREFLECTIONS CACHE)
unset(FFX_API_CUSTOM CACHE)

if (BUILD_TYPE STREQUAL ALL_SAMPLES)
message(STATUS "Enabling build of all Effects")
option(FFX_ALL "Build All FidelityFX Samples and APIs" ON)
else()
#Only enable the FFX API for the effect requested
option(FFX_ALL "Build All FidelityFX Samples and APIs" OFF)
if (BUILD_TYPE STREQUAL FFX_FSR)
option(FFX_FSR "Build FSR Sample" ON)
option(FFX_FSR1 "Build FFX FSR1 API" ON)
option(FFX_FSR2 "Build FFX FSR2 API" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_CACAO)
option(FFX_CACAO "Build CACAO Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_SPD)
option(FFX_SPD "Build SPD Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_LPM)
option(FFX_LPM "Build LPM Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_BLUR)
option(FFX_BLUR "Build BLUR Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_PARALLEL_SORT)
option(FFX_PARALLEL_SORT "Build Parallel Sort Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_VRS)
option(FFX_VRS "Build VRS Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_CAS)
option(FFX_CAS "Build CAS Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_DOF)
option(FFX_DOF "Build DoF Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_HYBRIDSHADOWS)
option(FFX_HYBRIDSHADOWS "Build Hybrid Shadows Sample" ON)
option(FFX_CLASSIFIER "Build Classifier" ON)
option(FFX_DENOISER "Build Denoiser" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_LENS)
option(FFX_LENS "Build LENS Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_SSSR)
option(FFX_SSSR "Build SSSR Sample" ON)
option(FFX_DENOISER "Build Denoiser Sample" ON)
endif()

if (BUILD_TYPE STREQUAL FFX_HYBRIDREFLECTIONS)
option(FFX_HYBRIDREFLECTIONS "Build Hybrid Reflections Sample" ON)
option(FFX_CLASSIFIER "Build Classifier Sample" ON)
option(FFX_DENOISER "Build Denoiser Sample" ON)
option(FFX_SPD "Build SPD Sample" ON)
endif()
endif()

# Pull in cauldron
add_subdirectory(${CAULDRON_ROOT})
set_target_properties(Framework PROPERTIES FOLDER Framework)

# Build rendermodules used by samples as a separate lib
add_subdirectory(${RENDERMODULE_ROOT})
set_target_properties(RenderModules PROPERTIES FOLDER Framework)

if( BUILD_TYPE STREQUAL CAULDRON)
# Set as startup project
set_property(DIRECTORY ${CMAKE_PROJECT_DIR} PROPERTY VS_STARTUP_PROJECT Cauldron)
return()
endif()

# Pull in SDK
option(FFX_API_CUSTOM "Use custom ffx build targets" ON)
add_subdirectory(sdk)

# Are we building with cauldron backend, or defaults (VK/DX12/...)
if (FFX_API STREQUAL CAULDRON)
# Set compile definitions for used API
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS FFX_API_CAULDRON)

# Build cauldron backend
add_subdirectory(${FFX_API_CAULDRON_ROOT})
else()
# Set compile definitions for used API
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<OR:$<CONFIG:DebugDX12>,$<CONFIG:ReleaseDX12>>:FFX_API_DX12>
$<$<OR:$<CONFIG:DebugVK>,$<CONFIG:ReleaseVK>>:FFX_API_VK>)

# Import libs
add_library(ffx_backend_native STATIC IMPORTED)
set_target_properties(ffx_backend_native PROPERTIES
IMPORTED_CONFIGURATIONS "DebugDX12;DebugVK;ReleaseDX12;ReleaseVK"
IMPORTED_LOCATION_DEBUGDX12 "${SDK_ROOT}/bin/ffx_sdk/ffx_backend_dx12_x64d.lib"
IMPORTED_LOCATION_RELEASEDX12 "${SDK_ROOT}/bin/ffx_sdk/ffx_backend_dx12_x64.lib"
IMPORTED_LOCATION_DEBUGVK "${SDK_ROOT}/bin/ffx_sdk/ffx_backend_vk_x64d.lib"
IMPORTED_LOCATION_RELEASEVK "${SDK_ROOT}/bin/ffx_sdk/ffx_backend_vk_x64.lib")
endif()

# Build all other effect samples
add_subdirectory(samples)

# Set a startup project
message(STATUS "Default project set to ${START_PROJECT}")
set_property(DIRECTORY ${CMAKE_PROJECT_DIR} PROPERTY VS_STARTUP_PROJECT ${START_PROJECT})
19 changes: 19 additions & 0 deletions Dependencies/FidelityFX-SDK/FidelityFX/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright © 2023 Advanced Micro Devices, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the “Software”), to deal
in 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 :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

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
AUTHORS 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 IN
THE SOFTWARE.
Loading

0 comments on commit 2ece720

Please sign in to comment.