Fix WebGL error with MirrorPadPacked on Safari 18.1 #8440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
This resolves a shader compiler error with Safari 18.1 when running the
MirrorPadPacked
op with the WebGL backend.The error that occurs is:
To reproduce the issue, run the following code on Safari 18.1 on iOS or macOS:
This issue does not happen on older versions of Safari (such as Safari 17.x). It's unclear which version of Safari this issue was first introduced in.
Investigation
When Safari compiles the shader, it converts the GLSL code to Metal but it appears there is a bug with this conversion process. In particular, it seems that applying an add/sub between a scalar and vector causes the shader compile error to happen, which occurs with the following line:
orig = 1 - (lt + gte)
. The three variables are vectors while the1
is a scalar.A bug has been filed with WebKit: https://bugs.webkit.org/show_bug.cgi?id=283576
Solution
Casting the scalar to the vector before doing the subtraction resolves the error.