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 bac1c3a49c3314fc680f0040a71bae1f390012a1..016f27a6a31ea3be8e240bfce5c8d88d65971be6 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 af1d975de95cdf477d3c82f896216a6c719fae86..d3275c7a89d0cd500d6b74dbe5be12a74bdcc463 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 c8f24a94e4d5feb574ccfd0fbb6ec7f48ef97557..22df7722b686d69e5146b6d3d26c165d7aef6ed6 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 0dd3087143f7a813c93b9c8f03c3e2a2a93e99aa..21d82977b7c810572af1787ee1dbf900a32e1624 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 1bc3eccf49d9ad05869b5d29f23db42ed3b6fc34..7261b316c100e7088650a44918af928f5e573bda 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 1af5790a676445ed17d03dccb937100602de8ccd..7d5a944bf7d38d7bb135394281dbdddc76bf849f 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 968890f7fb19978ec727c5e10b65dc16c71a0a83..8e6839b812086d44a99b635de5cb10f0992d44fd 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 09223b7cfb1d95b01f9be4f39e8567b942ab65fb..b9b42cd6d553e6fd5aec15e2b2fd25c93c0fd4c7 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 9c9d145c4b69f67afe2a6a512af28439352747b8..536fe8b249bc06e268ae5e225e83786c79259816 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 e4c9ba7d870fccb95137a10ecf8e4c427a5885c2..502ad0bd6cc24ceec0e7ded1ab306127ad834860 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 fd055e225e024d5f5148c333b5cfcffb55bf0f9b..a66927235e57cd89003ab04b312b8a8426fbe24b 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 345ffa7ee11bc1184ff88353c8ad164f6d62c20f..fd9f2fee423a347df0b6284279093905f2d2198a 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 3bc9840a9719ad1bb59e452f23fb6afc39a3e91f..3f6e16fcb0a5393a27e809431720646be2b0981a 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 6895f644104a6e0be24507fa6447aebbce2c5625..fb24379c90b174d56627782bfc89ada8a78c9aaa 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 ad267a4e6aef554041e0fc3393caa07d316d6f4c..87387b1e2d53f56ae675ebfb3490051c02c7083a 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 d3373ea79e80fb9b333adc3ad8da01b8f992ef39..a7f80db554a90a894f37844384518657ad925a14 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 f26cfabb7dfcda899d15fa9a6efed5f067f1fdf4..357c8c90de3d23e5b19f37968a92ff3087cba453 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++) {