i965: Allow for variable-sized auxdata in the state cache.
authorEric Anholt <eric@anholt.net>
Mon, 18 Jan 2010 21:27:47 +0000 (13:27 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 19 Jan 2010 19:31:05 +0000 (11:31 -0800)
Everything has been constant-sized until now, but constant buffer
handling changes will make us want some additional variable sized
array.

17 files changed:
src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_clip.c
src/mesa/drivers/dri/i965/brw_clip_state.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_gs_state.c
src/mesa/drivers/dri/i965/brw_sf.c
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_vs.c
src/mesa/drivers/dri/i965/brw_vs_state.c
src/mesa/drivers/dri/i965/brw_vs_surface_state.c
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
src/mesa/drivers/dri/i965/brw_wm_state.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c

index bac1c3a..016f27a 100644 (file)
@@ -295,8 +295,7 @@ cc_unit_create_from_key(struct brw_context *brw, struct brw_cc_unit_key *key)
    bo = brw_upload_cache(&brw->cache, BRW_CC_UNIT,
                         key, sizeof(*key),
                         &brw->cc.vp_bo, 1,
-                        &cc, sizeof(cc),
-                        NULL, NULL);
+                        &cc, sizeof(cc));
 
    /* Emit CC viewport relocation */
    dri_bo_emit_reloc(bo,
index af1d975..d3275c7 100644 (file)
@@ -130,13 +130,14 @@ static void compile_clip_prog( struct brw_context *brw,
    /* Upload
     */
    dri_bo_unreference(brw->clip.prog_bo);
-   brw->clip.prog_bo = brw_upload_cache( &brw->cache,
-                                        BRW_CLIP_PROG,
-                                        &c.key, sizeof(c.key),
-                                        NULL, 0,
-                                        program, program_size,
-                                        &c.prog_data,
-                                        &brw->clip.prog_data );
+   brw->clip.prog_bo = brw_upload_cache_with_auxdata(&brw->cache,
+                                                    BRW_CLIP_PROG,
+                                                    &c.key, sizeof(c.key),
+                                                    NULL, 0,
+                                                    program, program_size,
+                                                    &c.prog_data,
+                                                    sizeof(c.prog_data),
+                                                    &brw->clip.prog_data);
 }
 
 /* Calculate interpolants for triangle and line rasterization.
index c8f24a9..22df772 100644 (file)
@@ -143,8 +143,7 @@ clip_unit_create_from_key(struct brw_context *brw,
    bo = brw_upload_cache(&brw->cache, BRW_CLIP_UNIT,
                         key, sizeof(*key),
                         &brw->clip.prog_bo, 1,
-                        &clip, sizeof(clip),
-                        NULL, NULL);
+                        &clip, sizeof(clip));
 
    /* Emit clip program relocation */
    assert(brw->clip.prog_bo);
index 0dd3087..21d8297 100644 (file)
@@ -332,7 +332,6 @@ struct brw_cache {
    struct brw_cache_item **items;
    GLuint size, n_items;
 
-   GLuint aux_size[BRW_MAX_CACHE];
    char *name[BRW_MAX_CACHE];
 
    /* Record of the last BOs chosen for each cache_id.  Used to set
index 1bc3ecc..7261b31 100644 (file)
@@ -125,12 +125,13 @@ static void compile_gs_prog( struct brw_context *brw,
    /* Upload
     */
    dri_bo_unreference(brw->gs.prog_bo);
-   brw->gs.prog_bo = brw_upload_cache( &brw->cache, BRW_GS_PROG,
-                                      &c.key, sizeof(c.key),
-                                      NULL, 0,
-                                      program, program_size,
-                                      &c.prog_data,
-                                      &brw->gs.prog_data );
+   brw->gs.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_GS_PROG,
+                                                  &c.key, sizeof(c.key),
+                                                  NULL, 0,
+                                                  program, program_size,
+                                                  &c.prog_data,
+                                                  sizeof(c.prog_data),
+                                                  &brw->gs.prog_data);
 }
 
 static const GLenum gs_prim[GL_POLYGON+1] = {  
index 1af5790..7d5a944 100644 (file)
@@ -108,8 +108,7 @@ gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key)
    bo = brw_upload_cache(&brw->cache, BRW_GS_UNIT,
                         key, sizeof(*key),
                         &brw->gs.prog_bo, 1,
-                        &gs, sizeof(gs),
-                        NULL, NULL);
+                        &gs, sizeof(gs));
 
    if (key->prog_active) {
       /* Emit GS program relocation */
index 968890f..8e6839b 100644 (file)
@@ -117,12 +117,13 @@ static void compile_sf_prog( struct brw_context *brw,
    /* Upload
     */
    dri_bo_unreference(brw->sf.prog_bo);
-   brw->sf.prog_bo = brw_upload_cache( &brw->cache, BRW_SF_PROG,
-                                      &c.key, sizeof(c.key),
-                                      NULL, 0,
-                                      program, program_size,
-                                      &c.prog_data,
-                                      &brw->sf.prog_data );
+   brw->sf.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_SF_PROG,
+                                                  &c.key, sizeof(c.key),
+                                                  NULL, 0,
+                                                  program, program_size,
+                                                  &c.prog_data,
+                                                  sizeof(c.prog_data),
+                                                  &brw->sf.prog_data);
 }
 
 /* Calculate interpolants for triangle and line rasterization.
index 09223b7..b9b42cd 100644 (file)
@@ -309,8 +309,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
    bo = brw_upload_cache(&brw->cache, BRW_SF_UNIT,
                         key, sizeof(*key),
                         reloc_bufs, 2,
-                        &sf, sizeof(sf),
-                        NULL, NULL);
+                        &sf, sizeof(sf));
 
    /* STATE_PREFETCH command description describes this state as being
     * something loaded through the GPE (L2 ISC), so it's INSTRUCTION domain.
index 9c9d145..536fe8b 100644 (file)
@@ -124,16 +124,26 @@ dri_bo *brw_cache_data(struct brw_cache *cache,
                       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,
-                         GLuint key_sz,
-                         dri_bo **reloc_bufs,
-                         GLuint nr_reloc_bufs,
-                         const void *data,
-                         GLuint data_sz,
-                         const void *aux,
-                         void *aux_return );
+drm_intel_bo *brw_upload_cache(struct brw_cache *cache,
+                              enum brw_cache_id cache_id,
+                              const void *key,
+                              GLuint key_sz,
+                              dri_bo **reloc_bufs,
+                              GLuint nr_reloc_bufs,
+                              const void *data,
+                              GLuint data_sz);
+
+drm_intel_bo *brw_upload_cache_with_auxdata(struct brw_cache *cache,
+                                           enum brw_cache_id cache_id,
+                                           const void *key,
+                                           GLuint key_sz,
+                                           dri_bo **reloc_bufs,
+                                           GLuint nr_reloc_bufs,
+                                           const void *data,
+                                           GLuint data_sz,
+                                           const void *aux,
+                                           GLuint aux_sz,
+                                           void *aux_return);
 
 dri_bo *brw_search_cache( struct brw_cache *cache,
                          enum brw_cache_id cache_id,
index e4c9ba7..502ad0b 100644 (file)
@@ -200,22 +200,22 @@ brw_search_cache(struct brw_cache *cache,
 }
 
 
-dri_bo *
-brw_upload_cache( struct brw_cache *cache,
-                 enum brw_cache_id cache_id,
-                 const void *key,
-                 GLuint key_size,
-                 dri_bo **reloc_bufs,
-                 GLuint nr_reloc_bufs,
-                 const void *data,
-                 GLuint data_size,
-                 const void *aux,
-                 void *aux_return )
+drm_intel_bo *
+brw_upload_cache_with_auxdata(struct brw_cache *cache,
+                             enum brw_cache_id cache_id,
+                             const void *key,
+                             GLuint key_size,
+                             dri_bo **reloc_bufs,
+                             GLuint nr_reloc_bufs,
+                             const void *data,
+                             GLuint data_size,
+                             const void *aux,
+                             GLuint aux_size,
+                             void *aux_return)
 {
    struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item);
    GLuint hash = hash_key(key, key_size, reloc_bufs, nr_reloc_bufs);
    GLuint relocs_size = nr_reloc_bufs * sizeof(dri_bo *);
-   GLuint aux_size = cache->aux_size[cache_id];
    void *tmp;
    dri_bo *bo;
    int i;
@@ -229,7 +229,7 @@ brw_upload_cache( struct brw_cache *cache,
    tmp = _mesa_malloc(key_size + aux_size + relocs_size);
 
    memcpy(tmp, key, key_size);
-   memcpy(tmp + key_size, aux, cache->aux_size[cache_id]);
+   memcpy(tmp + key_size, aux, aux_size);
    memcpy(tmp + key_size + aux_size, reloc_bufs, relocs_size);
    for (i = 0; i < nr_reloc_bufs; i++) {
       if (reloc_bufs[i] != NULL)
@@ -255,7 +255,6 @@ brw_upload_cache( struct brw_cache *cache,
    cache->n_items++;
 
    if (aux_return) {
-      assert(cache->aux_size[cache_id]);
       *(void **)aux_return = (void *)((char *)item->key + item->key_size);
    }
 
@@ -272,6 +271,23 @@ brw_upload_cache( struct brw_cache *cache,
    return bo;
 }
 
+drm_intel_bo *
+brw_upload_cache(struct brw_cache *cache,
+                enum brw_cache_id cache_id,
+                const void *key,
+                GLuint key_size,
+                dri_bo **reloc_bufs,
+                GLuint nr_reloc_bufs,
+                const void *data,
+                GLuint data_size)
+{
+   return brw_upload_cache_with_auxdata(cache, cache_id,
+                                       key, key_size,
+                                       reloc_bufs, nr_reloc_bufs,
+                                       data, data_size,
+                                       NULL, 0,
+                                       NULL);
+}
 
 /**
  * Wrapper around brw_cache_data_sz using the cache_id's canonical key size.
@@ -306,8 +322,7 @@ brw_cache_data(struct brw_cache *cache,
    bo = brw_upload_cache(cache, cache_id,
                         data, data_size,
                         reloc_bufs, nr_reloc_bufs,
-                        data, data_size,
-                        NULL, NULL);
+                        data, data_size);
 
    return bo;
 }
@@ -321,11 +336,9 @@ enum pool_type {
 static void
 brw_init_cache_id(struct brw_cache *cache,
                   const char *name,
-                  enum brw_cache_id id,
-                  GLuint aux_size)
+                  enum brw_cache_id id)
 {
    cache->name[id] = strdup(name);
-   cache->aux_size[id] = aux_size;
 }
 
 
@@ -341,80 +354,28 @@ brw_init_non_surface_cache(struct brw_context *brw)
    cache->items = (struct brw_cache_item **)
       _mesa_calloc(cache->size * sizeof(struct brw_cache_item));
 
-   brw_init_cache_id(cache,
-                    "CC_VP",
-                    BRW_CC_VP,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "CC_UNIT",
-                    BRW_CC_UNIT,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "WM_PROG",
-                    BRW_WM_PROG,
-                    sizeof(struct brw_wm_prog_data));
-
-   brw_init_cache_id(cache,
-                    "SAMPLER_DEFAULT_COLOR",
-                    BRW_SAMPLER_DEFAULT_COLOR,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "SAMPLER",
-                    BRW_SAMPLER,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "WM_UNIT",
-                    BRW_WM_UNIT,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "SF_PROG",
-                    BRW_SF_PROG,
-                    sizeof(struct brw_sf_prog_data));
-
-   brw_init_cache_id(cache,
-                    "SF_VP",
-                    BRW_SF_VP,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "SF_UNIT",
-                    BRW_SF_UNIT,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "VS_UNIT",
-                    BRW_VS_UNIT,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "VS_PROG",
-                    BRW_VS_PROG,
-                    sizeof(struct brw_vs_prog_data));
-
-   brw_init_cache_id(cache,
-                    "CLIP_UNIT",
-                    BRW_CLIP_UNIT,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "CLIP_PROG",
-                    BRW_CLIP_PROG,
-                    sizeof(struct brw_clip_prog_data));
-
-   brw_init_cache_id(cache,
-                    "GS_UNIT",
-                    BRW_GS_UNIT,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "GS_PROG",
-                    BRW_GS_PROG,
-                    sizeof(struct brw_gs_prog_data));
+   brw_init_cache_id(cache, "CC_VP", BRW_CC_VP);
+   brw_init_cache_id(cache, "CC_UNIT", BRW_CC_UNIT);
+   brw_init_cache_id(cache, "WM_PROG", BRW_WM_PROG);
+   brw_init_cache_id(cache, "SAMPLER_DEFAULT_COLOR", BRW_SAMPLER_DEFAULT_COLOR);
+   brw_init_cache_id(cache, "SAMPLER", BRW_SAMPLER);
+   brw_init_cache_id(cache, "WM_UNIT", BRW_WM_UNIT);
+   brw_init_cache_id(cache, "SF_PROG", BRW_SF_PROG);
+   brw_init_cache_id(cache, "SF_VP", BRW_SF_VP);
+
+   brw_init_cache_id(cache, "SF_UNIT", BRW_SF_UNIT);
+
+   brw_init_cache_id(cache, "VS_UNIT", BRW_VS_UNIT);
+
+   brw_init_cache_id(cache, "VS_PROG", BRW_VS_PROG);
+
+   brw_init_cache_id(cache, "CLIP_UNIT", BRW_CLIP_UNIT);
+
+   brw_init_cache_id(cache, "CLIP_PROG", BRW_CLIP_PROG);
+
+   brw_init_cache_id(cache, "GS_UNIT", BRW_GS_UNIT);
+
+   brw_init_cache_id(cache, "GS_PROG", BRW_GS_PROG);
 }
 
 
@@ -430,15 +391,8 @@ brw_init_surface_cache(struct brw_context *brw)
    cache->items = (struct brw_cache_item **)
       _mesa_calloc(cache->size * sizeof(struct brw_cache_item));
 
-   brw_init_cache_id(cache,
-                    "SS_SURFACE",
-                    BRW_SS_SURFACE,
-                    0);
-
-   brw_init_cache_id(cache,
-                    "SS_SURF_BIND",
-                    BRW_SS_SURF_BIND,
-                    0);
+   brw_init_cache_id(cache, "SS_SURFACE", BRW_SS_SURFACE);
+   brw_init_cache_id(cache, "SS_SURF_BIND", BRW_SS_SURF_BIND);
 }
 
 
index fd055e2..a669272 100644 (file)
@@ -74,12 +74,13 @@ static void do_vs_prog( struct brw_context *brw,
    program = brw_get_program(&c.func, &program_size);
 
    dri_bo_unreference(brw->vs.prog_bo);
-   brw->vs.prog_bo = brw_upload_cache( &brw->cache, BRW_VS_PROG,
-                                      &c.key, sizeof(c.key),
-                                      NULL, 0,
-                                      program, program_size,
-                                      &c.prog_data,
-                                      &brw->vs.prog_data );
+   brw->vs.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_VS_PROG,
+                                                  &c.key, sizeof(c.key),
+                                                  NULL, 0,
+                                                  program, program_size,
+                                                  &c.prog_data,
+                                                  sizeof(c.prog_data),
+                                                  &brw->vs.prog_data);
 }
 
 
index 345ffa7..fd9f2fe 100644 (file)
@@ -164,8 +164,7 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
    bo = brw_upload_cache(&brw->cache, BRW_VS_UNIT,
                         key, sizeof(*key),
                         &brw->vs.prog_bo, 1,
-                        &vs, sizeof(vs),
-                        NULL, NULL);
+                        &vs, sizeof(vs));
 
    /* Emit VS program relocation */
    dri_bo_emit_reloc(bo,
index 3bc9840..3f6e16f 100644 (file)
@@ -168,8 +168,7 @@ brw_vs_get_binding_table(struct brw_context *brw)
       bind_bo = brw_upload_cache( &brw->surface_cache, BRW_SS_SURF_BIND,
                                  NULL, 0,
                                  brw->vs.surf_bo, BRW_VS_MAX_SURF,
-                                 data, data_size,
-                                 NULL, NULL);
+                                 data, data_size);
 
       /* Emit binding table relocations to surface state */
       for (i = 0; i < BRW_VS_MAX_SURF; i++) {
index 6895f64..fb24379 100644 (file)
@@ -199,12 +199,13 @@ static void do_wm_prog( struct brw_context *brw,
    program = brw_get_program(&c->func, &program_size);
 
    dri_bo_unreference(brw->wm.prog_bo);
-   brw->wm.prog_bo = brw_upload_cache( &brw->cache, BRW_WM_PROG,
-                                      &c->key, sizeof(c->key),
-                                      NULL, 0,
-                                      program, program_size,
-                                      &c->prog_data,
-                                      &brw->wm.prog_data );
+   brw->wm.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_WM_PROG,
+                                                  &c->key, sizeof(c->key),
+                                                  NULL, 0,
+                                                  program, program_size,
+                                                  &c->prog_data,
+                                                  sizeof(c->prog_data),
+                                                  &brw->wm.prog_data);
 }
 
 
