TriangleExampleComponent.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  11. #include <Atom/RHI/FrameScheduler.h>
  12. #include <Atom/RHI/DrawItem.h>
  13. #include <Atom/RHI/Device.h>
  14. #include <Atom/RHI/Factory.h>
  15. #include <Atom/RHI/PipelineState.h>
  16. #include <Atom/RHI/BufferPool.h>
  17. #include <AzCore/Math/Matrix4x4.h>
  18. #include <RHI/BasicRHIComponent.h>
  19. namespace AtomSampleViewer
  20. {
  21. class TriangleExampleComponent final
  22. : public BasicRHIComponent
  23. {
  24. public:
  25. AZ_COMPONENT(TriangleExampleComponent, "{4807DFB6-4530-4D37-AF26-E8A4C130F7DC}", AZ::Component);
  26. AZ_DISABLE_COPY(TriangleExampleComponent);
  27. static void Reflect(AZ::ReflectContext* context);
  28. TriangleExampleComponent();
  29. ~TriangleExampleComponent() override = default;
  30. protected:
  31. // AZ::Component
  32. void Activate() override;
  33. void Deactivate() override;
  34. // RHISystemNotificationBus::Handler
  35. void OnFramePrepare(AZ::RHI::FrameGraphBuilder& frameGraphBuilder) override;
  36. AZ::RHI::Ptr<AZ::RHI::BufferPool> m_inputAssemblyBufferPool;
  37. AZ::RHI::Ptr<AZ::RHI::Buffer> m_inputAssemblyBuffer;
  38. AZ::RHI::ConstPtr<AZ::RHI::PipelineState> m_pipelineState;
  39. AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> m_shaderResourceGroup;
  40. AZ::RHI::ShaderInputConstantIndex m_objectMatrixConstantIndex;
  41. struct BufferData
  42. {
  43. AZStd::array<VertexPosition, 3> m_positions;
  44. AZStd::array<VertexColor, 3> m_colors;
  45. AZStd::array<uint16_t, 3> m_indices;
  46. };
  47. AZStd::array<AZ::RHI::StreamBufferView, 2> m_streamBufferViews;
  48. AZ::RHI::DrawItem m_drawItem;
  49. };
  50. } // namespace AtomSampleViewer