Mesa (main): radeonsi: add helper to use si_screen::aux_context
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 15 11:02:19 UTC 2022
Module: Mesa
Branch: main
Commit: bda1c081bd6e9e4ec144f963c8899cd0d17b211f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bda1c081bd6e9e4ec144f963c8899cd0d17b211f
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date: Tue Jun 14 16:35:49 2022 +0200
radeonsi: add helper to use si_screen::aux_context
This context needs to be locked before usage, and flushed after.
If it's forgotten, radeonsi may crash (eg #6666).
To avoid this kind of error, introduce 2 helpers.
cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17032>
---
src/gallium/drivers/radeonsi/si_pipe.c | 13 +++++++++++++
src/gallium/drivers/radeonsi/si_pipe.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 98d93af749e..08a4482dbcb 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -1469,3 +1469,16 @@ struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_conf
drmFreeVersion(version);
return rw ? rw->screen : NULL;
}
+
+struct si_context* si_get_aux_context(struct si_screen *sscreen)
+{
+ simple_mtx_lock(&sscreen->aux_context_lock);
+ return (struct si_context*)sscreen->aux_context;
+}
+
+void si_put_aux_context_flush(struct si_screen *sscreen)
+{
+ struct pipe_context *c = &((struct si_context*)sscreen->aux_context)->b;
+ c->flush(c, NULL, 0);
+ simple_mtx_unlock(&sscreen->aux_context_lock);
+}
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 092f1f74ee7..315a179f977 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -1526,6 +1526,8 @@ void si_init_compute_functions(struct si_context *sctx);
/* si_pipe.c */
bool si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler);
void si_init_aux_async_compute_ctx(struct si_screen *sscreen);
+struct si_context* si_get_aux_context(struct si_screen *sscreen);
+void si_put_aux_context_flush(struct si_screen *sscreen);
/* si_perfcounters.c */
void si_init_perfcounters(struct si_screen *screen);
More information about the mesa-commit
mailing list