3
0

PassAttachmentReflect.cpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 <math.h>
  9. #include <AzFramework/StringFunc/StringFunc.h>
  10. #include <Atom/RPI.Reflect/Pass/PassAttachmentReflect.h>
  11. #include <Atom/RPI.Reflect/Pass/PassName.h>
  12. namespace AZ
  13. {
  14. namespace RPI
  15. {
  16. RHI::ScopeAttachmentAccess GetAttachmentAccess(PassSlotType slotType)
  17. {
  18. return RHI::ScopeAttachmentAccess(uint32_t(slotType));
  19. }
  20. const char* ToString(AZ::RPI::PassSlotType slotType)
  21. {
  22. switch (slotType)
  23. {
  24. case AZ::RPI::PassSlotType::Input:
  25. return "Input";
  26. case AZ::RPI::PassSlotType::InputOutput:
  27. return "InputOutput";
  28. case AZ::RPI::PassSlotType::Output:
  29. return "Output";
  30. case AZ::RPI::PassSlotType::Uninitialized:
  31. default:
  32. return "Uninitialized";
  33. }
  34. }
  35. // --- PassSlot ---
  36. RHI::ScopeAttachmentAccess PassSlot::GetAttachmentAccess() const
  37. {
  38. return RPI::GetAttachmentAccess(m_slotType);
  39. }
  40. void PassSlot::Reflect(AZ::ReflectContext* context)
  41. {
  42. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  43. {
  44. serializeContext->Enum<PassSlotType>()
  45. ->Value("Input", PassSlotType::Input)
  46. ->Value("Output", PassSlotType::Output)
  47. ->Value("InputOutput", PassSlotType::InputOutput)
  48. ->Value("Uninitialized", PassSlotType::Uninitialized)
  49. ;
  50. serializeContext->Class<PassSlot>()
  51. ->Version(3)
  52. ->Field("Name", &PassSlot::m_name)
  53. ->Field("ShaderInputName", &PassSlot::m_shaderInputName)
  54. ->Field("ShaderImageDimensionsConstant", &PassSlot::m_shaderImageDimensionsName)
  55. ->Field("ShaderInputArrayIndex", &PassSlot::m_shaderInputArrayIndex)
  56. ->Field("SlotType", &PassSlot::m_slotType)
  57. ->Field("ScopeAttachmentUsage", &PassSlot::m_scopeAttachmentUsage)
  58. ->Field("ImageViewDesc", &PassSlot::m_imageViewDesc)
  59. ->Field("BufferViewDesc", &PassSlot::m_bufferViewDesc)
  60. ->Field("LoadStoreAction", &PassSlot::m_loadStoreAction)
  61. ->Field("FormatFallbacks", &PassSlot::m_formatFallbacks)
  62. ;
  63. }
  64. }
  65. // --- PassAttachmentRef ---
  66. void PassAttachmentRef::Reflect(AZ::ReflectContext* context)
  67. {
  68. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  69. {
  70. serializeContext->Class<PassAttachmentRef>()
  71. ->Version(0)
  72. ->Field("Pass", &PassAttachmentRef::m_pass)
  73. ->Field("Attachment", &PassAttachmentRef::m_attachment)
  74. ;
  75. }
  76. }
  77. // --- PassConnection ---
  78. void PassConnection::Reflect(AZ::ReflectContext* context)
  79. {
  80. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  81. {
  82. serializeContext->Class<PassConnection>()
  83. ->Version(0)
  84. ->Field("LocalSlot", &PassConnection::m_localSlot)
  85. ->Field("AttachmentRef", &PassConnection::m_attachmentRef)
  86. ;
  87. }
  88. }
  89. // --- PassFallbackConnection ---
  90. void PassFallbackConnection::Reflect(AZ::ReflectContext* context)
  91. {
  92. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  93. {
  94. serializeContext->Class<PassFallbackConnection>()
  95. ->Version(0)
  96. ->Field("Input", &PassFallbackConnection::m_inputSlotName)
  97. ->Field("Output", &PassFallbackConnection::m_outputSlotName)
  98. ;
  99. }
  100. }
  101. // --- PassAttachmentSizeMultipliers ---
  102. void PassAttachmentSizeMultipliers::Reflect(AZ::ReflectContext* context)
  103. {
  104. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  105. {
  106. serializeContext->Class<PassAttachmentSizeMultipliers>()
  107. ->Version(0)
  108. ->Field("WidthMultiplier", &PassAttachmentSizeMultipliers::m_widthMultiplier)
  109. ->Field("HeightMultiplier", &PassAttachmentSizeMultipliers::m_heightMultiplier)
  110. ->Field("DepthMultiplier", &PassAttachmentSizeMultipliers::m_depthMultiplier)
  111. ;
  112. }
  113. }
  114. RHI::Size PassAttachmentSizeMultipliers::ApplyModifiers(const RHI::Size& size) const
  115. {
  116. RHI::Size newSize;
  117. newSize.m_width = uint32_t(ceil(float(size.m_width) * m_widthMultiplier));
  118. newSize.m_height = uint32_t(ceil(float(size.m_height) * m_heightMultiplier));
  119. newSize.m_depth = uint32_t(ceil(float(size.m_depth) * m_depthMultiplier));
  120. return newSize;
  121. }
  122. // --- PassAttachmentSizeSource ---
  123. void PassAttachmentSizeSource::Reflect(AZ::ReflectContext* context)
  124. {
  125. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  126. {
  127. serializeContext->Class<PassAttachmentSizeSource>()
  128. ->Version(0)
  129. ->Field("Source", &PassAttachmentSizeSource::m_source)
  130. ->Field("Multipliers", &PassAttachmentSizeSource::m_multipliers)
  131. ;
  132. }
  133. }
  134. // --- PassAttachmentDesc ---
  135. void PassAttachmentDesc::Reflect(AZ::ReflectContext* context)
  136. {
  137. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  138. {
  139. serializeContext->Class<PassAttachmentDesc>()
  140. ->Version(3) // Removing PassAttachmentArraySizeSource class
  141. ->Field("Name", &PassAttachmentDesc::m_name)
  142. ->Field("Lifetime", &PassAttachmentDesc::m_lifetime)
  143. ->Field("SizeSource", &PassAttachmentDesc::m_sizeSource)
  144. ->Field("ArraySizeSource", &PassAttachmentDesc::m_arraySizeSource)
  145. ->Field("FormatSource", &PassAttachmentDesc::m_formatSource)
  146. ->Field("MultisampleSource", &PassAttachmentDesc::m_multisampleSource)
  147. ->Field("AssetRef", &PassAttachmentDesc::m_assetRef)
  148. ;
  149. }
  150. }
  151. // --- PassImageAttachmentDesc ---
  152. void PassImageAttachmentDesc::Reflect(AZ::ReflectContext* context)
  153. {
  154. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  155. {
  156. serializeContext->Class<PassImageAttachmentDesc, PassAttachmentDesc>()
  157. ->Version(0)
  158. ->Field("ImageDescriptor", &PassImageAttachmentDesc::m_imageDescriptor)
  159. ->Field("GenerateFullMipChain", &PassImageAttachmentDesc::m_generateFullMipChain)
  160. ->Field("FormatFallbacks", &PassImageAttachmentDesc::m_formatFallbacks)
  161. ;
  162. }
  163. }
  164. // --- PassBufferAttachmentDesc ---
  165. void PassBufferAttachmentDesc::Reflect(AZ::ReflectContext* context)
  166. {
  167. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  168. {
  169. serializeContext->Class<PassBufferAttachmentDesc, PassAttachmentDesc>()
  170. ->Version(0)
  171. ->Field("BufferDescriptor", &PassBufferAttachmentDesc::m_bufferDescriptor)
  172. ;
  173. }
  174. }
  175. } // namespace RPI
  176. } // namespace AZ