[Mesa-dev] [RFC]: gallium: add new float comparison opcodes returning integer booleans

Roland Scheidegger sroland at vmware.com
Fri Aug 9 11:42:22 PDT 2013


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.

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::
> 


More information about the mesa-dev mailing list