Skip to content

Commit a1f5ae2

Browse files
committed
IvyGenerationSample v1.0.0
0 parents  commit a1f5ae2

38 files changed

+6855
-0
lines changed

.clang-format

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
BasedOnStyle: Google
2+
IndentWidth: 4
3+
UseTab: Never
4+
ColumnLimit: 160
5+
Language: Cpp
6+
AccessModifierOffset: -4
7+
BreakBeforeBraces: Custom
8+
BraceWrapping:
9+
AfterCaseLabel: true
10+
AfterClass: true
11+
AfterControlStatement: true
12+
AfterEnum: true
13+
AfterFunction: true
14+
AfterNamespace: true
15+
AfterObjCDeclaration: true
16+
AfterStruct: true
17+
AfterUnion: true
18+
AfterExternBlock: false
19+
BeforeCatch: true
20+
BeforeElse: true
21+
IndentBraces: false
22+
SplitEmptyFunction: true
23+
SplitEmptyRecord: true
24+
SplitEmptyNamespace: true
25+
ConstructorInitializerAllOnOneLineOrOnePerLine : false
26+
BreakConstructorInitializers: BeforeComma
27+
DerivePointerAlignment: false
28+
IndentCaseLabels: false
29+
NamespaceIndentation: All
30+
AlignConsecutiveAssignments: true
31+
AlignConsecutiveDeclarations: true
32+
AlignEscapedNewlines: Left
33+
AlignTrailingComments: true
34+
AlignOperands: true
35+
AllowShortFunctionsOnASingleLine: false
36+
AllowShortIfStatementsOnASingleLine: false
37+
AllowShortLoopsOnASingleLine: false
38+
AllowShortBlocksOnASingleLine: false
39+
ReflowComments: false
40+
SortIncludes: false
41+
SortUsingDeclarations: false
42+
BinPackArguments: false
43+
BinPackParameters: false
44+
ExperimentalAutoDetectBinPacking: false
45+
AllowAllParametersOfDeclarationOnNextLine: true
46+
AlignConsecutiveMacros: true
47+
AlignAfterOpenBracket: true

.gitattributes

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Declare files that will always have LF line endings on checkout.
5+
*.c text eol=lf
6+
*.cpp text eol=lf
7+
*.h text eol=lf
8+
*.hpp text eol=lf
9+
*.idl text eol=lf
10+
*.json text eol=lf
11+
*.hlsl text eol=lf
12+
*.patch text eol=lf
13+
*.gltf text eol=lf
14+
15+
# Denote all files that are truly binary and should not be modified.
16+
*.png binary

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# CMake build folder
2+
build
3+
# Binary output folder
4+
bin
5+
# Cauldron media folder
6+
media
7+
!media/Ivy

CMakeLists.txt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file is part of the AMD Work Graph Ivy Generation Sample.
2+
#
3+
# Copyright (C) 2023 Advanced Micro Devices, Inc.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files(the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions :
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
cmake_minimum_required(VERSION 3.17)
24+
25+
project("Work Graphs Ivy Generation Sample" VERSION 0.1.0 LANGUAGES CXX)
26+
27+
# Import FidelityFX & Cauldron
28+
add_subdirectory(imported)
29+
30+
# Add Ivy Sample
31+
add_subdirectory(ivySample)
32+
33+
set_property(DIRECTORY ${CMAKE_PROJECT_DIR} PROPERTY VS_STARTUP_PROJECT IvySample)

area.jpg

1000 KB
Loading

gizmo.png

342 KB
Loading

