blob: 9c56982ad48d7cd3fa9f36dff3c61939ec8c4552 [file] [log] [blame]
Jesse Halld02edcb2015-09-08 07:44:48 -07001/*
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 Hall04f4f472015-08-16 19:51:04 -070017#include <hardware/hwvulkan.h>
18
Jesse Hallf8faf0c2015-08-31 11:34:32 -070019#include <array>
Jesse Hall04f4f472015-08-16 19:51:04 -070020#include <algorithm>
Jesse Hallbde8ee32015-09-01 16:24:29 -070021#include <inttypes.h>
22#include <string.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070023
Jesse Hall73ab0ac2015-08-25 15:09:15 +010024// #define LOG_NDEBUG 0
25#include <log/log.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070026#include <utils/Errors.h>
27
28#include "null_driver.h"
29
30using namespace null_driver;
31
32struct VkPhysicalDevice_T {
33 hwvulkan_dispatch_t dispatch;
34};
35
36struct VkInstance_T {
37 hwvulkan_dispatch_t dispatch;
Jesse Hall03b6fe12015-11-24 12:44:21 -080038 VkAllocCallbacks allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -070039 VkPhysicalDevice_T physical_device;
40};
41
42struct VkQueue_T {
43 hwvulkan_dispatch_t dispatch;
44};
45
46struct VkCmdBuffer_T {
47 hwvulkan_dispatch_t dispatch;
48};
49
Jesse Hallf8faf0c2015-08-31 11:34:32 -070050namespace {
51// Handles for non-dispatchable objects are either pointers, or arbitrary
52// 64-bit non-zero values. We only use pointers when we need to keep state for
53// the object even in a null driver. For the rest, we form a handle as:
54// [63:63] = 1 to distinguish from pointer handles*
55// [62:56] = non-zero handle type enum value
56// [55: 0] = per-handle-type incrementing counter
57// * This works because virtual addresses with the high bit set are reserved
58// for kernel data in all ABIs we run on.
59//
60// We never reclaim handles on vkDestroy*. It's not even necessary for us to
61// have distinct handles for live objects, and practically speaking we won't
62// ever create 2^56 objects of the same type from a single VkDevice in a null
63// driver.
64//
65// Using a namespace here instead of 'enum class' since we want scoped
66// constants but also want implicit conversions to integral types.
67namespace HandleType {
Jesse Hallc7a6eb52015-08-31 12:52:03 -070068enum Enum {
Jesse Hallc7a6eb52015-08-31 12:52:03 -070069 kBufferView,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070070 kDescriptorPool,
71 kDescriptorSet,
72 kDescriptorSetLayout,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070073 kEvent,
74 kFence,
75 kFramebuffer,
76 kImageView,
77 kPipeline,
78 kPipelineCache,
79 kPipelineLayout,
80 kQueryPool,
81 kRenderPass,
82 kSampler,
83 kSemaphore,
84 kShader,
85 kShaderModule,
Jesse Hallf8faf0c2015-08-31 11:34:32 -070086
Jesse Hallc7a6eb52015-08-31 12:52:03 -070087 kNumTypes
88};
89} // namespace HandleType
Jesse Hallf8faf0c2015-08-31 11:34:32 -070090uint64_t AllocHandle(VkDevice device, HandleType::Enum type);
Jesse Hallbde8ee32015-09-01 16:24:29 -070091
92const VkDeviceSize kMaxDeviceMemory = VkDeviceSize(INTPTR_MAX) + 1;
93
Jesse Hallc7a6eb52015-08-31 12:52:03 -070094} // anonymous namespace
Jesse Hallf8faf0c2015-08-31 11:34:32 -070095
Jesse Hall04f4f472015-08-16 19:51:04 -070096struct VkDevice_T {
97 hwvulkan_dispatch_t dispatch;
Jesse Hall03b6fe12015-11-24 12:44:21 -080098 VkAllocCallbacks allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -070099 VkInstance_T* instance;
100 VkQueue_T queue;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700101 std::array<uint64_t, HandleType::kNumTypes> next_handle;
Jesse Hall04f4f472015-08-16 19:51:04 -0700102};
103
104// -----------------------------------------------------------------------------
105// Declare HAL_MODULE_INFO_SYM early so it can be referenced by nulldrv_device
106// later.
107
108namespace {
109int OpenDevice(const hw_module_t* module, const char* id, hw_device_t** device);
110hw_module_methods_t nulldrv_module_methods = {.open = OpenDevice};
111} // namespace
112
113#pragma clang diagnostic push
114#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
115__attribute__((visibility("default"))) hwvulkan_module_t HAL_MODULE_INFO_SYM = {
116 .common =
117 {
Michael Lentine03c64b02015-08-26 18:27:26 -0500118 .tag = HARDWARE_MODULE_TAG,
119 .module_api_version = HWVULKAN_MODULE_API_VERSION_0_1,
120 .hal_api_version = HARDWARE_HAL_API_VERSION,
121 .id = HWVULKAN_HARDWARE_MODULE_ID,
122 .name = "Null Vulkan Driver",
123 .author = "The Android Open Source Project",
124 .methods = &nulldrv_module_methods,
Jesse Hall04f4f472015-08-16 19:51:04 -0700125 },
126};
127#pragma clang diagnostic pop
128
129// -----------------------------------------------------------------------------
130
131namespace {
132
Jesse Hall03b6fe12015-11-24 12:44:21 -0800133VkResult CreateInstance(const VkInstanceCreateInfo* /*create_info*/,
134 const VkAllocCallbacks* allocator,
Jesse Hall04f4f472015-08-16 19:51:04 -0700135 VkInstance* out_instance) {
Jesse Hallb1352bc2015-09-04 16:12:33 -0700136 // Assume the loader provided alloc callbacks even if the app didn't.
137 ALOG_ASSERT(
Jesse Hall03b6fe12015-11-24 12:44:21 -0800138 allocator,
Jesse Hallb1352bc2015-09-04 16:12:33 -0700139 "Missing alloc callbacks, loader or app should have provided them");
140
Jesse Hall03b6fe12015-11-24 12:44:21 -0800141 VkInstance_T* instance = static_cast<VkInstance_T*>(allocator->pfnAlloc(
142 allocator->pUserData, sizeof(VkInstance_T), alignof(VkInstance_T),
143 VK_SYSTEM_ALLOC_SCOPE_INSTANCE));
Jesse Hall04f4f472015-08-16 19:51:04 -0700144 if (!instance)
145 return VK_ERROR_OUT_OF_HOST_MEMORY;
146
147 instance->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800148 instance->allocator = *allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -0700149 instance->physical_device.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
150
151 *out_instance = instance;
152 return VK_SUCCESS;
153}
154
155int CloseDevice(struct hw_device_t* /*device*/) {
156 // nothing to do - opening a device doesn't allocate any resources
157 return 0;
158}
159
160hwvulkan_device_t nulldrv_device = {
161 .common =
162 {
Michael Lentine03c64b02015-08-26 18:27:26 -0500163 .tag = HARDWARE_DEVICE_TAG,
164 .version = HWVULKAN_DEVICE_API_VERSION_0_1,
165 .module = &HAL_MODULE_INFO_SYM.common,
166 .close = CloseDevice,
Jesse Hall04f4f472015-08-16 19:51:04 -0700167 },
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700168 .EnumerateInstanceExtensionProperties =
169 EnumerateInstanceExtensionProperties,
Jesse Hall04f4f472015-08-16 19:51:04 -0700170 .CreateInstance = CreateInstance,
171 .GetInstanceProcAddr = GetInstanceProcAddr};
172
173int OpenDevice(const hw_module_t* /*module*/,
174 const char* id,
175 hw_device_t** device) {
176 if (strcmp(id, HWVULKAN_DEVICE_0) == 0) {
177 *device = &nulldrv_device.common;
178 return 0;
179 }
180 return -ENOENT;
181}
182
183VkInstance_T* GetInstanceFromPhysicalDevice(
184 VkPhysicalDevice_T* physical_device) {
185 return reinterpret_cast<VkInstance_T*>(
186 reinterpret_cast<uintptr_t>(physical_device) -
187 offsetof(VkInstance_T, physical_device));
188}
189
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700190uint64_t AllocHandle(VkDevice device, HandleType::Enum type) {
191 const uint64_t kHandleMask = (UINT64_C(1) << 56) - 1;
192 ALOGE_IF(device->next_handle[type] == kHandleMask,
Jesse Hallbde8ee32015-09-01 16:24:29 -0700193 "non-dispatchable handles of type=%u are about to overflow", type);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700194 return (UINT64_C(1) << 63) | ((uint64_t(type) & 0x7) << 56) |
195 (device->next_handle[type]++ & kHandleMask);
196}
197
Jesse Hall04f4f472015-08-16 19:51:04 -0700198} // namespace
199
200namespace null_driver {
201
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800202#define DEFINE_OBJECT_HANDLE_CONVERSION(T) \
203 T* Get##T##FromHandle(Vk##T h); \
204 T* Get##T##FromHandle(Vk##T h) { \
205 return reinterpret_cast<T*>(uintptr_t(h)); \
206 } \
207 Vk##T GetHandleTo##T(const T* obj); \
208 Vk##T GetHandleTo##T(const T* obj) { \
209 return Vk##T(reinterpret_cast<uintptr_t>(obj)); \
210 }
Jesse Hallf6578742015-08-29 17:06:12 +0100211
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100212// -----------------------------------------------------------------------------
213// Global
214
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700215VkResult EnumerateInstanceExtensionProperties(const char*,
216 uint32_t* count,
217 VkExtensionProperties*) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100218 *count = 0;
219 return VK_SUCCESS;
220}
221
Jesse Hall04f4f472015-08-16 19:51:04 -0700222PFN_vkVoidFunction GetInstanceProcAddr(VkInstance, const char* name) {
223 PFN_vkVoidFunction proc = LookupInstanceProcAddr(name);
224 if (!proc && strcmp(name, "vkGetDeviceProcAddr") == 0)
225 proc = reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr);
226 return proc;
227}
228
229PFN_vkVoidFunction GetDeviceProcAddr(VkDevice, const char* name) {
Jesse Hallb1352bc2015-09-04 16:12:33 -0700230 PFN_vkVoidFunction proc = LookupDeviceProcAddr(name);
231 if (proc)
232 return proc;
Jesse Hall70f93352015-11-04 09:41:31 -0800233 if (strcmp(name, "vkGetSwapchainGrallocUsageANDROID") == 0)
234 return reinterpret_cast<PFN_vkVoidFunction>(
235 GetSwapchainGrallocUsageANDROID);
Jesse Hallab9aeef2015-11-04 10:56:20 -0800236 if (strcmp(name, "vkAcquireImageANDROID") == 0)
237 return reinterpret_cast<PFN_vkVoidFunction>(AcquireImageANDROID);
238 if (strcmp(name, "vkQueueSignalReleaseImageANDROID") == 0)
Jesse Hallb1352bc2015-09-04 16:12:33 -0700239 return reinterpret_cast<PFN_vkVoidFunction>(
Jesse Hallab9aeef2015-11-04 10:56:20 -0800240 QueueSignalReleaseImageANDROID);
Jesse Hallb1352bc2015-09-04 16:12:33 -0700241 return nullptr;
Jesse Hall04f4f472015-08-16 19:51:04 -0700242}
243
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100244// -----------------------------------------------------------------------------
245// Instance
246
Jesse Hall03b6fe12015-11-24 12:44:21 -0800247void DestroyInstance(VkInstance instance,
248 const VkAllocCallbacks* /*allocator*/) {
249 instance->allocator.pfnFree(instance->allocator.pUserData, instance);
Jesse Hall04f4f472015-08-16 19:51:04 -0700250}
251
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100252// -----------------------------------------------------------------------------
253// PhysicalDevice
254
Jesse Hall04f4f472015-08-16 19:51:04 -0700255VkResult EnumeratePhysicalDevices(VkInstance instance,
256 uint32_t* physical_device_count,
257 VkPhysicalDevice* physical_devices) {
258 if (physical_devices && *physical_device_count >= 1)
259 physical_devices[0] = &instance->physical_device;
260 *physical_device_count = 1;
261 return VK_SUCCESS;
262}
263
Jesse Hall606a54e2015-11-19 22:17:28 -0800264void GetPhysicalDeviceProperties(VkPhysicalDevice,
265 VkPhysicalDeviceProperties* properties) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700266 properties->apiVersion = VK_API_VERSION;
267 properties->driverVersion = VK_MAKE_VERSION(0, 0, 1);
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700268 properties->vendorId = 0;
269 properties->deviceId = 0;
Jesse Hall04f4f472015-08-16 19:51:04 -0700270 properties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER;
271 strcpy(properties->deviceName, "Android Vulkan Null Driver");
272 memset(properties->pipelineCacheUUID, 0,
273 sizeof(properties->pipelineCacheUUID));
Jesse Hall04f4f472015-08-16 19:51:04 -0700274}
275
Jesse Hall606a54e2015-11-19 22:17:28 -0800276void GetPhysicalDeviceQueueFamilyProperties(
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700277 VkPhysicalDevice,
278 uint32_t* count,
279 VkQueueFamilyProperties* properties) {
280 if (properties) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700281 properties->queueFlags =
282 VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_DMA_BIT;
283 properties->queueCount = 1;
Jesse Hallacfa5342015-11-19 21:51:33 -0800284 properties->timestampValidBits = 64;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700285 }
286 *count = 1;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700287}
288
Jesse Hall606a54e2015-11-19 22:17:28 -0800289void GetPhysicalDeviceMemoryProperties(
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100290 VkPhysicalDevice,
291 VkPhysicalDeviceMemoryProperties* properties) {
292 properties->memoryTypeCount = 1;
293 properties->memoryTypes[0].propertyFlags =
294 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
295 properties->memoryTypes[0].heapIndex = 0;
296 properties->memoryHeapCount = 1;
Jesse Hallbde8ee32015-09-01 16:24:29 -0700297 properties->memoryHeaps[0].size = kMaxDeviceMemory;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700298 properties->memoryHeaps[0].flags = VK_MEMORY_HEAP_HOST_LOCAL_BIT;
Jesse Hall04f4f472015-08-16 19:51:04 -0700299}
300
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100301// -----------------------------------------------------------------------------
302// Device
303
Jesse Hall04f4f472015-08-16 19:51:04 -0700304VkResult CreateDevice(VkPhysicalDevice physical_device,
305 const VkDeviceCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800306 const VkAllocCallbacks* allocator,
Jesse Hall04f4f472015-08-16 19:51:04 -0700307 VkDevice* out_device) {
308 VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800309 if (!allocator)
310 allocator = &instance->allocator;
311 VkDevice_T* device = static_cast<VkDevice_T*>(
312 allocator->pfnAlloc(allocator->pUserData, sizeof(VkDevice_T),
313 alignof(VkDevice_T), VK_SYSTEM_ALLOC_SCOPE_DEVICE));
Jesse Hall04f4f472015-08-16 19:51:04 -0700314 if (!device)
315 return VK_ERROR_OUT_OF_HOST_MEMORY;
316
317 device->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800318 device->allocator = *allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -0700319 device->instance = instance;
320 device->queue.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700321 std::fill(device->next_handle.begin(), device->next_handle.end(),
322 UINT64_C(0));
Jesse Hall04f4f472015-08-16 19:51:04 -0700323
324 *out_device = device;
325 return VK_SUCCESS;
326}
327
Jesse Hall03b6fe12015-11-24 12:44:21 -0800328void DestroyDevice(VkDevice device, const VkAllocCallbacks* /*allocator*/) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700329 if (!device)
Jesse Hallcf25c412015-10-29 17:14:50 -0700330 return;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800331 device->allocator.pfnFree(device->allocator.pUserData, device);
Jesse Hall04f4f472015-08-16 19:51:04 -0700332}
333
Jesse Hall606a54e2015-11-19 22:17:28 -0800334void GetDeviceQueue(VkDevice device, uint32_t, uint32_t, VkQueue* queue) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700335 *queue = &device->queue;
Jesse Hall04f4f472015-08-16 19:51:04 -0700336}
337
338// -----------------------------------------------------------------------------
Jesse Hall03b6fe12015-11-24 12:44:21 -0800339// CmdPool
340
341struct CmdPool {
342 typedef VkCmdPool HandleType;
343 VkAllocCallbacks allocator;
344};
345DEFINE_OBJECT_HANDLE_CONVERSION(CmdPool)
346
347VkResult CreateCommandPool(VkDevice device,
348 const VkCmdPoolCreateInfo* /*create_info*/,
349 const VkAllocCallbacks* allocator,
350 VkCmdPool* cmd_pool) {
351 if (!allocator)
352 allocator = &device->allocator;
353 CmdPool* pool = static_cast<CmdPool*>(
354 allocator->pfnAlloc(allocator->pUserData, sizeof(CmdPool),
355 alignof(CmdPool), VK_SYSTEM_ALLOC_SCOPE_OBJECT));
356 if (!pool)
357 return VK_ERROR_OUT_OF_HOST_MEMORY;
358 pool->allocator = *allocator;
359 *cmd_pool = GetHandleToCmdPool(pool);
360 return VK_SUCCESS;
361}
362
363void DestroyCommandPool(VkDevice /*device*/,
364 VkCmdPool cmd_pool,
365 const VkAllocCallbacks* /*allocator*/) {
366 CmdPool* pool = GetCmdPoolFromHandle(cmd_pool);
367 pool->allocator.pfnFree(pool->allocator.pUserData, pool);
368}
369
370// -----------------------------------------------------------------------------
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700371// CmdBuffer
372
Jesse Hall03b6fe12015-11-24 12:44:21 -0800373VkResult AllocCommandBuffers(VkDevice /*device*/,
Jesse Hallfbf97b02015-11-20 14:17:03 -0800374 const VkCmdBufferAllocInfo* alloc_info,
375 VkCmdBuffer* cmdbufs) {
376 VkResult result = VK_SUCCESS;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800377 CmdPool& pool = *GetCmdPoolFromHandle(alloc_info->cmdPool);
378 std::fill(cmdbufs, cmdbufs + alloc_info->bufferCount, nullptr);
379 for (uint32_t i = 0; i < alloc_info->bufferCount; i++) {
380 cmdbufs[i] = static_cast<VkCmdBuffer_T*>(pool.allocator.pfnAlloc(
381 pool.allocator.pUserData, sizeof(VkCmdBuffer_T),
382 alignof(VkCmdBuffer_T), VK_SYSTEM_ALLOC_SCOPE_OBJECT));
Jesse Hallfbf97b02015-11-20 14:17:03 -0800383 if (!cmdbufs[i]) {
384 result = VK_ERROR_OUT_OF_HOST_MEMORY;
385 break;
386 }
387 cmdbufs[i]->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
388 }
389 if (result != VK_SUCCESS) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800390 for (uint32_t i = 0; i < alloc_info->bufferCount; i++) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800391 if (!cmdbufs[i])
392 break;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800393 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800394 }
395 }
Jesse Hallfbf97b02015-11-20 14:17:03 -0800396 return result;
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700397}
398
Jesse Hall03b6fe12015-11-24 12:44:21 -0800399void FreeCommandBuffers(VkDevice /*device*/,
400 VkCmdPool cmd_pool,
Jesse Hallfbf97b02015-11-20 14:17:03 -0800401 uint32_t count,
402 const VkCmdBuffer* cmdbufs) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800403 CmdPool& pool = *GetCmdPoolFromHandle(cmd_pool);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800404 for (uint32_t i = 0; i < count; i++)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800405 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700406}
407
408// -----------------------------------------------------------------------------
Jesse Hall2077ce02015-08-29 18:10:59 +0100409// DeviceMemory
410
411struct DeviceMemory {
412 typedef VkDeviceMemory HandleType;
413 VkDeviceSize size;
414 alignas(16) uint8_t data[0];
415};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800416DEFINE_OBJECT_HANDLE_CONVERSION(DeviceMemory)
Jesse Hall2077ce02015-08-29 18:10:59 +0100417
418VkResult AllocMemory(VkDevice device,
419 const VkMemoryAllocInfo* alloc_info,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800420 const VkAllocCallbacks* allocator,
Jesse Hall2077ce02015-08-29 18:10:59 +0100421 VkDeviceMemory* mem_handle) {
422 if (SIZE_MAX - sizeof(DeviceMemory) <= alloc_info->allocationSize)
423 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800424 if (!allocator)
425 allocator = &device->allocator;
Jesse Hall2077ce02015-08-29 18:10:59 +0100426
Jesse Hall2077ce02015-08-29 18:10:59 +0100427 size_t size = sizeof(DeviceMemory) + size_t(alloc_info->allocationSize);
428 DeviceMemory* mem = static_cast<DeviceMemory*>(
Jesse Hall03b6fe12015-11-24 12:44:21 -0800429 allocator->pfnAlloc(allocator->pUserData, size, alignof(DeviceMemory),
430 VK_SYSTEM_ALLOC_SCOPE_OBJECT));
Jesse Hall2077ce02015-08-29 18:10:59 +0100431 if (!mem)
432 return VK_ERROR_OUT_OF_HOST_MEMORY;
433 mem->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800434 *mem_handle = GetHandleToDeviceMemory(mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100435 return VK_SUCCESS;
436}
437
Jesse Hall03b6fe12015-11-24 12:44:21 -0800438void FreeMemory(VkDevice device,
439 VkDeviceMemory mem_handle,
440 const VkAllocCallbacks* allocator) {
441 if (!allocator)
442 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800443 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800444 allocator->pfnFree(allocator->pUserData, mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100445}
446
447VkResult MapMemory(VkDevice,
448 VkDeviceMemory mem_handle,
449 VkDeviceSize offset,
450 VkDeviceSize,
451 VkMemoryMapFlags,
452 void** out_ptr) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800453 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall2077ce02015-08-29 18:10:59 +0100454 *out_ptr = &mem->data[0] + offset;
455 return VK_SUCCESS;
456}
457
458// -----------------------------------------------------------------------------
Jesse Hallf6578742015-08-29 17:06:12 +0100459// Buffer
460
461struct Buffer {
462 typedef VkBuffer HandleType;
463 VkDeviceSize size;
464};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800465DEFINE_OBJECT_HANDLE_CONVERSION(Buffer)
Jesse Hallf6578742015-08-29 17:06:12 +0100466
467VkResult CreateBuffer(VkDevice device,
468 const VkBufferCreateInfo* create_info,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800469 const VkAllocCallbacks* allocator,
Jesse Hallf6578742015-08-29 17:06:12 +0100470 VkBuffer* buffer_handle) {
Jesse Hallbde8ee32015-09-01 16:24:29 -0700471 ALOGW_IF(create_info->size > kMaxDeviceMemory,
472 "CreateBuffer: requested size 0x%" PRIx64
473 " exceeds max device memory size 0x%" PRIx64,
474 create_info->size, kMaxDeviceMemory);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800475 if (!allocator)
476 allocator = &device->allocator;
Jesse Hallf6578742015-08-29 17:06:12 +0100477 Buffer* buffer = static_cast<Buffer*>(
Jesse Hall03b6fe12015-11-24 12:44:21 -0800478 allocator->pfnAlloc(allocator->pUserData, sizeof(Buffer),
479 alignof(Buffer), VK_SYSTEM_ALLOC_SCOPE_OBJECT));
Jesse Hallf6578742015-08-29 17:06:12 +0100480 if (!buffer)
481 return VK_ERROR_OUT_OF_HOST_MEMORY;
482 buffer->size = create_info->size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800483 *buffer_handle = GetHandleToBuffer(buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100484 return VK_SUCCESS;
485}
486
Jesse Hall606a54e2015-11-19 22:17:28 -0800487void GetBufferMemoryRequirements(VkDevice,
488 VkBuffer buffer_handle,
489 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800490 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hallf6578742015-08-29 17:06:12 +0100491 requirements->size = buffer->size;
492 requirements->alignment = 16; // allow fast Neon/SSE memcpy
493 requirements->memoryTypeBits = 0x1;
Jesse Hallf6578742015-08-29 17:06:12 +0100494}
495
Jesse Hall03b6fe12015-11-24 12:44:21 -0800496void DestroyBuffer(VkDevice device,
497 VkBuffer buffer_handle,
498 const VkAllocCallbacks* allocator) {
499 if (!allocator)
500 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800501 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800502 allocator->pfnFree(allocator->pUserData, buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100503}
504
505// -----------------------------------------------------------------------------
Jesse Hall85c05b62015-09-01 18:07:41 -0700506// Image
507
508struct Image {
509 typedef VkImage HandleType;
510 VkDeviceSize size;
511};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800512DEFINE_OBJECT_HANDLE_CONVERSION(Image)
Jesse Hall85c05b62015-09-01 18:07:41 -0700513
514VkResult CreateImage(VkDevice device,
515 const VkImageCreateInfo* create_info,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800516 const VkAllocCallbacks* allocator,
Jesse Hall85c05b62015-09-01 18:07:41 -0700517 VkImage* image_handle) {
518 if (create_info->imageType != VK_IMAGE_TYPE_2D ||
519 create_info->format != VK_FORMAT_R8G8B8A8_UNORM ||
520 create_info->mipLevels != 1) {
521 ALOGE("CreateImage: not yet implemented: type=%d format=%d mips=%u",
522 create_info->imageType, create_info->format,
523 create_info->mipLevels);
Jesse Halla15a4bf2015-11-19 22:48:02 -0800524 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall85c05b62015-09-01 18:07:41 -0700525 }
526
527 VkDeviceSize size =
528 VkDeviceSize(create_info->extent.width * create_info->extent.height) *
Jesse Halla15a4bf2015-11-19 22:48:02 -0800529 create_info->arrayLayers * create_info->samples * 4u;
Jesse Hall85c05b62015-09-01 18:07:41 -0700530 ALOGW_IF(size > kMaxDeviceMemory,
531 "CreateImage: image size 0x%" PRIx64
532 " exceeds max device memory size 0x%" PRIx64,
533 size, kMaxDeviceMemory);
534
Jesse Hall03b6fe12015-11-24 12:44:21 -0800535 if (!allocator)
536 allocator = &device->allocator;
Jesse Hall85c05b62015-09-01 18:07:41 -0700537 Image* image = static_cast<Image*>(
Jesse Hall03b6fe12015-11-24 12:44:21 -0800538 allocator->pfnAlloc(allocator->pUserData, sizeof(Image), alignof(Image),
539 VK_SYSTEM_ALLOC_SCOPE_OBJECT));
Jesse Hall85c05b62015-09-01 18:07:41 -0700540 if (!image)
541 return VK_ERROR_OUT_OF_HOST_MEMORY;
542 image->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800543 *image_handle = GetHandleToImage(image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700544 return VK_SUCCESS;
545}
546
Jesse Hall606a54e2015-11-19 22:17:28 -0800547void GetImageMemoryRequirements(VkDevice,
548 VkImage image_handle,
549 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800550 Image* image = GetImageFromHandle(image_handle);
Jesse Hall85c05b62015-09-01 18:07:41 -0700551 requirements->size = image->size;
552 requirements->alignment = 16; // allow fast Neon/SSE memcpy
553 requirements->memoryTypeBits = 0x1;
Jesse Hall85c05b62015-09-01 18:07:41 -0700554}
555
Jesse Hall03b6fe12015-11-24 12:44:21 -0800556void DestroyImage(VkDevice device,
557 VkImage image_handle,
558 const VkAllocCallbacks* allocator) {
559 if (!allocator)
560 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800561 Image* image = GetImageFromHandle(image_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800562 allocator->pfnFree(allocator->pUserData, image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700563}
564
565// -----------------------------------------------------------------------------
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700566// No-op types
567
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700568VkResult CreateBufferView(VkDevice device,
569 const VkBufferViewCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800570 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700571 VkBufferView* view) {
572 *view = AllocHandle(device, HandleType::kBufferView);
573 return VK_SUCCESS;
574}
575
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700576VkResult CreateDescriptorPool(VkDevice device,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700577 const VkDescriptorPoolCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800578 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700579 VkDescriptorPool* pool) {
580 *pool = AllocHandle(device, HandleType::kDescriptorPool);
581 return VK_SUCCESS;
582}
583
584VkResult AllocDescriptorSets(VkDevice device,
Jesse Hallfbf97b02015-11-20 14:17:03 -0800585 const VkDescriptorSetAllocInfo* alloc_info,
586 VkDescriptorSet* descriptor_sets) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800587 for (uint32_t i = 0; i < alloc_info->setLayoutCount; i++)
Jesse Hallfbf97b02015-11-20 14:17:03 -0800588 descriptor_sets[i] = AllocHandle(device, HandleType::kDescriptorSet);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700589 return VK_SUCCESS;
590}
591
592VkResult CreateDescriptorSetLayout(VkDevice device,
593 const VkDescriptorSetLayoutCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800594 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700595 VkDescriptorSetLayout* layout) {
596 *layout = AllocHandle(device, HandleType::kDescriptorSetLayout);
597 return VK_SUCCESS;
598}
599
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700600VkResult CreateEvent(VkDevice device,
601 const VkEventCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800602 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700603 VkEvent* event) {
604 *event = AllocHandle(device, HandleType::kEvent);
605 return VK_SUCCESS;
606}
607
608VkResult CreateFence(VkDevice device,
609 const VkFenceCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800610 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700611 VkFence* fence) {
612 *fence = AllocHandle(device, HandleType::kFence);
613 return VK_SUCCESS;
614}
615
616VkResult CreateFramebuffer(VkDevice device,
617 const VkFramebufferCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800618 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700619 VkFramebuffer* framebuffer) {
620 *framebuffer = AllocHandle(device, HandleType::kFramebuffer);
621 return VK_SUCCESS;
622}
623
624VkResult CreateImageView(VkDevice device,
625 const VkImageViewCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800626 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700627 VkImageView* view) {
628 *view = AllocHandle(device, HandleType::kImageView);
629 return VK_SUCCESS;
630}
631
632VkResult CreateGraphicsPipelines(VkDevice device,
633 VkPipelineCache,
634 uint32_t count,
635 const VkGraphicsPipelineCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800636 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700637 VkPipeline* pipelines) {
638 for (uint32_t i = 0; i < count; i++)
639 pipelines[i] = AllocHandle(device, HandleType::kPipeline);
640 return VK_SUCCESS;
641}
642
643VkResult CreateComputePipelines(VkDevice device,
644 VkPipelineCache,
645 uint32_t count,
646 const VkComputePipelineCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800647 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700648 VkPipeline* pipelines) {
649 for (uint32_t i = 0; i < count; i++)
650 pipelines[i] = AllocHandle(device, HandleType::kPipeline);
651 return VK_SUCCESS;
652}
653
654VkResult CreatePipelineCache(VkDevice device,
655 const VkPipelineCacheCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800656 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700657 VkPipelineCache* cache) {
658 *cache = AllocHandle(device, HandleType::kPipelineCache);
659 return VK_SUCCESS;
660}
661
662VkResult CreatePipelineLayout(VkDevice device,
663 const VkPipelineLayoutCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800664 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700665 VkPipelineLayout* layout) {
666 *layout = AllocHandle(device, HandleType::kPipelineLayout);
667 return VK_SUCCESS;
668}
669
670VkResult CreateQueryPool(VkDevice device,
671 const VkQueryPoolCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800672 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700673 VkQueryPool* pool) {
674 *pool = AllocHandle(device, HandleType::kQueryPool);
675 return VK_SUCCESS;
676}
677
678VkResult CreateRenderPass(VkDevice device,
679 const VkRenderPassCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800680 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700681 VkRenderPass* renderpass) {
682 *renderpass = AllocHandle(device, HandleType::kRenderPass);
683 return VK_SUCCESS;
684}
685
686VkResult CreateSampler(VkDevice device,
687 const VkSamplerCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800688 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700689 VkSampler* sampler) {
690 *sampler = AllocHandle(device, HandleType::kSampler);
691 return VK_SUCCESS;
692}
693
694VkResult CreateSemaphore(VkDevice device,
695 const VkSemaphoreCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800696 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700697 VkSemaphore* semaphore) {
698 *semaphore = AllocHandle(device, HandleType::kSemaphore);
699 return VK_SUCCESS;
700}
701
702VkResult CreateShader(VkDevice device,
703 const VkShaderCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800704 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700705 VkShader* shader) {
706 *shader = AllocHandle(device, HandleType::kShader);
707 return VK_SUCCESS;
708}
709
710VkResult CreateShaderModule(VkDevice device,
711 const VkShaderModuleCreateInfo*,
Jesse Hall03b6fe12015-11-24 12:44:21 -0800712 const VkAllocCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700713 VkShaderModule* module) {
714 *module = AllocHandle(device, HandleType::kShaderModule);
715 return VK_SUCCESS;
716}
717
Jesse Hall70f93352015-11-04 09:41:31 -0800718VkResult GetSwapchainGrallocUsageANDROID(VkDevice,
719 VkFormat,
720 VkImageUsageFlags,
721 int* grallocUsage) {
722 // The null driver never reads or writes the gralloc buffer
723 *grallocUsage = 0;
724 return VK_SUCCESS;
725}
726
Jesse Hallab9aeef2015-11-04 10:56:20 -0800727VkResult AcquireImageANDROID(VkDevice, VkImage, int fence, VkSemaphore) {
Jesse Halld7b994a2015-09-07 14:17:37 -0700728 close(fence);
729 return VK_SUCCESS;
730}
731
Jesse Hallab9aeef2015-11-04 10:56:20 -0800732VkResult QueueSignalReleaseImageANDROID(VkQueue, VkImage, int* fence) {
Jesse Halld7b994a2015-09-07 14:17:37 -0700733 *fence = -1;
734 return VK_SUCCESS;
735}
736
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700737// -----------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -0700738// No-op entrypoints
739
740// clang-format off
741#pragma clang diagnostic push
742#pragma clang diagnostic ignored "-Wunused-parameter"
743
Jesse Hall606a54e2015-11-19 22:17:28 -0800744void GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100745 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700746}
747
Jesse Hall606a54e2015-11-19 22:17:28 -0800748void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100749 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700750}
751
Jesse Hall606a54e2015-11-19 22:17:28 -0800752void GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100753 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700754}
755
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700756VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100757 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700758 return VK_SUCCESS;
759}
760
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700761VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100762 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700763 return VK_SUCCESS;
764}
765
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700766VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100767 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700768 return VK_SUCCESS;
769}
770
Jesse Halla366a512015-11-19 22:30:07 -0800771VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700772 return VK_SUCCESS;
773}
774
775VkResult QueueWaitIdle(VkQueue queue) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100776 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700777 return VK_SUCCESS;
778}
779
780VkResult DeviceWaitIdle(VkDevice device) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100781 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700782 return VK_SUCCESS;
783}
784
Jesse Hallcf25c412015-10-29 17:14:50 -0700785void UnmapMemory(VkDevice device, VkDeviceMemory mem) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700786}
787
788VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100789 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700790 return VK_SUCCESS;
791}
792
793VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100794 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700795 return VK_SUCCESS;
796}
797
Jesse Hall606a54e2015-11-19 22:17:28 -0800798void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100799 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700800}
801
Jesse Hall04f4f472015-08-16 19:51:04 -0700802VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) {
803 return VK_SUCCESS;
804}
805
Jesse Hall04f4f472015-08-16 19:51:04 -0700806VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) {
807 return VK_SUCCESS;
808}
809
Jesse Hall606a54e2015-11-19 22:17:28 -0800810void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100811 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700812}
813
Jesse Hall606a54e2015-11-19 22:17:28 -0800814void GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, uint32_t samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pNumProperties, VkSparseImageFormatProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100815 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700816}
817
818VkResult QueueBindSparseBufferMemory(VkQueue queue, VkBuffer buffer, uint32_t numBindings, const VkSparseMemoryBindInfo* pBindInfo) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100819 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700820 return VK_SUCCESS;
821}
822
823VkResult QueueBindSparseImageOpaqueMemory(VkQueue queue, VkImage image, uint32_t numBindings, const VkSparseMemoryBindInfo* pBindInfo) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100824 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700825 return VK_SUCCESS;
826}
827
828VkResult QueueBindSparseImageMemory(VkQueue queue, VkImage image, uint32_t numBindings, const VkSparseImageMemoryBindInfo* pBindInfo) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100829 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700830 return VK_SUCCESS;
831}
832
Jesse Hall03b6fe12015-11-24 12:44:21 -0800833void DestroyFence(VkDevice device, VkFence fence, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700834}
835
836VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) {
837 return VK_SUCCESS;
838}
839
840VkResult GetFenceStatus(VkDevice device, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100841 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700842 return VK_SUCCESS;
843}
844
845VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) {
846 return VK_SUCCESS;
847}
848
Jesse Hall03b6fe12015-11-24 12:44:21 -0800849void DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700850}
851
Jesse Hall03b6fe12015-11-24 12:44:21 -0800852void DestroyEvent(VkDevice device, VkEvent event, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700853}
854
855VkResult GetEventStatus(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100856 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700857 return VK_SUCCESS;
858}
859
860VkResult SetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100861 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700862 return VK_SUCCESS;
863}
864
865VkResult ResetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100866 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700867 return VK_SUCCESS;
868}
869
Jesse Hall03b6fe12015-11-24 12:44:21 -0800870void DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700871}
872
Jesse Halla9bb62b2015-11-21 19:31:56 -0800873VkResult GetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100874 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700875 return VK_SUCCESS;
876}
877
Jesse Hall03b6fe12015-11-24 12:44:21 -0800878void DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700879}
880
Jesse Hall606a54e2015-11-19 22:17:28 -0800881void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100882 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700883}
884
Jesse Hall03b6fe12015-11-24 12:44:21 -0800885void DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700886}
887
Jesse Hall03b6fe12015-11-24 12:44:21 -0800888void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700889}
890
Jesse Hall03b6fe12015-11-24 12:44:21 -0800891void DestroyShader(VkDevice device, VkShader shader, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700892}
893
Jesse Hall03b6fe12015-11-24 12:44:21 -0800894void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700895}
896
Jesse Halla9bb62b2015-11-21 19:31:56 -0800897VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100898 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700899 return VK_SUCCESS;
900}
901
902VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100903 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700904 return VK_SUCCESS;
905}
906
Jesse Hall03b6fe12015-11-24 12:44:21 -0800907void DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700908}
909
Jesse Hall03b6fe12015-11-24 12:44:21 -0800910void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700911}
912
Jesse Hall03b6fe12015-11-24 12:44:21 -0800913void DestroySampler(VkDevice device, VkSampler sampler, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700914}
915
Jesse Hall03b6fe12015-11-24 12:44:21 -0800916void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700917}
918
Jesse Hall03b6fe12015-11-24 12:44:21 -0800919void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700920}
921
Jesse Hallfbf97b02015-11-20 14:17:03 -0800922VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100923 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700924 return VK_SUCCESS;
925}
926
Jesse Hallcf25c412015-10-29 17:14:50 -0700927void UpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100928 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700929}
930
931VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100932 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700933 return VK_SUCCESS;
934}
935
Jesse Hall03b6fe12015-11-24 12:44:21 -0800936void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700937}
938
Jesse Hall03b6fe12015-11-24 12:44:21 -0800939void DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700940}
941
Jesse Hall606a54e2015-11-19 22:17:28 -0800942void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100943 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700944}
945
Jesse Hall04f4f472015-08-16 19:51:04 -0700946VkResult ResetCommandPool(VkDevice device, VkCmdPool cmdPool, VkCmdPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100947 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700948 return VK_SUCCESS;
949}
950
Jesse Hall04f4f472015-08-16 19:51:04 -0700951VkResult BeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo) {
952 return VK_SUCCESS;
953}
954
955VkResult EndCommandBuffer(VkCmdBuffer cmdBuffer) {
956 return VK_SUCCESS;
957}
958
959VkResult ResetCommandBuffer(VkCmdBuffer cmdBuffer, VkCmdBufferResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100960 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700961 return VK_SUCCESS;
962}
963
964void CmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) {
965}
966
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700967void CmdSetViewport(VkCmdBuffer cmdBuffer, uint32_t viewportCount, const VkViewport* pViewports) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700968}
969
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700970void CmdSetScissor(VkCmdBuffer cmdBuffer, uint32_t scissorCount, const VkRect2D* pScissors) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700971}
972
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700973void CmdSetLineWidth(VkCmdBuffer cmdBuffer, float lineWidth) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700974}
975
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700976void CmdSetDepthBias(VkCmdBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) {
977}
978
979void CmdSetBlendConstants(VkCmdBuffer cmdBuffer, const float blendConst[4]) {
980}
981
982void CmdSetDepthBounds(VkCmdBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) {
983}
984
985void CmdSetStencilCompareMask(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) {
986}
987
988void CmdSetStencilWriteMask(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) {
989}
990
991void CmdSetStencilReference(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700992}
993
994void CmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets) {
995}
996
997void CmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) {
998}
999
1000void CmdBindVertexBuffers(VkCmdBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) {
1001}
1002
Jesse Hallcf25c412015-10-29 17:14:50 -07001003void CmdDraw(VkCmdBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001004}
1005
Jesse Hallcf25c412015-10-29 17:14:50 -07001006void CmdDrawIndexed(VkCmdBuffer cmdBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001007}
1008
1009void CmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
1010}
1011
1012void CmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
1013}
1014
1015void CmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) {
1016}
1017
1018void CmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) {
1019}
1020
1021void CmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) {
1022}
1023
1024void CmdCopyImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) {
1025}
1026
Jesse Hall23ff73f2015-11-29 14:36:39 -08001027void CmdBlitImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001028}
1029
1030void CmdCopyBufferToImage(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
1031}
1032
1033void CmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
1034}
1035
1036void CmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) {
1037}
1038
1039void CmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) {
1040}
1041
1042void CmdClearColorImage(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
1043}
1044
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001045void CmdClearDepthStencilImage(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001046}
1047
Jesse Halla15a4bf2015-11-19 22:48:02 -08001048void CmdClearAttachments(VkCmdBuffer cmdBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001049}
1050
1051void CmdResolveImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) {
1052}
1053
1054void CmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
1055}
1056
1057void CmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
1058}
1059
1060void CmdWaitEvents(VkCmdBuffer cmdBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, uint32_t memBarrierCount, const void* const* ppMemBarriers) {
1061}
1062
1063void CmdPipelineBarrier(VkCmdBuffer cmdBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, VkBool32 byRegion, uint32_t memBarrierCount, const void* const* ppMemBarriers) {
1064}
1065
1066void CmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) {
1067}
1068
1069void CmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) {
1070}
1071
1072void CmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) {
1073}
1074
Jesse Halla3a7a1d2015-11-24 11:37:23 -08001075void CmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001076}
1077
1078void CmdCopyQueryPoolResults(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkQueryResultFlags flags) {
1079}
1080
1081void CmdPushConstants(VkCmdBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) {
1082}
1083
1084void CmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkRenderPassContents contents) {
1085}
1086
1087void CmdNextSubpass(VkCmdBuffer cmdBuffer, VkRenderPassContents contents) {
1088}
1089
1090void CmdEndRenderPass(VkCmdBuffer cmdBuffer) {
1091}
1092
1093void CmdExecuteCommands(VkCmdBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCmdBuffer* pCmdBuffers) {
1094}
1095
Jesse Hall04f4f472015-08-16 19:51:04 -07001096#pragma clang diagnostic pop
1097// clang-format on
1098
1099} // namespace null_driver