| 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 |  | 
| Dan Albert | 09dc47b | 2017-10-12 13:27:37 -0700 | [diff] [blame] | 19 | #include <errno.h> | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 20 | #include <inttypes.h> | 
| Jesse Hall | d3b1450 | 2016-04-20 16:58:11 -0700 | [diff] [blame] | 21 | #include <stdlib.h> | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 22 | #include <string.h> | 
| Steven Moreland | 54409a3 | 2017-07-17 11:49:21 -0700 | [diff] [blame] | 23 | #include <unistd.h> | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 24 |  | 
| Mark Salyzyn | a5e161b | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 25 | #include <algorithm> | 
 | 26 | #include <array> | 
 | 27 |  | 
| Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 28 | #include <log/log.h> | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 29 |  | 
| Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 30 | #include "null_driver_gen.h" | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 31 |  | 
 | 32 | using namespace null_driver; | 
 | 33 |  | 
 | 34 | struct VkPhysicalDevice_T { | 
 | 35 |     hwvulkan_dispatch_t dispatch; | 
 | 36 | }; | 
 | 37 |  | 
 | 38 | struct VkInstance_T { | 
 | 39 |     hwvulkan_dispatch_t dispatch; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 40 |     VkAllocationCallbacks allocator; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 41 |     VkPhysicalDevice_T physical_device; | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 42 |     uint64_t next_callback_handle; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 43 | }; | 
 | 44 |  | 
 | 45 | struct VkQueue_T { | 
 | 46 |     hwvulkan_dispatch_t dispatch; | 
 | 47 | }; | 
 | 48 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 49 | struct VkCommandBuffer_T { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 50 |     hwvulkan_dispatch_t dispatch; | 
 | 51 | }; | 
 | 52 |  | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 53 | namespace { | 
 | 54 | // Handles for non-dispatchable objects are either pointers, or arbitrary | 
 | 55 | // 64-bit non-zero values. We only use pointers when we need to keep state for | 
 | 56 | // the object even in a null driver. For the rest, we form a handle as: | 
 | 57 | //   [63:63] = 1 to distinguish from pointer handles* | 
 | 58 | //   [62:56] = non-zero handle type enum value | 
 | 59 | //   [55: 0] = per-handle-type incrementing counter | 
 | 60 | // * This works because virtual addresses with the high bit set are reserved | 
 | 61 | // for kernel data in all ABIs we run on. | 
 | 62 | // | 
 | 63 | // We never reclaim handles on vkDestroy*. It's not even necessary for us to | 
 | 64 | // have distinct handles for live objects, and practically speaking we won't | 
 | 65 | // ever create 2^56 objects of the same type from a single VkDevice in a null | 
 | 66 | // driver. | 
 | 67 | // | 
 | 68 | // Using a namespace here instead of 'enum class' since we want scoped | 
 | 69 | // constants but also want implicit conversions to integral types. | 
 | 70 | namespace HandleType { | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 71 | enum Enum { | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 72 |     kBufferView, | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 73 |     kDebugReportCallbackEXT, | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 74 |     kDescriptorPool, | 
 | 75 |     kDescriptorSet, | 
 | 76 |     kDescriptorSetLayout, | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 77 |     kEvent, | 
 | 78 |     kFence, | 
 | 79 |     kFramebuffer, | 
 | 80 |     kImageView, | 
 | 81 |     kPipeline, | 
 | 82 |     kPipelineCache, | 
 | 83 |     kPipelineLayout, | 
 | 84 |     kQueryPool, | 
 | 85 |     kRenderPass, | 
 | 86 |     kSampler, | 
 | 87 |     kSemaphore, | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 88 |     kShaderModule, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 89 |  | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 90 |     kNumTypes | 
 | 91 | }; | 
 | 92 | }  // namespace HandleType | 
| Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 93 |  | 
| Jesse Hall | 00f10fe | 2016-02-08 21:20:20 -0800 | [diff] [blame] | 94 | const VkDeviceSize kMaxDeviceMemory = 0x10000000;  // 256 MiB, arbitrary | 
| Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 95 |  | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 96 | }  // anonymous namespace | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 97 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 98 | struct VkDevice_T { | 
 | 99 |     hwvulkan_dispatch_t dispatch; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 100 |     VkAllocationCallbacks allocator; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 101 |     VkInstance_T* instance; | 
 | 102 |     VkQueue_T queue; | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 103 |     std::array<uint64_t, HandleType::kNumTypes> next_handle; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 104 | }; | 
 | 105 |  | 
 | 106 | // ----------------------------------------------------------------------------- | 
 | 107 | // Declare HAL_MODULE_INFO_SYM early so it can be referenced by nulldrv_device | 
 | 108 | // later. | 
 | 109 |  | 
 | 110 | namespace { | 
 | 111 | int OpenDevice(const hw_module_t* module, const char* id, hw_device_t** device); | 
 | 112 | hw_module_methods_t nulldrv_module_methods = {.open = OpenDevice}; | 
 | 113 | }  // namespace | 
 | 114 |  | 
 | 115 | #pragma clang diagnostic push | 
 | 116 | #pragma clang diagnostic ignored "-Wmissing-variable-declarations" | 
 | 117 | __attribute__((visibility("default"))) hwvulkan_module_t HAL_MODULE_INFO_SYM = { | 
 | 118 |     .common = | 
 | 119 |         { | 
| Michael Lentine | 03c64b0 | 2015-08-26 18:27:26 -0500 | [diff] [blame] | 120 |             .tag = HARDWARE_MODULE_TAG, | 
 | 121 |             .module_api_version = HWVULKAN_MODULE_API_VERSION_0_1, | 
 | 122 |             .hal_api_version = HARDWARE_HAL_API_VERSION, | 
 | 123 |             .id = HWVULKAN_HARDWARE_MODULE_ID, | 
 | 124 |             .name = "Null Vulkan Driver", | 
 | 125 |             .author = "The Android Open Source Project", | 
 | 126 |             .methods = &nulldrv_module_methods, | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 127 |         }, | 
 | 128 | }; | 
 | 129 | #pragma clang diagnostic pop | 
 | 130 |  | 
 | 131 | // ----------------------------------------------------------------------------- | 
 | 132 |  | 
 | 133 | namespace { | 
 | 134 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 135 | int CloseDevice(struct hw_device_t* /*device*/) { | 
 | 136 |     // nothing to do - opening a device doesn't allocate any resources | 
 | 137 |     return 0; | 
 | 138 | } | 
 | 139 |  | 
 | 140 | hwvulkan_device_t nulldrv_device = { | 
 | 141 |     .common = | 
 | 142 |         { | 
| Michael Lentine | 03c64b0 | 2015-08-26 18:27:26 -0500 | [diff] [blame] | 143 |             .tag = HARDWARE_DEVICE_TAG, | 
 | 144 |             .version = HWVULKAN_DEVICE_API_VERSION_0_1, | 
 | 145 |             .module = &HAL_MODULE_INFO_SYM.common, | 
 | 146 |             .close = CloseDevice, | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 147 |         }, | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 148 |     .EnumerateInstanceExtensionProperties = | 
 | 149 |         EnumerateInstanceExtensionProperties, | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 150 |     .CreateInstance = CreateInstance, | 
 | 151 |     .GetInstanceProcAddr = GetInstanceProcAddr}; | 
 | 152 |  | 
 | 153 | int OpenDevice(const hw_module_t* /*module*/, | 
 | 154 |                const char* id, | 
 | 155 |                hw_device_t** device) { | 
 | 156 |     if (strcmp(id, HWVULKAN_DEVICE_0) == 0) { | 
 | 157 |         *device = &nulldrv_device.common; | 
 | 158 |         return 0; | 
 | 159 |     } | 
 | 160 |     return -ENOENT; | 
 | 161 | } | 
 | 162 |  | 
 | 163 | VkInstance_T* GetInstanceFromPhysicalDevice( | 
 | 164 |     VkPhysicalDevice_T* physical_device) { | 
 | 165 |     return reinterpret_cast<VkInstance_T*>( | 
 | 166 |         reinterpret_cast<uintptr_t>(physical_device) - | 
 | 167 |         offsetof(VkInstance_T, physical_device)); | 
 | 168 | } | 
 | 169 |  | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 170 | uint64_t AllocHandle(uint64_t type, uint64_t* next_handle) { | 
 | 171 |     const uint64_t kHandleMask = (UINT64_C(1) << 56) - 1; | 
 | 172 |     ALOGE_IF(*next_handle == kHandleMask, | 
 | 173 |              "non-dispatchable handles of type=%" PRIu64 | 
 | 174 |              " are about to overflow", | 
 | 175 |              type); | 
 | 176 |     return (UINT64_C(1) << 63) | ((type & 0x7) << 56) | | 
 | 177 |            ((*next_handle)++ & kHandleMask); | 
 | 178 | } | 
 | 179 |  | 
 | 180 | template <class Handle> | 
 | 181 | Handle AllocHandle(VkInstance instance, HandleType::Enum type) { | 
 | 182 |     return reinterpret_cast<Handle>( | 
 | 183 |         AllocHandle(type, &instance->next_callback_handle)); | 
 | 184 | } | 
 | 185 |  | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 186 | template <class Handle> | 
 | 187 | Handle AllocHandle(VkDevice device, HandleType::Enum type) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 188 |     return reinterpret_cast<Handle>( | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 189 |         AllocHandle(type, &device->next_handle[type])); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 190 | } | 
 | 191 |  | 
