TextureViewImpl.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Gr/TextureView.h>
  7. #include <AnKi/Gr/Vulkan/VulkanObject.h>
  8. #include <AnKi/Gr/Vulkan/TextureImpl.h>
  9. namespace anki {
  10. /// @addtogroup vulkan
  11. /// @{
  12. /// Texture view implementation.
  13. class TextureViewImpl final : public TextureView, public VulkanObject<TextureView, TextureViewImpl>
  14. {
  15. public:
  16. TextureViewImpl(GrManager* manager, CString name)
  17. : TextureView(manager, name)
  18. {
  19. }
  20. ~TextureViewImpl();
  21. ANKI_USE_RESULT Error init(const TextureViewInitInfo& inf);
  22. VkImageSubresourceRange getVkImageSubresourceRange() const
  23. {
  24. VkImageSubresourceRange out;
  25. static_cast<const TextureImpl&>(*m_tex).computeVkImageSubresourceRange(getSubresource(), out);
  26. return out;
  27. }
  28. VkImageView getHandle() const
  29. {
  30. ANKI_ASSERT(m_handle);
  31. return m_handle;
  32. }
  33. U64 getHash() const
  34. {
  35. ANKI_ASSERT(m_hash);
  36. return m_hash;
  37. }
  38. const TextureImpl& getTextureImpl() const
  39. {
  40. return static_cast<const TextureImpl&>(*m_tex);
  41. }
  42. U32 getOrCreateBindlessIndex(VkImageLayout layout);
  43. private:
  44. VkImageView m_handle = {}; ///< Cache the handle.
  45. Array<U32, 2> m_bindlessIndices = {MAX_U32, MAX_U32}; ///< Cache it.
  46. /// This is a hash that depends on the Texture and the VkImageView. It's used as a replacement of
  47. /// TextureView::m_uuid since it creates less unique IDs.
  48. U64 m_hash = 0;
  49. const MicroImageView* m_microImageView = nullptr;
  50. TexturePtr m_tex; ///< Hold a reference.
  51. };
  52. /// @}
  53. } // end namespace anki