PipelineLayout.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/Vulkan/DescriptorSet.h>
  7. #include <AnKi/Util/HashMap.h>
  8. namespace anki
  9. {
  10. /// @addtogroup vulkan
  11. /// @{
  12. class PipelineLayout
  13. {
  14. friend class PipelineLayoutFactory;
  15. public:
  16. VkPipelineLayout getHandle() const
  17. {
  18. ANKI_ASSERT(m_handle);
  19. return m_handle;
  20. }
  21. private:
  22. VkPipelineLayout m_handle = VK_NULL_HANDLE;
  23. };
  24. /// Creator of pipeline layouts.
  25. class PipelineLayoutFactory
  26. {
  27. public:
  28. PipelineLayoutFactory() = default;
  29. ~PipelineLayoutFactory() = default;
  30. void init(GrAllocator<U8> alloc, VkDevice dev)
  31. {
  32. m_alloc = alloc;
  33. m_dev = dev;
  34. }
  35. void destroy();
  36. /// @note It's thread-safe.
  37. ANKI_USE_RESULT Error newPipelineLayout(const WeakArray<DescriptorSetLayout>& dsetLayouts, U32 pushConstantsSize,
  38. PipelineLayout& layout);
  39. private:
  40. GrAllocator<U8> m_alloc;
  41. VkDevice m_dev = VK_NULL_HANDLE;
  42. HashMap<U64, VkPipelineLayout> m_layouts;
  43. Mutex m_layoutsMtx;
  44. };
  45. /// @}
  46. } // end namespace anki