TextureView.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2009-2020, 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. {
  10. TextureView* TextureView::newInstance(GrManager* manager, const TextureViewInitInfo& init)
  11. {
  12. TextureViewImpl* impl = manager->getAllocator().newInstance<TextureViewImpl>(manager, init.getName());
  13. const Error err = impl->init(init);
  14. if(err)
  15. {
  16. manager->getAllocator().deleteInstance(impl);
  17. impl = nullptr;
  18. }
  19. return impl;
  20. }
  21. U32 TextureView::getOrCreateBindlessTextureIndex()
  22. {
  23. ANKI_VK_SELF(TextureViewImpl);
  24. ANKI_ASSERT(self.getTextureImpl().computeLayout(TextureUsageBit::ALL_SAMPLED, 0)
  25. == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
  26. return self.getOrCreateBindlessIndex(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, DescriptorType::TEXTURE);
  27. }
  28. U32 TextureView::getOrCreateBindlessImageIndex()
  29. {
  30. ANKI_VK_SELF(TextureViewImpl);
  31. ANKI_ASSERT(self.getTextureImpl().computeLayout(TextureUsageBit::ALL_IMAGE, 0) == VK_IMAGE_LAYOUT_GENERAL);
  32. return self.getOrCreateBindlessIndex(VK_IMAGE_LAYOUT_GENERAL, DescriptorType::IMAGE);
  33. }
  34. } // end namespace anki