PipelineLayout.h 1.1 KB

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