i965/gs: Add GS_OPCODE_SET_DWORD_2_IMMED.
[mesa.git] / src / mesa / drivers / dri / i915 / i915_program.c
index 507adf1d3dca0560e2fa63ced4212c61ace5261f..4437167722758803aeac95200ab248d6456c2dcf 100644 (file)
@@ -442,14 +442,16 @@ i915_emit_param4fv(struct i915_fragment_program * p, const GLfloat * values)
 void
 i915_program_error(struct i915_fragment_program *p, const char *fmt, ...)
 {
-   va_list args;
+   if (unlikely((INTEL_DEBUG & (DEBUG_WM | DEBUG_PERF)) != 0)) {
+      va_list args;
 
-   fprintf(stderr, "i915_program_error: ");
-   va_start(args, fmt);
-   vfprintf(stderr, fmt, args);
-   va_end(args);
+      fprintf(stderr, "i915_program_error: ");
+      va_start(args, fmt);
+      vfprintf(stderr, fmt, args);
+      va_end(args);
 
-   fprintf(stderr, "\n");
+      fprintf(stderr, "\n");
+   }
    p->error = 1;
 }
 
@@ -538,7 +540,6 @@ i915_upload_program(struct i915_context *i915,
 {
    GLuint program_size = p->csr - p->program;
    GLuint decl_size = p->decl - p->declarations;
-   GLuint nr;
 
    if (p->error)
       return;
@@ -555,33 +556,33 @@ i915_upload_program(struct i915_context *i915,
       i915->state.ProgramSize = decl_size + program_size;
    }
 
-   nr = p->nr_constants;
-   if (i915->state.ConstantSize != 2 + nr*4 ||
-       memcmp(i915->state.Constant + 2,
-             p->constant, 4*sizeof(int)*nr)) {
-      if (nr) {
-        I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 1);
-        I915_STATECHANGE(i915, I915_UPLOAD_CONSTANTS);
-
-        i915->state.Constant[0] = _3DSTATE_PIXEL_SHADER_CONSTANTS | (nr * 4);
-        i915->state.Constant[1] = (1 << nr) -1;
-
-        memcpy(&i915->state.Constant[2], p->constant, 4 * sizeof(int) * nr);
-        i915->state.ConstantSize = 2 + nr * 4;
-
-        if (0) {
-           GLuint i;
-           for (i = 0; i < nr; i++) {
-              fprintf(stderr, "const[%d]: %f %f %f %f\n", i,
-                      p->constant[i][0],
-                      p->constant[i][1], p->constant[i][2], p->constant[i][3]);
-           }
-        }
-      }
-      else {
-        I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 0);
+   /* Always seemed to get a failure if I used memcmp() to
+    * shortcircuit this state upload.  Needs further investigation?
+    */
+   if (p->nr_constants) {
+      GLuint nr = p->nr_constants;
+
+      I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 1);
+      I915_STATECHANGE(i915, I915_UPLOAD_CONSTANTS);
+
+      i915->state.Constant[0] = _3DSTATE_PIXEL_SHADER_CONSTANTS | ((nr) * 4);
+      i915->state.Constant[1] = (1 << (nr - 1)) | ((1 << (nr - 1)) - 1);
+
+      memcpy(&i915->state.Constant[2], p->constant, 4 * sizeof(int) * (nr));
+      i915->state.ConstantSize = 2 + (nr) * 4;
+
+      if (0) {
+         GLuint i;
+         for (i = 0; i < nr; i++) {
+            fprintf(stderr, "const[%d]: %f %f %f %f\n", i,
+                    p->constant[i][0],
+                    p->constant[i][1], p->constant[i][2], p->constant[i][3]);
+         }
       }
    }
+   else {
+      I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 0);
+   }
 
    p->on_hardware = 1;
 }