blob: 7e890befb7b16ac87042fb28d64f5458ebd455c6 [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;
38 const VkAllocCallbacks* alloc;
39 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,
70 kCmdPool,
71 kDescriptorPool,
72 kDescriptorSet,
73 kDescriptorSetLayout,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070074 kEvent,
75 kFence,
76 kFramebuffer,
77 kImageView,
78 kPipeline,
79 kPipelineCache,
80 kPipelineLayout,
81 kQueryPool,
82 kRenderPass,
83 kSampler,
84 kSemaphore,
85 kShader,
86 kShaderModule,
Jesse Hallf8faf0c2015-08-31 11:34:32 -070087
Jesse Hallc7a6eb52015-08-31 12:52:03 -070088 kNumTypes
89};
90} // namespace HandleType
Jesse Hallf8faf0c2015-08-31 11:34:32 -070091uint64_t AllocHandle(VkDevice device, HandleType::Enum type);
Jesse Hallbde8ee32015-09-01 16:24:29 -070092
93const VkDeviceSize kMaxDeviceMemory = VkDeviceSize(INTPTR_MAX) + 1;
94
Jesse Hallc7a6eb52015-08-31 12:52:03 -070095} // anonymous namespace
Jesse Hallf8faf0c2015-08-31 11:34:32 -070096
Jesse Hall04f4f472015-08-16 19:51:04 -070097struct VkDevice_T {
98 hwvulkan_dispatch_t dispatch;
99 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
133VkResult CreateInstance(const VkInstanceCreateInfo* create_info,
134 VkInstance* out_instance) {
Jesse Hallb1352bc2015-09-04 16:12:33 -0700135 // Assume the loader provided alloc callbacks even if the app didn't.
136 ALOG_ASSERT(
Jesse Halld7b994a2015-09-07 14:17:37 -0700137 create_info->pAllocCb,
Jesse Hallb1352bc2015-09-04 16:12:33 -0700138 "Missing alloc callbacks, loader or app should have provided them");
139
Jesse Hall04f4f472015-08-16 19:51:04 -0700140 VkInstance_T* instance =
141 static_cast<VkInstance_T*>(create_info->pAllocCb->pfnAlloc(
142 create_info->pAllocCb->pUserData, sizeof(VkInstance_T),
143 alignof(VkInstance_T), VK_SYSTEM_ALLOC_TYPE_API_OBJECT));
144 if (!instance)
145 return VK_ERROR_OUT_OF_HOST_MEMORY;
146
147 instance->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
148 instance->alloc = create_info->pAllocCb;
149 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 Hallf6578742015-08-29 17:06:12 +0100202template <typename HandleT>
203struct HandleTraits {};
204
205template <typename HandleT>
206typename HandleTraits<HandleT>::PointerType GetObjectFromHandle(
207 const HandleT& h) {
208 return reinterpret_cast<typename HandleTraits<HandleT>::PointerType>(
209 uintptr_t(h.handle));
210}
211
212template <typename T>
213typename T::HandleType GetHandleToObject(const T* obj) {
214 return typename T::HandleType(reinterpret_cast<uintptr_t>(obj));
215}
216
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100217// -----------------------------------------------------------------------------
218// Global
219
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700220VkResult EnumerateInstanceExtensionProperties(const char*,
221 uint32_t* count,
222 VkExtensionProperties*) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100223 *count = 0;
224 return VK_SUCCESS;
225}
226
Jesse Hall04f4f472015-08-16 19:51:04 -0700227PFN_vkVoidFunction GetInstanceProcAddr(VkInstance, const char* name) {
228 PFN_vkVoidFunction proc = LookupInstanceProcAddr(name);
229 if (!proc && strcmp(name, "vkGetDeviceProcAddr") == 0)
230 proc = reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr);
231 return proc;
232}
233
234PFN_vkVoidFunction GetDeviceProcAddr(VkDevice, const char* name) {
Jesse Hallb1352bc2015-09-04 16:12:33 -0700235 PFN_vkVoidFunction proc = LookupDeviceProcAddr(name);
236 if (proc)
237 return proc;
Jesse Hall70f93352015-11-04 09:41:31 -0800238 if (strcmp(name, "vkGetSwapchainGrallocUsageANDROID") == 0)
239 return reinterpret_cast<PFN_vkVoidFunction>(
240 GetSwapchainGrallocUsageANDROID);
Jesse Hallab9aeef2015-11-04 10:56:20 -0800241 if (strcmp(name, "vkAcquireImageANDROID") == 0)
242 return reinterpret_cast<PFN_vkVoidFunction>(AcquireImageANDROID);
243 if (strcmp(name, "vkQueueSignalReleaseImageANDROID") == 0)
Jesse Hallb1352bc2015-09-04 16:12:33 -0700244 return reinterpret_cast<PFN_vkVoidFunction>(
Jesse Hallab9aeef2015-11-04 10:56:20 -0800245 QueueSignalReleaseImageANDROID);
Jesse Hallb1352bc2015-09-04 16:12:33 -0700246 return nullptr;
Jesse Hall04f4f472015-08-16 19:51:04 -0700247}
248
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100249// -----------------------------------------------------------------------------
250// Instance
251
Jesse Hallcf25c412015-10-29 17:14:50 -0700252void DestroyInstance(VkInstance instance) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700253 instance->alloc->pfnFree(instance->alloc->pUserData, instance);
Jesse Hall04f4f472015-08-16 19:51:04 -0700254}
255
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100256// -----------------------------------------------------------------------------
257// PhysicalDevice
258
Jesse Hall04f4f472015-08-16 19:51:04 -0700259VkResult EnumeratePhysicalDevices(VkInstance instance,
260 uint32_t* physical_device_count,
261 VkPhysicalDevice* physical_devices) {
262 if (physical_devices && *physical_device_count >= 1)
263 physical_devices[0] = &instance->physical_device;
264 *physical_device_count = 1;
265 return VK_SUCCESS;
266}
267
Jesse Hall606a54e2015-11-19 22:17:28 -0800268void GetPhysicalDeviceProperties(VkPhysicalDevice,
269 VkPhysicalDeviceProperties* properties) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700270 properties->apiVersion = VK_API_VERSION;
271 properties->driverVersion = VK_MAKE_VERSION(0, 0, 1);
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700272 properties->vendorId = 0;
273 properties->deviceId = 0;
Jesse Hall04f4f472015-08-16 19:51:04 -0700274 properties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER;
275 strcpy(properties->deviceName, "Android Vulkan Null Driver");
276 memset(properties->pipelineCacheUUID, 0,
277 sizeof(properties->pipelineCacheUUID));
Jesse Hall04f4f472015-08-16 19:51:04 -0700278}
279
Jesse Hall606a54e2015-11-19 22:17:28 -0800280void GetPhysicalDeviceQueueFamilyProperties(
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700281 VkPhysicalDevice,
282 uint32_t* count,
283 VkQueueFamilyProperties* properties) {
284 if (properties) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700285 properties->queueFlags =
286 VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_DMA_BIT;
287 properties->queueCount = 1;
Jesse Hallacfa5342015-11-19 21:51:33 -0800288 properties->timestampValidBits = 64;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700289 }
290 *count = 1;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700291}
292
Jesse Hall606a54e2015-11-19 22:17:28 -0800293void GetPhysicalDeviceMemoryProperties(
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100294 VkPhysicalDevice,
295 VkPhysicalDeviceMemoryProperties* properties) {
296 properties->memoryTypeCount = 1;
297 properties->memoryTypes[0].propertyFlags =
298 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
299 properties->memoryTypes[0].heapIndex = 0;
300 properties->memoryHeapCount = 1;
Jesse Hallbde8ee32015-09-01 16:24:29 -0700301 properties->memoryHeaps[0].size = kMaxDeviceMemory;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700302 properties->memoryHeaps[0].flags = VK_MEMORY_HEAP_HOST_LOCAL_BIT;
Jesse Hall04f4f472015-08-16 19:51:04 -0700303}
304
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100305// -----------------------------------------------------------------------------
306// Device
307
Jesse Hall04f4f472015-08-16 19:51:04 -0700308VkResult CreateDevice(VkPhysicalDevice physical_device,
309 const VkDeviceCreateInfo*,
310 VkDevice* out_device) {
311 VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device);
312 VkDevice_T* device = static_cast<VkDevice_T*>(instance->alloc->pfnAlloc(
313 instance->alloc->pUserData, sizeof(VkDevice_T), alignof(VkDevice_T),
314 VK_SYSTEM_ALLOC_TYPE_API_OBJECT));
315 if (!device)
316 return VK_ERROR_OUT_OF_HOST_MEMORY;
317
318 device->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
319 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 Hallcf25c412015-10-29 17:14:50 -0700328void DestroyDevice(VkDevice device) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700329 if (!device)
Jesse Hallcf25c412015-10-29 17:14:50 -0700330 return;
Jesse Hall04f4f472015-08-16 19:51:04 -0700331 const VkAllocCallbacks* alloc = device->instance->alloc;
332 alloc->pfnFree(alloc->pUserData, device);
Jesse Hall04f4f472015-08-16 19:51:04 -0700333}
334
Jesse Hall606a54e2015-11-19 22:17:28 -0800335void GetDeviceQueue(VkDevice device, uint32_t, uint32_t, VkQueue* queue) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700336 *queue = &device->queue;
Jesse Hall04f4f472015-08-16 19:51:04 -0700337}
338
339// -----------------------------------------------------------------------------
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700340// CmdBuffer
341
Jesse Hallfbf97b02015-11-20 14:17:03 -0800342VkResult AllocCommandBuffers(VkDevice device,
343 const VkCmdBufferAllocInfo* alloc_info,
344 VkCmdBuffer* cmdbufs) {
345 VkResult result = VK_SUCCESS;
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700346 const VkAllocCallbacks* alloc = device->instance->alloc;
Jesse Hallfbf97b02015-11-20 14:17:03 -0800347
348 std::fill(cmdbufs, cmdbufs + alloc_info->count, nullptr);
349 for (uint32_t i = 0; i < alloc_info->count; i++) {
350 cmdbufs[i] = static_cast<VkCmdBuffer_T*>(alloc->pfnAlloc(
351 alloc->pUserData, sizeof(VkCmdBuffer_T), alignof(VkCmdBuffer_T),
352 VK_SYSTEM_ALLOC_TYPE_API_OBJECT));
353 if (!cmdbufs[i]) {
354 result = VK_ERROR_OUT_OF_HOST_MEMORY;
355 break;
356 }
357 cmdbufs[i]->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
358 }
359 if (result != VK_SUCCESS) {
360 for (uint32_t i = 0; i < alloc_info->count; i++) {
361 if (!cmdbufs[i])
362 break;
363 alloc->pfnFree(alloc->pUserData, cmdbufs[i]);
364 }
365 }
366
367 return result;
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700368}
369
Jesse Hallfbf97b02015-11-20 14:17:03 -0800370void FreeCommandBuffers(VkDevice device,
371 VkCmdPool,
372 uint32_t count,
373 const VkCmdBuffer* cmdbufs) {
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700374 const VkAllocCallbacks* alloc = device->instance->alloc;
Jesse Hallfbf97b02015-11-20 14:17:03 -0800375 for (uint32_t i = 0; i < count; i++)
376 alloc->pfnFree(alloc->pUserData, cmdbufs[i]);
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700377}
378
379// -----------------------------------------------------------------------------
Jesse Hall2077ce02015-08-29 18:10:59 +0100380// DeviceMemory
381
382struct DeviceMemory {
383 typedef VkDeviceMemory HandleType;
384 VkDeviceSize size;
385 alignas(16) uint8_t data[0];
386};
387template <>
388struct HandleTraits<VkDeviceMemory> {
389 typedef DeviceMemory* PointerType;
390};
391
392VkResult AllocMemory(VkDevice device,
393 const VkMemoryAllocInfo* alloc_info,
394 VkDeviceMemory* mem_handle) {
395 if (SIZE_MAX - sizeof(DeviceMemory) <= alloc_info->allocationSize)
396 return VK_ERROR_OUT_OF_HOST_MEMORY;
397
398 const VkAllocCallbacks* alloc = device->instance->alloc;
399 size_t size = sizeof(DeviceMemory) + size_t(alloc_info->allocationSize);
400 DeviceMemory* mem = static_cast<DeviceMemory*>(
401 alloc->pfnAlloc(alloc->pUserData, size, alignof(DeviceMemory),
402 VK_SYSTEM_ALLOC_TYPE_API_OBJECT));
403 if (!mem)
404 return VK_ERROR_OUT_OF_HOST_MEMORY;
405 mem->size = size;
406 *mem_handle = GetHandleToObject(mem);
407 return VK_SUCCESS;
408}
409
Jesse Hallcf25c412015-10-29 17:14:50 -0700410void FreeMemory(VkDevice device, VkDeviceMemory mem_handle) {
Jesse Hall2077ce02015-08-29 18:10:59 +0100411 const VkAllocCallbacks* alloc = device->instance->alloc;
412 DeviceMemory* mem = GetObjectFromHandle(mem_handle);
413 alloc->pfnFree(alloc->pUserData, mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100414}
415
416VkResult MapMemory(VkDevice,
417 VkDeviceMemory mem_handle,
418 VkDeviceSize offset,
419 VkDeviceSize,
420 VkMemoryMapFlags,
421 void** out_ptr) {
422 DeviceMemory* mem = GetObjectFromHandle(mem_handle);
423 *out_ptr = &mem->data[0] + offset;
424 return VK_SUCCESS;
425}
426
427// -----------------------------------------------------------------------------
Jesse Hallf6578742015-08-29 17:06:12 +0100428// Buffer
429
430struct Buffer {
431 typedef VkBuffer HandleType;
432 VkDeviceSize size;
433};
434template <>
435struct HandleTraits<VkBuffer> {
436 typedef Buffer* PointerType;
437};
438
439VkResult CreateBuffer(VkDevice device,
440 const VkBufferCreateInfo* create_info,
441 VkBuffer* buffer_handle) {
Jesse Hallbde8ee32015-09-01 16:24:29 -0700442 ALOGW_IF(create_info->size > kMaxDeviceMemory,
443 "CreateBuffer: requested size 0x%" PRIx64
444 " exceeds max device memory size 0x%" PRIx64,
445 create_info->size, kMaxDeviceMemory);
446
Jesse Hallf6578742015-08-29 17:06:12 +0100447 const VkAllocCallbacks* alloc = device->instance->alloc;
448 Buffer* buffer = static_cast<Buffer*>(
449 alloc->pfnAlloc(alloc->pUserData, sizeof(Buffer), alignof(Buffer),
450 VK_SYSTEM_ALLOC_TYPE_API_OBJECT));
451 if (!buffer)
452 return VK_ERROR_OUT_OF_HOST_MEMORY;
453 buffer->size = create_info->size;
454 *buffer_handle = GetHandleToObject(buffer);
455 return VK_SUCCESS;
456}
457
Jesse Hall606a54e2015-11-19 22:17:28 -0800458void GetBufferMemoryRequirements(VkDevice,
459 VkBuffer buffer_handle,
460 VkMemoryRequirements* requirements) {
Jesse Hallf6578742015-08-29 17:06:12 +0100461 Buffer* buffer = GetObjectFromHandle(buffer_handle);
462 requirements->size = buffer->size;
463 requirements->alignment = 16; // allow fast Neon/SSE memcpy
464 requirements->memoryTypeBits = 0x1;
Jesse Hallf6578742015-08-29 17:06:12 +0100465}
466
Jesse Hallcf25c412015-10-29 17:14:50 -0700467void DestroyBuffer(VkDevice device, VkBuffer buffer_handle) {
Jesse Hallf6578742015-08-29 17:06:12 +0100468 const VkAllocCallbacks* alloc = device->instance->alloc;
469 Buffer* buffer = GetObjectFromHandle(buffer_handle);
470 alloc->pfnFree(alloc->pUserData, buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100471}
472
473// -----------------------------------------------------------------------------
Jesse Hall85c05b62015-09-01 18:07:41 -0700474// Image
475
476struct Image {
477 typedef VkImage HandleType;
478 VkDeviceSize size;
479};
480template <>
481struct HandleTraits<VkImage> {
482 typedef Image* PointerType;
483};
484
485VkResult CreateImage(VkDevice device,
486 const VkImageCreateInfo* create_info,
487 VkImage* image_handle) {
488 if (create_info->imageType != VK_IMAGE_TYPE_2D ||
489 create_info->format != VK_FORMAT_R8G8B8A8_UNORM ||
490 create_info->mipLevels != 1) {
491 ALOGE("CreateImage: not yet implemented: type=%d format=%d mips=%u",
492 create_info->imageType, create_info->format,
493 create_info->mipLevels);
Jesse Halla15a4bf2015-11-19 22:48:02 -0800494 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall85c05b62015-09-01 18:07:41 -0700495 }
496
497 VkDeviceSize size =
498 VkDeviceSize(create_info->extent.width * create_info->extent.height) *
Jesse Halla15a4bf2015-11-19 22:48:02 -0800499 create_info->arrayLayers * create_info->samples * 4u;
Jesse Hall85c05b62015-09-01 18:07:41 -0700500 ALOGW_IF(size > kMaxDeviceMemory,
501 "CreateImage: image size 0x%" PRIx64
502 " exceeds max device memory size 0x%" PRIx64,
503 size, kMaxDeviceMemory);
504
505 const VkAllocCallbacks* alloc = device->instance->alloc;
506 Image* image = static_cast<Image*>(
507 alloc->pfnAlloc(alloc->pUserData, sizeof(Image), alignof(Image),
508 VK_SYSTEM_ALLOC_TYPE_API_OBJECT));
509 if (!image)
510 return VK_ERROR_OUT_OF_HOST_MEMORY;
511 image->size = size;
512 *image_handle = GetHandleToObject(image);
513 return VK_SUCCESS;
514}
515
Jesse Hall606a54e2015-11-19 22:17:28 -0800516void GetImageMemoryRequirements(VkDevice,
517 VkImage image_handle,
518 VkMemoryRequirements* requirements) {
Jesse Hall85c05b62015-09-01 18:07:41 -0700519 Image* image = GetObjectFromHandle(image_handle);
520 requirements->size = image->size;
521 requirements->alignment = 16; // allow fast Neon/SSE memcpy
522 requirements->memoryTypeBits = 0x1;
Jesse Hall85c05b62015-09-01 18:07:41 -0700523}
524
Jesse Hallcf25c412015-10-29 17:14:50 -0700525void DestroyImage(VkDevice device, VkImage image_handle) {
Jesse Hall85c05b62015-09-01 18:07:41 -0700526 const VkAllocCallbacks* alloc = device->instance->alloc;
527 Image* image = GetObjectFromHandle(image_handle);
528 alloc->pfnFree(alloc->pUserData, image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700529}
530
531// -----------------------------------------------------------------------------
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700532// No-op types
533
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700534VkResult CreateBufferView(VkDevice device,
535 const VkBufferViewCreateInfo*,
536 VkBufferView* view) {
537 *view = AllocHandle(device, HandleType::kBufferView);
538 return VK_SUCCESS;
539}
540
541VkResult CreateCommandPool(VkDevice device,
542 const VkCmdPoolCreateInfo*,
543 VkCmdPool* pool) {
544 *pool = AllocHandle(device, HandleType::kCmdPool);
545 return VK_SUCCESS;
546}
547
548VkResult CreateDescriptorPool(VkDevice device,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700549 const VkDescriptorPoolCreateInfo*,
550 VkDescriptorPool* pool) {
551 *pool = AllocHandle(device, HandleType::kDescriptorPool);
552 return VK_SUCCESS;
553}
554
555VkResult AllocDescriptorSets(VkDevice device,
Jesse Hallfbf97b02015-11-20 14:17:03 -0800556 const VkDescriptorSetAllocInfo* alloc_info,
557 VkDescriptorSet* descriptor_sets) {
558 for (uint32_t i = 0; i < alloc_info->count; i++)
559 descriptor_sets[i] = AllocHandle(device, HandleType::kDescriptorSet);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700560 return VK_SUCCESS;
561}
562
563VkResult CreateDescriptorSetLayout(VkDevice device,
564 const VkDescriptorSetLayoutCreateInfo*,
565 VkDescriptorSetLayout* layout) {
566 *layout = AllocHandle(device, HandleType::kDescriptorSetLayout);
567 return VK_SUCCESS;
568}
569
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700570VkResult CreateEvent(VkDevice device,
571 const VkEventCreateInfo*,
572 VkEvent* event) {
573 *event = AllocHandle(device, HandleType::kEvent);
574 return VK_SUCCESS;
575}
576
577VkResult CreateFence(VkDevice device,
578 const VkFenceCreateInfo*,
579 VkFence* fence) {
580 *fence = AllocHandle(device, HandleType::kFence);
581 return VK_SUCCESS;
582}
583
584VkResult CreateFramebuffer(VkDevice device,
585 const VkFramebufferCreateInfo*,
586 VkFramebuffer* framebuffer) {
587 *framebuffer = AllocHandle(device, HandleType::kFramebuffer);
588 return VK_SUCCESS;
589}
590
591VkResult CreateImageView(VkDevice device,
592 const VkImageViewCreateInfo*,
593 VkImageView* view) {
594 *view = AllocHandle(device, HandleType::kImageView);
595 return VK_SUCCESS;
596}
597
598VkResult CreateGraphicsPipelines(VkDevice device,
599 VkPipelineCache,
600 uint32_t count,
601 const VkGraphicsPipelineCreateInfo*,
602 VkPipeline* pipelines) {
603 for (uint32_t i = 0; i < count; i++)
604 pipelines[i] = AllocHandle(device, HandleType::kPipeline);
605 return VK_SUCCESS;
606}
607
608VkResult CreateComputePipelines(VkDevice device,
609 VkPipelineCache,
610 uint32_t count,
611 const VkComputePipelineCreateInfo*,
612 VkPipeline* pipelines) {
613 for (uint32_t i = 0; i < count; i++)
614 pipelines[i] = AllocHandle(device, HandleType::kPipeline);
615 return VK_SUCCESS;
616}
617
618VkResult CreatePipelineCache(VkDevice device,
619 const VkPipelineCacheCreateInfo*,
620 VkPipelineCache* cache) {
621 *cache = AllocHandle(device, HandleType::kPipelineCache);
622 return VK_SUCCESS;
623}
624
625VkResult CreatePipelineLayout(VkDevice device,
626 const VkPipelineLayoutCreateInfo*,
627 VkPipelineLayout* layout) {
628 *layout = AllocHandle(device, HandleType::kPipelineLayout);
629 return VK_SUCCESS;
630}
631
632VkResult CreateQueryPool(VkDevice device,
633 const VkQueryPoolCreateInfo*,
634 VkQueryPool* pool) {
635 *pool = AllocHandle(device, HandleType::kQueryPool);
636 return VK_SUCCESS;
637}
638
639VkResult CreateRenderPass(VkDevice device,
640 const VkRenderPassCreateInfo*,
641 VkRenderPass* renderpass) {
642 *renderpass = AllocHandle(device, HandleType::kRenderPass);
643 return VK_SUCCESS;
644}
645
646VkResult CreateSampler(VkDevice device,
647 const VkSamplerCreateInfo*,
648 VkSampler* sampler) {
649 *sampler = AllocHandle(device, HandleType::kSampler);
650 return VK_SUCCESS;
651}
652
653VkResult CreateSemaphore(VkDevice device,
654 const VkSemaphoreCreateInfo*,
655 VkSemaphore* semaphore) {
656 *semaphore = AllocHandle(device, HandleType::kSemaphore);
657 return VK_SUCCESS;
658}
659
660VkResult CreateShader(VkDevice device,
661 const VkShaderCreateInfo*,
662 VkShader* shader) {
663 *shader = AllocHandle(device, HandleType::kShader);
664 return VK_SUCCESS;
665}
666
667VkResult CreateShaderModule(VkDevice device,
668 const VkShaderModuleCreateInfo*,
669 VkShaderModule* module) {
670 *module = AllocHandle(device, HandleType::kShaderModule);
671 return VK_SUCCESS;
672}
673
Jesse Hall70f93352015-11-04 09:41:31 -0800674VkResult GetSwapchainGrallocUsageANDROID(VkDevice,
675 VkFormat,
676 VkImageUsageFlags,
677 int* grallocUsage) {
678 // The null driver never reads or writes the gralloc buffer
679 *grallocUsage = 0;
680 return VK_SUCCESS;
681}
682
Jesse Hallab9aeef2015-11-04 10:56:20 -0800683VkResult AcquireImageANDROID(VkDevice, VkImage, int fence, VkSemaphore) {
Jesse Halld7b994a2015-09-07 14:17:37 -0700684 close(fence);
685 return VK_SUCCESS;
686}
687
Jesse Hallab9aeef2015-11-04 10:56:20 -0800688VkResult QueueSignalReleaseImageANDROID(VkQueue, VkImage, int* fence) {
Jesse Halld7b994a2015-09-07 14:17:37 -0700689 *fence = -1;
690 return VK_SUCCESS;
691}
692
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700693// -----------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -0700694// No-op entrypoints
695
696// clang-format off
697#pragma clang diagnostic push
698#pragma clang diagnostic ignored "-Wunused-parameter"
699
Jesse Hall606a54e2015-11-19 22:17:28 -0800700void GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100701 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700702}
703
Jesse Hall606a54e2015-11-19 22:17:28 -0800704void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100705 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700706}
707
Jesse Hall606a54e2015-11-19 22:17:28 -0800708void GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100709 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700710}
711
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700712VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100713 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700714 return VK_SUCCESS;
715}
716
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700717VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100718 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700719 return VK_SUCCESS;
720}
721
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700722VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100723 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700724 return VK_SUCCESS;
725}
726
Jesse Halla366a512015-11-19 22:30:07 -0800727VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700728 return VK_SUCCESS;
729}
730
731VkResult QueueWaitIdle(VkQueue queue) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100732 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700733 return VK_SUCCESS;
734}
735
736VkResult DeviceWaitIdle(VkDevice device) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100737 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700738 return VK_SUCCESS;
739}
740
Jesse Hallcf25c412015-10-29 17:14:50 -0700741void UnmapMemory(VkDevice device, VkDeviceMemory mem) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700742}
743
744VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100745 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700746 return VK_SUCCESS;
747}
748
749VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100750 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700751 return VK_SUCCESS;
752}
753
Jesse Hall606a54e2015-11-19 22:17:28 -0800754void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100755 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700756}
757
Jesse Hall04f4f472015-08-16 19:51:04 -0700758VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) {
759 return VK_SUCCESS;
760}
761
Jesse Hall04f4f472015-08-16 19:51:04 -0700762VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) {
763 return VK_SUCCESS;
764}
765
Jesse Hall606a54e2015-11-19 22:17:28 -0800766void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100767 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700768}
769
Jesse Hall606a54e2015-11-19 22:17:28 -0800770void 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 +0100771 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700772}
773
774VkResult QueueBindSparseBufferMemory(VkQueue queue, VkBuffer buffer, uint32_t numBindings, const VkSparseMemoryBindInfo* pBindInfo) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100775 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700776 return VK_SUCCESS;
777}
778
779VkResult QueueBindSparseImageOpaqueMemory(VkQueue queue, VkImage image, uint32_t numBindings, const VkSparseMemoryBindInfo* pBindInfo) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100780 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700781 return VK_SUCCESS;
782}
783
784VkResult QueueBindSparseImageMemory(VkQueue queue, VkImage image, uint32_t numBindings, const VkSparseImageMemoryBindInfo* pBindInfo) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100785 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700786 return VK_SUCCESS;
787}
788
Jesse Hallcf25c412015-10-29 17:14:50 -0700789void DestroyFence(VkDevice device, VkFence fence) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700790}
791
792VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) {
793 return VK_SUCCESS;
794}
795
796VkResult GetFenceStatus(VkDevice device, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100797 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700798 return VK_SUCCESS;
799}
800
801VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) {
802 return VK_SUCCESS;
803}
804
Jesse Hallcf25c412015-10-29 17:14:50 -0700805void DestroySemaphore(VkDevice device, VkSemaphore semaphore) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700806}
807
808VkResult QueueSignalSemaphore(VkQueue queue, VkSemaphore semaphore) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100809 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700810 return VK_SUCCESS;
811}
812
813VkResult QueueWaitSemaphore(VkQueue queue, VkSemaphore semaphore) {
814 return VK_SUCCESS;
815}
816
Jesse Hallcf25c412015-10-29 17:14:50 -0700817void DestroyEvent(VkDevice device, VkEvent event) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700818}
819
820VkResult GetEventStatus(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100821 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700822 return VK_SUCCESS;
823}
824
825VkResult SetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100826 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700827 return VK_SUCCESS;
828}
829
830VkResult ResetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100831 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700832 return VK_SUCCESS;
833}
834
Jesse Hallcf25c412015-10-29 17:14:50 -0700835void DestroyQueryPool(VkDevice device, VkQueryPool queryPool) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700836}
837
838VkResult GetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, size_t* pDataSize, void* pData, VkQueryResultFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100839 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700840 return VK_SUCCESS;
841}
842
Jesse Hallcf25c412015-10-29 17:14:50 -0700843void DestroyBufferView(VkDevice device, VkBufferView bufferView) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700844}
845
Jesse Hall606a54e2015-11-19 22:17:28 -0800846void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100847 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700848}
849
Jesse Hallcf25c412015-10-29 17:14:50 -0700850void DestroyImageView(VkDevice device, VkImageView imageView) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700851}
852
Jesse Hallcf25c412015-10-29 17:14:50 -0700853void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700854}
855
Jesse Hallcf25c412015-10-29 17:14:50 -0700856void DestroyShader(VkDevice device, VkShader shader) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700857}
858
Jesse Hallcf25c412015-10-29 17:14:50 -0700859void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700860}
861
862size_t GetPipelineCacheSize(VkDevice device, VkPipelineCache pipelineCache) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100863 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700864 return VK_SUCCESS;
865}
866
Jesse Hall606a54e2015-11-19 22:17:28 -0800867VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t dataSize, void* pData) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100868 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700869 return VK_SUCCESS;
870}
871
872VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100873 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700874 return VK_SUCCESS;
875}
876
Jesse Hallcf25c412015-10-29 17:14:50 -0700877void DestroyPipeline(VkDevice device, VkPipeline pipeline) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700878}
879
Jesse Hallcf25c412015-10-29 17:14:50 -0700880void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700881}
882
Jesse Hallcf25c412015-10-29 17:14:50 -0700883void DestroySampler(VkDevice device, VkSampler sampler) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700884}
885
Jesse Hallcf25c412015-10-29 17:14:50 -0700886void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700887}
888
Jesse Hallcf25c412015-10-29 17:14:50 -0700889void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700890}
891
Jesse Hallfbf97b02015-11-20 14:17:03 -0800892VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100893 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700894 return VK_SUCCESS;
895}
896
Jesse Hallcf25c412015-10-29 17:14:50 -0700897void UpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100898 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700899}
900
901VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100902 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700903 return VK_SUCCESS;
904}
905
Jesse Hallcf25c412015-10-29 17:14:50 -0700906void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700907}
908
Jesse Hallcf25c412015-10-29 17:14:50 -0700909void DestroyRenderPass(VkDevice device, VkRenderPass renderPass) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700910}
911
Jesse Hall606a54e2015-11-19 22:17:28 -0800912void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100913 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700914}
915
Jesse Hallcf25c412015-10-29 17:14:50 -0700916void DestroyCommandPool(VkDevice device, VkCmdPool cmdPool) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700917}
918
919VkResult ResetCommandPool(VkDevice device, VkCmdPool cmdPool, VkCmdPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100920 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700921 return VK_SUCCESS;
922}
923
Jesse Hall04f4f472015-08-16 19:51:04 -0700924VkResult BeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo) {
925 return VK_SUCCESS;
926}
927
928VkResult EndCommandBuffer(VkCmdBuffer cmdBuffer) {
929 return VK_SUCCESS;
930}
931
932VkResult ResetCommandBuffer(VkCmdBuffer cmdBuffer, VkCmdBufferResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100933 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -0700934 return VK_SUCCESS;
935}
936
937void CmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) {
938}
939
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700940void CmdSetViewport(VkCmdBuffer cmdBuffer, uint32_t viewportCount, const VkViewport* pViewports) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700941}
942
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700943void CmdSetScissor(VkCmdBuffer cmdBuffer, uint32_t scissorCount, const VkRect2D* pScissors) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700944}
945
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700946void CmdSetLineWidth(VkCmdBuffer cmdBuffer, float lineWidth) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700947}
948
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700949void CmdSetDepthBias(VkCmdBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) {
950}
951
952void CmdSetBlendConstants(VkCmdBuffer cmdBuffer, const float blendConst[4]) {
953}
954
955void CmdSetDepthBounds(VkCmdBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) {
956}
957
958void CmdSetStencilCompareMask(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) {
959}
960
961void CmdSetStencilWriteMask(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) {
962}
963
964void CmdSetStencilReference(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700965}
966
967void CmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets) {
968}
969
970void CmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) {
971}
972
973void CmdBindVertexBuffers(VkCmdBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) {
974}
975
Jesse Hallcf25c412015-10-29 17:14:50 -0700976void CmdDraw(VkCmdBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700977}
978
Jesse Hallcf25c412015-10-29 17:14:50 -0700979void 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 -0700980}
981
982void CmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
983}
984
985void CmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
986}
987
988void CmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) {
989}
990
991void CmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) {
992}
993
994void CmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) {
995}
996
997void CmdCopyImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) {
998}
999
1000void CmdBlitImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkTexFilter filter) {
1001}
1002
1003void CmdCopyBufferToImage(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
1004}
1005
1006void CmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
1007}
1008
1009void CmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) {
1010}
1011
1012void CmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) {
1013}
1014
1015void CmdClearColorImage(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
1016}
1017
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001018void CmdClearDepthStencilImage(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001019}
1020
Jesse Halla15a4bf2015-11-19 22:48:02 -08001021void CmdClearAttachments(VkCmdBuffer cmdBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001022}
1023
1024void CmdResolveImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) {
1025}
1026
1027void CmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
1028}
1029
1030void CmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
1031}
1032
1033void CmdWaitEvents(VkCmdBuffer cmdBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, uint32_t memBarrierCount, const void* const* ppMemBarriers) {
1034}
1035
1036void CmdPipelineBarrier(VkCmdBuffer cmdBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, VkBool32 byRegion, uint32_t memBarrierCount, const void* const* ppMemBarriers) {
1037}
1038
1039void CmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) {
1040}
1041
1042void CmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) {
1043}
1044
1045void CmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) {
1046}
1047
1048void CmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkDeviceSize destOffset) {
1049}
1050
1051void CmdCopyQueryPoolResults(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkQueryResultFlags flags) {
1052}
1053
1054void CmdPushConstants(VkCmdBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) {
1055}
1056
1057void CmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkRenderPassContents contents) {
1058}
1059
1060void CmdNextSubpass(VkCmdBuffer cmdBuffer, VkRenderPassContents contents) {
1061}
1062
1063void CmdEndRenderPass(VkCmdBuffer cmdBuffer) {
1064}
1065
1066void CmdExecuteCommands(VkCmdBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCmdBuffer* pCmdBuffers) {
1067}
1068
Jesse Hall04f4f472015-08-16 19:51:04 -07001069#pragma clang diagnostic pop
1070// clang-format on
1071
1072} // namespace null_driver