| Jesse Hall | d3b1450 | 2016-04-20 16:58:11 -0700 | [diff] [blame] | 192 | VKAPI_ATTR void* DefaultAllocate(void*, | 
 | 193 |                                  size_t size, | 
 | 194 |                                  size_t alignment, | 
 | 195 |                                  VkSystemAllocationScope) { | 
 | 196 |     void* ptr = nullptr; | 
 | 197 |     // Vulkan requires 'alignment' to be a power of two, but posix_memalign | 
 | 198 |     // additionally requires that it be at least sizeof(void*). | 
 | 199 |     int ret = posix_memalign(&ptr, std::max(alignment, sizeof(void*)), size); | 
 | 200 |     return ret == 0 ? ptr : nullptr; | 
 | 201 | } | 
 | 202 |  | 
 | 203 | VKAPI_ATTR void* DefaultReallocate(void*, | 
 | 204 |                                    void* ptr, | 
 | 205 |                                    size_t size, | 
 | 206 |                                    size_t alignment, | 
 | 207 |                                    VkSystemAllocationScope) { | 
 | 208 |     if (size == 0) { | 
 | 209 |         free(ptr); | 
 | 210 |         return nullptr; | 
 | 211 |     } | 
 | 212 |  | 
 | 213 |     // TODO(jessehall): Right now we never shrink allocations; if the new | 
 | 214 |     // request is smaller than the existing chunk, we just continue using it. | 
 | 215 |     // The null driver never reallocs, so this doesn't matter. If that changes, | 
 | 216 |     // or if this code is copied into some other project, this should probably | 
 | 217 |     // have a heuristic to allocate-copy-free when doing so will save "enough" | 
 | 218 |     // space. | 
 | 219 |     size_t old_size = ptr ? malloc_usable_size(ptr) : 0; | 
 | 220 |     if (size <= old_size) | 
 | 221 |         return ptr; | 
 | 222 |  | 
 | 223 |     void* new_ptr = nullptr; | 
 | 224 |     if (posix_memalign(&new_ptr, std::max(alignment, sizeof(void*)), size) != 0) | 
 | 225 |         return nullptr; | 
 | 226 |     if (ptr) { | 
 | 227 |         memcpy(new_ptr, ptr, std::min(old_size, size)); | 
 | 228 |         free(ptr); | 
 | 229 |     } | 
 | 230 |     return new_ptr; | 
 | 231 | } | 
 | 232 |  | 
 | 233 | VKAPI_ATTR void DefaultFree(void*, void* ptr) { | 
 | 234 |     free(ptr); | 
 | 235 | } | 
 | 236 |  | 
 | 237 | const VkAllocationCallbacks kDefaultAllocCallbacks = { | 
 | 238 |     .pUserData = nullptr, | 
 | 239 |     .pfnAllocation = DefaultAllocate, | 
 | 240 |     .pfnReallocation = DefaultReallocate, | 
 | 241 |     .pfnFree = DefaultFree, | 
 | 242 | }; | 
 | 243 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 244 | }  // namespace | 
 | 245 |  | 
 | 246 | namespace null_driver { | 
 | 247 |  | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 248 | #define DEFINE_OBJECT_HANDLE_CONVERSION(T)              \ | 
 | 249 |     T* Get##T##FromHandle(Vk##T h);                     \ | 
 | 250 |     T* Get##T##FromHandle(Vk##T h) {                    \ | 
 | 251 |         return reinterpret_cast<T*>(uintptr_t(h));      \ | 
 | 252 |     }                                                   \ | 
 | 253 |     Vk##T GetHandleTo##T(const T* obj);                 \ | 
 | 254 |     Vk##T GetHandleTo##T(const T* obj) {                \ | 
 | 255 |         return Vk##T(reinterpret_cast<uintptr_t>(obj)); \ | 
 | 256 |     } | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 257 |  | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 258 | // ----------------------------------------------------------------------------- | 
 | 259 | // Global | 
 | 260 |  | 
| Jesse Hall | e1b1278 | 2015-11-30 11:27:32 -0800 | [diff] [blame] | 261 | VKAPI_ATTR | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 262 | VkResult EnumerateInstanceExtensionProperties( | 
 | 263 |     const char* layer_name, | 
 | 264 |     uint32_t* count, | 
 | 265 |     VkExtensionProperties* properties) { | 
 | 266 |     if (layer_name) { | 
 | 267 |         ALOGW( | 
 | 268 |             "Driver vkEnumerateInstanceExtensionProperties shouldn't be called " | 
 | 269 |             "with a layer name ('%s')", | 
 | 270 |             layer_name); | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 271 |     } | 
 | 272 |  | 
 | 273 |     const VkExtensionProperties kExtensions[] = { | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 274 |         {VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION}}; | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 275 |     const uint32_t kExtensionsCount = | 
 | 276 |         sizeof(kExtensions) / sizeof(kExtensions[0]); | 
 | 277 |  | 
 | 278 |     if (!properties || *count > kExtensionsCount) | 
 | 279 |         *count = kExtensionsCount; | 
 | 280 |     if (properties) | 
 | 281 |         std::copy(kExtensions, kExtensions + *count, properties); | 
 | 282 |     return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS; | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 283 | } | 
 | 284 |  | 
| Jesse Hall | e1b1278 | 2015-11-30 11:27:32 -0800 | [diff] [blame] | 285 | VKAPI_ATTR | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 286 | VkResult CreateInstance(const VkInstanceCreateInfo* create_info, | 
| Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 287 |                         const VkAllocationCallbacks* allocator, | 
 | 288 |                         VkInstance* out_instance) { | 
| Jesse Hall | d3b1450 | 2016-04-20 16:58:11 -0700 | [diff] [blame] | 289 |     if (!allocator) | 
 | 290 |         allocator = &kDefaultAllocCallbacks; | 
| Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 291 |  | 
 | 292 |     VkInstance_T* instance = | 
 | 293 |         static_cast<VkInstance_T*>(allocator->pfnAllocation( | 
 | 294 |             allocator->pUserData, sizeof(VkInstance_T), alignof(VkInstance_T), | 
 | 295 |             VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE)); | 
 | 296 |     if (!instance) | 
 | 297 |         return VK_ERROR_OUT_OF_HOST_MEMORY; | 
 | 298 |  | 
 | 299 |     instance->dispatch.magic = HWVULKAN_DISPATCH_MAGIC; | 
 | 300 |     instance->allocator = *allocator; | 
 | 301 |     instance->physical_device.dispatch.magic = HWVULKAN_DISPATCH_MAGIC; | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 302 |     instance->next_callback_handle = 0; | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 303 |  | 
 | 304 |     for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) { | 
 | 305 |         if (strcmp(create_info->ppEnabledExtensionNames[i], | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 306 |                    VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0) { | 
 | 307 |             ALOGV("instance extension '%s' requested", | 
 | 308 |                   create_info->ppEnabledExtensionNames[i]); | 
 | 309 |         } else if (strcmp(create_info->ppEnabledExtensionNames[i], | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 310 |                    VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) { | 
| Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 311 |             ALOGV("instance extension '%s' requested", | 
 | 312 |                   create_info->ppEnabledExtensionNames[i]); | 
 | 313 |         } else { | 
 | 314 |             ALOGW("unsupported extension '%s' requested", | 
 | 315 |                   create_info->ppEnabledExtensionNames[i]); | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 316 |         } | 
 | 317 |     } | 
| Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 318 |  | 
 | 319 |     *out_instance = instance; | 
 | 320 |     return VK_SUCCESS; | 
 | 321 | } | 
 | 322 |  | 
 | 323 | VKAPI_ATTR | 
 | 324 | PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name) { | 
 | 325 |     return instance ? GetInstanceProcAddr(name) : GetGlobalProcAddr(name); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 326 | } | 
 | 327 |  | 
| Jesse Hall | e1b1278 | 2015-11-30 11:27:32 -0800 | [diff] [blame] | 328 | VKAPI_ATTR | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 329 | PFN_vkVoidFunction GetDeviceProcAddr(VkDevice, const char* name) { | 
| Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 330 |     return GetInstanceProcAddr(name); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 331 | } | 
 | 332 |  | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 333 | // ----------------------------------------------------------------------------- | 
 | 334 | // Instance | 
 | 335 |  | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 336 | void DestroyInstance(VkInstance instance, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 337 |                      const VkAllocationCallbacks* /*allocator*/) { | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 338 |     instance->allocator.pfnFree(instance->allocator.pUserData, instance); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 339 | } | 
 | 340 |  | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 341 | // ----------------------------------------------------------------------------- | 
 | 342 | // PhysicalDevice | 
 | 343 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 344 | VkResult EnumeratePhysicalDevices(VkInstance instance, | 
 | 345 |                                   uint32_t* physical_device_count, | 
 | 346 |                                   VkPhysicalDevice* physical_devices) { | 
 | 347 |     if (physical_devices && *physical_device_count >= 1) | 
 | 348 |         physical_devices[0] = &instance->physical_device; | 
 | 349 |     *physical_device_count = 1; | 
 | 350 |     return VK_SUCCESS; | 
 | 351 | } | 
 | 352 |  | 
