[Mesa-dev] [PATCH 06/12] glsl: Add lowering pass for ir_triop_vector_insert
Ian Romanick
idr at freedesktop.org
Tue Apr 9 16:10:14 PDT 2013
On 04/09/2013 10:29 AM, Eric Anholt wrote:
> Ian Romanick <idr at freedesktop.org> writes:
>
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> This will eventually replace do_vec_index_to_cond_assign. This lowering
>> pass is called in all the places where do_vec_index_to_cond_assign or
>> do_vec_index_to_swizzle is called.
>
>> +
>> + ir_constant *const cmp_indices =
>> + new(factory.mem_ctx) ir_constant(glsl_type::get_instance(GLSL_TYPE_INT,
>> + components,
>> + 1),
>> + &cmp_indices_data);
>> +
>> + ir_variable *const cmp_result =
>> + factory.make_temp(glsl_type::get_instance(GLSL_TYPE_BOOL,
>> + components,
>> + 1),
>> + "index_condition");
>
> I wish we had some helpers like glsl_type::bvec(components) instead of
> these verbose getters for sized vectors.
>
>> + ir_variable *const src_temp =
>> + factory.make_temp(expr->operands[1]->type, "src_temp");
>> +
>> + const ir_swizzle_mask m = { 0, 0, 0, 0, components, false };
>> + ir_rvalue *broadcast_index =
>> + new(factory.mem_ctx) ir_swizzle(expr->operands[2], m);
>
> Optionally:
>
> ir_rvalue *broadcast_index =
> swizzle_for_size(swizzle_xxxx(expr->operands[2]), components).
Hm... I think I tried that (or some variation there of), but it didn't
work. I'll try again.
>> + factory.emit(assign(temp, expr->operands[0]));
>> + factory.emit(assign(src_temp, expr->operands[1]));
>> + factory.emit(assign(cmp_result, equal(broadcast_index, cmp_indices)));
>> + factory.emit(if_tree(swizzle_x(cmp_result), assign(temp, src_temp, 1)));
>> + factory.emit(if_tree(swizzle_y(cmp_result), assign(temp, src_temp, 2)));
>> +
>> + if (components > 2)
>> + factory.emit(if_tree(swizzle_z(cmp_result), assign(temp, src_temp, 4)));
>> +
>> + if (components > 3)
>> + factory.emit(if_tree(swizzle_w(cmp_result), assign(temp, src_temp, 8)));
>
> Please use the WRITEMASK_* defines here.
Okay.
> I know our hardware doesn't like the swizzling of that bvec compare
> result and we'd rather just see individual compares as the condition of
> each if statement. (we basically have to emit a compare of the swizzled
> bool against 0, after masking its high bits off, when we could have just
> compared the index value to a constant). I imagine other hardware would
> prefer the same.
Should we add a lowering pass or an option of some sort?
More information about the mesa-dev
mailing list