summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-12-19 11:49:36 -0800
committerGitHub <noreply@github.com>2017-12-19 11:49:36 -0800
commitacf26257b74ca5446fd5a0390a29723dc25ef2a3 (patch)
tree16b8c68d32240be96e148a26e5cd7a10c5f4b0f0 /tests
parent393e25fd2e2b8c5ff82ff4c6b14a9d7152d37a5e (diff)
Fix floating-point literal emit to be locale-independent. (#315)
There was a bug that arose in the context of Falcor, because: - Slang uses `sprintf` to format floating-point values when outputting HLSL/GLSL source - Falcor (or a library it uses) does the equivalent of `setlocale(LC_ALL, "")` to set the global locale for the process based on the user's environment variables This led to a floating-point literal of `0.5` getting printed as `0,5f`, with a comma for the decimal point. This then gets consumed by `glslang` which (luckily for us) complains that `5f` is not a valid floating-point literal in their language (since it has neither decimal point nor exponent). The most expedient fix in this case was to switch from using C `sprintf` for formatting floating-point numbers over to using the C++ `<stdio>` implementation, which allows the locale to be set per-stream so that we don't have to rely on (or potentially disrupt) the global locale set by an application using Slang. Longer term if we have the time/resources to do the Right Thing, it would be best to implement our own printing logic for floating-point numbers, since we would eventually need/want to support arbitrary-precision numbers for literals.
Diffstat (limited to 'tests')
0 files changed, 0 insertions, 0 deletions