Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / gallium / drivers / freedreno / ir3 / ir3_gallium.c
index 5544e0e50c71e5f1ac8510d2b303aea542381736..810c3b2051ef35b023722725d1f3321747fd8520 100644 (file)
@@ -44,8 +44,7 @@
 #include "ir3/ir3_nir.h"
 
 static void
-dump_shader_info(struct ir3_shader_variant *v, bool binning_pass,
-               struct pipe_debug_callback *debug)
+dump_shader_info(struct ir3_shader_variant *v, struct pipe_debug_callback *debug)
 {
        if (!unlikely(fd_mesa_debug & FD_DBG_SHADERDB))
                return;
@@ -53,6 +52,7 @@ dump_shader_info(struct ir3_shader_variant *v, bool binning_pass,
        pipe_debug_message(debug, SHADER_INFO,
                        "%s shader: %u inst, %u nops, %u non-nops, %u mov, %u cov, "
                        "%u dwords, %u last-baryf, %u half, %u full, %u constlen, "
+                       "%u cat0, %u cat1, %u cat2, %u cat3, %u cat4, %u cat5, %u cat6, %u cat7, "
                        "%u sstall, %u (ss), %u (sy), %d max_sun, %d loops\n",
                        ir3_shader_stage(v),
                        v->info.instrs_count,
@@ -65,6 +65,14 @@ dump_shader_info(struct ir3_shader_variant *v, bool binning_pass,
                        v->info.max_half_reg + 1,
                        v->info.max_reg + 1,
                        v->constlen,
+                       v->info.instrs_per_cat[0],
+                       v->info.instrs_per_cat[1],
+                       v->info.instrs_per_cat[2],
+                       v->info.instrs_per_cat[3],
+                       v->info.instrs_per_cat[4],
+                       v->info.instrs_per_cat[5],
+                       v->info.instrs_per_cat[6],
+                       v->info.instrs_per_cat[7],
                        v->info.sstall,
                        v->info.ss, v->info.sy,
                        v->max_sun, v->loops);
@@ -118,9 +126,14 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key,
                                        key.vastc_srgb, key.fastc_srgb);
 
                }
-               dump_shader_info(v, binning_pass, debug);
 
+               dump_shader_info(v, debug);
                upload_shader_variant(v);
+
+               if (v->binning) {
+                       upload_shader_variant(v->binning);
+                       dump_shader_info(v->binning, debug);
+               }
        }
 
        return v;
@@ -168,7 +181,7 @@ ir3_shader_create(struct ir3_compiler *compiler,
        struct ir3_stream_output_info stream_output;
        copy_stream_out(&stream_output, &cso->stream_output);
 
-       struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, &stream_output);
+       struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, 0, &stream_output);
 
        /* Compile standard variants immediately to try to avoid draw-time stalls
         * to run the compiler.
@@ -203,10 +216,27 @@ ir3_shader_create(struct ir3_compiler *compiler,
                break;
        }
 
-       ir3_shader_variant(shader, key, false, debug);
+       key.safe_constlen = false;
+       struct ir3_shader_variant *v = ir3_shader_variant(shader, key, false, debug);
+       if (!v)
+               return NULL;
+
+       if (v->constlen > compiler->max_const_safe) {
+               key.safe_constlen = true;
+               ir3_shader_variant(shader, key, false, debug);
+       }
 
-       if (nir->info.stage == MESA_SHADER_VERTEX)
-               ir3_shader_variant(shader, key, true, debug);
+       if (nir->info.stage == MESA_SHADER_VERTEX) {
+               key.safe_constlen = false;
+               v = ir3_shader_variant(shader, key, true, debug);
+               if (!v)
+                       return NULL;
+
+               if (v->constlen > compiler->max_const_safe) {
+                       key.safe_constlen = true;
+                       ir3_shader_variant(shader, key, true, debug);
+               }
+       }
 
        shader->initial_variants_done = true;
 
@@ -234,7 +264,7 @@ ir3_shader_create_compute(struct ir3_compiler *compiler,
                nir = tgsi_to_nir(cso->prog, screen, false);
        }
 
-       struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, NULL);
+       struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, 0, NULL);
 
        /* Immediately compile a standard variant.  We have so few variants in our
         * shaders, that doing so almost eliminates draw-time recompiles.  (This
@@ -268,7 +298,7 @@ ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso)
                fd_bo_del(v->bo);
                v->bo = NULL;
 
-               if (v->binning) {
+               if (v->binning && v->binning->bo) {
                        fd_bo_del(v->binning->bo);
                        v->binning->bo = NULL;
                }
@@ -277,6 +307,14 @@ ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso)
        ir3_shader_destroy(so);
 }
 
+static void
+ir3_screen_finalize_nir(struct pipe_screen *pscreen, void *nir, bool optimize)
+{
+       struct fd_screen *screen = fd_screen(pscreen);
+
+       ir3_finalize_nir(screen->compiler, nir);
+}
+
 void
 ir3_prog_init(struct pipe_context *pctx)
 {
@@ -295,3 +333,9 @@ ir3_prog_init(struct pipe_context *pctx)
        pctx->create_fs_state = ir3_shader_state_create;
        pctx->delete_fs_state = ir3_shader_state_delete;
 }
+
+void
+ir3_screen_init(struct pipe_screen *pscreen)
+{
+       pscreen->finalize_nir = ir3_screen_finalize_nir;
+}