Skip to content

Inconsistent run-time library usage for locale handling breaks GPU code generation on some systems. #2351

Open

Description

@cozdas

Several GPU code paths format float constants with std::to_string(), which follows the C runtime locale (LC_NUMERIC). All other float formatting in OCIO follows the C++ global locale, for example via std::ostringstream. These are independent settings, so on comma-decimal systems (e.g. fr_FR, sv_SE) the two mechanisms can produce different decimal separators in the same shader. The affected call sites emit literals such as 100 000000 instead of 100.0, while neighboring constants from getFloatString() remain correct. The resulting GLSL/HLSL fails to compile or produces incorrect output.

This is most visible with ACES 2.x fixed-function GPU paths (gamut compress / tone scale), but the same pattern exists in grading-tone GPU code.

Affected call sites (12 float std::to_string calls across 7 lines, 2 files):

ops/fixedfunction/FixedFunctionOpGPU.cpp

  • _Add_Focus_Gain_func (line 947)
  • _Add_Compress_Gamut_func (line 1187)
  • _Add_Gamut_Compress_Inv_Shader (line 1269)

ops/gradingtone/GradingToneOpGPU.cpp

  • Add_MidsPre_Shader (line 304)
  • Add_SContrastTopPre_Shader (lines 1249, 1260)
  • Add_SContrastBottomPre_Shader (line 1300)

Suggested fix: Replace std::to_string(float) with getFloatString(), or route through the existing FloatToString() helpers in ParseUtils.cpp.

Activity

  1. changed the title [-]Inconsistent run-time usage for locale handling breaks GPU code generation on some systems.[/-] [+]Inconsistent run-time library usage for locale handling breaks GPU code generation on some systems.[/+] on Sep 24, 2026
  2. remia commented on Sep 28, 2026

    @remia
    Collaborator

    Sounds like something we want to fix in OCIO 2.6, is there a way to update the CI so that at least one job force a locale triggering these issues (as it's not the first time we run into this)? I assume the GPU CI could be 2 jobs with / without the locale change if that is the only place where we test the GPU path.

  3. doug-walker commented on Sep 28, 2026

    @doug-walker
    Collaborator

    @remia , I think it will be too tight to fix this for 2.6.0, but we will commit to fixing it for 2.6.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions