[Mesa-dev] [PATCH 1/5] glsl: Allow vector logic ops to be generated.

Connor Abbott cwabbott0 at gmail.com
Wed Mar 18 18:30:59 PDT 2015


So in GLSL, add and mul can take a combination of a scalar and a
vector, and it'll splat the scalar automatically, and with this this
series that means that and/or can now take a combination of a scalar
and a vector as well, and we'll have to splat them as well. Are you
sure that the various backends will handle this gracefully? At the
very least, we'll need to update GLSL-to-NIR to handle this case --
there's a block of opcodes in the giant switch statement that handle
generating the scalar->vector swizzle, and we'll need to move
logical_and and logical_or (perhaps logical_xor as well) over there if
they aren't already. We should probably also add something to
ir_validate similar to what ir_binop_add and ir_binop_mul have to make
this explicit. Patches 4-5 have my r-b though.

On Wed, Mar 18, 2015 at 2:53 PM, Ian Romanick <idr at freedesktop.org> wrote:
> Patches 1, 2, and 3 are
>
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>
> Patches 4 and 5 are
>
> Acked-by: Ian Romanick <ian.d.romanick at intel.com>
>
> On 03/18/2015 11:37 AM, Matt Turner wrote:
>> They're not accessible from the source language, but optimizations are
>> allowed to generate them.
>> ---
>>  src/glsl/ir_validate.cpp                                 | 6 +++---
>>  src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp | 9 +++------
>>  2 files changed, 6 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
>> index 7a7688c..72c5f06 100644
>> --- a/src/glsl/ir_validate.cpp
>> +++ b/src/glsl/ir_validate.cpp
>> @@ -543,9 +543,9 @@ ir_validate::visit_leave(ir_expression *ir)
>>     case ir_binop_logic_and:
>>     case ir_binop_logic_xor:
>>     case ir_binop_logic_or:
>> -      assert(ir->type == glsl_type::bool_type);
>> -      assert(ir->operands[0]->type == glsl_type::bool_type);
>> -      assert(ir->operands[1]->type == glsl_type::bool_type);
>> +      assert(ir->type->base_type == GLSL_TYPE_BOOL);
>> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
>> +      assert(ir->operands[1]->type->base_type == GLSL_TYPE_BOOL);
>>        break;
>>
>>     case ir_binop_dot:
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
>> index 933fdde..4049b09 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
>> @@ -271,6 +271,9 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir)
>>     case ir_binop_bit_and:
>>     case ir_binop_bit_xor:
>>     case ir_binop_bit_or:
>> +   case ir_binop_logic_and:
>> +   case ir_binop_logic_xor:
>> +   case ir_binop_logic_or:
>>     case ir_binop_less:
>>     case ir_binop_greater:
>>     case ir_binop_lequal:
>> @@ -329,12 +332,6 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir)
>>        break;
>>     }
>>
>> -   case ir_binop_logic_and:
>> -   case ir_binop_logic_xor:
>> -   case ir_binop_logic_or:
>> -      ir->fprint(stderr);
>> -      fprintf(stderr, "\n");
>> -      unreachable("not reached: expression operates on scalars only");
>>     case ir_binop_all_equal:
>>     case ir_binop_any_nequal: {
>>        ir_expression *last = NULL;
>>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list