BsVulkanCommandBufferManager.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsVulkanPrerequisites.h"
  5. #include "BsCommandBufferManager.h"
  6. #include "BsVulkanCommandBuffer.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Vulkan
  10. * @{
  11. */
  12. /**
  13. * Handles creation of Vulkan command buffers. See CommandBuffer.
  14. *
  15. * @note Core thread only.
  16. */
  17. class VulkanCommandBufferManager : public CommandBufferManager
  18. {
  19. public:
  20. VulkanCommandBufferManager(const VulkanRenderAPI& rapi);
  21. ~VulkanCommandBufferManager();
  22. /** @copydoc CommandBufferManager::createInternal() */
  23. SPtr<CommandBuffer> createInternal(GpuQueueType type, UINT32 deviceIdx = 0, UINT32 queueIdx = 0,
  24. bool secondary = false) override;
  25. /** Notifies the manager that this buffer was just submitted to the queue for execution. */
  26. void setActiveBuffer(GpuQueueType type, UINT32 deviceIdx, UINT32 queueIdx, VulkanCmdBuffer* buffer);
  27. /**
  28. * Returns a set of command buffer semaphores depending on the provided sync mask.
  29. *
  30. * @param[in] deviceIdx Index of the device to get the semaphores for.
  31. * @param[in] syncMask Mask that has a bit enabled for each command buffer to retrieve the semaphore for.
  32. * If the command buffer is not currently executing, semaphore won't be returned.
  33. * @param[out] semaphores List containing all the required semaphores. Semaphores are tightly packed at the
  34. * beginning of the array.
  35. * @param[out] count Number of semaphores provided in the @p semaphores array.
  36. */
  37. void getSyncSemaphores(UINT32 deviceIdx, UINT32 syncMask, VkSemaphore(&semaphores)[BS_MAX_COMMAND_BUFFERS],
  38. UINT32& count);
  39. /**
  40. * Checks if any of the active command buffers finished executing on the device and updates their states
  41. * accordingly.
  42. */
  43. void refreshStates(UINT32 deviceIdx);
  44. private:
  45. /** Contains command buffers specific to one device. */
  46. struct PerDeviceData
  47. {
  48. VulkanCmdBuffer* buffers[BS_MAX_COMMAND_BUFFERS];
  49. };
  50. const VulkanRenderAPI& mRapi;
  51. PerDeviceData* mDeviceData;
  52. UINT32 mNumDevices;
  53. };
  54. /** @} */
  55. }