ATOM-13883 [RHI][Core] - Moving RHI init settings to the new settings registry system (#3086)
* Moved PlatformLimits to setreg. Removed Device PostInit. Some clean up. Signed-off-by: jiaweig <jiaweig@amazon.com> * Move setreg loading the PlatformLimitsDescriptor super class. Signed-off-by: jiaweig <jiaweig@amazon.com> * Apply same implementation for fake device used in unit tests Signed-off-by: jiaweig <jiaweig@amazon.com> * Add implementation for Null renderer. Swap order for register RHI interface in initialization. Signed-off-by: jiaweig <jiaweig@amazon.com> * Move back setreg from PlatfromLimitsDescriptor to Device, due to Linux dependency issue. Signed-off-by: jiaweig <jiaweig@amazon.com> * Changed the function to take in RHI backend name Signed-off-by: jiaweig <jiaweig@amazon.com>
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 0,
|
||||
"ClassName": "PlatformLimits",
|
||||
"ClassData": {
|
||||
"m_platformLimitsDescriptor":
|
||||
{
|
||||
"$type": "Vulkan::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 0,
|
||||
"ClassName": "PlatformLimits",
|
||||
"ClassData": {
|
||||
"m_platformLimitsDescriptor":
|
||||
{
|
||||
"$type": "Vulkan::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 0,
|
||||
"ClassName": "PlatformLimits",
|
||||
"ClassData": {
|
||||
"m_platformLimitsDescriptor":
|
||||
{
|
||||
"$type": "Metal::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 0,
|
||||
"ClassName": "PlatformLimits",
|
||||
"ClassData": {
|
||||
"m_platformLimitsDescriptor":
|
||||
{
|
||||
"$type": "DX12::PlatformLimitsDescriptor",
|
||||
|
||||
"m_descriptorHeapLimits": {
|
||||
"DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV": [1000000, 1000000],
|
||||
"DESCRIPTOR_HEAP_TYPE_SAMPLER": [2048, 2048],
|
||||
"DESCRIPTOR_HEAP_TYPE_RTV": [2048, 0],
|
||||
"DESCRIPTOR_HEAP_TYPE_DSV": [2048, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 0,
|
||||
"ClassName": "PlatformLimits",
|
||||
"ClassData": {
|
||||
"m_platformLimitsDescriptor":
|
||||
{
|
||||
"$type": "Vulkan::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 0,
|
||||
"ClassName": "PlatformLimits",
|
||||
"ClassData": {
|
||||
"m_platformLimitsDescriptor":
|
||||
{
|
||||
"$type": "Metal::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace AZ
|
||||
class DeviceDescriptor
|
||||
{
|
||||
public:
|
||||
virtual ~DeviceDescriptor() = default;
|
||||
AZ_RTTI(DeviceDescriptor, "{8446A34C-A079-44B8-A20F-45D9CAB1FAFD}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
DeviceDescriptor() = default;
|
||||
virtual ~DeviceDescriptor();
|
||||
|
||||
uint32_t m_frameCountMax = RHI::Limits::Device::FrameCountMax;
|
||||
ConstPtr<PlatformLimitsDescriptor> m_platformLimitsDescriptor = nullptr;
|
||||
Ptr<PlatformLimitsDescriptor> m_platformLimitsDescriptor = nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace AZ
|
||||
{
|
||||
struct TransientAttachmentPoolBudgets
|
||||
{
|
||||
AZ_TYPE_INFO(TransientAttachmentPoolBudgets, "{CE39BBEF-C9CD-4B9A-BA41-C886D9F063BC}");
|
||||
AZ_TYPE_INFO(AZ::RHI::TransientAttachmentPoolBudgets, "{CE39BBEF-C9CD-4B9A-BA41-C886D9F063BC}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
//! Defines the maximum amount of memory the pool is allowed to consume for transient buffers.
|
||||
@@ -53,8 +53,8 @@ namespace AZ
|
||||
: public AZStd::intrusive_base
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(PlatformLimitsDescriptor, "{3A7B2BE4-0337-4F59-B4FC-B7E529EBE6C5}");
|
||||
AZ_CLASS_ALLOCATOR(PlatformLimitsDescriptor, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(AZ::RHI::PlatformLimitsDescriptor, "{3A7B2BE4-0337-4F59-B4FC-B7E529EBE6C5}");
|
||||
AZ_CLASS_ALLOCATOR(AZ::RHI::PlatformLimitsDescriptor, AZ::SystemAllocator, 0);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
static RHI::Ptr<PlatformLimitsDescriptor> Create();
|
||||
|
||||
@@ -67,13 +67,15 @@ namespace AZ
|
||||
HeapPagingParameters m_pagingParameters;
|
||||
HeapMemoryHintParameters m_usageHintParameters;
|
||||
HeapAllocationStrategy m_heapAllocationStrategy = HeapAllocationStrategy::MemoryHint;
|
||||
|
||||
void LoadPlatformLimitsDescriptor(const char* rhiName);
|
||||
};
|
||||
|
||||
class PlatformLimits final
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(PlatformLimits, "{48158F25-5044-441C-A2B2-2D3E9255B0C3}");
|
||||
AZ_CLASS_ALLOCATOR(PlatformLimits, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(AZ::RHI::PlatformLimits, "{48158F25-5044-441C-A2B2-2D3E9255B0C3}");
|
||||
AZ_CLASS_ALLOCATOR(AZ::RHI::PlatformLimits, AZ::SystemAllocator, 0);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
Ptr<PlatformLimitsDescriptor> m_platformLimitsDescriptor = nullptr;
|
||||
|
||||
@@ -26,8 +26,6 @@ namespace AZ
|
||||
|
||||
//! The set of globally declared draw list tags, which will be registered with the registry at startup.
|
||||
AZStd::vector<AZ::Name> m_drawListTags;
|
||||
|
||||
const RHI::PlatformLimits* m_platformLimits = nullptr;
|
||||
};
|
||||
} // namespace RHI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -60,10 +60,6 @@ namespace AZ
|
||||
//! been called), and an error code is returned.
|
||||
ResultCode Init(PhysicalDevice& physicalDevice);
|
||||
|
||||
//! Called to initialize anything that wasn't done as part of Init. DeviceDescriptor is passed down
|
||||
//! as part of this API. This is called after AssetCatalog is loaded and hence any file can be loaded at this point
|
||||
ResultCode PostInit(const DeviceDescriptor& descriptor);
|
||||
|
||||
//! Begins execution of a frame. The device internally manages a set of command queues. This
|
||||
//! method will synchronize the CPU with the GPU according to the number of in-light frames
|
||||
//! configured on the device. This means you should make sure any manipulation of N-buffered
|
||||
@@ -147,7 +143,9 @@ namespace AZ
|
||||
DeviceFeatures m_features;
|
||||
DeviceLimits m_limits;
|
||||
ResourcePoolDatabase m_resourcePoolDatabase;
|
||||
|
||||
|
||||
DeviceDescriptor m_descriptor;
|
||||
|
||||
using FormatCapabilitiesList = AZStd::array<FormatCapabilities, static_cast<uint32_t>(Format::Count)>;
|
||||
|
||||
private:
|
||||
@@ -165,10 +163,6 @@ namespace AZ
|
||||
|
||||
//! Called when just the device is being initialized.
|
||||
virtual ResultCode InitInternal(PhysicalDevice& physicalDevice) = 0;
|
||||
|
||||
//! Called to initialize anything that wasnt done as part of InitInternal.
|
||||
//! This is called after AssetCatalog is loaded and hence any file can be loaded at this point
|
||||
virtual ResultCode PostInitInternal(const DeviceDescriptor& descriptor) = 0;
|
||||
|
||||
//! Called when the device is being shutdown.
|
||||
virtual void ShutdownInternal() = 0;
|
||||
@@ -190,6 +184,9 @@ namespace AZ
|
||||
|
||||
//! Fills the capabilities for each format.
|
||||
virtual void FillFormatsCapabilitiesInternal(FormatCapabilitiesList& formatsCapabilities) = 0;
|
||||
|
||||
//! Initialize limits and resources associated with them.
|
||||
virtual ResultCode InitializeLimits() = 0;
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
void CalculateDepthStencilNearestSupportedFormats();
|
||||
@@ -198,8 +195,6 @@ namespace AZ
|
||||
//! All platform specific format mappings should be executed before this function is called
|
||||
void FillRemainingSupportedFormats();
|
||||
|
||||
DeviceDescriptor m_descriptor;
|
||||
|
||||
// The physical device backing this logical device instance.
|
||||
Ptr<PhysicalDevice> m_physicalDevice;
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ namespace AZ
|
||||
RHI::FrameScheduler m_frameScheduler;
|
||||
RHI::FrameSchedulerCompileRequest m_compileRequest;
|
||||
|
||||
ConstPtr<PlatformLimitsDescriptor> m_platformLimitsDescriptor = nullptr;
|
||||
RHI::CpuProfilerImpl m_cpuProfiler;
|
||||
};
|
||||
} // namespace RPI
|
||||
|
||||
@@ -24,5 +24,11 @@ namespace AZ
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
DeviceDescriptor::~DeviceDescriptor()
|
||||
{
|
||||
m_platformLimitsDescriptor = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
#include <Atom/RHI.Reflect/PlatformLimitsDescriptor.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Settings/SettingsRegistryImpl.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -17,8 +18,8 @@ namespace AZ
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PlatformLimits>()
|
||||
->Version(0)
|
||||
->Field("m_platformLimitsDescriptor", &PlatformLimits::m_platformLimitsDescriptor)
|
||||
->Version(1)
|
||||
->Field("PlatformLimitsDescriptor", &PlatformLimits::m_platformLimitsDescriptor)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -28,10 +29,10 @@ namespace AZ
|
||||
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<TransientAttachmentPoolBudgets>()
|
||||
->Version(0)
|
||||
->Field("m_bufferBudgetInBytes", &TransientAttachmentPoolBudgets::m_bufferBudgetInBytes)
|
||||
->Field("m_imageBudgetInBytes", &TransientAttachmentPoolBudgets::m_imageBudgetInBytes)
|
||||
->Field("m_renderTargetBudgetInBytes", &TransientAttachmentPoolBudgets::m_renderTargetBudgetInBytes)
|
||||
->Version(1)
|
||||
->Field("BufferBudgetInBytes", &TransientAttachmentPoolBudgets::m_bufferBudgetInBytes)
|
||||
->Field("ImageBudgetInBytes", &TransientAttachmentPoolBudgets::m_imageBudgetInBytes)
|
||||
->Field("RenderTargetBudgetInBytes", &TransientAttachmentPoolBudgets::m_renderTargetBudgetInBytes)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -41,13 +42,13 @@ namespace AZ
|
||||
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PlatformDefaultValues>()
|
||||
->Version(0)
|
||||
->Field("m_stagingBufferBudgetInBytes", &PlatformDefaultValues::m_stagingBufferBudgetInBytes)
|
||||
->Field("m_asyncQueueStagingBufferSizeInBytes", &PlatformDefaultValues::m_asyncQueueStagingBufferSizeInBytes)
|
||||
->Field("m_mediumStagingBufferPageSizeInBytes", &PlatformDefaultValues::m_mediumStagingBufferPageSizeInBytes)
|
||||
->Field("m_largestStagingBufferPageSizeInBytes", &PlatformDefaultValues::m_largestStagingBufferPageSizeInBytes)
|
||||
->Field("m_imagePoolPageSizeInBytes", &PlatformDefaultValues::m_imagePoolPageSizeInBytes)
|
||||
->Field("m_bufferPoolPageSizeInBytes", &PlatformDefaultValues::m_bufferPoolPageSizeInBytes)
|
||||
->Version(1)
|
||||
->Field("StagingBufferBudgetInBytes", &PlatformDefaultValues::m_stagingBufferBudgetInBytes)
|
||||
->Field("AsyncQueueStagingBufferSizeInBytes", &PlatformDefaultValues::m_asyncQueueStagingBufferSizeInBytes)
|
||||
->Field("MediumStagingBufferPageSizeInBytes", &PlatformDefaultValues::m_mediumStagingBufferPageSizeInBytes)
|
||||
->Field("LargestStagingBufferPageSizeInBytes", &PlatformDefaultValues::m_largestStagingBufferPageSizeInBytes)
|
||||
->Field("ImagePoolPageSizeInBytes", &PlatformDefaultValues::m_imagePoolPageSizeInBytes)
|
||||
->Field("BufferPoolPageSizeInBytes", &PlatformDefaultValues::m_bufferPoolPageSizeInBytes)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -58,12 +59,12 @@ namespace AZ
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PlatformLimitsDescriptor>()
|
||||
->Version(1)
|
||||
->Field("m_transientAttachmentPoolBudgets", &PlatformLimitsDescriptor::m_transientAttachmentPoolBudgets)
|
||||
->Field("m_platformDefaultValues", &PlatformLimitsDescriptor::m_platformDefaultValues)
|
||||
->Field("m_pagingParameters", &PlatformLimitsDescriptor::m_pagingParameters)
|
||||
->Field("m_usageHintParameters", &PlatformLimitsDescriptor::m_usageHintParameters)
|
||||
->Field("m_heapAllocationStrategy", &PlatformLimitsDescriptor::m_heapAllocationStrategy)
|
||||
->Version(2)
|
||||
->Field("TransientAttachmentPoolBudgets", &PlatformLimitsDescriptor::m_transientAttachmentPoolBudgets)
|
||||
->Field("PlatformDefaultValues", &PlatformLimitsDescriptor::m_platformDefaultValues)
|
||||
->Field("PagingParameters", &PlatformLimitsDescriptor::m_pagingParameters)
|
||||
->Field("UsageHintParameters", &PlatformLimitsDescriptor::m_usageHintParameters)
|
||||
->Field("HeapAllocationStrategy", &PlatformLimitsDescriptor::m_heapAllocationStrategy)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -72,5 +73,18 @@ namespace AZ
|
||||
{
|
||||
return aznew PlatformLimitsDescriptor;
|
||||
}
|
||||
|
||||
void PlatformLimitsDescriptor::LoadPlatformLimitsDescriptor(const char* rhiName)
|
||||
{
|
||||
auto settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
AZStd::string platformLimitsRegPath = AZStd::string::format("/Amazon/Atom/RHI/PlatformLimits/%s", rhiName);
|
||||
if (!(settingsRegistry &&
|
||||
settingsRegistry->GetObject(this, azrtti_typeid(this), platformLimitsRegPath.c_str())))
|
||||
{
|
||||
AZ_Warning(
|
||||
"Device", false, "Platform limits for %s %s is not loaded correctly. Will use default values.",
|
||||
AZ_TRAIT_OS_PLATFORM_NAME, rhiName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace AZ
|
||||
|
||||
m_physicalDevice = &physicalDevice;
|
||||
|
||||
const ResultCode resultCode = InitInternal(physicalDevice);
|
||||
RHI::ResultCode resultCode = InitInternal(physicalDevice);
|
||||
|
||||
if (resultCode == ResultCode::Success)
|
||||
{
|
||||
@@ -90,6 +90,9 @@ namespace AZ
|
||||
|
||||
// Assume all formats that haven't been mapped yet are supported and map to themselves
|
||||
FillRemainingSupportedFormats();
|
||||
|
||||
// Initialize limits and resources that are associated with them
|
||||
resultCode = InitializeLimits();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -98,29 +101,6 @@ namespace AZ
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
ResultCode Device::PostInit(const DeviceDescriptor& descriptor)
|
||||
{
|
||||
if (Validation::IsEnabled())
|
||||
{
|
||||
if (!IsInitialized())
|
||||
{
|
||||
AZ_Error("Device", false, "Device is not initialized.");
|
||||
return ResultCode::InvalidOperation;
|
||||
}
|
||||
}
|
||||
|
||||
m_descriptor = descriptor;
|
||||
const ResultCode resultCode = PostInitInternal(descriptor);
|
||||
|
||||
if (resultCode != ResultCode::Success)
|
||||
{
|
||||
AZ_Error("Device", false, "Device is not initialized.");
|
||||
return ResultCode::InvalidOperation;
|
||||
}
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
void Device::Shutdown()
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
Ptr<RHI::PlatformLimitsDescriptor> platformLimitsDescriptor = m_device->GetDescriptor().m_platformLimitsDescriptor;
|
||||
|
||||
RHI::FrameSchedulerDescriptor frameSchedulerDescriptor;
|
||||
if (descriptor.m_platformLimits)
|
||||
{
|
||||
m_platformLimitsDescriptor = descriptor.m_platformLimits->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;
|
||||
}
|
||||
|
||||
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,10 +180,9 @@ namespace AZ
|
||||
Interface<RHISystemInterface>::Unregister(this);
|
||||
m_frameScheduler.Shutdown();
|
||||
|
||||
m_platformLimitsDescriptor = nullptr;
|
||||
m_pipelineStateCache = nullptr;
|
||||
if (m_device)
|
||||
{
|
||||
{
|
||||
m_device->PreShutdown();
|
||||
AZ_Assert(m_device->use_count()==1, "The ref count for Device is %i but it should be 1 here to ensure all the resources are released", m_device->use_count());
|
||||
m_device = nullptr;
|
||||
@@ -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)
|
||||
|
||||
@@ -17,6 +17,11 @@ namespace UnitTest
|
||||
m_descriptor.m_description = "UnitTest Fake Device";
|
||||
}
|
||||
|
||||
Device::Device()
|
||||
{
|
||||
m_descriptor.m_platformLimitsDescriptor = aznew RHI::PlatformLimitsDescriptor;
|
||||
}
|
||||
|
||||
RHI::PhysicalDeviceList PhysicalDevice::Enumerate()
|
||||
{
|
||||
return RHI::PhysicalDeviceList{aznew PhysicalDevice};
|
||||
@@ -29,7 +34,6 @@ namespace UnitTest
|
||||
|
||||
RHI::Ptr<RHI::Device> device = RHI::Factory::Get().CreateDevice();
|
||||
device->Init(*physicalDevices[0]);
|
||||
device->PostInit(RHI::DeviceDescriptor{});
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -31,10 +31,11 @@ namespace UnitTest
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(Device, AZ::SystemAllocator, 0);
|
||||
|
||||
Device();
|
||||
|
||||
private:
|
||||
|
||||
AZ::RHI::ResultCode InitInternal(AZ::RHI::PhysicalDevice&) override { return AZ::RHI::ResultCode::Success; }
|
||||
AZ::RHI::ResultCode PostInitInternal(const AZ::RHI::DeviceDescriptor&) override { return AZ::RHI::ResultCode::Success; }
|
||||
|
||||
void ShutdownInternal() override {}
|
||||
|
||||
@@ -54,7 +55,9 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
void FillFormatsCapabilitiesInternal([[maybe_unused]] FormatCapabilitiesList& formatsCapabilities) override {}
|
||||
|
||||
|
||||
AZ::RHI::ResultCode InitializeLimits() override { return AZ::RHI::ResultCode::Success; }
|
||||
|
||||
void PreShutdown() override {}
|
||||
|
||||
AZ::RHI::ResourceMemoryRequirements GetResourceMemoryRequirements([[maybe_unused]] const AZ::RHI::ImageDescriptor& descriptor) { return AZ::RHI::ResourceMemoryRequirements{}; };
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace AZ
|
||||
DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
||||
DESCRIPTOR_HEAP_TYPE_SAMPLER,
|
||||
DESCRIPTOR_HEAP_TYPE_RTV,
|
||||
DESCRIPTOR_HEAP_TYPE_DSV);
|
||||
DESCRIPTOR_HEAP_TYPE_DSV);
|
||||
|
||||
struct FrameGraphExecuterData
|
||||
{
|
||||
AZ_TYPE_INFO(FrameGraphExecuterData, "{C21547F6-DE48-4F82-B812-1A187101AB4E}");
|
||||
AZ_TYPE_INFO(AZ::DX12::FrameGraphExecuterData, "{C21547F6-DE48-4F82-B812-1A187101AB4E}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
//Cost per draw/dispatch item
|
||||
@@ -52,15 +52,15 @@ namespace AZ
|
||||
{
|
||||
using Base = RHI::PlatformLimitsDescriptor;
|
||||
public:
|
||||
AZ_RTTI(DX12::PlatformLimitsDescriptor, "{ADCC8071-FCE4-4FA1-A048-DF8982951A0D}", Base);
|
||||
AZ_CLASS_ALLOCATOR(PlatformLimitsDescriptor, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(AZ::DX12::PlatformLimitsDescriptor, "{ADCC8071-FCE4-4FA1-A048-DF8982951A0D}", Base);
|
||||
AZ_CLASS_ALLOCATOR(AZ::DX12::PlatformLimitsDescriptor, AZ::SystemAllocator, 0);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
PlatformLimitsDescriptor() = default;
|
||||
|
||||
static const uint32_t NumHeapFlags = 2;// D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE + 1;
|
||||
|
||||
//! string key: stringifed version of DESCRIPTOR_HEAP_TYPE.
|
||||
//! string key: string version of DESCRIPTOR_HEAP_TYPE.
|
||||
//! int array: Max count for descriptors
|
||||
AZStd::unordered_map<AZStd::string, AZStd::array<uint32_t, NumHeapFlags>> m_descriptorHeapLimits;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace AZ
|
||||
{
|
||||
serializeContext->Class<PlatformLimitsDescriptor, Base>()
|
||||
->Version(0)
|
||||
->Field("m_descriptorHeapLimits", &PlatformLimitsDescriptor::m_descriptorHeapLimits)
|
||||
->Field("m_frameGraphExecuterData", &PlatformLimitsDescriptor::m_frameGraphExecuterData)
|
||||
->Field("DescriptorHeapLimits", &PlatformLimitsDescriptor::m_descriptorHeapLimits)
|
||||
->Field("FrameGraphExecuterData", &PlatformLimitsDescriptor::m_frameGraphExecuterData)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,11 @@ namespace AZ
|
||||
{
|
||||
serializeContext->Class<FrameGraphExecuterData>()
|
||||
->Version(0)
|
||||
->Field("m_itemCost", &FrameGraphExecuterData::m_itemCost)
|
||||
->Field("m_attachmentCost", &FrameGraphExecuterData::m_attachmentCost)
|
||||
->Field("m_swapChainsPerCommandList", &FrameGraphExecuterData::m_swapChainsPerCommandList)
|
||||
->Field("m_commandListCostThresholdMin", &FrameGraphExecuterData::m_commandListCostThresholdMin)
|
||||
->Field("m_commandListsPerScopeMax", &FrameGraphExecuterData::m_commandListsPerScopeMax)
|
||||
->Field("ItemCost", &FrameGraphExecuterData::m_itemCost)
|
||||
->Field("AttachmentCost", &FrameGraphExecuterData::m_attachmentCost)
|
||||
->Field("SwapChainsPerCommandList", &FrameGraphExecuterData::m_swapChainsPerCommandList)
|
||||
->Field("CommandListCostThresholdMin", &FrameGraphExecuterData::m_commandListCostThresholdMin)
|
||||
->Field("CommandListsPerScopeMax", &FrameGraphExecuterData::m_commandListsPerScopeMax)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include <Atom/RHI/Factory.h>
|
||||
#include <Atom/RHI/RHISystemInterface.h>
|
||||
#include <RHI/Device.h>
|
||||
#include <RHI/PhysicalDevice.h>
|
||||
@@ -29,6 +30,13 @@ namespace AZ
|
||||
void DeviceCompileMemoryStatisticsInternal(RHI::MemoryStatisticsBuilder& builder, IDXGIAdapterX* dxgiAdapter);
|
||||
}
|
||||
|
||||
Device::Device()
|
||||
{
|
||||
RHI::Ptr<PlatformLimitsDescriptor> platformLimitsDescriptor = aznew PlatformLimitsDescriptor();
|
||||
platformLimitsDescriptor->LoadPlatformLimitsDescriptor(RHI::Factory::Get().GetName().GetCStr());
|
||||
m_descriptor.m_platformLimitsDescriptor = RHI::Ptr<RHI::PlatformLimitsDescriptor>(platformLimitsDescriptor);
|
||||
}
|
||||
|
||||
RHI::Ptr<Device> Device::Create()
|
||||
{
|
||||
return aznew Device();
|
||||
@@ -43,35 +51,31 @@ namespace AZ
|
||||
}
|
||||
|
||||
InitFeatures();
|
||||
|
||||
return RHI::ResultCode::Success;
|
||||
}
|
||||
|
||||
RHI::ResultCode Device::PostInitInternal(const RHI::DeviceDescriptor& descriptor)
|
||||
RHI::ResultCode Device::InitializeLimits()
|
||||
{
|
||||
m_allocationInfoCache.SetInitFunction([](auto& cache) { cache.set_capacity(64); });
|
||||
|
||||
{
|
||||
ReleaseQueue::Descriptor releaseQueueDescriptor;
|
||||
releaseQueueDescriptor.m_collectLatency = descriptor.m_frameCountMax - 1;
|
||||
releaseQueueDescriptor.m_collectLatency = m_descriptor.m_frameCountMax - 1;
|
||||
m_releaseQueue.Init(releaseQueueDescriptor);
|
||||
}
|
||||
|
||||
m_descriptorContext = AZStd::make_shared<DescriptorContext>();
|
||||
|
||||
RHI::ConstPtr<RHI::PlatformLimitsDescriptor> rhiDescriptor = descriptor.m_platformLimitsDescriptor;
|
||||
if (RHI::ConstPtr<PlatformLimitsDescriptor> platLimitsDesc = azrtti_cast<const PlatformLimitsDescriptor*>(rhiDescriptor))
|
||||
{
|
||||
m_descriptorContext->Init(m_dx12Device.get(), platLimitsDesc);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Missing PlatformLimits config file for DX12 backend");
|
||||
}
|
||||
RHI::ConstPtr<RHI::PlatformLimitsDescriptor> rhiDescriptor = m_descriptor.m_platformLimitsDescriptor;
|
||||
RHI::ConstPtr<PlatformLimitsDescriptor> platLimitsDesc = azrtti_cast<const PlatformLimitsDescriptor*>(rhiDescriptor);
|
||||
AZ_Assert(platLimitsDesc != nullptr, "Missing PlatformLimits config file for DX12 backend");
|
||||
m_descriptorContext->Init(m_dx12Device.get(), platLimitsDesc);
|
||||
|
||||
{
|
||||
CommandListAllocator::Descriptor commandListAllocatorDescriptor;
|
||||
commandListAllocatorDescriptor.m_device = this;
|
||||
commandListAllocatorDescriptor.m_frameCountMax = descriptor.m_frameCountMax;
|
||||
commandListAllocatorDescriptor.m_frameCountMax = m_descriptor.m_frameCountMax;
|
||||
commandListAllocatorDescriptor.m_descriptorContext = m_descriptorContext;
|
||||
m_commandListAllocator.Init(commandListAllocatorDescriptor);
|
||||
}
|
||||
@@ -80,9 +84,9 @@ namespace AZ
|
||||
StagingMemoryAllocator::Descriptor allocatorDesc;
|
||||
allocatorDesc.m_device = this;
|
||||
|
||||
allocatorDesc.m_mediumPageSizeInBytes = RHI::RHISystemInterface::Get()->GetPlatformLimitsDescriptor()->m_platformDefaultValues.m_mediumStagingBufferPageSizeInBytes;
|
||||
allocatorDesc.m_largePageSizeInBytes = RHI::RHISystemInterface::Get()->GetPlatformLimitsDescriptor()->m_platformDefaultValues.m_largestStagingBufferPageSizeInBytes;
|
||||
allocatorDesc.m_collectLatency = descriptor.m_frameCountMax;
|
||||
allocatorDesc.m_mediumPageSizeInBytes = platLimitsDesc->m_platformDefaultValues.m_mediumStagingBufferPageSizeInBytes;
|
||||
allocatorDesc.m_largePageSizeInBytes = platLimitsDesc->m_platformDefaultValues.m_largestStagingBufferPageSizeInBytes;
|
||||
allocatorDesc.m_collectLatency = m_descriptor.m_frameCountMax;
|
||||
m_stagingMemoryAllocator.Init(allocatorDesc);
|
||||
}
|
||||
|
||||
@@ -90,7 +94,7 @@ namespace AZ
|
||||
|
||||
m_commandQueueContext.Init(*this);
|
||||
|
||||
m_asyncUploadQueue.Init(*this, AsyncUploadQueue::Descriptor(RHI::RHISystemInterface::Get()->GetPlatformLimitsDescriptor()->m_platformDefaultValues.m_asyncQueueStagingBufferSizeInBytes));
|
||||
m_asyncUploadQueue.Init(*this, AsyncUploadQueue::Descriptor(platLimitsDesc->m_platformDefaultValues.m_asyncQueueStagingBufferSizeInBytes));
|
||||
|
||||
m_samplerCache.SetCapacity(SamplerCacheCapacity);
|
||||
|
||||
|
||||
@@ -143,12 +143,11 @@ namespace AZ
|
||||
|
||||
bool IsAftermathInitialized() const;
|
||||
private:
|
||||
Device() = default;
|
||||
Device();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// RHI::Device
|
||||
RHI::ResultCode InitInternal(RHI::PhysicalDevice& physicalDevice) override;
|
||||
RHI::ResultCode PostInitInternal(const RHI::DeviceDescriptor & params) override;
|
||||
|
||||
void ShutdownInternal() override;
|
||||
void CompileMemoryStatisticsInternal(RHI::MemoryStatisticsBuilder& builder) override;
|
||||
@@ -158,6 +157,7 @@ namespace AZ
|
||||
void WaitForIdleInternal() override;
|
||||
AZStd::chrono::microseconds GpuTimestampToMicroseconds(uint64_t gpuTimestamp, RHI::HardwareQueueClass queueClass) const override;
|
||||
void FillFormatsCapabilitiesInternal(FormatCapabilitiesList& formatsCapabilities) override;
|
||||
RHI::ResultCode InitializeLimits() override;
|
||||
AZStd::vector<RHI::Format> GetValidSwapChainImageFormats(const RHI::WindowHandle& windowHandle) const override;
|
||||
void PreShutdown() override;
|
||||
RHI::ResourceMemoryRequirements GetResourceMemoryRequirements(const RHI::ImageDescriptor & descriptor) override;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace AZ
|
||||
{
|
||||
struct FrameGraphExecuterData
|
||||
{
|
||||
AZ_TYPE_INFO(FrameGraphExecuterData, "{BD831EFB-CC74-46F8-BE48-118B2E8F07D0}");
|
||||
AZ_TYPE_INFO(AZ::Metal::FrameGraphExecuterData, "{BD831EFB-CC74-46F8-BE48-118B2E8F07D0}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
//Cost per draw/dispatch item
|
||||
@@ -43,8 +43,8 @@ namespace AZ
|
||||
{
|
||||
using Base = RHI::PlatformLimitsDescriptor;
|
||||
public:
|
||||
AZ_RTTI(Metal::PlatformLimitsDescriptor, "{B89F116F-9FEF-4BCA-9EC7-9FF8F772B7FD}", Base);
|
||||
AZ_CLASS_ALLOCATOR(PlatformLimitsDescriptor, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(AZ::Metal::PlatformLimitsDescriptor, "{B89F116F-9FEF-4BCA-9EC7-9FF8F772B7FD}", Base);
|
||||
AZ_CLASS_ALLOCATOR(AZ::Metal::PlatformLimitsDescriptor, AZ::SystemAllocator, 0);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
FrameGraphExecuterData m_frameGraphExecuterData;
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace AZ
|
||||
if (SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PlatformLimitsDescriptor, Base>()
|
||||
->Version(0)
|
||||
->Field("m_frameGraphExecuterData", &PlatformLimitsDescriptor::m_frameGraphExecuterData)
|
||||
->Version(1)
|
||||
->Field("FrameGraphExecuterData", &PlatformLimitsDescriptor::m_frameGraphExecuterData)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,12 @@ namespace AZ
|
||||
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<FrameGraphExecuterData>()
|
||||
->Version(0)
|
||||
->Field("m_itemCost", &FrameGraphExecuterData::m_itemCost)
|
||||
->Field("m_attachmentCost", &FrameGraphExecuterData::m_attachmentCost)
|
||||
->Field("m_swapChainsPerCommandList", &FrameGraphExecuterData::m_swapChainsPerCommandList)
|
||||
->Field("m_commandListCostThresholdMin", &FrameGraphExecuterData::m_commandListCostThresholdMin)
|
||||
->Field("m_commandListsPerScopeMax", &FrameGraphExecuterData::m_commandListsPerScopeMax)
|
||||
->Version(1)
|
||||
->Field("ItemCost", &FrameGraphExecuterData::m_itemCost)
|
||||
->Field("AttachmentCost", &FrameGraphExecuterData::m_attachmentCost)
|
||||
->Field("SwapChainsPerCommandList", &FrameGraphExecuterData::m_swapChainsPerCommandList)
|
||||
->Field("CommandListCostThresholdMin", &FrameGraphExecuterData::m_commandListCostThresholdMin)
|
||||
->Field("CommandListsPerScopeMax", &FrameGraphExecuterData::m_commandListsPerScopeMax)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include <Atom/RHI/Factory.h>
|
||||
#include <Atom/RHI/RHISystemInterface.h>
|
||||
#include <Atom/RHI.Reflect/Metal/PlatformLimitsDescriptor.h>
|
||||
#include <AzCore/Debug/EventTrace.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
@@ -27,6 +29,13 @@ namespace AZ
|
||||
{
|
||||
namespace Metal
|
||||
{
|
||||
Device::Device()
|
||||
{
|
||||
RHI::Ptr<PlatformLimitsDescriptor> platformLimitsDescriptor = aznew PlatformLimitsDescriptor();
|
||||
platformLimitsDescriptor->LoadPlatformLimitsDescriptor(RHI::Factory::Get().GetName().GetCStr());
|
||||
m_descriptor.m_platformLimitsDescriptor = RHI::Ptr<RHI::PlatformLimitsDescriptor>(platformLimitsDescriptor);
|
||||
}
|
||||
|
||||
RHI::Ptr<Device> Device::Create()
|
||||
{
|
||||
return aznew Device();
|
||||
@@ -42,24 +51,24 @@ namespace AZ
|
||||
return RHI::ResultCode::Success;
|
||||
}
|
||||
|
||||
RHI::ResultCode Device::PostInitInternal(const RHI::DeviceDescriptor& descriptor)
|
||||
RHI::ResultCode Device::InitializeLimits()
|
||||
{
|
||||
{
|
||||
ReleaseQueue::Descriptor releaseQueueDescriptor;
|
||||
releaseQueueDescriptor.m_collectLatency = descriptor.m_frameCountMax;
|
||||
releaseQueueDescriptor.m_collectLatency = m_descriptor.m_frameCountMax;
|
||||
m_releaseQueue.Init(releaseQueueDescriptor);
|
||||
}
|
||||
|
||||
{
|
||||
CommandListAllocator::Descriptor commandListAllocatorDescriptor;
|
||||
commandListAllocatorDescriptor.m_frameCountMax = descriptor.m_frameCountMax;
|
||||
commandListAllocatorDescriptor.m_frameCountMax = m_descriptor.m_frameCountMax;
|
||||
m_commandListAllocator.Init(commandListAllocatorDescriptor, this);
|
||||
}
|
||||
|
||||
m_pipelineLayoutCache.Init(*this);
|
||||
m_commandQueueContext.Init(*this);
|
||||
|
||||
m_asyncUploadQueue.Init(*this, AsyncUploadQueue::Descriptor(RHI::RHISystemInterface::Get()->GetPlatformLimitsDescriptor()->m_platformDefaultValues.m_asyncQueueStagingBufferSizeInBytes));
|
||||
m_asyncUploadQueue.Init(*this, AsyncUploadQueue::Descriptor(m_descriptor.m_platformLimitsDescriptor->m_platformDefaultValues.m_asyncQueueStagingBufferSizeInBytes));
|
||||
|
||||
BufferMemoryAllocator::Descriptor allocatorDescriptor;
|
||||
allocatorDescriptor.m_device = this;
|
||||
@@ -77,6 +86,7 @@ namespace AZ
|
||||
|
||||
m_samplerCache = [[NSCache alloc]init];
|
||||
[m_samplerCache setName:@"SamplerCache"];
|
||||
|
||||
return RHI::ResultCode::Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,12 +154,11 @@ namespace AZ
|
||||
void ObjectCollectionNotify(RHI::ObjectCollectorNotifyFunction notifyFunction) override;
|
||||
|
||||
private:
|
||||
Device() = default;
|
||||
Device();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// RHI::Device
|
||||
RHI::ResultCode InitInternal(RHI::PhysicalDevice& physicalDevice) override;
|
||||
RHI::ResultCode PostInitInternal(const RHI::DeviceDescriptor& params) override;
|
||||
void ShutdownInternal() override;
|
||||
void CompileMemoryStatisticsInternal(RHI::MemoryStatisticsBuilder& builder) override;
|
||||
void UpdateCpuTimingStatisticsInternal(RHI::CpuTimingStatistics& cpuTimingStatistics) const override;
|
||||
@@ -168,6 +167,7 @@ namespace AZ
|
||||
void WaitForIdleInternal() override;
|
||||
AZStd::chrono::microseconds GpuTimestampToMicroseconds(uint64_t gpuTimestamp, RHI::HardwareQueueClass queueClass) const override;
|
||||
void FillFormatsCapabilitiesInternal(FormatCapabilitiesList& formatsCapabilities) override;
|
||||
RHI::ResultCode InitializeLimits() override;
|
||||
void PreShutdown() override;
|
||||
AZStd::vector<RHI::Format> GetValidSwapChainImageFormats(const RHI::WindowHandle& windowHandle) const override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -16,6 +16,11 @@ namespace AZ
|
||||
return aznew Device();
|
||||
}
|
||||
|
||||
Device::Device()
|
||||
{
|
||||
m_descriptor.m_platformLimitsDescriptor = aznew RHI::PlatformLimitsDescriptor;
|
||||
}
|
||||
|
||||
void Device::FillFormatsCapabilitiesInternal(FormatCapabilitiesList& formatsCapabilities)
|
||||
{
|
||||
formatsCapabilities.fill(static_cast<RHI::FormatCapabilities>(~0));
|
||||
|
||||
@@ -25,12 +25,11 @@ namespace AZ
|
||||
static RHI::Ptr<Device> Create();
|
||||
|
||||
private:
|
||||
Device() = default;
|
||||
Device();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// RHI::Device
|
||||
RHI::ResultCode InitInternal([[maybe_unused]] RHI::PhysicalDevice& physicalDevice) override { return RHI::ResultCode::Success;}
|
||||
RHI::ResultCode PostInitInternal([[maybe_unused]] const RHI::DeviceDescriptor& params) override { return RHI::ResultCode::Success;}
|
||||
RHI::ResultCode InitInternal([[maybe_unused]] RHI::PhysicalDevice& physicalDevice) override { return RHI::ResultCode::Success; }
|
||||
void ShutdownInternal() override {}
|
||||
void CompileMemoryStatisticsInternal([[maybe_unused]] RHI::MemoryStatisticsBuilder& builder) override {}
|
||||
void UpdateCpuTimingStatisticsInternal([[maybe_unused]] RHI::CpuTimingStatistics& cpuTimingStatistics) const override {}
|
||||
@@ -39,6 +38,7 @@ namespace AZ
|
||||
void WaitForIdleInternal() override {}
|
||||
AZStd::chrono::microseconds GpuTimestampToMicroseconds([[maybe_unused]] uint64_t gpuTimestamp, [[maybe_unused]] RHI::HardwareQueueClass queueClass) const override { return AZStd::chrono::microseconds();}
|
||||
void FillFormatsCapabilitiesInternal([[maybe_unused]] FormatCapabilitiesList& formatsCapabilities) override;
|
||||
RHI::ResultCode InitializeLimits() override { return RHI::ResultCode::Success; }
|
||||
void PreShutdown() override {}
|
||||
RHI::ResourceMemoryRequirements GetResourceMemoryRequirements([[maybe_unused]] const RHI::ImageDescriptor& descriptor) override { return RHI::ResourceMemoryRequirements();}
|
||||
RHI::ResourceMemoryRequirements GetResourceMemoryRequirements([[maybe_unused]] const RHI::BufferDescriptor& descriptor) override { return RHI::ResourceMemoryRequirements();}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
// For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
{
|
||||
"Amazon":
|
||||
{
|
||||
"Atom":
|
||||
{
|
||||
"RHI":
|
||||
{
|
||||
"PlatformLimits":
|
||||
{
|
||||
"metal":
|
||||
{
|
||||
"$type": "AZ::Vulkan::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
// For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
{
|
||||
"Amazon":
|
||||
{
|
||||
"Atom":
|
||||
{
|
||||
"RHI":
|
||||
{
|
||||
"PlatformLimits":
|
||||
{
|
||||
"vulkan":
|
||||
{
|
||||
"$type": "AZ::Vulkan::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
// For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
{
|
||||
"Amazon":
|
||||
{
|
||||
"Atom":
|
||||
{
|
||||
"RHI":
|
||||
{
|
||||
"PlatformLimits":
|
||||
{
|
||||
"metal":
|
||||
{
|
||||
"$type": "AZ::Metal::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
// For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
{
|
||||
"Amazon":
|
||||
{
|
||||
"Atom":
|
||||
{
|
||||
"RHI":
|
||||
{
|
||||
"PlatformLimits":
|
||||
{
|
||||
"dx12":
|
||||
{
|
||||
"$type": "AZ::DX12::PlatformLimitsDescriptor",
|
||||
"DescriptorHeapLimits":
|
||||
{
|
||||
"DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV": [1000000, 1000000],
|
||||
"DESCRIPTOR_HEAP_TYPE_SAMPLER": [2048, 2048],
|
||||
"DESCRIPTOR_HEAP_TYPE_RTV": [2048, 0],
|
||||
"DESCRIPTOR_HEAP_TYPE_DSV": [2048, 0]
|
||||
}
|
||||
},
|
||||
"vulkan":
|
||||
{
|
||||
"$type": "AZ::Vulkan::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
// For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
{
|
||||
"Amazon":
|
||||
{
|
||||
"Atom":
|
||||
{
|
||||
"RHI":
|
||||
{
|
||||
"PlatformLimits":
|
||||
{
|
||||
"metal":
|
||||
{
|
||||
"$type": "AZ::Metal::PlatformLimitsDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -20,7 +20,7 @@ namespace AZ
|
||||
{
|
||||
struct FrameGraphExecuterData
|
||||
{
|
||||
AZ_TYPE_INFO(FrameGraphExecuterData, "{648B4414-7208-4BFD-8E8F-CF2CA923ABCF}");
|
||||
AZ_TYPE_INFO(AZ::Vulkan::FrameGraphExecuterData, "{648B4414-7208-4BFD-8E8F-CF2CA923ABCF}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
//Cost per draw/dispatch item
|
||||
@@ -45,8 +45,8 @@ namespace AZ
|
||||
{
|
||||
using Base = RHI::PlatformLimitsDescriptor;
|
||||
public:
|
||||
AZ_RTTI(Vulkan::PlatformLimitsDescriptor, "{23673F3F-1562-4D1B-B130-553B35B48C64}", Base);
|
||||
AZ_CLASS_ALLOCATOR(PlatformLimitsDescriptor, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(AZ::Vulkan::PlatformLimitsDescriptor, "{23673F3F-1562-4D1B-B130-553B35B48C64}", Base);
|
||||
AZ_CLASS_ALLOCATOR(AZ::Vulkan::PlatformLimitsDescriptor, AZ::SystemAllocator, 0);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
FrameGraphExecuterData m_frameGraphExecuterData;
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace AZ
|
||||
if (SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PlatformLimitsDescriptor, Base>()
|
||||
->Version(0)
|
||||
->Field("m_frameGraphExecuterData", &PlatformLimitsDescriptor::m_frameGraphExecuterData)
|
||||
->Version(1)
|
||||
->Field("FrameGraphExecuterData", &PlatformLimitsDescriptor::m_frameGraphExecuterData)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -30,11 +30,11 @@ namespace AZ
|
||||
{
|
||||
serializeContext->Class<FrameGraphExecuterData>()
|
||||
->Version(0)
|
||||
->Field("m_itemCost", &FrameGraphExecuterData::m_itemCost)
|
||||
->Field("m_attachmentCost", &FrameGraphExecuterData::m_attachmentCost)
|
||||
->Field("m_swapChainsPerCommandList", &FrameGraphExecuterData::m_swapChainsPerCommandList)
|
||||
->Field("m_commandListCostThresholdMin", &FrameGraphExecuterData::m_commandListCostThresholdMin)
|
||||
->Field("m_commandListsPerScopeMax", &FrameGraphExecuterData::m_commandListsPerScopeMax)
|
||||
->Field("ItemCost", &FrameGraphExecuterData::m_itemCost)
|
||||
->Field("AttachmentCost", &FrameGraphExecuterData::m_attachmentCost)
|
||||
->Field("SwapChainsPerCommandList", &FrameGraphExecuterData::m_swapChainsPerCommandList)
|
||||
->Field("CommandListCostThresholdMin", &FrameGraphExecuterData::m_commandListCostThresholdMin)
|
||||
->Field("CommandListsPerScopeMax", &FrameGraphExecuterData::m_commandListsPerScopeMax)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace AZ
|
||||
{
|
||||
auto& device = static_cast<Device&>(deviceBase);
|
||||
|
||||
VkDeviceSize bufferPageSizeInBytes = RHI::RHISystemInterface::Get()->GetPlatformLimitsDescriptor()->m_platformDefaultValues.m_bufferPoolPageSizeInBytes;
|
||||
VkDeviceSize bufferPageSizeInBytes = device.GetDescriptor().m_platformLimitsDescriptor->m_platformDefaultValues.m_bufferPoolPageSizeInBytes;
|
||||
VkMemoryPropertyFlags additionalMemoryPropertyFlags = 0;
|
||||
if (const auto* descriptor = azrtti_cast<const BufferPoolDescriptor*>(&descriptorBase))
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
#include <Atom/RHI.Loader/FunctionLoader.h>
|
||||
#include <Atom/RHI.Reflect/Vulkan/PlatformLimitsDescriptor.h>
|
||||
#include <Atom/RHI/Factory.h>
|
||||
#include <Atom/RHI/RHISystemInterface.h>
|
||||
#include <Atom/RHI/TransientAttachmentPool.h>
|
||||
#include <AzCore/std/containers/set.h>
|
||||
@@ -31,6 +33,13 @@ namespace AZ
|
||||
{
|
||||
namespace Vulkan
|
||||
{
|
||||
Device::Device()
|
||||
{
|
||||
RHI::Ptr<PlatformLimitsDescriptor> platformLimitsDescriptor = aznew PlatformLimitsDescriptor();
|
||||
platformLimitsDescriptor->LoadPlatformLimitsDescriptor(RHI::Factory::Get().GetName().GetCStr());
|
||||
m_descriptor.m_platformLimitsDescriptor = RHI::Ptr<RHI::PlatformLimitsDescriptor>(platformLimitsDescriptor);
|
||||
}
|
||||
|
||||
RHI::Ptr<Device> Device::Create()
|
||||
{
|
||||
return aznew Device();
|
||||
@@ -232,7 +241,7 @@ namespace AZ
|
||||
return RHI::ResultCode::Success;
|
||||
}
|
||||
|
||||
RHI::ResultCode Device::PostInitInternal( const RHI::DeviceDescriptor& descriptor)
|
||||
RHI::ResultCode Device::InitializeLimits()
|
||||
{
|
||||
CommandQueueContext::Descriptor commandQueueContextDescriptor;
|
||||
commandQueueContextDescriptor.m_frameCountMax = RHI::Limits::Device::FrameCountMax;
|
||||
@@ -241,7 +250,7 @@ namespace AZ
|
||||
|
||||
// Initialize member variables.
|
||||
ReleaseQueue::Descriptor releaseQueueDescriptor;
|
||||
releaseQueueDescriptor.m_collectLatency = descriptor.m_frameCountMax - 1;
|
||||
releaseQueueDescriptor.m_collectLatency = m_descriptor.m_frameCountMax - 1;
|
||||
m_releaseQueue.Init(releaseQueueDescriptor);
|
||||
|
||||
|
||||
@@ -272,7 +281,7 @@ namespace AZ
|
||||
poolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Host;
|
||||
poolDesc.m_hostMemoryAccess = RHI::HostMemoryAccess::Write;
|
||||
poolDesc.m_bindFlags = RHI::BufferBindFlags::CopyRead;
|
||||
poolDesc.m_budgetInBytes = RHI::RHISystemInterface::Get()->GetPlatformLimitsDescriptor()->m_platformDefaultValues.m_stagingBufferBudgetInBytes;
|
||||
poolDesc.m_budgetInBytes = m_descriptor.m_platformLimitsDescriptor->m_platformDefaultValues.m_stagingBufferBudgetInBytes;
|
||||
result = m_stagingBufferPool->Init(*this, poolDesc);
|
||||
RETURN_RESULT_IF_UNSUCCESSFUL(result);
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace AZ
|
||||
void DestroyBufferResource(VkBuffer vkBuffer) const;
|
||||
|
||||
private:
|
||||
Device() = default;
|
||||
Device();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// RHI::Object
|
||||
@@ -120,7 +120,6 @@ namespace AZ
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// RHI::Device
|
||||
RHI::ResultCode InitInternal(RHI::PhysicalDevice& physicalDevice) override;
|
||||
RHI::ResultCode PostInitInternal(const RHI::DeviceDescriptor& params) override;
|
||||
|
||||
void ShutdownInternal() override;
|
||||
void BeginFrameInternal() override;
|
||||
@@ -131,6 +130,7 @@ namespace AZ
|
||||
AZStd::vector<RHI::Format> GetValidSwapChainImageFormats(const RHI::WindowHandle& windowHandle) const override;
|
||||
AZStd::chrono::microseconds GpuTimestampToMicroseconds(uint64_t gpuTimestamp, RHI::HardwareQueueClass queueClass) const override;
|
||||
void FillFormatsCapabilitiesInternal(FormatCapabilitiesList& formatsCapabilities) override;
|
||||
RHI::ResultCode InitializeLimits() override;
|
||||
void PreShutdown() override;
|
||||
RHI::ResourceMemoryRequirements GetResourceMemoryRequirements(const RHI::ImageDescriptor& descriptor) override;
|
||||
RHI::ResourceMemoryRequirements GetResourceMemoryRequirements(const RHI::BufferDescriptor& descriptor) override;
|
||||
|
||||
@@ -349,19 +349,6 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
//[GFX TODO][ATOM-5867] - Move file loading code within RHI to reduce coupling with RPI
|
||||
AZStd::string platformLimitsFilePath = AZStd::string::format("config/platform/%s/%s/platformlimits.azasset", AZ_TRAIT_OS_PLATFORM_NAME, GetRenderApiName().GetCStr());
|
||||
AZStd::to_lower(platformLimitsFilePath.begin(), platformLimitsFilePath.end());
|
||||
|
||||
Data::Asset<AnyAsset> platformLimitsAsset;
|
||||
platformLimitsAsset = RPI::AssetUtils::LoadCriticalAsset<AnyAsset>(platformLimitsFilePath.c_str(), RPI::AssetUtils::TraceLevel::None);
|
||||
// Only read the m_platformLimits if the platformLimitsAsset is ready.
|
||||
// The platformLimitsAsset may not exist for null renderer which is allowed
|
||||
if (platformLimitsAsset.IsReady())
|
||||
{
|
||||
m_descriptor.m_rhiSystemDescriptor.m_platformLimits = RPI::GetDataFromAnyAsset<RHI::PlatformLimits>(platformLimitsAsset);
|
||||
}
|
||||
|
||||
m_commonShaderAssetForSrgs = AssetUtils::LoadCriticalAsset<ShaderAsset>( m_descriptor.m_commonSrgsShaderAssetPath.c_str());
|
||||
if (!m_commonShaderAssetForSrgs.IsReady())
|
||||
{
|
||||
|
||||
@@ -47,7 +47,6 @@ namespace UnitTest
|
||||
|
||||
RHI::Ptr<RHI::Device> device = Get().CreateDevice();
|
||||
device->Init(*physicalDevices[0]);
|
||||
device->PostInit(RHI::DeviceDescriptor{});
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ namespace UnitTest
|
||||
m_descriptor.m_description = "UnitTest Fake Device";
|
||||
}
|
||||
|
||||
Device::Device()
|
||||
{
|
||||
m_descriptor.m_platformLimitsDescriptor = aznew RHI::PlatformLimitsDescriptor;
|
||||
}
|
||||
|
||||
RHI::PhysicalDeviceList PhysicalDevice::Enumerate()
|
||||
{
|
||||
return RHI::PhysicalDeviceList{ aznew PhysicalDevice };
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace UnitTest
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(Device, AZ::SystemAllocator, 0);
|
||||
Device();
|
||||
|
||||
private:
|
||||
AZ::RHI::ResultCode InitInternal(AZ::RHI::PhysicalDevice&) override { return AZ::RHI::ResultCode::Success; }
|
||||
AZ::RHI::ResultCode PostInitInternal(const AZ::RHI::DeviceDescriptor&) override { return AZ::RHI::ResultCode::Success; }
|
||||
void ShutdownInternal() override {}
|
||||
void BeginFrameInternal() override {}
|
||||
void EndFrameInternal() override {}
|
||||
@@ -67,6 +67,7 @@ namespace UnitTest
|
||||
return AZStd::chrono::microseconds();
|
||||
}
|
||||
void FillFormatsCapabilitiesInternal([[maybe_unused]] FormatCapabilitiesList& formatsCapabilities) override {}
|
||||
AZ::RHI::ResultCode InitializeLimits() override { return AZ::RHI::ResultCode::Success; }
|
||||
void PreShutdown() override {}
|
||||
AZ::RHI::ResourceMemoryRequirements GetResourceMemoryRequirements([[maybe_unused]] const AZ::RHI::ImageDescriptor& descriptor) { return AZ::RHI::ResourceMemoryRequirements{}; };
|
||||
AZ::RHI::ResourceMemoryRequirements GetResourceMemoryRequirements([[maybe_unused]] const AZ::RHI::BufferDescriptor& descriptor) { return AZ::RHI::ResourceMemoryRequirements{}; };
|
||||
|
||||
Reference in New Issue
Block a user