mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-16 22:20:29 +01:00
zink: Make screen->queue_lock a pointer
Fixes: 015eda4a41 ("zink: deduplicate VkDevice and VkInstance")
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38414>
This commit is contained in:
parent
f0dc8c0224
commit
dff1b9d4e9
6 changed files with 24 additions and 22 deletions
|
|
@ -795,7 +795,7 @@ submit_queue(void *data, void *gdata, int thread_index)
|
|||
);
|
||||
}
|
||||
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
VRAM_ALLOC_LOOP(result,
|
||||
VKSCR(QueueSubmit)(screen->queue, num_si, submit, VK_NULL_HANDLE),
|
||||
if (result != VK_SUCCESS) {
|
||||
|
|
@ -803,7 +803,7 @@ submit_queue(void *data, void *gdata, int thread_index)
|
|||
bs->is_device_lost = true;
|
||||
}
|
||||
);
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
|
||||
unsigned i = 0;
|
||||
VkSemaphore *sem = bs->signal_semaphores.data;
|
||||
|
|
|
|||
|
|
@ -783,11 +783,11 @@ init_timeline_wait(struct zink_context *ctx, struct zink_resource *res, bool com
|
|||
|
||||
if (zink_resource_usage_is_unflushed(res) && !zink_resource_usage_matches(res, ctx->bs)) {
|
||||
/* assuming this is a batch that is doing an async submit: unlock wait for that to finish */
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
/* note that this can deadlock if multi-context */
|
||||
zink_resource_usage_unflushed_wait(ctx, res, ZINK_RESOURCE_ACCESS_RW);
|
||||
/* make sure to lock again and take queue ownership */
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
}
|
||||
*wait = screen->sem;
|
||||
timeline.pWaitSemaphoreValues = &screen->curr_batch;
|
||||
|
|
@ -1024,7 +1024,7 @@ zink_bo_commit(struct zink_context *ctx, struct zink_resource *res, unsigned lev
|
|||
struct zink_bo *bo = res->obj->bo;
|
||||
VkSemaphore cur_sem = *sem;
|
||||
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
simple_mtx_lock(&bo->lock);
|
||||
if (res->base.b.target == PIPE_BUFFER) {
|
||||
ok = buffer_bo_commit(ctx, res, box->x, box->width, commit, &cur_sem);
|
||||
|
|
@ -1242,7 +1242,7 @@ zink_bo_commit(struct zink_context *ctx, struct zink_resource *res, unsigned lev
|
|||
out:
|
||||
|
||||
simple_mtx_unlock(&bo->lock);
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
*sem = cur_sem;
|
||||
return ok;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,17 +125,17 @@ zink_context_destroy(struct pipe_context *pctx)
|
|||
if (util_queue_is_initialized(&screen->flush_queue))
|
||||
util_queue_finish(&screen->flush_queue);
|
||||
if (ctx->bs && !screen->device_lost) {
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
VkResult result = VKSCR(QueueWaitIdle)(screen->queue);
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
mesa_loge("ZINK: vkQueueWaitIdle failed (%s)", vk_Result_to_str(result));
|
||||
|
||||
if (screen->queue_sparse && screen->queue_sparse != screen->queue) {
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
VkResult result = VKSCR(QueueWaitIdle)(screen->queue_sparse);
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
mesa_loge("ZINK: vkQueueWaitIdle failed (%s)", vk_Result_to_str(result));
|
||||
|
|
|
|||
|
|
@ -349,9 +349,9 @@ kopper_CreateSwapchain(struct zink_screen *screen, struct kopper_displaytarget *
|
|||
if (error == VK_ERROR_NATIVE_WINDOW_IN_USE_KHR) {
|
||||
if (cdt->async)
|
||||
util_queue_finish(&screen->flush_queue);
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
VkResult wait_result = VKSCR(QueueWaitIdle)(screen->queue);
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
if (wait_result != VK_SUCCESS)
|
||||
mesa_loge("ZINK: vkQueueWaitIdle failed (%s)", vk_Result_to_str(wait_result));
|
||||
error = VKSCR(CreateSwapchainKHR)(screen->dev, &cswap->scci, NULL,
|
||||
|
|
@ -754,7 +754,7 @@ kopper_present(void *data, void *gdata, int thread_idx)
|
|||
VkResult error = VK_SUCCESS;
|
||||
cpi->info.pResults = &error;
|
||||
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
if (screen->driver_workarounds.implicit_sync && cdt->type != KOPPER_WIN32) {
|
||||
if (!screen->fence) {
|
||||
VkFenceCreateInfo fci = {0};
|
||||
|
|
@ -771,13 +771,13 @@ kopper_present(void *data, void *gdata, int thread_idx)
|
|||
|
||||
error = VKSCR(QueueSubmit)(screen->queue, 1, &si, screen->fence);
|
||||
if (!zink_screen_handle_vkresult(screen, error)) {
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
VKSCR(DestroySemaphore)(screen->dev, cpi->sem, NULL);
|
||||
goto out;
|
||||
}
|
||||
error = VKSCR(WaitForFences)(screen->dev, 1, &screen->fence, VK_TRUE, UINT64_MAX);
|
||||
if (!zink_screen_handle_vkresult(screen, error)) {
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
VKSCR(DestroySemaphore)(screen->dev, cpi->sem, NULL);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -787,7 +787,7 @@ kopper_present(void *data, void *gdata, int thread_idx)
|
|||
VkResult error2 = VKSCR(QueuePresentKHR)(screen->queue, &cpi->info);
|
||||
zink_screen_debug_marker_end(screen, screen->frame_marker_emitted);
|
||||
zink_screen_debug_marker_begin(screen, "frame");
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
swapchain->last_present = cpi->image;
|
||||
if (cpi->indefinite_acquire)
|
||||
p_atomic_dec(&swapchain->num_acquires);
|
||||
|
|
@ -1067,9 +1067,9 @@ zink_kopper_present_readback(struct zink_context *ctx, struct zink_resource *res
|
|||
si.waitSemaphoreCount = !!acquire;
|
||||
si.pWaitSemaphores = &acquire;
|
||||
si.pSignalSemaphores = &present;
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
VkResult error = VKSCR(QueueSubmit)(screen->queue, 1, &si, VK_NULL_HANDLE);
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
if (!zink_screen_handle_vkresult(screen, error))
|
||||
return false;
|
||||
|
||||
|
|
@ -1077,9 +1077,9 @@ zink_kopper_present_readback(struct zink_context *ctx, struct zink_resource *res
|
|||
if (cdt->async)
|
||||
util_queue_fence_wait(&cdt->swapchain->present_fence);
|
||||
|
||||
simple_mtx_lock(&screen->queue_lock);
|
||||
simple_mtx_lock(screen->queue_lock);
|
||||
error = VKSCR(QueueWaitIdle)(screen->queue);
|
||||
simple_mtx_unlock(&screen->queue_lock);
|
||||
simple_mtx_unlock(screen->queue_lock);
|
||||
|
||||
simple_mtx_lock(&screen->semaphores_lock);
|
||||
util_dynarray_append(&screen->semaphores, acquire);
|
||||
|
|
|
|||
|
|
@ -1832,7 +1832,8 @@ update_queue_props(struct zink_screen *screen)
|
|||
static void
|
||||
init_queue(struct zink_screen *screen)
|
||||
{
|
||||
simple_mtx_init(&screen->queue_lock, mtx_plain);
|
||||
simple_mtx_init(&screen->queue_lock_storage, mtx_plain);
|
||||
screen->queue_lock = &screen->queue_lock_storage;
|
||||
VKSCR(GetDeviceQueue)(screen->dev, screen->gfx_queue, 0, &screen->queue);
|
||||
if (screen->sparse_queue != screen->gfx_queue)
|
||||
VKSCR(GetDeviceQueue)(screen->dev, screen->sparse_queue, 0, &screen->queue_sparse);
|
||||
|
|
|
|||
|
|
@ -1480,7 +1480,8 @@ struct zink_screen {
|
|||
VkDevice dev;
|
||||
VkQueue queue; //gfx+compute
|
||||
VkQueue queue_sparse;
|
||||
simple_mtx_t queue_lock;
|
||||
simple_mtx_t *queue_lock;
|
||||
simple_mtx_t queue_lock_storage;
|
||||
VkDebugUtilsMessengerEXT debugUtilsCallbackHandle;
|
||||
|
||||
uint32_t cur_custom_border_color_samplers;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue