From 141cb55903a98ac1f52d9946cf612e9b5e945e51 Mon Sep 17 00:00:00 2001 From: bosnichd Date: Fri, 10 Sep 2021 13:12:45 -0600 Subject: [PATCH] Fix issue #4045 (#4053) * Remove unused Vulkan ShaderDescriptor class. Signed-off-by: bosnichd * Add missing dependency on Gem::Atom_RHI.Public Signed-off-by: bosnichd * Revert changes made to Gems/Atom/RHI/Vulkan/Code/* in https://github.com/o3de/o3de/pull/4021, and instead just check a trait to determine whether the RHI Vulkan targets have been defined else where. Gems/Atom/RHI/Vulkan/Code/CMakeLists.txt maybe needs to be revisited at some point, but my changes are causing numerous issues on mac so this just restores the prior behavior for all platforms while also providing a mechanism for any platform to simply define exactly what Vulkan related targets it needs independently. Signed-off-by: bosnichd --- Gems/Atom/RHI/Vulkan/Code/CMakeLists.txt | 9 +-- .../RHI.Reflect/Vulkan/ShaderDescriptor.h | 57 ------------------ .../ModuleStub_Unimplemented.cpp | 9 +-- .../Source/RHI.Reflect/ShaderDescriptor.cpp | 59 ------------------- .../RHI/Vulkan/Code/Source/RHI/ShaderModule.h | 2 - ...atom_rhi_vulkan_reflect_common_files.cmake | 2 - 6 files changed, 6 insertions(+), 132 deletions(-) delete mode 100644 Gems/Atom/RHI/Vulkan/Code/Include/Atom/RHI.Reflect/Vulkan/ShaderDescriptor.h delete mode 100644 Gems/Atom/RHI/Vulkan/Code/Source/RHI.Reflect/ShaderDescriptor.cpp diff --git a/Gems/Atom/RHI/Vulkan/Code/CMakeLists.txt b/Gems/Atom/RHI/Vulkan/Code/CMakeLists.txt index 5c74852f57..fb13d1fddb 100644 --- a/Gems/Atom/RHI/Vulkan/Code/CMakeLists.txt +++ b/Gems/Atom/RHI/Vulkan/Code/CMakeLists.txt @@ -9,7 +9,11 @@ ly_get_list_relative_pal_filename(pal_include_dir ${CMAKE_CURRENT_LIST_DIR}/Include/Platform/${PAL_PLATFORM_NAME}) ly_get_list_relative_pal_filename(pal_source_dir ${CMAKE_CURRENT_LIST_DIR}/Source/Platform/${PAL_PLATFORM_NAME}) -include(${pal_source_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) # PAL_TRAIT_ATOM_RHI_VULKAN_SUPPORTED +include(${pal_source_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) # PAL_TRAIT_ATOM_RHI_VULKAN_SUPPORTED / PAL_TRAIT_ATOM_RHI_VULKAN_TARGETS_ALREADY_DEFINED + +if(PAL_TRAIT_ATOM_RHI_VULKAN_TARGETS_ALREADY_DEFINED) + return() # Vulkan targets already defined in PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake +endif() if(NOT PAL_TRAIT_ATOM_RHI_VULKAN_SUPPORTED) @@ -19,12 +23,9 @@ if(NOT PAL_TRAIT_ATOM_RHI_VULKAN_SUPPORTED) NAMESPACE Gem FILES_CMAKE atom_rhi_vulkan_stub_module.cmake - atom_rhi_vulkan_reflect_common_files.cmake INCLUDE_DIRECTORIES PRIVATE - Include Source - ${pal_include_dir} Include/Atom/RHI.Loader/Glad BUILD_DEPENDENCIES PRIVATE diff --git a/Gems/Atom/RHI/Vulkan/Code/Include/Atom/RHI.Reflect/Vulkan/ShaderDescriptor.h b/Gems/Atom/RHI/Vulkan/Code/Include/Atom/RHI.Reflect/Vulkan/ShaderDescriptor.h deleted file mode 100644 index b432dcf0cb..0000000000 --- a/Gems/Atom/RHI/Vulkan/Code/Include/Atom/RHI.Reflect/Vulkan/ShaderDescriptor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 - * - */ -#pragma once - -#include -#include -#include -#include -#include - -namespace AZ -{ - class ReflectContext; - - namespace Vulkan - { - using ShaderByteCode = AZStd::vector; - - // TODO: remove this class after checking it is no longer necessary. - class ShaderDescriptor final - : public RHI::Object - { - using Base = RHI::Object; - public: - AZ_CLASS_ALLOCATOR(ShaderDescriptor, AZ::SystemAllocator, 0); - AZ_RTTI(ShaderDescriptor, "EB289A24-52DF-45E5-B3D0-C33B6DBAAAA7", Base); - - static void Reflect(AZ::ReflectContext* context); - - /// Clears all bytecodes and resets descriptor - void Clear(); - - /// Finalizes the descriptor and builds the hash value. - void Finalize(); - - /// Assigns bytecode to a specific shader stage. - void SetByteCode(RHI::ShaderStage shaderStage, const ShaderByteCode& bytecode); - - /// Returns whether bytecode exists for the given shader stage. - bool HasByteCode(RHI::ShaderStage shaderStage) const; - - /// Returns the bytecode for the given shader stage. - const ShaderByteCode& GetByteCode(RHI::ShaderStage shaderStage) const; - - private: - /// The set of shader bytecodes indexed by shader stage. - AZStd::array(RHI::ShaderStage::GraphicsCount)> m_byteCodesByStage; - size_t m_hash = 0; - }; - - } -} diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/Platform/Common/Unimplemented/ModuleStub_Unimplemented.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/Platform/Common/Unimplemented/ModuleStub_Unimplemented.cpp index 44a8a26968..8c06700404 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/Platform/Common/Unimplemented/ModuleStub_Unimplemented.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/Platform/Common/Unimplemented/ModuleStub_Unimplemented.cpp @@ -5,8 +5,6 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - -#include #include namespace AZ @@ -19,12 +17,7 @@ namespace AZ public: AZ_RTTI(PlatformModule, "{958CB096-796C-42C7-9B29-17C6FE792C30}", Module); - PlatformModule() - { - m_descriptors.insert(m_descriptors.end(), { - ReflectSystemComponent::CreateDescriptor() - }); - } + PlatformModule() = default; ~PlatformModule() override = default; AZ::ComponentTypeList GetRequiredSystemComponents() const override diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI.Reflect/ShaderDescriptor.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI.Reflect/ShaderDescriptor.cpp deleted file mode 100644 index b82d72a98c..0000000000 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI.Reflect/ShaderDescriptor.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 - * - */ -#include -#include - -namespace AZ -{ - namespace Vulkan - { - void ShaderDescriptor::Reflect(AZ::ReflectContext* context) - { - if (SerializeContext* serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Version(1) - ->Field("m_byteCodesByStage", &ShaderDescriptor::m_byteCodesByStage); - } - } - - void ShaderDescriptor::Clear() - { - m_hash = 0; - m_byteCodesByStage.fill(ShaderByteCode()); - } - - void ShaderDescriptor::Finalize() - { - AZ::Crc32 crc; - for (const ShaderByteCode& byteCode : m_byteCodesByStage) - { - if (!byteCode.empty()) - { - crc.Add(byteCode.data(), byteCode.size()); - } - } - m_hash = crc; - } - - void ShaderDescriptor::SetByteCode(RHI::ShaderStage shaderStage, const ShaderByteCode& bytecode) - { - m_byteCodesByStage[static_cast(shaderStage)] = bytecode; - } - - bool ShaderDescriptor::HasByteCode(RHI::ShaderStage shaderStage) const - { - return !(m_byteCodesByStage[static_cast(shaderStage)].empty()); - } - - const ShaderByteCode& ShaderDescriptor::GetByteCode(RHI::ShaderStage shaderStage) const - { - return m_byteCodesByStage[static_cast(shaderStage)]; - } - } -} diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/ShaderModule.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/ShaderModule.h index 244a1c1b82..74632e4539 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/ShaderModule.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/ShaderModule.h @@ -9,8 +9,6 @@ #include #include -#include -#include #include namespace AZ diff --git a/Gems/Atom/RHI/Vulkan/Code/atom_rhi_vulkan_reflect_common_files.cmake b/Gems/Atom/RHI/Vulkan/Code/atom_rhi_vulkan_reflect_common_files.cmake index 8965cd054d..92c22ddfc5 100644 --- a/Gems/Atom/RHI/Vulkan/Code/atom_rhi_vulkan_reflect_common_files.cmake +++ b/Gems/Atom/RHI/Vulkan/Code/atom_rhi_vulkan_reflect_common_files.cmake @@ -11,8 +11,6 @@ set(FILES Include/Atom/RHI.Reflect/Vulkan/BufferPoolDescriptor.h Source/RHI.Reflect/ImagePoolDescriptor.cpp Include/Atom/RHI.Reflect/Vulkan/ImagePoolDescriptor.h - Source/RHI.Reflect/ShaderDescriptor.cpp - Include/Atom/RHI.Reflect/Vulkan/ShaderDescriptor.h Source/RHI.Reflect/ShaderStageFunction.cpp Include/Atom/RHI.Reflect/Vulkan/ShaderStageFunction.h Source/RHI.Reflect/ReflectSystemComponent.cpp