[Mesa-dev] [PATCH 16/22] i965: Modify signature to update_texture_surface functions.

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


Previously these functions would accept a pointer to the binding table
and an index indicating which entry in the binding table should be
updated.  Now they merely take a pointer to the binding table entry to
be updated.

This will make it easier to generalize brw_texture_surfaces to support
geometry shaders.
---
 src/mesa/drivers/dri/i965/brw_context.h           |  3 +--
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  | 20 +++++++++-----------
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 16 +++++++---------
 3 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 28943e2..487680e 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -864,8 +864,7 @@ struct brw_context
 
       void (*update_texture_surface)(struct gl_context *ctx,
                                      unsigned unit,
-                                     uint32_t *binding_table,
-                                     unsigned surf_index);
+                                     uint32_t *surf_offset);
       void (*update_renderbuffer_surface)(struct brw_context *brw,
 					  struct gl_renderbuffer *rb,
 					  bool layered,
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 e08a127..3fecc68 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -194,8 +194,7 @@ brw_get_texture_swizzle(const struct gl_context *ctx,
 static void
 brw_update_buffer_texture_surface(struct gl_context *ctx,
                                   unsigned unit,
-                                  uint32_t *binding_table,
-                                  unsigned surf_index)
+                                  uint32_t *surf_offset)
 {
    struct brw_context *brw = brw_context(ctx);
    struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
@@ -213,7 +212,7 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
    }
 
    surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
-			  6 * 4, 32, &binding_table[surf_index]);
+			  6 * 4, 32, surf_offset);
 
    surf[0] = (BRW_SURFACE_BUFFER << BRW_SURFACE_TYPE_SHIFT |
 	      (brw_format_for_mesa_format(format) << BRW_SURFACE_FORMAT_SHIFT));
@@ -226,7 +225,7 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
 
       /* Emit relocation to surface contents. */
       drm_intel_bo_emit_reloc(brw->batch.bo,
-			      binding_table[surf_index] + 4,
+			      *surf_offset + 4,
 			      bo, 0, I915_GEM_DOMAIN_SAMPLER, 0);
 
       int w = intel_obj->Base.Size / texel_size;
@@ -247,8 +246,7 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
 static void
 brw_update_texture_surface(struct gl_context *ctx,
                            unsigned unit,
-                           uint32_t *binding_table,
-                           unsigned surf_index)
+                           uint32_t *surf_offset)
 {
    struct brw_context *brw = brw_context(ctx);
    struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
@@ -260,12 +258,12 @@ brw_update_texture_surface(struct gl_context *ctx,
    uint32_t tile_x, tile_y;
 
    if (tObj->Target == GL_TEXTURE_BUFFER) {
-      brw_update_buffer_texture_surface(ctx, unit, binding_table, surf_index);
+      brw_update_buffer_texture_surface(ctx, unit, surf_offset);
       return;
    }
 
    surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
-			  6 * 4, 32, &binding_table[surf_index]);
+			  6 * 4, 32, surf_offset);
 
    surf[0] = (translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
 	      BRW_SURFACE_MIPMAPLAYOUT_BELOW << BRW_SURFACE_MIPLAYOUT_SHIFT |
@@ -303,7 +301,7 @@ brw_update_texture_surface(struct gl_context *ctx,
 
    /* Emit relocation to surface contents */
    drm_intel_bo_emit_reloc(brw->batch.bo,
-			   binding_table[surf_index] + 4,
+			   *surf_offset + 4,
 			   intelObj->mt->region->bo,
                            surf[1] - intelObj->mt->region->bo->offset,
 			   I915_GEM_DOMAIN_SAMPLER, 0);
@@ -773,7 +771,7 @@ brw_update_texture_surfaces(struct brw_context *brw)
          /* _NEW_TEXTURE */
          if (ctx->Texture.Unit[unit]._ReallyEnabled) {
             brw->vtbl.update_texture_surface(ctx, unit,
-                                             brw->vs.base.surf_offset,
+                                             brw->vs.base.surf_offset +
                                              SURF_INDEX_VEC4_TEXTURE(s));
          }
       }
@@ -784,7 +782,7 @@ brw_update_texture_surfaces(struct brw_context *brw)
          /* _NEW_TEXTURE */
          if (ctx->Texture.Unit[unit]._ReallyEnabled) {
             brw->vtbl.update_texture_surface(ctx, unit,
-                                             brw->wm.surf_offset,
+                                             brw->wm.surf_offset +
                                              SURF_INDEX_TEXTURE(s));
          }
       }
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 91f854b..6b28937 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -228,8 +228,7 @@ gen7_check_surface_setup(uint32_t *surf, bool is_render_target)
 static void
 gen7_update_buffer_texture_surface(struct gl_context *ctx,
                                    unsigned unit,
-                                   uint32_t *binding_table,
-                                   unsigned surf_index)
+                                   uint32_t *surf_offset)
 {
    struct brw_context *brw = brw_context(ctx);
    struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
@@ -239,7 +238,7 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,
    gl_format format = tObj->_BufferObjectFormat;
 
    uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
-                                    8 * 4, 32, &binding_table[surf_index]);
+                                    8 * 4, 32, surf_offset);
    memset(surf, 0, 8 * 4);
 
    uint32_t surface_format = brw_format_for_mesa_format(format);
@@ -256,7 +255,7 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,
       surf[1] = bo->offset; /* reloc */
 
       drm_intel_bo_emit_reloc(brw->batch.bo,
-			      binding_table[surf_index] + 4,
+			      *surf_offset + 4,
 			      bo, 0,
 			      I915_GEM_DOMAIN_SAMPLER, 0);
 
@@ -276,8 +275,7 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,
 static void
 gen7_update_texture_surface(struct gl_context *ctx,
                             unsigned unit,
-                            uint32_t *binding_table,
-                            unsigned surf_index)
+                            uint32_t *surf_offset)
 {
    struct brw_context *brw = brw_context(ctx);
    struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
@@ -288,12 +286,12 @@ gen7_update_texture_surface(struct gl_context *ctx,
    uint32_t tile_x, tile_y;
 
    if (tObj->Target == GL_TEXTURE_BUFFER) {
-      gen7_update_buffer_texture_surface(ctx, unit, binding_table, surf_index);
+      gen7_update_buffer_texture_surface(ctx, unit, surf_offset);
       return;
    }
 
    uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
-                                    8 * 4, 32, &binding_table[surf_index]);
+                                    8 * 4, 32, surf_offset);
    memset(surf, 0, 8 * 4);
 
    uint32_t tex_format = translate_tex_format(brw,
@@ -359,7 +357,7 @@ gen7_update_texture_surface(struct gl_context *ctx,
 
    /* Emit relocation to surface contents */
    drm_intel_bo_emit_reloc(brw->batch.bo,
-			   binding_table[surf_index] + 4,
+			   *surf_offset + 4,
 			   intelObj->mt->region->bo,
                            surf[1] - intelObj->mt->region->bo->offset,
 			   I915_GEM_DOMAIN_SAMPLER, 0);
-- 
1.8.4



More information about the mesa-dev mailing list