[Mesa-dev] [RFC]: gallium: add new float comparison opcodes returning integer booleans
Roland Scheidegger
sroland at vmware.com
Fri Aug 9 12:31:47 PDT 2013
Am 09.08.2013 21:00, schrieb Christoph Bumiller:
> On 09.08.2013 20:42, Roland Scheidegger wrote:
>> This is a proposal for new comparison instructions, as the old ones
>> don't really fit modern (graphic or opencl I guess for that matter)
>> languages well.
>> If you've got objections, think the naming is crazy or whatnot I'm open
>> for suggestions :-). I would think this is not just a much better fit
>> for d3d10/glsl but for hw as well.
>
> I think current hardware can do both, and as for the names, I'm fine
> with the prefixed ones being the "modern" opcodes (prefix referring to
> the source type in both cases) and the ones that are named exactly like
> the legacy opcodes behaving like the legacy ones.
>
> Otoh newcomers might get confused and think the F prefix meaning that
> they should return a float, we had a similar issue with legacy-KIL and
> KILP-condition-is-predicate-if-any (and I just need to say again I'd
> have preferred to keep the name KIL and rename KILP to DISCARD), but
> seriously, the opcodes are documented so it should be no trouble to
> figure out what they do (ok in practice that doesn't always work since
> we sometimes like to read what we expect instead of what's actually
> written).
Yes the naming gets a bit inconsistent. Now d3d10 just uses eq/ge/lt/ne,
so basically the same as our old names but without the "s", and uses a
prefix only for the integer comparison ones. But I really didn't feel
like renaming the legacy ones (and reusing the old names for new
behavior is just asking for trouble anyway).
I guess something like SGEI etc. would also do but that doesn't look
better to me neither. Now just d3d10 names would do too (so dropping the
s) but that is inconsistent with the integer comparison opcodes too.
Difficult problem :-).
Though maybe another option would be to just rename all the integer
comparisons too (dropping the "s") but I'm not sure there's really a
good enough reason for changing the code everywhere just so the names
are a bit more consistent.
>> Roland
>>
>> Am 09.08.2013 20:40, schrieb sroland at vmware.com:
>>> From: Roland Scheidegger <sroland at vmware.com>
>>>
>>> The old float comparison opcodes always return floats 0.0 and 1.0 (clarified
>>> in docs these were really floats, was always the case) for legacy graphics.
>>> But everybody else (opengl,opencl,d3d10) just has to work around their
>>> return results (converting the returned float back to int/boolean).
>>> ---
>>> src/gallium/docs/source/tgsi.rst | 84 ++++++++++++++++++++++++++++++--------
>>> 1 file changed, 68 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
>>> index 949ad89..b7c40cf 100644
>>> --- a/src/gallium/docs/source/tgsi.rst
>>> +++ b/src/gallium/docs/source/tgsi.rst
>>> @@ -512,13 +512,13 @@ This instruction replicates its result.
>>>
>>> .. math::
>>>
>>> - dst.x = (src0.x == src1.x) ? 1 : 0
>>> + dst.x = (src0.x == src1.x) ? 1.0F : 0.0F
>>>
>>> - dst.y = (src0.y == src1.y) ? 1 : 0
>>> + dst.y = (src0.y == src1.y) ? 1.0F : 0.0F
>>>
>>> - dst.z = (src0.z == src1.z) ? 1 : 0
>>> + dst.z = (src0.z == src1.z) ? 1.0F : 0.0F
>>>
>>> - dst.w = (src0.w == src1.w) ? 1 : 0
>>> + dst.w = (src0.w == src1.w) ? 1.0F : 0.0F
>>>
>>>
>>> .. opcode:: SFL - Set On False
>>> @@ -538,13 +538,13 @@ This instruction replicates its result.
>>>
>>> .. math::
>>>
>>> - dst.x = (src0.x > src1.x) ? 1 : 0
>>> + dst.x = (src0.x > src1.x) ? 1.0F : 0.0F
>>>
>>> - dst.y = (src0.y > src1.y) ? 1 : 0
>>> + dst.y = (src0.y > src1.y) ? 1.0F : 0.0F
>>>
>>> - dst.z = (src0.z > src1.z) ? 1 : 0
>>> + dst.z = (src0.z > src1.z) ? 1.0F : 0.0F
>>>
>>> - dst.w = (src0.w > src1.w) ? 1 : 0
>>> + dst.w = (src0.w > src1.w) ? 1.0F : 0.0F
>>>
>>>
>>> .. opcode:: SIN - Sine
>>> @@ -560,26 +560,26 @@ This instruction replicates its result.
>>>
>>> .. math::
>>>
>>> - dst.x = (src0.x <= src1.x) ? 1 : 0
>>> + dst.x = (src0.x <= src1.x) ? 1.0F : 0.0F
>>>
>>> - dst.y = (src0.y <= src1.y) ? 1 : 0
>>> + dst.y = (src0.y <= src1.y) ? 1.0F : 0.0F
>>>
>>> - dst.z = (src0.z <= src1.z) ? 1 : 0
>>> + dst.z = (src0.z <= src1.z) ? 1.0F : 0.0F
>>>
>>> - dst.w = (src0.w <= src1.w) ? 1 : 0
>>> + dst.w = (src0.w <= src1.w) ? 1.0F : 0.0F
>>>
>>>
>>> .. opcode:: SNE - Set On Not Equal
>>>
>>> .. math::
>>>
>>> - dst.x = (src0.x != src1.x) ? 1 : 0
>>> + dst.x = (src0.x != src1.x) ? 1.0F : 0.0F
>>>
>>> - dst.y = (src0.y != src1.y) ? 1 : 0
>>> + dst.y = (src0.y != src1.y) ? 1.0F : 0.0F
>>>
>>> - dst.z = (src0.z != src1.z) ? 1 : 0
>>> + dst.z = (src0.z != src1.z) ? 1.0F : 0.0F
>>>
>>> - dst.w = (src0.w != src1.w) ? 1 : 0
>>> + dst.w = (src0.w != src1.w) ? 1.0F : 0.0F
>>>
>>>
>>> .. opcode:: STR - Set On True
>>> @@ -1325,6 +1325,19 @@ Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
>>>
>>>
>>>
>>> +.. opcode:: FSLT - Float Set On Less Than (ordered)
>>> +
>>> +.. math::
>>> +
>>> + dst.x = (src0.x < src1.x) ? ~0 : 0
>>> +
>>> + dst.y = (src0.y < src1.y) ? ~0 : 0
>>> +
>>> + dst.z = (src0.z < src1.z) ? ~0 : 0
>>> +
>>> + dst.w = (src0.w < src1.w) ? ~0 : 0
>>> +
>>> +
>>> .. opcode:: ISLT - Signed Integer Set On Less Than
>>>
>>> .. math::
>>> @@ -1351,6 +1364,19 @@ Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
>>> dst.w = (src0.w < src1.w) ? ~0 : 0
>>>
>>>
>>> +.. opcode:: FSGE - Float Set On Greater Equal Than (ordered)
>>> +
>>> +.. math::
>>> +
>>> + dst.x = (src0.x >= src1.x) ? ~0 : 0
>>> +
>>> + dst.y = (src0.y >= src1.y) ? ~0 : 0
>>> +
>>> + dst.z = (src0.z >= src1.z) ? ~0 : 0
>>> +
>>> + dst.w = (src0.w >= src1.w) ? ~0 : 0
>>> +
>>> +
>>> .. opcode:: ISGE - Signed Integer Set On Greater Equal Than
>>>
>>> .. math::
>>> @@ -1377,6 +1403,19 @@ Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
>>> dst.w = (src0.w >= src1.w) ? ~0 : 0
>>>
>>>
>>> +.. opcode:: FSEQ - Float Set On Equal (ordered)
>>> +
>>> +.. math::
>>> +
>>> + dst.x = (src0.x == src1.x) ? ~0 : 0
>>> +
>>> + dst.y = (src0.y == src1.y) ? ~0 : 0
>>> +
>>> + dst.z = (src0.z == src1.z) ? ~0 : 0
>>> +
>>> + dst.w = (src0.w == src1.w) ? ~0 : 0
>>> +
>>> +
>>> .. opcode:: USEQ - Integer Set On Equal
>>>
>>> .. math::
>>> @@ -1390,6 +1429,19 @@ Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
>>> dst.w = (src0.w == src1.w) ? ~0 : 0
>>>
>>>
>>> +.. opcode:: FSNE - Float Set On Not Equal (unordered)
>>> +
>>> +.. math::
>>> +
>>> + dst.x = (src0.x != src1.x) ? ~0 : 0
>>> +
>>> + dst.y = (src0.y != src1.y) ? ~0 : 0
>>> +
>>> + dst.z = (src0.z != src1.z) ? ~0 : 0
>>> +
>>> + dst.w = (src0.w != src1.w) ? ~0 : 0
>>> +
>>> +
>>> .. opcode:: USNE - Integer Set On Not Equal
>>>
>>> .. math::
>>>
>> _______________________________________________
>> 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