From: Courtney Goeltzenleuchter Date: Tue, 28 May 2013 15:54:43 +0000 (-0600) Subject: ilo: simplify shader variant handling X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8b1c9de166129086ff73a3ed0378e3feb06dda15;p=mesa.git ilo: simplify shader variant handling Remove hash function on shader variants. Nature of variants limits them to a small number and thus its more efficient to just do a memory compare of the actual shader structures rather than compute and compare hashes. --- diff --git a/src/gallium/drivers/ilo/ilo_shader.c b/src/gallium/drivers/ilo/ilo_shader.c index 9a367213fa5..67e1a80b751 100644 --- a/src/gallium/drivers/ilo/ilo_shader.c +++ b/src/gallium/drivers/ilo/ilo_shader.c @@ -160,23 +160,6 @@ ilo_shader_variant_guess(struct ilo_shader_variant *variant, } } -/** - * Hash a shader variant. - */ -static unsigned int -ilo_shader_variant_hash(const struct ilo_shader_variant *variant) -{ - const int num_bytes = sizeof(*variant); - const unsigned char *bytes = (const unsigned char *) variant; - const unsigned int seed = 131; - unsigned int hash = 0; - int i; - - for (i = 0; i < num_bytes; i++) - hash = hash * seed + bytes[i]; - - return hash; -} /** * Parse a TGSI instruction for the shader info. @@ -428,14 +411,12 @@ ilo_shader_state_gc(struct ilo_shader_state *state) */ static struct ilo_shader * ilo_shader_state_search_variant(struct ilo_shader_state *state, - unsigned int hash, const struct ilo_shader_variant *variant) { struct ilo_shader *sh = NULL, *tmp; LIST_FOR_EACH_ENTRY(tmp, &state->variants, list) { - if (tmp->hash == hash && - memcmp(&tmp->variant, variant, sizeof(*variant)) == 0) { + if (memcmp(&tmp->variant, variant, sizeof(*variant)) == 0) { sh = tmp; break; } @@ -451,10 +432,9 @@ struct ilo_shader * ilo_shader_state_add_variant(struct ilo_shader_state *state, const struct ilo_shader_variant *variant) { - const unsigned int hash = ilo_shader_variant_hash(variant); struct ilo_shader *sh; - sh = ilo_shader_state_search_variant(state, hash, variant); + sh = ilo_shader_state_search_variant(state, variant); if (sh) return sh; @@ -483,7 +463,6 @@ ilo_shader_state_add_variant(struct ilo_shader_state *state, } sh->variant = *variant; - sh->hash = hash; ilo_shader_state_add_shader(state, sh); diff --git a/src/gallium/drivers/ilo/ilo_shader.h b/src/gallium/drivers/ilo/ilo_shader.h index 66adabac35d..1ea0b4a0d1d 100644 --- a/src/gallium/drivers/ilo/ilo_shader.h +++ b/src/gallium/drivers/ilo/ilo_shader.h @@ -74,8 +74,6 @@ struct ilo_shader_variant { */ struct ilo_shader { struct ilo_shader_variant variant; - /* hash of the shader variant for quicker lookup */ - unsigned hash; struct { int semantic_names[PIPE_MAX_SHADER_INPUTS];