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" "FilePath": "Shaders/PostProcessing/SsaoCompute.shader"
}, },
"Make Fullscreen Pass": true, "Make Fullscreen Pass": true,
"PipelineViewTag": "MainCamera" "PipelineViewTag": "MainCamera",
"Use Async Compute": true
}, },
"FallbackConnections": [ "FallbackConnections": [
{ {

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

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

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

@ -76,6 +76,9 @@ namespace AZ
/// Returns the hardware queue class for this scope. /// Returns the hardware queue class for this scope.
HardwareQueueClass GetHardwareQueueClass() const; 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 * 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 * 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; const AZStd::vector<Ptr<Fence>>& GetFencesToSignal() const;
/// Initializes the scope. /// Initializes the scope.
void Init(const ScopeId& scopeId); void Init(const ScopeId& scopeId, HardwareQueueClass hardwareQueueClass = HardwareQueueClass::Graphics);
/// Activates the scope for the current frame. /// Activates the scope for the current frame.
void Activate(const FrameGraph* frameGraph, uint32_t index, const GraphGroupId& groupId); void Activate(const FrameGraph* frameGraph, uint32_t index, const GraphGroupId& groupId);

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

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

@ -40,7 +40,18 @@ namespace AZ
return m_scope.get(); return m_scope.get();
} }
void ScopeProducer::SetHardwareQueueClass(HardwareQueueClass hardwareQueueClass)
{
m_scope->SetHardwareQueueClass(hardwareQueueClass);
}
// DEPRECATED: use InitScope instead
void ScopeProducer::SetScopeId(const ScopeId& scopeId) void ScopeProducer::SetScopeId(const ScopeId& scopeId)
{
InitScope(scopeId);
}
void ScopeProducer::InitScope(const ScopeId& scopeId, HardwareQueueClass hardwareQueueClass)
{ {
m_scopeId = scopeId; m_scopeId = scopeId;
@ -49,7 +60,7 @@ namespace AZ
m_scope->Shutdown(); 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 // The shader resource group for this pass
Data::Instance<ShaderResourceGroup> m_shaderResourceGroup = nullptr; Data::Instance<ShaderResourceGroup> m_shaderResourceGroup = nullptr;
// Determines which hardware queue the pass will run on
RHI::HardwareQueueClass m_hardwareQueueClass = RHI::HardwareQueueClass::Graphics;
private: private:
// Helper function that binds a single attachment to the pass shader resource group // 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); 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)) if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{ {
serializeContext->Class<ComputePassData, RenderPassData>() serializeContext->Class<ComputePassData, RenderPassData>()
->Version(1) ->Version(2)
->Field("ShaderAsset", &ComputePassData::m_shaderReference) ->Field("ShaderAsset", &ComputePassData::m_shaderReference)
->Field("Target Thread Count X", &ComputePassData::m_totalNumberOfThreadsX) ->Field("Target Thread Count X", &ComputePassData::m_totalNumberOfThreadsX)
->Field("Target Thread Count Y", &ComputePassData::m_totalNumberOfThreadsY) ->Field("Target Thread Count Y", &ComputePassData::m_totalNumberOfThreadsY)
->Field("Target Thread Count Z", &ComputePassData::m_totalNumberOfThreadsZ) ->Field("Target Thread Count Z", &ComputePassData::m_totalNumberOfThreadsZ)
->Field("Make Fullscreen Pass", &ComputePassData::m_makeFullscreenPass) ->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; uint32_t m_totalNumberOfThreadsZ = 0;
bool m_makeFullscreenPass = false; 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 RPI
} // namespace AZ } // namespace AZ

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

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

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

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

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

Loading…
Cancel
Save