[Mesa-dev] [PATCH 08/13] i965: Split brw_wm_surfaces state into renderbuffer and texture atoms.

Kenneth Graunke kenneth at whitecape.org
Tue Nov 8 14:32:07 PST 2011


First, the texturing setup code is relevant for all pipeline stages,
while renderbuffer surfaces are only used by the WM.

Secondly, renderbuffer and texture setup depends on a different set of
dirty bits.  There's no reason to walk the array of textures when
changing draw buffers, or vice-versa.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_state.h            |    3 +-
 src/mesa/drivers/dri/i965/brw_state_upload.c     |    9 +++--
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   38 +++++++++++++++------
 3 files changed, 35 insertions(+), 15 deletions(-)

FACT CHECK: I believe brw_texture_surfaces doesn't need the NEW_BUFFERS dirty
bit.  However, I'm not positive, and would appreciate confirmation.

diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 3979206..9b11c6f 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -69,7 +69,8 @@ extern const struct brw_tracked_state brw_vs_unit;
 extern const struct brw_tracked_state brw_wm_input_sizes;
 extern const struct brw_tracked_state brw_wm_prog;
 extern const struct brw_tracked_state brw_wm_samplers;
-extern const struct brw_tracked_state brw_wm_surfaces;
+extern const struct brw_tracked_state brw_renderbuffer_surfaces;
+extern const struct brw_tracked_state brw_texture_surfaces;
 extern const struct brw_tracked_state brw_wm_binding_table;
 extern const struct brw_tracked_state brw_wm_unit;
 
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index d3bc5e0..7f32c20 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -67,7 +67,8 @@ static const struct brw_tracked_state *gen4_atoms[] =
    &brw_wm_pull_constants, /* Before brw_wm_binding_table */
 
    &brw_vs_surfaces,		/* must do before unit */
-   &brw_wm_surfaces,		/* must do before samplers and unit */
+   &brw_renderbuffer_surfaces,  /* must do before unit */
+   &brw_texture_surfaces,       /* must do before unit */
    &brw_wm_binding_table,
    &brw_wm_samplers,
 
@@ -138,7 +139,8 @@ static const struct brw_tracked_state *gen6_atoms[] =
    &gen6_wm_push_constants, /* Before wm_state */
 
    &brw_vs_surfaces,		/* must do before unit */
-   &brw_wm_surfaces,		/* must do before samplers and unit */
+   &brw_renderbuffer_surfaces,  /* must do before unit */
+   &brw_texture_surfaces,       /* must do before unit */
    &brw_wm_binding_table,
 
    &brw_wm_samplers,
@@ -202,7 +204,8 @@ const struct brw_tracked_state *gen7_atoms[] =
    &gen6_wm_push_constants, /* Before wm_surfaces and constant_buffer */
 
    &brw_vs_surfaces,		/* must do before unit */
-   &brw_wm_surfaces,		/* must do before samplers and unit */
+   &brw_renderbuffer_surfaces,  /* must do before unit */
+   &brw_texture_surfaces,       /* must do before unit */
    &brw_wm_binding_table,
 
    &gen7_samplers,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 2cc9392..b8dff89 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -508,11 +508,10 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
 }
 
 /**
- * Constructs the set of surface state objects pointed to by the
- * binding table.
+ * Construct SURFACE_STATE objects for renderbuffers/draw buffers.
  */
 static void
-brw_upload_wm_surfaces(struct brw_context *brw)
+brw_update_renderbuffer_surfaces(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
    struct gl_context *ctx = &brw->intel.ctx;
@@ -531,15 +530,34 @@ brw_upload_wm_surfaces(struct brw_context *brw)
    } else {
       intel->vtbl.update_null_renderbuffer_surface(brw, 0);
    }
+   brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
+}
+
+const struct brw_tracked_state brw_renderbuffer_surfaces = {
+   .dirty = {
+      .mesa = (_NEW_COLOR |
+               _NEW_BUFFERS),
+      .brw = BRW_NEW_BATCH,
+      .cache = 0
+   },
+   .emit = brw_update_renderbuffer_surfaces,
+};
 
-   /* Update surfaces for textures */
-   for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
+/**
+ * Construct SURFACE_STATE objects for enabled textures.
+ */
+static void
+brw_update_texture_surfaces(struct brw_context *brw)
+{
+   struct gl_context *ctx = &brw->intel.ctx;
+
+   for (unsigned i = 0; i < BRW_MAX_TEX_UNIT; i++) {
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
       const GLuint surf = SURF_INDEX_TEXTURE(i);
 
       /* _NEW_TEXTURE */
       if (texUnit->_ReallyEnabled) {
-	 intel->vtbl.update_texture_surface(ctx, i);
+	 brw->intel.vtbl.update_texture_surface(ctx, i);
       } else {
          brw->wm.surf_offset[surf] = 0;
       }
@@ -548,15 +566,13 @@ brw_upload_wm_surfaces(struct brw_context *brw)
    brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
 }
 
-const struct brw_tracked_state brw_wm_surfaces = {
+const struct brw_tracked_state brw_texture_surfaces = {
    .dirty = {
-      .mesa = (_NEW_COLOR |
-               _NEW_TEXTURE |
-               _NEW_BUFFERS),
+      .mesa = _NEW_TEXTURE,
       .brw = BRW_NEW_BATCH,
       .cache = 0
    },
-   .emit = brw_upload_wm_surfaces,
+   .emit = brw_update_texture_surfaces,
 };
 
 /**
-- 
1.7.7.1



More information about the mesa-dev mailing list