imported/CMakeLists.txt

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# This file is part of the AMD Work Graph Ivy Generation Sample.
2+
#
3+
# Copyright (C) 2023 Advanced Micro Devices, Inc.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files(the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions :
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
include(FetchContent)
24+
25+
FetchContent_Declare(
26+
ffxsdk
27+
GIT_REPOSITORY https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK
28+
GIT_TAG 55ff22bb6981a9b9c087b9465101769fc0acd447 # fsr3-v3.0.4
29+
)
30+
31+
FetchContent_GetProperties(ffxsdk)
32+
33+
# manually import FidelityFX SDK
34+
if (NOT ffxsdk_POPULATED)
35+
message(STATUS "Downloading FidelityFX SDK")
36+
FetchContent_Populate(ffxsdk)
37+
message(STATUS "Downloaded FidelityFX SDK to ${ffxsdk_SOURCE_DIR}")
38+
39+
# set root directory of FidelityFX SDK for patches
40+
set(FFX_ROOT ${ffxsdk_SOURCE_DIR})
41+
# Apply patches to FidelityFX SDK
42+
include(patch-ffx.cmake)
43+
44+
# don't build any FFX samples
45+
set(BUILD_TYPE CAULDRON)
46+
47+
# FFX uses CMAKE_HOME_DIRECTORY as root directory for all internal paths
48+
# since FFX is not the top-level repository here, we need to change CMAKE_HOME_DIRECTORY such that all the paths still match up
49+
set(CMAKE_HOME_DIRECTORY ${ffxsdk_SOURCE_DIR})
50+
add_subdirectory(${ffxsdk_SOURCE_DIR} ${ffxsdk_BINARY_DIR})
51+
52+
message(STATUS "Downloading FidelityFX SDK media")
53+
# Download FFX media
54+
execute_process(
55+
COMMAND ${FFX_ROOT}/UpdateMedia.bat
56+
WORKING_DIRECTORY ${FFX_ROOT})
57+
58+
59+
# Copy Media to repository root directory
60+
message(STATUS "Copying FidelityFX SDK media")
61+
# Copy Sponza scene
62+
file(COPY ${FFX_ROOT}/media/SponzaNew DESTINATION ${CMAKE_SOURCE_DIR}/media)
63+
# Create Textures folder
64+
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/media/Textures)
65+
# Copy BRDF lookup folder
66+
file(COPY ${FFX_ROOT}/media/Textures/BRDF DESTINATION ${CMAKE_SOURCE_DIR}/media/Textures)
67+
# Create IBL folder
68+
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/media/IBL)
69+
# Copy IBL folder for procedural skydome
70+
file(COPY
71+
${FFX_ROOT}/media/IBL/mud_road_puresky_Diffuse.dds
72+
${FFX_ROOT}/media/IBL/mud_road_puresky_Specular.dds
73+
${FFX_ROOT}/media/IBL/LICENSE.md
74+
DESTINATION
75+
${CMAKE_SOURCE_DIR}/media/IBL)
76+
77+
endif()
78+
79+
# set root directory of FidelityFX SDK
80+
set(FFX_ROOT ${ffxsdk_SOURCE_DIR} PARENT_SCOPE)
81+
82+
# propagate configurations to top level; only DX12 is supported for this sample
83+
set(CMAKE_CONFIGURATION_TYPES "DebugDX12;ReleaseDX12;RelWithDebInfoDX12" PARENT_SCOPE)

