The best way to make this code more readable is to replace it entirely. It's horribly overcomplicated for what is basically an open-coded hash table. I've had various starts at that...but never quite managed to finish. :( You could probably grab iris_program_cache.c from my iris branch, make it work with one buffer again, and try and just use hash_table...
But, that's a lot of work. This is probably fine...I think you can get into const casting hell when start pulling out prog_data from a const cache entry and handing it back as a non-const pointer. Everything goes through void * though, so it ends up working for now... Acked-by: Kenneth Graunke <kenn...@whitecape.org> On Tuesday, October 2, 2018 7:30:09 AM PDT Eric Engestrom wrote: > Ping? > I'm just adding `const` to make it easier to read and understand the > code, and allow the compiler to tell us if we make a mistake and start > modifying things shouldn't. > > On Tuesday, 2018-08-07 12:02:53 +0100, Eric Engestrom wrote: > > Signed-off-by: Eric Engestrom <eric.engest...@intel.com> > > --- > > v2: forgot the hunk that was the point of this :facepalm: > > --- > > src/mesa/drivers/dri/i965/brw_program_cache.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/src/mesa/drivers/dri/i965/brw_program_cache.c > > b/src/mesa/drivers/dri/i965/brw_program_cache.c > > index 600b0611c8b89095e393..a9a21d911612f9218e2a 100644 > > --- a/src/mesa/drivers/dri/i965/brw_program_cache.c > > +++ b/src/mesa/drivers/dri/i965/brw_program_cache.c > > @@ -142,11 +142,11 @@ brw_cache_item_equals(const struct brw_cache_item *a, > > (memcmp(a->key, b->key, a->key_size) == 0); > > } > > > > -static struct brw_cache_item * > > -search_cache(struct brw_cache *cache, GLuint hash, > > - struct brw_cache_item *lookup) > > +static const struct brw_cache_item * > > +search_cache(const struct brw_cache *cache, GLuint hash, > > + const struct brw_cache_item *lookup) > > { > > - struct brw_cache_item *c; > > + const struct brw_cache_item *c; > > > > #if 0 > > int bucketcount = 0; > > @@ -194,11 +194,11 @@ rehash(struct brw_cache *cache) > > * Returns the buffer object matching cache_id and key, or NULL. > > */ > > bool > > -brw_search_cache(struct brw_cache *cache, enum brw_cache_id cache_id, > > +brw_search_cache(const struct brw_cache *cache, enum brw_cache_id cache_id, > > const void *key, GLuint key_size, uint32_t *inout_offset, > > void *inout_prog_data, bool flag_state) > > { > > - struct brw_cache_item *item; > > + const struct brw_cache_item *item; > > struct brw_cache_item lookup; > > GLuint hash; > > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev >
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev