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 201999359cfbf9283340ae4e0450f2cfb2c41c59..b63a542e5adb83d5ba5066dc2b06b186844e58c1 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 765eab36d86a011c2c04d191b3841bf27981419e..6317e886dcc597703c492cce590682d505a3607c 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 98d5f1b03f7d1487585282d721fbd2057e27f7ef..7b687766491d769d537e40ae07d7a769addc5f89 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 */