Page MenuHome

Fix Metal GPU backend shader compile errors in certain language environments
ClosedPublic

Authored by Tomoaki Nakano (tomnak) on Dec 29 2022, 5:44 AM.

Details

Summary

This patch fixes an issue where Blender 3.5 alpha with the Metal GPU backend enabled on Japanese macOS fails to compile shaders and crashes on startup.

In a Japanese environment, defaultCStringEncoding is the legacy MacJapanese encoding, and it erroneously converts backslashes (0x5c) to Yen symbols (¥).
Therefore, Metal shader compile fails with the following log and Blender crashes.

2022-12-29 13:50:10.200 Blender[13404:246707] Compile Error - Metal Shader Library (Stage: 0), error Error Domain=MTLLibraryErrorDomain Code=3 "program_source:225:74: error: non-ASCII characters are not allowed outside of literals and identifiers
    template<typename T, access A = access::sample> struct STRUCT_NAME { ¥
                                                                         ^
program_source:226:14: error: no template named 'TEX_TYPE'
      thread TEX_TYPE<T, A> *texture; ¥
             ^
program_source:226:39: error: non-ASCII characters are not allowed outside of literals and identifiers
      thread TEX_TYPE<T, A> *texture; ¥
                                      ^
program_source:227:29: error: non-ASCII characters are not allowed outside of literals and identifiers
      thread sampler *samp; ¥
                            ^
...

We can use stringWithUTF8String instead.

Diff Detail

Repository
rB Blender

Event Timeline

Tomoaki Nakano (tomnak) requested review of this revision.Dec 29 2022, 5:44 AM
Tomoaki Nakano (tomnak) created this revision.
Tomoaki Nakano (tomnak) edited the summary of this revision. (Show Details)Dec 29 2022, 9:51 AM

This looks good to me and appears to work as expected

This revision is now accepted and ready to land.Mon, Jan 16, 4:24 PM

@Michael Parkin-White (MichaelPW) @Clément Foucault (fclem)
Thank you for your review.
I don't have commit right.
Could you please commit?