From: Thomas Helland Date: Tue, 16 Aug 2016 20:10:26 +0000 (+0200) Subject: glsl: Convert link_varyings to the util hash table X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f10cc9407b9144fec3e608767edf3bf02df647f2;p=mesa.git glsl: Convert link_varyings to the util hash table Signed-off-by: Thomas Helland Reviewed-by: Timothy Arceri --- diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp index 1fad31087ec..8c436c2f440 100644 --- a/src/compiler/glsl/link_varyings.cpp +++ b/src/compiler/glsl/link_varyings.cpp @@ -36,7 +36,7 @@ #include "linker.h" #include "link_varyings.h" #include "main/macros.h" -#include "program/hash_table.h" +#include "util/hash_table.h" #include "program.h" @@ -981,8 +981,11 @@ tfeedback_decl::find_candidate(gl_shader_program *prog, name = "gl_TessLevelInnerMESA"; break; } - this->matched_candidate = (const tfeedback_candidate *) - hash_table_find(tfeedback_candidates, name); + hash_entry *entry = _mesa_hash_table_search(tfeedback_candidates, name); + + this->matched_candidate = entry ? + (const tfeedback_candidate *) entry->data : NULL; + if (!this->matched_candidate) { /* From GL_EXT_transform_feedback: * A program will fail to link if: @@ -994,6 +997,7 @@ tfeedback_decl::find_candidate(gl_shader_program *prog, linker_error(prog, "Transform feedback varying %s undeclared.", this->orig_name); } + return this->matched_candidate; } @@ -1789,8 +1793,9 @@ private: candidate->toplevel_var = this->toplevel_var; candidate->type = type; candidate->offset = this->varying_floats; - hash_table_insert(this->tfeedback_candidates, candidate, - ralloc_strdup(this->mem_ctx, name)); + _mesa_hash_table_insert(this->tfeedback_candidates, + ralloc_strdup(this->mem_ctx, name), + candidate); this->varying_floats += type->component_slots(); } @@ -1861,11 +1866,12 @@ populate_consumer_input_sets(void *mem_ctx, exec_list *ir, ralloc_asprintf(mem_ctx, "%s.%s", input_var->get_interface_type()->without_array()->name, input_var->name); - hash_table_insert(consumer_interface_inputs, input_var, - iface_field_name); + _mesa_hash_table_insert(consumer_interface_inputs, + iface_field_name, input_var); } else { - hash_table_insert(consumer_inputs, input_var, - ralloc_strdup(mem_ctx, input_var->name)); + _mesa_hash_table_insert(consumer_inputs, + ralloc_strdup(mem_ctx, input_var->name), + input_var); } } } @@ -1893,12 +1899,11 @@ get_matching_input(void *mem_ctx, ralloc_asprintf(mem_ctx, "%s.%s", output_var->get_interface_type()->without_array()->name, output_var->name); - input_var = - (ir_variable *) hash_table_find(consumer_interface_inputs, - iface_field_name); + hash_entry *entry = _mesa_hash_table_search(consumer_interface_inputs, iface_field_name); + input_var = entry ? (ir_variable *) entry->data : NULL; } else { - input_var = - (ir_variable *) hash_table_find(consumer_inputs, output_var->name); + hash_entry *entry = _mesa_hash_table_search(consumer_inputs, output_var->name); + input_var = entry ? (ir_variable *) entry->data : NULL; } return (input_var == NULL || input_var->data.mode != ir_var_shader_in) @@ -2075,12 +2080,15 @@ assign_varying_locations(struct gl_context *ctx, varying_matches matches(disable_varying_packing, xfb_enabled, producer ? producer->Stage : (gl_shader_stage)-1, consumer ? consumer->Stage : (gl_shader_stage)-1); - hash_table *tfeedback_candidates - = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); - hash_table *consumer_inputs - = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); - hash_table *consumer_interface_inputs - = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); + hash_table *tfeedback_candidates = + _mesa_hash_table_create(NULL, _mesa_key_hash_string, + _mesa_key_string_equal); + hash_table *consumer_inputs = + _mesa_hash_table_create(NULL, _mesa_key_hash_string, + _mesa_key_string_equal); + hash_table *consumer_interface_inputs = + _mesa_hash_table_create(NULL, _mesa_key_hash_string, + _mesa_key_string_equal); ir_variable *consumer_inputs_with_locations[VARYING_SLOT_TESS_MAX] = { NULL, }; @@ -2175,8 +2183,8 @@ assign_varying_locations(struct gl_context *ctx, } } - hash_table_dtor(consumer_inputs); - hash_table_dtor(consumer_interface_inputs); + _mesa_hash_table_destroy(consumer_inputs, NULL); + _mesa_hash_table_destroy(consumer_interface_inputs, NULL); for (unsigned i = 0; i < num_tfeedback_decls; ++i) { if (!tfeedback_decls[i].is_varying()) @@ -2186,7 +2194,7 @@ assign_varying_locations(struct gl_context *ctx, = tfeedback_decls[i].find_candidate(prog, tfeedback_candidates); if (matched_candidate == NULL) { - hash_table_dtor(tfeedback_candidates); + _mesa_hash_table_destroy(tfeedback_candidates, NULL); return false; } @@ -2204,11 +2212,11 @@ assign_varying_locations(struct gl_context *ctx, continue; if (!tfeedback_decls[i].assign_location(ctx, prog)) { - hash_table_dtor(tfeedback_candidates); + _mesa_hash_table_destroy(tfeedback_candidates, NULL); return false; } } - hash_table_dtor(tfeedback_candidates); + _mesa_hash_table_destroy(tfeedback_candidates, NULL); if (consumer && producer) { foreach_in_list(ir_instruction, node, consumer->ir) {