i965: Use MESA_FORMAT_B8G8R8X8_SRGB for RGB visuals
[mesa.git] / src / mesa / drivers / dri / i965 / brw_curbe.c
index fea5d332c239ca88d1c1d01847ddab4d04bfc4d1..b777bce70c176c2db5ed02d67c642654fe6ffda0 100644 (file)
@@ -50,7 +50,6 @@
  */
 
 
-#include "main/glheader.h"
 #include "main/context.h"
 #include "main/macros.h"
 #include "main/enums.h"
 static void calculate_curbe_offsets( struct brw_context *brw )
 {
    struct gl_context *ctx = &brw->ctx;
-   /* CACHE_NEW_WM_PROG */
+   /* BRW_NEW_FS_PROG_DATA */
    const GLuint nr_fp_regs = (brw->wm.prog_data->base.nr_params + 15) / 16;
 
-   /* CACHE_NEW_VS_PROG */
+   /* BRW_NEW_VS_PROG_DATA */
    const GLuint nr_vp_regs = (brw->vs.prog_data->base.base.nr_params + 15) / 16;
    GLuint nr_clip_regs = 0;
    GLuint total_regs;
@@ -134,7 +133,7 @@ static void calculate_curbe_offsets( struct brw_context *brw )
                  brw->curbe.vs_start,
                  brw->curbe.vs_size );
 
-      brw->state.dirty.brw |= BRW_NEW_CURBE_OFFSETS;
+      brw->ctx.NewDriverState |= BRW_NEW_CURBE_OFFSETS;
    }
 }
 
@@ -142,8 +141,9 @@ static void calculate_curbe_offsets( struct brw_context *brw )
 const struct brw_tracked_state brw_curbe_offsets = {
    .dirty = {
       .mesa = _NEW_TRANSFORM,
-      .brw  = BRW_NEW_CONTEXT,
-      .cache = CACHE_NEW_VS_PROG | CACHE_NEW_WM_PROG
+      .brw  = BRW_NEW_CONTEXT |
+              BRW_NEW_FS_PROG_DATA |
+              BRW_NEW_VS_PROG_DATA,
    },
    .emit = calculate_curbe_offsets
 };
@@ -175,7 +175,7 @@ void brw_upload_cs_urb_state(struct brw_context *brw)
    ADVANCE_BATCH();
 }
 
-static GLfloat fixed_plane[6][4] = {
+static const GLfloat fixed_plane[6][4] = {
    { 0,    0,   -1, 1 },
    { 0,    0,    1, 1 },
    { 0,   -1,    0, 1 },
@@ -216,7 +216,7 @@ brw_upload_constant_buffer(struct brw_context *brw)
       /* BRW_NEW_CURBE_OFFSETS */
       GLuint offset = brw->curbe.wm_start * 16;
 
-      /* CACHE_NEW_WM_PROG | _NEW_PROGRAM_CONSTANTS: copy uniform values */
+      /* BRW_NEW_FS_PROG_DATA | _NEW_PROGRAM_CONSTANTS: copy uniform values */
       for (i = 0; i < brw->wm.prog_data->base.nr_params; i++) {
         buf[offset + i] = *brw->wm.prog_data->base.param[i];
       }
@@ -257,7 +257,7 @@ brw_upload_constant_buffer(struct brw_context *brw)
 
       GLuint offset = brw->curbe.vs_start * 16;
 
-      /* CACHE_NEW_VS_PROG | _NEW_PROGRAM_CONSTANTS: copy uniform values */
+      /* BRW_NEW_VS_PROG_DATA | _NEW_PROGRAM_CONSTANTS: copy uniform values */
       for (i = 0; i < brw->vs.prog_data->base.base.nr_params; i++) {
          buf[offset + i] = *brw->vs.prog_data->base.base.param[i];
       }
@@ -303,17 +303,43 @@ emit:
                (brw->curbe.total_size - 1) + brw->curbe.curbe_offset);
    }
    ADVANCE_BATCH();
+
+   /* Work around a Broadwater/Crestline depth interpolator bug.  The
+    * following sequence will cause GPU hangs:
+    *
+    * 1. Change state so that all depth related fields in CC_STATE are
+    *    disabled, and in WM_STATE, only "PS Use Source Depth" is enabled.
+    * 2. Emit a CONSTANT_BUFFER packet.
+    * 3. Draw via 3DPRIMITIVE.
+    *
+    * The recommended workaround is to emit a non-pipelined state change after
+    * emitting CONSTANT_BUFFER, in order to drain the windowizer pipeline.
+    *
+    * We arbitrarily choose 3DSTATE_GLOBAL_DEPTH_CLAMP_OFFSET (as it's small),
+    * and always emit it when "PS Use Source Depth" is set.  We could be more
+    * precise, but the additional complexity is probably not worth it.
+    *
+    * BRW_NEW_FRAGMENT_PROGRAM
+    */
+   if (brw->gen == 4 && !brw->is_g4x &&
+       (brw->fragment_program->Base.InputsRead & (1 << VARYING_SLOT_POS))) {
+      BEGIN_BATCH(2);
+      OUT_BATCH(_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP << 16 | (2 - 2));
+      OUT_BATCH(0);
+      ADVANCE_BATCH();
+   }
 }
 
 const struct brw_tracked_state brw_constant_buffer = {
    .dirty = {
       .mesa = _NEW_PROGRAM_CONSTANTS,
-      .brw  = (BRW_NEW_URB_FENCE |
-              BRW_NEW_PSP | /* Implicit - hardware requires this, not used above */
-              BRW_NEW_CURBE_OFFSETS |
-              BRW_NEW_BATCH),
-      .cache = (CACHE_NEW_VS_PROG |
-                CACHE_NEW_WM_PROG)
+      .brw  = BRW_NEW_BATCH |
+              BRW_NEW_CURBE_OFFSETS |
+              BRW_NEW_FRAGMENT_PROGRAM |
+              BRW_NEW_FS_PROG_DATA |
+              BRW_NEW_PSP | /* Implicit - hardware requires this, not used above */
+              BRW_NEW_URB_FENCE |
+              BRW_NEW_VS_PROG_DATA,
    },
    .emit = brw_upload_constant_buffer,
 };