[Mesa-dev] [PATCH 1/7] glsl: Adds an horizontal_location fields to ir_variable.
Vincent Lejeune
vljn at ovi.com
Thu Feb 16 13:03:07 PST 2012
This field allows to address output variables more precisely
(varyings won't have to "hold" a whole register if they are not vec4).
---
src/glsl/ir.cpp | 1 +
src/glsl/ir.h | 22 ++++++++++++++++++++++
src/glsl/ir_clone.cpp | 1 +
src/glsl/linker.cpp | 6 +++++-
4 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index a5eca5a..a4c93ce 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1335,6 +1335,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
this->pixel_center_integer = false;
this->depth_layout = ir_depth_layout_none;
this->used = false;
+ this->horizontal_location = 0;
if (type && type->base_type == GLSL_TYPE_SAMPLER)
this->read_only = true;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 1faae3c..cf0e444 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -396,6 +396,28 @@ public:
* slot has not been assigned, the value will be -1.
*/
int location;
+
+ /**
+ * Storage starting component for this variable
+ *
+ * Variable storage can be 4-bytes aligned instead of 16-bytes aligned to
+ * preserve space, for instance a vec2 can be stored in FILE[location].yz
+ * and in this case, its starting_component is y (eq to 1).
+ *
+ * Register can be seen as a 2D array as follow :
+ * - Locations are assigned to rows,
+ * - Components are assigned to columns.
+ *
+ * 0: [ 0.x 0.y 0.z 0.w]
+ * 1: [ 1.x 1.y 1.z 1.w]
+ * 2: [ 2.x 2.y 2.z 2.w]
+ * ...
+ * n: [ n.x n.y n.z n.w]
+ *
+ * Thus we refers this as "horizontal_location" (vertical location is
+ * the above "location" field).
+ */
+ unsigned horizontal_location:2;
/**
* Built-in state that backs this uniform
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index c63615c..17e800a 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -46,6 +46,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
var->invariant = this->invariant;
var->interpolation = this->interpolation;
var->location = this->location;
+ var->horizontal_location = this->horizontal_location;
var->warn_extension = this->warn_extension;
var->origin_upper_left = this->origin_upper_left;
var->pixel_center_integer = this->pixel_center_integer;
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 5095751..8e690ac 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1458,6 +1458,8 @@ private:
* variable. -1 if a location hasn't been assigned yet.
*/
int location;
+
+ unsigned horizontal_location;
/**
* If location != -1, the number of vector elements in this variable, or 1
@@ -1496,6 +1498,7 @@ tfeedback_decl::init(struct gl_context *ctx, struct gl_shader_program *prog,
*/
this->location = -1;
+ this->horizontal_location = 0;
this->orig_name = input;
this->is_clip_distance_mesa = false;
@@ -1602,6 +1605,7 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
this->vector_elements = output_var->type->vector_elements;
this->matrix_columns = output_var->type->matrix_columns;
this->type = output_var->type->gl_type;
+ this->horizontal_location = output_var->horizontal_location;
}
/* From GL_EXT_transform_feedback:
@@ -1687,7 +1691,7 @@ tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
for (unsigned v = 0; v < this->matrix_columns; ++v) {
unsigned num_components = this->vector_elements;
assert(info->NumOutputs < max_outputs);
- info->Outputs[info->NumOutputs].ComponentOffset = 0;
+ info->Outputs[info->NumOutputs].ComponentOffset = this->horizontal_location;
if (this->is_clip_distance_mesa) {
if (this->is_subscripted) {
num_components = 1;
--
1.7.7
More information about the mesa-dev
mailing list