| Jesse Hall | 57f7f8c | 2016-01-17 17:21:36 -0800 | [diff] [blame] | 353 | VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice /*gpu*/, | 
 | 354 |                                         uint32_t* count, | 
 | 355 |                                         VkLayerProperties* /*properties*/) { | 
 | 356 |     ALOGW("Driver vkEnumerateDeviceLayerProperties shouldn't be called"); | 
 | 357 |     *count = 0; | 
 | 358 |     return VK_SUCCESS; | 
 | 359 | } | 
 | 360 |  | 
 | 361 | VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice /*gpu*/, | 
 | 362 |                                             const char* layer_name, | 
 | 363 |                                             uint32_t* count, | 
 | 364 |                                             VkExtensionProperties* properties) { | 
 | 365 |     if (layer_name) { | 
 | 366 |         ALOGW( | 
 | 367 |             "Driver vkEnumerateDeviceExtensionProperties shouldn't be called " | 
 | 368 |             "with a layer name ('%s')", | 
 | 369 |             layer_name); | 
 | 370 |         *count = 0; | 
 | 371 |         return VK_SUCCESS; | 
 | 372 |     } | 
 | 373 |  | 
 | 374 |     const VkExtensionProperties kExtensions[] = { | 
 | 375 |         {VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME, | 
 | 376 |          VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION}}; | 
 | 377 |     const uint32_t kExtensionsCount = | 
 | 378 |         sizeof(kExtensions) / sizeof(kExtensions[0]); | 
 | 379 |  | 
 | 380 |     if (!properties || *count > kExtensionsCount) | 
 | 381 |         *count = kExtensionsCount; | 
 | 382 |     if (properties) | 
 | 383 |         std::copy(kExtensions, kExtensions + *count, properties); | 
 | 384 |     return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS; | 
 | 385 | } | 
 | 386 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 387 | void GetPhysicalDeviceProperties(VkPhysicalDevice, | 
 | 388 |                                  VkPhysicalDeviceProperties* properties) { | 
| Jesse Hall | 2676338 | 2016-05-20 07:13:52 -0700 | [diff] [blame] | 389 |     properties->apiVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 390 |     properties->driverVersion = VK_MAKE_VERSION(0, 0, 1); | 
| Jesse Hall | 65ab552 | 2015-11-30 00:07:16 -0800 | [diff] [blame] | 391 |     properties->vendorID = 0; | 
 | 392 |     properties->deviceID = 0; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 393 |     properties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER; | 
 | 394 |     strcpy(properties->deviceName, "Android Vulkan Null Driver"); | 
 | 395 |     memset(properties->pipelineCacheUUID, 0, | 
 | 396 |            sizeof(properties->pipelineCacheUUID)); | 
| Jesse Hall | c34849e | 2016-02-09 22:35:04 -0800 | [diff] [blame] | 397 |     properties->limits = VkPhysicalDeviceLimits{ | 
 | 398 |         4096,     // maxImageDimension1D | 
 | 399 |         4096,     // maxImageDimension2D | 
 | 400 |         256,      // maxImageDimension3D | 
 | 401 |         4096,     // maxImageDimensionCube | 
 | 402 |         256,      // maxImageArrayLayers | 
 | 403 |         65536,    // maxTexelBufferElements | 
 | 404 |         16384,    // maxUniformBufferRange | 
 | 405 |         1 << 27,  // maxStorageBufferRange | 
 | 406 |         128,      // maxPushConstantsSize | 
 | 407 |         4096,     // maxMemoryAllocationCount | 
 | 408 |         4000,     // maxSamplerAllocationCount | 
 | 409 |         1,        // bufferImageGranularity | 
 | 410 |         0,        // sparseAddressSpaceSize | 
 | 411 |         4,        // maxBoundDescriptorSets | 
 | 412 |         16,       // maxPerStageDescriptorSamplers | 
 | 413 |         12,       // maxPerStageDescriptorUniformBuffers | 
 | 414 |         4,        // maxPerStageDescriptorStorageBuffers | 
 | 415 |         16,       // maxPerStageDescriptorSampledImages | 
 | 416 |         4,        // maxPerStageDescriptorStorageImages | 
 | 417 |         4,        // maxPerStageDescriptorInputAttachments | 
 | 418 |         128,      // maxPerStageResources | 
 | 419 |         96,       // maxDescriptorSetSamplers | 
 | 420 |         72,       // maxDescriptorSetUniformBuffers | 
 | 421 |         8,        // maxDescriptorSetUniformBuffersDynamic | 
 | 422 |         24,       // maxDescriptorSetStorageBuffers | 
 | 423 |         4,        // maxDescriptorSetStorageBuffersDynamic | 
 | 424 |         96,       // maxDescriptorSetSampledImages | 
 | 425 |         24,       // maxDescriptorSetStorageImages | 
 | 426 |         4,        // maxDescriptorSetInputAttachments | 
 | 427 |         16,       // maxVertexInputAttributes | 
 | 428 |         16,       // maxVertexInputBindings | 
 | 429 |         2047,     // maxVertexInputAttributeOffset | 
 | 430 |         2048,     // maxVertexInputBindingStride | 
 | 431 |         64,       // maxVertexOutputComponents | 
 | 432 |         0,        // maxTessellationGenerationLevel | 
 | 433 |         0,        // maxTessellationPatchSize | 
 | 434 |         0,        // maxTessellationControlPerVertexInputComponents | 
 | 435 |         0,        // maxTessellationControlPerVertexOutputComponents | 
 | 436 |         0,        // maxTessellationControlPerPatchOutputComponents | 
 | 437 |         0,        // maxTessellationControlTotalOutputComponents | 
 | 438 |         0,        // maxTessellationEvaluationInputComponents | 
 | 439 |         0,        // maxTessellationEvaluationOutputComponents | 
 | 440 |         0,        // maxGeometryShaderInvocations | 
 | 441 |         0,        // maxGeometryInputComponents | 
 | 442 |         0,        // maxGeometryOutputComponents | 
 | 443 |         0,        // maxGeometryOutputVertices | 
 | 444 |         0,        // maxGeometryTotalOutputComponents | 
 | 445 |         64,       // maxFragmentInputComponents | 
 | 446 |         4,        // maxFragmentOutputAttachments | 
 | 447 |         0,        // maxFragmentDualSrcAttachments | 
 | 448 |         4,        // maxFragmentCombinedOutputResources | 
 | 449 |         16384,    // maxComputeSharedMemorySize | 
 | 450 |         {65536, 65536, 65536},  // maxComputeWorkGroupCount[3] | 
 | 451 |         128,                    // maxComputeWorkGroupInvocations | 
 | 452 |         {128, 128, 64},         // maxComputeWorkGroupSize[3] | 
 | 453 |         4,                      // subPixelPrecisionBits | 
 | 454 |         4,                      // subTexelPrecisionBits | 
 | 455 |         4,                      // mipmapPrecisionBits | 
 | 456 |         UINT32_MAX,             // maxDrawIndexedIndexValue | 
 | 457 |         1,                      // maxDrawIndirectCount | 
 | 458 |         2,                      // maxSamplerLodBias | 
 | 459 |         1,                      // maxSamplerAnisotropy | 
 | 460 |         1,                      // maxViewports | 
 | 461 |         {4096, 4096},           // maxViewportDimensions[2] | 
 | 462 |         {-8192.0f, 8191.0f},    // viewportBoundsRange[2] | 
 | 463 |         0,                      // viewportSubPixelBits | 
 | 464 |         64,                     // minMemoryMapAlignment | 
 | 465 |         256,                    // minTexelBufferOffsetAlignment | 
 | 466 |         256,                    // minUniformBufferOffsetAlignment | 
 | 467 |         256,                    // minStorageBufferOffsetAlignment | 
 | 468 |         -8,                     // minTexelOffset | 
 | 469 |         7,                      // maxTexelOffset | 
 | 470 |         0,                      // minTexelGatherOffset | 
 | 471 |         0,                      // maxTexelGatherOffset | 
 | 472 |         0.0f,                   // minInterpolationOffset | 
 | 473 |         0.0f,                   // maxInterpolationOffset | 
 | 474 |         0,                      // subPixelInterpolationOffsetBits | 
 | 475 |         4096,                   // maxFramebufferWidth | 
 | 476 |         4096,                   // maxFramebufferHeight | 
 | 477 |         256,                    // maxFramebufferLayers | 
 | 478 |         VK_SAMPLE_COUNT_1_BIT | | 
 | 479 |             VK_SAMPLE_COUNT_4_BIT,  // framebufferColorSampleCounts | 
 | 480 |         VK_SAMPLE_COUNT_1_BIT | | 
 | 481 |             VK_SAMPLE_COUNT_4_BIT,  // framebufferDepthSampleCounts | 
 | 482 |         VK_SAMPLE_COUNT_1_BIT | | 
 | 483 |             VK_SAMPLE_COUNT_4_BIT,  // framebufferStencilSampleCounts | 
 | 484 |         VK_SAMPLE_COUNT_1_BIT | | 
 | 485 |             VK_SAMPLE_COUNT_4_BIT,  // framebufferNoAttachmentsSampleCounts | 
 | 486 |         4,                          // maxColorAttachments | 
 | 487 |         VK_SAMPLE_COUNT_1_BIT | | 
 | 488 |             VK_SAMPLE_COUNT_4_BIT,  // sampledImageColorSampleCounts | 
 | 489 |         VK_SAMPLE_COUNT_1_BIT,      // sampledImageIntegerSampleCounts | 
 | 490 |         VK_SAMPLE_COUNT_1_BIT | | 
 | 491 |             VK_SAMPLE_COUNT_4_BIT,  // sampledImageDepthSampleCounts | 
 | 492 |         VK_SAMPLE_COUNT_1_BIT | | 
 | 493 |             VK_SAMPLE_COUNT_4_BIT,  // sampledImageStencilSampleCounts | 
 | 494 |         VK_SAMPLE_COUNT_1_BIT,      // storageImageSampleCounts | 
 | 495 |         1,                          // maxSampleMaskWords | 
 | 496 |         VK_TRUE,                    // timestampComputeAndGraphics | 
 | 497 |         1,                          // timestampPeriod | 
 | 498 |         0,                          // maxClipDistances | 
 | 499 |         0,                          // maxCullDistances | 
 | 500 |         0,                          // maxCombinedClipAndCullDistances | 
 | 501 |         2,                          // discreteQueuePriorities | 
 | 502 |         {1.0f, 1.0f},               // pointSizeRange[2] | 
 | 503 |         {1.0f, 1.0f},               // lineWidthRange[2] | 
 | 504 |         0.0f,                       // pointSizeGranularity | 
 | 505 |         0.0f,                       // lineWidthGranularity | 
 | 506 |         VK_TRUE,                    // strictLines | 
 | 507 |         VK_TRUE,                    // standardSampleLocations | 
 | 508 |         1,                          // optimalBufferCopyOffsetAlignment | 
 | 509 |         1,                          // optimalBufferCopyRowPitchAlignment | 
 | 510 |         64,                         // nonCoherentAtomSize | 
 | 511 |     }; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 512 | } | 
 | 513 |  | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 514 | void GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physical_device, | 
 | 515 |                                   VkPhysicalDeviceProperties2KHR* properties) { | 
 | 516 |     GetPhysicalDeviceProperties(physical_device, &properties->properties); | 
| Chris Forbes | b4eb278 | 2017-03-15 16:09:15 +1300 | [diff] [blame] | 517 |  | 
 | 518 |     while (properties->pNext) { | 
 | 519 |         properties = reinterpret_cast<VkPhysicalDeviceProperties2KHR *>(properties->pNext); | 
 | 520 |  | 
 | 521 | #pragma clang diagnostic push | 
 | 522 | #pragma clang diagnostic ignored "-Wold-style-cast" | 
 | 523 |         switch ((VkFlags)properties->sType) { | 
 | 524 |         case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: { | 
 | 525 |             VkPhysicalDevicePresentationPropertiesANDROID *presentation_properties = | 
 | 526 |                 reinterpret_cast<VkPhysicalDevicePresentationPropertiesANDROID *>(properties); | 
 | 527 | #pragma clang diagnostic pop | 
 | 528 |  | 
 | 529 |                 // Claim that we do all the right things for the loader to | 
 | 530 |                 // expose KHR_shared_presentable_image on our behalf. | 
 | 531 |                 presentation_properties->sharedImage = VK_TRUE; | 
 | 532 |             } break; | 
 | 533 |  | 
 | 534 |         default: | 
 | 535 |             // Silently ignore other extension query structs | 
 | 536 |             break; | 
 | 537 |         } | 
 | 538 |     } | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 539 | } | 
 | 540 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 541 | void GetPhysicalDeviceQueueFamilyProperties( | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 542 |     VkPhysicalDevice, | 
 | 543 |     uint32_t* count, | 
 | 544 |     VkQueueFamilyProperties* properties) { | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 545 |     if (!properties || *count > 1) | 
 | 546 |         *count = 1; | 
 | 547 |     if (properties && *count == 1) { | 
| Jesse Hall | 65ab552 | 2015-11-30 00:07:16 -0800 | [diff] [blame] | 548 |         properties->queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | | 
 | 549 |                                  VK_QUEUE_TRANSFER_BIT; | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 550 |         properties->queueCount = 1; | 
| Jesse Hall | acfa534 | 2015-11-19 21:51:33 -0800 | [diff] [blame] | 551 |         properties->timestampValidBits = 64; | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 552 |         properties->minImageTransferGranularity = VkExtent3D{1, 1, 1}; | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 553 |     } | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 554 | } | 
 | 555 |  | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 556 | void GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physical_device, uint32_t* count, VkQueueFamilyProperties2KHR* properties) { | 
 | 557 |     // note: even though multiple structures, this is safe to forward in this | 
 | 558 |     // case since we only expose one queue family. | 
 | 559 |     GetPhysicalDeviceQueueFamilyProperties(physical_device, count, properties ? &properties->queueFamilyProperties : nullptr); | 
 | 560 | } | 
 | 561 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 562 | void GetPhysicalDeviceMemoryProperties( | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 563 |     VkPhysicalDevice, | 
 | 564 |     VkPhysicalDeviceMemoryProperties* properties) { | 
 | 565 |     properties->memoryTypeCount = 1; | 
 | 566 |     properties->memoryTypes[0].propertyFlags = | 
| Jesse Hall | d1af812 | 2015-11-29 23:50:38 -0800 | [diff] [blame] | 567 |         VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | | 
 | 568 |         VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | | 
 | 569 |         VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | | 
 | 570 |         VK_MEMORY_PROPERTY_HOST_CACHED_BIT; | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 571 |     properties->memoryTypes[0].heapIndex = 0; | 
 | 572 |     properties->memoryHeapCount = 1; | 
| Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 573 |     properties->memoryHeaps[0].size = kMaxDeviceMemory; | 
| Jesse Hall | d1af812 | 2015-11-29 23:50:38 -0800 | [diff] [blame] | 574 |     properties->memoryHeaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 575 | } | 
 | 576 |  | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 577 | void GetPhysicalDeviceMemoryProperties2KHR(VkPhysicalDevice physical_device, VkPhysicalDeviceMemoryProperties2KHR* properties) { | 
 | 578 |     GetPhysicalDeviceMemoryProperties(physical_device, &properties->memoryProperties); | 
 | 579 | } | 
 | 580 |  | 
