Skip to content

Commit

Permalink
Mesh Node Sample v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
maxoberberger committed Jul 18, 2024
0 parents commit f3486b1
Show file tree
Hide file tree
Showing 46 changed files with 6,760 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
BasedOnStyle: Google
IndentWidth: 4
UseTab: Never
ColumnLimit: 160
Language: Cpp
AccessModifierOffset: -4
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
ConstructorInitializerAllOnOneLineOrOnePerLine : false
BreakConstructorInitializers: BeforeComma
DerivePointerAlignment: false
IndentCaseLabels: false
NamespaceIndentation: All
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignTrailingComments: true
AlignOperands: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: false
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
BinPackArguments: false
BinPackParameters: false
ExperimentalAutoDetectBinPacking: false
AllowAllParametersOfDeclarationOnNextLine: true
AlignConsecutiveMacros: true
AlignAfterOpenBracket: true
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Declare files that will always have LF line endings on checkout.
*.c text eol=lf
*.cpp text eol=lf
*.h text eol=lf
*.hpp text eol=lf
*.idl text eol=lf
*.json text eol=lf
*.hlsl text eol=lf
*.patch text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# CMake build folder
build
# Binary output folder
bin
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is part of the AMD Work Graph Mesh Node Sample.
#
# Copyright (C) 2024 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)

project("Work Graphs Mesh Node Sample" VERSION 0.1.0 LANGUAGES CXX)

# Import FidelityFX & Cauldron
add_subdirectory(imported)

# Add Work Graph Mesh Node Sample
add_subdirectory(meshNodeSample)

set_property(DIRECTORY ${CMAKE_PROJECT_DIR} PROPERTY VS_STARTUP_PROJECT MeshNodeSample)
67 changes: 67 additions & 0 deletions imported/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This file is part of the AMD Work Graph Mesh Node Sample.
#
# Copyright (C) 2024 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.

include(FetchContent)

FetchContent_Declare(
ffxsdk
GIT_REPOSITORY https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK
GIT_TAG 55ff22bb6981a9b9c087b9465101769fc0acd447 # fsr3-v3.0.4
)

FetchContent_GetProperties(ffxsdk)

# manually import FidelityFX SDK
if (NOT ffxsdk_POPULATED)
message(STATUS "Downloading FidelityFX SDK")
FetchContent_Populate(ffxsdk)
message(STATUS "Downloaded FidelityFX SDK to ${ffxsdk_SOURCE_DIR}")

# set root directory of FidelityFX SDK for patches
set(FFX_ROOT ${ffxsdk_SOURCE_DIR})
# Apply patches to FidelityFX SDK
include(patch-ffx.cmake)

# don't build any FFX samples
set(BUILD_TYPE FFX_NONE)
# build FFX SDK with Cauldron backend
set(FFX_API CAULDRON)
# enable FSR2 in FFX SDK.
set(FFX_FSR2 ON)
# FFX_FSR is required for FFX_FSR2, but also enables FFX sample, which also requires FFX_FSR1
set(FFX_FSR ON)
set(FFX_FSR1 ON)

# FFX uses CMAKE_HOME_DIRECTORY as root directory for all internal paths
# since FFX is not the top-level repository here, we need to change CMAKE_HOME_DIRECTORY such that all the paths still match up
set(CMAKE_HOME_DIRECTORY ${ffxsdk_SOURCE_DIR})
add_subdirectory(${ffxsdk_SOURCE_DIR} ${ffxsdk_BINARY_DIR})

# Move FFX_FSR sample to folder in solution
set_target_properties(FFX_FSR PROPERTIES FOLDER "FFX Samples")
endif()

# set root directory of FidelityFX SDK
set(FFX_ROOT ${ffxsdk_SOURCE_DIR} PARENT_SCOPE)

