VkGraphicsState.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2009-present, 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/VkCommon.h>
  7. #include <AnKi/Gr/ShaderProgram.h>
  8. #include <AnKi/Gr/BackendCommon/GraphicsStateTracker.h>
  9. #include <AnKi/Util/HashMap.h>
  10. namespace anki {
  11. /// @addtogroup vulkan
  12. /// @{
  13. class GraphicsPipelineFactory
  14. {
  15. public:
  16. ~GraphicsPipelineFactory();
  17. /// Write state to the command buffer.
  18. /// @note It's thread-safe.
  19. void flushState(GraphicsStateTracker& state, VkCommandBuffer& cmdb);
  20. private:
  21. GrHashMap<U64, VkPipeline> m_map;
  22. RWMutex m_mtx;
  23. };
  24. /// On disk pipeline cache.
  25. class PipelineCache : public MakeSingleton<PipelineCache>
  26. {
  27. public:
  28. VkPipelineCache m_cacheHandle = VK_NULL_HANDLE;
  29. #if ANKI_PLATFORM_MOBILE
  30. /// Workaround a bug in Qualcomm
  31. Mutex* m_globalCreatePipelineMtx = nullptr;
  32. #endif
  33. ~PipelineCache()
  34. {
  35. destroy();
  36. }
  37. Error init(CString cacheDir);
  38. private:
  39. GrString m_dumpFilename;
  40. PtrSize m_dumpSize = 0;
  41. void destroy();
  42. Error destroyInternal();
  43. };
  44. /// @}
  45. } // end namespace anki