TextureArrayExampleComponent.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <RHI/BasicRHIComponent.h>
  10. #include <AzCore/Component/TickBus.h>
  11. namespace AtomSampleViewer
  12. {
  13. // This sample has the simple purpose of testing the texture array feature. This sample stores multiple image views
  14. // within a single binding slot within a SRG. This allows the shader to index within this texture array to sample from a texture.
  15. class TextureArrayExampleComponent final
  16. : public BasicRHIComponent
  17. , public AZ::TickBus::Handler
  18. {
  19. using Base = BasicRHIComponent;
  20. public:
  21. AZ_COMPONENT(TextureArrayExampleComponent, "{11EAD34A-B4BD-4CBA-B20B-E5AB33F4F49D}", AZ::Component);
  22. AZ_DISABLE_COPY(TextureArrayExampleComponent);
  23. TextureArrayExampleComponent();
  24. ~TextureArrayExampleComponent() override = default;
  25. static void Reflect(AZ::ReflectContext* context);
  26. //AZ::Component
  27. void Activate();
  28. void Deactivate();
  29. private:
  30. // AZ::TickBus::Handler overrides...
  31. void OnTick(float deltaTime, AZ::ScriptTimePoint scriptTime);
  32. AZ::RHI::Ptr<AZ::RHI::BufferPool> m_inputAssemblyBufferPool;
  33. AZ::RHI::Ptr<AZ::RHI::Buffer> m_rectangleInputAssemblyBuffer;
  34. AZStd::array<AZ::RHI::StreamBufferView, 2> m_rectangleStreamBufferViews;
  35. AZ::RHI::InputStreamLayout m_rectangleInputStreamLayout;
  36. AZ::RHI::ConstPtr<AZ::RHI::PipelineState> m_pipelineState;
  37. AZ::RHI::GeometryView m_geometryView;
  38. // Srg related resources
  39. AZ::Data::Instance<AZ::RPI::Shader> m_shader;
  40. AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> m_textureArraySrg;
  41. AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> m_textureIndexSrg;
  42. AZ::RHI::ShaderInputImageIndex m_textureArray;
  43. AZ::RHI::ShaderInputConstantIndex m_textureIndex;
  44. };
  45. } // namespace AtomSampleViewer