[Mesa-dev] [PATCH 2/9] i965: Rework Sandybridge 3DSTATE_VIEWPORT_STATE_POINTERS.

Kenneth Graunke kenneth at whitecape.org
Thu May 11 23:31:59 UTC 2017


On Gen7+ we emit 3DSTATE_VIEWPORT_STATE_POINTERS_{SF_CL,CC} when
emitting a new viewport.

This patch makes us take the same approach on Sandybridge - but because
we have a combined command, we just set the appropriate "change" bits.
This eliminates an atom, some dirty flagging, and some brw->*.vp_offset
writes.  It does mean we'll emit two 3DSTATE_VIEWPORT_STATE_POINTERS
instead of one if both change, but that's probably fine.
---
 src/mesa/drivers/dri/i965/genX_state_upload.c | 48 +++++++++------------------
 1 file changed, 15 insertions(+), 33 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 44c1ffc4045..39801ecb259 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -1842,6 +1842,11 @@ genX(upload_cc_viewport)(struct brw_context *brw)
    brw_batch_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), ptr) {
       ptr.CCViewportPointer = cc_vp_offset;
    }
+#elif GEN_GEN == 6
+   brw_batch_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_POINTERS), vp) {
+      vp.CCViewportStateChange = 1;
+      vp.PointertoCC_VIEWPORT = cc_vp_offset;
+   }
 #else
    brw->cc.vp_offset = cc_vp_offset;
    ctx->NewDriverState |= BRW_NEW_CC_VP;
@@ -1967,10 +1972,11 @@ genX(upload_sf_clip_viewport)(struct brw_context *brw)
 #else
    struct GENX(SF_VIEWPORT) sfv;
    struct GENX(CLIP_VIEWPORT) clv;
+   uint32_t sf_vp_offset, clip_vp_offset;
    uint32_t *sf_map = brw_state_batch(brw, 8 * 4 * viewport_count,
-                                      32, &brw->sf.vp_offset);
+                                      32, &sf_vp_offset);
    uint32_t *clip_map = brw_state_batch(brw, 4 * 4 * viewport_count,
-                                        32, &brw->clip.vp_offset);
+                                        32, &clip_vp_offset);
 #endif
 
    /* _NEW_BUFFERS */
@@ -2045,6 +2051,13 @@ genX(upload_sf_clip_viewport)(struct brw_context *brw)
    brw_batch_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP), ptr) {
       ptr.SFClipViewportPointer = sf_clip_vp_offset;
    }
+#elif GEN_GEN == 6
+   brw_batch_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_POINTERS), vp) {
+      vp.SFViewportStateChange = 1;
+      vp.CLIPViewportStateChange = 1;
+      vp.PointertoCLIP_VIEWPORT = clip_vp_offset;
+      vp.PointertoSF_VIEWPORT = sf_vp_offset;
+   }
 #else
    brw->ctx.NewDriverState |= BRW_NEW_SF_VP | BRW_NEW_CLIP_VP;
 #endif
@@ -3872,36 +3885,6 @@ static const struct brw_tracked_state genX(ps_blend) = {
 
 /* ---------------------------------------------------------------------- */
 
-#if GEN_GEN == 6
-static void
-genX(upload_viewport_state_pointers)(struct brw_context *brw)
-{
-   brw_batch_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_POINTERS), vp) {
-      vp.CCViewportStateChange = 1;
-      vp.SFViewportStateChange = 1;
-      vp.CLIPViewportStateChange = 1;
-      vp.PointertoCLIP_VIEWPORT = brw->clip.vp_offset;
-      vp.PointertoSF_VIEWPORT = brw->sf.vp_offset;
-      vp.PointertoCC_VIEWPORT = brw->cc.vp_offset;
-   }
-}
-
-static const struct brw_tracked_state genX(viewport_state) = {
-   .dirty = {
-      .mesa = 0,
-      .brw = BRW_NEW_BATCH |
-             BRW_NEW_BLORP |
-             BRW_NEW_CC_VP |
-             BRW_NEW_CLIP_VP |
-             BRW_NEW_SF_VP |
-             BRW_NEW_STATE_BASE_ADDRESS,
-   },
-   .emit = genX(upload_viewport_state_pointers),
-};
-#endif
-
-/* ---------------------------------------------------------------------- */
-
 void
 genX(init_atoms)(struct brw_context *brw)
 {
@@ -3971,7 +3954,6 @@ genX(init_atoms)(struct brw_context *brw)
       /* Command packets: */
 
       &genX(cc_vp),
-      &genX(viewport_state),	/* must do after *_vp stages */
 
       &gen6_urb,
       &genX(blend_state),		/* must do before cc unit */
-- 
2.12.2



More information about the mesa-dev mailing list