summaryrefslogtreecommitdiffstats
path: root/src/gallium/docs/source
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2013-02-01 10:59:43 -0700
committerBrian Paul <[email protected]>2013-02-04 09:33:44 -0700
commitd276a40e15dce26494ec61670fe2aeef62dbeba1 (patch)
tree387857a2e30bc93de9c0c142961efe0be82471ef /src/gallium/docs/source
parent6455d40b7ec09e3a3923c9b78952dc29627afed1 (diff)
gallium: add SQRT shader opcode
The glsl-to-tgsi translater will emit SQRT to implement GLSL's sqrt() and distance() functions if the PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED query says it's supported by the driver. Otherwise, sqrt(x) is implemented with x*rsq(x). The problem with this is sqrt(0) must be handled specially because rsq(0) might be Inf/NaN/undefined (and then 0*rsq(0) is Inf/Nan/undefined). In the glsl-to-tgsi code we use an extra CMP to check if x is zero and then replace the result of x*rsq(x) with zero. In the end, this makes sqrt() generate much more reasonable code for drivers that can do square roots. Note that many of piglit's generated shader tests use the GLSL distance() function.
Diffstat (limited to 'src/gallium/docs/source')
-rw-r--r--src/gallium/docs/source/tgsi.rst9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
index 548a9a39855..5f03f324535 100644
--- a/src/gallium/docs/source/tgsi.rst
+++ b/src/gallium/docs/source/tgsi.rst
@@ -89,6 +89,15 @@ This instruction replicates its result.
dst = \frac{1}{\sqrt{|src.x|}}
+.. opcode:: SQRT - Square Root
+
+This instruction replicates its result.
+
+.. math::
+
+ dst = {\sqrt{src.x}}
+
+
.. opcode:: EXP - Approximate Exponential Base 2
.. math::