imported/agilitysdk-version.patch

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
diff --git a/framework/cauldron/framework/libs/agilitysdk/CAULDRONREADME.md b/framework/cauldron/framework/libs/agilitysdk/CAULDRONREADME.md
2+
index e445450..470c187 100644
3+
--- a/framework/cauldron/framework/libs/agilitysdk/CAULDRONREADME.md
4+
+++ b/framework/cauldron/framework/libs/agilitysdk/CAULDRONREADME.md
5+
@@ -1,7 +1,7 @@
6+
# DX12 Agility SDK
7+
8+
## Current Version
9+
-1.608.2
10+
+1.715.0-preview
11+
12+
## How to update
13+
1. Download the latest version (as a .nupkg) from https://devblogs.microsoft.com/directx/directx12agility/
14+
diff --git a/framework/cauldron/framework/src/render/dx12/device_dx12.cpp b/framework/cauldron/framework/src/render/dx12/device_dx12.cpp
15+
index 6782b97..580ff02 100644
16+
--- a/framework/cauldron/framework/src/render/dx12/device_dx12.cpp
17+
+++ b/framework/cauldron/framework/src/render/dx12/device_dx12.cpp
18+
@@ -36,7 +36,7 @@
19+
using namespace Microsoft::WRL;
20+
21+
// D3D12SDKVersion needs to line up with the version number on Microsoft's DirectX12 Agility SDK Download page
22+
-extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 608; }
23+
+extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 715; }
24+
extern "C" { __declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\"; }
25+
26+
namespace cauldron
27+
diff --git a/sdk/tools/ffx_shader_compiler/libs/agilitysdk/FFX_SDK_README.md b/sdk/tools/ffx_shader_compiler/libs/agilitysdk/FFX_SDK_README.md
28+
index d3ae9cd..db89102 100644
29+
--- a/sdk/tools/ffx_shader_compiler/libs/agilitysdk/FFX_SDK_README.md
30+
+++ b/sdk/tools/ffx_shader_compiler/libs/agilitysdk/FFX_SDK_README.md
31+
@@ -1,7 +1,7 @@
32+
# DX12 Agility SDK
33+
34+
## Current Version
35+
-1.608.2
36+
+1.715.0-preview
37+
38+
## How to update
39+
1. Download the latest version (as a .nupkg) from https://devblogs.microsoft.com/directx/directx12agility/
40+
diff --git a/sdk/tools/ffx_shader_compiler/src/hlsl_compiler.cpp b/sdk/tools/ffx_shader_compiler/src/hlsl_compiler.cpp
41+
index 5375d3d..39884e1 100644
42+
--- a/sdk/tools/ffx_shader_compiler/src/hlsl_compiler.cpp
43+
+++ b/sdk/tools/ffx_shader_compiler/src/hlsl_compiler.cpp
44+
@@ -24,7 +24,7 @@
45+
#include "utils.h"
46+
47+
// D3D12SDKVersion needs to line up with the version number on Microsoft's DirectX12 Agility SDK Download page
48+
-extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 608; }
49+
+extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 715; }
50+
extern "C" { __declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\"; }
51+
52+
struct DxcCustomIncludeHandler : public IDxcIncludeHandler

imported/binoutput.patch

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/common.cmake b/common.cmake
2+
index 88aeb5d..4a2283b 100644
3+
--- a/common.cmake
4+
+++ b/common.cmake
5+
@@ -40,7 +40,7 @@ endif()
6+
set(SAMPLE_ROOT ${CMAKE_HOME_DIRECTORY}/samples)
7+
set(SDK_ROOT ${CMAKE_HOME_DIRECTORY}/sdk)
8+
set(FRAMEWORK_ROOT ${CMAKE_HOME_DIRECTORY}/framework)
9+
-set(BIN_OUTPUT ${CMAKE_HOME_DIRECTORY}/bin)
10+
+set(BIN_OUTPUT ${CMAKE_SOURCE_DIR}/bin)
11+
set(CAULDRON_ROOT ${FRAMEWORK_ROOT}/cauldron)
12+
set(RENDERMODULE_ROOT ${FRAMEWORK_ROOT}/rendermodules)
13+
set(FFX_API_CAULDRON_ROOT ${SAMPLE_ROOT}/ffx_cauldron)

imported/dxil.patch

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/framework/cauldron/framework/libs/dxc/CMakeLists.txt b/framework/cauldron/framework/libs/dxc/CMakeLists.txt
2+
index 6695b76..fad43bb 100644
3+
--- a/framework/cauldron/framework/libs/dxc/CMakeLists.txt
4+
+++ b/framework/cauldron/framework/libs/dxc/CMakeLists.txt
5+
@@ -2,8 +2,7 @@ add_library(dxc INTERFACE)
6+
target_include_directories(dxc INTERFACE BEFORE "inc/")
7+
8+
set(dxc_binaries
9+
- ${CMAKE_CURRENT_SOURCE_DIR}/bin/x64/dxcompiler.dll
10+
- ${CMAKE_CURRENT_SOURCE_DIR}/bin/x64/dxil.dll)
11+
+ ${CMAKE_CURRENT_SOURCE_DIR}/bin/x64/dxcompiler.dll)
12+
13+
copyTargetCommand("${dxc_binaries}" ${BIN_OUTPUT} copied_dxc_bin)
14+
add_dependencies(dxc copied_dxc_bin)
15+
\ No newline at end of file
16+
diff --git a/framework/cauldron/framework/src/render/win/shaderbuilder_win.cpp b/framework/cauldron/framework/src/render/win/shaderbuilder_win.cpp
17+
index 4847f86..47e2b50 100644
18+
--- a/framework/cauldron/framework/src/render/win/shaderbuilder_win.cpp
19+
+++ b/framework/cauldron/framework/src/render/win/shaderbuilder_win.cpp
20+
@@ -312,14 +312,10 @@ namespace cauldron
21+
ComPtr<IDxcResult> pCompiledResult;
22+
pCompiler->Compile(&shaderCodeBuffer, arguments.data(), static_cast<UINT32>(arguments.size()), &includeFileHandler, IID_PPV_ARGS(&pCompiledResult));
23+
24+
- // Handle any errors if they occurred
25+
- ComPtr<IDxcBlobUtf8> pErrors; // wide version currently doesn't appear to be supported
26+
- pCompiledResult->GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&pErrors), nullptr);
27+
- if (pErrors && pErrors->GetStringLength() > 0)
28+
+ HRESULT compileStatus;
29+
+ if (FAILED(pCompiledResult->GetStatus(&compileStatus)) || FAILED(compileStatus))
30+
{
31+
- std::string errorString = pErrors->GetStringPointer();
32+
- std::wstring errorWString = StringToWString(errorString.c_str());
33+
- CauldronCritical(L"%ls : %ls", (shaderFile)? filePath.c_str() : L"ShaderCodeString", errorWString.c_str());
34+
+ CauldronCritical(L"%ls", (shaderFile)? filePath.c_str() : L"ShaderCodeString");
35+
return nullptr;
36+
}
37+

