Added support for hardware queue class on passes (#7339)

* Added support for hardware queue class on passes. Compute pass data and copy pass data can now specify to run on their appropriate queue.

Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>

* addressed PR feedaback

Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>

* fixing python test failures on AR

Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>
monroegm-disable-blank-issue-2
antonmic 4 years ago committed by GitHub
parent 01892914ea
commit 4216e4cfed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,7 +50,8 @@
"FilePath": "Shaders/PostProcessing/SsaoCompute.shader"
},
"Make Fullscreen Pass": true,
"PipelineViewTag": "MainCamera"
"PipelineViewTag": "MainCamera",
"Use Async Compute": true
},
"FallbackConnections": [
{

@ -72,7 +72,7 @@ namespace AZ
void DiffuseProbeGridVisualizationAccelerationStructurePass::BuildInternal()
{
SetScopeId(RHI::ScopeId(GetPathName()));
InitScope(RHI::ScopeId(GetPathName()));
}
void DiffuseProbeGridVisualizationAccelerationStructurePass::FrameBeginInternal(FramePrepareParams params)

@ -50,7 +50,7 @@ namespace AZ
void DepthOfFieldCopyFocusDepthToCpuPass::BuildInternal()
{
SetScopeId(RHI::ScopeId(GetPathName()));
InitScope(RHI::ScopeId(GetPathName()));
}
void DepthOfFieldCopyFocusDepthToCpuPass::FrameBeginInternal(FramePrepareParams params)

@ -40,7 +40,7 @@ namespace AZ
void RayTracingAccelerationStructurePass::BuildInternal()
{
SetScopeId(RHI::ScopeId(GetPathName()));
InitScope(RHI::ScopeId(GetPathName()));
}
void RayTracingAccelerationStructurePass::FrameBeginInternal(FramePrepareParams params)

@ -76,6 +76,9 @@ namespace AZ
/// Returns the hardware queue class for this scope.
HardwareQueueClass GetHardwareQueueClass() const;
/// Sets the hardware queue class for this scope.
void SetHardwareQueueClass(HardwareQueueClass hardwareQueueClass);
/**
* Returns the estimated number of draw / dispatch / copy items that the user will submit
* while in this scope. This is an estimation intended to be used by the platform-specific
@ -120,7 +123,7 @@ namespace AZ
const AZStd::vector<Ptr<Fence>>& GetFencesToSignal() const;
/// Initializes the scope.
void Init(const ScopeId& scopeId);
void Init(const ScopeId& scopeId, HardwareQueueClass hardwareQueueClass = HardwareQueueClass::Graphics);
/// Activates the scope for the current frame.
void Activate(const FrameGraph* frameGraph, uint32_t index, const GraphGroupId& groupId);

@ -86,11 +86,22 @@ namespace AZ
ScopeProducer();
/**
* Sets ID of the scope producer. Used by class that inherit from
* ScopeProducer but that can't supply a ScopeId at construction.
* Sets the HardwareQueueClass on the scope
*/
void SetHardwareQueueClass(HardwareQueueClass hardwareQueueClass);
/**
* DEPRECATED.
* @deprecated Use InitScope instead
*/
void SetScopeId(const ScopeId& scopeId);
/**
* Initializes the scope with a ScopeId and HardwareQueueClass.
* Used by classes that inherit from ScopeProducer but can't supply a ScopeId at construction.
*/
void InitScope(const ScopeId& scopeId, HardwareQueueClass hardwareQueueClass = HardwareQueueClass::Graphics);
private:
//////////////////////////////////////////////////////////////////////////
// User Overrides - Derived classes should override from these methods.

@ -24,12 +24,13 @@ namespace AZ
return m_isActive;
}
void Scope::Init(const ScopeId& scopeId)
void Scope::Init(const ScopeId& scopeId, HardwareQueueClass hardwareQueueClass)
{
AZ_Assert(!scopeId.IsEmpty(), "Scope id is not valid.");
AZ_Assert(IsInitialized() == false, "Scope was previously initialized.");
SetName(scopeId);
m_id = scopeId;
m_hardwareQueueClass = hardwareQueueClass;
InitInternal();
m_isInitialized = true;
}
@ -134,6 +135,11 @@ namespace AZ
return m_hardwareQueueClass;
}
void Scope::SetHardwareQueueClass(HardwareQueueClass hardwareQueueClass)
{
m_hardwareQueueClass = hardwareQueueClass;
}
uint32_t Scope::GetEstimatedItemCount() const
{
return m_estimatedItemCount;

@ -40,7 +40,18 @@ namespace AZ
return m_scope.get();
}
void ScopeProducer::SetHardwareQueueClass(HardwareQueueClass hardwareQueueClass)
{
m_scope->SetHardwareQueueClass(hardwareQueueClass);
}
// DEPRECATED: use InitScope instead
void ScopeProducer::SetScopeId(const ScopeId& scopeId)
{
InitScope(scopeId);
}
void ScopeProducer::InitScope(const ScopeId& scopeId, HardwareQueueClass hardwareQueueClass)
{
m_scopeId = scopeId;
@ -49,7 +60,7 @@ namespace AZ
m_scope->Shutdown();
}
m_scope->Init(scopeId);
m_scope->Init(scopeId, hardwareQueueClass);
}
}
}

