summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorRobert Stepinski <rob.stepinski@gmail.com>2019-03-06 17:44:02 -0500
committerTim Foley <tfoleyNV@users.noreply.github.com>2019-03-06 14:44:02 -0800
commit87610f6def3e3dceac0082c1b60abbe2aee09014 (patch)
treedec1143f7326c6a456f2f664a464cda1168f4659 /source
parent325b721d1d488e2ea74d13d914ec1f31761989ea (diff)
Add GLSL intrinsics for f32tof16() and f16tof32() (#883)
Diffstat (limited to 'source')
-rw-r--r--source/slang/hlsl.meta.slang12
-rw-r--r--source/slang/hlsl.meta.slang.h14
2 files changed, 21 insertions, 5 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index a8fd37243..4135a9051 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -717,12 +717,20 @@ __generic<T : __BuiltinFloatingPointType, let N : int> vector<T,N> exp2(vector<T
__generic<T : __BuiltinFloatingPointType, let N : int, let M : int> matrix<T,N,M> exp2(matrix<T,N,M> x);
// Convert 16-bit float stored in low bits of integer
+__target_intrinsic(glsl, "unpackHalf2x16($0).x")
float f16tof32(uint value);
-__generic<let N : int> vector<float,N> f16tof32(vector<uint,N> value);
+
+__generic<let N : int>
+__target_intrinsic(glsl, "unpackHalf2x16($0).x")
+vector<float,N> f16tof32(vector<uint,N> value);
// Convert to 16-bit float stored in low bits of integer
+__target_intrinsic(glsl, "packHalf2x16(vec2($0,0.0))")
uint f32tof16(float value);
-__generic<let N : int> vector<uint,N> f32tof16(vector<float,N> value);
+
+__generic<let N : int>
+__target_intrinsic(glsl, "packHalf2x16(vec2($0,0.0))")
+vector<uint,N> f32tof16(vector<float,N> value);
// Flip surface normal to face forward, if needed
__generic<T : __BuiltinFloatingPointType, let N : int> vector<T,N> faceforward(vector<T,N> n, vector<T,N> i, vector<T,N> ng);
diff --git a/source/slang/hlsl.meta.slang.h b/source/slang/hlsl.meta.slang.h
index 375c8aab0..67d8d3cc0 100644
--- a/source/slang/hlsl.meta.slang.h
+++ b/source/slang/hlsl.meta.slang.h
@@ -793,12 +793,20 @@ SLANG_RAW("__generic<T : __BuiltinFloatingPointType, let N : int> vector<T,N> ex
SLANG_RAW("__generic<T : __BuiltinFloatingPointType, let N : int, let M : int> matrix<T,N,M> exp2(matrix<T,N,M> x);\n")
SLANG_RAW("\n")
SLANG_RAW("// Convert 16-bit float stored in low bits of integer\n")
+SLANG_RAW("__target_intrinsic(glsl, \"unpackHalf2x16($0).x\")\n")
SLANG_RAW("float f16tof32(uint value);\n")
-SLANG_RAW("__generic<let N : int> vector<float,N> f16tof32(vector<uint,N> value);\n")
+SLANG_RAW("\n")
+SLANG_RAW("__generic<let N : int>\n")
+SLANG_RAW("__target_intrinsic(glsl, \"unpackHalf2x16($0).x\")\n")
+SLANG_RAW("vector<float,N> f16tof32(vector<uint,N> value);\n")
SLANG_RAW("\n")
SLANG_RAW("// Convert to 16-bit float stored in low bits of integer\n")
+SLANG_RAW("__target_intrinsic(glsl, \"packHalf2x16(vec2($0,0.0))\")\n")
SLANG_RAW("uint f32tof16(float value);\n")
-SLANG_RAW("__generic<let N : int> vector<uint,N> f32tof16(vector<float,N> value);\n")
+SLANG_RAW("\n")
+SLANG_RAW("__generic<let N : int>\n")
+SLANG_RAW("__target_intrinsic(glsl, \"packHalf2x16(vec2($0,0.0))\")\n")
+SLANG_RAW("vector<uint,N> f32tof16(vector<float,N> value);\n")
SLANG_RAW("\n")
SLANG_RAW("// Flip surface normal to face forward, if needed\n")
SLANG_RAW("__generic<T : __BuiltinFloatingPointType, let N : int> vector<T,N> faceforward(vector<T,N> n, vector<T,N> i, vector<T,N> ng);\n")
@@ -1513,7 +1521,7 @@ for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa)
sb << "};\n";
}
-SLANG_RAW("#line 1440 \"hlsl.meta.slang\"")
+SLANG_RAW("#line 1448 \"hlsl.meta.slang\"")
SLANG_RAW("\n")
SLANG_RAW("\n")
SLANG_RAW("\n")