radeonsi: make si_compile_shader return bool
authorMarek Olšák <marek.olsak@amd.com>
Wed, 15 Jan 2020 23:57:25 +0000 (18:57 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 23 Jan 2020 19:10:21 +0000 (19:10 +0000)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3421>

src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index d86b061c35f56ecf9063263dfe6cd42e631f9697..a7d8a44e3a9e244cc2d4e9dfe3080a05690ba6ba 100644 (file)
@@ -1714,10 +1714,10 @@ static struct nir_shader *get_nir_shader(struct si_shader_selector *sel,
        return NULL;
 }
 
-int si_compile_shader(struct si_screen *sscreen,
-                     struct ac_llvm_compiler *compiler,
-                     struct si_shader *shader,
-                     struct pipe_debug_callback *debug)
+bool si_compile_shader(struct si_screen *sscreen,
+                      struct ac_llvm_compiler *compiler,
+                      struct si_shader *shader,
+                      struct pipe_debug_callback *debug)
 {
        struct si_shader_selector *sel = shader->selector;
        struct si_shader_context ctx;
@@ -1743,7 +1743,7 @@ int si_compile_shader(struct si_screen *sscreen,
        if (shader->key.opt.ngg_culling) {
                if (!si_build_main_function(&ctx, shader, nir, false, true)) {
                        si_llvm_dispose(&ctx);
-                       return -1;
+                       return false;
                }
                ngg_cull_main_fn = ctx.main_fn;
                ctx.main_fn = NULL;
@@ -1751,7 +1751,7 @@ int si_compile_shader(struct si_screen *sscreen,
 
        if (!si_build_main_function(&ctx, shader, nir, free_nir, false)) {
                si_llvm_dispose(&ctx);
-               return -1;
+               return false;
        }
 
        if (shader->is_monolithic && ctx.type == PIPE_SHADER_VERTEX) {
@@ -1834,7 +1834,7 @@ int si_compile_shader(struct si_screen *sscreen,
 
                        if (!si_build_main_function(&ctx, &shader_ls, nir, free_nir, false)) {
                                si_llvm_dispose(&ctx);
-                               return -1;
+                               return false;
                        }
                        shader->info.uses_instanceid |= ls->info.uses_instanceid;
                        parts[1] = ctx.main_fn;
@@ -1902,7 +1902,7 @@ int si_compile_shader(struct si_screen *sscreen,
 
                        if (!si_build_main_function(&ctx, &shader_es, nir, free_nir, false)) {
                                si_llvm_dispose(&ctx);
-                               return -1;
+                               return false;
                        }
                        shader->info.uses_instanceid |= es->info.uses_instanceid;
                        es_main = ctx.main_fn;
@@ -1977,7 +1977,7 @@ int si_compile_shader(struct si_screen *sscreen,
                             si_should_optimize_less(compiler, shader->selector))) {
                si_llvm_dispose(&ctx);
                fprintf(stderr, "LLVM failed to compile shader\n");
-               return -1;
+               return false;
        }
 
        si_llvm_dispose(&ctx);
@@ -2028,7 +2028,7 @@ int si_compile_shader(struct si_screen *sscreen,
 
        si_calculate_max_simd_waves(shader);
        si_shader_dump_stats_for_shader_db(sscreen, shader, debug);
-       return 0;
+       return true;
 }
 
 /**
@@ -2542,7 +2542,6 @@ bool si_create_shader_variant(struct si_screen *sscreen,
 {
        struct si_shader_selector *sel = shader->selector;
        struct si_shader *mainp = *si_get_main_shader_part(sel, &shader->key);
-       int r;
 
        /* LS, ES, VS are compiled on demand if the main part hasn't been
         * compiled for that stage.
@@ -2557,8 +2556,7 @@ bool si_create_shader_variant(struct si_screen *sscreen,
                /* Monolithic shader (compiled as a whole, has many variants,
                 * may take a long time to compile).
                 */
-               r = si_compile_shader(sscreen, compiler, shader, debug);
-               if (r)
+               if (!si_compile_shader(sscreen, compiler, shader, debug))
                        return false;
        } else {
                /* The shader consists of several parts:
index 3a1d0e44290130aabf8dd5b6f7f29d02c6d718c4..f5fe060b7901233caf77e4e68daab3dbc6115992 100644 (file)
@@ -832,10 +832,10 @@ struct si_shader_part {
 };
 
 /* si_shader.c */
-int si_compile_shader(struct si_screen *sscreen,
-                     struct ac_llvm_compiler *compiler,
-                     struct si_shader *shader,
-                     struct pipe_debug_callback *debug);
+bool si_compile_shader(struct si_screen *sscreen,
+                      struct ac_llvm_compiler *compiler,
+                      struct si_shader *shader,
+                      struct pipe_debug_callback *debug);
 bool si_create_shader_variant(struct si_screen *sscreen,
                              struct ac_llvm_compiler *compiler,
                              struct si_shader *shader,
index d270ae7c31aa43da897880585c3296772a0d9379..69827d0774bcb2b825c510663560c6153fbb5990 100644 (file)
@@ -2254,8 +2254,8 @@ static bool si_check_missing_main_part(struct si_screen *sscreen,
                main_part->key.as_ngg = key->as_ngg;
                main_part->is_monolithic = false;
 
-               if (si_compile_shader(sscreen, compiler_state->compiler,
-                                          main_part, &compiler_state->debug) != 0) {
+               if (!si_compile_shader(sscreen, compiler_state->compiler,
+                                      main_part, &compiler_state->debug)) {
                        FREE(main_part);
                        return false;
                }
@@ -2632,8 +2632,7 @@ static void si_init_shader_selector_async(void *job, int thread_index)
                        simple_mtx_unlock(&sscreen->shader_cache_mutex);
 
                        /* Compile the shader if it hasn't been loaded from the cache. */
-                       if (si_compile_shader(sscreen, compiler, shader,
-                                                  debug) != 0) {
+                       if (!si_compile_shader(sscreen, compiler, shader, debug)) {
                                FREE(shader);
                                fprintf(stderr, "radeonsi: can't compile a main shader part\n");
                                return;