Mesa (master): zink: implement pipe_device_reset_callback
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 2 13:53:20 UTC 2020
Module: Mesa
Branch: master
Commit: 95b9fc4146656493ad2544bd75ee14c01feb9163
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=95b9fc4146656493ad2544bd75ee14c01feb9163
Author: Hoe Hao Cheng <haochengho12907 at gmail.com>
Date: Tue Sep 22 19:50:33 2020 +0800
zink: implement pipe_device_reset_callback
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6763>
---
src/gallium/drivers/zink/zink_batch.c | 4 ++--
src/gallium/drivers/zink/zink_context.c | 35 +++++++++++++++++++++++++++++++++
src/gallium/drivers/zink/zink_context.h | 3 +++
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index ee0fa994cdc..88c547cbb90 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -99,8 +99,8 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
si.pCommandBuffers = &batch->cmdbuf;
if (vkQueueSubmit(ctx->queue, 1, &si, batch->fence->fence) != VK_SUCCESS) {
- debug_printf("vkQueueSubmit failed\n");
- abort();
+ debug_printf("ZINK: vkQueueSubmit() failed\n");
+ ctx->is_device_lost = true;
}
}
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index f223c8366b6..802e4a116f0 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -75,6 +75,39 @@ zink_context_destroy(struct pipe_context *pctx)
FREE(ctx);
}
+static enum pipe_reset_status
+zink_get_device_reset_status(struct pipe_context *pctx)
+{
+ struct zink_context *ctx = zink_context(pctx);
+
+ enum pipe_reset_status status = PIPE_NO_RESET;
+
+ if (ctx->is_device_lost) {
+ // Since we don't know what really happened to the hardware, just
+ // assume that we are in the wrong
+ status = PIPE_GUILTY_CONTEXT_RESET;
+
+ debug_printf("ZINK: device lost detected!\n");
+
+ if (ctx->reset.reset)
+ ctx->reset.reset(ctx->reset.data, status);
+ }
+
+ return status;
+}
+
+static void
+zink_set_device_reset_callback(struct pipe_context *pctx,
+ const struct pipe_device_reset_callback *cb)
+{
+ struct zink_context *ctx = zink_context(pctx);
+
+ if (cb)
+ ctx->reset = *cb;
+ else
+ memset(&ctx->reset, 0, sizeof(ctx->reset));
+}
+
static VkSamplerMipmapMode
sampler_mipmap_mode(enum pipe_tex_mipfilter filter)
{
@@ -1166,6 +1199,8 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
ctx->base.priv = priv;
ctx->base.destroy = zink_context_destroy;
+ ctx->base.get_device_reset_status = zink_get_device_reset_status;
+ ctx->base.set_device_reset_callback = zink_set_device_reset_callback;
zink_context_state_init(&ctx->base);
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index 52c5459d650..a901bfbce69 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -81,8 +81,11 @@ struct zink_context {
struct slab_child_pool transfer_pool;
struct blitter_context *blitter;
+ struct pipe_device_reset_callback reset;
+
VkCommandPool cmdpool;
struct zink_batch batches[4];
+ bool is_device_lost;
unsigned curr_batch;
VkQueue queue;
More information about the mesa-commit
mailing list