PlatformLimitsDescriptor.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/RHI.Reflect/PlatformLimitsDescriptor.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/Settings/SettingsRegistryImpl.h>
  11. namespace AZ::RHI
  12. {
  13. void PlatformLimits::Reflect(ReflectContext* context)
  14. {
  15. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  16. {
  17. serializeContext->Class<PlatformLimits>()
  18. ->Version(1)
  19. ->Field("PlatformLimitsDescriptor", &PlatformLimits::m_platformLimitsDescriptor)
  20. ;
  21. }
  22. }
  23. void TransientAttachmentPoolBudgets::Reflect(AZ::ReflectContext* context)
  24. {
  25. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  26. {
  27. serializeContext->Class<TransientAttachmentPoolBudgets>()
  28. ->Version(1)
  29. ->Field("BufferBudgetInBytes", &TransientAttachmentPoolBudgets::m_bufferBudgetInBytes)
  30. ->Field("ImageBudgetInBytes", &TransientAttachmentPoolBudgets::m_imageBudgetInBytes)
  31. ->Field("RenderTargetBudgetInBytes", &TransientAttachmentPoolBudgets::m_renderTargetBudgetInBytes)
  32. ;
  33. }
  34. }
  35. void PlatformDefaultValues::Reflect(AZ::ReflectContext* context)
  36. {
  37. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  38. {
  39. serializeContext->Class<PlatformDefaultValues>()
  40. ->Version(1)
  41. ->Field("StagingBufferBudgetInBytes", &PlatformDefaultValues::m_stagingBufferBudgetInBytes)
  42. ->Field("AsyncQueueStagingBufferSizeInBytes", &PlatformDefaultValues::m_asyncQueueStagingBufferSizeInBytes)
  43. ->Field("MediumStagingBufferPageSizeInBytes", &PlatformDefaultValues::m_mediumStagingBufferPageSizeInBytes)
  44. ->Field("LargestStagingBufferPageSizeInBytes", &PlatformDefaultValues::m_largestStagingBufferPageSizeInBytes)
  45. ->Field("ImagePoolPageSizeInBytes", &PlatformDefaultValues::m_imagePoolPageSizeInBytes)
  46. ->Field("BufferPoolPageSizeInBytes", &PlatformDefaultValues::m_bufferPoolPageSizeInBytes)
  47. ;
  48. }
  49. }
  50. void PlatformLimitsDescriptor::Reflect(AZ::ReflectContext* context)
  51. {
  52. PlatformDefaultValues::Reflect(context);
  53. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  54. {
  55. serializeContext->Class<PlatformLimitsDescriptor>()
  56. ->Version(2)
  57. ->Field("TransientAttachmentPoolBudgets", &PlatformLimitsDescriptor::m_transientAttachmentPoolBudgets)
  58. ->Field("PlatformDefaultValues", &PlatformLimitsDescriptor::m_platformDefaultValues)
  59. ->Field("PagingParameters", &PlatformLimitsDescriptor::m_pagingParameters)
  60. ->Field("UsageHintParameters", &PlatformLimitsDescriptor::m_usageHintParameters)
  61. ->Field("HeapAllocationStrategy", &PlatformLimitsDescriptor::m_heapAllocationStrategy)
  62. ;
  63. }
  64. }
  65. RHI::Ptr<PlatformLimitsDescriptor> PlatformLimitsDescriptor::Create()
  66. {
  67. return aznew PlatformLimitsDescriptor;
  68. }
  69. void PlatformLimitsDescriptor::LoadPlatformLimitsDescriptor(const char* rhiName)
  70. {
  71. auto settingsRegistry = AZ::SettingsRegistry::Get();
  72. AZStd::string platformLimitsRegPath = AZStd::string::format("/O3DE/Atom/RHI/PlatformLimits/%s", rhiName);
  73. if (!(settingsRegistry &&
  74. settingsRegistry->GetObject(this, azrtti_typeid(this), platformLimitsRegPath.c_str())))
  75. {
  76. AZ_Warning(
  77. "Device", false, "Platform limits for %s %s is not loaded correctly. Will use default values.",
  78. AZ_TRAIT_OS_PLATFORM_NAME, rhiName);
  79. }
  80. }
  81. }