diff --git a/Code/Framework/AtomCore/AtomCore/atomcore_files.cmake b/Code/Framework/AtomCore/AtomCore/atomcore_files.cmake index 9167c1e645..827d26ecf5 100644 --- a/Code/Framework/AtomCore/AtomCore/atomcore_files.cmake +++ b/Code/Framework/AtomCore/AtomCore/atomcore_files.cmake @@ -13,7 +13,6 @@ set(FILES Instance/InstanceData.h Instance/InstanceData.cpp Instance/InstanceDatabase.h - std/containers/array_view.h std/containers/fixed_vector_set.h std/containers/lru_cache.h std/containers/vector_set.h diff --git a/Code/Framework/AtomCore/AtomCore/std/containers/array_view.h b/Code/Framework/AtomCore/AtomCore/std/containers/array_view.h deleted file mode 100644 index 522b69bf9b..0000000000 --- a/Code/Framework/AtomCore/AtomCore/std/containers/array_view.h +++ /dev/null @@ -1,156 +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 - -namespace AZStd -{ - /** - * Immutable wrapper for an array of data. It does not maintain storage for the data, - * but just holds pointers to mark the beginning and end of the array. It can be - * conveniently constructed from a variety of other container types like array, - * vector, and fixed_vector. - * - * Example: - * Given "void Func(AZStd::array_view a) {...}" you can call... - * - Func({1,2,3}); - * - AZStd::array a = {1,2,3}; - * Func(a); - * - AZStd::vector v = {1,2,3}; - * Func(v); - * - AZStd::fixed_vector fv = {1,2,3}; - * Func(fv); - * - * Since the array_view does not copy and store any data, it is only valid as long as the data used to create it is valid. - */ - template - class array_view final - { - public: - using value_type = Element; - - using pointer = value_type*; - using const_pointer = const value_type*; - - using reference = value_type&; - using const_reference = const value_type&; - - using size_type = AZStd::size_t; - using difference_type = AZStd::ptrdiff_t; - - using iterator = const value_type*; - using const_iterator = const value_type*; - using reverse_iterator = AZStd::reverse_iterator; - using const_reverse_iterator = AZStd::reverse_iterator; - - array_view() - : m_begin(nullptr) - , m_end(nullptr) - { } - - ~array_view() = default; - - array_view(const_pointer s, size_type length) - : m_begin(s) - , m_end(m_begin + length) - { - if (length == 0) erase(); - } - - array_view(const_pointer first, const_pointer last) - : m_begin(first) - , m_end(last) - { } - - // We explicitly delete this constructor because it's too easy to accidentally - // create an array_view to just the first element instead of an entire array. - array_view(const_pointer s) = delete; - - template - array_view(const AZStd::array& data) - : m_begin(data.data()) - , m_end(m_begin + data.size()) - { } - - array_view(const AZStd::vector& data) - : m_begin(data.data()) - , m_end(m_begin + data.size()) - { } - - template - array_view(const AZStd::fixed_vector& data) - : m_begin(data.data()) - , m_end(m_begin + data.size()) - { } - - array_view(const array_view&) = default; - - array_view(array_view&& other) - : array_view(other.m_begin, other.m_end) - { -#if AZ_DEBUG_BUILD // Clearing the original pointers isn't necessary, but is good for debugging - other.m_begin = nullptr; - other.m_end = nullptr; -#endif - } - - array_view& operator=(const array_view& other) = default; - - array_view& operator=(array_view&& other) - { - m_begin = other.m_begin; - m_end = other.m_end; -#if AZ_DEBUG_BUILD // Clearing the original pointers isn't necessary, but is good for debugging - other.m_begin = nullptr; - other.m_end = nullptr; -#endif - return *this; - } - - size_type size() const { return m_end - m_begin; } - - bool empty() const { return m_end == m_begin; } - - const_pointer data() const { return m_begin; } - - const_reference operator[](size_type index) const - { - AZ_Assert(index < size(), "index value is out of range"); - return m_begin[index]; - } - - void erase() { m_begin = m_end = nullptr; } - - iterator begin() const { return m_begin; } - iterator end() const { return m_end; } - const_iterator cbegin() const { return m_begin; } - const_iterator cend() const { return m_end; } - reverse_iterator rbegin() const { return reverse_iterator(m_end); } - reverse_iterator rend() const { return reverse_iterator(m_begin); } - const_reverse_iterator crbegin() const { return const_reverse_iterator(cend()); } - const_reverse_iterator crend() const { return const_reverse_iterator(cbegin()); } - - friend bool operator==(array_view lhs, array_view rhs) - { - return lhs.m_begin == rhs.m_begin && lhs.m_end == rhs.m_end; - } - - friend bool operator!=(array_view lhs, array_view rhs) { return !(lhs == rhs); } - friend bool operator< (array_view lhs, array_view rhs) { return lhs.m_begin < rhs.m_begin || lhs.m_begin == rhs.m_begin && lhs.m_end < rhs.m_end; } - friend bool operator> (array_view lhs, array_view rhs) { return lhs.m_begin > rhs.m_begin || lhs.m_begin == rhs.m_begin && lhs.m_end > rhs.m_end; } - friend bool operator<=(array_view lhs, array_view rhs) { return lhs == rhs || lhs < rhs; } - friend bool operator>=(array_view lhs, array_view rhs) { return lhs == rhs || lhs > rhs; } - - private: - const_pointer m_begin; - const_pointer m_end; - }; -} // namespace AZStd diff --git a/Code/Framework/AtomCore/Tests/ArrayView.cpp b/Code/Framework/AtomCore/Tests/ArrayView.cpp deleted file mode 100644 index f0208ced3b..0000000000 --- a/Code/Framework/AtomCore/Tests/ArrayView.cpp +++ /dev/null @@ -1,300 +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 -#include - -namespace UnitTest -{ - using namespace AZStd; - - class ArrayView : public AllocatorsTestFixture - { - protected: - template - void ExpectEqual(initializer_list expectedValues, array_view arrayView) - { - EXPECT_EQ(false, arrayView.empty()); - EXPECT_EQ(expectedValues.size(), arrayView.size()); - - typename AZStd::vector::const_iterator iterator = arrayView.begin(); - - for (int i = 0; i < expectedValues.size(); ++i, ++iterator) - { - EXPECT_EQ(expectedValues.begin()[i], arrayView[i]); - EXPECT_EQ(expectedValues.begin()[i], *iterator); - } - - EXPECT_EQ(iterator, arrayView.end()); - } - }; - - TEST_F(ArrayView, DefaultConstructor) - { - array_view defaultView; - - EXPECT_EQ(nullptr, defaultView.begin()); - EXPECT_EQ(nullptr, defaultView.end()); - EXPECT_EQ(0, defaultView.size()); - EXPECT_EQ(true, defaultView.empty()); - } - - TEST_F(ArrayView, PointerConstructor1) - { - int originalValues[4] = { 2,3,4,5 }; - array_view view(originalValues, AZ_ARRAY_SIZE(originalValues)); - - ExpectEqual({ 2,3,4,5 }, view); - - EXPECT_EQ(originalValues, view.begin()); - EXPECT_EQ(&originalValues[4], view.end()); - } - - TEST_F(ArrayView, PointerConstructor2) - { - int originalValues[3] = { 6,7,8 }; - array_view view(originalValues, &originalValues[3]); - - ExpectEqual({ 6,7,8 }, view); - - EXPECT_EQ(originalValues, view.begin()); - EXPECT_EQ(&originalValues[3], view.end()); - } - - TEST_F(ArrayView, ArrayConstructor) - { - array originalValues = { 9,10,11,12 }; - array_view view(originalValues); - - ExpectEqual({ 9,10,11,12 }, view); - - EXPECT_EQ(originalValues.begin(), view.begin()); - EXPECT_EQ(originalValues.end(), view.end()); - } - - - TEST_F(ArrayView, VectorConstructor) - { - vector originalValues = { 13,14,15,16,17,18 }; - array_view view(originalValues); - - ExpectEqual({ 13,14,15,16,17,18 }, view); - - EXPECT_EQ(originalValues.begin(), view.begin()); - EXPECT_EQ(originalValues.end(), view.end()); - } - - TEST_F(ArrayView, FixedVectorConstructor) - { - fixed_vector originalValues = { 17,18,19 }; // Note that even though the fixed_vector capacity is 10, it's size is 3, so the view size will be 3 as well - array_view view(originalValues); - - ExpectEqual({ 17,18,19 }, view); - - EXPECT_EQ(originalValues.begin(), view.begin()); - EXPECT_EQ(originalValues.end(), view.end()); - } - - TEST_F(ArrayView, CopyConstructor) - { - fixed_vector originalValues = { 27,28 }; - - array_view view1(originalValues); - array_view view2(view1); - - ExpectEqual({ 27,28 }, view2); - - EXPECT_EQ(view1.begin(), view2.begin()); - EXPECT_EQ(view1.end(), view2.end()); - } - - TEST_F(ArrayView, MoveConstructor) - { - int originalValues[] = { 29,30,31 }; - array_view view1(originalValues, AZ_ARRAY_SIZE(originalValues)); - array_view view2(AZStd::move(view1)); - - ExpectEqual({ 29,30,31 }, view2); - - EXPECT_EQ(originalValues, view2.begin()); - EXPECT_EQ(&originalValues[3], view2.end()); - - // This isn't strictly necessary but is a good way to make sure the move - // constructor actually exists and it itn't just calling the copy constructor -#if AZ_DEBUG_BUILD // The pointers are only cleared in debug - EXPECT_EQ(nullptr, view1.begin()); - EXPECT_EQ(nullptr, view1.end()); -#endif - } - - TEST_F(ArrayView, AssignmentOperator) - { - fixed_vector originalValues = { 32,33,34,35 }; - - array_view view1(originalValues); - array_view view2; - - view2 = view1; - - ExpectEqual({ 32,33,34,35 }, view2); - - EXPECT_EQ(view1.begin(), view2.begin()); - EXPECT_EQ(view1.end(), view2.end()); - } - - TEST_F(ArrayView, MoveAssignmentOperator) - { - int originalValues[] = { 36,37,38,39,40 }; - array_view view1(originalValues, AZ_ARRAY_SIZE(originalValues)); - array_view view2; - view2 = AZStd::move(view1); - - ExpectEqual({ 36,37,38,39,40 }, view2); - - EXPECT_EQ(originalValues, view2.begin()); - EXPECT_EQ(&originalValues[5], view2.end()); - - // This isn't strictly necessary but is a good way to make sure the move - // assignment operator actually exists and it itn't just calling the norm - // assignment operator -#if AZ_DEBUG_BUILD // The pointers are only cleared in debug - EXPECT_EQ(nullptr, view1.begin()); - EXPECT_EQ(nullptr, view1.end()); -#endif - } - - TEST_F(ArrayView, Erase) - { - fixed_vector originalValues = { 1,2,3,4 }; - - array_view view(originalValues); - view.erase(); - - EXPECT_EQ(nullptr, view.begin()); - EXPECT_EQ(nullptr, view.end()); - EXPECT_EQ(0, view.size()); - EXPECT_EQ(true, view.empty()); - } - - TEST_F(ArrayView, BeginAndEnd) - { - fixed_vector originalValues = { 1,2,3,4 }; - - array_view view(originalValues); - - EXPECT_EQ(1, view.begin()[0]); - EXPECT_EQ(4, view.end()[-1]); - EXPECT_EQ(1, view.cbegin()[0]); - EXPECT_EQ(4, view.cend()[-1]); - EXPECT_EQ(4, view.rbegin()[0]); - EXPECT_EQ(1, view.rend()[-1]); - EXPECT_EQ(4, view.crbegin()[0]); - EXPECT_EQ(1, view.crend()[-1]); - } - - TEST_F(ArrayView, ImplicitConstruction) - { - // This test verifies that we can pass in various non-array_view types - // into functions that take an array_view - - // The compile cannot detect the correct template type so that has to be specified explicitly - - ExpectEqual({ 1,2,3 }, vector({ 1,2,3 })); - ExpectEqual({ 1,2,3 }, fixed_vector({ 1,2,3 })); - ExpectEqual({ 1,2,3 }, array({ 1,2,3 })); - } - - void CheckComparisonOperators(bool areEqual, array_view a, array_view b) - { - EXPECT_EQ(areEqual, a == b); - - // For less/greater operators, the exact order doesn't really matter; - // We just check for internal consistency - if (areEqual) - { - EXPECT_EQ(false, a != b); - EXPECT_EQ(false, a < b); - EXPECT_EQ(false, a > b); - EXPECT_EQ(true, a <= b); - EXPECT_EQ(true, a >= b); - } - else - { - EXPECT_EQ(true, a != b); - - EXPECT_EQ(a > b, a >= b); - EXPECT_EQ(a < b, a <= b); - - EXPECT_NE(a > b, a < b); - EXPECT_NE(a >= b, a <= b); - EXPECT_NE(a >= b, a < b); - EXPECT_NE(a > b, a <= b); - EXPECT_NE(a <= b, a > b); - EXPECT_NE(a < b, a >= b); - } - } - - TEST_F(ArrayView, ComparisonOperators) - { - int arrayA[] = { 1,2,3 }; - int arrayB[] = { 1,2,3 }; - - array_view arrayA_view(arrayA, 3); - array_view arrayB_view(arrayB, 3); - array_view arrayA_otherView(arrayA, 3); - // view of a sub-array aligned to the beginning of the array - array_view arrayA_headView(arrayA, 2); - array_view arrayB_headView(arrayB, 2); - // view of a sub-array aligned to the end of the array - array_view arrayA_tailView(&arrayA[1], 2); - array_view arrayB_tailView(&arrayB[1], 2); - // view of a sub-array in the middle of the array - array_view arrayA_centerView(&arrayA[1], 1); - array_view arrayB_centerView(&arrayB[1], 1); - - // Same view - CheckComparisonOperators(true, arrayA_view, arrayA_view); - - // Different view, same array - CheckComparisonOperators(true, arrayA_view, arrayA_otherView); - CheckComparisonOperators(true, arrayA_otherView, arrayA_view); - - // Different arrays - CheckComparisonOperators(false, arrayA_view, arrayB_view); - CheckComparisonOperators(false, arrayB_view, arrayA_view); - - // Same arrays, but one is a just a subset of the array - CheckComparisonOperators(false, arrayA_view, arrayA_headView); - CheckComparisonOperators(false, arrayA_view, arrayA_tailView); - CheckComparisonOperators(false, arrayA_view, arrayA_centerView); - CheckComparisonOperators(false, arrayA_headView, arrayA_view); - CheckComparisonOperators(false, arrayA_tailView, arrayA_view); - CheckComparisonOperators(false, arrayA_centerView, arrayA_view); - - // Different arrays, different lengths - CheckComparisonOperators(false, arrayA_view, arrayB_headView); - CheckComparisonOperators(false, arrayB_view, arrayA_headView); - CheckComparisonOperators(false, arrayB_headView, arrayA_view); - CheckComparisonOperators(false, arrayA_headView, arrayB_view); - } - - TEST_F(ArrayView, AssertOutOfBounds) - { - array_view view({ 1,2,3,4 }); - - AZ_TEST_START_TRACE_SUPPRESSION; - - view[4]; - view[5]; - - AZ_TEST_STOP_TRACE_SUPPRESSION(2); - } - -} diff --git a/Code/Framework/AtomCore/Tests/atomcore_tests_files.cmake b/Code/Framework/AtomCore/Tests/atomcore_tests_files.cmake index 4522a4b7b6..c518371e8d 100644 --- a/Code/Framework/AtomCore/Tests/atomcore_tests_files.cmake +++ b/Code/Framework/AtomCore/Tests/atomcore_tests_files.cmake @@ -7,7 +7,6 @@ # set(FILES - ArrayView.cpp ConcurrencyCheckerTests.cpp InstanceDatabase.cpp lru_cache.cpp diff --git a/Code/Framework/AzCore/AzCore/std/containers/span.h b/Code/Framework/AzCore/AzCore/std/containers/span.h index d0ac704fc3..807d87e634 100644 --- a/Code/Framework/AzCore/AzCore/std/containers/span.h +++ b/Code/Framework/AzCore/AzCore/std/containers/span.h @@ -42,12 +42,11 @@ namespace AZStd::Internal namespace AZStd { /** - * First pass partial implementation of span copied over from array_view. It - * returns non-const iterator/pointers. first(), last(), and subspan() - * are yet to be implemented. It does not maintain storage for the data, - * but just holds pointers to mark the beginning and end of the array. - * It can be conveniently constructed from a variety of other container - * types like array, vector, and fixed_vector. + * Full C++20 implementation of span done using the C++ draft at https://eel.is/c++draft/views. + * It does not maintain storage for the data, + * but just hold a pointer to mark the beginning and the size for the elements. + * It can be constructed any type that models the C++ contiguous_range concept + * such like array, vector, fixed_vector, raw-array, string_view, string, etc... . * * Example: * Given "void Func(AZStd::span a) {...}" you can call... @@ -84,7 +83,7 @@ namespace AZStd inline static constexpr size_t extent = Extent; - constexpr span() noexcept = default;; + constexpr span() noexcept = default; ~span() = default; @@ -110,12 +109,12 @@ namespace AZStd Extent != dynamic_extent, int> = 0> constexpr explicit span(It first, End last); - template> + template> constexpr span(type_identity_t (&arr)[N]) noexcept; - template > + template > constexpr span(array& data) noexcept; - template > + template > constexpr span(const array& data) noexcept; template && diff --git a/Code/Framework/AzCore/Tests/AZStd/SpanTests.cpp b/Code/Framework/AzCore/Tests/AZStd/SpanTests.cpp index f9861ae1f2..6fe0704491 100644 --- a/Code/Framework/AzCore/Tests/AZStd/SpanTests.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/SpanTests.cpp @@ -246,4 +246,16 @@ namespace UnitTest AZ_TEST_STOP_TRACE_SUPPRESSION(1); } } + + TEST_F(SpanTestFixture, CanInitializeFixedArrayToDynamicExtentSpan) + { + constexpr size_t arrayElementCount = 5; + static constexpr AZStd::array intArray{ 4, 5, 6, 1, 7 }; + + constexpr AZStd::span arraySpan(intArray); + static_assert(intArray.data() == arraySpan.data()); + + constexpr AZStd::span arraySpanFixedExtent(intArray); + static_assert(intArray.data() == arraySpanFixedExtent.data()); + } } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/Utils.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/Utils.cpp index 20e1b18e77..bcf330f7d3 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/Utils.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/Utils.cpp @@ -286,7 +286,7 @@ namespace ImageProcessingAtom for (u32 slice = 0; slice < arraySize; slice++) { - AZStd::array_view imageData = imageAsset->GetSubImageData(mip, slice); + AZStd::span imageData = imageAsset->GetSubImageData(mip, slice); memcpy(imageBuf + slice * imageData.size(), imageData.data(), imageData.size()); } } diff --git a/Gems/Atom/Asset/Shader/Code/Tests/SupervariantCmdArgumentTests.cpp b/Gems/Atom/Asset/Shader/Code/Tests/SupervariantCmdArgumentTests.cpp index da80b15d79..df7dbc3186 100644 --- a/Gems/Atom/Asset/Shader/Code/Tests/SupervariantCmdArgumentTests.cpp +++ b/Gems/Atom/Asset/Shader/Code/Tests/SupervariantCmdArgumentTests.cpp @@ -71,7 +71,7 @@ namespace UnitTest //! Helper function. //! Given an input list of {Key, Value} pairs returns a list of strings where each string is of the form: "Key=Value". - AZStd::vector CreateListOfStringsFromListOfKeyValues(AZStd::array_view listOfKeyValues) const + AZStd::vector CreateListOfStringsFromListOfKeyValues(AZStd::span listOfKeyValues) const { AZStd::vector listOfStrings; for (const auto& keyValue : listOfKeyValues) @@ -90,7 +90,7 @@ namespace UnitTest //! Helper function. //! Given an input list of {Key, Value} pairs returns a list of strings where each string is of the form: "Key1", "Value1", "Key2", "Value2". - AZStd::vector CreateListOfSingleStringsFromListOfKeyValues(AZStd::array_view listOfKeyValues) const + AZStd::vector CreateListOfSingleStringsFromListOfKeyValues(AZStd::span listOfKeyValues) const { AZStd::vector listOfStrings; for (const auto& keyValue : listOfKeyValues) @@ -134,7 +134,7 @@ namespace UnitTest //! Returns a command line string that results of concatenating the input list of {Key, Value} pairs (with '='). //! Example of a returned string: //! "key1=value1 key2 key3 key4=value" - AZStd::string CreateCmdLineStringFromListOfKeyValues(AZStd::array_view listOfKeyValues) const + AZStd::string CreateCmdLineStringFromListOfKeyValues(AZStd::span listOfKeyValues) const { AZStd::string cmdLineString; for (const auto& keyValueView : listOfKeyValues) @@ -148,7 +148,7 @@ namespace UnitTest //! Returns a command line string of macro definitions that results of concatenating the input list of {Key, Value} pairs. //! Example of a returned string: //! "-Dkey1=value1 -Dkey2 -Dkey3 -Dkey4=value" - AZStd::string CreateMacroDefinitionCmdLineStringFromListOfKeyValues(AZStd::array_view listOfKeyValues) const + AZStd::string CreateMacroDefinitionCmdLineStringFromListOfKeyValues(AZStd::span listOfKeyValues) const { AZStd::string cmdLineString; for (const auto& keyValueView : listOfKeyValues) @@ -161,7 +161,7 @@ namespace UnitTest //! @param includePaths A List of folder paths //! @param predefinedMacros A List of strings with format: "name[=value]" ShaderBuilder::PreprocessorOptions CreatePreprocessorOptions( - AZStd::array_view includePaths, AZStd::array_view predefinedMacros) const + AZStd::span includePaths, AZStd::span predefinedMacros) const { ShaderBuilder::PreprocessorOptions preprocessorOptions; @@ -200,8 +200,8 @@ namespace UnitTest //! @param azslcAdditionalFreeArguments A string representing series of command line arguments for AZSLc. //! @param dxcAdditionalFreeArguments: A string representing series of command line arguments for DXC. ShaderBuilder::GlobalBuildOptions CreateGlobalBuildOptions( - AZStd::array_view includePaths, - AZStd::array_view predefinedMacros, + AZStd::span includePaths, + AZStd::span predefinedMacros, AZStd::string_view azslcAdditionalFreeArguments, AZStd::string_view dxcAdditionalFreeArguments) const { @@ -227,7 +227,7 @@ namespace UnitTest return supervariantInfo; } - bool StringContainsAllSubstrings(AZStd::string_view haystack, AZStd::array_view substrings) + bool StringContainsAllSubstrings(AZStd::string_view haystack, AZStd::span substrings) { return AZStd::all_of(AZ_BEGIN_END(substrings), [&](AZStd::string_view needle) -> bool @@ -237,7 +237,7 @@ namespace UnitTest ); } - bool StringDoesNotContainAnyOneOfTheSubstrings(AZStd::string_view haystack, AZStd::array_view substrings) + bool StringDoesNotContainAnyOneOfTheSubstrings(AZStd::string_view haystack, AZStd::span substrings) { return AZStd::all_of(AZ_BEGIN_END(substrings), [&](AZStd::string_view needle) -> bool { return (haystack.find(needle) == AZStd::string::npos); @@ -247,7 +247,7 @@ namespace UnitTest //! @returns: True if all strings in @substring appear in @vectorOfString. //! @remark: Keep in mind that this is not the same as saying that all strings in @vectorOfStrings appear in @substrings. bool VectorContainsAllSubstrings( - AZStd::array_view vectorOfStrings, AZStd::array_view substrings) + AZStd::span vectorOfStrings, AZStd::span substrings) { return AZStd::all_of( AZ_BEGIN_END(substrings), @@ -264,7 +264,7 @@ namespace UnitTest } //! @returns: True only if None of the strings in @vectorOfStrings contains any of the strings in @substrings. - bool VectorDoesNotContainAnyOneOfTheSubstrings(AZStd::array_view vectorOfStrings, AZStd::array_view substrings) + bool VectorDoesNotContainAnyOneOfTheSubstrings(AZStd::span vectorOfStrings, AZStd::span substrings) { return AZStd::all_of(AZ_BEGIN_END(vectorOfStrings), [&](AZStd::string_view haystack) -> bool { return StringDoesNotContainAnyOneOfTheSubstrings(haystack, substrings); diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SkinnedMesh/SkinnedMeshInputBuffers.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SkinnedMesh/SkinnedMeshInputBuffers.h index c52bed8cf2..bb5f08c65e 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SkinnedMesh/SkinnedMeshInputBuffers.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SkinnedMesh/SkinnedMeshInputBuffers.h @@ -27,13 +27,13 @@ namespace AZ class BufferView; class IndexBufferView; } - + namespace RPI { class Model; class ShaderResourceGroup; } - + namespace Render { //! Info needed to create per-submesh views into the skinned mesh buffers so that the target skinned model can be broken into multiple sub-meshes. @@ -212,8 +212,8 @@ namespace AZ //! Get an individual lod const SkinnedMeshInputLod& GetLod(size_t lodIndex) const; - //! Get an array_view of the buffer views for all the input streams - AZStd::array_view> GetInputBufferViews(size_t lodIndex) const; + //! Get a span of the buffer views for all the input streams + AZStd::span> GetInputBufferViews(size_t lodIndex) const; //! Get the buffer view for a specific input stream AZ::RHI::Ptr GetInputBufferView(size_t lodIndex, uint8_t inputStream) const; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/IndexedDataVector.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/IndexedDataVector.h index b2d483e48c..5deecb990f 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/IndexedDataVector.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/IndexedDataVector.h @@ -8,7 +8,7 @@ #pragma once -#include +#include #include namespace AZ::Render diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/MultiIndexedDataVector.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/MultiIndexedDataVector.h index c0f11dd159..cc065680dc 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/MultiIndexedDataVector.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/MultiIndexedDataVector.h @@ -9,7 +9,7 @@ #pragma once #include -#include +#include namespace AZ { diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp index 5529a2916b..4a5ea4a112 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp @@ -71,7 +71,7 @@ namespace AZ } } - const AZStd::array_view CascadedShadowmapsPass::GetPipelineViewTags() + const AZStd::span CascadedShadowmapsPass::GetPipelineViewTags() { if (m_childrenPipelineViewTags.size() != Shadow::MaxNumberOfCascades) { @@ -181,7 +181,7 @@ namespace AZ RPI::Ptr CascadedShadowmapsPass::CreateChild(uint16_t cascadeIndex) { - const AZStd::array_view childrenViewTags = GetPipelineViewTags(); + const AZStd::span childrenViewTags = GetPipelineViewTags(); const Name passName{ AZStd::string::format("DirectionalLightShadowmapPass.%d", cascadeIndex) }; auto passData = AZStd::make_shared(); diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h index e673a77ddb..1f7acfadb2 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -36,7 +36,7 @@ namespace AZ void SetCameraViewName(const AZStd::string& viewName); //! This returns pipeline view tag for children. - const AZStd::array_view GetPipelineViewTags(); + const AZStd::span GetPipelineViewTags(); //! This exposes the shadowmap atlas. ShadowmapAtlas& GetShadowmapAtlas(); diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp index 5cf65adcee..1b8ad72a4c 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp @@ -1018,7 +1018,7 @@ namespace AZ for (const auto& passIt : m_cascadedShadowmapsPasses) { CascadedShadowmapsPass* shadowPass = passIt.second.front(); - const AZStd::array_view& viewTags = shadowPass->GetPipelineViewTags(); + const AZStd::span& viewTags = shadowPass->GetPipelineViewTags(); AZ_Assert(viewTags.size() >= cascadeCount, "DirectionalLightFeatureProcessor: There is not enough pipeline view tags."); RPI::RenderPipeline* pipeline = shadowPass->GetRenderPipeline(); diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/EsmShadowmapsPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/EsmShadowmapsPass.cpp index 553133aef7..722a8f3d23 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/EsmShadowmapsPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/EsmShadowmapsPass.cpp @@ -112,7 +112,7 @@ namespace AZ m_shadowmapImageSize = inputBinding.m_attachment->m_descriptor.m_image.m_size; m_shadowmapArraySize = inputBinding.m_attachment->m_descriptor.m_image.m_arraySize; - const AZStd::array_view>& children = GetChildren(); + const AZStd::span>& children = GetChildren(); AZ_Assert(children.size() == EsmChildPassKindCount, "[EsmShadowmapsPass '%s'] The count of children is wrong.", GetPathName().GetCStr()); for (uint32_t childPassIndex = 0; childPassIndex < EsmChildPassKindCount; ++childPassIndex) diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/EsmShadowmapsPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/EsmShadowmapsPass.h index 5a9898d507..3e4ec1735e 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/EsmShadowmapsPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/EsmShadowmapsPass.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h index dc7df7de78..cc99cdb8f1 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.cpp index 8e446435fa..69681110c9 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include namespace AZ @@ -114,14 +114,14 @@ namespace AZ } } - AZStd::array_view> DecalFeatureProcessor::GetImageArray() const + AZStd::span> DecalFeatureProcessor::GetImageArray() const { // [GFX TODO][ATOM-4445] Replace this hardcoded constant with atlasing / bindless so we can have far more than 8 decal textures // Note this constant also is defined in View.srg const size_t MaxDecals = 8; size_t numImages = AZStd::min(MaxDecals, m_decalData.GetDataCount()); - AZStd::array_view imageArrayView(m_decalData.GetDataVector<1>().begin(), m_decalData.GetDataVector<1>().begin() + numImages); + AZStd::span imageArrayView(m_decalData.GetDataVector<1>().begin(), m_decalData.GetDataVector<1>().begin() + numImages); return imageArrayView; } @@ -130,8 +130,8 @@ namespace AZ { AZ_PROFILE_SCOPE(RPI, "DecalFeatureProcessor: Render"); - AZStd::array_view> baseMaps = GetImagesFromDecalData<1>(); - AZStd::array_view> opacityMaps = GetImagesFromDecalData<2>(); + AZStd::span> baseMaps = GetImagesFromDecalData<1>(); + AZStd::span> opacityMaps = GetImagesFromDecalData<2>(); for (const RPI::ViewPtr& view : packet.m_views) { diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.h index f651b5cd2d..b2785b1770 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.h @@ -81,11 +81,11 @@ namespace AZ DecalFeatureProcessor(const DecalFeatureProcessor&) = delete; Data::Instance GetImageFromMaterial(const AZ::Name& mapName, Data::Instance materialInstance) const; - AZStd::array_view> GetImageArray() const; + AZStd::span> GetImageArray() const; void CacheShaderIndices(); template - AZStd::array_view> GetImagesFromDecalData(); + AZStd::span> GetImagesFromDecalData(); static constexpr const char* FeatureProcessorName = "DecalFeatureProcessor"; @@ -105,7 +105,7 @@ namespace AZ }; template - AZStd::array_view> + AZStd::span> AZ::Render::DecalFeatureProcessor::GetImagesFromDecalData() { // [GFX TODO][ATOM-4445] Replace this hardcoded constant with atlasing / bindless so we can have far more than 8 decal textures @@ -113,7 +113,7 @@ namespace AZ const size_t MaxDecals = 4; size_t numImages = AZStd::min(MaxDecals, m_decalData.GetDataCount()); - AZStd::array_view imageArrayView(m_decalData.GetDataVector().begin(), m_decalData.GetDataVector().begin() + numImages); + AZStd::span imageArrayView(m_decalData.GetDataVector().begin(), m_decalData.GetDataVector().begin() + numImages); return imageArrayView; } } // namespace Render diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArray.cpp b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArray.cpp index 56ff1648d4..d570990be0 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArray.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArray.cpp @@ -267,7 +267,7 @@ namespace AZ return AZ::RHI::GetImageSubresourceLayout(mipSize, descriptor.m_format); } - AZStd::array_view DecalTextureArray::GetRawImageData(const AZ::Name& mapName, int arrayLevel, const int mip) const + AZStd::span DecalTextureArray::GetRawImageData(const AZ::Name& mapName, int arrayLevel, const int mip) const { // We always want to provide valid data to the AssetCreator for each texture. // If this spot in the array is empty, just provide some random image as filler. diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArray.h b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArray.h index 39e66176fd..a9bf994aac 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArray.h +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArray.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include @@ -81,7 +81,7 @@ namespace AZ RHI::Size GetImageDimensions(const DecalMapType mapType) const; RHI::Format GetFormat(const DecalMapType mapType) const; RHI::ImageSubresourceLayout GetLayout(const DecalMapType mapType, int mip) const; - AZStd::array_view GetRawImageData(const AZ::Name& mapName, int arrayLevel, int mip) const; + AZStd::span GetRawImageData(const AZ::Name& mapName, int arrayLevel, int mip) const; bool AreAllAssetsReady() const; bool IsAssetReady(const MaterialData& materialData) const; diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp index c6b4d4e754..681a316b91 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 6b9a3fc698..1aa79d1945 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -772,7 +772,7 @@ namespace AZ return; } - const AZStd::array_view>& modelLods = m_model->GetLods(); + const AZStd::span>& modelLods = m_model->GetLods(); if (modelLods.empty()) { return; diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshDispatchItem.cpp b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshDispatchItem.cpp index 5ec26cebde..2ccfdd2c26 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshDispatchItem.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshDispatchItem.cpp @@ -225,12 +225,12 @@ namespace AZ return m_boneTransforms; } - AZStd::array_view> SkinnedMeshDispatchItem::GetSourceUnskinnedBufferViews() const + AZStd::span> SkinnedMeshDispatchItem::GetSourceUnskinnedBufferViews() const { return m_inputBuffers->GetInputBufferViews(m_lodIndex); } - AZStd::array_view> SkinnedMeshDispatchItem::GetTargetSkinnedBufferViews() const + AZStd::span> SkinnedMeshDispatchItem::GetTargetSkinnedBufferViews() const { return m_actorInstanceBufferViews; } diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshDispatchItem.h b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshDispatchItem.h index 739267d602..54b61f28c4 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshDispatchItem.h +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshDispatchItem.h @@ -65,8 +65,8 @@ namespace AZ const RHI::DispatchItem& GetRHIDispatchItem() const; Data::Instance GetBoneTransforms() const; - AZStd::array_view> GetSourceUnskinnedBufferViews() const; - AZStd::array_view> GetTargetSkinnedBufferViews() const; + AZStd::span> GetSourceUnskinnedBufferViews() const; + AZStd::span> GetTargetSkinnedBufferViews() const; size_t GetVertexCount() const; private: // SkinnedMeshShaderOptionNotificationBus::Handler diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshInputBuffers.cpp b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshInputBuffers.cpp index 4146a669fe..e3219be597 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshInputBuffers.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshInputBuffers.cpp @@ -212,7 +212,7 @@ namespace AZ void SkinnedMeshInputLod::CreateSharedSubMeshBufferViews() { - AZStd::array_view meshes = m_modelLodAsset->GetMeshes(); + AZStd::span meshes = m_modelLodAsset->GetMeshes(); m_sharedSubMeshViews.resize(meshes.size()); // The index and static buffer views will be shared by all instances that use the same SkinnedMeshInputBuffers, so set them here @@ -307,7 +307,7 @@ namespace AZ return m_lods[lodIndex]; } - AZStd::array_view> SkinnedMeshInputBuffers::GetInputBufferViews(size_t lodIndex) const + AZStd::span> SkinnedMeshInputBuffers::GetInputBufferViews(size_t lodIndex) const { return m_lods[lodIndex].m_bufferViews; } diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshRenderProxy.cpp b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshRenderProxy.cpp index 2f8ccc12ed..6f1e636b85 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshRenderProxy.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshRenderProxy.cpp @@ -145,7 +145,7 @@ namespace AZ } } - AZStd::array_view> SkinnedMeshRenderProxy::GetDispatchItems() const + AZStd::span> SkinnedMeshRenderProxy::GetDispatchItems() const { return m_dispatchItemsByLod; } diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshRenderProxy.h b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshRenderProxy.h index ffad21207e..275c8ea21d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshRenderProxy.h +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshRenderProxy.h @@ -45,7 +45,7 @@ namespace AZ void SetSkinningMatrices(const AZStd::vector& data) override; void SetMorphTargetWeights(uint32_t lodIndex, const AZStd::vector& weights) override; - AZStd::array_view< AZStd::unique_ptr> GetDispatchItems() const; + AZStd::span> GetDispatchItems() const; private: AZ_DISABLE_COPY_MOVE(SkinnedMeshRenderProxy); diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshStatsCollector.cpp b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshStatsCollector.cpp index abfdf4c101..124c697e4a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshStatsCollector.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshStatsCollector.cpp @@ -78,7 +78,7 @@ namespace AZ } } - void SkinnedMeshStatsCollector::AddReadOnlyBufferViewsToSceneStats(const AZStd::array_view>& sourceUnskinnedBufferViews) + void SkinnedMeshStatsCollector::AddReadOnlyBufferViewsToSceneStats(const AZStd::span>& sourceUnskinnedBufferViews) { for (const AZ::RHI::Ptr& bufferView : sourceUnskinnedBufferViews) { @@ -94,7 +94,7 @@ namespace AZ } } - void SkinnedMeshStatsCollector::AddWritableBufferViewsToSceneStats(const AZStd::array_view>& targetSkinnedBufferViews) + void SkinnedMeshStatsCollector::AddWritableBufferViewsToSceneStats(const AZStd::span>& targetSkinnedBufferViews) { for (const AZ::RHI::Ptr& bufferView : targetSkinnedBufferViews) { diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshStatsCollector.h b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshStatsCollector.h index f81cf0d5af..ef35a2aa65 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshStatsCollector.h +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshStatsCollector.h @@ -33,8 +33,8 @@ namespace AZ void ResetAllStats(); void AddDispatchItemToSceneStats(const AZStd::unique_ptr& dispatchItem); void AddBonesToSceneStats(const Data::Instance& boneTransformBuffer); - void AddReadOnlyBufferViewsToSceneStats(const AZStd::array_view>& sourceUnskinnedBufferViews); - void AddWritableBufferViewsToSceneStats(const AZStd::array_view>& targetSkinnedBufferViews); + void AddReadOnlyBufferViewsToSceneStats(const AZStd::span>& sourceUnskinnedBufferViews); + void AddWritableBufferViewsToSceneStats(const AZStd::span>& targetSkinnedBufferViews); void AddVerticesToSceneStats(size_t vertexCount); SkinnedMeshSceneStats m_sceneStats; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/ShaderCompilerArguments.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/ShaderCompilerArguments.h index 83a868ab65..012d9288a0 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/ShaderCompilerArguments.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/ShaderCompilerArguments.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace AZ { diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/Utils.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/Utils.h index d648f05b46..4b1f647102 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/Utils.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/Utils.h @@ -129,7 +129,7 @@ namespace AZ //! @returns A new string based on @commandLineString but with the matching arguments and their values //! removed from it. AZStd::string RemoveArgumentsFromCommandLineString( - AZStd::array_view listOfArguments, AZStd::string_view commandLineString); + AZStd::span listOfArguments, AZStd::string_view commandLineString); //! @param commandLineString: " --arg1 -arg2 --arg3=foo --arg4=bar " //! @returns "--arg1 -arg2 --arg3=foo --arg4=bar" diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ConstantsLayout.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ConstantsLayout.h index 653e8e4474..eae84e7970 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ConstantsLayout.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ConstantsLayout.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -72,7 +72,7 @@ namespace AZ //! Returns the full lists of shader input added to the layout. Inputs //! maintain their original order with respect to AddShaderInput. - AZStd::array_view GetShaderInputList() const; + AZStd::span GetShaderInputList() const; //! Returns the total size in bytes used by the constants. uint32_t GetDataSize() const; @@ -84,7 +84,7 @@ namespace AZ //! Prints to the console the shader input names specified by input list of indices //! Will ignore any indices outside of the inputs array bounds - void DebugPrintNames(AZStd::array_view constantList) const; + void DebugPrintNames(AZStd::span constantList) const; protected: ConstantsLayout() = default; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/IndirectBufferLayout.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/IndirectBufferLayout.h index fd26d845f7..a645cfc7b3 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/IndirectBufferLayout.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/IndirectBufferLayout.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace AZ { @@ -137,7 +137,7 @@ namespace AZ bool AddIndirectCommand(const IndirectCommandDescriptor& command); /// Returns the list of indirect commands of the layout. Must be called after the layout is finalized. - AZStd::array_view GetCommands() const; + AZStd::span GetCommands() const; //! Returns the position of a command. //! Must be called after the layout is finalized. diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/InputStreamLayout.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/InputStreamLayout.h index 879584f224..914709a60f 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/InputStreamLayout.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/InputStreamLayout.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -158,10 +158,10 @@ namespace AZ const PrimitiveTopology GetTopology() const; /// Returns the list of stream channels. - AZStd::array_view GetStreamChannels() const; + AZStd::span GetStreamChannels() const; /// Returns the list of stream buffers. - AZStd::array_view GetStreamBuffers() const; + AZStd::span GetStreamBuffers() const; /// Returns the hash computed in Finalize(), which must be called first. HashValue64 GetHash() const; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/PipelineLayoutDescriptor.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/PipelineLayoutDescriptor.h index 216021a316..86bc059c1a 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/PipelineLayoutDescriptor.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/PipelineLayoutDescriptor.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/PipelineLibraryData.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/PipelineLibraryData.h index c86d38fdeb..38f3cb0c51 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/PipelineLibraryData.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/PipelineLibraryData.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include @@ -47,7 +47,7 @@ namespace AZ static ConstPtr Create(AZStd::vector&& data); /// Returns the data payload which describes the platform-specific pipeline library data. - AZStd::array_view GetData() const; + AZStd::span GetData() const; private: PipelineLibraryData(AZStd::vector&& data); diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/RenderAttachmentLayout.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/RenderAttachmentLayout.h index 9a3c3dd226..bb3c2156c2 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/RenderAttachmentLayout.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/RenderAttachmentLayout.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace AZ { diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ShaderResourceGroupLayout.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ShaderResourceGroupLayout.h index 34737019ca..5510fc039f 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ShaderResourceGroupLayout.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ShaderResourceGroupLayout.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -116,7 +116,7 @@ namespace AZ // The following methods are only permitted on a finalized layout. /// Returns the full list of static samplers descriptors declared on the layout. - AZStd::array_view GetStaticSamplers() const; + AZStd::span GetStaticSamplers() const; /** * Resolves an shader input name to an index for each type of shader input. To maximize performance, @@ -148,13 +148,13 @@ namespace AZ * maintain their original order with respect to AddShaderInput. Each type * of shader input has its own separate list. */ - AZStd::array_view GetShaderInputListForBuffers() const; - AZStd::array_view GetShaderInputListForImages() const; - AZStd::array_view GetShaderInputListForSamplers() const; - AZStd::array_view GetShaderInputListForConstants() const; + AZStd::span GetShaderInputListForBuffers() const; + AZStd::span GetShaderInputListForImages() const; + AZStd::span GetShaderInputListForSamplers() const; + AZStd::span GetShaderInputListForConstants() const; - AZStd::array_view GetShaderInputListForBufferUnboundedArrays() const; - AZStd::array_view GetShaderInputListForImageUnboundedArrays() const; + AZStd::span GetShaderInputListForBufferUnboundedArrays() const; + AZStd::span GetShaderInputListForImageUnboundedArrays() const; /** * Each shader input may contain multiple shader resources. The layout computes diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/CommandListStates.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/CommandListStates.h index 34a25eb8b6..1937631f13 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/CommandListStates.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/CommandListStates.h @@ -20,7 +20,7 @@ namespace AZ struct CommandListRenderTargetsState { using StateList = AZStd::fixed_vector; - void Set(AZStd::array_view newElements) + void Set(AZStd::span newElements) { m_states = StateList(newElements.begin(), newElements.end()); m_isDirty = true; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/ConstantsData.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/ConstantsData.h index fd38e4c08d..04aa97a189 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/ConstantsData.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/ConstantsData.h @@ -20,11 +20,11 @@ namespace AZ { namespace RHI { - //! The intent of this class is to provide fast and thin access to the underlying constant - //! data (inline or from an SRG), with basic validation to protect the user. As a secondary objective, it provides type-specific convenience - //! operations as long as they don't violate the primary "fast" and "thin" objectives. To clarify, thin means - //! we don't make assumptions about the data or how the user wants to operate on the data, and the convenience - //! operations boil down to thin wrappers for single calls to SetConstantRaw and GetConstantRaw. So these + //! The intent of this class is to provide fast and thin access to the underlying constant + //! data (inline or from an SRG), with basic validation to protect the user. As a secondary objective, it provides type-specific convenience + //! operations as long as they don't violate the primary "fast" and "thin" objectives. To clarify, thin means + //! we don't make assumptions about the data or how the user wants to operate on the data, and the convenience + //! operations boil down to thin wrappers for single calls to SetConstantRaw and GetConstantRaw. So these //! convenience functions are provided in situations that are "low-hanging-fruit". class ConstantsData { @@ -53,7 +53,7 @@ namespace AZ //! Assigns an array of type T to the constant shader input. template - bool SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view values); + bool SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span values); //! Assigns constant data as a whole. bool SetConstantData(const void* bytes, size_t byteCount); @@ -64,7 +64,7 @@ namespace AZ //! of elements in the returned array is the number of evenly divisible elements. //! If the strides do not match, an empty array is returned. template - AZStd::array_view GetConstantArray(ShaderInputConstantIndex inputIndex) const; + AZStd::span GetConstantArray(ShaderInputConstantIndex inputIndex) const; //! Returns the constant data as type 'T' returned by value. The size of the constant region //! must match the size of T exactly. Otherwise, an empty instance is returned. @@ -77,11 +77,11 @@ namespace AZ template T GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const; - //! Returns constant data for the given shader input index as an array of bytes. - AZStd::array_view GetConstantRaw(ShaderInputConstantIndex inputIndex) const; + //! Returns constant data for the given shader input index as a span of bytes. + AZStd::span GetConstantRaw(ShaderInputConstantIndex inputIndex) const; //! Returns the opaque constant data populated by calls to SetConstant and SetConstantData. - AZStd::array_view GetConstantData() const; + AZStd::span GetConstantData() const; //! Returns the constants layout. const ConstantsLayout* GetLayout() const; @@ -123,7 +123,7 @@ namespace AZ template bool ConstantsData::SetConstant(ShaderInputConstantIndex inputIndex, const T& value) { - AZStd::array_view valueArray(&value, 1); + AZStd::span valueArray(&value, 1); return SetConstantArray(inputIndex, valueArray); } @@ -152,7 +152,7 @@ namespace AZ bool ConstantsData::SetConstant(ShaderInputConstantIndex inputIndex, const Color& value); template <> - bool ConstantsData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view values); + bool ConstantsData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span values); template <> bool ConstantsData::GetConstant(ShaderInputConstantIndex inputIndex) const; @@ -213,7 +213,7 @@ namespace AZ } template - bool ConstantsData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view values) + bool ConstantsData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span values) { const size_t sizeInBytes = values.size() * sizeof(T); if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) @@ -224,15 +224,15 @@ namespace AZ } template - AZStd::array_view ConstantsData::GetConstantArray(ShaderInputConstantIndex inputIndex) const + AZStd::span ConstantsData::GetConstantArray(ShaderInputConstantIndex inputIndex) const { - AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + AZStd::span constantBytes = GetConstantRaw(inputIndex); const size_t elementSize = sizeof(T); const size_t elementCount = DivideByMultiple(constantBytes.size(), elementSize); const size_t sizeInBytes = elementCount * elementSize; if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) { - return AZStd::array_view(reinterpret_cast(constantBytes.data()), elementCount); + return AZStd::span(reinterpret_cast(constantBytes.data()), elementCount); } return {}; } @@ -240,7 +240,7 @@ namespace AZ template T ConstantsData::GetConstant(ShaderInputConstantIndex inputIndex) const { - AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + AZStd::span constantBytes = GetConstantRaw(inputIndex); const size_t sizeInBytes = sizeof(T); if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) { @@ -252,7 +252,7 @@ namespace AZ template T ConstantsData::GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const { - AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + AZStd::span constantBytes = GetConstantRaw(inputIndex); const size_t elementSize = sizeof(T); const size_t elementOffset = arrayIndex * elementSize; if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::ArrayElement, elementOffset, elementSize)) diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/DrawList.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/DrawList.h index 72bfed3300..dfb458217f 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/DrawList.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/DrawList.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -36,7 +36,7 @@ namespace AZ using DrawListMask = AZStd::bitset; using DrawList = AZStd::vector; - using DrawListView = AZStd::array_view; + using DrawListView = AZStd::span; /// Contains a table of draw lists, indexed by the tag. using DrawListsByTag = AZStd::array; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/DrawPacketBuilder.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/DrawPacketBuilder.h index 30e013d486..fdaa2b594a 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/DrawPacketBuilder.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/DrawPacketBuilder.h @@ -32,7 +32,7 @@ namespace AZ uint8_t m_stencilRef = 0; //! The array of stream buffers to bind for this draw item. - AZStd::array_view m_streamBufferViews; + AZStd::span m_streamBufferViews; //! Shader resource group unique for this draw request const ShaderResourceGroup* m_uniqueShaderResourceGroup = nullptr; @@ -56,13 +56,13 @@ namespace AZ void SetIndexBufferView(const IndexBufferView& indexBufferView); - void SetRootConstants(AZStd::array_view rootConstants); + void SetRootConstants(AZStd::span rootConstants); - void SetScissors(AZStd::array_view scissors); + void SetScissors(AZStd::span scissors); void SetScissor(const Scissor& scissor); - void SetViewports(AZStd::array_view viewports); + void SetViewports(AZStd::span viewports); void SetViewport(const Viewport& viewport); @@ -85,7 +85,7 @@ namespace AZ IndexBufferView m_indexBufferView; AZStd::fixed_vector m_drawRequests; AZStd::fixed_vector m_shaderResourceGroups; - AZStd::array_view m_rootConstants; + AZStd::span m_rootConstants; AZStd::fixed_vector m_scissors; AZStd::fixed_vector m_viewports; }; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraph.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraph.h index c361750bc6..ac7a224594 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraph.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraph.h @@ -7,7 +7,7 @@ */ #pragma once -#include +#include #include #include @@ -105,11 +105,11 @@ namespace AZ // See RHI::FrameGraphInterface for detailed comments ResultCode UseAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access, ScopeAttachmentUsage usage); ResultCode UseAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access, ScopeAttachmentUsage usage); - ResultCode UseAttachments(AZStd::array_view descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage); + ResultCode UseAttachments(AZStd::span descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage); ResultCode UseResolveAttachment(const ResolveScopeAttachmentDescriptor& descriptor); - ResultCode UseColorAttachments(AZStd::array_view descriptors); + ResultCode UseColorAttachments(AZStd::span descriptors); ResultCode UseDepthStencilAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access); - ResultCode UseSubpassInputAttachments(AZStd::array_view descriptors); + ResultCode UseSubpassInputAttachments(AZStd::span descriptors); ResultCode UseShaderAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access); ResultCode UseShaderAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access); ResultCode UseCopyAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access); diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraphExecuter.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraphExecuter.h index fa05428967..72fe29d0d5 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraphExecuter.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraphExecuter.h @@ -124,7 +124,7 @@ namespace AZ FrameGraphExecuteGroupType* AddGroup(); //! Returns a list of the registered execute groups. - AZStd::array_view> GetGroups() const; + AZStd::span> GetGroups() const; private: ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraphInterface.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraphInterface.h index a9bf2130cd..ed14783c56 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraphInterface.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/FrameGraphInterface.h @@ -18,7 +18,7 @@ #include #include -#include +#include namespace AZ { @@ -79,7 +79,7 @@ namespace AZ //! Declares an array of image attachments for use on the current scope. ResultCode UseAttachments( - AZStd::array_view descriptors, + AZStd::span descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage) { @@ -87,7 +87,7 @@ namespace AZ } //! Declares an array of color attachments for use on the current scope. - ResultCode UseColorAttachments(AZStd::array_view descriptors) + ResultCode UseColorAttachments(AZStd::span descriptors) { return m_frameGraph.UseColorAttachments(descriptors); } @@ -100,7 +100,7 @@ namespace AZ //! Declares an array of subpass input attachments for use on the current scope. //! See UseSubpassInputAttachment for a definition about a SubpassInput. - ResultCode UseSubpassInputAttachments(AZStd::array_view descriptors) + ResultCode UseSubpassInputAttachments(AZStd::span descriptors) { return m_frameGraph.UseSubpassInputAttachments(descriptors); } diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/PipelineLibrary.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/PipelineLibrary.h index 3a49b121cd..687038f52e 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/PipelineLibrary.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/PipelineLibrary.h @@ -19,7 +19,7 @@ namespace AZ /// A handle typed to the pipeline library. Used by the PipelineStateCache to abstract access. using PipelineLibraryHandle = Handle; - + //! PipelineState initialization is an expensive operation on certain platforms. If multiple pipeline states //! are created with little variation between them, the contents are still duplicated. This class is an allocation //! context for pipeline states, provided at PipelineState::Init, which will perform de-duplication of @@ -58,7 +58,7 @@ namespace AZ //! libraries and merge them into a single unified library. The serialized data can then be //! extracted from the unified library. An error code is returned on failure and the behavior //! is as if the method was never called. - ResultCode MergeInto(AZStd::array_view librariesToMerge); + ResultCode MergeInto(AZStd::span librariesToMerge); //! Serializes the platform-specific data and returns it as a new PipelineLibraryData instance. //! The data is opaque to the user and can only be used to re-initialize the library. Use @@ -85,7 +85,7 @@ namespace AZ virtual void ShutdownInternal() = 0; /// Called when libraries are being merged into this one. - virtual ResultCode MergeIntoInternal(AZStd::array_view libraries) = 0; + virtual ResultCode MergeIntoInternal(AZStd::span libraries) = 0; /// Called when the library is serializing out platform-specific data. virtual ConstPtr GetSerializedDataInternal() const = 0; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h index ef4e734c01..8904924c41 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h @@ -24,16 +24,16 @@ namespace AZ //! and shader constants. It utilizes basic reflection information from the shader resource group layout //! to construct the table in the correct format for the platform-specific compile phase. The user //! is expected to create instances of this class, fill data, and then push it to an SRG instance. - //! + //! //! The shader resource group (SRG) includes a set of built-in SRG constants in a single internally-managed //! constant buffer. This is separate from any custom constant buffers that some SRG layouts may include //! as shader resources. SRG constants can be conveniently accessed through a variety of SetConstant. - //! + //! //! This data structure holds strong references to the resource views bound onto it. - //! + //! //! NOTE [Performance Warning]: This data structure allocates memory. If compiling several SRG's in a batch, //! prefer to share the data between them (i.e. within a single job). - //! + //! //! NOTE [SRG Constants]: The ConstantsData class is used for efficiently setting/getting the constants values of the SRG. class ShaderResourceGroupData { @@ -65,25 +65,25 @@ namespace AZ bool SetImageView(ShaderInputImageIndex inputIndex, const ImageView* imageView, uint32_t arrayIndex); //! Sets an array of image view for the given shader input index. - bool SetImageViewArray(ShaderInputImageIndex inputIndex, AZStd::array_view imageViews, uint32_t arrayIndex = 0); + bool SetImageViewArray(ShaderInputImageIndex inputIndex, AZStd::span imageViews, uint32_t arrayIndex = 0); //! Sets an unbounded array of image view for the given shader input index. - bool SetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::array_view imageViews); + bool SetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::span imageViews); //! Sets one buffer view for the given shader input index. bool SetBufferView(ShaderInputBufferIndex inputIndex, const BufferView* bufferView, uint32_t arrayIndex = 0); //! Sets an array of image view for the given shader input index. - bool SetBufferViewArray(ShaderInputBufferIndex inputIndex, AZStd::array_view bufferViews, uint32_t arrayIndex = 0); + bool SetBufferViewArray(ShaderInputBufferIndex inputIndex, AZStd::span bufferViews, uint32_t arrayIndex = 0); //! Sets an unbounded array of buffer view for the given shader input index. - bool SetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::array_view bufferViews); + bool SetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::span bufferViews); //! Sets one sampler for the given shader input index, using the bindingIndex as the key. bool SetSampler(ShaderInputSamplerIndex inputIndex, const SamplerState& sampler, uint32_t arrayIndex = 0); //! Sets an array of samplers for the given shader input index. - bool SetSamplerArray(ShaderInputSamplerIndex inputIndex, AZStd::array_view samplers, uint32_t arrayIndex = 0); + bool SetSamplerArray(ShaderInputSamplerIndex inputIndex, AZStd::span samplers, uint32_t arrayIndex = 0); //! Assigns constant data for the given constant shader input index. bool SetConstantRaw(ShaderInputConstantIndex inputIndex, const void* bytes, uint32_t byteCount); @@ -96,17 +96,17 @@ namespace AZ //! Assigns a specified number of rows from a Matrix template bool SetConstantMatrixRows(ShaderInputConstantIndex inputIndex, const T& value, uint32_t rowCount); - + //! Assigns a value of type T to the constant shader input, at an array offset. template bool SetConstant(ShaderInputConstantIndex inputIndex, const T& value, uint32_t arrayIndex); //! Assigns an array of type T to the constant shader input. template - bool SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view values); + bool SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span values); //! Assigns constant data as a whole. - //! + //! //! CAUTION! //! Different platforms might follow different packing rules for the internally-managed SRG constant buffer. //! To set manually a constant buffer as a whole please use Constant Buffers in AZSL, @@ -118,33 +118,33 @@ namespace AZ //! Returns a single image view associated with the image shader input index and array offset. const ConstPtr& GetImageView(ShaderInputImageIndex inputIndex, uint32_t arrayIndex) const; - //! Returns an array of image views associated with the given image shader input index. - AZStd::array_view> GetImageViewArray(ShaderInputImageIndex inputIndex) const; + //! Returns a span of image views associated with the given image shader input index. + AZStd::span> GetImageViewArray(ShaderInputImageIndex inputIndex) const; - //! Returns an unbounded array of image views associated with the given buffer shader input index. - AZStd::array_view> GetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex) const; + //! Returns an unbounded span of image views associated with the given buffer shader input index. + AZStd::span> GetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex) const; //! Returns a single buffer view associated with the buffer shader input index and array offset. const ConstPtr& GetBufferView(ShaderInputBufferIndex inputIndex, uint32_t arrayIndex) const; - //! Returns an array of buffer views associated with the given buffer shader input index. - AZStd::array_view> GetBufferViewArray(ShaderInputBufferIndex inputIndex) const; + //! Returns a span of buffer views associated with the given buffer shader input index. + AZStd::span> GetBufferViewArray(ShaderInputBufferIndex inputIndex) const; - //! Returns an unbounded array of buffer views associated with the given buffer shader input index. - AZStd::array_view> GetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex) const; + //! Returns an unbounded span of buffer views associated with the given buffer shader input index. + AZStd::span> GetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex) const; //! Returns a single sampler associated with the sampler shader input index and array offset. const SamplerState& GetSampler(ShaderInputSamplerIndex inputIndex, uint32_t arrayIndex) const; - //! Returns an array of samplers associated with the sampler shader input index. - AZStd::array_view GetSamplerArray(ShaderInputSamplerIndex inputIndex) const; + //! Returns a span of samplers associated with the sampler shader input index. + AZStd::span GetSamplerArray(ShaderInputSamplerIndex inputIndex) const; //! Returns constant data for the given shader input index as a template type. //! The stride of T must match the size of the constant input region. The number - //! of elements in the returned array is the number of evenly divisible elements. - //! If the strides do not match, an empty array is returned. + //! of elements in the returned span is the number of evenly divisible elements. + //! If the strides do not match, an empty span is returned. template - AZStd::array_view GetConstantArray(ShaderInputConstantIndex inputIndex) const; + AZStd::span GetConstantArray(ShaderInputConstantIndex inputIndex) const; //! Returns the constant data as type 'T' returned by value. The size of the constant region //! must match the size of T exactly. Otherwise, an empty instance is returned. @@ -157,25 +157,25 @@ namespace AZ template T GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const; - //! Returns constant data for the given shader input index as an array of bytes. - AZStd::array_view GetConstantRaw(ShaderInputConstantIndex inputIndex) const; + //! Returns constant data for the given shader input index as a span of bytes. + AZStd::span GetConstantRaw(ShaderInputConstantIndex inputIndex) const; //! Returns a {Buffer, Image, Sampler} shader resource group. Each resource type has its own separate group. //! - The size of this group matches the size provided by ShaderResourceGroupLayout::GetGroupSizeFor{Buffer, Image, Sampler}. - //! - Use ShaderResourceGroupLayout::GetGroupInterval to retrieve a [min, max) interval into the array. - AZStd::array_view> GetImageGroup() const; - AZStd::array_view> GetBufferGroup() const; - AZStd::array_view GetSamplerGroup() const; - + //! - Use ShaderResourceGroupLayout::GetGroupInterval to retrieve a [min, max) interval into the span. + AZStd::span> GetImageGroup() const; + AZStd::span> GetBufferGroup() const; + AZStd::span GetSamplerGroup() const; + //! Reset image and buffer views setup for this ShaderResourceGroupData //! So it won't hold references for any RHI resources void ResetViews(); //! Returns the opaque constant data populated by calls to SetConstant and SetConstantData. - //! + //! //! CAUTION! //! Different platforms might follow different packing rules for the internally-managed SRG constant buffer. - AZStd::array_view GetConstantData() const; + AZStd::span GetConstantData() const; //! Returns the underlying ConstantsData struct const ConstantsData& GetConstantsData() const; @@ -213,7 +213,7 @@ namespace AZ //! times in order to ensure all SRG buffers are updated. void DisableCompilationForAllResourceTypes(); - //! Returns true if any of the resource type has been enabled for compilation. + //! Returns true if any of the resource type has been enabled for compilation. bool IsAnyResourceTypeUpdated() const; //! Enable compilation for a resourceType specified by resourceType/resourceTypeMask @@ -265,7 +265,7 @@ namespace AZ EnableResourceTypeCompilation(ResourceTypeMask::ConstantDataMask, ResourceType::ConstantData); return m_constantsData.SetConstant(inputIndex, value, arrayIndex); } - + template bool ShaderResourceGroupData::SetConstantMatrixRows(ShaderInputConstantIndex inputIndex, const T& value, uint32_t rowCount) { @@ -274,7 +274,7 @@ namespace AZ } template - bool ShaderResourceGroupData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view values) + bool ShaderResourceGroupData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span values) { if (!values.empty()) { @@ -284,7 +284,7 @@ namespace AZ } template - AZStd::array_view ShaderResourceGroupData::GetConstantArray(ShaderInputConstantIndex inputIndex) const + AZStd::span ShaderResourceGroupData::GetConstantArray(ShaderInputConstantIndex inputIndex) const { return m_constantsData.GetConstantArray(inputIndex); } diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamBufferView.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamBufferView.h index 4efc7da002..f1138804ab 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamBufferView.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamBufferView.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include namespace AZ @@ -65,6 +65,6 @@ namespace AZ }; /// Utility function for checking that the set of StreamBufferViews aligns with the InputStreamLayout - bool ValidateStreamBufferViews(const InputStreamLayout& inputStreamLayout, AZStd::array_view streamBufferViews); + bool ValidateStreamBufferViews(const InputStreamLayout& inputStreamLayout, AZStd::span streamBufferViews); } } diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamingImagePool.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamingImagePool.h index ee139b6dc2..a719ce5a7a 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamingImagePool.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamingImagePool.h @@ -11,7 +11,7 @@ #include #include -#include +#include namespace AZ { @@ -34,7 +34,7 @@ namespace AZ struct StreamingImageMipSlice { /// An array of subresource datas. The size of this array must match the array size of the image. - AZStd::array_view m_subresources; + AZStd::span m_subresources; /// The layout of each image in the array. ImageSubresourceLayout m_subresourceLayout; @@ -52,7 +52,7 @@ namespace AZ StreamingImageInitRequest( Image& image, const ImageDescriptor& descriptor, - AZStd::array_view tailMipSlices); + AZStd::span tailMipSlices); /// The image to initialize. Image* m_image = nullptr; @@ -65,7 +65,7 @@ namespace AZ * This should only include the baseline set of mips necessary to render the image at * its lowest resolution. The uploads is performed synchronously. */ - AZStd::array_view m_tailMipSlices; + AZStd::span m_tailMipSlices; }; /** @@ -83,7 +83,7 @@ namespace AZ * remain valid for the duration of the upload (until m_completeCallback * is triggered). */ - AZStd::array_view m_mipSlices; + AZStd::span m_mipSlices; /// Whether the function need to wait until the upload is finished. bool m_waitForUpload = false; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/TransientAttachmentPool.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/TransientAttachmentPool.h index 334568154c..49317250f4 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/TransientAttachmentPool.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/TransientAttachmentPool.h @@ -123,7 +123,7 @@ namespace AZ protected: // Adds the stats of a list of heaps into the Pool's TransientAttachmentStatistics. - void CollectHeapStats(AliasedResourceTypeFlags typeMask, AZStd::array_view heapStats); + void CollectHeapStats(AliasedResourceTypeFlags typeMask, AZStd::span heapStats); Scope* m_currentScope = nullptr; RHI::TransientAttachmentStatistics m_statistics; diff --git a/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp b/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp index 6b5b9cc3a5..b3a6b01ebb 100644 --- a/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp @@ -496,7 +496,7 @@ namespace AZ } AZStd::string RemoveArgumentsFromCommandLineString( - AZStd::array_view listOfArgumentsToRemove, AZStd::string_view commandLineString) + AZStd::span listOfArgumentsToRemove, AZStd::string_view commandLineString) { AZStd::string customizedArguments = commandLineString; for (const AZStd::string& azslcArgumentName : listOfArgumentsToRemove) diff --git a/Gems/Atom/RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp b/Gems/Atom/RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp index 8b9d6ae668..cdbd74ca17 100644 --- a/Gems/Atom/RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp @@ -106,7 +106,7 @@ namespace AZ return m_inputs[inputIndex.GetIndex()]; } - AZStd::array_view ConstantsLayout::GetShaderInputList() const + AZStd::span ConstantsLayout::GetShaderInputList() const { return m_inputs; } @@ -145,7 +145,7 @@ namespace AZ return true; } - void ConstantsLayout::DebugPrintNames(AZStd::array_view constantList) const + void ConstantsLayout::DebugPrintNames(AZStd::span constantList) const { AZStd::string output; for (const ShaderInputConstantIndex& constantIdx : constantList) diff --git a/Gems/Atom/RHI/Code/Source/RHI.Reflect/IndirectBufferLayout.cpp b/Gems/Atom/RHI/Code/Source/RHI.Reflect/IndirectBufferLayout.cpp index 4eb5ca0abb..467d9f5cb1 100644 --- a/Gems/Atom/RHI/Code/Source/RHI.Reflect/IndirectBufferLayout.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI.Reflect/IndirectBufferLayout.cpp @@ -137,11 +137,11 @@ namespace AZ return true; } - AZStd::array_view IndirectBufferLayout::GetCommands() const + AZStd::span IndirectBufferLayout::GetCommands() const { if (!ValidateFinalizeState(ValidateFinalizeStateExpect::Finalized)) { - return AZStd::array_view(); + return AZStd::span(); } return m_commands; } diff --git a/Gems/Atom/RHI/Code/Source/RHI.Reflect/InputStreamLayout.cpp b/Gems/Atom/RHI/Code/Source/RHI.Reflect/InputStreamLayout.cpp index 3b548446b9..1ddb41ac8e 100644 --- a/Gems/Atom/RHI/Code/Source/RHI.Reflect/InputStreamLayout.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI.Reflect/InputStreamLayout.cpp @@ -159,12 +159,12 @@ namespace AZ return m_topology; } - AZStd::array_view InputStreamLayout::GetStreamChannels() const + AZStd::span InputStreamLayout::GetStreamChannels() const { return m_streamChannels; } - AZStd::array_view InputStreamLayout::GetStreamBuffers() const + AZStd::span InputStreamLayout::GetStreamBuffers() const { return m_streamBuffers; } diff --git a/Gems/Atom/RHI/Code/Source/RHI.Reflect/PipelineLibraryData.cpp b/Gems/Atom/RHI/Code/Source/RHI.Reflect/PipelineLibraryData.cpp index 1efe5d895a..1f0458032f 100644 --- a/Gems/Atom/RHI/Code/Source/RHI.Reflect/PipelineLibraryData.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI.Reflect/PipelineLibraryData.cpp @@ -31,7 +31,7 @@ namespace AZ : m_data{AZStd::move(data)} {} - AZStd::array_view PipelineLibraryData::GetData() const + AZStd::span PipelineLibraryData::GetData() const { return m_data; } diff --git a/Gems/Atom/RHI/Code/Source/RHI.Reflect/ShaderResourceGroupLayout.cpp b/Gems/Atom/RHI/Code/Source/RHI.Reflect/ShaderResourceGroupLayout.cpp index 6028593017..357d6da51a 100644 --- a/Gems/Atom/RHI/Code/Source/RHI.Reflect/ShaderResourceGroupLayout.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI.Reflect/ShaderResourceGroupLayout.cpp @@ -432,7 +432,7 @@ namespace AZ m_bindingSlot = Handle(bindingSlot); } - AZStd::array_view ShaderResourceGroupLayout::GetStaticSamplers() const + AZStd::span ShaderResourceGroupLayout::GetStaticSamplers() const { return m_staticSamplers; } @@ -497,32 +497,32 @@ namespace AZ return m_constantsDataLayout->GetShaderInput(index); } - AZStd::array_view ShaderResourceGroupLayout::GetShaderInputListForBuffers() const + AZStd::span ShaderResourceGroupLayout::GetShaderInputListForBuffers() const { return m_inputsForBuffers; } - AZStd::array_view ShaderResourceGroupLayout::GetShaderInputListForImages() const + AZStd::span ShaderResourceGroupLayout::GetShaderInputListForImages() const { return m_inputsForImages; } - AZStd::array_view ShaderResourceGroupLayout::GetShaderInputListForSamplers() const + AZStd::span ShaderResourceGroupLayout::GetShaderInputListForSamplers() const { return m_inputsForSamplers; } - AZStd::array_view ShaderResourceGroupLayout::GetShaderInputListForConstants() const + AZStd::span ShaderResourceGroupLayout::GetShaderInputListForConstants() const { return m_constantsDataLayout->GetShaderInputList(); } - AZStd::array_view ShaderResourceGroupLayout::GetShaderInputListForBufferUnboundedArrays() const + AZStd::span ShaderResourceGroupLayout::GetShaderInputListForBufferUnboundedArrays() const { return m_inputsForBufferUnboundedArrays; } - AZStd::array_view ShaderResourceGroupLayout::GetShaderInputListForImageUnboundedArrays() const + AZStd::span ShaderResourceGroupLayout::GetShaderInputListForImageUnboundedArrays() const { return m_inputsForImageUnboundedArrays; } diff --git a/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp b/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp index a86f278ee2..bff7c7e626 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp @@ -144,7 +144,7 @@ namespace AZ } template <> - bool ConstantsData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view values) + bool ConstantsData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span values) { // The shader packs type bool as 4 bytes const size_t elementSize = 4; @@ -310,7 +310,7 @@ namespace AZ template <> bool ConstantsData::GetConstant(ShaderInputConstantIndex inputIndex) const { - AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + AZStd::span constantBytes = GetConstantRaw(inputIndex); // The shader packs bool data as 4 bytes const size_t sizeInBytes = 4; if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) @@ -328,7 +328,7 @@ namespace AZ const size_t sizeInBytes = sizeof(float) * 11; if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) { - const AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + const AZStd::span constantBytes = GetConstantRaw(inputIndex); // As per shader packing rules the Matrix3x3 is stored as 11 floats (2 are padding). float localData[12]; @@ -348,7 +348,7 @@ namespace AZ const uint32_t sizeInBytes = sizeof(Matrix3x4); if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) { - const AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + const AZStd::span constantBytes = GetConstantRaw(inputIndex); const Matrix3x4& resultMatrix = Matrix3x4::CreateFromRowMajorFloat12(reinterpret_cast(constantBytes.data())); return resultMatrix; } @@ -361,7 +361,7 @@ namespace AZ const size_t sizeInBytes = sizeof(float) * 16; if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) { - const AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + const AZStd::span constantBytes = GetConstantRaw(inputIndex); const Matrix4x4& resultMatrix = Matrix4x4::CreateFromRowMajorFloat16(reinterpret_cast(constantBytes.data())); return resultMatrix; } @@ -374,7 +374,7 @@ namespace AZ constexpr size_t vector2Size = 8; if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(vector2Size))) { - AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + AZStd::span constantBytes = GetConstantRaw(inputIndex); return Vector2::CreateFromFloat2(reinterpret_cast(constantBytes.data())); } return Vector2(); @@ -387,7 +387,7 @@ namespace AZ constexpr size_t vector3Size = sizeof(float) * 3; if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, vector3Size)) { - AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + AZStd::span constantBytes = GetConstantRaw(inputIndex); return Vector3::CreateFromFloat3(reinterpret_cast(constantBytes.data())); } return Vector3(); @@ -399,7 +399,7 @@ namespace AZ constexpr size_t vector4Size = 16; if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(vector4Size))) { - AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + AZStd::span constantBytes = GetConstantRaw(inputIndex); return Vector4::CreateFromFloat4(reinterpret_cast(constantBytes.data())); } return Vector4(); @@ -411,19 +411,19 @@ namespace AZ constexpr size_t colorSize = sizeof(Color); if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(colorSize))) { - AZStd::array_view constantBytes = GetConstantRaw(inputIndex); + AZStd::span constantBytes = GetConstantRaw(inputIndex); return Color::CreateFromFloat4(reinterpret_cast(constantBytes.data())); } return Color(); } - AZStd::array_view ConstantsData::GetConstantRaw(ShaderInputConstantIndex inputIndex) const + AZStd::span ConstantsData::GetConstantRaw(ShaderInputConstantIndex inputIndex) const { const Interval interval = GetLayout()->GetInterval(inputIndex); - return AZStd::array_view(&m_constantData[interval.m_min], interval.m_max - interval.m_min); + return AZStd::span(&m_constantData[interval.m_min], interval.m_max - interval.m_min); } - AZStd::array_view ConstantsData::GetConstantData() const + AZStd::span ConstantsData::GetConstantData() const { return m_constantData; } @@ -436,11 +436,11 @@ namespace AZ bool ConstantsData::ConstantIsEqual(const ConstantsData& other, ShaderInputConstantIndex inputIndex) const { - AZStd::array_view myConstant = GetConstantRaw(inputIndex); - AZStd::array_view otherConstant = other.GetConstantRaw(inputIndex); + AZStd::span myConstant = GetConstantRaw(inputIndex); + AZStd::span otherConstant = other.GetConstantRaw(inputIndex); // If they point to the same data, they are equal - if (myConstant == otherConstant) + if (myConstant.data() == otherConstant.data() && myConstant.size() == otherConstant.size()) { return true; } @@ -474,8 +474,8 @@ namespace AZ return differingIndices; } - AZStd::array_view myShaderInputs = m_layout->GetShaderInputList(); - AZStd::array_view otherShaderInputs = other.m_layout->GetShaderInputList(); + AZStd::span myShaderInputs = m_layout->GetShaderInputList(); + AZStd::span otherShaderInputs = other.m_layout->GetShaderInputList(); size_t minSize = AZStd::min(myShaderInputs.size(), otherShaderInputs.size()); size_t maxSize = AZStd::max(myShaderInputs.size(), otherShaderInputs.size()); diff --git a/Gems/Atom/RHI/Code/Source/RHI/DrawPacketBuilder.cpp b/Gems/Atom/RHI/Code/Source/RHI/DrawPacketBuilder.cpp index ec9dd1a14f..1cfd745227 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/DrawPacketBuilder.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/DrawPacketBuilder.cpp @@ -33,29 +33,29 @@ namespace AZ m_indexBufferView = indexBufferView; } - void DrawPacketBuilder::SetRootConstants(AZStd::array_view rootConstants) + void DrawPacketBuilder::SetRootConstants(AZStd::span rootConstants) { m_rootConstants = rootConstants; } - void DrawPacketBuilder::SetScissors(AZStd::array_view scissors) + void DrawPacketBuilder::SetScissors(AZStd::span scissors) { m_scissors = decltype(m_scissors)(scissors.begin(), scissors.end()); } void DrawPacketBuilder::SetScissor(const Scissor& scissor) { - SetScissors(AZStd::array_view(&scissor, 1)); + SetScissors(AZStd::span(&scissor, 1)); } - void DrawPacketBuilder::SetViewports(AZStd::array_view viewports) + void DrawPacketBuilder::SetViewports(AZStd::span viewports) { m_viewports = decltype(m_viewports)(viewports.begin(), viewports.end()); } void DrawPacketBuilder::SetViewport(const Viewport& viewport) { - SetViewports(AZStd::array_view(&viewport, 1)); + SetViewports(AZStd::span(&viewport, 1)); } void DrawPacketBuilder::AddShaderResourceGroup(const ShaderResourceGroup* shaderResourceGroup) diff --git a/Gems/Atom/RHI/Code/Source/RHI/FrameGraph.cpp b/Gems/Atom/RHI/Code/Source/RHI/FrameGraph.cpp index 25158b1b3d..08840670a0 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/FrameGraph.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/FrameGraph.cpp @@ -327,7 +327,7 @@ namespace AZ return ResultCode::InvalidArgument; } - ResultCode FrameGraph::UseAttachments(AZStd::array_view descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage) + ResultCode FrameGraph::UseAttachments(AZStd::span descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage) { for (const ImageScopeAttachmentDescriptor& descriptor : descriptors) { @@ -354,7 +354,7 @@ namespace AZ return ResultCode::InvalidArgument; } - ResultCode FrameGraph::UseColorAttachments(AZStd::array_view descriptors) + ResultCode FrameGraph::UseColorAttachments(AZStd::span descriptors) { return UseAttachments(descriptors, ScopeAttachmentAccess::Write, ScopeAttachmentUsage::RenderTarget); } @@ -364,7 +364,7 @@ namespace AZ return UseAttachment(descriptor, access, ScopeAttachmentUsage::DepthStencil); } - ResultCode FrameGraph::UseSubpassInputAttachments(AZStd::array_view descriptors) + ResultCode FrameGraph::UseSubpassInputAttachments(AZStd::span descriptors) { return UseAttachments(descriptors, ScopeAttachmentAccess::Read, ScopeAttachmentUsage::SubpassInput); } diff --git a/Gems/Atom/RHI/Code/Source/RHI/FrameGraphExecuter.cpp b/Gems/Atom/RHI/Code/Source/RHI/FrameGraphExecuter.cpp index 7599e9c8f6..a27d34b4c2 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/FrameGraphExecuter.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/FrameGraphExecuter.cpp @@ -19,7 +19,7 @@ namespace AZ m_jobPolicy = jobPolicy; } - AZStd::array_view> FrameGraphExecuter::GetGroups() const + AZStd::span> FrameGraphExecuter::GetGroups() const { return m_groups; } diff --git a/Gems/Atom/RHI/Code/Source/RHI/PipelineLibrary.cpp b/Gems/Atom/RHI/Code/Source/RHI/PipelineLibrary.cpp index be0428bc91..6a05565c38 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/PipelineLibrary.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/PipelineLibrary.cpp @@ -44,7 +44,7 @@ namespace AZ return resultCode; } - ResultCode PipelineLibrary::MergeInto(AZStd::array_view librariesToMerge) + ResultCode PipelineLibrary::MergeInto(AZStd::span librariesToMerge) { if (!ValidateIsInitialized()) { diff --git a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupData.cpp b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupData.cpp index eed14b41b7..09006f0a60 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupData.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupData.cpp @@ -112,7 +112,7 @@ namespace AZ return SetImageViewArray(inputIndex, imageViews, arrayIndex); } - bool ShaderResourceGroupData::SetImageViewArray(ShaderInputImageIndex inputIndex, AZStd::array_view imageViews, uint32_t arrayIndex) + bool ShaderResourceGroupData::SetImageViewArray(ShaderInputImageIndex inputIndex, AZStd::span imageViews, uint32_t arrayIndex) { if (GetLayout()->ValidateAccess(inputIndex, static_cast(arrayIndex + imageViews.size() - 1))) { @@ -132,13 +132,13 @@ namespace AZ { EnableResourceTypeCompilation(ResourceTypeMask::ImageViewMask, ResourceType::ImageView); } - + return isValidAll; } return false; } - bool ShaderResourceGroupData::SetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::array_view imageViews) + bool ShaderResourceGroupData::SetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::span imageViews) { if (GetLayout()->ValidateAccess(inputIndex)) { @@ -169,7 +169,7 @@ namespace AZ return SetBufferViewArray(inputIndex, bufferViews, arrayIndex); } - bool ShaderResourceGroupData::SetBufferViewArray(ShaderInputBufferIndex inputIndex, AZStd::array_view bufferViews, uint32_t arrayIndex) + bool ShaderResourceGroupData::SetBufferViewArray(ShaderInputBufferIndex inputIndex, AZStd::span bufferViews, uint32_t arrayIndex) { if (GetLayout()->ValidateAccess(inputIndex, static_cast(arrayIndex + bufferViews.size() - 1))) { @@ -194,7 +194,7 @@ namespace AZ return false; } - bool ShaderResourceGroupData::SetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::array_view bufferViews) + bool ShaderResourceGroupData::SetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::span bufferViews) { if (GetLayout()->ValidateAccess(inputIndex)) { @@ -221,10 +221,10 @@ namespace AZ bool ShaderResourceGroupData::SetSampler(ShaderInputSamplerIndex inputIndex, const SamplerState& sampler, uint32_t arrayIndex) { - return SetSamplerArray(inputIndex, AZStd::array_view(&sampler, 1), arrayIndex); + return SetSamplerArray(inputIndex, AZStd::span(&sampler, 1), arrayIndex); } - bool ShaderResourceGroupData::SetSamplerArray(ShaderInputSamplerIndex inputIndex, AZStd::array_view samplers, uint32_t arrayIndex) + bool ShaderResourceGroupData::SetSamplerArray(ShaderInputSamplerIndex inputIndex, AZStd::span samplers, uint32_t arrayIndex) { if (GetLayout()->ValidateAccess(inputIndex, static_cast(arrayIndex + samplers.size() - 1))) { @@ -241,7 +241,7 @@ namespace AZ return true; } return false; - } + } bool ShaderResourceGroupData::SetConstantRaw(ShaderInputConstantIndex inputIndex, const void* bytes, uint32_t byteCount) { @@ -265,7 +265,7 @@ namespace AZ EnableResourceTypeCompilation(ResourceTypeMask::ConstantDataMask, ResourceType::ConstantData); return m_constantsData.SetConstantData(bytes, byteOffset, byteCount); } - + const RHI::ConstPtr& ShaderResourceGroupData::GetImageView(RHI::ShaderInputImageIndex inputIndex, uint32_t arrayIndex) const { if (GetLayout()->ValidateAccess(inputIndex, arrayIndex)) @@ -276,21 +276,21 @@ namespace AZ return s_nullImageView; } - AZStd::array_view> ShaderResourceGroupData::GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const + AZStd::span> ShaderResourceGroupData::GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const { if (GetLayout()->ValidateAccess(inputIndex, 0)) { const Interval interval = GetLayout()->GetGroupInterval(inputIndex); - return AZStd::array_view>(&m_imageViews[interval.m_min], interval.m_max - interval.m_min); + return AZStd::span>(&m_imageViews[interval.m_min], interval.m_max - interval.m_min); } return {}; } - AZStd::array_view> ShaderResourceGroupData::GetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex) const + AZStd::span> ShaderResourceGroupData::GetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex) const { if (GetLayout()->ValidateAccess(inputIndex)) { - return AZStd::array_view>(m_imageViewsUnboundedArray.data(), m_imageViewsUnboundedArray.size()); + return AZStd::span>(m_imageViewsUnboundedArray.data(), m_imageViewsUnboundedArray.size()); } return {}; } @@ -305,21 +305,21 @@ namespace AZ return s_nullBufferView; } - AZStd::array_view> ShaderResourceGroupData::GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const + AZStd::span> ShaderResourceGroupData::GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const { if (GetLayout()->ValidateAccess(inputIndex, 0)) { const Interval interval = GetLayout()->GetGroupInterval(inputIndex); - return AZStd::array_view>(&m_bufferViews[interval.m_min], interval.m_max - interval.m_min); + return AZStd::span>(&m_bufferViews[interval.m_min], interval.m_max - interval.m_min); } return {}; } - AZStd::array_view> ShaderResourceGroupData::GetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex) const + AZStd::span> ShaderResourceGroupData::GetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex) const { if (GetLayout()->ValidateAccess(inputIndex)) { - return AZStd::array_view>(m_bufferViewsUnboundedArray.data(), m_bufferViewsUnboundedArray.size()); + return AZStd::span>(m_bufferViewsUnboundedArray.data(), m_bufferViewsUnboundedArray.size()); } return {}; } @@ -334,28 +334,28 @@ namespace AZ return s_nullSamplerState; } - AZStd::array_view ShaderResourceGroupData::GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const + AZStd::span ShaderResourceGroupData::GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const { const Interval interval = GetLayout()->GetGroupInterval(inputIndex); - return AZStd::array_view(&m_samplers[interval.m_min], interval.m_max - interval.m_min); + return AZStd::span(&m_samplers[interval.m_min], interval.m_max - interval.m_min); } - AZStd::array_view ShaderResourceGroupData::GetConstantRaw(ShaderInputConstantIndex inputIndex) const + AZStd::span ShaderResourceGroupData::GetConstantRaw(ShaderInputConstantIndex inputIndex) const { return m_constantsData.GetConstantRaw(inputIndex); } - AZStd::array_view> ShaderResourceGroupData::GetImageGroup() const + AZStd::span> ShaderResourceGroupData::GetImageGroup() const { return m_imageViews; } - AZStd::array_view> ShaderResourceGroupData::GetBufferGroup() const + AZStd::span> ShaderResourceGroupData::GetBufferGroup() const { return m_bufferViews; } - AZStd::array_view ShaderResourceGroupData::GetSamplerGroup() const + AZStd::span ShaderResourceGroupData::GetSamplerGroup() const { return m_samplers; } @@ -368,7 +368,7 @@ namespace AZ m_bufferViewsUnboundedArray.assign(m_bufferViewsUnboundedArray.size(), nullptr); } - AZStd::array_view ShaderResourceGroupData::GetConstantData() const + AZStd::span ShaderResourceGroupData::GetConstantData() const { return m_constantsData.GetConstantData(); } diff --git a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp index 5d1da487ab..797fdec089 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp @@ -202,8 +202,8 @@ namespace AZ // Generate diffs for image views. if (HasImageGroup()) { - AZStd::array_view> viewGroupOld = shaderResourceGroup.GetData().GetImageGroup(); - AZStd::array_view> viewGroupNew = groupData.GetImageGroup(); + AZStd::span> viewGroupOld = shaderResourceGroup.GetData().GetImageGroup(); + AZStd::span> viewGroupNew = groupData.GetImageGroup(); AZ_Assert(viewGroupOld.size() == viewGroupNew.size(), "ShaderResourceGroupData layouts do not match."); for (size_t i = 0; i < viewGroupOld.size(); ++i) { @@ -214,8 +214,8 @@ namespace AZ // Generate diffs for buffer views. if (HasBufferGroup()) { - AZStd::array_view> viewGroupOld = shaderResourceGroup.GetData().GetBufferGroup(); - AZStd::array_view> viewGroupNew = groupData.GetBufferGroup(); + AZStd::span> viewGroupOld = shaderResourceGroup.GetData().GetBufferGroup(); + AZStd::span> viewGroupNew = groupData.GetBufferGroup(); AZ_Assert(viewGroupOld.size() == viewGroupNew.size(), "ShaderResourceGroupData layouts do not match."); for (size_t i = 0; i < viewGroupOld.size(); ++i) { diff --git a/Gems/Atom/RHI/Code/Source/RHI/StreamBufferView.cpp b/Gems/Atom/RHI/Code/Source/RHI/StreamBufferView.cpp index 0d4a826362..b88f58e8ff 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/StreamBufferView.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/StreamBufferView.cpp @@ -56,7 +56,7 @@ namespace AZ return m_byteStride; } - bool ValidateStreamBufferViews(const RHI::InputStreamLayout& inputStreamLayout, AZStd::array_view streamBufferViews) + bool ValidateStreamBufferViews(const RHI::InputStreamLayout& inputStreamLayout, AZStd::span streamBufferViews) { bool ok = true; diff --git a/Gems/Atom/RHI/Code/Source/RHI/StreamingImagePool.cpp b/Gems/Atom/RHI/Code/Source/RHI/StreamingImagePool.cpp index 6db8da3b55..7bddb4d2f4 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/StreamingImagePool.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/StreamingImagePool.cpp @@ -14,7 +14,7 @@ namespace AZ StreamingImageInitRequest::StreamingImageInitRequest( Image& image, const ImageDescriptor& descriptor, - AZStd::array_view tailMipSlices) + AZStd::span tailMipSlices) : m_image{&image} , m_descriptor{descriptor} , m_tailMipSlices{tailMipSlices} diff --git a/Gems/Atom/RHI/Code/Source/RHI/TransientAttachmentPool.cpp b/Gems/Atom/RHI/Code/Source/RHI/TransientAttachmentPool.cpp index 4e5f83fa8c..2169fcd5d7 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/TransientAttachmentPool.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/TransientAttachmentPool.cpp @@ -117,7 +117,7 @@ namespace AZ return m_compileFlags; } - void TransientAttachmentPool::CollectHeapStats(AliasedResourceTypeFlags typeMask, AZStd::array_view heapStats) + void TransientAttachmentPool::CollectHeapStats(AliasedResourceTypeFlags typeMask, AZStd::span heapStats) { // [GFX_TODO][ATOM-4162] Report the memory allocated stat correctly (or as close as possible) when the heap // supports multiple resource types. Right now we are assigning all the memory used to one resource type. diff --git a/Gems/Atom/RHI/Code/Tests/InputStreamLayoutBuilderTests.cpp b/Gems/Atom/RHI/Code/Tests/InputStreamLayoutBuilderTests.cpp index 07b9078a4c..8b5bac4374 100644 --- a/Gems/Atom/RHI/Code/Tests/InputStreamLayoutBuilderTests.cpp +++ b/Gems/Atom/RHI/Code/Tests/InputStreamLayoutBuilderTests.cpp @@ -20,7 +20,7 @@ namespace UnitTest { protected: - void ExpectEq(AZStd::array_view expected, AZStd::array_view actual) + void ExpectEq(AZStd::span expected, AZStd::span actual) { EXPECT_EQ(expected.size(), actual.size()); for (int i = 0; i < expected.size() && i < actual.size(); ++i) @@ -31,7 +31,7 @@ namespace UnitTest } } - void ExpectEq(AZStd::array_view expected, AZStd::array_view actual) + void ExpectEq(AZStd::span expected, AZStd::span actual) { EXPECT_EQ(expected.size(), actual.size()); for (int i = 0; i < expected.size() && i < actual.size(); ++i) diff --git a/Gems/Atom/RHI/Code/Tests/PipelineState.cpp b/Gems/Atom/RHI/Code/Tests/PipelineState.cpp index 248f4d4b60..eefd6931a1 100644 --- a/Gems/Atom/RHI/Code/Tests/PipelineState.cpp +++ b/Gems/Atom/RHI/Code/Tests/PipelineState.cpp @@ -28,7 +28,7 @@ namespace UnitTest { } - RHI::ResultCode PipelineLibrary::MergeIntoInternal([[maybe_unused]] AZStd::array_view libraries) + RHI::ResultCode PipelineLibrary::MergeIntoInternal([[maybe_unused]] AZStd::span libraries) { return RHI::ResultCode::Success; } diff --git a/Gems/Atom/RHI/Code/Tests/PipelineState.h b/Gems/Atom/RHI/Code/Tests/PipelineState.h index 93478a8d73..ddaedfd73b 100644 --- a/Gems/Atom/RHI/Code/Tests/PipelineState.h +++ b/Gems/Atom/RHI/Code/Tests/PipelineState.h @@ -25,7 +25,7 @@ namespace UnitTest private: AZ::RHI::ResultCode InitInternal(AZ::RHI::Device&, const AZ::RHI::PipelineLibraryData*) override { return AZ::RHI::ResultCode::Success; } void ShutdownInternal() override; - AZ::RHI::ResultCode MergeIntoInternal(AZStd::array_view) override; + AZ::RHI::ResultCode MergeIntoInternal(AZStd::span) override; AZ::RHI::ConstPtr GetSerializedDataInternal() const override { return nullptr; } }; diff --git a/Gems/Atom/RHI/Code/Tests/RenderAttachmentLayoutBuilderTests.cpp b/Gems/Atom/RHI/Code/Tests/RenderAttachmentLayoutBuilderTests.cpp index fef484a3cd..2ed68750ad 100644 --- a/Gems/Atom/RHI/Code/Tests/RenderAttachmentLayoutBuilderTests.cpp +++ b/Gems/Atom/RHI/Code/Tests/RenderAttachmentLayoutBuilderTests.cpp @@ -21,13 +21,13 @@ namespace UnitTest protected: template - void ExpectEqMemory(AZStd::array_view expected, AZStd::array_view actual) + void ExpectEqMemory(AZStd::span expected, AZStd::span actual) { EXPECT_EQ(expected.size(), actual.size()); EXPECT_TRUE(memcmp(expected.data(), actual.data(), expected.size() * sizeof(T)) == 0); } - void ExpectEq(AZStd::array_view expected, AZStd::array_view actual) + void ExpectEq(AZStd::span expected, AZStd::span actual) { EXPECT_EQ(expected.size(), actual.size()); for (int i = 0; i < expected.size() && i < actual.size(); ++i) diff --git a/Gems/Atom/RHI/Code/Tests/ShaderResourceGroupTests.cpp b/Gems/Atom/RHI/Code/Tests/ShaderResourceGroupTests.cpp index 83b3b68b25..9544bd971a 100644 --- a/Gems/Atom/RHI/Code/Tests/ShaderResourceGroupTests.cpp +++ b/Gems/Atom/RHI/Code/Tests/ShaderResourceGroupTests.cpp @@ -316,7 +316,7 @@ namespace UnitTest const auto ValidateFloat4Values = [&]() { - AZStd::array_view float4ValueResult = srgData.GetConstantArray(float4ValueIndex); + AZStd::span float4ValueResult = srgData.GetConstantArray(float4ValueIndex); EXPECT_EQ(float4ValueResult.size(), 4); EXPECT_EQ(float4ValueResult[0], float4Values[0]); EXPECT_EQ(float4ValueResult[1], float4Values[1]); @@ -324,13 +324,13 @@ namespace UnitTest EXPECT_EQ(float4ValueResult[3], float4Values[3]); }; - AZStd::array_view uintValuesResult = srgData.GetConstantArray(uintValueIndex); + AZStd::span uintValuesResult = srgData.GetConstantArray(uintValueIndex); EXPECT_EQ(uintValuesResult.size(), 3); EXPECT_EQ(uintValuesResult[0], uintValues[0]); EXPECT_EQ(uintValuesResult[1], uintValues[1]); EXPECT_EQ(uintValuesResult[2], uintValues[2]); - AZStd::array_view nestedDataResult = srgData.GetConstantArray(nestedDataIndex); + AZStd::span nestedDataResult = srgData.GetConstantArray(nestedDataIndex); EXPECT_EQ(nestedDataResult.size(), 16); ValidateFloat4Values(); @@ -484,17 +484,17 @@ namespace UnitTest const Vector4 vector4 = Vector4::CreateFromFloat4(vector4values); EXPECT_TRUE(srgData.SetConstant(vector2index, vector2)); - AZStd::array_view resultVector2 = srgData.GetConstantRaw(vector2index); + AZStd::span resultVector2 = srgData.GetConstantRaw(vector2index); const Vector2 vector2result = *reinterpret_cast(resultVector2.data()); EXPECT_EQ(vector2result, vector2); EXPECT_TRUE(srgData.SetConstant(vector3index, vector3)); - AZStd::array_view resutVector3 = srgData.GetConstantRaw(vector3index); + AZStd::span resutVector3 = srgData.GetConstantRaw(vector3index); const Vector3 vector3result = *reinterpret_cast(resutVector3.data()); EXPECT_EQ(vector3result, vector3); EXPECT_TRUE(srgData.SetConstant(vector4index, vector4)); - AZStd::array_view resutVector4 = srgData.GetConstantRaw(vector4index); + AZStd::span resutVector4 = srgData.GetConstantRaw(vector4index); const Vector4 vector4result = *reinterpret_cast(resutVector4.data()); EXPECT_EQ(vector4result, vector4); } @@ -524,7 +524,7 @@ namespace UnitTest AZ_TEST_START_ASSERTTEST; EXPECT_FALSE(srgData.SetConstant(vector2index, vector3)); AZ_TEST_STOP_ASSERTTEST(1); - AZStd::array_view resutV3 = srgData.GetConstantRaw(vector2index); + AZStd::span resutV3 = srgData.GetConstantRaw(vector2index); const Vector3 v3result = *reinterpret_cast(resutV3.data()); EXPECT_NE(v3result, vector3); @@ -534,7 +534,7 @@ namespace UnitTest AZ_TEST_START_ASSERTTEST; EXPECT_FALSE(srgData.SetConstant(vector3index, vector4)); AZ_TEST_STOP_ASSERTTEST(1); - AZStd::array_view resutV4 = srgData.GetConstantRaw(vector3index); + AZStd::span resutV4 = srgData.GetConstantRaw(vector3index); const Vector4 v4result = *reinterpret_cast(resutV4.data()); EXPECT_NE(v4result, vector4); @@ -544,7 +544,7 @@ namespace UnitTest AZ_TEST_START_ASSERTTEST; EXPECT_FALSE(srgData.SetConstant(vector4index, vector3)); AZ_TEST_STOP_ASSERTTEST(1); - AZStd::array_view resutV3FromIndex4 = srgData.GetConstantRaw(vector4index); + AZStd::span resutV3FromIndex4 = srgData.GetConstantRaw(vector4index); const Vector4 v4resultFromIndex4 = *reinterpret_cast(resutV3FromIndex4.data()); EXPECT_NE(v4resultFromIndex4, vector4); } diff --git a/Gems/Atom/RHI/DX12/Code/Include/Atom/RHI.Reflect/DX12/ShaderStageFunction.h b/Gems/Atom/RHI/DX12/Code/Include/Atom/RHI.Reflect/DX12/ShaderStageFunction.h index e2c325d406..fa04c3a241 100644 --- a/Gems/Atom/RHI/DX12/Code/Include/Atom/RHI.Reflect/DX12/ShaderStageFunction.h +++ b/Gems/Atom/RHI/DX12/Code/Include/Atom/RHI.Reflect/DX12/ShaderStageFunction.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ namespace AZ namespace DX12 { using ShaderByteCode = AZStd::vector; - using ShaderByteCodeView = AZStd::array_view; + using ShaderByteCodeView = AZStd::span; /** * A set of indices used to access physical sub-stages within a virtual stage. diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.h b/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.h index a468ee4bc2..870d8eef19 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.h +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.h @@ -9,7 +9,7 @@ #include -#include +#include namespace AZ { diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.cpp index 25b412fbe1..a3026b592e 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.cpp @@ -129,14 +129,14 @@ namespace AZ const RHI::Viewport* viewports, uint32_t count) { - m_state.m_viewportState.Set(AZStd::array_view(viewports, count)); + m_state.m_viewportState.Set(AZStd::span(viewports, count)); } void CommandList::SetScissors( const RHI::Scissor* scissors, uint32_t count) { - m_state.m_scissorState.Set(AZStd::array_view(scissors, count)); + m_state.m_scissorState.Set(AZStd::span(scissors, count)); } void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup) diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h index da71d669b4..1c02af1fdf 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/PipelineLibrary.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/PipelineLibrary.cpp index ae3053f446..0f1fab642a 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/PipelineLibrary.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/PipelineLibrary.cpp @@ -46,7 +46,7 @@ namespace AZ ID3D12DeviceX* dx12Device = device.GetDevice(); #if defined (AZ_DX12_USE_PIPELINE_LIBRARY) - AZStd::array_view bytes; + AZStd::span bytes; bool shouldCreateLibFromSerializedData = true; if (RHI::Factory::Get().IsRenderDocModuleLoaded() || @@ -214,7 +214,7 @@ namespace AZ #endif } - RHI::ResultCode PipelineLibrary::MergeIntoInternal([[maybe_unused]] AZStd::array_view pipelineLibraries) + RHI::ResultCode PipelineLibrary::MergeIntoInternal([[maybe_unused]] AZStd::span pipelineLibraries) { if (RHI::Factory::Get().IsRenderDocModuleLoaded() || RHI::Factory::Get().IsPixModuleLoaded()) @@ -239,14 +239,14 @@ namespace AZ } } #endif - return RHI::ResultCode::Success; + return RHI::ResultCode::Success; } RHI::ConstPtr PipelineLibrary::GetSerializedDataInternal() const { #if defined (AZ_DX12_USE_PIPELINE_LIBRARY) AZStd::lock_guard lock(m_mutex); - + AZStd::vector serializedData(m_library->GetSerializedSize()); HRESULT hr = m_library->Serialize(serializedData.data(), serializedData.size()); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/PipelineLibrary.h b/Gems/Atom/RHI/DX12/Code/Source/RHI/PipelineLibrary.h index b970882246..f34c5bf8ae 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/PipelineLibrary.h +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/PipelineLibrary.h @@ -33,7 +33,7 @@ namespace AZ // RHI::PipelineLibrary RHI::ResultCode InitInternal(RHI::Device& device, const RHI::PipelineLibraryData* serializedData) override; void ShutdownInternal() override; - RHI::ResultCode MergeIntoInternal(AZStd::array_view libraries) override; + RHI::ResultCode MergeIntoInternal(AZStd::span libraries) override; RHI::ConstPtr GetSerializedDataInternal() const override; bool IsMergeRequired() const; ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/ShaderResourceGroupPool.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/ShaderResourceGroupPool.cpp index e2573c72d9..9ec074cd81 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/ShaderResourceGroupPool.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/ShaderResourceGroupPool.cpp @@ -20,7 +20,7 @@ namespace AZ namespace DX12 { template - AZStd::vector ShaderResourceGroupPool::GetSRVsFromImageViews(const AZStd::array_view>& imageViews, D3D12_SRV_DIMENSION dimension) + AZStd::vector ShaderResourceGroupPool::GetSRVsFromImageViews(const AZStd::span>& imageViews, D3D12_SRV_DIMENSION dimension) { AZStd::vector cpuSourceDescriptors(imageViews.size(), m_descriptorContext->GetNullHandleSRV(dimension)); @@ -36,7 +36,7 @@ namespace AZ } template - AZStd::vector ShaderResourceGroupPool::GetUAVsFromImageViews(const AZStd::array_view>& imageViews, D3D12_UAV_DIMENSION dimension) + AZStd::vector ShaderResourceGroupPool::GetUAVsFromImageViews(const AZStd::span>& imageViews, D3D12_UAV_DIMENSION dimension) { AZStd::vector cpuSourceDescriptors(imageViews.size(), m_descriptorContext->GetNullHandleUAV(dimension)); for (size_t i = 0; i < cpuSourceDescriptors.size(); ++i) @@ -50,7 +50,7 @@ namespace AZ return cpuSourceDescriptors; } - AZStd::vector ShaderResourceGroupPool::GetCBVsFromBufferViews(const AZStd::array_view>& bufferViews) + AZStd::vector ShaderResourceGroupPool::GetCBVsFromBufferViews(const AZStd::span>& bufferViews) { AZStd::vector cpuSourceDescriptors(bufferViews.size(), m_descriptorContext->GetNullHandleCBV()); @@ -278,7 +278,7 @@ namespace AZ { const RHI::ShaderInputBufferIndex bufferInputIndex(shaderInputIndex); - AZStd::array_view> bufferViews = groupData.GetBufferViewArray(bufferInputIndex); + AZStd::span> bufferViews = groupData.GetBufferViewArray(bufferInputIndex); D3D12_DESCRIPTOR_RANGE_TYPE descriptorRangeType = ConvertShaderInputBufferAccess(shaderInputBuffer.m_access); AZStd::vector descriptorHandles; switch (descriptorRangeType) @@ -313,7 +313,7 @@ namespace AZ { const RHI::ShaderInputImageIndex imageInputIndex(shaderInputIndex); - AZStd::array_view> imageViews = groupData.GetImageViewArray(imageInputIndex); + AZStd::span> imageViews = groupData.GetImageViewArray(imageInputIndex); D3D12_DESCRIPTOR_RANGE_TYPE descriptorRangeType = ConvertShaderInputImageAccess(shaderInputImage.m_access); AZStd::vector descriptorHandles; @@ -349,7 +349,7 @@ namespace AZ { const RHI::ShaderInputSamplerIndex samplerInputIndex(shaderInputIndex); - AZStd::array_view samplers = groupData.GetSamplerArray(samplerInputIndex); + AZStd::span samplers = groupData.GetSamplerArray(samplerInputIndex); UpdateDescriptorTableRange(descriptorTable, samplerInputIndex, samplers); } } @@ -364,7 +364,7 @@ namespace AZ for (const RHI::ShaderInputBufferUnboundedArrayDescriptor& shaderInputBufferUnboundedArray : groupLayout.GetShaderInputListForBufferUnboundedArrays()) { const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex); - AZStd::array_view> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex); + AZStd::span> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex); uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex; @@ -403,7 +403,7 @@ namespace AZ for (const RHI::ShaderInputImageUnboundedArrayDescriptor& shaderInputImageUnboundedArray : groupLayout.GetShaderInputListForImageUnboundedArrays()) { const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex); - AZStd::array_view> imageViews = groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex); + AZStd::span> imageViews = groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex); uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex; @@ -447,7 +447,7 @@ namespace AZ RHI::ShaderInputBufferAccess bufferAccess) { const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex); - AZStd::array_view> bufferViews = + AZStd::span> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex); if (bufferViews.empty()) @@ -488,7 +488,7 @@ namespace AZ RHI::ShaderInputImageType imageType) { const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex); - AZStd::array_view> imageViews = + AZStd::span> imageViews = groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex); if (imageViews.empty()) @@ -565,7 +565,7 @@ namespace AZ for (const RHI::ShaderInputBufferUnboundedArrayDescriptor& shaderInputBufferUnboundedArray : groupLayout.GetShaderInputListForBufferUnboundedArrays()) { const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex); - AZStd::array_view> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex); + AZStd::span> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex); uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex; if (!bufferViews.empty()) @@ -597,7 +597,7 @@ namespace AZ groupLayout.GetShaderInputListForImageUnboundedArrays()) { const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex); - AZStd::array_view> imageViews = + AZStd::span> imageViews = groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex); uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex; @@ -675,7 +675,7 @@ namespace AZ void ShaderResourceGroupPool::UpdateDescriptorTableRange( DescriptorTable descriptorTable, RHI::ShaderInputSamplerIndex samplerInputIndex, - AZStd::array_view samplerStates) + AZStd::span samplerStates) { const DescriptorHandle nullHandle = m_descriptorContext->GetNullHandleSampler(); AZStd::vector cpuSourceDescriptors(aznumeric_caster(samplerStates.size()), nullHandle); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/ShaderResourceGroupPool.h b/Gems/Atom/RHI/DX12/Code/Source/RHI/ShaderResourceGroupPool.h index e1b2145097..2c375f7385 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/ShaderResourceGroupPool.h +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/ShaderResourceGroupPool.h @@ -82,7 +82,7 @@ namespace AZ void UpdateDescriptorTableRange( DescriptorTable descriptorTable, RHI::ShaderInputSamplerIndex samplerIndex, - AZStd::array_view samplerStates); + AZStd::span samplerStates); //Cache all the gpu handles for the Descriptor tables related to all the views void CacheGpuHandlesForViews(ShaderResourceGroup& group); @@ -93,12 +93,12 @@ namespace AZ DescriptorTable GetSamplerTable(DescriptorTable descriptorTable, RHI::ShaderInputSamplerIndex samplerInputIndex) const; template - AZStd::vector GetSRVsFromImageViews(const AZStd::array_view>& imageViews, D3D12_SRV_DIMENSION dimension); + AZStd::vector GetSRVsFromImageViews(const AZStd::span>& imageViews, D3D12_SRV_DIMENSION dimension); template - AZStd::vector GetUAVsFromImageViews(const AZStd::array_view>& bufferViews, D3D12_UAV_DIMENSION dimension); + AZStd::vector GetUAVsFromImageViews(const AZStd::span>& bufferViews, D3D12_UAV_DIMENSION dimension); - AZStd::vector GetCBVsFromBufferViews(const AZStd::array_view>& bufferViews); + AZStd::vector GetCBVsFromBufferViews(const AZStd::span>& bufferViews); MemoryPoolSubAllocator m_constantAllocator; DescriptorContext* m_descriptorContext = nullptr; diff --git a/Gems/Atom/RHI/Metal/Code/Include/Atom/RHI.Reflect/Metal/ShaderStageFunction.h b/Gems/Atom/RHI/Metal/Code/Include/Atom/RHI.Reflect/Metal/ShaderStageFunction.h index cb655cd1b6..8069e32644 100644 --- a/Gems/Atom/RHI/Metal/Code/Include/Atom/RHI.Reflect/Metal/ShaderStageFunction.h +++ b/Gems/Atom/RHI/Metal/Code/Include/Atom/RHI.Reflect/Metal/ShaderStageFunction.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp index 8c80205c17..79660f6382 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp @@ -53,7 +53,7 @@ namespace AZ { return AZ::Metal::PipelineLayoutDescriptor::Create(); } - + bool ShaderPlatformInterface::BuildPipelineLayoutDescriptor( RHI::Ptr pipelineLayoutDescriptor, const ShaderResourceGroupInfoList& srgInfoList, @@ -62,10 +62,10 @@ namespace AZ { AZ::Metal::PipelineLayoutDescriptor* metalDescriptor = azrtti_cast(pipelineLayoutDescriptor.get()); AZ_Assert(metalDescriptor, "PipelineLayoutDescriptor should have been created by now"); - + const uint32_t groupLayoutCount = static_cast(srgInfoList.size()); AZ_Assert(groupLayoutCount <= RHI::Limits::Pipeline::ShaderResourceGroupCountMax, "Exceeded ShaderResourceGroupLayout count limit."); - + // Slot to index mapping AZ::Metal::SlotToIndexTable slotToIndexTable; AZ::Metal::IndexToSlotTable indexToSlotTable; @@ -81,17 +81,17 @@ namespace AZ { return first.m_layout->GetBindingSlot() < second.m_layout->GetBindingSlot(); }); - + for (uint32_t groupLayoutIndex = 0; groupLayoutIndex < groupLayoutCount; ++groupLayoutIndex) { const auto& srgInfo = sortedSrgInfos[groupLayoutIndex]; const RHI::ShaderResourceGroupLayout& groupLayout = *srgInfo.m_layout; const uint32_t srgLayoutSlot = groupLayout.GetBindingSlot(); - + AZ_Assert(srgLayoutSlot <= RHI::Limits::Pipeline::ShaderResourceGroupCountMax, "Cannot exceed the array limit"); slotToIndexTable[srgLayoutSlot] = groupLayoutIndex; indexToSlotTable[groupLayoutIndex] = srgLayoutSlot; - + ShaderResourceGroupVisibility srgVisibility; for (const auto& resourceBindInfo : srgInfo.m_bindingInfo.m_resourcesRegisterMap) { @@ -99,24 +99,24 @@ namespace AZ } srgVisibility.m_constantDataStageMask = srgInfo.m_bindingInfo.m_constantDataBindingInfo.m_shaderStageMask; metalDescriptor->AddShaderResourceGroupVisibility(srgVisibility); - + //cache the layout in order to fill out unused variables m_srgLayouts[groupLayoutIndex] = srgInfo.m_layout; } - + if (rootConstantsInfo.m_totalSizeInBytes > 0) { metalDescriptor->SetRootConstantBinding(RootConstantBinding{ rootConstantsInfo.m_registerId, rootConstantsInfo.m_spaceId }); } - + metalDescriptor->SetBindingTables(slotToIndexTable, indexToSlotTable); return metalDescriptor->Finalize() == RHI::ResultCode::Success; } - + RHI::Ptr ShaderPlatformInterface::CreateShaderStageFunction(const StageDescriptor& stageDescriptor) { RHI::Ptr newShaderStageFunction = ShaderStageFunction::Create(RHI::ToRHIShaderStage(stageDescriptor.m_stageType)); - + const Metal::ShaderSourceCode& sourceCode = stageDescriptor.m_sourceCode; //Metal sourceCode is great for debugging but it is not needed as we are also packing the bytecode. This @@ -127,7 +127,7 @@ namespace AZ const AZStd::string& entryFunctionName = stageDescriptor.m_entryFunctionName; newShaderStageFunction->SetByteCode(byteCode); newShaderStageFunction->SetEntryFunctionName(entryFunctionName); - + newShaderStageFunction->Finalize(); return newShaderStageFunction; } @@ -159,7 +159,7 @@ namespace AZ return shaderCompilerArguments.MakeAdditionalAzslcCommandLineString() + " --use-spaces --unique-idx --namespace=mt,vk --root-const=128 --pad-root-const"; } - + AZStd::string ShaderPlatformInterface::GetAzslCompilerWarningParameters(const RHI::ShaderCompilerArguments& shaderCompilerArguments) const { return shaderCompilerArguments.MakeAdditionalAzslcWarningCommandLineString(); @@ -255,7 +255,7 @@ namespace AZ // Stage profile name parameter const AZStd::string shaderModelVersion = "6_2"; - + const AZStd::unordered_map stageToProfileName = { {RHI::ShaderHardwareStage::Vertex, "vs_" + shaderModelVersion}, @@ -268,15 +268,15 @@ namespace AZ AZ_Error(MetalShaderPlatformName, false, "Unsupported shader stage"); return false; } - + // For this approach we will be doing hlsl->spirv(through dxc) and spirv->metalSL(through spirv cross) // Output spirv file AZStd::string shaderSpirvOutputFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "spirv"); - + // Compilation parameters AZStd::string params = shaderCompilerArguments.MakeAdditionalDxcCommandLineString(); params += " -spirv"; // Generate SPIRV shader - + // Enable half precision types when shader model >= 6.2 int shaderModelMajor = 0; int shaderModelMinor = 0; @@ -318,7 +318,7 @@ namespace AZ params.c_str(), // 3 shaderSpirvOutputFile.c_str(), // 4 dxcInputFile.c_str()); // 5 - + // Run dxc Compiler if (!RHI::ExecuteShaderCompiler(dxcRelativePath, dxcCommandOptions, shaderSourceFile, "DXC")) { @@ -329,9 +329,9 @@ namespace AZ { byProducts.m_intermediatePaths.insert(shaderSpirvOutputFile); // the spirv spit by DXC } - + IO::FileIOStream spirvOutFileStream(shaderSpirvOutputFile.data(), AZ::IO::OpenMode::ModeRead | AZ::IO::OpenMode::ModeBinary); - + if (!spirvOutFileStream.IsOpen()) { AZ_Error(MetalShaderPlatformName, false, "Failed because the shader file \"%s\" could not be opened", shaderSpirvOutputFile.data()); @@ -343,12 +343,12 @@ namespace AZ spirvOutFileStream.Close(); return false; } - + // spirv cross compiler executable static const char* spirvCrossRelativePath = "Builders/SPIRVCross/spirv-cross"; - + AZStd::string spirvCrossCommandOptions = AZStd::string::format("--msl --msl-version 20100 --msl-invariant-float-math --msl-argument-buffers --msl-decoration-binding --msl-texture-buffer-native --output \"%s\" \"%s\"", shaderMSLOutputFile.c_str(), shaderSpirvOutputFile.c_str()); - + // Run spirv cross if (!RHI::ExecuteShaderCompiler(spirvCrossRelativePath, spirvCrossCommandOptions, shaderSpirvOutputFile, "SpirvCross")) { @@ -357,7 +357,7 @@ namespace AZ return false; } spirvOutFileStream.Close(); - + IO::FileIOStream outFileStream(shaderMSLOutputFile.data(), IO::OpenMode::ModeRead); bool finalizeShaderResult = UpdateCompiledShader(outFileStream, MetalShaderPlatformName, shaderMSLOutputFile.data(), sourceMetalShader); AZ_Assert(finalizeShaderResult, "Final compiled shader was not created. Check if %s was created", shaderMSLOutputFile.c_str()); @@ -366,7 +366,7 @@ namespace AZ { byProducts.m_intermediatePaths.emplace(AZStd::move(shaderMSLOutputFile)); // .msl metal out of sv-cross } - + bool compileMetalSL = CreateMetalLib(MetalShaderPlatformName, shaderSourceFile, tempFolder, compiledByteCode, sourceMetalShader, platform); if (!compileMetalSL) { @@ -376,7 +376,7 @@ namespace AZ return finalizeShaderResult; } - + bool ShaderPlatformInterface::UpdateCompiledShader(AZ::IO::FileIOStream& fileStream, const char* platformName, const char* fileName, AZStd::vector& compiledShader) const { if (!fileStream.IsOpen()) @@ -390,16 +390,16 @@ namespace AZ fileStream.Close(); return false; } - + compiledShader.resize(fileStream.GetLength() + 1); // +1 to add end of string memset(compiledShader.data(), 0, fileStream.GetLength() + 1); fileStream.Read(fileStream.GetLength(), compiledShader.data()); fileStream.Close(); - + //Ensure that the argument buffer declaration in the shader matches the srg layout return AddUnusedResources(compiledShader); } - + bool ShaderPlatformInterface::CreateMetalLib(const char* platformName, const AZStd::string& shaderSourceFile, const AZStd::string& tempFolder, @@ -408,22 +408,22 @@ namespace AZ const AssetBuilderSDK::PlatformInfo& platform) const { AZStd::string inputMetalFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "metal"); - + AZ::IO::FileIOStream sourceMtlfileStream(inputMetalFile.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary); if (!sourceMtlfileStream.IsOpen()) { AZ_Error(platformName, false, "Failed because the shader file \"%s\" could not be opened", inputMetalFile.c_str()); return false; } - + AZStd::string mtlSource = AZStd::string(sourceMetalShader.begin(), sourceMetalShader.end()); sourceMtlfileStream.Write(mtlSource.size(), mtlSource.data()); sourceMtlfileStream.Close(); - + AZStd::string outputAirFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "air"); AZStd::string outMetalLibFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "metallib"); - - //Debug symbols are always enabled at the moment. Need to turn them off for optimized shader assets. + + //Debug symbols are always enabled at the moment. Need to turn them off for optimized shader assets. AZStd::string shaderDebugInfo = "-gline-tables-only -MO"; AZStd::string shaderMslToAirOptions = "-fpreserve-invariance"; @@ -434,47 +434,47 @@ namespace AZ { platformSdk = "iphoneos"; } - + //Convert to air file AZStd::string mslToAirCommandOptions = AZStd::string::format("-sdk %s metal \"%s\" %s %s -c -o \"%s\"", platformSdk.c_str(), inputMetalFile.c_str(), shaderDebugInfo.c_str(), shaderMslToAirOptions.c_str(), outputAirFile.c_str()); - + if (!RHI::ExecuteShaderCompiler("/usr/bin/xcrun", mslToAirCommandOptions, inputMetalFile, "MslToAir")) { AZ_Error(MetalShaderPlatformName, false, "Failed to convert to AIR file %s", inputMetalFile.c_str()); return false; } - + //convert to metallib AZStd::string airToMetalLibCommandOptions = AZStd::string::format("-sdk %s metallib \"%s\" -o \"%s\"", platformSdk.c_str(), outputAirFile.c_str(), outMetalLibFile.c_str()); - + if (!RHI::ExecuteShaderCompiler("/usr/bin/xcrun", airToMetalLibCommandOptions, outputAirFile, "AirToMetallib")) { AZ_Error(MetalShaderPlatformName, false, "Failed to convert to metallib file"); return false; } - + AZ::IO::FileIOStream fileStream(outMetalLibFile.data(), AZ::IO::OpenMode::ModeRead); compiledByteCode.resize(fileStream.GetLength()); memset(compiledByteCode.data(), 0, fileStream.GetLength() ); fileStream.Read(fileStream.GetLength(), compiledByteCode.data()); fileStream.Close(); - + return true; } - + bool ShaderPlatformInterface::AddUnusedResources(AZStd::vector& compiledShader) const { AZStd::string finalMetalSLStr = AZStd::string(compiledShader.begin(), compiledShader.end()); - + const uint32_t groupLayoutCount = static_cast(m_srgLayouts.size()); AZStd::string constantBufferTempStructs = "\n"; AZStd::string structuredBufferTempStructs = "\n"; - + for (uint32_t groupLayoutIndex = 0; groupLayoutIndex < groupLayoutCount; ++groupLayoutIndex) { //const auto& srgInfo = m_srgInfoList[groupLayoutIndex]; const RHI::ShaderResourceGroupLayout& groupLayout = *m_srgLayouts[groupLayoutIndex]; - + //Check if an argument buffer declaration exists for this srg layout. AZStd::string srgBuffer = AZStd::string::format("spvDescriptorSetBuffer%i", groupLayoutIndex); size_t startOfArgBufferPos = finalMetalSLStr.find(srgBuffer); @@ -485,7 +485,7 @@ namespace AZ size_t endOfArgBufferPos = finalMetalSLStr.find("}", startOfArgBufferPos); AZStd::string fullArgBufferDeclarationStr = finalMetalSLStr.substr(startOfArgBufferPos,endOfArgBufferPos - startOfArgBufferPos + 1); - + //Add all the existing or dummy entries into m_argBufferEntries which is a set. The reason for using a set //is because we need the entries to be sorted based on the register and we do not want duplicates. bool result = AddConstantBufferEntries(groupLayout, constantBufferTempStructs, fullArgBufferDeclarationStr, groupLayoutIndex); @@ -494,44 +494,44 @@ namespace AZ AZ_Error(MetalShaderPlatformName, false, "Failed because adding constant buffer entries within AddUnusedResources failed"); return false; } - + result = AddImageEntries(groupLayout, fullArgBufferDeclarationStr); if(!result) { AZ_Error(MetalShaderPlatformName, false, "Failed because adding image entries within AddUnusedResources failed"); return false; } - + result = AddSamplerEntries(groupLayout, fullArgBufferDeclarationStr); if(!result) { AZ_Error(MetalShaderPlatformName, false, "Failed because adding static sampler entries within AddUnusedResources failed"); return false; } - + result = AddBufferEntries(groupLayout, structuredBufferTempStructs, fullArgBufferDeclarationStr, groupLayoutIndex); if(!result) { AZ_Error(MetalShaderPlatformName, false, "Failed because adding buffer entries within AddUnusedResources failed"); return false; } - + //Create a new spvDescriptorSetBuffer which matches the layout. AZStd::string newArgBufferLayoutStr = "\n"; for (const ArgBufferEntries &entry : m_argBufferEntries ) { newArgBufferLayoutStr += " " + entry.first + "\n"; } - + //Replace the existing declaration with the new one just generated. //We look for '{' and '}' to find out boundaries of the argument buffer declaration to replace size_t startOfArgBufferBracketPos = finalMetalSLStr.find("{", startOfArgBufferPos) + 1; size_t endOfArgBufferBracketPos = finalMetalSLStr.find("}", startOfArgBufferBracketPos) - 1; finalMetalSLStr.replace(startOfArgBufferBracketPos, endOfArgBufferBracketPos - startOfArgBufferBracketPos, newArgBufferLayoutStr); - + m_argBufferEntries.clear(); } - + //Add dummy definitions of constant buffer and structured buffer types to the top of the file AZStd::string startOfShaderTag = "using namespace metal;"; const size_t startOfShaderPos = finalMetalSLStr.find(startOfShaderTag); @@ -540,28 +540,28 @@ namespace AZ finalMetalSLStr.insert(startOfShaderPos + startOfShaderTag.length() + 1, constantBufferTempStructs); finalMetalSLStr.insert(startOfShaderPos + startOfShaderTag.length() + 1, structuredBufferTempStructs); } - + compiledShader = AZStd::vector(finalMetalSLStr.begin(), finalMetalSLStr.end()); return true; } - + bool ShaderPlatformInterface::AddConstantBufferEntries(const RHI::ShaderResourceGroupLayout& groupLayout, AZStd::string& constantBufferTempStructs, AZStd::string& argBufferStr, uint32_t groupLayoutIndex) const { - AZStd::array_view shaderInputConstantList = groupLayout.GetShaderInputListForConstants(); + AZStd::span shaderInputConstantList = groupLayout.GetShaderInputListForConstants(); if (shaderInputConstantList.empty()) { return true; } - + //Only need the information from the first element of the constant buffer. const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0]; - + uint32_t regId = shaderInputConstant.m_registerId; AZStd::string srgResource = AZStd::string::format("id(%i)", regId); - + size_t resourceStartPos = argBufferStr.find(srgResource); //Check if we need to create a dummy entry if (resourceStartPos == AZStd::string::npos) @@ -578,7 +578,7 @@ namespace AZ * */ constantBufferTempStructs += AZStd::string::format("struct type_DummyStruct%i_DescSet%i\n{\n float dummyArray[%i];\n};\n", regId, groupLayoutIndex, numElements); - + //Create the final resource entry to be added to the set AZStd::string dummyResource = AZStd::string::format("constant type_DummyStruct%i_DescSet%i* dummyConstantBuffer%i [[id(%i)]];", regId, groupLayoutIndex, regId, regId); m_argBufferEntries.insert(AZStd::make_pair(dummyResource, regId)); @@ -590,7 +590,7 @@ namespace AZ return AddExistingResourceEntry("constant type_ConstantBuffer", resourceStartPos, regId, argBufferStr); } } - + bool ShaderPlatformInterface::AddImageEntries(const RHI::ShaderResourceGroupLayout& groupLayout, AZStd::string& argBufferStr) const { @@ -599,7 +599,7 @@ namespace AZ { uint32_t regId = shaderInputImage.m_registerId; AZStd::string srgResource = AZStd::string::format("id(%i)", regId); - + const size_t resourceStartPos = argBufferStr.find(srgResource); //Check if we need to create a dummy entry if (resourceStartPos == AZStd::string::npos) @@ -652,7 +652,7 @@ namespace AZ AZ_Assert(false, "Invalid texture type."); } } - + //Create the resource entry to be added to the set. Handle arrays by checking the shaderInputImage.m_count AZStd::string dummyResource; if(shaderInputImage.m_count > 1) @@ -678,11 +678,11 @@ namespace AZ } return result; } - + bool ShaderPlatformInterface::ProcessSamplerEntry(uint32_t regId, AZStd::string& argBufferStr, uint32_t samplercount) const { AZStd::string srgResource = AZStd::string::format("id(%i)", regId); - + const size_t resourceStartPos = argBufferStr.find(srgResource); //Check if we need to create a dummy entry if (resourceStartPos == AZStd::string::npos) @@ -705,7 +705,7 @@ namespace AZ return AddExistingResourceEntry("sampler", resourceStartPos, regId, argBufferStr); } } - + bool ShaderPlatformInterface::AddSamplerEntries(const RHI::ShaderResourceGroupLayout& groupLayout, AZStd::string& argBufferStr) const { @@ -714,15 +714,15 @@ namespace AZ { result &= ProcessSamplerEntry(staticSampler.m_registerId, argBufferStr, 0); } - + for (const RHI::ShaderInputSamplerDescriptor& dynamicSampler : groupLayout.GetShaderInputListForSamplers()) { result &= ProcessSamplerEntry(dynamicSampler.m_registerId, argBufferStr, dynamicSampler.m_count); } - + return result; } - + bool ShaderPlatformInterface::AddBufferEntries(const RHI::ShaderResourceGroupLayout& groupLayout, AZStd::string& structuredBufferTempStructs, AZStd::string& argBufferStr, @@ -733,7 +733,7 @@ namespace AZ { uint32_t regId = shaderInputBuffer.m_registerId; AZStd::string srgResource = AZStd::string::format("id(%i)", regId); - + size_t resourceStartPos = argBufferStr.find(srgResource); //Check if we need to create a dummy entry if (resourceStartPos == AZStd::string::npos) @@ -755,7 +755,7 @@ namespace AZ */ structuredBufferTempStructs += AZStd::string::format("struct DummySRG_%s_DescSet%i\n{\n float dummyArray[%i];\n};\n", shaderInputBuffer.m_name.GetCStr(), groupLayoutIndex, numElements); structuredBufferTempStructs += AZStd::string::format("struct type_RWStructuredDummyBuffer%i_DescSet%i\n{\n DummySRG_%s_DescSet%i _m0[%i];\n};\n", regId, groupLayoutIndex, shaderInputBuffer.m_name.GetCStr(), groupLayoutIndex, shaderInputBuffer.m_count); - + //Create the final resource entry to be added to the set AZStd::string dummyResource = AZStd::string::format("device type_RWStructuredDummyBuffer%i_DescSet%i* dummyStructuredBuffer%i [[id(%i)]];", regId, groupLayoutIndex, regId, regId); m_argBufferEntries.insert(AZStd::make_pair(dummyResource, regId)); @@ -823,7 +823,7 @@ namespace AZ } return result; } - + bool ShaderPlatformInterface::AddExistingResourceEntry(const char* resourceStr, size_t resourceStartPos, uint32_t regId, @@ -832,8 +832,8 @@ namespace AZ size_t prevEndOfLine = argBufferStr.rfind("\n", resourceStartPos); size_t nextEndOfLine = argBufferStr.find("\n", resourceStartPos); size_t startOfEntryPos = argBufferStr.find(resourceStr, prevEndOfLine); - - //Check to see if a valid entry is found. + + //Check to see if a valid entry is found. if(startOfEntryPos == AZStd::string::npos || startOfEntryPos > nextEndOfLine) { AZ_Error(MetalShaderPlatformName, startOfEntryPos != AZStd::string::npos, "Entry-> %s not found within Descriptor set %s", resourceStr, argBufferStr.c_str()); @@ -843,7 +843,7 @@ namespace AZ { size_t endOfEntryPos = argBufferStr.find("\n", startOfEntryPos); AZ_Assert(endOfEntryPos != AZStd::string::npos, "Resource entry missing"); - + AZStd::string existingEntry = argBufferStr.substr(prevEndOfLine,endOfEntryPos - prevEndOfLine); m_argBufferEntries.insert(AZStd::make_pair(existingEntry, regId)); return true; diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp index b820a6bf76..6775258032 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp @@ -23,14 +23,14 @@ namespace AZ { return aznew ArgumentBuffer(); } - + void ArgumentBuffer::Init(Device* device, RHI::ConstPtr srgLayout, ShaderResourceGroup& group, ShaderResourceGroupPool* srgPool) { @autoreleasepool { m_device = device; m_srgLayout = srgLayout; - + m_constantBufferSize = srgLayout->GetConstantDataSize(); if (m_constantBufferSize) { @@ -47,23 +47,23 @@ namespace AZ m_constantBuffer.SetName(constantBufferName.c_str()); AZ_Assert(m_constantBuffer.IsValid(), "Couldnt allocate memory for Constant buffer") } - - + + NSMutableArray* argBufferDecriptors = [[[NSMutableArray alloc] init] autorelease]; bool argDescriptorsCreated = CreateArgumentDescriptors(argBufferDecriptors); - + if(argDescriptorsCreated) { NSSortDescriptor* sortDescriptor; sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"index" ascending:YES] autorelease]; NSArray* sortedArgDescriptors = [argBufferDecriptors sortedArrayUsingDescriptors:@[sortDescriptor]]; - + m_argumentEncoder = [m_device->GetMtlDevice() newArgumentEncoderWithArguments:sortedArgDescriptors]; NSUInteger argumentBufferLength = m_argumentEncoder.encodedLength; - + RHI::BufferDescriptor bufferDescriptor; - + bufferDescriptor.m_byteCount = argumentBufferLength; bufferDescriptor.m_bindFlags = RHI::BufferBindFlags::Constant; AZStd::string argBufferName = "ArgumentBuffer"; @@ -77,24 +77,24 @@ namespace AZ m_argumentBuffer.SetName(argBufferName.c_str()); SetName(Name(argBufferName.c_str())); - + //Attach the argument buffer to the argument encoder [m_argumentEncoder setArgumentBuffer:m_argumentBuffer.GetGpuAddress>() offset:m_argumentBuffer.GetOffset()]; - + //Attach the static samplers AttachStaticSamplers(); - + //Attach the constant buffer AttachConstantBuffer(); } } } - + bool ArgumentBuffer::CreateArgumentDescriptors(NSMutableArray* argBufferDecriptors) { bool resourceAdded = false; - + for (const RHI::ShaderInputBufferDescriptor& shaderInputBuffer : m_srgLayout->GetShaderInputListForBuffers()) { MTLArgumentDescriptor* bufferArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease]; @@ -102,7 +102,7 @@ namespace AZ [argBufferDecriptors addObject:bufferArgDescriptor]; resourceAdded = true; } - + for (const RHI::ShaderInputImageDescriptor& shaderInputImage : m_srgLayout->GetShaderInputListForImages()) { MTLArgumentDescriptor* imgArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease]; @@ -110,7 +110,7 @@ namespace AZ [argBufferDecriptors addObject:imgArgDescriptor]; resourceAdded = true; } - + for (const RHI::ShaderInputSamplerDescriptor& shaderInputSampler : m_srgLayout->GetShaderInputListForSamplers()) { MTLArgumentDescriptor* samplerArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease]; @@ -121,7 +121,7 @@ namespace AZ [argBufferDecriptors addObject:samplerArgDescriptor]; resourceAdded = true; } - + for (const RHI::ShaderInputStaticSamplerDescriptor& staticSamplerInput : m_srgLayout->GetStaticSamplers()) { MTLArgumentDescriptor* staticSamplerArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease]; @@ -131,8 +131,8 @@ namespace AZ [argBufferDecriptors addObject:staticSamplerArgDescriptor]; resourceAdded = true; } - - AZStd::array_view shaderInputConstantList = m_srgLayout->GetShaderInputListForConstants(); + + AZStd::span shaderInputConstantList = m_srgLayout->GetShaderInputListForConstants(); if (!shaderInputConstantList.empty()) { const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0]; @@ -143,10 +143,10 @@ namespace AZ [argBufferDecriptors addObject:constBufferArgDescriptor]; resourceAdded = true; } - + return resourceAdded; } - + void ArgumentBuffer::AttachStaticSamplers() { for (const RHI::ShaderInputStaticSamplerDescriptor& staticSampler : m_srgLayout->GetStaticSamplers()) @@ -157,17 +157,17 @@ namespace AZ [m_argumentEncoder setSamplerState:mtlSamplerState atIndex:staticSampler.m_registerId]; } } - + void ArgumentBuffer::AttachConstantBuffer() { - AZStd::array_view shaderInputConstantList = m_srgLayout->GetShaderInputListForConstants(); + AZStd::span shaderInputConstantList = m_srgLayout->GetShaderInputListForConstants(); if (!shaderInputConstantList.empty()) { const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0]; [m_argumentEncoder setBuffer:m_constantBuffer.GetGpuAddress>() offset:m_constantBuffer.GetOffset() atIndex:shaderInputConstant.m_registerId]; } } - + void ArgumentBuffer::BindNullSamplers(uint32_t registerId, uint32_t samplerCount) { AZStd::array, MaxEntriesInArgTable> mtlSamplers; @@ -177,25 +177,25 @@ namespace AZ { mtlSamplers[i] = nullMtlSampler; } - + NSRange range = {registerId, samplerCount}; [m_argumentEncoder setSamplerStates : mtlSamplers.data() withRange : range]; } - + void ArgumentBuffer::UpdateImageViews(const RHI::ShaderInputImageDescriptor& shaderInputImage, const RHI::ShaderInputImageIndex shaderInputIndex, - const AZStd::array_view>& imageViews) + const AZStd::span>& imageViews) { int imageArrayLen = 0; AZStd::array, MaxEntriesInArgTable> mtlTextures; - + for (const RHI::ConstPtr& imageViewBase : imageViews) { if (imageViewBase && !imageViewBase->IsStale()) { const auto& imageView = static_cast(*imageViewBase); - + RHI::Ptr textureMemPtr = imageView.GetMemoryView().GetMemory(); mtlTextures[imageArrayLen] = textureMemPtr->GetGpuAddress>(); m_resourceBindings[shaderInputImage.m_name].insert(ResourceBindingData{textureMemPtr, .m_imageAccess = shaderInputImage.m_access}); @@ -208,7 +208,7 @@ namespace AZ } imageArrayLen++; } - + AZ_Assert(imageArrayLen==shaderInputImage.m_count, "Make sure we have created the correct length of texture array"); if(imageArrayLen > 0) { @@ -217,10 +217,10 @@ namespace AZ withRange : range]; } } - + void ArgumentBuffer::UpdateSamplers(const RHI::ShaderInputSamplerDescriptor& shaderInputSampler, const RHI::ShaderInputSamplerIndex shaderInputIndex, - const AZStd::array_view& samplerStates) + const AZStd::span& samplerStates) { int samplerArrayLen = 0; AZStd::array, MaxEntriesInArgTable> mtlSamplers; @@ -232,7 +232,7 @@ namespace AZ mtlSamplers[samplerArrayLen] = GetMtlSampler(samplerDesc); samplerArrayLen++; } - + AZ_Assert(samplerArrayLen==shaderInputSampler.m_count, "Make sure we dont have a nil sampler within mtlSamplers"); if(samplerArrayLen > 0) { @@ -245,16 +245,16 @@ namespace AZ BindNullSamplers(shaderInputSampler.m_registerId, shaderInputSampler.m_count); } } - + void ArgumentBuffer::UpdateBufferViews(const RHI::ShaderInputBufferDescriptor& shaderInputBuffer, const RHI::ShaderInputBufferIndex shaderInputIndex, - const AZStd::array_view>& bufferViews) + const AZStd::span>& bufferViews) { int bufferArrayLen = 0; AZStd::array, MaxEntriesInArgTable> mtlBuffers; AZStd::array mtlBufferOffsets; AZStd::array, MaxEntriesInArgTable> mtlTextures; - + for (const RHI::ConstPtr& bufferViewBase : bufferViews) { if (bufferViewBase && !bufferViewBase->IsStale()) @@ -298,12 +298,12 @@ namespace AZ bufferArrayLen++; } - + AZ_Assert(bufferArrayLen==shaderInputBuffer.m_count, "Make sure we have created the correct length of buffer array"); if(bufferArrayLen > 0) { NSRange range = {shaderInputBuffer.m_registerId, bufferArrayLen}; - + if(shaderInputBuffer.m_type == RHI::ShaderInputBufferType::Typed) { [m_argumentEncoder setTextures : mtlTextures.data() @@ -317,8 +317,8 @@ namespace AZ } } } - - void ArgumentBuffer::UpdateConstantBufferViews(AZStd::array_view rawData) + + void ArgumentBuffer::UpdateConstantBufferViews(AZStd::span rawData) { AZ_Assert(rawData.size() <= m_constantBufferSize, "rawData size can not be bigger than constant Buffer Size"); if ( (m_constantBufferSize > 0) && (rawData.size() <= m_constantBufferSize)) @@ -326,11 +326,11 @@ namespace AZ memcpy(m_constantBuffer.GetCpuAddress(), rawData.data(), rawData.size()); } } - + void ArgumentBuffer::Shutdown() { ClearResourceTracking(); - + #if defined(ARGUMENTBUFFER_PAGEALLOCATOR) if(m_constantBuffer.IsValid()) { @@ -339,13 +339,13 @@ namespace AZ if(m_argumentBuffer.IsValid()) { m_device->GetArgumentBufferAllocator().DeAllocate(m_argumentBuffer); - } + } #else if(m_argumentBuffer.IsValid()) { m_device->QueueForRelease(m_argumentBuffer); } - + if(m_constantBuffer.IsValid()) { m_device->QueueForRelease(m_constantBuffer); @@ -354,28 +354,28 @@ namespace AZ m_argumentBuffer = {}; m_constantBuffer = {}; - + [m_argumentEncoder release]; m_argumentEncoder = nil; - + Base::Shutdown(); } - + id ArgumentBuffer::GetArgEncoderBuffer() const { return m_argumentBuffer.GetGpuAddress>(); }; - + size_t ArgumentBuffer::GetOffset() const { return m_argumentBuffer.GetOffset(); }; - + void ArgumentBuffer::ClearResourceTracking() { m_resourceBindings.clear(); } - + id ArgumentBuffer::GetMtlSampler(MTLSamplerDescriptor* samplerDesc) { const NSCache* samplerCache = m_device->GetSamplerCache(); @@ -385,10 +385,10 @@ namespace AZ mtlSamplerState = [m_device->GetMtlDevice() newSamplerStateWithDescriptor:samplerDesc]; [samplerCache setObject:mtlSamplerState forKey:samplerDesc]; } - + return mtlSamplerState; } - + void ArgumentBuffer::CollectUntrackedResources(id commandEncoder, const ShaderResourceGroupVisibility& srgResourcesVisInfo, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentCompute, @@ -408,19 +408,19 @@ namespace AZ else { MTLRenderStages mtlRenderStages = GetRenderStages(srgResourcesVisInfo.m_constantDataStageMask); - AZStd::pair key = AZStd::make_pair(MTLResourceUsageRead, mtlRenderStages); + AZStd::pair key = AZStd::make_pair(MTLResourceUsageRead, mtlRenderStages); resourcesToMakeResidentGraphics[key].emplace(mtlconstantBufferResource); } } } - + //Cach all the resources within a srg that are used by the shader based on the visibility information for (const auto& it : m_resourceBindings) { //Extract the visibility mask for the give resource auto visMaskIt = srgResourcesVisInfo.m_resourcesStageMask.find(it.first); AZ_Assert(visMaskIt != srgResourcesVisInfo.m_resourcesStageMask.end(), "No Visibility information available") - + uint8_t numBitsSet = RHI::CountBitsSet(static_cast(visMaskIt->second)); //Only use this resource if it is used in one of the shaders if (numBitsSet > 0) @@ -464,7 +464,7 @@ namespace AZ AZ_Assert(false, "Undefined Resource type"); } } - + id mtlResourceToBind = resourceBindingData.m_resourcPtr->GetGpuAddress>(); resourcesToMakeResidentMap[resourceUsage].emplace(mtlResourceToBind); } @@ -475,7 +475,7 @@ namespace AZ const ResourceBindingsSet& resourceBindingDataSet, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const { - + MTLRenderStages mtlRenderStages = GetRenderStages(visShaderMask); MTLResourceUsage resourceUsage = MTLResourceUsageRead; for (const auto& resourceBindingData : resourceBindingDataSet) @@ -498,17 +498,17 @@ namespace AZ AZ_Assert(false, "Undefined Resource type"); } } - + AZStd::pair key = AZStd::make_pair(resourceUsage, mtlRenderStages); id mtlResourceToBind = resourceBindingData.m_resourcPtr->GetGpuAddress>(); resourcesToMakeResidentMap[key].emplace(mtlResourceToBind); } } - + bool ArgumentBuffer::IsNullHeapNeededForVertexStage(const ShaderResourceGroupVisibility& srgResourcesVisInfo) const { bool isUsedByVertexStage = false; - + //Iterate over all the SRG entries for (const auto& it : srgResourcesVisInfo.m_resourcesStageMask) { @@ -520,7 +520,7 @@ namespace AZ } return isUsedByVertexStage; } - + bool ArgumentBuffer::IsNullDescHeapNeeded() const { return m_useNullDescriptorHeap; diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h index a680516dc6..03d8cdd439 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h @@ -26,12 +26,12 @@ struct ResourceBindingData AZ::RHI::ShaderInputImageAccess m_imageAccess; AZ::RHI::ShaderInputBufferAccess m_bufferAccess; }; - + bool operator==(const ResourceBindingData& other) const { return this->m_resourcPtr == other.m_resourcPtr; }; - + size_t GetHash() const { return static_cast(m_resourcPtr->GetHash()); @@ -58,12 +58,12 @@ namespace AZ class BufferMemoryAllocator; class ShaderResourceGroup; struct ShaderResourceGroupCompiledData; - + class ArgumentBuffer final : public RHI::DeviceObject { using Base = RHI::DeviceObject; - + public: AZ_CLASS_ALLOCATOR(ArgumentBuffer, AZ::SystemAllocator, 0); AZ_RTTI(ArgumentBuffer, "FEFE8823-7772-4EA0-9241-65C49ADFF6B3", Base); @@ -78,21 +78,21 @@ namespace AZ void UpdateImageViews(const RHI::ShaderInputImageDescriptor& shaderInputImage, const RHI::ShaderInputImageIndex shaderInputIndex, - const AZStd::array_view>& imageViews); - + const AZStd::span>& imageViews); + void UpdateSamplers(const RHI::ShaderInputSamplerDescriptor& shaderInputSampler, const RHI::ShaderInputSamplerIndex shaderInputIndex, - const AZStd::array_view& samplerStates); - + const AZStd::span& samplerStates); + void UpdateBufferViews(const RHI::ShaderInputBufferDescriptor& shaderInputBuffer, const RHI::ShaderInputBufferIndex shaderInputIndex, - const AZStd::array_view>& bufferViews); - - void UpdateConstantBufferViews(AZStd::array_view rawData); - + const AZStd::span>& bufferViews); + + void UpdateConstantBufferViews(AZStd::span rawData); + id GetArgEncoderBuffer() const; size_t GetOffset() const; - + //Map to cache all the resources based on the usage as we can batch all the resources for a given usage. using ComputeResourcesToMakeResidentMap = AZStd::unordered_map>>; //Map to cache all the resources based on the usage and shader stage as we can batch all the resources for a given usage/shader usage. @@ -102,31 +102,31 @@ namespace AZ const ShaderResourceGroupVisibility& srgResourcesVisInfo, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentCompute, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentGraphics) const; - + void ClearResourceTracking(); bool IsNullHeapNeededForVertexStage(const ShaderResourceGroupVisibility& srgResourcesVisInfo) const; bool IsNullDescHeapNeeded() const; - + ////////////////////////////////////////////////////////////////////////// // RHI::DeviceObject void Shutdown() override; ////////////////////////////////////////////////////////////////////////// - + private: - + bool CreateArgumentDescriptors(NSMutableArray * argBufferDecriptors); void AttachStaticSamplers(); void AttachConstantBuffer(); - + // Use a cache to store and retrieve samplers id GetMtlSampler(MTLSamplerDescriptor* samplerDesc); using ResourceBindingsSet = AZStd::unordered_set; using ResourceBindingsMap = AZStd::unordered_map; ResourceBindingsMap m_resourceBindings; - + static const int MaxEntriesInArgTable = 31; - + void CollectResourcesForCompute(id encoder, const ResourceBindingsSet& resourceBindingData, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const; @@ -139,13 +139,13 @@ namespace AZ const ResourceBindingsMap& resourceMap, const ShaderResourceGroupVisibility& srgResourcesVisInfo) const; void BindNullSamplers(uint32_t registerId, uint32_t samplerCount); - + Device* m_device = nullptr; RHI::ConstPtr m_srgLayout; - + id m_argumentEncoder; uint32_t m_constantBufferSize = 0; - + #if defined(ARGUMENTBUFFER_PAGEALLOCATOR) BufferMemoryView m_argumentBuffer; BufferMemoryView m_constantBuffer; diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/AsyncUploadQueue.h b/Gems/Atom/RHI/Metal/Code/Source/RHI/AsyncUploadQueue.h index 7ae4a75764..3db15eca4c 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/AsyncUploadQueue.h +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/AsyncUploadQueue.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -34,7 +34,7 @@ namespace AZ : public RHI::DeviceObject { using Base = RHI::DeviceObject; - + public: AsyncUploadQueue() = default; @@ -57,13 +57,13 @@ namespace AZ uint64_t QueueUpload(const RHI::BufferStreamRequest& request); //! Queue copy commands to upload image subresources. - //! @param residentMip is the resident mip level the expand request starts from. + //! @param residentMip is the resident mip level the expand request starts from. //! @return queue id which can be use to check whether upload finished or wait for upload finish RHI::AsyncWorkHandle QueueUpload(const RHI::StreamingImageExpandRequest& request, uint32_t residentMip); bool IsUploadFinished(uint64_t fenceValue); void WaitForUpload(const RHI::AsyncWorkHandle& workHandle); - + private: struct FramePacket; RHI::AsyncWorkHandle CreateAsyncWork(Fence& fence, RHI::Fence::SignalCallback callback = nullptr); @@ -84,26 +84,26 @@ namespace AZ Fence m_fence; // Using persistent mapping for the staging resource so the Map function only need to be called called once. - uint8_t* m_stagingResourceData = nullptr; + uint8_t* m_stagingResourceData = nullptr; uint32_t m_dataOffset = 0; }; - + RHI::Ptr m_copyQueue; - // Begin the frame packet which m_frameIndex point to and get ready to start recording copy command by using this frame packet + // Begin the frame packet which m_frameIndex point to and get ready to start recording copy command by using this frame packet FramePacket* BeginFramePacket(CommandQueue* commandQueue); void EndFramePacket(CommandQueue* commandQueue); bool m_recordingFrame = false; - AZStd::vector m_framePackets; + AZStd::vector m_framePackets; size_t m_frameIndex = 0; Descriptor m_descriptor; // Fence for external upload request Fence m_uploadFence; - + RHI::Ptr m_device; - + //Command Buffer associated with the async copy queue CommandQueueCommandBuffer m_commandBuffer; diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.cpp index 2b8be3d1ab..c0277152b6 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.cpp @@ -28,7 +28,7 @@ namespace AZ { return aznew CommandList(); } - + void CommandList::Init(RHI::HardwareQueueClass hardwareQueueClass, Device* device) { CommandListBase::Init(hardwareQueueClass, device); @@ -39,13 +39,13 @@ namespace AZ //Undefined symbols for architecture arm64: // "_objc_memmove_collectable", referenced from: //We can come back and revisit this after upgrading the build server machines to Mojave. - + m_state.m_pipelineState = nullptr; m_state.m_pipelineLayout = nullptr; m_state.m_streamsHash = AZ::HashValue64{0}; m_state.m_indicesHash = AZ::HashValue64{0}; m_state.m_stencilRef = -1; - + CommandListBase::Reset(); } @@ -59,11 +59,11 @@ namespace AZ Reset(); CommandListBase::FlushEncoder(); } - + void CommandList::Submit(const RHI::CopyItem& copyItem) { CreateEncoder(CommandEncoderType::Blit); - + id blitEncoder = GetEncoder>(); switch (copyItem.m_type) { @@ -78,7 +78,7 @@ namespace AZ toBuffer:destinationBuffer->GetMemoryView().GetGpuAddress>() destinationOffset:descriptor.m_destinationOffset size:descriptor.m_size]; - + Platform::SynchronizeBufferOnGPU(blitEncoder, destinationBuffer->GetMemoryView().GetGpuAddress>()); break; } @@ -87,19 +87,19 @@ namespace AZ const RHI::CopyImageDescriptor& descriptor = copyItem.m_image; const Image* sourceImage = static_cast(descriptor.m_sourceImage); const Image* destinationImage = static_cast(descriptor.m_destinationImage); - + MTLOrigin sourceOrigin = MTLOriginMake(descriptor.m_sourceOrigin.m_left, descriptor.m_sourceOrigin.m_top, descriptor.m_sourceOrigin.m_front); - + MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width, descriptor.m_sourceSize.m_height, descriptor.m_sourceSize.m_depth); - + MTLOrigin destinationOrigin = MTLOriginMake(descriptor.m_destinationOrigin.m_left, descriptor.m_destinationOrigin.m_top, descriptor.m_destinationOrigin.m_front); - + [blitEncoder copyFromTexture: sourceImage->GetMemoryView().GetGpuAddress>() sourceSlice: descriptor.m_sourceSubresource.m_arraySlice sourceLevel: descriptor.m_sourceSubresource.m_mipSlice @@ -109,7 +109,7 @@ namespace AZ destinationSlice: descriptor.m_destinationSubresource.m_arraySlice destinationLevel: descriptor.m_destinationSubresource.m_mipSlice destinationOrigin: destinationOrigin]; - + Platform::SynchronizeTextureOnGPU(blitEncoder, destinationImage->GetMemoryView().GetGpuAddress>()); break; } @@ -122,11 +122,11 @@ namespace AZ MTLOrigin destinationOrigin = MTLOriginMake(descriptor.m_destinationOrigin.m_left, descriptor.m_destinationOrigin.m_top, descriptor.m_destinationOrigin.m_front); - + MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width, descriptor.m_sourceSize.m_height, descriptor.m_sourceSize.m_depth); - + [blitEncoder copyFromBuffer:sourceBuffer->GetMemoryView().GetGpuAddress>() sourceOffset:sourceBuffer->GetMemoryView().GetOffset() + descriptor.m_sourceOffset sourceBytesPerRow:descriptor.m_sourceBytesPerRow @@ -136,7 +136,7 @@ namespace AZ destinationSlice:descriptor.m_destinationSubresource.m_arraySlice destinationLevel:descriptor.m_destinationSubresource.m_mipSlice destinationOrigin:destinationOrigin]; - + Platform::SynchronizeTextureOnGPU(blitEncoder, destinationImage->GetMemoryView().GetGpuAddress>()); break; } @@ -145,15 +145,15 @@ namespace AZ const RHI::CopyImageToBufferDescriptor& descriptor = copyItem.m_imageToBuffer; const auto* sourceImage = static_cast(descriptor.m_sourceImage); const auto* destinationBuffer = static_cast(descriptor.m_destinationBuffer); - + MTLOrigin sourceOrigin = MTLOriginMake(descriptor.m_sourceOrigin.m_left, descriptor.m_sourceOrigin.m_top, descriptor.m_sourceOrigin.m_front); - + MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width, descriptor.m_sourceSize.m_height, descriptor.m_sourceSize.m_depth); - + [blitEncoder copyFromTexture:sourceImage->GetMemoryView().GetGpuAddress>() sourceSlice:descriptor.m_sourceSubresource.m_arraySlice sourceLevel:descriptor.m_sourceSubresource.m_mipSlice @@ -163,7 +163,7 @@ namespace AZ destinationOffset:destinationBuffer->GetMemoryView().GetOffset() + descriptor.m_destinationOffset destinationBytesPerRow:descriptor.m_destinationBytesPerRow destinationBytesPerImage:descriptor.m_destinationBytesPerImage]; - + Platform::SynchronizeBufferOnGPU(blitEncoder, destinationBuffer->GetMemoryView().GetGpuAddress>()); break; } @@ -173,27 +173,27 @@ namespace AZ } } } - + void CommandList::Submit(const RHI::DispatchItem& dispatchItem) { AZ_PROFILE_FUNCTION(RHI); - + CreateEncoder(CommandEncoderType::Compute); bool bindResourceSuccessfull = CommitShaderResources(dispatchItem); - + if(!bindResourceSuccessfull) { AZ_Assert(false, "Resource binding was unsuccessfully."); return; } const RHI::DispatchDirect& arguments = dispatchItem.m_arguments.m_direct; - MTLSize threadsPerGroup = {arguments.m_threadsPerGroupX, arguments.m_threadsPerGroupY, arguments.m_threadsPerGroupZ}; + MTLSize threadsPerGroup = {arguments.m_threadsPerGroupX, arguments.m_threadsPerGroupY, arguments.m_threadsPerGroupZ}; MTLSize numThreadGroup = {arguments.GetNumberOfGroupsX(), arguments.GetNumberOfGroupsY(), arguments.GetNumberOfGroupsZ()}; - + id computeEncoder = GetEncoder>(); [computeEncoder dispatchThreadgroups: numThreadGroup threadsPerThreadgroup: threadsPerGroup]; - + } void CommandList::Submit(const RHI::DispatchRaysItem& dispatchRaysItem) @@ -204,14 +204,14 @@ namespace AZ void CommandList::SetViewports(const RHI::Viewport* rhiViewports, uint32_t count) { - m_state.m_viewportState.Set(AZStd::array_view(rhiViewports, count)); + m_state.m_viewportState.Set(AZStd::span(rhiViewports, count)); } void CommandList::SetScissors(const RHI::Scissor* rhiScissors, uint32_t count) { - m_state.m_scissorState.Set(AZStd::array_view(rhiScissors, count)); + m_state.m_scissorState.Set(AZStd::span(rhiScissors, count)); } - + template void CommandList::SetRootConstants(const Item& item, const PipelineState* pipelineState) { @@ -221,15 +221,15 @@ namespace AZ if(m_commandEncoderType == CommandEncoderType::Render) { id renderEncoder = GetEncoder>(); - + [renderEncoder setVertexBytes: item.m_rootConstants length: pipelineLayout.GetRootConstantsSize() atIndex: pipelineLayout.GetRootConstantsSlotIndex()]; - + [renderEncoder setFragmentBytes: item.m_rootConstants length: pipelineLayout.GetRootConstantsSize() atIndex: pipelineLayout.GetRootConstantsSlotIndex()]; - + } else if(m_commandEncoderType == CommandEncoderType::Compute) { @@ -237,39 +237,39 @@ namespace AZ [computeEncoder setBytes: item.m_rootConstants length: pipelineLayout.GetRootConstantsSize() atIndex: pipelineLayout.GetRootConstantsSlotIndex()]; - + } } } - + bool CommandList::SetArgumentBuffers(const PipelineState* pipelineState, RHI::PipelineStateType stateType) { bool bindNullDescriptorHeap = false; MTLRenderStages mtlRenderStagesForNullDescHeap = 0; ShaderResourceBindings& bindings = GetShaderResourceBindingsByPipelineType(stateType); const PipelineLayout& pipelineLayout = pipelineState->GetPipelineLayout(); - + uint32_t bufferVertexRegisterIdMin = RHI::Limits::Pipeline::ShaderResourceGroupCountMax; uint32_t bufferFragmentOrComputeRegisterIdMin = RHI::Limits::Pipeline::ShaderResourceGroupCountMax; uint32_t bufferVertexRegisterIdMax = 0; uint32_t bufferFragmentOrComputeRegisterIdMax = 0; - + //Arrays to cache all the buffers and offsets in order to make batch calls MetalArgumentBufferArray mtlVertexArgBuffers; MetalArgumentBufferArrayOffsets mtlVertexArgBufferOffsets; MetalArgumentBufferArray mtlFragmentOrComputeArgBuffers; MetalArgumentBufferArrayOffsets mtlFragmentOrComputeArgBufferOffsets; - + mtlVertexArgBuffers.fill(nil); mtlFragmentOrComputeArgBuffers.fill(nil); mtlVertexArgBufferOffsets.fill(0); mtlFragmentOrComputeArgBufferOffsets.fill(0); - + //Map to cache all the resources based on the usage as we can batch all the resources for a given usage ArgumentBuffer::ComputeResourcesToMakeResidentMap resourcesToMakeResidentCompute; //Map to cache all the resources based on the usage and shader stage as we can batch all the resources for a given usage/shader usage ArgumentBuffer::GraphicsResourcesToMakeResidentMap resourcesToMakeResidentGraphics; - + for (uint32_t slot = 0; slot < RHI::Limits::Pipeline::ShaderResourceGroupCountMax; ++slot) { const ShaderResourceGroup* shaderResourceGroup = bindings.m_srgsBySlot[slot]; @@ -282,7 +282,7 @@ namespace AZ uint32_t srgVisIndex = pipelineLayout.GetIndexBySlot(shaderResourceGroup->GetBindingSlot()); const RHI::ShaderStageMask& srgVisInfo = pipelineLayout.GetSrgVisibility(srgVisIndex); const ShaderResourceGroupVisibility& srgResourcesVisInfo = pipelineLayout.GetSrgResourcesVisibility(srgVisIndex); - + bool isSrgUpdatd = bindings.m_srgsByIndex[slot] != shaderResourceGroup; if(isSrgUpdatd) { @@ -290,12 +290,12 @@ namespace AZ auto& compiledArgBuffer = shaderResourceGroup->GetCompiledArgumentBuffer(); id argBuffer = compiledArgBuffer.GetArgEncoderBuffer(); size_t argBufferOffset = compiledArgBuffer.GetOffset(); - + if(srgVisInfo != RHI::ShaderStageMask::None) { bool isNullDescHeapNeeded = compiledArgBuffer.IsNullDescHeapNeeded(); bindNullDescriptorHeap |= isNullDescHeapNeeded; - + //For graphics and compute shader stages, cache all the argument buffers, offsets and track the min/max indices if(m_commandEncoderType == CommandEncoderType::Render) { @@ -305,11 +305,11 @@ namespace AZ mtlVertexArgBuffers[slotIndex] = argBuffer; mtlVertexArgBufferOffsets[slotIndex] = argBufferOffset; bufferVertexRegisterIdMin = AZStd::min(slotIndex, bufferVertexRegisterIdMin); - bufferVertexRegisterIdMax = AZStd::max(slotIndex, bufferVertexRegisterIdMax); + bufferVertexRegisterIdMax = AZStd::max(slotIndex, bufferVertexRegisterIdMax); mtlRenderStagesForNullDescHeap = shaderResourceGroup->IsNullHeapNeededForVertexStage(srgResourcesVisInfo) ? mtlRenderStagesForNullDescHeap | MTLRenderStageVertex : mtlRenderStagesForNullDescHeap; } - + if( numBitsSet > 1 || srgVisInfo == RHI::ShaderStageMask::Fragment) { mtlFragmentOrComputeArgBuffers[slotIndex] = argBuffer; @@ -328,7 +328,7 @@ namespace AZ } } } - + //Check if the srg has been updated or if the srg resources visibility hash has been updated //as it is possible for draw items to have different PSOs in the same pass. const AZ::HashValue64 srgResourcesVisHash = pipelineLayout.GetSrgResourcesVisibilityHash(srgVisIndex); @@ -337,8 +337,8 @@ namespace AZ bindings.m_srgVisHashByIndex[slot] = srgResourcesVisHash; if(srgVisInfo != RHI::ShaderStageMask::None) { - - + + //For graphics and compute encoder make the resource resident (call UseResource) for the duration //of the work associated with the current scope and ensure that it's in a //format compatible with the appropriate metal function. @@ -353,7 +353,7 @@ namespace AZ } } } - + //For graphics and compute encoder bind all the argument buffers if(m_commandEncoderType == CommandEncoderType::Render) { @@ -362,7 +362,7 @@ namespace AZ bufferVertexRegisterIdMax, mtlVertexArgBuffers, mtlVertexArgBufferOffsets); - + BindArgumentBuffers(RHI::ShaderStage::Fragment, bufferFragmentOrComputeRegisterIdMin, bufferFragmentOrComputeRegisterIdMax, @@ -377,40 +377,40 @@ namespace AZ mtlFragmentOrComputeArgBuffers, mtlFragmentOrComputeArgBufferOffsets); } - + id renderEncoder = GetEncoder>(); id computeEncoder = GetEncoder>(); - + //Call UseResource on all resources for Compute stage for (const auto& key : resourcesToMakeResidentCompute) { AZStd::vector> resourcesToProcessVec(key.second.begin(), key.second.end()); - + [computeEncoder useResources: &resourcesToProcessVec[0] count: resourcesToProcessVec.size() usage: key.first]; - + } - + //Call UseResource on all resources for Vertex and Fragment stages for (const auto& key : resourcesToMakeResidentGraphics) { - + AZStd::vector> resourcesToProcessVec(key.second.begin(), key.second.end()); - + [renderEncoder useResources: &resourcesToProcessVec[0] count: resourcesToProcessVec.size() usage: key.first.first stages: key.first.second]; } - + if(bindNullDescriptorHeap) { MakeHeapsResident(mtlRenderStagesForNullDescHeap); } return true; } - + void CommandList::BindArgumentBuffers(RHI::ShaderStage shaderStage, uint16_t registerIdMin, uint16_t registerIdMax, @@ -428,7 +428,7 @@ namespace AZ if(mtlArgBuffers[i] == nil) { NSRange range = { startingIndex, i-startingIndex }; - + switch(shaderStage) { case RHI::ShaderStage::Vertex: @@ -462,7 +462,7 @@ namespace AZ } trackingRange = false; - + } } else @@ -475,13 +475,13 @@ namespace AZ } } } - + void CommandList::Submit(const RHI::DrawItem& drawItem) { AZ_PROFILE_FUNCTION(RHI); - + CreateEncoder(CommandEncoderType::Render); - + RHI::CommandListScissorState scissorState; if (drawItem.m_scissorsCount) { @@ -496,15 +496,15 @@ namespace AZ } CommitViewportState(); CommitScissorState(); - + const PipelineState* pipelineState = static_cast(drawItem.m_pipelineState); AZ_Assert(pipelineState, "PipelineState can not be null"); - + if(m_renderPassMultiSampleState != pipelineState->m_pipelineStateMultiSampleState) { AZ_Assert(false,"MultisampleState in the image descriptor needs to match the one provided in the pipeline state"); } - + id renderEncoder = GetEncoder>(); bool bindResourceSuccessfull = CommitShaderResources(drawItem); if(!bindResourceSuccessfull) @@ -512,21 +512,21 @@ namespace AZ AZ_Assert(false, "Resource binding was unsuccessfully."); return; } - + SetStreamBuffers(drawItem.m_streamBufferViews, drawItem.m_streamBufferViewCount); SetStencilRef(drawItem.m_stencilRef); MTLPrimitiveType mtlPrimType = pipelineState->GetPipelineTopology(); - + switch (drawItem.m_arguments.m_type) { case RHI::DrawType::Indexed: { const RHI::DrawIndexed& indexed = drawItem.m_arguments.m_indexed; - + const RHI::IndexBufferView& indexBuffDescriptor = *drawItem.m_indexBufferView; AZ::HashValue64 indicesHash = indexBuffDescriptor.GetHash(); - + m_state.m_indicesHash = indicesHash; const Buffer * buff = static_cast(indexBuffDescriptor.GetBuffer()); id mtlBuff = buff->GetMemoryView().GetGpuAddress>(); @@ -534,7 +534,7 @@ namespace AZ MTLIndexTypeUInt16 : MTLIndexTypeUInt32; uint32_t indexTypeSize = 0; GetIndexTypeSizeInBytes(mtlIndexType, indexTypeSize); - + uint32_t indexOffset = indexBuffDescriptor.GetByteOffset() + (indexed.m_indexOffset * indexTypeSize) + buff->GetMemoryView().GetOffset(); [renderEncoder drawIndexedPrimitives: mtlPrimType indexCount: indexed.m_indexCount @@ -546,15 +546,15 @@ namespace AZ baseInstance: indexed.m_instanceOffset]; break; } - + case RHI::DrawType::Linear: - { + { const RHI::DrawLinear& linear = drawItem.m_arguments.m_linear; [renderEncoder drawPrimitives: mtlPrimType vertexStart: linear.m_vertexOffset vertexCount: linear.m_vertexCount instanceCount: linear.m_instanceCount - baseInstance: linear.m_instanceOffset]; + baseInstance: linear.m_instanceOffset]; break; } } @@ -576,7 +576,7 @@ namespace AZ { CommandListBase::Shutdown(); } - + void CommandList::SetPipelineState(const PipelineState* pipelineState) { if (m_state.m_pipelineState != pipelineState) @@ -608,7 +608,7 @@ namespace AZ AZ_Assert(false, "Type not supported."); } } - + ShaderResourceBindings& bindings = GetShaderResourceBindingsByPipelineType(pipelineState->GetType()); for (size_t i = 0; i < bindings.m_srgsByIndex.size(); ++i) { @@ -623,7 +623,7 @@ namespace AZ } } } - + void CommandList::SetStencilRef(uint8_t stencilRef) { if (m_state.m_stencilRef != stencilRef) @@ -633,24 +633,24 @@ namespace AZ m_state.m_stencilRef = stencilRef; } } - + void CommandList::SetStreamBuffers(const RHI::StreamBufferView* streams, uint32_t count) { uint16_t bufferArrayLen = 0; AZStd::array, METAL_MAX_ENTRIES_BUFFER_ARG_TABLE> mtlStreamBuffers; AZStd::array mtlStreamBufferOffsets; - + AZ::HashValue64 streamsHash = AZ::HashValue64{0}; for (uint32_t i = 0; i < count; ++i) { streamsHash = AZ::TypeHash64(streamsHash, streams[i].GetHash()); } - + if (streamsHash != m_state.m_streamsHash) { m_state.m_streamsHash = streamsHash; AZ_Assert(count <= METAL_MAX_ENTRIES_BUFFER_ARG_TABLE , "Slots needed cannot exceed METAL_MAX_ENTRIES_BUFFER_ARG_TABLE"); - + NSRange range = {METAL_MAX_ENTRIES_BUFFER_ARG_TABLE - count, count}; //The stream buffers are populated from bottom to top as the top slots are taken by argument buffers for (int i = count-1; i >= 0; --i) @@ -671,7 +671,7 @@ namespace AZ withRange: range]; } } - + void CommandList::SetRasterizerState(const RasterizerState& rastState) { id renderEncoder = GetEncoder>(); @@ -681,17 +681,17 @@ namespace AZ [renderEncoder setTriangleFillMode: rastState.m_triangleFillMode]; [renderEncoder setDepthClipMode: rastState.m_depthClipMode]; } - + void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup) { SetShaderResourceGroup(static_cast(&shaderResourceGroup)); } - + void CommandList::SetShaderResourceGroupForDispatch(const RHI::ShaderResourceGroup& shaderResourceGroup) { SetShaderResourceGroup(static_cast(&shaderResourceGroup)); } - + CommandList::ShaderResourceBindings& CommandList::GetShaderResourceBindingsByPipelineType(RHI::PipelineStateType pipelineType) { return m_state.m_bindingsByPipe[static_cast(pipelineType)]; @@ -706,15 +706,15 @@ namespace AZ AZ_Assert(false, "Pipeline state not provided"); return false; } - + SetPipelineState(pipelineState); - + // Assign shader resource groups from the item to slot bindings. for (uint32_t srgIndex = 0; srgIndex < item.m_shaderResourceGroupCount; ++srgIndex) { SetShaderResourceGroup(static_cast(item.m_shaderResourceGroups[srgIndex])); } - + if (item.m_uniqueShaderResourceGroup) { SetShaderResourceGroup(static_cast(item.m_uniqueShaderResourceGroup)); @@ -730,7 +730,7 @@ namespace AZ { return; } - + AZ_PROFILE_FUNCTION(RHI); const auto& viewports = m_state.m_viewportState.m_states; MTLViewport metalViewports[viewports.size()]; @@ -744,7 +744,7 @@ namespace AZ metalViewports[i].znear = viewports[i].m_minZ; metalViewports[i].zfar = viewports[i].m_maxZ; } - + id renderEncoder = GetEncoder>(); [renderEncoder setViewports: metalViewports count: viewports.size()]; @@ -760,7 +760,7 @@ namespace AZ AZStd::array metalScissorRects; const auto& scissors = m_state.m_scissorState.m_states; - + AZ_Assert(scissors.size() <= MaxScissorsAllowed , "Number of scissors violate the maximum number of scissors allowed"); for (uint32_t i = 0; i < scissors.size(); ++i) { diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLibrary.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLibrary.cpp index cd0d152f7c..63d741dffd 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLibrary.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLibrary.cpp @@ -27,7 +27,7 @@ namespace AZ { } - RHI::ResultCode PipelineLibrary::MergeIntoInternal(AZStd::array_view pipelineLibraries) + RHI::ResultCode PipelineLibrary::MergeIntoInternal(AZStd::span pipelineLibraries) { return RHI::ResultCode::Success; } diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLibrary.h b/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLibrary.h index 8ec5f257c9..f462e20a8e 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLibrary.h +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLibrary.h @@ -30,7 +30,7 @@ namespace AZ // RHI::PipelineLibrary RHI::ResultCode InitInternal(RHI::Device& device, const RHI::PipelineLibraryData* serializedData) override; void ShutdownInternal() override; - RHI::ResultCode MergeIntoInternal(AZStd::array_view libraries) override; + RHI::ResultCode MergeIntoInternal(AZStd::span libraries) override; RHI::ConstPtr GetSerializedDataInternal() const override; ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ShaderResourceGroupPool.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/ShaderResourceGroupPool.cpp index fa962697e1..fac4c5621b 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ShaderResourceGroupPool.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ShaderResourceGroupPool.cpp @@ -37,7 +37,7 @@ namespace AZ RHI::ResultCode ShaderResourceGroupPool::InitGroupInternal(RHI::ShaderResourceGroup& groupBase) { ShaderResourceGroup& group = static_cast(groupBase); - + for (size_t i = 0; i < RHI::Limits::Device::FrameCountMax; ++i) { auto argBuffer = ArgumentBuffer::Create(); @@ -82,7 +82,7 @@ namespace AZ for (const RHI::ShaderInputImageDescriptor& shaderInputImage : layout->GetShaderInputListForImages()) { const RHI::ShaderInputImageIndex imageInputIndex(shaderInputIndex); - AZStd::array_view> imageViews = groupData.GetImageViewArray(imageInputIndex); + AZStd::span> imageViews = groupData.GetImageViewArray(imageInputIndex); argBuffer.UpdateImageViews(shaderInputImage, imageInputIndex, imageViews); ++shaderInputIndex; } @@ -91,7 +91,7 @@ namespace AZ for (const RHI::ShaderInputSamplerDescriptor& shaderInputSampler : layout->GetShaderInputListForSamplers()) { const RHI::ShaderInputSamplerIndex samplerInputIndex(shaderInputIndex); - AZStd::array_view samplerStates = groupData.GetSamplerArray(samplerInputIndex); + AZStd::span samplerStates = groupData.GetSamplerArray(samplerInputIndex); argBuffer.UpdateSamplers(shaderInputSampler, samplerInputIndex, samplerStates); ++shaderInputIndex; } @@ -100,7 +100,7 @@ namespace AZ for (const RHI::ShaderInputBufferDescriptor& shaderInputBuffer : layout->GetShaderInputListForBuffers()) { const RHI::ShaderInputBufferIndex bufferInputIndex(shaderInputIndex); - AZStd::array_view> bufferViews = groupData.GetBufferViewArray(bufferInputIndex); + AZStd::span> bufferViews = groupData.GetBufferViewArray(bufferInputIndex); argBuffer.UpdateBufferViews(shaderInputBuffer, bufferInputIndex, bufferViews); ++shaderInputIndex; } diff --git a/Gems/Atom/RHI/Null/Code/Source/RHI/PipelineLibrary.h b/Gems/Atom/RHI/Null/Code/Source/RHI/PipelineLibrary.h index 1edd1ee8bc..e30b4c0ac7 100644 --- a/Gems/Atom/RHI/Null/Code/Source/RHI/PipelineLibrary.h +++ b/Gems/Atom/RHI/Null/Code/Source/RHI/PipelineLibrary.h @@ -30,7 +30,7 @@ namespace AZ // RHI::PipelineLibrary RHI::ResultCode InitInternal([[maybe_unused]] RHI::Device& device, [[maybe_unused]] const RHI::PipelineLibraryData* serializedData) override { return RHI::ResultCode::Success;} void ShutdownInternal() override {} - RHI::ResultCode MergeIntoInternal([[maybe_unused]] AZStd::array_view libraries) override { return RHI::ResultCode::Success;} + RHI::ResultCode MergeIntoInternal([[maybe_unused]] AZStd::span libraries) override { return RHI::ResultCode::Success;} RHI::ConstPtr GetSerializedDataInternal() const override { return nullptr;} ////////////////////////////////////////////////////////////////////////// }; diff --git a/Gems/Atom/RHI/Vulkan/Code/Include/Atom/RHI.Reflect/Vulkan/ShaderStageFunction.h b/Gems/Atom/RHI/Vulkan/Code/Include/Atom/RHI.Reflect/Vulkan/ShaderStageFunction.h index 799e4f3b89..7627100a05 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Include/Atom/RHI.Reflect/Vulkan/ShaderStageFunction.h +++ b/Gems/Atom/RHI/Vulkan/Code/Include/Atom/RHI.Reflect/Vulkan/ShaderStageFunction.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -21,7 +21,7 @@ namespace AZ namespace Vulkan { using ShaderByteCode = AZStd::vector; - using ShaderByteCodeView = AZStd::array_view; + using ShaderByteCodeView = AZStd::span; /** * A set of indices used to access physical sub-stages within a virtual stage. diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp index c74b9d4d13..c1d87b0211 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp @@ -76,12 +76,12 @@ namespace AZ void CommandList::SetViewports(const RHI::Viewport* rhiViewports, uint32_t count) { - m_state.m_viewportState.Set(AZStd::array_view(rhiViewports, count)); + m_state.m_viewportState.Set(AZStd::span(rhiViewports, count)); } void CommandList::SetScissors(const RHI::Scissor* rhiScissors, uint32_t count) { - m_state.m_scissorState.Set(AZStd::array_view(rhiScissors, count)); + m_state.m_scissorState.Set(AZStd::span(rhiScissors, count)); } void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup) @@ -625,7 +625,7 @@ namespace AZ return ConvertResult(vkResult); } - void CommandList::ExecuteSecondaryCommandLists(const AZStd::array_view>& commands) + void CommandList::ExecuteSecondaryCommandLists(const AZStd::span>& commands) { AZ_Assert(m_isUpdating, "Secondary command buffers must be executed between BeginCommandBuffer() and EndCommandBuffer()."); AZ_Assert(m_descriptor.m_level == VK_COMMAND_BUFFER_LEVEL_PRIMARY, "Trying to execute commands from a secondary command list"); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.h index 799c706d60..651842e081 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -103,7 +103,7 @@ namespace AZ bool IsInsideRenderPass() const; const Framebuffer* GetActiveFramebuffer() const; const RenderPass* GetActiveRenderpass() const; - void ExecuteSecondaryCommandLists(const AZStd::array_view>& commands); + void ExecuteSecondaryCommandLists(const AZStd::span>& commands); uint32_t GetQueueFamilyIndex() const; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp index 815eba086c..9a759d1842 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp @@ -39,7 +39,7 @@ namespace AZ } } - void DescriptorSet::UpdateBufferViews(uint32_t layoutIndex, const AZStd::array_view>& bufViews) + void DescriptorSet::UpdateBufferViews(uint32_t layoutIndex, const AZStd::span>& bufViews) { const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout; VkDescriptorType type = layout.GetDescriptorType(layoutIndex); @@ -119,7 +119,7 @@ namespace AZ m_updateData.push_back(AZStd::move(data)); } - void DescriptorSet::UpdateImageViews(uint32_t layoutIndex, const AZStd::array_view>& imageViews, RHI::ShaderInputImageType imageType) + void DescriptorSet::UpdateImageViews(uint32_t layoutIndex, const AZStd::span>& imageViews, RHI::ShaderInputImageType imageType) { const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout; @@ -169,7 +169,7 @@ namespace AZ m_updateData.push_back(AZStd::move(data)); } - void DescriptorSet::UpdateSamplers(uint32_t layoutIndex, const AZStd::array_view& samplers) + void DescriptorSet::UpdateSamplers(uint32_t layoutIndex, const AZStd::span& samplers) { auto& device = static_cast(GetDevice()); @@ -189,7 +189,7 @@ namespace AZ m_updateData.push_back(AZStd::move(data)); } - void DescriptorSet::UpdateConstantData(AZStd::array_view rawData) + void DescriptorSet::UpdateConstantData(AZStd::span rawData) { AZ_Assert(m_constantDataBuffer, "Null constant buffer"); const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.h index 24fb587ade..1610a09418 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -57,10 +57,10 @@ namespace AZ void CommitUpdates(); - void UpdateBufferViews(uint32_t index, const AZStd::array_view>& bufViews); - void UpdateImageViews(uint32_t index, const AZStd::array_view>& imageViews, RHI::ShaderInputImageType imageType); - void UpdateSamplers(uint32_t index, const AZStd::array_view& samplers); - void UpdateConstantData(AZStd::array_view data); + void UpdateBufferViews(uint32_t index, const AZStd::span>& bufViews); + void UpdateImageViews(uint32_t index, const AZStd::span>& imageViews, RHI::ShaderInputImageType imageType); + void UpdateSamplers(uint32_t index, const AZStd::span& samplers); + void UpdateConstantData(AZStd::span data); RHI::Ptr GetConstantDataBufferView() const; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSetLayout.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSetLayout.cpp index 564614a0a8..1c8e21b22f 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSetLayout.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSetLayout.cpp @@ -152,12 +152,12 @@ namespace AZ RHI::ResultCode DescriptorSetLayout::BuildDescriptorSetLayoutBindings() { - const AZStd::array_view bufferDescs = m_shaderResourceGroupLayout->GetShaderInputListForBuffers(); - const AZStd::array_view imageDescs = m_shaderResourceGroupLayout->GetShaderInputListForImages(); - const AZStd::array_view bufferUnboundedArrayDescs = m_shaderResourceGroupLayout->GetShaderInputListForBufferUnboundedArrays(); - const AZStd::array_view imageUnboundedArrayDescs = m_shaderResourceGroupLayout->GetShaderInputListForImageUnboundedArrays(); - const AZStd::array_view samplerDescs = m_shaderResourceGroupLayout->GetShaderInputListForSamplers(); - const AZStd::array_view& staticSamplerDescs = m_shaderResourceGroupLayout->GetStaticSamplers(); + const AZStd::span bufferDescs = m_shaderResourceGroupLayout->GetShaderInputListForBuffers(); + const AZStd::span imageDescs = m_shaderResourceGroupLayout->GetShaderInputListForImages(); + const AZStd::span bufferUnboundedArrayDescs = m_shaderResourceGroupLayout->GetShaderInputListForBufferUnboundedArrays(); + const AZStd::span imageUnboundedArrayDescs = m_shaderResourceGroupLayout->GetShaderInputListForImageUnboundedArrays(); + const AZStd::span samplerDescs = m_shaderResourceGroupLayout->GetShaderInputListForSamplers(); + const AZStd::span& staticSamplerDescs = m_shaderResourceGroupLayout->GetStaticSamplers(); // The + 1 is for Constant Data. m_descriptorSetLayoutBindings.reserve( @@ -173,7 +173,7 @@ namespace AZ m_constantDataSize = m_shaderResourceGroupLayout->GetConstantDataSize(); if (m_constantDataSize) { - AZStd::array_view inputListForConstants = m_shaderResourceGroupLayout->GetShaderInputListForConstants(); + AZStd::span inputListForConstants = m_shaderResourceGroupLayout->GetShaderInputListForConstants(); AZ_Assert(!inputListForConstants.empty(), "Empty constant input list"); m_descriptorSetLayoutBindings.emplace_back(VkDescriptorSetLayoutBinding{}); VkDescriptorSetLayoutBinding& vbinding = m_descriptorSetLayoutBindings.back(); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroup.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroup.cpp index 12efb488fb..8df7aac253 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroup.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroup.cpp @@ -81,12 +81,12 @@ namespace AZ { } - AZStd::array_view FrameGraphExecuteGroup::GetScopes() const + AZStd::span FrameGraphExecuteGroup::GetScopes() const { - return AZStd::array_view(&m_scope, 1); + return AZStd::span(&m_scope, 1); } - AZStd::array_view> FrameGraphExecuteGroup::GetCommandLists() const + AZStd::span> FrameGraphExecuteGroup::GetCommandLists() const { return m_secondaryCommands; } diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroup.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroup.h index c7726beb76..f33775a9fa 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroup.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroup.h @@ -44,8 +44,8 @@ namespace AZ ////////////////////////////////////////////////////////////////////////// // FrameGraphExecuteGroupBase - AZStd::array_view GetScopes() const override; - AZStd::array_view> GetCommandLists() const override; + AZStd::span GetScopes() const override; + AZStd::span> GetCommandLists() const override; ////////////////////////////////////////////////////////////////////////// //! Set the render context and subpass that will be used by this execute group. diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupBase.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupBase.h index 529c452658..c1666d5ef2 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupBase.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupBase.h @@ -37,9 +37,9 @@ namespace AZ const RHI::GraphGroupId& GetGroupId() const; - virtual AZStd::array_view GetScopes() const = 0; + virtual AZStd::span GetScopes() const = 0; - virtual AZStd::array_view> GetCommandLists() const = 0; + virtual AZStd::span> GetCommandLists() const = 0; protected: RHI::Ptr AcquireCommandList(VkCommandBufferLevel level) const; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupMerged.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupMerged.cpp index 84b6cafa7d..053afc802e 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupMerged.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupMerged.cpp @@ -113,14 +113,14 @@ namespace AZ scope->EmitScopeBarriers(*m_commandList, Scope::BarrierSlot::Epilogue); } - AZStd::array_view FrameGraphExecuteGroupMerged::GetScopes() const + AZStd::span FrameGraphExecuteGroupMerged::GetScopes() const { return m_scopes; } - AZStd::array_view> FrameGraphExecuteGroupMerged::GetCommandLists() const + AZStd::span> FrameGraphExecuteGroupMerged::GetCommandLists() const { - return AZStd::array_view>(&m_commandList, 1); + return AZStd::span>(&m_commandList, 1); } void FrameGraphExecuteGroupMerged::SetPrimaryCommandList(CommandList& commandList) @@ -128,7 +128,7 @@ namespace AZ m_commandList = &commandList; } - void FrameGraphExecuteGroupMerged::SetRenderPasscontexts(AZStd::array_view renderPassContexts) + void FrameGraphExecuteGroupMerged::SetRenderPasscontexts(AZStd::span renderPassContexts) { m_renderPassContexts = renderPassContexts; } diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupMerged.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupMerged.h index 82c85ce3fe..47f97806a2 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupMerged.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/FrameGraphExecuteGroupMerged.h @@ -33,12 +33,12 @@ namespace AZ //! Set the command list that the group will use. void SetPrimaryCommandList(CommandList& commandList); //! Set the list of renderpasses that the group will use. - void SetRenderPasscontexts(AZStd::array_view renderPassContexts); + void SetRenderPasscontexts(AZStd::span renderPassContexts); ////////////////////////////////////////////////////////////////////////// // FrameGraphExecuteGroupBase - AZStd::array_view GetScopes() const override; - AZStd::array_view> GetCommandLists() const override; + AZStd::span GetScopes() const override; + AZStd::span> GetCommandLists() const override; ////////////////////////////////////////////////////////////////////////// private: @@ -60,7 +60,7 @@ namespace AZ // Primary command list used to record the work. RHI::Ptr m_commandList; // List of renderpasses and framebuffers used by the scopes in the group. - AZStd::array_view m_renderPassContexts; + AZStd::span m_renderPassContexts; }; } } diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLayout.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLayout.cpp index f627ddf2cc..e61fc7817a 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLayout.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLayout.cpp @@ -48,7 +48,7 @@ namespace AZ template void AddShaderInputs( RHI::ShaderResourceGroupLayout& srgLayout, - AZStd::array_view shaderInputs, + AZStd::span shaderInputs, const uint32_t bindingSlot, const RHI::ShaderResourceGroupBindingInfo& srgBidingInfo) { diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLibrary.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLibrary.cpp index a797285981..c9e35a481b 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLibrary.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLibrary.cpp @@ -31,7 +31,7 @@ namespace AZ VkPipelineCacheCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; createInfo.pNext = nullptr; - createInfo.flags = 0; + createInfo.flags = 0; createInfo.initialDataSize = 0; createInfo.pInitialData = nullptr; @@ -59,7 +59,7 @@ namespace AZ } } - RHI::ResultCode PipelineLibrary::MergeIntoInternal(AZStd::array_view libraries) + RHI::ResultCode PipelineLibrary::MergeIntoInternal(AZStd::span libraries) { auto& device = static_cast(GetDevice()); if (libraries.empty()) diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLibrary.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLibrary.h index 03d78970da..34c254ec65 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLibrary.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PipelineLibrary.h @@ -42,7 +42,7 @@ namespace AZ // RHI::PipelineLibrary RHI::ResultCode InitInternal(RHI::Device& device, const RHI::PipelineLibraryData* serializedData) override; void ShutdownInternal() override; - RHI::ResultCode MergeIntoInternal(AZStd::array_view libraries) override; + RHI::ResultCode MergeIntoInternal(AZStd::span libraries) override; RHI::ConstPtr GetSerializedDataInternal() const override; ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.cpp index a3282067a7..6b629c675d 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.cpp @@ -77,20 +77,20 @@ namespace AZ return m_descriptor.m_attachmentCount; } - AZStd::array_view RenderPass::GetSubpassAttachments(const uint32_t subpassIndex, const AttachmentType type) const + AZStd::span RenderPass::GetSubpassAttachments(const uint32_t subpassIndex, const AttachmentType type) const { const SubpassDescriptor& descriptor = m_descriptor.m_subpassDescriptors[subpassIndex]; switch (type) { case AttachmentType::Color: - return AZStd::array_view(descriptor.m_rendertargetAttachments.begin(), descriptor.m_rendertargetCount); + return AZStd::span(descriptor.m_rendertargetAttachments.begin(), descriptor.m_rendertargetCount); case AttachmentType::DepthStencil: return descriptor.m_depthStencilAttachment.IsValid() ? - AZStd::array_view(&descriptor.m_depthStencilAttachment, 1) : AZStd::array_view(); + AZStd::span(&descriptor.m_depthStencilAttachment, 1) : AZStd::span(); case AttachmentType::InputAttachment: - return AZStd::array_view(descriptor.m_subpassInputAttachments.begin(), descriptor.m_subpassInputCount); + return AZStd::span(descriptor.m_subpassInputAttachments.begin(), descriptor.m_subpassInputCount); case AttachmentType::Resolve: - return AZStd::array_view(descriptor.m_resolveAttachments.begin(), descriptor.m_rendertargetCount); + return AZStd::span(descriptor.m_resolveAttachments.begin(), descriptor.m_rendertargetCount); default: AZ_Assert(false, "Invalid attachment type %d", type); return {}; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.h index 8aaef51bd0..1fb3018f3a 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.h @@ -147,7 +147,7 @@ namespace AZ void BuildSubpassDescriptions(const AZStd::vector& subpassReferences, AZStd::vector& subpassDescriptions) const; void BuildSubpassDependencies(AZStd::vector& subpassDependencies) const; - AZStd::array_view GetSubpassAttachments(const uint32_t subpassIndex, const AttachmentType type) const; + AZStd::span GetSubpassAttachments(const uint32_t subpassIndex, const AttachmentType type) const; Descriptor m_descriptor; VkRenderPass m_nativeRenderPass = VK_NULL_HANDLE; @@ -157,7 +157,7 @@ namespace AZ template void RenderPass::BuildAttachmentReferences(uint32_t subpassIndex, SubpassReferences& subpasReferences) const { - AZStd::array_view subpassAttachmentList = GetSubpassAttachments(subpassIndex, type); + AZStd::span subpassAttachmentList = GetSubpassAttachments(subpassIndex, type); AZStd::vector& attachmentReferenceList = subpasReferences.m_attachmentReferences[static_cast(type)]; attachmentReferenceList.resize(subpassAttachmentList.size()); for (uint32_t index = 0; index < subpassAttachmentList.size(); ++index) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialPropertyId.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialPropertyId.h index fd63494f30..f669406172 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialPropertyId.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialPropertyId.h @@ -9,7 +9,7 @@ #pragma once #include -#include +#include namespace AZ { @@ -34,7 +34,7 @@ namespace AZ explicit MaterialPropertyId(AZStd::string_view propertyName); MaterialPropertyId(AZStd::string_view groupName, AZStd::string_view propertyName); MaterialPropertyId(const Name& groupName, const Name& propertyName); - explicit MaterialPropertyId(const AZStd::array_view names); + explicit MaterialPropertyId(const AZStd::span names); AZ_DEFAULT_COPY_MOVE(MaterialPropertyId); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/GpuQuery/GpuQueryTypes.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/GpuQuery/GpuQueryTypes.h index 0a06c48989..9c20de36bb 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/GpuQuery/GpuQueryTypes.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/GpuQuery/GpuQueryTypes.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include @@ -65,7 +65,7 @@ namespace AZ static void Reflect(AZ::ReflectContext* context); PipelineStatisticsResult() = default; - PipelineStatisticsResult(AZStd::array_view&& statisticsResultArray); + PipelineStatisticsResult(AZStd::span&& statisticsResultArray); PipelineStatisticsResult& operator+=(const PipelineStatisticsResult& rhs); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/GpuQuery/QueryPool.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/GpuQuery/QueryPool.h index f152d92973..0ca88b3d33 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/GpuQuery/QueryPool.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/GpuQuery/QueryPool.h @@ -15,7 +15,7 @@ #include -#include +#include namespace AZ { @@ -59,15 +59,15 @@ namespace AZ protected: QueryPool(uint32_t queryCapacity, uint32_t queriesPerResult, RHI::QueryType queryType, RHI::PipelineStatisticsFlags statisticsFlags); - // Returns the RHI Query array. - AZStd::array_view> GetRhiQueryArray() const; + // Returns the RHI Query array as a span. + AZStd::span> GetRhiQueryArray() const; private: // Distributes the RHI Query indices into sub-intervals. Each sub interval is assigned to a RPI Query. void CreateRhiQueryIntervals(); - // Returns an array of RHI Queries depending on the indices that are provided. - AZStd::array_view> GetRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const; + // Returns a span of RHI Queries depending on the indices that are provided. + AZStd::span> GetRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const; // Returns an array of raw RHI Query pointers depending on the indices that are provided. AZStd::vector GetRawRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h index 91a9a2d009..a3de586e76 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h @@ -51,7 +51,7 @@ namespace AZ size_t GetLodCount() const; //! Returns the full list of Lods, where index 0 is the most detailed, and N-1 is the least. - AZStd::array_view> GetLods() const; + AZStd::span> GetLods() const; //! Returns whether a buffer upload is pending. bool IsUploadPending() const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/ModelLod.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/ModelLod.h index 0d0304a04e..9ad6edf2ce 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/ModelLod.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/ModelLod.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -92,7 +92,7 @@ namespace AZ //! Blocks the CPU until pending buffer uploads have completed. void WaitForUpload(); - AZStd::array_view GetMeshes() const; + AZStd::span GetMeshes() const; //! Compares a ShaderInputContract to the mesh's available streams, and if any of them are optional, sets the corresponding "*_isBound" shader option. //! Call this function to update the ShaderOptionKey before fetching a ShaderVariant, to find a variant that is compatible with this mesh's streams. diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h index f5bf11a438..c9db343203 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h @@ -73,7 +73,7 @@ namespace AZ Ptr FindChildPass() const; //! Gets the list of children. Useful for validating hierarchies - AZStd::array_view> GetChildren() const; + AZStd::span> GetChildren() const; //! Searches the tree for the first pass that uses the given DrawListTag. const Pass* FindPass(RHI::DrawListTag drawListTag) const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h index be7ac9e7a4..a3b739ade7 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassAttachment.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassAttachment.h index d60a5a8064..8ee4270373 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassAttachment.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassAttachment.h @@ -192,7 +192,7 @@ namespace AZ }; using PassAttachmentBindingList = AZStd::vector; - using PassAttachmentBindingListView = AZStd::array_view; + using PassAttachmentBindingListView = AZStd::span; } // namespace RPI diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassLibrary.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassLibrary.h index f79da54636..8db633509d 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassLibrary.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassLibrary.h @@ -15,7 +15,7 @@ #include #include -#include +#include namespace AZ { diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/Shader.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/Shader.h index be20d89d65..07354e7bfc 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/Shader.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/Shader.h @@ -127,7 +127,7 @@ namespace AZ const RHI::Ptr& FindFallbackShaderResourceGroupLayout() const; /// Returns the set of shader resource groups referenced by all variants in the shader asset. - AZStd::array_view> GetShaderResourceGroupLayouts() const; + AZStd::span> GetShaderResourceGroupLayouts() const; /// Returns a reference to the asset used to initialize this shader. const Data::Asset& GetAsset() const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/ShaderResourceGroup.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/ShaderResourceGroup.h index 99f1f5f598..771ea5ab31 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/ShaderResourceGroup.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/ShaderResourceGroup.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -104,16 +104,16 @@ namespace AZ bool SetImage(RHI::ShaderInputImageIndex inputIndex, const Data::Instance& image, uint32_t arrayIndex = 0); /// Sets multiple RPI images for the given shader input index. - bool SetImageArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view> images, uint32_t arrayIndex = 0); - bool SetImageArray(RHI::ShaderInputImageIndex inputIndex, AZStd::array_view> images, uint32_t arrayIndex = 0); + bool SetImageArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span> images, uint32_t arrayIndex = 0); + bool SetImageArray(RHI::ShaderInputImageIndex inputIndex, AZStd::span> images, uint32_t arrayIndex = 0); /// Returns a single RPI image associated with the image shader input index and array offset. const Data::Instance& GetImage(RHI::ShaderInputNameIndex& inputIndex, uint32_t arrayIndex = 0) const; const Data::Instance& GetImage(RHI::ShaderInputImageIndex inputIndex, uint32_t arrayIndex = 0) const; - /// Returns an array of RPI images associated with the image shader input index. - AZStd::array_view> GetImageArray(RHI::ShaderInputNameIndex& inputIndex) const; - AZStd::array_view> GetImageArray(RHI::ShaderInputImageIndex inputIndex) const; + /// Returns a span of RPI images associated with the image shader input index. + AZStd::span> GetImageArray(RHI::ShaderInputNameIndex& inputIndex) const; + AZStd::span> GetImageArray(RHI::ShaderInputImageIndex inputIndex) const; ////////////////////////////////////////////////////////////////////////// // Methods for assignment / access of RPI Buffer types. @@ -123,17 +123,17 @@ namespace AZ bool SetBuffer(RHI::ShaderInputBufferIndex inputIndex, const Data::Instance& buffer, uint32_t arrayIndex = 0); /// Sets multiple RPI buffers for the given shader input index. - bool SetBufferArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view> buffers, uint32_t arrayIndex = 0); - bool SetBufferArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::array_view> buffers, uint32_t arrayIndex = 0); + bool SetBufferArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span> buffers, uint32_t arrayIndex = 0); + bool SetBufferArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::span> buffers, uint32_t arrayIndex = 0); /// Returns a single RPI buffer associated with the buffer shader input index and array offset. const Data::Instance& GetBuffer(RHI::ShaderInputNameIndex& inputIndex, uint32_t arrayIndex = 0) const; const Data::Instance& GetBuffer(RHI::ShaderInputBufferIndex inputIndex, uint32_t arrayIndex = 0) const; - /// Returns an array of RPI buffers associated with the buffer shader input index. - AZStd::array_view> GetBufferArray(RHI::ShaderInputNameIndex& inputIndex) const; - AZStd::array_view> GetBufferArray(RHI::ShaderInputBufferIndex inputIndex) const; - + /// Returns a span of RPI buffers associated with the buffer shader input index. + AZStd::span> GetBufferArray(RHI::ShaderInputNameIndex& inputIndex) const; + AZStd::span> GetBufferArray(RHI::ShaderInputBufferIndex inputIndex) const; + //! Reset image and buffer views so that it won't hold references for any RHI resources void ResetViews(); @@ -145,19 +145,19 @@ namespace AZ bool SetImageView(RHI::ShaderInputImageIndex inputIndex, const RHI::ImageView* imageView, uint32_t arrayIndex = 0); /// Sets an array of image view for the given shader input index. - bool SetImageViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view imageViews, uint32_t arrayIndex = 0); - bool SetImageViewArray(RHI::ShaderInputImageIndex inputIndex, AZStd::array_view imageViews, uint32_t arrayIndex = 0); + bool SetImageViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span imageViews, uint32_t arrayIndex = 0); + bool SetImageViewArray(RHI::ShaderInputImageIndex inputIndex, AZStd::span imageViews, uint32_t arrayIndex = 0); /// Sets an unbounded array of image views for the given shader input index. - bool SetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::array_view imageViews); + bool SetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::span imageViews); /// Returns a single image view associated with the image shader input index and array offset. const RHI::ConstPtr& GetImageView(RHI::ShaderInputNameIndex& inputIndex, uint32_t arrayIndex = 0) const; const RHI::ConstPtr& GetImageView(RHI::ShaderInputImageIndex inputIndex, uint32_t arrayIndex = 0) const; - /// Returns an array of image views associated with the given image shader input index. - AZStd::array_view> GetImageViewArray(RHI::ShaderInputNameIndex& inputIndex) const; - AZStd::array_view> GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const; + /// Returns a span of image views associated with the given image shader input index. + AZStd::span> GetImageViewArray(RHI::ShaderInputNameIndex& inputIndex) const; + AZStd::span> GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const; ////////////////////////////////////////////////////////////////////////// // Methods for assignment / access of RHI Buffer types. @@ -167,19 +167,19 @@ namespace AZ bool SetBufferView(RHI::ShaderInputBufferIndex inputIndex, const RHI::BufferView* bufferView, uint32_t arrayIndex = 0); /// Sets an array of buffer view for the given shader input index. - bool SetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view bufferViews, uint32_t arrayIndex = 0); - bool SetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::array_view bufferViews, uint32_t arrayIndex = 0); + bool SetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span bufferViews, uint32_t arrayIndex = 0); + bool SetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::span bufferViews, uint32_t arrayIndex = 0); /// Sets an unbounded array of buffer views for the given shader input index. - bool SetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::array_view bufferViews); + bool SetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::span bufferViews); /// Returns a single buffer view associated with the buffer shader input index and array offset. const RHI::ConstPtr& GetBufferView(RHI::ShaderInputNameIndex& inputIndex, uint32_t arrayIndex = 0) const; const RHI::ConstPtr& GetBufferView(RHI::ShaderInputBufferIndex inputIndex, uint32_t arrayIndex = 0) const; - /// Returns an array of buffer views associated with the given buffer shader input index. - AZStd::array_view> GetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex) const; - AZStd::array_view> GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const; + /// Returns a span of buffer views associated with the given buffer shader input index. + AZStd::span> GetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex) const; + AZStd::span> GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const; ////////////////////////////////////////////////////////////////////////// // Methods for assignment / access of RHI Sampler types. @@ -189,16 +189,16 @@ namespace AZ bool SetSampler(RHI::ShaderInputSamplerIndex inputIndex, const RHI::SamplerState& sampler, uint32_t arrayIndex = 0); /// Sets an array of samplers for the given shader input index. - bool SetSamplerArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view samplers, uint32_t arrayIndex = 0); - bool SetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex, AZStd::array_view samplers, uint32_t arrayIndex = 0); + bool SetSamplerArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span samplers, uint32_t arrayIndex = 0); + bool SetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex, AZStd::span samplers, uint32_t arrayIndex = 0); /// Returns a single sampler associated with the sampler shader input index and array offset. const RHI::SamplerState& GetSampler(RHI::ShaderInputNameIndex& inputIndex, uint32_t arrayIndex) const; const RHI::SamplerState& GetSampler(RHI::ShaderInputSamplerIndex inputIndex, uint32_t arrayIndex) const; - /// Returns an array of samplers associated with the sampler shader input index. - AZStd::array_view GetSamplerArray(RHI::ShaderInputNameIndex& inputIndex) const; - AZStd::array_view GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const; + /// Returns a span of samplers associated with the sampler shader input index. + AZStd::span GetSamplerArray(RHI::ShaderInputNameIndex& inputIndex) const; + AZStd::span GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const; ////////////////////////////////////////////////////////////////////////// // Methods for assignment / access SRG constants. @@ -227,11 +227,11 @@ namespace AZ template bool SetConstant(RHI::ShaderInputConstantIndex inputIndex, const T& value, uint32_t arrayIndex); - /// Assigns an array of type T to the constant shader input. + /// Assigns a span of type T to the constant shader input. template - bool SetConstantArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view values); + bool SetConstantArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span values); template - bool SetConstantArray(RHI::ShaderInputConstantIndex inputIndex, AZStd::array_view values); + bool SetConstantArray(RHI::ShaderInputConstantIndex inputIndex, AZStd::span values); /// Assigns an array of type T to the constant shader input. template @@ -253,9 +253,9 @@ namespace AZ * If the strides do not match, an empty array is returned. */ template - AZStd::array_view GetConstantArray(RHI::ShaderInputNameIndex& inputIndex) const; + AZStd::span GetConstantArray(RHI::ShaderInputNameIndex& inputIndex) const; template - AZStd::array_view GetConstantArray(RHI::ShaderInputConstantIndex inputIndex) const; + AZStd::span GetConstantArray(RHI::ShaderInputConstantIndex inputIndex) const; /** * Returns the constant data as type 'T' returned by value. The size of the constant region @@ -276,9 +276,9 @@ namespace AZ template T GetConstant(RHI::ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const; - /// Returns constant data for the given shader input index as an array of bytes. - AZStd::array_view GetConstantRaw(RHI::ShaderInputNameIndex& inputIndex) const; - AZStd::array_view GetConstantRaw(RHI::ShaderInputConstantIndex inputIndex) const; + /// Returns constant data for the given shader input index as a span of bytes. + AZStd::span GetConstantRaw(RHI::ShaderInputNameIndex& inputIndex) const; + AZStd::span GetConstantRaw(RHI::ShaderInputConstantIndex inputIndex) const; private: ShaderResourceGroup() = default; @@ -415,13 +415,13 @@ namespace AZ } template - bool ShaderResourceGroup::SetConstantArray(RHI::ShaderInputConstantIndex inputIndex, AZStd::array_view values) + bool ShaderResourceGroup::SetConstantArray(RHI::ShaderInputConstantIndex inputIndex, AZStd::span values) { return m_data.SetConstantArray(inputIndex, values); } template - bool ShaderResourceGroup::SetConstantArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view values) + bool ShaderResourceGroup::SetConstantArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span values) { if (inputIndex.ValidateOrFindConstantIndex(GetLayout())) { @@ -433,7 +433,7 @@ namespace AZ template bool ShaderResourceGroup::SetConstantArray(RHI::ShaderInputConstantIndex inputIndex, const AZStd::array& values) { - return SetConstantArray(inputIndex, AZStd::array_view(values)); + return SetConstantArray(inputIndex, AZStd::span(values)); } template @@ -441,19 +441,19 @@ namespace AZ { if (inputIndex.ValidateOrFindConstantIndex(GetLayout())) { - return SetConstantArray(inputIndex.GetConstantIndex(), AZStd::array_view(values)); + return SetConstantArray(inputIndex.GetConstantIndex(), AZStd::span(values)); } return false; } template - AZStd::array_view ShaderResourceGroup::GetConstantArray(RHI::ShaderInputConstantIndex inputIndex) const + AZStd::span ShaderResourceGroup::GetConstantArray(RHI::ShaderInputConstantIndex inputIndex) const { return m_data.GetConstantArray(inputIndex); } template - AZStd::array_view ShaderResourceGroup::GetConstantArray(RHI::ShaderInputNameIndex& inputIndex) const + AZStd::span ShaderResourceGroup::GetConstantArray(RHI::ShaderInputNameIndex& inputIndex) const { if (inputIndex.ValidateOrFindConstantIndex(GetLayout())) { diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Buffer/BufferAsset.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Buffer/BufferAsset.h index e6fe68b21e..75556887e1 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Buffer/BufferAsset.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Buffer/BufferAsset.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include @@ -46,7 +46,7 @@ namespace AZ BufferAsset() = default; ~BufferAsset() = default; - AZStd::array_view GetBuffer() const; + AZStd::span GetBuffer() const; const RHI::BufferDescriptor& GetBufferDescriptor() const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Image/ImageMipChainAsset.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Image/ImageMipChainAsset.h index 69c1933bd6..397b47b5d2 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Image/ImageMipChainAsset.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Image/ImageMipChainAsset.h @@ -14,7 +14,7 @@ #include -#include +#include #include @@ -64,10 +64,10 @@ namespace AZ size_t GetSubImageCount() const; //! Returns the sub-image data blob for a given mip slice and array slice (local to the group). - AZStd::array_view GetSubImageData(uint32_t mipSlice, uint32_t arraySlice) const; + AZStd::span GetSubImageData(uint32_t mipSlice, uint32_t arraySlice) const; //! Returns the sub-image data blob for a linear index (local to the group). - AZStd::array_view GetSubImageData(uint32_t subImageIndex) const; + AZStd::span GetSubImageData(uint32_t subImageIndex) const; //! Returns the sub-image layout for a single sub-image by index. const RHI::ImageSubresourceLayout& GetSubImageLayout(uint32_t subImageIndex) const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Image/StreamingImageAsset.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Image/StreamingImageAsset.h index 73af8370cb..76e49edbb4 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Image/StreamingImageAsset.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Image/StreamingImageAsset.h @@ -83,7 +83,7 @@ namespace AZ size_t GetMipCount(size_t mipChainIndex) const; //! Get image data for specified mip and slice. It may return empty array if its mipchain assets are not loaded - AZStd::array_view GetSubImageData(uint32_t mip, uint32_t slice); + AZStd::span GetSubImageData(uint32_t mip, uint32_t slice); //! Returns streaming image pool asset id of the pool that will be used to create the streaming image. const Data::AssetId& GetPoolAssetId() const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialAsset.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialAsset.h index b7cc51dcc4..63c42a3882 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialAsset.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialAsset.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialTypeAsset.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialTypeAsset.h index 9065b17254..f2302065e2 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialTypeAsset.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialTypeAsset.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -118,7 +118,7 @@ namespace AZ //! The entries in this list align with the entries in the MaterialPropertiesLayout. Each AZStd::any is guaranteed //! to have a value of type that matches the corresponding MaterialPropertyDescriptor. //! For images, the value will be of type ImageBinding. - AZStd::array_view GetDefaultPropertyValues() const; + AZStd::span GetDefaultPropertyValues() const; //! Returns a map from the UV shader inputs to a custom name. MaterialUvNameMap GetUvNameMap() const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialTypeAssetCreator.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialTypeAssetCreator.h index 6bd84b5546..ce6fbbae23 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialTypeAssetCreator.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialTypeAssetCreator.h @@ -9,7 +9,7 @@ #include #include -#include +#include namespace AZ { diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelAsset.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelAsset.h index 91d89ce719..ea02e87405 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelAsset.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelAsset.h @@ -59,7 +59,7 @@ namespace AZ //! Returns the number of Lods in the model size_t GetLodCount() const; - AZStd::array_view> GetLodAssets() const; + AZStd::span> GetLodAssets() const; //! Checks a ray for intersection against this model. The ray must be in the same coordinate space as the model. //! Important: only to be used in the Editor, it may kick off a job to calculate spatial information. diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelKdTree.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelKdTree.h index 134f1c767d..2e51a37488 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelKdTree.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelKdTree.h @@ -50,9 +50,9 @@ namespace AZ eSA_Invalid }; - static AZStd::array_view GetPositionsBuffer(const ModelLodAsset::Mesh& mesh); + static AZStd::span GetPositionsBuffer(const ModelLodAsset::Mesh& mesh); - static AZStd::array_view GetIndexBuffer(const ModelLodAsset::Mesh& mesh); + static AZStd::span GetIndexBuffer(const ModelLodAsset::Mesh& mesh); private: @@ -75,7 +75,7 @@ namespace AZ struct MeshData { const ModelLodAsset::Mesh* m_mesh = nullptr; - AZStd::array_view m_vertexData; + AZStd::span m_vertexData; }; AZStd::vector m_meshes; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelLodAsset.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelLodAsset.h index 4b09cf8d91..d7b4979e06 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelLodAsset.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Model/ModelLodAsset.h @@ -101,10 +101,10 @@ namespace AZ //! A helper method for returning this mesh's index buffer using a specific type for the elements. //! @note It's the caller's responsibility to choose the right type for the buffer. template - AZStd::array_view GetIndexBufferTyped() const; + AZStd::span GetIndexBufferTyped() const; //! Return an array view of the list of all stream buffer info (not including the index buffer) - AZStd::array_view GetStreamBufferInfoList() const; + AZStd::span GetStreamBufferInfoList() const; //! A helper method for returning a specific buffer asset view. //! It will return nullptr if the semantic buffer is not found. @@ -117,11 +117,11 @@ namespace AZ //! In perf loop, re-use AZ::Name instance. //! @note It's the caller's responsibility to choose the right type for the buffer. template - AZStd::array_view GetSemanticBufferTyped(const AZ::Name& semantic) const; + AZStd::span GetSemanticBufferTyped(const AZ::Name& semantic) const; private: template - AZStd::array_view GetBufferTyped(const BufferAssetView& bufferAssetView) const; + AZStd::span GetBufferTyped(const BufferAssetView& bufferAssetView) const; AZ::Name m_name; AZ::Aabb m_aabb = AZ::Aabb::CreateNull(); @@ -143,7 +143,7 @@ namespace AZ }; //! Returns an array view into the collection of meshes owned by this lod - AZStd::array_view GetMeshes() const; + AZStd::span GetMeshes() const; //! Returns the model-space axis-aligned bounding box of all meshes in the lod const AZ::Aabb& GetAabb() const; @@ -173,24 +173,24 @@ namespace AZ using ModelLodAssetHandler = AssetHandler; template - AZStd::array_view ModelLodAsset::Mesh::GetIndexBufferTyped() const + AZStd::span ModelLodAsset::Mesh::GetIndexBufferTyped() const { return GetBufferTyped(GetIndexBufferAssetView()); } template - AZStd::array_view ModelLodAsset::Mesh::GetSemanticBufferTyped(const AZ::Name& semantic) const + AZStd::span ModelLodAsset::Mesh::GetSemanticBufferTyped(const AZ::Name& semantic) const { const BufferAssetView* bufferAssetView = GetSemanticBufferAssetView(semantic); - return bufferAssetView ? GetBufferTyped(*bufferAssetView) : AZStd::array_view{}; + return bufferAssetView ? GetBufferTyped(*bufferAssetView) : AZStd::span{}; } template - AZStd::array_view ModelLodAsset::Mesh::GetBufferTyped(const BufferAssetView& bufferAssetView) const + AZStd::span ModelLodAsset::Mesh::GetBufferTyped(const BufferAssetView& bufferAssetView) const { if (const BufferAsset* bufferAsset = bufferAssetView.GetBufferAsset().Get()) { - const AZStd::array_view rawBuffer = bufferAsset->GetBuffer(); + const AZStd::span rawBuffer = bufferAsset->GetBuffer(); if (!rawBuffer.empty()) { const auto& bufferViewDescriptor = bufferAssetView.GetBufferViewDescriptor(); @@ -202,7 +202,7 @@ namespace AZ "Size of buffer (%d) is not a multiple of the type's size specified (%d)", endMeshRawBuffer - beginMeshRawBuffer, sizeof(T)); - return AZStd::array_view(reinterpret_cast(beginMeshRawBuffer), reinterpret_cast(endMeshRawBuffer)); + return AZStd::span(reinterpret_cast(beginMeshRawBuffer), reinterpret_cast(endMeshRawBuffer)); } } return {}; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassAttachmentReflect.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassAttachmentReflect.h index 0de3676abe..b0008c44d1 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassAttachmentReflect.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassAttachmentReflect.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -130,7 +130,7 @@ namespace AZ }; using PassSlotList = AZStd::vector; - using PassSlotListView = AZStd::array_view; + using PassSlotListView = AZStd::span; //! Refers to a PassAttachment or a PassAttachmentBinding on an adjacent Pass in the hierarchy. Specifies the //! name of attachment or binding/slot as well as the name of the Pass on which the attachment or binding lives. @@ -166,7 +166,7 @@ namespace AZ }; using PassConnectionList = AZStd::vector; - using PassConnectionListView = AZStd::array_view; + using PassConnectionListView = AZStd::span; //! Specifies a connection from a Pass's output slot to one of it's input slots. This is used as a fallback //! for the output when the pass is disabled so the output can present a valid attachments to subsequent passes. @@ -183,7 +183,7 @@ namespace AZ }; using PassFallbackConnectionList = AZStd::vector; - using PassFallbackConnectionListView = AZStd::array_view; + using PassFallbackConnectionListView = AZStd::span; // --- Pass Attachment Descriptor Classes --- @@ -269,7 +269,7 @@ namespace AZ }; using PassImageAttachmentDescList = AZStd::vector; - using PassImageAttachmentDescListView = AZStd::array_view; + using PassImageAttachmentDescListView = AZStd::span; //! A PassAttachmentDesc used for buffers struct PassBufferAttachmentDesc final @@ -283,7 +283,7 @@ namespace AZ }; using PassBufferAttachmentDescList = AZStd::vector; - using PassBufferAttachmentDescListView = AZStd::array_view; + using PassBufferAttachmentDescListView = AZStd::span; } // namespace RPI diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassRequest.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassRequest.h index 28d9fcc812..92067938b6 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassRequest.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassRequest.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -75,7 +75,7 @@ namespace AZ }; using PassRequestList = AZStd::vector; - using PassRequestListView = AZStd::array_view; + using PassRequestListView = AZStd::span; } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassTemplate.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassTemplate.h index d33b632848..f6bcd019cc 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassTemplate.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/PassTemplate.h @@ -11,7 +11,7 @@ #include -#include +#include #include #include diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Shader/ShaderAsset.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Shader/ShaderAsset.h index 70451bd055..bea7cb4b26 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Shader/ShaderAsset.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Shader/ShaderAsset.h @@ -158,8 +158,8 @@ namespace AZ //! Returns the set of shader resource group layouts owned by a given supervariant. - AZStd::array_view> GetShaderResourceGroupLayouts( SupervariantIndex supervariantIndex) const; - AZStd::array_view> GetShaderResourceGroupLayouts() const + AZStd::span> GetShaderResourceGroupLayouts( SupervariantIndex supervariantIndex) const; + AZStd::span> GetShaderResourceGroupLayouts() const { return GetShaderResourceGroupLayouts(DefaultSupervariantIndex); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyId.cpp b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyId.cpp index d123fe33b7..3b0d6d79b8 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyId.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialPropertyId.cpp @@ -88,7 +88,7 @@ namespace AZ { } - MaterialPropertyId::MaterialPropertyId(const AZStd::array_view names) + MaterialPropertyId::MaterialPropertyId(const AZStd::span names) { for (const auto& name : names) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/GpuQueryTypes.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/GpuQueryTypes.cpp index 1c8c504aad..69637bce4e 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/GpuQueryTypes.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/GpuQueryTypes.cpp @@ -54,7 +54,7 @@ namespace AZ // --- PipelineStatisticsResult --- - PipelineStatisticsResult::PipelineStatisticsResult(AZStd::array_view&& statisticsResultArray) + PipelineStatisticsResult::PipelineStatisticsResult(AZStd::span&& statisticsResultArray) { for (const PipelineStatisticsResult& result : statisticsResultArray) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/QueryPool.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/QueryPool.cpp index 755b4e8cea..d4411b57c0 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/QueryPool.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/QueryPool.cpp @@ -147,7 +147,7 @@ namespace AZ return endQuery->End(commandList); } - AZStd::array_view> RPI::QueryPool::GetRhiQueryArray() const + AZStd::span> RPI::QueryPool::GetRhiQueryArray() const { return m_rhiQueryArray; } @@ -230,12 +230,12 @@ namespace AZ return m_queriesPerResult; } - AZStd::array_view> QueryPool::GetRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const + AZStd::span> QueryPool::GetRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const { const uint32_t queryCount = rhiQueryIndices.m_max - rhiQueryIndices.m_min + 1u; AZ_Assert(rhiQueryIndices.m_max < m_rhiQueryCapacity, "Query array index is going over the limit"); - return AZStd::array_view>(m_rhiQueryArray.begin() + rhiQueryIndices.m_min, queryCount); + return AZStd::span>(m_rhiQueryArray.begin() + rhiQueryIndices.m_min, queryCount); } AZStd::vector QueryPool::GetRawRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/TimestampQueryPool.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/TimestampQueryPool.cpp index 7edc325b9e..33b776671a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/TimestampQueryPool.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/GpuQuery/TimestampQueryPool.cpp @@ -26,7 +26,7 @@ namespace AZ RHI::ResultCode TimestampQueryPool::BeginQueryInternal(RHI::Interval rhiQueryIndices, RHI::CommandList& commandList) { - AZStd::array_view> rhiQueryArray = GetRhiQueryArray(); + AZStd::span> rhiQueryArray = GetRhiQueryArray(); AZ::RHI::Ptr beginQuery = rhiQueryArray[rhiQueryIndices.m_min]; return beginQuery->WriteTimestamp(commandList); @@ -34,7 +34,7 @@ namespace AZ RHI::ResultCode TimestampQueryPool::EndQueryInternal(RHI::Interval rhiQueryIndices, RHI::CommandList& commandList) { - AZStd::array_view> rhiQueryArray = GetRhiQueryArray(); + AZStd::span> rhiQueryArray = GetRhiQueryArray(); AZ::RHI::Ptr endQuery = rhiQueryArray[rhiQueryIndices.m_max]; return endQuery->WriteTimestamp(commandList); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp index 4f3cf52dad..b5d1c06d8d 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp @@ -57,7 +57,7 @@ namespace AZ return m_lods.size(); } - AZStd::array_view> Model::GetLods() const + AZStd::span> Model::GetLods() const { return m_lods; } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp index a928aec12f..0af1893a71 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp @@ -28,7 +28,7 @@ namespace AZ &modelAssetAny); } - AZStd::array_view ModelLod::GetMeshes() const + AZStd::span ModelLod::GetMeshes() const { return m_meshes; } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index 55f3e44173..77a3e1524a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -398,7 +398,7 @@ namespace AZ // --- Debug functions --- - AZStd::array_view> ParentPass::GetChildren() const + AZStd::span> ParentPass::GetChildren() const { return m_children; } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp index 130c0158d1..de79931ed0 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp @@ -490,7 +490,7 @@ namespace AZ return m_asset->FindFallbackShaderResourceGroupLayout(m_supervariantIndex); } - AZStd::array_view> Shader::GetShaderResourceGroupLayouts() const + AZStd::span> Shader::GetShaderResourceGroupLayouts() const { return m_asset->GetShaderResourceGroupLayouts(m_supervariantIndex); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderResourceGroup.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderResourceGroup.cpp index b927e864fc..383ddddf19 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderResourceGroup.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderResourceGroup.cpp @@ -76,7 +76,7 @@ namespace AZ { const auto& lay = shaderAsset.FindShaderResourceGroupLayout(srgName, supervariantIndex); m_layout = lay.get(); - + if (!m_layout) { AZ_Assert(false, "ShaderResourceGroup cannot be initialized due to invalid ShaderResourceGroupLayout"); @@ -188,7 +188,7 @@ namespace AZ { return GetLayout()->HasShaderVariantKeyFallbackEntry(); } - + bool ShaderResourceGroup::SetImage(RHI::ShaderInputNameIndex& inputIndex, const Data::Instance& image, uint32_t arrayIndex) { if (inputIndex.ValidateOrFindImageIndex(GetLayout())) @@ -215,7 +215,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetImageArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view> images, uint32_t arrayIndex) + bool ShaderResourceGroup::SetImageArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span> images, uint32_t arrayIndex) { if (inputIndex.ValidateOrFindImageIndex(GetLayout())) { @@ -224,7 +224,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetImageArray(RHI::ShaderInputImageIndex inputIndex, AZStd::array_view> images, uint32_t arrayIndex) + bool ShaderResourceGroup::SetImageArray(RHI::ShaderInputImageIndex inputIndex, AZStd::span> images, uint32_t arrayIndex) { if (GetLayout()->ValidateAccess(inputIndex, arrayIndex + static_cast(images.size()) - 1)) { @@ -257,7 +257,7 @@ namespace AZ return s_nullImage; } - AZStd::array_view> ShaderResourceGroup::GetImageArray(RHI::ShaderInputNameIndex& inputIndex) const + AZStd::span> ShaderResourceGroup::GetImageArray(RHI::ShaderInputNameIndex& inputIndex) const { if (inputIndex.ValidateOrFindImageIndex(GetLayout())) { @@ -266,12 +266,12 @@ namespace AZ return {}; } - AZStd::array_view> ShaderResourceGroup::GetImageArray(RHI::ShaderInputImageIndex inputIndex) const + AZStd::span> ShaderResourceGroup::GetImageArray(RHI::ShaderInputImageIndex inputIndex) const { if (m_layout->ValidateAccess(inputIndex, 0)) { const RHI::Interval interval = m_layout->GetGroupInterval(inputIndex); - return AZStd::array_view>(&m_imageGroup[interval.m_min], interval.m_max - interval.m_min); + return AZStd::span>(&m_imageGroup[interval.m_min], interval.m_max - interval.m_min); } return {}; } @@ -299,7 +299,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetImageViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view imageViews, uint32_t arrayIndex) + bool ShaderResourceGroup::SetImageViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span imageViews, uint32_t arrayIndex) { if (inputIndex.ValidateOrFindImageIndex(GetLayout())) { @@ -308,7 +308,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetImageViewArray(RHI::ShaderInputImageIndex inputIndex, AZStd::array_view imageViews, uint32_t arrayIndex) + bool ShaderResourceGroup::SetImageViewArray(RHI::ShaderInputImageIndex inputIndex, AZStd::span imageViews, uint32_t arrayIndex) { if (GetLayout()->ValidateAccess(inputIndex, arrayIndex + static_cast(imageViews.size()) - 1)) { @@ -322,7 +322,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::array_view imageViews) + bool ShaderResourceGroup::SetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::span imageViews) { return m_data.SetImageViewUnboundedArray(inputIndex, imageViews); } @@ -350,7 +350,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view bufferViews, uint32_t arrayIndex) + bool ShaderResourceGroup::SetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span bufferViews, uint32_t arrayIndex) { if (inputIndex.ValidateOrFindBufferIndex(GetLayout())) { @@ -359,7 +359,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::array_view bufferViews, uint32_t arrayIndex) + bool ShaderResourceGroup::SetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::span bufferViews, uint32_t arrayIndex) { if (GetLayout()->ValidateAccess(inputIndex, arrayIndex + static_cast(bufferViews.size()) - 1)) { @@ -373,7 +373,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::array_view bufferViews) + bool ShaderResourceGroup::SetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::span bufferViews) { return m_data.SetBufferViewUnboundedArray(inputIndex, bufferViews); } @@ -392,7 +392,7 @@ namespace AZ return m_data.SetSampler(inputIndex, sampler, arrayIndex); } - bool ShaderResourceGroup::SetSamplerArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view samplers, uint32_t arrayIndex) + bool ShaderResourceGroup::SetSamplerArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span samplers, uint32_t arrayIndex) { if (inputIndex.ValidateOrFindSamplerIndex(GetLayout())) { @@ -401,7 +401,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex, AZStd::array_view samplers, uint32_t arrayIndex) + bool ShaderResourceGroup::SetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex, AZStd::span samplers, uint32_t arrayIndex) { return m_data.SetSamplerArray(inputIndex, samplers, arrayIndex); } @@ -437,7 +437,7 @@ namespace AZ bool ShaderResourceGroup::ApplyDataMappings(const RHI::ShaderDataMappings& mappings) { bool success = true; - + success = success && ApplyDataMappingArray(mappings.m_colorMappings); success = success && ApplyDataMappingArray(mappings.m_uintMappings); success = success && ApplyDataMappingArray(mappings.m_floatMappings); @@ -461,13 +461,13 @@ namespace AZ return m_data.GetImageView(inputIndex, arrayIndex); } - AZStd::array_view> ShaderResourceGroup::GetImageViewArray(RHI::ShaderInputNameIndex& inputIndex) const + AZStd::span> ShaderResourceGroup::GetImageViewArray(RHI::ShaderInputNameIndex& inputIndex) const { inputIndex.ValidateOrFindImageIndex(GetLayout()); return GetImageViewArray(inputIndex.GetImageIndex()); } - AZStd::array_view> ShaderResourceGroup::GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const + AZStd::span> ShaderResourceGroup::GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const { return m_data.GetImageViewArray(inputIndex); } @@ -483,13 +483,13 @@ namespace AZ return m_data.GetBufferView(inputIndex, arrayIndex); } - AZStd::array_view> ShaderResourceGroup::GetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex) const + AZStd::span> ShaderResourceGroup::GetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex) const { inputIndex.ValidateOrFindBufferIndex(GetLayout()); return GetBufferViewArray(inputIndex.GetBufferIndex()); } - AZStd::array_view> ShaderResourceGroup::GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const + AZStd::span> ShaderResourceGroup::GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const { return m_data.GetBufferViewArray(inputIndex); } @@ -520,7 +520,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetBufferArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view> buffers, uint32_t arrayIndex) + bool ShaderResourceGroup::SetBufferArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span> buffers, uint32_t arrayIndex) { if (inputIndex.ValidateOrFindBufferIndex(GetLayout())) { @@ -529,7 +529,7 @@ namespace AZ return false; } - bool ShaderResourceGroup::SetBufferArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::array_view> buffers, uint32_t arrayIndex) + bool ShaderResourceGroup::SetBufferArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::span> buffers, uint32_t arrayIndex) { if (GetLayout()->ValidateAccess(inputIndex, arrayIndex + static_cast(buffers.size()) - 1)) { @@ -562,7 +562,7 @@ namespace AZ return s_nullBuffer; } - AZStd::array_view> ShaderResourceGroup::GetBufferArray(RHI::ShaderInputNameIndex& inputIndex) const + AZStd::span> ShaderResourceGroup::GetBufferArray(RHI::ShaderInputNameIndex& inputIndex) const { if (inputIndex.ValidateOrFindBufferIndex(GetLayout())) { @@ -571,12 +571,12 @@ namespace AZ return {}; } - AZStd::array_view> ShaderResourceGroup::GetBufferArray(RHI::ShaderInputBufferIndex inputIndex) const + AZStd::span> ShaderResourceGroup::GetBufferArray(RHI::ShaderInputBufferIndex inputIndex) const { if (m_layout->ValidateAccess(inputIndex, 0)) { const RHI::Interval interval = m_layout->GetGroupInterval(inputIndex); - return AZStd::array_view>(&m_bufferGroup[interval.m_min], interval.m_max - interval.m_min); + return AZStd::span>(&m_bufferGroup[interval.m_min], interval.m_max - interval.m_min); } return {}; } @@ -597,24 +597,24 @@ namespace AZ return m_data.GetSampler(inputIndex, arrayIndex); } - AZStd::array_view ShaderResourceGroup::GetSamplerArray(RHI::ShaderInputNameIndex& inputIndex) const + AZStd::span ShaderResourceGroup::GetSamplerArray(RHI::ShaderInputNameIndex& inputIndex) const { inputIndex.ValidateOrFindSamplerIndex(GetLayout()); return GetSamplerArray(inputIndex.GetSamplerIndex()); } - AZStd::array_view ShaderResourceGroup::GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const + AZStd::span ShaderResourceGroup::GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const { return m_data.GetSamplerArray(inputIndex); } - AZStd::array_view ShaderResourceGroup::GetConstantRaw(RHI::ShaderInputNameIndex& inputIndex) const + AZStd::span ShaderResourceGroup::GetConstantRaw(RHI::ShaderInputNameIndex& inputIndex) const { inputIndex.ValidateOrFindConstantIndex(GetLayout()); return GetConstantRaw(inputIndex.GetConstantIndex()); } - AZStd::array_view ShaderResourceGroup::GetConstantRaw(RHI::ShaderInputConstantIndex inputIndex) const + AZStd::span ShaderResourceGroup::GetConstantRaw(RHI::ShaderInputConstantIndex inputIndex) const { return m_data.GetConstantRaw(inputIndex); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAsset.cpp index 95f47d7393..92508162a5 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAsset.cpp @@ -49,9 +49,9 @@ namespace AZ } } - AZStd::array_view BufferAsset::GetBuffer() const + AZStd::span BufferAsset::GetBuffer() const { - return AZStd::array_view(m_buffer); + return AZStd::span(m_buffer); } const RHI::BufferDescriptor& BufferAsset::GetBufferDescriptor() const diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAssetCreator.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAssetCreator.cpp index feeeff36cf..ec8292a52e 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAssetCreator.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAssetCreator.cpp @@ -165,7 +165,7 @@ namespace AZ creator.SetPoolAsset(sourceAsset->GetPoolAsset()); creator.SetBufferViewDescriptor(sourceAsset->GetBufferViewDescriptor()); - const AZStd::array_view sourceBuffer = sourceAsset->GetBuffer(); + const AZStd::span sourceBuffer = sourceAsset->GetBuffer(); creator.SetBuffer(sourceBuffer.data(), sourceBuffer.size(), sourceAsset->GetBufferDescriptor()); return creator.End(clonedResult); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/ImageMipChainAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/ImageMipChainAsset.cpp index f86200485a..e86cfb7c82 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/ImageMipChainAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/ImageMipChainAsset.cpp @@ -49,19 +49,19 @@ namespace AZ return m_subImageDatas.size(); } - AZStd::array_view ImageMipChainAsset::GetSubImageData(uint32_t mipSlice, uint32_t arraySlice) const + AZStd::span ImageMipChainAsset::GetSubImageData(uint32_t mipSlice, uint32_t arraySlice) const { return GetSubImageData(mipSlice * m_arraySize + arraySlice); } - AZStd::array_view ImageMipChainAsset::GetSubImageData(uint32_t subImageIndex) const + AZStd::span ImageMipChainAsset::GetSubImageData(uint32_t subImageIndex) const { AZ_Assert(subImageIndex < m_subImageDataOffsets.size() && subImageIndex < m_subImageDatas.size(), "subImageIndex is out of range"); // The offset vector contains an extra sentinel value. const size_t dataSize = m_subImageDataOffsets[subImageIndex + 1] - m_subImageDataOffsets[subImageIndex]; - return AZStd::array_view(reinterpret_cast(m_subImageDatas[subImageIndex].m_data), dataSize); + return AZStd::span(reinterpret_cast(m_subImageDatas[subImageIndex].m_data), dataSize); } const RHI::ImageSubresourceLayout& ImageMipChainAsset::GetSubImageLayout(uint32_t mipSlice) const @@ -111,7 +111,7 @@ namespace AZ for (uint16_t mipSliceIndex = 0; mipSliceIndex < m_mipLevels; ++mipSliceIndex) { RHI::StreamingImageMipSlice mipSlice; - mipSlice.m_subresources = AZStd::array_view(&m_subImageDatas[m_arraySize * mipSliceIndex], m_arraySize); + mipSlice.m_subresources = AZStd::span(&m_subImageDatas[m_arraySize * mipSliceIndex], m_arraySize); mipSlice.m_subresourceLayout = m_subImageLayouts[mipSliceIndex]; m_mipSlices.push_back(mipSlice); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp index 59f359e474..a67ed6f4bc 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp @@ -94,11 +94,11 @@ namespace AZ return m_totalImageDataSize; } - AZStd::array_view StreamingImageAsset::GetSubImageData(uint32_t mip, uint32_t slice) + AZStd::span StreamingImageAsset::GetSubImageData(uint32_t mip, uint32_t slice) { if (mip >= m_mipLevelToChainIndex.size()) { - return AZStd::array_view(); + return AZStd::span(); } size_t mipChainIndex = m_mipLevelToChainIndex[mip]; @@ -119,7 +119,7 @@ namespace AZ if (mipChainAsset == nullptr) { AZ_Warning("Streaming Image", false, "MipChain asset wasn't loaded"); - return AZStd::array_view(); + return AZStd::span(); } return mipChainAsset->GetSubImageData(mip - mipChain.m_mipOffset, slice); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialTypeAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialTypeAsset.cpp index 48654d7769..bf765b1178 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialTypeAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialTypeAsset.cpp @@ -154,7 +154,7 @@ namespace AZ return m_materialPropertiesLayout.get(); } - AZStd::array_view MaterialTypeAsset::GetDefaultPropertyValues() const + AZStd::span MaterialTypeAsset::GetDefaultPropertyValues() const { return m_propertyValues; } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp index 0574803591..6780763d7c 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp @@ -82,9 +82,9 @@ namespace AZ return m_lodAssets.size(); } - AZStd::array_view> ModelAsset::GetLodAssets() const + AZStd::span> ModelAsset::GetLodAssets() const { - return AZStd::array_view>(m_lodAssets); + return AZStd::span>(m_lodAssets); } void ModelAsset::SetReady() @@ -213,7 +213,7 @@ namespace AZ } RHI::BufferViewDescriptor positionBufferViewDesc = positionBufferView->GetBufferViewDescriptor(); - AZStd::array_view positionRawBuffer = bufferAssetViewPtr->GetBuffer(); + AZStd::span positionRawBuffer = bufferAssetViewPtr->GetBuffer(); const uint32_t positionElementSize = positionBufferViewDesc.m_elementSize; const uint32_t positionElementCount = positionBufferViewDesc.m_elementCount; @@ -227,7 +227,7 @@ namespace AZ } RHI::BufferViewDescriptor indexBufferViewDesc = indexBufferView.GetBufferViewDescriptor(); - AZStd::array_view indexRawBuffer = indexAssetViewPtr->GetBuffer(); + AZStd::span indexRawBuffer = indexAssetViewPtr->GetBuffer(); const AZ::Vector3 rayEnd = rayStart + rayDir; AZ::Vector3 a, b, c; @@ -297,7 +297,7 @@ namespace AZ { for (const ModelLodAsset::Mesh& mesh : loadAssetPtr->GetMeshes()) { - const AZStd::array_view& streamBufferList = mesh.GetStreamBufferInfoList(); + const AZStd::span& streamBufferList = mesh.GetStreamBufferInfoList(); // find position semantic const ModelLodAsset::Mesh::StreamBufferInfo* positionBuffer = nullptr; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAssetCreator.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAssetCreator.cpp index 524ef9e910..f6fb9455d7 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAssetCreator.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAssetCreator.cpp @@ -101,7 +101,7 @@ namespace AZ creator.SetName(sourceAsset->GetName().GetStringView()); AZ::Data::AssetId lastUsedId = cloneAssetId; - const AZStd::array_view> sourceLodAssets = sourceAsset->GetLodAssets(); + const AZStd::span> sourceLodAssets = sourceAsset->GetLodAssets(); for (const Data::Asset& sourceLodAsset : sourceLodAssets) { Data::Asset lodAsset; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelKdTree.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelKdTree.cpp index b84390a318..5681cf71c1 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelKdTree.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelKdTree.cpp @@ -61,7 +61,7 @@ namespace AZ { const auto& [first, second, third] = triangleIndices; - const AZStd::array_view& positionBuffer = m_meshes[nObjIndex].m_vertexData; + const AZStd::span& positionBuffer = m_meshes[nObjIndex].m_vertexData; if (positionBuffer.empty()) { @@ -114,7 +114,7 @@ namespace AZ for (AZ::u8 meshIndex = 0, meshCount = aznumeric_caster(m_meshes.size()); meshIndex < meshCount; ++meshIndex) { - const AZStd::array_view positionBuffer = m_meshes[meshIndex].m_vertexData; + const AZStd::span positionBuffer = m_meshes[meshIndex].m_vertexData; for (size_t positionIndex = 0; positionIndex < positionBuffer.size(); positionIndex += 3) { entireBoundBox.AddPoint({positionBuffer[positionIndex], positionBuffer[positionIndex + 1], positionBuffer[positionIndex + 2]}); @@ -137,14 +137,14 @@ namespace AZ return true; } - AZStd::array_view ModelKdTree::GetPositionsBuffer(const ModelLodAsset::Mesh& mesh) + AZStd::span ModelKdTree::GetPositionsBuffer(const ModelLodAsset::Mesh& mesh) { - AZStd::array_view positionBuffer = mesh.GetSemanticBufferTyped(AZ::Name{"POSITION"}); + AZStd::span positionBuffer = mesh.GetSemanticBufferTyped(AZ::Name{"POSITION"}); AZ_Warning("ModelKdTree", !positionBuffer.empty(), "Could not find position buffers in a mesh"); return positionBuffer; } - AZStd::array_view ModelKdTree::GetIndexBuffer(const ModelLodAsset::Mesh& mesh) + AZStd::span ModelKdTree::GetIndexBuffer(const ModelLodAsset::Mesh& mesh) { return mesh.GetIndexBufferTyped(); } @@ -264,7 +264,7 @@ namespace AZ const auto& [first, second, third] = pNode->GetVertexIndex(i); const AZ::u32 nObjIndex = pNode->GetObjIndex(i); - const AZStd::array_view positionBuffer = m_meshes[nObjIndex].m_vertexData; + const AZStd::span positionBuffer = m_meshes[nObjIndex].m_vertexData; if (positionBuffer.empty()) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelLodAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelLodAsset.cpp index ccf0d49b46..7dffaccf0a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelLodAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelLodAsset.cpp @@ -95,9 +95,9 @@ namespace AZ return m_indexBufferAssetView; } - AZStd::array_view ModelLodAsset::Mesh::GetStreamBufferInfoList() const + AZStd::span ModelLodAsset::Mesh::GetStreamBufferInfoList() const { - return AZStd::array_view(m_streamBufferInfo); + return AZStd::span(m_streamBufferInfo); } void ModelLodAsset::AddMesh(const Mesh& mesh) @@ -109,9 +109,9 @@ namespace AZ m_aabb.AddAabb(meshAabb); } - AZStd::array_view ModelLodAsset::GetMeshes() const + AZStd::span ModelLodAsset::GetMeshes() const { - return AZStd::array_view(m_meshes); + return AZStd::span(m_meshes); } const AZ::Aabb& ModelLodAsset::GetAabb() const @@ -121,7 +121,7 @@ namespace AZ const BufferAssetView* ModelLodAsset::Mesh::GetSemanticBufferAssetView(const AZ::Name& semantic) const { - const AZStd::array_view& streamBufferList = GetStreamBufferInfoList(); + const AZStd::span& streamBufferList = GetStreamBufferInfoList(); for (const ModelLodAsset::Mesh::StreamBufferInfo& streamBufferInfo : streamBufferList) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelLodAssetCreator.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelLodAssetCreator.cpp index f94116db70..94d20ed6ea 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelLodAssetCreator.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelLodAssetCreator.cpp @@ -243,7 +243,7 @@ namespace AZ bool ModelLodAssetCreator::Clone(const Data::Asset& sourceAsset, Data::Asset& clonedResult, Data::AssetId& inOutLastCreatedAssetId) { - AZStd::array_view sourceMeshes = sourceAsset->GetMeshes(); + AZStd::span sourceMeshes = sourceAsset->GetMeshes(); if (sourceMeshes.empty()) { return true; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp index 6daca5553e..ca1188a70e 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp @@ -383,7 +383,7 @@ namespace AZ return RHI::NullSrgLayout; } - AZStd::array_view> ShaderAsset::GetShaderResourceGroupLayouts( + AZStd::span> ShaderAsset::GetShaderResourceGroupLayouts( SupervariantIndex supervariantIndex) const { auto supervariant = GetSupervariant(supervariantIndex); diff --git a/Gems/Atom/RPI/Code/Tests/Common/RHI/Stubs.h b/Gems/Atom/RPI/Code/Tests/Common/RHI/Stubs.h index b8d1cfa050..400eb9521c 100644 --- a/Gems/Atom/RPI/Code/Tests/Common/RHI/Stubs.h +++ b/Gems/Atom/RPI/Code/Tests/Common/RHI/Stubs.h @@ -132,7 +132,7 @@ namespace UnitTest { return m_data; } - + private: bool m_isMapped = false; AZStd::vector m_data; @@ -146,7 +146,7 @@ namespace UnitTest private: AZ::RHI::ResultCode InitInternal(AZ::RHI::Device&, const AZ::RHI::BufferPoolDescriptor&) override { return AZ::RHI::ResultCode::Success;} - + AZ::RHI::ResultCode InitBufferInternal(AZ::RHI::Buffer& bufferBase, const AZ::RHI::BufferDescriptor& descriptor) override { AZ_Assert(IsInitialized(), "Buffer Pool is not initialized"); @@ -264,7 +264,7 @@ namespace UnitTest private: AZ::RHI::ResultCode InitInternal(AZ::RHI::Device&, const AZ::RHI::PipelineLibraryData*) override { return AZ::RHI::ResultCode::Success; } void ShutdownInternal() override {} - AZ::RHI::ResultCode MergeIntoInternal(AZStd::array_view) override { return AZ::RHI::ResultCode::Success; } + AZ::RHI::ResultCode MergeIntoInternal(AZStd::span) override { return AZ::RHI::ResultCode::Success; } AZ::RHI::ConstPtr GetSerializedDataInternal() const override { return nullptr; } }; @@ -372,11 +372,11 @@ namespace UnitTest AZ::RHI::ResultCode InitInternal([[maybe_unused]] AZ::RHI::Device& device, [[maybe_unused]] const AZ::RHI::QueryPoolDescriptor& descriptor) override { return AZ::RHI::ResultCode::Success; } AZ::RHI::ResultCode InitQueryInternal([[maybe_unused]] AZ::RHI::Query& query) override { return AZ::RHI::ResultCode::Success; } AZ::RHI::ResultCode GetResultsInternal( - [[maybe_unused]] uint32_t startIndex, - [[maybe_unused]] uint32_t queryCount, - [[maybe_unused]] uint64_t* results, - [[maybe_unused]] uint32_t resultsCount, - [[maybe_unused]] AZ::RHI::QueryResultFlagBits flags) override + [[maybe_unused]] uint32_t startIndex, + [[maybe_unused]] uint32_t queryCount, + [[maybe_unused]] uint64_t* results, + [[maybe_unused]] uint32_t resultsCount, + [[maybe_unused]] AZ::RHI::QueryResultFlagBits flags) override { return AZ::RHI::ResultCode::Success; } }; diff --git a/Gems/Atom/RPI/Code/Tests/Image/StreamingImageTests.cpp b/Gems/Atom/RPI/Code/Tests/Image/StreamingImageTests.cpp index f7476c0bc4..cb8d903673 100644 --- a/Gems/Atom/RPI/Code/Tests/Image/StreamingImageTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Image/StreamingImageTests.cpp @@ -214,7 +214,7 @@ namespace UnitTest return image; } - void ValidateImageData(AZStd::array_view data, const AZ::RHI::ImageSubresourceLayout& layout) + void ValidateImageData(AZStd::span data, const AZ::RHI::ImageSubresourceLayout& layout) { const uint32_t pixelSize = layout.m_size.m_width / layout.m_bytesPerRow; @@ -259,7 +259,7 @@ namespace UnitTest for (uint16_t arrayIndex = 0; arrayIndex < mipChain->GetArraySize(); ++arrayIndex) { - AZStd::array_view imageData = mipChain->GetSubImageData(mipLevel, arrayIndex); + AZStd::span imageData = mipChain->GetSubImageData(mipLevel, arrayIndex); ValidateImageData(imageData, layout); } } @@ -573,7 +573,7 @@ namespace UnitTest EXPECT_EQ(mipChain->GetArraySize(), arraySize); EXPECT_EQ(mipChain->GetSubImageCount(), mipLevels * arraySize); - AZStd::array_view dataView = mipChain->GetSubImageData(0); + AZStd::span dataView = mipChain->GetSubImageData(0); EXPECT_EQ(dataView[0], data[0]); EXPECT_EQ(dataView[1], data[1]); EXPECT_EQ(dataView[2], data[2]); diff --git a/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp index 94518c6aef..133592e72c 100644 --- a/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp @@ -646,7 +646,7 @@ namespace UnitTest MaterialPropertyIndex myFloat2 = layout->FindPropertyIndex(Name("general.MyFloat2")); MaterialPropertyIndex myColor = layout->FindPropertyIndex(Name("general.MyColor")); - AZStd::array_view properties; + AZStd::span properties; // Check level 1 properties properties = materialAssetLevel1.GetValue()->GetPropertyValues(); @@ -736,7 +736,7 @@ namespace UnitTest // The properties will finalize automatically when we call GetPropertyValues()... - AZStd::array_view properties; + AZStd::span properties; // Check level 1 properties properties = materialAssetLevel1->GetPropertyValues(); diff --git a/Gems/Atom/RPI/Code/Tests/Shader/ShaderTests.cpp b/Gems/Atom/RPI/Code/Tests/Shader/ShaderTests.cpp index 38b3fa9eb2..74f79ad80a 100644 --- a/Gems/Atom/RPI/Code/Tests/Shader/ShaderTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Shader/ShaderTests.cpp @@ -538,7 +538,11 @@ namespace UnitTest auto shaderAsset = shader->GetAsset(); EXPECT_EQ(shader->GetPipelineStateType(), shaderAsset->GetPipelineStateType()); - EXPECT_EQ(shader->GetShaderResourceGroupLayouts(), shaderAsset->GetShaderResourceGroupLayouts()); + using ShaderResourceGroupLayoutSpan = AZStd::span>; + ShaderResourceGroupLayoutSpan shaderResourceGroupLayoutSpan = shader->GetShaderResourceGroupLayouts(); + ShaderResourceGroupLayoutSpan shaderAssetResourceGroupLayoutSpan = shader->GetShaderResourceGroupLayouts(); + EXPECT_EQ(shaderResourceGroupLayoutSpan.data(), shaderAssetResourceGroupLayoutSpan.data()); + EXPECT_EQ(shaderResourceGroupLayoutSpan.size(), shaderAssetResourceGroupLayoutSpan.size()); const RPI::ShaderVariant& rootShaderVariant = shader->GetVariant( RPI::ShaderVariantStableId{0} ); diff --git a/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp b/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp index 0c3c82933b..f69cfe180a 100644 --- a/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp @@ -57,7 +57,7 @@ namespace UnitTest } template - void ExpectEqual(AZStd::initializer_list expectedValues, AZStd::array_view arrayView) + void ExpectEqual(AZStd::initializer_list expectedValues, AZStd::span arrayView) { EXPECT_EQ(expectedValues.size(), arrayView.size()); @@ -215,14 +215,14 @@ namespace UnitTest EXPECT_TRUE(m_srg->SetConstant(inputIndex, true)); EXPECT_EQ(true, m_srg->GetConstant(inputIndex)); - AZStd::array_view result = m_srg->GetConstantRaw(inputIndex); - AZStd::array_view resultInUint = AZStd::array_view(reinterpret_cast(result.data()), 1); + AZStd::span result = m_srg->GetConstantRaw(inputIndex); + AZStd::span resultInUint = AZStd::span(reinterpret_cast(result.data()), 1); ExpectEqual({ 1 /*true*/ }, resultInUint); EXPECT_TRUE(m_srg->SetConstant(inputIndex, false)); EXPECT_EQ(false, m_srg->GetConstant(inputIndex)); result = m_srg->GetConstantRaw(inputIndex); - resultInUint = AZStd::array_view(reinterpret_cast(result.data()), 1); + resultInUint = AZStd::span(reinterpret_cast(result.data()), 1); ExpectEqual({ 0 /*false*/ }, resultInUint); } @@ -232,13 +232,13 @@ namespace UnitTest // Check using inputIndex EXPECT_TRUE(m_srg->SetConstantArray(inputIndex, AZStd::array({ true, false }))); - AZStd::array_view result = m_srg->GetConstantRaw(inputIndex); - AZStd::array_view resultInUint = AZStd::array_view(reinterpret_cast(result.data()), 2); + AZStd::span result = m_srg->GetConstantRaw(inputIndex); + AZStd::span resultInUint = AZStd::span(reinterpret_cast(result.data()), 2); ExpectEqual({ 1 /*true*/, 0 /*false*/ }, resultInUint); EXPECT_TRUE(m_srg->SetConstantArray(inputIndex, AZStd::array({ false, true }))); result = m_srg->GetConstantRaw(inputIndex); - resultInUint = AZStd::array_view(reinterpret_cast(result.data()), 2); + resultInUint = AZStd::span(reinterpret_cast(result.data()), 2); ExpectEqual({ 0 /*false*/, 1 /*true*/ }, resultInUint); } } @@ -263,8 +263,8 @@ namespace UnitTest const RHI::ShaderInputConstantIndex inputIndex(1); EXPECT_TRUE(m_srg->SetConstantArray(inputIndex, AZStd::array({ asBools[1], asBools[2] }))); - AZStd::array_view result = m_srg->GetConstantRaw(inputIndex); - AZStd::array_view resultInUint = AZStd::array_view(reinterpret_cast(result.data()), 2); + AZStd::span result = m_srg->GetConstantRaw(inputIndex); + AZStd::span resultInUint = AZStd::span(reinterpret_cast(result.data()), 2); EXPECT_THAT(resultInUint, testing::ElementsAre(testing::IsTrue(), testing::IsFalse())); } } @@ -356,7 +356,7 @@ namespace UnitTest { using namespace AZ; - AZStd::array_view values; + AZStd::span values; const RHI::ShaderInputConstantIndex inputIndex(17); // Demonstrate the syntax of setting with a variable, and inputIndex... diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp index 2a0d91d0ad..6ec809e871 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp @@ -734,7 +734,7 @@ namespace MaterialEditor return false; } - AZStd::array_view parentPropertyValues = materialTypeAsset->GetDefaultPropertyValues(); + AZStd::span parentPropertyValues = materialTypeAsset->GetDefaultPropertyValues(); AZ::Data::Asset parentMaterialAsset; if (!m_materialSourceData.m_parentMaterial.empty()) { diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImageComparison.h b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImageComparison.h index cbd4a3c30a..4126e9eb4a 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImageComparison.h +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImageComparison.h @@ -7,7 +7,7 @@ */ #pragma once -#include +#include #include #include @@ -31,8 +31,8 @@ namespace AZ //! @param filteredDiff [out] an alternate RMS value calculated after removing any diffs less than @minDiffFilter. //! @param minDiffFilter diff values less than this will be filtered out before calculating @filteredDiff. ImageDiffResultCode CalcImageDiffRms( - AZStd::array_view bufferA, const RHI::Size& sizeA, RHI::Format formatA, - AZStd::array_view bufferB, const RHI::Size& sizeB, RHI::Format formatB, + AZStd::span bufferA, const RHI::Size& sizeA, RHI::Format formatA, + AZStd::span bufferB, const RHI::Size& sizeB, RHI::Format formatB, float* diffScore = nullptr, float* filteredDiffScore = nullptr, float minDiffFilter = 0.0); diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/PngFile.h b/Gems/Atom/Utils/Code/Include/Atom/Utils/PngFile.h index b862786c2f..01e9134b4d 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/PngFile.h +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/PngFile.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -55,7 +55,7 @@ namespace AZ static PngFile Load(const char* path, LoadSettings loadSettings = {}); //! @return the loaded PngFile or an invalid PngFile if there was an error. - static PngFile LoadFromBuffer(AZStd::array_view data, LoadSettings loadSettings = {}); + static PngFile LoadFromBuffer(AZStd::span data, LoadSettings loadSettings = {}); //! Create a PngFile from an RHI data buffer. //! @param size the dimensions of the image (m_depth is not used, assumed to be 1) @@ -63,7 +63,7 @@ namespace AZ //! @param data the buffer of image data. The size of the buffer must match the @size and @format parameters. //! @param errorHandler optional callback function describing any errors that are encountered //! @return the created PngFile or an invalid PngFile if there was an error. - static PngFile Create(const RHI::Size& size, RHI::Format format, AZStd::array_view data, ErrorHandler errorHandler = {}); + static PngFile Create(const RHI::Size& size, RHI::Format format, AZStd::span data, ErrorHandler errorHandler = {}); static PngFile Create(const RHI::Size& size, RHI::Format format, AZStd::vector&& data, ErrorHandler errorHandler = {}); PngFile() = default; diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/PpmFile.h b/Gems/Atom/Utils/Code/Include/Atom/Utils/PpmFile.h index 77b0049df8..e50b83dc4b 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/PpmFile.h +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/PpmFile.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include @@ -26,7 +26,7 @@ namespace AZ //! @param size image dimensions //! @param format only R8G8B8A8_UNORM and B8G8R8A8_UNORM are supported at this time //! @return the buffer is ppm binary with RGB payload (alpha is omitted as it is not supported by .ppm format) - static AZStd::vector CreatePpmFromImageBuffer(AZStd::array_view buffer, const RHI::Size& size, RHI::Format format); + static AZStd::vector CreatePpmFromImageBuffer(AZStd::span buffer, const RHI::Size& size, RHI::Format format); //! Fills an image buffer with data from ppm file contents. //! @param ppmData the data loaded from a ppm file @@ -34,7 +34,7 @@ namespace AZ //! @param size output image dimensions //! @param format output image format //! @return true if the data was parsed successfully - static bool CreateImageBufferFromPpm(AZStd::array_view ppmData, AZStd::vector& buffer, RHI::Size& size, RHI::Format& format); + static bool CreateImageBufferFromPpm(AZStd::span ppmData, AZStd::vector& buffer, RHI::Size& size, RHI::Format& format); }; } } // namespace AZ diff --git a/Gems/Atom/Utils/Code/Source/ImageComparison.cpp b/Gems/Atom/Utils/Code/Source/ImageComparison.cpp index a17d07ed3f..0bad268ba5 100644 --- a/Gems/Atom/Utils/Code/Source/ImageComparison.cpp +++ b/Gems/Atom/Utils/Code/Source/ImageComparison.cpp @@ -8,13 +8,15 @@ #include +#include + namespace AZ { namespace Utils { ImageDiffResultCode CalcImageDiffRms( - AZStd::array_view bufferA, const RHI::Size& sizeA, RHI::Format formatA, - AZStd::array_view bufferB, const RHI::Size& sizeB, RHI::Format formatB, + AZStd::span bufferA, const RHI::Size& sizeA, RHI::Format formatA, + AZStd::span bufferB, const RHI::Size& sizeB, RHI::Format formatB, float* diffScore, float* filteredDiffScore, float minDiffFilter) diff --git a/Gems/Atom/Utils/Code/Source/PngFile.cpp b/Gems/Atom/Utils/Code/Source/PngFile.cpp index 1454dc68c9..7c1673221e 100644 --- a/Gems/Atom/Utils/Code/Source/PngFile.cpp +++ b/Gems/Atom/Utils/Code/Source/PngFile.cpp @@ -28,7 +28,7 @@ namespace AZ } } - PngFile PngFile::Create(const RHI::Size& size, RHI::Format format, AZStd::array_view data, ErrorHandler errorHandler) + PngFile PngFile::Create(const RHI::Size& size, RHI::Format format, AZStd::span data, ErrorHandler errorHandler) { return Create(size, format, AZStd::vector{data.begin(), data.end()}, errorHandler); } @@ -89,7 +89,7 @@ namespace AZ return pngFile; } - PngFile PngFile::LoadFromBuffer(AZStd::array_view data, LoadSettings loadSettings) + PngFile PngFile::LoadFromBuffer(AZStd::span data, LoadSettings loadSettings) { if (!loadSettings.m_errorHandler) { diff --git a/Gems/Atom/Utils/Code/Source/PpmFile.cpp b/Gems/Atom/Utils/Code/Source/PpmFile.cpp index 8fe40339f3..4e586f5df1 100644 --- a/Gems/Atom/Utils/Code/Source/PpmFile.cpp +++ b/Gems/Atom/Utils/Code/Source/PpmFile.cpp @@ -11,7 +11,7 @@ namespace AZ { - AZStd::vector Utils::PpmFile::CreatePpmFromImageBuffer(AZStd::array_view buffer, const RHI::Size& size, RHI::Format format) + AZStd::vector Utils::PpmFile::CreatePpmFromImageBuffer(AZStd::span buffer, const RHI::Size& size, RHI::Format format) { AZ_Assert(format == RHI::Format::R8G8B8A8_UNORM || format == RHI::Format::B8G8R8A8_UNORM, "CreatePpmFromImageReadbackResult only supports R8G8B8A8_UNORM"); @@ -46,7 +46,7 @@ namespace AZ return outBuffer; } - bool Utils::PpmFile::CreateImageBufferFromPpm(AZStd::array_view ppmData, AZStd::vector& buffer, RHI::Size& size, RHI::Format& format) + bool Utils::PpmFile::CreateImageBufferFromPpm(AZStd::span ppmData, AZStd::vector& buffer, RHI::Size& size, RHI::Format& format) { if (ppmData.size() < 2) { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index e26d328e17..9718d6b598 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -356,10 +356,10 @@ namespace AZ bool MeshComponentController::RequiresCloning(const Data::Asset& modelAsset) { // Is the model asset containing a cloth buffer? If yes, we need to clone the model asset for instancing. - const AZStd::array_view> lodAssets = modelAsset->GetLodAssets(); + const AZStd::span> lodAssets = modelAsset->GetLodAssets(); for (const AZ::Data::Asset& lodAsset : lodAssets) { - const AZStd::array_view meshes = lodAsset->GetMeshes(); + const AZStd::span meshes = lodAsset->GetMeshes(); for (const AZ::RPI::ModelLodAsset::Mesh& mesh : meshes) { if (mesh.GetSemanticBufferAssetView(AZ::Name("CLOTH_DATA")) != nullptr) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/ActorAsset.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/ActorAsset.cpp index 18b09b6eb1..996405ed4a 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/ActorAsset.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/ActorAsset.cpp @@ -59,7 +59,7 @@ namespace AZ lodVertexCount = 0; const Data::Asset& lodAsset = actor->GetMeshAsset()->GetLodAssets()[lodIndex]; - const AZStd::array_view modelMeshes = lodAsset->GetMeshes(); + const AZStd::span modelMeshes = lodAsset->GetMeshes(); for (const RPI::ModelLodAsset::Mesh& modelMesh : modelMeshes) { const size_t subMeshIndexCount = modelMesh.GetIndexCount(); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index d2b675684f..35aea57702 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -810,7 +810,7 @@ namespace AZ::Render if (m_wrinkleMasks.size()) { - wrinkleMaskObjectSrg->SetImageArray(wrinkleMasksIndex, AZStd::array_view>(m_wrinkleMasks.data(), m_wrinkleMasks.size())); + wrinkleMaskObjectSrg->SetImageArray(wrinkleMasksIndex, AZStd::span>(m_wrinkleMasks.data(), m_wrinkleMasks.size())); // Set the weights for any active masks for (size_t i = 0; i < m_wrinkleMaskWeights.size(); ++i) diff --git a/Gems/AtomTressFX/Code/Passes/HairParentPass.h b/Gems/AtomTressFX/Code/Passes/HairParentPass.h index e494e92e1d..05574bfd52 100644 --- a/Gems/AtomTressFX/Code/Passes/HairParentPass.h +++ b/Gems/AtomTressFX/Code/Passes/HairParentPass.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include namespace AZ diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp index 0c05da6981..39ff278c46 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp @@ -2551,7 +2551,7 @@ namespace EMotionFX Node* Actor::FindMeshJoint(const AZ::Data::Asset& lodModelAsset) const { - const AZStd::array_view& sourceMeshes = lodModelAsset->GetMeshes(); + const AZStd::span& sourceMeshes = lodModelAsset->GetMeshes(); // Use the first joint that we can find for any of the Atom sub meshes and use it as owner of our mesh. for (const AZ::RPI::ModelLodAsset::Mesh& sourceMesh : sourceMeshes) @@ -2574,7 +2574,7 @@ namespace EMotionFX AZ_Assert(m_meshAsset.IsReady(), "Mesh asset should be fully loaded and ready."); AZStd::vector& lodLevels = m_meshLodData.m_lodLevels; - const AZStd::array_view>& lodAssets = m_meshAsset->GetLodAssets(); + const AZStd::span>& lodAssets = m_meshAsset->GetLodAssets(); const size_t numLODLevels = lodAssets.size(); lodLevels.clear(); @@ -2700,7 +2700,7 @@ namespace EMotionFX AZ_Assert(m_meshAsset.IsReady() && m_morphTargetMetaAsset.IsReady(), "Mesh as well as morph target meta asset asset should be fully loaded and ready."); AZStd::vector& lodLevels = m_meshLodData.m_lodLevels; - const AZStd::array_view>& lodAssets = m_meshAsset->GetLodAssets(); + const AZStd::span>& lodAssets = m_meshAsset->GetLodAssets(); const size_t numLODLevels = lodAssets.size(); AZ_Assert(m_morphSetups.size() == numLODLevels, "There needs to be a morph setup for every single LOD level."); @@ -2708,7 +2708,7 @@ namespace EMotionFX for (size_t lodLevel = 0; lodLevel < numLODLevels; ++lodLevel) { const AZ::Data::Asset& lodAsset = lodAssets[lodLevel]; - const AZStd::array_view& sourceMeshes = lodAsset->GetMeshes(); + const AZStd::span& sourceMeshes = lodAsset->GetMeshes(); MorphSetup* morphSetup = m_morphSetups[static_cast(lodLevel)]; if (!morphSetup) @@ -2744,7 +2744,7 @@ namespace EMotionFX // The lod has shared buffers that combine the data from each submesh. In case any of the submeshes has a // morph target buffer view we can access the entire morph target buffer via the buffer asset. - AZStd::array_view morphTargetDeltaView; + AZStd::span morphTargetDeltaView; for (const AZ::RPI::ModelLodAsset::Mesh& sourceMesh : sourceMeshes) { if (const auto* bufferAssetView = sourceMesh.GetSemanticBufferAssetView(AZ::Name("MORPHTARGET_VERTEXDELTAS"))) diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.cpp index 9908cb0f58..6adbf05c15 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.cpp @@ -187,7 +187,7 @@ namespace EMotionFX const AZ::RPI::ModelLodAsset::Mesh& sourceMesh = sourceModelLod->GetMeshes()[0]; // Copy the index buffer for the entire lod - AZStd::array_view indexBuffer = sourceMesh.GetIndexBufferAssetView().GetBufferAsset()->GetBuffer(); + AZStd::span indexBuffer = sourceMesh.GetIndexBufferAssetView().GetBufferAsset()->GetBuffer(); const AZ::RHI::BufferViewDescriptor& indexBufferViewDescriptor = sourceMesh.GetIndexBufferAssetView().GetBufferAsset()->GetBufferViewDescriptor(); AZ_ErrorOnce("EMotionFX", indexBufferViewDescriptor.m_elementSize == 4, "Index buffer must stored as 4 bytes."); const size_t indexBufferCountsInBytes = indexBufferViewDescriptor.m_elementCount * indexBufferViewDescriptor.m_elementSize; diff --git a/Gems/LyShine/Code/Source/LyShinePass.h b/Gems/LyShine/Code/Source/LyShinePass.h index 6275353641..c93f6db0a6 100644 --- a/Gems/LyShine/Code/Source/LyShinePass.h +++ b/Gems/LyShine/Code/Source/LyShinePass.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include "LyShinePassDataBus.h" diff --git a/Gems/Terrain/Code/Source/TerrainRenderer/BindlessImageArrayHandler.cpp b/Gems/Terrain/Code/Source/TerrainRenderer/BindlessImageArrayHandler.cpp index 595877c88b..81095eb800 100644 --- a/Gems/Terrain/Code/Source/TerrainRenderer/BindlessImageArrayHandler.cpp +++ b/Gems/Terrain/Code/Source/TerrainRenderer/BindlessImageArrayHandler.cpp @@ -94,7 +94,7 @@ namespace AZ::Render return false; } - AZStd::array_view imageViews(m_bindlessImageViews.data(), m_bindlessImageViews.size()); + AZStd::span imageViews(m_bindlessImageViews.data(), m_bindlessImageViews.size()); return srg->SetImageViewUnboundedArray(m_texturesIndex, imageViews); }