r600g/sb: fix allocation of indirectly addressed input arrays
authorVadim Girlin <vadimgirlin@gmail.com>
Thu, 2 May 2013 03:56:32 +0000 (07:56 +0400)
committerVadim Girlin <vadimgirlin@gmail.com>
Fri, 3 May 2013 12:53:41 +0000 (16:53 +0400)
Some inputs may be preloaded into predefined GPRs,
so we can't reallocate arrays with such inputs.

Fixes issues with webgl demo: http://oos.moxiecode.com/js_webgl/snake/

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
src/gallium/drivers/r600/sb/sb_ra_coalesce.cpp
src/gallium/drivers/r600/sb/sb_ra_init.cpp
src/gallium/drivers/r600/sb/sb_shader.cpp
src/gallium/drivers/r600/sb/sb_shader.h

index cec4bbc74de8ed0d1b50915478bb5ae314ac8b2f..25c46f79c8e67a29a07ee10a45cfea03c4bc7415 100644 (file)
@@ -345,13 +345,17 @@ void coalescer::init_reg_bitset(sb_bitset &bs, val_set &vs) {
        for (val_set::iterator I = vs.begin(sh), E = vs.end(sh); I != E; ++I) {
                value *v = *I;
 
-               if (!v->is_sgpr())
+               if (!v->is_any_gpr())
                        continue;
 
-               if (v->gpr) {
-                       if (v->gpr >= bs.size())
-                               bs.resize(v->gpr + 64);
-                       bs.set(v->gpr, 1);
+               unsigned gpr = v->get_final_gpr();
+               if (!gpr)
+                       continue;
+
+               if (gpr) {
+                       if (gpr >= bs.size())
+                               bs.resize(gpr + 64);
+                       bs.set(gpr, 1);
                }
        }
 }
index 0447f29eb1b99e06e2c7acaa71c23514a538a017..99ff6ff3ff5bc1c72c5241c06044b5ac41d86630 100644 (file)
@@ -244,6 +244,12 @@ void ra_init::alloc_arrays() {
                        cerr << "\n";
                );
 
+               // skip preallocated arrays (e.g. with preloaded inputs)
+               if (a->gpr) {
+                       RA_DUMP( cerr << "   FIXED at " << a->gpr << "\n"; );
+                       continue;
+               }
+
                bool dead = a->is_dead();
 
                if (dead) {
index 6dd3678e66af141b75cac98beca959dd2a47622f..3fd6ea49f54fc2f907fae1f307e301bdf3680181 100644 (file)
@@ -61,7 +61,7 @@ bool shader::assign_slot(alu_node* n, alu_node *slots[5]) {
        return true;
 }
 
-void shader::add_gpr_values(vvec& vec, unsigned gpr, unsigned comp_mask,
+void shader::add_pinned_gpr_values(vvec& vec, unsigned gpr, unsigned comp_mask,
                             bool src) {
        unsigned chan = 0;
        while (comp_mask) {
@@ -72,6 +72,11 @@ void shader::add_gpr_values(vvec& vec, unsigned gpr, unsigned comp_mask,
                                v->gpr = v->pin_gpr = v->select;
                                v->fix();
                        }
+                       if (v->array && !v->array->gpr) {
+                               // if pinned value can be accessed with indirect addressing
+                               // pin the entire array to its original location
+                               v->array->gpr = v->array->base_gpr;
+                       }
                        vec.push_back(v);
                }
                comp_mask >>= 1;
@@ -199,7 +204,7 @@ void shader::add_input(unsigned gpr, bool preloaded, unsigned comp_mask) {
        i.comp_mask = comp_mask;
 
        if (preloaded) {
-               add_gpr_values(root->dst, gpr, comp_mask, true);
+               add_pinned_gpr_values(root->dst, gpr, comp_mask, true);
        }
 
 }
@@ -217,9 +222,9 @@ void shader::init_call_fs(cf_node* cf) {
        for(inputs_vec::const_iterator I = inputs.begin(),
                        E = inputs.end(); I != E; ++I, ++gpr) {
                if (!I->preloaded)
-                       add_gpr_values(cf->dst, gpr, I->comp_mask, false);
+                       add_pinned_gpr_values(cf->dst, gpr, I->comp_mask, false);
                else
-                       add_gpr_values(cf->src, gpr, I->comp_mask, true);
+                       add_pinned_gpr_values(cf->src, gpr, I->comp_mask, true);
        }
 }
 
index aa71d542aad2925045ebd1e748a32143c6bd51fe..b2e3837c4c0963c19f90414c60b4494e74f02a1a 100644 (file)
@@ -315,7 +315,7 @@ public:
        value* get_value_version(value* v, unsigned ver);
 
        void init();
-       void add_gpr_values(vvec& vec, unsigned gpr, unsigned comp_mask, bool src);
+       void add_pinned_gpr_values(vvec& vec, unsigned gpr, unsigned comp_mask, bool src);
 
        void dump_ir();