i965/vec4: Remove uses_clip_distance from program key.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vec4.cpp
index abdf3abd4be797610ff5e479a890ef9073f1676f..2bc8cc4a676f4fa41b96289841e3027ae7f03a58 100644 (file)
@@ -222,6 +222,9 @@ vec4_visitor::can_do_source_mods(vec4_instruction *inst)
    if (inst->is_send_from_grf())
       return false;
 
+   if (!inst->can_do_source_mods())
+      return false;
+
    return true;
 }
 
@@ -259,6 +262,9 @@ vec4_visitor::implied_mrf_writes(vec4_instruction *inst)
       return 2;
    case VS_OPCODE_SCRATCH_WRITE:
       return 3;
+   case GS_OPCODE_URB_WRITE:
+   case GS_OPCODE_THREAD_END:
+      return 0;
    case SHADER_OPCODE_SHADER_TIME_ADD:
       return 0;
    case SHADER_OPCODE_TEX:
@@ -267,6 +273,7 @@ vec4_visitor::implied_mrf_writes(vec4_instruction *inst)
    case SHADER_OPCODE_TXF:
    case SHADER_OPCODE_TXF_MS:
    case SHADER_OPCODE_TXS:
+   case SHADER_OPCODE_TG4:
       return inst->header_present ? 1 : 0;
    default:
       assert(!"not reached");
@@ -310,7 +317,20 @@ vec4_visitor::dead_code_eliminate()
       if (inst->dst.file == GRF) {
          assert(this->virtual_grf_end[inst->dst.reg] >= pc);
          if (this->virtual_grf_end[inst->dst.reg] == pc) {
-            inst->remove();
+            /* Don't dead code eliminate instructions that write to the
+             * accumulator as a side-effect. Instead just set the destination
+             * to the null register to free it.
+             */
+            switch (inst->opcode) {
+            case BRW_OPCODE_ADDC:
+            case BRW_OPCODE_SUBB:
+            case BRW_OPCODE_MACH:
+               inst->dst = dst_reg(retype(brw_null_reg(), inst->dst.type));
+               break;
+            default:
+               inst->remove();
+               break;
+            }
             progress = true;
          }
       }
@@ -1031,10 +1051,14 @@ vec4_visitor::split_virtual_grfs()
       vec4_instruction *inst = (vec4_instruction *)node;
 
       /* If there's a SEND message loading from a GRF on gen7+, it needs to be
-       * contiguous.  Assume that the GRF for the SEND is always in src[0].
+       * contiguous.
        */
       if (inst->is_send_from_grf()) {
-         split_grf[inst->src[0].reg] = false;
+         for (int i = 0; i < 3; i++) {
+            if (inst->src[i].file == GRF) {
+               split_grf[inst->src[i].reg] = false;
+            }
+         }
       }
    }
 
@@ -1268,6 +1292,7 @@ vec4_visitor::setup_uniforms(int reg)
    if (brw->gen < 6 && this->uniforms == 0) {
       this->uniform_vector_size[this->uniforms] = 1;
 
+      prog_data->param = reralloc(NULL, prog_data->param, const float *, 4);
       for (unsigned int i = 0; i < 4; i++) {
         unsigned int slot = this->uniforms * 4 + i;
         static float zero = 0.0;
@@ -1404,6 +1429,8 @@ vec4_visitor::run()
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
       emit_shader_time_begin();
 
+   assign_common_binding_table_offsets(0);
+
    emit_prolog();
 
    /* Generate VS IR for main().  (the visitor only descends into
@@ -1416,7 +1443,7 @@ vec4_visitor::run()
    }
    base_ir = NULL;
 
-   if (key->userclip_active && !key->uses_clip_distance)
+   if (key->userclip_active && !prog->UsesClipDistanceOut)
       setup_uniform_clipplane_values();
 
    emit_thread_end();
@@ -1569,7 +1596,7 @@ bool
 brw_vec4_prog_data_compare(const struct brw_vec4_prog_data *a,
                            const struct brw_vec4_prog_data *b)
 {
-   /* Compare all the struct up to the pointers. */
+   /* Compare all the struct (including the base) up to the pointers. */
    if (memcmp(a, b, offsetof(struct brw_vec4_prog_data, param)))
       return false;