venus: stop using vn_renderer_sync in vn_queue

Move away from vn_renderer_sync and toward a userspace-only solution
temporarily until the kernel does what we need.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10146>
This commit is contained in:
Chia-I Wu
2021-04-01 14:00:21 -07:00
committed by Marge Bot
parent 6d2454ad3c
commit 0d848dcb0d
3 changed files with 28 additions and 36 deletions
+20 -9
View File
@@ -2835,6 +2835,16 @@ vn_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
return VK_SUCCESS;
}
static void
vn_queue_fini(struct vn_queue *queue)
{
if (queue->wait_fence != VK_NULL_HANDLE) {
vn_DestroyFence(vn_device_to_handle(queue->device), queue->wait_fence,
NULL);
}
vn_object_base_fini(&queue->base);
}
static VkResult
vn_queue_init(struct vn_device *dev,
struct vn_queue *queue,
@@ -2863,7 +2873,11 @@ vn_queue_init(struct vn_device *dev,
queue->sync_queue_index = sync_queue_index;
VkResult result =
vn_renderer_sync_create_cpu(dev->instance->renderer, &queue->idle_sync);
vn_CreateFence(vn_device_to_handle(dev),
&(const VkFenceCreateInfo){
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
},
NULL, &queue->wait_fence);
if (result != VK_SUCCESS)
return result;
@@ -2908,7 +2922,7 @@ vn_device_init_queues(struct vn_device *dev,
if (result != VK_SUCCESS) {
for (uint32_t i = 0; i < count; i++)
vn_renderer_sync_destroy(queues[i].idle_sync);
vn_queue_fini(&queues[i]);
vk_free(alloc, queues);
return result;
@@ -3068,15 +3082,12 @@ vn_DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++)
vn_device_memory_pool_fini(dev, i);
vn_async_vkDestroyDevice(dev->instance, device, NULL);
for (uint32_t i = 0; i < dev->queue_count; i++) {
struct vn_queue *queue = &dev->queues[i];
vn_renderer_sync_destroy(queue->idle_sync);
vn_object_base_fini(&queue->base);
}
for (uint32_t i = 0; i < dev->queue_count; i++)
vn_queue_fini(&dev->queues[i]);
vk_free(alloc, dev->queues);
vn_async_vkDestroyDevice(dev->instance, device, NULL);
vn_device_base_fini(&dev->base);
vk_free(alloc, dev);
}
+7 -25
View File
@@ -494,34 +494,16 @@ VkResult
vn_QueueWaitIdle(VkQueue _queue)
{
struct vn_queue *queue = vn_queue_from_handle(_queue);
struct vn_device *dev = queue->device;
struct vn_renderer *renderer = dev->instance->renderer;
VkDevice device = vn_device_to_handle(queue->device);
vn_instance_ring_wait(dev->instance);
VkResult result = vn_QueueSubmit(_queue, 0, NULL, queue->wait_fence);
if (result != VK_SUCCESS)
return result;
const uint64_t val = ++queue->idle_sync_value;
const struct vn_renderer_submit submit = {
.batches =
&(const struct vn_renderer_submit_batch){
.sync_queue_index = queue->sync_queue_index,
.vk_queue_id = queue->base.id,
.syncs = &queue->idle_sync,
.sync_values = &val,
.sync_count = 1,
},
.batch_count = 1,
};
vn_renderer_submit(renderer, &submit);
result = vn_WaitForFences(device, 1, &queue->wait_fence, true, UINT64_MAX);
vn_ResetFences(device, 1, &queue->wait_fence);
const struct vn_renderer_wait wait = {
.timeout = UINT64_MAX,
.syncs = &queue->idle_sync,
.sync_values = &val,
.sync_count = 1,
};
VkResult result = vn_renderer_wait(renderer, &wait);
return vn_result(dev->instance, result);
return vn_result(queue->device->instance, result);
}
/* fence commands */
+1 -2
View File
@@ -23,8 +23,7 @@ struct vn_queue {
uint32_t sync_queue_index;
struct vn_renderer_sync *idle_sync;
uint64_t idle_sync_value;
VkFence wait_fence;
};
VK_DEFINE_HANDLE_CASTS(vn_queue, base.base, VkQueue, VK_OBJECT_TYPE_QUEUE)