UnifiedScopeAttachmentDescriptor.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 <AzCore/Serialization/SerializeContext.h>
  9. #include <Atom/RHI.Reflect/UnifiedScopeAttachmentDescriptor.h>
  10. namespace AZ::RHI
  11. {
  12. UnifiedScopeAttachmentDescriptor::UnifiedScopeAttachmentDescriptor(
  13. const AttachmentId& attachmentId,
  14. const BufferViewDescriptor& bufferViewDescriptor,
  15. const AttachmentLoadStoreAction& loadStoreAction)
  16. : ScopeAttachmentDescriptor(attachmentId, loadStoreAction)
  17. {
  18. SetAsBuffer(bufferViewDescriptor);
  19. }
  20. UnifiedScopeAttachmentDescriptor::UnifiedScopeAttachmentDescriptor(
  21. const AttachmentId& attachmentId,
  22. const ImageViewDescriptor& imageViewDescriptor,
  23. const AttachmentLoadStoreAction& loadStoreAction)
  24. : ScopeAttachmentDescriptor(attachmentId, loadStoreAction)
  25. {
  26. SetAsImage(imageViewDescriptor);
  27. }
  28. UnifiedScopeAttachmentDescriptor::UnifiedScopeAttachmentDescriptor(
  29. const AttachmentId& attachmentId,
  30. const AttachmentId& resolveAttachmentId,
  31. const ImageViewDescriptor& imageViewDescriptor,
  32. const AttachmentLoadStoreAction& loadStoreAction)
  33. : ScopeAttachmentDescriptor(attachmentId, loadStoreAction)
  34. {
  35. SetAsResolve(imageViewDescriptor, resolveAttachmentId);
  36. }
  37. // Setters...
  38. void UnifiedScopeAttachmentDescriptor::SetAsBuffer(const BufferViewDescriptor& desc)
  39. {
  40. m_bufferViewDescriptor = desc;
  41. m_type = AttachmentType::Buffer;
  42. }
  43. void UnifiedScopeAttachmentDescriptor::SetAsImage(const ImageViewDescriptor& desc)
  44. {
  45. m_imageViewDescriptor = desc;
  46. m_type = AttachmentType::Image;
  47. }
  48. void UnifiedScopeAttachmentDescriptor::SetAsResolve(const ImageViewDescriptor& desc, AttachmentId resolveAttachmentId)
  49. {
  50. m_imageViewDescriptor = desc;
  51. m_resolveAttachmentId = resolveAttachmentId;
  52. m_type = AttachmentType::Resolve;
  53. }
  54. // Getters...
  55. BufferScopeAttachmentDescriptor UnifiedScopeAttachmentDescriptor::GetAsBuffer() const
  56. {
  57. AZ_Assert(m_type == AttachmentType::Buffer, "UnifiedScopeAttachmentDescriptor type mismatch during casting");
  58. return BufferScopeAttachmentDescriptor(m_attachmentId, m_bufferViewDescriptor, m_loadStoreAction);
  59. }
  60. ImageScopeAttachmentDescriptor UnifiedScopeAttachmentDescriptor::GetAsImage() const
  61. {
  62. AZ_Assert(m_type == AttachmentType::Image, "UnifiedScopeAttachmentDescriptor type mismatch during casting");
  63. return ImageScopeAttachmentDescriptor(m_attachmentId, m_imageViewDescriptor, m_loadStoreAction);
  64. }
  65. ResolveScopeAttachmentDescriptor UnifiedScopeAttachmentDescriptor::GetAsResolve() const
  66. {
  67. AZ_Assert(m_type == AttachmentType::Resolve, "UnifiedScopeAttachmentDescriptor type mismatch during casting");
  68. return ResolveScopeAttachmentDescriptor(m_attachmentId, m_resolveAttachmentId, m_imageViewDescriptor, m_loadStoreAction);
  69. }
  70. BufferViewDescriptor& UnifiedScopeAttachmentDescriptor::GetBufferViewDescriptor()
  71. {
  72. return m_bufferViewDescriptor;
  73. }
  74. ImageViewDescriptor& UnifiedScopeAttachmentDescriptor::GetImageViewDescriptor()
  75. {
  76. return m_imageViewDescriptor;
  77. }
  78. AttachmentType UnifiedScopeAttachmentDescriptor::GetType() const
  79. {
  80. return m_type;
  81. }
  82. }