Mesa (master): i965: Remove the surface key used to generate constant surfaces.

Eric Anholt anholt at kemper.freedesktop.org
Fri Jun 11 19:28:13 UTC 2010


Module: Mesa
Branch: master
Commit: 108264e859b4f435e9608472dc2e388aa200183c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=108264e859b4f435e9608472dc2e388aa200183c

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jun 11 12:21:23 2010 -0700

i965: Remove the surface key used to generate constant surfaces.

We had to fill out all that junk when using the cache, but no more.

---

 src/mesa/drivers/dri/i965/brw_state.h            |   17 +---------
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c |   22 +------------
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   37 ++++++----------------
 3 files changed, 14 insertions(+), 62 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 3c30d1f..5756b8f 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -110,20 +110,6 @@ const struct brw_tracked_state gen6_viewport_state;
 const struct brw_tracked_state gen6_vs_state;
 const struct brw_tracked_state gen6_wm_state;
 
-/**
- * Use same key for WM and VS surfaces.
- */
-struct brw_surface_key {
-   GLenum target, depthmode;
-   drm_intel_bo *bo;
-   GLint format, internal_format;
-   GLint first_level, last_level;
-   GLint width, height, depth;
-   GLint pitch, cpp;
-   uint32_t tiling;
-   GLuint offset;
-};
-
 /***********************************************************************
  * brw_state.c
  */
@@ -193,7 +179,8 @@ void *brw_state_batch(struct brw_context *brw,
 
 /* brw_wm_surface_state.c */
 void brw_create_constant_surface(struct brw_context *brw,
-				 struct brw_surface_key *key,
+				 drm_intel_bo *bo,
+				 int width,
 				 drm_intel_bo **out_bo,
 				 uint32_t *out_offset);
 
diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
index c697756..be9e415 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
@@ -105,7 +105,6 @@ brw_update_vs_constant_surface( GLcontext *ctx,
                                 GLuint surf)
 {
    struct brw_context *brw = brw_context(ctx);
-   struct brw_surface_key key;
    struct brw_vertex_program *vp =
       (struct brw_vertex_program *) brw->vertex_program;
    const struct gl_program_parameter_list *params = vp->program.Base.Parameters;
@@ -121,25 +120,8 @@ brw_update_vs_constant_surface( GLcontext *ctx,
       return;
    }
 
-   memset(&key, 0, sizeof(key));
-
-   key.format = MESA_FORMAT_RGBA_FLOAT32;
-   key.internal_format = GL_RGBA;
-   key.bo = brw->vs.const_bo;
-   key.depthmode = GL_NONE;
-   key.pitch = params->NumParameters;
-   key.width = params->NumParameters;
-   key.height = 1;
-   key.depth = 1;
-   key.cpp = 16;
-
-   /*
-   printf("%s:\n", __FUNCTION__);
-   printf("  width %d  height %d  depth %d  cpp %d  pitch %d\n",
-          key.width, key.height, key.depth, key.cpp, key.pitch);
-   */
-
-   brw_create_constant_surface(brw, &key, &brw->vs.surf_bo[surf],
+   brw_create_constant_surface(brw, brw->vs.const_bo, params->NumParameters,
+			       &brw->vs.surf_bo[surf],
 			       &brw->vs.surf_offset[surf]);
 }
 
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 25b7e46..77898db 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -257,11 +257,12 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit )
  */
 void
 brw_create_constant_surface(struct brw_context *brw,
-			    struct brw_surface_key *key,
+			    drm_intel_bo *bo,
+			    int width,
 			    drm_intel_bo **out_bo,
 			    uint32_t *out_offset)
 {
-   const GLint w = key->width - 1;
+   const GLint w = width - 1;
    struct brw_surface_state surf;
    void *map;
 
@@ -271,14 +272,14 @@ brw_create_constant_surface(struct brw_context *brw,
    surf.ss0.surface_type = BRW_SURFACE_BUFFER;
    surf.ss0.surface_format = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT;
 
-   assert(key->bo);
-   surf.ss1.base_addr = key->bo->offset; /* reloc */
+   assert(bo);
+   surf.ss1.base_addr = bo->offset; /* reloc */
 
    surf.ss2.width = w & 0x7f;            /* bits 6:0 of size or width */
    surf.ss2.height = (w >> 7) & 0x1fff;  /* bits 19:7 of size or width */
    surf.ss3.depth = (w >> 20) & 0x7f;    /* bits 26:20 of size or width */
-   surf.ss3.pitch = (key->pitch * key->cpp) - 1; /* ignored?? */
-   brw_set_surface_tiling(&surf, key->tiling); /* tiling now allowed */
+   surf.ss3.pitch = (width * 16) - 1; /* ignored?? */
+   brw_set_surface_tiling(&surf, I915_TILING_NONE); /* tiling now allowed */
 
    map = brw_state_batch(brw, sizeof(surf), 32, out_bo, out_offset);
    memcpy(map, &surf, sizeof(surf));
@@ -289,7 +290,7 @@ brw_create_constant_surface(struct brw_context *brw,
     */
    drm_intel_bo_emit_reloc(*out_bo, (*out_offset +
 				     offsetof(struct brw_surface_state, ss1)),
-			   key->bo, 0,
+			   bo, 0,
 			   I915_GEM_DOMAIN_SAMPLER, 0);
 }
 
@@ -349,7 +350,6 @@ const struct brw_tracked_state brw_wm_constants = {
 static void upload_wm_constant_surface(struct brw_context *brw )
 {
    GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;
-   struct brw_surface_key key;
    struct brw_fragment_program *fp =
       (struct brw_fragment_program *) brw->fragment_program;
    const struct gl_program_parameter_list *params =
@@ -367,25 +367,8 @@ static void upload_wm_constant_surface(struct brw_context *brw )
       return;
    }
 
-   memset(&key, 0, sizeof(key));
-
-   key.format = MESA_FORMAT_RGBA_FLOAT32;
-   key.internal_format = GL_RGBA;
-   key.bo = brw->wm.const_bo;
-   key.depthmode = GL_NONE;
-   key.pitch = params->NumParameters;
-   key.width = params->NumParameters;
-   key.height = 1;
-   key.depth = 1;
-   key.cpp = 16;
-
-   /*
-   printf("%s:\n", __FUNCTION__);
-   printf("  width %d  height %d  depth %d  cpp %d  pitch %d\n",
-          key.width, key.height, key.depth, key.cpp, key.pitch);
-   */
-
-   brw_create_constant_surface(brw, &key, &brw->wm.surf_bo[surf],
+   brw_create_constant_surface(brw, brw->wm.const_bo, params->NumParameters,
+			       &brw->wm.surf_bo[surf],
 			       &brw->wm.surf_offset[surf]);
    brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
 }




More information about the mesa-commit mailing list