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.
This commit is contained in:
Courtney Goeltzenleuchter 2013-05-28 09:54:43 -06:00 committed by Chia-I Wu
parent 98dfd59a04
commit 8b1c9de166
2 changed files with 2 additions and 25 deletions

View file

@ -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);

View file

@ -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];