[Mesa-dev] [PATCH] glsl_to_tgsi: Adds support for horizontal location
Vincent Lejeune
vljn at ovi.com
Tue Feb 7 12:55:03 PST 2012
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 33 ++++++++++++++++++++++++---
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ab05896..388e9d7 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1949,6 +1949,17 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
}
this->result = st_src_reg(entry->file, entry->index, var->type);
+ if (ir->type->is_scalar() || ir->type->is_vector())
+ this->result.swizzle = swizzle_for_size(ir->type->vector_elements);
+ else
+ this->result.swizzle = SWIZZLE_NOOP;
+ unsigned swz = this->result.swizzle;
+ this->result.swizzle = MAKE_SWIZZLE4(
+ GET_SWZ(swz, 0) + ir->var->horizontal_location % 4,
+ GET_SWZ(swz, 1) + ir->var->horizontal_location % 4,
+ GET_SWZ(swz, 2) + ir->var->horizontal_location % 4,
+ GET_SWZ(swz, 3) + ir->var->horizontal_location % 4
+ );
if (!native_integers)
this->result.type = GLSL_TYPE_FLOAT;
}
@@ -2169,10 +2180,17 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
l.writemask = WRITEMASK_XYZW;
} else if (ir->lhs->type->is_scalar() &&
ir->lhs->variable_referenced()->mode == ir_var_out) {
- /* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
- * FINISHME: W component of fragment shader output zero, work correctly.
- */
- l.writemask = WRITEMASK_XYZW;
+
+ ir_variable *inside_var = ir->lhs->variable_referenced();
+ if (inside_var->location >= VERT_RESULT_VAR0) {
+ l.writemask = 1 << inside_var->horizontal_location;
+ } else {
+ /* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
+ * FINISHME: W component of fragment shader output zero, work correctly.
+ */
+ l.writemask = WRITEMASK_XYZW;
+ }
+
} else {
int swizzles[4];
int first_enabled_chan = 0;
@@ -2180,6 +2198,13 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
l.writemask = ir->write_mask;
+ if (ir_variable *inside_var = ir->lhs->variable_referenced()) {
+ if (inside_var->location >= VERT_RESULT_VAR0) {
+ l.writemask = l.writemask << inside_var->horizontal_location;
+
+ }
+ }
+
for (int i = 0; i < 4; i++) {
if (l.writemask & (1 << i)) {
first_enabled_chan = GET_SWZ(r.swizzle, i);
--
1.7.7
More information about the mesa-dev
mailing list