--- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 37 +++++++++++++++++++++++---- 1 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index f139e95..5872519 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; } @@ -2004,10 +2015,10 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir) } /* If the type is smaller than a vec4, replicate the last channel out. */ - if (ir->type->is_scalar() || ir->type->is_vector()) + /*if (ir->type->is_scalar() || ir->type->is_vector()) src.swizzle = swizzle_for_size(ir->type->vector_elements); else - src.swizzle = SWIZZLE_NOOP; + src.swizzle = SWIZZLE_NOOP;*/ this->result = src; } @@ -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 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev