pan/midgard: Track shader quadword count while scheduling
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 30 Aug 2019 20:57:20 +0000 (13:57 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 30 Aug 2019 22:50:26 +0000 (15:50 -0700)
This allow multiblock blend shaders to compute constant colour offsets
correctly.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_schedule.c

index 2019993..b63a542 100644 (file)
@@ -280,6 +280,8 @@ typedef struct compiler_context {
         /* Alpha ref value passed in */
         float alpha_ref;
 
+        unsigned quadword_count;
+
         /* The mapping of sysvals to uniforms, the count, and the off-by-one inverse */
         unsigned sysvals[MAX_SYSVAL_COUNT];
         unsigned sysval_count;
index 765eab3..6317e88 100644 (file)
@@ -2807,7 +2807,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
                 disassemble_midgard(program->compiled.data, program->compiled.size);
 
         if (midgard_debug & MIDGARD_DBG_SHADERDB) {
-                unsigned nr_bundles = 0, nr_ins = 0, nr_quadwords = 0;
+                unsigned nr_bundles = 0, nr_ins = 0;
 
                 /* Count instructions and bundles */
 
@@ -2815,8 +2815,6 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
                         nr_bundles += util_dynarray_num_elements(
                                               &block->bundles, midgard_bundle);
 
-                        nr_quadwords += block->quadword_count;
-
                         mir_foreach_bundle_in_block(block, bun)
                                 nr_ins += bun->instruction_count;
                 }
@@ -2839,7 +2837,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
                         "%d:%d spills:fills\n",
                         SHADER_DB_COUNT++,
                         gl_shader_stage_name(ctx->stage),
-                        nr_ins, nr_bundles, nr_quadwords,
+                        nr_ins, nr_bundles, ctx->quadword_count,
                         nr_registers, nr_threads,
                         ctx->loop_count,
                         ctx->spills, ctx->fills);
index 98d5f1b..7b68776 100644 (file)
@@ -630,9 +630,8 @@ schedule_block(compiler_context *ctx, midgard_block *block)
                 util_dynarray_append(&block->bundles, midgard_bundle, bundle);
 
                 if (bundle.has_blend_constant) {
-                        /* TODO: Multiblock? */
-                        int quadwords_within_block = block->quadword_count + quadword_size(bundle.tag) - 1;
-                        ctx->blend_constant_offset = quadwords_within_block * 0x10;
+                        unsigned offset = ctx->quadword_count + block->quadword_count + quadword_size(bundle.tag) - 1;
+                        ctx->blend_constant_offset = offset * 0x10;
                 }
 
                 while(skip--)
@@ -642,6 +641,7 @@ schedule_block(compiler_context *ctx, midgard_block *block)
         }
 
         block->is_scheduled = true;
+        ctx->quadword_count += block->quadword_count;
 }
 
 /* The following passes reorder MIR instructions to enable better scheduling */