index ad267a4..87387b1 100644 (file)
@@ -326,8 +326,7 @@ static void upload_wm_samplers( struct brw_context *brw )
       brw->wm.sampler_bo = brw_upload_cache(&brw->cache, BRW_SAMPLER,
                                            &key, sizeof(key),
                                            brw->wm.sdc_bo, key.sampler_count,
-                                           &sampler, sizeof(sampler),
-                                           NULL, NULL);
+                                           &sampler, sizeof(sampler));
 
       /* Emit SDC relocations */
       for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
index d3373ea..a7f80db 100644 (file)
@@ -210,8 +210,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
    bo = brw_upload_cache(&brw->cache, BRW_WM_UNIT,
                         key, sizeof(*key),
                         reloc_bufs, 3,
-                        &wm, sizeof(wm),
-                        NULL, NULL);
+                        &wm, sizeof(wm));
 
    /* Emit WM program relocation */
    dri_bo_emit_reloc(bo,
index f26cfab..357c8c9 100644 (file)
@@ -256,8 +256,7 @@ brw_create_texture_surface( struct brw_context *brw,
    bo = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE,
                         key, sizeof(*key),
                         &key->bo, key->bo ? 1 : 0,
-                        &surf, sizeof(surf),
-                        NULL, NULL);
+                        &surf, sizeof(surf));
 
    if (key->bo) {
       /* Emit relocation to surface contents */
@@ -351,8 +350,7 @@ brw_create_constant_surface( struct brw_context *brw,
    bo = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE,
                         key, sizeof(*key),
                         &key->bo, key->bo ? 1 : 0,
-                        &surf, sizeof(surf),
-                        NULL, NULL);
+                        &surf, sizeof(surf));
 
    if (key->bo) {
       /* Emit relocation to surface contents.  Section 5.1.1 of the gen4
@@ -653,8 +651,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
                                                BRW_SS_SURFACE,
                                                &key, sizeof(key),
                                               &region_bo, 1,
-                                              &surf, sizeof(surf),
-                                              NULL, NULL);
+                                              &surf, sizeof(surf));
       if (region_bo != NULL) {
         /* We might sample from it, and we might render to it, so flag
          * them both.  We might be able to figure out from other state
@@ -701,8 +698,7 @@ brw_wm_get_binding_table(struct brw_context *brw)
       bind_bo = brw_upload_cache( &brw->surface_cache, BRW_SS_SURF_BIND,
                                  NULL, 0,
                                  brw->wm.surf_bo, brw->wm.nr_surfaces,
-                                 data, data_size,
-                                 NULL, NULL);
+                                 data, data_size);
 
       /* Emit binding table relocations to surface state */
       for (i = 0; i < BRW_WM_MAX_SURF; i++) {