Address feedback of PR for ATOM-6088.

* Rename DrawItemKeyPair to DrawItemProperties.
* Switch back to use Ptr<DrawListTagRegistry> instead of DrawListTagRegistry
* Updated some comment.
This commit is contained in:
qingtao
2021-04-27 13:26:43 -07:00
parent 12f528d744
commit 60db6b55d0
20 changed files with 104 additions and 83 deletions
@@ -58,7 +58,8 @@ namespace AZ
virtual RHI::Ptr<DynamicDrawContext> CreateDynamicDrawContext(Scene* scene) = 0;
//! Create a DynamicDrawContext for specified render pipeline
//! This allows draw calls are only submitted to selected render pipeline (viewport)
//! Draw calls submitted through the context created by this function are only submitted
//! to the supplied render pipeline (viewport)
virtual RHI::Ptr<DynamicDrawContext> CreateDynamicDrawContext(RenderPipeline* pipeline) = 0;
//! Get a DynamicBuffer from DynamicDrawSystem.
@@ -187,6 +187,7 @@ namespace AZ
//! Get draw filter tag
RHI::DrawFilterTag GetDrawFilterTag() const;
//! Get draw filter mask
RHI::DrawFilterMask GetDrawFilterMask() const;
private:
@@ -261,7 +262,9 @@ namespace AZ
// A tag to filter draw items submitted by passes of this render pipeline.
// This tag is allocated when it's added to a scene. It's set to invalid when it's removed to the scene.
RHI::DrawFilterTag m_drawFilterTag;
RHI::DrawFilterMask m_drawFilterMask = 0; // The corresponding mask of the m_drawFilterTag
// A mask to filter draw items submitted by passes of this render pipeline.
// This mask is created from the value of m_drawFilterTag.
RHI::DrawFilterMask m_drawFilterMask = 0;
};
} // namespace RPI
@@ -237,7 +237,7 @@ namespace AZ
DynamicDrawSystem* m_dynamicDrawSystem = nullptr;
// Registry which allocates draw filter tag for RenderPipeline
RHI::DrawFilterTagRegistry m_drawFilterTagRegistry;
RHI::Ptr<RHI::DrawFilterTagRegistry> m_drawFilterTagRegistry;
};
// --- Template functions ---
@@ -75,7 +75,7 @@ namespace AZ
void AddDrawPacket(const RHI::DrawPacket* drawPacket, Vector3 worldPosition);
//! Add a draw item to this view with its associated draw list tag
void AddDrawItem(RHI::DrawListTag drawListTag, const RHI::DrawItemKeyPair& drawItemKeyPair);
void AddDrawItem(RHI::DrawListTag drawListTag, const RHI::DrawItemProperties& drawItemProperties);
//! Sets the worldToView matrix and recalculates the other matrices.
void SetWorldToViewMatrix(const AZ::Matrix4x4& worldToView);
@@ -602,11 +602,11 @@ namespace AZ
drawItemInfo.m_drawItem.m_streamBufferViews = &m_cachedStreamBufferViews[drawItemInfo.m_vertexBufferViewIndex];
}
RHI::DrawItemKeyPair drawItemKeyPair;
drawItemKeyPair.m_sortKey = sortKey;
drawItemKeyPair.m_item = &drawItemInfo.m_drawItem;
drawItemKeyPair.m_drawFilterMask = m_drawFilter;
view->AddDrawItem(m_drawListTag, drawItemKeyPair);
RHI::DrawItemProperties drawItemProperties;
drawItemProperties.m_sortKey = sortKey;
drawItemProperties.m_item = &drawItemInfo.m_drawItem;
drawItemProperties.m_drawFilterMask = m_drawFilter;
view->AddDrawItem(m_drawListTag, drawItemProperties);
sortKey++;
}
}
@@ -195,11 +195,11 @@ namespace AZ
SetSrgsForDraw(commandList);
}
for (const RHI::DrawItemKeyPair& drawItemKeyPair : drawListViewPartition)
for (const RHI::DrawItemProperties& drawItemProperties : drawListViewPartition)
{
if (drawItemKeyPair.m_drawFilterMask & m_pipeline->GetDrawFilterMask())
if (drawItemProperties.m_drawFilterMask & m_pipeline->GetDrawFilterMask())
{
commandList->Submit(*drawItemKeyPair.m_item);
commandList->Submit(*drawItemProperties.m_item);
}
}
}
@@ -87,6 +87,7 @@ namespace AZ
m_id = Uuid::CreateRandom();
m_cullingScene = aznew CullingScene();
SceneRequestBus::Handler::BusConnect(m_id);
m_drawFilterTagRegistry = RHI::DrawFilterTagRegistry::Create();
}
Scene::~Scene()
@@ -269,7 +270,7 @@ namespace AZ
return;
}
pipeline->SetDrawFilterTag(m_drawFilterTagRegistry.AcquireTag(pipelineId));
pipeline->SetDrawFilterTag(m_drawFilterTagRegistry->AcquireTag(pipelineId));
m_pipelines.push_back(pipeline);
@@ -305,7 +306,7 @@ namespace AZ
m_defaultPipeline = nullptr;
}
m_drawFilterTagRegistry.ReleaseTag(pipelineToRemove->GetDrawFilterTag());
m_drawFilterTagRegistry->ReleaseTag(pipelineToRemove->GetDrawFilterTag());
pipelineToRemove->OnRemovedFromScene(this);
m_pipelines.erase(it);
@@ -90,9 +90,9 @@ namespace AZ
AddDrawPacket(drawPacket, depth);
}
void View::AddDrawItem(RHI::DrawListTag drawListTag, const RHI::DrawItemKeyPair& drawItemKeyPair)
void View::AddDrawItem(RHI::DrawListTag drawListTag, const RHI::DrawItemProperties& drawItemProperties)
{
m_drawListContext.AddDrawItem(drawListTag, drawItemKeyPair);
m_drawListContext.AddDrawItem(drawListTag, drawItemProperties);
}
void View::SetWorldToViewMatrix(const AZ::Matrix4x4& worldToView)