summaryrefslogtreecommitdiffstats
path: root/tests
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 /tests
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 'tests')
-rw-r--r--tests/cross-compile/half-conversion.slang13
-rw-r--r--tests/cross-compile/half-conversion.slang.glsl42
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/cross-compile/half-conversion.slang b/tests/cross-compile/half-conversion.slang
new file mode 100644
index 000000000..316629f81
--- /dev/null
+++ b/tests/cross-compile/half-conversion.slang
@@ -0,0 +1,13 @@
+// half-conversion.slang
+
+//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage fragment
+
+cbuffer C
+{
+ uint4 u;
+}
+
+float4 main() : SV_Target
+{
+ return f16tof32(u);
+}
diff --git a/tests/cross-compile/half-conversion.slang.glsl b/tests/cross-compile/half-conversion.slang.glsl
new file mode 100644
index 000000000..3b7b740e4
--- /dev/null
+++ b/tests/cross-compile/half-conversion.slang.glsl
@@ -0,0 +1,42 @@
+//half-conversion.slang.glsl
+//TEST_IGNORE_FILE:
+
+#version 450
+
+struct SLANG_ParameterGroup_C_0
+{
+ uvec4 u_0;
+};
+
+layout(binding = 0)
+layout(std140) uniform _S1
+{
+ SLANG_ParameterGroup_C_0 _data;
+} C_0;
+
+vec4 f16tof32_0(uvec4 value_0)
+{
+ int i_0;
+ vec4 result_0;
+ i_0 = 0;
+ for(;;)
+ {
+ if(i_0 < 4) {} else break;
+
+ float _S2 = (unpackHalf2x16((value_0[i_0])).x);
+ result_0[i_0] = _S2;
+ int _S3 = i_0 + int(1);
+ i_0 = _S3;
+ }
+ return result_0;
+}
+
+layout(location = 0)
+out vec4 _S4;
+
+void main()
+{
+ vec4 _S5 = f16tof32_0(C_0._data.u_0);
+ _S4 = _S5;
+ return;
+}