Skip to content

Commit 3118340

Browse files
committed
AMD Render Pipeline Shaders SDK Open Beta 1.1
1 parent 3a69303 commit 3118340

File tree

242 files changed

+8654
-2124
lines changed

Some content is hidden

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

242 files changed

+8654
-2124
lines changed

.clang-format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
22
#
33
# This file is part of the AMD Render Pipeline Shaders SDK which is
44
# released under the AMD INTERNAL EVALUATION LICENSE.
55
#
6-
# See file LICENSE.RTF for full license details.
6+
# See file LICENSE.txt for full license details.
77

88
BasedOnStyle: Google
99
IndentWidth: 4

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
22
#
33
# This file is part of the AMD Render Pipeline Shaders SDK which is
44
# released under the AMD INTERNAL EVALUATION LICENSE.
55
#
6-
# See file LICENSE.RTF for full license details.
6+
# See file LICENSE.txt for full license details.
77

88
/bin
99
/lib
@@ -24,4 +24,6 @@
2424
*.json
2525
/docs/*
2626
!/docs/assets
27+
!/docs/tutorial
28+
!/docs/faq.md
2729
/tests/imported/tmp

.gitlab-ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ variables:
55
stages:
66
- build
77
- test
8+
- deploy
89

910
build:
1011
tags:
@@ -58,4 +59,4 @@ test:
5859
artifacts:
5960
name: "%PackageName%-%CI_COMMIT_TAG%-%CI_COMMIT_REF_NAME%-%CI_COMMIT_SHORT_SHA%"
6061
paths:
61-
- rpsTestLog.txt
62+
- rpsTestLog.txt

CMakeLists.txt

Lines changed: 123 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
22
#
33
# This file is part of the AMD Render Pipeline Shaders SDK which is
44
# released under the AMD INTERNAL EVALUATION LICENSE.
55
#
6-
# See file LICENSE.RTF for full license details.
6+
# See file LICENSE.txt for full license details.
77

88
cmake_minimum_required(VERSION 3.12.1)
99

1010
option( RpsBuildTests "Enable unit test targets" ON )
1111
option( RpsBuildTools "Enable tool targets" ON )
12+
option( RpsBuildExamples "Enable example targets" ON )
1213
option( RpsEnableVulkan "Enable Vulkan backend" ON )
1314
option( RpsEnableImGui "Enable ImGui" ON)
1415
option( RpsEnableDXAgilitySDK "Enable DX12 Agility SDK" OFF )
16+
option( RpsEnableDefaultDeviceImpl "Enable default allocator & printer support" ON )
1517

1618
if ( "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "" )
1719
project( "rps" )
@@ -21,37 +23,42 @@ else ( )
2123
endif ( )
2224

2325
set( NugetPackagesRoot "${CMAKE_BINARY_DIR}/rps_nuget_packages" )
24-
set( DXAgilitySDK_VERSION_STRING "1.706.3-preview" )
25-
set( DXAgilitySDK_VERSION 706 ) # to set D3D12SDKVersion
26+
set( DXAgilitySDK_VERSION_STRING "1.608.3" )
27+
set( DXAgilitySDK_VERSION 608 ) # to set D3D12SDKVersion
2628
set( DXAgilitySDK_INSTALL_DIR "${NugetPackagesRoot}/DXAgilitySDK.${DXAgilitySDK_VERSION_STRING}" )
2729
set( RpsDXAgilitySDK_DIR "${DXAgilitySDK_INSTALL_DIR}" CACHE STRING "DX12 Agility SDK directory" )
2830

2931
set( RpsRootSolutionFolder "" CACHE STRING "Root IDE solution folder" )
3032
set( RpsImGui_DIR "${PROJECT_SOURCE_DIR}/external/imgui" CACHE STRING "ImGui source directory" )
31-
32-
function( BuildFolderProperty RelativeFolder OutputVar )
33-
if ( "${RpsRootSolutionFolder}" STREQUAL "" )
34-
set(${OutputVar} "${RelativeFolder}" PARENT_SCOPE)
35-
else()
36-
set(${OutputVar} "${RpsRootSolutionFolder}/${RelativeFolder}" PARENT_SCOPE)
37-
endif()
38-
endfunction()
33+
set( RpsDXC_DIR "" CACHE STRING "The specified directory is expected to contain dxcompiler.dll and dxil.dll" )
3934

4035
if ( "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Arm64" )
4136
set( RpsEnableVulkan OFF )
4237
endif ( )
4338

39+
if ( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
40+
set( RpsOsLinux TRUE )
41+
endif ( )
42+
4443
if ( RpsEnableVulkan )
4544
find_package( Vulkan 1.2 )
4645
endif ( )
4746

4847
if ( NOT WIN32 )
49-
set ( RpsEnableDXAgilitySDK OFF )
48+
set( RpsEnableDXAgilitySDK OFF )
5049
endif()
5150

51+
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
52+
set( RPS_X64 ON )
53+
elseif ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
54+
set( RPS_X86 ON)
55+
endif()
56+
57+
include( tools/utils.cmake )
58+
5259
# JIT only supports win64 for now
5360
set ( RpsJITSupported FALSE )
54-
if ( WIN32 AND (CMAKE_SIZEOF_VOID_P EQUAL 8) )
61+
if ( WIN32 AND RPS_X64 )
5562
set ( RpsJITSupported TRUE )
5663
endif ( )
5764

@@ -88,7 +95,7 @@ if ( RpsEnableDXAgilitySDK )
8895

8996
# download agility sdk.
9097
if ( PING_STATUS GREATER 0 )
91-
set ( RpsEnableDXAgilitySDK OFF )
98+
set ( RpsEnableDXAgilitySDK OFF ) # NOTE: this shadows cache var.
9299
message( WARNING "Cannot download DXAgilitySDK as no internet connection. Unsetting RpsEnableDXAgilitySDK." )
93100
else()
94101
set( DXAgilitySDK_DOWNLOAD_URL "https://www.nuget.org/api/v2/package/Microsoft.Direct3D.D3D12/${DXAgilitySDK_VERSION_STRING}" )
@@ -111,7 +118,7 @@ if ( RpsEnableDXAgilitySDK )
111118
message( STATUS "Successfully installed DXAgilitySDK to ${DXAgilitySDK_INSTALL_DIR}" )
112119
message( STATUS "DX12AgilitySDK_INCLUDE_DIR = ${DX12AgilitySDK_INCLUDE_DIR}")
113120
else()
114-
set ( RpsEnableDXAgilitySDK OFF )
121+
set ( RpsEnableDXAgilitySDK OFF ) # NOTE: this shadows cache var.
115122
message( WARNING "Unsetting RpsEnableDXAgilitySDK. DXAgilitySDK install failed with: ${DX12AgilitySDK_ERROR}" )
116123
endif()
117124
endif()
@@ -141,16 +148,20 @@ if ( RpsEnableImGui AND (CMAKE_SIZEOF_VOID_P LESS 8) )
141148
add_definitions( -DImTextureID=ImU64 )
142149
endif( )
143150

144-
include(CheckIncludeFiles)
151+
if ( NOT RpsEnableDefaultDeviceImpl )
152+
add_definitions( -DRPS_ENABLE_DEFAULT_DEVICE_IMPL=0 )
153+
endif( )
154+
155+
include( CheckIncludeFiles )
145156

146157
function( CheckIncludeFilesAndAddDefinition IncludeFileName DefinitionName )
147-
check_include_files( ${IncludeFileName} IncludeFileFound)
158+
check_include_files( ${IncludeFileName} IncludeFileFound )
148159
if ( ${IncludeFileFound} )
149160
add_definitions( -D${DefinitionName} )
150161
endif( )
151162
endfunction( )
152163

153-
CheckIncludeFilesAndAddDefinition(intrin.h RPS_HAS_INTRIN_H)
164+
CheckIncludeFilesAndAddDefinition( intrin.h RPS_HAS_INTRIN_H )
154165

155166
function( TryCompileFileAndAddDefinition TryCompileFileName DefinitionName )
156167
try_compile( TryCompileSucceeded ${CMAKE_CURRENT_BINARY_DIR}/cmake_try_compile ${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake_tests/${TryCompileFileName} )
@@ -172,22 +183,40 @@ if ( RpsBuildTests )
172183
endif ( )
173184

174185
# Compile RPSL
175-
function( CompileRpslDxc TargetName RpslFileName GeneratedSources OutDirPrefix )
186+
187+
if ( WIN32 OR RpsOsLinux )
188+
set( RpsOsSupportsRpslCompiler TRUE )
189+
endif ( )
190+
191+
function( CompileRpslDxc TargetName RpslFileName GeneratedSource OutDirPrefix )
176192
get_filename_component( FileNameWithoutExtension ${RpslFileName} NAME_WE )
177-
set( OutDirectory "${CMAKE_CURRENT_BINARY_DIR}/${TargetName}/${OutDirPrefix}/" )
193+
set( OutDirectory "${CMAKE_CURRENT_BINARY_DIR}/${TargetName}.tmp/${OutDirPrefix}/" )
178194
# message( STATUS "Rps-hlslc Output Dir: " ${OutDirectory} )
179195
# message( STATUS "Working dir: " ${OutDirectory} )
180196
set( OutputSource ${OutDirectory}${FileNameWithoutExtension}.rpsl.g.c )
181197
string( APPEND RpsCompileOpts
182198
"$<IF:$<CONFIG:DEBUG>,-O0,-O3>")
199+
if ( WIN32 )
200+
set( RpsCompilerBinaryDir "${PROJECT_SOURCE_DIR}/tools/rps_hlslc/win-x64/" )
201+
set( RpsHlslcDxcompilerLib "${RpsCompilerBinaryDir}/dxcompiler.dll" )
202+
set( ExecPostfix ".exe" )
203+
elseif ( RpsOsLinux )
204+
set( RpsCompilerBinaryDir "${PROJECT_SOURCE_DIR}/tools/rps_hlslc/linux-x64/bin" )
205+
set( RpsHlslcDxcompilerLib "${RpsCompilerBinaryDir}/../lib/libdxcompiler.so" )
206+
else ( )
207+
message( SEND_ERROR "Unsupported OS" )
208+
endif ( )
209+
set( RpsHlslcExec "${RpsCompilerBinaryDir}/rps-hlslc${ExecPostfix}" )
210+
set( RpsLlvmCbeExec "${RpsCompilerBinaryDir}/llvm-cbe${ExecPostfix}" )
211+
file( MAKE_DIRECTORY ${OutDirectory} )
183212
add_custom_command(
184213
OUTPUT ${OutputSource}
185-
COMMAND "${PROJECT_SOURCE_DIR}/tools/rps_hlslc/bin/rps-hlslc.exe" "${RpslFileName}" -od "${OutDirectory}" -m ${FileNameWithoutExtension} ${RpsCompileOpts}
186-
COMMAND ${CMAKE_COMMAND} -E echo "Compiling RPSL ${RpslFileName} : '${PROJECT_SOURCE_DIR}/tools/rps_hlslc/bin/rps-hlslc.exe ${RpslFileName} -od ${OutDirectory} -m ${FileNameWithoutExtension} ${RpsCompileOpts}'"
214+
COMMAND "${RpsHlslcExec}" "${RpslFileName}" -od "${OutDirectory}" -m ${FileNameWithoutExtension} ${RpsCompileOpts}
215+
COMMAND ${CMAKE_COMMAND} -E echo "Compiling RPSL ${RpslFileName} : '${RpsHlslcExec} ${RpslFileName} -od ${OutDirectory} -m ${FileNameWithoutExtension} ${RpsCompileOpts}'"
187216
WORKING_DIRECTORY ${OutDirectory}
188-
DEPENDS ${RpslFileName} "${PROJECT_SOURCE_DIR}/tools/rps_hlslc/bin/rps-hlslc.exe" "${PROJECT_SOURCE_DIR}/tools/rps_hlslc/bin/dxcompiler.dll" "${PROJECT_SOURCE_DIR}/tools/rps_hlslc/bin/llvm-cbe.exe"
217+
DEPENDS ${RpslFileName} "${RpsHlslcExec}" "${RpsHlslcDxcompilerLib}" "${RpsLlvmCbeExec}"
189218
VERBATIM )
190-
set( GeneratedSources "${GeneratedSources}" "${OutputSource}" PARENT_SCOPE )
219+
set( ${GeneratedSource} "${OutputSource}" PARENT_SCOPE )
191220
endfunction()
192221

193222
# Copy assets
@@ -199,58 +228,82 @@ function( CopyShaders TargetName ShaderFiles SrcFolder )
199228
endforeach()
200229
endfunction()
201230

202-
function( CopyDXC TargetName )
203-
#x64 only for now
204-
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
205-
add_custom_command(
206-
TARGET ${TargetName} POST_BUILD
207-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
208-
${PROJECT_SOURCE_DIR}/external/dxc/x64/dxil.dll
209-
$<TARGET_FILE_DIR:${TargetName}>)
210-
add_custom_command(
211-
TARGET ${TargetName} POST_BUILD
212-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
213-
${PROJECT_SOURCE_DIR}/tools/rps_hlslc/bin/dxcompiler.dll
214-
$<TARGET_FILE_DIR:${TargetName}>)
215-
endif()
231+
FindSpirvTools( SPIRV_DXCOMPILER_DLL )
232+
CheckFindFile( SPIRV_DXCOMPILER_DLL ${SPIRV_DXCOMPILER_DLL} )
233+
234+
function( CopySpirvDXC TargetName )
235+
add_custom_command(
236+
TARGET ${TargetName} POST_BUILD
237+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
238+
${SPIRV_DXCOMPILER_DLL}
239+
$<TARGET_FILE_DIR:${TargetName}>/spirv_dxc/dxcompiler.dll)
216240
endfunction()
217241

218-
function( CopyJITCompiler TargetName )
219-
#x64 only for now
220-
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
242+
if ( WIN32 )
243+
244+
FindDXC( DXCOMPILER_DLL DXIL_DLL )
245+
CheckFindFile( DXCOMPILER_DLL ${DXCOMPILER_DLL} )
246+
CheckFindFile( DXIL_DLL ${DXIL_DLL} )
247+
248+
function( CopyDXC TargetName )
221249
add_custom_command(
222250
TARGET ${TargetName} POST_BUILD
223251
COMMAND ${CMAKE_COMMAND} -E copy_if_different
224-
${PROJECT_SOURCE_DIR}/tools/rps_hlslc/bin/rps-jit.dll
252+
${DXCOMPILER_DLL}
225253
$<TARGET_FILE_DIR:${TargetName}>)
226-
# TODO: For now we need rps-hlslc.exe to compile rpsl to bitcode.
227-
# Should allow dxcompiler.dll handle this.
228254
add_custom_command(
229255
TARGET ${TargetName} POST_BUILD
230256
COMMAND ${CMAKE_COMMAND} -E copy_if_different
231-
${PROJECT_SOURCE_DIR}/tools/rps_hlslc/bin/rps-hlslc.exe
257+
${DXIL_DLL}
232258
$<TARGET_FILE_DIR:${TargetName}>)
233-
CopyDXC( ${TargetName} )
234-
endif()
235-
endfunction()
259+
endfunction()
236260

237-
function( CopyDX12AgilitySDKBinaries TargetName )
238-
if (RpsEnableDXAgilitySDK)
239-
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
240-
set( AgilitySDKPlatformName x64 )
241-
endif()
242-
foreach(BinaryToCopy D3D12Core.dll D3D12SDKLayers.dll)
261+
function( CopyJITCompiler TargetName )
262+
#x64 only for now
263+
if( RPS_X64 )
243264
add_custom_command(
244265
TARGET ${TargetName} POST_BUILD
245266
COMMAND ${CMAKE_COMMAND} -E copy_if_different
246-
${DX12AgilitySDK_DIR}/bin/${AgilitySDKPlatformName}/${BinaryToCopy}
247-
$<TARGET_FILE_DIR:${TargetName}>/D3D12/${BinaryToCopy} )
248-
endforeach()
249-
endif()
250-
endfunction()
267+
${PROJECT_SOURCE_DIR}/tools/rps_hlslc/win-x64/rps-jit.dll
268+
$<TARGET_FILE_DIR:${TargetName}>)
269+
# TODO: For now we need rps-hlslc.exe to compile rpsl to bitcode.
270+
# Should allow dxcompiler.dll handle this.
271+
add_custom_command(
272+
TARGET ${TargetName} POST_BUILD
273+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
274+
${PROJECT_SOURCE_DIR}/tools/rps_hlslc/win-x64/rps-hlslc.exe
275+
$<TARGET_FILE_DIR:${TargetName}>/rps_hlslc/rps-hlslc.exe)
276+
add_custom_command(
277+
TARGET ${TargetName} POST_BUILD
278+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
279+
${PROJECT_SOURCE_DIR}/tools/rps_hlslc/win-x64/dxcompiler.dll
280+
$<TARGET_FILE_DIR:${TargetName}>/rps_hlslc/dxcompiler.dll)
281+
# ensures dxil.dll is present.
282+
CopyDXC( ${TargetName} )
283+
endif()
284+
endfunction()
285+
286+
function( CopyDX12AgilitySDKBinaries TargetName )
287+
if ( RpsEnableDXAgilitySDK )
288+
if( RPS_X64 )
289+
set( AgilitySDKPlatformName x64 )
290+
elseif( RPS_X86 )
291+
set( AgilitySDKPlatformName win32 )
292+
endif()
293+
foreach( BinaryToCopy D3D12Core.dll D3D12SDKLayers.dll )
294+
add_custom_command(
295+
TARGET ${TargetName} POST_BUILD
296+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
297+
${DX12AgilitySDK_DIR}/bin/${AgilitySDKPlatformName}/${BinaryToCopy}
298+
$<TARGET_FILE_DIR:${TargetName}>/D3D12/${BinaryToCopy} )
299+
endforeach()
300+
endif()
301+
endfunction()
302+
303+
endif() # end if ( WIN32 )
251304

252305
# Adding a library module from the ./src/${ModuleName} folder
253-
function( AddModule ModuleName ModuleFolder SrcFolder SrcInclude CompileFlags LibType LinkLibs )
306+
function( AddModule ModuleName ModuleFolder SrcFolder SrcInclude CompileFlags CompileDefinitions LibType LinkLibs )
254307
file( GLOB_RECURSE HeaderFiles
255308
"${ModuleFolder}/*.h"
256309
"${ModuleFolder}/*.hpp"
@@ -267,6 +320,10 @@ function( AddModule ModuleName ModuleFolder SrcFolder SrcInclude CompileFlags Li
267320
set(ModuleName ${ModuleName}.headers)
268321
add_custom_target( ${ModuleName} SOURCES ${HeaderFiles} )
269322
endif ( )
323+
324+
if( CompileDefinitions )
325+
set_target_properties( ${ModuleName} PROPERTIES COMPILE_DEFINITIONS "${CompileDefinitions}")
326+
endif( )
270327

271328
if ( CompileFlags )
272329
set_target_properties( ${ModuleName} PROPERTIES COMPILE_FLAGS "${CompileFlags}")
@@ -337,7 +394,7 @@ function( AddCppApp AppName AppFolder SrcFolder SrcSharedFolder SrcInclude Compi
337394

338395
if ( SrcSharedFolder )
339396
file( GLOB_RECURSE SourceSharedFiles
340-
"${SrcSharedFolder}/*.h" )
397+
"${SrcSharedFolder}/*_shared.hpp" )
341398
source_group( TREE "${SrcSharedFolder}/" PREFIX "shared" FILES ${SourceSharedFiles} )
342399

343400
if ( ${AppName} MATCHES "rpsl" )
@@ -349,7 +406,8 @@ function( AddCppApp AppName AppFolder SrcFolder SrcSharedFolder SrcInclude Compi
349406
set( GeneratedSources "" )
350407
foreach( RpslFileName ${RpslFiles} )
351408
message( STATUS "Found Rpsl: " ${RpslFileName} )
352-
CompileRpslDxc( ${AppName} ${RpslFileName} "${GeneratedSources}" "Generated")
409+
CompileRpslDxc( ${AppName} ${RpslFileName} RpslOutputSource "Generated")
410+
set( GeneratedSources ${GeneratedSources} ${RpslOutputSource} )
353411
endforeach()
354412
source_group( TREE "${CMAKE_CURRENT_BINARY_DIR}/${AppName}/Generated/" PREFIX "rps_generated" FILES ${GeneratedSources} )
355413

@@ -385,7 +443,7 @@ function( AddCppApp AppName AppFolder SrcFolder SrcSharedFolder SrcInclude Compi
385443

386444
endfunction()
387445

388-
function( AddSampleApps AppNames Variant Platform SrcInclude CompileFlags DependenciesString )
446+
function( AddSampleApps AppNames Variant Platform SrcInclude CompileFlags CompileDefinitions DependenciesString )
389447
foreach(AppName ${AppNames})
390448
AddCppApp( ${AppName}${Variant}_${Platform} "samples/${Platform}" ${PROJECT_SOURCE_DIR}/samples/${Platform}/${AppName} ${PROJECT_SOURCE_DIR}/samples/shared/${AppName} "${SrcInclude}" ${CompileFlags} "${DependenciesString}" )
391449
endforeach()
@@ -396,7 +454,7 @@ set ( FullSource TRUE )
396454

397455
# Common for full or limited source
398456
BuildFolderProperty( "modules" ModuleFolder )
399-
AddModule( rps ${PROJECT_SOURCE_DIR}/include "${ModuleFolder}" "" "" INTERFACE "" )
457+
AddModule( rps ${PROJECT_SOURCE_DIR}/include "${ModuleFolder}" "" "" "${CompileDefinitions}" INTERFACE "" )
400458

401459
add_subdirectory( src )
402460
add_subdirectory( external )

Doxyfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
22
#
33
# This file is part of the AMD Render Pipeline Shaders SDK which is
44
# released under the AMD INTERNAL EVALUATION LICENSE.
55
#
6-
# See file LICENSE.RTF for full license details.
6+
# See file LICENSE.txt for full license details.
77

88
# Doxyfile 1.9.2
99

0 commit comments

Comments
 (0)