blob: 72a4763accbf13cc7ab45c6ae365729b7d210672 [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
26#include <android/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
890VkResult AcquireImageANDROID(VkDevice,
891 VkImage,
892 int fence,
893 VkSemaphore,
894 VkFence) {
895 close(fence);
896 return VK_SUCCESS;
897}
898
899VkResult QueueSignalReleaseImageANDROID(VkQueue,
900 uint32_t,
901 const VkSemaphore*,
902 VkImage,
903 int* fence) {
904 *fence = -1;
905 return VK_SUCCESS;
906}
907
Jesse Hall85c05b62015-09-01 18:07:41 -0700908// -----------------------------------------------------------------------------
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700909// No-op types
910
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700911VkResult CreateBufferView(VkDevice device,
912 const VkBufferViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800913 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700914 VkBufferView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800915 *view = AllocHandle<VkBufferView>(device, HandleType::kBufferView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700916 return VK_SUCCESS;
917}
918
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700919VkResult CreateDescriptorPool(VkDevice device,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700920 const VkDescriptorPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800921 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700922 VkDescriptorPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800923 *pool = AllocHandle<VkDescriptorPool>(device, HandleType::kDescriptorPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700924 return VK_SUCCESS;
925}
926
Jesse Hall3fbc8562015-11-29 22:10:52 -0800927VkResult AllocateDescriptorSets(VkDevice device,
928 const VkDescriptorSetAllocateInfo* alloc_info,
929 VkDescriptorSet* descriptor_sets) {
Jesse Hall3dd678a2016-01-08 21:52:01 -0800930 for (uint32_t i = 0; i < alloc_info->descriptorSetCount; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800931 descriptor_sets[i] =
932 AllocHandle<VkDescriptorSet>(device, HandleType::kDescriptorSet);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700933 return VK_SUCCESS;
934}
935
936VkResult CreateDescriptorSetLayout(VkDevice device,
937 const VkDescriptorSetLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800938 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700939 VkDescriptorSetLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800940 *layout = AllocHandle<VkDescriptorSetLayout>(
941 device, HandleType::kDescriptorSetLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700942 return VK_SUCCESS;
943}
944
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700945VkResult CreateEvent(VkDevice device,
946 const VkEventCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800947 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700948 VkEvent* event) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800949 *event = AllocHandle<VkEvent>(device, HandleType::kEvent);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700950 return VK_SUCCESS;
951}
952
953VkResult CreateFence(VkDevice device,
954 const VkFenceCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800955 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700956 VkFence* fence) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800957 *fence = AllocHandle<VkFence>(device, HandleType::kFence);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700958 return VK_SUCCESS;
959}
960
961VkResult CreateFramebuffer(VkDevice device,
962 const VkFramebufferCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800963 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700964 VkFramebuffer* framebuffer) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800965 *framebuffer = AllocHandle<VkFramebuffer>(device, HandleType::kFramebuffer);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700966 return VK_SUCCESS;
967}
968
969VkResult CreateImageView(VkDevice device,
970 const VkImageViewCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800971 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700972 VkImageView* view) {
Michael Lentine3fec89e2015-12-04 16:25:11 -0800973 *view = AllocHandle<VkImageView>(device, HandleType::kImageView);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700974 return VK_SUCCESS;
975}
976
977VkResult CreateGraphicsPipelines(VkDevice device,
978 VkPipelineCache,
979 uint32_t count,
980 const VkGraphicsPipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800981 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700982 VkPipeline* pipelines) {
983 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800984 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700985 return VK_SUCCESS;
986}
987
988VkResult CreateComputePipelines(VkDevice device,
989 VkPipelineCache,
990 uint32_t count,
991 const VkComputePipelineCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -0800992 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700993 VkPipeline* pipelines) {
994 for (uint32_t i = 0; i < count; i++)
Michael Lentine3fec89e2015-12-04 16:25:11 -0800995 pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
Jesse Hallf8faf0c2015-08-31 11:34:32 -0700996 return VK_SUCCESS;
997}
998
999VkResult CreatePipelineCache(VkDevice device,
1000 const VkPipelineCacheCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001001 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001002 VkPipelineCache* cache) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001003 *cache = AllocHandle<VkPipelineCache>(device, HandleType::kPipelineCache);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001004 return VK_SUCCESS;
1005}
1006
1007VkResult CreatePipelineLayout(VkDevice device,
1008 const VkPipelineLayoutCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001009 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001010 VkPipelineLayout* layout) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001011 *layout =
1012 AllocHandle<VkPipelineLayout>(device, HandleType::kPipelineLayout);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001013 return VK_SUCCESS;
1014}
1015
1016VkResult CreateQueryPool(VkDevice device,
1017 const VkQueryPoolCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001018 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001019 VkQueryPool* pool) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001020 *pool = AllocHandle<VkQueryPool>(device, HandleType::kQueryPool);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001021 return VK_SUCCESS;
1022}
1023
1024VkResult CreateRenderPass(VkDevice device,
1025 const VkRenderPassCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001026 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001027 VkRenderPass* renderpass) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001028 *renderpass = AllocHandle<VkRenderPass>(device, HandleType::kRenderPass);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001029 return VK_SUCCESS;
1030}
1031
1032VkResult CreateSampler(VkDevice device,
1033 const VkSamplerCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001034 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001035 VkSampler* sampler) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001036 *sampler = AllocHandle<VkSampler>(device, HandleType::kSampler);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001037 return VK_SUCCESS;
1038}
1039
1040VkResult CreateSemaphore(VkDevice device,
1041 const VkSemaphoreCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001042 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001043 VkSemaphore* semaphore) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001044 *semaphore = AllocHandle<VkSemaphore>(device, HandleType::kSemaphore);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001045 return VK_SUCCESS;
1046}
1047
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001048VkResult CreateShaderModule(VkDevice device,
1049 const VkShaderModuleCreateInfo*,
Jesse Hall3fbc8562015-11-29 22:10:52 -08001050 const VkAllocationCallbacks* /*allocator*/,
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001051 VkShaderModule* module) {
Michael Lentine3fec89e2015-12-04 16:25:11 -08001052 *module = AllocHandle<VkShaderModule>(device, HandleType::kShaderModule);
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001053 return VK_SUCCESS;
1054}
1055
Jesse Hall715b86a2016-01-16 16:34:29 -08001056VkResult CreateDebugReportCallbackEXT(VkInstance instance,
1057 const VkDebugReportCallbackCreateInfoEXT*,
1058 const VkAllocationCallbacks*,
1059 VkDebugReportCallbackEXT* callback) {
1060 *callback = AllocHandle<VkDebugReportCallbackEXT>(
1061 instance, HandleType::kDebugReportCallbackEXT);
1062 return VK_SUCCESS;
1063}
1064
Jesse Hallf8faf0c2015-08-31 11:34:32 -07001065// -----------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -07001066// No-op entrypoints
1067
1068// clang-format off
1069#pragma clang diagnostic push
1070#pragma clang diagnostic ignored "-Wunused-parameter"
1071
Jesse Hall606a54e2015-11-19 22:17:28 -08001072void GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001073 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001074}
1075
Jesse Halla9e57032015-11-30 01:03:10 -08001076VkResult GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001077 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Halla9e57032015-11-30 01:03:10 -08001078 return VK_SUCCESS;
Jesse Hall04f4f472015-08-16 19:51:04 -07001079}
1080
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001081VkResult EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001082 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001083 return VK_SUCCESS;
1084}
1085
Jesse Halla366a512015-11-19 22:30:07 -08001086VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmitInfo, VkFence fence) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001087 return VK_SUCCESS;
1088}
1089
1090VkResult QueueWaitIdle(VkQueue queue) {
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
1095VkResult DeviceWaitIdle(VkDevice device) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001096 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001097 return VK_SUCCESS;
1098}
1099
Jesse Hallcf25c412015-10-29 17:14:50 -07001100void UnmapMemory(VkDevice device, VkDeviceMemory mem) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001101}
1102
1103VkResult FlushMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001104 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001105 return VK_SUCCESS;
1106}
1107
1108VkResult InvalidateMappedMemoryRanges(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001109 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001110 return VK_SUCCESS;
1111}
1112
Jesse Hall606a54e2015-11-19 22:17:28 -08001113void GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001114 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001115}
1116
Jesse Hall04f4f472015-08-16 19:51:04 -07001117VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset) {
1118 return VK_SUCCESS;
1119}
1120
Jesse Hall04f4f472015-08-16 19:51:04 -07001121VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) {
1122 return VK_SUCCESS;
1123}
1124
Jesse Hall606a54e2015-11-19 22:17:28 -08001125void GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001126 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001127}
1128
Jesse Hall091ed9e2015-11-30 00:55:29 -08001129void 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 +01001130 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001131}
1132
Jesse Halla6429252015-11-29 18:59:42 -08001133VkResult QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001134 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001135 return VK_SUCCESS;
1136}
1137
Jesse Hall3fbc8562015-11-29 22:10:52 -08001138void DestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001139}
1140
1141VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) {
1142 return VK_SUCCESS;
1143}
1144
1145VkResult GetFenceStatus(VkDevice device, VkFence fence) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001146 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001147 return VK_SUCCESS;
1148}
1149
1150VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) {
1151 return VK_SUCCESS;
1152}
1153
Jesse Hall3fbc8562015-11-29 22:10:52 -08001154void DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001155}
1156
Jesse Hall3fbc8562015-11-29 22:10:52 -08001157void DestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001158}
1159
1160VkResult GetEventStatus(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001161 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001162 return VK_SUCCESS;
1163}
1164
1165VkResult SetEvent(VkDevice device, VkEvent event) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001166 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001167 return VK_SUCCESS;
1168}
1169
1170VkResult ResetEvent(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
Jesse Hall3fbc8562015-11-29 22:10:52 -08001175void DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001176}
1177
Jesse Halla9bb62b2015-11-21 19:31:56 -08001178VkResult 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 +01001179 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001180 return VK_SUCCESS;
1181}
1182
Jesse Hall3fbc8562015-11-29 22:10:52 -08001183void DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001184}
1185
Jesse Hall606a54e2015-11-19 22:17:28 -08001186void GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001187 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001188}
1189
Jesse Hall3fbc8562015-11-29 22:10:52 -08001190void DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001191}
1192
Jesse Hall3fbc8562015-11-29 22:10:52 -08001193void DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001194}
1195
Jesse Hall3fbc8562015-11-29 22:10:52 -08001196void DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001197}
1198
Jesse Halla9bb62b2015-11-21 19:31:56 -08001199VkResult GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001200 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001201 return VK_SUCCESS;
1202}
1203
1204VkResult MergePipelineCaches(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001205 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001206 return VK_SUCCESS;
1207}
1208
Jesse Hall3fbc8562015-11-29 22:10:52 -08001209void DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001210}
1211
Jesse Hall3fbc8562015-11-29 22:10:52 -08001212void DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001213}
1214
Jesse Hall3fbc8562015-11-29 22:10:52 -08001215void DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001216}
1217
Jesse Hall3fbc8562015-11-29 22:10:52 -08001218void DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001219}
1220
Jesse Hall3fbc8562015-11-29 22:10:52 -08001221void DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001222}
1223
Jesse Hallfbf97b02015-11-20 14:17:03 -08001224VkResult ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001225 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001226 return VK_SUCCESS;
1227}
1228
Jesse Hallcf25c412015-10-29 17:14:50 -07001229void UpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001230 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001231}
1232
1233VkResult FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) {
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 Hall3fbc8562015-11-29 22:10:52 -08001238void DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001239}
1240
Jesse Hall3fbc8562015-11-29 22:10:52 -08001241void DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* allocator) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001242}
1243
Jesse Hall606a54e2015-11-19 22:17:28 -08001244void GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001245 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001246}
1247
Jesse Hall3fbc8562015-11-29 22:10:52 -08001248VkResult ResetCommandPool(VkDevice device, VkCommandPool cmdPool, VkCommandPoolResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001249 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001250 return VK_SUCCESS;
1251}
1252
Jesse Hall3fbc8562015-11-29 22:10:52 -08001253VkResult BeginCommandBuffer(VkCommandBuffer cmdBuffer, const VkCommandBufferBeginInfo* pBeginInfo) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001254 return VK_SUCCESS;
1255}
1256
Jesse Hall3fbc8562015-11-29 22:10:52 -08001257VkResult EndCommandBuffer(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001258 return VK_SUCCESS;
1259}
1260
Jesse Hall3fbc8562015-11-29 22:10:52 -08001261VkResult ResetCommandBuffer(VkCommandBuffer cmdBuffer, VkCommandBufferResetFlags flags) {
Jesse Hall73ab0ac2015-08-25 15:09:15 +01001262 ALOGV("TODO: vk%s", __FUNCTION__);
Jesse Hall04f4f472015-08-16 19:51:04 -07001263 return VK_SUCCESS;
1264}
1265
Jesse Hall3fbc8562015-11-29 22:10:52 -08001266void CmdBindPipeline(VkCommandBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001267}
1268
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001269void CmdSetViewport(VkCommandBuffer cmdBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001270}
1271
Jesse Hallf9fa9a52016-01-08 16:08:51 -08001272void CmdSetScissor(VkCommandBuffer cmdBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001273}
1274
Jesse Hall3fbc8562015-11-29 22:10:52 -08001275void CmdSetLineWidth(VkCommandBuffer cmdBuffer, float lineWidth) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001276}
1277
Jesse Hall3fbc8562015-11-29 22:10:52 -08001278void CmdSetDepthBias(VkCommandBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001279}
1280
Jesse Hall3fbc8562015-11-29 22:10:52 -08001281void CmdSetBlendConstants(VkCommandBuffer cmdBuffer, const float blendConst[4]) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001282}
1283
Jesse Hall3fbc8562015-11-29 22:10:52 -08001284void CmdSetDepthBounds(VkCommandBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001285}
1286
Jesse Hall3fbc8562015-11-29 22:10:52 -08001287void CmdSetStencilCompareMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001288}
1289
Jesse Hall3fbc8562015-11-29 22:10:52 -08001290void CmdSetStencilWriteMask(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask) {
Jesse Hall5ae3abb2015-10-08 14:00:22 -07001291}
1292
Jesse Hall3fbc8562015-11-29 22:10:52 -08001293void CmdSetStencilReference(VkCommandBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001294}
1295
Jesse Hall3fbc8562015-11-29 22:10:52 -08001296void 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 -07001297}
1298
Jesse Hall3fbc8562015-11-29 22:10:52 -08001299void CmdBindIndexBuffer(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001300}
1301
Jesse Hall3fbc8562015-11-29 22:10:52 -08001302void CmdBindVertexBuffers(VkCommandBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001303}
1304
Jesse Hall3fbc8562015-11-29 22:10:52 -08001305void CmdDraw(VkCommandBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001306}
1307
Jesse Hall3fbc8562015-11-29 22:10:52 -08001308void 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 -07001309}
1310
Jesse Hall3fbc8562015-11-29 22:10:52 -08001311void CmdDrawIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001312}
1313
Jesse Hall3fbc8562015-11-29 22:10:52 -08001314void CmdDrawIndexedIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001315}
1316
Jesse Hall3fbc8562015-11-29 22:10:52 -08001317void CmdDispatch(VkCommandBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001318}
1319
Jesse Hall3fbc8562015-11-29 22:10:52 -08001320void CmdDispatchIndirect(VkCommandBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001321}
1322
Jesse Hall3fbc8562015-11-29 22:10:52 -08001323void CmdCopyBuffer(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001324}
1325
Jesse Hall3fbc8562015-11-29 22:10:52 -08001326void CmdCopyImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001327}
1328
Jesse Hall3fbc8562015-11-29 22:10:52 -08001329void 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 -07001330}
1331
Jesse Hall3fbc8562015-11-29 22:10:52 -08001332void CmdCopyBufferToImage(VkCommandBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001333}
1334
Jesse Hall3fbc8562015-11-29 22:10:52 -08001335void CmdCopyImageToBuffer(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001336}
1337
Jesse Hall3fbc8562015-11-29 22:10:52 -08001338void CmdUpdateBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001339}
1340
Jesse Hall3fbc8562015-11-29 22:10:52 -08001341void CmdFillBuffer(VkCommandBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001342}
1343
Jesse Hall3fbc8562015-11-29 22:10:52 -08001344void CmdClearColorImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001345}
1346
Jesse Hall3fbc8562015-11-29 22:10:52 -08001347void CmdClearDepthStencilImage(VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001348}
1349
Jesse Hall3fbc8562015-11-29 22:10:52 -08001350void CmdClearAttachments(VkCommandBuffer cmdBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001351}
1352
Jesse Hall3fbc8562015-11-29 22:10:52 -08001353void CmdResolveImage(VkCommandBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001354}
1355
Jesse Hall3fbc8562015-11-29 22:10:52 -08001356void CmdSetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001357}
1358
Jesse Hall3fbc8562015-11-29 22:10:52 -08001359void CmdResetEvent(VkCommandBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001360}
1361
Jesse Hall3dd678a2016-01-08 21:52:01 -08001362void 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 -07001363}
1364
Jesse Hall3dd678a2016-01-08 21:52:01 -08001365void 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 -07001366}
1367
Jesse Hall3fbc8562015-11-29 22:10:52 -08001368void CmdBeginQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001369}
1370
Jesse Hall3fbc8562015-11-29 22:10:52 -08001371void CmdEndQuery(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001372}
1373
Jesse Hall3fbc8562015-11-29 22:10:52 -08001374void CmdResetQueryPool(VkCommandBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001375}
1376
Jesse Hall3fbc8562015-11-29 22:10:52 -08001377void CmdWriteTimestamp(VkCommandBuffer cmdBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001378}
1379
Jesse Hall3fbc8562015-11-29 22:10:52 -08001380void 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 -07001381}
1382
Jesse Hall3fbc8562015-11-29 22:10:52 -08001383void CmdPushConstants(VkCommandBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001384}
1385
Jesse Hall65ab5522015-11-30 00:07:16 -08001386void CmdBeginRenderPass(VkCommandBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001387}
1388
Jesse Hall65ab5522015-11-30 00:07:16 -08001389void CmdNextSubpass(VkCommandBuffer cmdBuffer, VkSubpassContents contents) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001390}
1391
Jesse Hall3fbc8562015-11-29 22:10:52 -08001392void CmdEndRenderPass(VkCommandBuffer cmdBuffer) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001393}
1394
Jesse Hall3fbc8562015-11-29 22:10:52 -08001395void CmdExecuteCommands(VkCommandBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCommandBuffer* pCmdBuffers) {
Jesse Hall04f4f472015-08-16 19:51:04 -07001396}
1397
Jesse Hall715b86a2016-01-16 16:34:29 -08001398void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator) {
1399}
1400
1401void DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage) {
1402}
1403
Jesse Hall04f4f472015-08-16 19:51:04 -07001404#pragma clang diagnostic pop
1405// clang-format on
1406
1407} // namespace null_driver