imported/patch-ffx.cmake

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file is part of the AMD Work Graph Ivy Generation Sample.
2+
#
3+
# Copyright (C) 2023 Advanced Micro Devices, Inc.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files(the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions :
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
# This scripts applies small modifications to the FidelityFX & Cauldron SDK
24+
# Patches:
25+
# - Update Microsoft Agility SDK to 714
26+
# - patch camera component to allow for custom implementation
27+
28+
# Update Agility SDK
29+
include(update-agilitysdk.cmake)
30+
31+
find_package(Git)
32+
33+
message(STATUS "Patching common.cmake")
34+
# Patch bin output directory
35+
execute_process(COMMAND "${GIT_EXECUTABLE}" apply "${CMAKE_CURRENT_SOURCE_DIR}/binoutput.patch"
36+
WORKING_DIRECTORY "${FFX_ROOT}"
37+
ERROR_QUIET
38+
OUTPUT_STRIP_TRAILING_WHITESPACE)
39+
40+
message(STATUS "Patching dxil.dll copy")
41+
# Patch copying of dxil.dll to output directory
42+
execute_process(COMMAND "${GIT_EXECUTABLE}" apply "${CMAKE_CURRENT_SOURCE_DIR}/dxil.patch"
43+
WORKING_DIRECTORY "${FFX_ROOT}"
44+
#ERROR_QUIET
45+
OUTPUT_STRIP_TRAILING_WHITESPACE)

0 commit comments

Comments
 (0)