TriangleExampleComponent.h 1.8 KB

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