blob: c403ededf981e1288c93e0b9b64430d042bb9ced [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>
Jesse Halld3b14502016-04-20 16:58:11 -070022#include <stdlib.h>
Jesse Hall715b86a2016-01-16 16:34:29 -080023#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 Halld3b14502016-04-20 16:58:11 -0700190VKAPI_ATTR void* DefaultAllocate(void*,
191 size_t size,
192 size_t alignment,
193 VkSystemAllocationScope) {
194 void* ptr = nullptr;
195 // Vulkan requires 'alignment' to be a power of two, but posix_memalign
196 // additionally requires that it be at least sizeof(void*).
197 int ret = posix_memalign(&ptr, std::max(alignment, sizeof(void*)), size);
198 return ret == 0 ? ptr : nullptr;
199}
200
201VKAPI_ATTR void* DefaultReallocate(void*,
202 void* ptr,
203 size_t size,
204 size_t alignment,
205 VkSystemAllocationScope) {
206 if (size == 0) {
207 free(ptr);
208 return nullptr;
209 }
210
211 // TODO(jessehall): Right now we never shrink allocations; if the new
212 // request is smaller than the existing chunk, we just continue using it.
213 // The null driver never reallocs, so this doesn't matter. If that changes,
214 // or if this code is copied into some other project, this should probably
215 // have a heuristic to allocate-copy-free when doing so will save "enough"
216 // space.
217 size_t old_size = ptr ? malloc_usable_size(ptr) : 0;
218 if (size <= old_size)
219 return ptr;
220
221 void* new_ptr = nullptr;
222 if (posix_memalign(&new_ptr, std::max(alignment, sizeof(void*)), size) != 0)
223 return nullptr;
224 if (ptr) {
225 memcpy(new_ptr, ptr, std::min(old_size, size));
226 free(ptr);
227 }
228 return new_ptr;
229}
230
231VKAPI_ATTR void DefaultFree(void*, void* ptr) {
232 free(ptr);
233}
234
235const VkAllocationCallbacks kDefaultAllocCallbacks = {
236 .pUserData = nullptr,
237 .pfnAllocation = DefaultAllocate,
238 .pfnReallocation = DefaultReallocate,
239 .pfnFree = DefaultFree,
240};
241
Jesse Hall04f4f472015-08-16 19:51:04 -0700242} // namespace
243
244namespace null_driver {
245
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800246#define DEFINE_OBJECT_HANDLE_CONVERSION(T) \
247 T* Get##T##FromHandle(Vk##T h); \
248 T* Get##T##FromHandle(Vk##T h) { \
249 return reinterpret_cast<T*>(uintptr_t(h)); \
250 } \
251 Vk##T GetHandleTo##T(const T* obj); \
252 Vk##T GetHandleTo##T(const T* obj) { \
253 return Vk##T(reinterpret_cast<uintptr_t>(obj)); \
254 }
Jesse Hallf6578742015-08-29 17:06:12 +0100255
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100256// -----------------------------------------------------------------------------
257// Global
258
Jesse Halle1b12782015-11-30 11:27:32 -0800259VKAPI_ATTR
Jesse Hall715b86a2016-01-16 16:34:29 -0800260VkResult EnumerateInstanceExtensionProperties(
261 const char* layer_name,
262 uint32_t* count,
263 VkExtensionProperties* properties) {
264 if (layer_name) {
265 ALOGW(
266 "Driver vkEnumerateInstanceExtensionProperties shouldn't be called "
267 "with a layer name ('%s')",
268 layer_name);
Jesse Hall715b86a2016-01-16 16:34:29 -0800269 }
270
Jesse Hall4b62e4f2016-01-21 09:49:49 -0800271// NOTE: Change this to zero to report and extension, which can be useful
272// for testing changes to the loader.
273#if 1
274 (void)properties; // unused
275 *count = 0;
276 return VK_SUCCESS;
277#else
Jesse Hall715b86a2016-01-16 16:34:29 -0800278 const VkExtensionProperties kExtensions[] = {
279 {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}};
280 const uint32_t kExtensionsCount =
281 sizeof(kExtensions) / sizeof(kExtensions[0]);
282
283 if (!properties || *count > kExtensionsCount)
284 *count = kExtensionsCount;
285 if (properties)
286 std::copy(kExtensions, kExtensions + *count, properties);
287 return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS;
Jesse Hall4b62e4f2016-01-21 09:49:49 -0800288#endif
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100289}
290
Jesse Halle1b12782015-11-30 11:27:32 -0800291VKAPI_ATTR
Jesse Hall715b86a2016-01-16 16:34:29 -0800292VkResult CreateInstance(const VkInstanceCreateInfo* create_info,
Jesse Hall1f91d392015-12-11 16:28:44 -0800293 const VkAllocationCallbacks* allocator,
294 VkInstance* out_instance) {
Jesse Halld3b14502016-04-20 16:58:11 -0700295 if (!allocator)
296 allocator = &kDefaultAllocCallbacks;
Jesse Hall1f91d392015-12-11 16:28:44 -0800297
298 VkInstance_T* instance =
299 static_cast<VkInstance_T*>(allocator->pfnAllocation(
300 allocator->pUserData, sizeof(VkInstance_T), alignof(VkInstance_T),
301 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE));
302 if (!instance)
303 return VK_ERROR_OUT_OF_HOST_MEMORY;
304
305 instance->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
306 instance->allocator = *allocator;
307 instance->physical_device.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall715b86a2016-01-16 16:34:29 -0800308 instance->next_callback_handle = 0;
Jesse Hall715b86a2016-01-16 16:34:29 -0800309
310 for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
311 if (strcmp(create_info->ppEnabledExtensionNames[i],
312 VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) {
Jesse Hallb1471272016-01-17 21:36:58 -0800313 ALOGV("instance extension '%s' requested",
314 create_info->ppEnabledExtensionNames[i]);
315 } else {
316 ALOGW("unsupported extension '%s' requested",
317 create_info->ppEnabledExtensionNames[i]);
Jesse Hall715b86a2016-01-16 16:34:29 -0800318 }
319 }
Jesse Hall1f91d392015-12-11 16:28:44 -0800320
321 *out_instance = instance;
322 return VK_SUCCESS;
323}
324
325VKAPI_ATTR
326PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name) {
327 return instance ? GetInstanceProcAddr(name) : GetGlobalProcAddr(name);
Jesse Hall04f4f472015-08-16 19:51:04 -0700328}
329
Jesse Halle1b12782015-11-30 11:27:32 -0800330VKAPI_ATTR
Jesse Hall04f4f472015-08-16 19:51:04 -0700331PFN_vkVoidFunction GetDeviceProcAddr(VkDevice, const char* name) {
Jesse Hall1f91d392015-12-11 16:28:44 -0800332 return GetInstanceProcAddr(name);
Jesse Hall04f4f472015-08-16 19:51:04 -0700333}
334
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100335// -----------------------------------------------------------------------------
336// Instance
337
Jesse Hall03b6fe12015-11-24 12:44:21 -0800338void DestroyInstance(VkInstance instance,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800339 const VkAllocationCallbacks* /*allocator*/) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800340 instance->allocator.pfnFree(instance->allocator.pUserData, instance);
Jesse Hall04f4f472015-08-16 19:51:04 -0700341}
342
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100343// -----------------------------------------------------------------------------
344// PhysicalDevice
345
Jesse Hall04f4f472015-08-16 19:51:04 -0700346VkResult EnumeratePhysicalDevices(VkInstance instance,
347 uint32_t* physical_device_count,
348 VkPhysicalDevice* physical_devices) {
349 if (physical_devices && *physical_device_count >= 1)
350 physical_devices[0] = &instance->physical_device;
351 *physical_device_count = 1;
352 return VK_SUCCESS;
353}
354
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800355VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice /*gpu*/,
356 uint32_t* count,
357 VkLayerProperties* /*properties*/) {
358 ALOGW("Driver vkEnumerateDeviceLayerProperties shouldn't be called");
359 *count = 0;
360 return VK_SUCCESS;
361}
362
363VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice /*gpu*/,
364 const char* layer_name,
365 uint32_t* count,
366 VkExtensionProperties* properties) {
367 if (layer_name) {
368 ALOGW(
369 "Driver vkEnumerateDeviceExtensionProperties shouldn't be called "
370 "with a layer name ('%s')",
371 layer_name);
372 *count = 0;
373 return VK_SUCCESS;
374 }
375
376 const VkExtensionProperties kExtensions[] = {
377 {VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME,
378 VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION}};
379 const uint32_t kExtensionsCount =
380 sizeof(kExtensions) / sizeof(kExtensions[0]);
381
382 if (!properties || *count > kExtensionsCount)
383 *count = kExtensionsCount;
384 if (properties)
385 std::copy(kExtensions, kExtensions + *count, properties);
386 return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS;
387}
388
Jesse Hall606a54e2015-11-19 22:17:28 -0800389void GetPhysicalDeviceProperties(VkPhysicalDevice,
390 VkPhysicalDeviceProperties* properties) {
Jesse Hall26763382016-05-20 07:13:52 -0700391 properties->apiVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION);
Jesse Hall04f4f472015-08-16 19:51:04 -0700392 properties->driverVersion = VK_MAKE_VERSION(0, 0, 1);
Jesse Hall65ab5522015-11-30 00:07:16 -0800393 properties->vendorID = 0;
394 properties->deviceID = 0;
Jesse Hall04f4f472015-08-16 19:51:04 -0700395 properties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER;
396 strcpy(properties->deviceName, "Android Vulkan Null Driver");
397 memset(properties->pipelineCacheUUID, 0,
398 sizeof(properties->pipelineCacheUUID));
Jesse Hallc34849e2016-02-09 22:35:04 -0800399 properties->limits = VkPhysicalDeviceLimits{
400 4096, // maxImageDimension1D
401 4096, // maxImageDimension2D
402 256, // maxImageDimension3D
403 4096, // maxImageDimensionCube
404 256, // maxImageArrayLayers
405 65536, // maxTexelBufferElements
406 16384, // maxUniformBufferRange
407 1 << 27, // maxStorageBufferRange
408 128, // maxPushConstantsSize
409 4096, // maxMemoryAllocationCount
410 4000, // maxSamplerAllocationCount
411 1, // bufferImageGranularity
412 0, // sparseAddressSpaceSize
413 4, // maxBoundDescriptorSets
414 16, // maxPerStageDescriptorSamplers
415 12, // maxPerStageDescriptorUniformBuffers
416 4, // maxPerStageDescriptorStorageBuffers
417 16, // maxPerStageDescriptorSampledImages
418 4, // maxPerStageDescriptorStorageImages
419 4, // maxPerStageDescriptorInputAttachments
420 128, // maxPerStageResources
421 96, // maxDescriptorSetSamplers
422 72, // maxDescriptorSetUniformBuffers
423 8, // maxDescriptorSetUniformBuffersDynamic
424 24, // maxDescriptorSetStorageBuffers
425 4, // maxDescriptorSetStorageBuffersDynamic
426 96, // maxDescriptorSetSampledImages
427 24, // maxDescriptorSetStorageImages
428 4, // maxDescriptorSetInputAttachments
429 16, // maxVertexInputAttributes
430 16, // maxVertexInputBindings
431 2047, // maxVertexInputAttributeOffset
432 2048, // maxVertexInputBindingStride
433 64, // maxVertexOutputComponents
434 0, // maxTessellationGenerationLevel
435 0, // maxTessellationPatchSize
436 0, // maxTessellationControlPerVertexInputComponents
437 0, // maxTessellationControlPerVertexOutputComponents
438 0, // maxTessellationControlPerPatchOutputComponents
439 0, // maxTessellationControlTotalOutputComponents
440 0, // maxTessellationEvaluationInputComponents
441 0, // maxTessellationEvaluationOutputComponents
442 0, // maxGeometryShaderInvocations
443 0, // maxGeometryInputComponents
444 0, // maxGeometryOutputComponents
445 0, // maxGeometryOutputVertices
446 0, // maxGeometryTotalOutputComponents
447 64, // maxFragmentInputComponents
448 4, // maxFragmentOutputAttachments
449 0, // maxFragmentDualSrcAttachments
450 4, // maxFragmentCombinedOutputResources
451 16384, // maxComputeSharedMemorySize
452 {65536, 65536, 65536}, // maxComputeWorkGroupCount[3]
453 128, // maxComputeWorkGroupInvocations
454 {128, 128, 64}, // maxComputeWorkGroupSize[3]
455 4, // subPixelPrecisionBits
456 4, // subTexelPrecisionBits
457 4, // mipmapPrecisionBits
458 UINT32_MAX, // maxDrawIndexedIndexValue
459 1, // maxDrawIndirectCount
460 2, // maxSamplerLodBias
461 1, // maxSamplerAnisotropy
462 1, // maxViewports
463 {4096, 4096}, // maxViewportDimensions[2]
464 {-8192.0f, 8191.0f}, // viewportBoundsRange[2]
465 0, // viewportSubPixelBits
466 64, // minMemoryMapAlignment
467 256, // minTexelBufferOffsetAlignment
468 256, // minUniformBufferOffsetAlignment
469 256, // minStorageBufferOffsetAlignment
470 -8, // minTexelOffset
471 7, // maxTexelOffset
472 0, // minTexelGatherOffset
473 0, // maxTexelGatherOffset
474 0.0f, // minInterpolationOffset
475 0.0f, // maxInterpolationOffset
476 0, // subPixelInterpolationOffsetBits
477 4096, // maxFramebufferWidth
478 4096, // maxFramebufferHeight
479 256, // maxFramebufferLayers
480 VK_SAMPLE_COUNT_1_BIT |
481 VK_SAMPLE_COUNT_4_BIT, // framebufferColorSampleCounts
482 VK_SAMPLE_COUNT_1_BIT |
483 VK_SAMPLE_COUNT_4_BIT, // framebufferDepthSampleCounts
484 VK_SAMPLE_COUNT_1_BIT |
485 VK_SAMPLE_COUNT_4_BIT, // framebufferStencilSampleCounts
486 VK_SAMPLE_COUNT_1_BIT |
487 VK_SAMPLE_COUNT_4_BIT, // framebufferNoAttachmentsSampleCounts
488 4, // maxColorAttachments
489 VK_SAMPLE_COUNT_1_BIT |
490 VK_SAMPLE_COUNT_4_BIT, // sampledImageColorSampleCounts
491 VK_SAMPLE_COUNT_1_BIT, // sampledImageIntegerSampleCounts
492 VK_SAMPLE_COUNT_1_BIT |
493 VK_SAMPLE_COUNT_4_BIT, // sampledImageDepthSampleCounts
494 VK_SAMPLE_COUNT_1_BIT |
495 VK_SAMPLE_COUNT_4_BIT, // sampledImageStencilSampleCounts
496 VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts
497 1, // maxSampleMaskWords
498 VK_TRUE, // timestampComputeAndGraphics
499 1, // timestampPeriod
500 0, // maxClipDistances
501 0, // maxCullDistances
502 0, // maxCombinedClipAndCullDistances
503 2, // discreteQueuePriorities
504 {1.0f, 1.0f}, // pointSizeRange[2]
505 {1.0f, 1.0f}, // lineWidthRange[2]
506 0.0f, // pointSizeGranularity
507 0.0f, // lineWidthGranularity
508 VK_TRUE, // strictLines
509 VK_TRUE, // standardSampleLocations
510 1, // optimalBufferCopyOffsetAlignment
511 1, // optimalBufferCopyRowPitchAlignment
512 64, // nonCoherentAtomSize
513 };
Jesse Hall04f4f472015-08-16 19:51:04 -0700514}
515
Jesse Hall606a54e2015-11-19 22:17:28 -0800516void GetPhysicalDeviceQueueFamilyProperties(
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700517 VkPhysicalDevice,
518 uint32_t* count,
519 VkQueueFamilyProperties* properties) {
Jesse Hall715b86a2016-01-16 16:34:29 -0800520 if (!properties || *count > 1)
521 *count = 1;
522 if (properties && *count == 1) {
Jesse Hall65ab5522015-11-30 00:07:16 -0800523 properties->queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT |
524 VK_QUEUE_TRANSFER_BIT;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700525 properties->queueCount = 1;
Jesse Hallacfa5342015-11-19 21:51:33 -0800526 properties->timestampValidBits = 64;
Jesse Hall715b86a2016-01-16 16:34:29 -0800527 properties->minImageTransferGranularity = VkExtent3D{1, 1, 1};
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700528 }
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700529}
530
Jesse Hall606a54e2015-11-19 22:17:28 -0800531void GetPhysicalDeviceMemoryProperties(
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100532 VkPhysicalDevice,
533 VkPhysicalDeviceMemoryProperties* properties) {
534 properties->memoryTypeCount = 1;
535 properties->memoryTypes[0].propertyFlags =
Jesse Halld1af8122015-11-29 23:50:38 -0800536 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
537 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
538 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
539 VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100540 properties->memoryTypes[0].heapIndex = 0;
541 properties->memoryHeapCount = 1;
Jesse Hallbde8ee32015-09-01 16:24:29 -0700542 properties->memoryHeaps[0].size = kMaxDeviceMemory;
Jesse Halld1af8122015-11-29 23:50:38 -0800543 properties->memoryHeaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
Jesse Hall04f4f472015-08-16 19:51:04 -0700544}
545
Jesse Hall8e37cf32016-01-18 04:00:57 -0800546void GetPhysicalDeviceFeatures(VkPhysicalDevice /*gpu*/,
547 VkPhysicalDeviceFeatures* features) {
548 *features = VkPhysicalDeviceFeatures{
549 VK_TRUE, // robustBufferAccess
550 VK_FALSE, // fullDrawIndexUint32
551 VK_FALSE, // imageCubeArray
552 VK_FALSE, // independentBlend
553 VK_FALSE, // geometryShader
554 VK_FALSE, // tessellationShader
555 VK_FALSE, // sampleRateShading
556 VK_FALSE, // dualSrcBlend
557 VK_FALSE, // logicOp
558 VK_FALSE, // multiDrawIndirect
559 VK_FALSE, // drawIndirectFirstInstance
560 VK_FALSE, // depthClamp
561 VK_FALSE, // depthBiasClamp
562 VK_FALSE, // fillModeNonSolid
563 VK_FALSE, // depthBounds
564 VK_FALSE, // wideLines
565 VK_FALSE, // largePoints
566 VK_FALSE, // alphaToOne
567 VK_FALSE, // multiViewport
568 VK_FALSE, // samplerAnisotropy
569 VK_FALSE, // textureCompressionETC2
570 VK_FALSE, // textureCompressionASTC_LDR
571 VK_FALSE, // textureCompressionBC
572 VK_FALSE, // occlusionQueryPrecise
573 VK_FALSE, // pipelineStatisticsQuery
574 VK_FALSE, // vertexPipelineStoresAndAtomics
575 VK_FALSE, // fragmentStoresAndAtomics
576 VK_FALSE, // shaderTessellationAndGeometryPointSize
577 VK_FALSE, // shaderImageGatherExtended
578 VK_FALSE, // shaderStorageImageExtendedFormats
579 VK_FALSE, // shaderStorageImageMultisample
580 VK_FALSE, // shaderStorageImageReadWithoutFormat
581 VK_FALSE, // shaderStorageImageWriteWithoutFormat
582 VK_FALSE, // shaderUniformBufferArrayDynamicIndexing
583 VK_FALSE, // shaderSampledImageArrayDynamicIndexing
584 VK_FALSE, // shaderStorageBufferArrayDynamicIndexing
585 VK_FALSE, // shaderStorageImageArrayDynamicIndexing
586 VK_FALSE, // shaderClipDistance
587 VK_FALSE, // shaderCullDistance
588 VK_FALSE, // shaderFloat64
589 VK_FALSE, // shaderInt64
590 VK_FALSE, // shaderInt16
591 VK_FALSE, // shaderResourceResidency
592 VK_FALSE, // shaderResourceMinLod
593 VK_FALSE, // sparseBinding
594 VK_FALSE, // sparseResidencyBuffer
595 VK_FALSE, // sparseResidencyImage2D
596 VK_FALSE, // sparseResidencyImage3D
597 VK_FALSE, // sparseResidency2Samples
598 VK_FALSE, // sparseResidency4Samples
599 VK_FALSE, // sparseResidency8Samples
600 VK_FALSE, // sparseResidency16Samples
601 VK_FALSE, // sparseResidencyAliased
602 VK_FALSE, // variableMultisampleRate
603 VK_FALSE, // inheritedQueries
604 };
605}
606
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100607// -----------------------------------------------------------------------------
608// Device
609
Jesse Hall04f4f472015-08-16 19:51:04 -0700610VkResult CreateDevice(VkPhysicalDevice physical_device,
Jesse Hallb1471272016-01-17 21:36:58 -0800611 const VkDeviceCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800612 const VkAllocationCallbacks* allocator,
Jesse Hall04f4f472015-08-16 19:51:04 -0700613 VkDevice* out_device) {
614 VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800615 if (!allocator)
616 allocator = &instance->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800617 VkDevice_T* device = static_cast<VkDevice_T*>(allocator->pfnAllocation(
618 allocator->pUserData, sizeof(VkDevice_T), alignof(VkDevice_T),
619 VK_SYSTEM_ALLOCATION_SCOPE_DEVICE));
Jesse Hall04f4f472015-08-16 19:51:04 -0700620 if (!device)
621 return VK_ERROR_OUT_OF_HOST_MEMORY;
622
623 device->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800624 device->allocator = *allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -0700625 device->instance = instance;
626 device->queue.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700627 std::fill(device->next_handle.begin(), device->next_handle.end(),
628 UINT64_C(0));
Jesse Hall04f4f472015-08-16 19:51:04 -0700629
Jesse Hallb1471272016-01-17 21:36:58 -0800630 for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
631 if (strcmp(create_info->ppEnabledExtensionNames[i],
632 VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME) == 0) {
633 ALOGV("Enabling " VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME);
634 }
635 }
636
Jesse Hall04f4f472015-08-16 19:51:04 -0700637 *out_device = device;
638 return VK_SUCCESS;
639}
640
Jesse Hall3fbc8562015-11-29 22:10:52 -0800641void DestroyDevice(VkDevice device,
642 const VkAllocationCallbacks* /*allocator*/) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700643 if (!device)
Jesse Hallcf25c412015-10-29 17:14:50 -0700644 return;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800645 device->allocator.pfnFree(device->allocator.pUserData, device);
Jesse Hall04f4f472015-08-16 19:51:04 -0700646}
647
Jesse Hall606a54e2015-11-19 22:17:28 -0800648void GetDeviceQueue(VkDevice device, uint32_t, uint32_t, VkQueue* queue) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700649 *queue = &device->queue;
Jesse Hall04f4f472015-08-16 19:51:04 -0700650}
651
652// -----------------------------------------------------------------------------
Jesse Hall3fbc8562015-11-29 22:10:52 -0800653// CommandPool
Jesse Hall03b6fe12015-11-24 12:44:21 -0800654
Jesse Hall3fbc8562015-11-29 22:10:52 -0800655struct CommandPool {
656 typedef VkCommandPool HandleType;
657 VkAllocationCallbacks allocator;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800658};
Jesse Hall3fbc8562015-11-29 22:10:52 -0800659DEFINE_OBJECT_HANDLE_CONVERSION(CommandPool)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800660
661VkResult CreateCommandPool(VkDevice device,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800662 const VkCommandPoolCreateInfo* /*create_info*/,
663 const VkAllocationCallbacks* allocator,
664 VkCommandPool* cmd_pool) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800665 if (!allocator)
666 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800667 CommandPool* pool = static_cast<CommandPool*>(allocator->pfnAllocation(
668 allocator->pUserData, sizeof(CommandPool), alignof(CommandPool),
669 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall03b6fe12015-11-24 12:44:21 -0800670 if (!pool)
671 return VK_ERROR_OUT_OF_HOST_MEMORY;
672 pool->allocator = *allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800673 *cmd_pool = GetHandleToCommandPool(pool);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800674 return VK_SUCCESS;
675}
676
677void DestroyCommandPool(VkDevice /*device*/,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800678 VkCommandPool cmd_pool,
679 const VkAllocationCallbacks* /*allocator*/) {
680 CommandPool* pool = GetCommandPoolFromHandle(cmd_pool);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800681 pool->allocator.pfnFree(pool->allocator.pUserData, pool);
682}
683
684// -----------------------------------------------------------------------------
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700685// CmdBuffer
686
Jesse Hall3fbc8562015-11-29 22:10:52 -0800687VkResult AllocateCommandBuffers(VkDevice /*device*/,
688 const VkCommandBufferAllocateInfo* alloc_info,
689 VkCommandBuffer* cmdbufs) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800690 VkResult result = VK_SUCCESS;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800691 CommandPool& pool = *GetCommandPoolFromHandle(alloc_info->commandPool);
Jesse Hall3dd678a2016-01-08 21:52:01 -0800692 std::fill(cmdbufs, cmdbufs + alloc_info->commandBufferCount, nullptr);
693 for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) {
Jesse Hall3fbc8562015-11-29 22:10:52 -0800694 cmdbufs[i] =
695 static_cast<VkCommandBuffer_T*>(pool.allocator.pfnAllocation(
696 pool.allocator.pUserData, sizeof(VkCommandBuffer_T),
697 alignof(VkCommandBuffer_T), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hallfbf97b02015-11-20 14:17:03 -0800698 if (!cmdbufs[i]) {
699 result = VK_ERROR_OUT_OF_HOST_MEMORY;
700 break;
701 }
702 cmdbufs[i]->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
703 }
704 if (result != VK_SUCCESS) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800705 for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800706 if (!cmdbufs[i])
707 break;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800708 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800709 }
710 }
Jesse Hallfbf97b02015-11-20 14:17:03 -0800711 return result;
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700712}
713
Jesse Hall03b6fe12015-11-24 12:44:21 -0800714void FreeCommandBuffers(VkDevice /*device*/,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800715 VkCommandPool cmd_pool,
Jesse Hallfbf97b02015-11-20 14:17:03 -0800716 uint32_t count,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800717 const VkCommandBuffer* cmdbufs) {
718 CommandPool& pool = *GetCommandPoolFromHandle(cmd_pool);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800719 for (uint32_t i = 0; i < count; i++)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800720 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700721}
722
723// -----------------------------------------------------------------------------
Jesse Hall2077ce02015-08-29 18:10:59 +0100724// DeviceMemory
725
726struct DeviceMemory {
727 typedef VkDeviceMemory HandleType;
728 VkDeviceSize size;
729 alignas(16) uint8_t data[0];
730};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800731DEFINE_OBJECT_HANDLE_CONVERSION(DeviceMemory)
Jesse Hall2077ce02015-08-29 18:10:59 +0100732
Jesse Hall3fbc8562015-11-29 22:10:52 -0800733VkResult AllocateMemory(VkDevice device,
734 const VkMemoryAllocateInfo* alloc_info,
735 const VkAllocationCallbacks* allocator,
736 VkDeviceMemory* mem_handle) {
Jesse Hall2077ce02015-08-29 18:10:59 +0100737 if (SIZE_MAX - sizeof(DeviceMemory) <= alloc_info->allocationSize)
738 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800739 if (!allocator)
740 allocator = &device->allocator;
Jesse Hall2077ce02015-08-29 18:10:59 +0100741
Jesse Hall2077ce02015-08-29 18:10:59 +0100742 size_t size = sizeof(DeviceMemory) + size_t(alloc_info->allocationSize);
Jesse Hall3fbc8562015-11-29 22:10:52 -0800743 DeviceMemory* mem = static_cast<DeviceMemory*>(allocator->pfnAllocation(
744 allocator->pUserData, size, alignof(DeviceMemory),
745 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall2077ce02015-08-29 18:10:59 +0100746 if (!mem)
747 return VK_ERROR_OUT_OF_HOST_MEMORY;
748 mem->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800749 *mem_handle = GetHandleToDeviceMemory(mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100750 return VK_SUCCESS;
751}
752
Jesse Hall03b6fe12015-11-24 12:44:21 -0800753void FreeMemory(VkDevice device,
754 VkDeviceMemory mem_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800755 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800756 if (!allocator)
757 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800758 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800759 allocator->pfnFree(allocator->pUserData, mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100760}
761
762VkResult MapMemory(VkDevice,
763 VkDeviceMemory mem_handle,
764 VkDeviceSize offset,
765 VkDeviceSize,
766 VkMemoryMapFlags,
767 void** out_ptr) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800768 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall2077ce02015-08-29 18:10:59 +0100769 *out_ptr = &mem->data[0] + offset;
770 return VK_SUCCESS;
771}
772
773// -----------------------------------------------------------------------------
Jesse Hallf6578742015-08-29 17:06:12 +0100774// Buffer
775
776struct Buffer {
777 typedef VkBuffer HandleType;
778 VkDeviceSize size;
779};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800780DEFINE_OBJECT_HANDLE_CONVERSION(Buffer)
Jesse Hallf6578742015-08-29 17:06:12 +0100781
782VkResult CreateBuffer(VkDevice device,
783 const VkBufferCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800784 const VkAllocationCallbacks* allocator,
Jesse Hallf6578742015-08-29 17:06:12 +0100785 VkBuffer* buffer_handle) {
Jesse Hallbde8ee32015-09-01 16:24:29 -0700786 ALOGW_IF(create_info->size > kMaxDeviceMemory,
787 "CreateBuffer: requested size 0x%" PRIx64
788 " exceeds max device memory size 0x%" PRIx64,
789 create_info->size, kMaxDeviceMemory);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800790 if (!allocator)
791 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800792 Buffer* buffer = static_cast<Buffer*>(allocator->pfnAllocation(
793 allocator->pUserData, sizeof(Buffer), alignof(Buffer),
794 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hallf6578742015-08-29 17:06:12 +0100795 if (!buffer)
796 return VK_ERROR_OUT_OF_HOST_MEMORY;
797 buffer->size = create_info->size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800798 *buffer_handle = GetHandleToBuffer(buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100799 return VK_SUCCESS;
800}
801
Jesse Hall606a54e2015-11-19 22:17:28 -0800802void GetBufferMemoryRequirements(VkDevice,
803 VkBuffer buffer_handle,
804 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800805 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hallf6578742015-08-29 17:06:12 +0100806 requirements->size = buffer->size;
807 requirements->alignment = 16; // allow fast Neon/SSE memcpy
808 requirements->memoryTypeBits = 0x1;
Jesse Hallf6578742015-08-29 17:06:12 +0100809}
810
Jesse Hall03b6fe12015-11-24 12:44:21 -0800811void DestroyBuffer(VkDevice device,
812 VkBuffer buffer_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800813 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800814 if (!allocator)
815 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800816 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800817 allocator->pfnFree(allocator->pUserData, buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100818}
819
820// -----------------------------------------------------------------------------
Jesse Hall85c05b62015-09-01 18:07:41 -0700821// Image
822
823struct Image {
824 typedef VkImage HandleType;
825 VkDeviceSize size;
826};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800827DEFINE_OBJECT_HANDLE_CONVERSION(Image)
Jesse Hall85c05b62015-09-01 18:07:41 -0700828
829VkResult CreateImage(VkDevice device,
830 const VkImageCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800831 const VkAllocationCallbacks* allocator,
Jesse Hall85c05b62015-09-01 18:07:41 -0700832 VkImage* image_handle) {
833 if (create_info->imageType != VK_IMAGE_TYPE_2D ||
834 create_info->format != VK_FORMAT_R8G8B8A8_UNORM ||
835 create_info->mipLevels != 1) {
836 ALOGE("CreateImage: not yet implemented: type=%d format=%d mips=%u",
837 create_info->imageType, create_info->format,
838 create_info->mipLevels);
Jesse Halla15a4bf2015-11-19 22:48:02 -0800839 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall85c05b62015-09-01 18:07:41 -0700840 }
841
842 VkDeviceSize size =
843 VkDeviceSize(create_info->extent.width * create_info->extent.height) *
Jesse Halla15a4bf2015-11-19 22:48:02 -0800844 create_info->arrayLayers * create_info->samples * 4u;
Jesse Hall85c05b62015-09-01 18:07:41 -0700845 ALOGW_IF(size > kMaxDeviceMemory,
846 "CreateImage: image size 0x%" PRIx64
847 " exceeds max device memory size 0x%" PRIx64,
848 size, kMaxDeviceMemory);
849
Jesse Hall03b6fe12015-11-24 12:44:21 -0800850 if (!allocator)
851 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800852 Image* image = static_cast<Image*>(allocator->pfnAllocation(
853 allocator->pUserData, sizeof(Image), alignof(Image),
854 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall85c05b62015-09-01 18:07:41 -0700855 if (!image)
856 return VK_ERROR_OUT_OF_HOST_MEMORY;
857 image->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800858 *image_handle = GetHandleToImage(image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700859 return VK_SUCCESS;
860}
861
Jesse Hall606a54e2015-11-19 22:17:28 -0800862void GetImageMemoryRequirements(VkDevice,
863 VkImage image_handle,
864 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800865 Image* image = GetImageFromHandle(image_handle);
Jesse Hall85c05b62015-09-01 18:07:41 -0700866 requirements->size = image->size;
867 requirements->alignment = 16; // allow fast Neon/SSE memcpy
868 requirements->memoryTypeBits = 0x1;
Jesse Hall85c05b62015-09-01 18:07:41 -0700869}
870
Jesse Hall03b6fe12015-11-24 12:44:21 -0800871void DestroyImage(VkDevice device,
872 VkImage image_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800873 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800874 if (!allocator)
875 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800876 Image* image = GetImageFromHandle(image_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800877 allocator->pfnFree(allocator->pUserData, image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700878}
879
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800880VkResult GetSwapchainGrallocUsageANDROID(VkDevice,
881 VkFormat,
882 VkImageUsageFlags,
883 int* grallocUsage) {
884 // The null driver never reads or writes the gralloc buffer
885 *grallocUsage = 0;
886 return VK_SUCCESS;
887}
888
Chris Forbes8e4438b2016-12-07 16:26:49 +1300889VkResult GetSwapchainGrallocUsage2ANDROID(VkDevice,
890 VkFormat,
891 VkImageUsageFlags,
892 VkSwapchainImageUsageFlagsANDROID,
893 int* grallocUsage) {
894 // The null driver never reads or writes the gralloc buffer
895 *grallocUsage = 0;
896 return VK_SUCCESS;
897}
898
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800899VkResult AcquireImageANDROID(VkDevice,
900 VkImage,
901 int fence,
902 VkSemaphore,
903 VkFence) {
904 close(fence);
905 return VK_SUCCESS;
906}
907
908VkResult QueueSignalReleaseImageANDROID(VkQueue,
909 uint32_t,
910 const VkSemaphore*,
911 VkImage,
912 int* fence) {
913 *fence = -1;
914 return VK_SUCCESS;
915}
916
Jesse Hall85c05b62015-09-01 18:07:41 -0700917// -----------------------------------------------------------------------------
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700918// No-op types
919
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700920VkResult CreateBufferView(VkDevice device,
921 const VkBufferViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800922 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700923 VkBufferView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800924 *view = AllocHandle<VkBufferView>(device, HandleType::kBufferView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700925 return VK_SUCCESS;
926}
927
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700928VkResult CreateDescriptorPool(VkDevice device,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700929 const VkDescriptorPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800930 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700931 VkDescriptorPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800932 *pool = AllocHandle<VkDescriptorPool>(device, HandleType::kDescriptorPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700933 return VK_SUCCESS;
934}
935
Jesse Hall3fbc8562015-11-29 22:10:52 -0800936VkResult AllocateDescriptorSets(VkDevice device,
937 const VkDescriptorSetAllocateInfo* alloc_info,
938 VkDescriptorSet* descriptor_sets) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800939 for (uint32_t i = 0; i < alloc_info->descriptorSetCount; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800940 descriptor_sets[i] =
941 AllocHandle<VkDescriptorSet>(device, HandleType::kDescriptorSet);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700942 return VK_SUCCESS;
943}
944
945VkResult CreateDescriptorSetLayout(VkDevice device,
946 const VkDescriptorSetLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800947 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700948 VkDescriptorSetLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800949 *layout = AllocHandle<VkDescriptorSetLayout>(
950 device, HandleType::kDescriptorSetLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700951 return VK_SUCCESS;
952}
953
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700954VkResult CreateEvent(VkDevice device,
955 const VkEventCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800956 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700957 VkEvent* event) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800958 *event = AllocHandle<VkEvent>(device, HandleType::kEvent);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700959 return VK_SUCCESS;
960}
961
962VkResult CreateFence(VkDevice device,
963 const VkFenceCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800964 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700965 VkFence* fence) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800966 *fence = AllocHandle<VkFence>(device, HandleType::kFence);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700967 return VK_SUCCESS;
968}
969
970VkResult CreateFramebuffer(VkDevice device,
971 const VkFramebufferCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800972 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700973 VkFramebuffer* framebuffer) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800974 *framebuffer = AllocHandle<VkFramebuffer>(device, HandleType::kFramebuffer);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700975 return VK_SUCCESS;
976}
977
978VkResult CreateImageView(VkDevice device,
979 const VkImageViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800980 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700981 VkImageView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800982 *view = AllocHandle<VkImageView>(device, HandleType::kImageView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700983 return VK_SUCCESS;
984}
985
986VkResult CreateGraphicsPipelines(VkDevice device,
987 VkPipelineCache,
988 uint32_t count,
989 const VkGraphicsPipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800990 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700991 VkPipeline* pipelines) {
992 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800993 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700994 return VK_SUCCESS;
995}
996
997VkResult CreateComputePipelines(VkDevice device,
998 VkPipelineCache,
999 uint32_t count,
1000 const VkComputePipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001001 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001002 VkPipeline* pipelines) {
1003 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -08001004 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001005 return VK_SUCCESS;
1006}
1007
1008VkResult CreatePipelineCache(VkDevice device,
1009 const VkPipelineCacheCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001010 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001011 VkPipelineCache* cache) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001012 *cache = AllocHandle<VkPipelineCache>(device, HandleType::kPipelineCache);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001013 return VK_SUCCESS;
1014}
1015
1016VkResult CreatePipelineLayout(VkDevice device,
1017 const VkPipelineLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001018 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001019 VkPipelineLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001020 *layout =
1021 AllocHandle<VkPipelineLayout>(device, HandleType::kPipelineLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001022 return VK_SUCCESS;
1023}
1024
1025VkResult CreateQueryPool(VkDevice device,
1026 const VkQueryPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001027 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001028 VkQueryPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001029 *pool = AllocHandle<VkQueryPool>(device, HandleType::kQueryPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001030 return VK_SUCCESS;
1031}
1032
1033VkResult CreateRenderPass(VkDevice device,
1034 const VkRenderPassCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001035 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001036 VkRenderPass* renderpass) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001037 *renderpass = AllocHandle<VkRenderPass>(device, HandleType::kRenderPass);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001038 return VK_SUCCESS;
1039}
1040
1041VkResult CreateSampler(VkDevice device,
1042 const VkSamplerCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001043 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001044 VkSampler* sampler) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001045 *sampler = AllocHandle<VkSampler>(device, HandleType::kSampler);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001046 return VK_SUCCESS;
1047}
1048
1049VkResult CreateSemaphore(VkDevice device,
1050 const VkSemaphoreCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001051 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001052 VkSemaphore* semaphore) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001053 *semaphore = AllocHandle<VkSemaphore>(device, HandleType::kSemaphore);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001054 return VK_SUCCESS;
1055}
1056
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001057VkResult CreateShaderModule(VkDevice device,
1058 const VkShaderModuleCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001059 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001060 VkShaderModule* module) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001061 *module = AllocHandle<VkShaderModule>(device, HandleType::kShaderModule);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001062 return VK_SUCCESS;
1063}
1064
Jesse Hall715b86a2016-01-16 16:34:29 -08001065VkResult CreateDebugReportCallbackEXT(VkInstance instance,
1066 const VkDebugReportCallbackCreateInfoEXT*,
1067 const VkAllocationCallbacks*,
1068 VkDebugReportCallbackEXT* callback) {
1069 *callback = AllocHandle<VkDebugReportCallbackEXT>(
1070 instance, HandleType::kDebugReportCallbackEXT);
1071 return VK_SUCCESS;
1072}
1073
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001074// -----------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -07001075// No-op entrypoints
1076
1077// clang-format off
1078#pragma clang diagnostic push
1079#pragma clang diagnostic ignored "-Wunused-parameter"
1080
Jesse Hall606a54e2015-11-19 22:17:28 -08001081void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001082 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001083}
1084
Jesse Halla9e57032015-11-30 01:03:10 -08001085VkResult GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001086 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Halla9e57032015-11-30 01:03:10 -08001087 return VK_SUCCESS;
Jesse Hall04f4f472015-08-16 19:51:04 -07001088}
1089
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001090VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001091 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001092 return VK_SUCCESS;
1093}
1094
Jesse Halla366a512015-11-19 22:30:07 -08001095VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001096 return VK_SUCCESS;
1097}
1098
1099VkResult QueueWaitIdle(VkQueue queue) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001100 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001101 return VK_SUCCESS;
1102}
1103
1104VkResult DeviceWaitIdle(VkDevice device) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001105 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001106 return VK_SUCCESS;
1107}
1108
Jesse Hallcf25c412015-10-29 17:14:50 -07001109void UnmapMemory(VkDevice device, VkDeviceMemory mem) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001110}
1111
1112VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001113 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001114 return VK_SUCCESS;
1115}
1116
1117VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001118 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001119 return VK_SUCCESS;
1120}
1121
Jesse Hall606a54e2015-11-19 22:17:28 -08001122void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001123 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001124}
1125
Jesse Hall04f4f472015-08-16 19:51:04 -07001126VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) {
1127 return VK_SUCCESS;
1128}
1129
Jesse Hall04f4f472015-08-16 19:51:04 -07001130VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) {
1131 return VK_SUCCESS;
1132}
1133
Jesse Hall606a54e2015-11-19 22:17:28 -08001134void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001135 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001136}
1137
Jesse Hall091ed9e2015-11-30 00:55:29 -08001138void 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 +01001139 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001140}
1141
Jesse Halla6429252015-11-29 18:59:42 -08001142VkResult QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001143 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001144 return VK_SUCCESS;
1145}
1146
Jesse Hall3fbc8562015-11-29 22:10:52 -08001147void DestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001148}
1149
1150VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) {
1151 return VK_SUCCESS;
1152}
1153
1154VkResult GetFenceStatus(VkDevice device, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001155 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001156 return VK_SUCCESS;
1157}
1158
1159VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) {
1160 return VK_SUCCESS;
1161}
1162
Jesse Hall3fbc8562015-11-29 22:10:52 -08001163void DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001164}
1165
Jesse Hall3fbc8562015-11-29 22:10:52 -08001166void DestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001167}
1168
1169VkResult GetEventStatus(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001170 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001171 return VK_SUCCESS;
1172}
1173
1174VkResult SetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001175 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001176 return VK_SUCCESS;
1177}
1178
1179VkResult ResetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001180 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001181 return VK_SUCCESS;
1182}
1183
Jesse Hall3fbc8562015-11-29 22:10:52 -08001184void DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001185}
1186
Jesse Halla9bb62b2015-11-21 19:31:56 -08001187VkResult 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 +01001188 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001189 return VK_SUCCESS;
1190}
1191
Jesse Hall3fbc8562015-11-29 22:10:52 -08001192void DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001193}
1194
Jesse Hall606a54e2015-11-19 22:17:28 -08001195void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001196 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001197}
1198
Jesse Hall3fbc8562015-11-29 22:10:52 -08001199void DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001200}
1201
Jesse Hall3fbc8562015-11-29 22:10:52 -08001202void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001203}
1204
Jesse Hall3fbc8562015-11-29 22:10:52 -08001205void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001206}
1207
Jesse Halla9bb62b2015-11-21 19:31:56 -08001208VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001209 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001210 return VK_SUCCESS;
1211}
1212
1213VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001214 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001215 return VK_SUCCESS;
1216}
1217
Jesse Hall3fbc8562015-11-29 22:10:52 -08001218void DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001219}
1220
Jesse Hall3fbc8562015-11-29 22:10:52 -08001221void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001222}
1223
Jesse Hall3fbc8562015-11-29 22:10:52 -08001224void DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001225}
1226
Jesse Hall3fbc8562015-11-29 22:10:52 -08001227void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001228}
1229
Jesse Hall3fbc8562015-11-29 22:10:52 -08001230void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001231}
1232
Jesse Hallfbf97b02015-11-20 14:17:03 -08001233VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001234 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001235 return VK_SUCCESS;
1236}
1237
Jesse Hallcf25c412015-10-29 17:14:50 -07001238void UpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001239 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001240}
1241
1242VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001243 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001244 return VK_SUCCESS;
1245}
1246
Jesse Hall3fbc8562015-11-29 22:10:52 -08001247void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001248}
1249
Jesse Hall3fbc8562015-11-29 22:10:52 -08001250void DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001251}
1252
Jesse Hall606a54e2015-11-19 22:17:28 -08001253void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001254 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001255}
1256
Jesse Hall3fbc8562015-11-29 22:10:52 -08001257VkResult ResetCommandPool(VkDevice device, VkCommandPool cmdPool, VkCommandPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001258 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001259 return VK_SUCCESS;
1260}
1261
Jesse Hall3fbc8562015-11-29 22:10:52 -08001262VkResult BeginCommandBuffer(VkCommandBuffer cmdBuffer, const VkCommandBufferBeginInfo* pBeginInfo) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001263 return VK_SUCCESS;
1264}
1265
Jesse Hall3fbc8562015-11-29 22:10:52 -08001266VkResult EndCommandBuffer(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001267 return VK_SUCCESS;
1268}
1269
Jesse Hall3fbc8562015-11-29 22:10:52 -08001270VkResult ResetCommandBuffer(VkCommandBuffer cmdBuffer, VkCommandBufferResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001271 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001272 return VK_SUCCESS;
1273}
1274
Jesse Hall3fbc8562015-11-29 22:10:52 -08001275void CmdBindPipeline(VkCommandBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001276}
1277
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001278void CmdSetViewport(VkCommandBuffer cmdBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001279}
1280
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001281void CmdSetScissor(VkCommandBuffer cmdBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001282}
1283
Jesse Hall3fbc8562015-11-29 22:10:52 -08001284void CmdSetLineWidth(VkCommandBuffer cmdBuffer, float lineWidth) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001285}
1286
Jesse Hall3fbc8562015-11-29 22:10:52 -08001287void CmdSetDepthBias(VkCommandBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001288}
1289
Jesse Hall3fbc8562015-11-29 22:10:52 -08001290void CmdSetBlendConstants(VkCommandBuffer cmdBuffer, const float blendConst[4]) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001291}
1292
Jesse Hall3fbc8562015-11-29 22:10:52 -08001293void CmdSetDepthBounds(VkCommandBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001294}
1295
Jesse Hall3fbc8562015-11-29 22:10:52 -08001296void CmdSetStencilCompareMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001297}
1298
Jesse Hall3fbc8562015-11-29 22:10:52 -08001299void CmdSetStencilWriteMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001300}
1301
Jesse Hall3fbc8562015-11-29 22:10:52 -08001302void CmdSetStencilReference(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001303}
1304
Jesse Hall3fbc8562015-11-29 22:10:52 -08001305void 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 -07001306}
1307
Jesse Hall3fbc8562015-11-29 22:10:52 -08001308void CmdBindIndexBuffer(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001309}
1310
Jesse Hall3fbc8562015-11-29 22:10:52 -08001311void CmdBindVertexBuffers(VkCommandBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001312}
1313
Jesse Hall3fbc8562015-11-29 22:10:52 -08001314void CmdDraw(VkCommandBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001315}
1316
Jesse Hall3fbc8562015-11-29 22:10:52 -08001317void 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 -07001318}
1319
Jesse Hall3fbc8562015-11-29 22:10:52 -08001320void CmdDrawIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001321}
1322
Jesse Hall3fbc8562015-11-29 22:10:52 -08001323void CmdDrawIndexedIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001324}
1325
Jesse Hall3fbc8562015-11-29 22:10:52 -08001326void CmdDispatch(VkCommandBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001327}
1328
Jesse Hall3fbc8562015-11-29 22:10:52 -08001329void CmdDispatchIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001330}
1331
Jesse Hall3fbc8562015-11-29 22:10:52 -08001332void CmdCopyBuffer(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001333}
1334
Jesse Hall3fbc8562015-11-29 22:10:52 -08001335void CmdCopyImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001336}
1337
Jesse Hall3fbc8562015-11-29 22:10:52 -08001338void 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 -07001339}
1340
Jesse Hall3fbc8562015-11-29 22:10:52 -08001341void CmdCopyBufferToImage(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001342}
1343
Jesse Hall3fbc8562015-11-29 22:10:52 -08001344void CmdCopyImageToBuffer(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001345}
1346
Jesse Hall56d386a2016-07-26 15:20:40 -07001347void CmdUpdateBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const void* pData) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001348}
1349
Jesse Hall3fbc8562015-11-29 22:10:52 -08001350void CmdFillBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001351}
1352
Jesse Hall3fbc8562015-11-29 22:10:52 -08001353void CmdClearColorImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001354}
1355
Jesse Hall3fbc8562015-11-29 22:10:52 -08001356void CmdClearDepthStencilImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001357}
1358
Jesse Hall3fbc8562015-11-29 22:10:52 -08001359void CmdClearAttachments(VkCommandBuffer cmdBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001360}
1361
Jesse Hall3fbc8562015-11-29 22:10:52 -08001362void CmdResolveImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001363}
1364
Jesse Hall3fbc8562015-11-29 22:10:52 -08001365void CmdSetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001366}
1367
Jesse Hall3fbc8562015-11-29 22:10:52 -08001368void CmdResetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001369}
1370
Jesse Hall3dd678a2016-01-08 21:52:01 -08001371void 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 -07001372}
1373
Jesse Hall3dd678a2016-01-08 21:52:01 -08001374void 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 -07001375}
1376
Jesse Hall3fbc8562015-11-29 22:10:52 -08001377void CmdBeginQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001378}
1379
Jesse Hall3fbc8562015-11-29 22:10:52 -08001380void CmdEndQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001381}
1382
Jesse Hall3fbc8562015-11-29 22:10:52 -08001383void CmdResetQueryPool(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001384}
1385
Jesse Hall3fbc8562015-11-29 22:10:52 -08001386void CmdWriteTimestamp(VkCommandBuffer cmdBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001387}
1388
Jesse Hall3fbc8562015-11-29 22:10:52 -08001389void 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 -07001390}
1391
Jesse Hall3fbc8562015-11-29 22:10:52 -08001392void CmdPushConstants(VkCommandBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001393}
1394
Jesse Hall65ab5522015-11-30 00:07:16 -08001395void CmdBeginRenderPass(VkCommandBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001396}
1397
Jesse Hall65ab5522015-11-30 00:07:16 -08001398void CmdNextSubpass(VkCommandBuffer cmdBuffer, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001399}
1400
Jesse Hall3fbc8562015-11-29 22:10:52 -08001401void CmdEndRenderPass(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001402}
1403
Jesse Hall3fbc8562015-11-29 22:10:52 -08001404void CmdExecuteCommands(VkCommandBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCommandBuffer* pCmdBuffers) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001405}
1406
Jesse Hall715b86a2016-01-16 16:34:29 -08001407void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) {
1408}
1409
1410void DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage) {
1411}
1412
Jesse Hall04f4f472015-08-16 19:51:04 -07001413#pragma clang diagnostic pop
1414// clang-format on
1415
1416} // namespace null_driver