[Mesa-dev] [PATCH 7/8] nir/spirv: cast shift operand to u32

Karol Herbst kherbst at redhat.com
Mon Jul 16 15:32:08 UTC 2018


On Mon, Jul 16, 2018 at 5:24 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> Do we need to do something similar for specialization constants?
>

I don't think so. The problem here wasn't constants, but simply that
we can end up with non 32 bit shift values inside the SPIR-V, but we
only support 32 bit shifts in nir. It is legal SPIR-V, so we might
just want to fix that.

> On Mon, Jul 16, 2018 at 7:28 AM Karol Herbst <kherbst at redhat.com> wrote:
>>
>> Signed-off-by: Karol Herbst <kherbst at redhat.com>
>> ---
>>  src/compiler/spirv/vtn_alu.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
>> index 5db6c7f0a87..d6f149d12e9 100644
>> --- a/src/compiler/spirv/vtn_alu.c
>> +++ b/src/compiler/spirv/vtn_alu.c
>> @@ -743,6 +743,16 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
>>           src[1] = tmp;
>>        }
>>
>> +      switch (op) {
>> +      case nir_op_ishl:
>> +      case nir_op_ishr:
>> +      case nir_op_ushr:
>> +         src[1] = nir_u2u32(&b->nb, src[1]);
>> +         break;
>> +      default:
>> +         break;
>> +      }
>> +
>>        val->ssa->def = nir_build_alu(&b->nb, op, src[0], src[1], src[2],
>> src[3]);
>>        break;
>>     } /* default */
>> --
>> 2.17.1
>>
>> _______________________________________________
>> 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