fixup draw/depth region handling in i830 along lines of i915
authorDave Airlie <airliedfreedesktop.org>
Thu, 23 Nov 2006 00:09:16 +0000 (00:09 +0000)
committerDave Airlie <airliedfreedesktop.org>
Thu, 23 Nov 2006 00:09:16 +0000 (00:09 +0000)
src/mesa/drivers/dri/i915tex/i830_context.h
src/mesa/drivers/dri/i915tex/i830_metaops.c
src/mesa/drivers/dri/i915tex/i830_vtbl.c

index e5377b3..3d75410 100644 (file)
@@ -156,6 +156,11 @@ do {                                               \
  */
 extern void i830InitVtbl(struct i830_context *i830);
 
+extern void
+i830_state_draw_region(struct intel_context *intel,
+                       struct i830_hw_state *state,
+                       struct intel_region *color_region,
+                       struct intel_region *depth_region);
 /* i830_context.c
  */
 extern GLboolean
index c90f502..f76646d 100644 (file)
@@ -400,40 +400,12 @@ meta_import_pixel_state(struct intel_context *intel)
  */
 static void
 meta_draw_region(struct intel_context *intel,
-                 struct intel_region *draw_region,
+                 struct intel_region *color_region,
                  struct intel_region *depth_region)
 {
    struct i830_context *i830 = i830_context(&intel->ctx);
-   GLuint format;
-   GLuint depth_format = DEPTH_FRMT_16_FIXED;
 
-   intel_region_release(&i830->meta.draw_region);
-   intel_region_reference(&i830->meta.draw_region, draw_region);
-
-   intel_region_release(&i830->meta.depth_region);
-   intel_region_reference(&i830->meta.depth_region, depth_region);
-
-   /* XXX FBO: grab code from i915 meta_draw_region */
-
-   /* XXX: 555 support?
-    */
-   if (draw_region->cpp == 2)
-      format = DV_PF_565;
-   else
-      format = DV_PF_8888;
-
-   if (depth_region) {
-      if (depth_region->cpp == 2)
-         depth_format = DEPTH_FRMT_16_FIXED;
-      else
-         depth_format = DEPTH_FRMT_24_FIXED_8_OTHER;
-   }
-
-   i830->meta.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) |       /* .5 */
-                                          DSTORG_VERT_BIAS(0x8) |       /* .5 */
-                                          format | DEPTH_IS_Z | depth_format);
-
-   i830->meta.emitted &= ~I830_UPLOAD_BUFFERS;
+   i830_state_draw_region(intel, &i830->meta, color_region, depth_region);
 }
 
 
index 45502da..18fc6d4 100644 (file)
@@ -518,28 +518,79 @@ i830_destroy_context(struct intel_context *intel)
    _tnl_free_vertices(&intel->ctx);
 }
 
-static void
-i830_set_draw_region(struct intel_context *intel,
-                     struct intel_region *draw_region,
-                     struct intel_region *depth_region)
+
+void
+i830_state_draw_region(struct intel_context *intel,
+                      struct i830_hw_state *state,
+                      struct intel_region *color_region,
+                      struct intel_region *depth_region)
 {
    struct i830_context *i830 = i830_context(&intel->ctx);
+   GLuint value;
 
-   intel_region_release(&i830->state.draw_region);
-   intel_region_release(&i830->state.depth_region);
-   intel_region_reference(&i830->state.draw_region, draw_region);
-   intel_region_reference(&i830->state.depth_region, depth_region);
+   ASSERT(state == &i830->state || state == &i830->meta);
 
-   /* XXX FBO: Need code from i915_set_draw_region() */
+   if (state->draw_region != color_region) {
+      intel_region_release(&state->draw_region);
+      intel_region_reference(&state->draw_region, color_region);
+   }
+   if (state->depth_region != depth_region) {
+      intel_region_release(&state->depth_region);
+      intel_region_reference(&state->depth_region, depth_region);
+   }
+
+   /*
+    * Set stride/cpp values
+    */
+   if (color_region) {
+      state->Buffer[I830_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+      state->Buffer[I830_DESTREG_CBUFADDR1] =
+         (BUF_3D_ID_COLOR_BACK |
+          BUF_3D_PITCH(color_region->pitch * color_region->cpp) |
+          BUF_3D_USE_FENCE);
+   }
+
+   if (depth_region) {
+      state->Buffer[I830_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+      state->Buffer[I830_DESTREG_DBUFADDR1] =
+         (BUF_3D_ID_DEPTH |
+          BUF_3D_PITCH(depth_region->pitch * depth_region->cpp) |
+          BUF_3D_USE_FENCE);
+   }
+
+   /*
+    * Compute/set I830_DESTREG_DV1 value
+    */
+   value = (DSTORG_HORT_BIAS(0x8) |     /* .5 */
+            DSTORG_VERT_BIAS(0x8) | DEPTH_IS_Z);    /* .5 */
+            
+   if (color_region && color_region->cpp == 4) {
+      value |= DV_PF_8888;
+   }
+   else {
+      value |= DV_PF_565;
+   }
+   if (depth_region && depth_region->cpp == 4) {
+      value |= DEPTH_FRMT_24_FIXED_8_OTHER;
+   }
+   else {
+      value |= DEPTH_FRMT_16_FIXED;
+   }
+   state->Buffer[I830_DESTREG_DV1] = value;
 
    I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
-   I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
-   i830->state.Buffer[I830_DESTREG_CBUFADDR1] =
-      (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(draw_region->pitch) |
-       BUF_3D_USE_FENCE);
-   i830->state.Buffer[I830_DESTREG_DBUFADDR1] =
-      (BUF_3D_ID_DEPTH | BUF_3D_PITCH(depth_region->pitch) |
-       BUF_3D_USE_FENCE);
+
+
+}
+
+
+static void
+i830_set_draw_region(struct intel_context *intel,
+                     struct intel_region *color_region,
+                     struct intel_region *depth_region)
+{
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   i830_state_draw_region(intel, &i830->state, color_region, depth_region);
 }
 
 #if 0