[Mesa-dev] [PATCH 1/3] gallium: add new float comparison instructions returning integer masks
sroland at vmware.com
sroland at vmware.com
Mon Aug 12 16:18:02 PDT 2013
From: Roland Scheidegger <sroland at vmware.com>
Newer graphic languages don't want messy float mask results but instead true
"boolean" mask results for float comparisons. Otherwise just need to convert
the floats back to integers. Need to keep the old opcodes however due to both
legacy (gl and d3d9) needing them and because older hw can't really deal with
integers. These new FSEQ/FSGE/FSLT/FSNE opcodes are part of integer API and
hence must be supported if a driver claims to support glsl 1.30 (or
PIPE_SHADER_CAP_INTEGERS).
---
src/gallium/docs/source/tgsi.rst | 92 +++++++++++++++++++++++-----
src/gallium/include/pipe/p_shader_tokens.h | 7 ++-
2 files changed, 82 insertions(+), 17 deletions(-)
diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
index 949ad89..41f2798 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,21 @@ Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
+.. opcode:: FSLT - Float Set On Less Than (ordered)
+
+ Same comparison as SLT but returns integer instead of 1.0/0.0 float
+
+.. 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 +1366,21 @@ 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)
+
+ Same comparison as SGE but returns integer instead of 1.0/0.0 float
+
+.. 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 +1407,21 @@ 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)
+
+ Same comparison as SEQ but returns integer instead of 1.0/0.0 float
+
+.. 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 +1435,21 @@ 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)
+
+ Same comparison as SNE but returns integer instead of 1.0/0.0 float
+
+.. 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::
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 9aaf687..872dfe9 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -367,7 +367,12 @@ struct tgsi_property_data {
#define TGSI_OPCODE_TXQ_LZ 103 /* TXQ for mipmap level 0 */
/* gap */
#define TGSI_OPCODE_NOP 107
- /* gap */
+
+#define TGSI_OPCODE_FSEQ 108
+#define TGSI_OPCODE_FSGE 109
+#define TGSI_OPCODE_FSLT 110
+#define TGSI_OPCODE_FSNE 111
+
#define TGSI_OPCODE_NRM4 112
#define TGSI_OPCODE_CALLNZ 113
/* gap */
--
1.7.9.5
More information about the mesa-dev
mailing list