From 129faf8c4af4a57b7f1c71749f45b31aebfab038 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 26 Mar 2021 10:53:58 -0700 Subject: Append proper suffixes to 16-bit literals for GLSL (#1767) * Append proper suffixes to 16-bit literals for GLSL The GLSL output path wasn't putting suffixes on literals of 16-bit types, and that was leading to compilation errors in downstream `glslang`. This change adds the suffixes defined by `GL_EXT_shader_explicit_arithmetic_types`. This change also wraps up 8-bit literals so that they are emitted as, e.g., `int8_t(1)` instead of just `1`, to make sure we don't have implicit conversions in the output GLSL that weren't implicit in the Slang IR. We similarly wrap floating-point special values like infinities in their desired types when the type is `float` (e.g., `double(1.0 / 0.0)` for a double-precision infinity). Note: Standad IEEE 754 half-precision doesn't provide an encoding for infinite or not-a-number values, so it might be considered an error if we emit `half(1.0 / 0.0)` but there really isn't a significantly better alternative for us to emit. * fixup --- source/slang/slang-ir.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 945cf488f..a983188b7 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -4945,10 +4945,14 @@ namespace Slang { case kIROp_IntLit: dump(context, irConst->value.intVal); + dump(context, " : "); + dumpType(context, irConst->getFullType()); return; case kIROp_FloatLit: dump(context, irConst->value.floatVal); + dump(context, " : "); + dumpType(context, irConst->getFullType()); return; case kIROp_BoolLit: -- cgit v1.2.3