1
1
# This file is part of the AMD & HSC Work Graph Playground.
2
2
#
3
- # Copyright (C) 2024 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
3
+ # Copyright (C) 2025 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
4
4
# All rights reserved.
5
5
#
6
6
# Permission is hereby granted, free of charge, to any person obtaining a copy
22
22
# THE SOFTWARE.
23
23
24
24
cmake_minimum_required (VERSION 3.17 )
25
- project (WorkGraphPlayground VERSION 0 .1 )
25
+ project (WorkGraphPlayground VERSION 1 .1 )
26
26
27
27
set (CMAKE_CXX_STANDARD 20 )
28
28
set (CMAKE_CXX_STANDARD_REQUIRED True )
@@ -35,23 +35,28 @@ add_compile_definitions(UNICODE _UNICODE)
35
35
36
36
set_property (GLOBAL PROPERTY USE_FOLDERS ON )
37
37
38
+ option (PLAYGROUND_ENABLE_MESH_NODES "Enable experimental mesh node support" OFF )
39
+ set (PLAYGROUND_COPY_TUTORIAL_MODE "none" CACHE STRING "Mode for copying tutorial files to output bin folder.\n none: do not copy tutorial files.\n copy: copy tutorial files after build step.\n symlink: create symlinks for tutorial folder to bin folder." )
40
+ set_property (CACHE PLAYGROUND_COPY_TUTORIAL_MODE PROPERTY STRINGS none copy symlink )
41
+
38
42
add_subdirectory (imported )
39
43
44
+ add_executable (${PROJECT_NAME} )
45
+
46
+ if (PLAYGROUND_ENABLE_MESH_NODES )
47
+ target_compile_definitions (${PROJECT_NAME} PRIVATE ENABLE_MESH_NODES )
48
+ endif ()
40
49
50
+ # collect & add C++ source files
41
51
file (GLOB PROJECT_SOURCE_FILES
42
52
${CMAKE_CURRENT_SOURCE_DIR} /include/*.h
43
53
${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} )
54
+ target_sources (${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_FILES} )
55
+
52
56
target_include_directories (${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} /include )
57
+ # link NuGet packages and ImGui
53
58
target_link_libraries (${PROJECT_NAME} PRIVATE
54
- Microsoft.Direct3D.D3D12
59
+ Microsoft.Direct3D.D3D12
55
60
Microsoft.Direct3D.DXC
56
61
Microsoft.Direct3D.WARP
57
62
d3d12
@@ -60,36 +65,92 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
60
65
dxguid
61
66
imgui )
62
67
63
- set_target_properties (${PROJECT_NAME} PROPERTIES
68
+ set_target_properties (${PROJECT_NAME} PROPERTIES
69
+ # set playground app to be DPI aware, i.e. disable scaling in Windows compositor
64
70
VS_DPI_AWARE "PerMonitor"
65
- VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY} /$<CONFIG>" )
71
+ # set working directory to current directory
72
+ VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
73
+
74
+ # set playground as startup project
66
75
set_property (DIRECTORY "." PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME} )
67
76
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} )
77
+ set (TUTORIAL_FOLDER_LIST "" )
78
+ function (add_tutorial_folder TUTORIAL_FOLDER PREFIX SOURCE_GROUP )
79
+ if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /${TUTORIAL_FOLDER} )
80
+ message (FATAL "Tutorial folder ${TUTORIAL_FOLDER} not found in current source directory!" )
79
81
endif ()
80
82
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 ()
83
+ # collect tutorial source files
84
+ file (GLOB_RECURSE TUTORIAL_FILES
85
+ ${CMAKE_CURRENT_SOURCE_DIR} /${TUTORIAL_FOLDER}/*.md
86
+ ${CMAKE_CURRENT_SOURCE_DIR} /${TUTORIAL_FOLDER}/*.png
87
+ ${CMAKE_CURRENT_SOURCE_DIR} /${TUTORIAL_FOLDER}/*.h
88
+ ${CMAKE_CURRENT_SOURCE_DIR} /${TUTORIAL_FOLDER}/*.hlsl )
89
+
90
+ # add tutorial source files and disable compilation of HLSL files
91
+ target_sources (${PROJECT_NAME} PRIVATE ${TUTORIAL_FILES} )
92
+ set_source_files_properties (${TUTORIAL_FILES} PROPERTIES VS_TOOL_OVERRIDE "Text" )
93
+
94
+ if ("${PLAYGROUND_COPY_TUTORIAL_MODE} " STREQUAL "copy" )
95
+ add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
96
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
97
+ ${CMAKE_CURRENT_SOURCE_DIR} /${TUTORIAL_FOLDER}
98
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} /$<CONFIG>/${TUTORIAL_FOLDER} )
99
+ elseif ("${PLAYGROUND_COPY_TUTORIAL_MODE} " STREQUAL "symlink" )
100
+ # To allow for easy copying of the playground and all tutorials, we support creating symlinks for all
101
+ # tutorial folders to the bin output folder. As shader source files are not part of the build process
102
+ # changes to these files are not tracked by the build system.
103
+ # To still keep all the shader source files in the bin folder up-to-date, we create a symlink for each folder.
104
+ # This way, updates to the shader source file are automatically propagated to the bin folder,
105
+ # allowing you to copy/move/compress the bin folder with the latest version of your shader file.
106
+
107
+ add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
108
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
109
+ ${CMAKE_CURRENT_SOURCE_DIR} /${TUTORIAL_FOLDER}
110
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} /$<CONFIG>/${TUTORIAL_FOLDER} )
111
+ endif ()
112
+
113
+ # set source group for shader files & link to bin folder
114
+ foreach (TUTORIAL_FILE ${TUTORIAL_FILES} )
115
+ get_filename_component (TUTORIAL_FILE_DIRECTORY ${TUTORIAL_FILE} DIRECTORY )
116
+ get_filename_component (TUTORIAL_FILE_NAME ${TUTORIAL_FILE} NAME )
117
+ file (RELATIVE_PATH TUTORIAL_FILE_DIRECTORY_RELATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} /${TUTORIAL_FOLDER} ${TUTORIAL_FILE_DIRECTORY} )
118
+
119
+ if ("${TUTORIAL_FILE_DIRECTORY_RELATIVE_PATH} " STREQUAL "" )
120
+ source_group ("${SOURCE_GROUP} " FILES ${TUTORIAL_FILE} )
121
+ else ()
122
+ source_group ("${SOURCE_GROUP} /${TUTORIAL_FILE_DIRECTORY_RELATIVE_PATH} " FILES ${TUTORIAL_FILE} )
123
+ endif ()
124
+ endforeach ()
125
+
126
+ set (TUTORIAL_FOLDER_LIST "${TUTORIAL_FOLDER_LIST} std::make_pair(\" ${TUTORIAL_FOLDER} \" , \" ${PREFIX} \" )," PARENT_SCOPE )
127
+ endfunction (add_tutorial_folder )
128
+
129
+ add_tutorial_folder (tutorials "Tutorial" "Shader Source Files" )
130
+
131
+ if (PLAYGROUND_ENABLE_MESH_NODES )
132
+ # Add mesh node tutorials. These are only included if mesh nodes are enabled.
133
+ add_tutorial_folder (mesh-node-tutorials "Mesh Node Tutorial" "Shader Source Files/Mesh Nodes" )
134
+ endif ()
135
+
136
+ ########################################################################################################
137
+ # Add new tutorial folders here
138
+ #
139
+ # Example:
140
+ # add_tutorial_folder(./path/to/your/folder "My Tutorial Prefix" "Shader Source Files/My New Tutorials")
141
+ #
142
+ # Tutorials in this folder will show up in the UI as "My Tutorial Prefix #: Tutorial Name" and
143
+ # show up in the solution under "Shader Source Files/My New Tutorials"
144
+ #
145
+
146
+
147
+
148
+ ########################################################################################################
149
+
150
+ # Once all tutorials are added, set define for app to scan all tutorial folders at runtime
151
+ target_compile_definitions (${PROJECT_NAME} PRIVATE TUTORIAL_FOLDER_LIST=${TUTORIAL_FOLDER_LIST} )
152
+
153
+
154
+
155
+
156
+
0 commit comments