31
32
if (queue->sync_fence != VK_NULL_HANDLE) {
32
33
vn_DestroyFence(dev_handle, queue->sync_fence, NULL);
35
if (queue->sparse_semaphore != VK_NULL_HANDLE) {
36
vn_DestroySemaphore(dev_handle, queue->sparse_semaphore, NULL);
34
38
vn_object_base_fini(&queue->base);
163
167
vk_free(&dev->base.base.alloc, dev->queue_families);
171
vn_device_memory_report_init(struct vn_device *dev,
172
const VkDeviceCreateInfo *create_info)
174
const struct vk_features *app_feats = &dev->base.base.enabled_features;
175
if (!app_feats->deviceMemoryReport)
179
vk_foreach_struct_const(pnext, create_info->pNext) {
181
VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT)
185
struct vn_device_memory_report *mem_reports = NULL;
188
vk_alloc(&dev->base.base.alloc, sizeof(*mem_reports) * count,
189
VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
191
return VK_ERROR_OUT_OF_HOST_MEMORY;
195
vk_foreach_struct_const(pnext, create_info->pNext) {
197
VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT) {
198
const struct VkDeviceDeviceMemoryReportCreateInfoEXT *report =
200
mem_reports[count].callback = report->pfnUserCallback;
201
mem_reports[count].data = report->pUserData;
206
dev->memory_report_count = count;
207
dev->memory_reports = mem_reports;
213
vn_device_memory_report_fini(struct vn_device *dev)
215
vk_free(&dev->base.base.alloc, dev->memory_reports);
167
219
find_extension_names(const char *const *exts,
168
220
uint32_t ext_count,
290
342
extra_exts[extra_count++] = VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME;
345
if (app_exts->EXT_device_memory_report) {
346
/* see vn_physical_device_get_native_extensions */
347
block_exts[block_count++] = VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME;
293
350
if (app_exts->EXT_physical_device_drm) {
294
351
/* see vn_physical_device_get_native_extensions */
295
352
block_exts[block_count++] = VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME;
363
420
#if !defined(ANDROID) && defined(ENABLE_SHADER_CACHE)
364
421
const VkPhysicalDeviceProperties *vulkan_1_0_props =
365
422
&dev->physical_device->properties.vulkan_1_0;
366
struct mesa_sha1 sha1_ctx;
367
uint8_t sha1[SHA1_DIGEST_LENGTH];
369
_mesa_sha1_init(&sha1_ctx);
370
_mesa_sha1_update(&sha1_ctx, vulkan_1_0_props->pipelineCacheUUID,
371
sizeof(vulkan_1_0_props->pipelineCacheUUID));
372
_mesa_sha1_update(&sha1_ctx, &vulkan_1_0_props->vendorID,
373
sizeof(vulkan_1_0_props->vendorID));
374
_mesa_sha1_update(&sha1_ctx, &vulkan_1_0_props->deviceID,
375
sizeof(vulkan_1_0_props->deviceID));
376
_mesa_sha1_final(&sha1_ctx, sha1);
378
char uuid[VK_UUID_SIZE];
379
_mesa_sha1_format(uuid, sha1);
424
char uuid[VK_UUID_SIZE * 2 + 1];
425
mesa_bytes_to_hex(uuid, vulkan_1_0_props->pipelineCacheUUID, VK_UUID_SIZE);
381
427
struct disk_cache *cache = disk_cache_create("venus", uuid, 0);
427
473
if (result != VK_SUCCESS)
476
result = vn_device_memory_report_init(dev, create_info);
477
if (result != VK_SUCCESS)
478
goto out_destroy_device;
430
480
if (!vn_device_queue_family_init(dev, create_info)) {
431
481
result = VK_ERROR_OUT_OF_HOST_MEMORY;
432
goto out_destroy_device;
482
goto out_memory_report_fini;
435
485
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++) {
437
487
mtx_init(&pool->mutex, mtx_plain);
440
result = vn_buffer_cache_init(dev);
490
result = vn_device_feedback_pool_init(dev);
441
491
if (result != VK_SUCCESS)
442
492
goto out_memory_pool_fini;
444
result = vn_device_feedback_pool_init(dev);
445
if (result != VK_SUCCESS)
446
goto out_buffer_cache_fini;
448
494
result = vn_feedback_cmd_pools_init(dev);
449
495
if (result != VK_SUCCESS)
450
496
goto out_feedback_pool_fini;
466
514
out_feedback_pool_fini:
467
515
vn_device_feedback_pool_fini(dev);
469
out_buffer_cache_fini:
470
vn_buffer_cache_fini(dev);
472
517
out_memory_pool_fini:
473
518
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++)
474
519
vn_device_memory_pool_fini(dev, i);
476
521
vn_device_queue_family_fini(dev);
523
out_memory_report_fini:
524
vn_device_memory_report_fini(dev);
478
526
out_destroy_device:
479
527
vn_call_vkDestroyDevice(instance, dev_handle, NULL);
549
599
vn_device_feedback_pool_fini(dev);
551
vn_buffer_cache_fini(dev);
553
601
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++)
554
602
vn_device_memory_pool_fini(dev, i);
556
604
vn_device_queue_family_fini(dev);
606
vn_device_memory_report_fini(dev);
558
608
/* We must emit vkDestroyDevice before freeing dev->queues. Otherwise,
559
609
* another thread might reuse their object ids while they still refer to
560
610
* the queues in the renderer.