blob: 89c65af44aa0fd9d92d9db778d069e2a8b3e3f52 [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 Hall715b86a2016-01-16 16:34:29 -080019#include <inttypes.h>
Jesse Halld3b14502016-04-20 16:58:11 -070020#include <stdlib.h>
Jesse Hall715b86a2016-01-16 16:34:29 -080021#include <string.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070022
Mark Salyzyna5e161b2016-09-29 08:08:05 -070023#include <algorithm>
24#include <array>
25
Mark Salyzyn7823e122016-09-29 08:08:05 -070026#include <log/log.h>
Jesse Hall04f4f472015-08-16 19:51:04 -070027#include <utils/Errors.h>
28
Jesse Hall1f91d392015-12-11 16:28:44 -080029#include "null_driver_gen.h"
Jesse Hall04f4f472015-08-16 19:51:04 -070030
31using namespace null_driver;
32
33struct VkPhysicalDevice_T {
34 hwvulkan_dispatch_t dispatch;
35};
36
37struct VkInstance_T {
38 hwvulkan_dispatch_t dispatch;
Jesse Hall3fbc8562015-11-29 22:10:52 -080039 VkAllocationCallbacks allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -070040 VkPhysicalDevice_T physical_device;
Jesse Hall715b86a2016-01-16 16:34:29 -080041 uint64_t next_callback_handle;
Jesse Hall04f4f472015-08-16 19:51:04 -070042};
43
44struct VkQueue_T {
45 hwvulkan_dispatch_t dispatch;
46};
47
Jesse Hall3fbc8562015-11-29 22:10:52 -080048struct VkCommandBuffer_T {
Jesse Hall04f4f472015-08-16 19:51:04 -070049 hwvulkan_dispatch_t dispatch;
50};
51
Jesse Hallf8faf0c2015-08-31 11:34:32 -070052namespace {
53// Handles for non-dispatchable objects are either pointers, or arbitrary
54// 64-bit non-zero values. We only use pointers when we need to keep state for
55// the object even in a null driver. For the rest, we form a handle as:
56// [63:63] = 1 to distinguish from pointer handles*
57// [62:56] = non-zero handle type enum value
58// [55: 0] = per-handle-type incrementing counter
59// * This works because virtual addresses with the high bit set are reserved
60// for kernel data in all ABIs we run on.
61//
62// We never reclaim handles on vkDestroy*. It's not even necessary for us to
63// have distinct handles for live objects, and practically speaking we won't
64// ever create 2^56 objects of the same type from a single VkDevice in a null
65// driver.
66//
67// Using a namespace here instead of 'enum class' since we want scoped
68// constants but also want implicit conversions to integral types.
69namespace HandleType {
Jesse Hallc7a6eb52015-08-31 12:52:03 -070070enum Enum {
Jesse Hallc7a6eb52015-08-31 12:52:03 -070071 kBufferView,
Jesse Hall715b86a2016-01-16 16:34:29 -080072 kDebugReportCallbackEXT,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070073 kDescriptorPool,
74 kDescriptorSet,
75 kDescriptorSetLayout,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070076 kEvent,
77 kFence,
78 kFramebuffer,
79 kImageView,
80 kPipeline,
81 kPipelineCache,
82 kPipelineLayout,
83 kQueryPool,
84 kRenderPass,
85 kSampler,
86 kSemaphore,
Jesse Hallc7a6eb52015-08-31 12:52:03 -070087 kShaderModule,
Jesse Hallf8faf0c2015-08-31 11:34:32 -070088
Jesse Hallc7a6eb52015-08-31 12:52:03 -070089 kNumTypes
90};
91} // namespace HandleType
Jesse Hallbde8ee32015-09-01 16:24:29 -070092
Jesse Hall00f10fe2016-02-08 21:20:20 -080093const VkDeviceSize kMaxDeviceMemory = 0x10000000; // 256 MiB, arbitrary
Jesse Hallbde8ee32015-09-01 16:24:29 -070094
Jesse Hallc7a6eb52015-08-31 12:52:03 -070095} // anonymous namespace
Jesse Hallf8faf0c2015-08-31 11:34:32 -070096
Jesse Hall04f4f472015-08-16 19:51:04 -070097struct VkDevice_T {
98 hwvulkan_dispatch_t dispatch;
Jesse Hall3fbc8562015-11-29 22:10:52 -080099 VkAllocationCallbacks allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -0700100 VkInstance_T* instance;
101 VkQueue_T queue;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700102 std::array<uint64_t, HandleType::kNumTypes> next_handle;
Jesse Hall04f4f472015-08-16 19:51:04 -0700103};
104
105// -----------------------------------------------------------------------------
106// Declare HAL_MODULE_INFO_SYM early so it can be referenced by nulldrv_device
107// later.
108
109namespace {
110int OpenDevice(const hw_module_t* module, const char* id, hw_device_t** device);
111hw_module_methods_t nulldrv_module_methods = {.open = OpenDevice};
112} // namespace
113
114#pragma clang diagnostic push
115#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
116__attribute__((visibility("default"))) hwvulkan_module_t HAL_MODULE_INFO_SYM = {
117 .common =
118 {
Michael Lentine03c64b02015-08-26 18:27:26 -0500119 .tag = HARDWARE_MODULE_TAG,
120 .module_api_version = HWVULKAN_MODULE_API_VERSION_0_1,
121 .hal_api_version = HARDWARE_HAL_API_VERSION,
122 .id = HWVULKAN_HARDWARE_MODULE_ID,
123 .name = "Null Vulkan Driver",
124 .author = "The Android Open Source Project",
125 .methods = &nulldrv_module_methods,
Jesse Hall04f4f472015-08-16 19:51:04 -0700126 },
127};
128#pragma clang diagnostic pop
129
130// -----------------------------------------------------------------------------
131
132namespace {
133
Jesse Hall04f4f472015-08-16 19:51:04 -0700134int CloseDevice(struct hw_device_t* /*device*/) {
135 // nothing to do - opening a device doesn't allocate any resources
136 return 0;
137}
138
139hwvulkan_device_t nulldrv_device = {
140 .common =
141 {
Michael Lentine03c64b02015-08-26 18:27:26 -0500142 .tag = HARDWARE_DEVICE_TAG,
143 .version = HWVULKAN_DEVICE_API_VERSION_0_1,
144 .module = &HAL_MODULE_INFO_SYM.common,
145 .close = CloseDevice,
Jesse Hall04f4f472015-08-16 19:51:04 -0700146 },
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700147 .EnumerateInstanceExtensionProperties =
148 EnumerateInstanceExtensionProperties,
Jesse Hall04f4f472015-08-16 19:51:04 -0700149 .CreateInstance = CreateInstance,
150 .GetInstanceProcAddr = GetInstanceProcAddr};
151
152int OpenDevice(const hw_module_t* /*module*/,
153 const char* id,
154 hw_device_t** device) {
155 if (strcmp(id, HWVULKAN_DEVICE_0) == 0) {
156 *device = &nulldrv_device.common;
157 return 0;
158 }
159 return -ENOENT;
160}
161
162VkInstance_T* GetInstanceFromPhysicalDevice(
163 VkPhysicalDevice_T* physical_device) {
164 return reinterpret_cast<VkInstance_T*>(
165 reinterpret_cast<uintptr_t>(physical_device) -
166 offsetof(VkInstance_T, physical_device));
167}
168
Jesse Hall715b86a2016-01-16 16:34:29 -0800169uint64_t AllocHandle(uint64_t type, uint64_t* next_handle) {
170 const uint64_t kHandleMask = (UINT64_C(1) << 56) - 1;
171 ALOGE_IF(*next_handle == kHandleMask,
172 "non-dispatchable handles of type=%" PRIu64
173 " are about to overflow",
174 type);
175 return (UINT64_C(1) << 63) | ((type & 0x7) << 56) |
176 ((*next_handle)++ & kHandleMask);
177}
178
179template <class Handle>
180Handle AllocHandle(VkInstance instance, HandleType::Enum type) {
181 return reinterpret_cast<Handle>(
182 AllocHandle(type, &instance->next_callback_handle));
183}
184
Michael Lentine3fec89e2015-12-04 16:25:11 -0800185template <class Handle>
186Handle AllocHandle(VkDevice device, HandleType::Enum type) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800187 return reinterpret_cast<Handle>(
Jesse Hall715b86a2016-01-16 16:34:29 -0800188 AllocHandle(type, &device->next_handle[type]));
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700189}
190
Jesse Halld3b14502016-04-20 16:58:11 -0700191VKAPI_ATTR void* DefaultAllocate(void*,
192 size_t size,
193 size_t alignment,
194 VkSystemAllocationScope) {
195 void* ptr = nullptr;
196 // Vulkan requires 'alignment' to be a power of two, but posix_memalign
197 // additionally requires that it be at least sizeof(void*).
198 int ret = posix_memalign(&ptr, std::max(alignment, sizeof(void*)), size);
199 return ret == 0 ? ptr : nullptr;
200}
201
202VKAPI_ATTR void* DefaultReallocate(void*,
203 void* ptr,
204 size_t size,
205 size_t alignment,
206 VkSystemAllocationScope) {
207 if (size == 0) {
208 free(ptr);
209 return nullptr;
210 }
211
212 // TODO(jessehall): Right now we never shrink allocations; if the new
213 // request is smaller than the existing chunk, we just continue using it.
214 // The null driver never reallocs, so this doesn't matter. If that changes,
215 // or if this code is copied into some other project, this should probably
216 // have a heuristic to allocate-copy-free when doing so will save "enough"
217 // space.
218 size_t old_size = ptr ? malloc_usable_size(ptr) : 0;
219 if (size <= old_size)
220 return ptr;
221
222 void* new_ptr = nullptr;
223 if (posix_memalign(&new_ptr, std::max(alignment, sizeof(void*)), size) != 0)
224 return nullptr;
225 if (ptr) {
226 memcpy(new_ptr, ptr, std::min(old_size, size));
227 free(ptr);
228 }
229 return new_ptr;
230}
231
232VKAPI_ATTR void DefaultFree(void*, void* ptr) {
233 free(ptr);
234}
235
236const VkAllocationCallbacks kDefaultAllocCallbacks = {
237 .pUserData = nullptr,
238 .pfnAllocation = DefaultAllocate,
239 .pfnReallocation = DefaultReallocate,
240 .pfnFree = DefaultFree,
241};
242
Jesse Hall04f4f472015-08-16 19:51:04 -0700243} // namespace
244
245namespace null_driver {
246
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800247#define DEFINE_OBJECT_HANDLE_CONVERSION(T) \
248 T* Get##T##FromHandle(Vk##T h); \
249 T* Get##T##FromHandle(Vk##T h) { \
250 return reinterpret_cast<T*>(uintptr_t(h)); \
251 } \
252 Vk##T GetHandleTo##T(const T* obj); \
253 Vk##T GetHandleTo##T(const T* obj) { \
254 return Vk##T(reinterpret_cast<uintptr_t>(obj)); \
255 }
Jesse Hallf6578742015-08-29 17:06:12 +0100256
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100257// -----------------------------------------------------------------------------
258// Global
259
Jesse Halle1b12782015-11-30 11:27:32 -0800260VKAPI_ATTR
Jesse Hall715b86a2016-01-16 16:34:29 -0800261VkResult EnumerateInstanceExtensionProperties(
262 const char* layer_name,
263 uint32_t* count,
264 VkExtensionProperties* properties) {
265 if (layer_name) {
266 ALOGW(
267 "Driver vkEnumerateInstanceExtensionProperties shouldn't be called "
268 "with a layer name ('%s')",
269 layer_name);
Jesse Hall715b86a2016-01-16 16:34:29 -0800270 }
271
Jesse Hall4b62e4f2016-01-21 09:49:49 -0800272// NOTE: Change this to zero to report and extension, which can be useful
273// for testing changes to the loader.
274#if 1
275 (void)properties; // unused
276 *count = 0;
277 return VK_SUCCESS;
278#else
Jesse Hall715b86a2016-01-16 16:34:29 -0800279 const VkExtensionProperties kExtensions[] = {
280 {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}};
281 const uint32_t kExtensionsCount =
282 sizeof(kExtensions) / sizeof(kExtensions[0]);
283
284 if (!properties || *count > kExtensionsCount)
285 *count = kExtensionsCount;
286 if (properties)
287 std::copy(kExtensions, kExtensions + *count, properties);
288 return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS;
Jesse Hall4b62e4f2016-01-21 09:49:49 -0800289#endif
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100290}
291
Jesse Halle1b12782015-11-30 11:27:32 -0800292VKAPI_ATTR
Jesse Hall715b86a2016-01-16 16:34:29 -0800293VkResult CreateInstance(const VkInstanceCreateInfo* create_info,
Jesse Hall1f91d392015-12-11 16:28:44 -0800294 const VkAllocationCallbacks* allocator,
295 VkInstance* out_instance) {
Jesse Halld3b14502016-04-20 16:58:11 -0700296 if (!allocator)
297 allocator = &kDefaultAllocCallbacks;
Jesse Hall1f91d392015-12-11 16:28:44 -0800298
299 VkInstance_T* instance =
300 static_cast<VkInstance_T*>(allocator->pfnAllocation(
301 allocator->pUserData, sizeof(VkInstance_T), alignof(VkInstance_T),
302 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE));
303 if (!instance)
304 return VK_ERROR_OUT_OF_HOST_MEMORY;
305
306 instance->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
307 instance->allocator = *allocator;
308 instance->physical_device.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall715b86a2016-01-16 16:34:29 -0800309 instance->next_callback_handle = 0;
Jesse Hall715b86a2016-01-16 16:34:29 -0800310
311 for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
312 if (strcmp(create_info->ppEnabledExtensionNames[i],
313 VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) {
Jesse Hallb1471272016-01-17 21:36:58 -0800314 ALOGV("instance extension '%s' requested",
315 create_info->ppEnabledExtensionNames[i]);
316 } else {
317 ALOGW("unsupported extension '%s' requested",
318 create_info->ppEnabledExtensionNames[i]);
Jesse Hall715b86a2016-01-16 16:34:29 -0800319 }
320 }
Jesse Hall1f91d392015-12-11 16:28:44 -0800321
322 *out_instance = instance;
323 return VK_SUCCESS;
324}
325
326VKAPI_ATTR
327PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name) {
328 return instance ? GetInstanceProcAddr(name) : GetGlobalProcAddr(name);
Jesse Hall04f4f472015-08-16 19:51:04 -0700329}
330
Jesse Halle1b12782015-11-30 11:27:32 -0800331VKAPI_ATTR
Jesse Hall04f4f472015-08-16 19:51:04 -0700332PFN_vkVoidFunction GetDeviceProcAddr(VkDevice, const char* name) {
Jesse Hall1f91d392015-12-11 16:28:44 -0800333 return GetInstanceProcAddr(name);
Jesse Hall04f4f472015-08-16 19:51:04 -0700334}
335
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100336// -----------------------------------------------------------------------------
337// Instance
338
Jesse Hall03b6fe12015-11-24 12:44:21 -0800339void DestroyInstance(VkInstance instance,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800340 const VkAllocationCallbacks* /*allocator*/) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800341 instance->allocator.pfnFree(instance->allocator.pUserData, instance);
Jesse Hall04f4f472015-08-16 19:51:04 -0700342}
343
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100344// -----------------------------------------------------------------------------
345// PhysicalDevice
346
Jesse Hall04f4f472015-08-16 19:51:04 -0700347VkResult EnumeratePhysicalDevices(VkInstance instance,
348 uint32_t* physical_device_count,
349 VkPhysicalDevice* physical_devices) {
350 if (physical_devices && *physical_device_count >= 1)
351 physical_devices[0] = &instance->physical_device;
352 *physical_device_count = 1;
353 return VK_SUCCESS;
354}
355
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800356VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice /*gpu*/,
357 uint32_t* count,
358 VkLayerProperties* /*properties*/) {
359 ALOGW("Driver vkEnumerateDeviceLayerProperties shouldn't be called");
360 *count = 0;
361 return VK_SUCCESS;
362}
363
364VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice /*gpu*/,
365 const char* layer_name,
366 uint32_t* count,
367 VkExtensionProperties* properties) {
368 if (layer_name) {
369 ALOGW(
370 "Driver vkEnumerateDeviceExtensionProperties shouldn't be called "
371 "with a layer name ('%s')",
372 layer_name);
373 *count = 0;
374 return VK_SUCCESS;
375 }
376
377 const VkExtensionProperties kExtensions[] = {
378 {VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME,
379 VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION}};
380 const uint32_t kExtensionsCount =
381 sizeof(kExtensions) / sizeof(kExtensions[0]);
382
383 if (!properties || *count > kExtensionsCount)
384 *count = kExtensionsCount;
385 if (properties)
386 std::copy(kExtensions, kExtensions + *count, properties);
387 return *count < kExtensionsCount ? VK_INCOMPLETE : VK_SUCCESS;
388}
389
Jesse Hall606a54e2015-11-19 22:17:28 -0800390void GetPhysicalDeviceProperties(VkPhysicalDevice,
391 VkPhysicalDeviceProperties* properties) {
Jesse Hall26763382016-05-20 07:13:52 -0700392 properties->apiVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION);
Jesse Hall04f4f472015-08-16 19:51:04 -0700393 properties->driverVersion = VK_MAKE_VERSION(0, 0, 1);
Jesse Hall65ab5522015-11-30 00:07:16 -0800394 properties->vendorID = 0;
395 properties->deviceID = 0;
Jesse Hall04f4f472015-08-16 19:51:04 -0700396 properties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER;
397 strcpy(properties->deviceName, "Android Vulkan Null Driver");
398 memset(properties->pipelineCacheUUID, 0,
399 sizeof(properties->pipelineCacheUUID));
Jesse Hallc34849e2016-02-09 22:35:04 -0800400 properties->limits = VkPhysicalDeviceLimits{
401 4096, // maxImageDimension1D
402 4096, // maxImageDimension2D
403 256, // maxImageDimension3D
404 4096, // maxImageDimensionCube
405 256, // maxImageArrayLayers
406 65536, // maxTexelBufferElements
407 16384, // maxUniformBufferRange
408 1 << 27, // maxStorageBufferRange
409 128, // maxPushConstantsSize
410 4096, // maxMemoryAllocationCount
411 4000, // maxSamplerAllocationCount
412 1, // bufferImageGranularity
413 0, // sparseAddressSpaceSize
414 4, // maxBoundDescriptorSets
415 16, // maxPerStageDescriptorSamplers
416 12, // maxPerStageDescriptorUniformBuffers
417 4, // maxPerStageDescriptorStorageBuffers
418 16, // maxPerStageDescriptorSampledImages
419 4, // maxPerStageDescriptorStorageImages
420 4, // maxPerStageDescriptorInputAttachments
421 128, // maxPerStageResources
422 96, // maxDescriptorSetSamplers
423 72, // maxDescriptorSetUniformBuffers
424 8, // maxDescriptorSetUniformBuffersDynamic
425 24, // maxDescriptorSetStorageBuffers
426 4, // maxDescriptorSetStorageBuffersDynamic
427 96, // maxDescriptorSetSampledImages
428 24, // maxDescriptorSetStorageImages
429 4, // maxDescriptorSetInputAttachments
430 16, // maxVertexInputAttributes
431 16, // maxVertexInputBindings
432 2047, // maxVertexInputAttributeOffset
433 2048, // maxVertexInputBindingStride
434 64, // maxVertexOutputComponents
435 0, // maxTessellationGenerationLevel
436 0, // maxTessellationPatchSize
437 0, // maxTessellationControlPerVertexInputComponents
438 0, // maxTessellationControlPerVertexOutputComponents
439 0, // maxTessellationControlPerPatchOutputComponents
440 0, // maxTessellationControlTotalOutputComponents
441 0, // maxTessellationEvaluationInputComponents
442 0, // maxTessellationEvaluationOutputComponents
443 0, // maxGeometryShaderInvocations
444 0, // maxGeometryInputComponents
445 0, // maxGeometryOutputComponents
446 0, // maxGeometryOutputVertices
447 0, // maxGeometryTotalOutputComponents
448 64, // maxFragmentInputComponents
449 4, // maxFragmentOutputAttachments
450 0, // maxFragmentDualSrcAttachments
451 4, // maxFragmentCombinedOutputResources
452 16384, // maxComputeSharedMemorySize
453 {65536, 65536, 65536}, // maxComputeWorkGroupCount[3]
454 128, // maxComputeWorkGroupInvocations
455 {128, 128, 64}, // maxComputeWorkGroupSize[3]
456 4, // subPixelPrecisionBits
457 4, // subTexelPrecisionBits
458 4, // mipmapPrecisionBits
459 UINT32_MAX, // maxDrawIndexedIndexValue
460 1, // maxDrawIndirectCount
461 2, // maxSamplerLodBias
462 1, // maxSamplerAnisotropy
463 1, // maxViewports
464 {4096, 4096}, // maxViewportDimensions[2]
465 {-8192.0f, 8191.0f}, // viewportBoundsRange[2]
466 0, // viewportSubPixelBits
467 64, // minMemoryMapAlignment
468 256, // minTexelBufferOffsetAlignment
469 256, // minUniformBufferOffsetAlignment
470 256, // minStorageBufferOffsetAlignment
471 -8, // minTexelOffset
472 7, // maxTexelOffset
473 0, // minTexelGatherOffset
474 0, // maxTexelGatherOffset
475 0.0f, // minInterpolationOffset
476 0.0f, // maxInterpolationOffset
477 0, // subPixelInterpolationOffsetBits
478 4096, // maxFramebufferWidth
479 4096, // maxFramebufferHeight
480 256, // maxFramebufferLayers
481 VK_SAMPLE_COUNT_1_BIT |
482 VK_SAMPLE_COUNT_4_BIT, // framebufferColorSampleCounts
483 VK_SAMPLE_COUNT_1_BIT |
484 VK_SAMPLE_COUNT_4_BIT, // framebufferDepthSampleCounts
485 VK_SAMPLE_COUNT_1_BIT |
486 VK_SAMPLE_COUNT_4_BIT, // framebufferStencilSampleCounts
487 VK_SAMPLE_COUNT_1_BIT |
488 VK_SAMPLE_COUNT_4_BIT, // framebufferNoAttachmentsSampleCounts
489 4, // maxColorAttachments
490 VK_SAMPLE_COUNT_1_BIT |
491 VK_SAMPLE_COUNT_4_BIT, // sampledImageColorSampleCounts
492 VK_SAMPLE_COUNT_1_BIT, // sampledImageIntegerSampleCounts
493 VK_SAMPLE_COUNT_1_BIT |
494 VK_SAMPLE_COUNT_4_BIT, // sampledImageDepthSampleCounts
495 VK_SAMPLE_COUNT_1_BIT |
496 VK_SAMPLE_COUNT_4_BIT, // sampledImageStencilSampleCounts
497 VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts
498 1, // maxSampleMaskWords
499 VK_TRUE, // timestampComputeAndGraphics
500 1, // timestampPeriod
501 0, // maxClipDistances
502 0, // maxCullDistances
503 0, // maxCombinedClipAndCullDistances
504 2, // discreteQueuePriorities
505 {1.0f, 1.0f}, // pointSizeRange[2]
506 {1.0f, 1.0f}, // lineWidthRange[2]
507 0.0f, // pointSizeGranularity
508 0.0f, // lineWidthGranularity
509 VK_TRUE, // strictLines
510 VK_TRUE, // standardSampleLocations
511 1, // optimalBufferCopyOffsetAlignment
512 1, // optimalBufferCopyRowPitchAlignment
513 64, // nonCoherentAtomSize
514 };
Jesse Hall04f4f472015-08-16 19:51:04 -0700515}
516
Jesse Hall606a54e2015-11-19 22:17:28 -0800517void GetPhysicalDeviceQueueFamilyProperties(
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700518 VkPhysicalDevice,
519 uint32_t* count,
520 VkQueueFamilyProperties* properties) {
Jesse Hall715b86a2016-01-16 16:34:29 -0800521 if (!properties || *count > 1)
522 *count = 1;
523 if (properties && *count == 1) {
Jesse Hall65ab5522015-11-30 00:07:16 -0800524 properties->queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT |
525 VK_QUEUE_TRANSFER_BIT;
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700526 properties->queueCount = 1;
Jesse Hallacfa5342015-11-19 21:51:33 -0800527 properties->timestampValidBits = 64;
Jesse Hall715b86a2016-01-16 16:34:29 -0800528 properties->minImageTransferGranularity = VkExtent3D{1, 1, 1};
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700529 }
Jesse Hall5ae3abb2015-10-08 14:00:22 -0700530}
531
Jesse Hall606a54e2015-11-19 22:17:28 -0800532void GetPhysicalDeviceMemoryProperties(
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100533 VkPhysicalDevice,
534 VkPhysicalDeviceMemoryProperties* properties) {
535 properties->memoryTypeCount = 1;
536 properties->memoryTypes[0].propertyFlags =
Jesse Halld1af8122015-11-29 23:50:38 -0800537 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
538 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
539 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
540 VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100541 properties->memoryTypes[0].heapIndex = 0;
542 properties->memoryHeapCount = 1;
Jesse Hallbde8ee32015-09-01 16:24:29 -0700543 properties->memoryHeaps[0].size = kMaxDeviceMemory;
Jesse Halld1af8122015-11-29 23:50:38 -0800544 properties->memoryHeaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
Jesse Hall04f4f472015-08-16 19:51:04 -0700545}
546
Jesse Hall8e37cf32016-01-18 04:00:57 -0800547void GetPhysicalDeviceFeatures(VkPhysicalDevice /*gpu*/,
548 VkPhysicalDeviceFeatures* features) {
549 *features = VkPhysicalDeviceFeatures{
550 VK_TRUE, // robustBufferAccess
551 VK_FALSE, // fullDrawIndexUint32
552 VK_FALSE, // imageCubeArray
553 VK_FALSE, // independentBlend
554 VK_FALSE, // geometryShader
555 VK_FALSE, // tessellationShader
556 VK_FALSE, // sampleRateShading
557 VK_FALSE, // dualSrcBlend
558 VK_FALSE, // logicOp
559 VK_FALSE, // multiDrawIndirect
560 VK_FALSE, // drawIndirectFirstInstance
561 VK_FALSE, // depthClamp
562 VK_FALSE, // depthBiasClamp
563 VK_FALSE, // fillModeNonSolid
564 VK_FALSE, // depthBounds
565 VK_FALSE, // wideLines
566 VK_FALSE, // largePoints
567 VK_FALSE, // alphaToOne
568 VK_FALSE, // multiViewport
569 VK_FALSE, // samplerAnisotropy
570 VK_FALSE, // textureCompressionETC2
571 VK_FALSE, // textureCompressionASTC_LDR
572 VK_FALSE, // textureCompressionBC
573 VK_FALSE, // occlusionQueryPrecise
574 VK_FALSE, // pipelineStatisticsQuery
575 VK_FALSE, // vertexPipelineStoresAndAtomics
576 VK_FALSE, // fragmentStoresAndAtomics
577 VK_FALSE, // shaderTessellationAndGeometryPointSize
578 VK_FALSE, // shaderImageGatherExtended
579 VK_FALSE, // shaderStorageImageExtendedFormats
580 VK_FALSE, // shaderStorageImageMultisample
581 VK_FALSE, // shaderStorageImageReadWithoutFormat
582 VK_FALSE, // shaderStorageImageWriteWithoutFormat
583 VK_FALSE, // shaderUniformBufferArrayDynamicIndexing
584 VK_FALSE, // shaderSampledImageArrayDynamicIndexing
585 VK_FALSE, // shaderStorageBufferArrayDynamicIndexing
586 VK_FALSE, // shaderStorageImageArrayDynamicIndexing
587 VK_FALSE, // shaderClipDistance
588 VK_FALSE, // shaderCullDistance
589 VK_FALSE, // shaderFloat64
590 VK_FALSE, // shaderInt64
591 VK_FALSE, // shaderInt16
592 VK_FALSE, // shaderResourceResidency
593 VK_FALSE, // shaderResourceMinLod
594 VK_FALSE, // sparseBinding
595 VK_FALSE, // sparseResidencyBuffer
596 VK_FALSE, // sparseResidencyImage2D
597 VK_FALSE, // sparseResidencyImage3D
598 VK_FALSE, // sparseResidency2Samples
599 VK_FALSE, // sparseResidency4Samples
600 VK_FALSE, // sparseResidency8Samples
601 VK_FALSE, // sparseResidency16Samples
602 VK_FALSE, // sparseResidencyAliased
603 VK_FALSE, // variableMultisampleRate
604 VK_FALSE, // inheritedQueries
605 };
606}
607
Jesse Hall73ab0ac2015-08-25 15:09:15 +0100608// -----------------------------------------------------------------------------
609// Device
610
Jesse Hall04f4f472015-08-16 19:51:04 -0700611VkResult CreateDevice(VkPhysicalDevice physical_device,
Jesse Hallb1471272016-01-17 21:36:58 -0800612 const VkDeviceCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800613 const VkAllocationCallbacks* allocator,
Jesse Hall04f4f472015-08-16 19:51:04 -0700614 VkDevice* out_device) {
615 VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800616 if (!allocator)
617 allocator = &instance->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800618 VkDevice_T* device = static_cast<VkDevice_T*>(allocator->pfnAllocation(
619 allocator->pUserData, sizeof(VkDevice_T), alignof(VkDevice_T),
620 VK_SYSTEM_ALLOCATION_SCOPE_DEVICE));
Jesse Hall04f4f472015-08-16 19:51:04 -0700621 if (!device)
622 return VK_ERROR_OUT_OF_HOST_MEMORY;
623
624 device->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800625 device->allocator = *allocator;
Jesse Hall04f4f472015-08-16 19:51:04 -0700626 device->instance = instance;
627 device->queue.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700628 std::fill(device->next_handle.begin(), device->next_handle.end(),
629 UINT64_C(0));
Jesse Hall04f4f472015-08-16 19:51:04 -0700630
Jesse Hallb1471272016-01-17 21:36:58 -0800631 for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
632 if (strcmp(create_info->ppEnabledExtensionNames[i],
633 VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME) == 0) {
634 ALOGV("Enabling " VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME);
635 }
636 }
637
Jesse Hall04f4f472015-08-16 19:51:04 -0700638 *out_device = device;
639 return VK_SUCCESS;
640}
641
Jesse Hall3fbc8562015-11-29 22:10:52 -0800642void DestroyDevice(VkDevice device,
643 const VkAllocationCallbacks* /*allocator*/) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700644 if (!device)
Jesse Hallcf25c412015-10-29 17:14:50 -0700645 return;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800646 device->allocator.pfnFree(device->allocator.pUserData, device);
Jesse Hall04f4f472015-08-16 19:51:04 -0700647}
648
Jesse Hall606a54e2015-11-19 22:17:28 -0800649void GetDeviceQueue(VkDevice device, uint32_t, uint32_t, VkQueue* queue) {
Jesse Hall04f4f472015-08-16 19:51:04 -0700650 *queue = &device->queue;
Jesse Hall04f4f472015-08-16 19:51:04 -0700651}
652
653// -----------------------------------------------------------------------------
Jesse Hall3fbc8562015-11-29 22:10:52 -0800654// CommandPool
Jesse Hall03b6fe12015-11-24 12:44:21 -0800655
Jesse Hall3fbc8562015-11-29 22:10:52 -0800656struct CommandPool {
657 typedef VkCommandPool HandleType;
658 VkAllocationCallbacks allocator;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800659};
Jesse Hall3fbc8562015-11-29 22:10:52 -0800660DEFINE_OBJECT_HANDLE_CONVERSION(CommandPool)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800661
662VkResult CreateCommandPool(VkDevice device,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800663 const VkCommandPoolCreateInfo* /*create_info*/,
664 const VkAllocationCallbacks* allocator,
665 VkCommandPool* cmd_pool) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800666 if (!allocator)
667 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800668 CommandPool* pool = static_cast<CommandPool*>(allocator->pfnAllocation(
669 allocator->pUserData, sizeof(CommandPool), alignof(CommandPool),
670 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall03b6fe12015-11-24 12:44:21 -0800671 if (!pool)
672 return VK_ERROR_OUT_OF_HOST_MEMORY;
673 pool->allocator = *allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800674 *cmd_pool = GetHandleToCommandPool(pool);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800675 return VK_SUCCESS;
676}
677
678void DestroyCommandPool(VkDevice /*device*/,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800679 VkCommandPool cmd_pool,
680 const VkAllocationCallbacks* /*allocator*/) {
681 CommandPool* pool = GetCommandPoolFromHandle(cmd_pool);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800682 pool->allocator.pfnFree(pool->allocator.pUserData, pool);
683}
684
685// -----------------------------------------------------------------------------
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700686// CmdBuffer
687
Jesse Hall3fbc8562015-11-29 22:10:52 -0800688VkResult AllocateCommandBuffers(VkDevice /*device*/,
689 const VkCommandBufferAllocateInfo* alloc_info,
690 VkCommandBuffer* cmdbufs) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800691 VkResult result = VK_SUCCESS;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800692 CommandPool& pool = *GetCommandPoolFromHandle(alloc_info->commandPool);
Jesse Hall3dd678a2016-01-08 21:52:01 -0800693 std::fill(cmdbufs, cmdbufs + alloc_info->commandBufferCount, nullptr);
694 for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) {
Jesse Hall3fbc8562015-11-29 22:10:52 -0800695 cmdbufs[i] =
696 static_cast<VkCommandBuffer_T*>(pool.allocator.pfnAllocation(
697 pool.allocator.pUserData, sizeof(VkCommandBuffer_T),
698 alignof(VkCommandBuffer_T), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hallfbf97b02015-11-20 14:17:03 -0800699 if (!cmdbufs[i]) {
700 result = VK_ERROR_OUT_OF_HOST_MEMORY;
701 break;
702 }
703 cmdbufs[i]->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
704 }
705 if (result != VK_SUCCESS) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800706 for (uint32_t i = 0; i < alloc_info->commandBufferCount; i++) {
Jesse Hallfbf97b02015-11-20 14:17:03 -0800707 if (!cmdbufs[i])
708 break;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800709 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800710 }
711 }
Jesse Hallfbf97b02015-11-20 14:17:03 -0800712 return result;
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700713}
714
Jesse Hall03b6fe12015-11-24 12:44:21 -0800715void FreeCommandBuffers(VkDevice /*device*/,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800716 VkCommandPool cmd_pool,
Jesse Hallfbf97b02015-11-20 14:17:03 -0800717 uint32_t count,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800718 const VkCommandBuffer* cmdbufs) {
719 CommandPool& pool = *GetCommandPoolFromHandle(cmd_pool);
Jesse Hallfbf97b02015-11-20 14:17:03 -0800720 for (uint32_t i = 0; i < count; i++)
Jesse Hall03b6fe12015-11-24 12:44:21 -0800721 pool.allocator.pfnFree(pool.allocator.pUserData, cmdbufs[i]);
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700722}
723
724// -----------------------------------------------------------------------------
Jesse Hall2077ce02015-08-29 18:10:59 +0100725// DeviceMemory
726
727struct DeviceMemory {
728 typedef VkDeviceMemory HandleType;
729 VkDeviceSize size;
730 alignas(16) uint8_t data[0];
731};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800732DEFINE_OBJECT_HANDLE_CONVERSION(DeviceMemory)
Jesse Hall2077ce02015-08-29 18:10:59 +0100733
Jesse Hall3fbc8562015-11-29 22:10:52 -0800734VkResult AllocateMemory(VkDevice device,
735 const VkMemoryAllocateInfo* alloc_info,
736 const VkAllocationCallbacks* allocator,
737 VkDeviceMemory* mem_handle) {
Jesse Hall2077ce02015-08-29 18:10:59 +0100738 if (SIZE_MAX - sizeof(DeviceMemory) <= alloc_info->allocationSize)
739 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall03b6fe12015-11-24 12:44:21 -0800740 if (!allocator)
741 allocator = &device->allocator;
Jesse Hall2077ce02015-08-29 18:10:59 +0100742
Jesse Hall2077ce02015-08-29 18:10:59 +0100743 size_t size = sizeof(DeviceMemory) + size_t(alloc_info->allocationSize);
Jesse Hall3fbc8562015-11-29 22:10:52 -0800744 DeviceMemory* mem = static_cast<DeviceMemory*>(allocator->pfnAllocation(
745 allocator->pUserData, size, alignof(DeviceMemory),
746 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall2077ce02015-08-29 18:10:59 +0100747 if (!mem)
748 return VK_ERROR_OUT_OF_HOST_MEMORY;
749 mem->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800750 *mem_handle = GetHandleToDeviceMemory(mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100751 return VK_SUCCESS;
752}
753
Jesse Hall03b6fe12015-11-24 12:44:21 -0800754void FreeMemory(VkDevice device,
755 VkDeviceMemory mem_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800756 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800757 if (!allocator)
758 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800759 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800760 allocator->pfnFree(allocator->pUserData, mem);
Jesse Hall2077ce02015-08-29 18:10:59 +0100761}
762
763VkResult MapMemory(VkDevice,
764 VkDeviceMemory mem_handle,
765 VkDeviceSize offset,
766 VkDeviceSize,
767 VkMemoryMapFlags,
768 void** out_ptr) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800769 DeviceMemory* mem = GetDeviceMemoryFromHandle(mem_handle);
Jesse Hall2077ce02015-08-29 18:10:59 +0100770 *out_ptr = &mem->data[0] + offset;
771 return VK_SUCCESS;
772}
773
774// -----------------------------------------------------------------------------
Jesse Hallf6578742015-08-29 17:06:12 +0100775// Buffer
776
777struct Buffer {
778 typedef VkBuffer HandleType;
779 VkDeviceSize size;
780};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800781DEFINE_OBJECT_HANDLE_CONVERSION(Buffer)
Jesse Hallf6578742015-08-29 17:06:12 +0100782
783VkResult CreateBuffer(VkDevice device,
784 const VkBufferCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800785 const VkAllocationCallbacks* allocator,
Jesse Hallf6578742015-08-29 17:06:12 +0100786 VkBuffer* buffer_handle) {
Jesse Hallbde8ee32015-09-01 16:24:29 -0700787 ALOGW_IF(create_info->size > kMaxDeviceMemory,
788 "CreateBuffer: requested size 0x%" PRIx64
789 " exceeds max device memory size 0x%" PRIx64,
790 create_info->size, kMaxDeviceMemory);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800791 if (!allocator)
792 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800793 Buffer* buffer = static_cast<Buffer*>(allocator->pfnAllocation(
794 allocator->pUserData, sizeof(Buffer), alignof(Buffer),
795 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hallf6578742015-08-29 17:06:12 +0100796 if (!buffer)
797 return VK_ERROR_OUT_OF_HOST_MEMORY;
798 buffer->size = create_info->size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800799 *buffer_handle = GetHandleToBuffer(buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100800 return VK_SUCCESS;
801}
802
Jesse Hall606a54e2015-11-19 22:17:28 -0800803void GetBufferMemoryRequirements(VkDevice,
804 VkBuffer buffer_handle,
805 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800806 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hallf6578742015-08-29 17:06:12 +0100807 requirements->size = buffer->size;
808 requirements->alignment = 16; // allow fast Neon/SSE memcpy
809 requirements->memoryTypeBits = 0x1;
Jesse Hallf6578742015-08-29 17:06:12 +0100810}
811
Jesse Hall03b6fe12015-11-24 12:44:21 -0800812void DestroyBuffer(VkDevice device,
813 VkBuffer buffer_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800814 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800815 if (!allocator)
816 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800817 Buffer* buffer = GetBufferFromHandle(buffer_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800818 allocator->pfnFree(allocator->pUserData, buffer);
Jesse Hallf6578742015-08-29 17:06:12 +0100819}
820
821// -----------------------------------------------------------------------------
Jesse Hall85c05b62015-09-01 18:07:41 -0700822// Image
823
824struct Image {
825 typedef VkImage HandleType;
826 VkDeviceSize size;
827};
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800828DEFINE_OBJECT_HANDLE_CONVERSION(Image)
Jesse Hall85c05b62015-09-01 18:07:41 -0700829
830VkResult CreateImage(VkDevice device,
831 const VkImageCreateInfo* create_info,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800832 const VkAllocationCallbacks* allocator,
Jesse Hall85c05b62015-09-01 18:07:41 -0700833 VkImage* image_handle) {
834 if (create_info->imageType != VK_IMAGE_TYPE_2D ||
835 create_info->format != VK_FORMAT_R8G8B8A8_UNORM ||
836 create_info->mipLevels != 1) {
837 ALOGE("CreateImage: not yet implemented: type=%d format=%d mips=%u",
838 create_info->imageType, create_info->format,
839 create_info->mipLevels);
Jesse Halla15a4bf2015-11-19 22:48:02 -0800840 return VK_ERROR_OUT_OF_HOST_MEMORY;
Jesse Hall85c05b62015-09-01 18:07:41 -0700841 }
842
843 VkDeviceSize size =
844 VkDeviceSize(create_info->extent.width * create_info->extent.height) *
Jesse Halla15a4bf2015-11-19 22:48:02 -0800845 create_info->arrayLayers * create_info->samples * 4u;
Jesse Hall85c05b62015-09-01 18:07:41 -0700846 ALOGW_IF(size > kMaxDeviceMemory,
847 "CreateImage: image size 0x%" PRIx64
848 " exceeds max device memory size 0x%" PRIx64,
849 size, kMaxDeviceMemory);
850
Jesse Hall03b6fe12015-11-24 12:44:21 -0800851 if (!allocator)
852 allocator = &device->allocator;
Jesse Hall3fbc8562015-11-29 22:10:52 -0800853 Image* image = static_cast<Image*>(allocator->pfnAllocation(
854 allocator->pUserData, sizeof(Image), alignof(Image),
855 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
Jesse Hall85c05b62015-09-01 18:07:41 -0700856 if (!image)
857 return VK_ERROR_OUT_OF_HOST_MEMORY;
858 image->size = size;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800859 *image_handle = GetHandleToImage(image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700860 return VK_SUCCESS;
861}
862
Jesse Hall606a54e2015-11-19 22:17:28 -0800863void GetImageMemoryRequirements(VkDevice,
864 VkImage image_handle,
865 VkMemoryRequirements* requirements) {
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800866 Image* image = GetImageFromHandle(image_handle);
Jesse Hall85c05b62015-09-01 18:07:41 -0700867 requirements->size = image->size;
868 requirements->alignment = 16; // allow fast Neon/SSE memcpy
869 requirements->memoryTypeBits = 0x1;
Jesse Hall85c05b62015-09-01 18:07:41 -0700870}
871
Jesse Hall03b6fe12015-11-24 12:44:21 -0800872void DestroyImage(VkDevice device,
873 VkImage image_handle,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800874 const VkAllocationCallbacks* allocator) {
Jesse Hall03b6fe12015-11-24 12:44:21 -0800875 if (!allocator)
876 allocator = &device->allocator;
Jesse Halla3a7a1d2015-11-24 11:37:23 -0800877 Image* image = GetImageFromHandle(image_handle);
Jesse Hall03b6fe12015-11-24 12:44:21 -0800878 allocator->pfnFree(allocator->pUserData, image);
Jesse Hall85c05b62015-09-01 18:07:41 -0700879}
880
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800881VkResult GetSwapchainGrallocUsageANDROID(VkDevice,
882 VkFormat,
883 VkImageUsageFlags,
884 int* grallocUsage) {
885 // The null driver never reads or writes the gralloc buffer
886 *grallocUsage = 0;
887 return VK_SUCCESS;
888}
889
Chris Forbes8e4438b2016-12-07 16:26:49 +1300890VkResult GetSwapchainGrallocUsage2ANDROID(VkDevice,
891 VkFormat,
892 VkImageUsageFlags,
893 VkSwapchainImageUsageFlagsANDROID,
894 int* grallocUsage) {
895 // The null driver never reads or writes the gralloc buffer
896 *grallocUsage = 0;
897 return VK_SUCCESS;
898}
899
Jesse Hall57f7f8c2016-01-17 17:21:36 -0800900VkResult AcquireImageANDROID(VkDevice,
901 VkImage,
902 int fence,
903 VkSemaphore,
904 VkFence) {
905 close(fence);
906 return VK_SUCCESS;
907}
908
909VkResult QueueSignalReleaseImageANDROID(VkQueue,
910 uint32_t,
911 const VkSemaphore*,
912 VkImage,
913 int* fence) {
914 *fence = -1;
915 return VK_SUCCESS;
916}
917
Jesse Hall85c05b62015-09-01 18:07:41 -0700918// -----------------------------------------------------------------------------
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700919// No-op types
920
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700921VkResult CreateBufferView(VkDevice device,
922 const VkBufferViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800923 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700924 VkBufferView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800925 *view = AllocHandle<VkBufferView>(device, HandleType::kBufferView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700926 return VK_SUCCESS;
927}
928
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700929VkResult CreateDescriptorPool(VkDevice device,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700930 const VkDescriptorPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800931 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700932 VkDescriptorPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800933 *pool = AllocHandle<VkDescriptorPool>(device, HandleType::kDescriptorPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700934 return VK_SUCCESS;
935}
936
Jesse Hall3fbc8562015-11-29 22:10:52 -0800937VkResult AllocateDescriptorSets(VkDevice device,
938 const VkDescriptorSetAllocateInfo* alloc_info,
939 VkDescriptorSet* descriptor_sets) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800940 for (uint32_t i = 0; i < alloc_info->descriptorSetCount; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800941 descriptor_sets[i] =
942 AllocHandle<VkDescriptorSet>(device, HandleType::kDescriptorSet);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700943 return VK_SUCCESS;
944}
945
946VkResult CreateDescriptorSetLayout(VkDevice device,
947 const VkDescriptorSetLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800948 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700949 VkDescriptorSetLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800950 *layout = AllocHandle<VkDescriptorSetLayout>(
951 device, HandleType::kDescriptorSetLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700952 return VK_SUCCESS;
953}
954
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700955VkResult CreateEvent(VkDevice device,
956 const VkEventCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800957 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700958 VkEvent* event) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800959 *event = AllocHandle<VkEvent>(device, HandleType::kEvent);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700960 return VK_SUCCESS;
961}
962
963VkResult CreateFence(VkDevice device,
964 const VkFenceCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800965 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700966 VkFence* fence) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800967 *fence = AllocHandle<VkFence>(device, HandleType::kFence);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700968 return VK_SUCCESS;
969}
970
971VkResult CreateFramebuffer(VkDevice device,
972 const VkFramebufferCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800973 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700974 VkFramebuffer* framebuffer) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800975 *framebuffer = AllocHandle<VkFramebuffer>(device, HandleType::kFramebuffer);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700976 return VK_SUCCESS;
977}
978
979VkResult CreateImageView(VkDevice device,
980 const VkImageViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800981 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700982 VkImageView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800983 *view = AllocHandle<VkImageView>(device, HandleType::kImageView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700984 return VK_SUCCESS;
985}
986
987VkResult CreateGraphicsPipelines(VkDevice device,
988 VkPipelineCache,
989 uint32_t count,
990 const VkGraphicsPipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800991 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700992 VkPipeline* pipelines) {
993 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800994 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700995 return VK_SUCCESS;
996}
997
998VkResult CreateComputePipelines(VkDevice device,
999 VkPipelineCache,
1000 uint32_t count,
1001 const VkComputePipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001002 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001003 VkPipeline* pipelines) {
1004 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -08001005 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001006 return VK_SUCCESS;
1007}
1008
1009VkResult CreatePipelineCache(VkDevice device,
1010 const VkPipelineCacheCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001011 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001012 VkPipelineCache* cache) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001013 *cache = AllocHandle<VkPipelineCache>(device, HandleType::kPipelineCache);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001014 return VK_SUCCESS;
1015}
1016
1017VkResult CreatePipelineLayout(VkDevice device,
1018 const VkPipelineLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001019 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001020 VkPipelineLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001021 *layout =
1022 AllocHandle<VkPipelineLayout>(device, HandleType::kPipelineLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001023 return VK_SUCCESS;
1024}
1025
1026VkResult CreateQueryPool(VkDevice device,
1027 const VkQueryPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001028 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001029 VkQueryPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001030 *pool = AllocHandle<VkQueryPool>(device, HandleType::kQueryPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001031 return VK_SUCCESS;
1032}
1033
1034VkResult CreateRenderPass(VkDevice device,
1035 const VkRenderPassCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001036 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001037 VkRenderPass* renderpass) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001038 *renderpass = AllocHandle<VkRenderPass>(device, HandleType::kRenderPass);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001039 return VK_SUCCESS;
1040}
1041
1042VkResult CreateSampler(VkDevice device,
1043 const VkSamplerCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001044 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001045 VkSampler* sampler) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001046 *sampler = AllocHandle<VkSampler>(device, HandleType::kSampler);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001047 return VK_SUCCESS;
1048}
1049
1050VkResult CreateSemaphore(VkDevice device,
1051 const VkSemaphoreCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001052 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001053 VkSemaphore* semaphore) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001054 *semaphore = AllocHandle<VkSemaphore>(device, HandleType::kSemaphore);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001055 return VK_SUCCESS;
1056}
1057
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001058VkResult CreateShaderModule(VkDevice device,
1059 const VkShaderModuleCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001060 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001061 VkShaderModule* module) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001062 *module = AllocHandle<VkShaderModule>(device, HandleType::kShaderModule);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001063 return VK_SUCCESS;
1064}
1065
Jesse Hall715b86a2016-01-16 16:34:29 -08001066VkResult CreateDebugReportCallbackEXT(VkInstance instance,
1067 const VkDebugReportCallbackCreateInfoEXT*,
1068 const VkAllocationCallbacks*,
1069 VkDebugReportCallbackEXT* callback) {
1070 *callback = AllocHandle<VkDebugReportCallbackEXT>(
1071 instance, HandleType::kDebugReportCallbackEXT);
1072 return VK_SUCCESS;
1073}
1074
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001075// -----------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -07001076// No-op entrypoints
1077
1078// clang-format off
1079#pragma clang diagnostic push
1080#pragma clang diagnostic ignored "-Wunused-parameter"
1081
Jesse Hall606a54e2015-11-19 22:17:28 -08001082void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001083 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001084}
1085
Jesse Halla9e57032015-11-30 01:03:10 -08001086VkResult GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001087 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Halla9e57032015-11-30 01:03:10 -08001088 return VK_SUCCESS;
Jesse Hall04f4f472015-08-16 19:51:04 -07001089}
1090
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001091VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001092 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001093 return VK_SUCCESS;
1094}
1095
Jesse Halla366a512015-11-19 22:30:07 -08001096VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001097 return VK_SUCCESS;
1098}
1099
1100VkResult QueueWaitIdle(VkQueue queue) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001101 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001102 return VK_SUCCESS;
1103}
1104
1105VkResult DeviceWaitIdle(VkDevice device) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001106 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001107 return VK_SUCCESS;
1108}
1109
Jesse Hallcf25c412015-10-29 17:14:50 -07001110void UnmapMemory(VkDevice device, VkDeviceMemory mem) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001111}
1112
1113VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001114 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001115 return VK_SUCCESS;
1116}
1117
1118VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001119 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001120 return VK_SUCCESS;
1121}
1122
Jesse Hall606a54e2015-11-19 22:17:28 -08001123void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001124 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001125}
1126
Jesse Hall04f4f472015-08-16 19:51:04 -07001127VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) {
1128 return VK_SUCCESS;
1129}
1130
Jesse Hall04f4f472015-08-16 19:51:04 -07001131VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) {
1132 return VK_SUCCESS;
1133}
1134
Jesse Hall606a54e2015-11-19 22:17:28 -08001135void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001136 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001137}
1138
Jesse Hall091ed9e2015-11-30 00:55:29 -08001139void 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 +01001140 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001141}
1142
Jesse Halla6429252015-11-29 18:59:42 -08001143VkResult QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001144 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001145 return VK_SUCCESS;
1146}
1147
Jesse Hall3fbc8562015-11-29 22:10:52 -08001148void DestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001149}
1150
1151VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) {
1152 return VK_SUCCESS;
1153}
1154
1155VkResult GetFenceStatus(VkDevice device, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001156 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001157 return VK_SUCCESS;
1158}
1159
1160VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) {
1161 return VK_SUCCESS;
1162}
1163
Jesse Hall3fbc8562015-11-29 22:10:52 -08001164void DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001165}
1166
Jesse Hall3fbc8562015-11-29 22:10:52 -08001167void DestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001168}
1169
1170VkResult GetEventStatus(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001171 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001172 return VK_SUCCESS;
1173}
1174
1175VkResult SetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001176 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001177 return VK_SUCCESS;
1178}
1179
1180VkResult ResetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001181 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001182 return VK_SUCCESS;
1183}
1184
Jesse Hall3fbc8562015-11-29 22:10:52 -08001185void DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001186}
1187
Jesse Halla9bb62b2015-11-21 19:31:56 -08001188VkResult 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 +01001189 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001190 return VK_SUCCESS;
1191}
1192
Jesse Hall3fbc8562015-11-29 22:10:52 -08001193void DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001194}
1195
Jesse Hall606a54e2015-11-19 22:17:28 -08001196void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001197 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001198}
1199
Jesse Hall3fbc8562015-11-29 22:10:52 -08001200void DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001201}
1202
Jesse Hall3fbc8562015-11-29 22:10:52 -08001203void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001204}
1205
Jesse Hall3fbc8562015-11-29 22:10:52 -08001206void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001207}
1208
Jesse Halla9bb62b2015-11-21 19:31:56 -08001209VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001210 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001211 return VK_SUCCESS;
1212}
1213
1214VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001215 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001216 return VK_SUCCESS;
1217}
1218
Jesse Hall3fbc8562015-11-29 22:10:52 -08001219void DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001220}
1221
Jesse Hall3fbc8562015-11-29 22:10:52 -08001222void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001223}
1224
Jesse Hall3fbc8562015-11-29 22:10:52 -08001225void DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001226}
1227
Jesse Hall3fbc8562015-11-29 22:10:52 -08001228void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001229}
1230
Jesse Hall3fbc8562015-11-29 22:10:52 -08001231void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001232}
1233
Jesse Hallfbf97b02015-11-20 14:17:03 -08001234VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001235 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001236 return VK_SUCCESS;
1237}
1238
Jesse Hallcf25c412015-10-29 17:14:50 -07001239void UpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001240 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001241}
1242
1243VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001244 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001245 return VK_SUCCESS;
1246}
1247
Jesse Hall3fbc8562015-11-29 22:10:52 -08001248void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001249}
1250
Jesse Hall3fbc8562015-11-29 22:10:52 -08001251void DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001252}
1253
Jesse Hall606a54e2015-11-19 22:17:28 -08001254void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001255 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001256}
1257
Jesse Hall3fbc8562015-11-29 22:10:52 -08001258VkResult ResetCommandPool(VkDevice device, VkCommandPool cmdPool, VkCommandPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001259 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001260 return VK_SUCCESS;
1261}
1262
Jesse Hall3fbc8562015-11-29 22:10:52 -08001263VkResult BeginCommandBuffer(VkCommandBuffer cmdBuffer, const VkCommandBufferBeginInfo* pBeginInfo) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001264 return VK_SUCCESS;
1265}
1266
Jesse Hall3fbc8562015-11-29 22:10:52 -08001267VkResult EndCommandBuffer(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001268 return VK_SUCCESS;
1269}
1270
Jesse Hall3fbc8562015-11-29 22:10:52 -08001271VkResult ResetCommandBuffer(VkCommandBuffer cmdBuffer, VkCommandBufferResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001272 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001273 return VK_SUCCESS;
1274}
1275
Jesse Hall3fbc8562015-11-29 22:10:52 -08001276void CmdBindPipeline(VkCommandBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001277}
1278
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001279void CmdSetViewport(VkCommandBuffer cmdBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001280}
1281
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001282void CmdSetScissor(VkCommandBuffer cmdBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001283}
1284
Jesse Hall3fbc8562015-11-29 22:10:52 -08001285void CmdSetLineWidth(VkCommandBuffer cmdBuffer, float lineWidth) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001286}
1287
Jesse Hall3fbc8562015-11-29 22:10:52 -08001288void CmdSetDepthBias(VkCommandBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001289}
1290
Jesse Hall3fbc8562015-11-29 22:10:52 -08001291void CmdSetBlendConstants(VkCommandBuffer cmdBuffer, const float blendConst[4]) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001292}
1293
Jesse Hall3fbc8562015-11-29 22:10:52 -08001294void CmdSetDepthBounds(VkCommandBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001295}
1296
Jesse Hall3fbc8562015-11-29 22:10:52 -08001297void CmdSetStencilCompareMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001298}
1299
Jesse Hall3fbc8562015-11-29 22:10:52 -08001300void CmdSetStencilWriteMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001301}
1302
Jesse Hall3fbc8562015-11-29 22:10:52 -08001303void CmdSetStencilReference(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001304}
1305
Jesse Hall3fbc8562015-11-29 22:10:52 -08001306void 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 -07001307}
1308
Jesse Hall3fbc8562015-11-29 22:10:52 -08001309void CmdBindIndexBuffer(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001310}
1311
Jesse Hall3fbc8562015-11-29 22:10:52 -08001312void CmdBindVertexBuffers(VkCommandBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001313}
1314
Jesse Hall3fbc8562015-11-29 22:10:52 -08001315void CmdDraw(VkCommandBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001316}
1317
Jesse Hall3fbc8562015-11-29 22:10:52 -08001318void 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 -07001319}
1320
Jesse Hall3fbc8562015-11-29 22:10:52 -08001321void CmdDrawIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001322}
1323
Jesse Hall3fbc8562015-11-29 22:10:52 -08001324void CmdDrawIndexedIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001325}
1326
Jesse Hall3fbc8562015-11-29 22:10:52 -08001327void CmdDispatch(VkCommandBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001328}
1329
Jesse Hall3fbc8562015-11-29 22:10:52 -08001330void CmdDispatchIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001331}
1332
Jesse Hall3fbc8562015-11-29 22:10:52 -08001333void CmdCopyBuffer(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001334}
1335
Jesse Hall3fbc8562015-11-29 22:10:52 -08001336void CmdCopyImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001337}
1338
Jesse Hall3fbc8562015-11-29 22:10:52 -08001339void 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 -07001340}
1341
Jesse Hall3fbc8562015-11-29 22:10:52 -08001342void CmdCopyBufferToImage(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001343}
1344
Jesse Hall3fbc8562015-11-29 22:10:52 -08001345void CmdCopyImageToBuffer(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001346}
1347
Jesse Hall56d386a2016-07-26 15:20:40 -07001348void CmdUpdateBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const void* pData) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001349}
1350
Jesse Hall3fbc8562015-11-29 22:10:52 -08001351void CmdFillBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001352}
1353
Jesse Hall3fbc8562015-11-29 22:10:52 -08001354void CmdClearColorImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001355}
1356
Jesse Hall3fbc8562015-11-29 22:10:52 -08001357void CmdClearDepthStencilImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001358}
1359
Jesse Hall3fbc8562015-11-29 22:10:52 -08001360void CmdClearAttachments(VkCommandBuffer cmdBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001361}
1362
Jesse Hall3fbc8562015-11-29 22:10:52 -08001363void CmdResolveImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001364}
1365
Jesse Hall3fbc8562015-11-29 22:10:52 -08001366void CmdSetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001367}
1368
Jesse Hall3fbc8562015-11-29 22:10:52 -08001369void CmdResetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001370}
1371
Jesse Hall3dd678a2016-01-08 21:52:01 -08001372void 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 -07001373}
1374
Jesse Hall3dd678a2016-01-08 21:52:01 -08001375void 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 -07001376}
1377
Jesse Hall3fbc8562015-11-29 22:10:52 -08001378void CmdBeginQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001379}
1380
Jesse Hall3fbc8562015-11-29 22:10:52 -08001381void CmdEndQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001382}
1383
Jesse Hall3fbc8562015-11-29 22:10:52 -08001384void CmdResetQueryPool(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001385}
1386
Jesse Hall3fbc8562015-11-29 22:10:52 -08001387void CmdWriteTimestamp(VkCommandBuffer cmdBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001388}
1389
Jesse Hall3fbc8562015-11-29 22:10:52 -08001390void 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 -07001391}
1392
Jesse Hall3fbc8562015-11-29 22:10:52 -08001393void CmdPushConstants(VkCommandBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001394}
1395
Jesse Hall65ab5522015-11-30 00:07:16 -08001396void CmdBeginRenderPass(VkCommandBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001397}
1398
Jesse Hall65ab5522015-11-30 00:07:16 -08001399void CmdNextSubpass(VkCommandBuffer cmdBuffer, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001400}
1401
Jesse Hall3fbc8562015-11-29 22:10:52 -08001402void CmdEndRenderPass(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001403}
1404
Jesse Hall3fbc8562015-11-29 22:10:52 -08001405void CmdExecuteCommands(VkCommandBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCommandBuffer* pCmdBuffers) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001406}
1407
Jesse Hall715b86a2016-01-16 16:34:29 -08001408void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) {
1409}
1410
1411void DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage) {
1412}
1413
Jesse Hall04f4f472015-08-16 19:51:04 -07001414#pragma clang diagnostic pop
1415// clang-format on
1416
1417} // namespace null_driver