Addressing PR feedback and fixed a small issue with the draw item count display

Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>
This commit is contained in:
antonmic
2021-08-08 16:46:42 -07:00
parent d693ee5dd3
commit 64cff38f82
5 changed files with 26 additions and 14 deletions
@@ -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);
}
}
@@ -151,11 +151,11 @@ namespace AZ
void ConstantsLayout::DebugPrintNames(AZStd::array_view<ShaderInputConstantIndex> 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 += " - ";
}
}
@@ -408,26 +408,26 @@ namespace AZ
bool ConstantsData::ConstantIsEqual(const ConstantsData& other, ShaderInputConstantIndex inputIndex) const
{
AZStd::array_view<uint8_t> myConstans = GetConstantRaw(inputIndex);
AZStd::array_view<uint8_t> otherConstans = other.GetConstantRaw(inputIndex);
AZStd::array_view<uint8_t> myConstant = GetConstantRaw(inputIndex);
AZStd::array_view<uint8_t> 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;
}
@@ -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)
{
@@ -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();