Skip to content

Commit

Permalink
Work Graph Playground v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
maxoberberger committed Nov 8, 2024
0 parents commit 616e78b
Show file tree
Hide file tree
Showing 45 changed files with 6,575 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
BasedOnStyle: Google
ColumnLimit: 120
IndentWidth: 4
AlignAfterOpenBracket: Align
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterUnion: false
AfterStruct: false
SplitEmptyFunction: true
AfterNamespace: false
AfterClass: false
AfterFunction: true
AfterControlStatement: MultiLine
BeforeElse: false
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
DerivePointerAlignment: false
PointerAlignment: Left
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: false
AlignConsecutiveAssignments: AcrossComments
AlignConsecutiveDeclarations: AcrossComments
AlignConsecutiveBitFields: AcrossComments
AlignOperands: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowAllArgumentsOnNextLine: true
AllowShortCaseLabelsOnASingleLine: false
BinPackArguments: false
BinPackParameters: false
AccessModifierOffset: -4
ReflowComments: true
SortIncludes: true
TabWidth: 4
AlwaysBreakTemplateDeclarations: Yes
AllowShortFunctionsOnASingleLine: Empty
UseTab: Never
NamespaceIndentation: All
---
Language: Cpp
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ignore thumbnails created by Windows
Thumbs.db

# build folder
build/

# vscode related files
.vscode/
*.code-workspace

# UI window placements
**/imgui.ini*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "imported/imgui"]
path = imported/imgui
url = https://github.com/ocornut/imgui
95 changes: 95 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This file is part of the AMD & HSC Work Graph Playground.
#
# Copyright (C) 2024 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
# All rights reserved.
#
# 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(WorkGraphPlayground VERSION 0.1)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

add_compile_definitions(UNICODE _UNICODE)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

add_subdirectory(imported)


