GrVkCommandPool.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2018 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef GrVkCommandPool_DEFINED
  8. #define GrVkCommandPool_DEFINED
  9. #include "src/gpu/vk/GrVkGpuCommandBuffer.h"
  10. #include "src/gpu/vk/GrVkInterface.h"
  11. #include "src/gpu/vk/GrVkResource.h"
  12. #include "src/gpu/vk/GrVkResourceProvider.h"
  13. class GrVkPrimaryCommandBuffer;
  14. class GrVkSecondaryCommandBuffer;
  15. class GrVkGpu;
  16. class GrVkCommandPool : public GrVkResource {
  17. public:
  18. static GrVkCommandPool* Create(const GrVkGpu* gpu);
  19. VkCommandPool vkCommandPool() const {
  20. return fCommandPool;
  21. }
  22. void reset(GrVkGpu* gpu);
  23. void releaseResources(GrVkGpu* gpu);
  24. GrVkPrimaryCommandBuffer* getPrimaryCommandBuffer() { return fPrimaryCommandBuffer; }
  25. GrVkSecondaryCommandBuffer* findOrCreateSecondaryCommandBuffer(GrVkGpu* gpu);
  26. void recycleSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer);
  27. // marks that we are finished with this command pool; it is not legal to continue creating or
  28. // writing to command buffers in a closed pool
  29. void close();
  30. // returns true if close() has not been called
  31. bool isOpen() const { return fOpen; }
  32. #ifdef SK_DEBUG
  33. void dumpInfo() const override {
  34. SkDebugf("GrVkCommandPool: %p (%d refs)\n", fCommandPool, this->getRefCnt());
  35. }
  36. #endif
  37. private:
  38. GrVkCommandPool() = delete;
  39. GrVkCommandPool(const GrVkGpu* gpu, VkCommandPool commandPool);
  40. void abandonGPUData() const override;
  41. void freeGPUData(GrVkGpu* gpu) const override;
  42. bool fOpen = true;
  43. VkCommandPool fCommandPool;
  44. GrVkPrimaryCommandBuffer* fPrimaryCommandBuffer;
  45. // Array of available secondary command buffers that are not in flight
  46. SkSTArray<4, GrVkSecondaryCommandBuffer*, true> fAvailableSecondaryBuffers;
  47. };
  48. #endif