From 64cff38f8294338371555ef737008be3879f2a28 Mon Sep 17 00:00:00 2001 From: antonmic <56370189+antonmic@users.noreply.github.com> Date: Sun, 8 Aug 2021 16:46:42 -0700 Subject: [PATCH] Addressing PR feedback and fixed a small issue with the draw item count display Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com> --- .../Code/Include/Atom/RHI/ShaderResourceGroupDebug.h | 12 +++++++++++- .../RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp | 6 +++--- Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp | 12 ++++++------ .../RHI/Code/Source/RHI/ShaderResourceGroupDebug.cpp | 6 +++--- .../RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp | 4 +++- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupDebug.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupDebug.h index b81f9e0c0b..d9ea77d823 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupDebug.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupDebug.h @@ -14,8 +14,18 @@ namespace AZ struct DrawItem; class ShaderResourceGroup; + /// Given a ShaderResourceGroup and a reference ConstantsData input, this function will fetch the ConstantsData on the SRG and compare it + /// to the reference ConstantsData. It will print the names of any constants that are different between the two. + /// The parameter updateReferenceData can be used to set the reference data to the SRG's constant data after the comparison. This is + /// useful for keeping track of differences in between calls to the function, such as between frames. void PrintConstantDataDiff(const ShaderResourceGroup& shaderResourceGroup, ConstantsData& referenceData, bool updateReferenceData = false); - void PrintConstantDataDiff(const DrawItem& drawItem, ConstantsData& referenceData, u32 srgBindingSlot, bool updateReferenceData = false); + + /// Given a DrawItem, an SRG binding slot on that draw item and a reference ConstantsData input, this function will fetch the ConstantsData + /// from the draw item's SRG at the binding slot and compare it to the reference ConstantsData. It will print the names of any constants + /// that are different between the two. + /// The parameter updateReferenceData can be used to set the reference data to the draw item's constant data after the comparison. This is + /// useful for keeping track of differences in between calls to the function, such as between frames. + void PrintConstantDataDiff(const DrawItem& drawItem, ConstantsData& referenceData, uint32_t srgBindingSlot, bool updateReferenceData = false); } } diff --git a/Gems/Atom/RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp b/Gems/Atom/RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp index f14d1d4c4e..8be053e4ef 100644 --- a/Gems/Atom/RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI.Reflect/ConstantsLayout.cpp @@ -151,11 +151,11 @@ namespace AZ void ConstantsLayout::DebugPrintNames(AZStd::array_view constantList) const { AZStd::string output; - for (const ShaderInputConstantIndex& constandIdx : constantList) + for (const ShaderInputConstantIndex& constantIdx : constantList) { - if (constandIdx.GetIndex() < m_inputs.size()) + if (constantIdx.GetIndex() < m_inputs.size()) { - output += m_inputs[constandIdx.GetIndex()].m_name.GetCStr(); + output += m_inputs[constantIdx.GetIndex()].m_name.GetCStr(); output += " - "; } } diff --git a/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp b/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp index d4caa3dd66..1524883e54 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp @@ -408,26 +408,26 @@ namespace AZ bool ConstantsData::ConstantIsEqual(const ConstantsData& other, ShaderInputConstantIndex inputIndex) const { - AZStd::array_view myConstans = GetConstantRaw(inputIndex); - AZStd::array_view otherConstans = other.GetConstantRaw(inputIndex); + AZStd::array_view myConstant = GetConstantRaw(inputIndex); + AZStd::array_view otherConstant = other.GetConstantRaw(inputIndex); // If they point to the same data, they are equal - if (myConstans == otherConstans) + if (myConstant == otherConstant) { return true; } // If they point to data of different size, they are not equal - if (myConstans.size() != otherConstans.size()) + if (myConstant.size() != otherConstant.size()) { return false; } // If they point to differing data of same size, compare the data // Note: due to small size of data this loop will be faster than a mem compare - for(uint32_t i = 0; i < myConstans.size(); ++i) + for(uint32_t i = 0; i < myConstant.size(); ++i) { - if (myConstans[i] != otherConstans[i]) + if (myConstant[i] != otherConstant[i]) { return false; } diff --git a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupDebug.cpp b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupDebug.cpp index 4bd8d0aab8..54399eba88 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupDebug.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupDebug.cpp @@ -36,10 +36,10 @@ namespace AZ } } - void PrintConstantDataDiff(const DrawItem& drawItem, ConstantsData& referenceData, u32 srgBindingSlot, bool updateReferenceData) + void PrintConstantDataDiff(const DrawItem& drawItem, ConstantsData& referenceData, uint32_t srgBindingSlot, bool updateReferenceData) { - s32 srgIndex = -1; - for (u32 i = 0; i < drawItem.m_shaderResourceGroupCount; ++i) + int srgIndex = -1; + for (uint32_t i = 0; i < drawItem.m_shaderResourceGroupCount; ++i) { if (drawItem.m_shaderResourceGroups[i]->GetBindingSlot() == srgBindingSlot) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp index 13f2215c8b..2e61542c36 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp @@ -166,11 +166,14 @@ namespace AZ // clean up data m_drawListView = {}; m_combinedDrawList.clear(); + m_drawItemCount = 0; // draw list from view was sorted and if it's the only draw list then we can use it directly if (viewDrawList.size() > 0 && drawLists.size() == 0) { m_drawListView = viewDrawList; + m_drawItemCount += viewDrawList.size(); + PassSystemInterface::Get()->IncrementFrameDrawItemCount(m_drawItemCount); return; } @@ -178,7 +181,6 @@ namespace AZ drawLists.push_back(viewDrawList); // combine draw items from mutiple draw lists to one draw list and sort it. - m_drawItemCount = 0; for (auto drawList : drawLists) { m_drawItemCount += drawList.size();