diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2021-09-30 17:17:04 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2021-09-30 17:29:30 +0300 |
commit | f72bb3c6f5f734cfe1fbd2b00d1b90d2262c2722 (patch) | |
tree | 928fc11f011ff4d1de2566cc17e82333b8b45dd2 /spirv_glsl.cpp | |
parent | 9462b90067f60c8dcd406e1dcfdd15a206ddba5f (diff) |
Improve handling of INT_MIN/INT64_MIN literals.
We cannot naively convert these to decimal literals. C/C++ (and thus
MSL) has extremely awkward literal promotion rules.
Diffstat (limited to 'spirv_glsl.cpp')
-rw-r--r-- | spirv_glsl.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 2b19346d..af486e4e 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -5290,13 +5290,15 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t break; case SPIRType::Int64: + { + auto tmp = type; + tmp.vecsize = 1; + tmp.columns = 1; + auto int64_type = type_to_glsl(tmp); + if (splat) { - res += convert_to_string(c.scalar_i64(vector, 0)); - if (backend.long_long_literal_suffix) - res += "ll"; - else - res += "l"; + res += convert_to_string(c.scalar_i64(vector, 0), int64_type, backend.long_long_literal_suffix); } else { @@ -5305,19 +5307,14 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t if (c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) res += to_name(c.specialization_constant_id(vector, i)); else - { - res += convert_to_string(c.scalar_i64(vector, i)); - if (backend.long_long_literal_suffix) - res += "ll"; - else - res += "l"; - } + res += convert_to_string(c.scalar_i64(vector, i), int64_type, backend.long_long_literal_suffix); if (i + 1 < c.vector_size()) res += ", "; } } break; + } case SPIRType::UInt64: if (splat) |