[Mesa-dev] [PATCH 17/22] i965/gs: generalize brw_texture_surfaces in preparation for gs.

Paul Berry stereotype441 at gmail.com
Mon Aug 26 15:12:48 PDT 2013


There is a slight functionality change.  Previously we would compute a
common value for num_samplers for all stages, and populate that many
entries in each stage's surf_offset table regardless of how many
samplers each stage used.  Now we only populate the number of entries
in the surf_offset table corresponding to the number of samplers
actually used by the stage.
---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 64 ++++++++++++------------
 1 file changed, 33 insertions(+), 31 deletions(-)

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 3fecc68..1b4388c 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -742,51 +742,53 @@ const struct brw_tracked_state gen6_renderbuffer_surfaces = {
    .emit = brw_update_renderbuffer_surfaces,
 };
 
-/**
- * Construct SURFACE_STATE objects for enabled textures.
- */
+
 static void
-brw_update_texture_surfaces(struct brw_context *brw)
+update_stage_texture_surfaces(struct brw_context *brw,
+                              const struct gl_program *prog,
+                              uint32_t *surf_offset)
 {
-   struct gl_context *ctx = &brw->ctx;
+   if (!prog)
+      return;
 
-   /* BRW_NEW_VERTEX_PROGRAM and BRW_NEW_FRAGMENT_PROGRAM:
-    * Unfortunately, we're stuck using the gl_program structs until the
-    * ARB_fragment_program front-end gets converted to GLSL IR.  These
-    * have the downside that SamplerUnits is split and only contains the
-    * mappings for samplers active in that stage.
-    */
-   struct gl_program *vs = (struct gl_program *) brw->vertex_program;
-   struct gl_program *fs = (struct gl_program *) brw->fragment_program;
+   struct gl_context *ctx = &brw->ctx;
 
-   unsigned num_samplers = _mesa_fls(vs->SamplersUsed | fs->SamplersUsed);
+   unsigned num_samplers = _mesa_fls(prog->SamplersUsed);
 
    for (unsigned s = 0; s < num_samplers; s++) {
-      brw->vs.base.surf_offset[SURF_INDEX_VEC4_TEXTURE(s)] = 0;
-      brw->wm.surf_offset[SURF_INDEX_TEXTURE(s)] = 0;
+      surf_offset[s] = 0;
 
-      if (vs->SamplersUsed & (1 << s)) {
-         const unsigned unit = vs->SamplerUnits[s];
+      if (prog->SamplersUsed & (1 << s)) {
+         const unsigned unit = prog->SamplerUnits[s];
 
          /* _NEW_TEXTURE */
          if (ctx->Texture.Unit[unit]._ReallyEnabled) {
-            brw->vtbl.update_texture_surface(ctx, unit,
-                                             brw->vs.base.surf_offset +
-                                             SURF_INDEX_VEC4_TEXTURE(s));
+            brw->vtbl.update_texture_surface(ctx, unit, surf_offset + s);
          }
       }
+   }
+}
 
-      if (fs->SamplersUsed & (1 << s)) {
-         const unsigned unit = fs->SamplerUnits[s];
 
-         /* _NEW_TEXTURE */
-         if (ctx->Texture.Unit[unit]._ReallyEnabled) {
-            brw->vtbl.update_texture_surface(ctx, unit,
-                                             brw->wm.surf_offset +
-                                             SURF_INDEX_TEXTURE(s));
-         }
-      }
-   }
+/**
+ * Construct SURFACE_STATE objects for enabled textures.
+ */
+static void
+brw_update_texture_surfaces(struct brw_context *brw)
+{
+   /* BRW_NEW_VERTEX_PROGRAM */
+   struct gl_program *vs = (struct gl_program *) brw->vertex_program;
+
+   /* BRW_NEW_FRAGMENT_PROGRAM */
+   struct gl_program *fs = (struct gl_program *) brw->fragment_program;
+
+   /* _NEW_TEXTURE */
+   update_stage_texture_surfaces(brw, vs,
+                                 brw->vs.base.surf_offset +
+                                 SURF_INDEX_VEC4_TEXTURE(0));
+   update_stage_texture_surfaces(brw, fs,
+                                 brw->wm.surf_offset +
+                                 SURF_INDEX_TEXTURE(0));
 
    brw->state.dirty.brw |= BRW_NEW_SURFACES;
 }
-- 
1.8.4



More information about the mesa-dev mailing list