VulkanAMF.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // Notice Regarding Standards. AMD does not provide a license or sublicense to
  3. // any Intellectual Property Rights relating to any standards, including but not
  4. // limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
  5. // AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
  6. // (collectively, the "Media Technologies"). For clarity, you will pay any
  7. // royalties due for such third party technologies, which may include the Media
  8. // Technologies that are owed as a result of AMD providing the Software to you.
  9. //
  10. // MIT license
  11. //
  12. // Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining a copy
  15. // of this software and associated documentation files (the "Software"), to deal
  16. // in the Software without restriction, including without limitation the rights
  17. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18. // copies of the Software, and to permit persons to whom the Software is
  19. // furnished to do so, subject to the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be included in
  22. // all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  27. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  28. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  29. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  30. // THE SOFTWARE.
  31. //
  32. #ifndef __VulkanAMF_h__
  33. #define __VulkanAMF_h__
  34. #pragma once
  35. #include "Platform.h"
  36. #include "vulkan/vulkan.h"
  37. #if defined(__cplusplus)
  38. namespace amf
  39. {
  40. #endif
  41. typedef struct AMFVulkanDevice
  42. {
  43. amf_size cbSizeof; // sizeof(AMFVulkanDevice)
  44. void* pNext; // reserved for extensions
  45. VkInstance hInstance;
  46. VkPhysicalDevice hPhysicalDevice;
  47. VkDevice hDevice;
  48. } AMFVulkanDevice;
  49. typedef struct AMFVulkanSync
  50. {
  51. amf_size cbSizeof; // sizeof(AMFVulkanSync)
  52. void* pNext; // reserved for extensions
  53. VkSemaphore hSemaphore; // VkSemaphore; can be nullptr
  54. bool bSubmitted; // if true - wait for hSemaphore. re-submit hSemaphore if not synced by other ways and set to true
  55. VkFence hFence; // To sync on CPU; can be nullptr. Submitted in vkQueueSubmit. If waited for hFence, null it, do not delete or reset.
  56. } AMFVulkanSync;
  57. typedef struct AMFVulkanBuffer
  58. {
  59. amf_size cbSizeof; // sizeof(AMFVulkanBuffer)
  60. void* pNext; // reserved for extensions
  61. VkBuffer hBuffer;
  62. VkDeviceMemory hMemory;
  63. amf_int64 iSize;
  64. amf_int64 iAllocatedSize; // for reuse
  65. amf_uint32 eAccessFlags; // VkAccessFlagBits
  66. amf_uint32 eUsage; // AMF_BUFFER_USAGE
  67. amf_uint32 eAccess; // AMF_MEMORY_CPU_ACCESS
  68. AMFVulkanSync Sync;
  69. } AMFVulkanBuffer;
  70. typedef struct AMFVulkanSurface
  71. {
  72. amf_size cbSizeof; // sizeof(AMFVulkanSurface)
  73. void* pNext; // reserved for extensions
  74. // surface properties
  75. VkImage hImage; // vulkan native image for which the surface is created
  76. VkDeviceMemory hMemory; // memory for hImage, can be nullptr
  77. amf_int64 iSize; // memory size
  78. amf_uint32 eFormat; // VkFormat
  79. amf_int32 iWidth; // image width
  80. amf_int32 iHeight; // image height
  81. amf_uint32 eCurrentLayout; // VkImageLayout
  82. amf_uint32 eUsage; // AMF_SURFACE_USAGE
  83. amf_uint32 eAccess; // AMF_MEMORY_CPU_ACCESS
  84. AMFVulkanSync Sync; // To sync on GPU
  85. } AMFVulkanSurface;
  86. typedef struct AMFVulkanView
  87. {
  88. amf_size cbSizeof; // sizeof(AMFVulkanView)
  89. void* pNext; // reserved for extensions
  90. // surface properties
  91. AMFVulkanSurface *pSurface;
  92. VkImageView hView;
  93. amf_int32 iPlaneWidth;
  94. amf_int32 iPlaneHeight;
  95. amf_int32 iPlaneWidthPitch;
  96. amf_int32 iPlaneHeightPitch;
  97. } AMFVulkanView;
  98. #define AMF_CONTEXT_VULKAN_COMPUTE_QUEUE L"VulkanComputeQueue" // amf_int64; default=0; Compute queue index in range [0, (VkQueueFamilyProperties.queueCount-1)] of the compute queue family.
  99. #if defined(__cplusplus)
  100. } // namespace amf
  101. #endif
  102. #endif // __VulkanAMF_h__