@ -113,6 +113,9 @@ namespace AZ
// The shader resource group for this pass
Data::Instance<ShaderResourceGroup> m_shaderResourceGroup = nullptr;
// Determines which hardware queue the pass will run on
RHI::HardwareQueueClass m_hardwareQueueClass = RHI::HardwareQueueClass::Graphics;
private:
// Helper function that binds a single attachment to the pass shader resource group
void BindAttachment(const RHI::FrameGraphCompileContext& context, PassAttachmentBinding& binding, int16_t& imageIndex, int16_t& bufferIndex);

@ -29,12 +29,13 @@ namespace AZ
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<ComputePassData, RenderPassData>()
->Version(1)
->Version(2)
->Field("ShaderAsset", &ComputePassData::m_shaderReference)
->Field("Target Thread Count X", &ComputePassData::m_totalNumberOfThreadsX)
->Field("Target Thread Count Y", &ComputePassData::m_totalNumberOfThreadsY)
->Field("Target Thread Count Z", &ComputePassData::m_totalNumberOfThreadsZ)
->Field("Make Fullscreen Pass", &ComputePassData::m_makeFullscreenPass)
->Field("Use Async Compute", &ComputePassData::m_useAsyncCompute)
;
}
}
@ -46,6 +47,9 @@ namespace AZ
uint32_t m_totalNumberOfThreadsZ = 0;
bool m_makeFullscreenPass = false;
// Whether the pass should use async compute and run on the compute hardware queue.
bool m_useAsyncCompute = false;
};
} // namespace RPI
} // namespace AZ

@ -32,7 +32,7 @@ namespace AZ
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<CopyPassData, PassData>()
->Version(0)
->Version(1)
->Field("BufferSize", &CopyPassData::m_bufferSize)
->Field("BufferSourceOffset", &CopyPassData::m_bufferSourceOffset)
->Field("BufferSourceBytesPerRow", &CopyPassData::m_bufferSourceBytesPerRow)
@ -46,6 +46,7 @@ namespace AZ
->Field("ImageDestinationSubresource", &CopyPassData::m_imageDestinationSubresource)
->Field("ImageDestinationOrigin", &CopyPassData::m_imageDestinationOrigin)
->Field("CloneInput", &CopyPassData::m_cloneInput)
->Field("UseCopyQueue", &CopyPassData::m_useCopyQueue)
;
}
}
@ -75,6 +76,9 @@ namespace AZ
// If set to true, pass will automatically create a transient output attachment based on input
// If false, the output target of the copy will need to be specified
bool m_cloneInput = true;
// Whether the pass should use the copy queue.
bool m_useCopyQueue = false;
};
} // namespace RPI
} // namespace AZ

@ -58,6 +58,12 @@ namespace AZ
return;
}
// Hardware Queue Class
if (passData->m_useAsyncCompute)
{
m_hardwareQueueClass = RHI::HardwareQueueClass::Compute;
}
// Load Shader
Data::Asset<ShaderAsset> shaderAsset;
if (passData->m_shaderReference.m_assetId.IsValid())

@ -38,6 +38,11 @@ namespace AZ
if (copyData)
{
m_data = *copyData;
if (copyData->m_useCopyQueue)
{
m_hardwareQueueClass = RHI::HardwareQueueClass::Copy;
}
}
}

@ -183,7 +183,7 @@ namespace AZ
{
if (GetScopeId().IsEmpty())
{
SetScopeId(RHI::ScopeId(GetPathName()));
InitScope(RHI::ScopeId(GetPathName()), m_hardwareQueueClass);
}
params.m_frameGraphBuilder->ImportScopeProducer(*this);

@ -32,7 +32,7 @@ namespace AZ
m_destAttachmentId = destAttachmentId;
// Use the unique destination attachment id as scope id
SetScopeId(m_destAttachmentId);
InitScope(m_destAttachmentId);
// Clear the previous attachment and copy item
m_copyItem = {};
@ -124,7 +124,7 @@ namespace AZ
ImageAttachmentPreviewPass::ImageAttachmentPreviewPass(const PassDescriptor& descriptor)
: Pass(descriptor)
{
SetScopeId(RHI::ScopeId(GetPathName()));
InitScope(RHI::ScopeId(GetPathName()));
}
ImageAttachmentPreviewPass::~ImageAttachmentPreviewPass()

Loading…
Cancel
Save