diff options
author | Chris Forbes <[email protected]> | 2013-10-13 00:02:55 +1300 |
---|---|---|
committer | Chris Forbes <[email protected]> | 2013-10-26 22:56:25 +1300 |
commit | 06de9f8ff15559dffddf26d1969d35e74fbf253f (patch) | |
tree | 3b331f11ebda41031e7988935d557e53c15a3db0 /src/mesa/drivers | |
parent | 72b5e9c42a6cfe085f7683057672ab2278e45c2e (diff) |
i965: Generalize coord+offset lowering pass for ir_txf
ir_txf expects an ivec* coordinate, and may be larger than ivec2;
shuffle things around so that this will work.
V2: Fix style nits, use ir_builder
Signed-off-by: Chris Forbes <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_lower_unnormalized_offset.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_lower_unnormalized_offset.cpp b/src/mesa/drivers/dri/i965/brw_lower_unnormalized_offset.cpp index 0581e0539ae..df4fe4be463 100644 --- a/src/mesa/drivers/dri/i965/brw_lower_unnormalized_offset.cpp +++ b/src/mesa/drivers/dri/i965/brw_lower_unnormalized_offset.cpp @@ -52,11 +52,34 @@ public: ir_visitor_status brw_lower_unnormalized_offset_visitor::visit_leave(ir_texture *ir) { - if (ir->sampler->type->sampler_dimensionality != GLSL_SAMPLER_DIM_RECT || - !ir->offset || ir->op != ir_tg4) + if (!ir->offset) return visit_continue; - ir->coordinate = add(ir->coordinate, i2f(ir->offset)); + if (ir->op == ir_tg4) { + if (ir->sampler->type->sampler_dimensionality != GLSL_SAMPLER_DIM_RECT) + return visit_continue; + } + else if (ir->op != ir_txf) { + return visit_continue; + } + + void *mem_ctx = ralloc_parent(ir); + + if (ir->op == ir_txf) { + ir_variable *var = new(mem_ctx) ir_variable(ir->coordinate->type, + "coordinate", + ir_var_temporary); + base_ir->insert_before(var); + base_ir->insert_before(assign(var, ir->coordinate)); + base_ir->insert_before(assign(var, + add(swizzle_for_size(var, ir->offset->type->vector_elements), ir->offset), + (1 << ir->offset->type->vector_elements) - 1)); + + ir->coordinate = new(mem_ctx) ir_dereference_variable(var); + } else { + ir->coordinate = add(ir->coordinate, i2f(ir->offset)); + } + ir->offset = NULL; progress = true; |