i965: Fix a crash in the texture gradient lowering pass with cube samplers
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 13 Feb 2015 07:29:32 +0000 (08:29 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 16 Feb 2015 09:53:48 +0000 (10:53 +0100)
We need to swizzle the rhs to match the number of components in the writemask,
otherwise we'll hit an assertion in ir_assignment.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp

index 9679d2842075a55852510d99e628e1f054a54794..0424003ffd504948cb6bbacb30d9ab961130ce36 100644 (file)
@@ -124,7 +124,9 @@ lower_texture_grad_visitor::visit_leave(ir_texture *ir)
       new(mem_ctx) ir_variable(grad_type, "size", ir_var_temporary);
    if (ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE) {
       base_ir->insert_before(size);
-      base_ir->insert_before(assign(size, expr(ir_unop_i2f, txs), WRITEMASK_XY));
+      base_ir->insert_before(assign(size,
+                                    swizzle_for_size(expr(ir_unop_i2f, txs), 2),
+                                    WRITEMASK_XY));
       base_ir->insert_before(assign(size, new(mem_ctx) ir_constant(1.0f), WRITEMASK_Z));
    } else {
       emit(size, expr(ir_unop_i2f,