BsVulkanCommandBufferManager.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. Must be able to hold at least BS_MAX_COMMAND_BUFFERS entries.
  35. * @param[out] count Number of semaphores provided in the @p semaphores array.
  36. */
  37. void getSyncSemaphores(UINT32 deviceIdx, UINT32 syncMask, VkSemaphore* semaphores, UINT32& count);
  38. /**
  39. * Checks if any of the active command buffers finished executing on the device and updates their states
  40. * accordingly.
  41. */
  42. void refreshStates(UINT32 deviceIdx);
  43. private:
  44. /** Contains command buffers specific to one device. */
  45. struct PerDeviceData
  46. {
  47. VulkanCmdBuffer* buffers[BS_MAX_COMMAND_BUFFERS];
  48. };
  49. const VulkanRenderAPI& mRapi;
  50. PerDeviceData* mDeviceData;
  51. UINT32 mNumDevices;
  52. };
  53. /** @} */
  54. }