Mesa (main): radeonsi: fail to create pipe_screen if LLVM doesn't support the GPU

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 25 14:05:16 UTC 2022


Module: Mesa
Branch: main
Commit: fe4ec76115fe1c51cfa3659a61747d0397635a9d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe4ec76115fe1c51cfa3659a61747d0397635a9d

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Apr 22 14:10:03 2022 -0400

radeonsi: fail to create pipe_screen if LLVM doesn't support the GPU

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16112>

---

 src/gallium/drivers/radeonsi/si_pipe.c | 19 ++++++++++++++++---
 src/gallium/drivers/radeonsi/si_pipe.h |  2 +-
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index a849ef4b705..a55fe2de5d1 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -134,7 +134,7 @@ static const struct debug_named_value test_options[] = {
    DEBUG_NAMED_VALUE_END /* must be last */
 };
 
-void si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler)
+bool si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler)
 {
    /* Only create the less-optimizing version of the compiler on APUs
     * predating Ryzen (Raven). */
@@ -146,11 +146,15 @@ void si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compil
       (create_low_opt_compiler ? AC_TM_CREATE_LOW_OPT : 0);
 
    ac_init_llvm_once();
-   ac_init_llvm_compiler(compiler, sscreen->info.family, tm_options);
-   compiler->passes = ac_create_llvm_passes(compiler->tm);
 
+   if (!ac_init_llvm_compiler(compiler, sscreen->info.family, tm_options))
+      return false;
+
+   compiler->passes = ac_create_llvm_passes(compiler->tm);
    if (compiler->low_opt_tm)
       compiler->low_opt_passes = ac_create_llvm_passes(compiler->low_opt_tm);
+
+   return true;
 }
 
 void si_init_aux_async_compute_ctx(struct si_screen *sscreen)
@@ -1077,6 +1081,15 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
       return NULL;
    }
 
+   /* Initialize just one compiler instance to check for errors. The other compiler instances are
+    * initialized on demand.
+    */
+   if (!si_init_compiler(sscreen, &sscreen->compiler[0])) {
+      /* The callee prints the error message. */
+      FREE(sscreen);
+      return NULL;
+   }
+
    util_idalloc_mt_init_tc(&sscreen->buffer_ids);
 
    /* Set functions first. */
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index fe5f9d81a1c..66779e1cba3 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -1501,7 +1501,7 @@ void si_emit_initial_compute_regs(struct si_context *sctx, struct radeon_cmdbuf
 void si_init_compute_functions(struct si_context *sctx);
 
 /* si_pipe.c */
-void si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler);
+bool si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler);
 void si_init_aux_async_compute_ctx(struct si_screen *sscreen);
 
 /* si_perfcounters.c */



More information about the mesa-commit mailing list