Merge branch 'development' of https://github.com/o3de/o3de into cgalvan/DraftStreamingImageAssetPixelAPI

This commit is contained in:
Chris Galvan
2022-01-26 16:46:58 -06:00
170 changed files with 833 additions and 1274 deletions
@@ -13,7 +13,6 @@ set(FILES
Instance/InstanceData.h Instance/InstanceData.h
Instance/InstanceData.cpp Instance/InstanceData.cpp
Instance/InstanceDatabase.h Instance/InstanceDatabase.h
std/containers/array_view.h
std/containers/fixed_vector_set.h std/containers/fixed_vector_set.h
std/containers/lru_cache.h std/containers/lru_cache.h
std/containers/vector_set.h std/containers/vector_set.h
@@ -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 <AzCore/std/containers/vector.h>
#include <AzCore/std/containers/fixed_vector.h>
#include <AzCore/std/containers/array.h>
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<int> a) {...}" you can call...
* - Func({1,2,3});
* - AZStd::array<int,3> a = {1,2,3};
* Func(a);
* - AZStd::vector<int> v = {1,2,3};
* Func(v);
* - AZStd::fixed_vector<int,10> 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 Element>
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<iterator>;
using const_reverse_iterator = AZStd::reverse_iterator<const_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<AZStd::size_t N>
array_view(const AZStd::array<value_type, N>& data)
: m_begin(data.data())
, m_end(m_begin + data.size())
{ }
array_view(const AZStd::vector<value_type>& data)
: m_begin(data.data())
, m_end(m_begin + data.size())
{ }
template<AZStd::size_t N>
array_view(const AZStd::fixed_vector<value_type, N>& 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
-300
View File
@@ -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 <AtomCore/std/containers/array_view.h>
#include <AzCore/std/containers/array.h>
#include <AzCore/UnitTest/TestTypes.h>
namespace UnitTest
{
using namespace AZStd;
class ArrayView : public AllocatorsTestFixture
{
protected:
template<typename T>
void ExpectEqual(initializer_list<T> expectedValues, array_view<T> arrayView)
{
EXPECT_EQ(false, arrayView.empty());
EXPECT_EQ(expectedValues.size(), arrayView.size());
typename AZStd::vector<T>::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<bool> 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<int> 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<int> 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<int, 4> originalValues = { 9,10,11,12 };
array_view<int> 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<int> originalValues = { 13,14,15,16,17,18 };
array_view<int> 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<int, 10> 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<int> 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<int, 2> originalValues = { 27,28 };
array_view<int> view1(originalValues);
array_view<int> 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<int> view1(originalValues, AZ_ARRAY_SIZE(originalValues));
array_view<int> 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<int, 4> originalValues = { 32,33,34,35 };
array_view<int> view1(originalValues);
array_view<int> 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<int> view1(originalValues, AZ_ARRAY_SIZE(originalValues));
array_view<int> 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<int, 4> originalValues = { 1,2,3,4 };
array_view<int> 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<int, 4> originalValues = { 1,2,3,4 };
array_view<int> 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<int>({ 1,2,3 }, vector<int>({ 1,2,3 }));
ExpectEqual<int>({ 1,2,3 }, fixed_vector<int, 3>({ 1,2,3 }));
ExpectEqual<int>({ 1,2,3 }, array<int, 3>({ 1,2,3 }));
}
void CheckComparisonOperators(bool areEqual, array_view<int> a, array_view<int> 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<int> arrayA_view(arrayA, 3);
array_view<int> arrayB_view(arrayB, 3);
array_view<int> arrayA_otherView(arrayA, 3);
// view of a sub-array aligned to the beginning of the array
array_view<int> arrayA_headView(arrayA, 2);
array_view<int> arrayB_headView(arrayB, 2);
// view of a sub-array aligned to the end of the array
array_view<int> arrayA_tailView(&arrayA[1], 2);
array_view<int> arrayB_tailView(&arrayB[1], 2);
// view of a sub-array in the middle of the array
array_view<int> arrayA_centerView(&arrayA[1], 1);
array_view<int> 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<int> view({ 1,2,3,4 });
AZ_TEST_START_TRACE_SUPPRESSION;
view[4];
view[5];
AZ_TEST_STOP_TRACE_SUPPRESSION(2);
}
}
@@ -7,7 +7,6 @@
# #
set(FILES set(FILES
ArrayView.cpp
ConcurrencyCheckerTests.cpp ConcurrencyCheckerTests.cpp
InstanceDatabase.cpp InstanceDatabase.cpp
lru_cache.cpp lru_cache.cpp
@@ -42,12 +42,11 @@ namespace AZStd::Internal
namespace AZStd namespace AZStd
{ {
/** /**
* First pass partial implementation of span copied over from array_view. It * Full C++20 implementation of span done using the C++ draft at https://eel.is/c++draft/views.
* returns non-const iterator/pointers. first(), last(), and subspan() * It does not maintain storage for the data,
* are yet to be implemented. It does not maintain storage for the data, * but just hold a pointer to mark the beginning and the size for the elements.
* but just holds pointers to mark the beginning and end of the array. * It can be constructed any type that models the C++ contiguous_range concept
* It can be conveniently constructed from a variety of other container * such like array, vector, fixed_vector, raw-array, string_view, string, etc... .
* types like array, vector, and fixed_vector.
* *
* Example: * Example:
* Given "void Func(AZStd::span<int> a) {...}" you can call... * Given "void Func(AZStd::span<int> a) {...}" you can call...
@@ -84,7 +83,7 @@ namespace AZStd
inline static constexpr size_t extent = Extent; inline static constexpr size_t extent = Extent;
constexpr span() noexcept = default;; constexpr span() noexcept = default;
~span() = default; ~span() = default;
@@ -110,12 +109,12 @@ namespace AZStd
Extent != dynamic_extent, int> = 0> Extent != dynamic_extent, int> = 0>
constexpr explicit span(It first, End last); constexpr explicit span(It first, End last);
template<size_t N, class = enable_if_t<N == dynamic_extent || N == Extent>> template<size_t N, class = enable_if_t<extent == dynamic_extent || N == Extent>>
constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept; constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
template <class U, size_t N, class = enable_if_t<N == dynamic_extent || N == Extent>> template <class U, size_t N, class = enable_if_t<extent == dynamic_extent || N == Extent>>
constexpr span(array<U, N>& data) noexcept; constexpr span(array<U, N>& data) noexcept;
template <class U, size_t N, class = enable_if_t<N == dynamic_extent || N == Extent>> template <class U, size_t N, class = enable_if_t<extent == dynamic_extent || N == Extent>>
constexpr span(const array<U, N>& data) noexcept; constexpr span(const array<U, N>& data) noexcept;
template <class R, class = enable_if_t<ranges::contiguous_range<R> && template <class R, class = enable_if_t<ranges::contiguous_range<R> &&
@@ -246,4 +246,16 @@ namespace UnitTest
AZ_TEST_STOP_TRACE_SUPPRESSION(1); AZ_TEST_STOP_TRACE_SUPPRESSION(1);
} }
} }
TEST_F(SpanTestFixture, CanInitializeFixedArrayToDynamicExtentSpan)
{
constexpr size_t arrayElementCount = 5;
static constexpr AZStd::array<int, arrayElementCount> intArray{ 4, 5, 6, 1, 7 };
constexpr AZStd::span<const int, AZStd::dynamic_extent> arraySpan(intArray);
static_assert(intArray.data() == arraySpan.data());
constexpr AZStd::span<const int, arrayElementCount> arraySpanFixedExtent(intArray);
static_assert(intArray.data() == arraySpanFixedExtent.data());
}
} }
@@ -286,7 +286,7 @@ namespace ImageProcessingAtom
for (u32 slice = 0; slice < arraySize; slice++) for (u32 slice = 0; slice < arraySize; slice++)
{ {
AZStd::array_view<uint8_t> imageData = imageAsset->GetSubImageData(mip, slice); AZStd::span<const uint8_t> imageData = imageAsset->GetSubImageData(mip, slice);
memcpy(imageBuf + slice * imageData.size(), imageData.data(), imageData.size()); memcpy(imageBuf + slice * imageData.size(), imageData.data(), imageData.size());
} }
} }
@@ -71,7 +71,7 @@ namespace UnitTest
//! Helper function. //! Helper function.
//! Given an input list of {Key, Value} pairs returns a list of strings where each string is of the form: "Key=Value". //! Given an input list of {Key, Value} pairs returns a list of strings where each string is of the form: "Key=Value".
AZStd::vector<AZStd::string> CreateListOfStringsFromListOfKeyValues(AZStd::array_view<KeyValueView> listOfKeyValues) const AZStd::vector<AZStd::string> CreateListOfStringsFromListOfKeyValues(AZStd::span<const KeyValueView> listOfKeyValues) const
{ {
AZStd::vector<AZStd::string> listOfStrings; AZStd::vector<AZStd::string> listOfStrings;
for (const auto& keyValue : listOfKeyValues) for (const auto& keyValue : listOfKeyValues)
@@ -90,7 +90,7 @@ namespace UnitTest
//! Helper function. //! 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". //! 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<AZStd::string> CreateListOfSingleStringsFromListOfKeyValues(AZStd::array_view<KeyValueView> listOfKeyValues) const AZStd::vector<AZStd::string> CreateListOfSingleStringsFromListOfKeyValues(AZStd::span<const KeyValueView> listOfKeyValues) const
{ {
AZStd::vector<AZStd::string> listOfStrings; AZStd::vector<AZStd::string> listOfStrings;
for (const auto& keyValue : listOfKeyValues) 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 '='). //! Returns a command line string that results of concatenating the input list of {Key, Value} pairs (with '=').
//! Example of a returned string: //! Example of a returned string:
//! "key1=value1 key2 key3 key4=value" //! "key1=value1 key2 key3 key4=value"
AZStd::string CreateCmdLineStringFromListOfKeyValues(AZStd::array_view<KeyValueView> listOfKeyValues) const AZStd::string CreateCmdLineStringFromListOfKeyValues(AZStd::span<const KeyValueView> listOfKeyValues) const
{ {
AZStd::string cmdLineString; AZStd::string cmdLineString;
for (const auto& keyValueView : listOfKeyValues) 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. //! Returns a command line string of macro definitions that results of concatenating the input list of {Key, Value} pairs.
//! Example of a returned string: //! Example of a returned string:
//! "-Dkey1=value1 -Dkey2 -Dkey3 -Dkey4=value" //! "-Dkey1=value1 -Dkey2 -Dkey3 -Dkey4=value"
AZStd::string CreateMacroDefinitionCmdLineStringFromListOfKeyValues(AZStd::array_view<KeyValueView> listOfKeyValues) const AZStd::string CreateMacroDefinitionCmdLineStringFromListOfKeyValues(AZStd::span<const KeyValueView> listOfKeyValues) const
{ {
AZStd::string cmdLineString; AZStd::string cmdLineString;
for (const auto& keyValueView : listOfKeyValues) for (const auto& keyValueView : listOfKeyValues)
@@ -161,7 +161,7 @@ namespace UnitTest
//! @param includePaths A List of folder paths //! @param includePaths A List of folder paths
//! @param predefinedMacros A List of strings with format: "name[=value]" //! @param predefinedMacros A List of strings with format: "name[=value]"
ShaderBuilder::PreprocessorOptions CreatePreprocessorOptions( ShaderBuilder::PreprocessorOptions CreatePreprocessorOptions(
AZStd::array_view<AZStd::string> includePaths, AZStd::array_view<AZStd::string> predefinedMacros) const AZStd::span<const AZStd::string> includePaths, AZStd::span<const AZStd::string> predefinedMacros) const
{ {
ShaderBuilder::PreprocessorOptions preprocessorOptions; ShaderBuilder::PreprocessorOptions preprocessorOptions;
@@ -200,8 +200,8 @@ namespace UnitTest
//! @param azslcAdditionalFreeArguments A string representing series of command line arguments for AZSLc. //! @param azslcAdditionalFreeArguments A string representing series of command line arguments for AZSLc.
//! @param dxcAdditionalFreeArguments: A string representing series of command line arguments for DXC. //! @param dxcAdditionalFreeArguments: A string representing series of command line arguments for DXC.
ShaderBuilder::GlobalBuildOptions CreateGlobalBuildOptions( ShaderBuilder::GlobalBuildOptions CreateGlobalBuildOptions(
AZStd::array_view<AZStd::string> includePaths, AZStd::span<const AZStd::string> includePaths,
AZStd::array_view<AZStd::string> predefinedMacros, AZStd::span<const AZStd::string> predefinedMacros,
AZStd::string_view azslcAdditionalFreeArguments, AZStd::string_view azslcAdditionalFreeArguments,
AZStd::string_view dxcAdditionalFreeArguments) const AZStd::string_view dxcAdditionalFreeArguments) const
{ {
@@ -227,7 +227,7 @@ namespace UnitTest
return supervariantInfo; return supervariantInfo;
} }
bool StringContainsAllSubstrings(AZStd::string_view haystack, AZStd::array_view<AZStd::string> substrings) bool StringContainsAllSubstrings(AZStd::string_view haystack, AZStd::span<const AZStd::string> substrings)
{ {
return AZStd::all_of(AZ_BEGIN_END(substrings), return AZStd::all_of(AZ_BEGIN_END(substrings),
[&](AZStd::string_view needle) -> bool [&](AZStd::string_view needle) -> bool
@@ -237,7 +237,7 @@ namespace UnitTest
); );
} }
bool StringDoesNotContainAnyOneOfTheSubstrings(AZStd::string_view haystack, AZStd::array_view<AZStd::string> substrings) bool StringDoesNotContainAnyOneOfTheSubstrings(AZStd::string_view haystack, AZStd::span<const AZStd::string> substrings)
{ {
return AZStd::all_of(AZ_BEGIN_END(substrings), [&](AZStd::string_view needle) -> bool { return AZStd::all_of(AZ_BEGIN_END(substrings), [&](AZStd::string_view needle) -> bool {
return (haystack.find(needle) == AZStd::string::npos); return (haystack.find(needle) == AZStd::string::npos);
@@ -247,7 +247,7 @@ namespace UnitTest
//! @returns: True if all strings in @substring appear in @vectorOfString. //! @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. //! @remark: Keep in mind that this is not the same as saying that all strings in @vectorOfStrings appear in @substrings.
bool VectorContainsAllSubstrings( bool VectorContainsAllSubstrings(
AZStd::array_view<AZStd::string> vectorOfStrings, AZStd::array_view<AZStd::string> substrings) AZStd::span<const AZStd::string> vectorOfStrings, AZStd::span<const AZStd::string> substrings)
{ {
return AZStd::all_of( return AZStd::all_of(
AZ_BEGIN_END(substrings), 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. //! @returns: True only if None of the strings in @vectorOfStrings contains any of the strings in @substrings.
bool VectorDoesNotContainAnyOneOfTheSubstrings(AZStd::array_view<AZStd::string> vectorOfStrings, AZStd::array_view<AZStd::string> substrings) bool VectorDoesNotContainAnyOneOfTheSubstrings(AZStd::span<const AZStd::string> vectorOfStrings, AZStd::span<const AZStd::string> substrings)
{ {
return AZStd::all_of(AZ_BEGIN_END(vectorOfStrings), [&](AZStd::string_view haystack) -> bool { return AZStd::all_of(AZ_BEGIN_END(vectorOfStrings), [&](AZStd::string_view haystack) -> bool {
return StringDoesNotContainAnyOneOfTheSubstrings(haystack, substrings); return StringDoesNotContainAnyOneOfTheSubstrings(haystack, substrings);
@@ -27,13 +27,13 @@ namespace AZ
class BufferView; class BufferView;
class IndexBufferView; class IndexBufferView;
} }
namespace RPI namespace RPI
{ {
class Model; class Model;
class ShaderResourceGroup; class ShaderResourceGroup;
} }
namespace Render 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. //! 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 //! Get an individual lod
const SkinnedMeshInputLod& GetLod(size_t lodIndex) const; const SkinnedMeshInputLod& GetLod(size_t lodIndex) const;
//! Get an array_view of the buffer views for all the input streams //! Get a span of the buffer views for all the input streams
AZStd::array_view<AZ::RHI::Ptr<RHI::BufferView>> GetInputBufferViews(size_t lodIndex) const; AZStd::span<const AZ::RHI::Ptr<RHI::BufferView>> GetInputBufferViews(size_t lodIndex) const;
//! Get the buffer view for a specific input stream //! Get the buffer view for a specific input stream
AZ::RHI::Ptr<const RHI::BufferView> GetInputBufferView(size_t lodIndex, uint8_t inputStream) const; AZ::RHI::Ptr<const RHI::BufferView> GetInputBufferView(size_t lodIndex, uint8_t inputStream) const;
@@ -8,7 +8,7 @@
#pragma once #pragma once
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
namespace AZ::Render namespace AZ::Render
@@ -9,7 +9,7 @@
#pragma once #pragma once
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
namespace AZ namespace AZ
{ {
@@ -71,7 +71,7 @@ namespace AZ
} }
} }
const AZStd::array_view<RPI::PipelineViewTag> CascadedShadowmapsPass::GetPipelineViewTags() const AZStd::span<const RPI::PipelineViewTag> CascadedShadowmapsPass::GetPipelineViewTags()
{ {
if (m_childrenPipelineViewTags.size() != Shadow::MaxNumberOfCascades) if (m_childrenPipelineViewTags.size() != Shadow::MaxNumberOfCascades)
{ {
@@ -181,7 +181,7 @@ namespace AZ
RPI::Ptr<ShadowmapPass> CascadedShadowmapsPass::CreateChild(uint16_t cascadeIndex) RPI::Ptr<ShadowmapPass> CascadedShadowmapsPass::CreateChild(uint16_t cascadeIndex)
{ {
const AZStd::array_view<RPI::PipelineViewTag> childrenViewTags = GetPipelineViewTags(); const AZStd::span<const RPI::PipelineViewTag> childrenViewTags = GetPipelineViewTags();
const Name passName{ AZStd::string::format("DirectionalLightShadowmapPass.%d", cascadeIndex) }; const Name passName{ AZStd::string::format("DirectionalLightShadowmapPass.%d", cascadeIndex) };
auto passData = AZStd::make_shared<RPI::RasterPassData>(); auto passData = AZStd::make_shared<RPI::RasterPassData>();
@@ -9,7 +9,7 @@
#include <Atom/Feature/CoreLights/CoreLightsConstants.h> #include <Atom/Feature/CoreLights/CoreLightsConstants.h>
#include <Atom/RPI.Public/Pass/ParentPass.h> #include <Atom/RPI.Public/Pass/ParentPass.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/containers/fixed_vector.h> #include <AzCore/std/containers/fixed_vector.h>
#include <CoreLights/ShadowmapAtlas.h> #include <CoreLights/ShadowmapAtlas.h>
#include <CoreLights/ShadowmapPass.h> #include <CoreLights/ShadowmapPass.h>
@@ -36,7 +36,7 @@ namespace AZ
void SetCameraViewName(const AZStd::string& viewName); void SetCameraViewName(const AZStd::string& viewName);
//! This returns pipeline view tag for children. //! This returns pipeline view tag for children.
const AZStd::array_view<RPI::PipelineViewTag> GetPipelineViewTags(); const AZStd::span<const RPI::PipelineViewTag> GetPipelineViewTags();
//! This exposes the shadowmap atlas. //! This exposes the shadowmap atlas.
ShadowmapAtlas& GetShadowmapAtlas(); ShadowmapAtlas& GetShadowmapAtlas();
@@ -1018,7 +1018,7 @@ namespace AZ
for (const auto& passIt : m_cascadedShadowmapsPasses) for (const auto& passIt : m_cascadedShadowmapsPasses)
{ {
CascadedShadowmapsPass* shadowPass = passIt.second.front(); CascadedShadowmapsPass* shadowPass = passIt.second.front();
const AZStd::array_view<RPI::PipelineViewTag>& viewTags = shadowPass->GetPipelineViewTags(); const AZStd::span<const RPI::PipelineViewTag>& viewTags = shadowPass->GetPipelineViewTags();
AZ_Assert(viewTags.size() >= cascadeCount, "DirectionalLightFeatureProcessor: There is not enough pipeline view tags."); AZ_Assert(viewTags.size() >= cascadeCount, "DirectionalLightFeatureProcessor: There is not enough pipeline view tags.");
RPI::RenderPipeline* pipeline = shadowPass->GetRenderPipeline(); RPI::RenderPipeline* pipeline = shadowPass->GetRenderPipeline();
@@ -112,7 +112,7 @@ namespace AZ
m_shadowmapImageSize = inputBinding.m_attachment->m_descriptor.m_image.m_size; m_shadowmapImageSize = inputBinding.m_attachment->m_descriptor.m_image.m_size;
m_shadowmapArraySize = inputBinding.m_attachment->m_descriptor.m_image.m_arraySize; m_shadowmapArraySize = inputBinding.m_attachment->m_descriptor.m_image.m_arraySize;
const AZStd::array_view<RPI::Ptr<RPI::Pass>>& children = GetChildren(); const AZStd::span<const RPI::Ptr<RPI::Pass>>& children = GetChildren();
AZ_Assert(children.size() == EsmChildPassKindCount, "[EsmShadowmapsPass '%s'] The count of children is wrong.", GetPathName().GetCStr()); AZ_Assert(children.size() == EsmChildPassKindCount, "[EsmShadowmapsPass '%s'] The count of children is wrong.", GetPathName().GetCStr());
for (uint32_t childPassIndex = 0; childPassIndex < EsmChildPassKindCount; ++childPassIndex) for (uint32_t childPassIndex = 0; childPassIndex < EsmChildPassKindCount; ++childPassIndex)
@@ -15,7 +15,7 @@
#include <Atom/RPI.Public/Buffer/Buffer.h> #include <Atom/RPI.Public/Buffer/Buffer.h>
#include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h> #include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
#include <AtomCore/Instance/Instance.h> #include <AtomCore/Instance/Instance.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/containers/array.h> #include <AzCore/std/containers/array.h>
#include <AzCore/Preprocessor/Enum.h> #include <AzCore/Preprocessor/Enum.h>
@@ -9,7 +9,7 @@
#include <Atom/Feature/CoreLights/CoreLightsConstants.h> #include <Atom/Feature/CoreLights/CoreLightsConstants.h>
#include <Atom/RPI.Public/Pass/ParentPass.h> #include <Atom/RPI.Public/Pass/ParentPass.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
#include <CoreLights/ShadowmapAtlas.h> #include <CoreLights/ShadowmapAtlas.h>
#include <CoreLights/ShadowmapPass.h> #include <CoreLights/ShadowmapPass.h>
@@ -16,7 +16,7 @@
#include <Atom/RPI.Public/Scene.h> #include <Atom/RPI.Public/Scene.h>
#include <Atom/RPI.Public/View.h> #include <Atom/RPI.Public/View.h>
#include <AzCore/Math/Quaternion.h> #include <AzCore/Math/Quaternion.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <Atom/RPI.Reflect/Asset/AssetUtils.h> #include <Atom/RPI.Reflect/Asset/AssetUtils.h>
namespace AZ namespace AZ
@@ -114,14 +114,14 @@ namespace AZ
} }
} }
AZStd::array_view<Data::Instance<RPI::Image>> DecalFeatureProcessor::GetImageArray() const AZStd::span<const Data::Instance<RPI::Image>> DecalFeatureProcessor::GetImageArray() const
{ {
// [GFX TODO][ATOM-4445] Replace this hardcoded constant with atlasing / bindless so we can have far more than 8 decal textures // [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 // Note this constant also is defined in View.srg
const size_t MaxDecals = 8; const size_t MaxDecals = 8;
size_t numImages = AZStd::min(MaxDecals, m_decalData.GetDataCount()); size_t numImages = AZStd::min(MaxDecals, m_decalData.GetDataCount());
AZStd::array_view<ImagePtr> imageArrayView(m_decalData.GetDataVector<1>().begin(), m_decalData.GetDataVector<1>().begin() + numImages); AZStd::span<const ImagePtr> imageArrayView(m_decalData.GetDataVector<1>().begin(), m_decalData.GetDataVector<1>().begin() + numImages);
return imageArrayView; return imageArrayView;
} }
@@ -130,8 +130,8 @@ namespace AZ
{ {
AZ_PROFILE_SCOPE(RPI, "DecalFeatureProcessor: Render"); AZ_PROFILE_SCOPE(RPI, "DecalFeatureProcessor: Render");
AZStd::array_view<Data::Instance<RPI::Image>> baseMaps = GetImagesFromDecalData<1>(); AZStd::span<const Data::Instance<RPI::Image>> baseMaps = GetImagesFromDecalData<1>();
AZStd::array_view<Data::Instance<RPI::Image>> opacityMaps = GetImagesFromDecalData<2>(); AZStd::span<const Data::Instance<RPI::Image>> opacityMaps = GetImagesFromDecalData<2>();
for (const RPI::ViewPtr& view : packet.m_views) for (const RPI::ViewPtr& view : packet.m_views)
{ {
@@ -81,11 +81,11 @@ namespace AZ
DecalFeatureProcessor(const DecalFeatureProcessor&) = delete; DecalFeatureProcessor(const DecalFeatureProcessor&) = delete;
Data::Instance<RPI::Image> GetImageFromMaterial(const AZ::Name& mapName, Data::Instance<RPI::Material> materialInstance) const; Data::Instance<RPI::Image> GetImageFromMaterial(const AZ::Name& mapName, Data::Instance<RPI::Material> materialInstance) const;
AZStd::array_view<Data::Instance<RPI::Image>> GetImageArray() const; AZStd::span<const Data::Instance<RPI::Image>> GetImageArray() const;
void CacheShaderIndices(); void CacheShaderIndices();
template<size_t ArrayIndex> template<size_t ArrayIndex>
AZStd::array_view<Data::Instance<RPI::Image>> GetImagesFromDecalData(); AZStd::span<const Data::Instance<RPI::Image>> GetImagesFromDecalData();
static constexpr const char* FeatureProcessorName = "DecalFeatureProcessor"; static constexpr const char* FeatureProcessorName = "DecalFeatureProcessor";
@@ -105,7 +105,7 @@ namespace AZ
}; };
template<size_t ArrayIndex> template<size_t ArrayIndex>
AZStd::array_view<Data::Instance<RPI::Image>> AZStd::span<const Data::Instance<RPI::Image>>
AZ::Render::DecalFeatureProcessor::GetImagesFromDecalData() 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 // [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; const size_t MaxDecals = 4;
size_t numImages = AZStd::min(MaxDecals, m_decalData.GetDataCount()); size_t numImages = AZStd::min(MaxDecals, m_decalData.GetDataCount());
AZStd::array_view<ImagePtr> imageArrayView(m_decalData.GetDataVector<ArrayIndex>().begin(), m_decalData.GetDataVector<ArrayIndex>().begin() + numImages); AZStd::span<const ImagePtr> imageArrayView(m_decalData.GetDataVector<ArrayIndex>().begin(), m_decalData.GetDataVector<ArrayIndex>().begin() + numImages);
return imageArrayView; return imageArrayView;
} }
} // namespace Render } // namespace Render
@@ -267,7 +267,7 @@ namespace AZ
return AZ::RHI::GetImageSubresourceLayout(mipSize, descriptor.m_format); return AZ::RHI::GetImageSubresourceLayout(mipSize, descriptor.m_format);
} }
AZStd::array_view<uint8_t> DecalTextureArray::GetRawImageData(const AZ::Name& mapName, int arrayLevel, const int mip) const AZStd::span<const uint8_t> 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. // 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. // If this spot in the array is empty, just provide some random image as filler.
@@ -13,7 +13,7 @@
#include <AzCore/Asset/AssetCommon.h> #include <AzCore/Asset/AssetCommon.h>
#include <Atom/RHI.Reflect/ImageDescriptor.h> #include <Atom/RHI.Reflect/ImageDescriptor.h>
#include <Atom/RHI.Reflect/ImageSubresource.h> #include <Atom/RHI.Reflect/ImageSubresource.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <Atom/RPI.Public/Image/StreamingImage.h> #include <Atom/RPI.Public/Image/StreamingImage.h>
@@ -81,7 +81,7 @@ namespace AZ
RHI::Size GetImageDimensions(const DecalMapType mapType) const; RHI::Size GetImageDimensions(const DecalMapType mapType) const;
RHI::Format GetFormat(const DecalMapType mapType) const; RHI::Format GetFormat(const DecalMapType mapType) const;
RHI::ImageSubresourceLayout GetLayout(const DecalMapType mapType, int mip) const; RHI::ImageSubresourceLayout GetLayout(const DecalMapType mapType, int mip) const;
AZStd::array_view<uint8_t> GetRawImageData(const AZ::Name& mapName, int arrayLevel, int mip) const; AZStd::span<const uint8_t> GetRawImageData(const AZ::Name& mapName, int arrayLevel, int mip) const;
bool AreAllAssetsReady() const; bool AreAllAssetsReady() const;
bool IsAssetReady(const MaterialData& materialData) const; bool IsAssetReady(const MaterialData& materialData) const;
@@ -13,7 +13,7 @@
#include <Atom/RPI.Public/Scene.h> #include <Atom/RPI.Public/Scene.h>
#include <Atom/RPI.Public/View.h> #include <Atom/RPI.Public/View.h>
#include <AzCore/Math/Quaternion.h> #include <AzCore/Math/Quaternion.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <Atom/RPI.Public/Image/ImageSystemInterface.h> #include <Atom/RPI.Public/Image/ImageSystemInterface.h>
#include <Atom/RPI.Reflect/Image/StreamingImageAssetHandler.h> #include <Atom/RPI.Reflect/Image/StreamingImageAssetHandler.h>
#include <AtomCore/Instance/InstanceDatabase.h> #include <AtomCore/Instance/InstanceDatabase.h>
@@ -772,7 +772,7 @@ namespace AZ
return; return;
} }
const AZStd::array_view<Data::Instance<RPI::ModelLod>>& modelLods = m_model->GetLods(); const AZStd::span<const Data::Instance<RPI::ModelLod>>& modelLods = m_model->GetLods();
if (modelLods.empty()) if (modelLods.empty())
{ {
return; return;
@@ -225,12 +225,12 @@ namespace AZ
return m_boneTransforms; return m_boneTransforms;
} }
AZStd::array_view<AZ::RHI::Ptr<RHI::BufferView>> SkinnedMeshDispatchItem::GetSourceUnskinnedBufferViews() const AZStd::span<const AZ::RHI::Ptr<RHI::BufferView>> SkinnedMeshDispatchItem::GetSourceUnskinnedBufferViews() const
{ {
return m_inputBuffers->GetInputBufferViews(m_lodIndex); return m_inputBuffers->GetInputBufferViews(m_lodIndex);
} }
AZStd::array_view<AZ::RHI::Ptr<RHI::BufferView>> SkinnedMeshDispatchItem::GetTargetSkinnedBufferViews() const AZStd::span<const AZ::RHI::Ptr<RHI::BufferView>> SkinnedMeshDispatchItem::GetTargetSkinnedBufferViews() const
{ {
return m_actorInstanceBufferViews; return m_actorInstanceBufferViews;
} }
@@ -65,8 +65,8 @@ namespace AZ
const RHI::DispatchItem& GetRHIDispatchItem() const; const RHI::DispatchItem& GetRHIDispatchItem() const;
Data::Instance<RPI::Buffer> GetBoneTransforms() const; Data::Instance<RPI::Buffer> GetBoneTransforms() const;
AZStd::array_view<RHI::Ptr<RHI::BufferView>> GetSourceUnskinnedBufferViews() const; AZStd::span<const RHI::Ptr<RHI::BufferView>> GetSourceUnskinnedBufferViews() const;
AZStd::array_view<RHI::Ptr<RHI::BufferView>> GetTargetSkinnedBufferViews() const; AZStd::span<const RHI::Ptr<RHI::BufferView>> GetTargetSkinnedBufferViews() const;
size_t GetVertexCount() const; size_t GetVertexCount() const;
private: private:
// SkinnedMeshShaderOptionNotificationBus::Handler // SkinnedMeshShaderOptionNotificationBus::Handler
@@ -212,7 +212,7 @@ namespace AZ
void SkinnedMeshInputLod::CreateSharedSubMeshBufferViews() void SkinnedMeshInputLod::CreateSharedSubMeshBufferViews()
{ {
AZStd::array_view<RPI::ModelLodAsset::Mesh> meshes = m_modelLodAsset->GetMeshes(); AZStd::span<const RPI::ModelLodAsset::Mesh> meshes = m_modelLodAsset->GetMeshes();
m_sharedSubMeshViews.resize(meshes.size()); 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 // 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]; return m_lods[lodIndex];
} }
AZStd::array_view<AZ::RHI::Ptr<RHI::BufferView>> SkinnedMeshInputBuffers::GetInputBufferViews(size_t lodIndex) const AZStd::span<const AZ::RHI::Ptr<RHI::BufferView>> SkinnedMeshInputBuffers::GetInputBufferViews(size_t lodIndex) const
{ {
return m_lods[lodIndex].m_bufferViews; return m_lods[lodIndex].m_bufferViews;
} }
@@ -145,7 +145,7 @@ namespace AZ
} }
} }
AZStd::array_view<AZStd::unique_ptr<SkinnedMeshDispatchItem>> SkinnedMeshRenderProxy::GetDispatchItems() const AZStd::span<const AZStd::unique_ptr<SkinnedMeshDispatchItem>> SkinnedMeshRenderProxy::GetDispatchItems() const
{ {
return m_dispatchItemsByLod; return m_dispatchItemsByLod;
} }
@@ -45,7 +45,7 @@ namespace AZ
void SetSkinningMatrices(const AZStd::vector<float>& data) override; void SetSkinningMatrices(const AZStd::vector<float>& data) override;
void SetMorphTargetWeights(uint32_t lodIndex, const AZStd::vector<float>& weights) override; void SetMorphTargetWeights(uint32_t lodIndex, const AZStd::vector<float>& weights) override;
AZStd::array_view< AZStd::unique_ptr<SkinnedMeshDispatchItem>> GetDispatchItems() const; AZStd::span<const AZStd::unique_ptr<SkinnedMeshDispatchItem>> GetDispatchItems() const;
private: private:
AZ_DISABLE_COPY_MOVE(SkinnedMeshRenderProxy); AZ_DISABLE_COPY_MOVE(SkinnedMeshRenderProxy);
@@ -78,7 +78,7 @@ namespace AZ
} }
} }
void SkinnedMeshStatsCollector::AddReadOnlyBufferViewsToSceneStats(const AZStd::array_view<AZ::RHI::Ptr<RHI::BufferView>>& sourceUnskinnedBufferViews) void SkinnedMeshStatsCollector::AddReadOnlyBufferViewsToSceneStats(const AZStd::span<const AZ::RHI::Ptr<RHI::BufferView>>& sourceUnskinnedBufferViews)
{ {
for (const AZ::RHI::Ptr<RHI::BufferView>& bufferView : sourceUnskinnedBufferViews) for (const AZ::RHI::Ptr<RHI::BufferView>& bufferView : sourceUnskinnedBufferViews)
{ {
@@ -94,7 +94,7 @@ namespace AZ
} }
} }
void SkinnedMeshStatsCollector::AddWritableBufferViewsToSceneStats(const AZStd::array_view<AZ::RHI::Ptr<RHI::BufferView>>& targetSkinnedBufferViews) void SkinnedMeshStatsCollector::AddWritableBufferViewsToSceneStats(const AZStd::span<const AZ::RHI::Ptr<RHI::BufferView>>& targetSkinnedBufferViews)
{ {
for (const AZ::RHI::Ptr<RHI::BufferView>& bufferView : targetSkinnedBufferViews) for (const AZ::RHI::Ptr<RHI::BufferView>& bufferView : targetSkinnedBufferViews)
{ {
@@ -33,8 +33,8 @@ namespace AZ
void ResetAllStats(); void ResetAllStats();
void AddDispatchItemToSceneStats(const AZStd::unique_ptr<SkinnedMeshDispatchItem>& dispatchItem); void AddDispatchItemToSceneStats(const AZStd::unique_ptr<SkinnedMeshDispatchItem>& dispatchItem);
void AddBonesToSceneStats(const Data::Instance<RPI::Buffer>& boneTransformBuffer); void AddBonesToSceneStats(const Data::Instance<RPI::Buffer>& boneTransformBuffer);
void AddReadOnlyBufferViewsToSceneStats(const AZStd::array_view<AZ::RHI::Ptr<RHI::BufferView>>& sourceUnskinnedBufferViews); void AddReadOnlyBufferViewsToSceneStats(const AZStd::span<const AZ::RHI::Ptr<RHI::BufferView>>& sourceUnskinnedBufferViews);
void AddWritableBufferViewsToSceneStats(const AZStd::array_view<AZ::RHI::Ptr<RHI::BufferView>>& targetSkinnedBufferViews); void AddWritableBufferViewsToSceneStats(const AZStd::span<const AZ::RHI::Ptr<RHI::BufferView>>& targetSkinnedBufferViews);
void AddVerticesToSceneStats(size_t vertexCount); void AddVerticesToSceneStats(size_t vertexCount);
SkinnedMeshSceneStats m_sceneStats; SkinnedMeshSceneStats m_sceneStats;
@@ -10,7 +10,7 @@
#include <AzCore/Serialization/SerializeContext.h> #include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Preprocessor/Enum.h> #include <AzCore/Preprocessor/Enum.h>
#include <AzCore/std/string/string.h> #include <AzCore/std/string/string.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
namespace AZ namespace AZ
{ {
@@ -129,7 +129,7 @@ namespace AZ
//! @returns A new string based on @commandLineString but with the matching arguments and their values //! @returns A new string based on @commandLineString but with the matching arguments and their values
//! removed from it. //! removed from it.
AZStd::string RemoveArgumentsFromCommandLineString( AZStd::string RemoveArgumentsFromCommandLineString(
AZStd::array_view<AZStd::string> listOfArguments, AZStd::string_view commandLineString); AZStd::span<const AZStd::string> listOfArguments, AZStd::string_view commandLineString);
//! @param commandLineString: " --arg1 -arg2 --arg3=foo --arg4=bar " //! @param commandLineString: " --arg1 -arg2 --arg3=foo --arg4=bar "
//! @returns "--arg1 -arg2 --arg3=foo --arg4=bar" //! @returns "--arg1 -arg2 --arg3=foo --arg4=bar"
@@ -9,7 +9,7 @@
#include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h> #include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
#include <Atom/RHI.Reflect/NameIdReflectionMap.h> #include <Atom/RHI.Reflect/NameIdReflectionMap.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/smart_ptr/intrusive_base.h> #include <AzCore/std/smart_ptr/intrusive_base.h>
#include <AzCore/Utils/TypeHash.h> #include <AzCore/Utils/TypeHash.h>
@@ -72,7 +72,7 @@ namespace AZ
//! Returns the full lists of shader input added to the layout. Inputs //! Returns the full lists of shader input added to the layout. Inputs
//! maintain their original order with respect to AddShaderInput. //! maintain their original order with respect to AddShaderInput.
AZStd::array_view<ShaderInputConstantDescriptor> GetShaderInputList() const; AZStd::span<const ShaderInputConstantDescriptor> GetShaderInputList() const;
//! Returns the total size in bytes used by the constants. //! Returns the total size in bytes used by the constants.
uint32_t GetDataSize() const; uint32_t GetDataSize() const;
@@ -84,7 +84,7 @@ namespace AZ
//! Prints to the console the shader input names specified by input list of indices //! Prints to the console the shader input names specified by input list of indices
//! Will ignore any indices outside of the inputs array bounds //! Will ignore any indices outside of the inputs array bounds
void DebugPrintNames(AZStd::array_view<ShaderInputConstantIndex> constantList) const; void DebugPrintNames(AZStd::span<const ShaderInputConstantIndex> constantList) const;
protected: protected:
ConstantsLayout() = default; ConstantsLayout() = default;
@@ -12,7 +12,7 @@
#include <AzCore/Memory/SystemAllocator.h> #include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/RTTI/RTTI.h> #include <AzCore/RTTI/RTTI.h>
#include <AzCore/Utils/TypeHash.h> #include <AzCore/Utils/TypeHash.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
namespace AZ namespace AZ
{ {
@@ -137,7 +137,7 @@ namespace AZ
bool AddIndirectCommand(const IndirectCommandDescriptor& command); bool AddIndirectCommand(const IndirectCommandDescriptor& command);
/// Returns the list of indirect commands of the layout. Must be called after the layout is finalized. /// Returns the list of indirect commands of the layout. Must be called after the layout is finalized.
AZStd::array_view<IndirectCommandDescriptor> GetCommands() const; AZStd::span<const IndirectCommandDescriptor> GetCommands() const;
//! Returns the position of a command. //! Returns the position of a command.
//! Must be called after the layout is finalized. //! Must be called after the layout is finalized.
@@ -10,7 +10,7 @@
#include <Atom/RHI.Reflect/Format.h> #include <Atom/RHI.Reflect/Format.h>
#include <Atom/RHI.Reflect/Limits.h> #include <Atom/RHI.Reflect/Limits.h>
#include <Atom/RHI.Reflect/ShaderSemantic.h> #include <Atom/RHI.Reflect/ShaderSemantic.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/containers/fixed_vector.h> #include <AzCore/std/containers/fixed_vector.h>
#include <AzCore/Utils/TypeHash.h> #include <AzCore/Utils/TypeHash.h>
@@ -158,10 +158,10 @@ namespace AZ
const PrimitiveTopology GetTopology() const; const PrimitiveTopology GetTopology() const;
/// Returns the list of stream channels. /// Returns the list of stream channels.
AZStd::array_view<StreamChannelDescriptor> GetStreamChannels() const; AZStd::span<const StreamChannelDescriptor> GetStreamChannels() const;
/// Returns the list of stream buffers. /// Returns the list of stream buffers.
AZStd::array_view<StreamBufferDescriptor> GetStreamBuffers() const; AZStd::span<const StreamBufferDescriptor> GetStreamBuffers() const;
/// Returns the hash computed in Finalize(), which must be called first. /// Returns the hash computed in Finalize(), which must be called first.
HashValue64 GetHash() const; HashValue64 GetHash() const;
@@ -10,7 +10,7 @@
#include <Atom/RHI.Reflect/ShaderResourceGroupLayout.h> #include <Atom/RHI.Reflect/ShaderResourceGroupLayout.h>
#include <Atom/RHI.Reflect/ConstantsLayout.h> #include <Atom/RHI.Reflect/ConstantsLayout.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/Name/Name.h> #include <AzCore/Name/Name.h>
#include <AzCore/Serialization/SerializeContext.h> #include <AzCore/Serialization/SerializeContext.h>
@@ -8,7 +8,7 @@
#pragma once #pragma once
#include <Atom/RHI.Reflect/Base.h> #include <Atom/RHI.Reflect/Base.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/Serialization/SerializeContext.h> #include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/smart_ptr/intrusive_base.h> #include <AzCore/std/smart_ptr/intrusive_base.h>
@@ -47,7 +47,7 @@ namespace AZ
static ConstPtr<PipelineLibraryData> Create(AZStd::vector<uint8_t>&& data); static ConstPtr<PipelineLibraryData> Create(AZStd::vector<uint8_t>&& data);
/// Returns the data payload which describes the platform-specific pipeline library data. /// Returns the data payload which describes the platform-specific pipeline library data.
AZStd::array_view<uint8_t> GetData() const; AZStd::span<const uint8_t> GetData() const;
private: private:
PipelineLibraryData(AZStd::vector<uint8_t>&& data); PipelineLibraryData(AZStd::vector<uint8_t>&& data);
@@ -13,7 +13,7 @@
#include <Atom/RHI.Reflect/Limits.h> #include <Atom/RHI.Reflect/Limits.h>
#include <AzCore/Utils/TypeHash.h> #include <AzCore/Utils/TypeHash.h>
#include <AzCore/std/containers/array.h> #include <AzCore/std/containers/array.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
namespace AZ namespace AZ
{ {
@@ -10,7 +10,7 @@
#include <Atom/RHI.Reflect/ConstantsLayout.h> #include <Atom/RHI.Reflect/ConstantsLayout.h>
#include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h> #include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
#include <Atom/RHI.Reflect/NameIdReflectionMap.h> #include <Atom/RHI.Reflect/NameIdReflectionMap.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/smart_ptr/intrusive_base.h> #include <AzCore/std/smart_ptr/intrusive_base.h>
#include <AzCore/Outcome/Outcome.h> #include <AzCore/Outcome/Outcome.h>
#include <AzCore/Serialization/SerializeContext.h> #include <AzCore/Serialization/SerializeContext.h>
@@ -116,7 +116,7 @@ namespace AZ
// The following methods are only permitted on a finalized layout. // The following methods are only permitted on a finalized layout.
/// Returns the full list of static samplers descriptors declared on the layout. /// Returns the full list of static samplers descriptors declared on the layout.
AZStd::array_view<ShaderInputStaticSamplerDescriptor> GetStaticSamplers() const; AZStd::span<const ShaderInputStaticSamplerDescriptor> GetStaticSamplers() const;
/** /**
* Resolves an shader input name to an index for each type of shader input. To maximize performance, * 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 * maintain their original order with respect to AddShaderInput. Each type
* of shader input has its own separate list. * of shader input has its own separate list.
*/ */
AZStd::array_view<ShaderInputBufferDescriptor> GetShaderInputListForBuffers() const; AZStd::span<const ShaderInputBufferDescriptor> GetShaderInputListForBuffers() const;
AZStd::array_view<ShaderInputImageDescriptor> GetShaderInputListForImages() const; AZStd::span<const ShaderInputImageDescriptor> GetShaderInputListForImages() const;
AZStd::array_view<ShaderInputSamplerDescriptor> GetShaderInputListForSamplers() const; AZStd::span<const ShaderInputSamplerDescriptor> GetShaderInputListForSamplers() const;
AZStd::array_view<ShaderInputConstantDescriptor> GetShaderInputListForConstants() const; AZStd::span<const ShaderInputConstantDescriptor> GetShaderInputListForConstants() const;
AZStd::array_view<ShaderInputBufferUnboundedArrayDescriptor> GetShaderInputListForBufferUnboundedArrays() const; AZStd::span<const ShaderInputBufferUnboundedArrayDescriptor> GetShaderInputListForBufferUnboundedArrays() const;
AZStd::array_view<ShaderInputImageUnboundedArrayDescriptor> GetShaderInputListForImageUnboundedArrays() const; AZStd::span<const ShaderInputImageUnboundedArrayDescriptor> GetShaderInputListForImageUnboundedArrays() const;
/** /**
* Each shader input may contain multiple shader resources. The layout computes * Each shader input may contain multiple shader resources. The layout computes
@@ -20,7 +20,7 @@ namespace AZ
struct CommandListRenderTargetsState struct CommandListRenderTargetsState
{ {
using StateList = AZStd::fixed_vector<T, RHI::Limits::Pipeline::AttachmentColorCountMax>; using StateList = AZStd::fixed_vector<T, RHI::Limits::Pipeline::AttachmentColorCountMax>;
void Set(AZStd::array_view<T> newElements) void Set(AZStd::span<const T> newElements)
{ {
m_states = StateList(newElements.begin(), newElements.end()); m_states = StateList(newElements.begin(), newElements.end());
m_isDirty = true; m_isDirty = true;
@@ -20,11 +20,11 @@ namespace AZ
{ {
namespace RHI namespace RHI
{ {
//! The intent of this class is to provide fast and thin access to the underlying constant //! 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 //! 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 //! 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 //! 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 //! 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". //! convenience functions are provided in situations that are "low-hanging-fruit".
class ConstantsData class ConstantsData
{ {
@@ -53,7 +53,7 @@ namespace AZ
//! Assigns an array of type T to the constant shader input. //! Assigns an array of type T to the constant shader input.
template <typename T> template <typename T>
bool SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view<T> values); bool SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span<const T> values);
//! Assigns constant data as a whole. //! Assigns constant data as a whole.
bool SetConstantData(const void* bytes, size_t byteCount); 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. //! of elements in the returned array is the number of evenly divisible elements.
//! If the strides do not match, an empty array is returned. //! If the strides do not match, an empty array is returned.
template <typename T> template <typename T>
AZStd::array_view<T> GetConstantArray(ShaderInputConstantIndex inputIndex) const; AZStd::span<const T> GetConstantArray(ShaderInputConstantIndex inputIndex) const;
//! Returns the constant data as type 'T' returned by value. The size of the constant region //! 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. //! must match the size of T exactly. Otherwise, an empty instance is returned.
@@ -77,11 +77,11 @@ namespace AZ
template <typename T> template <typename T>
T GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const; T GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const;
//! Returns constant data for the given shader input index as an array of bytes. //! Returns constant data for the given shader input index as a span of bytes.
AZStd::array_view<uint8_t> GetConstantRaw(ShaderInputConstantIndex inputIndex) const; AZStd::span<const uint8_t> GetConstantRaw(ShaderInputConstantIndex inputIndex) const;
//! Returns the opaque constant data populated by calls to SetConstant and SetConstantData. //! Returns the opaque constant data populated by calls to SetConstant and SetConstantData.
AZStd::array_view<uint8_t> GetConstantData() const; AZStd::span<const uint8_t> GetConstantData() const;
//! Returns the constants layout. //! Returns the constants layout.
const ConstantsLayout* GetLayout() const; const ConstantsLayout* GetLayout() const;
@@ -123,7 +123,7 @@ namespace AZ
template <typename T> template <typename T>
bool ConstantsData::SetConstant(ShaderInputConstantIndex inputIndex, const T& value) bool ConstantsData::SetConstant(ShaderInputConstantIndex inputIndex, const T& value)
{ {
AZStd::array_view<T> valueArray(&value, 1); AZStd::span<const T> valueArray(&value, 1);
return SetConstantArray(inputIndex, valueArray); return SetConstantArray(inputIndex, valueArray);
} }
@@ -152,7 +152,7 @@ namespace AZ
bool ConstantsData::SetConstant<Color>(ShaderInputConstantIndex inputIndex, const Color& value); bool ConstantsData::SetConstant<Color>(ShaderInputConstantIndex inputIndex, const Color& value);
template <> template <>
bool ConstantsData::SetConstantArray<bool>(ShaderInputConstantIndex inputIndex, AZStd::array_view<bool> values); bool ConstantsData::SetConstantArray<bool>(ShaderInputConstantIndex inputIndex, AZStd::span<const bool> values);
template <> template <>
bool ConstantsData::GetConstant<bool>(ShaderInputConstantIndex inputIndex) const; bool ConstantsData::GetConstant<bool>(ShaderInputConstantIndex inputIndex) const;
@@ -213,7 +213,7 @@ namespace AZ
} }
template <typename T> template <typename T>
bool ConstantsData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view<T> values) bool ConstantsData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span<const T> values)
{ {
const size_t sizeInBytes = values.size() * sizeof(T); const size_t sizeInBytes = values.size() * sizeof(T);
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes))
@@ -224,15 +224,15 @@ namespace AZ
} }
template <typename T> template <typename T>
AZStd::array_view<T> ConstantsData::GetConstantArray(ShaderInputConstantIndex inputIndex) const AZStd::span<const T> ConstantsData::GetConstantArray(ShaderInputConstantIndex inputIndex) const
{ {
AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
const size_t elementSize = sizeof(T); const size_t elementSize = sizeof(T);
const size_t elementCount = DivideByMultiple(constantBytes.size(), elementSize); const size_t elementCount = DivideByMultiple(constantBytes.size(), elementSize);
const size_t sizeInBytes = elementCount * elementSize; const size_t sizeInBytes = elementCount * elementSize;
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes))
{ {
return AZStd::array_view<T>(reinterpret_cast<const T*>(constantBytes.data()), elementCount); return AZStd::span<const T>(reinterpret_cast<const T*>(constantBytes.data()), elementCount);
} }
return {}; return {};
} }
@@ -240,7 +240,7 @@ namespace AZ
template <typename T> template <typename T>
T ConstantsData::GetConstant(ShaderInputConstantIndex inputIndex) const T ConstantsData::GetConstant(ShaderInputConstantIndex inputIndex) const
{ {
AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
const size_t sizeInBytes = sizeof(T); const size_t sizeInBytes = sizeof(T);
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes))
{ {
@@ -252,7 +252,7 @@ namespace AZ
template <typename T> template <typename T>
T ConstantsData::GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const T ConstantsData::GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const
{ {
AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
const size_t elementSize = sizeof(T); const size_t elementSize = sizeof(T);
const size_t elementOffset = arrayIndex * elementSize; const size_t elementOffset = arrayIndex * elementSize;
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::ArrayElement, elementOffset, elementSize)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::ArrayElement, elementOffset, elementSize))
@@ -11,7 +11,7 @@
#include <Atom/RHI.Reflect/Base.h> #include <Atom/RHI.Reflect/Base.h>
#include <Atom/RHI.Reflect/Handle.h> #include <Atom/RHI.Reflect/Handle.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/containers/bitset.h> #include <AzCore/std/containers/bitset.h>
@@ -36,7 +36,7 @@ namespace AZ
using DrawListMask = AZStd::bitset<RHI::Limits::Pipeline::DrawListTagCountMax>; using DrawListMask = AZStd::bitset<RHI::Limits::Pipeline::DrawListTagCountMax>;
using DrawList = AZStd::vector<RHI::DrawItemProperties>; using DrawList = AZStd::vector<RHI::DrawItemProperties>;
using DrawListView = AZStd::array_view<RHI::DrawItemProperties>; using DrawListView = AZStd::span<const RHI::DrawItemProperties>;
/// Contains a table of draw lists, indexed by the tag. /// Contains a table of draw lists, indexed by the tag.
using DrawListsByTag = AZStd::array<DrawList, RHI::Limits::Pipeline::DrawListTagCountMax>; using DrawListsByTag = AZStd::array<DrawList, RHI::Limits::Pipeline::DrawListTagCountMax>;
@@ -32,7 +32,7 @@ namespace AZ
uint8_t m_stencilRef = 0; uint8_t m_stencilRef = 0;
//! The array of stream buffers to bind for this draw item. //! The array of stream buffers to bind for this draw item.
AZStd::array_view<StreamBufferView> m_streamBufferViews; AZStd::span<const StreamBufferView> m_streamBufferViews;
//! Shader resource group unique for this draw request //! Shader resource group unique for this draw request
const ShaderResourceGroup* m_uniqueShaderResourceGroup = nullptr; const ShaderResourceGroup* m_uniqueShaderResourceGroup = nullptr;
@@ -56,13 +56,13 @@ namespace AZ
void SetIndexBufferView(const IndexBufferView& indexBufferView); void SetIndexBufferView(const IndexBufferView& indexBufferView);
void SetRootConstants(AZStd::array_view<uint8_t> rootConstants); void SetRootConstants(AZStd::span<const uint8_t> rootConstants);
void SetScissors(AZStd::array_view<Scissor> scissors); void SetScissors(AZStd::span<const Scissor> scissors);
void SetScissor(const Scissor& scissor); void SetScissor(const Scissor& scissor);
void SetViewports(AZStd::array_view<Viewport> viewports); void SetViewports(AZStd::span<const Viewport> viewports);
void SetViewport(const Viewport& viewport); void SetViewport(const Viewport& viewport);
@@ -85,7 +85,7 @@ namespace AZ
IndexBufferView m_indexBufferView; IndexBufferView m_indexBufferView;
AZStd::fixed_vector<DrawRequest, DrawItemCountMax> m_drawRequests; AZStd::fixed_vector<DrawRequest, DrawItemCountMax> m_drawRequests;
AZStd::fixed_vector<const ShaderResourceGroup*, Limits::Pipeline::ShaderResourceGroupCountMax> m_shaderResourceGroups; AZStd::fixed_vector<const ShaderResourceGroup*, Limits::Pipeline::ShaderResourceGroupCountMax> m_shaderResourceGroups;
AZStd::array_view<uint8_t> m_rootConstants; AZStd::span<const uint8_t> m_rootConstants;
AZStd::fixed_vector<Scissor, Limits::Pipeline::AttachmentColorCountMax> m_scissors; AZStd::fixed_vector<Scissor, Limits::Pipeline::AttachmentColorCountMax> m_scissors;
AZStd::fixed_vector<Viewport, Limits::Pipeline::AttachmentColorCountMax> m_viewports; AZStd::fixed_vector<Viewport, Limits::Pipeline::AttachmentColorCountMax> m_viewports;
}; };
@@ -7,7 +7,7 @@
*/ */
#pragma once #pragma once
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <Atom/RHI.Reflect/BufferScopeAttachmentDescriptor.h> #include <Atom/RHI.Reflect/BufferScopeAttachmentDescriptor.h>
#include <Atom/RHI.Reflect/ImageScopeAttachmentDescriptor.h> #include <Atom/RHI.Reflect/ImageScopeAttachmentDescriptor.h>
@@ -105,11 +105,11 @@ namespace AZ
// See RHI::FrameGraphInterface for detailed comments // See RHI::FrameGraphInterface for detailed comments
ResultCode UseAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access, ScopeAttachmentUsage usage); ResultCode UseAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access, ScopeAttachmentUsage usage);
ResultCode UseAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access, ScopeAttachmentUsage usage); ResultCode UseAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access, ScopeAttachmentUsage usage);
ResultCode UseAttachments(AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage); ResultCode UseAttachments(AZStd::span<const ImageScopeAttachmentDescriptor> descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage);
ResultCode UseResolveAttachment(const ResolveScopeAttachmentDescriptor& descriptor); ResultCode UseResolveAttachment(const ResolveScopeAttachmentDescriptor& descriptor);
ResultCode UseColorAttachments(AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors); ResultCode UseColorAttachments(AZStd::span<const ImageScopeAttachmentDescriptor> descriptors);
ResultCode UseDepthStencilAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access); ResultCode UseDepthStencilAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access);
ResultCode UseSubpassInputAttachments(AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors); ResultCode UseSubpassInputAttachments(AZStd::span<const ImageScopeAttachmentDescriptor> descriptors);
ResultCode UseShaderAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access); ResultCode UseShaderAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access);
ResultCode UseShaderAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access); ResultCode UseShaderAttachment(const ImageScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access);
ResultCode UseCopyAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access); ResultCode UseCopyAttachment(const BufferScopeAttachmentDescriptor& descriptor, ScopeAttachmentAccess access);
@@ -124,7 +124,7 @@ namespace AZ
FrameGraphExecuteGroupType* AddGroup(); FrameGraphExecuteGroupType* AddGroup();
//! Returns a list of the registered execute groups. //! Returns a list of the registered execute groups.
AZStd::array_view<AZStd::unique_ptr<FrameGraphExecuteGroup>> GetGroups() const; AZStd::span<const AZStd::unique_ptr<FrameGraphExecuteGroup>> GetGroups() const;
private: private:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -18,7 +18,7 @@
#include <Atom/RHI.Reflect/ResolveScopeAttachmentDescriptor.h> #include <Atom/RHI.Reflect/ResolveScopeAttachmentDescriptor.h>
#include <Atom/RHI.Reflect/ScopeId.h> #include <Atom/RHI.Reflect/ScopeId.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
namespace AZ namespace AZ
{ {
@@ -79,7 +79,7 @@ namespace AZ
//! Declares an array of image attachments for use on the current scope. //! Declares an array of image attachments for use on the current scope.
ResultCode UseAttachments( ResultCode UseAttachments(
AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors, AZStd::span<const ImageScopeAttachmentDescriptor> descriptors,
ScopeAttachmentAccess access, ScopeAttachmentAccess access,
ScopeAttachmentUsage usage) ScopeAttachmentUsage usage)
{ {
@@ -87,7 +87,7 @@ namespace AZ
} }
//! Declares an array of color attachments for use on the current scope. //! Declares an array of color attachments for use on the current scope.
ResultCode UseColorAttachments(AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors) ResultCode UseColorAttachments(AZStd::span<const ImageScopeAttachmentDescriptor> descriptors)
{ {
return m_frameGraph.UseColorAttachments(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. //! Declares an array of subpass input attachments for use on the current scope.
//! See UseSubpassInputAttachment for a definition about a SubpassInput. //! See UseSubpassInputAttachment for a definition about a SubpassInput.
ResultCode UseSubpassInputAttachments(AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors) ResultCode UseSubpassInputAttachments(AZStd::span<const ImageScopeAttachmentDescriptor> descriptors)
{ {
return m_frameGraph.UseSubpassInputAttachments(descriptors); return m_frameGraph.UseSubpassInputAttachments(descriptors);
} }
@@ -19,7 +19,7 @@ namespace AZ
/// A handle typed to the pipeline library. Used by the PipelineStateCache to abstract access. /// A handle typed to the pipeline library. Used by the PipelineStateCache to abstract access.
using PipelineLibraryHandle = Handle<uint32_t, class PipelineLibrary>; using PipelineLibraryHandle = Handle<uint32_t, class PipelineLibrary>;
//! PipelineState initialization is an expensive operation on certain platforms. If multiple pipeline states //! 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 //! 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 //! 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 //! 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 //! extracted from the unified library. An error code is returned on failure and the behavior
//! is as if the method was never called. //! is as if the method was never called.
ResultCode MergeInto(AZStd::array_view<const PipelineLibrary*> librariesToMerge); ResultCode MergeInto(AZStd::span<const PipelineLibrary* const> librariesToMerge);
//! Serializes the platform-specific data and returns it as a new PipelineLibraryData instance. //! 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 //! 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; virtual void ShutdownInternal() = 0;
/// Called when libraries are being merged into this one. /// Called when libraries are being merged into this one.
virtual ResultCode MergeIntoInternal(AZStd::array_view<const PipelineLibrary*> libraries) = 0; virtual ResultCode MergeIntoInternal(AZStd::span<const PipelineLibrary* const> libraries) = 0;
/// Called when the library is serializing out platform-specific data. /// Called when the library is serializing out platform-specific data.
virtual ConstPtr<PipelineLibraryData> GetSerializedDataInternal() const = 0; virtual ConstPtr<PipelineLibraryData> GetSerializedDataInternal() const = 0;
@@ -24,16 +24,16 @@ namespace AZ
//! and shader constants. It utilizes basic reflection information from the shader resource group layout //! 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 //! 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. //! 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 //! 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 //! 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. //! 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. //! 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, //! 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). //! 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. //! NOTE [SRG Constants]: The ConstantsData class is used for efficiently setting/getting the constants values of the SRG.
class ShaderResourceGroupData class ShaderResourceGroupData
{ {
@@ -65,25 +65,25 @@ namespace AZ
bool SetImageView(ShaderInputImageIndex inputIndex, const ImageView* imageView, uint32_t arrayIndex); bool SetImageView(ShaderInputImageIndex inputIndex, const ImageView* imageView, uint32_t arrayIndex);
//! Sets an array of image view for the given shader input index. //! Sets an array of image view for the given shader input index.
bool SetImageViewArray(ShaderInputImageIndex inputIndex, AZStd::array_view<const ImageView*> imageViews, uint32_t arrayIndex = 0); bool SetImageViewArray(ShaderInputImageIndex inputIndex, AZStd::span<const ImageView* const> imageViews, uint32_t arrayIndex = 0);
//! Sets an unbounded array of image view for the given shader input index. //! Sets an unbounded array of image view for the given shader input index.
bool SetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::array_view<const ImageView*> imageViews); bool SetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::span<const ImageView* const> imageViews);
//! Sets one buffer view for the given shader input index. //! Sets one buffer view for the given shader input index.
bool SetBufferView(ShaderInputBufferIndex inputIndex, const BufferView* bufferView, uint32_t arrayIndex = 0); bool SetBufferView(ShaderInputBufferIndex inputIndex, const BufferView* bufferView, uint32_t arrayIndex = 0);
//! Sets an array of image view for the given shader input index. //! Sets an array of image view for the given shader input index.
bool SetBufferViewArray(ShaderInputBufferIndex inputIndex, AZStd::array_view<const BufferView*> bufferViews, uint32_t arrayIndex = 0); bool SetBufferViewArray(ShaderInputBufferIndex inputIndex, AZStd::span<const BufferView* const> bufferViews, uint32_t arrayIndex = 0);
//! Sets an unbounded array of buffer view for the given shader input index. //! Sets an unbounded array of buffer view for the given shader input index.
bool SetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::array_view<const BufferView*> bufferViews); bool SetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::span<const BufferView* const> bufferViews);
//! Sets one sampler for the given shader input index, using the bindingIndex as the key. //! 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); bool SetSampler(ShaderInputSamplerIndex inputIndex, const SamplerState& sampler, uint32_t arrayIndex = 0);
//! Sets an array of samplers for the given shader input index. //! Sets an array of samplers for the given shader input index.
bool SetSamplerArray(ShaderInputSamplerIndex inputIndex, AZStd::array_view<SamplerState> samplers, uint32_t arrayIndex = 0); bool SetSamplerArray(ShaderInputSamplerIndex inputIndex, AZStd::span<const SamplerState> samplers, uint32_t arrayIndex = 0);
//! Assigns constant data for the given constant shader input index. //! Assigns constant data for the given constant shader input index.
bool SetConstantRaw(ShaderInputConstantIndex inputIndex, const void* bytes, uint32_t byteCount); 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 //! Assigns a specified number of rows from a Matrix
template <typename T> template <typename T>
bool SetConstantMatrixRows(ShaderInputConstantIndex inputIndex, const T& value, uint32_t rowCount); 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. //! Assigns a value of type T to the constant shader input, at an array offset.
template <typename T> template <typename T>
bool SetConstant(ShaderInputConstantIndex inputIndex, const T& value, uint32_t arrayIndex); bool SetConstant(ShaderInputConstantIndex inputIndex, const T& value, uint32_t arrayIndex);
//! Assigns an array of type T to the constant shader input. //! Assigns an array of type T to the constant shader input.
template <typename T> template <typename T>
bool SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view<T> values); bool SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span<const T> values);
//! Assigns constant data as a whole. //! Assigns constant data as a whole.
//! //!
//! CAUTION! //! CAUTION!
//! Different platforms might follow different packing rules for the internally-managed SRG constant buffer. //! 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, //! 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. //! Returns a single image view associated with the image shader input index and array offset.
const ConstPtr<ImageView>& GetImageView(ShaderInputImageIndex inputIndex, uint32_t arrayIndex) const; const ConstPtr<ImageView>& GetImageView(ShaderInputImageIndex inputIndex, uint32_t arrayIndex) const;
//! Returns an array of image views associated with the given image shader input index. //! Returns a span of image views associated with the given image shader input index.
AZStd::array_view<ConstPtr<ImageView>> GetImageViewArray(ShaderInputImageIndex inputIndex) const; AZStd::span<const ConstPtr<ImageView>> GetImageViewArray(ShaderInputImageIndex inputIndex) const;
//! Returns an unbounded array of image views associated with the given buffer shader input index. //! Returns an unbounded span of image views associated with the given buffer shader input index.
AZStd::array_view<ConstPtr<ImageView>> GetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex) const; AZStd::span<const ConstPtr<ImageView>> GetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex) const;
//! Returns a single buffer view associated with the buffer shader input index and array offset. //! Returns a single buffer view associated with the buffer shader input index and array offset.
const ConstPtr<BufferView>& GetBufferView(ShaderInputBufferIndex inputIndex, uint32_t arrayIndex) const; const ConstPtr<BufferView>& GetBufferView(ShaderInputBufferIndex inputIndex, uint32_t arrayIndex) const;
//! Returns an array of buffer views associated with the given buffer shader input index. //! Returns a span of buffer views associated with the given buffer shader input index.
AZStd::array_view<ConstPtr<BufferView>> GetBufferViewArray(ShaderInputBufferIndex inputIndex) const; AZStd::span<const ConstPtr<BufferView>> GetBufferViewArray(ShaderInputBufferIndex inputIndex) const;
//! Returns an unbounded array of buffer views associated with the given buffer shader input index. //! Returns an unbounded span of buffer views associated with the given buffer shader input index.
AZStd::array_view<ConstPtr<BufferView>> GetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex) const; AZStd::span<const ConstPtr<BufferView>> GetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex) const;
//! Returns a single sampler associated with the sampler shader input index and array offset. //! Returns a single sampler associated with the sampler shader input index and array offset.
const SamplerState& GetSampler(ShaderInputSamplerIndex inputIndex, uint32_t arrayIndex) const; const SamplerState& GetSampler(ShaderInputSamplerIndex inputIndex, uint32_t arrayIndex) const;
//! Returns an array of samplers associated with the sampler shader input index. //! Returns a span of samplers associated with the sampler shader input index.
AZStd::array_view<SamplerState> GetSamplerArray(ShaderInputSamplerIndex inputIndex) const; AZStd::span<const SamplerState> GetSamplerArray(ShaderInputSamplerIndex inputIndex) const;
//! Returns constant data for the given shader input index as a template type. //! 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 //! 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. //! of elements in the returned span is the number of evenly divisible elements.
//! If the strides do not match, an empty array is returned. //! If the strides do not match, an empty span is returned.
template <typename T> template <typename T>
AZStd::array_view<T> GetConstantArray(ShaderInputConstantIndex inputIndex) const; AZStd::span<const T> GetConstantArray(ShaderInputConstantIndex inputIndex) const;
//! Returns the constant data as type 'T' returned by value. The size of the constant region //! 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. //! must match the size of T exactly. Otherwise, an empty instance is returned.
@@ -157,25 +157,25 @@ namespace AZ
template <typename T> template <typename T>
T GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const; T GetConstant(ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const;
//! Returns constant data for the given shader input index as an array of bytes. //! Returns constant data for the given shader input index as a span of bytes.
AZStd::array_view<uint8_t> GetConstantRaw(ShaderInputConstantIndex inputIndex) const; AZStd::span<const uint8_t> GetConstantRaw(ShaderInputConstantIndex inputIndex) const;
//! Returns a {Buffer, Image, Sampler} shader resource group. Each resource type has its own separate group. //! 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}. //! - 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. //! - Use ShaderResourceGroupLayout::GetGroupInterval to retrieve a [min, max) interval into the span.
AZStd::array_view<ConstPtr<ImageView>> GetImageGroup() const; AZStd::span<const ConstPtr<ImageView>> GetImageGroup() const;
AZStd::array_view<ConstPtr<BufferView>> GetBufferGroup() const; AZStd::span<const ConstPtr<BufferView>> GetBufferGroup() const;
AZStd::array_view<SamplerState> GetSamplerGroup() const; AZStd::span<const SamplerState> GetSamplerGroup() const;
//! Reset image and buffer views setup for this ShaderResourceGroupData //! Reset image and buffer views setup for this ShaderResourceGroupData
//! So it won't hold references for any RHI resources //! So it won't hold references for any RHI resources
void ResetViews(); void ResetViews();
//! Returns the opaque constant data populated by calls to SetConstant and SetConstantData. //! Returns the opaque constant data populated by calls to SetConstant and SetConstantData.
//! //!
//! CAUTION! //! CAUTION!
//! Different platforms might follow different packing rules for the internally-managed SRG constant buffer. //! Different platforms might follow different packing rules for the internally-managed SRG constant buffer.
AZStd::array_view<uint8_t> GetConstantData() const; AZStd::span<const uint8_t> GetConstantData() const;
//! Returns the underlying ConstantsData struct //! Returns the underlying ConstantsData struct
const ConstantsData& GetConstantsData() const; const ConstantsData& GetConstantsData() const;
@@ -213,7 +213,7 @@ namespace AZ
//! times in order to ensure all SRG buffers are updated. //! times in order to ensure all SRG buffers are updated.
void DisableCompilationForAllResourceTypes(); 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; bool IsAnyResourceTypeUpdated() const;
//! Enable compilation for a resourceType specified by resourceType/resourceTypeMask //! Enable compilation for a resourceType specified by resourceType/resourceTypeMask
@@ -265,7 +265,7 @@ namespace AZ
EnableResourceTypeCompilation(ResourceTypeMask::ConstantDataMask, ResourceType::ConstantData); EnableResourceTypeCompilation(ResourceTypeMask::ConstantDataMask, ResourceType::ConstantData);
return m_constantsData.SetConstant(inputIndex, value, arrayIndex); return m_constantsData.SetConstant(inputIndex, value, arrayIndex);
} }
template<typename T> template<typename T>
bool ShaderResourceGroupData::SetConstantMatrixRows(ShaderInputConstantIndex inputIndex, const T& value, uint32_t rowCount) bool ShaderResourceGroupData::SetConstantMatrixRows(ShaderInputConstantIndex inputIndex, const T& value, uint32_t rowCount)
{ {
@@ -274,7 +274,7 @@ namespace AZ
} }
template <typename T> template <typename T>
bool ShaderResourceGroupData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::array_view<T> values) bool ShaderResourceGroupData::SetConstantArray(ShaderInputConstantIndex inputIndex, AZStd::span<const T> values)
{ {
if (!values.empty()) if (!values.empty())
{ {
@@ -284,7 +284,7 @@ namespace AZ
} }
template <typename T> template <typename T>
AZStd::array_view<T> ShaderResourceGroupData::GetConstantArray(ShaderInputConstantIndex inputIndex) const AZStd::span<const T> ShaderResourceGroupData::GetConstantArray(ShaderInputConstantIndex inputIndex) const
{ {
return m_constantsData.GetConstantArray<T>(inputIndex); return m_constantsData.GetConstantArray<T>(inputIndex);
} }
@@ -8,7 +8,7 @@
#pragma once #pragma once
#include <Atom/RHI.Reflect/Format.h> #include <Atom/RHI.Reflect/Format.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/Utils/TypeHash.h> #include <AzCore/Utils/TypeHash.h>
namespace AZ namespace AZ
@@ -65,6 +65,6 @@ namespace AZ
}; };
/// Utility function for checking that the set of StreamBufferViews aligns with the InputStreamLayout /// Utility function for checking that the set of StreamBufferViews aligns with the InputStreamLayout
bool ValidateStreamBufferViews(const InputStreamLayout& inputStreamLayout, AZStd::array_view<StreamBufferView> streamBufferViews); bool ValidateStreamBufferViews(const InputStreamLayout& inputStreamLayout, AZStd::span<const StreamBufferView> streamBufferViews);
} }
} }
@@ -11,7 +11,7 @@
#include <Atom/RHI/Image.h> #include <Atom/RHI/Image.h>
#include <Atom/RHI/ImagePoolBase.h> #include <Atom/RHI/ImagePoolBase.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
namespace AZ namespace AZ
{ {
@@ -34,7 +34,7 @@ namespace AZ
struct StreamingImageMipSlice struct StreamingImageMipSlice
{ {
/// An array of subresource datas. The size of this array must match the array size of the image. /// An array of subresource datas. The size of this array must match the array size of the image.
AZStd::array_view<StreamingImageSubresourceData> m_subresources; AZStd::span<const StreamingImageSubresourceData> m_subresources;
/// The layout of each image in the array. /// The layout of each image in the array.
ImageSubresourceLayout m_subresourceLayout; ImageSubresourceLayout m_subresourceLayout;
@@ -52,7 +52,7 @@ namespace AZ
StreamingImageInitRequest( StreamingImageInitRequest(
Image& image, Image& image,
const ImageDescriptor& descriptor, const ImageDescriptor& descriptor,
AZStd::array_view<StreamingImageMipSlice> tailMipSlices); AZStd::span<const StreamingImageMipSlice> tailMipSlices);
/// The image to initialize. /// The image to initialize.
Image* m_image = nullptr; 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 * This should only include the baseline set of mips necessary to render the image at
* its lowest resolution. The uploads is performed synchronously. * its lowest resolution. The uploads is performed synchronously.
*/ */
AZStd::array_view<StreamingImageMipSlice> m_tailMipSlices; AZStd::span<const StreamingImageMipSlice> m_tailMipSlices;
}; };
/** /**
@@ -83,7 +83,7 @@ namespace AZ
* remain valid for the duration of the upload (until m_completeCallback * remain valid for the duration of the upload (until m_completeCallback
* is triggered). * is triggered).
*/ */
AZStd::array_view<StreamingImageMipSlice> m_mipSlices; AZStd::span<const StreamingImageMipSlice> m_mipSlices;
/// Whether the function need to wait until the upload is finished. /// Whether the function need to wait until the upload is finished.
bool m_waitForUpload = false; bool m_waitForUpload = false;
@@ -123,7 +123,7 @@ namespace AZ
protected: protected:
// Adds the stats of a list of heaps into the Pool's TransientAttachmentStatistics. // Adds the stats of a list of heaps into the Pool's TransientAttachmentStatistics.
void CollectHeapStats(AliasedResourceTypeFlags typeMask, AZStd::array_view<TransientAttachmentStatistics::Heap> heapStats); void CollectHeapStats(AliasedResourceTypeFlags typeMask, AZStd::span<const TransientAttachmentStatistics::Heap> heapStats);
Scope* m_currentScope = nullptr; Scope* m_currentScope = nullptr;
RHI::TransientAttachmentStatistics m_statistics; RHI::TransientAttachmentStatistics m_statistics;
+1 -1
View File
@@ -496,7 +496,7 @@ namespace AZ
} }
AZStd::string RemoveArgumentsFromCommandLineString( AZStd::string RemoveArgumentsFromCommandLineString(
AZStd::array_view<AZStd::string> listOfArgumentsToRemove, AZStd::string_view commandLineString) AZStd::span<const AZStd::string> listOfArgumentsToRemove, AZStd::string_view commandLineString)
{ {
AZStd::string customizedArguments = commandLineString; AZStd::string customizedArguments = commandLineString;
for (const AZStd::string& azslcArgumentName : listOfArgumentsToRemove) for (const AZStd::string& azslcArgumentName : listOfArgumentsToRemove)
@@ -106,7 +106,7 @@ namespace AZ
return m_inputs[inputIndex.GetIndex()]; return m_inputs[inputIndex.GetIndex()];
} }
AZStd::array_view<ShaderInputConstantDescriptor> ConstantsLayout::GetShaderInputList() const AZStd::span<const ShaderInputConstantDescriptor> ConstantsLayout::GetShaderInputList() const
{ {
return m_inputs; return m_inputs;
} }
@@ -145,7 +145,7 @@ namespace AZ
return true; return true;
} }
void ConstantsLayout::DebugPrintNames(AZStd::array_view<ShaderInputConstantIndex> constantList) const void ConstantsLayout::DebugPrintNames(AZStd::span<const ShaderInputConstantIndex> constantList) const
{ {
AZStd::string output; AZStd::string output;
for (const ShaderInputConstantIndex& constantIdx : constantList) for (const ShaderInputConstantIndex& constantIdx : constantList)
@@ -137,11 +137,11 @@ namespace AZ
return true; return true;
} }
AZStd::array_view<IndirectCommandDescriptor> IndirectBufferLayout::GetCommands() const AZStd::span<const IndirectCommandDescriptor> IndirectBufferLayout::GetCommands() const
{ {
if (!ValidateFinalizeState(ValidateFinalizeStateExpect::Finalized)) if (!ValidateFinalizeState(ValidateFinalizeStateExpect::Finalized))
{ {
return AZStd::array_view<IndirectCommandDescriptor>(); return AZStd::span<const IndirectCommandDescriptor>();
} }
return m_commands; return m_commands;
} }
@@ -159,12 +159,12 @@ namespace AZ
return m_topology; return m_topology;
} }
AZStd::array_view<StreamChannelDescriptor> InputStreamLayout::GetStreamChannels() const AZStd::span<const StreamChannelDescriptor> InputStreamLayout::GetStreamChannels() const
{ {
return m_streamChannels; return m_streamChannels;
} }
AZStd::array_view<StreamBufferDescriptor> InputStreamLayout::GetStreamBuffers() const AZStd::span<const StreamBufferDescriptor> InputStreamLayout::GetStreamBuffers() const
{ {
return m_streamBuffers; return m_streamBuffers;
} }
@@ -31,7 +31,7 @@ namespace AZ
: m_data{AZStd::move(data)} : m_data{AZStd::move(data)}
{} {}
AZStd::array_view<uint8_t> PipelineLibraryData::GetData() const AZStd::span<const uint8_t> PipelineLibraryData::GetData() const
{ {
return m_data; return m_data;
} }
@@ -432,7 +432,7 @@ namespace AZ
m_bindingSlot = Handle<uint32_t>(bindingSlot); m_bindingSlot = Handle<uint32_t>(bindingSlot);
} }
AZStd::array_view<ShaderInputStaticSamplerDescriptor> ShaderResourceGroupLayout::GetStaticSamplers() const AZStd::span<const ShaderInputStaticSamplerDescriptor> ShaderResourceGroupLayout::GetStaticSamplers() const
{ {
return m_staticSamplers; return m_staticSamplers;
} }
@@ -497,32 +497,32 @@ namespace AZ
return m_constantsDataLayout->GetShaderInput(index); return m_constantsDataLayout->GetShaderInput(index);
} }
AZStd::array_view<ShaderInputBufferDescriptor> ShaderResourceGroupLayout::GetShaderInputListForBuffers() const AZStd::span<const ShaderInputBufferDescriptor> ShaderResourceGroupLayout::GetShaderInputListForBuffers() const
{ {
return m_inputsForBuffers; return m_inputsForBuffers;
} }
AZStd::array_view<ShaderInputImageDescriptor> ShaderResourceGroupLayout::GetShaderInputListForImages() const AZStd::span<const ShaderInputImageDescriptor> ShaderResourceGroupLayout::GetShaderInputListForImages() const
{ {
return m_inputsForImages; return m_inputsForImages;
} }
AZStd::array_view<ShaderInputSamplerDescriptor> ShaderResourceGroupLayout::GetShaderInputListForSamplers() const AZStd::span<const ShaderInputSamplerDescriptor> ShaderResourceGroupLayout::GetShaderInputListForSamplers() const
{ {
return m_inputsForSamplers; return m_inputsForSamplers;
} }
AZStd::array_view<ShaderInputConstantDescriptor> ShaderResourceGroupLayout::GetShaderInputListForConstants() const AZStd::span<const ShaderInputConstantDescriptor> ShaderResourceGroupLayout::GetShaderInputListForConstants() const
{ {
return m_constantsDataLayout->GetShaderInputList(); return m_constantsDataLayout->GetShaderInputList();
} }
AZStd::array_view<ShaderInputBufferUnboundedArrayDescriptor> ShaderResourceGroupLayout::GetShaderInputListForBufferUnboundedArrays() const AZStd::span<const ShaderInputBufferUnboundedArrayDescriptor> ShaderResourceGroupLayout::GetShaderInputListForBufferUnboundedArrays() const
{ {
return m_inputsForBufferUnboundedArrays; return m_inputsForBufferUnboundedArrays;
} }
AZStd::array_view<ShaderInputImageUnboundedArrayDescriptor> ShaderResourceGroupLayout::GetShaderInputListForImageUnboundedArrays() const AZStd::span<const ShaderInputImageUnboundedArrayDescriptor> ShaderResourceGroupLayout::GetShaderInputListForImageUnboundedArrays() const
{ {
return m_inputsForImageUnboundedArrays; return m_inputsForImageUnboundedArrays;
} }
+17 -17
View File
@@ -144,7 +144,7 @@ namespace AZ
} }
template <> template <>
bool ConstantsData::SetConstantArray<bool>(ShaderInputConstantIndex inputIndex, AZStd::array_view<bool> values) bool ConstantsData::SetConstantArray<bool>(ShaderInputConstantIndex inputIndex, AZStd::span<const bool> values)
{ {
// The shader packs type bool as 4 bytes // The shader packs type bool as 4 bytes
const size_t elementSize = 4; const size_t elementSize = 4;
@@ -310,7 +310,7 @@ namespace AZ
template <> template <>
bool ConstantsData::GetConstant<bool>(ShaderInputConstantIndex inputIndex) const bool ConstantsData::GetConstant<bool>(ShaderInputConstantIndex inputIndex) const
{ {
AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
// The shader packs bool data as 4 bytes // The shader packs bool data as 4 bytes
const size_t sizeInBytes = 4; const size_t sizeInBytes = 4;
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes))
@@ -328,7 +328,7 @@ namespace AZ
const size_t sizeInBytes = sizeof(float) * 11; const size_t sizeInBytes = sizeof(float) * 11;
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes))
{ {
const AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); const AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
// As per shader packing rules the Matrix3x3 is stored as 11 floats (2 are padding). // As per shader packing rules the Matrix3x3 is stored as 11 floats (2 are padding).
float localData[12]; float localData[12];
@@ -348,7 +348,7 @@ namespace AZ
const uint32_t sizeInBytes = sizeof(Matrix3x4); const uint32_t sizeInBytes = sizeof(Matrix3x4);
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes))
{ {
const AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); const AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
const Matrix3x4& resultMatrix = Matrix3x4::CreateFromRowMajorFloat12(reinterpret_cast<const float*>(constantBytes.data())); const Matrix3x4& resultMatrix = Matrix3x4::CreateFromRowMajorFloat12(reinterpret_cast<const float*>(constantBytes.data()));
return resultMatrix; return resultMatrix;
} }
@@ -361,7 +361,7 @@ namespace AZ
const size_t sizeInBytes = sizeof(float) * 16; const size_t sizeInBytes = sizeof(float) * 16;
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, sizeInBytes))
{ {
const AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); const AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
const Matrix4x4& resultMatrix = Matrix4x4::CreateFromRowMajorFloat16(reinterpret_cast<const float*>(constantBytes.data())); const Matrix4x4& resultMatrix = Matrix4x4::CreateFromRowMajorFloat16(reinterpret_cast<const float*>(constantBytes.data()));
return resultMatrix; return resultMatrix;
} }
@@ -374,7 +374,7 @@ namespace AZ
constexpr size_t vector2Size = 8; constexpr size_t vector2Size = 8;
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(vector2Size))) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(vector2Size)))
{ {
AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
return Vector2::CreateFromFloat2(reinterpret_cast<const float*>(constantBytes.data())); return Vector2::CreateFromFloat2(reinterpret_cast<const float*>(constantBytes.data()));
} }
return Vector2(); return Vector2();
@@ -387,7 +387,7 @@ namespace AZ
constexpr size_t vector3Size = sizeof(float) * 3; constexpr size_t vector3Size = sizeof(float) * 3;
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, vector3Size)) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, vector3Size))
{ {
AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
return Vector3::CreateFromFloat3(reinterpret_cast<const float*>(constantBytes.data())); return Vector3::CreateFromFloat3(reinterpret_cast<const float*>(constantBytes.data()));
} }
return Vector3(); return Vector3();
@@ -399,7 +399,7 @@ namespace AZ
constexpr size_t vector4Size = 16; constexpr size_t vector4Size = 16;
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(vector4Size))) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(vector4Size)))
{ {
AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
return Vector4::CreateFromFloat4(reinterpret_cast<const float*>(constantBytes.data())); return Vector4::CreateFromFloat4(reinterpret_cast<const float*>(constantBytes.data()));
} }
return Vector4(); return Vector4();
@@ -411,19 +411,19 @@ namespace AZ
constexpr size_t colorSize = sizeof(Color); constexpr size_t colorSize = sizeof(Color);
if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(colorSize))) if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::Complete, 0, aznumeric_caster(colorSize)))
{ {
AZStd::array_view<uint8_t> constantBytes = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> constantBytes = GetConstantRaw(inputIndex);
return Color::CreateFromFloat4(reinterpret_cast<const float*>(constantBytes.data())); return Color::CreateFromFloat4(reinterpret_cast<const float*>(constantBytes.data()));
} }
return Color(); return Color();
} }
AZStd::array_view<uint8_t> ConstantsData::GetConstantRaw(ShaderInputConstantIndex inputIndex) const AZStd::span<const uint8_t> ConstantsData::GetConstantRaw(ShaderInputConstantIndex inputIndex) const
{ {
const Interval interval = GetLayout()->GetInterval(inputIndex); const Interval interval = GetLayout()->GetInterval(inputIndex);
return AZStd::array_view<uint8_t>(&m_constantData[interval.m_min], interval.m_max - interval.m_min); return AZStd::span<const uint8_t>(&m_constantData[interval.m_min], interval.m_max - interval.m_min);
} }
AZStd::array_view<uint8_t> ConstantsData::GetConstantData() const AZStd::span<const uint8_t> ConstantsData::GetConstantData() const
{ {
return m_constantData; return m_constantData;
} }
@@ -436,11 +436,11 @@ namespace AZ
bool ConstantsData::ConstantIsEqual(const ConstantsData& other, ShaderInputConstantIndex inputIndex) const bool ConstantsData::ConstantIsEqual(const ConstantsData& other, ShaderInputConstantIndex inputIndex) const
{ {
AZStd::array_view<uint8_t> myConstant = GetConstantRaw(inputIndex); AZStd::span<const uint8_t> myConstant = GetConstantRaw(inputIndex);
AZStd::array_view<uint8_t> otherConstant = other.GetConstantRaw(inputIndex); AZStd::span<const uint8_t> otherConstant = other.GetConstantRaw(inputIndex);
// If they point to the same data, they are equal // If they point to the same data, they are equal
if (myConstant == otherConstant) if (myConstant.data() == otherConstant.data() && myConstant.size() == otherConstant.size())
{ {
return true; return true;
} }
@@ -474,8 +474,8 @@ namespace AZ
return differingIndices; return differingIndices;
} }
AZStd::array_view<ShaderInputConstantDescriptor> myShaderInputs = m_layout->GetShaderInputList(); AZStd::span<const ShaderInputConstantDescriptor> myShaderInputs = m_layout->GetShaderInputList();
AZStd::array_view<ShaderInputConstantDescriptor> otherShaderInputs = other.m_layout->GetShaderInputList(); AZStd::span<const ShaderInputConstantDescriptor> otherShaderInputs = other.m_layout->GetShaderInputList();
size_t minSize = AZStd::min(myShaderInputs.size(), otherShaderInputs.size()); size_t minSize = AZStd::min(myShaderInputs.size(), otherShaderInputs.size());
size_t maxSize = AZStd::max(myShaderInputs.size(), otherShaderInputs.size()); size_t maxSize = AZStd::max(myShaderInputs.size(), otherShaderInputs.size());
@@ -33,29 +33,29 @@ namespace AZ
m_indexBufferView = indexBufferView; m_indexBufferView = indexBufferView;
} }
void DrawPacketBuilder::SetRootConstants(AZStd::array_view<uint8_t> rootConstants) void DrawPacketBuilder::SetRootConstants(AZStd::span<const uint8_t> rootConstants)
{ {
m_rootConstants = rootConstants; m_rootConstants = rootConstants;
} }
void DrawPacketBuilder::SetScissors(AZStd::array_view<Scissor> scissors) void DrawPacketBuilder::SetScissors(AZStd::span<const Scissor> scissors)
{ {
m_scissors = decltype(m_scissors)(scissors.begin(), scissors.end()); m_scissors = decltype(m_scissors)(scissors.begin(), scissors.end());
} }
void DrawPacketBuilder::SetScissor(const Scissor& scissor) void DrawPacketBuilder::SetScissor(const Scissor& scissor)
{ {
SetScissors(AZStd::array_view<Scissor>(&scissor, 1)); SetScissors(AZStd::span<const Scissor>(&scissor, 1));
} }
void DrawPacketBuilder::SetViewports(AZStd::array_view<Viewport> viewports) void DrawPacketBuilder::SetViewports(AZStd::span<const Viewport> viewports)
{ {
m_viewports = decltype(m_viewports)(viewports.begin(), viewports.end()); m_viewports = decltype(m_viewports)(viewports.begin(), viewports.end());
} }
void DrawPacketBuilder::SetViewport(const Viewport& viewport) void DrawPacketBuilder::SetViewport(const Viewport& viewport)
{ {
SetViewports(AZStd::array_view<Viewport>(&viewport, 1)); SetViewports(AZStd::span<const Viewport>(&viewport, 1));
} }
void DrawPacketBuilder::AddShaderResourceGroup(const ShaderResourceGroup* shaderResourceGroup) void DrawPacketBuilder::AddShaderResourceGroup(const ShaderResourceGroup* shaderResourceGroup)
+3 -3
View File
@@ -327,7 +327,7 @@ namespace AZ
return ResultCode::InvalidArgument; return ResultCode::InvalidArgument;
} }
ResultCode FrameGraph::UseAttachments(AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage) ResultCode FrameGraph::UseAttachments(AZStd::span<const ImageScopeAttachmentDescriptor> descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage)
{ {
for (const ImageScopeAttachmentDescriptor& descriptor : descriptors) for (const ImageScopeAttachmentDescriptor& descriptor : descriptors)
{ {
@@ -354,7 +354,7 @@ namespace AZ
return ResultCode::InvalidArgument; return ResultCode::InvalidArgument;
} }
ResultCode FrameGraph::UseColorAttachments(AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors) ResultCode FrameGraph::UseColorAttachments(AZStd::span<const ImageScopeAttachmentDescriptor> descriptors)
{ {
return UseAttachments(descriptors, ScopeAttachmentAccess::Write, ScopeAttachmentUsage::RenderTarget); return UseAttachments(descriptors, ScopeAttachmentAccess::Write, ScopeAttachmentUsage::RenderTarget);
} }
@@ -364,7 +364,7 @@ namespace AZ
return UseAttachment(descriptor, access, ScopeAttachmentUsage::DepthStencil); return UseAttachment(descriptor, access, ScopeAttachmentUsage::DepthStencil);
} }
ResultCode FrameGraph::UseSubpassInputAttachments(AZStd::array_view<ImageScopeAttachmentDescriptor> descriptors) ResultCode FrameGraph::UseSubpassInputAttachments(AZStd::span<const ImageScopeAttachmentDescriptor> descriptors)
{ {
return UseAttachments(descriptors, ScopeAttachmentAccess::Read, ScopeAttachmentUsage::SubpassInput); return UseAttachments(descriptors, ScopeAttachmentAccess::Read, ScopeAttachmentUsage::SubpassInput);
} }
@@ -19,7 +19,7 @@ namespace AZ
m_jobPolicy = jobPolicy; m_jobPolicy = jobPolicy;
} }
AZStd::array_view<AZStd::unique_ptr<FrameGraphExecuteGroup>> FrameGraphExecuter::GetGroups() const AZStd::span<const AZStd::unique_ptr<FrameGraphExecuteGroup>> FrameGraphExecuter::GetGroups() const
{ {
return m_groups; return m_groups;
} }
@@ -44,7 +44,7 @@ namespace AZ
return resultCode; return resultCode;
} }
ResultCode PipelineLibrary::MergeInto(AZStd::array_view<const PipelineLibrary*> librariesToMerge) ResultCode PipelineLibrary::MergeInto(AZStd::span<const PipelineLibrary* const> librariesToMerge)
{ {
if (!ValidateIsInitialized()) if (!ValidateIsInitialized())
{ {
@@ -112,7 +112,7 @@ namespace AZ
return SetImageViewArray(inputIndex, imageViews, arrayIndex); return SetImageViewArray(inputIndex, imageViews, arrayIndex);
} }
bool ShaderResourceGroupData::SetImageViewArray(ShaderInputImageIndex inputIndex, AZStd::array_view<const ImageView*> imageViews, uint32_t arrayIndex) bool ShaderResourceGroupData::SetImageViewArray(ShaderInputImageIndex inputIndex, AZStd::span<const ImageView* const> imageViews, uint32_t arrayIndex)
{ {
if (GetLayout()->ValidateAccess(inputIndex, static_cast<uint32_t>(arrayIndex + imageViews.size() - 1))) if (GetLayout()->ValidateAccess(inputIndex, static_cast<uint32_t>(arrayIndex + imageViews.size() - 1)))
{ {
@@ -132,13 +132,13 @@ namespace AZ
{ {
EnableResourceTypeCompilation(ResourceTypeMask::ImageViewMask, ResourceType::ImageView); EnableResourceTypeCompilation(ResourceTypeMask::ImageViewMask, ResourceType::ImageView);
} }
return isValidAll; return isValidAll;
} }
return false; return false;
} }
bool ShaderResourceGroupData::SetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::array_view<const ImageView*> imageViews) bool ShaderResourceGroupData::SetImageViewUnboundedArray(ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::span<const ImageView* const> imageViews)
{ {
if (GetLayout()->ValidateAccess(inputIndex)) if (GetLayout()->ValidateAccess(inputIndex))
{ {
@@ -169,7 +169,7 @@ namespace AZ
return SetBufferViewArray(inputIndex, bufferViews, arrayIndex); return SetBufferViewArray(inputIndex, bufferViews, arrayIndex);
} }
bool ShaderResourceGroupData::SetBufferViewArray(ShaderInputBufferIndex inputIndex, AZStd::array_view<const BufferView*> bufferViews, uint32_t arrayIndex) bool ShaderResourceGroupData::SetBufferViewArray(ShaderInputBufferIndex inputIndex, AZStd::span<const BufferView* const> bufferViews, uint32_t arrayIndex)
{ {
if (GetLayout()->ValidateAccess(inputIndex, static_cast<uint32_t>(arrayIndex + bufferViews.size() - 1))) if (GetLayout()->ValidateAccess(inputIndex, static_cast<uint32_t>(arrayIndex + bufferViews.size() - 1)))
{ {
@@ -194,7 +194,7 @@ namespace AZ
return false; return false;
} }
bool ShaderResourceGroupData::SetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::array_view<const BufferView*> bufferViews) bool ShaderResourceGroupData::SetBufferViewUnboundedArray(ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::span<const BufferView* const> bufferViews)
{ {
if (GetLayout()->ValidateAccess(inputIndex)) if (GetLayout()->ValidateAccess(inputIndex))
{ {
@@ -221,10 +221,10 @@ namespace AZ
bool ShaderResourceGroupData::SetSampler(ShaderInputSamplerIndex inputIndex, const SamplerState& sampler, uint32_t arrayIndex) bool ShaderResourceGroupData::SetSampler(ShaderInputSamplerIndex inputIndex, const SamplerState& sampler, uint32_t arrayIndex)
{ {
return SetSamplerArray(inputIndex, AZStd::array_view<SamplerState>(&sampler, 1), arrayIndex); return SetSamplerArray(inputIndex, AZStd::span<const SamplerState>(&sampler, 1), arrayIndex);
} }
bool ShaderResourceGroupData::SetSamplerArray(ShaderInputSamplerIndex inputIndex, AZStd::array_view<SamplerState> samplers, uint32_t arrayIndex) bool ShaderResourceGroupData::SetSamplerArray(ShaderInputSamplerIndex inputIndex, AZStd::span<const SamplerState> samplers, uint32_t arrayIndex)
{ {
if (GetLayout()->ValidateAccess(inputIndex, static_cast<uint32_t>(arrayIndex + samplers.size() - 1))) if (GetLayout()->ValidateAccess(inputIndex, static_cast<uint32_t>(arrayIndex + samplers.size() - 1)))
{ {
@@ -241,7 +241,7 @@ namespace AZ
return true; return true;
} }
return false; return false;
} }
bool ShaderResourceGroupData::SetConstantRaw(ShaderInputConstantIndex inputIndex, const void* bytes, uint32_t byteCount) bool ShaderResourceGroupData::SetConstantRaw(ShaderInputConstantIndex inputIndex, const void* bytes, uint32_t byteCount)
{ {
@@ -265,7 +265,7 @@ namespace AZ
EnableResourceTypeCompilation(ResourceTypeMask::ConstantDataMask, ResourceType::ConstantData); EnableResourceTypeCompilation(ResourceTypeMask::ConstantDataMask, ResourceType::ConstantData);
return m_constantsData.SetConstantData(bytes, byteOffset, byteCount); return m_constantsData.SetConstantData(bytes, byteOffset, byteCount);
} }
const RHI::ConstPtr<RHI::ImageView>& ShaderResourceGroupData::GetImageView(RHI::ShaderInputImageIndex inputIndex, uint32_t arrayIndex) const const RHI::ConstPtr<RHI::ImageView>& ShaderResourceGroupData::GetImageView(RHI::ShaderInputImageIndex inputIndex, uint32_t arrayIndex) const
{ {
if (GetLayout()->ValidateAccess(inputIndex, arrayIndex)) if (GetLayout()->ValidateAccess(inputIndex, arrayIndex))
@@ -276,21 +276,21 @@ namespace AZ
return s_nullImageView; return s_nullImageView;
} }
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> ShaderResourceGroupData::GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const AZStd::span<const RHI::ConstPtr<RHI::ImageView>> ShaderResourceGroupData::GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const
{ {
if (GetLayout()->ValidateAccess(inputIndex, 0)) if (GetLayout()->ValidateAccess(inputIndex, 0))
{ {
const Interval interval = GetLayout()->GetGroupInterval(inputIndex); const Interval interval = GetLayout()->GetGroupInterval(inputIndex);
return AZStd::array_view<RHI::ConstPtr<RHI::ImageView>>(&m_imageViews[interval.m_min], interval.m_max - interval.m_min); return AZStd::span<const RHI::ConstPtr<RHI::ImageView>>(&m_imageViews[interval.m_min], interval.m_max - interval.m_min);
} }
return {}; return {};
} }
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> ShaderResourceGroupData::GetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex) const AZStd::span<const RHI::ConstPtr<RHI::ImageView>> ShaderResourceGroupData::GetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex) const
{ {
if (GetLayout()->ValidateAccess(inputIndex)) if (GetLayout()->ValidateAccess(inputIndex))
{ {
return AZStd::array_view<RHI::ConstPtr<RHI::ImageView>>(m_imageViewsUnboundedArray.data(), m_imageViewsUnboundedArray.size()); return AZStd::span<const RHI::ConstPtr<RHI::ImageView>>(m_imageViewsUnboundedArray.data(), m_imageViewsUnboundedArray.size());
} }
return {}; return {};
} }
@@ -305,21 +305,21 @@ namespace AZ
return s_nullBufferView; return s_nullBufferView;
} }
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> ShaderResourceGroupData::GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const AZStd::span<const RHI::ConstPtr<RHI::BufferView>> ShaderResourceGroupData::GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const
{ {
if (GetLayout()->ValidateAccess(inputIndex, 0)) if (GetLayout()->ValidateAccess(inputIndex, 0))
{ {
const Interval interval = GetLayout()->GetGroupInterval(inputIndex); const Interval interval = GetLayout()->GetGroupInterval(inputIndex);
return AZStd::array_view<RHI::ConstPtr<RHI::BufferView>>(&m_bufferViews[interval.m_min], interval.m_max - interval.m_min); return AZStd::span<const RHI::ConstPtr<RHI::BufferView>>(&m_bufferViews[interval.m_min], interval.m_max - interval.m_min);
} }
return {}; return {};
} }
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> ShaderResourceGroupData::GetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex) const AZStd::span<const RHI::ConstPtr<RHI::BufferView>> ShaderResourceGroupData::GetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex) const
{ {
if (GetLayout()->ValidateAccess(inputIndex)) if (GetLayout()->ValidateAccess(inputIndex))
{ {
return AZStd::array_view<RHI::ConstPtr<RHI::BufferView>>(m_bufferViewsUnboundedArray.data(), m_bufferViewsUnboundedArray.size()); return AZStd::span<const RHI::ConstPtr<RHI::BufferView>>(m_bufferViewsUnboundedArray.data(), m_bufferViewsUnboundedArray.size());
} }
return {}; return {};
} }
@@ -334,28 +334,28 @@ namespace AZ
return s_nullSamplerState; return s_nullSamplerState;
} }
AZStd::array_view<RHI::SamplerState> ShaderResourceGroupData::GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const AZStd::span<const RHI::SamplerState> ShaderResourceGroupData::GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const
{ {
const Interval interval = GetLayout()->GetGroupInterval(inputIndex); const Interval interval = GetLayout()->GetGroupInterval(inputIndex);
return AZStd::array_view<RHI::SamplerState>(&m_samplers[interval.m_min], interval.m_max - interval.m_min); return AZStd::span<const RHI::SamplerState>(&m_samplers[interval.m_min], interval.m_max - interval.m_min);
} }
AZStd::array_view<uint8_t> ShaderResourceGroupData::GetConstantRaw(ShaderInputConstantIndex inputIndex) const AZStd::span<const uint8_t> ShaderResourceGroupData::GetConstantRaw(ShaderInputConstantIndex inputIndex) const
{ {
return m_constantsData.GetConstantRaw(inputIndex); return m_constantsData.GetConstantRaw(inputIndex);
} }
AZStd::array_view<ConstPtr<ImageView>> ShaderResourceGroupData::GetImageGroup() const AZStd::span<const ConstPtr<ImageView>> ShaderResourceGroupData::GetImageGroup() const
{ {
return m_imageViews; return m_imageViews;
} }
AZStd::array_view<ConstPtr<BufferView>> ShaderResourceGroupData::GetBufferGroup() const AZStd::span<const ConstPtr<BufferView>> ShaderResourceGroupData::GetBufferGroup() const
{ {
return m_bufferViews; return m_bufferViews;
} }
AZStd::array_view<SamplerState> ShaderResourceGroupData::GetSamplerGroup() const AZStd::span<const SamplerState> ShaderResourceGroupData::GetSamplerGroup() const
{ {
return m_samplers; return m_samplers;
} }
@@ -368,7 +368,7 @@ namespace AZ
m_bufferViewsUnboundedArray.assign(m_bufferViewsUnboundedArray.size(), nullptr); m_bufferViewsUnboundedArray.assign(m_bufferViewsUnboundedArray.size(), nullptr);
} }
AZStd::array_view<uint8_t> ShaderResourceGroupData::GetConstantData() const AZStd::span<const uint8_t> ShaderResourceGroupData::GetConstantData() const
{ {
return m_constantsData.GetConstantData(); return m_constantsData.GetConstantData();
} }
@@ -202,8 +202,8 @@ namespace AZ
// Generate diffs for image views. // Generate diffs for image views.
if (HasImageGroup()) if (HasImageGroup())
{ {
AZStd::array_view<ConstPtr<ImageView>> viewGroupOld = shaderResourceGroup.GetData().GetImageGroup(); AZStd::span<const ConstPtr<ImageView>> viewGroupOld = shaderResourceGroup.GetData().GetImageGroup();
AZStd::array_view<ConstPtr<ImageView>> viewGroupNew = groupData.GetImageGroup(); AZStd::span<const ConstPtr<ImageView>> viewGroupNew = groupData.GetImageGroup();
AZ_Assert(viewGroupOld.size() == viewGroupNew.size(), "ShaderResourceGroupData layouts do not match."); AZ_Assert(viewGroupOld.size() == viewGroupNew.size(), "ShaderResourceGroupData layouts do not match.");
for (size_t i = 0; i < viewGroupOld.size(); ++i) for (size_t i = 0; i < viewGroupOld.size(); ++i)
{ {
@@ -214,8 +214,8 @@ namespace AZ
// Generate diffs for buffer views. // Generate diffs for buffer views.
if (HasBufferGroup()) if (HasBufferGroup())
{ {
AZStd::array_view<ConstPtr<BufferView>> viewGroupOld = shaderResourceGroup.GetData().GetBufferGroup(); AZStd::span<const ConstPtr<BufferView>> viewGroupOld = shaderResourceGroup.GetData().GetBufferGroup();
AZStd::array_view<ConstPtr<BufferView>> viewGroupNew = groupData.GetBufferGroup(); AZStd::span<const ConstPtr<BufferView>> viewGroupNew = groupData.GetBufferGroup();
AZ_Assert(viewGroupOld.size() == viewGroupNew.size(), "ShaderResourceGroupData layouts do not match."); AZ_Assert(viewGroupOld.size() == viewGroupNew.size(), "ShaderResourceGroupData layouts do not match.");
for (size_t i = 0; i < viewGroupOld.size(); ++i) for (size_t i = 0; i < viewGroupOld.size(); ++i)
{ {
@@ -56,7 +56,7 @@ namespace AZ
return m_byteStride; return m_byteStride;
} }
bool ValidateStreamBufferViews(const RHI::InputStreamLayout& inputStreamLayout, AZStd::array_view<RHI::StreamBufferView> streamBufferViews) bool ValidateStreamBufferViews(const RHI::InputStreamLayout& inputStreamLayout, AZStd::span<const RHI::StreamBufferView> streamBufferViews)
{ {
bool ok = true; bool ok = true;
@@ -14,7 +14,7 @@ namespace AZ
StreamingImageInitRequest::StreamingImageInitRequest( StreamingImageInitRequest::StreamingImageInitRequest(
Image& image, Image& image,
const ImageDescriptor& descriptor, const ImageDescriptor& descriptor,
AZStd::array_view<StreamingImageMipSlice> tailMipSlices) AZStd::span<const StreamingImageMipSlice> tailMipSlices)
: m_image{&image} : m_image{&image}
, m_descriptor{descriptor} , m_descriptor{descriptor}
, m_tailMipSlices{tailMipSlices} , m_tailMipSlices{tailMipSlices}
@@ -117,7 +117,7 @@ namespace AZ
return m_compileFlags; return m_compileFlags;
} }
void TransientAttachmentPool::CollectHeapStats(AliasedResourceTypeFlags typeMask, AZStd::array_view<TransientAttachmentStatistics::Heap> heapStats) void TransientAttachmentPool::CollectHeapStats(AliasedResourceTypeFlags typeMask, AZStd::span<const TransientAttachmentStatistics::Heap> heapStats)
{ {
// [GFX_TODO][ATOM-4162] Report the memory allocated stat correctly (or as close as possible) when the heap // [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. // supports multiple resource types. Right now we are assigning all the memory used to one resource type.
@@ -20,7 +20,7 @@ namespace UnitTest
{ {
protected: protected:
void ExpectEq(AZStd::array_view<StreamBufferDescriptor> expected, AZStd::array_view<StreamBufferDescriptor> actual) void ExpectEq(AZStd::span<const StreamBufferDescriptor> expected, AZStd::span<const StreamBufferDescriptor> actual)
{ {
EXPECT_EQ(expected.size(), actual.size()); EXPECT_EQ(expected.size(), actual.size());
for (int i = 0; i < expected.size() && i < actual.size(); ++i) for (int i = 0; i < expected.size() && i < actual.size(); ++i)
@@ -31,7 +31,7 @@ namespace UnitTest
} }
} }
void ExpectEq(AZStd::array_view<StreamChannelDescriptor> expected, AZStd::array_view<StreamChannelDescriptor> actual) void ExpectEq(AZStd::span<const StreamChannelDescriptor> expected, AZStd::span<const StreamChannelDescriptor> actual)
{ {
EXPECT_EQ(expected.size(), actual.size()); EXPECT_EQ(expected.size(), actual.size());
for (int i = 0; i < expected.size() && i < actual.size(); ++i) for (int i = 0; i < expected.size() && i < actual.size(); ++i)
+1 -1
View File
@@ -28,7 +28,7 @@ namespace UnitTest
{ {
} }
RHI::ResultCode PipelineLibrary::MergeIntoInternal([[maybe_unused]] AZStd::array_view<const RHI::PipelineLibrary*> libraries) RHI::ResultCode PipelineLibrary::MergeIntoInternal([[maybe_unused]] AZStd::span<const RHI::PipelineLibrary* const> libraries)
{ {
return RHI::ResultCode::Success; return RHI::ResultCode::Success;
} }
+1 -1
View File
@@ -25,7 +25,7 @@ namespace UnitTest
private: private:
AZ::RHI::ResultCode InitInternal(AZ::RHI::Device&, const AZ::RHI::PipelineLibraryData*) override { return AZ::RHI::ResultCode::Success; } AZ::RHI::ResultCode InitInternal(AZ::RHI::Device&, const AZ::RHI::PipelineLibraryData*) override { return AZ::RHI::ResultCode::Success; }
void ShutdownInternal() override; void ShutdownInternal() override;
AZ::RHI::ResultCode MergeIntoInternal(AZStd::array_view<const AZ::RHI::PipelineLibrary*>) override; AZ::RHI::ResultCode MergeIntoInternal(AZStd::span<const AZ::RHI::PipelineLibrary* const>) override;
AZ::RHI::ConstPtr<AZ::RHI::PipelineLibraryData> GetSerializedDataInternal() const override { return nullptr; } AZ::RHI::ConstPtr<AZ::RHI::PipelineLibraryData> GetSerializedDataInternal() const override { return nullptr; }
}; };
@@ -21,13 +21,13 @@ namespace UnitTest
protected: protected:
template<class T> template<class T>
void ExpectEqMemory(AZStd::array_view<T> expected, AZStd::array_view<T> actual) void ExpectEqMemory(AZStd::span<const T> expected, AZStd::span<const T> actual)
{ {
EXPECT_EQ(expected.size(), actual.size()); EXPECT_EQ(expected.size(), actual.size());
EXPECT_TRUE(memcmp(expected.data(), actual.data(), expected.size() * sizeof(T)) == 0); EXPECT_TRUE(memcmp(expected.data(), actual.data(), expected.size() * sizeof(T)) == 0);
} }
void ExpectEq(AZStd::array_view<SubpassRenderAttachmentLayout> expected, AZStd::array_view<SubpassRenderAttachmentLayout> actual) void ExpectEq(AZStd::span<const SubpassRenderAttachmentLayout> expected, AZStd::span<const SubpassRenderAttachmentLayout> actual)
{ {
EXPECT_EQ(expected.size(), actual.size()); EXPECT_EQ(expected.size(), actual.size());
for (int i = 0; i < expected.size() && i < actual.size(); ++i) for (int i = 0; i < expected.size() && i < actual.size(); ++i)
@@ -316,7 +316,7 @@ namespace UnitTest
const auto ValidateFloat4Values = [&]() const auto ValidateFloat4Values = [&]()
{ {
AZStd::array_view<float> float4ValueResult = srgData.GetConstantArray<float>(float4ValueIndex); AZStd::span<const float> float4ValueResult = srgData.GetConstantArray<float>(float4ValueIndex);
EXPECT_EQ(float4ValueResult.size(), 4); EXPECT_EQ(float4ValueResult.size(), 4);
EXPECT_EQ(float4ValueResult[0], float4Values[0]); EXPECT_EQ(float4ValueResult[0], float4Values[0]);
EXPECT_EQ(float4ValueResult[1], float4Values[1]); EXPECT_EQ(float4ValueResult[1], float4Values[1]);
@@ -324,13 +324,13 @@ namespace UnitTest
EXPECT_EQ(float4ValueResult[3], float4Values[3]); EXPECT_EQ(float4ValueResult[3], float4Values[3]);
}; };
AZStd::array_view<uint32_t> uintValuesResult = srgData.GetConstantArray<uint32_t>(uintValueIndex); AZStd::span<const uint32_t> uintValuesResult = srgData.GetConstantArray<uint32_t>(uintValueIndex);
EXPECT_EQ(uintValuesResult.size(), 3); EXPECT_EQ(uintValuesResult.size(), 3);
EXPECT_EQ(uintValuesResult[0], uintValues[0]); EXPECT_EQ(uintValuesResult[0], uintValues[0]);
EXPECT_EQ(uintValuesResult[1], uintValues[1]); EXPECT_EQ(uintValuesResult[1], uintValues[1]);
EXPECT_EQ(uintValuesResult[2], uintValues[2]); EXPECT_EQ(uintValuesResult[2], uintValues[2]);
AZStd::array_view<NestedData> nestedDataResult = srgData.GetConstantArray<NestedData>(nestedDataIndex); AZStd::span<const NestedData> nestedDataResult = srgData.GetConstantArray<NestedData>(nestedDataIndex);
EXPECT_EQ(nestedDataResult.size(), 16); EXPECT_EQ(nestedDataResult.size(), 16);
ValidateFloat4Values(); ValidateFloat4Values();
@@ -484,17 +484,17 @@ namespace UnitTest
const Vector4 vector4 = Vector4::CreateFromFloat4(vector4values); const Vector4 vector4 = Vector4::CreateFromFloat4(vector4values);
EXPECT_TRUE(srgData.SetConstant(vector2index, vector2)); EXPECT_TRUE(srgData.SetConstant(vector2index, vector2));
AZStd::array_view<uint8_t> resultVector2 = srgData.GetConstantRaw(vector2index); AZStd::span<const uint8_t> resultVector2 = srgData.GetConstantRaw(vector2index);
const Vector2 vector2result = *reinterpret_cast<const Vector2*>(resultVector2.data()); const Vector2 vector2result = *reinterpret_cast<const Vector2*>(resultVector2.data());
EXPECT_EQ(vector2result, vector2); EXPECT_EQ(vector2result, vector2);
EXPECT_TRUE(srgData.SetConstant(vector3index, vector3)); EXPECT_TRUE(srgData.SetConstant(vector3index, vector3));
AZStd::array_view<uint8_t> resutVector3 = srgData.GetConstantRaw(vector3index); AZStd::span<const uint8_t> resutVector3 = srgData.GetConstantRaw(vector3index);
const Vector3 vector3result = *reinterpret_cast<const Vector3*>(resutVector3.data()); const Vector3 vector3result = *reinterpret_cast<const Vector3*>(resutVector3.data());
EXPECT_EQ(vector3result, vector3); EXPECT_EQ(vector3result, vector3);
EXPECT_TRUE(srgData.SetConstant(vector4index, vector4)); EXPECT_TRUE(srgData.SetConstant(vector4index, vector4));
AZStd::array_view<uint8_t> resutVector4 = srgData.GetConstantRaw(vector4index); AZStd::span<const uint8_t> resutVector4 = srgData.GetConstantRaw(vector4index);
const Vector4 vector4result = *reinterpret_cast<const Vector4*>(resutVector4.data()); const Vector4 vector4result = *reinterpret_cast<const Vector4*>(resutVector4.data());
EXPECT_EQ(vector4result, vector4); EXPECT_EQ(vector4result, vector4);
} }
@@ -524,7 +524,7 @@ namespace UnitTest
AZ_TEST_START_ASSERTTEST; AZ_TEST_START_ASSERTTEST;
EXPECT_FALSE(srgData.SetConstant(vector2index, vector3)); EXPECT_FALSE(srgData.SetConstant(vector2index, vector3));
AZ_TEST_STOP_ASSERTTEST(1); AZ_TEST_STOP_ASSERTTEST(1);
AZStd::array_view<uint8_t> resutV3 = srgData.GetConstantRaw(vector2index); AZStd::span<const uint8_t> resutV3 = srgData.GetConstantRaw(vector2index);
const Vector3 v3result = *reinterpret_cast<const Vector3*>(resutV3.data()); const Vector3 v3result = *reinterpret_cast<const Vector3*>(resutV3.data());
EXPECT_NE(v3result, vector3); EXPECT_NE(v3result, vector3);
@@ -534,7 +534,7 @@ namespace UnitTest
AZ_TEST_START_ASSERTTEST; AZ_TEST_START_ASSERTTEST;
EXPECT_FALSE(srgData.SetConstant(vector3index, vector4)); EXPECT_FALSE(srgData.SetConstant(vector3index, vector4));
AZ_TEST_STOP_ASSERTTEST(1); AZ_TEST_STOP_ASSERTTEST(1);
AZStd::array_view<uint8_t> resutV4 = srgData.GetConstantRaw(vector3index); AZStd::span<const uint8_t> resutV4 = srgData.GetConstantRaw(vector3index);
const Vector4 v4result = *reinterpret_cast<const Vector4*>(resutV4.data()); const Vector4 v4result = *reinterpret_cast<const Vector4*>(resutV4.data());
EXPECT_NE(v4result, vector4); EXPECT_NE(v4result, vector4);
@@ -544,7 +544,7 @@ namespace UnitTest
AZ_TEST_START_ASSERTTEST; AZ_TEST_START_ASSERTTEST;
EXPECT_FALSE(srgData.SetConstant(vector4index, vector3)); EXPECT_FALSE(srgData.SetConstant(vector4index, vector3));
AZ_TEST_STOP_ASSERTTEST(1); AZ_TEST_STOP_ASSERTTEST(1);
AZStd::array_view<uint8_t> resutV3FromIndex4 = srgData.GetConstantRaw(vector4index); AZStd::span<const uint8_t> resutV3FromIndex4 = srgData.GetConstantRaw(vector4index);
const Vector4 v4resultFromIndex4 = *reinterpret_cast<const Vector4*>(resutV3FromIndex4.data()); const Vector4 v4resultFromIndex4 = *reinterpret_cast<const Vector4*>(resutV3FromIndex4.data());
EXPECT_NE(v4resultFromIndex4, vector4); EXPECT_NE(v4resultFromIndex4, vector4);
} }
@@ -8,7 +8,7 @@
#pragma once #pragma once
#include <Atom/RHI.Reflect/ShaderStageFunction.h> #include <Atom/RHI.Reflect/ShaderStageFunction.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/Memory/SystemAllocator.h> #include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/std/containers/array.h> #include <AzCore/std/containers/array.h>
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
@@ -19,7 +19,7 @@ namespace AZ
namespace DX12 namespace DX12
{ {
using ShaderByteCode = AZStd::vector<uint8_t>; using ShaderByteCode = AZStd::vector<uint8_t>;
using ShaderByteCodeView = AZStd::array_view<uint8_t>; using ShaderByteCodeView = AZStd::span<const uint8_t>;
/** /**
* A set of indices used to access physical sub-stages within a virtual stage. * A set of indices used to access physical sub-stages within a virtual stage.
@@ -9,7 +9,7 @@
#include <RHI/CommandQueue.h> #include <RHI/CommandQueue.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
namespace AZ namespace AZ
{ {
@@ -129,14 +129,14 @@ namespace AZ
const RHI::Viewport* viewports, const RHI::Viewport* viewports,
uint32_t count) uint32_t count)
{ {
m_state.m_viewportState.Set(AZStd::array_view<RHI::Viewport>(viewports, count)); m_state.m_viewportState.Set(AZStd::span<const RHI::Viewport>(viewports, count));
} }
void CommandList::SetScissors( void CommandList::SetScissors(
const RHI::Scissor* scissors, const RHI::Scissor* scissors,
uint32_t count) uint32_t count)
{ {
m_state.m_scissorState.Set(AZStd::array_view<RHI::Scissor>(scissors, count)); m_state.m_scissorState.Set(AZStd::span<const RHI::Scissor>(scissors, count));
} }
void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup) void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup)
@@ -18,7 +18,7 @@
#include <Atom/RHI/CommandListValidator.h> #include <Atom/RHI/CommandListValidator.h>
#include <Atom/RHI/CommandListStates.h> #include <Atom/RHI/CommandListStates.h>
#include <Atom/RHI/ObjectPool.h> #include <Atom/RHI/ObjectPool.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/Memory/SystemAllocator.h> #include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/std/containers/array.h> #include <AzCore/std/containers/array.h>
@@ -46,7 +46,7 @@ namespace AZ
ID3D12DeviceX* dx12Device = device.GetDevice(); ID3D12DeviceX* dx12Device = device.GetDevice();
#if defined (AZ_DX12_USE_PIPELINE_LIBRARY) #if defined (AZ_DX12_USE_PIPELINE_LIBRARY)
AZStd::array_view<uint8_t> bytes; AZStd::span<const uint8_t> bytes;
bool shouldCreateLibFromSerializedData = true; bool shouldCreateLibFromSerializedData = true;
if (RHI::Factory::Get().IsRenderDocModuleLoaded() || if (RHI::Factory::Get().IsRenderDocModuleLoaded() ||
@@ -214,7 +214,7 @@ namespace AZ
#endif #endif
} }
RHI::ResultCode PipelineLibrary::MergeIntoInternal([[maybe_unused]] AZStd::array_view<const RHI::PipelineLibrary*> pipelineLibraries) RHI::ResultCode PipelineLibrary::MergeIntoInternal([[maybe_unused]] AZStd::span<const RHI::PipelineLibrary* const> pipelineLibraries)
{ {
if (RHI::Factory::Get().IsRenderDocModuleLoaded() || if (RHI::Factory::Get().IsRenderDocModuleLoaded() ||
RHI::Factory::Get().IsPixModuleLoaded()) RHI::Factory::Get().IsPixModuleLoaded())
@@ -239,14 +239,14 @@ namespace AZ
} }
} }
#endif #endif
return RHI::ResultCode::Success; return RHI::ResultCode::Success;
} }
RHI::ConstPtr<RHI::PipelineLibraryData> PipelineLibrary::GetSerializedDataInternal() const RHI::ConstPtr<RHI::PipelineLibraryData> PipelineLibrary::GetSerializedDataInternal() const
{ {
#if defined (AZ_DX12_USE_PIPELINE_LIBRARY) #if defined (AZ_DX12_USE_PIPELINE_LIBRARY)
AZStd::lock_guard<AZStd::mutex> lock(m_mutex); AZStd::lock_guard<AZStd::mutex> lock(m_mutex);
AZStd::vector<uint8_t> serializedData(m_library->GetSerializedSize()); AZStd::vector<uint8_t> serializedData(m_library->GetSerializedSize());
HRESULT hr = m_library->Serialize(serializedData.data(), serializedData.size()); HRESULT hr = m_library->Serialize(serializedData.data(), serializedData.size());
@@ -33,7 +33,7 @@ namespace AZ
// RHI::PipelineLibrary // RHI::PipelineLibrary
RHI::ResultCode InitInternal(RHI::Device& device, const RHI::PipelineLibraryData* serializedData) override; RHI::ResultCode InitInternal(RHI::Device& device, const RHI::PipelineLibraryData* serializedData) override;
void ShutdownInternal() override; void ShutdownInternal() override;
RHI::ResultCode MergeIntoInternal(AZStd::array_view<const RHI::PipelineLibrary*> libraries) override; RHI::ResultCode MergeIntoInternal(AZStd::span<const RHI::PipelineLibrary* const> libraries) override;
RHI::ConstPtr<RHI::PipelineLibraryData> GetSerializedDataInternal() const override; RHI::ConstPtr<RHI::PipelineLibraryData> GetSerializedDataInternal() const override;
bool IsMergeRequired() const; bool IsMergeRequired() const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -20,7 +20,7 @@ namespace AZ
namespace DX12 namespace DX12
{ {
template<typename T, typename U> template<typename T, typename U>
AZStd::vector<DescriptorHandle> ShaderResourceGroupPool::GetSRVsFromImageViews(const AZStd::array_view<RHI::ConstPtr<T>>& imageViews, D3D12_SRV_DIMENSION dimension) AZStd::vector<DescriptorHandle> ShaderResourceGroupPool::GetSRVsFromImageViews(const AZStd::span<const RHI::ConstPtr<T>>& imageViews, D3D12_SRV_DIMENSION dimension)
{ {
AZStd::vector<DescriptorHandle> cpuSourceDescriptors(imageViews.size(), m_descriptorContext->GetNullHandleSRV(dimension)); AZStd::vector<DescriptorHandle> cpuSourceDescriptors(imageViews.size(), m_descriptorContext->GetNullHandleSRV(dimension));
@@ -36,7 +36,7 @@ namespace AZ
} }
template<typename T, typename U> template<typename T, typename U>
AZStd::vector<DescriptorHandle> ShaderResourceGroupPool::GetUAVsFromImageViews(const AZStd::array_view<RHI::ConstPtr<T>>& imageViews, D3D12_UAV_DIMENSION dimension) AZStd::vector<DescriptorHandle> ShaderResourceGroupPool::GetUAVsFromImageViews(const AZStd::span<const RHI::ConstPtr<T>>& imageViews, D3D12_UAV_DIMENSION dimension)
{ {
AZStd::vector<DescriptorHandle> cpuSourceDescriptors(imageViews.size(), m_descriptorContext->GetNullHandleUAV(dimension)); AZStd::vector<DescriptorHandle> cpuSourceDescriptors(imageViews.size(), m_descriptorContext->GetNullHandleUAV(dimension));
for (size_t i = 0; i < cpuSourceDescriptors.size(); ++i) for (size_t i = 0; i < cpuSourceDescriptors.size(); ++i)
@@ -50,7 +50,7 @@ namespace AZ
return cpuSourceDescriptors; return cpuSourceDescriptors;
} }
AZStd::vector<DescriptorHandle> ShaderResourceGroupPool::GetCBVsFromBufferViews(const AZStd::array_view<RHI::ConstPtr<RHI::BufferView>>& bufferViews) AZStd::vector<DescriptorHandle> ShaderResourceGroupPool::GetCBVsFromBufferViews(const AZStd::span<const RHI::ConstPtr<RHI::BufferView>>& bufferViews)
{ {
AZStd::vector<DescriptorHandle> cpuSourceDescriptors(bufferViews.size(), m_descriptorContext->GetNullHandleCBV()); AZStd::vector<DescriptorHandle> cpuSourceDescriptors(bufferViews.size(), m_descriptorContext->GetNullHandleCBV());
@@ -278,7 +278,7 @@ namespace AZ
{ {
const RHI::ShaderInputBufferIndex bufferInputIndex(shaderInputIndex); const RHI::ShaderInputBufferIndex bufferInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> bufferViews = groupData.GetBufferViewArray(bufferInputIndex); AZStd::span<const RHI::ConstPtr<RHI::BufferView>> bufferViews = groupData.GetBufferViewArray(bufferInputIndex);
D3D12_DESCRIPTOR_RANGE_TYPE descriptorRangeType = ConvertShaderInputBufferAccess(shaderInputBuffer.m_access); D3D12_DESCRIPTOR_RANGE_TYPE descriptorRangeType = ConvertShaderInputBufferAccess(shaderInputBuffer.m_access);
AZStd::vector<DescriptorHandle> descriptorHandles; AZStd::vector<DescriptorHandle> descriptorHandles;
switch (descriptorRangeType) switch (descriptorRangeType)
@@ -313,7 +313,7 @@ namespace AZ
{ {
const RHI::ShaderInputImageIndex imageInputIndex(shaderInputIndex); const RHI::ShaderInputImageIndex imageInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> imageViews = groupData.GetImageViewArray(imageInputIndex); AZStd::span<const RHI::ConstPtr<RHI::ImageView>> imageViews = groupData.GetImageViewArray(imageInputIndex);
D3D12_DESCRIPTOR_RANGE_TYPE descriptorRangeType = ConvertShaderInputImageAccess(shaderInputImage.m_access); D3D12_DESCRIPTOR_RANGE_TYPE descriptorRangeType = ConvertShaderInputImageAccess(shaderInputImage.m_access);
AZStd::vector<DescriptorHandle> descriptorHandles; AZStd::vector<DescriptorHandle> descriptorHandles;
@@ -349,7 +349,7 @@ namespace AZ
{ {
const RHI::ShaderInputSamplerIndex samplerInputIndex(shaderInputIndex); const RHI::ShaderInputSamplerIndex samplerInputIndex(shaderInputIndex);
AZStd::array_view<RHI::SamplerState> samplers = groupData.GetSamplerArray(samplerInputIndex); AZStd::span<const RHI::SamplerState> samplers = groupData.GetSamplerArray(samplerInputIndex);
UpdateDescriptorTableRange(descriptorTable, samplerInputIndex, samplers); UpdateDescriptorTableRange(descriptorTable, samplerInputIndex, samplers);
} }
} }
@@ -364,7 +364,7 @@ namespace AZ
for (const RHI::ShaderInputBufferUnboundedArrayDescriptor& shaderInputBufferUnboundedArray : groupLayout.GetShaderInputListForBufferUnboundedArrays()) for (const RHI::ShaderInputBufferUnboundedArrayDescriptor& shaderInputBufferUnboundedArray : groupLayout.GetShaderInputListForBufferUnboundedArrays())
{ {
const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex); const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex); AZStd::span<const RHI::ConstPtr<RHI::BufferView>> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex);
uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex; uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex;
@@ -403,7 +403,7 @@ namespace AZ
for (const RHI::ShaderInputImageUnboundedArrayDescriptor& shaderInputImageUnboundedArray : groupLayout.GetShaderInputListForImageUnboundedArrays()) for (const RHI::ShaderInputImageUnboundedArrayDescriptor& shaderInputImageUnboundedArray : groupLayout.GetShaderInputListForImageUnboundedArrays())
{ {
const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex); const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> imageViews = groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex); AZStd::span<const RHI::ConstPtr<RHI::ImageView>> imageViews = groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex);
uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex; uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex;
@@ -447,7 +447,7 @@ namespace AZ
RHI::ShaderInputBufferAccess bufferAccess) RHI::ShaderInputBufferAccess bufferAccess)
{ {
const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex); const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> bufferViews = AZStd::span<const RHI::ConstPtr<RHI::BufferView>> bufferViews =
groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex); groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex);
if (bufferViews.empty()) if (bufferViews.empty())
@@ -488,7 +488,7 @@ namespace AZ
RHI::ShaderInputImageType imageType) RHI::ShaderInputImageType imageType)
{ {
const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex); const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> imageViews = AZStd::span<const RHI::ConstPtr<RHI::ImageView>> imageViews =
groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex); groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex);
if (imageViews.empty()) if (imageViews.empty())
@@ -565,7 +565,7 @@ namespace AZ
for (const RHI::ShaderInputBufferUnboundedArrayDescriptor& shaderInputBufferUnboundedArray : groupLayout.GetShaderInputListForBufferUnboundedArrays()) for (const RHI::ShaderInputBufferUnboundedArrayDescriptor& shaderInputBufferUnboundedArray : groupLayout.GetShaderInputListForBufferUnboundedArrays())
{ {
const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex); const RHI::ShaderInputBufferUnboundedArrayIndex bufferUnboundedArrayInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex); AZStd::span<const RHI::ConstPtr<RHI::BufferView>> bufferViews = groupData.GetBufferViewUnboundedArray(bufferUnboundedArrayInputIndex);
uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex; uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex;
if (!bufferViews.empty()) if (!bufferViews.empty())
@@ -597,7 +597,7 @@ namespace AZ
groupLayout.GetShaderInputListForImageUnboundedArrays()) groupLayout.GetShaderInputListForImageUnboundedArrays())
{ {
const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex); const RHI::ShaderInputImageUnboundedArrayIndex imageUnboundedArrayInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> imageViews = AZStd::span<const RHI::ConstPtr<RHI::ImageView>> imageViews =
groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex); groupData.GetImageViewUnboundedArray(imageUnboundedArrayInputIndex);
uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex; uint32_t tableIndex = shaderInputIndex * RHI::Limits::Device::FrameCountMax + group.m_compiledDataIndex;
@@ -675,7 +675,7 @@ namespace AZ
void ShaderResourceGroupPool::UpdateDescriptorTableRange( void ShaderResourceGroupPool::UpdateDescriptorTableRange(
DescriptorTable descriptorTable, DescriptorTable descriptorTable,
RHI::ShaderInputSamplerIndex samplerInputIndex, RHI::ShaderInputSamplerIndex samplerInputIndex,
AZStd::array_view<RHI::SamplerState> samplerStates) AZStd::span<const RHI::SamplerState> samplerStates)
{ {
const DescriptorHandle nullHandle = m_descriptorContext->GetNullHandleSampler(); const DescriptorHandle nullHandle = m_descriptorContext->GetNullHandleSampler();
AZStd::vector<DescriptorHandle> cpuSourceDescriptors(aznumeric_caster(samplerStates.size()), nullHandle); AZStd::vector<DescriptorHandle> cpuSourceDescriptors(aznumeric_caster(samplerStates.size()), nullHandle);
@@ -82,7 +82,7 @@ namespace AZ
void UpdateDescriptorTableRange( void UpdateDescriptorTableRange(
DescriptorTable descriptorTable, DescriptorTable descriptorTable,
RHI::ShaderInputSamplerIndex samplerIndex, RHI::ShaderInputSamplerIndex samplerIndex,
AZStd::array_view<RHI::SamplerState> samplerStates); AZStd::span<const RHI::SamplerState> samplerStates);
//Cache all the gpu handles for the Descriptor tables related to all the views //Cache all the gpu handles for the Descriptor tables related to all the views
void CacheGpuHandlesForViews(ShaderResourceGroup& group); void CacheGpuHandlesForViews(ShaderResourceGroup& group);
@@ -93,12 +93,12 @@ namespace AZ
DescriptorTable GetSamplerTable(DescriptorTable descriptorTable, RHI::ShaderInputSamplerIndex samplerInputIndex) const; DescriptorTable GetSamplerTable(DescriptorTable descriptorTable, RHI::ShaderInputSamplerIndex samplerInputIndex) const;
template<typename T, typename U> template<typename T, typename U>
AZStd::vector<DescriptorHandle> GetSRVsFromImageViews(const AZStd::array_view<RHI::ConstPtr<T>>& imageViews, D3D12_SRV_DIMENSION dimension); AZStd::vector<DescriptorHandle> GetSRVsFromImageViews(const AZStd::span<const RHI::ConstPtr<T>>& imageViews, D3D12_SRV_DIMENSION dimension);
template<typename T, typename U> template<typename T, typename U>
AZStd::vector<DescriptorHandle> GetUAVsFromImageViews(const AZStd::array_view<RHI::ConstPtr<T>>& bufferViews, D3D12_UAV_DIMENSION dimension); AZStd::vector<DescriptorHandle> GetUAVsFromImageViews(const AZStd::span<const RHI::ConstPtr<T>>& bufferViews, D3D12_UAV_DIMENSION dimension);
AZStd::vector<DescriptorHandle> GetCBVsFromBufferViews(const AZStd::array_view<RHI::ConstPtr<RHI::BufferView>>& bufferViews); AZStd::vector<DescriptorHandle> GetCBVsFromBufferViews(const AZStd::span<const RHI::ConstPtr<RHI::BufferView>>& bufferViews);
MemoryPoolSubAllocator m_constantAllocator; MemoryPoolSubAllocator m_constantAllocator;
DescriptorContext* m_descriptorContext = nullptr; DescriptorContext* m_descriptorContext = nullptr;
@@ -9,7 +9,7 @@
#include <Atom/RHI.Reflect/Metal/Base.h> #include <Atom/RHI.Reflect/Metal/Base.h>
#include <Atom/RHI.Reflect/ShaderStageFunction.h> #include <Atom/RHI.Reflect/ShaderStageFunction.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/Memory/SystemAllocator.h> #include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/std/containers/array.h> #include <AzCore/std/containers/array.h>
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
@@ -53,7 +53,7 @@ namespace AZ
{ {
return AZ::Metal::PipelineLayoutDescriptor::Create(); return AZ::Metal::PipelineLayoutDescriptor::Create();
} }
bool ShaderPlatformInterface::BuildPipelineLayoutDescriptor( bool ShaderPlatformInterface::BuildPipelineLayoutDescriptor(
RHI::Ptr<RHI::PipelineLayoutDescriptor> pipelineLayoutDescriptor, RHI::Ptr<RHI::PipelineLayoutDescriptor> pipelineLayoutDescriptor,
const ShaderResourceGroupInfoList& srgInfoList, const ShaderResourceGroupInfoList& srgInfoList,
@@ -62,10 +62,10 @@ namespace AZ
{ {
AZ::Metal::PipelineLayoutDescriptor* metalDescriptor = azrtti_cast<AZ::Metal::PipelineLayoutDescriptor*>(pipelineLayoutDescriptor.get()); AZ::Metal::PipelineLayoutDescriptor* metalDescriptor = azrtti_cast<AZ::Metal::PipelineLayoutDescriptor*>(pipelineLayoutDescriptor.get());
AZ_Assert(metalDescriptor, "PipelineLayoutDescriptor should have been created by now"); AZ_Assert(metalDescriptor, "PipelineLayoutDescriptor should have been created by now");
const uint32_t groupLayoutCount = static_cast<uint32_t>(srgInfoList.size()); const uint32_t groupLayoutCount = static_cast<uint32_t>(srgInfoList.size());
AZ_Assert(groupLayoutCount <= RHI::Limits::Pipeline::ShaderResourceGroupCountMax, "Exceeded ShaderResourceGroupLayout count limit."); AZ_Assert(groupLayoutCount <= RHI::Limits::Pipeline::ShaderResourceGroupCountMax, "Exceeded ShaderResourceGroupLayout count limit.");
// Slot to index mapping // Slot to index mapping
AZ::Metal::SlotToIndexTable slotToIndexTable; AZ::Metal::SlotToIndexTable slotToIndexTable;
AZ::Metal::IndexToSlotTable indexToSlotTable; AZ::Metal::IndexToSlotTable indexToSlotTable;
@@ -81,17 +81,17 @@ namespace AZ
{ {
return first.m_layout->GetBindingSlot() < second.m_layout->GetBindingSlot(); return first.m_layout->GetBindingSlot() < second.m_layout->GetBindingSlot();
}); });
for (uint32_t groupLayoutIndex = 0; groupLayoutIndex < groupLayoutCount; ++groupLayoutIndex) for (uint32_t groupLayoutIndex = 0; groupLayoutIndex < groupLayoutCount; ++groupLayoutIndex)
{ {
const auto& srgInfo = sortedSrgInfos[groupLayoutIndex]; const auto& srgInfo = sortedSrgInfos[groupLayoutIndex];
const RHI::ShaderResourceGroupLayout& groupLayout = *srgInfo.m_layout; const RHI::ShaderResourceGroupLayout& groupLayout = *srgInfo.m_layout;
const uint32_t srgLayoutSlot = groupLayout.GetBindingSlot(); const uint32_t srgLayoutSlot = groupLayout.GetBindingSlot();
AZ_Assert(srgLayoutSlot <= RHI::Limits::Pipeline::ShaderResourceGroupCountMax, "Cannot exceed the array limit"); AZ_Assert(srgLayoutSlot <= RHI::Limits::Pipeline::ShaderResourceGroupCountMax, "Cannot exceed the array limit");
slotToIndexTable[srgLayoutSlot] = groupLayoutIndex; slotToIndexTable[srgLayoutSlot] = groupLayoutIndex;
indexToSlotTable[groupLayoutIndex] = srgLayoutSlot; indexToSlotTable[groupLayoutIndex] = srgLayoutSlot;
ShaderResourceGroupVisibility srgVisibility; ShaderResourceGroupVisibility srgVisibility;
for (const auto& resourceBindInfo : srgInfo.m_bindingInfo.m_resourcesRegisterMap) 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; srgVisibility.m_constantDataStageMask = srgInfo.m_bindingInfo.m_constantDataBindingInfo.m_shaderStageMask;
metalDescriptor->AddShaderResourceGroupVisibility(srgVisibility); metalDescriptor->AddShaderResourceGroupVisibility(srgVisibility);
//cache the layout in order to fill out unused variables //cache the layout in order to fill out unused variables
m_srgLayouts[groupLayoutIndex] = srgInfo.m_layout; m_srgLayouts[groupLayoutIndex] = srgInfo.m_layout;
} }
if (rootConstantsInfo.m_totalSizeInBytes > 0) if (rootConstantsInfo.m_totalSizeInBytes > 0)
{ {
metalDescriptor->SetRootConstantBinding(RootConstantBinding{ rootConstantsInfo.m_registerId, rootConstantsInfo.m_spaceId }); metalDescriptor->SetRootConstantBinding(RootConstantBinding{ rootConstantsInfo.m_registerId, rootConstantsInfo.m_spaceId });
} }
metalDescriptor->SetBindingTables(slotToIndexTable, indexToSlotTable); metalDescriptor->SetBindingTables(slotToIndexTable, indexToSlotTable);
return metalDescriptor->Finalize() == RHI::ResultCode::Success; return metalDescriptor->Finalize() == RHI::ResultCode::Success;
} }
RHI::Ptr<RHI::ShaderStageFunction> ShaderPlatformInterface::CreateShaderStageFunction(const StageDescriptor& stageDescriptor) RHI::Ptr<RHI::ShaderStageFunction> ShaderPlatformInterface::CreateShaderStageFunction(const StageDescriptor& stageDescriptor)
{ {
RHI::Ptr<ShaderStageFunction> newShaderStageFunction = ShaderStageFunction::Create(RHI::ToRHIShaderStage(stageDescriptor.m_stageType)); RHI::Ptr<ShaderStageFunction> newShaderStageFunction = ShaderStageFunction::Create(RHI::ToRHIShaderStage(stageDescriptor.m_stageType));
const Metal::ShaderSourceCode& sourceCode = stageDescriptor.m_sourceCode; 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 //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; const AZStd::string& entryFunctionName = stageDescriptor.m_entryFunctionName;
newShaderStageFunction->SetByteCode(byteCode); newShaderStageFunction->SetByteCode(byteCode);
newShaderStageFunction->SetEntryFunctionName(entryFunctionName); newShaderStageFunction->SetEntryFunctionName(entryFunctionName);
newShaderStageFunction->Finalize(); newShaderStageFunction->Finalize();
return newShaderStageFunction; return newShaderStageFunction;
} }
@@ -159,7 +159,7 @@ namespace AZ
return shaderCompilerArguments.MakeAdditionalAzslcCommandLineString() + return shaderCompilerArguments.MakeAdditionalAzslcCommandLineString() +
" --use-spaces --unique-idx --namespace=mt,vk --root-const=128 --pad-root-const"; " --use-spaces --unique-idx --namespace=mt,vk --root-const=128 --pad-root-const";
} }
AZStd::string ShaderPlatformInterface::GetAzslCompilerWarningParameters(const RHI::ShaderCompilerArguments& shaderCompilerArguments) const AZStd::string ShaderPlatformInterface::GetAzslCompilerWarningParameters(const RHI::ShaderCompilerArguments& shaderCompilerArguments) const
{ {
return shaderCompilerArguments.MakeAdditionalAzslcWarningCommandLineString(); return shaderCompilerArguments.MakeAdditionalAzslcWarningCommandLineString();
@@ -255,7 +255,7 @@ namespace AZ
// Stage profile name parameter // Stage profile name parameter
const AZStd::string shaderModelVersion = "6_2"; const AZStd::string shaderModelVersion = "6_2";
const AZStd::unordered_map<RHI::ShaderHardwareStage, AZStd::string> stageToProfileName = const AZStd::unordered_map<RHI::ShaderHardwareStage, AZStd::string> stageToProfileName =
{ {
{RHI::ShaderHardwareStage::Vertex, "vs_" + shaderModelVersion}, {RHI::ShaderHardwareStage::Vertex, "vs_" + shaderModelVersion},
@@ -268,15 +268,15 @@ namespace AZ
AZ_Error(MetalShaderPlatformName, false, "Unsupported shader stage"); AZ_Error(MetalShaderPlatformName, false, "Unsupported shader stage");
return false; return false;
} }
// For this approach we will be doing hlsl->spirv(through dxc) and spirv->metalSL(through spirv cross) // For this approach we will be doing hlsl->spirv(through dxc) and spirv->metalSL(through spirv cross)
// Output spirv file // Output spirv file
AZStd::string shaderSpirvOutputFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "spirv"); AZStd::string shaderSpirvOutputFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "spirv");
// Compilation parameters // Compilation parameters
AZStd::string params = shaderCompilerArguments.MakeAdditionalDxcCommandLineString(); AZStd::string params = shaderCompilerArguments.MakeAdditionalDxcCommandLineString();
params += " -spirv"; // Generate SPIRV shader params += " -spirv"; // Generate SPIRV shader
// Enable half precision types when shader model >= 6.2 // Enable half precision types when shader model >= 6.2
int shaderModelMajor = 0; int shaderModelMajor = 0;
int shaderModelMinor = 0; int shaderModelMinor = 0;
@@ -318,7 +318,7 @@ namespace AZ
params.c_str(), // 3 params.c_str(), // 3
shaderSpirvOutputFile.c_str(), // 4 shaderSpirvOutputFile.c_str(), // 4
dxcInputFile.c_str()); // 5 dxcInputFile.c_str()); // 5
// Run dxc Compiler // Run dxc Compiler
if (!RHI::ExecuteShaderCompiler(dxcRelativePath, dxcCommandOptions, shaderSourceFile, "DXC")) if (!RHI::ExecuteShaderCompiler(dxcRelativePath, dxcCommandOptions, shaderSourceFile, "DXC"))
{ {
@@ -329,9 +329,9 @@ namespace AZ
{ {
byProducts.m_intermediatePaths.insert(shaderSpirvOutputFile); // the spirv spit by DXC byProducts.m_intermediatePaths.insert(shaderSpirvOutputFile); // the spirv spit by DXC
} }
IO::FileIOStream spirvOutFileStream(shaderSpirvOutputFile.data(), AZ::IO::OpenMode::ModeRead | AZ::IO::OpenMode::ModeBinary); IO::FileIOStream spirvOutFileStream(shaderSpirvOutputFile.data(), AZ::IO::OpenMode::ModeRead | AZ::IO::OpenMode::ModeBinary);
if (!spirvOutFileStream.IsOpen()) if (!spirvOutFileStream.IsOpen())
{ {
AZ_Error(MetalShaderPlatformName, false, "Failed because the shader file \"%s\" could not be opened", shaderSpirvOutputFile.data()); AZ_Error(MetalShaderPlatformName, false, "Failed because the shader file \"%s\" could not be opened", shaderSpirvOutputFile.data());
@@ -343,12 +343,12 @@ namespace AZ
spirvOutFileStream.Close(); spirvOutFileStream.Close();
return false; return false;
} }
// spirv cross compiler executable // spirv cross compiler executable
static const char* spirvCrossRelativePath = "Builders/SPIRVCross/spirv-cross"; 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()); 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 // Run spirv cross
if (!RHI::ExecuteShaderCompiler(spirvCrossRelativePath, spirvCrossCommandOptions, shaderSpirvOutputFile, "SpirvCross")) if (!RHI::ExecuteShaderCompiler(spirvCrossRelativePath, spirvCrossCommandOptions, shaderSpirvOutputFile, "SpirvCross"))
{ {
@@ -357,7 +357,7 @@ namespace AZ
return false; return false;
} }
spirvOutFileStream.Close(); spirvOutFileStream.Close();
IO::FileIOStream outFileStream(shaderMSLOutputFile.data(), IO::OpenMode::ModeRead); IO::FileIOStream outFileStream(shaderMSLOutputFile.data(), IO::OpenMode::ModeRead);
bool finalizeShaderResult = UpdateCompiledShader(outFileStream, MetalShaderPlatformName, shaderMSLOutputFile.data(), sourceMetalShader); 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()); 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 byProducts.m_intermediatePaths.emplace(AZStd::move(shaderMSLOutputFile)); // .msl metal out of sv-cross
} }
bool compileMetalSL = CreateMetalLib(MetalShaderPlatformName, shaderSourceFile, tempFolder, compiledByteCode, sourceMetalShader, platform); bool compileMetalSL = CreateMetalLib(MetalShaderPlatformName, shaderSourceFile, tempFolder, compiledByteCode, sourceMetalShader, platform);
if (!compileMetalSL) if (!compileMetalSL)
{ {
@@ -376,7 +376,7 @@ namespace AZ
return finalizeShaderResult; return finalizeShaderResult;
} }
bool ShaderPlatformInterface::UpdateCompiledShader(AZ::IO::FileIOStream& fileStream, const char* platformName, const char* fileName, AZStd::vector<char>& compiledShader) const bool ShaderPlatformInterface::UpdateCompiledShader(AZ::IO::FileIOStream& fileStream, const char* platformName, const char* fileName, AZStd::vector<char>& compiledShader) const
{ {
if (!fileStream.IsOpen()) if (!fileStream.IsOpen())
@@ -390,16 +390,16 @@ namespace AZ
fileStream.Close(); fileStream.Close();
return false; return false;
} }
compiledShader.resize(fileStream.GetLength() + 1); // +1 to add end of string compiledShader.resize(fileStream.GetLength() + 1); // +1 to add end of string
memset(compiledShader.data(), 0, fileStream.GetLength() + 1); memset(compiledShader.data(), 0, fileStream.GetLength() + 1);
fileStream.Read(fileStream.GetLength(), compiledShader.data()); fileStream.Read(fileStream.GetLength(), compiledShader.data());
fileStream.Close(); fileStream.Close();
//Ensure that the argument buffer declaration in the shader matches the srg layout //Ensure that the argument buffer declaration in the shader matches the srg layout
return AddUnusedResources(compiledShader); return AddUnusedResources(compiledShader);
} }
bool ShaderPlatformInterface::CreateMetalLib(const char* platformName, bool ShaderPlatformInterface::CreateMetalLib(const char* platformName,
const AZStd::string& shaderSourceFile, const AZStd::string& shaderSourceFile,
const AZStd::string& tempFolder, const AZStd::string& tempFolder,
@@ -408,22 +408,22 @@ namespace AZ
const AssetBuilderSDK::PlatformInfo& platform) const const AssetBuilderSDK::PlatformInfo& platform) const
{ {
AZStd::string inputMetalFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "metal"); AZStd::string inputMetalFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "metal");
AZ::IO::FileIOStream sourceMtlfileStream(inputMetalFile.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary); AZ::IO::FileIOStream sourceMtlfileStream(inputMetalFile.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary);
if (!sourceMtlfileStream.IsOpen()) if (!sourceMtlfileStream.IsOpen())
{ {
AZ_Error(platformName, false, "Failed because the shader file \"%s\" could not be opened", inputMetalFile.c_str()); AZ_Error(platformName, false, "Failed because the shader file \"%s\" could not be opened", inputMetalFile.c_str());
return false; return false;
} }
AZStd::string mtlSource = AZStd::string(sourceMetalShader.begin(), sourceMetalShader.end()); AZStd::string mtlSource = AZStd::string(sourceMetalShader.begin(), sourceMetalShader.end());
sourceMtlfileStream.Write(mtlSource.size(), mtlSource.data()); sourceMtlfileStream.Write(mtlSource.size(), mtlSource.data());
sourceMtlfileStream.Close(); sourceMtlfileStream.Close();
AZStd::string outputAirFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "air"); AZStd::string outputAirFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "air");
AZStd::string outMetalLibFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "metallib"); 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 shaderDebugInfo = "-gline-tables-only -MO";
AZStd::string shaderMslToAirOptions = "-fpreserve-invariance"; AZStd::string shaderMslToAirOptions = "-fpreserve-invariance";
@@ -434,47 +434,47 @@ namespace AZ
{ {
platformSdk = "iphoneos"; platformSdk = "iphoneos";
} }
//Convert to air file //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()); 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")) if (!RHI::ExecuteShaderCompiler("/usr/bin/xcrun", mslToAirCommandOptions, inputMetalFile, "MslToAir"))
{ {
AZ_Error(MetalShaderPlatformName, false, "Failed to convert to AIR file %s", inputMetalFile.c_str()); AZ_Error(MetalShaderPlatformName, false, "Failed to convert to AIR file %s", inputMetalFile.c_str());
return false; return false;
} }
//convert to metallib //convert to metallib
AZStd::string airToMetalLibCommandOptions = AZStd::string::format("-sdk %s metallib \"%s\" -o \"%s\"", platformSdk.c_str(), outputAirFile.c_str(), outMetalLibFile.c_str()); 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")) if (!RHI::ExecuteShaderCompiler("/usr/bin/xcrun", airToMetalLibCommandOptions, outputAirFile, "AirToMetallib"))
{ {
AZ_Error(MetalShaderPlatformName, false, "Failed to convert to metallib file"); AZ_Error(MetalShaderPlatformName, false, "Failed to convert to metallib file");
return false; return false;
} }
AZ::IO::FileIOStream fileStream(outMetalLibFile.data(), AZ::IO::OpenMode::ModeRead); AZ::IO::FileIOStream fileStream(outMetalLibFile.data(), AZ::IO::OpenMode::ModeRead);
compiledByteCode.resize(fileStream.GetLength()); compiledByteCode.resize(fileStream.GetLength());
memset(compiledByteCode.data(), 0, fileStream.GetLength() ); memset(compiledByteCode.data(), 0, fileStream.GetLength() );
fileStream.Read(fileStream.GetLength(), compiledByteCode.data()); fileStream.Read(fileStream.GetLength(), compiledByteCode.data());
fileStream.Close(); fileStream.Close();
return true; return true;
} }
bool ShaderPlatformInterface::AddUnusedResources(AZStd::vector<char>& compiledShader) const bool ShaderPlatformInterface::AddUnusedResources(AZStd::vector<char>& compiledShader) const
{ {
AZStd::string finalMetalSLStr = AZStd::string(compiledShader.begin(), compiledShader.end()); AZStd::string finalMetalSLStr = AZStd::string(compiledShader.begin(), compiledShader.end());
const uint32_t groupLayoutCount = static_cast<uint32_t>(m_srgLayouts.size()); const uint32_t groupLayoutCount = static_cast<uint32_t>(m_srgLayouts.size());
AZStd::string constantBufferTempStructs = "\n"; AZStd::string constantBufferTempStructs = "\n";
AZStd::string structuredBufferTempStructs = "\n"; AZStd::string structuredBufferTempStructs = "\n";
for (uint32_t groupLayoutIndex = 0; groupLayoutIndex < groupLayoutCount; ++groupLayoutIndex) for (uint32_t groupLayoutIndex = 0; groupLayoutIndex < groupLayoutCount; ++groupLayoutIndex)
{ {
//const auto& srgInfo = m_srgInfoList[groupLayoutIndex]; //const auto& srgInfo = m_srgInfoList[groupLayoutIndex];
const RHI::ShaderResourceGroupLayout& groupLayout = *m_srgLayouts[groupLayoutIndex]; const RHI::ShaderResourceGroupLayout& groupLayout = *m_srgLayouts[groupLayoutIndex];
//Check if an argument buffer declaration exists for this srg layout. //Check if an argument buffer declaration exists for this srg layout.
AZStd::string srgBuffer = AZStd::string::format("spvDescriptorSetBuffer%i", groupLayoutIndex); AZStd::string srgBuffer = AZStd::string::format("spvDescriptorSetBuffer%i", groupLayoutIndex);
size_t startOfArgBufferPos = finalMetalSLStr.find(srgBuffer); size_t startOfArgBufferPos = finalMetalSLStr.find(srgBuffer);
@@ -485,7 +485,7 @@ namespace AZ
size_t endOfArgBufferPos = finalMetalSLStr.find("}", startOfArgBufferPos); size_t endOfArgBufferPos = finalMetalSLStr.find("}", startOfArgBufferPos);
AZStd::string fullArgBufferDeclarationStr = finalMetalSLStr.substr(startOfArgBufferPos,endOfArgBufferPos - startOfArgBufferPos + 1); 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 //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. //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); 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"); AZ_Error(MetalShaderPlatformName, false, "Failed because adding constant buffer entries within AddUnusedResources failed");
return false; return false;
} }
result = AddImageEntries(groupLayout, fullArgBufferDeclarationStr); result = AddImageEntries(groupLayout, fullArgBufferDeclarationStr);
if(!result) if(!result)
{ {
AZ_Error(MetalShaderPlatformName, false, "Failed because adding image entries within AddUnusedResources failed"); AZ_Error(MetalShaderPlatformName, false, "Failed because adding image entries within AddUnusedResources failed");
return false; return false;
} }
result = AddSamplerEntries(groupLayout, fullArgBufferDeclarationStr); result = AddSamplerEntries(groupLayout, fullArgBufferDeclarationStr);
if(!result) if(!result)
{ {
AZ_Error(MetalShaderPlatformName, false, "Failed because adding static sampler entries within AddUnusedResources failed"); AZ_Error(MetalShaderPlatformName, false, "Failed because adding static sampler entries within AddUnusedResources failed");
return false; return false;
} }
result = AddBufferEntries(groupLayout, structuredBufferTempStructs, fullArgBufferDeclarationStr, groupLayoutIndex); result = AddBufferEntries(groupLayout, structuredBufferTempStructs, fullArgBufferDeclarationStr, groupLayoutIndex);
if(!result) if(!result)
{ {
AZ_Error(MetalShaderPlatformName, false, "Failed because adding buffer entries within AddUnusedResources failed"); AZ_Error(MetalShaderPlatformName, false, "Failed because adding buffer entries within AddUnusedResources failed");
return false; return false;
} }
//Create a new spvDescriptorSetBuffer which matches the layout. //Create a new spvDescriptorSetBuffer which matches the layout.
AZStd::string newArgBufferLayoutStr = "\n"; AZStd::string newArgBufferLayoutStr = "\n";
for (const ArgBufferEntries &entry : m_argBufferEntries ) for (const ArgBufferEntries &entry : m_argBufferEntries )
{ {
newArgBufferLayoutStr += " " + entry.first + "\n"; newArgBufferLayoutStr += " " + entry.first + "\n";
} }
//Replace the existing declaration with the new one just generated. //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 //We look for '{' and '}' to find out boundaries of the argument buffer declaration to replace
size_t startOfArgBufferBracketPos = finalMetalSLStr.find("{", startOfArgBufferPos) + 1; size_t startOfArgBufferBracketPos = finalMetalSLStr.find("{", startOfArgBufferPos) + 1;
size_t endOfArgBufferBracketPos = finalMetalSLStr.find("}", startOfArgBufferBracketPos) - 1; size_t endOfArgBufferBracketPos = finalMetalSLStr.find("}", startOfArgBufferBracketPos) - 1;
finalMetalSLStr.replace(startOfArgBufferBracketPos, endOfArgBufferBracketPos - startOfArgBufferBracketPos, newArgBufferLayoutStr); finalMetalSLStr.replace(startOfArgBufferBracketPos, endOfArgBufferBracketPos - startOfArgBufferBracketPos, newArgBufferLayoutStr);
m_argBufferEntries.clear(); m_argBufferEntries.clear();
} }
//Add dummy definitions of constant buffer and structured buffer types to the top of the file //Add dummy definitions of constant buffer and structured buffer types to the top of the file
AZStd::string startOfShaderTag = "using namespace metal;"; AZStd::string startOfShaderTag = "using namespace metal;";
const size_t startOfShaderPos = finalMetalSLStr.find(startOfShaderTag); 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, constantBufferTempStructs);
finalMetalSLStr.insert(startOfShaderPos + startOfShaderTag.length() + 1, structuredBufferTempStructs); finalMetalSLStr.insert(startOfShaderPos + startOfShaderTag.length() + 1, structuredBufferTempStructs);
} }
compiledShader = AZStd::vector<char>(finalMetalSLStr.begin(), finalMetalSLStr.end()); compiledShader = AZStd::vector<char>(finalMetalSLStr.begin(), finalMetalSLStr.end());
return true; return true;
} }
bool ShaderPlatformInterface::AddConstantBufferEntries(const RHI::ShaderResourceGroupLayout& groupLayout, bool ShaderPlatformInterface::AddConstantBufferEntries(const RHI::ShaderResourceGroupLayout& groupLayout,
AZStd::string& constantBufferTempStructs, AZStd::string& constantBufferTempStructs,
AZStd::string& argBufferStr, AZStd::string& argBufferStr,
uint32_t groupLayoutIndex) const uint32_t groupLayoutIndex) const
{ {
AZStd::array_view<RHI::ShaderInputConstantDescriptor> shaderInputConstantList = groupLayout.GetShaderInputListForConstants(); AZStd::span<const RHI::ShaderInputConstantDescriptor> shaderInputConstantList = groupLayout.GetShaderInputListForConstants();
if (shaderInputConstantList.empty()) if (shaderInputConstantList.empty())
{ {
return true; return true;
} }
//Only need the information from the first element of the constant buffer. //Only need the information from the first element of the constant buffer.
const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0]; const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0];
uint32_t regId = shaderInputConstant.m_registerId; uint32_t regId = shaderInputConstant.m_registerId;
AZStd::string srgResource = AZStd::string::format("id(%i)", regId); AZStd::string srgResource = AZStd::string::format("id(%i)", regId);
size_t resourceStartPos = argBufferStr.find(srgResource); size_t resourceStartPos = argBufferStr.find(srgResource);
//Check if we need to create a dummy entry //Check if we need to create a dummy entry
if (resourceStartPos == AZStd::string::npos) 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); 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 //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); 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)); m_argBufferEntries.insert(AZStd::make_pair(dummyResource, regId));
@@ -590,7 +590,7 @@ namespace AZ
return AddExistingResourceEntry("constant type_ConstantBuffer", resourceStartPos, regId, argBufferStr); return AddExistingResourceEntry("constant type_ConstantBuffer", resourceStartPos, regId, argBufferStr);
} }
} }
bool ShaderPlatformInterface::AddImageEntries(const RHI::ShaderResourceGroupLayout& groupLayout, bool ShaderPlatformInterface::AddImageEntries(const RHI::ShaderResourceGroupLayout& groupLayout,
AZStd::string& argBufferStr) const AZStd::string& argBufferStr) const
{ {
@@ -599,7 +599,7 @@ namespace AZ
{ {
uint32_t regId = shaderInputImage.m_registerId; uint32_t regId = shaderInputImage.m_registerId;
AZStd::string srgResource = AZStd::string::format("id(%i)", regId); AZStd::string srgResource = AZStd::string::format("id(%i)", regId);
const size_t resourceStartPos = argBufferStr.find(srgResource); const size_t resourceStartPos = argBufferStr.find(srgResource);
//Check if we need to create a dummy entry //Check if we need to create a dummy entry
if (resourceStartPos == AZStd::string::npos) if (resourceStartPos == AZStd::string::npos)
@@ -652,7 +652,7 @@ namespace AZ
AZ_Assert(false, "Invalid texture type."); AZ_Assert(false, "Invalid texture type.");
} }
} }
//Create the resource entry to be added to the set. Handle arrays by checking the shaderInputImage.m_count //Create the resource entry to be added to the set. Handle arrays by checking the shaderInputImage.m_count
AZStd::string dummyResource; AZStd::string dummyResource;
if(shaderInputImage.m_count > 1) if(shaderInputImage.m_count > 1)
@@ -678,11 +678,11 @@ namespace AZ
} }
return result; return result;
} }
bool ShaderPlatformInterface::ProcessSamplerEntry(uint32_t regId, AZStd::string& argBufferStr, uint32_t samplercount) const bool ShaderPlatformInterface::ProcessSamplerEntry(uint32_t regId, AZStd::string& argBufferStr, uint32_t samplercount) const
{ {
AZStd::string srgResource = AZStd::string::format("id(%i)", regId); AZStd::string srgResource = AZStd::string::format("id(%i)", regId);
const size_t resourceStartPos = argBufferStr.find(srgResource); const size_t resourceStartPos = argBufferStr.find(srgResource);
//Check if we need to create a dummy entry //Check if we need to create a dummy entry
if (resourceStartPos == AZStd::string::npos) if (resourceStartPos == AZStd::string::npos)
@@ -705,7 +705,7 @@ namespace AZ
return AddExistingResourceEntry("sampler", resourceStartPos, regId, argBufferStr); return AddExistingResourceEntry("sampler", resourceStartPos, regId, argBufferStr);
} }
} }
bool ShaderPlatformInterface::AddSamplerEntries(const RHI::ShaderResourceGroupLayout& groupLayout, bool ShaderPlatformInterface::AddSamplerEntries(const RHI::ShaderResourceGroupLayout& groupLayout,
AZStd::string& argBufferStr) const AZStd::string& argBufferStr) const
{ {
@@ -714,15 +714,15 @@ namespace AZ
{ {
result &= ProcessSamplerEntry(staticSampler.m_registerId, argBufferStr, 0); result &= ProcessSamplerEntry(staticSampler.m_registerId, argBufferStr, 0);
} }
for (const RHI::ShaderInputSamplerDescriptor& dynamicSampler : groupLayout.GetShaderInputListForSamplers()) for (const RHI::ShaderInputSamplerDescriptor& dynamicSampler : groupLayout.GetShaderInputListForSamplers())
{ {
result &= ProcessSamplerEntry(dynamicSampler.m_registerId, argBufferStr, dynamicSampler.m_count); result &= ProcessSamplerEntry(dynamicSampler.m_registerId, argBufferStr, dynamicSampler.m_count);
} }
return result; return result;
} }
bool ShaderPlatformInterface::AddBufferEntries(const RHI::ShaderResourceGroupLayout& groupLayout, bool ShaderPlatformInterface::AddBufferEntries(const RHI::ShaderResourceGroupLayout& groupLayout,
AZStd::string& structuredBufferTempStructs, AZStd::string& structuredBufferTempStructs,
AZStd::string& argBufferStr, AZStd::string& argBufferStr,
@@ -733,7 +733,7 @@ namespace AZ
{ {
uint32_t regId = shaderInputBuffer.m_registerId; uint32_t regId = shaderInputBuffer.m_registerId;
AZStd::string srgResource = AZStd::string::format("id(%i)", regId); AZStd::string srgResource = AZStd::string::format("id(%i)", regId);
size_t resourceStartPos = argBufferStr.find(srgResource); size_t resourceStartPos = argBufferStr.find(srgResource);
//Check if we need to create a dummy entry //Check if we need to create a dummy entry
if (resourceStartPos == AZStd::string::npos) 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 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); 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 //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); 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)); m_argBufferEntries.insert(AZStd::make_pair(dummyResource, regId));
@@ -823,7 +823,7 @@ namespace AZ
} }
return result; return result;
} }
bool ShaderPlatformInterface::AddExistingResourceEntry(const char* resourceStr, bool ShaderPlatformInterface::AddExistingResourceEntry(const char* resourceStr,
size_t resourceStartPos, size_t resourceStartPos,
uint32_t regId, uint32_t regId,
@@ -832,8 +832,8 @@ namespace AZ
size_t prevEndOfLine = argBufferStr.rfind("\n", resourceStartPos); size_t prevEndOfLine = argBufferStr.rfind("\n", resourceStartPos);
size_t nextEndOfLine = argBufferStr.find("\n", resourceStartPos); size_t nextEndOfLine = argBufferStr.find("\n", resourceStartPos);
size_t startOfEntryPos = argBufferStr.find(resourceStr, prevEndOfLine); 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) 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()); 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); size_t endOfEntryPos = argBufferStr.find("\n", startOfEntryPos);
AZ_Assert(endOfEntryPos != AZStd::string::npos, "Resource entry missing"); AZ_Assert(endOfEntryPos != AZStd::string::npos, "Resource entry missing");
AZStd::string existingEntry = argBufferStr.substr(prevEndOfLine,endOfEntryPos - prevEndOfLine); AZStd::string existingEntry = argBufferStr.substr(prevEndOfLine,endOfEntryPos - prevEndOfLine);
m_argBufferEntries.insert(AZStd::make_pair(existingEntry, regId)); m_argBufferEntries.insert(AZStd::make_pair(existingEntry, regId));
return true; return true;
@@ -23,14 +23,14 @@ namespace AZ
{ {
return aznew ArgumentBuffer(); return aznew ArgumentBuffer();
} }
void ArgumentBuffer::Init(Device* device, RHI::ConstPtr<RHI::ShaderResourceGroupLayout> srgLayout, ShaderResourceGroup& group, ShaderResourceGroupPool* srgPool) void ArgumentBuffer::Init(Device* device, RHI::ConstPtr<RHI::ShaderResourceGroupLayout> srgLayout, ShaderResourceGroup& group, ShaderResourceGroupPool* srgPool)
{ {
@autoreleasepool @autoreleasepool
{ {
m_device = device; m_device = device;
m_srgLayout = srgLayout; m_srgLayout = srgLayout;
m_constantBufferSize = srgLayout->GetConstantDataSize(); m_constantBufferSize = srgLayout->GetConstantDataSize();
if (m_constantBufferSize) if (m_constantBufferSize)
{ {
@@ -47,23 +47,23 @@ namespace AZ
m_constantBuffer.SetName(constantBufferName.c_str()); m_constantBuffer.SetName(constantBufferName.c_str());
AZ_Assert(m_constantBuffer.IsValid(), "Couldnt allocate memory for Constant buffer") AZ_Assert(m_constantBuffer.IsValid(), "Couldnt allocate memory for Constant buffer")
} }
NSMutableArray* argBufferDecriptors = [[[NSMutableArray alloc] init] autorelease]; NSMutableArray* argBufferDecriptors = [[[NSMutableArray alloc] init] autorelease];
bool argDescriptorsCreated = CreateArgumentDescriptors(argBufferDecriptors); bool argDescriptorsCreated = CreateArgumentDescriptors(argBufferDecriptors);
if(argDescriptorsCreated) if(argDescriptorsCreated)
{ {
NSSortDescriptor* sortDescriptor; NSSortDescriptor* sortDescriptor;
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"index" sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"index"
ascending:YES] autorelease]; ascending:YES] autorelease];
NSArray* sortedArgDescriptors = [argBufferDecriptors sortedArrayUsingDescriptors:@[sortDescriptor]]; NSArray* sortedArgDescriptors = [argBufferDecriptors sortedArrayUsingDescriptors:@[sortDescriptor]];
m_argumentEncoder = [m_device->GetMtlDevice() newArgumentEncoderWithArguments:sortedArgDescriptors]; m_argumentEncoder = [m_device->GetMtlDevice() newArgumentEncoderWithArguments:sortedArgDescriptors];
NSUInteger argumentBufferLength = m_argumentEncoder.encodedLength; NSUInteger argumentBufferLength = m_argumentEncoder.encodedLength;
RHI::BufferDescriptor bufferDescriptor; RHI::BufferDescriptor bufferDescriptor;
bufferDescriptor.m_byteCount = argumentBufferLength; bufferDescriptor.m_byteCount = argumentBufferLength;
bufferDescriptor.m_bindFlags = RHI::BufferBindFlags::Constant; bufferDescriptor.m_bindFlags = RHI::BufferBindFlags::Constant;
AZStd::string argBufferName = "ArgumentBuffer"; AZStd::string argBufferName = "ArgumentBuffer";
@@ -77,24 +77,24 @@ namespace AZ
m_argumentBuffer.SetName(argBufferName.c_str()); m_argumentBuffer.SetName(argBufferName.c_str());
SetName(Name(argBufferName.c_str())); SetName(Name(argBufferName.c_str()));
//Attach the argument buffer to the argument encoder //Attach the argument buffer to the argument encoder
[m_argumentEncoder setArgumentBuffer:m_argumentBuffer.GetGpuAddress<id<MTLBuffer>>() [m_argumentEncoder setArgumentBuffer:m_argumentBuffer.GetGpuAddress<id<MTLBuffer>>()
offset:m_argumentBuffer.GetOffset()]; offset:m_argumentBuffer.GetOffset()];
//Attach the static samplers //Attach the static samplers
AttachStaticSamplers(); AttachStaticSamplers();
//Attach the constant buffer //Attach the constant buffer
AttachConstantBuffer(); AttachConstantBuffer();
} }
} }
} }
bool ArgumentBuffer::CreateArgumentDescriptors(NSMutableArray* argBufferDecriptors) bool ArgumentBuffer::CreateArgumentDescriptors(NSMutableArray* argBufferDecriptors)
{ {
bool resourceAdded = false; bool resourceAdded = false;
for (const RHI::ShaderInputBufferDescriptor& shaderInputBuffer : m_srgLayout->GetShaderInputListForBuffers()) for (const RHI::ShaderInputBufferDescriptor& shaderInputBuffer : m_srgLayout->GetShaderInputListForBuffers())
{ {
MTLArgumentDescriptor* bufferArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease]; MTLArgumentDescriptor* bufferArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease];
@@ -102,7 +102,7 @@ namespace AZ
[argBufferDecriptors addObject:bufferArgDescriptor]; [argBufferDecriptors addObject:bufferArgDescriptor];
resourceAdded = true; resourceAdded = true;
} }
for (const RHI::ShaderInputImageDescriptor& shaderInputImage : m_srgLayout->GetShaderInputListForImages()) for (const RHI::ShaderInputImageDescriptor& shaderInputImage : m_srgLayout->GetShaderInputListForImages())
{ {
MTLArgumentDescriptor* imgArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease]; MTLArgumentDescriptor* imgArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease];
@@ -110,7 +110,7 @@ namespace AZ
[argBufferDecriptors addObject:imgArgDescriptor]; [argBufferDecriptors addObject:imgArgDescriptor];
resourceAdded = true; resourceAdded = true;
} }
for (const RHI::ShaderInputSamplerDescriptor& shaderInputSampler : m_srgLayout->GetShaderInputListForSamplers()) for (const RHI::ShaderInputSamplerDescriptor& shaderInputSampler : m_srgLayout->GetShaderInputListForSamplers())
{ {
MTLArgumentDescriptor* samplerArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease]; MTLArgumentDescriptor* samplerArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease];
@@ -121,7 +121,7 @@ namespace AZ
[argBufferDecriptors addObject:samplerArgDescriptor]; [argBufferDecriptors addObject:samplerArgDescriptor];
resourceAdded = true; resourceAdded = true;
} }
for (const RHI::ShaderInputStaticSamplerDescriptor& staticSamplerInput : m_srgLayout->GetStaticSamplers()) for (const RHI::ShaderInputStaticSamplerDescriptor& staticSamplerInput : m_srgLayout->GetStaticSamplers())
{ {
MTLArgumentDescriptor* staticSamplerArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease]; MTLArgumentDescriptor* staticSamplerArgDescriptor = [[[MTLArgumentDescriptor alloc] init] autorelease];
@@ -131,8 +131,8 @@ namespace AZ
[argBufferDecriptors addObject:staticSamplerArgDescriptor]; [argBufferDecriptors addObject:staticSamplerArgDescriptor];
resourceAdded = true; resourceAdded = true;
} }
AZStd::array_view<RHI::ShaderInputConstantDescriptor> shaderInputConstantList = m_srgLayout->GetShaderInputListForConstants(); AZStd::span<const RHI::ShaderInputConstantDescriptor> shaderInputConstantList = m_srgLayout->GetShaderInputListForConstants();
if (!shaderInputConstantList.empty()) if (!shaderInputConstantList.empty())
{ {
const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0]; const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0];
@@ -143,10 +143,10 @@ namespace AZ
[argBufferDecriptors addObject:constBufferArgDescriptor]; [argBufferDecriptors addObject:constBufferArgDescriptor];
resourceAdded = true; resourceAdded = true;
} }
return resourceAdded; return resourceAdded;
} }
void ArgumentBuffer::AttachStaticSamplers() void ArgumentBuffer::AttachStaticSamplers()
{ {
for (const RHI::ShaderInputStaticSamplerDescriptor& staticSampler : m_srgLayout->GetStaticSamplers()) for (const RHI::ShaderInputStaticSamplerDescriptor& staticSampler : m_srgLayout->GetStaticSamplers())
@@ -157,17 +157,17 @@ namespace AZ
[m_argumentEncoder setSamplerState:mtlSamplerState atIndex:staticSampler.m_registerId]; [m_argumentEncoder setSamplerState:mtlSamplerState atIndex:staticSampler.m_registerId];
} }
} }
void ArgumentBuffer::AttachConstantBuffer() void ArgumentBuffer::AttachConstantBuffer()
{ {
AZStd::array_view<RHI::ShaderInputConstantDescriptor> shaderInputConstantList = m_srgLayout->GetShaderInputListForConstants(); AZStd::span<const RHI::ShaderInputConstantDescriptor> shaderInputConstantList = m_srgLayout->GetShaderInputListForConstants();
if (!shaderInputConstantList.empty()) if (!shaderInputConstantList.empty())
{ {
const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0]; const RHI::ShaderInputConstantDescriptor& shaderInputConstant = shaderInputConstantList[0];
[m_argumentEncoder setBuffer:m_constantBuffer.GetGpuAddress<id<MTLBuffer>>() offset:m_constantBuffer.GetOffset() atIndex:shaderInputConstant.m_registerId]; [m_argumentEncoder setBuffer:m_constantBuffer.GetGpuAddress<id<MTLBuffer>>() offset:m_constantBuffer.GetOffset() atIndex:shaderInputConstant.m_registerId];
} }
} }
void ArgumentBuffer::BindNullSamplers(uint32_t registerId, uint32_t samplerCount) void ArgumentBuffer::BindNullSamplers(uint32_t registerId, uint32_t samplerCount)
{ {
AZStd::array<id<MTLSamplerState>, MaxEntriesInArgTable> mtlSamplers; AZStd::array<id<MTLSamplerState>, MaxEntriesInArgTable> mtlSamplers;
@@ -177,25 +177,25 @@ namespace AZ
{ {
mtlSamplers[i] = nullMtlSampler; mtlSamplers[i] = nullMtlSampler;
} }
NSRange range = {registerId, samplerCount}; NSRange range = {registerId, samplerCount};
[m_argumentEncoder setSamplerStates : mtlSamplers.data() [m_argumentEncoder setSamplerStates : mtlSamplers.data()
withRange : range]; withRange : range];
} }
void ArgumentBuffer::UpdateImageViews(const RHI::ShaderInputImageDescriptor& shaderInputImage, void ArgumentBuffer::UpdateImageViews(const RHI::ShaderInputImageDescriptor& shaderInputImage,
const RHI::ShaderInputImageIndex shaderInputIndex, const RHI::ShaderInputImageIndex shaderInputIndex,
const AZStd::array_view<RHI::ConstPtr<RHI::ImageView>>& imageViews) const AZStd::span<const RHI::ConstPtr<RHI::ImageView>>& imageViews)
{ {
int imageArrayLen = 0; int imageArrayLen = 0;
AZStd::array<id<MTLTexture>, MaxEntriesInArgTable> mtlTextures; AZStd::array<id<MTLTexture>, MaxEntriesInArgTable> mtlTextures;
for (const RHI::ConstPtr<RHI::ImageView>& imageViewBase : imageViews) for (const RHI::ConstPtr<RHI::ImageView>& imageViewBase : imageViews)
{ {
if (imageViewBase && !imageViewBase->IsStale()) if (imageViewBase && !imageViewBase->IsStale())
{ {
const auto& imageView = static_cast<const ImageView&>(*imageViewBase); const auto& imageView = static_cast<const ImageView&>(*imageViewBase);
RHI::Ptr<Memory> textureMemPtr = imageView.GetMemoryView().GetMemory(); RHI::Ptr<Memory> textureMemPtr = imageView.GetMemoryView().GetMemory();
mtlTextures[imageArrayLen] = textureMemPtr->GetGpuAddress<id<MTLTexture>>(); mtlTextures[imageArrayLen] = textureMemPtr->GetGpuAddress<id<MTLTexture>>();
m_resourceBindings[shaderInputImage.m_name].insert(ResourceBindingData{textureMemPtr, .m_imageAccess = shaderInputImage.m_access}); m_resourceBindings[shaderInputImage.m_name].insert(ResourceBindingData{textureMemPtr, .m_imageAccess = shaderInputImage.m_access});
@@ -208,7 +208,7 @@ namespace AZ
} }
imageArrayLen++; imageArrayLen++;
} }
AZ_Assert(imageArrayLen==shaderInputImage.m_count, "Make sure we have created the correct length of texture array"); AZ_Assert(imageArrayLen==shaderInputImage.m_count, "Make sure we have created the correct length of texture array");
if(imageArrayLen > 0) if(imageArrayLen > 0)
{ {
@@ -217,10 +217,10 @@ namespace AZ
withRange : range]; withRange : range];
} }
} }
void ArgumentBuffer::UpdateSamplers(const RHI::ShaderInputSamplerDescriptor& shaderInputSampler, void ArgumentBuffer::UpdateSamplers(const RHI::ShaderInputSamplerDescriptor& shaderInputSampler,
const RHI::ShaderInputSamplerIndex shaderInputIndex, const RHI::ShaderInputSamplerIndex shaderInputIndex,
const AZStd::array_view<RHI::SamplerState>& samplerStates) const AZStd::span<const RHI::SamplerState>& samplerStates)
{ {
int samplerArrayLen = 0; int samplerArrayLen = 0;
AZStd::array<id<MTLSamplerState>, MaxEntriesInArgTable> mtlSamplers; AZStd::array<id<MTLSamplerState>, MaxEntriesInArgTable> mtlSamplers;
@@ -232,7 +232,7 @@ namespace AZ
mtlSamplers[samplerArrayLen] = GetMtlSampler(samplerDesc); mtlSamplers[samplerArrayLen] = GetMtlSampler(samplerDesc);
samplerArrayLen++; samplerArrayLen++;
} }
AZ_Assert(samplerArrayLen==shaderInputSampler.m_count, "Make sure we dont have a nil sampler within mtlSamplers"); AZ_Assert(samplerArrayLen==shaderInputSampler.m_count, "Make sure we dont have a nil sampler within mtlSamplers");
if(samplerArrayLen > 0) if(samplerArrayLen > 0)
{ {
@@ -245,16 +245,16 @@ namespace AZ
BindNullSamplers(shaderInputSampler.m_registerId, shaderInputSampler.m_count); BindNullSamplers(shaderInputSampler.m_registerId, shaderInputSampler.m_count);
} }
} }
void ArgumentBuffer::UpdateBufferViews(const RHI::ShaderInputBufferDescriptor& shaderInputBuffer, void ArgumentBuffer::UpdateBufferViews(const RHI::ShaderInputBufferDescriptor& shaderInputBuffer,
const RHI::ShaderInputBufferIndex shaderInputIndex, const RHI::ShaderInputBufferIndex shaderInputIndex,
const AZStd::array_view<RHI::ConstPtr<RHI::BufferView>>& bufferViews) const AZStd::span<const RHI::ConstPtr<RHI::BufferView>>& bufferViews)
{ {
int bufferArrayLen = 0; int bufferArrayLen = 0;
AZStd::array<id<MTLBuffer>, MaxEntriesInArgTable> mtlBuffers; AZStd::array<id<MTLBuffer>, MaxEntriesInArgTable> mtlBuffers;
AZStd::array<NSUInteger, MaxEntriesInArgTable> mtlBufferOffsets; AZStd::array<NSUInteger, MaxEntriesInArgTable> mtlBufferOffsets;
AZStd::array<id<MTLTexture>, MaxEntriesInArgTable> mtlTextures; AZStd::array<id<MTLTexture>, MaxEntriesInArgTable> mtlTextures;
for (const RHI::ConstPtr<RHI::BufferView>& bufferViewBase : bufferViews) for (const RHI::ConstPtr<RHI::BufferView>& bufferViewBase : bufferViews)
{ {
if (bufferViewBase && !bufferViewBase->IsStale()) if (bufferViewBase && !bufferViewBase->IsStale())
@@ -298,12 +298,12 @@ namespace AZ
bufferArrayLen++; bufferArrayLen++;
} }
AZ_Assert(bufferArrayLen==shaderInputBuffer.m_count, "Make sure we have created the correct length of buffer array"); AZ_Assert(bufferArrayLen==shaderInputBuffer.m_count, "Make sure we have created the correct length of buffer array");
if(bufferArrayLen > 0) if(bufferArrayLen > 0)
{ {
NSRange range = {shaderInputBuffer.m_registerId, bufferArrayLen}; NSRange range = {shaderInputBuffer.m_registerId, bufferArrayLen};
if(shaderInputBuffer.m_type == RHI::ShaderInputBufferType::Typed) if(shaderInputBuffer.m_type == RHI::ShaderInputBufferType::Typed)
{ {
[m_argumentEncoder setTextures : mtlTextures.data() [m_argumentEncoder setTextures : mtlTextures.data()
@@ -317,8 +317,8 @@ namespace AZ
} }
} }
} }
void ArgumentBuffer::UpdateConstantBufferViews(AZStd::array_view<uint8_t> rawData) void ArgumentBuffer::UpdateConstantBufferViews(AZStd::span<const uint8_t> rawData)
{ {
AZ_Assert(rawData.size() <= m_constantBufferSize, "rawData size can not be bigger than constant Buffer Size"); AZ_Assert(rawData.size() <= m_constantBufferSize, "rawData size can not be bigger than constant Buffer Size");
if ( (m_constantBufferSize > 0) && (rawData.size() <= m_constantBufferSize)) if ( (m_constantBufferSize > 0) && (rawData.size() <= m_constantBufferSize))
@@ -326,11 +326,11 @@ namespace AZ
memcpy(m_constantBuffer.GetCpuAddress(), rawData.data(), rawData.size()); memcpy(m_constantBuffer.GetCpuAddress(), rawData.data(), rawData.size());
} }
} }
void ArgumentBuffer::Shutdown() void ArgumentBuffer::Shutdown()
{ {
ClearResourceTracking(); ClearResourceTracking();
#if defined(ARGUMENTBUFFER_PAGEALLOCATOR) #if defined(ARGUMENTBUFFER_PAGEALLOCATOR)
if(m_constantBuffer.IsValid()) if(m_constantBuffer.IsValid())
{ {
@@ -339,13 +339,13 @@ namespace AZ
if(m_argumentBuffer.IsValid()) if(m_argumentBuffer.IsValid())
{ {
m_device->GetArgumentBufferAllocator().DeAllocate(m_argumentBuffer); m_device->GetArgumentBufferAllocator().DeAllocate(m_argumentBuffer);
} }
#else #else
if(m_argumentBuffer.IsValid()) if(m_argumentBuffer.IsValid())
{ {
m_device->QueueForRelease(m_argumentBuffer); m_device->QueueForRelease(m_argumentBuffer);
} }
if(m_constantBuffer.IsValid()) if(m_constantBuffer.IsValid())
{ {
m_device->QueueForRelease(m_constantBuffer); m_device->QueueForRelease(m_constantBuffer);
@@ -354,28 +354,28 @@ namespace AZ
m_argumentBuffer = {}; m_argumentBuffer = {};
m_constantBuffer = {}; m_constantBuffer = {};
[m_argumentEncoder release]; [m_argumentEncoder release];
m_argumentEncoder = nil; m_argumentEncoder = nil;
Base::Shutdown(); Base::Shutdown();
} }
id<MTLBuffer> ArgumentBuffer::GetArgEncoderBuffer() const id<MTLBuffer> ArgumentBuffer::GetArgEncoderBuffer() const
{ {
return m_argumentBuffer.GetGpuAddress<id<MTLBuffer>>(); return m_argumentBuffer.GetGpuAddress<id<MTLBuffer>>();
}; };
size_t ArgumentBuffer::GetOffset() const size_t ArgumentBuffer::GetOffset() const
{ {
return m_argumentBuffer.GetOffset(); return m_argumentBuffer.GetOffset();
}; };
void ArgumentBuffer::ClearResourceTracking() void ArgumentBuffer::ClearResourceTracking()
{ {
m_resourceBindings.clear(); m_resourceBindings.clear();
} }
id<MTLSamplerState> ArgumentBuffer::GetMtlSampler(MTLSamplerDescriptor* samplerDesc) id<MTLSamplerState> ArgumentBuffer::GetMtlSampler(MTLSamplerDescriptor* samplerDesc)
{ {
const NSCache* samplerCache = m_device->GetSamplerCache(); const NSCache* samplerCache = m_device->GetSamplerCache();
@@ -385,10 +385,10 @@ namespace AZ
mtlSamplerState = [m_device->GetMtlDevice() newSamplerStateWithDescriptor:samplerDesc]; mtlSamplerState = [m_device->GetMtlDevice() newSamplerStateWithDescriptor:samplerDesc];
[samplerCache setObject:mtlSamplerState forKey:samplerDesc]; [samplerCache setObject:mtlSamplerState forKey:samplerDesc];
} }
return mtlSamplerState; return mtlSamplerState;
} }
void ArgumentBuffer::CollectUntrackedResources(id<MTLCommandEncoder> commandEncoder, void ArgumentBuffer::CollectUntrackedResources(id<MTLCommandEncoder> commandEncoder,
const ShaderResourceGroupVisibility& srgResourcesVisInfo, const ShaderResourceGroupVisibility& srgResourcesVisInfo,
ComputeResourcesToMakeResidentMap& resourcesToMakeResidentCompute, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentCompute,
@@ -408,19 +408,19 @@ namespace AZ
else else
{ {
MTLRenderStages mtlRenderStages = GetRenderStages(srgResourcesVisInfo.m_constantDataStageMask); MTLRenderStages mtlRenderStages = GetRenderStages(srgResourcesVisInfo.m_constantDataStageMask);
AZStd::pair <MTLResourceUsage,MTLRenderStages> key = AZStd::make_pair(MTLResourceUsageRead, mtlRenderStages); AZStd::pair <MTLResourceUsage,MTLRenderStages> key = AZStd::make_pair(MTLResourceUsageRead, mtlRenderStages);
resourcesToMakeResidentGraphics[key].emplace(mtlconstantBufferResource); resourcesToMakeResidentGraphics[key].emplace(mtlconstantBufferResource);
} }
} }
} }
//Cach all the resources within a srg that are used by the shader based on the visibility information //Cach all the resources within a srg that are used by the shader based on the visibility information
for (const auto& it : m_resourceBindings) for (const auto& it : m_resourceBindings)
{ {
//Extract the visibility mask for the give resource //Extract the visibility mask for the give resource
auto visMaskIt = srgResourcesVisInfo.m_resourcesStageMask.find(it.first); auto visMaskIt = srgResourcesVisInfo.m_resourcesStageMask.find(it.first);
AZ_Assert(visMaskIt != srgResourcesVisInfo.m_resourcesStageMask.end(), "No Visibility information available") AZ_Assert(visMaskIt != srgResourcesVisInfo.m_resourcesStageMask.end(), "No Visibility information available")
uint8_t numBitsSet = RHI::CountBitsSet(static_cast<uint64_t>(visMaskIt->second)); uint8_t numBitsSet = RHI::CountBitsSet(static_cast<uint64_t>(visMaskIt->second));
//Only use this resource if it is used in one of the shaders //Only use this resource if it is used in one of the shaders
if (numBitsSet > 0) if (numBitsSet > 0)
@@ -464,7 +464,7 @@ namespace AZ
AZ_Assert(false, "Undefined Resource type"); AZ_Assert(false, "Undefined Resource type");
} }
} }
id<MTLResource> mtlResourceToBind = resourceBindingData.m_resourcPtr->GetGpuAddress<id<MTLResource>>(); id<MTLResource> mtlResourceToBind = resourceBindingData.m_resourcPtr->GetGpuAddress<id<MTLResource>>();
resourcesToMakeResidentMap[resourceUsage].emplace(mtlResourceToBind); resourcesToMakeResidentMap[resourceUsage].emplace(mtlResourceToBind);
} }
@@ -475,7 +475,7 @@ namespace AZ
const ResourceBindingsSet& resourceBindingDataSet, const ResourceBindingsSet& resourceBindingDataSet,
GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const
{ {
MTLRenderStages mtlRenderStages = GetRenderStages(visShaderMask); MTLRenderStages mtlRenderStages = GetRenderStages(visShaderMask);
MTLResourceUsage resourceUsage = MTLResourceUsageRead; MTLResourceUsage resourceUsage = MTLResourceUsageRead;
for (const auto& resourceBindingData : resourceBindingDataSet) for (const auto& resourceBindingData : resourceBindingDataSet)
@@ -498,17 +498,17 @@ namespace AZ
AZ_Assert(false, "Undefined Resource type"); AZ_Assert(false, "Undefined Resource type");
} }
} }
AZStd::pair <MTLResourceUsage, MTLRenderStages> key = AZStd::make_pair(resourceUsage, mtlRenderStages); AZStd::pair <MTLResourceUsage, MTLRenderStages> key = AZStd::make_pair(resourceUsage, mtlRenderStages);
id<MTLResource> mtlResourceToBind = resourceBindingData.m_resourcPtr->GetGpuAddress<id<MTLResource>>(); id<MTLResource> mtlResourceToBind = resourceBindingData.m_resourcPtr->GetGpuAddress<id<MTLResource>>();
resourcesToMakeResidentMap[key].emplace(mtlResourceToBind); resourcesToMakeResidentMap[key].emplace(mtlResourceToBind);
} }
} }
bool ArgumentBuffer::IsNullHeapNeededForVertexStage(const ShaderResourceGroupVisibility& srgResourcesVisInfo) const bool ArgumentBuffer::IsNullHeapNeededForVertexStage(const ShaderResourceGroupVisibility& srgResourcesVisInfo) const
{ {
bool isUsedByVertexStage = false; bool isUsedByVertexStage = false;
//Iterate over all the SRG entries //Iterate over all the SRG entries
for (const auto& it : srgResourcesVisInfo.m_resourcesStageMask) for (const auto& it : srgResourcesVisInfo.m_resourcesStageMask)
{ {
@@ -520,7 +520,7 @@ namespace AZ
} }
return isUsedByVertexStage; return isUsedByVertexStage;
} }
bool ArgumentBuffer::IsNullDescHeapNeeded() const bool ArgumentBuffer::IsNullDescHeapNeeded() const
{ {
return m_useNullDescriptorHeap; return m_useNullDescriptorHeap;
@@ -26,12 +26,12 @@ struct ResourceBindingData
AZ::RHI::ShaderInputImageAccess m_imageAccess; AZ::RHI::ShaderInputImageAccess m_imageAccess;
AZ::RHI::ShaderInputBufferAccess m_bufferAccess; AZ::RHI::ShaderInputBufferAccess m_bufferAccess;
}; };
bool operator==(const ResourceBindingData& other) const bool operator==(const ResourceBindingData& other) const
{ {
return this->m_resourcPtr == other.m_resourcPtr; return this->m_resourcPtr == other.m_resourcPtr;
}; };
size_t GetHash() const size_t GetHash() const
{ {
return static_cast<size_t>(m_resourcPtr->GetHash()); return static_cast<size_t>(m_resourcPtr->GetHash());
@@ -58,12 +58,12 @@ namespace AZ
class BufferMemoryAllocator; class BufferMemoryAllocator;
class ShaderResourceGroup; class ShaderResourceGroup;
struct ShaderResourceGroupCompiledData; struct ShaderResourceGroupCompiledData;
class ArgumentBuffer final class ArgumentBuffer final
: public RHI::DeviceObject : public RHI::DeviceObject
{ {
using Base = RHI::DeviceObject; using Base = RHI::DeviceObject;
public: public:
AZ_CLASS_ALLOCATOR(ArgumentBuffer, AZ::SystemAllocator, 0); AZ_CLASS_ALLOCATOR(ArgumentBuffer, AZ::SystemAllocator, 0);
AZ_RTTI(ArgumentBuffer, "FEFE8823-7772-4EA0-9241-65C49ADFF6B3", Base); AZ_RTTI(ArgumentBuffer, "FEFE8823-7772-4EA0-9241-65C49ADFF6B3", Base);
@@ -78,21 +78,21 @@ namespace AZ
void UpdateImageViews(const RHI::ShaderInputImageDescriptor& shaderInputImage, void UpdateImageViews(const RHI::ShaderInputImageDescriptor& shaderInputImage,
const RHI::ShaderInputImageIndex shaderInputIndex, const RHI::ShaderInputImageIndex shaderInputIndex,
const AZStd::array_view<RHI::ConstPtr<RHI::ImageView>>& imageViews); const AZStd::span<const RHI::ConstPtr<RHI::ImageView>>& imageViews);
void UpdateSamplers(const RHI::ShaderInputSamplerDescriptor& shaderInputSampler, void UpdateSamplers(const RHI::ShaderInputSamplerDescriptor& shaderInputSampler,
const RHI::ShaderInputSamplerIndex shaderInputIndex, const RHI::ShaderInputSamplerIndex shaderInputIndex,
const AZStd::array_view<RHI::SamplerState>& samplerStates); const AZStd::span<const RHI::SamplerState>& samplerStates);
void UpdateBufferViews(const RHI::ShaderInputBufferDescriptor& shaderInputBuffer, void UpdateBufferViews(const RHI::ShaderInputBufferDescriptor& shaderInputBuffer,
const RHI::ShaderInputBufferIndex shaderInputIndex, const RHI::ShaderInputBufferIndex shaderInputIndex,
const AZStd::array_view<RHI::ConstPtr<RHI::BufferView>>& bufferViews); const AZStd::span<const RHI::ConstPtr<RHI::BufferView>>& bufferViews);
void UpdateConstantBufferViews(AZStd::array_view<uint8_t> rawData); void UpdateConstantBufferViews(AZStd::span<const uint8_t> rawData);
id<MTLBuffer> GetArgEncoderBuffer() const; id<MTLBuffer> GetArgEncoderBuffer() const;
size_t GetOffset() 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. //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<MTLResourceUsage, AZStd::unordered_set<id <MTLResource>>>; using ComputeResourcesToMakeResidentMap = AZStd::unordered_map<MTLResourceUsage, AZStd::unordered_set<id <MTLResource>>>;
//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. //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, const ShaderResourceGroupVisibility& srgResourcesVisInfo,
ComputeResourcesToMakeResidentMap& resourcesToMakeResidentCompute, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentCompute,
GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentGraphics) const; GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentGraphics) const;
void ClearResourceTracking(); void ClearResourceTracking();
bool IsNullHeapNeededForVertexStage(const ShaderResourceGroupVisibility& srgResourcesVisInfo) const; bool IsNullHeapNeededForVertexStage(const ShaderResourceGroupVisibility& srgResourcesVisInfo) const;
bool IsNullDescHeapNeeded() const; bool IsNullDescHeapNeeded() const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// RHI::DeviceObject // RHI::DeviceObject
void Shutdown() override; void Shutdown() override;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
private: private:
bool CreateArgumentDescriptors(NSMutableArray * argBufferDecriptors); bool CreateArgumentDescriptors(NSMutableArray * argBufferDecriptors);
void AttachStaticSamplers(); void AttachStaticSamplers();
void AttachConstantBuffer(); void AttachConstantBuffer();
// Use a cache to store and retrieve samplers // Use a cache to store and retrieve samplers
id<MTLSamplerState> GetMtlSampler(MTLSamplerDescriptor* samplerDesc); id<MTLSamplerState> GetMtlSampler(MTLSamplerDescriptor* samplerDesc);
using ResourceBindingsSet = AZStd::unordered_set<ResourceBindingData>; using ResourceBindingsSet = AZStd::unordered_set<ResourceBindingData>;
using ResourceBindingsMap = AZStd::unordered_map<AZ::Name, ResourceBindingsSet>; using ResourceBindingsMap = AZStd::unordered_map<AZ::Name, ResourceBindingsSet>;
ResourceBindingsMap m_resourceBindings; ResourceBindingsMap m_resourceBindings;
static const int MaxEntriesInArgTable = 31; static const int MaxEntriesInArgTable = 31;
void CollectResourcesForCompute(id<MTLCommandEncoder> encoder, void CollectResourcesForCompute(id<MTLCommandEncoder> encoder,
const ResourceBindingsSet& resourceBindingData, const ResourceBindingsSet& resourceBindingData,
ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const; ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const;
@@ -139,13 +139,13 @@ namespace AZ
const ResourceBindingsMap& resourceMap, const ResourceBindingsMap& resourceMap,
const ShaderResourceGroupVisibility& srgResourcesVisInfo) const; const ShaderResourceGroupVisibility& srgResourcesVisInfo) const;
void BindNullSamplers(uint32_t registerId, uint32_t samplerCount); void BindNullSamplers(uint32_t registerId, uint32_t samplerCount);
Device* m_device = nullptr; Device* m_device = nullptr;
RHI::ConstPtr<RHI::ShaderResourceGroupLayout> m_srgLayout; RHI::ConstPtr<RHI::ShaderResourceGroupLayout> m_srgLayout;
id <MTLArgumentEncoder> m_argumentEncoder; id <MTLArgumentEncoder> m_argumentEncoder;
uint32_t m_constantBufferSize = 0; uint32_t m_constantBufferSize = 0;
#if defined(ARGUMENTBUFFER_PAGEALLOCATOR) #if defined(ARGUMENTBUFFER_PAGEALLOCATOR)
BufferMemoryView m_argumentBuffer; BufferMemoryView m_argumentBuffer;
BufferMemoryView m_constantBuffer; BufferMemoryView m_constantBuffer;
@@ -10,7 +10,7 @@
#include <Atom/RHI/AsyncWorkQueue.h> #include <Atom/RHI/AsyncWorkQueue.h>
#include <Atom/RHI/DeviceObject.h> #include <Atom/RHI/DeviceObject.h>
#include <Atom/RHI/StreamingImagePool.h> #include <Atom/RHI/StreamingImagePool.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <RHI/CommandQueue.h> #include <RHI/CommandQueue.h>
#include <RHI/Buffer.h> #include <RHI/Buffer.h>
#include <RHI/Image.h> #include <RHI/Image.h>
@@ -34,7 +34,7 @@ namespace AZ
: public RHI::DeviceObject : public RHI::DeviceObject
{ {
using Base = RHI::DeviceObject; using Base = RHI::DeviceObject;
public: public:
AsyncUploadQueue() = default; AsyncUploadQueue() = default;
@@ -57,13 +57,13 @@ namespace AZ
uint64_t QueueUpload(const RHI::BufferStreamRequest& request); uint64_t QueueUpload(const RHI::BufferStreamRequest& request);
//! Queue copy commands to upload image subresources. //! 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 //! @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); RHI::AsyncWorkHandle QueueUpload(const RHI::StreamingImageExpandRequest& request, uint32_t residentMip);
bool IsUploadFinished(uint64_t fenceValue); bool IsUploadFinished(uint64_t fenceValue);
void WaitForUpload(const RHI::AsyncWorkHandle& workHandle); void WaitForUpload(const RHI::AsyncWorkHandle& workHandle);
private: private:
struct FramePacket; struct FramePacket;
RHI::AsyncWorkHandle CreateAsyncWork(Fence& fence, RHI::Fence::SignalCallback callback = nullptr); RHI::AsyncWorkHandle CreateAsyncWork(Fence& fence, RHI::Fence::SignalCallback callback = nullptr);
@@ -84,26 +84,26 @@ namespace AZ
Fence m_fence; Fence m_fence;
// Using persistent mapping for the staging resource so the Map function only need to be called called once. // 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; uint32_t m_dataOffset = 0;
}; };
RHI::Ptr<CommandQueue> m_copyQueue; RHI::Ptr<CommandQueue> 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); FramePacket* BeginFramePacket(CommandQueue* commandQueue);
void EndFramePacket(CommandQueue* commandQueue); void EndFramePacket(CommandQueue* commandQueue);
bool m_recordingFrame = false; bool m_recordingFrame = false;
AZStd::vector<FramePacket> m_framePackets; AZStd::vector<FramePacket> m_framePackets;
size_t m_frameIndex = 0; size_t m_frameIndex = 0;
Descriptor m_descriptor; Descriptor m_descriptor;
// Fence for external upload request // Fence for external upload request
Fence m_uploadFence; Fence m_uploadFence;
RHI::Ptr<Device> m_device; RHI::Ptr<Device> m_device;
//Command Buffer associated with the async copy queue //Command Buffer associated with the async copy queue
CommandQueueCommandBuffer m_commandBuffer; CommandQueueCommandBuffer m_commandBuffer;
@@ -28,7 +28,7 @@ namespace AZ
{ {
return aznew CommandList(); return aznew CommandList();
} }
void CommandList::Init(RHI::HardwareQueueClass hardwareQueueClass, Device* device) void CommandList::Init(RHI::HardwareQueueClass hardwareQueueClass, Device* device)
{ {
CommandListBase::Init(hardwareQueueClass, device); CommandListBase::Init(hardwareQueueClass, device);
@@ -39,13 +39,13 @@ namespace AZ
//Undefined symbols for architecture arm64: //Undefined symbols for architecture arm64:
// "_objc_memmove_collectable", referenced from: // "_objc_memmove_collectable", referenced from:
//We can come back and revisit this after upgrading the build server machines to Mojave. //We can come back and revisit this after upgrading the build server machines to Mojave.
m_state.m_pipelineState = nullptr; m_state.m_pipelineState = nullptr;
m_state.m_pipelineLayout = nullptr; m_state.m_pipelineLayout = nullptr;
m_state.m_streamsHash = AZ::HashValue64{0}; m_state.m_streamsHash = AZ::HashValue64{0};
m_state.m_indicesHash = AZ::HashValue64{0}; m_state.m_indicesHash = AZ::HashValue64{0};
m_state.m_stencilRef = -1; m_state.m_stencilRef = -1;
CommandListBase::Reset(); CommandListBase::Reset();
} }
@@ -59,11 +59,11 @@ namespace AZ
Reset(); Reset();
CommandListBase::FlushEncoder(); CommandListBase::FlushEncoder();
} }
void CommandList::Submit(const RHI::CopyItem& copyItem) void CommandList::Submit(const RHI::CopyItem& copyItem)
{ {
CreateEncoder(CommandEncoderType::Blit); CreateEncoder(CommandEncoderType::Blit);
id<MTLBlitCommandEncoder> blitEncoder = GetEncoder<id<MTLBlitCommandEncoder>>(); id<MTLBlitCommandEncoder> blitEncoder = GetEncoder<id<MTLBlitCommandEncoder>>();
switch (copyItem.m_type) switch (copyItem.m_type)
{ {
@@ -78,7 +78,7 @@ namespace AZ
toBuffer:destinationBuffer->GetMemoryView().GetGpuAddress<id<MTLBuffer>>() toBuffer:destinationBuffer->GetMemoryView().GetGpuAddress<id<MTLBuffer>>()
destinationOffset:descriptor.m_destinationOffset destinationOffset:descriptor.m_destinationOffset
size:descriptor.m_size]; size:descriptor.m_size];
Platform::SynchronizeBufferOnGPU(blitEncoder, destinationBuffer->GetMemoryView().GetGpuAddress<id<MTLBuffer>>()); Platform::SynchronizeBufferOnGPU(blitEncoder, destinationBuffer->GetMemoryView().GetGpuAddress<id<MTLBuffer>>());
break; break;
} }
@@ -87,19 +87,19 @@ namespace AZ
const RHI::CopyImageDescriptor& descriptor = copyItem.m_image; const RHI::CopyImageDescriptor& descriptor = copyItem.m_image;
const Image* sourceImage = static_cast<const Image*>(descriptor.m_sourceImage); const Image* sourceImage = static_cast<const Image*>(descriptor.m_sourceImage);
const Image* destinationImage = static_cast<const Image*>(descriptor.m_destinationImage); const Image* destinationImage = static_cast<const Image*>(descriptor.m_destinationImage);
MTLOrigin sourceOrigin = MTLOriginMake(descriptor.m_sourceOrigin.m_left, MTLOrigin sourceOrigin = MTLOriginMake(descriptor.m_sourceOrigin.m_left,
descriptor.m_sourceOrigin.m_top, descriptor.m_sourceOrigin.m_top,
descriptor.m_sourceOrigin.m_front); descriptor.m_sourceOrigin.m_front);
MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width, MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width,
descriptor.m_sourceSize.m_height, descriptor.m_sourceSize.m_height,
descriptor.m_sourceSize.m_depth); descriptor.m_sourceSize.m_depth);
MTLOrigin destinationOrigin = MTLOriginMake(descriptor.m_destinationOrigin.m_left, MTLOrigin destinationOrigin = MTLOriginMake(descriptor.m_destinationOrigin.m_left,
descriptor.m_destinationOrigin.m_top, descriptor.m_destinationOrigin.m_top,
descriptor.m_destinationOrigin.m_front); descriptor.m_destinationOrigin.m_front);
[blitEncoder copyFromTexture: sourceImage->GetMemoryView().GetGpuAddress<id<MTLTexture>>() [blitEncoder copyFromTexture: sourceImage->GetMemoryView().GetGpuAddress<id<MTLTexture>>()
sourceSlice: descriptor.m_sourceSubresource.m_arraySlice sourceSlice: descriptor.m_sourceSubresource.m_arraySlice
sourceLevel: descriptor.m_sourceSubresource.m_mipSlice sourceLevel: descriptor.m_sourceSubresource.m_mipSlice
@@ -109,7 +109,7 @@ namespace AZ
destinationSlice: descriptor.m_destinationSubresource.m_arraySlice destinationSlice: descriptor.m_destinationSubresource.m_arraySlice
destinationLevel: descriptor.m_destinationSubresource.m_mipSlice destinationLevel: descriptor.m_destinationSubresource.m_mipSlice
destinationOrigin: destinationOrigin]; destinationOrigin: destinationOrigin];
Platform::SynchronizeTextureOnGPU(blitEncoder, destinationImage->GetMemoryView().GetGpuAddress<id<MTLTexture>>()); Platform::SynchronizeTextureOnGPU(blitEncoder, destinationImage->GetMemoryView().GetGpuAddress<id<MTLTexture>>());
break; break;
} }
@@ -122,11 +122,11 @@ namespace AZ
MTLOrigin destinationOrigin = MTLOriginMake(descriptor.m_destinationOrigin.m_left, MTLOrigin destinationOrigin = MTLOriginMake(descriptor.m_destinationOrigin.m_left,
descriptor.m_destinationOrigin.m_top, descriptor.m_destinationOrigin.m_top,
descriptor.m_destinationOrigin.m_front); descriptor.m_destinationOrigin.m_front);
MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width, MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width,
descriptor.m_sourceSize.m_height, descriptor.m_sourceSize.m_height,
descriptor.m_sourceSize.m_depth); descriptor.m_sourceSize.m_depth);
[blitEncoder copyFromBuffer:sourceBuffer->GetMemoryView().GetGpuAddress<id<MTLBuffer>>() [blitEncoder copyFromBuffer:sourceBuffer->GetMemoryView().GetGpuAddress<id<MTLBuffer>>()
sourceOffset:sourceBuffer->GetMemoryView().GetOffset() + descriptor.m_sourceOffset sourceOffset:sourceBuffer->GetMemoryView().GetOffset() + descriptor.m_sourceOffset
sourceBytesPerRow:descriptor.m_sourceBytesPerRow sourceBytesPerRow:descriptor.m_sourceBytesPerRow
@@ -136,7 +136,7 @@ namespace AZ
destinationSlice:descriptor.m_destinationSubresource.m_arraySlice destinationSlice:descriptor.m_destinationSubresource.m_arraySlice
destinationLevel:descriptor.m_destinationSubresource.m_mipSlice destinationLevel:descriptor.m_destinationSubresource.m_mipSlice
destinationOrigin:destinationOrigin]; destinationOrigin:destinationOrigin];
Platform::SynchronizeTextureOnGPU(blitEncoder, destinationImage->GetMemoryView().GetGpuAddress<id<MTLTexture>>()); Platform::SynchronizeTextureOnGPU(blitEncoder, destinationImage->GetMemoryView().GetGpuAddress<id<MTLTexture>>());
break; break;
} }
@@ -145,15 +145,15 @@ namespace AZ
const RHI::CopyImageToBufferDescriptor& descriptor = copyItem.m_imageToBuffer; const RHI::CopyImageToBufferDescriptor& descriptor = copyItem.m_imageToBuffer;
const auto* sourceImage = static_cast<const Image*>(descriptor.m_sourceImage); const auto* sourceImage = static_cast<const Image*>(descriptor.m_sourceImage);
const auto* destinationBuffer = static_cast<const Buffer*>(descriptor.m_destinationBuffer); const auto* destinationBuffer = static_cast<const Buffer*>(descriptor.m_destinationBuffer);
MTLOrigin sourceOrigin = MTLOriginMake(descriptor.m_sourceOrigin.m_left, MTLOrigin sourceOrigin = MTLOriginMake(descriptor.m_sourceOrigin.m_left,
descriptor.m_sourceOrigin.m_top, descriptor.m_sourceOrigin.m_top,
descriptor.m_sourceOrigin.m_front); descriptor.m_sourceOrigin.m_front);
MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width, MTLSize sourceSize = MTLSizeMake(descriptor.m_sourceSize.m_width,
descriptor.m_sourceSize.m_height, descriptor.m_sourceSize.m_height,
descriptor.m_sourceSize.m_depth); descriptor.m_sourceSize.m_depth);
[blitEncoder copyFromTexture:sourceImage->GetMemoryView().GetGpuAddress<id<MTLTexture>>() [blitEncoder copyFromTexture:sourceImage->GetMemoryView().GetGpuAddress<id<MTLTexture>>()
sourceSlice:descriptor.m_sourceSubresource.m_arraySlice sourceSlice:descriptor.m_sourceSubresource.m_arraySlice
sourceLevel:descriptor.m_sourceSubresource.m_mipSlice sourceLevel:descriptor.m_sourceSubresource.m_mipSlice
@@ -163,7 +163,7 @@ namespace AZ
destinationOffset:destinationBuffer->GetMemoryView().GetOffset() + descriptor.m_destinationOffset destinationOffset:destinationBuffer->GetMemoryView().GetOffset() + descriptor.m_destinationOffset
destinationBytesPerRow:descriptor.m_destinationBytesPerRow destinationBytesPerRow:descriptor.m_destinationBytesPerRow
destinationBytesPerImage:descriptor.m_destinationBytesPerImage]; destinationBytesPerImage:descriptor.m_destinationBytesPerImage];
Platform::SynchronizeBufferOnGPU(blitEncoder, destinationBuffer->GetMemoryView().GetGpuAddress<id<MTLBuffer>>()); Platform::SynchronizeBufferOnGPU(blitEncoder, destinationBuffer->GetMemoryView().GetGpuAddress<id<MTLBuffer>>());
break; break;
} }
@@ -173,27 +173,27 @@ namespace AZ
} }
} }
} }
void CommandList::Submit(const RHI::DispatchItem& dispatchItem) void CommandList::Submit(const RHI::DispatchItem& dispatchItem)
{ {
AZ_PROFILE_FUNCTION(RHI); AZ_PROFILE_FUNCTION(RHI);
CreateEncoder(CommandEncoderType::Compute); CreateEncoder(CommandEncoderType::Compute);
bool bindResourceSuccessfull = CommitShaderResources<RHI::PipelineStateType::Dispatch>(dispatchItem); bool bindResourceSuccessfull = CommitShaderResources<RHI::PipelineStateType::Dispatch>(dispatchItem);
if(!bindResourceSuccessfull) if(!bindResourceSuccessfull)
{ {
AZ_Assert(false, "Resource binding was unsuccessfully."); AZ_Assert(false, "Resource binding was unsuccessfully.");
return; return;
} }
const RHI::DispatchDirect& arguments = dispatchItem.m_arguments.m_direct; 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()}; MTLSize numThreadGroup = {arguments.GetNumberOfGroupsX(), arguments.GetNumberOfGroupsY(), arguments.GetNumberOfGroupsZ()};
id<MTLComputeCommandEncoder> computeEncoder = GetEncoder<id<MTLComputeCommandEncoder>>(); id<MTLComputeCommandEncoder> computeEncoder = GetEncoder<id<MTLComputeCommandEncoder>>();
[computeEncoder dispatchThreadgroups: numThreadGroup [computeEncoder dispatchThreadgroups: numThreadGroup
threadsPerThreadgroup: threadsPerGroup]; threadsPerThreadgroup: threadsPerGroup];
} }
void CommandList::Submit(const RHI::DispatchRaysItem& dispatchRaysItem) void CommandList::Submit(const RHI::DispatchRaysItem& dispatchRaysItem)
@@ -204,14 +204,14 @@ namespace AZ
void CommandList::SetViewports(const RHI::Viewport* rhiViewports, uint32_t count) void CommandList::SetViewports(const RHI::Viewport* rhiViewports, uint32_t count)
{ {
m_state.m_viewportState.Set(AZStd::array_view<RHI::Viewport>(rhiViewports, count)); m_state.m_viewportState.Set(AZStd::span<const RHI::Viewport>(rhiViewports, count));
} }
void CommandList::SetScissors(const RHI::Scissor* rhiScissors, uint32_t count) void CommandList::SetScissors(const RHI::Scissor* rhiScissors, uint32_t count)
{ {
m_state.m_scissorState.Set(AZStd::array_view<RHI::Scissor>(rhiScissors, count)); m_state.m_scissorState.Set(AZStd::span<const RHI::Scissor>(rhiScissors, count));
} }
template <typename Item> template <typename Item>
void CommandList::SetRootConstants(const Item& item, const PipelineState* pipelineState) void CommandList::SetRootConstants(const Item& item, const PipelineState* pipelineState)
{ {
@@ -221,15 +221,15 @@ namespace AZ
if(m_commandEncoderType == CommandEncoderType::Render) if(m_commandEncoderType == CommandEncoderType::Render)
{ {
id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>(); id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>();
[renderEncoder setVertexBytes: item.m_rootConstants [renderEncoder setVertexBytes: item.m_rootConstants
length: pipelineLayout.GetRootConstantsSize() length: pipelineLayout.GetRootConstantsSize()
atIndex: pipelineLayout.GetRootConstantsSlotIndex()]; atIndex: pipelineLayout.GetRootConstantsSlotIndex()];
[renderEncoder setFragmentBytes: item.m_rootConstants [renderEncoder setFragmentBytes: item.m_rootConstants
length: pipelineLayout.GetRootConstantsSize() length: pipelineLayout.GetRootConstantsSize()
atIndex: pipelineLayout.GetRootConstantsSlotIndex()]; atIndex: pipelineLayout.GetRootConstantsSlotIndex()];
} }
else if(m_commandEncoderType == CommandEncoderType::Compute) else if(m_commandEncoderType == CommandEncoderType::Compute)
{ {
@@ -237,39 +237,39 @@ namespace AZ
[computeEncoder setBytes: item.m_rootConstants [computeEncoder setBytes: item.m_rootConstants
length: pipelineLayout.GetRootConstantsSize() length: pipelineLayout.GetRootConstantsSize()
atIndex: pipelineLayout.GetRootConstantsSlotIndex()]; atIndex: pipelineLayout.GetRootConstantsSlotIndex()];
} }
} }
} }
bool CommandList::SetArgumentBuffers(const PipelineState* pipelineState, RHI::PipelineStateType stateType) bool CommandList::SetArgumentBuffers(const PipelineState* pipelineState, RHI::PipelineStateType stateType)
{ {
bool bindNullDescriptorHeap = false; bool bindNullDescriptorHeap = false;
MTLRenderStages mtlRenderStagesForNullDescHeap = 0; MTLRenderStages mtlRenderStagesForNullDescHeap = 0;
ShaderResourceBindings& bindings = GetShaderResourceBindingsByPipelineType(stateType); ShaderResourceBindings& bindings = GetShaderResourceBindingsByPipelineType(stateType);
const PipelineLayout& pipelineLayout = pipelineState->GetPipelineLayout(); const PipelineLayout& pipelineLayout = pipelineState->GetPipelineLayout();
uint32_t bufferVertexRegisterIdMin = RHI::Limits::Pipeline::ShaderResourceGroupCountMax; uint32_t bufferVertexRegisterIdMin = RHI::Limits::Pipeline::ShaderResourceGroupCountMax;
uint32_t bufferFragmentOrComputeRegisterIdMin = RHI::Limits::Pipeline::ShaderResourceGroupCountMax; uint32_t bufferFragmentOrComputeRegisterIdMin = RHI::Limits::Pipeline::ShaderResourceGroupCountMax;
uint32_t bufferVertexRegisterIdMax = 0; uint32_t bufferVertexRegisterIdMax = 0;
uint32_t bufferFragmentOrComputeRegisterIdMax = 0; uint32_t bufferFragmentOrComputeRegisterIdMax = 0;
//Arrays to cache all the buffers and offsets in order to make batch calls //Arrays to cache all the buffers and offsets in order to make batch calls
MetalArgumentBufferArray mtlVertexArgBuffers; MetalArgumentBufferArray mtlVertexArgBuffers;
MetalArgumentBufferArrayOffsets mtlVertexArgBufferOffsets; MetalArgumentBufferArrayOffsets mtlVertexArgBufferOffsets;
MetalArgumentBufferArray mtlFragmentOrComputeArgBuffers; MetalArgumentBufferArray mtlFragmentOrComputeArgBuffers;
MetalArgumentBufferArrayOffsets mtlFragmentOrComputeArgBufferOffsets; MetalArgumentBufferArrayOffsets mtlFragmentOrComputeArgBufferOffsets;
mtlVertexArgBuffers.fill(nil); mtlVertexArgBuffers.fill(nil);
mtlFragmentOrComputeArgBuffers.fill(nil); mtlFragmentOrComputeArgBuffers.fill(nil);
mtlVertexArgBufferOffsets.fill(0); mtlVertexArgBufferOffsets.fill(0);
mtlFragmentOrComputeArgBufferOffsets.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 //Map to cache all the resources based on the usage as we can batch all the resources for a given usage
ArgumentBuffer::ComputeResourcesToMakeResidentMap resourcesToMakeResidentCompute; 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 //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; ArgumentBuffer::GraphicsResourcesToMakeResidentMap resourcesToMakeResidentGraphics;
for (uint32_t slot = 0; slot < RHI::Limits::Pipeline::ShaderResourceGroupCountMax; ++slot) for (uint32_t slot = 0; slot < RHI::Limits::Pipeline::ShaderResourceGroupCountMax; ++slot)
{ {
const ShaderResourceGroup* shaderResourceGroup = bindings.m_srgsBySlot[slot]; const ShaderResourceGroup* shaderResourceGroup = bindings.m_srgsBySlot[slot];
@@ -282,7 +282,7 @@ namespace AZ
uint32_t srgVisIndex = pipelineLayout.GetIndexBySlot(shaderResourceGroup->GetBindingSlot()); uint32_t srgVisIndex = pipelineLayout.GetIndexBySlot(shaderResourceGroup->GetBindingSlot());
const RHI::ShaderStageMask& srgVisInfo = pipelineLayout.GetSrgVisibility(srgVisIndex); const RHI::ShaderStageMask& srgVisInfo = pipelineLayout.GetSrgVisibility(srgVisIndex);
const ShaderResourceGroupVisibility& srgResourcesVisInfo = pipelineLayout.GetSrgResourcesVisibility(srgVisIndex); const ShaderResourceGroupVisibility& srgResourcesVisInfo = pipelineLayout.GetSrgResourcesVisibility(srgVisIndex);
bool isSrgUpdatd = bindings.m_srgsByIndex[slot] != shaderResourceGroup; bool isSrgUpdatd = bindings.m_srgsByIndex[slot] != shaderResourceGroup;
if(isSrgUpdatd) if(isSrgUpdatd)
{ {
@@ -290,12 +290,12 @@ namespace AZ
auto& compiledArgBuffer = shaderResourceGroup->GetCompiledArgumentBuffer(); auto& compiledArgBuffer = shaderResourceGroup->GetCompiledArgumentBuffer();
id<MTLBuffer> argBuffer = compiledArgBuffer.GetArgEncoderBuffer(); id<MTLBuffer> argBuffer = compiledArgBuffer.GetArgEncoderBuffer();
size_t argBufferOffset = compiledArgBuffer.GetOffset(); size_t argBufferOffset = compiledArgBuffer.GetOffset();
if(srgVisInfo != RHI::ShaderStageMask::None) if(srgVisInfo != RHI::ShaderStageMask::None)
{ {
bool isNullDescHeapNeeded = compiledArgBuffer.IsNullDescHeapNeeded(); bool isNullDescHeapNeeded = compiledArgBuffer.IsNullDescHeapNeeded();
bindNullDescriptorHeap |= isNullDescHeapNeeded; bindNullDescriptorHeap |= isNullDescHeapNeeded;
//For graphics and compute shader stages, cache all the argument buffers, offsets and track the min/max indices //For graphics and compute shader stages, cache all the argument buffers, offsets and track the min/max indices
if(m_commandEncoderType == CommandEncoderType::Render) if(m_commandEncoderType == CommandEncoderType::Render)
{ {
@@ -305,11 +305,11 @@ namespace AZ
mtlVertexArgBuffers[slotIndex] = argBuffer; mtlVertexArgBuffers[slotIndex] = argBuffer;
mtlVertexArgBufferOffsets[slotIndex] = argBufferOffset; mtlVertexArgBufferOffsets[slotIndex] = argBufferOffset;
bufferVertexRegisterIdMin = AZStd::min(slotIndex, bufferVertexRegisterIdMin); bufferVertexRegisterIdMin = AZStd::min(slotIndex, bufferVertexRegisterIdMin);
bufferVertexRegisterIdMax = AZStd::max(slotIndex, bufferVertexRegisterIdMax); bufferVertexRegisterIdMax = AZStd::max(slotIndex, bufferVertexRegisterIdMax);
mtlRenderStagesForNullDescHeap = shaderResourceGroup->IsNullHeapNeededForVertexStage(srgResourcesVisInfo) ? mtlRenderStagesForNullDescHeap = shaderResourceGroup->IsNullHeapNeededForVertexStage(srgResourcesVisInfo) ?
mtlRenderStagesForNullDescHeap | MTLRenderStageVertex : mtlRenderStagesForNullDescHeap; mtlRenderStagesForNullDescHeap | MTLRenderStageVertex : mtlRenderStagesForNullDescHeap;
} }
if( numBitsSet > 1 || srgVisInfo == RHI::ShaderStageMask::Fragment) if( numBitsSet > 1 || srgVisInfo == RHI::ShaderStageMask::Fragment)
{ {
mtlFragmentOrComputeArgBuffers[slotIndex] = argBuffer; 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 //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. //as it is possible for draw items to have different PSOs in the same pass.
const AZ::HashValue64 srgResourcesVisHash = pipelineLayout.GetSrgResourcesVisibilityHash(srgVisIndex); const AZ::HashValue64 srgResourcesVisHash = pipelineLayout.GetSrgResourcesVisibilityHash(srgVisIndex);
@@ -337,8 +337,8 @@ namespace AZ
bindings.m_srgVisHashByIndex[slot] = srgResourcesVisHash; bindings.m_srgVisHashByIndex[slot] = srgResourcesVisHash;
if(srgVisInfo != RHI::ShaderStageMask::None) if(srgVisInfo != RHI::ShaderStageMask::None)
{ {
//For graphics and compute encoder make the resource resident (call UseResource) for the duration //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 //of the work associated with the current scope and ensure that it's in a
//format compatible with the appropriate metal function. //format compatible with the appropriate metal function.
@@ -353,7 +353,7 @@ namespace AZ
} }
} }
} }
//For graphics and compute encoder bind all the argument buffers //For graphics and compute encoder bind all the argument buffers
if(m_commandEncoderType == CommandEncoderType::Render) if(m_commandEncoderType == CommandEncoderType::Render)
{ {
@@ -362,7 +362,7 @@ namespace AZ
bufferVertexRegisterIdMax, bufferVertexRegisterIdMax,
mtlVertexArgBuffers, mtlVertexArgBuffers,
mtlVertexArgBufferOffsets); mtlVertexArgBufferOffsets);
BindArgumentBuffers(RHI::ShaderStage::Fragment, BindArgumentBuffers(RHI::ShaderStage::Fragment,
bufferFragmentOrComputeRegisterIdMin, bufferFragmentOrComputeRegisterIdMin,
bufferFragmentOrComputeRegisterIdMax, bufferFragmentOrComputeRegisterIdMax,
@@ -377,40 +377,40 @@ namespace AZ
mtlFragmentOrComputeArgBuffers, mtlFragmentOrComputeArgBuffers,
mtlFragmentOrComputeArgBufferOffsets); mtlFragmentOrComputeArgBufferOffsets);
} }
id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>(); id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>();
id<MTLComputeCommandEncoder> computeEncoder = GetEncoder<id<MTLComputeCommandEncoder>>(); id<MTLComputeCommandEncoder> computeEncoder = GetEncoder<id<MTLComputeCommandEncoder>>();
//Call UseResource on all resources for Compute stage //Call UseResource on all resources for Compute stage
for (const auto& key : resourcesToMakeResidentCompute) for (const auto& key : resourcesToMakeResidentCompute)
{ {
AZStd::vector<id <MTLResource>> resourcesToProcessVec(key.second.begin(), key.second.end()); AZStd::vector<id <MTLResource>> resourcesToProcessVec(key.second.begin(), key.second.end());
[computeEncoder useResources: &resourcesToProcessVec[0] [computeEncoder useResources: &resourcesToProcessVec[0]
count: resourcesToProcessVec.size() count: resourcesToProcessVec.size()
usage: key.first]; usage: key.first];
} }
//Call UseResource on all resources for Vertex and Fragment stages //Call UseResource on all resources for Vertex and Fragment stages
for (const auto& key : resourcesToMakeResidentGraphics) for (const auto& key : resourcesToMakeResidentGraphics)
{ {
AZStd::vector<id <MTLResource>> resourcesToProcessVec(key.second.begin(), key.second.end()); AZStd::vector<id <MTLResource>> resourcesToProcessVec(key.second.begin(), key.second.end());
[renderEncoder useResources: &resourcesToProcessVec[0] [renderEncoder useResources: &resourcesToProcessVec[0]
count: resourcesToProcessVec.size() count: resourcesToProcessVec.size()
usage: key.first.first usage: key.first.first
stages: key.first.second]; stages: key.first.second];
} }
if(bindNullDescriptorHeap) if(bindNullDescriptorHeap)
{ {
MakeHeapsResident(mtlRenderStagesForNullDescHeap); MakeHeapsResident(mtlRenderStagesForNullDescHeap);
} }
return true; return true;
} }
void CommandList::BindArgumentBuffers(RHI::ShaderStage shaderStage, void CommandList::BindArgumentBuffers(RHI::ShaderStage shaderStage,
uint16_t registerIdMin, uint16_t registerIdMin,
uint16_t registerIdMax, uint16_t registerIdMax,
@@ -428,7 +428,7 @@ namespace AZ
if(mtlArgBuffers[i] == nil) if(mtlArgBuffers[i] == nil)
{ {
NSRange range = { startingIndex, i-startingIndex }; NSRange range = { startingIndex, i-startingIndex };
switch(shaderStage) switch(shaderStage)
{ {
case RHI::ShaderStage::Vertex: case RHI::ShaderStage::Vertex:
@@ -462,7 +462,7 @@ namespace AZ
} }
trackingRange = false; trackingRange = false;
} }
} }
else else
@@ -475,13 +475,13 @@ namespace AZ
} }
} }
} }
void CommandList::Submit(const RHI::DrawItem& drawItem) void CommandList::Submit(const RHI::DrawItem& drawItem)
{ {
AZ_PROFILE_FUNCTION(RHI); AZ_PROFILE_FUNCTION(RHI);
CreateEncoder(CommandEncoderType::Render); CreateEncoder(CommandEncoderType::Render);
RHI::CommandListScissorState scissorState; RHI::CommandListScissorState scissorState;
if (drawItem.m_scissorsCount) if (drawItem.m_scissorsCount)
{ {
@@ -496,15 +496,15 @@ namespace AZ
} }
CommitViewportState(); CommitViewportState();
CommitScissorState(); CommitScissorState();
const PipelineState* pipelineState = static_cast<const PipelineState*>(drawItem.m_pipelineState); const PipelineState* pipelineState = static_cast<const PipelineState*>(drawItem.m_pipelineState);
AZ_Assert(pipelineState, "PipelineState can not be null"); AZ_Assert(pipelineState, "PipelineState can not be null");
if(m_renderPassMultiSampleState != pipelineState->m_pipelineStateMultiSampleState) if(m_renderPassMultiSampleState != pipelineState->m_pipelineStateMultiSampleState)
{ {
AZ_Assert(false,"MultisampleState in the image descriptor needs to match the one provided in the pipeline state"); AZ_Assert(false,"MultisampleState in the image descriptor needs to match the one provided in the pipeline state");
} }
id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>(); id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>();
bool bindResourceSuccessfull = CommitShaderResources<RHI::PipelineStateType::Draw>(drawItem); bool bindResourceSuccessfull = CommitShaderResources<RHI::PipelineStateType::Draw>(drawItem);
if(!bindResourceSuccessfull) if(!bindResourceSuccessfull)
@@ -512,21 +512,21 @@ namespace AZ
AZ_Assert(false, "Resource binding was unsuccessfully."); AZ_Assert(false, "Resource binding was unsuccessfully.");
return; return;
} }
SetStreamBuffers(drawItem.m_streamBufferViews, drawItem.m_streamBufferViewCount); SetStreamBuffers(drawItem.m_streamBufferViews, drawItem.m_streamBufferViewCount);
SetStencilRef(drawItem.m_stencilRef); SetStencilRef(drawItem.m_stencilRef);
MTLPrimitiveType mtlPrimType = pipelineState->GetPipelineTopology(); MTLPrimitiveType mtlPrimType = pipelineState->GetPipelineTopology();
switch (drawItem.m_arguments.m_type) switch (drawItem.m_arguments.m_type)
{ {
case RHI::DrawType::Indexed: case RHI::DrawType::Indexed:
{ {
const RHI::DrawIndexed& indexed = drawItem.m_arguments.m_indexed; const RHI::DrawIndexed& indexed = drawItem.m_arguments.m_indexed;
const RHI::IndexBufferView& indexBuffDescriptor = *drawItem.m_indexBufferView; const RHI::IndexBufferView& indexBuffDescriptor = *drawItem.m_indexBufferView;
AZ::HashValue64 indicesHash = indexBuffDescriptor.GetHash(); AZ::HashValue64 indicesHash = indexBuffDescriptor.GetHash();
m_state.m_indicesHash = indicesHash; m_state.m_indicesHash = indicesHash;
const Buffer * buff = static_cast<const Buffer*>(indexBuffDescriptor.GetBuffer()); const Buffer * buff = static_cast<const Buffer*>(indexBuffDescriptor.GetBuffer());
id<MTLBuffer> mtlBuff = buff->GetMemoryView().GetGpuAddress<id<MTLBuffer>>(); id<MTLBuffer> mtlBuff = buff->GetMemoryView().GetGpuAddress<id<MTLBuffer>>();
@@ -534,7 +534,7 @@ namespace AZ
MTLIndexTypeUInt16 : MTLIndexTypeUInt32; MTLIndexTypeUInt16 : MTLIndexTypeUInt32;
uint32_t indexTypeSize = 0; uint32_t indexTypeSize = 0;
GetIndexTypeSizeInBytes(mtlIndexType, indexTypeSize); GetIndexTypeSizeInBytes(mtlIndexType, indexTypeSize);
uint32_t indexOffset = indexBuffDescriptor.GetByteOffset() + (indexed.m_indexOffset * indexTypeSize) + buff->GetMemoryView().GetOffset(); uint32_t indexOffset = indexBuffDescriptor.GetByteOffset() + (indexed.m_indexOffset * indexTypeSize) + buff->GetMemoryView().GetOffset();
[renderEncoder drawIndexedPrimitives: mtlPrimType [renderEncoder drawIndexedPrimitives: mtlPrimType
indexCount: indexed.m_indexCount indexCount: indexed.m_indexCount
@@ -546,15 +546,15 @@ namespace AZ
baseInstance: indexed.m_instanceOffset]; baseInstance: indexed.m_instanceOffset];
break; break;
} }
case RHI::DrawType::Linear: case RHI::DrawType::Linear:
{ {
const RHI::DrawLinear& linear = drawItem.m_arguments.m_linear; const RHI::DrawLinear& linear = drawItem.m_arguments.m_linear;
[renderEncoder drawPrimitives: mtlPrimType [renderEncoder drawPrimitives: mtlPrimType
vertexStart: linear.m_vertexOffset vertexStart: linear.m_vertexOffset
vertexCount: linear.m_vertexCount vertexCount: linear.m_vertexCount
instanceCount: linear.m_instanceCount instanceCount: linear.m_instanceCount
baseInstance: linear.m_instanceOffset]; baseInstance: linear.m_instanceOffset];
break; break;
} }
} }
@@ -576,7 +576,7 @@ namespace AZ
{ {
CommandListBase::Shutdown(); CommandListBase::Shutdown();
} }
void CommandList::SetPipelineState(const PipelineState* pipelineState) void CommandList::SetPipelineState(const PipelineState* pipelineState)
{ {
if (m_state.m_pipelineState != pipelineState) if (m_state.m_pipelineState != pipelineState)
@@ -608,7 +608,7 @@ namespace AZ
AZ_Assert(false, "Type not supported."); AZ_Assert(false, "Type not supported.");
} }
} }
ShaderResourceBindings& bindings = GetShaderResourceBindingsByPipelineType(pipelineState->GetType()); ShaderResourceBindings& bindings = GetShaderResourceBindingsByPipelineType(pipelineState->GetType());
for (size_t i = 0; i < bindings.m_srgsByIndex.size(); ++i) for (size_t i = 0; i < bindings.m_srgsByIndex.size(); ++i)
{ {
@@ -623,7 +623,7 @@ namespace AZ
} }
} }
} }
void CommandList::SetStencilRef(uint8_t stencilRef) void CommandList::SetStencilRef(uint8_t stencilRef)
{ {
if (m_state.m_stencilRef != stencilRef) if (m_state.m_stencilRef != stencilRef)
@@ -633,24 +633,24 @@ namespace AZ
m_state.m_stencilRef = stencilRef; m_state.m_stencilRef = stencilRef;
} }
} }
void CommandList::SetStreamBuffers(const RHI::StreamBufferView* streams, uint32_t count) void CommandList::SetStreamBuffers(const RHI::StreamBufferView* streams, uint32_t count)
{ {
uint16_t bufferArrayLen = 0; uint16_t bufferArrayLen = 0;
AZStd::array<id<MTLBuffer>, METAL_MAX_ENTRIES_BUFFER_ARG_TABLE> mtlStreamBuffers; AZStd::array<id<MTLBuffer>, METAL_MAX_ENTRIES_BUFFER_ARG_TABLE> mtlStreamBuffers;
AZStd::array<NSUInteger, METAL_MAX_ENTRIES_BUFFER_ARG_TABLE> mtlStreamBufferOffsets; AZStd::array<NSUInteger, METAL_MAX_ENTRIES_BUFFER_ARG_TABLE> mtlStreamBufferOffsets;
AZ::HashValue64 streamsHash = AZ::HashValue64{0}; AZ::HashValue64 streamsHash = AZ::HashValue64{0};
for (uint32_t i = 0; i < count; ++i) for (uint32_t i = 0; i < count; ++i)
{ {
streamsHash = AZ::TypeHash64(streamsHash, streams[i].GetHash()); streamsHash = AZ::TypeHash64(streamsHash, streams[i].GetHash());
} }
if (streamsHash != m_state.m_streamsHash) if (streamsHash != m_state.m_streamsHash)
{ {
m_state.m_streamsHash = 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"); 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}; 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 //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) for (int i = count-1; i >= 0; --i)
@@ -671,7 +671,7 @@ namespace AZ
withRange: range]; withRange: range];
} }
} }
void CommandList::SetRasterizerState(const RasterizerState& rastState) void CommandList::SetRasterizerState(const RasterizerState& rastState)
{ {
id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>(); id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>();
@@ -681,17 +681,17 @@ namespace AZ
[renderEncoder setTriangleFillMode: rastState.m_triangleFillMode]; [renderEncoder setTriangleFillMode: rastState.m_triangleFillMode];
[renderEncoder setDepthClipMode: rastState.m_depthClipMode]; [renderEncoder setDepthClipMode: rastState.m_depthClipMode];
} }
void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup) void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup)
{ {
SetShaderResourceGroup<RHI::PipelineStateType::Draw>(static_cast<const ShaderResourceGroup*>(&shaderResourceGroup)); SetShaderResourceGroup<RHI::PipelineStateType::Draw>(static_cast<const ShaderResourceGroup*>(&shaderResourceGroup));
} }
void CommandList::SetShaderResourceGroupForDispatch(const RHI::ShaderResourceGroup& shaderResourceGroup) void CommandList::SetShaderResourceGroupForDispatch(const RHI::ShaderResourceGroup& shaderResourceGroup)
{ {
SetShaderResourceGroup<RHI::PipelineStateType::Dispatch>(static_cast<const ShaderResourceGroup*>(&shaderResourceGroup)); SetShaderResourceGroup<RHI::PipelineStateType::Dispatch>(static_cast<const ShaderResourceGroup*>(&shaderResourceGroup));
} }
CommandList::ShaderResourceBindings& CommandList::GetShaderResourceBindingsByPipelineType(RHI::PipelineStateType pipelineType) CommandList::ShaderResourceBindings& CommandList::GetShaderResourceBindingsByPipelineType(RHI::PipelineStateType pipelineType)
{ {
return m_state.m_bindingsByPipe[static_cast<size_t>(pipelineType)]; return m_state.m_bindingsByPipe[static_cast<size_t>(pipelineType)];
@@ -706,15 +706,15 @@ namespace AZ
AZ_Assert(false, "Pipeline state not provided"); AZ_Assert(false, "Pipeline state not provided");
return false; return false;
} }
SetPipelineState(pipelineState); SetPipelineState(pipelineState);
// Assign shader resource groups from the item to slot bindings. // Assign shader resource groups from the item to slot bindings.
for (uint32_t srgIndex = 0; srgIndex < item.m_shaderResourceGroupCount; ++srgIndex) for (uint32_t srgIndex = 0; srgIndex < item.m_shaderResourceGroupCount; ++srgIndex)
{ {
SetShaderResourceGroup<pipelineType>(static_cast<const ShaderResourceGroup*>(item.m_shaderResourceGroups[srgIndex])); SetShaderResourceGroup<pipelineType>(static_cast<const ShaderResourceGroup*>(item.m_shaderResourceGroups[srgIndex]));
} }
if (item.m_uniqueShaderResourceGroup) if (item.m_uniqueShaderResourceGroup)
{ {
SetShaderResourceGroup<pipelineType>(static_cast<const ShaderResourceGroup*>(item.m_uniqueShaderResourceGroup)); SetShaderResourceGroup<pipelineType>(static_cast<const ShaderResourceGroup*>(item.m_uniqueShaderResourceGroup));
@@ -730,7 +730,7 @@ namespace AZ
{ {
return; return;
} }
AZ_PROFILE_FUNCTION(RHI); AZ_PROFILE_FUNCTION(RHI);
const auto& viewports = m_state.m_viewportState.m_states; const auto& viewports = m_state.m_viewportState.m_states;
MTLViewport metalViewports[viewports.size()]; MTLViewport metalViewports[viewports.size()];
@@ -744,7 +744,7 @@ namespace AZ
metalViewports[i].znear = viewports[i].m_minZ; metalViewports[i].znear = viewports[i].m_minZ;
metalViewports[i].zfar = viewports[i].m_maxZ; metalViewports[i].zfar = viewports[i].m_maxZ;
} }
id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>(); id<MTLRenderCommandEncoder> renderEncoder = GetEncoder<id<MTLRenderCommandEncoder>>();
[renderEncoder setViewports: metalViewports [renderEncoder setViewports: metalViewports
count: viewports.size()]; count: viewports.size()];
@@ -760,7 +760,7 @@ namespace AZ
AZStd::array<MTLScissorRect, MaxScissorsAllowed> metalScissorRects; AZStd::array<MTLScissorRect, MaxScissorsAllowed> metalScissorRects;
const auto& scissors = m_state.m_scissorState.m_states; const auto& scissors = m_state.m_scissorState.m_states;
AZ_Assert(scissors.size() <= MaxScissorsAllowed , "Number of scissors violate the maximum number of scissors allowed"); AZ_Assert(scissors.size() <= MaxScissorsAllowed , "Number of scissors violate the maximum number of scissors allowed");
for (uint32_t i = 0; i < scissors.size(); ++i) for (uint32_t i = 0; i < scissors.size(); ++i)
{ {
@@ -27,7 +27,7 @@ namespace AZ
{ {
} }
RHI::ResultCode PipelineLibrary::MergeIntoInternal(AZStd::array_view<const RHI::PipelineLibrary*> pipelineLibraries) RHI::ResultCode PipelineLibrary::MergeIntoInternal(AZStd::span<const RHI::PipelineLibrary* const> pipelineLibraries)
{ {
return RHI::ResultCode::Success; return RHI::ResultCode::Success;
} }
@@ -30,7 +30,7 @@ namespace AZ
// RHI::PipelineLibrary // RHI::PipelineLibrary
RHI::ResultCode InitInternal(RHI::Device& device, const RHI::PipelineLibraryData* serializedData) override; RHI::ResultCode InitInternal(RHI::Device& device, const RHI::PipelineLibraryData* serializedData) override;
void ShutdownInternal() override; void ShutdownInternal() override;
RHI::ResultCode MergeIntoInternal(AZStd::array_view<const RHI::PipelineLibrary*> libraries) override; RHI::ResultCode MergeIntoInternal(AZStd::span<const RHI::PipelineLibrary* const> libraries) override;
RHI::ConstPtr<RHI::PipelineLibraryData> GetSerializedDataInternal() const override; RHI::ConstPtr<RHI::PipelineLibraryData> GetSerializedDataInternal() const override;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -37,7 +37,7 @@ namespace AZ
RHI::ResultCode ShaderResourceGroupPool::InitGroupInternal(RHI::ShaderResourceGroup& groupBase) RHI::ResultCode ShaderResourceGroupPool::InitGroupInternal(RHI::ShaderResourceGroup& groupBase)
{ {
ShaderResourceGroup& group = static_cast<ShaderResourceGroup&>(groupBase); ShaderResourceGroup& group = static_cast<ShaderResourceGroup&>(groupBase);
for (size_t i = 0; i < RHI::Limits::Device::FrameCountMax; ++i) for (size_t i = 0; i < RHI::Limits::Device::FrameCountMax; ++i)
{ {
auto argBuffer = ArgumentBuffer::Create(); auto argBuffer = ArgumentBuffer::Create();
@@ -82,7 +82,7 @@ namespace AZ
for (const RHI::ShaderInputImageDescriptor& shaderInputImage : layout->GetShaderInputListForImages()) for (const RHI::ShaderInputImageDescriptor& shaderInputImage : layout->GetShaderInputListForImages())
{ {
const RHI::ShaderInputImageIndex imageInputIndex(shaderInputIndex); const RHI::ShaderInputImageIndex imageInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> imageViews = groupData.GetImageViewArray(imageInputIndex); AZStd::span<const RHI::ConstPtr<RHI::ImageView>> imageViews = groupData.GetImageViewArray(imageInputIndex);
argBuffer.UpdateImageViews(shaderInputImage, imageInputIndex, imageViews); argBuffer.UpdateImageViews(shaderInputImage, imageInputIndex, imageViews);
++shaderInputIndex; ++shaderInputIndex;
} }
@@ -91,7 +91,7 @@ namespace AZ
for (const RHI::ShaderInputSamplerDescriptor& shaderInputSampler : layout->GetShaderInputListForSamplers()) for (const RHI::ShaderInputSamplerDescriptor& shaderInputSampler : layout->GetShaderInputListForSamplers())
{ {
const RHI::ShaderInputSamplerIndex samplerInputIndex(shaderInputIndex); const RHI::ShaderInputSamplerIndex samplerInputIndex(shaderInputIndex);
AZStd::array_view<RHI::SamplerState> samplerStates = groupData.GetSamplerArray(samplerInputIndex); AZStd::span<const RHI::SamplerState> samplerStates = groupData.GetSamplerArray(samplerInputIndex);
argBuffer.UpdateSamplers(shaderInputSampler, samplerInputIndex, samplerStates); argBuffer.UpdateSamplers(shaderInputSampler, samplerInputIndex, samplerStates);
++shaderInputIndex; ++shaderInputIndex;
} }
@@ -100,7 +100,7 @@ namespace AZ
for (const RHI::ShaderInputBufferDescriptor& shaderInputBuffer : layout->GetShaderInputListForBuffers()) for (const RHI::ShaderInputBufferDescriptor& shaderInputBuffer : layout->GetShaderInputListForBuffers())
{ {
const RHI::ShaderInputBufferIndex bufferInputIndex(shaderInputIndex); const RHI::ShaderInputBufferIndex bufferInputIndex(shaderInputIndex);
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> bufferViews = groupData.GetBufferViewArray(bufferInputIndex); AZStd::span<const RHI::ConstPtr<RHI::BufferView>> bufferViews = groupData.GetBufferViewArray(bufferInputIndex);
argBuffer.UpdateBufferViews(shaderInputBuffer, bufferInputIndex, bufferViews); argBuffer.UpdateBufferViews(shaderInputBuffer, bufferInputIndex, bufferViews);
++shaderInputIndex; ++shaderInputIndex;
} }
@@ -30,7 +30,7 @@ namespace AZ
// RHI::PipelineLibrary // RHI::PipelineLibrary
RHI::ResultCode InitInternal([[maybe_unused]] RHI::Device& device, [[maybe_unused]] const RHI::PipelineLibraryData* serializedData) override { return RHI::ResultCode::Success;} RHI::ResultCode InitInternal([[maybe_unused]] RHI::Device& device, [[maybe_unused]] const RHI::PipelineLibraryData* serializedData) override { return RHI::ResultCode::Success;}
void ShutdownInternal() override {} void ShutdownInternal() override {}
RHI::ResultCode MergeIntoInternal([[maybe_unused]] AZStd::array_view<const RHI::PipelineLibrary*> libraries) override { return RHI::ResultCode::Success;} RHI::ResultCode MergeIntoInternal([[maybe_unused]] AZStd::span<const RHI::PipelineLibrary* const> libraries) override { return RHI::ResultCode::Success;}
RHI::ConstPtr<RHI::PipelineLibraryData> GetSerializedDataInternal() const override { return nullptr;} RHI::ConstPtr<RHI::PipelineLibraryData> GetSerializedDataInternal() const override { return nullptr;}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
}; };
@@ -9,7 +9,7 @@
#include <Atom/RHI.Reflect/Vulkan/Base.h> #include <Atom/RHI.Reflect/Vulkan/Base.h>
#include <Atom/RHI.Reflect/ShaderStageFunction.h> #include <Atom/RHI.Reflect/ShaderStageFunction.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/Memory/SystemAllocator.h> #include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/std/containers/array.h> #include <AzCore/std/containers/array.h>
#include <AzCore/std/string/string_view.h> #include <AzCore/std/string/string_view.h>
@@ -21,7 +21,7 @@ namespace AZ
namespace Vulkan namespace Vulkan
{ {
using ShaderByteCode = AZStd::vector<uint8_t>; using ShaderByteCode = AZStd::vector<uint8_t>;
using ShaderByteCodeView = AZStd::array_view<uint8_t>; using ShaderByteCodeView = AZStd::span<const uint8_t>;
/** /**
* A set of indices used to access physical sub-stages within a virtual stage. * A set of indices used to access physical sub-stages within a virtual stage.
@@ -76,12 +76,12 @@ namespace AZ
void CommandList::SetViewports(const RHI::Viewport* rhiViewports, uint32_t count) void CommandList::SetViewports(const RHI::Viewport* rhiViewports, uint32_t count)
{ {
m_state.m_viewportState.Set(AZStd::array_view<RHI::Viewport>(rhiViewports, count)); m_state.m_viewportState.Set(AZStd::span<const RHI::Viewport>(rhiViewports, count));
} }
void CommandList::SetScissors(const RHI::Scissor* rhiScissors, uint32_t count) void CommandList::SetScissors(const RHI::Scissor* rhiScissors, uint32_t count)
{ {
m_state.m_scissorState.Set(AZStd::array_view<RHI::Scissor>(rhiScissors, count)); m_state.m_scissorState.Set(AZStd::span<const RHI::Scissor>(rhiScissors, count));
} }
void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup) void CommandList::SetShaderResourceGroupForDraw(const RHI::ShaderResourceGroup& shaderResourceGroup)
@@ -625,7 +625,7 @@ namespace AZ
return ConvertResult(vkResult); return ConvertResult(vkResult);
} }
void CommandList::ExecuteSecondaryCommandLists(const AZStd::array_view<RHI::Ptr<CommandList>>& commands) void CommandList::ExecuteSecondaryCommandLists(const AZStd::span<const RHI::Ptr<CommandList>>& commands)
{ {
AZ_Assert(m_isUpdating, "Secondary command buffers must be executed between BeginCommandBuffer() and EndCommandBuffer()."); 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"); AZ_Assert(m_descriptor.m_level == VK_COMMAND_BUFFER_LEVEL_PRIMARY, "Trying to execute commands from a secondary command list");
@@ -17,7 +17,7 @@
#include <Atom/RHI.Reflect/Limits.h> #include <Atom/RHI.Reflect/Limits.h>
#include <Atom/RHI.Reflect/ScopeId.h> #include <Atom/RHI.Reflect/ScopeId.h>
#include <Atom/RHI.Reflect/Interval.h> #include <Atom/RHI.Reflect/Interval.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/std/containers/list.h> #include <AzCore/std/containers/list.h>
#include <AzCore/std/containers/unordered_set.h> #include <AzCore/std/containers/unordered_set.h>
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
@@ -103,7 +103,7 @@ namespace AZ
bool IsInsideRenderPass() const; bool IsInsideRenderPass() const;
const Framebuffer* GetActiveFramebuffer() const; const Framebuffer* GetActiveFramebuffer() const;
const RenderPass* GetActiveRenderpass() const; const RenderPass* GetActiveRenderpass() const;
void ExecuteSecondaryCommandLists(const AZStd::array_view<RHI::Ptr<CommandList>>& commands); void ExecuteSecondaryCommandLists(const AZStd::span<const RHI::Ptr<CommandList>>& commands);
uint32_t GetQueueFamilyIndex() const; uint32_t GetQueueFamilyIndex() const;
@@ -39,7 +39,7 @@ namespace AZ
} }
} }
void DescriptorSet::UpdateBufferViews(uint32_t layoutIndex, const AZStd::array_view<RHI::ConstPtr<RHI::BufferView>>& bufViews) void DescriptorSet::UpdateBufferViews(uint32_t layoutIndex, const AZStd::span<const RHI::ConstPtr<RHI::BufferView>>& bufViews)
{ {
const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout; const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout;
VkDescriptorType type = layout.GetDescriptorType(layoutIndex); VkDescriptorType type = layout.GetDescriptorType(layoutIndex);
@@ -119,7 +119,7 @@ namespace AZ
m_updateData.push_back(AZStd::move(data)); m_updateData.push_back(AZStd::move(data));
} }
void DescriptorSet::UpdateImageViews(uint32_t layoutIndex, const AZStd::array_view<RHI::ConstPtr<RHI::ImageView>>& imageViews, RHI::ShaderInputImageType imageType) void DescriptorSet::UpdateImageViews(uint32_t layoutIndex, const AZStd::span<const RHI::ConstPtr<RHI::ImageView>>& imageViews, RHI::ShaderInputImageType imageType)
{ {
const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout; const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout;
@@ -169,7 +169,7 @@ namespace AZ
m_updateData.push_back(AZStd::move(data)); m_updateData.push_back(AZStd::move(data));
} }
void DescriptorSet::UpdateSamplers(uint32_t layoutIndex, const AZStd::array_view<RHI::SamplerState>& samplers) void DescriptorSet::UpdateSamplers(uint32_t layoutIndex, const AZStd::span<const RHI::SamplerState>& samplers)
{ {
auto& device = static_cast<Device&>(GetDevice()); auto& device = static_cast<Device&>(GetDevice());
@@ -189,7 +189,7 @@ namespace AZ
m_updateData.push_back(AZStd::move(data)); m_updateData.push_back(AZStd::move(data));
} }
void DescriptorSet::UpdateConstantData(AZStd::array_view<uint8_t> rawData) void DescriptorSet::UpdateConstantData(AZStd::span<const uint8_t> rawData)
{ {
AZ_Assert(m_constantDataBuffer, "Null constant buffer"); AZ_Assert(m_constantDataBuffer, "Null constant buffer");
const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout; const DescriptorSetLayout& layout = *m_descriptor.m_descriptorSetLayout;
@@ -13,7 +13,7 @@
#include <Atom/RHI/Image.h> #include <Atom/RHI/Image.h>
#include <Atom/RHI/ImageView.h> #include <Atom/RHI/ImageView.h>
#include <Atom/RHI.Reflect/SamplerState.h> #include <Atom/RHI.Reflect/SamplerState.h>
#include <AtomCore/std/containers/array_view.h> #include <AzCore/std/containers/span.h>
#include <AzCore/Memory/PoolAllocator.h> #include <AzCore/Memory/PoolAllocator.h>
#include <RHI/Buffer.h> #include <RHI/Buffer.h>
@@ -57,10 +57,10 @@ namespace AZ
void CommitUpdates(); void CommitUpdates();
void UpdateBufferViews(uint32_t index, const AZStd::array_view<RHI::ConstPtr<RHI::BufferView>>& bufViews); void UpdateBufferViews(uint32_t index, const AZStd::span<const RHI::ConstPtr<RHI::BufferView>>& bufViews);
void UpdateImageViews(uint32_t index, const AZStd::array_view<RHI::ConstPtr<RHI::ImageView>>& imageViews, RHI::ShaderInputImageType imageType); void UpdateImageViews(uint32_t index, const AZStd::span<const RHI::ConstPtr<RHI::ImageView>>& imageViews, RHI::ShaderInputImageType imageType);
void UpdateSamplers(uint32_t index, const AZStd::array_view<RHI::SamplerState>& samplers); void UpdateSamplers(uint32_t index, const AZStd::span<const RHI::SamplerState>& samplers);
void UpdateConstantData(AZStd::array_view<uint8_t> data); void UpdateConstantData(AZStd::span<const uint8_t> data);
RHI::Ptr<BufferView> GetConstantDataBufferView() const; RHI::Ptr<BufferView> GetConstantDataBufferView() const;
@@ -152,12 +152,12 @@ namespace AZ
RHI::ResultCode DescriptorSetLayout::BuildDescriptorSetLayoutBindings() RHI::ResultCode DescriptorSetLayout::BuildDescriptorSetLayoutBindings()
{ {
const AZStd::array_view<RHI::ShaderInputBufferDescriptor> bufferDescs = m_shaderResourceGroupLayout->GetShaderInputListForBuffers(); const AZStd::span<const RHI::ShaderInputBufferDescriptor> bufferDescs = m_shaderResourceGroupLayout->GetShaderInputListForBuffers();
const AZStd::array_view<RHI::ShaderInputImageDescriptor> imageDescs = m_shaderResourceGroupLayout->GetShaderInputListForImages(); const AZStd::span<const RHI::ShaderInputImageDescriptor> imageDescs = m_shaderResourceGroupLayout->GetShaderInputListForImages();
const AZStd::array_view<RHI::ShaderInputBufferUnboundedArrayDescriptor> bufferUnboundedArrayDescs = m_shaderResourceGroupLayout->GetShaderInputListForBufferUnboundedArrays(); const AZStd::span<const RHI::ShaderInputBufferUnboundedArrayDescriptor> bufferUnboundedArrayDescs = m_shaderResourceGroupLayout->GetShaderInputListForBufferUnboundedArrays();
const AZStd::array_view<RHI::ShaderInputImageUnboundedArrayDescriptor> imageUnboundedArrayDescs = m_shaderResourceGroupLayout->GetShaderInputListForImageUnboundedArrays(); const AZStd::span<const RHI::ShaderInputImageUnboundedArrayDescriptor> imageUnboundedArrayDescs = m_shaderResourceGroupLayout->GetShaderInputListForImageUnboundedArrays();
const AZStd::array_view<RHI::ShaderInputSamplerDescriptor> samplerDescs = m_shaderResourceGroupLayout->GetShaderInputListForSamplers(); const AZStd::span<const RHI::ShaderInputSamplerDescriptor> samplerDescs = m_shaderResourceGroupLayout->GetShaderInputListForSamplers();
const AZStd::array_view<RHI::ShaderInputStaticSamplerDescriptor>& staticSamplerDescs = m_shaderResourceGroupLayout->GetStaticSamplers(); const AZStd::span<const RHI::ShaderInputStaticSamplerDescriptor>& staticSamplerDescs = m_shaderResourceGroupLayout->GetStaticSamplers();
// The + 1 is for Constant Data. // The + 1 is for Constant Data.
m_descriptorSetLayoutBindings.reserve( m_descriptorSetLayoutBindings.reserve(
@@ -173,7 +173,7 @@ namespace AZ
m_constantDataSize = m_shaderResourceGroupLayout->GetConstantDataSize(); m_constantDataSize = m_shaderResourceGroupLayout->GetConstantDataSize();
if (m_constantDataSize) if (m_constantDataSize)
{ {
AZStd::array_view<RHI::ShaderInputConstantDescriptor> inputListForConstants = m_shaderResourceGroupLayout->GetShaderInputListForConstants(); AZStd::span<const RHI::ShaderInputConstantDescriptor> inputListForConstants = m_shaderResourceGroupLayout->GetShaderInputListForConstants();
AZ_Assert(!inputListForConstants.empty(), "Empty constant input list"); AZ_Assert(!inputListForConstants.empty(), "Empty constant input list");
m_descriptorSetLayoutBindings.emplace_back(VkDescriptorSetLayoutBinding{}); m_descriptorSetLayoutBindings.emplace_back(VkDescriptorSetLayoutBinding{});
VkDescriptorSetLayoutBinding& vbinding = m_descriptorSetLayoutBindings.back(); VkDescriptorSetLayoutBinding& vbinding = m_descriptorSetLayoutBindings.back();
@@ -81,12 +81,12 @@ namespace AZ
{ {
} }
AZStd::array_view<const Scope*> FrameGraphExecuteGroup::GetScopes() const AZStd::span<const Scope* const> FrameGraphExecuteGroup::GetScopes() const
{ {
return AZStd::array_view<const Scope*>(&m_scope, 1); return AZStd::span<const Scope* const>(&m_scope, 1);
} }
AZStd::array_view<RHI::Ptr<CommandList>> FrameGraphExecuteGroup::GetCommandLists() const AZStd::span<const RHI::Ptr<CommandList>> FrameGraphExecuteGroup::GetCommandLists() const
{ {
return m_secondaryCommands; return m_secondaryCommands;
} }
@@ -44,8 +44,8 @@ namespace AZ
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// FrameGraphExecuteGroupBase // FrameGraphExecuteGroupBase
AZStd::array_view<const Scope*> GetScopes() const override; AZStd::span<const Scope* const> GetScopes() const override;
AZStd::array_view<RHI::Ptr<CommandList>> GetCommandLists() const override; AZStd::span<const RHI::Ptr<CommandList>> GetCommandLists() const override;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//! Set the render context and subpass that will be used by this execute group. //! Set the render context and subpass that will be used by this execute group.
@@ -37,9 +37,9 @@ namespace AZ
const RHI::GraphGroupId& GetGroupId() const; const RHI::GraphGroupId& GetGroupId() const;
virtual AZStd::array_view<const Scope*> GetScopes() const = 0; virtual AZStd::span<const Scope* const> GetScopes() const = 0;
virtual AZStd::array_view<RHI::Ptr<CommandList>> GetCommandLists() const = 0; virtual AZStd::span<const RHI::Ptr<CommandList>> GetCommandLists() const = 0;
protected: protected:
RHI::Ptr<CommandList> AcquireCommandList(VkCommandBufferLevel level) const; RHI::Ptr<CommandList> AcquireCommandList(VkCommandBufferLevel level) const;
@@ -113,14 +113,14 @@ namespace AZ
scope->EmitScopeBarriers(*m_commandList, Scope::BarrierSlot::Epilogue); scope->EmitScopeBarriers(*m_commandList, Scope::BarrierSlot::Epilogue);
} }
AZStd::array_view<const Scope*> FrameGraphExecuteGroupMerged::GetScopes() const AZStd::span<const Scope* const> FrameGraphExecuteGroupMerged::GetScopes() const
{ {
return m_scopes; return m_scopes;
} }
AZStd::array_view<RHI::Ptr<CommandList>> FrameGraphExecuteGroupMerged::GetCommandLists() const AZStd::span<const RHI::Ptr<CommandList>> FrameGraphExecuteGroupMerged::GetCommandLists() const
{ {
return AZStd::array_view<RHI::Ptr<CommandList>>(&m_commandList, 1); return AZStd::span<const RHI::Ptr<CommandList>>(&m_commandList, 1);
} }
void FrameGraphExecuteGroupMerged::SetPrimaryCommandList(CommandList& commandList) void FrameGraphExecuteGroupMerged::SetPrimaryCommandList(CommandList& commandList)
@@ -128,7 +128,7 @@ namespace AZ
m_commandList = &commandList; m_commandList = &commandList;
} }
void FrameGraphExecuteGroupMerged::SetRenderPasscontexts(AZStd::array_view<RenderPassContext> renderPassContexts) void FrameGraphExecuteGroupMerged::SetRenderPasscontexts(AZStd::span<const RenderPassContext> renderPassContexts)
{ {
m_renderPassContexts = renderPassContexts; m_renderPassContexts = renderPassContexts;
} }

Some files were not shown because too many files have changed in this diff Show More