TextureViewImpl.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Gr/Vulkan/TextureViewImpl.h>
  6. #include <AnKi/Gr/Vulkan/TextureImpl.h>
  7. #include <AnKi/Gr/Vulkan/GrManagerImpl.h>
  8. namespace anki {
  9. TextureViewImpl::~TextureViewImpl()
  10. {
  11. }
  12. Error TextureViewImpl::init(const TextureViewInitInfo& inf)
  13. {
  14. ANKI_ASSERT(inf.isValid());
  15. // Store some stuff
  16. m_subresource = inf;
  17. m_tex = inf.m_texture;
  18. const TextureImpl& tex = static_cast<const TextureImpl&>(*m_tex);
  19. ANKI_ASSERT(tex.isSubresourceValid(inf));
  20. // Ask the texture for a view
  21. m_microImageView = &tex.getOrCreateView(inf);
  22. m_handle = m_microImageView->getHandle();
  23. m_texType = m_microImageView->getDerivedTextureType();
  24. // Create the hash
  25. Array<U64, 2> toHash = {tex.getUuid(), ptrToNumber(m_handle)};
  26. m_hash = computeHash(&toHash[0], sizeof(toHash));
  27. return Error::NONE;
  28. }
  29. U32 TextureViewImpl::getOrCreateBindlessIndex()
  30. {
  31. if(m_bindlessIndex == MAX_U32)
  32. {
  33. m_bindlessIndex = m_microImageView->getOrCreateBindlessIndex(getGrManagerImpl());
  34. }
  35. return m_bindlessIndex;
  36. }
  37. } // end namespace anki