libglsl_la_LDFLAGS =
glsl_compiler_SOURCES = \
+ $(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/program/prog_hash_table.c \
$(top_srcdir)/src/mesa/program/symbol_table.c \
$(GLSL_COMPILER_CXX_FILES)
glsl_compiler_LDADD = libglsl.la
glsl_test_SOURCES = \
+ $(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/program/prog_hash_table.c \
$(top_srcdir)/src/mesa/program/symbol_table.c \
$(GLSL_SRCDIR)/standalone_scaffolding.cpp \
if env['crosscompile'] and not env['embedded']:
Import('builtin_glsl_function')
else:
+ # Copy these files to avoid generation object files into src/mesa/program
+ env.Prepend(CPPPATH = ['#src/mesa/main'])
+ env.Command('hash_table.c', '#src/mesa/main/hash_table.c', Copy('$TARGET', '$SOURCE'))
# Copy these files to avoid generation object files into src/mesa/program
env.Prepend(CPPPATH = ['#src/mesa/program'])
env.Command('prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
mesa_objs = env.StaticObject([
+ 'hash_table.c',
'prog_hash_table.c',
'symbol_table.c',
])
$(GLSL_BUILDDIR)/glsl_parser.cc \
$(LIBGLSL_FILES) \
$(LIBGLSL_CXX_FILES) \
+ $(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/program/prog_hash_table.c \
$(top_srcdir)/src/mesa/program/symbol_table.c \
$(GLSL_COMPILER_CXX_FILES) \
#include "ir_visitor.h"
#include "ir_variable_refcount.h"
#include "glsl_types.h"
+#include "main/hash_table.h"
+ir_variable_refcount_visitor::ir_variable_refcount_visitor()
+{
+ this->mem_ctx = ralloc_context(NULL);
+ this->ht = _mesa_hash_table_create(NULL, _mesa_key_pointer_equal);
+}
+
+static void
+free_entry(struct hash_entry *entry)
+{
+ ir_variable_refcount_entry *ivre = (ir_variable_refcount_entry *) entry->data;
+ delete ivre;
+}
+
+ir_variable_refcount_visitor::~ir_variable_refcount_visitor()
+{
+ ralloc_free(this->mem_ctx);
+ _mesa_hash_table_destroy(this->ht, free_entry);
+}
// constructor
ir_variable_refcount_entry::ir_variable_refcount_entry(ir_variable *var)
ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
{
assert(var);
- foreach_iter(exec_list_iterator, iter, this->variable_list) {
- ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
- if (entry->var == var)
- return entry;
- }
- ir_variable_refcount_entry *entry = new(mem_ctx) ir_variable_refcount_entry(var);
+ struct hash_entry *e = _mesa_hash_table_search(this->ht,
+ _mesa_hash_pointer(var),
+ var);
+ if (e)
+ return (ir_variable_refcount_entry *)e->data;
+
+ ir_variable_refcount_entry *entry = new ir_variable_refcount_entry(var);
assert(entry->referenced_count == 0);
- this->variable_list.push_tail(entry);
+ _mesa_hash_table_insert(this->ht, _mesa_hash_pointer(var), var, entry);
+
return entry;
}
#include "ir_visitor.h"
#include "glsl_types.h"
-class ir_variable_refcount_entry : public exec_node
+class ir_variable_refcount_entry
{
public:
ir_variable_refcount_entry(ir_variable *var);
class ir_variable_refcount_visitor : public ir_hierarchical_visitor {
public:
- ir_variable_refcount_visitor(void)
- {
- this->mem_ctx = ralloc_context(NULL);
- this->variable_list.make_empty();
- }
-
- ~ir_variable_refcount_visitor(void)
- {
- ralloc_free(this->mem_ctx);
- }
+ ir_variable_refcount_visitor(void);
+ ~ir_variable_refcount_visitor(void);
virtual ir_visitor_status visit(ir_variable *);
virtual ir_visitor_status visit(ir_dereference_variable *);
ir_variable_refcount_entry *get_variable_entry(ir_variable *var);
- /* List of ir_variable_refcount_entry */
- exec_list variable_list;
+ struct hash_table *ht;
void *mem_ctx;
};
#include "ir_visitor.h"
#include "ir_variable_refcount.h"
#include "glsl_types.h"
+#include "main/hash_table.h"
static bool debug = false;
v.run(instructions);
- foreach_iter(exec_list_iterator, iter, v.variable_list) {
- ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
+ struct hash_entry *e;
+ hash_table_foreach(v.ht, e) {
+ ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)e->data;
/* Since each assignment is a reference, the refereneced count must be
* greater than or equal to the assignment count. If they are equal,
LOCAL_MODULE := libmesa_glsl_utils
LOCAL_SRC_FILES := \
+ main/hash_table.c \
program/prog_hash_table.c \
program/symbol_table.c
LOCAL_IS_HOST_MODULE := true
LOCAL_SRC_FILES := \
+ main/hash_table.c \
program/prog_hash_table.c \
program/symbol_table.c