i915: Remove most of the code under gen >= 4 checks.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_fs.cpp
index 9efdfc8e4859cd5ee7d91a0c2e609e0269ba6e18..97cd291f97427d91084afa9c58a935d6c5fb4fc2 100644 (file)
@@ -48,7 +48,6 @@ extern "C" {
 }
 #include "brw_fs.h"
 #include "glsl/glsl_types.h"
-#include "glsl/ir_print_visitor.h"
 
 void
 fs_inst::init()
@@ -818,6 +817,7 @@ fs_visitor::import_uniforms(fs_visitor *v)
                           import_uniforms_callback,
                           variable_ht);
    this->params_remap = v->params_remap;
+   this->nr_params_remap = v->nr_params_remap;
 }
 
 /* Our support for uniforms is piggy-backed on the struct
@@ -1490,6 +1490,7 @@ fs_visitor::remove_dead_constants()
 {
    if (dispatch_width == 8) {
       this->params_remap = ralloc_array(mem_ctx, int, c->prog_data.nr_params);
+      this->nr_params_remap = c->prog_data.nr_params;
 
       for (unsigned int i = 0; i < c->prog_data.nr_params; i++)
         this->params_remap[i] = -1;
@@ -1504,9 +1505,10 @@ fs_visitor::remove_dead_constants()
            if (inst->src[i].file != UNIFORM)
               continue;
 
-           /* if we get a negative constant nr or one greater than we can
-            * handle, this can cause an overflow, we can't just refuse to
-            * build, so just go undefined and alias everyone to constant 0.
+           /* Section 5.11 of the OpenGL 4.3 spec says:
+            *
+            *     "Out-of-bounds reads return undefined values, which include
+            *     values from other variables of the active program or zero."
             */
            if (constant_nr < 0 || constant_nr >= (int)c->prog_data.nr_params) {
               constant_nr = 0;
@@ -1558,8 +1560,8 @@ fs_visitor::remove_dead_constants()
         if (inst->src[i].file != UNIFORM)
            continue;
 
-         /* as above alias to 0 */
-        if (constant_nr < 0 || constant_nr >= (int)c->prog_data.nr_params) {
+        /* as above alias to 0 */
+        if (constant_nr < 0 || constant_nr >= (int)this->nr_params_remap) {
            constant_nr = 0;
         }
         assert(this->params_remap[constant_nr] != -1);