Skip to content

Commit 616e78b

Browse files
committed
Work Graph Playground v1.0.0
0 parents  commit 616e78b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+6575
-0
lines changed

.clang-format

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
BasedOnStyle: Google
3+
ColumnLimit: 120
4+
IndentWidth: 4
5+
AlignAfterOpenBracket: Align
6+
BreakBeforeBraces: Custom
7+
BraceWrapping:
8+
AfterCaseLabel: false
9+
AfterUnion: false
10+
AfterStruct: false
11+
SplitEmptyFunction: true
12+
AfterNamespace: false
13+
AfterClass: false
14+
AfterFunction: true
15+
AfterControlStatement: MultiLine
16+
BeforeElse: false
17+
AllowShortIfStatementsOnASingleLine: false
18+
IndentCaseLabels: false
19+
DerivePointerAlignment: false
20+
PointerAlignment: Left
21+
AlignTrailingComments: true
22+
AllowShortBlocksOnASingleLine: false
23+
AlignConsecutiveAssignments: AcrossComments
24+
AlignConsecutiveDeclarations: AcrossComments
25+
AlignConsecutiveBitFields: AcrossComments
26+
AlignOperands: true
27+
AllowAllParametersOfDeclarationOnNextLine: false
28+
AllowAllArgumentsOnNextLine: true
29+
AllowShortCaseLabelsOnASingleLine: false
30+
BinPackArguments: false
31+
BinPackParameters: false
32+
AccessModifierOffset: -4
33+
ReflowComments: true
34+
SortIncludes: true
35+
TabWidth: 4
36+
AlwaysBreakTemplateDeclarations: Yes
37+
AllowShortFunctionsOnASingleLine: Empty
38+
UseTab: Never
39+
NamespaceIndentation: All
40+
---
41+
Language: Cpp

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ignore thumbnails created by Windows
2+
Thumbs.db
3+
4+
# build folder
5+
build/
6+
7+
# vscode related files
8+
.vscode/
9+
*.code-workspace
10+
11+
# UI window placements
12+
**/imgui.ini*

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "imported/imgui"]
2+
path = imported/imgui
3+
url = https://github.com/ocornut/imgui

