summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2020-04-20 16:24:49 -0700
committerGitHub <noreply@github.com>2020-04-20 16:24:49 -0700
commit6d4fa92a86fe5d05dbfa248524cf976ab27f4444 (patch)
treeb931a3badcf6b18178d26fa980baba4426034072 /source
parentc4441d804aaa97bad7ff01bef505491d30bbc046 (diff)
Fix stdlib definitions of half<->float conversion (#1326)
These ended up being additional cases where we needed to use an explicit loop over components in the stdlib in order to produce valid GLSL output, but the existing declarations weren't doing it. I added a very minimal cross-compilation test just to confirm that we generate valid SPIR-V for code using `f16tof32()`.
Diffstat (limited to 'source')
-rw-r--r--source/slang/hlsl.meta.slang14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index 73cda7761..e9da539bf 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -1158,19 +1158,25 @@ 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")
+__glsl_version(420)
float f16tof32(uint value);
__generic<let N : int>
-__target_intrinsic(glsl, "unpackHalf2x16($0).x")
-vector<float,N> f16tof32(vector<uint,N> value);
+vector<float, N> f16tof32(vector<uint, N> value)
+{
+ VECTOR_MAP_UNARY(float, N, f16tof32, value);
+}
// Convert to 16-bit float stored in low bits of integer
__target_intrinsic(glsl, "packHalf2x16(vec2($0,0.0))")
+__glsl_version(420)
uint f32tof16(float value);
__generic<let N : int>
-__target_intrinsic(glsl, "packHalf2x16(vec2($0,0.0))")
-vector<uint,N> f32tof16(vector<float,N> value);
+vector<uint, N> f32tof16(vector<float, N> value)
+{
+ VECTOR_MAP_UNARY(uint, N, f32tof16, value);
+}
// Flip surface normal to face forward, if needed
__generic<T : __BuiltinFloatingPointType, let N : int>