nir: Move nir_lower_mediump_outputs from ir3
[mesa.git] / src / compiler / nir / nir_lower_double_ops.c
index 57bcb342a8045ae6d8b3daa2427289311de3b0c7..bb2476523ec8e48f5778a631c6576ab6e6725ecd 100644 (file)
@@ -440,6 +440,14 @@ lower_mod(nir_builder *b, nir_ssa_def *src0, nir_ssa_def *src1)
     * In practice this means the output value is actually in the interval
     * [0, y].
     *
+    * While Vulkan states this behaviour explicitly, OpenGL does not, and thus
+    * we need to assume that value should be in range [0, y); but on the other
+    * hand, mod(a,b) is defined as "a - b * floor(a/b)" and OpenGL allows for
+    * some error in division, so a/a could actually end up being 1.0 - 1ULP;
+    * so in this case floor(a/a) would end up as 0, and hence mod(a,a) == a.
+    *
+    * In summary, in the practice mod(a,a) can be "a" both for OpenGL and
+    * Vulkan.
     */
    nir_ssa_def *floor = nir_ffloor(b, nir_fdiv(b, src0, src1));