Fix RHI/Subpass sample for Vulkan. The issue was that we were exectui… (#4904)

* Fix RHI/Subpass sample for Vulkan. The issue was that we were exectuing the sub-pass groups more than once when parallel encoding was used.

Signed-off-by: moudgils <moudgils@amazon.com>

* Added a minor comment

Signed-off-by: moudgils <moudgils@amazon.com>

* Minor perf improvement

Signed-off-by: moudgils <moudgils@amazon.com>
monroegm-disable-blank-issue-2
moudgils 4 years ago committed by GitHub
parent 267d690171
commit ee043f4fed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,6 +27,7 @@ namespace AZ
{ {
EndInternal(); EndInternal();
m_device->GetCommandQueueContext().GetCommandQueue(m_hardwareQueueClass).ExecuteWork(AZStd::move(m_workRequest)); m_device->GetCommandQueueContext().GetCommandQueue(m_hardwareQueueClass).ExecuteWork(AZStd::move(m_workRequest));
m_isExecuted = true;
} }
bool FrameGraphExecuteGroupHandlerBase::IsComplete() const bool FrameGraphExecuteGroupHandlerBase::IsComplete() const
@ -42,6 +43,11 @@ namespace AZ
return true; return true;
} }
bool FrameGraphExecuteGroupHandlerBase::IsExecuted() const
{
return m_isExecuted;
}
template<class T> template<class T>
void InsertWorkRequestElements(T& destination, const T& source) void InsertWorkRequestElements(T& destination, const T& source)
{ {

@ -41,6 +41,7 @@ namespace AZ
void End(); void End();
bool IsComplete() const; bool IsComplete() const;
bool IsExecuted() const;
protected: protected:
virtual RHI::ResultCode InitInternal(Device& device, const AZStd::vector<RHI::FrameGraphExecuteGroup*>& executeGroups) = 0; virtual RHI::ResultCode InitInternal(Device& device, const AZStd::vector<RHI::FrameGraphExecuteGroup*>& executeGroups) = 0;
@ -52,6 +53,7 @@ namespace AZ
ExecuteWorkRequest m_workRequest; ExecuteWorkRequest m_workRequest;
RHI::HardwareQueueClass m_hardwareQueueClass = RHI::HardwareQueueClass::Graphics; RHI::HardwareQueueClass m_hardwareQueueClass = RHI::HardwareQueueClass::Graphics;
AZStd::vector<RHI::FrameGraphExecuteGroup*> m_executeGroups; AZStd::vector<RHI::FrameGraphExecuteGroup*> m_executeGroups;
bool m_isExecuted = false;
}; };
} }
} }

@ -177,8 +177,8 @@ namespace AZ
auto findIter = m_groupHandlers.find(group.GetGroupId()); auto findIter = m_groupHandlers.find(group.GetGroupId());
AZ_Assert(findIter != m_groupHandlers.end(), "Could not find group handler for groupId %d", group.GetGroupId().GetIndex()); AZ_Assert(findIter != m_groupHandlers.end(), "Could not find group handler for groupId %d", group.GetGroupId().GetIndex());
FrameGraphExecuteGroupHandlerBase* handler = findIter->second.get(); FrameGraphExecuteGroupHandlerBase* handler = findIter->second.get();
// Wait until all execute groups of the handler has finished. // Wait until all execute groups of the handler has finished and also make sure that the handler itself hasn't executed already (which is possible for parallel encoding).
if (handler->IsComplete()) if (!handler->IsExecuted() && handler->IsComplete())
{ {
// This will execute the recorded work into the queue. // This will execute the recorded work into the queue.
handler->End(); handler->End();

Loading…
Cancel
Save