CMakeLists.txt

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# This file is part of the AMD & HSC Work Graph Playground.
2+
#
3+
# Copyright (C) 2024 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
4+
# All rights reserved.
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files(the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions :
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
24+
cmake_minimum_required(VERSION 3.17)
25+
project(WorkGraphPlayground VERSION 0.1)
26+
27+
set(CMAKE_CXX_STANDARD 20)
28+
set(CMAKE_CXX_STANDARD_REQUIRED True)
29+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
30+
31+
set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
32+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
33+
34+
add_compile_definitions(UNICODE _UNICODE)
35+
36+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
37+
38+
add_subdirectory(imported)
39+
40+
41+
file(GLOB PROJECT_SOURCE_FILES
42+
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
43+
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
44+
file(GLOB_RECURSE PROJECT_SHADER_FILES
45+
${CMAKE_CURRENT_SOURCE_DIR}/tutorials/*.md
46+
${CMAKE_CURRENT_SOURCE_DIR}/tutorials/*.png
47+
${CMAKE_CURRENT_SOURCE_DIR}/tutorials/*.h
48+
${CMAKE_CURRENT_SOURCE_DIR}/tutorials/*.hlsl)
49+
set_source_files_properties(${PROJECT_SHADER_FILES} PROPERTIES VS_TOOL_OVERRIDE "Text")
50+
51+
add_executable(${PROJECT_NAME} ${PROJECT_SOURCE_FILES} ${PROJECT_SHADER_FILES})
52+
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
53+
target_link_libraries(${PROJECT_NAME} PRIVATE
54+
Microsoft.Direct3D.D3D12
55+
Microsoft.Direct3D.DXC
56+
Microsoft.Direct3D.WARP
57+
d3d12
58+
dxcompiler
59+
dxgi
60+
dxguid
61+
imgui)
62+
63+
set_target_properties(${PROJECT_NAME} PROPERTIES
64+
VS_DPI_AWARE "PerMonitor"
65+
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>")
66+
set_property(DIRECTORY "." PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
67+
68+
# set source group for shader files & link to bin folder
69+
set(SHADER_BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tutorials)
70+
foreach(SHADER ${PROJECT_SHADER_FILES})
71+
get_filename_component(SHADER_FILE_DIRECTORY ${SHADER} DIRECTORY)
72+
get_filename_component(SHADER_FILE_NAME ${SHADER} NAME)
73+
file(RELATIVE_PATH SHADER_FILE_DIRECTORY_RELATIVE_PATH ${SHADER_BASE_DIRECTORY} ${SHADER_FILE_DIRECTORY})
74+
75+
if ("${SHADER_FILE_DIRECTORY_RELATIVE_PATH}" STREQUAL "")
76+
source_group("Shader Source Files" FILES ${SHADER})
77+
else()
78+
source_group("Shader Source Files/${SHADER_FILE_DIRECTORY_RELATIVE_PATH}" FILES ${SHADER})
79+
endif()
80+
81+
# to enable shader hot-reloading, instead of copying the shaders to the bin output folder at the end of the build,
82+
# we create hardlinks between a file in the bin folder and the shader source file.
83+
# This way, updates to the shader source file are automatically propagated to the bin folder,
84+
# and - unlike symlinks - the hardlinks allow copying/moving/compressing the bin folder without having broken links.
85+
86+
# create parent folder
87+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
88+
COMMAND ${CMAKE_COMMAND} -E make_directory
89+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/tutorials/${SHADER_FILE_DIRECTORY_RELATIVE_PATH})
90+
# create hardlink
91+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
92+
COMMAND ${CMAKE_COMMAND} -E create_hardlink
93+
${SHADER}
94+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/tutorials/${SHADER_FILE_DIRECTORY_RELATIVE_PATH}/${SHADER_FILE_NAME})
95+
endforeach()

imported/CMakeLists.txt

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This file is part of the AMD & HSC Work Graph Playground.
2+
#
3+
# Copyright (C) 2024 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
4+
# All rights reserved.
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files(the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions :
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
24+
include(nuget.cmake)
25+
26+
fetch_nuget_package(
27+
PACKAGE Microsoft.Direct3D.D3D12
28+
VERSION 1.613.3
29+
)
30+
fetch_nuget_package(
31+
PACKAGE Microsoft.Direct3D.DXC
32+
VERSION 1.8.2403.18
33+
)
34+
fetch_nuget_package(
35+
PACKAGE Microsoft.Direct3D.WARP
36+
VERSION 1.0.13
37+
)
38+
39+
file(GLOB IMGUI_SOURCES
40+
${CMAKE_CURRENT_SOURCE_DIR}/imgui/*.h
41+
${CMAKE_CURRENT_SOURCE_DIR}/imgui/*.cpp
42+
${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/*_dx12.h
43+
${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/*_dx12.cpp
44+
${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/*_win32.h
45+
${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/*_win32.cpp)
46+
add_library(imgui STATIC ${IMGUI_SOURCES})
47+
target_include_directories(imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)

imported/imgui

Submodule imgui added at 004f039

imported/nuget.cmake

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# This file is part of the AMD & HSC Work Graph Playground.
2+
#
3+
# Copyright (C) 2024 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
4+
# All rights reserved.
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files(the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions :
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
24+
function(fetch_nuget_package)
25+
set(options)
26+
set(oneValueArgs PACKAGE VERSION)
27+
set(multiValueArgs)
28+
cmake_parse_arguments(FETCH_NUGET_PACKAGE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
29+
30+
if (NOT DEFINED FETCH_NUGET_PACKAGE_PACKAGE)
31+
message(FATAL_ERROR "Missing PACKAGE argument")
32+
endif()
33+
if (NOT DEFINED FETCH_NUGET_PACKAGE_VERSION)
34+
message(FATAL_ERROR "Missing VERSION argument")
35+
endif()
36+
37+
set(DOWNLOAD_URL "https://www.nuget.org/api/v2/package/${FETCH_NUGET_PACKAGE_PACKAGE}/${FETCH_NUGET_PACKAGE_VERSION}")
38+
set(DOWNLOAD_FILE ${CMAKE_CURRENT_BINARY_DIR}/nuget/${FETCH_NUGET_PACKAGE_PACKAGE}.zip)
39+
set(PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nuget/${FETCH_NUGET_PACKAGE_PACKAGE})
40+
41+
if (NOT EXISTS ${DOWNLOAD_FILE})
42+
message(STATUS "Downloading NuGet package \"${FETCH_NUGET_PACKAGE_PACKAGE}\" from \"${DOWNLOAD_URL}\".")
43+
44+
file(DOWNLOAD "${DOWNLOAD_URL}" ${DOWNLOAD_FILE} STATUS DOWNLOAD_RESULT)
45+
46+
list(GET DOWNLOAD_RESULT 0 DOWNLOAD_RESULT_CODE)
47+
if(NOT DOWNLOAD_RESULT_CODE EQUAL 0)
48+
message(FATAL_ERROR "Failed to download NuGet package \"${FETCH_NUGET_PACKAGE_PACKAGE}\" from \"${DOWNLOAD_URL}\". Error: ${DOWNLOAD_RESULT}.")
49+
endif()
50+
endif()
51+
52+
file(ARCHIVE_EXTRACT
53+
INPUT ${DOWNLOAD_FILE}
54+
DESTINATION ${PACKAGE_DIRECTORY})
55+
56+
message(STATUS "Adding NuGet package \"${FETCH_NUGET_PACKAGE_PACKAGE}\".")
57+
58+
add_library(${FETCH_NUGET_PACKAGE_PACKAGE} INTERFACE)
59+
target_include_directories(${FETCH_NUGET_PACKAGE_PACKAGE} INTERFACE ${PACKAGE_DIRECTORY}/build/native/include)
60+
61+
file(GLOB PACKAGE_BIN_FILES
62+
${PACKAGE_DIRECTORY}/build/native/bin/x64/*.exe
63+
${PACKAGE_DIRECTORY}/build/native/bin/x64/*.dll
64+
${PACKAGE_DIRECTORY}/build/native/bin/x64/*.pdb)
65+
66+
foreach(PACKAGE_BIN_FILE ${PACKAGE_BIN_FILES})
67+
get_filename_component(PACKAGE_BIN_FILE_NAME ${PACKAGE_BIN_FILE} NAME)
68+
message("Generating custom command for ${PACKAGE_BIN_FILE_NAME}")
69+
add_custom_command(
70+
OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/${PACKAGE_BIN_FILE_NAME}
71+
PRE_BUILD
72+
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>
73+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PACKAGE_BIN_FILE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>
74+
MAIN_DEPENDENCY ${PACKAGE_BIN_FILE}
75+
COMMENT "Updating ${PACKAGE_BIN_FILE} into bin folder"
76+
)
77+
list(APPEND COPY_FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/${PACKAGE_BIN_FILE_NAME})
78+
endforeach()
79+
80+
add_custom_target(${FETCH_NUGET_PACKAGE_PACKAGE}_copy DEPENDS "${COPY_FILES}")
81+
set_target_properties(${FETCH_NUGET_PACKAGE_PACKAGE}_copy PROPERTIES FOLDER CopyTargets)
82+
83+
add_dependencies(${FETCH_NUGET_PACKAGE_PACKAGE} ${FETCH_NUGET_PACKAGE_PACKAGE}_copy)
84+
85+
endfunction(fetch_nuget_package)

0 commit comments

Comments
 (0)