i965: Always pass the size argument to brw_cache_data.
authorEric Anholt <eric@anholt.net>
Thu, 5 Nov 2009 18:25:34 +0000 (10:25 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 6 Nov 2009 19:37:32 +0000 (11:37 -0800)
This keeps the individual state files from having to export their
structures for brw_state_cache initialization.

src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_sf_state.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_cache.c
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c

index 5cca605c3f1077b809599a763963c84688e91473..d4ccd28c9e85d6cd2ff564e0d4aa7a051f5ce115 100644 (file)
@@ -55,7 +55,8 @@ static void prepare_cc_vp( struct brw_context *brw )
    }
 
    dri_bo_unreference(brw->cc.vp_bo);
-   brw->cc.vp_bo = brw_cache_data( &brw->cache, BRW_CC_VP, &ccv, NULL, 0 );
+   brw->cc.vp_bo = brw_cache_data(&brw->cache, BRW_CC_VP, &ccv, sizeof(ccv),
+                                 NULL, 0);
 }
 
 const struct brw_tracked_state brw_cc_vp = {
index 59f9475b5ac066c16027123b3b7ac89f267b731b..e01930a4a0a1cdb0228053a32511bc3205718dc8 100644 (file)
@@ -333,7 +333,6 @@ struct brw_cache {
    struct brw_cache_item **items;
    GLuint size, n_items;
 
-   GLuint key_size[BRW_MAX_CACHE];             /* for fixed-size keys */
    GLuint aux_size[BRW_MAX_CACHE];
    char *name[BRW_MAX_CACHE];
 
index bc0f0760738dcdc5f733aed8ee94f09d7b50ca7c..d6b47b5d8dddafe1b82835accdbc225dbd0fb9eb 100644 (file)
@@ -93,7 +93,8 @@ static void upload_sf_vp(struct brw_context *brw)
    }
 
    dri_bo_unreference(brw->sf.vp_bo);
-   brw->sf.vp_bo = brw_cache_data( &brw->cache, BRW_SF_VP, &sfv, NULL, 0 );
+   brw->sf.vp_bo = brw_cache_data(&brw->cache, BRW_SF_VP, &sfv, sizeof(sfv),
+                                 NULL, 0);
 }
 
 const struct brw_tracked_state brw_sf_vp = {
index d639656b9d41a718e4cad082a386da65cf848339..ab6f1580806fc83ec298b6826045e6cb069d5e0a 100644 (file)
@@ -119,16 +119,10 @@ void brw_destroy_state(struct brw_context *brw);
 dri_bo *brw_cache_data(struct brw_cache *cache,
                       enum brw_cache_id cache_id,
                       const void *data,
+                      GLuint size,
                       dri_bo **reloc_bufs,
                       GLuint nr_reloc_bufs);
 
-dri_bo *brw_cache_data_sz(struct brw_cache *cache,
-                         enum brw_cache_id cache_id,
-                         const void *data,
-                         GLuint data_size,
-                         dri_bo **reloc_bufs,
-                         GLuint nr_reloc_bufs);
-
 dri_bo *brw_upload_cache( struct brw_cache *cache,
                          enum brw_cache_id cache_id,
                          const void *key,
index c262e1db8b9e83641d789b0adb61e37a783fde54..d2ab6247834d89c045fa8c8d9eaf45990f47b88d 100644 (file)
@@ -275,15 +275,22 @@ brw_upload_cache( struct brw_cache *cache,
 
 
 /**
- * This doesn't really work with aux data.  Use search/upload instead
+ * Wrapper around brw_cache_data_sz using the cache_id's canonical key size.
+ *
+ * If nr_reloc_bufs is nonzero, brw_search_cache()/brw_upload_cache() would be
+ * better to use, as the potentially changing offsets in the data-used-as-key
+ * will result in excessive cache misses.
+ *
+ * If aux data is involved, use search/upload instead.
+
  */
 dri_bo *
-brw_cache_data_sz(struct brw_cache *cache,
-                 enum brw_cache_id cache_id,
-                 const void *data,
-                 GLuint data_size,
-                 dri_bo **reloc_bufs,
-                 GLuint nr_reloc_bufs)
+brw_cache_data(struct brw_cache *cache,
+              enum brw_cache_id cache_id,
+              const void *data,
+              GLuint data_size,
+              dri_bo **reloc_bufs,
+              GLuint nr_reloc_bufs)
 {
    dri_bo *bo;
    struct brw_cache_item *item;
@@ -306,25 +313,6 @@ brw_cache_data_sz(struct brw_cache *cache,
    return bo;
 }
 
-
-/**
- * Wrapper around brw_cache_data_sz using the cache_id's canonical key size.
- *
- * If nr_reloc_bufs is nonzero, brw_search_cache()/brw_upload_cache() would be
- * better to use, as the potentially changing offsets in the data-used-as-key
- * will result in excessive cache misses.
- */
-dri_bo *
-brw_cache_data(struct brw_cache *cache,
-              enum brw_cache_id cache_id,
-              const void *data,
-              dri_bo **reloc_bufs,
-              GLuint nr_reloc_bufs)
-{
-   return brw_cache_data_sz(cache, cache_id, data, cache->key_size[cache_id],
-                           reloc_bufs, nr_reloc_bufs);
-}
-
 enum pool_type {
    DW_SURFACE_STATE,
    DW_GENERAL_STATE
@@ -335,11 +323,9 @@ static void
 brw_init_cache_id(struct brw_cache *cache,
                   const char *name,
                   enum brw_cache_id id,
-                  GLuint key_size,
                   GLuint aux_size)
 {
    cache->name[id] = strdup(name);
-   cache->key_size[id] = key_size;
    cache->aux_size[id] = aux_size;
 }
 
@@ -359,91 +345,76 @@ brw_init_non_surface_cache(struct brw_context *brw)
    brw_init_cache_id(cache,
                     "CC_VP",
                     BRW_CC_VP,
-                    sizeof(struct brw_cc_viewport),
                     0);
 
    brw_init_cache_id(cache,
                     "CC_UNIT",
                     BRW_CC_UNIT,
-                    sizeof(struct brw_cc_unit_state),
                     0);
 
    brw_init_cache_id(cache,
                     "WM_PROG",
                     BRW_WM_PROG,
-                    sizeof(struct brw_wm_prog_key),
                     sizeof(struct brw_wm_prog_data));
 
    brw_init_cache_id(cache,
                     "SAMPLER_DEFAULT_COLOR",
                     BRW_SAMPLER_DEFAULT_COLOR,
-                    sizeof(struct brw_sampler_default_color),
                     0);
 
    brw_init_cache_id(cache,
                     "SAMPLER",
                     BRW_SAMPLER,
-                    0,         /* variable key/data size */
                     0);
 
    brw_init_cache_id(cache,
                     "WM_UNIT",
                     BRW_WM_UNIT,
-                    sizeof(struct brw_wm_unit_state),
                     0);
 
    brw_init_cache_id(cache,
                     "SF_PROG",
                     BRW_SF_PROG,
-                    sizeof(struct brw_sf_prog_key),
                     sizeof(struct brw_sf_prog_data));
 
    brw_init_cache_id(cache,
                     "SF_VP",
                     BRW_SF_VP,
-                    sizeof(struct brw_sf_viewport),
                     0);
 
    brw_init_cache_id(cache,
                     "SF_UNIT",
                     BRW_SF_UNIT,
-                    sizeof(struct brw_sf_unit_state),
                     0);
 
    brw_init_cache_id(cache,
                     "VS_UNIT",
                     BRW_VS_UNIT,
-                    sizeof(struct brw_vs_unit_state),
                     0);
 
    brw_init_cache_id(cache,
                     "VS_PROG",
                     BRW_VS_PROG,
-                    sizeof(struct brw_vs_prog_key),
                     sizeof(struct brw_vs_prog_data));
 
    brw_init_cache_id(cache,
                     "CLIP_UNIT",
                     BRW_CLIP_UNIT,
-                    sizeof(struct brw_clip_unit_state),
                     0);
 
    brw_init_cache_id(cache,
                     "CLIP_PROG",
                     BRW_CLIP_PROG,
-                    sizeof(struct brw_clip_prog_key),
                     sizeof(struct brw_clip_prog_data));
 
    brw_init_cache_id(cache,
                     "GS_UNIT",
                     BRW_GS_UNIT,
-                    sizeof(struct brw_gs_unit_state),
                     0);
 
    brw_init_cache_id(cache,
                     "GS_PROG",
                     BRW_GS_PROG,
-                    sizeof(struct brw_gs_prog_key),
                     sizeof(struct brw_gs_prog_data));
 }
 
@@ -463,13 +434,11 @@ brw_init_surface_cache(struct brw_context *brw)
    brw_init_cache_id(cache,
                     "SS_SURFACE",
                     BRW_SS_SURFACE,
-                    sizeof(struct brw_surface_state),
                     0);
 
    brw_init_cache_id(cache,
                     "SS_SURF_BIND",
                     BRW_SS_SURF_BIND,
-                    0,
                     0);
 }
 
index 0acb027431344c7d3ce229574ea48f6268730bf2..aa2e519588179ea4a4897f0d345e1d68dbe18dfb 100644 (file)
@@ -73,8 +73,8 @@ static dri_bo *upload_default_color( struct brw_context *brw,
 
    COPY_4V(sdc.color, color); 
    
-   return brw_cache_data( &brw->cache, BRW_SAMPLER_DEFAULT_COLOR, &sdc,
-                         NULL, 0 );
+   return brw_cache_data(&brw->cache, BRW_SAMPLER_DEFAULT_COLOR,
+                        &sdc, sizeof(sdc), NULL, 0);
 }