| Jesse Hall | 8e37cf3 | 2016-01-18 04:00:57 -0800 | [diff] [blame] | 581 | void GetPhysicalDeviceFeatures(VkPhysicalDevice /*gpu*/, | 
 | 582 |                                VkPhysicalDeviceFeatures* features) { | 
 | 583 |     *features = VkPhysicalDeviceFeatures{ | 
 | 584 |         VK_TRUE,   // robustBufferAccess | 
 | 585 |         VK_FALSE,  // fullDrawIndexUint32 | 
 | 586 |         VK_FALSE,  // imageCubeArray | 
 | 587 |         VK_FALSE,  // independentBlend | 
 | 588 |         VK_FALSE,  // geometryShader | 
 | 589 |         VK_FALSE,  // tessellationShader | 
 | 590 |         VK_FALSE,  // sampleRateShading | 
 | 591 |         VK_FALSE,  // dualSrcBlend | 
 | 592 |         VK_FALSE,  // logicOp | 
 | 593 |         VK_FALSE,  // multiDrawIndirect | 
 | 594 |         VK_FALSE,  // drawIndirectFirstInstance | 
 | 595 |         VK_FALSE,  // depthClamp | 
 | 596 |         VK_FALSE,  // depthBiasClamp | 
 | 597 |         VK_FALSE,  // fillModeNonSolid | 
 | 598 |         VK_FALSE,  // depthBounds | 
 | 599 |         VK_FALSE,  // wideLines | 
 | 600 |         VK_FALSE,  // largePoints | 
 | 601 |         VK_FALSE,  // alphaToOne | 
 | 602 |         VK_FALSE,  // multiViewport | 
 | 603 |         VK_FALSE,  // samplerAnisotropy | 
 | 604 |         VK_FALSE,  // textureCompressionETC2 | 
 | 605 |         VK_FALSE,  // textureCompressionASTC_LDR | 
 | 606 |         VK_FALSE,  // textureCompressionBC | 
 | 607 |         VK_FALSE,  // occlusionQueryPrecise | 
 | 608 |         VK_FALSE,  // pipelineStatisticsQuery | 
 | 609 |         VK_FALSE,  // vertexPipelineStoresAndAtomics | 
 | 610 |         VK_FALSE,  // fragmentStoresAndAtomics | 
 | 611 |         VK_FALSE,  // shaderTessellationAndGeometryPointSize | 
 | 612 |         VK_FALSE,  // shaderImageGatherExtended | 
 | 613 |         VK_FALSE,  // shaderStorageImageExtendedFormats | 
 | 614 |         VK_FALSE,  // shaderStorageImageMultisample | 
 | 615 |         VK_FALSE,  // shaderStorageImageReadWithoutFormat | 
 | 616 |         VK_FALSE,  // shaderStorageImageWriteWithoutFormat | 
 | 617 |         VK_FALSE,  // shaderUniformBufferArrayDynamicIndexing | 
 | 618 |         VK_FALSE,  // shaderSampledImageArrayDynamicIndexing | 
 | 619 |         VK_FALSE,  // shaderStorageBufferArrayDynamicIndexing | 
 | 620 |         VK_FALSE,  // shaderStorageImageArrayDynamicIndexing | 
 | 621 |         VK_FALSE,  // shaderClipDistance | 
 | 622 |         VK_FALSE,  // shaderCullDistance | 
 | 623 |         VK_FALSE,  // shaderFloat64 | 
 | 624 |         VK_FALSE,  // shaderInt64 | 
 | 625 |         VK_FALSE,  // shaderInt16 | 
 | 626 |         VK_FALSE,  // shaderResourceResidency | 
 | 627 |         VK_FALSE,  // shaderResourceMinLod | 
 | 628 |         VK_FALSE,  // sparseBinding | 
 | 629 |         VK_FALSE,  // sparseResidencyBuffer | 
 | 630 |         VK_FALSE,  // sparseResidencyImage2D | 
 | 631 |         VK_FALSE,  // sparseResidencyImage3D | 
 | 632 |         VK_FALSE,  // sparseResidency2Samples | 
 | 633 |         VK_FALSE,  // sparseResidency4Samples | 
 | 634 |         VK_FALSE,  // sparseResidency8Samples | 
 | 635 |         VK_FALSE,  // sparseResidency16Samples | 
 | 636 |         VK_FALSE,  // sparseResidencyAliased | 
 | 637 |         VK_FALSE,  // variableMultisampleRate | 
 | 638 |         VK_FALSE,  // inheritedQueries | 
 | 639 |     }; | 
 | 640 | } | 
 | 641 |  | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 642 | void GetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physical_device, VkPhysicalDeviceFeatures2KHR* features) { | 
 | 643 |     GetPhysicalDeviceFeatures(physical_device, &features->features); | 
 | 644 | } | 
 | 645 |  | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 646 | // ----------------------------------------------------------------------------- | 
 | 647 | // Device | 
 | 648 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 649 | VkResult CreateDevice(VkPhysicalDevice physical_device, | 
| Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 650 |                       const VkDeviceCreateInfo* create_info, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 651 |                       const VkAllocationCallbacks* allocator, | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 652 |                       VkDevice* out_device) { | 
 | 653 |     VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device); | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 654 |     if (!allocator) | 
 | 655 |         allocator = &instance->allocator; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 656 |     VkDevice_T* device = static_cast<VkDevice_T*>(allocator->pfnAllocation( | 
 | 657 |         allocator->pUserData, sizeof(VkDevice_T), alignof(VkDevice_T), | 
 | 658 |         VK_SYSTEM_ALLOCATION_SCOPE_DEVICE)); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 659 |     if (!device) | 
 | 660 |         return VK_ERROR_OUT_OF_HOST_MEMORY; | 
 | 661 |  | 
 | 662 |     device->dispatch.magic = HWVULKAN_DISPATCH_MAGIC; | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 663 |     device->allocator = *allocator; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 664 |     device->instance = instance; | 
 | 665 |     device->queue.dispatch.magic = HWVULKAN_DISPATCH_MAGIC; | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 666 |     std::fill(device->next_handle.begin(), device->next_handle.end(), | 
 | 667 |               UINT64_C(0)); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 668 |  | 
| Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 669 |     for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) { | 
 | 670 |         if (strcmp(create_info->ppEnabledExtensionNames[i], | 
 | 671 |                    VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME) == 0) { | 
 | 672 |             ALOGV("Enabling " VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME); | 
 | 673 |         } | 
 | 674 |     } | 
 | 675 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 676 |     *out_device = device; | 
 | 677 |     return VK_SUCCESS; | 
 | 678 | } | 
 | 679 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 680 | void DestroyDevice(VkDevice device, | 
 | 681 |                    const VkAllocationCallbacks* /*allocator*/) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 682 |     if (!device) | 
| Jesse Hall | cf25c41 | 2015-10-29 17:14:50 -0700 | [diff] [blame] | 683 |         return; | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 684 |     device->allocator.pfnFree(device->allocator.pUserData, device); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 685 | } | 
 | 686 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 687 | void GetDeviceQueue(VkDevice device, uint32_t, uint32_t, VkQueue* queue) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 688 |     *queue = &device->queue; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 689 | } | 
 | 690 |  | 
 | 691 | // ----------------------------------------------------------------------------- | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 692 | // CommandPool | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 693 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 694 | struct CommandPool { | 
 | 695 |     typedef VkCommandPool HandleType; | 
 | 696 |     VkAllocationCallbacks allocator; | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 697 | }; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 698 | DEFINE_OBJECT_HANDLE_CONVERSION(CommandPool) | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 699 |  | 
 | 700 | VkResult CreateCommandPool(VkDevice device, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 701 |                            const VkCommandPoolCreateInfo* /*create_info*/, | 
 | 702 |                            const VkAllocationCallbacks* allocator, | 
 | 703 |                            VkCommandPool* cmd_pool) { | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 704 |     if (!allocator) | 
 | 705 |         allocator = &device->allocator; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 706 |     CommandPool* pool = static_cast<CommandPool*>(allocator->pfnAllocation( | 
 | 707 |         allocator->pUserData, sizeof(CommandPool), alignof(CommandPool), | 
 | 708 |         VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 709 |     if (!pool) | 
 | 710 |         return VK_ERROR_OUT_OF_HOST_MEMORY; | 
 | 711 |     pool->allocator = *allocator; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 712 |     *cmd_pool = GetHandleToCommandPool(pool); | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 713 |     return VK_SUCCESS; | 
 | 714 | } | 
 | 715 |  | 
 | 716 | void DestroyCommandPool(VkDevice /*device*/, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 717 |                         VkCommandPool cmd_pool, | 
 | 718 |                         const VkAllocationCallbacks* /*allocator*/) { | 
 | 719 |     CommandPool* pool = GetCommandPoolFromHandle(cmd_pool); | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 720 |     pool->allocator.pfnFree(pool->allocator.pUserData, pool); | 
 | 721 | } | 
 | 722 |  | 
 | 723 | // ----------------------------------------------------------------------------- | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 724 | // CmdBuffer | 
 | 725 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 726 | VkResult AllocateCommandBuffers(VkDevice /*device*/, | 
 | 727 |                                 const VkCommandBufferAllocateInfo* alloc_info, | 
 | 728 |                                 VkCommandBuffer* cmdbufs) { | 
| Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 729 |     VkResult result = VK_SUCCESS; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 730 |     CommandPool& pool = *GetCommandPoolFromHandle(alloc_info->commandPool); | 
| Jesse Hall | 3dd678a | 2016-01-08 21:52:01 -0800 | [diff] [blame] | 731 |     std::fill(cmdbufs, cmdbufs + alloc_info->commandBufferCount, nullptr); | 
 | 732 |     for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) { | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 733 |         cmdbufs[i] = | 
 | 734 |             static_cast<VkCommandBuffer_T*>(pool.allocator.pfnAllocation( | 
 | 735 |                 pool.allocator.pUserData, sizeof(VkCommandBuffer_T), | 
 | 736 |                 alignof(VkCommandBuffer_T), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); | 
| Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 737 |         if (!cmdbufs[i]) { | 
 | 738 |             result = VK_ERROR_OUT_OF_HOST_MEMORY; | 
 | 739 |             break; | 
 | 740 |         } | 
 | 741 |         cmdbufs[i]->dispatch.magic = HWVULKAN_DISPATCH_MAGIC; | 
 | 742 |     } | 
 | 743 |     if (result != VK_SUCCESS) { | 
| Jesse Hall | 3dd678a | 2016-01-08 21:52:01 -0800 | [diff] [blame] | 744 |         for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) { | 
| Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 745 |             if (!cmdbufs[i]) | 
 | 746 |                 break; | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 747 |             pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]); | 
| Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 748 |         } | 
 | 749 |     } | 
| Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 750 |     return result; | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 751 | } | 
 | 752 |  | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 753 | void FreeCommandBuffers(VkDevice /*device*/, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 754 |                         VkCommandPool cmd_pool, | 
| Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 755 |                         uint32_t count, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 756 |                         const VkCommandBuffer* cmdbufs) { | 
 | 757 |     CommandPool& pool = *GetCommandPoolFromHandle(cmd_pool); | 
| Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 758 |     for (uint32_t i = 0; i < count; i++) | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 759 |         pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]); | 
| Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 760 | } | 
 | 761 |  | 
 | 762 | // ----------------------------------------------------------------------------- | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 763 | // DeviceMemory | 
 | 764 |  | 
 | 765 | struct DeviceMemory { | 
 | 766 |     typedef VkDeviceMemory HandleType; | 
 | 767 |     VkDeviceSize size; | 
 | 768 |     alignas(16) uint8_t data[0]; | 
 | 769 | }; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 770 | DEFINE_OBJECT_HANDLE_CONVERSION(DeviceMemory) | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 771 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 772 | VkResult AllocateMemory(VkDevice device, | 
 | 773 |                         const VkMemoryAllocateInfo* alloc_info, | 
 | 774 |                         const VkAllocationCallbacks* allocator, | 
 | 775 |                         VkDeviceMemory* mem_handle) { | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 776 |     if (SIZE_MAX - sizeof(DeviceMemory) <= alloc_info->allocationSize) | 
 | 777 |         return VK_ERROR_OUT_OF_HOST_MEMORY; | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 778 |     if (!allocator) | 
 | 779 |         allocator = &device->allocator; | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 780 |  | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 781 |     size_t size = sizeof(DeviceMemory) + size_t(alloc_info->allocationSize); | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 782 |     DeviceMemory* mem = static_cast<DeviceMemory*>(allocator->pfnAllocation( | 
 | 783 |         allocator->pUserData, size, alignof(DeviceMemory), | 
 | 784 |         VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 785 |     if (!mem) | 
 | 786 |         return VK_ERROR_OUT_OF_HOST_MEMORY; | 
 | 787 |     mem->size = size; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 788 |     *mem_handle = GetHandleToDeviceMemory(mem); | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 789 |     return VK_SUCCESS; | 
 | 790 | } | 
 | 791 |  | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 792 | void FreeMemory(VkDevice device, | 
 | 793 |                 VkDeviceMemory mem_handle, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 794 |                 const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 795 |     if (!allocator) | 
 | 796 |         allocator = &device->allocator; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 797 |     DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle); | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 798 |     allocator->pfnFree(allocator->pUserData, mem); | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 799 | } | 
 | 800 |  | 
 | 801 | VkResult MapMemory(VkDevice, | 
 | 802 |                    VkDeviceMemory mem_handle, | 
 | 803 |                    VkDeviceSize offset, | 
 | 804 |                    VkDeviceSize, | 
 | 805 |                    VkMemoryMapFlags, | 
 | 806 |                    void** out_ptr) { | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 807 |     DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle); | 
| Jesse Hall | 2077ce0 | 2015-08-29 18:10:59 +0100 | [diff] [blame] | 808 |     *out_ptr = &mem->data[0] + offset; | 
 | 809 |     return VK_SUCCESS; | 
 | 810 | } | 
 | 811 |  | 
 | 812 | // ----------------------------------------------------------------------------- | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 813 | // Buffer | 
 | 814 |  | 
 | 815 | struct Buffer { | 
 | 816 |     typedef VkBuffer HandleType; | 
 | 817 |     VkDeviceSize size; | 
 | 818 | }; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 819 | DEFINE_OBJECT_HANDLE_CONVERSION(Buffer) | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 820 |  | 
 | 821 | VkResult CreateBuffer(VkDevice device, | 
 | 822 |                       const VkBufferCreateInfo* create_info, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 823 |                       const VkAllocationCallbacks* allocator, | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 824 |                       VkBuffer* buffer_handle) { | 
| Jesse Hall | bde8ee3 | 2015-09-01 16:24:29 -0700 | [diff] [blame] | 825 |     ALOGW_IF(create_info->size > kMaxDeviceMemory, | 
 | 826 |              "CreateBuffer: requested size 0x%" PRIx64 | 
 | 827 |              " exceeds max device memory size 0x%" PRIx64, | 
 | 828 |              create_info->size, kMaxDeviceMemory); | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 829 |     if (!allocator) | 
 | 830 |         allocator = &device->allocator; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 831 |     Buffer* buffer = static_cast<Buffer*>(allocator->pfnAllocation( | 
 | 832 |         allocator->pUserData, sizeof(Buffer), alignof(Buffer), | 
 | 833 |         VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 834 |     if (!buffer) | 
 | 835 |         return VK_ERROR_OUT_OF_HOST_MEMORY; | 
 | 836 |     buffer->size = create_info->size; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 837 |     *buffer_handle = GetHandleToBuffer(buffer); | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 838 |     return VK_SUCCESS; | 
 | 839 | } | 
 | 840 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 841 | void GetBufferMemoryRequirements(VkDevice, | 
 | 842 |                                  VkBuffer buffer_handle, | 
 | 843 |                                  VkMemoryRequirements* requirements) { | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 844 |     Buffer* buffer = GetBufferFromHandle(buffer_handle); | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 845 |     requirements->size = buffer->size; | 
 | 846 |     requirements->alignment = 16;  // allow fast Neon/SSE memcpy | 
 | 847 |     requirements->memoryTypeBits = 0x1; | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 848 | } | 
 | 849 |  | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 850 | void DestroyBuffer(VkDevice device, | 
 | 851 |                    VkBuffer buffer_handle, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 852 |                    const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 853 |     if (!allocator) | 
 | 854 |         allocator = &device->allocator; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 855 |     Buffer* buffer = GetBufferFromHandle(buffer_handle); | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 856 |     allocator->pfnFree(allocator->pUserData, buffer); | 
| Jesse Hall | f657874 | 2015-08-29 17:06:12 +0100 | [diff] [blame] | 857 | } | 
 | 858 |  | 
 | 859 | // ----------------------------------------------------------------------------- | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 860 | // Image | 
 | 861 |  | 
 | 862 | struct Image { | 
 | 863 |     typedef VkImage HandleType; | 
 | 864 |     VkDeviceSize size; | 
 | 865 | }; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 866 | DEFINE_OBJECT_HANDLE_CONVERSION(Image) | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 867 |  | 
 | 868 | VkResult CreateImage(VkDevice device, | 
 | 869 |                      const VkImageCreateInfo* create_info, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 870 |                      const VkAllocationCallbacks* allocator, | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 871 |                      VkImage* image_handle) { | 
 | 872 |     if (create_info->imageType != VK_IMAGE_TYPE_2D || | 
 | 873 |         create_info->format != VK_FORMAT_R8G8B8A8_UNORM || | 
 | 874 |         create_info->mipLevels != 1) { | 
 | 875 |         ALOGE("CreateImage: not yet implemented: type=%d format=%d mips=%u", | 
 | 876 |               create_info->imageType, create_info->format, | 
 | 877 |               create_info->mipLevels); | 
| Jesse Hall | a15a4bf | 2015-11-19 22:48:02 -0800 | [diff] [blame] | 878 |         return VK_ERROR_OUT_OF_HOST_MEMORY; | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 879 |     } | 
 | 880 |  | 
 | 881 |     VkDeviceSize size = | 
 | 882 |         VkDeviceSize(create_info->extent.width * create_info->extent.height) * | 
| Jesse Hall | a15a4bf | 2015-11-19 22:48:02 -0800 | [diff] [blame] | 883 |         create_info->arrayLayers * create_info->samples * 4u; | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 884 |     ALOGW_IF(size > kMaxDeviceMemory, | 
 | 885 |              "CreateImage: image size 0x%" PRIx64 | 
 | 886 |              " exceeds max device memory size 0x%" PRIx64, | 
 | 887 |              size, kMaxDeviceMemory); | 
 | 888 |  | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 889 |     if (!allocator) | 
 | 890 |         allocator = &device->allocator; | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 891 |     Image* image = static_cast<Image*>(allocator->pfnAllocation( | 
 | 892 |         allocator->pUserData, sizeof(Image), alignof(Image), | 
 | 893 |         VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 894 |     if (!image) | 
 | 895 |         return VK_ERROR_OUT_OF_HOST_MEMORY; | 
 | 896 |     image->size = size; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 897 |     *image_handle = GetHandleToImage(image); | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 898 |     return VK_SUCCESS; | 
 | 899 | } | 
 | 900 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 901 | void GetImageMemoryRequirements(VkDevice, | 
 | 902 |                                 VkImage image_handle, | 
 | 903 |                                 VkMemoryRequirements* requirements) { | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 904 |     Image* image = GetImageFromHandle(image_handle); | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 905 |     requirements->size = image->size; | 
 | 906 |     requirements->alignment = 16;  // allow fast Neon/SSE memcpy | 
 | 907 |     requirements->memoryTypeBits = 0x1; | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 908 | } | 
 | 909 |  | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 910 | void DestroyImage(VkDevice device, | 
 | 911 |                   VkImage image_handle, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 912 |                   const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 913 |     if (!allocator) | 
 | 914 |         allocator = &device->allocator; | 
| Jesse Hall | a3a7a1d | 2015-11-24 11:37:23 -0800 | [diff] [blame] | 915 |     Image* image = GetImageFromHandle(image_handle); | 
| Jesse Hall | 03b6fe1 | 2015-11-24 12:44:21 -0800 | [diff] [blame] | 916 |     allocator->pfnFree(allocator->pUserData, image); | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 917 | } | 
 | 918 |  | 
| Jesse Hall | 57f7f8c | 2016-01-17 17:21:36 -0800 | [diff] [blame] | 919 | VkResult GetSwapchainGrallocUsageANDROID(VkDevice, | 
 | 920 |                                          VkFormat, | 
 | 921 |                                          VkImageUsageFlags, | 
 | 922 |                                          int* grallocUsage) { | 
 | 923 |     // The null driver never reads or writes the gralloc buffer | 
 | 924 |     *grallocUsage = 0; | 
 | 925 |     return VK_SUCCESS; | 
 | 926 | } | 
 | 927 |  | 
| Chris Forbes | 8e4438b | 2016-12-07 16:26:49 +1300 | [diff] [blame] | 928 | VkResult GetSwapchainGrallocUsage2ANDROID(VkDevice, | 
 | 929 |                                           VkFormat, | 
 | 930 |                                           VkImageUsageFlags, | 
 | 931 |                                           VkSwapchainImageUsageFlagsANDROID, | 
| Jesse Hall | d1abd74 | 2017-02-09 21:45:51 -0800 | [diff] [blame] | 932 |                                           uint64_t* grallocConsumerUsage, | 
 | 933 |                                           uint64_t* grallocProducerUsage) { | 
| Chris Forbes | 8e4438b | 2016-12-07 16:26:49 +1300 | [diff] [blame] | 934 |     // The null driver never reads or writes the gralloc buffer | 
| Jesse Hall | d1abd74 | 2017-02-09 21:45:51 -0800 | [diff] [blame] | 935 |     *grallocConsumerUsage = 0; | 
 | 936 |     *grallocProducerUsage = 0; | 
| Chris Forbes | 8e4438b | 2016-12-07 16:26:49 +1300 | [diff] [blame] | 937 |     return VK_SUCCESS; | 
 | 938 | } | 
 | 939 |  | 
| Jesse Hall | 57f7f8c | 2016-01-17 17:21:36 -0800 | [diff] [blame] | 940 | VkResult AcquireImageANDROID(VkDevice, | 
 | 941 |                              VkImage, | 
 | 942 |                              int fence, | 
 | 943 |                              VkSemaphore, | 
 | 944 |                              VkFence) { | 
 | 945 |     close(fence); | 
 | 946 |     return VK_SUCCESS; | 
 | 947 | } | 
 | 948 |  | 
 | 949 | VkResult QueueSignalReleaseImageANDROID(VkQueue, | 
 | 950 |                                         uint32_t, | 
 | 951 |                                         const VkSemaphore*, | 
 | 952 |                                         VkImage, | 
 | 953 |                                         int* fence) { | 
 | 954 |     *fence = -1; | 
 | 955 |     return VK_SUCCESS; | 
 | 956 | } | 
 | 957 |  | 
| Jesse Hall | 85c05b6 | 2015-09-01 18:07:41 -0700 | [diff] [blame] | 958 | // ----------------------------------------------------------------------------- | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 959 | // No-op types | 
 | 960 |  | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 961 | VkResult CreateBufferView(VkDevice device, | 
 | 962 |                           const VkBufferViewCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 963 |                           const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 964 |                           VkBufferView* view) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 965 |     *view = AllocHandle<VkBufferView>(device, HandleType::kBufferView); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 966 |     return VK_SUCCESS; | 
 | 967 | } | 
 | 968 |  | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 969 | VkResult CreateDescriptorPool(VkDevice device, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 970 |                               const VkDescriptorPoolCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 971 |                               const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 972 |                               VkDescriptorPool* pool) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 973 |     *pool = AllocHandle<VkDescriptorPool>(device, HandleType::kDescriptorPool); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 974 |     return VK_SUCCESS; | 
 | 975 | } | 
 | 976 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 977 | VkResult AllocateDescriptorSets(VkDevice device, | 
 | 978 |                                 const VkDescriptorSetAllocateInfo* alloc_info, | 
 | 979 |                                 VkDescriptorSet* descriptor_sets) { | 
| Jesse Hall | 3dd678a | 2016-01-08 21:52:01 -0800 | [diff] [blame] | 980 |     for (uint32_t i = 0; i < alloc_info->descriptorSetCount; i++) | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 981 |         descriptor_sets[i] = | 
 | 982 |             AllocHandle<VkDescriptorSet>(device, HandleType::kDescriptorSet); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 983 |     return VK_SUCCESS; | 
 | 984 | } | 
 | 985 |  | 
 | 986 | VkResult CreateDescriptorSetLayout(VkDevice device, | 
 | 987 |                                    const VkDescriptorSetLayoutCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 988 |                                    const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 989 |                                    VkDescriptorSetLayout* layout) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 990 |     *layout = AllocHandle<VkDescriptorSetLayout>( | 
 | 991 |         device, HandleType::kDescriptorSetLayout); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 992 |     return VK_SUCCESS; | 
 | 993 | } | 
 | 994 |  | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 995 | VkResult CreateEvent(VkDevice device, | 
 | 996 |                      const VkEventCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 997 |                      const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 998 |                      VkEvent* event) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 999 |     *event = AllocHandle<VkEvent>(device, HandleType::kEvent); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1000 |     return VK_SUCCESS; | 
 | 1001 | } | 
 | 1002 |  | 
 | 1003 | VkResult CreateFence(VkDevice device, | 
 | 1004 |                      const VkFenceCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1005 |                      const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1006 |                      VkFence* fence) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1007 |     *fence = AllocHandle<VkFence>(device, HandleType::kFence); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1008 |     return VK_SUCCESS; | 
 | 1009 | } | 
 | 1010 |  | 
 | 1011 | VkResult CreateFramebuffer(VkDevice device, | 
 | 1012 |                            const VkFramebufferCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1013 |                            const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1014 |                            VkFramebuffer* framebuffer) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1015 |     *framebuffer = AllocHandle<VkFramebuffer>(device, HandleType::kFramebuffer); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1016 |     return VK_SUCCESS; | 
 | 1017 | } | 
 | 1018 |  | 
 | 1019 | VkResult CreateImageView(VkDevice device, | 
 | 1020 |                          const VkImageViewCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1021 |                          const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1022 |                          VkImageView* view) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1023 |     *view = AllocHandle<VkImageView>(device, HandleType::kImageView); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1024 |     return VK_SUCCESS; | 
 | 1025 | } | 
 | 1026 |  | 
 | 1027 | VkResult CreateGraphicsPipelines(VkDevice device, | 
 | 1028 |                                  VkPipelineCache, | 
 | 1029 |                                  uint32_t count, | 
 | 1030 |                                  const VkGraphicsPipelineCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1031 |                                  const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1032 |                                  VkPipeline* pipelines) { | 
 | 1033 |     for (uint32_t i = 0; i < count; i++) | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1034 |         pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1035 |     return VK_SUCCESS; | 
 | 1036 | } | 
 | 1037 |  | 
 | 1038 | VkResult CreateComputePipelines(VkDevice device, | 
 | 1039 |                                 VkPipelineCache, | 
 | 1040 |                                 uint32_t count, | 
 | 1041 |                                 const VkComputePipelineCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1042 |                                 const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1043 |                                 VkPipeline* pipelines) { | 
 | 1044 |     for (uint32_t i = 0; i < count; i++) | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1045 |         pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1046 |     return VK_SUCCESS; | 
 | 1047 | } | 
 | 1048 |  | 
 | 1049 | VkResult CreatePipelineCache(VkDevice device, | 
 | 1050 |                              const VkPipelineCacheCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1051 |                              const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1052 |                              VkPipelineCache* cache) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1053 |     *cache = AllocHandle<VkPipelineCache>(device, HandleType::kPipelineCache); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1054 |     return VK_SUCCESS; | 
 | 1055 | } | 
 | 1056 |  | 
 | 1057 | VkResult CreatePipelineLayout(VkDevice device, | 
 | 1058 |                               const VkPipelineLayoutCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1059 |                               const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1060 |                               VkPipelineLayout* layout) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1061 |     *layout = | 
 | 1062 |         AllocHandle<VkPipelineLayout>(device, HandleType::kPipelineLayout); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1063 |     return VK_SUCCESS; | 
 | 1064 | } | 
 | 1065 |  | 
 | 1066 | VkResult CreateQueryPool(VkDevice device, | 
 | 1067 |                          const VkQueryPoolCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1068 |                          const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1069 |                          VkQueryPool* pool) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1070 |     *pool = AllocHandle<VkQueryPool>(device, HandleType::kQueryPool); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1071 |     return VK_SUCCESS; | 
 | 1072 | } | 
 | 1073 |  | 
 | 1074 | VkResult CreateRenderPass(VkDevice device, | 
 | 1075 |                           const VkRenderPassCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1076 |                           const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1077 |                           VkRenderPass* renderpass) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1078 |     *renderpass = AllocHandle<VkRenderPass>(device, HandleType::kRenderPass); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1079 |     return VK_SUCCESS; | 
 | 1080 | } | 
 | 1081 |  | 
 | 1082 | VkResult CreateSampler(VkDevice device, | 
 | 1083 |                        const VkSamplerCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1084 |                        const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1085 |                        VkSampler* sampler) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1086 |     *sampler = AllocHandle<VkSampler>(device, HandleType::kSampler); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1087 |     return VK_SUCCESS; | 
 | 1088 | } | 
 | 1089 |  | 
 | 1090 | VkResult CreateSemaphore(VkDevice device, | 
 | 1091 |                          const VkSemaphoreCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1092 |                          const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1093 |                          VkSemaphore* semaphore) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1094 |     *semaphore = AllocHandle<VkSemaphore>(device, HandleType::kSemaphore); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1095 |     return VK_SUCCESS; | 
 | 1096 | } | 
 | 1097 |  | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1098 | VkResult CreateShaderModule(VkDevice device, | 
 | 1099 |                             const VkShaderModuleCreateInfo*, | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1100 |                             const VkAllocationCallbacks* /*allocator*/, | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1101 |                             VkShaderModule* module) { | 
| Michael Lentine | 3fec89e | 2015-12-04 16:25:11 -0800 | [diff] [blame] | 1102 |     *module = AllocHandle<VkShaderModule>(device, HandleType::kShaderModule); | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1103 |     return VK_SUCCESS; | 
 | 1104 | } | 
 | 1105 |  | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 1106 | VkResult CreateDebugReportCallbackEXT(VkInstance instance, | 
 | 1107 |                                       const VkDebugReportCallbackCreateInfoEXT*, | 
 | 1108 |                                       const VkAllocationCallbacks*, | 
 | 1109 |                                       VkDebugReportCallbackEXT* callback) { | 
 | 1110 |     *callback = AllocHandle<VkDebugReportCallbackEXT>( | 
 | 1111 |         instance, HandleType::kDebugReportCallbackEXT); | 
 | 1112 |     return VK_SUCCESS; | 
 | 1113 | } | 
 | 1114 |  | 
