summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-12 15:10:06 -0700
committerGitHub <noreply@github.com>2024-03-12 15:10:06 -0700
commiteef7e208bf7436a4f111a9290f37204e3220d82b (patch)
tree049e4a7dd90d1d0f53d09896c807d93a8ea7ef2e
parentedc85fc4631782d42e113f00dfbbd113dcd8c96f (diff)
Fix derivative implementation of `clamp`. (#3750)
-rw-r--r--source/slang/diff.meta.slang4
1 files changed, 2 insertions, 2 deletions
diff --git a/source/slang/diff.meta.slang b/source/slang/diff.meta.slang
index 8a46f7d60..5817ac7cf 100644
--- a/source/slang/diff.meta.slang
+++ b/source/slang/diff.meta.slang
@@ -1548,7 +1548,7 @@ DifferentialPair<T> __d_clamp(DifferentialPair<T> dpx, DifferentialPair<T> dpMin
{
return DifferentialPair<T>(
clamp(dpx.p, dpMin.p, dpMax.p),
- dpx.p < dpMin.p ? (dpx.p > dpMax.p ? dpMax.d : dpx.d) : dpMin.d);
+ dpx.p < dpMin.p ? dpMin.d : (dpx.p > dpMax.p ? dpMax.d : dpx.d));
}
__generic<T : __BuiltinFloatingPointType>
[BackwardDifferentiable]
@@ -1558,7 +1558,7 @@ void __d_clamp(inout DifferentialPair<T> dpx, inout DifferentialPair<T> dpMin, i
{
dpx = diffPair(dpx.p, dpx.p > dpMin.p && dpx.p < dpMax.p ? dOut : T.dzero());
dpMin = diffPair(dpMin.p, dpx.p <= dpMin.p ? dOut : T.dzero());
- dpMax = diffPair(dpMin.p, dpx.p >= dpMax.p ? dOut : T.dzero());
+ dpMax = diffPair(dpMax.p, dpx.p >= dpMax.p ? dOut : T.dzero());
}
VECTOR_MATRIX_TERNARY_DIFF_IMPL(clamp)