|
|
|
|
@ -30,42 +30,26 @@ namespace AZ
|
|
|
|
|
|
|
|
|
|
void RHISystem::InitDevice()
|
|
|
|
|
{
|
|
|
|
|
m_device = InitInternalDevice();
|
|
|
|
|
Interface<RHISystemInterface>::Register(this);
|
|
|
|
|
m_device = InitInternalDevice();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RHISystem::Init(const RHISystemDescriptor& descriptor)
|
|
|
|
|
{
|
|
|
|
|
m_cpuProfiler.Init();
|
|
|
|
|
|
|
|
|
|
RHI::FrameSchedulerDescriptor frameSchedulerDescriptor;
|
|
|
|
|
if (descriptor.m_platformLimits)
|
|
|
|
|
{
|
|
|
|
|
m_platformLimitsDescriptor = descriptor.m_platformLimits->m_platformLimitsDescriptor;
|
|
|
|
|
}
|
|
|
|
|
Ptr<RHI::PlatformLimitsDescriptor> platformLimitsDescriptor = m_device->GetDescriptor().m_platformLimitsDescriptor;
|
|
|
|
|
|
|
|
|
|
//If platformlimits.azasset file is not provided create an object with default config values.
|
|
|
|
|
if (!m_platformLimitsDescriptor)
|
|
|
|
|
{
|
|
|
|
|
m_platformLimitsDescriptor = PlatformLimitsDescriptor::Create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RHI::DeviceDescriptor deviceDesc;
|
|
|
|
|
deviceDesc.m_platformLimitsDescriptor = m_platformLimitsDescriptor;
|
|
|
|
|
if (m_device->PostInit(deviceDesc) != RHI::ResultCode::Success)
|
|
|
|
|
{
|
|
|
|
|
AZ_Assert(false, "RHISystem", "Unable to initialize RHI! \n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
RHI::FrameSchedulerDescriptor frameSchedulerDescriptor;
|
|
|
|
|
|
|
|
|
|
m_drawListTagRegistry = RHI::DrawListTagRegistry::Create();
|
|
|
|
|
m_pipelineStateCache = RHI::PipelineStateCache::Create(*m_device);
|
|
|
|
|
|
|
|
|
|
frameSchedulerDescriptor.m_transientAttachmentPoolDescriptor.m_renderTargetBudgetInBytes = m_platformLimitsDescriptor->m_transientAttachmentPoolBudgets.m_renderTargetBudgetInBytes;
|
|
|
|
|
frameSchedulerDescriptor.m_transientAttachmentPoolDescriptor.m_imageBudgetInBytes = m_platformLimitsDescriptor->m_transientAttachmentPoolBudgets.m_imageBudgetInBytes;
|
|
|
|
|
frameSchedulerDescriptor.m_transientAttachmentPoolDescriptor.m_bufferBudgetInBytes = m_platformLimitsDescriptor->m_transientAttachmentPoolBudgets.m_bufferBudgetInBytes;
|
|
|
|
|
frameSchedulerDescriptor.m_transientAttachmentPoolDescriptor.m_renderTargetBudgetInBytes = platformLimitsDescriptor->m_transientAttachmentPoolBudgets.m_renderTargetBudgetInBytes;
|
|
|
|
|
frameSchedulerDescriptor.m_transientAttachmentPoolDescriptor.m_imageBudgetInBytes = platformLimitsDescriptor->m_transientAttachmentPoolBudgets.m_imageBudgetInBytes;
|
|
|
|
|
frameSchedulerDescriptor.m_transientAttachmentPoolDescriptor.m_bufferBudgetInBytes = platformLimitsDescriptor->m_transientAttachmentPoolBudgets.m_bufferBudgetInBytes;
|
|
|
|
|
|
|
|
|
|
switch (m_platformLimitsDescriptor->m_heapAllocationStrategy)
|
|
|
|
|
switch (platformLimitsDescriptor->m_heapAllocationStrategy)
|
|
|
|
|
{
|
|
|
|
|
case HeapAllocationStrategy::Fixed:
|
|
|
|
|
{
|
|
|
|
|
@ -75,19 +59,19 @@ namespace AZ
|
|
|
|
|
case HeapAllocationStrategy::Paging:
|
|
|
|
|
{
|
|
|
|
|
RHI::HeapPagingParameters heapAllocationParameters;
|
|
|
|
|
heapAllocationParameters.m_collectLatency = m_platformLimitsDescriptor->m_pagingParameters.m_collectLatency;
|
|
|
|
|
heapAllocationParameters.m_initialAllocationPercentage = m_platformLimitsDescriptor->m_pagingParameters.m_initialAllocationPercentage;
|
|
|
|
|
heapAllocationParameters.m_pageSizeInBytes = m_platformLimitsDescriptor->m_pagingParameters.m_pageSizeInBytes;
|
|
|
|
|
heapAllocationParameters.m_collectLatency = platformLimitsDescriptor->m_pagingParameters.m_collectLatency;
|
|
|
|
|
heapAllocationParameters.m_initialAllocationPercentage = platformLimitsDescriptor->m_pagingParameters.m_initialAllocationPercentage;
|
|
|
|
|
heapAllocationParameters.m_pageSizeInBytes = platformLimitsDescriptor->m_pagingParameters.m_pageSizeInBytes;
|
|
|
|
|
frameSchedulerDescriptor.m_transientAttachmentPoolDescriptor.m_heapParameters = RHI::HeapAllocationParameters(heapAllocationParameters);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case HeapAllocationStrategy::MemoryHint:
|
|
|
|
|
{
|
|
|
|
|
RHI::HeapMemoryHintParameters heapAllocationParameters;
|
|
|
|
|
heapAllocationParameters.m_heapSizeScaleFactor = m_platformLimitsDescriptor->m_usageHintParameters.m_heapSizeScaleFactor;
|
|
|
|
|
heapAllocationParameters.m_collectLatency = m_platformLimitsDescriptor->m_usageHintParameters.m_collectLatency;
|
|
|
|
|
heapAllocationParameters.m_maxHeapWastedPercentage = m_platformLimitsDescriptor->m_usageHintParameters.m_maxHeapWastedPercentage;
|
|
|
|
|
heapAllocationParameters.m_minHeapSizeInBytes = m_platformLimitsDescriptor->m_usageHintParameters.m_minHeapSizeInBytes;
|
|
|
|
|
heapAllocationParameters.m_heapSizeScaleFactor = platformLimitsDescriptor->m_usageHintParameters.m_heapSizeScaleFactor;
|
|
|
|
|
heapAllocationParameters.m_collectLatency = platformLimitsDescriptor->m_usageHintParameters.m_collectLatency;
|
|
|
|
|
heapAllocationParameters.m_maxHeapWastedPercentage = platformLimitsDescriptor->m_usageHintParameters.m_maxHeapWastedPercentage;
|
|
|
|
|
heapAllocationParameters.m_minHeapSizeInBytes = platformLimitsDescriptor->m_usageHintParameters.m_minHeapSizeInBytes;
|
|
|
|
|
frameSchedulerDescriptor.m_transientAttachmentPoolDescriptor.m_heapParameters = RHI::HeapAllocationParameters(heapAllocationParameters);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
@ -98,7 +82,7 @@ namespace AZ
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frameSchedulerDescriptor.m_platformLimitsDescriptor = m_platformLimitsDescriptor;
|
|
|
|
|
frameSchedulerDescriptor.m_platformLimitsDescriptor = platformLimitsDescriptor;
|
|
|
|
|
m_frameScheduler.Init(*m_device, frameSchedulerDescriptor);
|
|
|
|
|
|
|
|
|
|
// Register draw list tags declared from content.
|
|
|
|
|
@ -183,6 +167,7 @@ namespace AZ
|
|
|
|
|
RHI::Ptr<RHI::Device> device = RHI::Factory::Get().CreateDevice();
|
|
|
|
|
if (device->Init(*physicalDeviceFound) == RHI::ResultCode::Success)
|
|
|
|
|
{
|
|
|
|
|
PlatformLimitsDescriptor::Create();
|
|
|
|
|
return device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -195,7 +180,6 @@ namespace AZ
|
|
|
|
|
Interface<RHISystemInterface>::Unregister(this);
|
|
|
|
|
m_frameScheduler.Shutdown();
|
|
|
|
|
|
|
|
|
|
m_platformLimitsDescriptor = nullptr;
|
|
|
|
|
m_pipelineStateCache = nullptr;
|
|
|
|
|
if (m_device)
|
|
|
|
|
{
|
|
|
|
|
@ -293,7 +277,7 @@ namespace AZ
|
|
|
|
|
|
|
|
|
|
ConstPtr<PlatformLimitsDescriptor> RHISystem::GetPlatformLimitsDescriptor() const
|
|
|
|
|
{
|
|
|
|
|
return m_platformLimitsDescriptor;
|
|
|
|
|
return m_device->GetDescriptor().m_platformLimitsDescriptor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RHISystem::QueueRayTracingShaderTableForBuild(RayTracingShaderTable* rayTracingShaderTable)
|
|
|
|
|
|