#include "st_nir.h"
#include "st_shader_cache.h"
+#include "util/hash_table.h"
#include <algorithm>
#define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) | \
const struct tgsi_opcode_info *info;
};
-class variable_storage : public exec_node {
+class variable_storage {
+ DECLARE_RZALLOC_CXX_OPERATORS(variable_storage)
+
public:
variable_storage(ir_variable *var, gl_register_file file, int index,
unsigned array_id = 0)
st_src_reg result;
/** List of variable_storage */
- exec_list variables;
+ struct hash_table *variables;
/** List of immediate_storage */
exec_list immediates;
variable_storage *
glsl_to_tgsi_visitor::find_variable_storage(ir_variable *var)
{
+ struct hash_entry *entry = _mesa_hash_table_search(this->variables,
+ var);
+ variable_storage *storage;
+ if (!entry)
+ return NULL;
- foreach_in_list(variable_storage, entry, &this->variables) {
- if (entry->var == var)
- return entry;
- }
+ storage = (variable_storage *)entry->data;
- return NULL;
+ return storage;
}
void
if (i == ir->get_num_state_slots()) {
/* We'll set the index later. */
storage = new(mem_ctx) variable_storage(ir, PROGRAM_STATE_VAR, -1);
- this->variables.push_tail(storage);
+
+ _mesa_hash_table_insert(this->variables, ir, storage);
dst = undef_dst;
} else {
storage = new(mem_ctx) variable_storage(ir, dst.file, dst.index,
dst.array_id);
- this->variables.push_tail(storage);
+ _mesa_hash_table_insert(this->variables, ir, storage);
}
case ir_var_uniform:
entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
var->data.param_index);
- this->variables.push_tail(entry);
+ _mesa_hash_table_insert(this->variables, var, entry);
break;
case ir_var_shader_in: {
/* The linker assigns locations for varyings and attributes,
decl->array_id);
entry->component = component;
- this->variables.push_tail(entry);
+ _mesa_hash_table_insert(this->variables, var, entry);
+
break;
}
case ir_var_shader_out: {
}
entry->component = component;
- this->variables.push_tail(entry);
+ _mesa_hash_table_insert(this->variables, var, entry);
+
break;
}
case ir_var_system_value:
entry = new(mem_ctx) variable_storage(var, src.file, src.index,
src.array_id);
- this->variables.push_tail(entry);
+ _mesa_hash_table_insert(this->variables, var, entry);
break;
}
have_fma = false;
use_shared_memory = false;
has_tex_txf_lz = false;
+ variables = NULL;
+}
+
+static void var_destroy(struct hash_entry *entry)
+{
+ variable_storage *storage = (variable_storage *)entry->data;
+
+ delete storage;
}
glsl_to_tgsi_visitor::~glsl_to_tgsi_visitor()
{
+ _mesa_hash_table_destroy(variables, var_destroy);
free(array_sizes);
ralloc_free(mem_ctx);
}
PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED);
v->has_tex_txf_lz = pscreen->get_param(pscreen,
PIPE_CAP_TGSI_TEX_TXF_LZ);
+
+ v->variables = _mesa_hash_table_create(v->mem_ctx, _mesa_hash_pointer,
+ _mesa_key_pointer_equal);
skip_merge_registers =
pscreen->get_shader_param(pscreen, ptarget,
PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS);