blob: cd61e86f0f4be6b6c51c47f40c625bd7e30b7865 [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>
Jesse Hall715b86a2016-01-16 16:34:29 -080018#include <vulkan/vk_ext_debug_report.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070019
Jesse Hall1f91d392015-12-11 16:28:44 -080020#include <algorithm>
21#include <array>
Jesse Hall715b86a2016-01-16 16:34:29 -080022#include <inttypes.h>
23#include <string.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070024
Jesse Hall73ab0ac2015-08-25 15:09:15 +010025#include <log/log.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070026#include <utils/Errors.h>
27
Jesse Hall1f91d392015-12-11 16:28:44 -080028#include "null_driver_gen.h"
Jesse Hall04f4f472015-08-16 19:51:04 -070029
30using namespace null_driver;
31
32struct VkPhysicalDevice_T {
33 hwvulkan_dispatch_t dispatch;
34};
35
36struct VkInstance_T {
37 hwvulkan_dispatch_t dispatch;
Jesse Hall3fbc8562015-11-29 22:10:52 -080038 VkAllocationCallbacks allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -070039 VkPhysicalDevice_T physical_device;
Jesse Hall715b86a2016-01-16 16:34:29 -080040 uint64_t next_callback_handle;
Jesse Hall04f4f472015-08-16 19:51:04 -070041};
42
43struct VkQueue_T {
44 hwvulkan_dispatch_t dispatch;
45};
46
Jesse Hall3fbc8562015-11-29 22:10:52 -080047struct VkCommandBuffer_T {
Jesse Hall04f4f472015-08-16 19:51:04 -070048 hwvulkan_dispatch_t dispatch;
49};
50
Jesse Hallf8faf0c2015-08-31 11:34:32 -070051namespace {
52// Handles for non-dispatchable objects are either pointers, or arbitrary
53// 64-bit non-zero values. We only use pointers when we need to keep state for
54// the object even in a null driver. For the rest, we form a handle as:
55// [63:63] = 1 to distinguish from pointer handles*
56// [62:56] = non-zero handle type enum value
57// [55: 0] = per-handle-type incrementing counter
58// * This works because virtual addresses with the high bit set are reserved
59// for kernel data in all ABIs we run on.
60//
61// We never reclaim handles on vkDestroy*. It's not even necessary for us to
62// have distinct handles for live objects, and practically speaking we won't
63// ever create 2^56 objects of the same type from a single VkDevice in a null
64// driver.
65//
66// Using a namespace here instead of 'enum class' since we want scoped
67// constants but also want implicit conversions to integral types.
68namespace HandleType {
Jesse Hallc7a6eb52015-08-31 12:52:03 -070069enum Enum {
Jesse Hallc7a6eb52015-08-31 12:52:03 -070070 kBufferView,
Jesse Hall715b86a2016-01-16 16:34:29 -080071 kDebugReportCallbackEXT,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070072 kDescriptorPool,
73 kDescriptorSet,
74 kDescriptorSetLayout,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070075 kEvent,
76 kFence,
77 kFramebuffer,
78 kImageView,
79 kPipeline,
80 kPipelineCache,
81 kPipelineLayout,
82 kQueryPool,
83 kRenderPass,
84 kSampler,
85 kSemaphore,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070086 kShaderModule,
Jesse Hallf8faf0c2015-08-31 11:34:32 -070087
Jesse Hallc7a6eb52015-08-31 12:52:03 -070088 kNumTypes
89};
90} // namespace HandleType
Jesse Hallbde8ee32015-09-01 16:24:29 -070091
Jesse Hall00f10fe2016-02-08 21:20:20 -080092const VkDeviceSize kMaxDeviceMemory = 0x10000000; // 256 MiB, arbitrary
Jesse Hallbde8ee32015-09-01 16:24:29 -070093
Jesse Hallc7a6eb52015-08-31 12:52:03 -070094} // anonymous namespace
Jesse Hallf8faf0c2015-08-31 11:34:32 -070095
Jesse Hall04f4f472015-08-16 19:51:04 -070096struct VkDevice_T {
97 hwvulkan_dispatch_t dispatch;
Jesse Hall3fbc8562015-11-29 22:10:52 -080098 VkAllocationCallbacks allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -070099 VkInstance_T* instance;
100 VkQueue_T queue;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700101 std::array<uint64_t, HandleType::kNumTypes> next_handle;
Jesse Hall04f4f472015-08-16 19:51:04 -0700102};
103
104// -----------------------------------------------------------------------------
105// Declare HAL_MODULE_INFO_SYM early so it can be referenced by nulldrv_device
106// later.
107
108namespace {
109int OpenDevice(const hw_module_t* module, const char* id, hw_device_t** device);
110hw_module_methods_t nulldrv_module_methods = {.open = OpenDevice};
111} // namespace
112
113#pragma clang diagnostic push
114#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
115__attribute__((visibility("default"))) hwvulkan_module_t HAL_MODULE_INFO_SYM = {
116 .common =
117 {
Michael Lentine03c64b02015-08-26 18:27:26 -0500118 .tag = HARDWARE_MODULE_TAG,
119 .module_api_version = HWVULKAN_MODULE_API_VERSION_0_1,
120 .hal_api_version = HARDWARE_HAL_API_VERSION,
121 .id = HWVULKAN_HARDWARE_MODULE_ID,
122 .name = "Null Vulkan Driver",
123 .author = "The Android Open Source Project",
124 .methods = &nulldrv_module_methods,
Jesse Hall04f4f472015-08-16 19:51:04 -0700125 },
126};
127#pragma clang diagnostic pop
128
129// -----------------------------------------------------------------------------
130
131namespace {
132
Jesse Hall04f4f472015-08-16 19:51:04 -0700133int CloseDevice(struct hw_device_t* /*device*/) {
134 // nothing to do - opening a device doesn't allocate any resources
135 return 0;
136}
137
138hwvulkan_device_t nulldrv_device = {
139 .common =
140 {
Michael Lentine03c64b02015-08-26 18:27:26 -0500141 .tag = HARDWARE_DEVICE_TAG,
142 .version = HWVULKAN_DEVICE_API_VERSION_0_1,
143 .module = &HAL_MODULE_INFO_SYM.common,
144 .close = CloseDevice,
Jesse Hall04f4f472015-08-16 19:51:04 -0700145 },
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700146 .EnumerateInstanceExtensionProperties =
147 EnumerateInstanceExtensionProperties,
Jesse Hall04f4f472015-08-16 19:51:04 -0700148 .CreateInstance = CreateInstance,
149 .GetInstanceProcAddr = GetInstanceProcAddr};
150
151int OpenDevice(const hw_module_t* /*module*/,
152 const char* id,
153 hw_device_t** device) {
154 if (strcmp(id, HWVULKAN_DEVICE_0) == 0) {
155 *device = &nulldrv_device.common;
156 return 0;
157 }
158 return -ENOENT;
159}
160
161VkInstance_T* GetInstanceFromPhysicalDevice(
162 VkPhysicalDevice_T* physical_device) {
163 return reinterpret_cast<VkInstance_T*>(
164 reinterpret_cast<uintptr_t>(physical_device) -
165 offsetof(VkInstance_T, physical_device));
166}
167
Jesse Hall715b86a2016-01-16 16:34:29 -0800168uint64_t AllocHandle(uint64_t type, uint64_t* next_handle) {
169 const uint64_t kHandleMask = (UINT64_C(1) << 56) - 1;
170 ALOGE_IF(*next_handle == kHandleMask,
171 "non-dispatchable handles of type=%" PRIu64
172 " are about to overflow",
173 type);
174 return (UINT64_C(1) << 63) | ((type & 0x7) << 56) |
175 ((*next_handle)++ & kHandleMask);
176}
177
178template <class Handle>
179Handle AllocHandle(VkInstance instance, HandleType::Enum type) {
180 return reinterpret_cast<Handle>(
181 AllocHandle(type, &instance->next_callback_handle));
182}
183
Michael Lentine3fec89e2015-12-04 16:25:11 -0800184template <class Handle>
185Handle AllocHandle(VkDevice device, HandleType::Enum type) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800186 return reinterpret_cast<Handle>(
Jesse Hall715b86a2016-01-16 16:34:29 -0800187 AllocHandle(type, &device->next_handle[type]));
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700188}
189
Jesse Hall04f4f472015-08-16 19:51:04 -0700190} // namespace
191
192namespace null_driver {
193
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800194#define DEFINE_OBJECT_HANDLE_CONVERSION(T) \
195 T* Get##T##FromHandle(Vk##T h); \
196 T* Get##T##FromHandle(Vk##T h) { \
197 return reinterpret_cast<T*>(uintptr_t(h)); \
198 } \
199 Vk##T GetHandleTo##T(const T* obj); \
200 Vk##T GetHandleTo##T(const T* obj) { \
201 return Vk##T(reinterpret_cast<uintptr_t>(obj)); \
202 }
Jesse Hallf6578742015-08-29 17:06:12 +0100203
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100204// -----------------------------------------------------------------------------
205// Global
206
Jesse Halle1b12782015-11-30 11:27:32 -0800207VKAPI_ATTR
Jesse Hall715b86a2016-01-16 16:34:29 -0800208VkResult EnumerateInstanceExtensionProperties(
209 const char* layer_name,
210 uint32_t* count,
211 VkExtensionProperties* properties) {
212 if (layer_name) {
213 ALOGW(
214 "Driver vkEnumerateInstanceExtensionProperties shouldn't be called "
215 "with a layer name ('%s')",
216 layer_name);
Jesse Hall715b86a2016-01-16 16:34:29 -0800217 }
218
Jesse Hall4b62e4f2016-01-21 09:49:49 -0800219// NOTE: Change this to zero to report and extension, which can be useful
220// for testing changes to the loader.
221#if 1
222 (void)properties; // unused
223 *count = 0;
224 return VK_SUCCESS;
225#else
Jesse Hall715b86a2016-01-16 16:34:29 -0800226 const VkExtensionProperties kExtensions[] = {
227 {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}};
228 const uint32_t kExtensionsCount =
229 sizeof(kExtensions) / sizeof(kExtensions[0]);
230
231 if (!properties || *count > kExtensionsCount)
232 *count = kExtensionsCount;
233 if (properties)
234 std::copy(kExtensions, kExtensions + *count, properties);
235 return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS;
Jesse Hall4b62e4f2016-01-21 09:49:49 -0800236#endif
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100237}
238
Jesse Halle1b12782015-11-30 11:27:32 -0800239VKAPI_ATTR
Jesse Hall715b86a2016-01-16 16:34:29 -0800240VkResult CreateInstance(const VkInstanceCreateInfo* create_info,
Jesse Hall1f91d392015-12-11 16:28:44 -0800241 const VkAllocationCallbacks* allocator,
242 VkInstance* out_instance) {
243 // Assume the loader provided alloc callbacks even if the app didn't.
244 ALOG_ASSERT(
245 allocator,
246 "Missing alloc callbacks, loader or app should have provided them");
247
248 VkInstance_T* instance =
249 static_cast<VkInstance_T*>(allocator->pfnAllocation(
250 allocator->pUserData, sizeof(VkInstance_T), alignof(VkInstance_T),
251 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE));
252 if (!instance)
253 return VK_ERROR_OUT_OF_HOST_MEMORY;
254
255 instance->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
256 instance->allocator = *allocator;
257 instance->physical_device.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall715b86a2016-01-16 16:34:29 -0800258 instance->next_callback_handle = 0;
Jesse Hall715b86a2016-01-16 16:34:29 -0800259
260 for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
261 if (strcmp(create_info->ppEnabledExtensionNames[i],
262 VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) {
Jesse Hallb1471272016-01-17 21:36:58 -0800263 ALOGV("instance extension '%s' requested",
264 create_info->ppEnabledExtensionNames[i]);
265 } else {
266 ALOGW("unsupported extension '%s' requested",
267 create_info->ppEnabledExtensionNames[i]);
Jesse Hall715b86a2016-01-16 16:34:29 -0800268 }
269 }
Jesse Hall1f91d392015-12-11 16:28:44 -0800270
271 *out_instance = instance;
272 return VK_SUCCESS;
273}
274
275VKAPI_ATTR
276PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name) {
277 return instance ? GetInstanceProcAddr(name) : GetGlobalProcAddr(name);
Jesse Hall04f4f472015-08-16 19:51:04 -0700278}
279
Jesse Halle1b12782015-11-30 11:27:32 -0800280VKAPI_ATTR
Jesse Hall04f4f472015-08-16 19:51:04 -0700281PFN_vkVoidFunction GetDeviceProcAddr(VkDevice, const char* name) {
Jesse Hall1f91d392015-12-11 16:28:44 -0800282 return GetInstanceProcAddr(name);
Jesse Hall04f4f472015-08-16 19:51:04 -0700283}
284
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100285// -----------------------------------------------------------------------------
286// Instance
287
Jesse Hall03b6fe12015-11-24 12:44:21 -0800288void DestroyInstance(VkInstance instance,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800289 const VkAllocationCallbacks* /*allocator*/) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800290 instance->allocator.pfnFree(instance->allocator.pUserData, instance);
Jesse Hall04f4f472015-08-16 19:51:04 -0700291}
292
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100293// -----------------------------------------------------------------------------
294// PhysicalDevice
295
Jesse Hall04f4f472015-08-16 19:51:04 -0700296VkResult EnumeratePhysicalDevices(VkInstance instance,
297 uint32_t* physical_device_count,
298 VkPhysicalDevice* physical_devices) {
299 if (physical_devices && *physical_device_count >= 1)
300 physical_devices[0] = &instance->physical_device;
301 *physical_device_count = 1;
302 return VK_SUCCESS;
303}
304
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800305VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice /*gpu*/,
306 uint32_t* count,
307 VkLayerProperties* /*properties*/) {
308 ALOGW("Driver vkEnumerateDeviceLayerProperties shouldn't be called");
309 *count = 0;
310 return VK_SUCCESS;
311}
312
313VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice /*gpu*/,
314 const char* layer_name,
315 uint32_t* count,
316 VkExtensionProperties* properties) {
317 if (layer_name) {
318 ALOGW(
319 "Driver vkEnumerateDeviceExtensionProperties shouldn't be called "
320 "with a layer name ('%s')",
321 layer_name);
322 *count = 0;
323 return VK_SUCCESS;
324 }
325
326 const VkExtensionProperties kExtensions[] = {
327 {VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME,
328 VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION}};
329 const uint32_t kExtensionsCount =
330 sizeof(kExtensions) / sizeof(kExtensions[0]);
331
332 if (!properties || *count > kExtensionsCount)
333 *count = kExtensionsCount;
334 if (properties)
335 std::copy(kExtensions, kExtensions + *count, properties);
336 return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS;
337}
338
Jesse Hall606a54e2015-11-19 22:17:28 -0800339void GetPhysicalDeviceProperties(VkPhysicalDevice,
340 VkPhysicalDeviceProperties* properties) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700341 properties->apiVersion = VK_API_VERSION;
342 properties->driverVersion = VK_MAKE_VERSION(0, 0, 1);
Jesse Hall65ab5522015-11-30 00:07:16 -0800343 properties->vendorID = 0;
344 properties->deviceID = 0;
Jesse Hall04f4f472015-08-16 19:51:04 -0700345 properties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER;
346 strcpy(properties->deviceName, "Android Vulkan Null Driver");
347 memset(properties->pipelineCacheUUID, 0,
348 sizeof(properties->pipelineCacheUUID));
Jesse Hallc34849e2016-02-09 22:35:04 -0800349 properties->limits = VkPhysicalDeviceLimits{
350 4096, // maxImageDimension1D
351 4096, // maxImageDimension2D
352 256, // maxImageDimension3D
353 4096, // maxImageDimensionCube
354 256, // maxImageArrayLayers
355 65536, // maxTexelBufferElements
356 16384, // maxUniformBufferRange
357 1 << 27, // maxStorageBufferRange
358 128, // maxPushConstantsSize
359 4096, // maxMemoryAllocationCount
360 4000, // maxSamplerAllocationCount
361 1, // bufferImageGranularity
362 0, // sparseAddressSpaceSize
363 4, // maxBoundDescriptorSets
364 16, // maxPerStageDescriptorSamplers
365 12, // maxPerStageDescriptorUniformBuffers
366 4, // maxPerStageDescriptorStorageBuffers
367 16, // maxPerStageDescriptorSampledImages
368 4, // maxPerStageDescriptorStorageImages
369 4, // maxPerStageDescriptorInputAttachments
370 128, // maxPerStageResources
371 96, // maxDescriptorSetSamplers
372 72, // maxDescriptorSetUniformBuffers
373 8, // maxDescriptorSetUniformBuffersDynamic
374 24, // maxDescriptorSetStorageBuffers
375 4, // maxDescriptorSetStorageBuffersDynamic
376 96, // maxDescriptorSetSampledImages
377 24, // maxDescriptorSetStorageImages
378 4, // maxDescriptorSetInputAttachments
379 16, // maxVertexInputAttributes
380 16, // maxVertexInputBindings
381 2047, // maxVertexInputAttributeOffset
382 2048, // maxVertexInputBindingStride
383 64, // maxVertexOutputComponents
384 0, // maxTessellationGenerationLevel
385 0, // maxTessellationPatchSize
386 0, // maxTessellationControlPerVertexInputComponents
387 0, // maxTessellationControlPerVertexOutputComponents
388 0, // maxTessellationControlPerPatchOutputComponents
389 0, // maxTessellationControlTotalOutputComponents
390 0, // maxTessellationEvaluationInputComponents
391 0, // maxTessellationEvaluationOutputComponents
392 0, // maxGeometryShaderInvocations
393 0, // maxGeometryInputComponents
394 0, // maxGeometryOutputComponents
395 0, // maxGeometryOutputVertices
396 0, // maxGeometryTotalOutputComponents
397 64, // maxFragmentInputComponents
398 4, // maxFragmentOutputAttachments
399 0, // maxFragmentDualSrcAttachments
400 4, // maxFragmentCombinedOutputResources
401 16384, // maxComputeSharedMemorySize
402 {65536, 65536, 65536}, // maxComputeWorkGroupCount[3]
403 128, // maxComputeWorkGroupInvocations
404 {128, 128, 64}, // maxComputeWorkGroupSize[3]
405 4, // subPixelPrecisionBits
406 4, // subTexelPrecisionBits
407 4, // mipmapPrecisionBits
408 UINT32_MAX, // maxDrawIndexedIndexValue
409 1, // maxDrawIndirectCount
410 2, // maxSamplerLodBias
411 1, // maxSamplerAnisotropy
412 1, // maxViewports
413 {4096, 4096}, // maxViewportDimensions[2]
414 {-8192.0f, 8191.0f}, // viewportBoundsRange[2]
415 0, // viewportSubPixelBits
416 64, // minMemoryMapAlignment
417 256, // minTexelBufferOffsetAlignment
418 256, // minUniformBufferOffsetAlignment
419 256, // minStorageBufferOffsetAlignment
420 -8, // minTexelOffset
421 7, // maxTexelOffset
422 0, // minTexelGatherOffset
423 0, // maxTexelGatherOffset
424 0.0f, // minInterpolationOffset
425 0.0f, // maxInterpolationOffset
426 0, // subPixelInterpolationOffsetBits
427 4096, // maxFramebufferWidth
428 4096, // maxFramebufferHeight
429 256, // maxFramebufferLayers
430 VK_SAMPLE_COUNT_1_BIT |
431 VK_SAMPLE_COUNT_4_BIT, // framebufferColorSampleCounts
432 VK_SAMPLE_COUNT_1_BIT |
433 VK_SAMPLE_COUNT_4_BIT, // framebufferDepthSampleCounts
434 VK_SAMPLE_COUNT_1_BIT |
435 VK_SAMPLE_COUNT_4_BIT, // framebufferStencilSampleCounts
436 VK_SAMPLE_COUNT_1_BIT |
437 VK_SAMPLE_COUNT_4_BIT, // framebufferNoAttachmentsSampleCounts
438 4, // maxColorAttachments
439 VK_SAMPLE_COUNT_1_BIT |
440 VK_SAMPLE_COUNT_4_BIT, // sampledImageColorSampleCounts
441 VK_SAMPLE_COUNT_1_BIT, // sampledImageIntegerSampleCounts
442 VK_SAMPLE_COUNT_1_BIT |
443 VK_SAMPLE_COUNT_4_BIT, // sampledImageDepthSampleCounts
444 VK_SAMPLE_COUNT_1_BIT |
445 VK_SAMPLE_COUNT_4_BIT, // sampledImageStencilSampleCounts
446 VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts
447 1, // maxSampleMaskWords
448 VK_TRUE, // timestampComputeAndGraphics
449 1, // timestampPeriod
450 0, // maxClipDistances
451 0, // maxCullDistances
452 0, // maxCombinedClipAndCullDistances
453 2, // discreteQueuePriorities
454 {1.0f, 1.0f}, // pointSizeRange[2]
455 {1.0f, 1.0f}, // lineWidthRange[2]
456 0.0f, // pointSizeGranularity
457 0.0f, // lineWidthGranularity
458 VK_TRUE, // strictLines
459 VK_TRUE, // standardSampleLocations
460 1, // optimalBufferCopyOffsetAlignment
461 1, // optimalBufferCopyRowPitchAlignment
462 64, // nonCoherentAtomSize
463 };
Jesse Hall04f4f472015-08-16 19:51:04 -0700464}
465
Jesse Hall606a54e2015-11-19 22:17:28 -0800466void GetPhysicalDeviceQueueFamilyProperties(
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700467 VkPhysicalDevice,
468 uint32_t* count,
469 VkQueueFamilyProperties* properties) {
Jesse Hall715b86a2016-01-16 16:34:29 -0800470 if (!properties || *count > 1)
471 *count = 1;
472 if (properties && *count == 1) {
Jesse Hall65ab5522015-11-30 00:07:16 -0800473 properties->queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT |
474 VK_QUEUE_TRANSFER_BIT;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700475 properties->queueCount = 1;
Jesse Hallacfa5342015-11-19 21:51:33 -0800476 properties->timestampValidBits = 64;
Jesse Hall715b86a2016-01-16 16:34:29 -0800477 properties->minImageTransferGranularity = VkExtent3D{1, 1, 1};
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700478 }
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700479}
480
Jesse Hall606a54e2015-11-19 22:17:28 -0800481void GetPhysicalDeviceMemoryProperties(
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100482 VkPhysicalDevice,
483 VkPhysicalDeviceMemoryProperties* properties) {
484 properties->memoryTypeCount = 1;
485 properties->memoryTypes[0].propertyFlags =
Jesse Halld1af8122015-11-29 23:50:38 -0800486 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
487 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
488 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
489 VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100490 properties->memoryTypes[0].heapIndex = 0;
491 properties->memoryHeapCount = 1;
Jesse Hallbde8ee32015-09-01 16:24:29 -0700492 properties->memoryHeaps[0].size = kMaxDeviceMemory;
Jesse Halld1af8122015-11-29 23:50:38 -0800493 properties->memoryHeaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
Jesse Hall04f4f472015-08-16 19:51:04 -0700494}
495
Jesse Hall8e37cf32016-01-18 04:00:57 -0800496void GetPhysicalDeviceFeatures(VkPhysicalDevice /*gpu*/,
497 VkPhysicalDeviceFeatures* features) {
498 *features = VkPhysicalDeviceFeatures{
499 VK_TRUE, // robustBufferAccess
500 VK_FALSE, // fullDrawIndexUint32
501 VK_FALSE, // imageCubeArray
502 VK_FALSE, // independentBlend
503 VK_FALSE, // geometryShader
504 VK_FALSE, // tessellationShader
505 VK_FALSE, // sampleRateShading
506 VK_FALSE, // dualSrcBlend
507 VK_FALSE, // logicOp
508 VK_FALSE, // multiDrawIndirect
509 VK_FALSE, // drawIndirectFirstInstance
510 VK_FALSE, // depthClamp
511 VK_FALSE, // depthBiasClamp
512 VK_FALSE, // fillModeNonSolid
513 VK_FALSE, // depthBounds
514 VK_FALSE, // wideLines
515 VK_FALSE, // largePoints
516 VK_FALSE, // alphaToOne
517 VK_FALSE, // multiViewport
518 VK_FALSE, // samplerAnisotropy
519 VK_FALSE, // textureCompressionETC2
520 VK_FALSE, // textureCompressionASTC_LDR
521 VK_FALSE, // textureCompressionBC
522 VK_FALSE, // occlusionQueryPrecise
523 VK_FALSE, // pipelineStatisticsQuery
524 VK_FALSE, // vertexPipelineStoresAndAtomics
525 VK_FALSE, // fragmentStoresAndAtomics
526 VK_FALSE, // shaderTessellationAndGeometryPointSize
527 VK_FALSE, // shaderImageGatherExtended
528 VK_FALSE, // shaderStorageImageExtendedFormats
529 VK_FALSE, // shaderStorageImageMultisample
530 VK_FALSE, // shaderStorageImageReadWithoutFormat
531 VK_FALSE, // shaderStorageImageWriteWithoutFormat
532 VK_FALSE, // shaderUniformBufferArrayDynamicIndexing
533 VK_FALSE, // shaderSampledImageArrayDynamicIndexing
534 VK_FALSE, // shaderStorageBufferArrayDynamicIndexing
535 VK_FALSE, // shaderStorageImageArrayDynamicIndexing
536 VK_FALSE, // shaderClipDistance
537 VK_FALSE, // shaderCullDistance
538 VK_FALSE, // shaderFloat64
539 VK_FALSE, // shaderInt64
540 VK_FALSE, // shaderInt16
541 VK_FALSE, // shaderResourceResidency
542 VK_FALSE, // shaderResourceMinLod
543 VK_FALSE, // sparseBinding
544 VK_FALSE, // sparseResidencyBuffer
545 VK_FALSE, // sparseResidencyImage2D
546 VK_FALSE, // sparseResidencyImage3D
547 VK_FALSE, // sparseResidency2Samples
548 VK_FALSE, // sparseResidency4Samples
549 VK_FALSE, // sparseResidency8Samples
550 VK_FALSE, // sparseResidency16Samples
551 VK_FALSE, // sparseResidencyAliased
552 VK_FALSE, // variableMultisampleRate
553 VK_FALSE, // inheritedQueries
554 };
555}
556
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100557// -----------------------------------------------------------------------------
558// Device
559
Jesse Hall04f4f472015-08-16 19:51:04 -0700560VkResult CreateDevice(VkPhysicalDevice physical_device,
Jesse Hallb1471272016-01-17 21:36:58 -0800561 const VkDeviceCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800562 const VkAllocationCallbacks* allocator,
Jesse Hall04f4f472015-08-16 19:51:04 -0700563 VkDevice* out_device) {
564 VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800565 if (!allocator)
566 allocator = &instance->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800567 VkDevice_T* device = static_cast<VkDevice_T*>(allocator->pfnAllocation(
568 allocator->pUserData, sizeof(VkDevice_T), alignof(VkDevice_T),
569 VK_SYSTEM_ALLOCATION_SCOPE_DEVICE));
Jesse Hall04f4f472015-08-16 19:51:04 -0700570 if (!device)
571 return VK_ERROR_OUT_OF_HOST_MEMORY;
572
573 device->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800574 device->allocator = *allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -0700575 device->instance = instance;
576 device->queue.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700577 std::fill(device->next_handle.begin(), device->next_handle.end(),
578 UINT64_C(0));
Jesse Hall04f4f472015-08-16 19:51:04 -0700579
Jesse Hallb1471272016-01-17 21:36:58 -0800580 for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
581 if (strcmp(create_info->ppEnabledExtensionNames[i],
582 VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME) == 0) {
583 ALOGV("Enabling " VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME);
584 }
585 }
586
Jesse Hall04f4f472015-08-16 19:51:04 -0700587 *out_device = device;
588 return VK_SUCCESS;
589}
590
Jesse Hall3fbc8562015-11-29 22:10:52 -0800591void DestroyDevice(VkDevice device,
592 const VkAllocationCallbacks* /*allocator*/) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700593 if (!device)
Jesse Hallcf25c412015-10-29 17:14:50 -0700594 return;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800595 device->allocator.pfnFree(device->allocator.pUserData, device);
Jesse Hall04f4f472015-08-16 19:51:04 -0700596}
597
Jesse Hall606a54e2015-11-19 22:17:28 -0800598void GetDeviceQueue(VkDevice device, uint32_t, uint32_t, VkQueue* queue) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700599 *queue = &device->queue;
Jesse Hall04f4f472015-08-16 19:51:04 -0700600}
601
602// -----------------------------------------------------------------------------
Jesse Hall3fbc8562015-11-29 22:10:52 -0800603// CommandPool
Jesse Hall03b6fe12015-11-24 12:44:21 -0800604
Jesse Hall3fbc8562015-11-29 22:10:52 -0800605struct CommandPool {
606 typedef VkCommandPool HandleType;
607 VkAllocationCallbacks allocator;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800608};
Jesse Hall3fbc8562015-11-29 22:10:52 -0800609DEFINE_OBJECT_HANDLE_CONVERSION(CommandPool)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800610
611VkResult CreateCommandPool(VkDevice device,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800612 const VkCommandPoolCreateInfo* /*create_info*/,
613 const VkAllocationCallbacks* allocator,
614 VkCommandPool* cmd_pool) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800615 if (!allocator)
616 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800617 CommandPool* pool = static_cast<CommandPool*>(allocator->pfnAllocation(
618 allocator->pUserData, sizeof(CommandPool), alignof(CommandPool),
619 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall03b6fe12015-11-24 12:44:21 -0800620 if (!pool)
621 return VK_ERROR_OUT_OF_HOST_MEMORY;
622 pool->allocator = *allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800623 *cmd_pool = GetHandleToCommandPool(pool);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800624 return VK_SUCCESS;
625}
626
627void DestroyCommandPool(VkDevice /*device*/,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800628 VkCommandPool cmd_pool,
629 const VkAllocationCallbacks* /*allocator*/) {
630 CommandPool* pool = GetCommandPoolFromHandle(cmd_pool);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800631 pool->allocator.pfnFree(pool->allocator.pUserData, pool);
632}
633
634// -----------------------------------------------------------------------------
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700635// CmdBuffer
636
Jesse Hall3fbc8562015-11-29 22:10:52 -0800637VkResult AllocateCommandBuffers(VkDevice /*device*/,
638 const VkCommandBufferAllocateInfo* alloc_info,
639 VkCommandBuffer* cmdbufs) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800640 VkResult result = VK_SUCCESS;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800641 CommandPool& pool = *GetCommandPoolFromHandle(alloc_info->commandPool);
Jesse Hall3dd678a2016-01-08 21:52:01 -0800642 std::fill(cmdbufs, cmdbufs + alloc_info->commandBufferCount, nullptr);
643 for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) {
Jesse Hall3fbc8562015-11-29 22:10:52 -0800644 cmdbufs[i] =
645 static_cast<VkCommandBuffer_T*>(pool.allocator.pfnAllocation(
646 pool.allocator.pUserData, sizeof(VkCommandBuffer_T),
647 alignof(VkCommandBuffer_T), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hallfbf97b02015-11-20 14:17:03 -0800648 if (!cmdbufs[i]) {
649 result = VK_ERROR_OUT_OF_HOST_MEMORY;
650 break;
651 }
652 cmdbufs[i]->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
653 }
654 if (result != VK_SUCCESS) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800655 for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800656 if (!cmdbufs[i])
657 break;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800658 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800659 }
660 }
Jesse Hallfbf97b02015-11-20 14:17:03 -0800661 return result;
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700662}
663
Jesse Hall03b6fe12015-11-24 12:44:21 -0800664void FreeCommandBuffers(VkDevice /*device*/,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800665 VkCommandPool cmd_pool,
Jesse Hallfbf97b02015-11-20 14:17:03 -0800666 uint32_t count,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800667 const VkCommandBuffer* cmdbufs) {
668 CommandPool& pool = *GetCommandPoolFromHandle(cmd_pool);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800669 for (uint32_t i = 0; i < count; i++)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800670 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700671}
672
673// -----------------------------------------------------------------------------
Jesse Hall2077ce02015-08-29 18:10:59 +0100674// DeviceMemory
675
676struct DeviceMemory {
677 typedef VkDeviceMemory HandleType;
678 VkDeviceSize size;
679 alignas(16) uint8_t data[0];
680};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800681DEFINE_OBJECT_HANDLE_CONVERSION(DeviceMemory)
Jesse Hall2077ce02015-08-29 18:10:59 +0100682
Jesse Hall3fbc8562015-11-29 22:10:52 -0800683VkResult AllocateMemory(VkDevice device,
684 const VkMemoryAllocateInfo* alloc_info,
685 const VkAllocationCallbacks* allocator,
686 VkDeviceMemory* mem_handle) {
Jesse Hall2077ce02015-08-29 18:10:59 +0100687 if (SIZE_MAX - sizeof(DeviceMemory) <= alloc_info->allocationSize)
688 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800689 if (!allocator)
690 allocator = &device->allocator;
Jesse Hall2077ce02015-08-29 18:10:59 +0100691
Jesse Hall2077ce02015-08-29 18:10:59 +0100692 size_t size = sizeof(DeviceMemory) + size_t(alloc_info->allocationSize);
Jesse Hall3fbc8562015-11-29 22:10:52 -0800693 DeviceMemory* mem = static_cast<DeviceMemory*>(allocator->pfnAllocation(
694 allocator->pUserData, size, alignof(DeviceMemory),
695 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall2077ce02015-08-29 18:10:59 +0100696 if (!mem)
697 return VK_ERROR_OUT_OF_HOST_MEMORY;
698 mem->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800699 *mem_handle = GetHandleToDeviceMemory(mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100700 return VK_SUCCESS;
701}
702
Jesse Hall03b6fe12015-11-24 12:44:21 -0800703void FreeMemory(VkDevice device,
704 VkDeviceMemory mem_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800705 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800706 if (!allocator)
707 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800708 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800709 allocator->pfnFree(allocator->pUserData, mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100710}
711
712VkResult MapMemory(VkDevice,
713 VkDeviceMemory mem_handle,
714 VkDeviceSize offset,
715 VkDeviceSize,
716 VkMemoryMapFlags,
717 void** out_ptr) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800718 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall2077ce02015-08-29 18:10:59 +0100719 *out_ptr = &mem->data[0] + offset;
720 return VK_SUCCESS;
721}
722
723// -----------------------------------------------------------------------------
Jesse Hallf6578742015-08-29 17:06:12 +0100724// Buffer
725
726struct Buffer {
727 typedef VkBuffer HandleType;
728 VkDeviceSize size;
729};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800730DEFINE_OBJECT_HANDLE_CONVERSION(Buffer)
Jesse Hallf6578742015-08-29 17:06:12 +0100731
732VkResult CreateBuffer(VkDevice device,
733 const VkBufferCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800734 const VkAllocationCallbacks* allocator,
Jesse Hallf6578742015-08-29 17:06:12 +0100735 VkBuffer* buffer_handle) {
Jesse Hallbde8ee32015-09-01 16:24:29 -0700736 ALOGW_IF(create_info->size > kMaxDeviceMemory,
737 "CreateBuffer: requested size 0x%" PRIx64
738 " exceeds max device memory size 0x%" PRIx64,
739 create_info->size, kMaxDeviceMemory);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800740 if (!allocator)
741 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800742 Buffer* buffer = static_cast<Buffer*>(allocator->pfnAllocation(
743 allocator->pUserData, sizeof(Buffer), alignof(Buffer),
744 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hallf6578742015-08-29 17:06:12 +0100745 if (!buffer)
746 return VK_ERROR_OUT_OF_HOST_MEMORY;
747 buffer->size = create_info->size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800748 *buffer_handle = GetHandleToBuffer(buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100749 return VK_SUCCESS;
750}
751
Jesse Hall606a54e2015-11-19 22:17:28 -0800752void GetBufferMemoryRequirements(VkDevice,
753 VkBuffer buffer_handle,
754 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800755 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hallf6578742015-08-29 17:06:12 +0100756 requirements->size = buffer->size;
757 requirements->alignment = 16; // allow fast Neon/SSE memcpy
758 requirements->memoryTypeBits = 0x1;
Jesse Hallf6578742015-08-29 17:06:12 +0100759}
760
Jesse Hall03b6fe12015-11-24 12:44:21 -0800761void DestroyBuffer(VkDevice device,
762 VkBuffer buffer_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800763 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800764 if (!allocator)
765 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800766 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800767 allocator->pfnFree(allocator->pUserData, buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100768}
769
770// -----------------------------------------------------------------------------
Jesse Hall85c05b62015-09-01 18:07:41 -0700771// Image
772
773struct Image {
774 typedef VkImage HandleType;
775 VkDeviceSize size;
776};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800777DEFINE_OBJECT_HANDLE_CONVERSION(Image)
Jesse Hall85c05b62015-09-01 18:07:41 -0700778
779VkResult CreateImage(VkDevice device,
780 const VkImageCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800781 const VkAllocationCallbacks* allocator,
Jesse Hall85c05b62015-09-01 18:07:41 -0700782 VkImage* image_handle) {
783 if (create_info->imageType != VK_IMAGE_TYPE_2D ||
784 create_info->format != VK_FORMAT_R8G8B8A8_UNORM ||
785 create_info->mipLevels != 1) {
786 ALOGE("CreateImage: not yet implemented: type=%d format=%d mips=%u",
787 create_info->imageType, create_info->format,
788 create_info->mipLevels);
Jesse Halla15a4bf2015-11-19 22:48:02 -0800789 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall85c05b62015-09-01 18:07:41 -0700790 }
791
792 VkDeviceSize size =
793 VkDeviceSize(create_info->extent.width * create_info->extent.height) *
Jesse Halla15a4bf2015-11-19 22:48:02 -0800794 create_info->arrayLayers * create_info->samples * 4u;
Jesse Hall85c05b62015-09-01 18:07:41 -0700795 ALOGW_IF(size > kMaxDeviceMemory,
796 "CreateImage: image size 0x%" PRIx64
797 " exceeds max device memory size 0x%" PRIx64,
798 size, kMaxDeviceMemory);
799
Jesse Hall03b6fe12015-11-24 12:44:21 -0800800 if (!allocator)
801 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800802 Image* image = static_cast<Image*>(allocator->pfnAllocation(
803 allocator->pUserData, sizeof(Image), alignof(Image),
804 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall85c05b62015-09-01 18:07:41 -0700805 if (!image)
806 return VK_ERROR_OUT_OF_HOST_MEMORY;
807 image->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800808 *image_handle = GetHandleToImage(image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700809 return VK_SUCCESS;
810}
811
Jesse Hall606a54e2015-11-19 22:17:28 -0800812void GetImageMemoryRequirements(VkDevice,
813 VkImage image_handle,
814 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800815 Image* image = GetImageFromHandle(image_handle);
Jesse Hall85c05b62015-09-01 18:07:41 -0700816 requirements->size = image->size;
817 requirements->alignment = 16; // allow fast Neon/SSE memcpy
818 requirements->memoryTypeBits = 0x1;
Jesse Hall85c05b62015-09-01 18:07:41 -0700819}
820
Jesse Hall03b6fe12015-11-24 12:44:21 -0800821void DestroyImage(VkDevice device,
822 VkImage image_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800823 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800824 if (!allocator)
825 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800826 Image* image = GetImageFromHandle(image_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800827 allocator->pfnFree(allocator->pUserData, image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700828}
829
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800830VkResult GetSwapchainGrallocUsageANDROID(VkDevice,
831 VkFormat,
832 VkImageUsageFlags,
833 int* grallocUsage) {
834 // The null driver never reads or writes the gralloc buffer
835 *grallocUsage = 0;
836 return VK_SUCCESS;
837}
838
839VkResult AcquireImageANDROID(VkDevice,
840 VkImage,
841 int fence,
842 VkSemaphore,
843 VkFence) {
844 close(fence);
845 return VK_SUCCESS;
846}
847
848VkResult QueueSignalReleaseImageANDROID(VkQueue,
849 uint32_t,
850 const VkSemaphore*,
851 VkImage,
852 int* fence) {
853 *fence = -1;
854 return VK_SUCCESS;
855}
856
Jesse Hall85c05b62015-09-01 18:07:41 -0700857// -----------------------------------------------------------------------------
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700858// No-op types
859
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700860VkResult CreateBufferView(VkDevice device,
861 const VkBufferViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800862 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700863 VkBufferView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800864 *view = AllocHandle<VkBufferView>(device, HandleType::kBufferView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700865 return VK_SUCCESS;
866}
867
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700868VkResult CreateDescriptorPool(VkDevice device,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700869 const VkDescriptorPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800870 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700871 VkDescriptorPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800872 *pool = AllocHandle<VkDescriptorPool>(device, HandleType::kDescriptorPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700873 return VK_SUCCESS;
874}
875
Jesse Hall3fbc8562015-11-29 22:10:52 -0800876VkResult AllocateDescriptorSets(VkDevice device,
877 const VkDescriptorSetAllocateInfo* alloc_info,
878 VkDescriptorSet* descriptor_sets) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800879 for (uint32_t i = 0; i < alloc_info->descriptorSetCount; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800880 descriptor_sets[i] =
881 AllocHandle<VkDescriptorSet>(device, HandleType::kDescriptorSet);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700882 return VK_SUCCESS;
883}
884
885VkResult CreateDescriptorSetLayout(VkDevice device,
886 const VkDescriptorSetLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800887 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700888 VkDescriptorSetLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800889 *layout = AllocHandle<VkDescriptorSetLayout>(
890 device, HandleType::kDescriptorSetLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700891 return VK_SUCCESS;
892}
893
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700894VkResult CreateEvent(VkDevice device,
895 const VkEventCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800896 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700897 VkEvent* event) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800898 *event = AllocHandle<VkEvent>(device, HandleType::kEvent);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700899 return VK_SUCCESS;
900}
901
902VkResult CreateFence(VkDevice device,
903 const VkFenceCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800904 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700905 VkFence* fence) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800906 *fence = AllocHandle<VkFence>(device, HandleType::kFence);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700907 return VK_SUCCESS;
908}
909
910VkResult CreateFramebuffer(VkDevice device,
911 const VkFramebufferCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800912 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700913 VkFramebuffer* framebuffer) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800914 *framebuffer = AllocHandle<VkFramebuffer>(device, HandleType::kFramebuffer);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700915 return VK_SUCCESS;
916}
917
918VkResult CreateImageView(VkDevice device,
919 const VkImageViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800920 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700921 VkImageView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800922 *view = AllocHandle<VkImageView>(device, HandleType::kImageView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700923 return VK_SUCCESS;
924}
925
926VkResult CreateGraphicsPipelines(VkDevice device,
927 VkPipelineCache,
928 uint32_t count,
929 const VkGraphicsPipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800930 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700931 VkPipeline* pipelines) {
932 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800933 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700934 return VK_SUCCESS;
935}
936
937VkResult CreateComputePipelines(VkDevice device,
938 VkPipelineCache,
939 uint32_t count,
940 const VkComputePipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800941 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700942 VkPipeline* pipelines) {
943 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800944 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700945 return VK_SUCCESS;
946}
947
948VkResult CreatePipelineCache(VkDevice device,
949 const VkPipelineCacheCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800950 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700951 VkPipelineCache* cache) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800952 *cache = AllocHandle<VkPipelineCache>(device, HandleType::kPipelineCache);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700953 return VK_SUCCESS;
954}
955
956VkResult CreatePipelineLayout(VkDevice device,
957 const VkPipelineLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800958 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700959 VkPipelineLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800960 *layout =
961 AllocHandle<VkPipelineLayout>(device, HandleType::kPipelineLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700962 return VK_SUCCESS;
963}
964
965VkResult CreateQueryPool(VkDevice device,
966 const VkQueryPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800967 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700968 VkQueryPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800969 *pool = AllocHandle<VkQueryPool>(device, HandleType::kQueryPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700970 return VK_SUCCESS;
971}
972
973VkResult CreateRenderPass(VkDevice device,
974 const VkRenderPassCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800975 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700976 VkRenderPass* renderpass) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800977 *renderpass = AllocHandle<VkRenderPass>(device, HandleType::kRenderPass);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700978 return VK_SUCCESS;
979}
980
981VkResult CreateSampler(VkDevice device,
982 const VkSamplerCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800983 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700984 VkSampler* sampler) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800985 *sampler = AllocHandle<VkSampler>(device, HandleType::kSampler);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700986 return VK_SUCCESS;
987}
988
989VkResult CreateSemaphore(VkDevice device,
990 const VkSemaphoreCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800991 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700992 VkSemaphore* semaphore) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800993 *semaphore = AllocHandle<VkSemaphore>(device, HandleType::kSemaphore);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700994 return VK_SUCCESS;
995}
996
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700997VkResult CreateShaderModule(VkDevice device,
998 const VkShaderModuleCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800999 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001000 VkShaderModule* module) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001001 *module = AllocHandle<VkShaderModule>(device, HandleType::kShaderModule);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001002 return VK_SUCCESS;
1003}
1004
Jesse Hall715b86a2016-01-16 16:34:29 -08001005VkResult CreateDebugReportCallbackEXT(VkInstance instance,
1006 const VkDebugReportCallbackCreateInfoEXT*,
1007 const VkAllocationCallbacks*,
1008 VkDebugReportCallbackEXT* callback) {
1009 *callback = AllocHandle<VkDebugReportCallbackEXT>(
1010 instance, HandleType::kDebugReportCallbackEXT);
1011 return VK_SUCCESS;
1012}
1013
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001014// -----------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -07001015// No-op entrypoints
1016
1017// clang-format off
1018#pragma clang diagnostic push
1019#pragma clang diagnostic ignored "-Wunused-parameter"
1020
Jesse Hall606a54e2015-11-19 22:17:28 -08001021void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001022 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001023}
1024
Jesse Halla9e57032015-11-30 01:03:10 -08001025VkResult GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001026 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Halla9e57032015-11-30 01:03:10 -08001027 return VK_SUCCESS;
Jesse Hall04f4f472015-08-16 19:51:04 -07001028}
1029
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001030VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001031 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001032 return VK_SUCCESS;
1033}
1034
Jesse Halla366a512015-11-19 22:30:07 -08001035VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001036 return VK_SUCCESS;
1037}
1038
1039VkResult QueueWaitIdle(VkQueue queue) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001040 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001041 return VK_SUCCESS;
1042}
1043
1044VkResult DeviceWaitIdle(VkDevice device) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001045 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001046 return VK_SUCCESS;
1047}
1048
Jesse Hallcf25c412015-10-29 17:14:50 -07001049void UnmapMemory(VkDevice device, VkDeviceMemory mem) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001050}
1051
1052VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001053 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001054 return VK_SUCCESS;
1055}
1056
1057VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001058 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001059 return VK_SUCCESS;
1060}
1061
Jesse Hall606a54e2015-11-19 22:17:28 -08001062void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001063 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001064}
1065
Jesse Hall04f4f472015-08-16 19:51:04 -07001066VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) {
1067 return VK_SUCCESS;
1068}
1069
Jesse Hall04f4f472015-08-16 19:51:04 -07001070VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) {
1071 return VK_SUCCESS;
1072}
1073
Jesse Hall606a54e2015-11-19 22:17:28 -08001074void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001075 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001076}
1077
Jesse Hall091ed9e2015-11-30 00:55:29 -08001078void 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 +01001079 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001080}
1081
Jesse Halla6429252015-11-29 18:59:42 -08001082VkResult QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001083 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001084 return VK_SUCCESS;
1085}
1086
Jesse Hall3fbc8562015-11-29 22:10:52 -08001087void DestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001088}
1089
1090VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) {
1091 return VK_SUCCESS;
1092}
1093
1094VkResult GetFenceStatus(VkDevice device, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001095 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001096 return VK_SUCCESS;
1097}
1098
1099VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) {
1100 return VK_SUCCESS;
1101}
1102
Jesse Hall3fbc8562015-11-29 22:10:52 -08001103void DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001104}
1105
Jesse Hall3fbc8562015-11-29 22:10:52 -08001106void DestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001107}
1108
1109VkResult GetEventStatus(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001110 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001111 return VK_SUCCESS;
1112}
1113
1114VkResult SetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001115 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001116 return VK_SUCCESS;
1117}
1118
1119VkResult ResetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001120 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001121 return VK_SUCCESS;
1122}
1123
Jesse Hall3fbc8562015-11-29 22:10:52 -08001124void DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001125}
1126
Jesse Halla9bb62b2015-11-21 19:31:56 -08001127VkResult 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 +01001128 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001129 return VK_SUCCESS;
1130}
1131
Jesse Hall3fbc8562015-11-29 22:10:52 -08001132void DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001133}
1134
Jesse Hall606a54e2015-11-19 22:17:28 -08001135void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001136 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001137}
1138
Jesse Hall3fbc8562015-11-29 22:10:52 -08001139void DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001140}
1141
Jesse Hall3fbc8562015-11-29 22:10:52 -08001142void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001143}
1144
Jesse Hall3fbc8562015-11-29 22:10:52 -08001145void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001146}
1147
Jesse Halla9bb62b2015-11-21 19:31:56 -08001148VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001149 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001150 return VK_SUCCESS;
1151}
1152
1153VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001154 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001155 return VK_SUCCESS;
1156}
1157
Jesse Hall3fbc8562015-11-29 22:10:52 -08001158void DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001159}
1160
Jesse Hall3fbc8562015-11-29 22:10:52 -08001161void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001162}
1163
Jesse Hall3fbc8562015-11-29 22:10:52 -08001164void DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001165}
1166
Jesse Hall3fbc8562015-11-29 22:10:52 -08001167void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001168}
1169
Jesse Hall3fbc8562015-11-29 22:10:52 -08001170void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001171}
1172
Jesse Hallfbf97b02015-11-20 14:17:03 -08001173VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001174 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001175 return VK_SUCCESS;
1176}
1177
Jesse Hallcf25c412015-10-29 17:14:50 -07001178void UpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001179 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001180}
1181
1182VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001183 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001184 return VK_SUCCESS;
1185}
1186
Jesse Hall3fbc8562015-11-29 22:10:52 -08001187void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001188}
1189
Jesse Hall3fbc8562015-11-29 22:10:52 -08001190void DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001191}
1192
Jesse Hall606a54e2015-11-19 22:17:28 -08001193void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001194 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001195}
1196
Jesse Hall3fbc8562015-11-29 22:10:52 -08001197VkResult ResetCommandPool(VkDevice device, VkCommandPool cmdPool, VkCommandPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001198 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001199 return VK_SUCCESS;
1200}
1201
Jesse Hall3fbc8562015-11-29 22:10:52 -08001202VkResult BeginCommandBuffer(VkCommandBuffer cmdBuffer, const VkCommandBufferBeginInfo* pBeginInfo) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001203 return VK_SUCCESS;
1204}
1205
Jesse Hall3fbc8562015-11-29 22:10:52 -08001206VkResult EndCommandBuffer(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001207 return VK_SUCCESS;
1208}
1209
Jesse Hall3fbc8562015-11-29 22:10:52 -08001210VkResult ResetCommandBuffer(VkCommandBuffer cmdBuffer, VkCommandBufferResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001211 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001212 return VK_SUCCESS;
1213}
1214
Jesse Hall3fbc8562015-11-29 22:10:52 -08001215void CmdBindPipeline(VkCommandBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001216}
1217
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001218void CmdSetViewport(VkCommandBuffer cmdBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001219}
1220
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001221void CmdSetScissor(VkCommandBuffer cmdBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001222}
1223
Jesse Hall3fbc8562015-11-29 22:10:52 -08001224void CmdSetLineWidth(VkCommandBuffer cmdBuffer, float lineWidth) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001225}
1226
Jesse Hall3fbc8562015-11-29 22:10:52 -08001227void CmdSetDepthBias(VkCommandBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001228}
1229
Jesse Hall3fbc8562015-11-29 22:10:52 -08001230void CmdSetBlendConstants(VkCommandBuffer cmdBuffer, const float blendConst[4]) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001231}
1232
Jesse Hall3fbc8562015-11-29 22:10:52 -08001233void CmdSetDepthBounds(VkCommandBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001234}
1235
Jesse Hall3fbc8562015-11-29 22:10:52 -08001236void CmdSetStencilCompareMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001237}
1238
Jesse Hall3fbc8562015-11-29 22:10:52 -08001239void CmdSetStencilWriteMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001240}
1241
Jesse Hall3fbc8562015-11-29 22:10:52 -08001242void CmdSetStencilReference(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001243}
1244
Jesse Hall3fbc8562015-11-29 22:10:52 -08001245void 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 -07001246}
1247
Jesse Hall3fbc8562015-11-29 22:10:52 -08001248void CmdBindIndexBuffer(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001249}
1250
Jesse Hall3fbc8562015-11-29 22:10:52 -08001251void CmdBindVertexBuffers(VkCommandBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001252}
1253
Jesse Hall3fbc8562015-11-29 22:10:52 -08001254void CmdDraw(VkCommandBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001255}
1256
Jesse Hall3fbc8562015-11-29 22:10:52 -08001257void 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 -07001258}
1259
Jesse Hall3fbc8562015-11-29 22:10:52 -08001260void CmdDrawIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001261}
1262
Jesse Hall3fbc8562015-11-29 22:10:52 -08001263void CmdDrawIndexedIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001264}
1265
Jesse Hall3fbc8562015-11-29 22:10:52 -08001266void CmdDispatch(VkCommandBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001267}
1268
Jesse Hall3fbc8562015-11-29 22:10:52 -08001269void CmdDispatchIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001270}
1271
Jesse Hall3fbc8562015-11-29 22:10:52 -08001272void CmdCopyBuffer(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001273}
1274
Jesse Hall3fbc8562015-11-29 22:10:52 -08001275void CmdCopyImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001276}
1277
Jesse Hall3fbc8562015-11-29 22:10:52 -08001278void 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 -07001279}
1280
Jesse Hall3fbc8562015-11-29 22:10:52 -08001281void CmdCopyBufferToImage(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001282}
1283
Jesse Hall3fbc8562015-11-29 22:10:52 -08001284void CmdCopyImageToBuffer(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001285}
1286
Jesse Hall3fbc8562015-11-29 22:10:52 -08001287void CmdUpdateBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001288}
1289
Jesse Hall3fbc8562015-11-29 22:10:52 -08001290void CmdFillBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001291}
1292
Jesse Hall3fbc8562015-11-29 22:10:52 -08001293void CmdClearColorImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001294}
1295
Jesse Hall3fbc8562015-11-29 22:10:52 -08001296void CmdClearDepthStencilImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001297}
1298
Jesse Hall3fbc8562015-11-29 22:10:52 -08001299void CmdClearAttachments(VkCommandBuffer cmdBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001300}
1301
Jesse Hall3fbc8562015-11-29 22:10:52 -08001302void CmdResolveImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001303}
1304
Jesse Hall3fbc8562015-11-29 22:10:52 -08001305void CmdSetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001306}
1307
Jesse Hall3fbc8562015-11-29 22:10:52 -08001308void CmdResetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001309}
1310
Jesse Hall3dd678a2016-01-08 21:52:01 -08001311void 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 -07001312}
1313
Jesse Hall3dd678a2016-01-08 21:52:01 -08001314void 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 -07001315}
1316
Jesse Hall3fbc8562015-11-29 22:10:52 -08001317void CmdBeginQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001318}
1319
Jesse Hall3fbc8562015-11-29 22:10:52 -08001320void CmdEndQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001321}
1322
Jesse Hall3fbc8562015-11-29 22:10:52 -08001323void CmdResetQueryPool(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001324}
1325
Jesse Hall3fbc8562015-11-29 22:10:52 -08001326void CmdWriteTimestamp(VkCommandBuffer cmdBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001327}
1328
Jesse Hall3fbc8562015-11-29 22:10:52 -08001329void 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 -07001330}
1331
Jesse Hall3fbc8562015-11-29 22:10:52 -08001332void CmdPushConstants(VkCommandBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001333}
1334
Jesse Hall65ab5522015-11-30 00:07:16 -08001335void CmdBeginRenderPass(VkCommandBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001336}
1337
Jesse Hall65ab5522015-11-30 00:07:16 -08001338void CmdNextSubpass(VkCommandBuffer cmdBuffer, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001339}
1340
Jesse Hall3fbc8562015-11-29 22:10:52 -08001341void CmdEndRenderPass(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001342}
1343
Jesse Hall3fbc8562015-11-29 22:10:52 -08001344void CmdExecuteCommands(VkCommandBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCommandBuffer* pCmdBuffers) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001345}
1346
Jesse Hall715b86a2016-01-16 16:34:29 -08001347void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) {
1348}
1349
1350void DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage) {
1351}
1352
Jesse Hall04f4f472015-08-16 19:51:04 -07001353#pragma clang diagnostic pop
1354// clang-format on
1355
1356} // namespace null_driver