From 9929782e8698b550bfed95bd6ae0d2f920afac84 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Fri, 3 Sep 2021 17:32:37 -0700 Subject: [PATCH] Changes how renderdoc is added, since this is not a real 3rdParty we want to depend on but some functionality we want to enable/disable Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- Gems/Atom/RHI/Code/CMakeLists.txt | 29 +++++++++---------- .../renderdoc_support_android.cmake} | 3 +- .../Code/Platform/Linux/renderdoc_linux.cmake | 27 +++++------------ .../Linux/renderdoc_support_linux.cmake | 14 +++++++++ .../Platform/Mac/renderdoc_support_mac.cmake | 9 ++++++ .../Windows/renderdoc_support_windows.cmake | 14 +++++++++ .../Platform/Windows/renderdoc_windows.cmake | 29 +++++-------------- .../Platform/iOS/renderdoc_support_ios.cmake | 9 ++++++ 8 files changed, 76 insertions(+), 58 deletions(-) rename Gems/Atom/RHI/Code/Platform/{AppleTV/AtomRHITests_traits_appletv.cmake => Android/renderdoc_support_android.cmake} (69%) create mode 100644 Gems/Atom/RHI/Code/Platform/Linux/renderdoc_support_linux.cmake create mode 100644 Gems/Atom/RHI/Code/Platform/Mac/renderdoc_support_mac.cmake create mode 100644 Gems/Atom/RHI/Code/Platform/Windows/renderdoc_support_windows.cmake create mode 100644 Gems/Atom/RHI/Code/Platform/iOS/renderdoc_support_ios.cmake diff --git a/Gems/Atom/RHI/Code/CMakeLists.txt b/Gems/Atom/RHI/Code/CMakeLists.txt index 343736ff7c..a70786a9e0 100644 --- a/Gems/Atom/RHI/Code/CMakeLists.txt +++ b/Gems/Atom/RHI/Code/CMakeLists.txt @@ -11,19 +11,16 @@ ly_get_list_relative_pal_filename(pal_source_dir ${CMAKE_CURRENT_LIST_DIR}/Sourc include(${pal_dir}/AtomRHITests_traits_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) -set(LY_RENDERDOC_ENABLED OFF CACHE BOOL "Enable RenderDoc integration.") -set(RENDERDOC_CMAKE ${CMAKE_CURRENT_SOURCE_DIR}/${pal_dir}/renderdoc_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) -if(EXISTS ${RENDERDOC_CMAKE}) - include(${RENDERDOC_CMAKE}) -endif() - -if(LY_RENDERDOC_ENABLED AND TARGET "3rdParty::renderdoc") - message(STATUS "Renderdoc found, adding as runtime dependency") - set(USE_RENDERDOC_DEFINE "USE_RENDERDOC") - set(RENDERDOC_BUILD_DEPENDENCY "3rdParty::renderdoc") -else() - set(USE_RENDERDOC_DEFINE "") - set(RENDERDOC_BUILD_DEPENDENCY "") +include(${CMAKE_CURRENT_SOURCE_DIR}/${pal_dir}/renderdoc_support_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) +if(PAL_TRAIT_BUILD_RENDERDOC_SUPPORTED) + set(LY_RENDERDOC_ENABLED OFF CACHE BOOL "Enable RenderDoc integration. Use LY_RENDERDOC_PATH to specific the path to RenderDoc.") + if(LY_RENDERDOC_ENABLED) + include(${CMAKE_CURRENT_SOURCE_DIR}/${pal_dir}/renderdoc_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) + if(PAL_TRAIT_BUILD_RENDERDOC_ENABLED) + message(STATUS "Renderdoc found, adding as runtime dependency") + set(RENDERDOC_DEFINE USE_RENDERDOC) + endif() + endif() endif() ly_add_target( @@ -61,11 +58,11 @@ ly_add_target( AZ::AzCore AZ::AzFramework Gem::Atom_RHI.Reflect - PUBLIC - ${RENDERDOC_BUILD_DEPENDENCY} COMPILE_DEFINITIONS PUBLIC - ${USE_RENDERDOC_DEFINE} + ${RENDERDOC_DEFINE} + RUNTIME_DEPENDENCIES + ${RENDERDOC_RUNTIME_DEPENDENCIES} ) ly_add_target( diff --git a/Gems/Atom/RHI/Code/Platform/AppleTV/AtomRHITests_traits_appletv.cmake b/Gems/Atom/RHI/Code/Platform/Android/renderdoc_support_android.cmake similarity index 69% rename from Gems/Atom/RHI/Code/Platform/AppleTV/AtomRHITests_traits_appletv.cmake rename to Gems/Atom/RHI/Code/Platform/Android/renderdoc_support_android.cmake index 1aeb95c7b1..97090b9144 100644 --- a/Gems/Atom/RHI/Code/Platform/AppleTV/AtomRHITests_traits_appletv.cmake +++ b/Gems/Atom/RHI/Code/Platform/Android/renderdoc_support_android.cmake @@ -6,5 +6,4 @@ # # -set(ATOM_RHI_TRAIT_BUILD_SUPPORTS_TEST FALSE) -set(ATOM_RHI_TRAIT_BUILD_SUPPORTS_EDIT FALSE) +set(PAL_TRAIT_BUILD_RENDERDOC_SUPPORTED FALSE) diff --git a/Gems/Atom/RHI/Code/Platform/Linux/renderdoc_linux.cmake b/Gems/Atom/RHI/Code/Platform/Linux/renderdoc_linux.cmake index 222a3d5768..aae720eb0f 100644 --- a/Gems/Atom/RHI/Code/Platform/Linux/renderdoc_linux.cmake +++ b/Gems/Atom/RHI/Code/Platform/Linux/renderdoc_linux.cmake @@ -6,24 +6,13 @@ # # -# Prevent bundling the renderdoc dll with a packaged title -if(NOT LY_MONOLITHIC_GAME) - if(DEFINED ENV{"ATOM_RENDERDOC_PATH"}) - set(RENDERDOC_PATH ENV{"ATOM_RENDERDOC_PATH"}) - endif() +set(PAL_TRAIT_BUILD_RENDERDOC_ENABLED FALSE) +set(LY_RENDERDOC_PATH "/usr/local" CACHE PATH "Path to RenderDoc.") - if(RENDERDOC_PATH) - # Normalize file path - file(TO_CMAKE_PATH "${RENDERDOC_PATH}" RENDERDOC_PATH) +# Normalize file path +file(TO_CMAKE_PATH "${LY_RENDERDOC_PATH}" LY_RENDERDOC_PATH) - if(EXISTS "${RENDERDOC_PATH}/librenderdoc.so") - ly_add_external_target( - NAME renderdoc - VERSION - 3RDPARTY_ROOT_DIRECTORY ${RENDERDOC_PATH} - INCLUDE_DIRECTORIES "." - RUNTIME_DEPENDENCIES "${RENDERDOC_PATH}/librenderdoc.so" - ) - endif() - endif() -endif() \ No newline at end of file +if(EXISTS "${LY_RENDERDOC_PATH}/librenderdoc.so") + set(RENDERDOC_RUNTIME_DEPENDENCIES "${RENDERDOC_PATH}/librenderdoc.so") + set(PAL_TRAIT_BUILD_RENDERDOC_ENABLED TRUE) +endif() diff --git a/Gems/Atom/RHI/Code/Platform/Linux/renderdoc_support_linux.cmake b/Gems/Atom/RHI/Code/Platform/Linux/renderdoc_support_linux.cmake new file mode 100644 index 0000000000..449593c791 --- /dev/null +++ b/Gems/Atom/RHI/Code/Platform/Linux/renderdoc_support_linux.cmake @@ -0,0 +1,14 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +# Prevent bundling the renderdoc dll with a packaged title +if(LY_MONOLITHIC_GAME) + set(PAL_TRAIT_BUILD_RENDERDOC_SUPPORTED FALSE) +else() + set(PAL_TRAIT_BUILD_RENDERDOC_SUPPORTED TRUE) +endif() diff --git a/Gems/Atom/RHI/Code/Platform/Mac/renderdoc_support_mac.cmake b/Gems/Atom/RHI/Code/Platform/Mac/renderdoc_support_mac.cmake new file mode 100644 index 0000000000..97090b9144 --- /dev/null +++ b/Gems/Atom/RHI/Code/Platform/Mac/renderdoc_support_mac.cmake @@ -0,0 +1,9 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(PAL_TRAIT_BUILD_RENDERDOC_SUPPORTED FALSE) diff --git a/Gems/Atom/RHI/Code/Platform/Windows/renderdoc_support_windows.cmake b/Gems/Atom/RHI/Code/Platform/Windows/renderdoc_support_windows.cmake new file mode 100644 index 0000000000..449593c791 --- /dev/null +++ b/Gems/Atom/RHI/Code/Platform/Windows/renderdoc_support_windows.cmake @@ -0,0 +1,14 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +# Prevent bundling the renderdoc dll with a packaged title +if(LY_MONOLITHIC_GAME) + set(PAL_TRAIT_BUILD_RENDERDOC_SUPPORTED FALSE) +else() + set(PAL_TRAIT_BUILD_RENDERDOC_SUPPORTED TRUE) +endif() diff --git a/Gems/Atom/RHI/Code/Platform/Windows/renderdoc_windows.cmake b/Gems/Atom/RHI/Code/Platform/Windows/renderdoc_windows.cmake index 90c44bcb7c..2d3c2c039f 100644 --- a/Gems/Atom/RHI/Code/Platform/Windows/renderdoc_windows.cmake +++ b/Gems/Atom/RHI/Code/Platform/Windows/renderdoc_windows.cmake @@ -6,26 +6,13 @@ # # -# Prevent bundling the renderdoc dll with a packaged title -if(NOT LY_MONOLITHIC_GAME) - # Common installation path for renderdoc path - set(RENDERDOC_PATH "$ENV{PROGRAMFILES}/RenderDoc") - if(DEFINED ENV{"ATOM_RENDERDOC_PATH"}) - set(RENDERDOC_PATH ENV{"ATOM_RENDERDOC_PATH"}) - endif() +set(PAL_TRAIT_BUILD_RENDERDOC_ENABLED FALSE) +set(LY_RENDERDOC_PATH "$ENV{PROGRAMFILES}/RenderDoc" CACHE PATH "Path to RenderDoc.") - if(RENDERDOC_PATH) - # Normalize file path - file(TO_CMAKE_PATH "${RENDERDOC_PATH}" RENDERDOC_PATH) +# Normalize file path +file(TO_CMAKE_PATH "${LY_RENDERDOC_PATH}" LY_RENDERDOC_PATH) - if(EXISTS "${RENDERDOC_PATH}/renderdoc.dll") - ly_add_external_target( - NAME renderdoc - VERSION - 3RDPARTY_ROOT_DIRECTORY ${RENDERDOC_PATH} - INCLUDE_DIRECTORIES "." - RUNTIME_DEPENDENCIES "${RENDERDOC_PATH}/renderdoc.dll" - ) - endif() - endif() -endif() \ No newline at end of file +if(EXISTS "${LY_RENDERDOC_PATH}/renderdoc.dll") + set(RENDERDOC_RUNTIME_DEPENDENCIES "${RENDERDOC_PATH}/renderdoc.dll") + set(PAL_TRAIT_BUILD_RENDERDOC_ENABLED TRUE) +endif() diff --git a/Gems/Atom/RHI/Code/Platform/iOS/renderdoc_support_ios.cmake b/Gems/Atom/RHI/Code/Platform/iOS/renderdoc_support_ios.cmake new file mode 100644 index 0000000000..97090b9144 --- /dev/null +++ b/Gems/Atom/RHI/Code/Platform/iOS/renderdoc_support_ios.cmake @@ -0,0 +1,9 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(PAL_TRAIT_BUILD_RENDERDOC_SUPPORTED FALSE)