i965/gen6: Move scissor state to state streaming.
authorEric Anholt <eric@anholt.net>
Mon, 25 Apr 2011 03:02:38 +0000 (20:02 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 29 Apr 2011 22:26:18 +0000 (15:26 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_misc_state.c
src/mesa/drivers/dri/i965/brw_sf_state.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_vtbl.c
src/mesa/drivers/dri/i965/gen6_scissor_state.c

index 748a750383338fe7762740ae186edda5f08dea92..0876c3e94e62803eaa53da0a45b874e3e0be4bd5 100644 (file)
@@ -668,7 +668,6 @@ struct brw_context
       struct brw_sf_prog_data *prog_data;
 
       drm_intel_bo *prog_bo;
-      drm_intel_bo *state_bo;
       uint32_t state_offset;
       uint32_t vp_offset;
    } sf;
index 0ddd61bfda119e20bca318492787fee7a7cb5ca3..c0ed6f750cd17f9b4cd753a2309d552523b398b3 100644 (file)
@@ -166,7 +166,6 @@ static void prepare_psp_urb_cbs(struct brw_context *brw)
    brw_add_validated_bo(brw, brw->vs.state_bo);
    brw_add_validated_bo(brw, brw->gs.state_bo);
    brw_add_validated_bo(brw, brw->clip.state_bo);
-   brw_add_validated_bo(brw, brw->sf.state_bo);
 }
 
 static void upload_psp_urb_cbs(struct brw_context *brw )