| Jesse Hall | f8faf0c | 2015-08-31 11:34:32 -0700 | [diff] [blame] | 1115 | // ----------------------------------------------------------------------------- | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1116 | // No-op entrypoints | 
 | 1117 |  | 
 | 1118 | // clang-format off | 
 | 1119 | #pragma clang diagnostic push | 
 | 1120 | #pragma clang diagnostic ignored "-Wunused-parameter" | 
 | 1121 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 1122 | void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1123 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1124 | } | 
 | 1125 |  | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 1126 | void GetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2KHR* pFormatProperties) { | 
 | 1127 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
 | 1128 | } | 
 | 1129 |  | 
| Jesse Hall | a9e5703 | 2015-11-30 01:03:10 -0800 | [diff] [blame] | 1130 | VkResult 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] | 1131 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | a9e5703 | 2015-11-30 01:03:10 -0800 | [diff] [blame] | 1132 |     return VK_SUCCESS; | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1133 | } | 
 | 1134 |  | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 1135 | VkResult GetPhysicalDeviceImageFormatProperties2KHR(VkPhysicalDevice physicalDevice, | 
 | 1136 |                                                     const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo, | 
 | 1137 |                                                     VkImageFormatProperties2KHR* pImageFormatProperties) { | 
 | 1138 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
 | 1139 |     return VK_SUCCESS; | 
 | 1140 | } | 
 | 1141 |  | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 1142 | VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1143 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1144 |     return VK_SUCCESS; | 
 | 1145 | } | 
 | 1146 |  | 
| Jesse Hall | a366a51 | 2015-11-19 22:30:07 -0800 | [diff] [blame] | 1147 | VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1148 |     return VK_SUCCESS; | 
 | 1149 | } | 
 | 1150 |  | 
 | 1151 | VkResult QueueWaitIdle(VkQueue queue) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1152 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1153 |     return VK_SUCCESS; | 
 | 1154 | } | 
 | 1155 |  | 
 | 1156 | VkResult DeviceWaitIdle(VkDevice device) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1157 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1158 |     return VK_SUCCESS; | 
 | 1159 | } | 
 | 1160 |  | 
| Jesse Hall | cf25c41 | 2015-10-29 17:14:50 -0700 | [diff] [blame] | 1161 | void UnmapMemory(VkDevice device, VkDeviceMemory mem) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1162 | } | 
 | 1163 |  | 
 | 1164 | VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1165 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1166 |     return VK_SUCCESS; | 
 | 1167 | } | 
 | 1168 |  | 
 | 1169 | VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1170 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1171 |     return VK_SUCCESS; | 
 | 1172 | } | 
 | 1173 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 1174 | void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1175 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1176 | } | 
 | 1177 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1178 | VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) { | 
 | 1179 |     return VK_SUCCESS; | 
 | 1180 | } | 
 | 1181 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1182 | VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) { | 
 | 1183 |     return VK_SUCCESS; | 
 | 1184 | } | 
 | 1185 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 1186 | void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1187 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1188 | } | 
 | 1189 |  | 
| Jesse Hall | 091ed9e | 2015-11-30 00:55:29 -0800 | [diff] [blame] | 1190 | void GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pNumProperties, VkSparseImageFormatProperties* pProperties) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1191 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1192 | } | 
 | 1193 |  | 
| Chris Forbes | 86bdfbe | 2017-01-26 12:45:49 +1300 | [diff] [blame] | 1194 | void GetPhysicalDeviceSparseImageFormatProperties2KHR(VkPhysicalDevice physicalDevice, | 
 | 1195 |                                                       VkPhysicalDeviceSparseImageFormatInfo2KHR const* pInfo, | 
 | 1196 |                                                       unsigned int* pNumProperties, | 
 | 1197 |                                                       VkSparseImageFormatProperties2KHR* pProperties) { | 
 | 1198 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
 | 1199 | } | 
 | 1200 |  | 
 | 1201 |  | 
