Jesse Hall | d02edcb | 2015-09-08 07:44:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The Android Open Source Project |
| 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. |
| 15 | */ |
| 16 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 17 | #include <hardware/hwvulkan.h> |
| 18 | |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 19 | #include <array> |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 20 | #include <algorithm> |
Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 21 | #include <inttypes.h> |
| 22 | #include <string.h> |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 23 | |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 24 | // #define LOG_NDEBUG 0 |
| 25 | #include <log/log.h> |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 26 | #include <utils/Errors.h> |
| 27 | |
| 28 | #include "null_driver.h" |
| 29 | |
| 30 | using namespace null_driver; |
| 31 | |
| 32 | struct VkPhysicalDevice_T { |
| 33 | hwvulkan_dispatch_t dispatch; |
| 34 | }; |
| 35 | |
| 36 | struct VkInstance_T { |
| 37 | hwvulkan_dispatch_t dispatch; |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 38 | VkAllocCallbacks allocator; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 39 | VkPhysicalDevice_T physical_device; |
| 40 | }; |
| 41 | |
| 42 | struct VkQueue_T { |
| 43 | hwvulkan_dispatch_t dispatch; |
| 44 | }; |
| 45 | |
| 46 | struct VkCmdBuffer_T { |
| 47 | hwvulkan_dispatch_t dispatch; |
| 48 | }; |
| 49 | |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 50 | namespace { |
| 51 | // Handles for non-dispatchable objects are either pointers, or arbitrary |
| 52 | // 64-bit non-zero values. We only use pointers when we need to keep state for |
| 53 | // the object even in a null driver. For the rest, we form a handle as: |
| 54 | // [63:63] = 1 to distinguish from pointer handles* |
| 55 | // [62:56] = non-zero handle type enum value |
| 56 | // [55: 0] = per-handle-type incrementing counter |
| 57 | // * This works because virtual addresses with the high bit set are reserved |
| 58 | // for kernel data in all ABIs we run on. |
| 59 | // |
| 60 | // We never reclaim handles on vkDestroy*. It's not even necessary for us to |
| 61 | // have distinct handles for live objects, and practically speaking we won't |
| 62 | // ever create 2^56 objects of the same type from a single VkDevice in a null |
| 63 | // driver. |
| 64 | // |
| 65 | // Using a namespace here instead of 'enum class' since we want scoped |
| 66 | // constants but also want implicit conversions to integral types. |
| 67 | namespace HandleType { |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 68 | enum Enum { |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 69 | kBufferView, |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 70 | kDescriptorPool, |
| 71 | kDescriptorSet, |
| 72 | kDescriptorSetLayout, |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 73 | kEvent, |
| 74 | kFence, |
| 75 | kFramebuffer, |
| 76 | kImageView, |
| 77 | kPipeline, |
| 78 | kPipelineCache, |
| 79 | kPipelineLayout, |
| 80 | kQueryPool, |
| 81 | kRenderPass, |
| 82 | kSampler, |
| 83 | kSemaphore, |
| 84 | kShader, |
| 85 | kShaderModule, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 86 | |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 87 | kNumTypes |
| 88 | }; |
| 89 | } // namespace HandleType |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 90 | uint64_t AllocHandle(VkDevice device, HandleType::Enum type); |
Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 91 | |
| 92 | const VkDeviceSize kMaxDeviceMemory = VkDeviceSize(INTPTR_MAX) + 1; |
| 93 | |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 94 | } // anonymous namespace |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 95 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 96 | struct VkDevice_T { |
| 97 | hwvulkan_dispatch_t dispatch; |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 98 | VkAllocCallbacks allocator; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 99 | VkInstance_T* instance; |
| 100 | VkQueue_T queue; |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 101 | std::array<uint64_t, HandleType::kNumTypes> next_handle; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | // ----------------------------------------------------------------------------- |
| 105 | // Declare HAL_MODULE_INFO_SYM early so it can be referenced by nulldrv_device |
| 106 | // later. |
| 107 | |
| 108 | namespace { |
| 109 | int OpenDevice(const hw_module_t* module, const char* id, hw_device_t** device); |
| 110 | hw_module_methods_t nulldrv_module_methods = {.open = OpenDevice}; |
| 111 | } // namespace |
| 112 | |
| 113 | #pragma clang diagnostic push |
| 114 | #pragma clang diagnostic ignored "-Wmissing-variable-declarations" |
| 115 | __attribute__((visibility("default"))) hwvulkan_module_t HAL_MODULE_INFO_SYM = { |
| 116 | .common = |
| 117 | { |
Michael Lentine | 03c64b0 | 2015-08-26 18:27:26 -0500 | [diff] [blame] | 118 | .tag = HARDWARE_MODULE_TAG, |
| 119 | .module_api_version = HWVULKAN_MODULE_API_VERSION_0_1, |
| 120 | .hal_api_version = HARDWARE_HAL_API_VERSION, |
| 121 | .id = HWVULKAN_HARDWARE_MODULE_ID, |
| 122 | .name = "Null Vulkan Driver", |
| 123 | .author = "The Android Open Source Project", |
| 124 | .methods = &nulldrv_module_methods, |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 125 | }, |
| 126 | }; |
| 127 | #pragma clang diagnostic pop |
| 128 | |
| 129 | // ----------------------------------------------------------------------------- |
| 130 | |
| 131 | namespace { |
| 132 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 133 | VkResult CreateInstance(const VkInstanceCreateInfo* /*create_info*/, |
| 134 | const VkAllocCallbacks* allocator, |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 135 | VkInstance* out_instance) { |
Jesse Hall | b1352bc | 2015-09-04 16:12:33 -0700 | [diff] [blame] | 136 | // Assume the loader provided alloc callbacks even if the app didn't. |
| 137 | ALOG_ASSERT( |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 138 | allocator, |
Jesse Hall | b1352bc | 2015-09-04 16:12:33 -0700 | [diff] [blame] | 139 | "Missing alloc callbacks, loader or app should have provided them"); |
| 140 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 141 | VkInstance_T* instance = static_cast<VkInstance_T*>(allocator->pfnAlloc( |
| 142 | allocator->pUserData, sizeof(VkInstance_T), alignof(VkInstance_T), |
| 143 | VK_SYSTEM_ALLOC_SCOPE_INSTANCE)); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 144 | if (!instance) |
| 145 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 146 | |
| 147 | instance->dispatch.magic = HWVULKAN_DISPATCH_MAGIC; |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 148 | instance->allocator = *allocator; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 149 | instance->physical_device.dispatch.magic = HWVULKAN_DISPATCH_MAGIC; |
| 150 | |
| 151 | *out_instance = instance; |
| 152 | return VK_SUCCESS; |
| 153 | } |
| 154 | |
| 155 | int CloseDevice(struct hw_device_t* /*device*/) { |
| 156 | // nothing to do - opening a device doesn't allocate any resources |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | hwvulkan_device_t nulldrv_device = { |
| 161 | .common = |
| 162 | { |
Michael Lentine | 03c64b0 | 2015-08-26 18:27:26 -0500 | [diff] [blame] | 163 | .tag = HARDWARE_DEVICE_TAG, |
| 164 | .version = HWVULKAN_DEVICE_API_VERSION_0_1, |
| 165 | .module = &HAL_MODULE_INFO_SYM.common, |
| 166 | .close = CloseDevice, |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 167 | }, |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 168 | .EnumerateInstanceExtensionProperties = |
| 169 | EnumerateInstanceExtensionProperties, |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 170 | .CreateInstance = CreateInstance, |
| 171 | .GetInstanceProcAddr = GetInstanceProcAddr}; |
| 172 | |
| 173 | int OpenDevice(const hw_module_t* /*module*/, |
| 174 | const char* id, |
| 175 | hw_device_t** device) { |
| 176 | if (strcmp(id, HWVULKAN_DEVICE_0) == 0) { |
| 177 | *device = &nulldrv_device.common; |
| 178 | return 0; |
| 179 | } |
| 180 | return -ENOENT; |
| 181 | } |
| 182 | |
| 183 | VkInstance_T* GetInstanceFromPhysicalDevice( |
| 184 | VkPhysicalDevice_T* physical_device) { |
| 185 | return reinterpret_cast<VkInstance_T*>( |
| 186 | reinterpret_cast<uintptr_t>(physical_device) - |
| 187 | offsetof(VkInstance_T, physical_device)); |
| 188 | } |
| 189 | |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 190 | uint64_t AllocHandle(VkDevice device, HandleType::Enum type) { |
| 191 | const uint64_t kHandleMask = (UINT64_C(1) << 56) - 1; |
| 192 | ALOGE_IF(device->next_handle[type] == kHandleMask, |
Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 193 | "non-dispatchable handles of type=%u are about to overflow", type); |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 194 | return (UINT64_C(1) << 63) | ((uint64_t(type) & 0x7) << 56) | |
| 195 | (device->next_handle[type]++ & kHandleMask); |
| 196 | } |
| 197 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 198 | } // namespace |
| 199 | |
| 200 | namespace null_driver { |
| 201 | |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 202 | #define DEFINE_OBJECT_HANDLE_CONVERSION(T) \ |
| 203 | T* Get##T##FromHandle(Vk##T h); \ |
| 204 | T* Get##T##FromHandle(Vk##T h) { \ |
| 205 | return reinterpret_cast<T*>(uintptr_t(h)); \ |
| 206 | } \ |
| 207 | Vk##T GetHandleTo##T(const T* obj); \ |
| 208 | Vk##T GetHandleTo##T(const T* obj) { \ |
| 209 | return Vk##T(reinterpret_cast<uintptr_t>(obj)); \ |
| 210 | } |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 211 | |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 212 | // ----------------------------------------------------------------------------- |
| 213 | // Global |
| 214 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 215 | VkResult EnumerateInstanceExtensionProperties(const char*, |
| 216 | uint32_t* count, |
| 217 | VkExtensionProperties*) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 218 | *count = 0; |
| 219 | return VK_SUCCESS; |
| 220 | } |
| 221 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 222 | PFN_vkVoidFunction GetInstanceProcAddr(VkInstance, const char* name) { |
| 223 | PFN_vkVoidFunction proc = LookupInstanceProcAddr(name); |
| 224 | if (!proc && strcmp(name, "vkGetDeviceProcAddr") == 0) |
| 225 | proc = reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr); |
| 226 | return proc; |
| 227 | } |
| 228 | |
| 229 | PFN_vkVoidFunction GetDeviceProcAddr(VkDevice, const char* name) { |
Jesse Hall | b1352bc | 2015-09-04 16:12:33 -0700 | [diff] [blame] | 230 | PFN_vkVoidFunction proc = LookupDeviceProcAddr(name); |
| 231 | if (proc) |
| 232 | return proc; |
Jesse Hall | 70f9335 | 2015-11-04 09:41:31 -0800 | [diff] [blame] | 233 | if (strcmp(name, "vkGetSwapchainGrallocUsageANDROID") == 0) |
| 234 | return reinterpret_cast<PFN_vkVoidFunction>( |
| 235 | GetSwapchainGrallocUsageANDROID); |
Jesse Hall | ab9aeef | 2015-11-04 10:56:20 -0800 | [diff] [blame] | 236 | if (strcmp(name, "vkAcquireImageANDROID") == 0) |
| 237 | return reinterpret_cast<PFN_vkVoidFunction>(AcquireImageANDROID); |
| 238 | if (strcmp(name, "vkQueueSignalReleaseImageANDROID") == 0) |
Jesse Hall | b1352bc | 2015-09-04 16:12:33 -0700 | [diff] [blame] | 239 | return reinterpret_cast<PFN_vkVoidFunction>( |
Jesse Hall | ab9aeef | 2015-11-04 10:56:20 -0800 | [diff] [blame] | 240 | QueueSignalReleaseImageANDROID); |
Jesse Hall | b1352bc | 2015-09-04 16:12:33 -0700 | [diff] [blame] | 241 | return nullptr; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 244 | // ----------------------------------------------------------------------------- |
| 245 | // Instance |
| 246 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 247 | void DestroyInstance(VkInstance instance, |
| 248 | const VkAllocCallbacks* /*allocator*/) { |
| 249 | instance->allocator.pfnFree(instance->allocator.pUserData, instance); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 250 | } |
| 251 | |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 252 | // ----------------------------------------------------------------------------- |
| 253 | // PhysicalDevice |
| 254 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 255 | VkResult EnumeratePhysicalDevices(VkInstance instance, |
| 256 | uint32_t* physical_device_count, |
| 257 | VkPhysicalDevice* physical_devices) { |
| 258 | if (physical_devices && *physical_device_count >= 1) |
| 259 | physical_devices[0] = &instance->physical_device; |
| 260 | *physical_device_count = 1; |
| 261 | return VK_SUCCESS; |
| 262 | } |
| 263 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 264 | void GetPhysicalDeviceProperties(VkPhysicalDevice, |
| 265 | VkPhysicalDeviceProperties* properties) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 266 | properties->apiVersion = VK_API_VERSION; |
| 267 | properties->driverVersion = VK_MAKE_VERSION(0, 0, 1); |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 268 | properties->vendorId = 0; |
| 269 | properties->deviceId = 0; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 270 | properties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER; |
| 271 | strcpy(properties->deviceName, "Android Vulkan Null Driver"); |
| 272 | memset(properties->pipelineCacheUUID, 0, |
| 273 | sizeof(properties->pipelineCacheUUID)); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 276 | void GetPhysicalDeviceQueueFamilyProperties( |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 277 | VkPhysicalDevice, |
| 278 | uint32_t* count, |
| 279 | VkQueueFamilyProperties* properties) { |
| 280 | if (properties) { |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 281 | properties->queueFlags = |
| 282 | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_DMA_BIT; |
| 283 | properties->queueCount = 1; |
Jesse Hall | acfa534 | 2015-11-19 21:51:33 -0800 | [diff] [blame] | 284 | properties->timestampValidBits = 64; |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 285 | } |
| 286 | *count = 1; |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 289 | void GetPhysicalDeviceMemoryProperties( |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 290 | VkPhysicalDevice, |
| 291 | VkPhysicalDeviceMemoryProperties* properties) { |
| 292 | properties->memoryTypeCount = 1; |
| 293 | properties->memoryTypes[0].propertyFlags = |
| 294 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 295 | properties->memoryTypes[0].heapIndex = 0; |
| 296 | properties->memoryHeapCount = 1; |
Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 297 | properties->memoryHeaps[0].size = kMaxDeviceMemory; |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 298 | properties->memoryHeaps[0].flags = VK_MEMORY_HEAP_HOST_LOCAL_BIT; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 301 | // ----------------------------------------------------------------------------- |
| 302 | // Device |
| 303 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 304 | VkResult CreateDevice(VkPhysicalDevice physical_device, |
| 305 | const VkDeviceCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 306 | const VkAllocCallbacks* allocator, |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 307 | VkDevice* out_device) { |
| 308 | VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device); |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 309 | if (!allocator) |
| 310 | allocator = &instance->allocator; |
| 311 | VkDevice_T* device = static_cast<VkDevice_T*>( |
| 312 | allocator->pfnAlloc(allocator->pUserData, sizeof(VkDevice_T), |
| 313 | alignof(VkDevice_T), VK_SYSTEM_ALLOC_SCOPE_DEVICE)); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 314 | if (!device) |
| 315 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 316 | |
| 317 | device->dispatch.magic = HWVULKAN_DISPATCH_MAGIC; |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 318 | device->allocator = *allocator; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 319 | device->instance = instance; |
| 320 | device->queue.dispatch.magic = HWVULKAN_DISPATCH_MAGIC; |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 321 | std::fill(device->next_handle.begin(), device->next_handle.end(), |
| 322 | UINT64_C(0)); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 323 | |
| 324 | *out_device = device; |
| 325 | return VK_SUCCESS; |
| 326 | } |
| 327 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 328 | void DestroyDevice(VkDevice device, const VkAllocCallbacks* /*allocator*/) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 329 | if (!device) |
Jesse Hall | cf25c41 | 2015-10-29 17:14:50 -0700 | [diff] [blame] | 330 | return; |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 331 | device->allocator.pfnFree(device->allocator.pUserData, device); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 334 | void GetDeviceQueue(VkDevice device, uint32_t, uint32_t, VkQueue* queue) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 335 | *queue = &device->queue; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | // ----------------------------------------------------------------------------- |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 339 | // CmdPool |
| 340 | |
| 341 | struct CmdPool { |
| 342 | typedef VkCmdPool HandleType; |
| 343 | VkAllocCallbacks allocator; |
| 344 | }; |
| 345 | DEFINE_OBJECT_HANDLE_CONVERSION(CmdPool) |
| 346 | |
| 347 | VkResult CreateCommandPool(VkDevice device, |
| 348 | const VkCmdPoolCreateInfo* /*create_info*/, |
| 349 | const VkAllocCallbacks* allocator, |
| 350 | VkCmdPool* cmd_pool) { |
| 351 | if (!allocator) |
| 352 | allocator = &device->allocator; |
| 353 | CmdPool* pool = static_cast<CmdPool*>( |
| 354 | allocator->pfnAlloc(allocator->pUserData, sizeof(CmdPool), |
| 355 | alignof(CmdPool), VK_SYSTEM_ALLOC_SCOPE_OBJECT)); |
| 356 | if (!pool) |
| 357 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 358 | pool->allocator = *allocator; |
| 359 | *cmd_pool = GetHandleToCmdPool(pool); |
| 360 | return VK_SUCCESS; |
| 361 | } |
| 362 | |
| 363 | void DestroyCommandPool(VkDevice /*device*/, |
| 364 | VkCmdPool cmd_pool, |
| 365 | const VkAllocCallbacks* /*allocator*/) { |
| 366 | CmdPool* pool = GetCmdPoolFromHandle(cmd_pool); |
| 367 | pool->allocator.pfnFree(pool->allocator.pUserData, pool); |
| 368 | } |
| 369 | |
| 370 | // ----------------------------------------------------------------------------- |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 371 | // CmdBuffer |
| 372 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 373 | VkResult AllocCommandBuffers(VkDevice /*device*/, |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 374 | const VkCmdBufferAllocInfo* alloc_info, |
| 375 | VkCmdBuffer* cmdbufs) { |
| 376 | VkResult result = VK_SUCCESS; |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 377 | CmdPool& pool = *GetCmdPoolFromHandle(alloc_info->cmdPool); |
| 378 | std::fill(cmdbufs, cmdbufs + alloc_info->bufferCount, nullptr); |
| 379 | for (uint32_t i = 0; i < alloc_info->bufferCount; i++) { |
| 380 | cmdbufs[i] = static_cast<VkCmdBuffer_T*>(pool.allocator.pfnAlloc( |
| 381 | pool.allocator.pUserData, sizeof(VkCmdBuffer_T), |
| 382 | alignof(VkCmdBuffer_T), VK_SYSTEM_ALLOC_SCOPE_OBJECT)); |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 383 | if (!cmdbufs[i]) { |
| 384 | result = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 385 | break; |
| 386 | } |
| 387 | cmdbufs[i]->dispatch.magic = HWVULKAN_DISPATCH_MAGIC; |
| 388 | } |
| 389 | if (result != VK_SUCCESS) { |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 390 | for (uint32_t i = 0; i < alloc_info->bufferCount; i++) { |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 391 | if (!cmdbufs[i]) |
| 392 | break; |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 393 | pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]); |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 394 | } |
| 395 | } |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 396 | return result; |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 399 | void FreeCommandBuffers(VkDevice /*device*/, |
| 400 | VkCmdPool cmd_pool, |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 401 | uint32_t count, |
| 402 | const VkCmdBuffer* cmdbufs) { |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 403 | CmdPool& pool = *GetCmdPoolFromHandle(cmd_pool); |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 404 | for (uint32_t i = 0; i < count; i++) |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 405 | pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]); |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | // ----------------------------------------------------------------------------- |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 409 | // DeviceMemory |
| 410 | |
| 411 | struct DeviceMemory { |
| 412 | typedef VkDeviceMemory HandleType; |
| 413 | VkDeviceSize size; |
| 414 | alignas(16) uint8_t data[0]; |
| 415 | }; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 416 | DEFINE_OBJECT_HANDLE_CONVERSION(DeviceMemory) |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 417 | |
| 418 | VkResult AllocMemory(VkDevice device, |
| 419 | const VkMemoryAllocInfo* alloc_info, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 420 | const VkAllocCallbacks* allocator, |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 421 | VkDeviceMemory* mem_handle) { |
| 422 | if (SIZE_MAX - sizeof(DeviceMemory) <= alloc_info->allocationSize) |
| 423 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 424 | if (!allocator) |
| 425 | allocator = &device->allocator; |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 426 | |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 427 | size_t size = sizeof(DeviceMemory) + size_t(alloc_info->allocationSize); |
| 428 | DeviceMemory* mem = static_cast<DeviceMemory*>( |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 429 | allocator->pfnAlloc(allocator->pUserData, size, alignof(DeviceMemory), |
| 430 | VK_SYSTEM_ALLOC_SCOPE_OBJECT)); |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 431 | if (!mem) |
| 432 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 433 | mem->size = size; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 434 | *mem_handle = GetHandleToDeviceMemory(mem); |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 435 | return VK_SUCCESS; |
| 436 | } |
| 437 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 438 | void FreeMemory(VkDevice device, |
| 439 | VkDeviceMemory mem_handle, |
| 440 | const VkAllocCallbacks* allocator) { |
| 441 | if (!allocator) |
| 442 | allocator = &device->allocator; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 443 | DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle); |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 444 | allocator->pfnFree(allocator->pUserData, mem); |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | VkResult MapMemory(VkDevice, |
| 448 | VkDeviceMemory mem_handle, |
| 449 | VkDeviceSize offset, |
| 450 | VkDeviceSize, |
| 451 | VkMemoryMapFlags, |
| 452 | void** out_ptr) { |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 453 | DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle); |
Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 454 | *out_ptr = &mem->data[0] + offset; |
| 455 | return VK_SUCCESS; |
| 456 | } |
| 457 | |
| 458 | // ----------------------------------------------------------------------------- |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 459 | // Buffer |
| 460 | |
| 461 | struct Buffer { |
| 462 | typedef VkBuffer HandleType; |
| 463 | VkDeviceSize size; |
| 464 | }; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 465 | DEFINE_OBJECT_HANDLE_CONVERSION(Buffer) |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 466 | |
| 467 | VkResult CreateBuffer(VkDevice device, |
| 468 | const VkBufferCreateInfo* create_info, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 469 | const VkAllocCallbacks* allocator, |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 470 | VkBuffer* buffer_handle) { |
Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 471 | ALOGW_IF(create_info->size > kMaxDeviceMemory, |
| 472 | "CreateBuffer: requested size 0x%" PRIx64 |
| 473 | " exceeds max device memory size 0x%" PRIx64, |
| 474 | create_info->size, kMaxDeviceMemory); |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 475 | if (!allocator) |
| 476 | allocator = &device->allocator; |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 477 | Buffer* buffer = static_cast<Buffer*>( |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 478 | allocator->pfnAlloc(allocator->pUserData, sizeof(Buffer), |
| 479 | alignof(Buffer), VK_SYSTEM_ALLOC_SCOPE_OBJECT)); |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 480 | if (!buffer) |
| 481 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 482 | buffer->size = create_info->size; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 483 | *buffer_handle = GetHandleToBuffer(buffer); |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 484 | return VK_SUCCESS; |
| 485 | } |
| 486 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 487 | void GetBufferMemoryRequirements(VkDevice, |
| 488 | VkBuffer buffer_handle, |
| 489 | VkMemoryRequirements* requirements) { |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 490 | Buffer* buffer = GetBufferFromHandle(buffer_handle); |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 491 | requirements->size = buffer->size; |
| 492 | requirements->alignment = 16; // allow fast Neon/SSE memcpy |
| 493 | requirements->memoryTypeBits = 0x1; |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 494 | } |
| 495 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 496 | void DestroyBuffer(VkDevice device, |
| 497 | VkBuffer buffer_handle, |
| 498 | const VkAllocCallbacks* allocator) { |
| 499 | if (!allocator) |
| 500 | allocator = &device->allocator; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 501 | Buffer* buffer = GetBufferFromHandle(buffer_handle); |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 502 | allocator->pfnFree(allocator->pUserData, buffer); |
Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | // ----------------------------------------------------------------------------- |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 506 | // Image |
| 507 | |
| 508 | struct Image { |
| 509 | typedef VkImage HandleType; |
| 510 | VkDeviceSize size; |
| 511 | }; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 512 | DEFINE_OBJECT_HANDLE_CONVERSION(Image) |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 513 | |
| 514 | VkResult CreateImage(VkDevice device, |
| 515 | const VkImageCreateInfo* create_info, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 516 | const VkAllocCallbacks* allocator, |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 517 | VkImage* image_handle) { |
| 518 | if (create_info->imageType != VK_IMAGE_TYPE_2D || |
| 519 | create_info->format != VK_FORMAT_R8G8B8A8_UNORM || |
| 520 | create_info->mipLevels != 1) { |
| 521 | ALOGE("CreateImage: not yet implemented: type=%d format=%d mips=%u", |
| 522 | create_info->imageType, create_info->format, |
| 523 | create_info->mipLevels); |
Jesse Hall | a15a4bf | 2015-11-19 22:48:02 -0800 | [diff] [blame] | 524 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | VkDeviceSize size = |
| 528 | VkDeviceSize(create_info->extent.width * create_info->extent.height) * |
Jesse Hall | a15a4bf | 2015-11-19 22:48:02 -0800 | [diff] [blame] | 529 | create_info->arrayLayers * create_info->samples * 4u; |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 530 | ALOGW_IF(size > kMaxDeviceMemory, |
| 531 | "CreateImage: image size 0x%" PRIx64 |
| 532 | " exceeds max device memory size 0x%" PRIx64, |
| 533 | size, kMaxDeviceMemory); |
| 534 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 535 | if (!allocator) |
| 536 | allocator = &device->allocator; |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 537 | Image* image = static_cast<Image*>( |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 538 | allocator->pfnAlloc(allocator->pUserData, sizeof(Image), alignof(Image), |
| 539 | VK_SYSTEM_ALLOC_SCOPE_OBJECT)); |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 540 | if (!image) |
| 541 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 542 | image->size = size; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 543 | *image_handle = GetHandleToImage(image); |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 544 | return VK_SUCCESS; |
| 545 | } |
| 546 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 547 | void GetImageMemoryRequirements(VkDevice, |
| 548 | VkImage image_handle, |
| 549 | VkMemoryRequirements* requirements) { |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 550 | Image* image = GetImageFromHandle(image_handle); |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 551 | requirements->size = image->size; |
| 552 | requirements->alignment = 16; // allow fast Neon/SSE memcpy |
| 553 | requirements->memoryTypeBits = 0x1; |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 554 | } |
| 555 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 556 | void DestroyImage(VkDevice device, |
| 557 | VkImage image_handle, |
| 558 | const VkAllocCallbacks* allocator) { |
| 559 | if (!allocator) |
| 560 | allocator = &device->allocator; |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 561 | Image* image = GetImageFromHandle(image_handle); |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 562 | allocator->pfnFree(allocator->pUserData, image); |
Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | // ----------------------------------------------------------------------------- |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 566 | // No-op types |
| 567 | |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 568 | VkResult CreateBufferView(VkDevice device, |
| 569 | const VkBufferViewCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 570 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 571 | VkBufferView* view) { |
| 572 | *view = AllocHandle(device, HandleType::kBufferView); |
| 573 | return VK_SUCCESS; |
| 574 | } |
| 575 | |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 576 | VkResult CreateDescriptorPool(VkDevice device, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 577 | const VkDescriptorPoolCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 578 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 579 | VkDescriptorPool* pool) { |
| 580 | *pool = AllocHandle(device, HandleType::kDescriptorPool); |
| 581 | return VK_SUCCESS; |
| 582 | } |
| 583 | |
| 584 | VkResult AllocDescriptorSets(VkDevice device, |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 585 | const VkDescriptorSetAllocInfo* alloc_info, |
| 586 | VkDescriptorSet* descriptor_sets) { |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 587 | for (uint32_t i = 0; i < alloc_info->setLayoutCount; i++) |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 588 | descriptor_sets[i] = AllocHandle(device, HandleType::kDescriptorSet); |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 589 | return VK_SUCCESS; |
| 590 | } |
| 591 | |
| 592 | VkResult CreateDescriptorSetLayout(VkDevice device, |
| 593 | const VkDescriptorSetLayoutCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 594 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 595 | VkDescriptorSetLayout* layout) { |
| 596 | *layout = AllocHandle(device, HandleType::kDescriptorSetLayout); |
| 597 | return VK_SUCCESS; |
| 598 | } |
| 599 | |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 600 | VkResult CreateEvent(VkDevice device, |
| 601 | const VkEventCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 602 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 603 | VkEvent* event) { |
| 604 | *event = AllocHandle(device, HandleType::kEvent); |
| 605 | return VK_SUCCESS; |
| 606 | } |
| 607 | |
| 608 | VkResult CreateFence(VkDevice device, |
| 609 | const VkFenceCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 610 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 611 | VkFence* fence) { |
| 612 | *fence = AllocHandle(device, HandleType::kFence); |
| 613 | return VK_SUCCESS; |
| 614 | } |
| 615 | |
| 616 | VkResult CreateFramebuffer(VkDevice device, |
| 617 | const VkFramebufferCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 618 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 619 | VkFramebuffer* framebuffer) { |
| 620 | *framebuffer = AllocHandle(device, HandleType::kFramebuffer); |
| 621 | return VK_SUCCESS; |
| 622 | } |
| 623 | |
| 624 | VkResult CreateImageView(VkDevice device, |
| 625 | const VkImageViewCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 626 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 627 | VkImageView* view) { |
| 628 | *view = AllocHandle(device, HandleType::kImageView); |
| 629 | return VK_SUCCESS; |
| 630 | } |
| 631 | |
| 632 | VkResult CreateGraphicsPipelines(VkDevice device, |
| 633 | VkPipelineCache, |
| 634 | uint32_t count, |
| 635 | const VkGraphicsPipelineCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 636 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 637 | VkPipeline* pipelines) { |
| 638 | for (uint32_t i = 0; i < count; i++) |
| 639 | pipelines[i] = AllocHandle(device, HandleType::kPipeline); |
| 640 | return VK_SUCCESS; |
| 641 | } |
| 642 | |
| 643 | VkResult CreateComputePipelines(VkDevice device, |
| 644 | VkPipelineCache, |
| 645 | uint32_t count, |
| 646 | const VkComputePipelineCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 647 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 648 | VkPipeline* pipelines) { |
| 649 | for (uint32_t i = 0; i < count; i++) |
| 650 | pipelines[i] = AllocHandle(device, HandleType::kPipeline); |
| 651 | return VK_SUCCESS; |
| 652 | } |
| 653 | |
| 654 | VkResult CreatePipelineCache(VkDevice device, |
| 655 | const VkPipelineCacheCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 656 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 657 | VkPipelineCache* cache) { |
| 658 | *cache = AllocHandle(device, HandleType::kPipelineCache); |
| 659 | return VK_SUCCESS; |
| 660 | } |
| 661 | |
| 662 | VkResult CreatePipelineLayout(VkDevice device, |
| 663 | const VkPipelineLayoutCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 664 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 665 | VkPipelineLayout* layout) { |
| 666 | *layout = AllocHandle(device, HandleType::kPipelineLayout); |
| 667 | return VK_SUCCESS; |
| 668 | } |
| 669 | |
| 670 | VkResult CreateQueryPool(VkDevice device, |
| 671 | const VkQueryPoolCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 672 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 673 | VkQueryPool* pool) { |
| 674 | *pool = AllocHandle(device, HandleType::kQueryPool); |
| 675 | return VK_SUCCESS; |
| 676 | } |
| 677 | |
| 678 | VkResult CreateRenderPass(VkDevice device, |
| 679 | const VkRenderPassCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 680 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 681 | VkRenderPass* renderpass) { |
| 682 | *renderpass = AllocHandle(device, HandleType::kRenderPass); |
| 683 | return VK_SUCCESS; |
| 684 | } |
| 685 | |
| 686 | VkResult CreateSampler(VkDevice device, |
| 687 | const VkSamplerCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 688 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 689 | VkSampler* sampler) { |
| 690 | *sampler = AllocHandle(device, HandleType::kSampler); |
| 691 | return VK_SUCCESS; |
| 692 | } |
| 693 | |
| 694 | VkResult CreateSemaphore(VkDevice device, |
| 695 | const VkSemaphoreCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 696 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 697 | VkSemaphore* semaphore) { |
| 698 | *semaphore = AllocHandle(device, HandleType::kSemaphore); |
| 699 | return VK_SUCCESS; |
| 700 | } |
| 701 | |
| 702 | VkResult CreateShader(VkDevice device, |
| 703 | const VkShaderCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 704 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 705 | VkShader* shader) { |
| 706 | *shader = AllocHandle(device, HandleType::kShader); |
| 707 | return VK_SUCCESS; |
| 708 | } |
| 709 | |
| 710 | VkResult CreateShaderModule(VkDevice device, |
| 711 | const VkShaderModuleCreateInfo*, |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 712 | const VkAllocCallbacks* /*allocator*/, |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 713 | VkShaderModule* module) { |
| 714 | *module = AllocHandle(device, HandleType::kShaderModule); |
| 715 | return VK_SUCCESS; |
| 716 | } |
| 717 | |
Jesse Hall | 70f9335 | 2015-11-04 09:41:31 -0800 | [diff] [blame] | 718 | VkResult GetSwapchainGrallocUsageANDROID(VkDevice, |
| 719 | VkFormat, |
| 720 | VkImageUsageFlags, |
| 721 | int* grallocUsage) { |
| 722 | // The null driver never reads or writes the gralloc buffer |
| 723 | *grallocUsage = 0; |
| 724 | return VK_SUCCESS; |
| 725 | } |
| 726 | |
Jesse Hall | ab9aeef | 2015-11-04 10:56:20 -0800 | [diff] [blame] | 727 | VkResult AcquireImageANDROID(VkDevice, VkImage, int fence, VkSemaphore) { |
Jesse Hall | d7b994a | 2015-09-07 14:17:37 -0700 | [diff] [blame] | 728 | close(fence); |
| 729 | return VK_SUCCESS; |
| 730 | } |
| 731 | |
Jesse Hall | ab9aeef | 2015-11-04 10:56:20 -0800 | [diff] [blame] | 732 | VkResult QueueSignalReleaseImageANDROID(VkQueue, VkImage, int* fence) { |
Jesse Hall | d7b994a | 2015-09-07 14:17:37 -0700 | [diff] [blame] | 733 | *fence = -1; |
| 734 | return VK_SUCCESS; |
| 735 | } |
| 736 | |
Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 737 | // ----------------------------------------------------------------------------- |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 738 | // No-op entrypoints |
| 739 | |
| 740 | // clang-format off |
| 741 | #pragma clang diagnostic push |
| 742 | #pragma clang diagnostic ignored "-Wunused-parameter" |
| 743 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 744 | void GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 745 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 746 | } |
| 747 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 748 | void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 749 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 750 | } |
| 751 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 752 | void GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 753 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 754 | } |
| 755 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 756 | VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 757 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 758 | return VK_SUCCESS; |
| 759 | } |
| 760 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 761 | VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t* pCount, VkLayerProperties* pProperties) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 762 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 763 | return VK_SUCCESS; |
| 764 | } |
| 765 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 766 | VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 767 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 768 | return VK_SUCCESS; |
| 769 | } |
| 770 | |
Jesse Hall | a366a51 | 2015-11-19 22:30:07 -0800 | [diff] [blame] | 771 | VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 772 | return VK_SUCCESS; |
| 773 | } |
| 774 | |
| 775 | VkResult QueueWaitIdle(VkQueue queue) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 776 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 777 | return VK_SUCCESS; |
| 778 | } |
| 779 | |
| 780 | VkResult DeviceWaitIdle(VkDevice device) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 781 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 782 | return VK_SUCCESS; |
| 783 | } |
| 784 | |
Jesse Hall | cf25c41 | 2015-10-29 17:14:50 -0700 | [diff] [blame] | 785 | void UnmapMemory(VkDevice device, VkDeviceMemory mem) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 789 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 790 | return VK_SUCCESS; |
| 791 | } |
| 792 | |
| 793 | VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 794 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 795 | return VK_SUCCESS; |
| 796 | } |
| 797 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 798 | void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 799 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 800 | } |
| 801 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 802 | VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) { |
| 803 | return VK_SUCCESS; |
| 804 | } |
| 805 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 806 | VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) { |
| 807 | return VK_SUCCESS; |
| 808 | } |
| 809 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 810 | void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 811 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 812 | } |
| 813 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 814 | void GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, uint32_t samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pNumProperties, VkSparseImageFormatProperties* pProperties) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 815 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | VkResult QueueBindSparseBufferMemory(VkQueue queue, VkBuffer buffer, uint32_t numBindings, const VkSparseMemoryBindInfo* pBindInfo) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 819 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 820 | return VK_SUCCESS; |
| 821 | } |
| 822 | |
| 823 | VkResult QueueBindSparseImageOpaqueMemory(VkQueue queue, VkImage image, uint32_t numBindings, const VkSparseMemoryBindInfo* pBindInfo) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 824 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 825 | return VK_SUCCESS; |
| 826 | } |
| 827 | |
| 828 | VkResult QueueBindSparseImageMemory(VkQueue queue, VkImage image, uint32_t numBindings, const VkSparseImageMemoryBindInfo* pBindInfo) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 829 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 830 | return VK_SUCCESS; |
| 831 | } |
| 832 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 833 | void DestroyFence(VkDevice device, VkFence fence, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) { |
| 837 | return VK_SUCCESS; |
| 838 | } |
| 839 | |
| 840 | VkResult GetFenceStatus(VkDevice device, VkFence fence) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 841 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 842 | return VK_SUCCESS; |
| 843 | } |
| 844 | |
| 845 | VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) { |
| 846 | return VK_SUCCESS; |
| 847 | } |
| 848 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 849 | void DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 850 | } |
| 851 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 852 | void DestroyEvent(VkDevice device, VkEvent event, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | VkResult GetEventStatus(VkDevice device, VkEvent event) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 856 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 857 | return VK_SUCCESS; |
| 858 | } |
| 859 | |
| 860 | VkResult SetEvent(VkDevice device, VkEvent event) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 861 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 862 | return VK_SUCCESS; |
| 863 | } |
| 864 | |
| 865 | VkResult ResetEvent(VkDevice device, VkEvent event) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 866 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 867 | return VK_SUCCESS; |
| 868 | } |
| 869 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 870 | void DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 871 | } |
| 872 | |
Jesse Hall | a9bb62b | 2015-11-21 19:31:56 -0800 | [diff] [blame] | 873 | VkResult GetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 874 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 875 | return VK_SUCCESS; |
| 876 | } |
| 877 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 878 | void DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 879 | } |
| 880 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 881 | void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 882 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 883 | } |
| 884 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 885 | void DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 886 | } |
| 887 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 888 | void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 889 | } |
| 890 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 891 | void DestroyShader(VkDevice device, VkShader shader, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 892 | } |
| 893 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 894 | void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 895 | } |
| 896 | |
Jesse Hall | a9bb62b | 2015-11-21 19:31:56 -0800 | [diff] [blame] | 897 | VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 898 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 899 | return VK_SUCCESS; |
| 900 | } |
| 901 | |
| 902 | VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 903 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 904 | return VK_SUCCESS; |
| 905 | } |
| 906 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 907 | void DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 908 | } |
| 909 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 910 | void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 911 | } |
| 912 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 913 | void DestroySampler(VkDevice device, VkSampler sampler, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 914 | } |
| 915 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 916 | void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 917 | } |
| 918 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 919 | void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 920 | } |
| 921 | |
Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 922 | VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 923 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 924 | return VK_SUCCESS; |
| 925 | } |
| 926 | |
Jesse Hall | cf25c41 | 2015-10-29 17:14:50 -0700 | [diff] [blame] | 927 | void UpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 928 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 932 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 933 | return VK_SUCCESS; |
| 934 | } |
| 935 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 936 | void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 937 | } |
| 938 | |
Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 939 | void DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocCallbacks* allocator) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 940 | } |
| 941 | |
Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 942 | void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 943 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 944 | } |
| 945 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 946 | VkResult ResetCommandPool(VkDevice device, VkCmdPool cmdPool, VkCmdPoolResetFlags flags) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 947 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 948 | return VK_SUCCESS; |
| 949 | } |
| 950 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 951 | VkResult BeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo) { |
| 952 | return VK_SUCCESS; |
| 953 | } |
| 954 | |
| 955 | VkResult EndCommandBuffer(VkCmdBuffer cmdBuffer) { |
| 956 | return VK_SUCCESS; |
| 957 | } |
| 958 | |
| 959 | VkResult ResetCommandBuffer(VkCmdBuffer cmdBuffer, VkCmdBufferResetFlags flags) { |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 960 | ALOGV("TODO: vk%s", __FUNCTION__); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 961 | return VK_SUCCESS; |
| 962 | } |
| 963 | |
| 964 | void CmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) { |
| 965 | } |
| 966 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 967 | void CmdSetViewport(VkCmdBuffer cmdBuffer, uint32_t viewportCount, const VkViewport* pViewports) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 968 | } |
| 969 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 970 | void CmdSetScissor(VkCmdBuffer cmdBuffer, uint32_t scissorCount, const VkRect2D* pScissors) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 971 | } |
| 972 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 973 | void CmdSetLineWidth(VkCmdBuffer cmdBuffer, float lineWidth) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 974 | } |
| 975 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 976 | void CmdSetDepthBias(VkCmdBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) { |
| 977 | } |
| 978 | |
| 979 | void CmdSetBlendConstants(VkCmdBuffer cmdBuffer, const float blendConst[4]) { |
| 980 | } |
| 981 | |
| 982 | void CmdSetDepthBounds(VkCmdBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) { |
| 983 | } |
| 984 | |
| 985 | void CmdSetStencilCompareMask(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) { |
| 986 | } |
| 987 | |
| 988 | void CmdSetStencilWriteMask(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) { |
| 989 | } |
| 990 | |
| 991 | void CmdSetStencilReference(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 992 | } |
| 993 | |
| 994 | void CmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets) { |
| 995 | } |
| 996 | |
| 997 | void CmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) { |
| 998 | } |
| 999 | |
| 1000 | void CmdBindVertexBuffers(VkCmdBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) { |
| 1001 | } |
| 1002 | |
Jesse Hall | cf25c41 | 2015-10-29 17:14:50 -0700 | [diff] [blame] | 1003 | void CmdDraw(VkCmdBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1004 | } |
| 1005 | |
Jesse Hall | cf25c41 | 2015-10-29 17:14:50 -0700 | [diff] [blame] | 1006 | void CmdDrawIndexed(VkCmdBuffer cmdBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | void CmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) { |
| 1010 | } |
| 1011 | |
| 1012 | void CmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) { |
| 1013 | } |
| 1014 | |
| 1015 | void CmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) { |
| 1016 | } |
| 1017 | |
| 1018 | void CmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) { |
| 1019 | } |
| 1020 | |
| 1021 | void CmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) { |
| 1022 | } |
| 1023 | |
| 1024 | void CmdCopyImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) { |
| 1025 | } |
| 1026 | |
Jesse Hall | 23ff73f | 2015-11-29 14:36:39 -0800 | [diff] [blame^] | 1027 | void CmdBlitImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | void CmdCopyBufferToImage(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) { |
| 1031 | } |
| 1032 | |
| 1033 | void CmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) { |
| 1034 | } |
| 1035 | |
| 1036 | void CmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) { |
| 1037 | } |
| 1038 | |
| 1039 | void CmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) { |
| 1040 | } |
| 1041 | |
| 1042 | void CmdClearColorImage(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) { |
| 1043 | } |
| 1044 | |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 1045 | void CmdClearDepthStencilImage(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
Jesse Hall | a15a4bf | 2015-11-19 22:48:02 -0800 | [diff] [blame] | 1048 | void CmdClearAttachments(VkCmdBuffer cmdBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | void CmdResolveImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) { |
| 1052 | } |
| 1053 | |
| 1054 | void CmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) { |
| 1055 | } |
| 1056 | |
| 1057 | void CmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) { |
| 1058 | } |
| 1059 | |
| 1060 | void CmdWaitEvents(VkCmdBuffer cmdBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, uint32_t memBarrierCount, const void* const* ppMemBarriers) { |
| 1061 | } |
| 1062 | |
| 1063 | void CmdPipelineBarrier(VkCmdBuffer cmdBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, VkBool32 byRegion, uint32_t memBarrierCount, const void* const* ppMemBarriers) { |
| 1064 | } |
| 1065 | |
| 1066 | void CmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) { |
| 1067 | } |
| 1068 | |
| 1069 | void CmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) { |
| 1070 | } |
| 1071 | |
| 1072 | void CmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) { |
| 1073 | } |
| 1074 | |
Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 1075 | void CmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1076 | } |
| 1077 | |
| 1078 | void CmdCopyQueryPoolResults(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkQueryResultFlags flags) { |
| 1079 | } |
| 1080 | |
| 1081 | void CmdPushConstants(VkCmdBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) { |
| 1082 | } |
| 1083 | |
| 1084 | void CmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkRenderPassContents contents) { |
| 1085 | } |
| 1086 | |
| 1087 | void CmdNextSubpass(VkCmdBuffer cmdBuffer, VkRenderPassContents contents) { |
| 1088 | } |
| 1089 | |
| 1090 | void CmdEndRenderPass(VkCmdBuffer cmdBuffer) { |
| 1091 | } |
| 1092 | |
| 1093 | void CmdExecuteCommands(VkCmdBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCmdBuffer* pCmdBuffers) { |
| 1094 | } |
| 1095 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1096 | #pragma clang diagnostic pop |
| 1097 | // clang-format on |
| 1098 | |
| 1099 | } // namespace null_driver |