summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-03-22 11:36:18 -0400
committerMarge Bot <eric+marge@anholt.net>2021-03-30 15:12:59 +0000
commitdc5d02ca545552e037b3b755a15bbd5a28bca65b (patch)
tree97a319e121f7f7ae867c12faa7d6425be6655c7f
parent38c5e154dfd5773f9e3a673d8ca0d5b35c6d0c24 (diff)
zink: break out queue submit into separate functions
to be used with async submission Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9885>
-rw-r--r--src/gallium/drivers/zink/zink_batch.c73
-rw-r--r--src/gallium/drivers/zink/zink_batch.h3
2 files changed, 47 insertions, 29 deletions
diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index eeffef7b7eb..2ea6e27b028 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -258,6 +258,46 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
zink_resume_queries(ctx, batch);
}
+static void
+post_submit(void *data, int thread_index)
+{
+ struct zink_batch_state *bs = data;
+
+ if (bs->is_device_lost && bs->ctx->reset.reset)
+ bs->ctx->reset.reset(bs->ctx->reset.data, PIPE_GUILTY_CONTEXT_RESET);
+}
+
+static void
+submit_queue(void *data, int thread_index)
+{
+ struct zink_batch_state *bs = data;
+ VkSubmitInfo si = {};
+ si.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ si.waitSemaphoreCount = 0;
+ si.pWaitSemaphores = NULL;
+ si.signalSemaphoreCount = 0;
+ si.pSignalSemaphores = NULL;
+ si.pWaitDstStageMask = NULL;
+ si.commandBufferCount = 1;
+ si.pCommandBuffers = &bs->cmdbuf;
+
+ struct wsi_memory_signal_submit_info mem_signal = {
+ .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA,
+ .pNext = si.pNext,
+ };
+
+ if (bs->flush_res) {
+ mem_signal.memory = bs->flush_res->obj->mem;
+ si.pNext = &mem_signal;
+ }
+
+ if (vkQueueSubmit(bs->queue, 1, &si, bs->fence.fence) != VK_SUCCESS) {
+ debug_printf("ZINK: vkQueueSubmit() failed\n");
+ bs->is_device_lost = true;
+ }
+ p_atomic_set(&bs->fence.submitted, true);
+}
+
void
zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
{
@@ -283,40 +323,15 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
vkFlushMappedMemoryRanges(screen->dev, 1, &range);
}
- VkSubmitInfo si = {};
- si.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- si.waitSemaphoreCount = 0;
- si.pWaitSemaphores = NULL;
- si.signalSemaphoreCount = 0;
- si.pSignalSemaphores = NULL;
- si.pWaitDstStageMask = NULL;
- si.commandBufferCount = 1;
- si.pCommandBuffers = &batch->state->cmdbuf;
-
- struct wsi_memory_signal_submit_info mem_signal = {
- .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA,
- .pNext = si.pNext,
- };
-
- if (batch->state->flush_res) {
- mem_signal.memory = batch->state->flush_res->obj->mem;
- si.pNext = &mem_signal;
- }
-
- if (vkQueueSubmit(batch->queue, 1, &si, batch->state->fence.fence) != VK_SUCCESS) {
- debug_printf("ZINK: vkQueueSubmit() failed\n");
- ctx->is_device_lost = true;
-
- if (ctx->reset.reset) {
- ctx->reset.reset(ctx->reset.data, PIPE_GUILTY_CONTEXT_RESET);
- }
- }
- batch->state->fence.submitted = true;
simple_mtx_lock(&ctx->batch_mtx);
ctx->last_fence = &batch->state->fence;
_mesa_hash_table_insert_pre_hashed(&ctx->batch_states, batch->state->fence.batch_id, (void*)(uintptr_t)batch->state->fence.batch_id, batch->state);
simple_mtx_unlock(&ctx->batch_mtx);
ctx->resource_size += batch->state->resource_size;
+
+ batch->state->queue = batch->queue;
+ submit_queue(batch->state, 0);
+ post_submit(batch->state, 0);
}
void
diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h
index 0fb4e9ca644..6490a38f223 100644
--- a/src/gallium/drivers/zink/zink_batch.h
+++ b/src/gallium/drivers/zink/zink_batch.h
@@ -54,6 +54,7 @@ struct zink_batch_state {
struct zink_context *ctx;
VkCommandPool cmdpool;
VkCommandBuffer cmdbuf;
+ VkQueue queue; //duplicated from batch for threading
struct zink_resource *flush_res;
@@ -72,6 +73,8 @@ struct zink_batch_state {
struct set *active_queries; /* zink_query objects which were active at some point in this batch */
VkDeviceSize resource_size;
+
+ bool is_device_lost;
};
struct zink_batch {