# propagate configurations to top level; only DX12 is supported for this sample
set(CMAKE_CONFIGURATION_TYPES "DebugDX12;ReleaseDX12;RelWithDebInfoDX12" PARENT_SCOPE)
52 changes: 52 additions & 0 deletions imported/agilitysdk-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/framework/cauldron/framework/libs/agilitysdk/CAULDRONREADME.md b/framework/cauldron/framework/libs/agilitysdk/CAULDRONREADME.md
index e445450..470c187 100644
--- a/framework/cauldron/framework/libs/agilitysdk/CAULDRONREADME.md
+++ b/framework/cauldron/framework/libs/agilitysdk/CAULDRONREADME.md
@@ -1,7 +1,7 @@
# DX12 Agility SDK

## Current Version
-1.608.2
+1.715.0-preview

## How to update
1. Download the latest version (as a .nupkg) from https://devblogs.microsoft.com/directx/directx12agility/
diff --git a/framework/cauldron/framework/src/render/dx12/device_dx12.cpp b/framework/cauldron/framework/src/render/dx12/device_dx12.cpp
index 6782b97..580ff02 100644
--- a/framework/cauldron/framework/src/render/dx12/device_dx12.cpp
+++ b/framework/cauldron/framework/src/render/dx12/device_dx12.cpp
@@ -36,7 +36,7 @@
using namespace Microsoft::WRL;

// D3D12SDKVersion needs to line up with the version number on Microsoft's DirectX12 Agility SDK Download page
-extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 608; }
+extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 715; }
extern "C" { __declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\"; }

namespace cauldron
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
index d3ae9cd..db89102 100644
--- a/sdk/tools/ffx_shader_compiler/libs/agilitysdk/FFX_SDK_README.md
+++ b/sdk/tools/ffx_shader_compiler/libs/agilitysdk/FFX_SDK_README.md
@@ -1,7 +1,7 @@
# DX12 Agility SDK

## Current Version
-1.608.2
+1.715.0-preview

## How to update
1. Download the latest version (as a .nupkg) from https://devblogs.microsoft.com/directx/directx12agility/
diff --git a/sdk/tools/ffx_shader_compiler/src/hlsl_compiler.cpp b/sdk/tools/ffx_shader_compiler/src/hlsl_compiler.cpp
index 5375d3d..39884e1 100644
--- a/sdk/tools/ffx_shader_compiler/src/hlsl_compiler.cpp
+++ b/sdk/tools/ffx_shader_compiler/src/hlsl_compiler.cpp
@@ -24,7 +24,7 @@
#include "utils.h"

// D3D12SDKVersion needs to line up with the version number on Microsoft's DirectX12 Agility SDK Download page
-extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 608; }
+extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 715; }
extern "C" { __declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\"; }

struct DxcCustomIncludeHandler : public IDxcIncludeHandler
13 changes: 13 additions & 0 deletions imported/binoutput.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/common.cmake b/common.cmake
index 88aeb5d..4a2283b 100644
--- a/common.cmake
+++ b/common.cmake
@@ -40,7 +40,7 @@ endif()
set(SAMPLE_ROOT ${CMAKE_HOME_DIRECTORY}/samples)
set(SDK_ROOT ${CMAKE_HOME_DIRECTORY}/sdk)
set(FRAMEWORK_ROOT ${CMAKE_HOME_DIRECTORY}/framework)
-set(BIN_OUTPUT ${CMAKE_HOME_DIRECTORY}/bin)
+set(BIN_OUTPUT ${CMAKE_SOURCE_DIR}/bin)
set(CAULDRON_ROOT ${FRAMEWORK_ROOT}/cauldron)
set(RENDERMODULE_ROOT ${FRAMEWORK_ROOT}/rendermodules)
set(FFX_API_CAULDRON_ROOT ${SAMPLE_ROOT}/ffx_cauldron)
13 changes: 13 additions & 0 deletions imported/cameracomponent.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/framework/cauldron/framework/inc/core/components/cameracomponent.h b/framework/cauldron/framework/inc/core/components/cameracomponent.h
index 114b5db..33a274d 100644
--- a/framework/cauldron/framework/inc/core/components/cameracomponent.h
+++ b/framework/cauldron/framework/inc/core/components/cameracomponent.h
@@ -245,7 +245,7 @@ namespace cauldron
*/
static void SetJitterCallbackFunc(CameraJitterCallback callbackFunc) { s_pSetJitterCallback = callbackFunc; }

- private:
+ protected:
CameraComponent() = delete;

void ResetCamera();
37 changes: 37 additions & 0 deletions imported/dxil.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/framework/cauldron/framework/libs/dxc/CMakeLists.txt b/framework/cauldron/framework/libs/dxc/CMakeLists.txt
index 6695b76..fad43bb 100644
--- a/framework/cauldron/framework/libs/dxc/CMakeLists.txt
+++ b/framework/cauldron/framework/libs/dxc/CMakeLists.txt
@@ -2,8 +2,7 @@ add_library(dxc INTERFACE)
target_include_directories(dxc INTERFACE BEFORE "inc/")

set(dxc_binaries
- ${CMAKE_CURRENT_SOURCE_DIR}/bin/x64/dxcompiler.dll
- ${CMAKE_CURRENT_SOURCE_DIR}/bin/x64/dxil.dll)
+ ${CMAKE_CURRENT_SOURCE_DIR}/bin/x64/dxcompiler.dll)

copyTargetCommand("${dxc_binaries}" ${BIN_OUTPUT} copied_dxc_bin)
add_dependencies(dxc copied_dxc_bin)
\ No newline at end of file
diff --git a/framework/cauldron/framework/src/render/win/shaderbuilder_win.cpp b/framework/cauldron/framework/src/render/win/shaderbuilder_win.cpp
index 4847f86..47e2b50 100644
--- a/framework/cauldron/framework/src/render/win/shaderbuilder_win.cpp
+++ b/framework/cauldron/framework/src/render/win/shaderbuilder_win.cpp
@@ -312,14 +312,10 @@ namespace cauldron
ComPtr<IDxcResult> pCompiledResult;
pCompiler->Compile(&shaderCodeBuffer, arguments.data(), static_cast<UINT32>(arguments.size()), &includeFileHandler, IID_PPV_ARGS(&pCompiledResult));

- // Handle any errors if they occurred
- ComPtr<IDxcBlobUtf8> pErrors; // wide version currently doesn't appear to be supported
- pCompiledResult->GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&pErrors), nullptr);
- if (pErrors && pErrors->GetStringLength() > 0)
+ HRESULT compileStatus;
+ if (FAILED(pCompiledResult->GetStatus(&compileStatus)) || FAILED(compileStatus))
{
- std::string errorString = pErrors->GetStringPointer();
- std::wstring errorWString = StringToWString(errorString.c_str());
- CauldronCritical(L"%ls : %ls", (shaderFile)? filePath.c_str() : L"ShaderCodeString", errorWString.c_str());
+ CauldronCritical(L"%ls", (shaderFile)? filePath.c_str() : L"ShaderCodeString");
return nullptr;
}

52 changes: 52 additions & 0 deletions imported/patch-ffx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file is part of the AMD Work Graph Mesh Node Sample.
#
# Copyright (C) 2024 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.

# This scripts applies small modifications to the FidelityFX & Cauldron SDK
# Patches:
# - Update Microsoft Agility SDK to 714
# - patch camera component to allow for custom implementation

# Update Agility SDK
include(update-agilitysdk.cmake)

find_package(Git)

message(STATUS "Patching cameracomponent.h")
# Patch camera component
execute_process(COMMAND "${GIT_EXECUTABLE}" apply "${CMAKE_CURRENT_SOURCE_DIR}/cameracomponent.patch"
WORKING_DIRECTORY "${FFX_ROOT}"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)

message(STATUS "Patching common.cmake")
# Patch bin output directory
execute_process(COMMAND "${GIT_EXECUTABLE}" apply "${CMAKE_CURRENT_SOURCE_DIR}/binoutput.patch"
WORKING_DIRECTORY "${FFX_ROOT}"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)

message(STATUS "Patching dxil.dll copy")
# Patch copying of dxil.dll to output directory
execute_process(COMMAND "${GIT_EXECUTABLE}" apply "${CMAKE_CURRENT_SOURCE_DIR}/dxil.patch"
WORKING_DIRECTORY "${FFX_ROOT}"
#ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
Loading

0 comments on commit f3486b1

Please sign in to comment.