[Mesa-dev] [PATCH] nir: create 32-bit bcsel for 32-bit conditions

Jason Ekstrand jason at jlekstrand.net
Wed Dec 19 01:47:51 UTC 2018


On December 18, 2018 19:42:56 Rhys Perry <pendingchaos02 at gmail.com> wrote:

> The 32-bit condition was in one of radv's meta shaders and had it from
> the start.
>
> 32-bit conditions seems to be valid after lowering booleans to 32-bit.
> Are they supposed to be invalid before the lowering?

It's not invalid in the sense that the validator doesn't complain. However, 
most passes are only set up to handle one type of Boolean so it's far safer 
if everything is 1-bit prior to lowering. Otherwise you may find yourself 
fixing a lot of these.

--Jason

>
> On Wed, 19 Dec 2018 at 00:59, Jason Ekstrand <jason at jlekstrand.net> wrote:
>>
>> Seems reasonable though I'm a bit surprised your running peephole_select
>> after lowering booleans.
>>
>> On December 18, 2018 18:16:46 Timothy Arceri <tarceri at itsqueeze.com> wrote:
>>
>>> Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
>>>
>>> On 18/12/18 3:16 am, Rhys Perry wrote:
>>>> Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
>>>> ---
>>>> src/compiler/nir/nir_opt_peephole_select.c | 4 +++-
>>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/src/compiler/nir/nir_opt_peephole_select.c
>>>> b/src/compiler/nir/nir_opt_peephole_select.c
>>>> index ad9d0abec0..241627ed99 100644
>>>> --- a/src/compiler/nir/nir_opt_peephole_select.c
>>>> +++ b/src/compiler/nir/nir_opt_peephole_select.c
>>>> @@ -205,7 +205,9 @@ nir_opt_peephole_select_block(nir_block *block,
>>>> nir_shader *shader,
>>>>      break;
>>>>
>>>>   nir_phi_instr *phi = nir_instr_as_phi(instr);
>>>> -      nir_alu_instr *sel = nir_alu_instr_create(shader, nir_op_bcsel);
>>>> +      nir_op sel_op = nir_src_bit_size(if_stmt->condition) == 1 ?
>>>> +                      nir_op_bcsel : nir_op_b32csel;
>>>> +      nir_alu_instr *sel = nir_alu_instr_create(shader, sel_op);
>>>>   nir_src_copy(&sel->src[0].src, &if_stmt->condition, sel);
>>>>   /* Splat the condition to all channels */
>>>>   memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle);
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev at lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev





More information about the mesa-dev mailing list