ATOM-15935 Adding draw to pass support to DynamicDrawContext (#2248)
The DynamicDrawContext can output to different scopes: Scene, RenderPipeline or RasterPass. Updated RasterPass so it can handle not only draw calls from Views but also from DynamicDrawContexts.
This commit is contained in:
@@ -53,34 +53,14 @@ namespace AZ
|
||||
return m_bufferAlloc->Allocate(size, alignment);
|
||||
}
|
||||
|
||||
RHI::Ptr<DynamicDrawContext> DynamicDrawSystem::CreateDynamicDrawContext(Scene* scene)
|
||||
RHI::Ptr<DynamicDrawContext> DynamicDrawSystem::CreateDynamicDrawContext()
|
||||
{
|
||||
if (!scene)
|
||||
{
|
||||
AZ_Error("RPI", false, "Failed to create a DynamicDrawContext: the input scene is invalid");
|
||||
return nullptr;
|
||||
}
|
||||
RHI::Ptr<DynamicDrawContext> drawContext = aznew DynamicDrawContext();
|
||||
drawContext->m_scene = scene;
|
||||
|
||||
AZStd::lock_guard<AZStd::mutex> lock(m_mutexDrawContext);
|
||||
m_dynamicDrawContexts.push_back(drawContext);
|
||||
return drawContext;
|
||||
}
|
||||
|
||||
RHI::Ptr<DynamicDrawContext> DynamicDrawSystem::CreateDynamicDrawContext(RenderPipeline* pipeline)
|
||||
{
|
||||
if (!pipeline || !pipeline->GetScene())
|
||||
{
|
||||
AZ_Error("RPI", false, "Failed to create a DynamicDrawContext: the input RenderPipeline is invalid or wasn't added to a Scene");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto context = CreateDynamicDrawContext(pipeline->GetScene());
|
||||
context->m_drawFilter = pipeline->GetDrawFilterMask();
|
||||
return context;
|
||||
}
|
||||
|
||||
// [GFX TODO][ATOM-13184] Add support of draw geometry with material for DynamicDrawSystemInterface
|
||||
void DynamicDrawSystem::DrawGeometry([[maybe_unused]] Data::Instance<Material> material, [[maybe_unused]] const GeometryData& geometry, [[maybe_unused]] ScenePtr scene)
|
||||
{
|
||||
@@ -101,9 +81,10 @@ namespace AZ
|
||||
{
|
||||
if (drawContext->m_scene == scene)
|
||||
{
|
||||
drawContext->FinalizeDrawList();
|
||||
for (auto& view : views)
|
||||
{
|
||||
drawContext->SubmitDrawData(view);
|
||||
drawContext->SubmitDrawList(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,6 +102,25 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::vector<RHI::DrawListView> DynamicDrawSystem::GetDrawListsForPass(const RasterPass* pass)
|
||||
{
|
||||
AZStd::vector<RHI::DrawListView> result;
|
||||
AZStd::lock_guard<AZStd::mutex> lock(m_mutexDrawContext);
|
||||
for (RHI::Ptr<DynamicDrawContext> drawContext : m_dynamicDrawContexts)
|
||||
{
|
||||
if (drawContext->m_pass == pass)
|
||||
{
|
||||
drawContext->FinalizeDrawList();
|
||||
auto drawListView = drawContext->GetDrawList();
|
||||
if (drawListView.size() > 0)
|
||||
{
|
||||
result.push_back(drawListView);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void DynamicDrawSystem::FrameEnd()
|
||||
{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user