diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2008-04-23 10:29:52 -0600 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2008-04-23 10:29:52 -0600 |
commit | 333976c90aafa602816defef3e4cc4a418601a51 (patch) | |
tree | 8c425dee7241cfa6d87fb3cb4e6a2a12de9c2652 /src/gallium/auxiliary/draw/draw_pt_fetch.c | |
parent | 43be7a4819ad342e1cb3f8e3fb966a8a78dc2c1b (diff) | |
download | external_mesa3d-333976c90aafa602816defef3e4cc4a418601a51.zip external_mesa3d-333976c90aafa602816defef3e4cc4a418601a51.tar.gz external_mesa3d-333976c90aafa602816defef3e4cc4a418601a51.tar.bz2 |
gallium: fix broken hashing for vertex translation
It seems we get hash collisions fairly easily and the code as it was didn't
deal with that properly.
I think we need a simpler hashing interface...
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_pt_fetch.c')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt_fetch.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 93da811..a8d4be5 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -70,13 +70,21 @@ static struct translate *cached_translate(struct pt_fetch *fetch, struct cso_hash_iter iter = cso_hash_find(fetch->hash, hash_key); struct translate *translate = 0; - if (cso_hash_iter_is_null(iter)) { + while (!cso_hash_iter_is_null(iter)) { + void *iter_data = cso_hash_iter_data(iter); + if (memcmp(iter_data, key, sizeof(*key)) == 0) { + /* found */ + translate = cso_hash_iter_data(iter); + break; + } + iter = cso_hash_iter_next(iter); + /*debug_printf("\tOK with %d\n", hash_key);*/ + } + + if (!translate) { + /* create/insert */ translate = translate_create(key); cso_hash_insert(fetch->hash, hash_key, translate); - /*debug_printf("\tCREATED with %d\n", hash_key);*/ - } else { - translate = cso_hash_iter_data(iter); - /*debug_printf("\tOK with %d\n", hash_key);*/ } return translate; |