blob: 6f57238b5d8c56ed14302aaebefc50be074799ef [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 Hall1f91d392015-12-11 16:28:44 -080019#include <algorithm>
20#include <array>
Jesse Hall715b86a2016-01-16 16:34:29 -080021#include <inttypes.h>
22#include <string.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070023
Jesse Hall73ab0ac2015-08-25 15:09:15 +010024#include <log/log.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070025#include <utils/Errors.h>
26
Jesse Hall1f91d392015-12-11 16:28:44 -080027#include "null_driver_gen.h"
Jesse Hall04f4f472015-08-16 19:51:04 -070028
29using namespace null_driver;
30
31struct VkPhysicalDevice_T {
32 hwvulkan_dispatch_t dispatch;
33};
34
35struct VkInstance_T {
36 hwvulkan_dispatch_t dispatch;
Jesse Hall3fbc8562015-11-29 22:10:52 -080037 VkAllocationCallbacks allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -070038 VkPhysicalDevice_T physical_device;
Jesse Hall715b86a2016-01-16 16:34:29 -080039 uint64_t next_callback_handle;
Jesse Hall04f4f472015-08-16 19:51:04 -070040};
41
42struct VkQueue_T {
43 hwvulkan_dispatch_t dispatch;
44};
45
Jesse Hall3fbc8562015-11-29 22:10:52 -080046struct VkCommandBuffer_T {
Jesse Hall04f4f472015-08-16 19:51:04 -070047 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 Hall715b86a2016-01-16 16:34:29 -080070 kDebugReportCallbackEXT,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070071 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,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070085 kShaderModule,
Jesse Hallf8faf0c2015-08-31 11:34:32 -070086
Jesse Hallc7a6eb52015-08-31 12:52:03 -070087 kNumTypes
88};
89} // namespace HandleType
Jesse Hallbde8ee32015-09-01 16:24:29 -070090
Jesse Hall00f10fe2016-02-08 21:20:20 -080091const VkDeviceSize kMaxDeviceMemory = 0x10000000; // 256 MiB, arbitrary
Jesse Hallbde8ee32015-09-01 16:24:29 -070092
Jesse Hallc7a6eb52015-08-31 12:52:03 -070093} // anonymous namespace
Jesse Hallf8faf0c2015-08-31 11:34:32 -070094
Jesse Hall04f4f472015-08-16 19:51:04 -070095struct VkDevice_T {
96 hwvulkan_dispatch_t dispatch;
Jesse Hall3fbc8562015-11-29 22:10:52 -080097 VkAllocationCallbacks allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -070098 VkInstance_T* instance;
99 VkQueue_T queue;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700100 std::array<uint64_t, HandleType::kNumTypes> next_handle;
Jesse Hall04f4f472015-08-16 19:51:04 -0700101};
102
103// -----------------------------------------------------------------------------
104// Declare HAL_MODULE_INFO_SYM early so it can be referenced by nulldrv_device
105// later.
106
107namespace {
108int OpenDevice(const hw_module_t* module, const char* id, hw_device_t** device);
109hw_module_methods_t nulldrv_module_methods = {.open = OpenDevice};
110} // namespace
111
112#pragma clang diagnostic push
113#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
114__attribute__((visibility("default"))) hwvulkan_module_t HAL_MODULE_INFO_SYM = {
115 .common =
116 {
Michael Lentine03c64b02015-08-26 18:27:26 -0500117 .tag = HARDWARE_MODULE_TAG,
118 .module_api_version = HWVULKAN_MODULE_API_VERSION_0_1,
119 .hal_api_version = HARDWARE_HAL_API_VERSION,
120 .id = HWVULKAN_HARDWARE_MODULE_ID,
121 .name = "Null Vulkan Driver",
122 .author = "The Android Open Source Project",
123 .methods = &nulldrv_module_methods,
Jesse Hall04f4f472015-08-16 19:51:04 -0700124 },
125};
126#pragma clang diagnostic pop
127
128// -----------------------------------------------------------------------------
129
130namespace {
131
Jesse Hall04f4f472015-08-16 19:51:04 -0700132int CloseDevice(struct hw_device_t* /*device*/) {
133 // nothing to do - opening a device doesn't allocate any resources
134 return 0;
135}
136
137hwvulkan_device_t nulldrv_device = {
138 .common =
139 {
Michael Lentine03c64b02015-08-26 18:27:26 -0500140 .tag = HARDWARE_DEVICE_TAG,
141 .version = HWVULKAN_DEVICE_API_VERSION_0_1,
142 .module = &HAL_MODULE_INFO_SYM.common,
143 .close = CloseDevice,
Jesse Hall04f4f472015-08-16 19:51:04 -0700144 },
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700145 .EnumerateInstanceExtensionProperties =
146 EnumerateInstanceExtensionProperties,
Jesse Hall04f4f472015-08-16 19:51:04 -0700147 .CreateInstance = CreateInstance,
148 .GetInstanceProcAddr = GetInstanceProcAddr};
149
150int OpenDevice(const hw_module_t* /*module*/,
151 const char* id,
152 hw_device_t** device) {
153 if (strcmp(id, HWVULKAN_DEVICE_0) == 0) {
154 *device = &nulldrv_device.common;
155 return 0;
156 }
157 return -ENOENT;
158}
159
160VkInstance_T* GetInstanceFromPhysicalDevice(
161 VkPhysicalDevice_T* physical_device) {
162 return reinterpret_cast<VkInstance_T*>(
163 reinterpret_cast<uintptr_t>(physical_device) -
164 offsetof(VkInstance_T, physical_device));
165}
166
Jesse Hall715b86a2016-01-16 16:34:29 -0800167uint64_t AllocHandle(uint64_t type, uint64_t* next_handle) {
168 const uint64_t kHandleMask = (UINT64_C(1) << 56) - 1;
169 ALOGE_IF(*next_handle == kHandleMask,
170 "non-dispatchable handles of type=%" PRIu64
171 " are about to overflow",
172 type);
173 return (UINT64_C(1) << 63) | ((type & 0x7) << 56) |
174 ((*next_handle)++ & kHandleMask);
175}
176
177template <class Handle>
178Handle AllocHandle(VkInstance instance, HandleType::Enum type) {
179 return reinterpret_cast<Handle>(
180 AllocHandle(type, &instance->next_callback_handle));
181}
182
Michael Lentine3fec89e2015-12-04 16:25:11 -0800183template <class Handle>
184Handle AllocHandle(VkDevice device, HandleType::Enum type) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800185 return reinterpret_cast<Handle>(
Jesse Hall715b86a2016-01-16 16:34:29 -0800186 AllocHandle(type, &device->next_handle[type]));
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700187}
188
Jesse Hall04f4f472015-08-16 19:51:04 -0700189} // namespace
190
191namespace null_driver {
192
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800193#define DEFINE_OBJECT_HANDLE_CONVERSION(T) \
194 T* Get##T##FromHandle(Vk##T h); \
195 T* Get##T##FromHandle(Vk##T h) { \
196 return reinterpret_cast<T*>(uintptr_t(h)); \
197 } \
198 Vk##T GetHandleTo##T(const T* obj); \
199 Vk##T GetHandleTo##T(const T* obj) { \
200 return Vk##T(reinterpret_cast<uintptr_t>(obj)); \
201 }
Jesse Hallf6578742015-08-29 17:06:12 +0100202
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100203// -----------------------------------------------------------------------------
204// Global
205
Jesse Halle1b12782015-11-30 11:27:32 -0800206VKAPI_ATTR
Jesse Hall715b86a2016-01-16 16:34:29 -0800207VkResult EnumerateInstanceExtensionProperties(
208 const char* layer_name,
209 uint32_t* count,
210 VkExtensionProperties* properties) {
211 if (layer_name) {
212 ALOGW(
213 "Driver vkEnumerateInstanceExtensionProperties shouldn't be called "
214 "with a layer name ('%s')",
215 layer_name);
Jesse Hall715b86a2016-01-16 16:34:29 -0800216 }
217
Jesse Hall4b62e4f2016-01-21 09:49:49 -0800218// NOTE: Change this to zero to report and extension, which can be useful
219// for testing changes to the loader.
220#if 1
221 (void)properties; // unused
222 *count = 0;
223 return VK_SUCCESS;
224#else
Jesse Hall715b86a2016-01-16 16:34:29 -0800225 const VkExtensionProperties kExtensions[] = {
226 {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}};
227 const uint32_t kExtensionsCount =
228 sizeof(kExtensions) / sizeof(kExtensions[0]);
229
230 if (!properties || *count > kExtensionsCount)
231 *count = kExtensionsCount;
232 if (properties)
233 std::copy(kExtensions, kExtensions + *count, properties);
234 return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS;
Jesse Hall4b62e4f2016-01-21 09:49:49 -0800235#endif
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100236}
237
Jesse Halle1b12782015-11-30 11:27:32 -0800238VKAPI_ATTR
Jesse Hall715b86a2016-01-16 16:34:29 -0800239VkResult CreateInstance(const VkInstanceCreateInfo* create_info,
Jesse Hall1f91d392015-12-11 16:28:44 -0800240 const VkAllocationCallbacks* allocator,
241 VkInstance* out_instance) {
242 // Assume the loader provided alloc callbacks even if the app didn't.
243 ALOG_ASSERT(
244 allocator,
245 "Missing alloc callbacks, loader or app should have provided them");
246
247 VkInstance_T* instance =
248 static_cast<VkInstance_T*>(allocator->pfnAllocation(
249 allocator->pUserData, sizeof(VkInstance_T), alignof(VkInstance_T),
250 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE));
251 if (!instance)
252 return VK_ERROR_OUT_OF_HOST_MEMORY;
253
254 instance->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
255 instance->allocator = *allocator;
256 instance->physical_device.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall715b86a2016-01-16 16:34:29 -0800257 instance->next_callback_handle = 0;
Jesse Hall715b86a2016-01-16 16:34:29 -0800258
259 for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
260 if (strcmp(create_info->ppEnabledExtensionNames[i],
261 VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) {
Jesse Hallb1471272016-01-17 21:36:58 -0800262 ALOGV("instance extension '%s' requested",
263 create_info->ppEnabledExtensionNames[i]);
264 } else {
265 ALOGW("unsupported extension '%s' requested",
266 create_info->ppEnabledExtensionNames[i]);
Jesse Hall715b86a2016-01-16 16:34:29 -0800267 }
268 }
Jesse Hall1f91d392015-12-11 16:28:44 -0800269
270 *out_instance = instance;
271 return VK_SUCCESS;
272}
273
274VKAPI_ATTR
275PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name) {
276 return instance ? GetInstanceProcAddr(name) : GetGlobalProcAddr(name);
Jesse Hall04f4f472015-08-16 19:51:04 -0700277}
278
Jesse Halle1b12782015-11-30 11:27:32 -0800279VKAPI_ATTR
Jesse Hall04f4f472015-08-16 19:51:04 -0700280PFN_vkVoidFunction GetDeviceProcAddr(VkDevice, const char* name) {
Jesse Hall1f91d392015-12-11 16:28:44 -0800281 return GetInstanceProcAddr(name);
Jesse Hall04f4f472015-08-16 19:51:04 -0700282}
283
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100284// -----------------------------------------------------------------------------
285// Instance
286
Jesse Hall03b6fe12015-11-24 12:44:21 -0800287void DestroyInstance(VkInstance instance,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800288 const VkAllocationCallbacks* /*allocator*/) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800289 instance->allocator.pfnFree(instance->allocator.pUserData, instance);
Jesse Hall04f4f472015-08-16 19:51:04 -0700290}
291
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100292// -----------------------------------------------------------------------------
293// PhysicalDevice
294
Jesse Hall04f4f472015-08-16 19:51:04 -0700295VkResult EnumeratePhysicalDevices(VkInstance instance,
296 uint32_t* physical_device_count,
297 VkPhysicalDevice* physical_devices) {
298 if (physical_devices && *physical_device_count >= 1)
299 physical_devices[0] = &instance->physical_device;
300 *physical_device_count = 1;
301 return VK_SUCCESS;
302}
303
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800304VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice /*gpu*/,
305 uint32_t* count,
306 VkLayerProperties* /*properties*/) {
307 ALOGW("Driver vkEnumerateDeviceLayerProperties shouldn't be called");
308 *count = 0;
309 return VK_SUCCESS;
310}
311
312VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice /*gpu*/,
313 const char* layer_name,
314 uint32_t* count,
315 VkExtensionProperties* properties) {
316 if (layer_name) {
317 ALOGW(
318 "Driver vkEnumerateDeviceExtensionProperties shouldn't be called "
319 "with a layer name ('%s')",
320 layer_name);
321 *count = 0;
322 return VK_SUCCESS;
323 }
324
325 const VkExtensionProperties kExtensions[] = {
326 {VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME,
327 VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION}};
328 const uint32_t kExtensionsCount =
329 sizeof(kExtensions) / sizeof(kExtensions[0]);
330
331 if (!properties || *count > kExtensionsCount)
332 *count = kExtensionsCount;
333 if (properties)
334 std::copy(kExtensions, kExtensions + *count, properties);
335 return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS;
336}
337
Jesse Hall606a54e2015-11-19 22:17:28 -0800338void GetPhysicalDeviceProperties(VkPhysicalDevice,
339 VkPhysicalDeviceProperties* properties) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700340 properties->apiVersion = VK_API_VERSION;
341 properties->driverVersion = VK_MAKE_VERSION(0, 0, 1);
Jesse Hall65ab5522015-11-30 00:07:16 -0800342 properties->vendorID = 0;
343 properties->deviceID = 0;
Jesse Hall04f4f472015-08-16 19:51:04 -0700344 properties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER;
345 strcpy(properties->deviceName, "Android Vulkan Null Driver");
346 memset(properties->pipelineCacheUUID, 0,
347 sizeof(properties->pipelineCacheUUID));
Jesse Hallc34849e2016-02-09 22:35:04 -0800348 properties->limits = VkPhysicalDeviceLimits{
349 4096, // maxImageDimension1D
350 4096, // maxImageDimension2D
351 256, // maxImageDimension3D
352 4096, // maxImageDimensionCube
353 256, // maxImageArrayLayers
354 65536, // maxTexelBufferElements
355 16384, // maxUniformBufferRange
356 1 << 27, // maxStorageBufferRange
357 128, // maxPushConstantsSize
358 4096, // maxMemoryAllocationCount
359 4000, // maxSamplerAllocationCount
360 1, // bufferImageGranularity
361 0, // sparseAddressSpaceSize
362 4, // maxBoundDescriptorSets
363 16, // maxPerStageDescriptorSamplers
364 12, // maxPerStageDescriptorUniformBuffers
365 4, // maxPerStageDescriptorStorageBuffers
366 16, // maxPerStageDescriptorSampledImages
367 4, // maxPerStageDescriptorStorageImages
368 4, // maxPerStageDescriptorInputAttachments
369 128, // maxPerStageResources
370 96, // maxDescriptorSetSamplers
371 72, // maxDescriptorSetUniformBuffers
372 8, // maxDescriptorSetUniformBuffersDynamic
373 24, // maxDescriptorSetStorageBuffers
374 4, // maxDescriptorSetStorageBuffersDynamic
375 96, // maxDescriptorSetSampledImages
376 24, // maxDescriptorSetStorageImages
377 4, // maxDescriptorSetInputAttachments
378 16, // maxVertexInputAttributes
379 16, // maxVertexInputBindings
380 2047, // maxVertexInputAttributeOffset
381 2048, // maxVertexInputBindingStride
382 64, // maxVertexOutputComponents
383 0, // maxTessellationGenerationLevel
384 0, // maxTessellationPatchSize
385 0, // maxTessellationControlPerVertexInputComponents
386 0, // maxTessellationControlPerVertexOutputComponents
387 0, // maxTessellationControlPerPatchOutputComponents
388 0, // maxTessellationControlTotalOutputComponents
389 0, // maxTessellationEvaluationInputComponents
390 0, // maxTessellationEvaluationOutputComponents
391 0, // maxGeometryShaderInvocations
392 0, // maxGeometryInputComponents
393 0, // maxGeometryOutputComponents
394 0, // maxGeometryOutputVertices
395 0, // maxGeometryTotalOutputComponents
396 64, // maxFragmentInputComponents
397 4, // maxFragmentOutputAttachments
398 0, // maxFragmentDualSrcAttachments
399 4, // maxFragmentCombinedOutputResources
400 16384, // maxComputeSharedMemorySize
401 {65536, 65536, 65536}, // maxComputeWorkGroupCount[3]
402 128, // maxComputeWorkGroupInvocations
403 {128, 128, 64}, // maxComputeWorkGroupSize[3]
404 4, // subPixelPrecisionBits
405 4, // subTexelPrecisionBits
406 4, // mipmapPrecisionBits
407 UINT32_MAX, // maxDrawIndexedIndexValue
408 1, // maxDrawIndirectCount
409 2, // maxSamplerLodBias
410 1, // maxSamplerAnisotropy
411 1, // maxViewports
412 {4096, 4096}, // maxViewportDimensions[2]
413 {-8192.0f, 8191.0f}, // viewportBoundsRange[2]
414 0, // viewportSubPixelBits
415 64, // minMemoryMapAlignment
416 256, // minTexelBufferOffsetAlignment
417 256, // minUniformBufferOffsetAlignment
418 256, // minStorageBufferOffsetAlignment
419 -8, // minTexelOffset
420 7, // maxTexelOffset
421 0, // minTexelGatherOffset
422 0, // maxTexelGatherOffset
423 0.0f, // minInterpolationOffset
424 0.0f, // maxInterpolationOffset
425 0, // subPixelInterpolationOffsetBits
426 4096, // maxFramebufferWidth
427 4096, // maxFramebufferHeight
428 256, // maxFramebufferLayers
429 VK_SAMPLE_COUNT_1_BIT |
430 VK_SAMPLE_COUNT_4_BIT, // framebufferColorSampleCounts
431 VK_SAMPLE_COUNT_1_BIT |
432 VK_SAMPLE_COUNT_4_BIT, // framebufferDepthSampleCounts
433 VK_SAMPLE_COUNT_1_BIT |
434 VK_SAMPLE_COUNT_4_BIT, // framebufferStencilSampleCounts
435 VK_SAMPLE_COUNT_1_BIT |
436 VK_SAMPLE_COUNT_4_BIT, // framebufferNoAttachmentsSampleCounts
437 4, // maxColorAttachments
438 VK_SAMPLE_COUNT_1_BIT |
439 VK_SAMPLE_COUNT_4_BIT, // sampledImageColorSampleCounts
440 VK_SAMPLE_COUNT_1_BIT, // sampledImageIntegerSampleCounts
441 VK_SAMPLE_COUNT_1_BIT |
442 VK_SAMPLE_COUNT_4_BIT, // sampledImageDepthSampleCounts
443 VK_SAMPLE_COUNT_1_BIT |
444 VK_SAMPLE_COUNT_4_BIT, // sampledImageStencilSampleCounts
445 VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts
446 1, // maxSampleMaskWords
447 VK_TRUE, // timestampComputeAndGraphics
448 1, // timestampPeriod
449 0, // maxClipDistances
450 0, // maxCullDistances
451 0, // maxCombinedClipAndCullDistances
452 2, // discreteQueuePriorities
453 {1.0f, 1.0f}, // pointSizeRange[2]
454 {1.0f, 1.0f}, // lineWidthRange[2]
455 0.0f, // pointSizeGranularity
456 0.0f, // lineWidthGranularity
457 VK_TRUE, // strictLines
458 VK_TRUE, // standardSampleLocations
459 1, // optimalBufferCopyOffsetAlignment
460 1, // optimalBufferCopyRowPitchAlignment
461 64, // nonCoherentAtomSize
462 };
Jesse Hall04f4f472015-08-16 19:51:04 -0700463}
464
Jesse Hall606a54e2015-11-19 22:17:28 -0800465void GetPhysicalDeviceQueueFamilyProperties(
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700466 VkPhysicalDevice,
467 uint32_t* count,
468 VkQueueFamilyProperties* properties) {
Jesse Hall715b86a2016-01-16 16:34:29 -0800469 if (!properties || *count > 1)
470 *count = 1;
471 if (properties && *count == 1) {
Jesse Hall65ab5522015-11-30 00:07:16 -0800472 properties->queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT |
473 VK_QUEUE_TRANSFER_BIT;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700474 properties->queueCount = 1;
Jesse Hallacfa5342015-11-19 21:51:33 -0800475 properties->timestampValidBits = 64;
Jesse Hall715b86a2016-01-16 16:34:29 -0800476 properties->minImageTransferGranularity = VkExtent3D{1, 1, 1};
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700477 }
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700478}
479
Jesse Hall606a54e2015-11-19 22:17:28 -0800480void GetPhysicalDeviceMemoryProperties(
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100481 VkPhysicalDevice,
482 VkPhysicalDeviceMemoryProperties* properties) {
483 properties->memoryTypeCount = 1;
484 properties->memoryTypes[0].propertyFlags =
Jesse Halld1af8122015-11-29 23:50:38 -0800485 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
486 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
487 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
488 VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100489 properties->memoryTypes[0].heapIndex = 0;
490 properties->memoryHeapCount = 1;
Jesse Hallbde8ee32015-09-01 16:24:29 -0700491 properties->memoryHeaps[0].size = kMaxDeviceMemory;
Jesse Halld1af8122015-11-29 23:50:38 -0800492 properties->memoryHeaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
Jesse Hall04f4f472015-08-16 19:51:04 -0700493}
494
Jesse Hall8e37cf32016-01-18 04:00:57 -0800495void GetPhysicalDeviceFeatures(VkPhysicalDevice /*gpu*/,
496 VkPhysicalDeviceFeatures* features) {
497 *features = VkPhysicalDeviceFeatures{
498 VK_TRUE, // robustBufferAccess
499 VK_FALSE, // fullDrawIndexUint32
500 VK_FALSE, // imageCubeArray
501 VK_FALSE, // independentBlend
502 VK_FALSE, // geometryShader
503 VK_FALSE, // tessellationShader
504 VK_FALSE, // sampleRateShading
505 VK_FALSE, // dualSrcBlend
506 VK_FALSE, // logicOp
507 VK_FALSE, // multiDrawIndirect
508 VK_FALSE, // drawIndirectFirstInstance
509 VK_FALSE, // depthClamp
510 VK_FALSE, // depthBiasClamp
511 VK_FALSE, // fillModeNonSolid
512 VK_FALSE, // depthBounds
513 VK_FALSE, // wideLines
514 VK_FALSE, // largePoints
515 VK_FALSE, // alphaToOne
516 VK_FALSE, // multiViewport
517 VK_FALSE, // samplerAnisotropy
518 VK_FALSE, // textureCompressionETC2
519 VK_FALSE, // textureCompressionASTC_LDR
520 VK_FALSE, // textureCompressionBC
521 VK_FALSE, // occlusionQueryPrecise
522 VK_FALSE, // pipelineStatisticsQuery
523 VK_FALSE, // vertexPipelineStoresAndAtomics
524 VK_FALSE, // fragmentStoresAndAtomics
525 VK_FALSE, // shaderTessellationAndGeometryPointSize
526 VK_FALSE, // shaderImageGatherExtended
527 VK_FALSE, // shaderStorageImageExtendedFormats
528 VK_FALSE, // shaderStorageImageMultisample
529 VK_FALSE, // shaderStorageImageReadWithoutFormat
530 VK_FALSE, // shaderStorageImageWriteWithoutFormat
531 VK_FALSE, // shaderUniformBufferArrayDynamicIndexing
532 VK_FALSE, // shaderSampledImageArrayDynamicIndexing
533 VK_FALSE, // shaderStorageBufferArrayDynamicIndexing
534 VK_FALSE, // shaderStorageImageArrayDynamicIndexing
535 VK_FALSE, // shaderClipDistance
536 VK_FALSE, // shaderCullDistance
537 VK_FALSE, // shaderFloat64
538 VK_FALSE, // shaderInt64
539 VK_FALSE, // shaderInt16
540 VK_FALSE, // shaderResourceResidency
541 VK_FALSE, // shaderResourceMinLod
542 VK_FALSE, // sparseBinding
543 VK_FALSE, // sparseResidencyBuffer
544 VK_FALSE, // sparseResidencyImage2D
545 VK_FALSE, // sparseResidencyImage3D
546 VK_FALSE, // sparseResidency2Samples
547 VK_FALSE, // sparseResidency4Samples
548 VK_FALSE, // sparseResidency8Samples
549 VK_FALSE, // sparseResidency16Samples
550 VK_FALSE, // sparseResidencyAliased
551 VK_FALSE, // variableMultisampleRate
552 VK_FALSE, // inheritedQueries
553 };
554}
555
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100556// -----------------------------------------------------------------------------
557// Device
558
Jesse Hall04f4f472015-08-16 19:51:04 -0700559VkResult CreateDevice(VkPhysicalDevice physical_device,
Jesse Hallb1471272016-01-17 21:36:58 -0800560 const VkDeviceCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800561 const VkAllocationCallbacks* allocator,
Jesse Hall04f4f472015-08-16 19:51:04 -0700562 VkDevice* out_device) {
563 VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800564 if (!allocator)
565 allocator = &instance->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800566 VkDevice_T* device = static_cast<VkDevice_T*>(allocator->pfnAllocation(
567 allocator->pUserData, sizeof(VkDevice_T), alignof(VkDevice_T),
568 VK_SYSTEM_ALLOCATION_SCOPE_DEVICE));
Jesse Hall04f4f472015-08-16 19:51:04 -0700569 if (!device)
570 return VK_ERROR_OUT_OF_HOST_MEMORY;
571
572 device->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800573 device->allocator = *allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -0700574 device->instance = instance;
575 device->queue.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700576 std::fill(device->next_handle.begin(), device->next_handle.end(),
577 UINT64_C(0));
Jesse Hall04f4f472015-08-16 19:51:04 -0700578
Jesse Hallb1471272016-01-17 21:36:58 -0800579 for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
580 if (strcmp(create_info->ppEnabledExtensionNames[i],
581 VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME) == 0) {
582 ALOGV("Enabling " VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME);
583 }
584 }
585
Jesse Hall04f4f472015-08-16 19:51:04 -0700586 *out_device = device;
587 return VK_SUCCESS;
588}
589
Jesse Hall3fbc8562015-11-29 22:10:52 -0800590void DestroyDevice(VkDevice device,
591 const VkAllocationCallbacks* /*allocator*/) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700592 if (!device)
Jesse Hallcf25c412015-10-29 17:14:50 -0700593 return;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800594 device->allocator.pfnFree(device->allocator.pUserData, device);
Jesse Hall04f4f472015-08-16 19:51:04 -0700595}
596
Jesse Hall606a54e2015-11-19 22:17:28 -0800597void GetDeviceQueue(VkDevice device, uint32_t, uint32_t, VkQueue* queue) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700598 *queue = &device->queue;
Jesse Hall04f4f472015-08-16 19:51:04 -0700599}
600
601// -----------------------------------------------------------------------------
Jesse Hall3fbc8562015-11-29 22:10:52 -0800602// CommandPool
Jesse Hall03b6fe12015-11-24 12:44:21 -0800603
Jesse Hall3fbc8562015-11-29 22:10:52 -0800604struct CommandPool {
605 typedef VkCommandPool HandleType;
606 VkAllocationCallbacks allocator;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800607};
Jesse Hall3fbc8562015-11-29 22:10:52 -0800608DEFINE_OBJECT_HANDLE_CONVERSION(CommandPool)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800609
610VkResult CreateCommandPool(VkDevice device,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800611 const VkCommandPoolCreateInfo* /*create_info*/,
612 const VkAllocationCallbacks* allocator,
613 VkCommandPool* cmd_pool) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800614 if (!allocator)
615 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800616 CommandPool* pool = static_cast<CommandPool*>(allocator->pfnAllocation(
617 allocator->pUserData, sizeof(CommandPool), alignof(CommandPool),
618 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall03b6fe12015-11-24 12:44:21 -0800619 if (!pool)
620 return VK_ERROR_OUT_OF_HOST_MEMORY;
621 pool->allocator = *allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800622 *cmd_pool = GetHandleToCommandPool(pool);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800623 return VK_SUCCESS;
624}
625
626void DestroyCommandPool(VkDevice /*device*/,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800627 VkCommandPool cmd_pool,
628 const VkAllocationCallbacks* /*allocator*/) {
629 CommandPool* pool = GetCommandPoolFromHandle(cmd_pool);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800630 pool->allocator.pfnFree(pool->allocator.pUserData, pool);
631}
632
633// -----------------------------------------------------------------------------
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700634// CmdBuffer
635
Jesse Hall3fbc8562015-11-29 22:10:52 -0800636VkResult AllocateCommandBuffers(VkDevice /*device*/,
637 const VkCommandBufferAllocateInfo* alloc_info,
638 VkCommandBuffer* cmdbufs) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800639 VkResult result = VK_SUCCESS;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800640 CommandPool& pool = *GetCommandPoolFromHandle(alloc_info->commandPool);
Jesse Hall3dd678a2016-01-08 21:52:01 -0800641 std::fill(cmdbufs, cmdbufs + alloc_info->commandBufferCount, nullptr);
642 for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) {
Jesse Hall3fbc8562015-11-29 22:10:52 -0800643 cmdbufs[i] =
644 static_cast<VkCommandBuffer_T*>(pool.allocator.pfnAllocation(
645 pool.allocator.pUserData, sizeof(VkCommandBuffer_T),
646 alignof(VkCommandBuffer_T), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hallfbf97b02015-11-20 14:17:03 -0800647 if (!cmdbufs[i]) {
648 result = VK_ERROR_OUT_OF_HOST_MEMORY;
649 break;
650 }
651 cmdbufs[i]->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
652 }
653 if (result != VK_SUCCESS) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800654 for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800655 if (!cmdbufs[i])
656 break;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800657 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800658 }
659 }
Jesse Hallfbf97b02015-11-20 14:17:03 -0800660 return result;
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700661}
662
Jesse Hall03b6fe12015-11-24 12:44:21 -0800663void FreeCommandBuffers(VkDevice /*device*/,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800664 VkCommandPool cmd_pool,
Jesse Hallfbf97b02015-11-20 14:17:03 -0800665 uint32_t count,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800666 const VkCommandBuffer* cmdbufs) {
667 CommandPool& pool = *GetCommandPoolFromHandle(cmd_pool);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800668 for (uint32_t i = 0; i < count; i++)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800669 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700670}
671
672// -----------------------------------------------------------------------------
Jesse Hall2077ce02015-08-29 18:10:59 +0100673// DeviceMemory
674
675struct DeviceMemory {
676 typedef VkDeviceMemory HandleType;
677 VkDeviceSize size;
678 alignas(16) uint8_t data[0];
679};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800680DEFINE_OBJECT_HANDLE_CONVERSION(DeviceMemory)
Jesse Hall2077ce02015-08-29 18:10:59 +0100681
Jesse Hall3fbc8562015-11-29 22:10:52 -0800682VkResult AllocateMemory(VkDevice device,
683 const VkMemoryAllocateInfo* alloc_info,
684 const VkAllocationCallbacks* allocator,
685 VkDeviceMemory* mem_handle) {
Jesse Hall2077ce02015-08-29 18:10:59 +0100686 if (SIZE_MAX - sizeof(DeviceMemory) <= alloc_info->allocationSize)
687 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800688 if (!allocator)
689 allocator = &device->allocator;
Jesse Hall2077ce02015-08-29 18:10:59 +0100690
Jesse Hall2077ce02015-08-29 18:10:59 +0100691 size_t size = sizeof(DeviceMemory) + size_t(alloc_info->allocationSize);
Jesse Hall3fbc8562015-11-29 22:10:52 -0800692 DeviceMemory* mem = static_cast<DeviceMemory*>(allocator->pfnAllocation(
693 allocator->pUserData, size, alignof(DeviceMemory),
694 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall2077ce02015-08-29 18:10:59 +0100695 if (!mem)
696 return VK_ERROR_OUT_OF_HOST_MEMORY;
697 mem->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800698 *mem_handle = GetHandleToDeviceMemory(mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100699 return VK_SUCCESS;
700}
701
Jesse Hall03b6fe12015-11-24 12:44:21 -0800702void FreeMemory(VkDevice device,
703 VkDeviceMemory mem_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800704 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800705 if (!allocator)
706 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800707 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800708 allocator->pfnFree(allocator->pUserData, mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100709}
710
711VkResult MapMemory(VkDevice,
712 VkDeviceMemory mem_handle,
713 VkDeviceSize offset,
714 VkDeviceSize,
715 VkMemoryMapFlags,
716 void** out_ptr) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800717 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall2077ce02015-08-29 18:10:59 +0100718 *out_ptr = &mem->data[0] + offset;
719 return VK_SUCCESS;
720}
721
722// -----------------------------------------------------------------------------
Jesse Hallf6578742015-08-29 17:06:12 +0100723// Buffer
724
725struct Buffer {
726 typedef VkBuffer HandleType;
727 VkDeviceSize size;
728};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800729DEFINE_OBJECT_HANDLE_CONVERSION(Buffer)
Jesse Hallf6578742015-08-29 17:06:12 +0100730
731VkResult CreateBuffer(VkDevice device,
732 const VkBufferCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800733 const VkAllocationCallbacks* allocator,
Jesse Hallf6578742015-08-29 17:06:12 +0100734 VkBuffer* buffer_handle) {
Jesse Hallbde8ee32015-09-01 16:24:29 -0700735 ALOGW_IF(create_info->size > kMaxDeviceMemory,
736 "CreateBuffer: requested size 0x%" PRIx64
737 " exceeds max device memory size 0x%" PRIx64,
738 create_info->size, kMaxDeviceMemory);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800739 if (!allocator)
740 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800741 Buffer* buffer = static_cast<Buffer*>(allocator->pfnAllocation(
742 allocator->pUserData, sizeof(Buffer), alignof(Buffer),
743 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hallf6578742015-08-29 17:06:12 +0100744 if (!buffer)
745 return VK_ERROR_OUT_OF_HOST_MEMORY;
746 buffer->size = create_info->size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800747 *buffer_handle = GetHandleToBuffer(buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100748 return VK_SUCCESS;
749}
750
Jesse Hall606a54e2015-11-19 22:17:28 -0800751void GetBufferMemoryRequirements(VkDevice,
752 VkBuffer buffer_handle,
753 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800754 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hallf6578742015-08-29 17:06:12 +0100755 requirements->size = buffer->size;
756 requirements->alignment = 16; // allow fast Neon/SSE memcpy
757 requirements->memoryTypeBits = 0x1;
Jesse Hallf6578742015-08-29 17:06:12 +0100758}
759
Jesse Hall03b6fe12015-11-24 12:44:21 -0800760void DestroyBuffer(VkDevice device,
761 VkBuffer buffer_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800762 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800763 if (!allocator)
764 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800765 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800766 allocator->pfnFree(allocator->pUserData, buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100767}
768
769// -----------------------------------------------------------------------------
Jesse Hall85c05b62015-09-01 18:07:41 -0700770// Image
771
772struct Image {
773 typedef VkImage HandleType;
774 VkDeviceSize size;
775};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800776DEFINE_OBJECT_HANDLE_CONVERSION(Image)
Jesse Hall85c05b62015-09-01 18:07:41 -0700777
778VkResult CreateImage(VkDevice device,
779 const VkImageCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800780 const VkAllocationCallbacks* allocator,
Jesse Hall85c05b62015-09-01 18:07:41 -0700781 VkImage* image_handle) {
782 if (create_info->imageType != VK_IMAGE_TYPE_2D ||
783 create_info->format != VK_FORMAT_R8G8B8A8_UNORM ||
784 create_info->mipLevels != 1) {
785 ALOGE("CreateImage: not yet implemented: type=%d format=%d mips=%u",
786 create_info->imageType, create_info->format,
787 create_info->mipLevels);
Jesse Halla15a4bf2015-11-19 22:48:02 -0800788 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall85c05b62015-09-01 18:07:41 -0700789 }
790
791 VkDeviceSize size =
792 VkDeviceSize(create_info->extent.width * create_info->extent.height) *
Jesse Halla15a4bf2015-11-19 22:48:02 -0800793 create_info->arrayLayers * create_info->samples * 4u;
Jesse Hall85c05b62015-09-01 18:07:41 -0700794 ALOGW_IF(size > kMaxDeviceMemory,
795 "CreateImage: image size 0x%" PRIx64
796 " exceeds max device memory size 0x%" PRIx64,
797 size, kMaxDeviceMemory);
798
Jesse Hall03b6fe12015-11-24 12:44:21 -0800799 if (!allocator)
800 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800801 Image* image = static_cast<Image*>(allocator->pfnAllocation(
802 allocator->pUserData, sizeof(Image), alignof(Image),
803 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall85c05b62015-09-01 18:07:41 -0700804 if (!image)
805 return VK_ERROR_OUT_OF_HOST_MEMORY;
806 image->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800807 *image_handle = GetHandleToImage(image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700808 return VK_SUCCESS;
809}
810
Jesse Hall606a54e2015-11-19 22:17:28 -0800811void GetImageMemoryRequirements(VkDevice,
812 VkImage image_handle,
813 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800814 Image* image = GetImageFromHandle(image_handle);
Jesse Hall85c05b62015-09-01 18:07:41 -0700815 requirements->size = image->size;
816 requirements->alignment = 16; // allow fast Neon/SSE memcpy
817 requirements->memoryTypeBits = 0x1;
Jesse Hall85c05b62015-09-01 18:07:41 -0700818}
819
Jesse Hall03b6fe12015-11-24 12:44:21 -0800820void DestroyImage(VkDevice device,
821 VkImage image_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800822 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800823 if (!allocator)
824 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800825 Image* image = GetImageFromHandle(image_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800826 allocator->pfnFree(allocator->pUserData, image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700827}
828
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800829VkResult GetSwapchainGrallocUsageANDROID(VkDevice,
830 VkFormat,
831 VkImageUsageFlags,
832 int* grallocUsage) {
833 // The null driver never reads or writes the gralloc buffer
834 *grallocUsage = 0;
835 return VK_SUCCESS;
836}
837
838VkResult AcquireImageANDROID(VkDevice,
839 VkImage,
840 int fence,
841 VkSemaphore,
842 VkFence) {
843 close(fence);
844 return VK_SUCCESS;
845}
846
847VkResult QueueSignalReleaseImageANDROID(VkQueue,
848 uint32_t,
849 const VkSemaphore*,
850 VkImage,
851 int* fence) {
852 *fence = -1;
853 return VK_SUCCESS;
854}
855
Jesse Hall85c05b62015-09-01 18:07:41 -0700856// -----------------------------------------------------------------------------
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700857// No-op types
858
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700859VkResult CreateBufferView(VkDevice device,
860 const VkBufferViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800861 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700862 VkBufferView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800863 *view = AllocHandle<VkBufferView>(device, HandleType::kBufferView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700864 return VK_SUCCESS;
865}
866
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700867VkResult CreateDescriptorPool(VkDevice device,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700868 const VkDescriptorPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800869 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700870 VkDescriptorPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800871 *pool = AllocHandle<VkDescriptorPool>(device, HandleType::kDescriptorPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700872 return VK_SUCCESS;
873}
874
Jesse Hall3fbc8562015-11-29 22:10:52 -0800875VkResult AllocateDescriptorSets(VkDevice device,
876 const VkDescriptorSetAllocateInfo* alloc_info,
877 VkDescriptorSet* descriptor_sets) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800878 for (uint32_t i = 0; i < alloc_info->descriptorSetCount; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800879 descriptor_sets[i] =
880 AllocHandle<VkDescriptorSet>(device, HandleType::kDescriptorSet);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700881 return VK_SUCCESS;
882}
883
884VkResult CreateDescriptorSetLayout(VkDevice device,
885 const VkDescriptorSetLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800886 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700887 VkDescriptorSetLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800888 *layout = AllocHandle<VkDescriptorSetLayout>(
889 device, HandleType::kDescriptorSetLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700890 return VK_SUCCESS;
891}
892
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700893VkResult CreateEvent(VkDevice device,
894 const VkEventCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800895 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700896 VkEvent* event) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800897 *event = AllocHandle<VkEvent>(device, HandleType::kEvent);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700898 return VK_SUCCESS;
899}
900
901VkResult CreateFence(VkDevice device,
902 const VkFenceCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800903 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700904 VkFence* fence) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800905 *fence = AllocHandle<VkFence>(device, HandleType::kFence);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700906 return VK_SUCCESS;
907}
908
909VkResult CreateFramebuffer(VkDevice device,
910 const VkFramebufferCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800911 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700912 VkFramebuffer* framebuffer) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800913 *framebuffer = AllocHandle<VkFramebuffer>(device, HandleType::kFramebuffer);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700914 return VK_SUCCESS;
915}
916
917VkResult CreateImageView(VkDevice device,
918 const VkImageViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800919 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700920 VkImageView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800921 *view = AllocHandle<VkImageView>(device, HandleType::kImageView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700922 return VK_SUCCESS;
923}
924
925VkResult CreateGraphicsPipelines(VkDevice device,
926 VkPipelineCache,
927 uint32_t count,
928 const VkGraphicsPipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800929 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700930 VkPipeline* pipelines) {
931 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800932 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700933 return VK_SUCCESS;
934}
935
936VkResult CreateComputePipelines(VkDevice device,
937 VkPipelineCache,
938 uint32_t count,
939 const VkComputePipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800940 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700941 VkPipeline* pipelines) {
942 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800943 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700944 return VK_SUCCESS;
945}
946
947VkResult CreatePipelineCache(VkDevice device,
948 const VkPipelineCacheCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800949 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700950 VkPipelineCache* cache) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800951 *cache = AllocHandle<VkPipelineCache>(device, HandleType::kPipelineCache);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700952 return VK_SUCCESS;
953}
954
955VkResult CreatePipelineLayout(VkDevice device,
956 const VkPipelineLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800957 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700958 VkPipelineLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800959 *layout =
960 AllocHandle<VkPipelineLayout>(device, HandleType::kPipelineLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700961 return VK_SUCCESS;
962}
963
964VkResult CreateQueryPool(VkDevice device,
965 const VkQueryPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800966 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700967 VkQueryPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800968 *pool = AllocHandle<VkQueryPool>(device, HandleType::kQueryPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700969 return VK_SUCCESS;
970}
971
972VkResult CreateRenderPass(VkDevice device,
973 const VkRenderPassCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800974 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700975 VkRenderPass* renderpass) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800976 *renderpass = AllocHandle<VkRenderPass>(device, HandleType::kRenderPass);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700977 return VK_SUCCESS;
978}
979
980VkResult CreateSampler(VkDevice device,
981 const VkSamplerCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800982 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700983 VkSampler* sampler) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800984 *sampler = AllocHandle<VkSampler>(device, HandleType::kSampler);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700985 return VK_SUCCESS;
986}
987
988VkResult CreateSemaphore(VkDevice device,
989 const VkSemaphoreCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800990 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700991 VkSemaphore* semaphore) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800992 *semaphore = AllocHandle<VkSemaphore>(device, HandleType::kSemaphore);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700993 return VK_SUCCESS;
994}
995
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700996VkResult CreateShaderModule(VkDevice device,
997 const VkShaderModuleCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800998 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700999 VkShaderModule* module) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001000 *module = AllocHandle<VkShaderModule>(device, HandleType::kShaderModule);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001001 return VK_SUCCESS;
1002}
1003
Jesse Hall715b86a2016-01-16 16:34:29 -08001004VkResult CreateDebugReportCallbackEXT(VkInstance instance,
1005 const VkDebugReportCallbackCreateInfoEXT*,
1006 const VkAllocationCallbacks*,
1007 VkDebugReportCallbackEXT* callback) {
1008 *callback = AllocHandle<VkDebugReportCallbackEXT>(
1009 instance, HandleType::kDebugReportCallbackEXT);
1010 return VK_SUCCESS;
1011}
1012
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001013// -----------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -07001014// No-op entrypoints
1015
1016// clang-format off
1017#pragma clang diagnostic push
1018#pragma clang diagnostic ignored "-Wunused-parameter"
1019
Jesse Hall606a54e2015-11-19 22:17:28 -08001020void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001021 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001022}
1023
Jesse Halla9e57032015-11-30 01:03:10 -08001024VkResult GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001025 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Halla9e57032015-11-30 01:03:10 -08001026 return VK_SUCCESS;
Jesse Hall04f4f472015-08-16 19:51:04 -07001027}
1028
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001029VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001030 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001031 return VK_SUCCESS;
1032}
1033
Jesse Halla366a512015-11-19 22:30:07 -08001034VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001035 return VK_SUCCESS;
1036}
1037
1038VkResult QueueWaitIdle(VkQueue queue) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001039 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001040 return VK_SUCCESS;
1041}
1042
1043VkResult DeviceWaitIdle(VkDevice device) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001044 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001045 return VK_SUCCESS;
1046}
1047
Jesse Hallcf25c412015-10-29 17:14:50 -07001048void UnmapMemory(VkDevice device, VkDeviceMemory mem) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001049}
1050
1051VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001052 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001053 return VK_SUCCESS;
1054}
1055
1056VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001057 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001058 return VK_SUCCESS;
1059}
1060
Jesse Hall606a54e2015-11-19 22:17:28 -08001061void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001062 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001063}
1064
Jesse Hall04f4f472015-08-16 19:51:04 -07001065VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) {
1066 return VK_SUCCESS;
1067}
1068
Jesse Hall04f4f472015-08-16 19:51:04 -07001069VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) {
1070 return VK_SUCCESS;
1071}
1072
Jesse Hall606a54e2015-11-19 22:17:28 -08001073void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001074 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001075}
1076
Jesse Hall091ed9e2015-11-30 00:55:29 -08001077void GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pNumProperties, VkSparseImageFormatProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001078 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001079}
1080
Jesse Halla6429252015-11-29 18:59:42 -08001081VkResult QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001082 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001083 return VK_SUCCESS;
1084}
1085
Jesse Hall3fbc8562015-11-29 22:10:52 -08001086void DestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001087}
1088
1089VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) {
1090 return VK_SUCCESS;
1091}
1092
1093VkResult GetFenceStatus(VkDevice device, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001094 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001095 return VK_SUCCESS;
1096}
1097
1098VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) {
1099 return VK_SUCCESS;
1100}
1101
Jesse Hall3fbc8562015-11-29 22:10:52 -08001102void DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001103}
1104
Jesse Hall3fbc8562015-11-29 22:10:52 -08001105void DestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001106}
1107
1108VkResult GetEventStatus(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001109 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001110 return VK_SUCCESS;
1111}
1112
1113VkResult SetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001114 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001115 return VK_SUCCESS;
1116}
1117
1118VkResult ResetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001119 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001120 return VK_SUCCESS;
1121}
1122
Jesse Hall3fbc8562015-11-29 22:10:52 -08001123void DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001124}
1125
Jesse Halla9bb62b2015-11-21 19:31:56 -08001126VkResult 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 +01001127 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001128 return VK_SUCCESS;
1129}
1130
Jesse Hall3fbc8562015-11-29 22:10:52 -08001131void DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001132}
1133
Jesse Hall606a54e2015-11-19 22:17:28 -08001134void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001135 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001136}
1137
Jesse Hall3fbc8562015-11-29 22:10:52 -08001138void DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001139}
1140
Jesse Hall3fbc8562015-11-29 22:10:52 -08001141void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001142}
1143
Jesse Hall3fbc8562015-11-29 22:10:52 -08001144void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001145}
1146
Jesse Halla9bb62b2015-11-21 19:31:56 -08001147VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001148 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001149 return VK_SUCCESS;
1150}
1151
1152VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001153 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001154 return VK_SUCCESS;
1155}
1156
Jesse Hall3fbc8562015-11-29 22:10:52 -08001157void DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001158}
1159
Jesse Hall3fbc8562015-11-29 22:10:52 -08001160void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001161}
1162
Jesse Hall3fbc8562015-11-29 22:10:52 -08001163void DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001164}
1165
Jesse Hall3fbc8562015-11-29 22:10:52 -08001166void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001167}
1168
Jesse Hall3fbc8562015-11-29 22:10:52 -08001169void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001170}
1171
Jesse Hallfbf97b02015-11-20 14:17:03 -08001172VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001173 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001174 return VK_SUCCESS;
1175}
1176
Jesse Hallcf25c412015-10-29 17:14:50 -07001177void UpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001178 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001179}
1180
1181VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001182 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001183 return VK_SUCCESS;
1184}
1185
Jesse Hall3fbc8562015-11-29 22:10:52 -08001186void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001187}
1188
Jesse Hall3fbc8562015-11-29 22:10:52 -08001189void DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001190}
1191
Jesse Hall606a54e2015-11-19 22:17:28 -08001192void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001193 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001194}
1195
Jesse Hall3fbc8562015-11-29 22:10:52 -08001196VkResult ResetCommandPool(VkDevice device, VkCommandPool cmdPool, VkCommandPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001197 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001198 return VK_SUCCESS;
1199}
1200
Jesse Hall3fbc8562015-11-29 22:10:52 -08001201VkResult BeginCommandBuffer(VkCommandBuffer cmdBuffer, const VkCommandBufferBeginInfo* pBeginInfo) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001202 return VK_SUCCESS;
1203}
1204
Jesse Hall3fbc8562015-11-29 22:10:52 -08001205VkResult EndCommandBuffer(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001206 return VK_SUCCESS;
1207}
1208
Jesse Hall3fbc8562015-11-29 22:10:52 -08001209VkResult ResetCommandBuffer(VkCommandBuffer cmdBuffer, VkCommandBufferResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001210 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001211 return VK_SUCCESS;
1212}
1213
Jesse Hall3fbc8562015-11-29 22:10:52 -08001214void CmdBindPipeline(VkCommandBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001215}
1216
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001217void CmdSetViewport(VkCommandBuffer cmdBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001218}
1219
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001220void CmdSetScissor(VkCommandBuffer cmdBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001221}
1222
Jesse Hall3fbc8562015-11-29 22:10:52 -08001223void CmdSetLineWidth(VkCommandBuffer cmdBuffer, float lineWidth) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001224}
1225
Jesse Hall3fbc8562015-11-29 22:10:52 -08001226void CmdSetDepthBias(VkCommandBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001227}
1228
Jesse Hall3fbc8562015-11-29 22:10:52 -08001229void CmdSetBlendConstants(VkCommandBuffer cmdBuffer, const float blendConst[4]) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001230}
1231
Jesse Hall3fbc8562015-11-29 22:10:52 -08001232void CmdSetDepthBounds(VkCommandBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001233}
1234
Jesse Hall3fbc8562015-11-29 22:10:52 -08001235void CmdSetStencilCompareMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001236}
1237
Jesse Hall3fbc8562015-11-29 22:10:52 -08001238void CmdSetStencilWriteMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001239}
1240
Jesse Hall3fbc8562015-11-29 22:10:52 -08001241void CmdSetStencilReference(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001242}
1243
Jesse Hall3fbc8562015-11-29 22:10:52 -08001244void CmdBindDescriptorSets(VkCommandBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001245}
1246
Jesse Hall3fbc8562015-11-29 22:10:52 -08001247void CmdBindIndexBuffer(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001248}
1249
Jesse Hall3fbc8562015-11-29 22:10:52 -08001250void CmdBindVertexBuffers(VkCommandBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001251}
1252
Jesse Hall3fbc8562015-11-29 22:10:52 -08001253void CmdDraw(VkCommandBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001254}
1255
Jesse Hall3fbc8562015-11-29 22:10:52 -08001256void CmdDrawIndexed(VkCommandBuffer cmdBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001257}
1258
Jesse Hall3fbc8562015-11-29 22:10:52 -08001259void CmdDrawIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001260}
1261
Jesse Hall3fbc8562015-11-29 22:10:52 -08001262void CmdDrawIndexedIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001263}
1264
Jesse Hall3fbc8562015-11-29 22:10:52 -08001265void CmdDispatch(VkCommandBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001266}
1267
Jesse Hall3fbc8562015-11-29 22:10:52 -08001268void CmdDispatchIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001269}
1270
Jesse Hall3fbc8562015-11-29 22:10:52 -08001271void CmdCopyBuffer(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001272}
1273
Jesse Hall3fbc8562015-11-29 22:10:52 -08001274void CmdCopyImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001275}
1276
Jesse Hall3fbc8562015-11-29 22:10:52 -08001277void CmdBlitImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001278}
1279
Jesse Hall3fbc8562015-11-29 22:10:52 -08001280void CmdCopyBufferToImage(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001281}
1282
Jesse Hall3fbc8562015-11-29 22:10:52 -08001283void CmdCopyImageToBuffer(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001284}
1285
Jesse Hall3fbc8562015-11-29 22:10:52 -08001286void CmdUpdateBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001287}
1288
Jesse Hall3fbc8562015-11-29 22:10:52 -08001289void CmdFillBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001290}
1291
Jesse Hall3fbc8562015-11-29 22:10:52 -08001292void CmdClearColorImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001293}
1294
Jesse Hall3fbc8562015-11-29 22:10:52 -08001295void CmdClearDepthStencilImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001296}
1297
Jesse Hall3fbc8562015-11-29 22:10:52 -08001298void CmdClearAttachments(VkCommandBuffer cmdBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001299}
1300
Jesse Hall3fbc8562015-11-29 22:10:52 -08001301void CmdResolveImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001302}
1303
Jesse Hall3fbc8562015-11-29 22:10:52 -08001304void CmdSetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001305}
1306
Jesse Hall3fbc8562015-11-29 22:10:52 -08001307void CmdResetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001308}
1309
Jesse Hall3dd678a2016-01-08 21:52:01 -08001310void CmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001311}
1312
Jesse Hall3dd678a2016-01-08 21:52:01 -08001313void CmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001314}
1315
Jesse Hall3fbc8562015-11-29 22:10:52 -08001316void CmdBeginQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001317}
1318
Jesse Hall3fbc8562015-11-29 22:10:52 -08001319void CmdEndQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001320}
1321
Jesse Hall3fbc8562015-11-29 22:10:52 -08001322void CmdResetQueryPool(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001323}
1324
Jesse Hall3fbc8562015-11-29 22:10:52 -08001325void CmdWriteTimestamp(VkCommandBuffer cmdBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001326}
1327
Jesse Hall3fbc8562015-11-29 22:10:52 -08001328void CmdCopyQueryPoolResults(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkQueryResultFlags flags) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001329}
1330
Jesse Hall3fbc8562015-11-29 22:10:52 -08001331void CmdPushConstants(VkCommandBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001332}
1333
Jesse Hall65ab5522015-11-30 00:07:16 -08001334void CmdBeginRenderPass(VkCommandBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001335}
1336
Jesse Hall65ab5522015-11-30 00:07:16 -08001337void CmdNextSubpass(VkCommandBuffer cmdBuffer, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001338}
1339
Jesse Hall3fbc8562015-11-29 22:10:52 -08001340void CmdEndRenderPass(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001341}
1342
Jesse Hall3fbc8562015-11-29 22:10:52 -08001343void CmdExecuteCommands(VkCommandBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCommandBuffer* pCmdBuffers) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001344}
1345
Jesse Hall715b86a2016-01-16 16:34:29 -08001346void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) {
1347}
1348
1349void DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage) {
1350}
1351
Jesse Hall04f4f472015-08-16 19:51:04 -07001352#pragma clang diagnostic pop
1353// clang-format on
1354
1355} // namespace null_driver