3
0

PassAttachmentReflect.cpp 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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("ScopeAttachmentStage", &PassSlot::m_scopeAttachmentStage)
  59. ->Field("ImageViewDesc", &PassSlot::m_imageViewDesc)
  60. ->Field("BufferViewDesc", &PassSlot::m_bufferViewDesc)
  61. ->Field("LoadStoreAction", &PassSlot::m_loadStoreAction)
  62. ->Field("FormatFallbacks", &PassSlot::m_formatFallbacks)
  63. ;
  64. }
  65. }
  66. // --- PassAttachmentRef ---
  67. void PassAttachmentRef::Reflect(AZ::ReflectContext* context)
  68. {
  69. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  70. {
  71. serializeContext->Class<PassAttachmentRef>()
  72. ->Version(0)
  73. ->Field("Pass", &PassAttachmentRef::m_pass)
  74. ->Field("Attachment", &PassAttachmentRef::m_attachment)
  75. ;
  76. }
  77. }
  78. // --- PassConnection ---
  79. void PassConnection::Reflect(AZ::ReflectContext* context)
  80. {
  81. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  82. {
  83. serializeContext->Class<PassConnection>()
  84. ->Version(0)
  85. ->Field("LocalSlot", &PassConnection::m_localSlot)
  86. ->Field("AttachmentRef", &PassConnection::m_attachmentRef)
  87. ;
  88. }
  89. }
  90. // --- PassFallbackConnection ---
  91. void PassFallbackConnection::Reflect(AZ::ReflectContext* context)
  92. {
  93. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  94. {
  95. serializeContext->Class<PassFallbackConnection>()
  96. ->Version(0)
  97. ->Field("Input", &PassFallbackConnection::m_inputSlotName)
  98. ->Field("Output", &PassFallbackConnection::m_outputSlotName)
  99. ;
  100. }
  101. }
  102. // --- PassAttachmentSizeMultipliers ---
  103. void PassAttachmentSizeMultipliers::Reflect(AZ::ReflectContext* context)
  104. {
  105. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  106. {
  107. serializeContext->Class<PassAttachmentSizeMultipliers>()
  108. ->Version(0)
  109. ->Field("WidthMultiplier", &PassAttachmentSizeMultipliers::m_widthMultiplier)
  110. ->Field("HeightMultiplier", &PassAttachmentSizeMultipliers::m_heightMultiplier)
  111. ->Field("DepthMultiplier", &PassAttachmentSizeMultipliers::m_depthMultiplier)
  112. ;
  113. }
  114. }
  115. RHI::Size PassAttachmentSizeMultipliers::ApplyModifiers(const RHI::Size& size) const
  116. {
  117. RHI::Size newSize;
  118. newSize.m_width = uint32_t(ceil(float(size.m_width) * m_widthMultiplier));
  119. newSize.m_height = uint32_t(ceil(float(size.m_height) * m_heightMultiplier));
  120. newSize.m_depth = uint32_t(ceil(float(size.m_depth) * m_depthMultiplier));
  121. return newSize;
  122. }
  123. // --- PassAttachmentSizeSource ---
  124. void PassAttachmentSizeSource::Reflect(AZ::ReflectContext* context)
  125. {
  126. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  127. {
  128. serializeContext->Class<PassAttachmentSizeSource>()
  129. ->Version(0)
  130. ->Field("Source", &PassAttachmentSizeSource::m_source)
  131. ->Field("Multipliers", &PassAttachmentSizeSource::m_multipliers)
  132. ;
  133. }
  134. }
  135. // --- PassAttachmentDesc ---
  136. void PassAttachmentDesc::Reflect(AZ::ReflectContext* context)
  137. {
  138. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  139. {
  140. serializeContext->Class<PassAttachmentDesc>()
  141. ->Version(3) // Removing PassAttachmentArraySizeSource class
  142. ->Field("Name", &PassAttachmentDesc::m_name)
  143. ->Field("Lifetime", &PassAttachmentDesc::m_lifetime)
  144. ->Field("SizeSource", &PassAttachmentDesc::m_sizeSource)
  145. ->Field("ArraySizeSource", &PassAttachmentDesc::m_arraySizeSource)
  146. ->Field("FormatSource", &PassAttachmentDesc::m_formatSource)
  147. ->Field("MultisampleSource", &PassAttachmentDesc::m_multisampleSource)
  148. ->Field("AssetRef", &PassAttachmentDesc::m_assetRef)
  149. ;
  150. }
  151. }
  152. // --- PassImageAttachmentDesc ---
  153. void PassImageAttachmentDesc::Reflect(AZ::ReflectContext* context)
  154. {
  155. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  156. {
  157. serializeContext->Class<PassImageAttachmentDesc, PassAttachmentDesc>()
  158. ->Version(0)
  159. ->Field("ImageDescriptor", &PassImageAttachmentDesc::m_imageDescriptor)
  160. ->Field("GenerateFullMipChain", &PassImageAttachmentDesc::m_generateFullMipChain)
  161. ->Field("FormatFallbacks", &PassImageAttachmentDesc::m_formatFallbacks)
  162. ;
  163. }
  164. }
  165. // --- PassBufferAttachmentDesc ---
  166. void PassBufferAttachmentDesc::Reflect(AZ::ReflectContext* context)
  167. {
  168. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  169. {
  170. serializeContext->Class<PassBufferAttachmentDesc, PassAttachmentDesc>()
  171. ->Version(0)
  172. ->Field("BufferDescriptor", &PassBufferAttachmentDesc::m_bufferDescriptor)
  173. ;
  174. }
  175. }
  176. } // namespace RPI
  177. } // namespace AZ