| Jesse Hall | a642925 | 2015-11-29 18:59:42 -0800 | [diff] [blame] | 1202 | VkResult QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1203 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1204 |     return VK_SUCCESS; | 
 | 1205 | } | 
 | 1206 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1207 | void DestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1208 | } | 
 | 1209 |  | 
 | 1210 | VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) { | 
 | 1211 |     return VK_SUCCESS; | 
 | 1212 | } | 
 | 1213 |  | 
 | 1214 | VkResult GetFenceStatus(VkDevice device, VkFence fence) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1215 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1216 |     return VK_SUCCESS; | 
 | 1217 | } | 
 | 1218 |  | 
 | 1219 | VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) { | 
 | 1220 |     return VK_SUCCESS; | 
 | 1221 | } | 
 | 1222 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1223 | void DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1224 | } | 
 | 1225 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1226 | void DestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1227 | } | 
 | 1228 |  | 
 | 1229 | VkResult GetEventStatus(VkDevice device, VkEvent event) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1230 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1231 |     return VK_SUCCESS; | 
 | 1232 | } | 
 | 1233 |  | 
 | 1234 | VkResult SetEvent(VkDevice device, VkEvent event) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1235 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1236 |     return VK_SUCCESS; | 
 | 1237 | } | 
 | 1238 |  | 
 | 1239 | VkResult ResetEvent(VkDevice device, VkEvent event) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1240 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1241 |     return VK_SUCCESS; | 
 | 1242 | } | 
 | 1243 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1244 | void DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1245 | } | 
 | 1246 |  | 
| Jesse Hall | a9bb62b | 2015-11-21 19:31:56 -0800 | [diff] [blame] | 1247 | 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] | 1248 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1249 |     return VK_SUCCESS; | 
 | 1250 | } | 
 | 1251 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1252 | void DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1253 | } | 
 | 1254 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 1255 | void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1256 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1257 | } | 
 | 1258 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1259 | void DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1260 | } | 
 | 1261 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1262 | void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1263 | } | 
 | 1264 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1265 | void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1266 | } | 
 | 1267 |  | 
| Jesse Hall | a9bb62b | 2015-11-21 19:31:56 -0800 | [diff] [blame] | 1268 | VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1269 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1270 |     return VK_SUCCESS; | 
 | 1271 | } | 
 | 1272 |  | 
 | 1273 | VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1274 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1275 |     return VK_SUCCESS; | 
 | 1276 | } | 
 | 1277 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1278 | void DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1279 | } | 
 | 1280 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1281 | void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1282 | } | 
 | 1283 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1284 | void DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1285 | } | 
 | 1286 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1287 | void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1288 | } | 
 | 1289 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1290 | void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1291 | } | 
 | 1292 |  | 
| Jesse Hall | fbf97b0 | 2015-11-20 14:17:03 -0800 | [diff] [blame] | 1293 | VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1294 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1295 |     return VK_SUCCESS; | 
 | 1296 | } | 
 | 1297 |  | 
| Jesse Hall | cf25c41 | 2015-10-29 17:14:50 -0700 | [diff] [blame] | 1298 | 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] | 1299 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1300 | } | 
 | 1301 |  | 
 | 1302 | VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1303 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1304 |     return VK_SUCCESS; | 
 | 1305 | } | 
 | 1306 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1307 | void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1308 | } | 
 | 1309 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1310 | void DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* allocator) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1311 | } | 
 | 1312 |  | 
| Jesse Hall | 606a54e | 2015-11-19 22:17:28 -0800 | [diff] [blame] | 1313 | void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1314 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1315 | } | 
 | 1316 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1317 | VkResult ResetCommandPool(VkDevice device, VkCommandPool cmdPool, VkCommandPoolResetFlags flags) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1318 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1319 |     return VK_SUCCESS; | 
 | 1320 | } | 
 | 1321 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1322 | VkResult BeginCommandBuffer(VkCommandBuffer cmdBuffer, const VkCommandBufferBeginInfo* pBeginInfo) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1323 |     return VK_SUCCESS; | 
 | 1324 | } | 
 | 1325 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1326 | VkResult EndCommandBuffer(VkCommandBuffer cmdBuffer) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1327 |     return VK_SUCCESS; | 
 | 1328 | } | 
 | 1329 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1330 | VkResult ResetCommandBuffer(VkCommandBuffer cmdBuffer, VkCommandBufferResetFlags flags) { | 
| Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 1331 |     ALOGV("TODO: vk%s", __FUNCTION__); | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1332 |     return VK_SUCCESS; | 
 | 1333 | } | 
 | 1334 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1335 | void CmdBindPipeline(VkCommandBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1336 | } | 
 | 1337 |  | 
| Jesse Hall | f9fa9a5 | 2016-01-08 16:08:51 -0800 | [diff] [blame] | 1338 | void CmdSetViewport(VkCommandBuffer cmdBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1339 | } | 
 | 1340 |  | 
| Jesse Hall | f9fa9a5 | 2016-01-08 16:08:51 -0800 | [diff] [blame] | 1341 | void CmdSetScissor(VkCommandBuffer cmdBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1342 | } | 
 | 1343 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1344 | void CmdSetLineWidth(VkCommandBuffer cmdBuffer, float lineWidth) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1345 | } | 
 | 1346 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1347 | void CmdSetDepthBias(VkCommandBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) { | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 1348 | } | 
 | 1349 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1350 | void CmdSetBlendConstants(VkCommandBuffer cmdBuffer, const float blendConst[4]) { | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 1351 | } | 
 | 1352 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1353 | void CmdSetDepthBounds(VkCommandBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) { | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 1354 | } | 
 | 1355 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1356 | void CmdSetStencilCompareMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) { | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 1357 | } | 
 | 1358 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1359 | void CmdSetStencilWriteMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) { | 
| Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 1360 | } | 
 | 1361 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1362 | void CmdSetStencilReference(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1363 | } | 
 | 1364 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1365 | void CmdBindDescriptorSets(VkCommandBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1366 | } | 
 | 1367 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1368 | void CmdBindIndexBuffer(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1369 | } | 
 | 1370 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1371 | void CmdBindVertexBuffers(VkCommandBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1372 | } | 
 | 1373 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1374 | void CmdDraw(VkCommandBuffer 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] | 1375 | } | 
 | 1376 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1377 | void CmdDrawIndexed(VkCommandBuffer 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] | 1378 | } | 
 | 1379 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1380 | void CmdDrawIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1381 | } | 
 | 1382 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1383 | void CmdDrawIndexedIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1384 | } | 
 | 1385 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1386 | void CmdDispatch(VkCommandBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1387 | } | 
 | 1388 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1389 | void CmdDispatchIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1390 | } | 
 | 1391 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1392 | void CmdCopyBuffer(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1393 | } | 
 | 1394 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1395 | void CmdCopyImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1396 | } | 
 | 1397 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1398 | void CmdBlitImage(VkCommandBuffer 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] | 1399 | } | 
 | 1400 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1401 | void CmdCopyBufferToImage(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1402 | } | 
 | 1403 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1404 | void CmdCopyImageToBuffer(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1405 | } | 
 | 1406 |  | 
| Jesse Hall | 56d386a | 2016-07-26 15:20:40 -0700 | [diff] [blame] | 1407 | void CmdUpdateBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const void* pData) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1408 | } | 
 | 1409 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1410 | void CmdFillBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1411 | } | 
 | 1412 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1413 | void CmdClearColorImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1414 | } | 
 | 1415 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1416 | void CmdClearDepthStencilImage(VkCommandBuffer 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] | 1417 | } | 
 | 1418 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1419 | void CmdClearAttachments(VkCommandBuffer 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] | 1420 | } | 
 | 1421 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1422 | void CmdResolveImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1423 | } | 
 | 1424 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1425 | void CmdSetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1426 | } | 
 | 1427 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1428 | void CmdResetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1429 | } | 
 | 1430 |  | 
| Jesse Hall | 3dd678a | 2016-01-08 21:52:01 -0800 | [diff] [blame] | 1431 | void CmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1432 | } | 
 | 1433 |  | 
| Jesse Hall | 3dd678a | 2016-01-08 21:52:01 -0800 | [diff] [blame] | 1434 | void CmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1435 | } | 
 | 1436 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1437 | void CmdBeginQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1438 | } | 
 | 1439 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1440 | void CmdEndQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1441 | } | 
 | 1442 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1443 | void CmdResetQueryPool(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1444 | } | 
 | 1445 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1446 | void CmdWriteTimestamp(VkCommandBuffer cmdBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1447 | } | 
 | 1448 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1449 | void CmdCopyQueryPoolResults(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkQueryResultFlags flags) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1450 | } | 
 | 1451 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1452 | void CmdPushConstants(VkCommandBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1453 | } | 
 | 1454 |  | 
| Jesse Hall | 65ab552 | 2015-11-30 00:07:16 -0800 | [diff] [blame] | 1455 | void CmdBeginRenderPass(VkCommandBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1456 | } | 
 | 1457 |  | 
| Jesse Hall | 65ab552 | 2015-11-30 00:07:16 -0800 | [diff] [blame] | 1458 | void CmdNextSubpass(VkCommandBuffer cmdBuffer, VkSubpassContents contents) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1459 | } | 
 | 1460 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1461 | void CmdEndRenderPass(VkCommandBuffer cmdBuffer) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1462 | } | 
 | 1463 |  | 
| Jesse Hall | 3fbc856 | 2015-11-29 22:10:52 -0800 | [diff] [blame] | 1464 | void CmdExecuteCommands(VkCommandBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCommandBuffer* pCmdBuffers) { | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1465 | } | 
 | 1466 |  | 
| Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 1467 | void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) { | 
 | 1468 | } | 
 | 1469 |  | 
 | 1470 | void DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage) { | 
 | 1471 | } | 
 | 1472 |  | 
| Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1473 | #pragma clang diagnostic pop | 
 | 1474 | // clang-format on | 
 | 1475 |  | 
 | 1476 | }  // namespace null_driver |