TextureView.cpp 907 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2009-2023, 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/TextureView.h>
  6. #include <AnKi/Gr/Vulkan/TextureViewImpl.h>
  7. #include <AnKi/Gr/GrManager.h>
  8. namespace anki {
  9. TextureView* TextureView::newInstance(const TextureViewInitInfo& init)
  10. {
  11. TextureViewImpl* impl = anki::newInstance<TextureViewImpl>(GrMemoryPool::getSingleton(), init.getName());
  12. const Error err = impl->init(init);
  13. if(err)
  14. {
  15. deleteInstance(GrMemoryPool::getSingleton(), impl);
  16. impl = nullptr;
  17. }
  18. return impl;
  19. }
  20. U32 TextureView::getOrCreateBindlessTextureIndex()
  21. {
  22. ANKI_VK_SELF(TextureViewImpl);
  23. ANKI_ASSERT(self.getTextureImpl().computeLayout(TextureUsageBit::kAllSampled, 0) == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
  24. return self.getOrCreateBindlessIndex();
  25. }
  26. } // end namespace anki