[Mesa-dev] [PATCH V2 2/3] i965: Generalize coord+offset lowering pass for ir_txf
Chris Forbes
chrisf at ijw.co.nz
Mon Oct 14 10:36:36 CEST 2013
ir_txf expects an ivec* coordinate, and may be larger than ivec2;
shuffle things around so that this will work.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
.../dri/i965/brw_lower_unnormalized_offset.cpp | 51 ++++++++++++++++++----
1 file changed, 42 insertions(+), 9 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 733c289..9106726 100644
--- a/src/mesa/drivers/dri/i965/brw_lower_unnormalized_offset.cpp
+++ b/src/mesa/drivers/dri/i965/brw_lower_unnormalized_offset.cpp
@@ -50,20 +50,53 @@ 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;
+ 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);
- ir->coordinate = new (mem_ctx) ir_expression(
- ir_binop_add,
- ir->coordinate,
- new (mem_ctx) ir_expression(
- ir_unop_i2f,
- ir->offset));
- ir->offset = NULL;
+ if (ir->op == ir_txf) {
+ ir_variable *var = new (mem_ctx) ir_variable(
+ ir->coordinate->type, "coordinate", ir_var_auto);
+ base_ir->insert_before(var);
+ ir_assignment *assign = new (mem_ctx) ir_assignment(
+ new (mem_ctx) ir_dereference_variable(var),
+ ir->coordinate,
+ NULL);
+ base_ir->insert_before(assign);
+
+ assign = new (mem_ctx) ir_assignment(
+ new (mem_ctx) ir_dereference_variable(var),
+ new (mem_ctx) ir_expression(
+ ir_binop_add,
+ new (mem_ctx) ir_swizzle(
+ new (mem_ctx) ir_dereference_variable(var),
+ 0, 1, 2, 3, ir->offset->type->vector_elements),
+ ir->offset),
+ NULL);
+ assign->write_mask = (1 << ir->offset->type->vector_elements) - 1;
+ base_ir->insert_before(assign);
+
+ ir->coordinate = new (mem_ctx) ir_dereference_variable(var);
+ } else {
+ ir->coordinate = new (mem_ctx) ir_expression(
+ ir_binop_add,
+ ir->coordinate,
+ new (mem_ctx) ir_expression(
+ ir_unop_i2f,
+ ir->offset));
+ }
+
+ ir->offset = NULL;
progress = true;
return visit_continue;
--
1.8.4
More information about the mesa-dev
mailing list