r600g/sb: Add dependency tracking for scratch ops
authorGlenn Kennard <glenn.kennard@gmail.com>
Sun, 5 Mar 2017 17:26:53 +0000 (18:26 +0100)
committerDave Airlie <airlied@redhat.com>
Thu, 8 Feb 2018 23:53:19 +0000 (09:53 +1000)
Signed-off-by: Glenn Kennard <glenn.kennard@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/r600_shader.h
src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
src/gallium/drivers/r600/sb/sb_bc_parser.cpp
src/gallium/drivers/r600/sb/sb_core.cpp
src/gallium/drivers/r600/sb/sb_ir.h
src/gallium/drivers/r600/sb/sb_ra_init.cpp
src/gallium/drivers/r600/sb/sb_sched.cpp
src/gallium/drivers/r600/sb/sb_valtable.cpp

index b837d1309ae608492001e5b1423b59fe273caf3a..3b3e667ec567efa3b934e74bf62cdf63da47a35c 100644 (file)
@@ -78,6 +78,7 @@ struct r600_shader {
        boolean                 uses_kill;
        boolean                 fs_write_all;
        boolean                 two_side;
+       boolean                 needs_scratch_space;
        /* Number of color outputs in the TGSI shader,
         * sometimes it could be higher than nr_cbufs (bug?).
         * Also with writes_all property on eg+ it will be set to max CB number */
index d3fab8002044ac66dff798420c578462c29dc349..e737f3d6cd0bb947b922e1aa229b1e3a7eb0afda 100644 (file)
@@ -311,7 +311,7 @@ void bc_finalizer::finalize_alu_group(alu_group_node* g, node *prev_node) {
                value *d = n->dst.empty() ? NULL : n->dst[0];
 
                if (d && d->is_special_reg()) {
-                       assert((n->bc.op_ptr->flags & AF_MOVA) || d->is_geometry_emit() || d->is_lds_oq() || d->is_lds_access());
+                       assert((n->bc.op_ptr->flags & AF_MOVA) || d->is_geometry_emit() || d->is_lds_oq() || d->is_lds_access() || d->is_scratch());
                        d = NULL;
                }
 
index 87035ee2a6b9fdb4948de5a2dcca1f7739a0cf9b..2ec842159b1c076eeae07fe0cd990bb1e35bd593 100644 (file)
@@ -725,6 +725,11 @@ int bc_parser::prepare_fetch_clause(cf_node *cf) {
                                n->src.push_back(get_cf_index_value(n->bc.resource_index_mode == V_SQ_CF_INDEX_1));
                        }
                }
+
+               if (n->bc.op == FETCH_OP_READ_SCRATCH) {
+                       n->src.push_back(sh->get_special_value(SV_SCRATCH));
+                       n->dst.push_back(sh->get_special_value(SV_SCRATCH));
+               }
        }
 
        return 0;
@@ -855,6 +860,10 @@ int bc_parser::prepare_ir() {
                                                c->flags |= NF_DONT_KILL;
                                        }
                                }
+                               else if (c->bc.op == CF_OP_MEM_SCRATCH) {
+                                       c->src.push_back(sh->get_special_value(SV_SCRATCH));
+                                       c->dst.push_back(sh->get_special_value(SV_SCRATCH));
+                               }
 
                                if (!burst_count--)
                                        break;
@@ -889,6 +898,9 @@ int bc_parser::prepare_ir() {
                                c->src.push_back(sh->get_special_value(SV_GEOMETRY_EMIT));
                                c->dst.push_back(sh->get_special_value(SV_GEOMETRY_EMIT));
                        }
+               } else if (c->bc.op == CF_OP_WAIT_ACK) {
+                       c->src.push_back(sh->get_special_value(SV_SCRATCH));
+                       c->dst.push_back(sh->get_special_value(SV_SCRATCH));
                }
        }
 
index 5049b677842c417a1d2612a8ff1953a5ba4e0171..a94d8d32b5053c993f5b083884735bf764ada510 100644 (file)
@@ -191,7 +191,7 @@ int r600_sb_bytecode_process(struct r600_context *rctx,
 
        // if conversion breaks the dependency tracking between CF_EMIT ops when it removes
        // the phi nodes for SV_GEOMETRY_EMIT. Just disable it for GS
-       if (sh->target != TARGET_GS && sh->target != TARGET_HS)
+       if ((sh->target != TARGET_GS && sh->target != TARGET_HS) || pshader->needs_scratch_space)
                SB_RUN_PASS(if_conversion,              1);
 
        // if_conversion breaks info about uses, but next pass (peephole)
index bee947504ed272089ea3155bf41702cc2fe9d3be..245af961e6996a3eba7bb2f7548137e3c73bca28 100644 (file)
@@ -46,6 +46,7 @@ enum special_regs {
        SV_LDS_RW,
        SV_LDS_OQA,
        SV_LDS_OQB,
+       SV_SCRATCH
 };
 
 class node;
@@ -517,6 +518,9 @@ public:
                        v = v->gvn_source;
                return v;
        }
+       bool is_scratch() {
+               return is_special_reg() && select == sel_chan(SV_SCRATCH, 0);
+       }
 
        bool is_float_0_or_1() {
                value *v = gvalue();
index e5ec9db23b70dd7353df99293169c90a9d3f026d..985e179452371991035cf9d22773d1212d62d90e 100644 (file)
@@ -708,7 +708,7 @@ void ra_split::split_vec(vvec &vv, vvec &v1, vvec &v2, bool allow_swz) {
 
                        assert(!o->is_dead());
 
-                       if (o->is_undef() || o->is_geometry_emit())
+                       if (o->is_undef() || o->is_geometry_emit() || o->is_scratch())
                                continue;
 
                        if (allow_swz && o->is_float_0_or_1())
index f5fd84d54ac9581048d7d6a778625878473f06f3..ffc66018b1063b90772f0c9b75c02631bf5665d7 100644 (file)
@@ -1670,7 +1670,7 @@ unsigned post_scheduler::try_add_instruction(node *n) {
                value *d = a->dst.empty() ? NULL : a->dst[0];
 
                if (d && d->is_special_reg()) {
-                       assert((a->bc.op_ptr->flags & AF_MOVA) || d->is_geometry_emit() || d->is_lds_oq() || d->is_lds_access());
+                       assert((a->bc.op_ptr->flags & AF_MOVA) || d->is_geometry_emit() || d->is_lds_oq() || d->is_lds_access() || d->is_scratch());
                        d = NULL;
                }
 
index 41cfbf0946afa7abc1976847e50c133af717d71c..dd336bc41772eca25cb62b88e1072f29e3936fab 100644 (file)
@@ -59,6 +59,7 @@ sb_ostream& operator << (sb_ostream &o, value &v) {
                        case SV_LDS_RW: o << "LDS_RW"; break;
                        case SV_LDS_OQA: o << "LDS_OQA"; break;
                        case SV_LDS_OQB: o << "LDS_OQB"; break;
+                       case SV_SCRATCH: o << "SCRATCH"; break;
                        default: o << "???specialreg"; break;
                }
                break;