index 0fa1dc90dcd5ee487d5e1ace6d462ed475991457..78b22c4df3d50cf2c7f22a06ec3e6f1faad3ffcb 100644 (file)
@@ -39,7 +39,7 @@
 static void upload_sf_vp(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
-   struct gl_context *ctx = &brw->intel.ctx;
+   struct gl_context *ctx = &intel->ctx;
    const GLfloat depth_scale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
    struct brw_sf_viewport *sfv;
    GLfloat y_scale, y_bias;
index 78d6f50d7bab2541c9e6743c6a5826ee0e79f446..f1f51c8761c4f1c2c223a6fe82642ce17658b0ed 100644 (file)
@@ -103,7 +103,6 @@ extern const struct brw_tracked_state gen6_depth_stencil_state;
 extern const struct brw_tracked_state gen6_gs_state;
 extern const struct brw_tracked_state gen6_sampler_state;
 extern const struct brw_tracked_state gen6_scissor_state;
-extern const struct brw_tracked_state gen6_scissor_state_pointers;
 extern const struct brw_tracked_state gen6_sf_state;
 extern const struct brw_tracked_state gen6_sf_vp;
 extern const struct brw_tracked_state gen6_urb;
index e148577214950d8519f7641eb6c59435d0c81d41..7d215f563c3f1eac9bbc4c97b50d06d1b5097e20 100644 (file)
@@ -149,7 +149,6 @@ static const struct brw_tracked_state *gen6_atoms[] =
    &gen6_wm_state,
 
    &gen6_scissor_state,
-   &gen6_scissor_state_pointers,
 
    &brw_state_base_address,
 
index 36c1cc8bba81b1ed63b2719104d0b40cb52bd850..b1b2e42d3deb2230adaac15976cc07c69f426fe2 100644 (file)
@@ -84,7 +84,6 @@ static void brw_destroy_context( struct intel_context *intel )
    dri_bo_release(&brw->clip.prog_bo);
    dri_bo_release(&brw->clip.state_bo);
    dri_bo_release(&brw->sf.prog_bo);
-   dri_bo_release(&brw->sf.state_bo);
    dri_bo_release(&brw->wm.prog_bo);
    dri_bo_release(&brw->wm.const_bo);
    dri_bo_release(&brw->cc.prog_bo);
index 12b65826ae99a98531f1258e99c6c43194546953..d0b37a078d5638ca79d67256872c1b64ec4fd865 100644 (file)
 #include "intel_batchbuffer.h"
 
 static void
-prepare_scissor_state(struct brw_context *brw)
+gen6_prepare_scissor_state(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->intel.ctx;
+   struct intel_context *intel = &brw->intel;
+   struct gl_context *ctx = &intel->ctx;
    const GLboolean render_to_fbo = (ctx->DrawBuffer->Name != 0);
-   struct gen6_scissor_rect scissor;
+   struct gen6_scissor_rect *scissor;
+   uint32_t scissor_state_offset;
+
+   scissor = brw_state_batch(brw, sizeof(*scissor), 32, &scissor_state_offset);
 
    /* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT */
 
@@ -54,62 +58,37 @@ prepare_scissor_state(struct brw_context *brw)
        * anything.  Instead, just provide a min > max scissor inside
        * the bounds, which produces the expected no rendering.
        */
-      scissor.xmin = 1;
-      scissor.xmax = 0;
-      scissor.ymin = 1;
-      scissor.ymax = 0;
+      scissor->xmin = 1;
+      scissor->xmax = 0;
+      scissor->ymin = 1;
+      scissor->ymax = 0;
    } else if (render_to_fbo) {
       /* texmemory: Y=0=bottom */
-      scissor.xmin = ctx->DrawBuffer->_Xmin;
-      scissor.xmax = ctx->DrawBuffer->_Xmax - 1;
-      scissor.ymin = ctx->DrawBuffer->_Ymin;
-      scissor.ymax = ctx->DrawBuffer->_Ymax - 1;
+      scissor->xmin = ctx->DrawBuffer->_Xmin;
+      scissor->xmax = ctx->DrawBuffer->_Xmax - 1;
+      scissor->ymin = ctx->DrawBuffer->_Ymin;
+      scissor->ymax = ctx->DrawBuffer->_Ymax - 1;
    }
    else {
       /* memory: Y=0=top */
-      scissor.xmin = ctx->DrawBuffer->_Xmin;
-      scissor.xmax = ctx->DrawBuffer->_Xmax - 1;
-      scissor.ymin = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax;
-      scissor.ymax = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin - 1;
+      scissor->xmin = ctx->DrawBuffer->_Xmin;
+      scissor->xmax = ctx->DrawBuffer->_Xmax - 1;
+      scissor->ymin = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax;
+      scissor->ymax = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin - 1;
    }
 
-   drm_intel_bo_unreference(brw->sf.state_bo);
-   brw->sf.state_bo = brw_cache_data(&brw->cache, BRW_SF_UNIT,
-                                    &scissor, sizeof(scissor));
-}
-
-const struct brw_tracked_state gen6_scissor_state = {
-   .dirty = {
-      .mesa = _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT,
-      .brw = 0,
-      .cache = 0,
-   },
-   .prepare = prepare_scissor_state,
-};
-
-static void upload_scissor_state_pointers(struct brw_context *brw)
-{
-   struct intel_context *intel = &brw->intel;
-
    BEGIN_BATCH(2);
    OUT_BATCH(_3DSTATE_SCISSOR_STATE_POINTERS << 16 | (2 - 2));
-   OUT_RELOC(brw->sf.state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   OUT_RELOC(intel->batch.bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
+            scissor_state_offset);
    ADVANCE_BATCH();
-
 }
 
-
-static void prepare_scissor_state_pointers(struct brw_context *brw)
-{
-   brw_add_validated_bo(brw, brw->sf.state_bo);
-}
-
-const struct brw_tracked_state gen6_scissor_state_pointers = {
+const struct brw_tracked_state gen6_scissor_state = {
    .dirty = {
-      .mesa = 0,
+      .mesa = _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT,
       .brw = BRW_NEW_BATCH,
-      .cache = CACHE_NEW_SF_UNIT
+      .cache = 0,
    },
-   .prepare = prepare_scissor_state_pointers,
-   .emit = upload_scissor_state_pointers,
+   .prepare = gen6_prepare_scissor_state,
 };