TextureView.cpp 922 B

1234567891011121314151617181920212223242526272829303132
  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/TextureView.h>
  6. #include <AnKi/Gr/Vulkan/TextureViewImpl.h>
  7. #include <AnKi/Gr/GrManager.h>
  8. namespace anki {
  9. TextureView* TextureView::newInstance(GrManager* manager, const TextureViewInitInfo& init)
  10. {
  11. TextureViewImpl* impl = manager->getAllocator().newInstance<TextureViewImpl>(manager, init.getName());
  12. const Error err = impl->init(init);
  13. if(err)
  14. {
  15. manager->getAllocator().deleteInstance(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::ALL_SAMPLED, 0)
  24. == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
  25. return self.getOrCreateBindlessIndex();
  26. }
  27. } // end namespace anki