TextureViewImpl.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. {
  11. /// @addtogroup vulkan
  12. /// @{
  13. /// Texture view implementation.
  14. class TextureViewImpl final : public TextureView, public VulkanObject<TextureView, TextureViewImpl>
  15. {
  16. public:
  17. TextureViewImpl(GrManager* manager, CString name)
  18. : TextureView(manager, name)
  19. {
  20. }
  21. ~TextureViewImpl();
  22. ANKI_USE_RESULT Error init(const TextureViewInitInfo& inf);
  23. VkImageSubresourceRange getVkImageSubresourceRange() const
  24. {
  25. VkImageSubresourceRange out;
  26. static_cast<const TextureImpl&>(*m_tex).computeVkImageSubresourceRange(getSubresource(), out);
  27. return out;
  28. }
  29. VkImageView getHandle() const
  30. {
  31. ANKI_ASSERT(m_handle);
  32. return m_handle;
  33. }
  34. U64 getHash() const
  35. {
  36. ANKI_ASSERT(m_hash);
  37. return m_hash;
  38. }
  39. const TextureImpl& getTextureImpl() const
  40. {
  41. return static_cast<const TextureImpl&>(*m_tex);
  42. }
  43. U32 getOrCreateBindlessIndex(VkImageLayout layout);
  44. private:
  45. VkImageView m_handle = {}; ///< Cache the handle.
  46. Array<U32, 2> m_bindlessIndices = {MAX_U32, MAX_U32}; ///< Cache it.
  47. /// This is a hash that depends on the Texture and the VkImageView. It's used as a replacement of
  48. /// TextureView::m_uuid since it creates less unique IDs.
  49. U64 m_hash = 0;
  50. const MicroImageView* m_microImageView = nullptr;
  51. TexturePtr m_tex; ///< Hold a reference.
  52. };
  53. /// @}
  54. } // end namespace anki