BsVulkanDevice.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "BsRenderAPI.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup Vulkan
  9. * @{
  10. */
  11. #define BS_MAX_VULKAN_QUEUES_PER_TYPE 4
  12. /** Types of GPU queues. */
  13. enum VulkanQueueType
  14. {
  15. /**
  16. * Queue used for rendering. Allows the use of draw commands, but also all commands supported by compute
  17. * or upload buffers.
  18. */
  19. VQT_GRAPHICS,
  20. /** Discrete queue used for compute operations. Allows the use of dispatch and upload commands. */
  21. VQT_COMPUTE,
  22. /** Queue used for memory transfer operations only. No rendering or compute dispatch allowed. */
  23. VQT_UPLOAD,
  24. VQT_COUNT // Keep at end
  25. };
  26. /** Represents a single GPU device usable by Vulkan. */
  27. class VulkanDevice
  28. {
  29. public:
  30. VulkanDevice(VkPhysicalDevice device);
  31. ~VulkanDevice();
  32. /** Returns an object describing the physical properties of the device. */
  33. VkPhysicalDevice getPhysical() const { return mPhysicalDevice; }
  34. /** Returns an object describing the logical properties of the device. */
  35. VkDevice getLogical() const { return mLogicalDevice; }
  36. /** Returns a set of properties describing the physical device. */
  37. const VkPhysicalDeviceProperties& getDeviceProperties() const { return mDeviceProperties; }
  38. /** Returns a set of features that the application can use to check if a specific feature is supported. */
  39. const VkPhysicalDeviceFeatures& getDeviceFeatures() const { return mDeviceFeatures; }
  40. /** Returns a set of properties describing the memory of the physical device. */
  41. const VkPhysicalDeviceMemoryProperties& getMemoryProperties() const { return mMemoryProperties; }
  42. /** Returns the number of queue supported on the device, per type. */
  43. UINT32 getNumQueues(VulkanQueueType type) const { return (UINT32)mQueueInfos[(int)type].queues.size(); }
  44. /** Returns queue of the specified type at the specified index. Index must be in range [0, getNumQueues()) */
  45. VkQueue getQueue(VulkanQueueType type, UINT32 idx) const { return mQueueInfos[(int)type].queues[idx]; }
  46. private:
  47. VkPhysicalDevice mPhysicalDevice;
  48. VkDevice mLogicalDevice;
  49. VkPhysicalDeviceProperties mDeviceProperties;
  50. VkPhysicalDeviceFeatures mDeviceFeatures;
  51. VkPhysicalDeviceMemoryProperties mMemoryProperties;
  52. /** Contains data about a set of queues of a specific type. */
  53. struct QueueInfo
  54. {
  55. UINT32 familyIdx;
  56. Vector<VkQueue> queues;
  57. };
  58. QueueInfo mQueueInfos[VQT_COUNT];
  59. };
  60. /** @} */
  61. }