Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 1 | // Copyright (C) 2018 The Android Open Source Project |
| 2 | // Copyright (C) 2018 Google Inc. |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 15 | #pragma once |
| 16 | |
| 17 | #include <vulkan/vulkan.h> |
| 18 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 19 | #include <atomic> |
Lingfeng Yang | 256f925 | 2020-07-14 14:27:33 -0700 | [diff] [blame] | 20 | #include <functional> |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 21 | #include <memory> |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 22 | #include <optional> |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 23 | #include <set> |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 24 | #include <unordered_map> |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 25 | |
Shalini S | db704c9 | 2023-01-27 21:35:33 +0000 | [diff] [blame] | 26 | #include "CommandBufferStagingStream.h" |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 27 | #include "HostVisibleMemoryVirtualization.h" |
| 28 | #include "VirtGpu.h" |
Shalini S | db704c9 | 2023-01-27 21:35:33 +0000 | [diff] [blame] | 29 | #include "VulkanHandleMapping.h" |
| 30 | #include "VulkanHandles.h" |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 31 | #include "aemu/base/Optional.h" |
Shalini S | db704c9 | 2023-01-27 21:35:33 +0000 | [diff] [blame] | 32 | #include "aemu/base/Tracing.h" |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 33 | #include "aemu/base/synchronization/AndroidLock.h" |
| 34 | #include "aemu/base/threads/AndroidWorkPool.h" |
Lingfeng Yang | 2b1b8cf | 2019-02-08 09:53:36 -0800 | [diff] [blame] | 35 | #include "goldfish_vk_transform_guest.h" |
| 36 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 37 | using gfxstream::guest::AutoLock; |
| 38 | using gfxstream::guest::Lock; |
| 39 | using gfxstream::guest::Optional; |
| 40 | using gfxstream::guest::RecursiveLock; |
| 41 | using gfxstream::guest::WorkPool; |
| 42 | |
| 43 | /// Use installed headers or locally defined Fuchsia-specific bits |
| 44 | #ifdef VK_USE_PLATFORM_FUCHSIA |
| 45 | |
| 46 | #include <cutils/native_handle.h> |
| 47 | #include <fidl/fuchsia.hardware.goldfish/cpp/wire.h> |
| 48 | #include <fidl/fuchsia.sysmem/cpp/wire.h> |
| 49 | #include <lib/zx/channel.h> |
| 50 | #include <lib/zx/vmo.h> |
| 51 | #include <zircon/errors.h> |
| 52 | #include <zircon/process.h> |
| 53 | #include <zircon/rights.h> |
| 54 | #include <zircon/syscalls.h> |
| 55 | #include <zircon/syscalls/object.h> |
| 56 | |
| 57 | #include <optional> |
| 58 | |
| 59 | #include "services/service_connector.h" |
| 60 | |
| 61 | #ifndef FUCHSIA_NO_TRACE |
| 62 | #include <lib/trace/event.h> |
| 63 | #endif |
| 64 | |
| 65 | #define GET_STATUS_SAFE(result, member) ((result).ok() ? ((result)->member) : ZX_OK) |
| 66 | |
C Stout | 5a3a422 | 2023-11-14 16:31:56 -0800 | [diff] [blame] | 67 | struct SetBufferCollectionImageConstraintsResult { |
| 68 | VkResult result; |
| 69 | fuchsia_sysmem::wire::BufferCollectionConstraints constraints; |
| 70 | std::vector<uint32_t> createInfoIndex; |
| 71 | }; |
| 72 | |
| 73 | struct SetBufferCollectionBufferConstraintsResult { |
| 74 | VkResult result; |
| 75 | fuchsia_sysmem::wire::BufferCollectionConstraints constraints; |
| 76 | }; |
| 77 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 78 | #else |
| 79 | |
| 80 | typedef uint32_t zx_handle_t; |
| 81 | typedef uint64_t zx_koid_t; |
| 82 | #define ZX_HANDLE_INVALID ((zx_handle_t)0) |
| 83 | #define ZX_KOID_INVALID ((zx_koid_t)0) |
| 84 | #endif // VK_USE_PLATFORM_FUCHSIA |
| 85 | |
| 86 | /// Use installed headers or locally defined Android-specific bits |
| 87 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 88 | #include "AndroidHardwareBuffer.h" |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 89 | #endif |
| 90 | |
C Stout | 8a64ca8 | 2024-01-31 17:24:24 -0800 | [diff] [blame] | 91 | #if defined(__linux__) || defined(__Fuchsia__) |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 92 | #include <android/hardware_buffer.h> |
Gurchetan Singh | b7feebd | 2024-01-23 14:12:36 -0800 | [diff] [blame] | 93 | #endif |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 94 | |
Gurchetan Singh | b7feebd | 2024-01-23 14:12:36 -0800 | [diff] [blame] | 95 | #if GFXSTREAM_ENABLE_GUEST_GOLDFISH |
| 96 | /// Goldfish sync only used for AEMU -- should replace in virtio-gpu when possibe |
| 97 | #include "../egl/goldfish_sync.h" |
| 98 | #endif |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 99 | |
Lingfeng Yang | 3175463 | 2018-12-21 18:24:55 -0800 | [diff] [blame] | 100 | struct EmulatorFeatureInfo; |
| 101 | |
Lingfeng Yang | 34b5cae | 2019-08-21 14:12:19 -0700 | [diff] [blame] | 102 | class HostConnection; |
| 103 | |
Jason Macnak | 3d66400 | 2023-03-30 16:00:50 -0700 | [diff] [blame] | 104 | namespace gfxstream { |
| 105 | namespace vk { |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 106 | |
Lingfeng Yang | 39a276e | 2019-06-17 13:27:22 -0700 | [diff] [blame] | 107 | class VkEncoder; |
| 108 | |
Lingfeng Yang | 97a0670 | 2018-12-24 17:02:43 -0800 | [diff] [blame] | 109 | class ResourceTracker { |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 110 | public: |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 111 | ResourceTracker(); |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 112 | ~ResourceTracker(); |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 113 | static ResourceTracker* get(); |
Lingfeng Yang | 4032911 | 2021-01-22 18:01:43 -0800 | [diff] [blame] | 114 | |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 115 | VulkanHandleMapping* createMapping(); |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 116 | VulkanHandleMapping* destroyMapping(); |
Lingfeng Yang | 6ab1b0d | 2018-11-27 23:36:03 -0800 | [diff] [blame] | 117 | |
Lingfeng Yang | 34b5cae | 2019-08-21 14:12:19 -0700 | [diff] [blame] | 118 | using HostConnectionGetFunc = HostConnection* (*)(); |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 119 | using VkEncoderGetFunc = VkEncoder* (*)(HostConnection*); |
Lingfeng Yang | 256f925 | 2020-07-14 14:27:33 -0700 | [diff] [blame] | 120 | using CleanupCallback = std::function<void()>; |
Lingfeng Yang | 34b5cae | 2019-08-21 14:12:19 -0700 | [diff] [blame] | 121 | |
| 122 | struct ThreadingCallbacks { |
Gurchetan Singh | 8672591 | 2023-09-06 14:22:46 -0700 | [diff] [blame] | 123 | HostConnectionGetFunc hostConnectionGetFunc = nullptr; |
| 124 | VkEncoderGetFunc vkEncoderGetFunc = nullptr; |
Lingfeng Yang | 34b5cae | 2019-08-21 14:12:19 -0700 | [diff] [blame] | 125 | }; |
| 126 | |
Lingfeng Yang | 4032911 | 2021-01-22 18:01:43 -0800 | [diff] [blame] | 127 | static uint32_t streamFeatureBits; |
| 128 | static ThreadingCallbacks threadingCallbacks; |
| 129 | |
Lingfeng Yang | 6ab1b0d | 2018-11-27 23:36:03 -0800 | [diff] [blame] | 130 | #define HANDLE_REGISTER_DECL(type) \ |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 131 | void register_##type(type); \ |
| 132 | void unregister_##type(type); |
Lingfeng Yang | 6ab1b0d | 2018-11-27 23:36:03 -0800 | [diff] [blame] | 133 | |
| 134 | GOLDFISH_VK_LIST_HANDLE_TYPES(HANDLE_REGISTER_DECL) |
| 135 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 136 | VkResult on_vkEnumerateInstanceExtensionProperties(void* context, VkResult input_result, |
| 137 | const char* pLayerName, |
| 138 | uint32_t* pPropertyCount, |
| 139 | VkExtensionProperties* pProperties); |
Lingfeng Yang | 154a33c | 2019-01-29 19:06:23 -0800 | [diff] [blame] | 140 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 141 | VkResult on_vkEnumerateDeviceExtensionProperties(void* context, VkResult input_result, |
| 142 | VkPhysicalDevice physicalDevice, |
| 143 | const char* pLayerName, |
| 144 | uint32_t* pPropertyCount, |
| 145 | VkExtensionProperties* pProperties); |
Lingfeng Yang | 154a33c | 2019-01-29 19:06:23 -0800 | [diff] [blame] | 146 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 147 | VkResult on_vkEnumeratePhysicalDevices(void* context, VkResult input_result, |
| 148 | VkInstance instance, uint32_t* pPhysicalDeviceCount, |
| 149 | VkPhysicalDevice* pPhysicalDevices); |
Lingfeng Yang | b64ca45 | 2019-02-14 22:04:28 -0800 | [diff] [blame] | 150 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 151 | void on_vkGetPhysicalDeviceFeatures2(void* context, VkPhysicalDevice physicalDevice, |
| 152 | VkPhysicalDeviceFeatures2* pFeatures); |
| 153 | void on_vkGetPhysicalDeviceFeatures2KHR(void* context, VkPhysicalDevice physicalDevice, |
| 154 | VkPhysicalDeviceFeatures2* pFeatures); |
| 155 | void on_vkGetPhysicalDeviceProperties(void* context, VkPhysicalDevice physicalDevice, |
| 156 | VkPhysicalDeviceProperties* pProperties); |
| 157 | void on_vkGetPhysicalDeviceProperties2(void* context, VkPhysicalDevice physicalDevice, |
| 158 | VkPhysicalDeviceProperties2* pProperties); |
| 159 | void on_vkGetPhysicalDeviceProperties2KHR(void* context, VkPhysicalDevice physicalDevice, |
| 160 | VkPhysicalDeviceProperties2* pProperties); |
Yilong Li | f336908 | 2020-06-25 03:39:24 -0700 | [diff] [blame] | 161 | |
Lingfeng Yang | 97a0670 | 2018-12-24 17:02:43 -0800 | [diff] [blame] | 162 | void on_vkGetPhysicalDeviceMemoryProperties( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 163 | void* context, VkPhysicalDevice physicalDevice, |
Lingfeng Yang | 97a0670 | 2018-12-24 17:02:43 -0800 | [diff] [blame] | 164 | VkPhysicalDeviceMemoryProperties* pMemoryProperties); |
Lingfeng Yang | 154a33c | 2019-01-29 19:06:23 -0800 | [diff] [blame] | 165 | void on_vkGetPhysicalDeviceMemoryProperties2( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 166 | void* context, VkPhysicalDevice physicalDevice, |
Lingfeng Yang | 154a33c | 2019-01-29 19:06:23 -0800 | [diff] [blame] | 167 | VkPhysicalDeviceMemoryProperties2* pMemoryProperties); |
| 168 | void on_vkGetPhysicalDeviceMemoryProperties2KHR( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 169 | void* context, VkPhysicalDevice physicalDevice, |
Lingfeng Yang | 154a33c | 2019-01-29 19:06:23 -0800 | [diff] [blame] | 170 | VkPhysicalDeviceMemoryProperties2* pMemoryProperties); |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 171 | void on_vkGetDeviceQueue(void* context, VkDevice device, uint32_t queueFamilyIndex, |
| 172 | uint32_t queueIndex, VkQueue* pQueue); |
| 173 | void on_vkGetDeviceQueue2(void* context, VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, |
Yilong Li | 366c366 | 2021-04-25 03:38:14 -0700 | [diff] [blame] | 174 | VkQueue* pQueue); |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame] | 175 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 176 | VkResult on_vkCreateInstance(void* context, VkResult input_result, |
| 177 | const VkInstanceCreateInfo* createInfo, |
| 178 | const VkAllocationCallbacks* pAllocator, VkInstance* pInstance); |
| 179 | VkResult on_vkCreateDevice(void* context, VkResult input_result, |
| 180 | VkPhysicalDevice physicalDevice, |
| 181 | const VkDeviceCreateInfo* pCreateInfo, |
| 182 | const VkAllocationCallbacks* pAllocator, VkDevice* pDevice); |
| 183 | void on_vkDestroyDevice_pre(void* context, VkDevice device, |
| 184 | const VkAllocationCallbacks* pAllocator); |
Lingfeng Yang | 131d5a4 | 2018-11-30 12:00:33 -0800 | [diff] [blame] | 185 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 186 | VkResult on_vkAllocateMemory(void* context, VkResult input_result, VkDevice device, |
| 187 | const VkMemoryAllocateInfo* pAllocateInfo, |
| 188 | const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory); |
| 189 | void on_vkFreeMemory(void* context, VkDevice device, VkDeviceMemory memory, |
| 190 | const VkAllocationCallbacks* pAllocator); |
Lingfeng Yang | 131d5a4 | 2018-11-30 12:00:33 -0800 | [diff] [blame] | 191 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 192 | VkResult on_vkMapMemory(void* context, VkResult input_result, VkDevice device, |
| 193 | VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, |
| 194 | VkMemoryMapFlags, void** ppData); |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame] | 195 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 196 | void on_vkUnmapMemory(void* context, VkDevice device, VkDeviceMemory memory); |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame] | 197 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 198 | VkResult on_vkCreateImage(void* context, VkResult input_result, VkDevice device, |
| 199 | const VkImageCreateInfo* pCreateInfo, |
| 200 | const VkAllocationCallbacks* pAllocator, VkImage* pImage); |
| 201 | void on_vkDestroyImage(void* context, VkDevice device, VkImage image, |
| 202 | const VkAllocationCallbacks* pAllocator); |
Lingfeng Yang | 4af5f32 | 2019-02-14 08:10:28 -0800 | [diff] [blame] | 203 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 204 | void on_vkGetImageMemoryRequirements(void* context, VkDevice device, VkImage image, |
| 205 | VkMemoryRequirements* pMemoryRequirements); |
| 206 | void on_vkGetImageMemoryRequirements2(void* context, VkDevice device, |
| 207 | const VkImageMemoryRequirementsInfo2* pInfo, |
| 208 | VkMemoryRequirements2* pMemoryRequirements); |
| 209 | void on_vkGetImageMemoryRequirements2KHR(void* context, VkDevice device, |
| 210 | const VkImageMemoryRequirementsInfo2* pInfo, |
| 211 | VkMemoryRequirements2* pMemoryRequirements); |
Aaron Ruby | a8140f4 | 2024-05-10 15:50:44 -0400 | [diff] [blame] | 212 | void on_vkGetImageSubresourceLayout(void* context, VkDevice device, VkImage image, |
| 213 | const VkImageSubresource* pSubresource, |
| 214 | VkSubresourceLayout* pLayout); |
Lingfeng Yang | 4af5f32 | 2019-02-14 08:10:28 -0800 | [diff] [blame] | 215 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 216 | VkResult on_vkBindImageMemory(void* context, VkResult input_result, VkDevice device, |
| 217 | VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset); |
| 218 | VkResult on_vkBindImageMemory2(void* context, VkResult input_result, VkDevice device, |
| 219 | uint32_t bindingCount, const VkBindImageMemoryInfo* pBindInfos); |
| 220 | VkResult on_vkBindImageMemory2KHR(void* context, VkResult input_result, VkDevice device, |
| 221 | uint32_t bindingCount, |
| 222 | const VkBindImageMemoryInfo* pBindInfos); |
Lingfeng Yang | 4af5f32 | 2019-02-14 08:10:28 -0800 | [diff] [blame] | 223 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 224 | VkResult on_vkCreateBuffer(void* context, VkResult input_result, VkDevice device, |
| 225 | const VkBufferCreateInfo* pCreateInfo, |
| 226 | const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer); |
| 227 | void on_vkDestroyBuffer(void* context, VkDevice device, VkBuffer buffer, |
| 228 | const VkAllocationCallbacks* pAllocator); |
Lingfeng Yang | 4af5f32 | 2019-02-14 08:10:28 -0800 | [diff] [blame] | 229 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 230 | void on_vkGetBufferMemoryRequirements(void* context, VkDevice device, VkBuffer buffer, |
| 231 | VkMemoryRequirements* pMemoryRequirements); |
| 232 | void on_vkGetBufferMemoryRequirements2(void* context, VkDevice device, |
| 233 | const VkBufferMemoryRequirementsInfo2* pInfo, |
| 234 | VkMemoryRequirements2* pMemoryRequirements); |
| 235 | void on_vkGetBufferMemoryRequirements2KHR(void* context, VkDevice device, |
| 236 | const VkBufferMemoryRequirementsInfo2* pInfo, |
| 237 | VkMemoryRequirements2* pMemoryRequirements); |
Lingfeng Yang | 4af5f32 | 2019-02-14 08:10:28 -0800 | [diff] [blame] | 238 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 239 | VkResult on_vkBindBufferMemory(void* context, VkResult input_result, VkDevice device, |
| 240 | VkBuffer buffer, VkDeviceMemory memory, |
| 241 | VkDeviceSize memoryOffset); |
| 242 | VkResult on_vkBindBufferMemory2(void* context, VkResult input_result, VkDevice device, |
| 243 | uint32_t bindInfoCount, |
| 244 | const VkBindBufferMemoryInfo* pBindInfos); |
| 245 | VkResult on_vkBindBufferMemory2KHR(void* context, VkResult input_result, VkDevice device, |
| 246 | uint32_t bindInfoCount, |
| 247 | const VkBindBufferMemoryInfo* pBindInfos); |
Lingfeng Yang | 4af5f32 | 2019-02-14 08:10:28 -0800 | [diff] [blame] | 248 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 249 | VkResult on_vkCreateSemaphore(void* context, VkResult, VkDevice device, |
| 250 | const VkSemaphoreCreateInfo* pCreateInfo, |
| 251 | const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore); |
| 252 | void on_vkDestroySemaphore(void* context, VkDevice device, VkSemaphore semaphore, |
| 253 | const VkAllocationCallbacks* pAllocator); |
| 254 | VkResult on_vkGetSemaphoreFdKHR(void* context, VkResult, VkDevice device, |
| 255 | const VkSemaphoreGetFdInfoKHR* pGetFdInfo, int* pFd); |
| 256 | VkResult on_vkImportSemaphoreFdKHR(void* context, VkResult, VkDevice device, |
| 257 | const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo); |
David Reveman | 32b110e | 2019-02-21 13:20:54 -0500 | [diff] [blame] | 258 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 259 | VkResult on_vkQueueSubmit(void* context, VkResult input_result, VkQueue queue, |
| 260 | uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence); |
David Reveman | 2471022 | 2019-02-25 02:21:42 -0500 | [diff] [blame] | 261 | |
Yahan Zhou | e4a8438 | 2023-09-13 16:27:47 -0700 | [diff] [blame] | 262 | VkResult on_vkQueueSubmit2(void* context, VkResult input_result, VkQueue queue, |
| 263 | uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence); |
| 264 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 265 | VkResult on_vkQueueWaitIdle(void* context, VkResult input_result, VkQueue queue); |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 266 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 267 | void unwrap_vkCreateImage_pCreateInfo(const VkImageCreateInfo* pCreateInfo, |
| 268 | VkImageCreateInfo* local_pCreateInfo); |
Jason Macnak | e0ac288 | 2023-06-07 09:13:51 -0700 | [diff] [blame] | 269 | |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame] | 270 | void unwrap_vkAcquireImageANDROID_nativeFenceFd(int fd, int* fd_out); |
| 271 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 272 | void unwrap_VkBindImageMemory2_pBindInfos(uint32_t bindInfoCount, |
| 273 | const VkBindImageMemoryInfo* inputBindInfos, |
| 274 | VkBindImageMemoryInfo* outputBindInfos); |
Jason Macnak | e0ac288 | 2023-06-07 09:13:51 -0700 | [diff] [blame] | 275 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 276 | VkResult on_vkGetMemoryFdKHR(void* context, VkResult input_result, VkDevice device, |
| 277 | const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd); |
Aaron Ruby | 16b349b | 2024-04-26 13:52:40 -0400 | [diff] [blame] | 278 | VkResult on_vkGetMemoryFdPropertiesKHR(void* context, VkResult input_result, VkDevice device, |
| 279 | VkExternalMemoryHandleTypeFlagBits handleType, int fd, |
| 280 | VkMemoryFdPropertiesKHR* pMemoryFdProperties); |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 281 | |
David Reveman | 5b7c584 | 2019-02-20 01:06:48 -0500 | [diff] [blame] | 282 | #ifdef VK_USE_PLATFORM_FUCHSIA |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 283 | VkResult on_vkGetMemoryZirconHandleFUCHSIA(void* context, VkResult input_result, |
| 284 | VkDevice device, |
| 285 | const VkMemoryGetZirconHandleInfoFUCHSIA* pInfo, |
| 286 | uint32_t* pHandle); |
David Reveman | 488704f | 2019-03-27 01:29:08 -0400 | [diff] [blame] | 287 | VkResult on_vkGetMemoryZirconHandlePropertiesFUCHSIA( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 288 | void* context, VkResult input_result, VkDevice device, |
| 289 | VkExternalMemoryHandleTypeFlagBits handleType, uint32_t handle, |
David Reveman | 488704f | 2019-03-27 01:29:08 -0400 | [diff] [blame] | 290 | VkMemoryZirconHandlePropertiesFUCHSIA* pProperties); |
David Reveman | ba51ee2 | 2019-03-26 11:22:21 -0400 | [diff] [blame] | 291 | VkResult on_vkGetSemaphoreZirconHandleFUCHSIA( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 292 | void* context, VkResult input_result, VkDevice device, |
| 293 | const VkSemaphoreGetZirconHandleInfoFUCHSIA* pInfo, uint32_t* pHandle); |
David Reveman | ba51ee2 | 2019-03-26 11:22:21 -0400 | [diff] [blame] | 294 | VkResult on_vkImportSemaphoreZirconHandleFUCHSIA( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 295 | void* context, VkResult input_result, VkDevice device, |
David Reveman | ba51ee2 | 2019-03-26 11:22:21 -0400 | [diff] [blame] | 296 | const VkImportSemaphoreZirconHandleInfoFUCHSIA* pInfo); |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 297 | VkResult on_vkCreateBufferCollectionFUCHSIA(void* context, VkResult input_result, |
| 298 | VkDevice device, |
| 299 | const VkBufferCollectionCreateInfoFUCHSIA* pInfo, |
| 300 | const VkAllocationCallbacks* pAllocator, |
| 301 | VkBufferCollectionFUCHSIA* pCollection); |
| 302 | void on_vkDestroyBufferCollectionFUCHSIA(void* context, VkResult input_result, VkDevice device, |
| 303 | VkBufferCollectionFUCHSIA collection, |
| 304 | const VkAllocationCallbacks* pAllocator); |
Yilong Li | e12328f | 2022-01-06 03:32:13 -0800 | [diff] [blame] | 305 | VkResult on_vkSetBufferCollectionBufferConstraintsFUCHSIA( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 306 | void* context, VkResult input_result, VkDevice device, VkBufferCollectionFUCHSIA collection, |
Yilong Li | e12328f | 2022-01-06 03:32:13 -0800 | [diff] [blame] | 307 | const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo); |
| 308 | VkResult on_vkSetBufferCollectionImageConstraintsFUCHSIA( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 309 | void* context, VkResult input_result, VkDevice device, VkBufferCollectionFUCHSIA collection, |
Yilong Li | e12328f | 2022-01-06 03:32:13 -0800 | [diff] [blame] | 310 | const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo); |
| 311 | VkResult on_vkGetBufferCollectionPropertiesFUCHSIA( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 312 | void* context, VkResult input_result, VkDevice device, VkBufferCollectionFUCHSIA collection, |
Yilong Li | e12328f | 2022-01-06 03:32:13 -0800 | [diff] [blame] | 313 | VkBufferCollectionPropertiesFUCHSIA* pProperties); |
C Stout | 5a3a422 | 2023-11-14 16:31:56 -0800 | [diff] [blame] | 314 | |
| 315 | VkResult setBufferCollectionImageConstraintsFUCHSIA( |
| 316 | VkEncoder* enc, VkDevice device, |
| 317 | fidl::WireSyncClient<fuchsia_sysmem::BufferCollection>* pCollection, |
| 318 | const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo); |
| 319 | |
| 320 | VkResult setBufferCollectionBufferConstraintsFUCHSIA( |
| 321 | fidl::WireSyncClient<fuchsia_sysmem::BufferCollection>* pCollection, |
| 322 | const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo); |
| 323 | |
David Reveman | 5b7c584 | 2019-02-20 01:06:48 -0500 | [diff] [blame] | 324 | #endif |
| 325 | |
Kaiyi Li | 6a76b33 | 2022-08-23 08:10:59 -0700 | [diff] [blame] | 326 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Lingfeng Yang | 4f3f91f | 2019-02-28 11:37:21 -0800 | [diff] [blame] | 327 | VkResult on_vkGetAndroidHardwareBufferPropertiesANDROID( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 328 | void* context, VkResult input_result, VkDevice device, const AHardwareBuffer* buffer, |
Lingfeng Yang | 4f3f91f | 2019-02-28 11:37:21 -0800 | [diff] [blame] | 329 | VkAndroidHardwareBufferPropertiesANDROID* pProperties); |
| 330 | VkResult on_vkGetMemoryAndroidHardwareBufferANDROID( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 331 | void* context, VkResult input_result, VkDevice device, |
| 332 | const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer); |
Kaiyi Li | 6a76b33 | 2022-08-23 08:10:59 -0700 | [diff] [blame] | 333 | #endif |
Lingfeng Yang | 4f3f91f | 2019-02-28 11:37:21 -0800 | [diff] [blame] | 334 | |
Lingfeng Yang | 5c70112 | 2019-03-05 08:34:46 -0800 | [diff] [blame] | 335 | VkResult on_vkCreateSamplerYcbcrConversion( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 336 | void* context, VkResult input_result, VkDevice device, |
Lingfeng Yang | 5c70112 | 2019-03-05 08:34:46 -0800 | [diff] [blame] | 337 | const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 338 | const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion); |
| 339 | void on_vkDestroySamplerYcbcrConversion(void* context, VkDevice device, |
| 340 | VkSamplerYcbcrConversion ycbcrConversion, |
| 341 | const VkAllocationCallbacks* pAllocator); |
Lingfeng Yang | 5c70112 | 2019-03-05 08:34:46 -0800 | [diff] [blame] | 342 | VkResult on_vkCreateSamplerYcbcrConversionKHR( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 343 | void* context, VkResult input_result, VkDevice device, |
Lingfeng Yang | 5c70112 | 2019-03-05 08:34:46 -0800 | [diff] [blame] | 344 | const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 345 | const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion); |
| 346 | void on_vkDestroySamplerYcbcrConversionKHR(void* context, VkDevice device, |
| 347 | VkSamplerYcbcrConversion ycbcrConversion, |
| 348 | const VkAllocationCallbacks* pAllocator); |
Roman Kiryanov | 004f48c | 2019-06-28 14:59:32 -0700 | [diff] [blame] | 349 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 350 | VkResult on_vkCreateSampler(void* context, VkResult input_result, VkDevice device, |
| 351 | const VkSamplerCreateInfo* pCreateInfo, |
| 352 | const VkAllocationCallbacks* pAllocator, VkSampler* pSampler); |
Lingfeng Yang | 5c70112 | 2019-03-05 08:34:46 -0800 | [diff] [blame] | 353 | |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 354 | void on_vkGetPhysicalDeviceExternalFenceProperties( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 355 | void* context, VkPhysicalDevice physicalDevice, |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 356 | const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, |
| 357 | VkExternalFenceProperties* pExternalFenceProperties); |
| 358 | |
| 359 | void on_vkGetPhysicalDeviceExternalFencePropertiesKHR( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 360 | void* context, VkPhysicalDevice physicalDevice, |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 361 | const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, |
| 362 | VkExternalFenceProperties* pExternalFenceProperties); |
| 363 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 364 | VkResult on_vkCreateFence(void* context, VkResult input_result, VkDevice device, |
| 365 | const VkFenceCreateInfo* pCreateInfo, |
| 366 | const VkAllocationCallbacks* pAllocator, VkFence* pFence); |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 367 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 368 | void on_vkDestroyFence(void* context, VkDevice device, VkFence fence, |
| 369 | const VkAllocationCallbacks* pAllocator); |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 370 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 371 | VkResult on_vkResetFences(void* context, VkResult input_result, VkDevice device, |
| 372 | uint32_t fenceCount, const VkFence* pFences); |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 373 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 374 | VkResult on_vkImportFenceFdKHR(void* context, VkResult input_result, VkDevice device, |
| 375 | const VkImportFenceFdInfoKHR* pImportFenceFdInfo); |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 376 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 377 | VkResult on_vkGetFenceFdKHR(void* context, VkResult input_result, VkDevice device, |
| 378 | const VkFenceGetFdInfoKHR* pGetFdInfo, int* pFd); |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 379 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 380 | VkResult on_vkWaitForFences(void* context, VkResult input_result, VkDevice device, |
| 381 | uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, |
| 382 | uint64_t timeout); |
Lingfeng Yang | cd2d8fe | 2019-08-16 12:21:50 -0700 | [diff] [blame] | 383 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 384 | VkResult on_vkCreateDescriptorPool(void* context, VkResult input_result, VkDevice device, |
| 385 | const VkDescriptorPoolCreateInfo* pCreateInfo, |
| 386 | const VkAllocationCallbacks* pAllocator, |
| 387 | VkDescriptorPool* pDescriptorPool); |
Lingfeng Yang | e9e77d5 | 2020-03-25 14:01:58 -0700 | [diff] [blame] | 388 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 389 | void on_vkDestroyDescriptorPool(void* context, VkDevice device, VkDescriptorPool descriptorPool, |
| 390 | const VkAllocationCallbacks* pAllocator); |
Lingfeng Yang | e9e77d5 | 2020-03-25 14:01:58 -0700 | [diff] [blame] | 391 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 392 | VkResult on_vkResetDescriptorPool(void* context, VkResult input_result, VkDevice device, |
| 393 | VkDescriptorPool descriptorPool, |
| 394 | VkDescriptorPoolResetFlags flags); |
Lingfeng Yang | e9e77d5 | 2020-03-25 14:01:58 -0700 | [diff] [blame] | 395 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 396 | VkResult on_vkAllocateDescriptorSets(void* context, VkResult input_result, VkDevice device, |
| 397 | const VkDescriptorSetAllocateInfo* pAllocateInfo, |
| 398 | VkDescriptorSet* pDescriptorSets); |
Lingfeng Yang | e9e77d5 | 2020-03-25 14:01:58 -0700 | [diff] [blame] | 399 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 400 | VkResult on_vkFreeDescriptorSets(void* context, VkResult input_result, VkDevice device, |
| 401 | VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 402 | const VkDescriptorSet* pDescriptorSets); |
Lingfeng Yang | e9e77d5 | 2020-03-25 14:01:58 -0700 | [diff] [blame] | 403 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 404 | VkResult on_vkCreateDescriptorSetLayout(void* context, VkResult input_result, VkDevice device, |
| 405 | const VkDescriptorSetLayoutCreateInfo* pCreateInfo, |
| 406 | const VkAllocationCallbacks* pAllocator, |
| 407 | VkDescriptorSetLayout* pSetLayout); |
Lingfeng Yang | 03354c7 | 2020-03-26 13:00:51 -0700 | [diff] [blame] | 408 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 409 | void on_vkUpdateDescriptorSets(void* context, VkDevice device, uint32_t descriptorWriteCount, |
| 410 | const VkWriteDescriptorSet* pDescriptorWrites, |
| 411 | uint32_t descriptorCopyCount, |
| 412 | const VkCopyDescriptorSet* pDescriptorCopies); |
Lingfeng Yang | 03354c7 | 2020-03-26 13:00:51 -0700 | [diff] [blame] | 413 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 414 | VkResult on_vkMapMemoryIntoAddressSpaceGOOGLE_pre(void* context, VkResult input_result, |
| 415 | VkDevice device, VkDeviceMemory memory, |
| 416 | uint64_t* pAddress); |
| 417 | VkResult on_vkMapMemoryIntoAddressSpaceGOOGLE(void* context, VkResult input_result, |
| 418 | VkDevice device, VkDeviceMemory memory, |
| 419 | uint64_t* pAddress); |
Lingfeng Yang | 236abc9 | 2018-12-21 20:19:33 -0800 | [diff] [blame] | 420 | |
Lingfeng Yang | 05d5ea3 | 2019-03-23 00:12:39 -0700 | [diff] [blame] | 421 | VkResult on_vkCreateDescriptorUpdateTemplate( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 422 | void* context, VkResult input_result, VkDevice device, |
Lingfeng Yang | 05d5ea3 | 2019-03-23 00:12:39 -0700 | [diff] [blame] | 423 | const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, |
| 424 | const VkAllocationCallbacks* pAllocator, |
| 425 | VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); |
| 426 | |
| 427 | VkResult on_vkCreateDescriptorUpdateTemplateKHR( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 428 | void* context, VkResult input_result, VkDevice device, |
Lingfeng Yang | 05d5ea3 | 2019-03-23 00:12:39 -0700 | [diff] [blame] | 429 | const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, |
| 430 | const VkAllocationCallbacks* pAllocator, |
| 431 | VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); |
| 432 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 433 | void on_vkUpdateDescriptorSetWithTemplate(void* context, VkDevice device, |
| 434 | VkDescriptorSet descriptorSet, |
| 435 | VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
| 436 | const void* pData); |
Lingfeng Yang | 05d5ea3 | 2019-03-23 00:12:39 -0700 | [diff] [blame] | 437 | |
Jean-Francois Thibert | f884afd | 2024-01-31 10:15:04 -0500 | [diff] [blame] | 438 | void on_vkUpdateDescriptorSetWithTemplateKHR(void* context, VkDevice device, |
| 439 | VkDescriptorSet descriptorSet, |
| 440 | VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
| 441 | const void* pData); |
| 442 | |
Lingfeng Yang | e517d1e | 2019-03-25 18:02:49 -0700 | [diff] [blame] | 443 | VkResult on_vkGetPhysicalDeviceImageFormatProperties2( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 444 | void* context, VkResult input_result, VkPhysicalDevice physicalDevice, |
Lingfeng Yang | e517d1e | 2019-03-25 18:02:49 -0700 | [diff] [blame] | 445 | const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, |
| 446 | VkImageFormatProperties2* pImageFormatProperties); |
| 447 | |
| 448 | VkResult on_vkGetPhysicalDeviceImageFormatProperties2KHR( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 449 | void* context, VkResult input_result, VkPhysicalDevice physicalDevice, |
Lingfeng Yang | e517d1e | 2019-03-25 18:02:49 -0700 | [diff] [blame] | 450 | const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, |
| 451 | VkImageFormatProperties2* pImageFormatProperties); |
| 452 | |
Andrew Woloszyn | 416d0a1 | 2023-10-04 17:02:19 -0400 | [diff] [blame] | 453 | void on_vkGetPhysicalDeviceExternalBufferProperties( |
| 454 | void* context, VkPhysicalDevice physicalDevice, |
| 455 | const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, |
| 456 | VkExternalBufferProperties* pExternalBufferProperties); |
| 457 | |
| 458 | void on_vkGetPhysicalDeviceExternalBufferPropertiesKHR( |
| 459 | void* context, VkPhysicalDevice physicalDevice, |
| 460 | const VkPhysicalDeviceExternalBufferInfoKHR* pExternalBufferInfo, |
| 461 | VkExternalBufferPropertiesKHR* pExternalBufferProperties); |
| 462 | |
Yilong Li | d1c6919 | 2021-02-05 02:06:07 -0800 | [diff] [blame] | 463 | void on_vkGetPhysicalDeviceExternalSemaphoreProperties( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 464 | void* context, VkPhysicalDevice physicalDevice, |
Yilong Li | d1c6919 | 2021-02-05 02:06:07 -0800 | [diff] [blame] | 465 | const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, |
| 466 | VkExternalSemaphoreProperties* pExternalSemaphoreProperties); |
| 467 | |
| 468 | void on_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 469 | void* context, VkPhysicalDevice physicalDevice, |
Yilong Li | d1c6919 | 2021-02-05 02:06:07 -0800 | [diff] [blame] | 470 | const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, |
| 471 | VkExternalSemaphoreProperties* pExternalSemaphoreProperties); |
| 472 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 473 | void registerEncoderCleanupCallback(const VkEncoder* encoder, void* handle, |
| 474 | CleanupCallback callback); |
Lingfeng Yang | 256f925 | 2020-07-14 14:27:33 -0700 | [diff] [blame] | 475 | void unregisterEncoderCleanupCallback(const VkEncoder* encoder, void* handle); |
| 476 | void onEncoderDeleted(const VkEncoder* encoder); |
| 477 | |
Lingfeng Yang | 39a276e | 2019-06-17 13:27:22 -0700 | [diff] [blame] | 478 | uint32_t syncEncodersForCommandBuffer(VkCommandBuffer commandBuffer, VkEncoder* current); |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 479 | uint32_t syncEncodersForQueue(VkQueue queue, VkEncoder* currentEncoder); |
Lingfeng Yang | 39a276e | 2019-06-17 13:27:22 -0700 | [diff] [blame] | 480 | |
Shalini S | db704c9 | 2023-01-27 21:35:33 +0000 | [diff] [blame] | 481 | CommandBufferStagingStream::Alloc getAlloc(); |
| 482 | CommandBufferStagingStream::Free getFree(); |
| 483 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 484 | VkResult on_vkBeginCommandBuffer(void* context, VkResult input_result, |
| 485 | VkCommandBuffer commandBuffer, |
| 486 | const VkCommandBufferBeginInfo* pBeginInfo); |
| 487 | VkResult on_vkEndCommandBuffer(void* context, VkResult input_result, |
| 488 | VkCommandBuffer commandBuffer); |
| 489 | VkResult on_vkResetCommandBuffer(void* context, VkResult input_result, |
| 490 | VkCommandBuffer commandBuffer, |
| 491 | VkCommandBufferResetFlags flags); |
Lingfeng Yang | c53e747 | 2019-03-27 08:50:55 -0700 | [diff] [blame] | 492 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 493 | VkResult on_vkCreateImageView(void* context, VkResult input_result, VkDevice device, |
| 494 | const VkImageViewCreateInfo* pCreateInfo, |
| 495 | const VkAllocationCallbacks* pAllocator, VkImageView* pView); |
Roman Kiryanov | 6db11e5 | 2019-04-26 14:18:14 -0700 | [diff] [blame] | 496 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 497 | void on_vkCmdExecuteCommands(void* context, VkCommandBuffer commandBuffer, |
| 498 | uint32_t commandBufferCount, |
| 499 | const VkCommandBuffer* pCommandBuffers); |
Lingfeng Yang | 967f9af | 2021-01-22 17:56:24 -0800 | [diff] [blame] | 500 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 501 | void on_vkCmdBindDescriptorSets(void* context, VkCommandBuffer commandBuffer, |
| 502 | VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, |
| 503 | uint32_t firstSet, uint32_t descriptorSetCount, |
| 504 | const VkDescriptorSet* pDescriptorSets, |
| 505 | uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets); |
Lingfeng Yang | 55676e0 | 2021-02-08 08:39:45 -0800 | [diff] [blame] | 506 | |
Jason Macnak | e6704de | 2022-05-27 09:41:20 -0700 | [diff] [blame] | 507 | void on_vkCmdPipelineBarrier( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 508 | void* context, VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 509 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 510 | uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, |
| 511 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, |
| 512 | uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers); |
Jason Macnak | e6704de | 2022-05-27 09:41:20 -0700 | [diff] [blame] | 513 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 514 | void on_vkDestroyDescriptorSetLayout(void* context, VkDevice device, |
| 515 | VkDescriptorSetLayout descriptorSetLayout, |
| 516 | const VkAllocationCallbacks* pAllocator); |
Lingfeng Yang | 55676e0 | 2021-02-08 08:39:45 -0800 | [diff] [blame] | 517 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 518 | VkResult on_vkAllocateCommandBuffers(void* context, VkResult input_result, VkDevice device, |
| 519 | const VkCommandBufferAllocateInfo* pAllocateInfo, |
| 520 | VkCommandBuffer* pCommandBuffers); |
Lingfeng Yang | 97f51af | 2021-04-22 12:24:11 -0700 | [diff] [blame] | 521 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 522 | VkResult on_vkQueueSignalReleaseImageANDROID(void* context, VkResult input_result, |
| 523 | VkQueue queue, uint32_t waitSemaphoreCount, |
| 524 | const VkSemaphore* pWaitSemaphores, VkImage image, |
| 525 | int* pNativeFenceFd); |
Lingfeng Yang | 084e534 | 2021-07-15 13:06:43 -0700 | [diff] [blame] | 526 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 527 | VkResult on_vkCreateGraphicsPipelines(void* context, VkResult input_result, VkDevice device, |
| 528 | VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 529 | const VkGraphicsPipelineCreateInfo* pCreateInfos, |
| 530 | const VkAllocationCallbacks* pAllocator, |
| 531 | VkPipeline* pPipelines); |
Yahan Zhou | 483ac02 | 2022-06-13 15:41:11 -0700 | [diff] [blame] | 532 | |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame] | 533 | uint8_t* getMappedPointer(VkDeviceMemory memory); |
| 534 | VkDeviceSize getMappedSize(VkDeviceMemory memory); |
Lingfeng Yang | 6ab1b0d | 2018-11-27 23:36:03 -0800 | [diff] [blame] | 535 | VkDeviceSize getNonCoherentExtendedSize(VkDevice device, VkDeviceSize basicSize) const; |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame] | 536 | bool isValidMemoryRange(const VkMappedMemoryRange& range) const; |
Gurchetan Singh | 5bb6c60 | 2023-04-04 02:53:32 +0000 | [diff] [blame] | 537 | |
Lingfeng Yang | 3175463 | 2018-12-21 18:24:55 -0800 | [diff] [blame] | 538 | void setupFeatures(const EmulatorFeatureInfo* features); |
Gurchetan Singh | 9928883 | 2023-09-07 09:40:10 -0700 | [diff] [blame] | 539 | void setupCaps(uint32_t& noRenderControlEnc); |
Gurchetan Singh | 5bb6c60 | 2023-04-04 02:53:32 +0000 | [diff] [blame] | 540 | |
Lingfeng Yang | 34b5cae | 2019-08-21 14:12:19 -0700 | [diff] [blame] | 541 | void setThreadingCallbacks(const ThreadingCallbacks& callbacks); |
Lingfeng Yang | b8a38c7 | 2019-02-02 20:27:54 -0800 | [diff] [blame] | 542 | bool hostSupportsVulkan() const; |
Lingfeng Yang | 236abc9 | 2018-12-21 20:19:33 -0800 | [diff] [blame] | 543 | bool usingDirectMapping() const; |
Lingfeng Yang | b55ed1c | 2019-06-20 15:57:08 -0700 | [diff] [blame] | 544 | uint32_t getStreamFeatures() const; |
Lingfeng Yang | 2b1b8cf | 2019-02-08 09:53:36 -0800 | [diff] [blame] | 545 | uint32_t getApiVersionFromInstance(VkInstance instance) const; |
| 546 | uint32_t getApiVersionFromDevice(VkDevice device) const; |
| 547 | bool hasInstanceExtension(VkInstance instance, const std::string& name) const; |
| 548 | bool hasDeviceExtension(VkDevice instance, const std::string& name) const; |
Yahan Zhou | 97f37fa | 2022-04-28 21:57:17 +0000 | [diff] [blame] | 549 | VkDevice getDevice(VkCommandBuffer commandBuffer) const; |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 550 | void addToCommandPool(VkCommandPool commandPool, uint32_t commandBufferCount, |
Lingfeng Yang | 967f9af | 2021-01-22 17:56:24 -0800 | [diff] [blame] | 551 | VkCommandBuffer* pCommandBuffers); |
| 552 | void resetCommandPoolStagingInfo(VkCommandPool commandPool); |
| 553 | |
Gurchetan Singh | b7be316 | 2021-11-04 09:36:15 -0700 | [diff] [blame] | 554 | #ifdef __GNUC__ |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 555 | #define ALWAYS_INLINE_GFXSTREAM |
Gurchetan Singh | b7be316 | 2021-11-04 09:36:15 -0700 | [diff] [blame] | 556 | #elif |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 557 | #define ALWAYS_INLINE_GFXSTREAM __attribute__((always_inline)) |
Gurchetan Singh | b7be316 | 2021-11-04 09:36:15 -0700 | [diff] [blame] | 558 | #endif |
Lingfeng Yang | 967f9af | 2021-01-22 17:56:24 -0800 | [diff] [blame] | 559 | |
| 560 | static VkEncoder* getCommandBufferEncoder(VkCommandBuffer commandBuffer); |
| 561 | static VkEncoder* getQueueEncoder(VkQueue queue); |
| 562 | static VkEncoder* getThreadLocalEncoder(); |
Lingfeng Yang | 2b1b8cf | 2019-02-08 09:53:36 -0800 | [diff] [blame] | 563 | |
Lingfeng Yang | db61655 | 2021-01-22 17:58:02 -0800 | [diff] [blame] | 564 | static void setSeqnoPtr(uint32_t* seqnoptr); |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 565 | static ALWAYS_INLINE_GFXSTREAM uint32_t nextSeqno(); |
| 566 | static ALWAYS_INLINE_GFXSTREAM uint32_t getSeqno(); |
Lingfeng Yang | db61655 | 2021-01-22 17:58:02 -0800 | [diff] [blame] | 567 | |
Lingfeng Yang | 2b1b8cf | 2019-02-08 09:53:36 -0800 | [diff] [blame] | 568 | // Transforms |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 569 | void deviceMemoryTransform_tohost(VkDeviceMemory* memory, uint32_t memoryCount, |
| 570 | VkDeviceSize* offset, uint32_t offsetCount, |
| 571 | VkDeviceSize* size, uint32_t sizeCount, uint32_t* typeIndex, |
| 572 | uint32_t typeIndexCount, uint32_t* typeBits, |
| 573 | uint32_t typeBitsCount); |
| 574 | void deviceMemoryTransform_fromhost(VkDeviceMemory* memory, uint32_t memoryCount, |
| 575 | VkDeviceSize* offset, uint32_t offsetCount, |
| 576 | VkDeviceSize* size, uint32_t sizeCount, uint32_t* typeIndex, |
| 577 | uint32_t typeIndexCount, uint32_t* typeBits, |
| 578 | uint32_t typeBitsCount); |
Lingfeng Yang | def88ba | 2018-12-13 12:43:17 -0800 | [diff] [blame] | 579 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 580 | void transformImpl_VkExternalMemoryProperties_fromhost(VkExternalMemoryProperties* pProperties, |
| 581 | uint32_t); |
| 582 | void transformImpl_VkExternalMemoryProperties_tohost(VkExternalMemoryProperties* pProperties, |
| 583 | uint32_t); |
Yilong Li | 353409a | 2022-01-04 02:37:56 -0800 | [diff] [blame] | 584 | void transformImpl_VkImageCreateInfo_fromhost(const VkImageCreateInfo*, uint32_t); |
| 585 | void transformImpl_VkImageCreateInfo_tohost(const VkImageCreateInfo*, uint32_t); |
Lingfeng Yang | 4af5f32 | 2019-02-14 08:10:28 -0800 | [diff] [blame] | 586 | |
Yilong Li | dbc16d5 | 2021-02-04 03:15:21 -0800 | [diff] [blame] | 587 | #define DEFINE_TRANSFORMED_TYPE_PROTOTYPE(type) \ |
| 588 | void transformImpl_##type##_tohost(type*, uint32_t); \ |
| 589 | void transformImpl_##type##_fromhost(type*, uint32_t); |
Lingfeng Yang | f0654ff | 2019-02-02 12:21:24 -0800 | [diff] [blame] | 590 | |
Yilong Li | d1c6919 | 2021-02-05 02:06:07 -0800 | [diff] [blame] | 591 | LIST_TRIVIAL_TRANSFORMED_TYPES(DEFINE_TRANSFORMED_TYPE_PROTOTYPE) |
Yilong Li | dbc16d5 | 2021-02-04 03:15:21 -0800 | [diff] [blame] | 592 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 593 | private: |
| 594 | VulkanHandleMapping* mCreateMapping = nullptr; |
| 595 | VulkanHandleMapping* mDestroyMapping = nullptr; |
| 596 | |
| 597 | uint32_t getColorBufferMemoryIndex(void* context, VkDevice device); |
| 598 | const VkPhysicalDeviceMemoryProperties& getPhysicalDeviceMemoryProperties( |
| 599 | void* context, VkDevice device, VkPhysicalDevice physicalDevice); |
| 600 | |
| 601 | VkResult on_vkGetPhysicalDeviceImageFormatProperties2_common( |
| 602 | bool isKhr, void* context, VkResult input_result, VkPhysicalDevice physicalDevice, |
| 603 | const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, |
| 604 | VkImageFormatProperties2* pImageFormatProperties); |
| 605 | |
Andrew Woloszyn | 416d0a1 | 2023-10-04 17:02:19 -0400 | [diff] [blame] | 606 | void on_vkGetPhysicalDeviceExternalBufferProperties_common( |
| 607 | bool isKhr, void* context, VkPhysicalDevice physicalDevice, |
| 608 | const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, |
| 609 | VkExternalBufferProperties* pExternalBufferProperties); |
| 610 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 611 | template <typename VkSubmitInfoType> |
| 612 | VkResult on_vkQueueSubmitTemplate(void* context, VkResult input_result, VkQueue queue, |
| 613 | uint32_t submitCount, const VkSubmitInfoType* pSubmits, |
| 614 | VkFence fence); |
| 615 | |
| 616 | void freeDescriptorSetsIfHostAllocated(VkEncoder* enc, VkDevice device, |
| 617 | uint32_t descriptorSetCount, |
| 618 | const VkDescriptorSet* sets); |
| 619 | void clearDescriptorPoolAndUnregisterDescriptorSets(void* context, VkDevice device, |
| 620 | VkDescriptorPool pool); |
| 621 | |
| 622 | void setDeviceInfo(VkDevice device, VkPhysicalDevice physdev, VkPhysicalDeviceProperties props, |
| 623 | VkPhysicalDeviceMemoryProperties memProps, uint32_t enabledExtensionCount, |
| 624 | const char* const* ppEnabledExtensionNames, const void* pNext); |
| 625 | |
| 626 | void setDeviceMemoryInfo(VkDevice device, VkDeviceMemory memory, VkDeviceSize allocationSize, |
| 627 | uint8_t* ptr, uint32_t memoryTypeIndex, AHardwareBuffer* ahw, |
Jason Macnak | 6d3d7b2 | 2024-04-01 16:48:53 -0700 | [diff] [blame] | 628 | bool imported, zx_handle_t vmoHandle, VirtGpuResourcePtr blobPtr); |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 629 | |
| 630 | void setImageInfo(VkImage image, VkDevice device, const VkImageCreateInfo* pCreateInfo); |
| 631 | |
| 632 | bool supportsDeferredCommands() const; |
| 633 | bool supportsAsyncQueueSubmit() const; |
| 634 | bool supportsCreateResourcesWithRequirements() const; |
| 635 | |
| 636 | int getHostInstanceExtensionIndex(const std::string& extName) const; |
| 637 | int getHostDeviceExtensionIndex(const std::string& extName) const; |
| 638 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 639 | CoherentMemoryPtr createCoherentMemory(VkDevice device, VkDeviceMemory mem, |
| 640 | const VkMemoryAllocateInfo& hostAllocationInfo, |
| 641 | VkEncoder* enc, VkResult& res); |
| 642 | VkResult allocateCoherentMemory(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, |
| 643 | VkEncoder* enc, VkDeviceMemory* pMemory); |
| 644 | |
| 645 | VkResult getCoherentMemory(const VkMemoryAllocateInfo* pAllocateInfo, VkEncoder* enc, |
| 646 | VkDevice device, VkDeviceMemory* pMemory); |
| 647 | |
| 648 | void transformImageMemoryRequirements2ForGuest(VkImage image, VkMemoryRequirements2* reqs2); |
| 649 | |
| 650 | void transformBufferMemoryRequirements2ForGuest(VkBuffer buffer, VkMemoryRequirements2* reqs2); |
| 651 | |
| 652 | void flushCommandBufferPendingCommandsBottomUp(void* context, VkQueue queue, |
| 653 | const std::vector<VkCommandBuffer>& workingSet); |
| 654 | |
| 655 | template <class VkSubmitInfoType> |
| 656 | void flushStagingStreams(void* context, VkQueue queue, uint32_t submitCount, |
| 657 | const VkSubmitInfoType* pSubmits); |
| 658 | |
| 659 | VkResult vkQueueSubmitEnc(VkEncoder* enc, VkQueue queue, uint32_t submitCount, |
| 660 | const VkSubmitInfo* pSubmits, VkFence fence); |
| 661 | |
| 662 | VkResult vkQueueSubmitEnc(VkEncoder* enc, VkQueue queue, uint32_t submitCount, |
| 663 | const VkSubmitInfo2* pSubmits, VkFence fence); |
| 664 | |
| 665 | VkResult initDescriptorUpdateTemplateBuffers( |
| 666 | const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, |
| 667 | VkDescriptorUpdateTemplate descriptorUpdateTemplate); |
| 668 | |
| 669 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 670 | VkResult exportSyncFdForQSRILocked(VkImage image, int* fd); |
| 671 | #endif |
| 672 | |
| 673 | void setInstanceInfo(VkInstance instance, uint32_t enabledExtensionCount, |
| 674 | const char* const* ppEnabledExtensionNames, uint32_t apiVersion); |
| 675 | |
| 676 | void resetCommandBufferStagingInfo(VkCommandBuffer commandBuffer, bool alsoResetPrimaries, |
| 677 | bool alsoClearPendingDescriptorSets); |
| 678 | |
| 679 | void resetCommandBufferPendingTopology(VkCommandBuffer commandBuffer); |
| 680 | |
| 681 | void clearCommandPool(VkCommandPool commandPool); |
| 682 | |
| 683 | void ensureSyncDeviceFd(void); |
| 684 | |
| 685 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 686 | void unwrap_VkNativeBufferANDROID(const VkNativeBufferANDROID* inputNativeInfo, |
| 687 | VkNativeBufferANDROID* outputNativeInfo); |
| 688 | |
| 689 | void unwrap_VkBindImageMemorySwapchainInfoKHR( |
| 690 | const VkBindImageMemorySwapchainInfoKHR* inputBimsi, |
| 691 | VkBindImageMemorySwapchainInfoKHR* outputBimsi); |
| 692 | #endif |
| 693 | |
C Stout | 5a3a422 | 2023-11-14 16:31:56 -0800 | [diff] [blame] | 694 | #if defined(VK_USE_PLATFORM_FUCHSIA) |
| 695 | VkResult getBufferCollectionImageCreateInfoIndexLocked( |
| 696 | VkBufferCollectionFUCHSIA collection, fuchsia_sysmem::wire::BufferCollectionInfo2& info, |
| 697 | uint32_t* outCreateInfoIndex); |
| 698 | |
| 699 | SetBufferCollectionImageConstraintsResult setBufferCollectionImageConstraintsImpl( |
| 700 | VkEncoder* enc, VkDevice device, |
| 701 | fidl::WireSyncClient<fuchsia_sysmem::BufferCollection>* pCollection, |
| 702 | const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo); |
| 703 | |
| 704 | VkResult setBufferCollectionConstraintsFUCHSIA( |
| 705 | VkEncoder* enc, VkDevice device, |
| 706 | fidl::WireSyncClient<fuchsia_sysmem::BufferCollection>* collection, |
| 707 | const VkImageCreateInfo* pImageInfo); |
| 708 | #endif |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 709 | |
| 710 | void unregister_VkDescriptorSet_locked(VkDescriptorSet set); |
| 711 | |
| 712 | #define HANDLE_DEFINE_TRIVIAL_INFO_STRUCT(type) \ |
| 713 | struct type##_Info { \ |
| 714 | uint32_t unused; \ |
| 715 | }; |
| 716 | GOLDFISH_VK_LIST_TRIVIAL_HANDLE_TYPES(HANDLE_DEFINE_TRIVIAL_INFO_STRUCT) |
| 717 | |
| 718 | struct VkInstance_Info { |
| 719 | uint32_t highestApiVersion; |
| 720 | std::set<std::string> enabledExtensions; |
| 721 | // Fodder for vkEnumeratePhysicalDevices. |
| 722 | std::vector<VkPhysicalDevice> physicalDevices; |
| 723 | }; |
| 724 | |
| 725 | struct VkDevice_Info { |
| 726 | VkPhysicalDevice physdev; |
| 727 | VkPhysicalDeviceProperties props; |
| 728 | VkPhysicalDeviceMemoryProperties memProps; |
| 729 | uint32_t apiVersion; |
| 730 | std::set<std::string> enabledExtensions; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 731 | std::vector<std::pair<PFN_vkDeviceMemoryReportCallbackEXT, void*>> |
| 732 | deviceMemoryReportCallbacks; |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 733 | }; |
| 734 | |
| 735 | struct VkDeviceMemory_Info { |
| 736 | bool dedicated = false; |
| 737 | bool imported = false; |
| 738 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 739 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 740 | AHardwareBuffer* ahw = nullptr; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 741 | #endif |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 742 | zx_handle_t vmoHandle = ZX_HANDLE_INVALID; |
| 743 | VkDevice device; |
| 744 | |
| 745 | uint8_t* ptr = nullptr; |
| 746 | |
| 747 | uint64_t blobId = 0; |
| 748 | uint64_t allocationSize = 0; |
| 749 | uint32_t memoryTypeIndex = 0; |
| 750 | uint64_t coherentMemorySize = 0; |
| 751 | uint64_t coherentMemoryOffset = 0; |
| 752 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 753 | #if defined(__ANDROID__) |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 754 | GoldfishAddressSpaceBlockPtr goldfishBlock = nullptr; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 755 | #endif // defined(__ANDROID__) |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 756 | CoherentMemoryPtr coherentMemory = nullptr; |
Jason Macnak | 6d3d7b2 | 2024-04-01 16:48:53 -0700 | [diff] [blame] | 757 | VirtGpuResourcePtr blobPtr = nullptr; |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 758 | }; |
| 759 | |
| 760 | struct VkCommandBuffer_Info { |
| 761 | uint32_t placeholder; |
| 762 | }; |
| 763 | |
| 764 | struct VkQueue_Info { |
| 765 | VkDevice device; |
| 766 | }; |
| 767 | |
| 768 | // custom guest-side structs for images/buffers because of AHardwareBuffer :(( |
| 769 | struct VkImage_Info { |
| 770 | VkDevice device; |
| 771 | VkImageCreateInfo createInfo; |
| 772 | bool external = false; |
| 773 | VkExternalMemoryImageCreateInfo externalCreateInfo; |
| 774 | VkDeviceMemory currentBacking = VK_NULL_HANDLE; |
| 775 | VkDeviceSize currentBackingOffset = 0; |
| 776 | VkDeviceSize currentBackingSize = 0; |
| 777 | bool baseRequirementsKnown = false; |
| 778 | VkMemoryRequirements baseRequirements; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 779 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 780 | bool hasExternalFormat = false; |
Sergiu | ad91847 | 2024-05-21 16:28:45 +0100 | [diff] [blame] | 781 | unsigned externalFourccFormat = 0; |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 782 | std::vector<int> pendingQsriSyncFds; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 783 | #endif |
| 784 | #ifdef VK_USE_PLATFORM_FUCHSIA |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 785 | bool isSysmemBackedMemory = false; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 786 | #endif |
Aaron Ruby | 42a8b75 | 2024-05-27 15:37:53 -0400 | [diff] [blame] | 787 | #ifdef LINUX_GUEST_BUILD |
| 788 | bool isDmaBufImage = false; |
Aaron Ruby | a8140f4 | 2024-05-10 15:50:44 -0400 | [diff] [blame] | 789 | VkImage linearPeerImage = VK_NULL_HANDLE; |
Aaron Ruby | 42a8b75 | 2024-05-27 15:37:53 -0400 | [diff] [blame] | 790 | #endif |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 791 | }; |
| 792 | |
| 793 | struct VkBuffer_Info { |
| 794 | VkDevice device; |
| 795 | VkBufferCreateInfo createInfo; |
| 796 | bool external = false; |
| 797 | VkExternalMemoryBufferCreateInfo externalCreateInfo; |
| 798 | VkDeviceMemory currentBacking = VK_NULL_HANDLE; |
| 799 | VkDeviceSize currentBackingOffset = 0; |
| 800 | VkDeviceSize currentBackingSize = 0; |
| 801 | bool baseRequirementsKnown = false; |
| 802 | VkMemoryRequirements baseRequirements; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 803 | #ifdef VK_USE_PLATFORM_FUCHSIA |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 804 | bool isSysmemBackedMemory = false; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 805 | #endif |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 806 | }; |
| 807 | |
| 808 | struct VkSemaphore_Info { |
| 809 | VkDevice device; |
| 810 | zx_handle_t eventHandle = ZX_HANDLE_INVALID; |
| 811 | zx_koid_t eventKoid = ZX_KOID_INVALID; |
| 812 | std::optional<int> syncFd = {}; |
| 813 | }; |
| 814 | |
| 815 | struct VkDescriptorUpdateTemplate_Info { |
| 816 | uint32_t templateEntryCount = 0; |
| 817 | VkDescriptorUpdateTemplateEntry* templateEntries; |
| 818 | |
| 819 | uint32_t imageInfoCount = 0; |
| 820 | uint32_t bufferInfoCount = 0; |
| 821 | uint32_t bufferViewCount = 0; |
| 822 | uint32_t inlineUniformBlockCount = 0; |
| 823 | uint32_t* imageInfoIndices; |
| 824 | uint32_t* bufferInfoIndices; |
| 825 | uint32_t* bufferViewIndices; |
| 826 | VkDescriptorImageInfo* imageInfos; |
| 827 | VkDescriptorBufferInfo* bufferInfos; |
| 828 | VkBufferView* bufferViews; |
| 829 | std::vector<uint8_t> inlineUniformBlockBuffer; |
| 830 | std::vector<uint32_t> inlineUniformBlockBytesPerBlocks; // bytes per uniform block |
| 831 | }; |
| 832 | |
| 833 | struct VkFence_Info { |
| 834 | VkDevice device; |
| 835 | bool external = false; |
| 836 | VkExportFenceCreateInfo exportFenceCreateInfo; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 837 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(__linux__) |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 838 | int syncFd = -1; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 839 | #endif |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 840 | }; |
| 841 | |
| 842 | struct VkDescriptorPool_Info { |
| 843 | uint32_t unused; |
| 844 | }; |
| 845 | |
| 846 | struct VkDescriptorSet_Info { |
| 847 | uint32_t unused; |
| 848 | }; |
| 849 | |
| 850 | struct VkDescriptorSetLayout_Info { |
| 851 | uint32_t unused; |
| 852 | }; |
| 853 | |
| 854 | struct VkCommandPool_Info { |
| 855 | uint32_t unused; |
| 856 | }; |
| 857 | |
| 858 | struct VkSampler_Info { |
| 859 | uint32_t unused; |
| 860 | }; |
| 861 | |
| 862 | struct VkBufferCollectionFUCHSIA_Info { |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 863 | #ifdef VK_USE_PLATFORM_FUCHSIA |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 864 | gfxstream::guest::Optional<fuchsia_sysmem::wire::BufferCollectionConstraints> constraints; |
| 865 | gfxstream::guest::Optional<VkBufferCollectionPropertiesFUCHSIA> properties; |
| 866 | |
| 867 | // the index of corresponding createInfo for each image format |
| 868 | // constraints in |constraints|. |
| 869 | std::vector<uint32_t> createInfoIndex; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 870 | #endif // VK_USE_PLATFORM_FUCHSIA |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 871 | }; |
| 872 | |
| 873 | VkDescriptorImageInfo filterNonexistentSampler(const VkDescriptorImageInfo& inputInfo); |
| 874 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 875 | void emitDeviceMemoryReport(VkDevice_Info info, VkDeviceMemoryReportEventTypeEXT type, |
| 876 | uint64_t memoryObjectId, VkDeviceSize size, VkObjectType objectType, |
| 877 | uint64_t objectHandle, uint32_t heapIndex = 0); |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 878 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 879 | void transformImageMemoryRequirementsForGuestLocked(VkImage image, VkMemoryRequirements* reqs); |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 880 | CoherentMemoryPtr freeCoherentMemoryLocked(VkDeviceMemory memory, VkDeviceMemory_Info& info); |
| 881 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 882 | mutable RecursiveLock mLock; |
| 883 | |
| 884 | std::optional<const VkPhysicalDeviceMemoryProperties> mCachedPhysicalDeviceMemoryProps; |
| 885 | std::unique_ptr<EmulatorFeatureInfo> mFeatureInfo; |
| 886 | #if defined(__ANDROID__) |
| 887 | std::unique_ptr<GoldfishAddressSpaceBlockProvider> mGoldfishAddressSpaceBlockProvider; |
| 888 | #endif // defined(__ANDROID__) |
| 889 | |
| 890 | struct VirtGpuCaps mCaps; |
| 891 | std::vector<VkExtensionProperties> mHostInstanceExtensions; |
| 892 | std::vector<VkExtensionProperties> mHostDeviceExtensions; |
| 893 | |
| 894 | // 32 bits only for now, upper bits may be used later. |
| 895 | std::atomic<uint32_t> mBlobId = 0; |
| 896 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(__linux__) |
| 897 | int mSyncDeviceFd = -1; |
| 898 | #endif |
| 899 | |
| 900 | #ifdef VK_USE_PLATFORM_FUCHSIA |
| 901 | fidl::WireSyncClient<fuchsia_hardware_goldfish::ControlDevice> mControlDevice; |
| 902 | fidl::WireSyncClient<fuchsia_sysmem::Allocator> mSysmemAllocator; |
| 903 | #endif |
| 904 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 905 | #define HANDLE_REGISTER_DECLARATION(type) std::unordered_map<type, type##_Info> info_##type; |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 906 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 907 | GOLDFISH_VK_LIST_HANDLE_TYPES(HANDLE_REGISTER_DECLARATION) |
Jason Macnak | eea882a | 2023-11-15 17:29:11 -0800 | [diff] [blame] | 908 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 909 | WorkPool mWorkPool{4}; |
| 910 | std::unordered_map<VkQueue, std::vector<WorkPool::WaitGroupHandle>> |
| 911 | mQueueSensitiveWorkPoolItems; |
| 912 | |
| 913 | std::unordered_map<const VkEncoder*, std::unordered_map<void*, CleanupCallback>> |
| 914 | mEncoderCleanupCallbacks; |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 915 | }; |
Lingfeng Yang | 71b596b | 2018-11-07 18:03:25 -0800 | [diff] [blame] | 916 | |
Jason Macnak | 3d66400 | 2023-03-30 16:00:50 -0700 | [diff] [blame] | 917 | } // namespace vk |
| 918 | } // namespace gfxstream |