i965: Split brw_wm_surfaces state into renderbuffer and texture atoms.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 2 Nov 2011 20:50:02 +0000 (13:50 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 11 Nov 2011 06:51:19 +0000 (22:51 -0800)
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@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c

index 3979206b3fb1c9356e1bf9dfb2e61b0a15aeeae5..9b11c6f1874253224a1d8639220d163c9f458b95 100644 (file)
@@ -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;
 
index d3bc5e0f440a9de9780694b1e794d9fecc3d1b47..7f32c20da5d746dceffe9aafa843169d6520e677 100644 (file)
@@ -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,
index 1bce06c1eae849d3831ab9c3f7c2d5b41632d050..3bda5fa912a4cffcc7155fd5af56f553a01a47bb 100644 (file)
@@ -542,11 +542,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;
@@ -565,15 +564,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;
       }
@@ -582,15 +600,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,
 };
 
 /**