summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-07 13:34:23 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-07 13:34:23 -0700
commitf3fe9dddb8c528b4f9955d9105908600b4a8d0c8 (patch)
tree8107b45190a0d8a33d07dcd6500ed0dfa939d530 /source
parentf70699c78235c33f909ffff87f8edf4b58b30c51 (diff)
Map HLSL `lerp` to GLSL `mix`
- Also fix a bug in `emit.cpp` where I wasn't detecting `__intrinsic` remaps that don't include `$` (this is a byproduct of changing the string index type to be unsigned; other bugs like this may be lurking)
Diffstat (limited to 'source')
-rw-r--r--source/slang/emit.cpp2
-rw-r--r--source/slang/slang-stdlib.cpp17
2 files changed, 15 insertions, 4 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 5d85b4d57..df74d19e4 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -1466,7 +1466,7 @@ struct EmitVisitor
{
auto name = getStringOrIdentifierTokenValue(targetIntrinsicModifier->definitionToken);
- if(name.IndexOf('$') < 0)
+ if(name.IndexOf('$') == -1)
{
// Simple case: it is just an ordinary name, so we call it like a builtin.
//
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp
index 87c2c2e8a..e1bba8885 100644
--- a/source/slang/slang-stdlib.cpp
+++ b/source/slang/slang-stdlib.cpp
@@ -592,9 +592,20 @@ __generic<T : __BuiltinFloatingPointType, let N : int, let M : int> __intrinsic
__generic<T : __BuiltinFloatingPointType, let N : int> __intrinsic T length(vector<T,N> x);
// Linear interpolation
-__generic<T : __BuiltinFloatingPointType> __intrinsic T lerp(T x, T y, T s);
-__generic<T : __BuiltinFloatingPointType, let N : int> __intrinsic vector<T,N> lerp(vector<T,N> x, vector<T,N> y, vector<T,N> s);
-__generic<T : __BuiltinFloatingPointType, let N : int, let M : int> __intrinsic matrix<T,N,M> lerp(matrix<T,N,M> x, matrix<T,N,M> y, matrix<T,N,M> s);
+__generic<T : __BuiltinFloatingPointType>
+__intrinsic(glsl, mix)
+__intrinsic
+T lerp(T x, T y, T s);
+
+__generic<T : __BuiltinFloatingPointType, let N : int>
+__intrinsic(glsl, mix)
+__intrinsic
+vector<T,N> lerp(vector<T,N> x, vector<T,N> y, vector<T,N> s);
+
+__generic<T : __BuiltinFloatingPointType, let N : int, let M : int>
+__intrinsic(glsl, mix)
+__intrinsic
+matrix<T,N,M> lerp(matrix<T,N,M> x, matrix<T,N,M> y, matrix<T,N,M> s);
// Legacy lighting function (obsolete)
__intrinsic float4 lit(float n_dot_l, float n_dot_h, float m);