file(GLOB PROJECT_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE PROJECT_SHADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tutorials/*.md
${CMAKE_CURRENT_SOURCE_DIR}/tutorials/*.png
${CMAKE_CURRENT_SOURCE_DIR}/tutorials/*.h
${CMAKE_CURRENT_SOURCE_DIR}/tutorials/*.hlsl)
set_source_files_properties(${PROJECT_SHADER_FILES} PROPERTIES VS_TOOL_OVERRIDE "Text")

add_executable(${PROJECT_NAME} ${PROJECT_SOURCE_FILES} ${PROJECT_SHADER_FILES})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PRIVATE
Microsoft.Direct3D.D3D12
Microsoft.Direct3D.DXC
Microsoft.Direct3D.WARP
d3d12
dxcompiler
dxgi
dxguid
imgui)

set_target_properties(${PROJECT_NAME} PROPERTIES
VS_DPI_AWARE "PerMonitor"
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>")
set_property(DIRECTORY "." PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})

# set source group for shader files & link to bin folder
set(SHADER_BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tutorials)
foreach(SHADER ${PROJECT_SHADER_FILES})
get_filename_component(SHADER_FILE_DIRECTORY ${SHADER} DIRECTORY)
get_filename_component(SHADER_FILE_NAME ${SHADER} NAME)
file(RELATIVE_PATH SHADER_FILE_DIRECTORY_RELATIVE_PATH ${SHADER_BASE_DIRECTORY} ${SHADER_FILE_DIRECTORY})

if ("${SHADER_FILE_DIRECTORY_RELATIVE_PATH}" STREQUAL "")
source_group("Shader Source Files" FILES ${SHADER})
else()
source_group("Shader Source Files/${SHADER_FILE_DIRECTORY_RELATIVE_PATH}" FILES ${SHADER})
endif()

# to enable shader hot-reloading, instead of copying the shaders to the bin output folder at the end of the build,
# we create hardlinks between a file in the bin folder and the shader source file.
# This way, updates to the shader source file are automatically propagated to the bin folder,
# and - unlike symlinks - the hardlinks allow copying/moving/compressing the bin folder without having broken links.

# create parent folder
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/tutorials/${SHADER_FILE_DIRECTORY_RELATIVE_PATH})
# create hardlink
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_hardlink
${SHADER}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/tutorials/${SHADER_FILE_DIRECTORY_RELATIVE_PATH}/${SHADER_FILE_NAME})
endforeach()
47 changes: 47 additions & 0 deletions imported/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is part of the AMD & HSC Work Graph Playground.
#
# Copyright (C) 2024 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
# All rights reserved.
#
# 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(nuget.cmake)

fetch_nuget_package(
PACKAGE Microsoft.Direct3D.D3D12
VERSION 1.613.3
)
fetch_nuget_package(
PACKAGE Microsoft.Direct3D.DXC
VERSION 1.8.2403.18
)
fetch_nuget_package(
PACKAGE Microsoft.Direct3D.WARP
VERSION 1.0.13
)

file(GLOB IMGUI_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/imgui/*.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/*_dx12.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/*_dx12.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/*_win32.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/*_win32.cpp)
add_library(imgui STATIC ${IMGUI_SOURCES})
target_include_directories(imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
1 change: 1 addition & 0 deletions imported/imgui
Submodule imgui added at 004f03
85 changes: 85 additions & 0 deletions imported/nuget.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This file is part of the AMD & HSC Work Graph Playground.
#
# Copyright (C) 2024 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
# All rights reserved.
#
# 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.

function(fetch_nuget_package)
set(options)
set(oneValueArgs PACKAGE VERSION)
set(multiValueArgs)
cmake_parse_arguments(FETCH_NUGET_PACKAGE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (NOT DEFINED FETCH_NUGET_PACKAGE_PACKAGE)
message(FATAL_ERROR "Missing PACKAGE argument")
endif()
if (NOT DEFINED FETCH_NUGET_PACKAGE_VERSION)
message(FATAL_ERROR "Missing VERSION argument")
endif()

set(DOWNLOAD_URL "https://www.nuget.org/api/v2/package/${FETCH_NUGET_PACKAGE_PACKAGE}/${FETCH_NUGET_PACKAGE_VERSION}")
set(DOWNLOAD_FILE ${CMAKE_CURRENT_BINARY_DIR}/nuget/${FETCH_NUGET_PACKAGE_PACKAGE}.zip)
set(PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nuget/${FETCH_NUGET_PACKAGE_PACKAGE})

if (NOT EXISTS ${DOWNLOAD_FILE})
message(STATUS "Downloading NuGet package \"${FETCH_NUGET_PACKAGE_PACKAGE}\" from \"${DOWNLOAD_URL}\".")

file(DOWNLOAD "${DOWNLOAD_URL}" ${DOWNLOAD_FILE} STATUS DOWNLOAD_RESULT)

list(GET DOWNLOAD_RESULT 0 DOWNLOAD_RESULT_CODE)
if(NOT DOWNLOAD_RESULT_CODE EQUAL 0)
message(FATAL_ERROR "Failed to download NuGet package \"${FETCH_NUGET_PACKAGE_PACKAGE}\" from \"${DOWNLOAD_URL}\". Error: ${DOWNLOAD_RESULT}.")
endif()
endif()

file(ARCHIVE_EXTRACT
INPUT ${DOWNLOAD_FILE}
DESTINATION ${PACKAGE_DIRECTORY})

message(STATUS "Adding NuGet package \"${FETCH_NUGET_PACKAGE_PACKAGE}\".")

add_library(${FETCH_NUGET_PACKAGE_PACKAGE} INTERFACE)
target_include_directories(${FETCH_NUGET_PACKAGE_PACKAGE} INTERFACE ${PACKAGE_DIRECTORY}/build/native/include)

file(GLOB PACKAGE_BIN_FILES
${PACKAGE_DIRECTORY}/build/native/bin/x64/*.exe
${PACKAGE_DIRECTORY}/build/native/bin/x64/*.dll
${PACKAGE_DIRECTORY}/build/native/bin/x64/*.pdb)

foreach(PACKAGE_BIN_FILE ${PACKAGE_BIN_FILES})
get_filename_component(PACKAGE_BIN_FILE_NAME ${PACKAGE_BIN_FILE} NAME)
message("Generating custom command for ${PACKAGE_BIN_FILE_NAME}")
add_custom_command(
OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/${PACKAGE_BIN_FILE_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PACKAGE_BIN_FILE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>
MAIN_DEPENDENCY ${PACKAGE_BIN_FILE}
COMMENT "Updating ${PACKAGE_BIN_FILE} into bin folder"
)
list(APPEND COPY_FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/${PACKAGE_BIN_FILE_NAME})
endforeach()

add_custom_target(${FETCH_NUGET_PACKAGE_PACKAGE}_copy DEPENDS "${COPY_FILES}")
set_target_properties(${FETCH_NUGET_PACKAGE_PACKAGE}_copy PROPERTIES FOLDER CopyTargets)

add_dependencies(${FETCH_NUGET_PACKAGE_PACKAGE} ${FETCH_NUGET_PACKAGE_PACKAGE}_copy)

endfunction(fetch_nuget_package)
Loading

0 comments on commit 616e78b

Please sign in to comment.