[Mesa-dev] [PATCH] tgsi: Add a conditional move inststruction

Roland Scheidegger sroland at vmware.com
Thu Apr 4 09:27:04 PDT 2013


FWIW it looks like we could use that opcode a bit more in glsl to tgsi
translation. There's one use of it in st_glsl_to_tgsi.cpp (though
coupled with a USNE which I'm not sure is even necessary) but another
place states that "If TGSI had a UCMP instruction or similar, this extra
instruction would not be necessary" (when it translates away what would
be a ucmp into i2f->cmp).
I don't know that if "MOVC" or "UCMP" is a better name.

Roland



Am 04.04.2013 18:06, schrieb Zack Rusin:
> Hah, yea, I'm sorry, that's a good point. So movc is a bitcast to unsigned followed by ucmp. Alright, I'm withdrawing the patch.
> 
> z
> 
> ----- Original Message -----
>>
>>
>> ----- Original Message -----
>>>>> Erm, unsigned < 0 doesn't make sense.
>>>>
>>>> Ah indeed!
>>>>
>>>>> Definitely what the description says:
>>>>> static void
>>>>> micro_ucmp(union tgsi_exec_channel *dst,
>>>>>            const union tgsi_exec_channel *src0,
>>>>>            const union tgsi_exec_channel *src1,
>>>>>            const union tgsi_exec_channel *src2)
>>>>> {
>>>>>    dst->u[0] = src0->u[0] ? src1->u[0] : src2->u[0];
>>>>>    dst->u[1] = src0->u[1] ? src1->u[1] : src2->u[1];
>>>>>    dst->u[2] = src0->u[2] ? src1->u[2] : src2->u[2];
>>>>>    dst->u[3] = src0->u[3] ? src1->u[3] : src2->u[3];
>>>>> }
>>>>>
>>>>> or
>>>>>
>>>>>    case TGSI_OPCODE_UCMP:
>>>>>    case TGSI_OPCODE_CMP:
>>>>>       FOR_EACH_DST_ENABLED_CHANNEL(0, c, tgsi) {
>>>>>          src0 = fetchSrc(0, c);
>>>>>          src1 = fetchSrc(1, c);
>>>>>          src2 = fetchSrc(2, c);
>>>>>          if (src1 == src2)
>>>>>             mkMov(dst0[c], src1);
>>>>>          else
>>>>>             mkCmp(OP_SLCT, (srcTy == TYPE_F32) ? CC_LT(less than 0) :
>>>>> CC_NE(not equal 0),
>>>>>                   srcTy, dst0[c], src1, src2, src0);
>>>>>       }
>>>>>
>>>>
>>>> But odd enough, the implementations I happend to look at seemed to do
>>>> "foo
>>>>> =
>>>> 0":
>>>
>>> Yea, like I mentioned it's pretty broken. Sometimes it's implemented as
>>> UCMP,
>>> sometimes it's implemented as MOVC.
>>> It seems to be used only as MOVC.
>>> It feels silly writing this, but we should probably make UCMP act like UCMP
>>> and add MOVC and use it when we need a MOVC.
>>
>> Zack, I believe Christoph has a point when he says that UCMP is semantically
>> the same as MOVC.
>>
>> Because for unsigned integers, "foo > 0" is the same as "foo != 0", therefore
>> having UCMP defined as
>>
>>   dst = src0 > 0 ? src1 : src2
>>
>> or a MOVC as
>>
>>   dst = src0 != 0 ? src1 : src2
>>
>> is pretty much the same.
>>
>> Jose
>>
>>
> _______________________________________________
> 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