VulkanUtility.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <array>
  3. #include <IUnityGraphicsVulkan.h>
  4. #include <IUnityRenderingExtensions.h>
  5. #include <vulkan/vulkan.h>
  6. namespace unity
  7. {
  8. namespace webrtc
  9. {
  10. class VulkanUtility
  11. {
  12. public:
  13. static bool FindMemoryTypeInto(
  14. const VkPhysicalDevice physicalDevice,
  15. uint32_t typeFilter,
  16. VkMemoryPropertyFlags properties,
  17. uint32_t* memoryTypeIndex);
  18. static VkDeviceSize CreateImage(
  19. const VkPhysicalDevice physicalDevice,
  20. const VkDevice device,
  21. const VkAllocationCallbacks* allocator,
  22. const uint32_t width,
  23. const uint32_t height,
  24. const VkImageTiling tiling,
  25. const VkImageUsageFlags usage,
  26. const VkMemoryPropertyFlags properties,
  27. const VkFormat format,
  28. VkImage* image,
  29. VkDeviceMemory* imageMemory,
  30. bool exportHandle);
  31. static VkResult CreateImage(
  32. const VkPhysicalDevice physicalDevice,
  33. const VkDevice device,
  34. const VkAllocationCallbacks* allocator,
  35. const uint32_t width,
  36. const uint32_t height,
  37. const VkImageTiling tiling,
  38. const VkImageUsageFlags usage,
  39. const VkMemoryPropertyFlags properties,
  40. const VkFormat format,
  41. UnityVulkanImage* image,
  42. bool exportHandle);
  43. static VkImageView CreateImageView(
  44. const VkDevice device, const VkAllocationCallbacks* allocator, const VkImage image, const VkFormat format);
  45. static bool GetPhysicalDeviceUUIDInto(
  46. VkInstance instance, VkPhysicalDevice phyDevice, std::array<uint8_t, VK_UUID_SIZE>* deviceUUID);
  47. static bool LoadDeviceFunctions(const VkDevice device);
  48. static bool LoadInstanceFunctions(const VkInstance instance);
  49. static void* GetExportHandle(const VkDevice device, const VkDeviceMemory memory);
  50. static VkResult DoImageLayoutTransition(
  51. const VkCommandBuffer commandBuffer,
  52. const VkImage image,
  53. const VkFormat format,
  54. const VkImageLayout oldLayout,
  55. const VkPipelineStageFlags oldStage,
  56. const VkImageLayout newLayout,
  57. const VkPipelineStageFlags newStage);
  58. static VkResult CopyImage(
  59. const VkCommandBuffer commandBuffer,
  60. const VkImage srcImage,
  61. const VkImage dstImage,
  62. const uint32_t width,
  63. const uint32_t height);
  64. };
  65. } // end namespace webrtc
  66. } // end namespace unity