zink: implement pipe_device_reset_callback
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6763>
This commit is contained in:
parent
7d6609e70d
commit
95b9fc4146
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue