r600/sb: handle scratch mem reads on r600
authorDave Airlie <airlied@redhat.com>
Tue, 6 Feb 2018 04:17:46 +0000 (14:17 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 8 Feb 2018 23:53:21 +0000 (09:53 +1000)
On r600 we use the scratch mem with read/read_ind, in that case
sb should track the rw_gpr as a dst instead of a src.

This stops the whole shader being optimised out.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
src/gallium/drivers/r600/sb/sb_bc_parser.cpp

index e737f3d6cd0bb947b922e1aa229b1e3a7eb0afda..5c572938a154792a68fb2feb214b131484e3e4f0 100644 (file)
@@ -778,8 +778,15 @@ void bc_finalizer::finalize_cf(cf_node* c) {
                int reg = -1;
                unsigned mask = 0;
 
+
                for (unsigned chan = 0; chan < 4; ++chan) {
-                       value *v = c->src[chan];
+                       value *v;
+                       if (ctx.hw_class == HW_CLASS_R600 && c->bc.op == CF_OP_MEM_SCRATCH &&
+                           (c->bc.type == 2 || c->bc.type == 3))
+                               v = c->dst[chan];
+                       else
+                               v = c->src[chan];
+
                        if (!v || v->is_undef())
                                continue;
 
index 2ec842159b1c076eeae07fe0cd990bb1e35bd593..a7b828268b9706f2db4f306ede551973e4937a80 100644 (file)
@@ -832,12 +832,23 @@ int bc_parser::prepare_ir() {
 
                        do {
 
-                               c->src.resize(4);
+                               if (ctx.hw_class == HW_CLASS_R600 && c->bc.op == CF_OP_MEM_SCRATCH &&
+                                   (c->bc.type == 2 || c->bc.type == 3)) {
+                                       c->dst.resize(4);
+                                       for(int s = 0; s < 4; ++s) {
+                                               if (c->bc.comp_mask & (1 << s))
+                                                       c->dst[s] =
+                                                               sh->get_gpr_value(true, c->bc.rw_gpr, s, false);
+                                       }
+                               } else {
+                                       c->src.resize(4);
 
-                               for(int s = 0; s < 4; ++s) {
-                                       if (c->bc.comp_mask & (1 << s))
-                                               c->src[s] =
+                               
+                                       for(int s = 0; s < 4; ++s) {
+                                               if (c->bc.comp_mask & (1 << s))
+                                                       c->src[s] =
                                                                sh->get_gpr_value(true, c->bc.rw_gpr, s, false);
+                                       }
                                }
 
                                if (((flags & CF_RAT) || (!(flags & CF_STRM))) && (c->bc.type & 1)) { // indexed write