[Mesa-dev] [PATCH 2/5] glsl: ir_variable * class now has a complete_location field holding more location info
Vincent Lejeune
vljn at ovi.com
Tue Jan 24 08:43:47 PST 2012
---
src/glsl/ir.cpp | 2 ++
src/glsl/ir.h | 12 +++++++++++-
src/glsl/ir_clone.cpp | 4 ++++
3 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index a5eca5a..ce89b1b 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -26,6 +26,7 @@
#include "ir_visitor.h"
#include "glsl_types.h"
+
ir_rvalue::ir_rvalue()
{
this->type = glsl_type::error_type;
@@ -1328,6 +1329,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
this->explicit_location = false;
this->has_initializer = false;
this->location = -1;
+ this->complete_location = NULL;
this->warn_extension = NULL;
this->constant_value = NULL;
this->constant_initializer = NULL;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 1faae3c..d206326 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -34,6 +34,7 @@
#include "list.h"
#include "ir_visitor.h"
#include "ir_hierarchical_visitor.h"
+#include "location_tree.h"
#include "main/mtypes.h"
/**
@@ -131,7 +132,6 @@ protected:
}
};
-
class ir_rvalue : public ir_instruction {
public:
virtual ir_rvalue *clone(void *mem_ctx, struct hash_table *) const = 0;
@@ -398,6 +398,16 @@ public:
int location;
/**
+ * Precise storage locations of this variable
+ * It is not always sufficient to associate a single int to location of
+ * a variable. For instance one might want to store a variable in an order
+ * not following declaration order or to have arrays whose registers
+ * overlap (but not components inside these registers, of course).
+ *
+ */
+ union location_tree *complete_location;
+
+ /**
* Built-in state that backs this uniform
*
* Once set at variable creation, \c state_slots must remain invariant.
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index c63615c..429127b 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -53,6 +53,10 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
var->has_initializer = this->has_initializer;
var->depth_layout = this->depth_layout;
+ if (this->complete_location) {
+ var->complete_location = location_tree_duplicate(var, this->complete_location, var->type);
+ }
+
var->num_state_slots = this->num_state_slots;
if (this->state_slots) {
/* FINISHME: This really wants to use something like talloc_reference, but
--
1.7.7
More information about the mesa-dev
mailing list