Updated all array_view uses with the C++20 span. (#7157)

* Updated all array_view uses with the C++20 span.

The updates were done in the following order
1. `AZStd::array_view<([^>].+)\* ?>`  -> `AZStd::span<\1 const>`
2. `AZStd::array_view<(?:const )(.+)>` -> `AZStd::span<const \1>`
3. `AZStd::array_view` -> `AZStd::span`

Removed the implementation of array_view.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added missing whitespace between `const` and the typename for spans.

Updated the ShaderTest comparison of the ShaderResourceGroupLayout span
to compare the sizes as well

Updated comments on some of the methods that stated that they return "an
array" to mention they return "a span".

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
lumberyard-employee-dm
2022-01-26 16:15:47 -06:00
committed by GitHub
parent 48cea89910
commit b9824ed172
170 changed files with 833 additions and 1274 deletions
@@ -88,7 +88,7 @@ namespace AZ
{
}
MaterialPropertyId::MaterialPropertyId(const AZStd::array_view<AZStd::string> names)
MaterialPropertyId::MaterialPropertyId(const AZStd::span<const AZStd::string> names)
{
for (const auto& name : names)
{
@@ -54,7 +54,7 @@ namespace AZ
// --- PipelineStatisticsResult ---
PipelineStatisticsResult::PipelineStatisticsResult(AZStd::array_view<PipelineStatisticsResult>&& statisticsResultArray)
PipelineStatisticsResult::PipelineStatisticsResult(AZStd::span<const PipelineStatisticsResult>&& statisticsResultArray)
{
for (const PipelineStatisticsResult& result : statisticsResultArray)
{
@@ -147,7 +147,7 @@ namespace AZ
return endQuery->End(commandList);
}
AZStd::array_view<RHI::Ptr<RHI::Query>> RPI::QueryPool::GetRhiQueryArray() const
AZStd::span<const RHI::Ptr<RHI::Query>> RPI::QueryPool::GetRhiQueryArray() const
{
return m_rhiQueryArray;
}
@@ -230,12 +230,12 @@ namespace AZ
return m_queriesPerResult;
}
AZStd::array_view<RHI::Ptr<RHI::Query>> QueryPool::GetRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const
AZStd::span<const RHI::Ptr<RHI::Query>> QueryPool::GetRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const
{
const uint32_t queryCount = rhiQueryIndices.m_max - rhiQueryIndices.m_min + 1u;
AZ_Assert(rhiQueryIndices.m_max < m_rhiQueryCapacity, "Query array index is going over the limit");
return AZStd::array_view<RHI::Ptr<RHI::Query>>(m_rhiQueryArray.begin() + rhiQueryIndices.m_min, queryCount);
return AZStd::span<const RHI::Ptr<RHI::Query>>(m_rhiQueryArray.begin() + rhiQueryIndices.m_min, queryCount);
}
AZStd::vector<RHI::Query*> QueryPool::GetRawRhiQueriesFromInterval(const RHI::Interval& rhiQueryIndices) const
@@ -26,7 +26,7 @@ namespace AZ
RHI::ResultCode TimestampQueryPool::BeginQueryInternal(RHI::Interval rhiQueryIndices, RHI::CommandList& commandList)
{
AZStd::array_view<RHI::Ptr<RHI::Query>> rhiQueryArray = GetRhiQueryArray();
AZStd::span<const RHI::Ptr<RHI::Query>> rhiQueryArray = GetRhiQueryArray();
AZ::RHI::Ptr<AZ::RHI::Query> beginQuery = rhiQueryArray[rhiQueryIndices.m_min];
return beginQuery->WriteTimestamp(commandList);
@@ -34,7 +34,7 @@ namespace AZ
RHI::ResultCode TimestampQueryPool::EndQueryInternal(RHI::Interval rhiQueryIndices, RHI::CommandList& commandList)
{
AZStd::array_view<RHI::Ptr<RHI::Query>> rhiQueryArray = GetRhiQueryArray();
AZStd::span<const RHI::Ptr<RHI::Query>> rhiQueryArray = GetRhiQueryArray();
AZ::RHI::Ptr<AZ::RHI::Query> endQuery = rhiQueryArray[rhiQueryIndices.m_max];
return endQuery->WriteTimestamp(commandList);
@@ -57,7 +57,7 @@ namespace AZ
return m_lods.size();
}
AZStd::array_view<Data::Instance<ModelLod>> Model::GetLods() const
AZStd::span<const Data::Instance<ModelLod>> Model::GetLods() const
{
return m_lods;
}
@@ -28,7 +28,7 @@ namespace AZ
&modelAssetAny);
}
AZStd::array_view<ModelLod::Mesh> ModelLod::GetMeshes() const
AZStd::span<const ModelLod::Mesh> ModelLod::GetMeshes() const
{
return m_meshes;
}
@@ -398,7 +398,7 @@ namespace AZ
// --- Debug functions ---
AZStd::array_view<Ptr<Pass>> ParentPass::GetChildren() const
AZStd::span<const Ptr<Pass>> ParentPass::GetChildren() const
{
return m_children;
}
@@ -490,7 +490,7 @@ namespace AZ
return m_asset->FindFallbackShaderResourceGroupLayout(m_supervariantIndex);
}
AZStd::array_view<RHI::Ptr<RHI::ShaderResourceGroupLayout>> Shader::GetShaderResourceGroupLayouts() const
AZStd::span<const RHI::Ptr<RHI::ShaderResourceGroupLayout>> Shader::GetShaderResourceGroupLayouts() const
{
return m_asset->GetShaderResourceGroupLayouts(m_supervariantIndex);
}
@@ -76,7 +76,7 @@ namespace AZ
{
const auto& lay = shaderAsset.FindShaderResourceGroupLayout(srgName, supervariantIndex);
m_layout = lay.get();
if (!m_layout)
{
AZ_Assert(false, "ShaderResourceGroup cannot be initialized due to invalid ShaderResourceGroupLayout");
@@ -188,7 +188,7 @@ namespace AZ
{
return GetLayout()->HasShaderVariantKeyFallbackEntry();
}
bool ShaderResourceGroup::SetImage(RHI::ShaderInputNameIndex& inputIndex, const Data::Instance<Image>& image, uint32_t arrayIndex)
{
if (inputIndex.ValidateOrFindImageIndex(GetLayout()))
@@ -215,7 +215,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetImageArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view<Data::Instance<Image>> images, uint32_t arrayIndex)
bool ShaderResourceGroup::SetImageArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span<const Data::Instance<Image>> images, uint32_t arrayIndex)
{
if (inputIndex.ValidateOrFindImageIndex(GetLayout()))
{
@@ -224,7 +224,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetImageArray(RHI::ShaderInputImageIndex inputIndex, AZStd::array_view<Data::Instance<Image>> images, uint32_t arrayIndex)
bool ShaderResourceGroup::SetImageArray(RHI::ShaderInputImageIndex inputIndex, AZStd::span<const Data::Instance<Image>> images, uint32_t arrayIndex)
{
if (GetLayout()->ValidateAccess(inputIndex, arrayIndex + static_cast<uint32_t>(images.size()) - 1))
{
@@ -257,7 +257,7 @@ namespace AZ
return s_nullImage;
}
AZStd::array_view<Data::Instance<Image>> ShaderResourceGroup::GetImageArray(RHI::ShaderInputNameIndex& inputIndex) const
AZStd::span<const Data::Instance<Image>> ShaderResourceGroup::GetImageArray(RHI::ShaderInputNameIndex& inputIndex) const
{
if (inputIndex.ValidateOrFindImageIndex(GetLayout()))
{
@@ -266,12 +266,12 @@ namespace AZ
return {};
}
AZStd::array_view<Data::Instance<Image>> ShaderResourceGroup::GetImageArray(RHI::ShaderInputImageIndex inputIndex) const
AZStd::span<const Data::Instance<Image>> ShaderResourceGroup::GetImageArray(RHI::ShaderInputImageIndex inputIndex) const
{
if (m_layout->ValidateAccess(inputIndex, 0))
{
const RHI::Interval interval = m_layout->GetGroupInterval(inputIndex);
return AZStd::array_view<Data::Instance<Image>>(&m_imageGroup[interval.m_min], interval.m_max - interval.m_min);
return AZStd::span<const Data::Instance<Image>>(&m_imageGroup[interval.m_min], interval.m_max - interval.m_min);
}
return {};
}
@@ -299,7 +299,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetImageViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view<const RHI::ImageView*> imageViews, uint32_t arrayIndex)
bool ShaderResourceGroup::SetImageViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span<const RHI::ImageView* const> imageViews, uint32_t arrayIndex)
{
if (inputIndex.ValidateOrFindImageIndex(GetLayout()))
{
@@ -308,7 +308,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetImageViewArray(RHI::ShaderInputImageIndex inputIndex, AZStd::array_view<const RHI::ImageView*> imageViews, uint32_t arrayIndex)
bool ShaderResourceGroup::SetImageViewArray(RHI::ShaderInputImageIndex inputIndex, AZStd::span<const RHI::ImageView* const> imageViews, uint32_t arrayIndex)
{
if (GetLayout()->ValidateAccess(inputIndex, arrayIndex + static_cast<uint32_t>(imageViews.size()) - 1))
{
@@ -322,7 +322,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::array_view<const RHI::ImageView*> imageViews)
bool ShaderResourceGroup::SetImageViewUnboundedArray(RHI::ShaderInputImageUnboundedArrayIndex inputIndex, AZStd::span<const RHI::ImageView* const> imageViews)
{
return m_data.SetImageViewUnboundedArray(inputIndex, imageViews);
}
@@ -350,7 +350,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view<const RHI::BufferView*> bufferViews, uint32_t arrayIndex)
bool ShaderResourceGroup::SetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span<const RHI::BufferView* const> bufferViews, uint32_t arrayIndex)
{
if (inputIndex.ValidateOrFindBufferIndex(GetLayout()))
{
@@ -359,7 +359,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::array_view<const RHI::BufferView*> bufferViews, uint32_t arrayIndex)
bool ShaderResourceGroup::SetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::span<const RHI::BufferView* const> bufferViews, uint32_t arrayIndex)
{
if (GetLayout()->ValidateAccess(inputIndex, arrayIndex + static_cast<uint32_t>(bufferViews.size()) - 1))
{
@@ -373,7 +373,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::array_view<const RHI::BufferView*> bufferViews)
bool ShaderResourceGroup::SetBufferViewUnboundedArray(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex, AZStd::span<const RHI::BufferView* const> bufferViews)
{
return m_data.SetBufferViewUnboundedArray(inputIndex, bufferViews);
}
@@ -392,7 +392,7 @@ namespace AZ
return m_data.SetSampler(inputIndex, sampler, arrayIndex);
}
bool ShaderResourceGroup::SetSamplerArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view<RHI::SamplerState> samplers, uint32_t arrayIndex)
bool ShaderResourceGroup::SetSamplerArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span<const RHI::SamplerState> samplers, uint32_t arrayIndex)
{
if (inputIndex.ValidateOrFindSamplerIndex(GetLayout()))
{
@@ -401,7 +401,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex, AZStd::array_view<RHI::SamplerState> samplers, uint32_t arrayIndex)
bool ShaderResourceGroup::SetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex, AZStd::span<const RHI::SamplerState> samplers, uint32_t arrayIndex)
{
return m_data.SetSamplerArray(inputIndex, samplers, arrayIndex);
}
@@ -437,7 +437,7 @@ namespace AZ
bool ShaderResourceGroup::ApplyDataMappings(const RHI::ShaderDataMappings& mappings)
{
bool success = true;
success = success && ApplyDataMappingArray(mappings.m_colorMappings);
success = success && ApplyDataMappingArray(mappings.m_uintMappings);
success = success && ApplyDataMappingArray(mappings.m_floatMappings);
@@ -461,13 +461,13 @@ namespace AZ
return m_data.GetImageView(inputIndex, arrayIndex);
}
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> ShaderResourceGroup::GetImageViewArray(RHI::ShaderInputNameIndex& inputIndex) const
AZStd::span<const RHI::ConstPtr<RHI::ImageView>> ShaderResourceGroup::GetImageViewArray(RHI::ShaderInputNameIndex& inputIndex) const
{
inputIndex.ValidateOrFindImageIndex(GetLayout());
return GetImageViewArray(inputIndex.GetImageIndex());
}
AZStd::array_view<RHI::ConstPtr<RHI::ImageView>> ShaderResourceGroup::GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const
AZStd::span<const RHI::ConstPtr<RHI::ImageView>> ShaderResourceGroup::GetImageViewArray(RHI::ShaderInputImageIndex inputIndex) const
{
return m_data.GetImageViewArray(inputIndex);
}
@@ -483,13 +483,13 @@ namespace AZ
return m_data.GetBufferView(inputIndex, arrayIndex);
}
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> ShaderResourceGroup::GetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex) const
AZStd::span<const RHI::ConstPtr<RHI::BufferView>> ShaderResourceGroup::GetBufferViewArray(RHI::ShaderInputNameIndex& inputIndex) const
{
inputIndex.ValidateOrFindBufferIndex(GetLayout());
return GetBufferViewArray(inputIndex.GetBufferIndex());
}
AZStd::array_view<RHI::ConstPtr<RHI::BufferView>> ShaderResourceGroup::GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const
AZStd::span<const RHI::ConstPtr<RHI::BufferView>> ShaderResourceGroup::GetBufferViewArray(RHI::ShaderInputBufferIndex inputIndex) const
{
return m_data.GetBufferViewArray(inputIndex);
}
@@ -520,7 +520,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetBufferArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::array_view<Data::Instance<Buffer>> buffers, uint32_t arrayIndex)
bool ShaderResourceGroup::SetBufferArray(RHI::ShaderInputNameIndex& inputIndex, AZStd::span<const Data::Instance<Buffer>> buffers, uint32_t arrayIndex)
{
if (inputIndex.ValidateOrFindBufferIndex(GetLayout()))
{
@@ -529,7 +529,7 @@ namespace AZ
return false;
}
bool ShaderResourceGroup::SetBufferArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::array_view<Data::Instance<Buffer>> buffers, uint32_t arrayIndex)
bool ShaderResourceGroup::SetBufferArray(RHI::ShaderInputBufferIndex inputIndex, AZStd::span<const Data::Instance<Buffer>> buffers, uint32_t arrayIndex)
{
if (GetLayout()->ValidateAccess(inputIndex, arrayIndex + static_cast<uint32_t>(buffers.size()) - 1))
{
@@ -562,7 +562,7 @@ namespace AZ
return s_nullBuffer;
}
AZStd::array_view<Data::Instance<Buffer>> ShaderResourceGroup::GetBufferArray(RHI::ShaderInputNameIndex& inputIndex) const
AZStd::span<const Data::Instance<Buffer>> ShaderResourceGroup::GetBufferArray(RHI::ShaderInputNameIndex& inputIndex) const
{
if (inputIndex.ValidateOrFindBufferIndex(GetLayout()))
{
@@ -571,12 +571,12 @@ namespace AZ
return {};
}
AZStd::array_view<Data::Instance<Buffer>> ShaderResourceGroup::GetBufferArray(RHI::ShaderInputBufferIndex inputIndex) const
AZStd::span<const Data::Instance<Buffer>> ShaderResourceGroup::GetBufferArray(RHI::ShaderInputBufferIndex inputIndex) const
{
if (m_layout->ValidateAccess(inputIndex, 0))
{
const RHI::Interval interval = m_layout->GetGroupInterval(inputIndex);
return AZStd::array_view<Data::Instance<Buffer>>(&m_bufferGroup[interval.m_min], interval.m_max - interval.m_min);
return AZStd::span<const Data::Instance<Buffer>>(&m_bufferGroup[interval.m_min], interval.m_max - interval.m_min);
}
return {};
}
@@ -597,24 +597,24 @@ namespace AZ
return m_data.GetSampler(inputIndex, arrayIndex);
}
AZStd::array_view<RHI::SamplerState> ShaderResourceGroup::GetSamplerArray(RHI::ShaderInputNameIndex& inputIndex) const
AZStd::span<const RHI::SamplerState> ShaderResourceGroup::GetSamplerArray(RHI::ShaderInputNameIndex& inputIndex) const
{
inputIndex.ValidateOrFindSamplerIndex(GetLayout());
return GetSamplerArray(inputIndex.GetSamplerIndex());
}
AZStd::array_view<RHI::SamplerState> ShaderResourceGroup::GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const
AZStd::span<const RHI::SamplerState> ShaderResourceGroup::GetSamplerArray(RHI::ShaderInputSamplerIndex inputIndex) const
{
return m_data.GetSamplerArray(inputIndex);
}
AZStd::array_view<uint8_t> ShaderResourceGroup::GetConstantRaw(RHI::ShaderInputNameIndex& inputIndex) const
AZStd::span<const uint8_t> ShaderResourceGroup::GetConstantRaw(RHI::ShaderInputNameIndex& inputIndex) const
{
inputIndex.ValidateOrFindConstantIndex(GetLayout());
return GetConstantRaw(inputIndex.GetConstantIndex());
}
AZStd::array_view<uint8_t> ShaderResourceGroup::GetConstantRaw(RHI::ShaderInputConstantIndex inputIndex) const
AZStd::span<const uint8_t> ShaderResourceGroup::GetConstantRaw(RHI::ShaderInputConstantIndex inputIndex) const
{
return m_data.GetConstantRaw(inputIndex);
}
@@ -49,9 +49,9 @@ namespace AZ
}
}
AZStd::array_view<uint8_t> BufferAsset::GetBuffer() const
AZStd::span<const uint8_t> BufferAsset::GetBuffer() const
{
return AZStd::array_view<uint8_t>(m_buffer);
return AZStd::span<const uint8_t>(m_buffer);
}
const RHI::BufferDescriptor& BufferAsset::GetBufferDescriptor() const
@@ -165,7 +165,7 @@ namespace AZ
creator.SetPoolAsset(sourceAsset->GetPoolAsset());
creator.SetBufferViewDescriptor(sourceAsset->GetBufferViewDescriptor());
const AZStd::array_view<uint8_t> sourceBuffer = sourceAsset->GetBuffer();
const AZStd::span<const uint8_t> sourceBuffer = sourceAsset->GetBuffer();
creator.SetBuffer(sourceBuffer.data(), sourceBuffer.size(), sourceAsset->GetBufferDescriptor());
return creator.End(clonedResult);
@@ -49,19 +49,19 @@ namespace AZ
return m_subImageDatas.size();
}
AZStd::array_view<uint8_t> ImageMipChainAsset::GetSubImageData(uint32_t mipSlice, uint32_t arraySlice) const
AZStd::span<const uint8_t> ImageMipChainAsset::GetSubImageData(uint32_t mipSlice, uint32_t arraySlice) const
{
return GetSubImageData(mipSlice * m_arraySize + arraySlice);
}
AZStd::array_view<uint8_t> ImageMipChainAsset::GetSubImageData(uint32_t subImageIndex) const
AZStd::span<const uint8_t> ImageMipChainAsset::GetSubImageData(uint32_t subImageIndex) const
{
AZ_Assert(subImageIndex < m_subImageDataOffsets.size() && subImageIndex < m_subImageDatas.size(), "subImageIndex is out of range");
// The offset vector contains an extra sentinel value.
const size_t dataSize = m_subImageDataOffsets[subImageIndex + 1] - m_subImageDataOffsets[subImageIndex];
return AZStd::array_view<uint8_t>(reinterpret_cast<const uint8_t*>(m_subImageDatas[subImageIndex].m_data), dataSize);
return AZStd::span<const uint8_t>(reinterpret_cast<const uint8_t*>(m_subImageDatas[subImageIndex].m_data), dataSize);
}
const RHI::ImageSubresourceLayout& ImageMipChainAsset::GetSubImageLayout(uint32_t mipSlice) const
@@ -111,7 +111,7 @@ namespace AZ
for (uint16_t mipSliceIndex = 0; mipSliceIndex < m_mipLevels; ++mipSliceIndex)
{
RHI::StreamingImageMipSlice mipSlice;
mipSlice.m_subresources = AZStd::array_view<RHI::StreamingImageSubresourceData>(&m_subImageDatas[m_arraySize * mipSliceIndex], m_arraySize);
mipSlice.m_subresources = AZStd::span<const RHI::StreamingImageSubresourceData>(&m_subImageDatas[m_arraySize * mipSliceIndex], m_arraySize);
mipSlice.m_subresourceLayout = m_subImageLayouts[mipSliceIndex];
m_mipSlices.push_back(mipSlice);
}
@@ -94,11 +94,11 @@ namespace AZ
return m_totalImageDataSize;
}
AZStd::array_view<uint8_t> StreamingImageAsset::GetSubImageData(uint32_t mip, uint32_t slice)
AZStd::span<const uint8_t> StreamingImageAsset::GetSubImageData(uint32_t mip, uint32_t slice)
{
if (mip >= m_mipLevelToChainIndex.size())
{
return AZStd::array_view<uint8_t>();
return AZStd::span<const uint8_t>();
}
size_t mipChainIndex = m_mipLevelToChainIndex[mip];
@@ -119,7 +119,7 @@ namespace AZ
if (mipChainAsset == nullptr)
{
AZ_Warning("Streaming Image", false, "MipChain asset wasn't loaded");
return AZStd::array_view<uint8_t>();
return AZStd::span<const uint8_t>();
}
return mipChainAsset->GetSubImageData(mip - mipChain.m_mipOffset, slice);
@@ -154,7 +154,7 @@ namespace AZ
return m_materialPropertiesLayout.get();
}
AZStd::array_view<MaterialPropertyValue> MaterialTypeAsset::GetDefaultPropertyValues() const
AZStd::span<const MaterialPropertyValue> MaterialTypeAsset::GetDefaultPropertyValues() const
{
return m_propertyValues;
}
@@ -82,9 +82,9 @@ namespace AZ
return m_lodAssets.size();
}
AZStd::array_view<Data::Asset<ModelLodAsset>> ModelAsset::GetLodAssets() const
AZStd::span<const Data::Asset<ModelLodAsset>> ModelAsset::GetLodAssets() const
{
return AZStd::array_view<Data::Asset<ModelLodAsset>>(m_lodAssets);
return AZStd::span<const Data::Asset<ModelLodAsset>>(m_lodAssets);
}
void ModelAsset::SetReady()
@@ -213,7 +213,7 @@ namespace AZ
}
RHI::BufferViewDescriptor positionBufferViewDesc = positionBufferView->GetBufferViewDescriptor();
AZStd::array_view<uint8_t> positionRawBuffer = bufferAssetViewPtr->GetBuffer();
AZStd::span<const uint8_t> positionRawBuffer = bufferAssetViewPtr->GetBuffer();
const uint32_t positionElementSize = positionBufferViewDesc.m_elementSize;
const uint32_t positionElementCount = positionBufferViewDesc.m_elementCount;
@@ -227,7 +227,7 @@ namespace AZ
}
RHI::BufferViewDescriptor indexBufferViewDesc = indexBufferView.GetBufferViewDescriptor();
AZStd::array_view<uint8_t> indexRawBuffer = indexAssetViewPtr->GetBuffer();
AZStd::span<const uint8_t> indexRawBuffer = indexAssetViewPtr->GetBuffer();
const AZ::Vector3 rayEnd = rayStart + rayDir;
AZ::Vector3 a, b, c;
@@ -297,7 +297,7 @@ namespace AZ
{
for (const ModelLodAsset::Mesh& mesh : loadAssetPtr->GetMeshes())
{
const AZStd::array_view<ModelLodAsset::Mesh::StreamBufferInfo>& streamBufferList = mesh.GetStreamBufferInfoList();
const AZStd::span<const ModelLodAsset::Mesh::StreamBufferInfo>& streamBufferList = mesh.GetStreamBufferInfoList();
// find position semantic
const ModelLodAsset::Mesh::StreamBufferInfo* positionBuffer = nullptr;
@@ -101,7 +101,7 @@ namespace AZ
creator.SetName(sourceAsset->GetName().GetStringView());
AZ::Data::AssetId lastUsedId = cloneAssetId;
const AZStd::array_view<Data::Asset<ModelLodAsset>> sourceLodAssets = sourceAsset->GetLodAssets();
const AZStd::span<const Data::Asset<ModelLodAsset>> sourceLodAssets = sourceAsset->GetLodAssets();
for (const Data::Asset<ModelLodAsset>& sourceLodAsset : sourceLodAssets)
{
Data::Asset<ModelLodAsset> lodAsset;
@@ -61,7 +61,7 @@ namespace AZ
{
const auto& [first, second, third] = triangleIndices;
const AZStd::array_view<float>& positionBuffer = m_meshes[nObjIndex].m_vertexData;
const AZStd::span<const float>& positionBuffer = m_meshes[nObjIndex].m_vertexData;
if (positionBuffer.empty())
{
@@ -114,7 +114,7 @@ namespace AZ
for (AZ::u8 meshIndex = 0, meshCount = aznumeric_caster(m_meshes.size()); meshIndex < meshCount; ++meshIndex)
{
const AZStd::array_view<float> positionBuffer = m_meshes[meshIndex].m_vertexData;
const AZStd::span<const float> positionBuffer = m_meshes[meshIndex].m_vertexData;
for (size_t positionIndex = 0; positionIndex < positionBuffer.size(); positionIndex += 3)
{
entireBoundBox.AddPoint({positionBuffer[positionIndex], positionBuffer[positionIndex + 1], positionBuffer[positionIndex + 2]});
@@ -137,14 +137,14 @@ namespace AZ
return true;
}
AZStd::array_view<float> ModelKdTree::GetPositionsBuffer(const ModelLodAsset::Mesh& mesh)
AZStd::span<const float> ModelKdTree::GetPositionsBuffer(const ModelLodAsset::Mesh& mesh)
{
AZStd::array_view<float> positionBuffer = mesh.GetSemanticBufferTyped<float>(AZ::Name{"POSITION"});
AZStd::span<const float> positionBuffer = mesh.GetSemanticBufferTyped<float>(AZ::Name{"POSITION"});
AZ_Warning("ModelKdTree", !positionBuffer.empty(), "Could not find position buffers in a mesh");
return positionBuffer;
}
AZStd::array_view<ModelKdTree::TriangleIndices> ModelKdTree::GetIndexBuffer(const ModelLodAsset::Mesh& mesh)
AZStd::span<const ModelKdTree::TriangleIndices> ModelKdTree::GetIndexBuffer(const ModelLodAsset::Mesh& mesh)
{
return mesh.GetIndexBufferTyped<ModelKdTree::TriangleIndices>();
}
@@ -264,7 +264,7 @@ namespace AZ
const auto& [first, second, third] = pNode->GetVertexIndex(i);
const AZ::u32 nObjIndex = pNode->GetObjIndex(i);
const AZStd::array_view<float> positionBuffer = m_meshes[nObjIndex].m_vertexData;
const AZStd::span<const float> positionBuffer = m_meshes[nObjIndex].m_vertexData;
if (positionBuffer.empty())
{
@@ -95,9 +95,9 @@ namespace AZ
return m_indexBufferAssetView;
}
AZStd::array_view<ModelLodAsset::Mesh::StreamBufferInfo> ModelLodAsset::Mesh::GetStreamBufferInfoList() const
AZStd::span<const ModelLodAsset::Mesh::StreamBufferInfo> ModelLodAsset::Mesh::GetStreamBufferInfoList() const
{
return AZStd::array_view<ModelLodAsset::Mesh::StreamBufferInfo>(m_streamBufferInfo);
return AZStd::span<const ModelLodAsset::Mesh::StreamBufferInfo>(m_streamBufferInfo);
}
void ModelLodAsset::AddMesh(const Mesh& mesh)
@@ -109,9 +109,9 @@ namespace AZ
m_aabb.AddAabb(meshAabb);
}
AZStd::array_view<ModelLodAsset::Mesh> ModelLodAsset::GetMeshes() const
AZStd::span<const ModelLodAsset::Mesh> ModelLodAsset::GetMeshes() const
{
return AZStd::array_view<ModelLodAsset::Mesh>(m_meshes);
return AZStd::span<const ModelLodAsset::Mesh>(m_meshes);
}
const AZ::Aabb& ModelLodAsset::GetAabb() const
@@ -121,7 +121,7 @@ namespace AZ
const BufferAssetView* ModelLodAsset::Mesh::GetSemanticBufferAssetView(const AZ::Name& semantic) const
{
const AZStd::array_view<ModelLodAsset::Mesh::StreamBufferInfo>& streamBufferList = GetStreamBufferInfoList();
const AZStd::span<const ModelLodAsset::Mesh::StreamBufferInfo>& streamBufferList = GetStreamBufferInfoList();
for (const ModelLodAsset::Mesh::StreamBufferInfo& streamBufferInfo : streamBufferList)
{
@@ -243,7 +243,7 @@ namespace AZ
bool ModelLodAssetCreator::Clone(const Data::Asset<ModelLodAsset>& sourceAsset, Data::Asset<ModelLodAsset>& clonedResult, Data::AssetId& inOutLastCreatedAssetId)
{
AZStd::array_view<ModelLodAsset::Mesh> sourceMeshes = sourceAsset->GetMeshes();
AZStd::span<const ModelLodAsset::Mesh> sourceMeshes = sourceAsset->GetMeshes();
if (sourceMeshes.empty())
{
return true;
@@ -383,7 +383,7 @@ namespace AZ
return RHI::NullSrgLayout;
}
AZStd::array_view<RHI::Ptr<RHI::ShaderResourceGroupLayout>> ShaderAsset::GetShaderResourceGroupLayouts(
AZStd::span<const RHI::Ptr<RHI::ShaderResourceGroupLayout>> ShaderAsset::GetShaderResourceGroupLayouts(
SupervariantIndex supervariantIndex) const
{
auto supervariant = GetSupervariant(supervariantIndex);