Bug 244152 - use of gl_VertexId causes error compiling shader with Metal backend
Summary: use of gl_VertexId causes error compiling shader with Metal backend
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: Safari Technology Preview
Hardware: Mac (Intel) macOS 12
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-08-19 23:37 PDT by morem
Modified: 2022-08-26 23:38 PDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description morem 2022-08-19 23:37:15 PDT
Hi,

I get an error checking the link status of a WebGL2 shader program

"Internal error compiling shader with Metal backend"

Or if I call `gl.validateProgram` before checking the link status

"Program has not been successfully linked."


I don't have a minimal reproduction but tracked it down to the use of `gl_VertexId` and found a workaround. If I use it as is I get the above error but if I do `int(gl_VertexId)` everything works fine. I don't see this issue with Firefox or Chrome on Mac or Win.

I see the issue in Safari 16.0, 15.6 and earlier.


You can trigger the error in Mol* here: https://molstar.org/viewer/?debug-mode=1&emdb=EMD-14403


Best
Alexander
Comment 2 Kenneth Russell 2022-08-22 14:11:06 PDT
The new repro link fails in Chrome with ANGLE's Metal backend as well. These are the reported compilation errors:

---
[.WebGL-0x118015ca100] GL_INVALID_OPERATION: Error: 0x00000502, in ../../third_party/angle/src/libANGLE/renderer/metal/ProgramMtl.mm, createMslShaderLib:768. Internal error compiling shader with Metal backend.
program_source:409:28: error: call to '_ureadFromTexture' is ambiguous
  metal::float4 ANGLE_55 = _ureadFromTexture(ANGLE_textureEnvs._utGroup, ANGLE_invocationVertexGlobals.gl_VertexID, ANGLE_userUniforms._uuGeoTexDim);
                           ^~~~~~~~~~~~~~~~~
program_source:377:15: note: candidate function
metal::float4 _ureadFromTexture(ANGLE_TextureEnv<metal::texture2d<float>> _utex, float _ui, metal::float2 _udim)
              ^
program_source:389:15: note: candidate function
metal::float4 _ureadFromTexture(ANGLE_TextureEnv<metal::texture2d<float>> _utex, int _ui, metal::float2 _udim)
              ^
program_source:418:28: error: call to '_ureadFromTexture' is ambiguous
  metal::float4 ANGLE_63 = _ureadFromTexture(ANGLE_textureEnvs._utPosition, ANGLE_invocationVertexGlobals.gl_VertexID, ANGLE_userUniforms._uuGeoTexDim);
                           ^~~~~~~~~~~~~~~~~
program_source:377:15: note: candidate function
metal::float4 _ureadFromTexture(ANGLE_TextureEnv<metal::texture2d<float>> _utex, float _ui, metal::float2 _udim)
              ^
program_source:389:15: note: candidate function
metal::float4 _ureadFromTexture(ANGLE_TextureEnv<metal::texture2d<float>> _utex, int _ui, metal::float2 _udim)
              ^
program_source:426:28: error: call to '_ureadFromTexture' is ambiguous
  metal::float4 ANGLE_68 = _ureadFromTexture(ANGLE_textureEnvs._utNormal, ANGLE_invocationVertexGlobals.gl_VertexID, ANGLE_userUniforms._uuGeoTexDim);
                           ^~~~~~~~~~~~~~~~~
program_source:377:15: note: candidate function
metal::float4 _ureadFromTexture(ANGLE_TextureEnv<metal::texture2d<float>> _utex, float _ui, metal::float2 _udim)
              ^
program_source:389:15: note: candidate function
metal::float4 _ureadFromTexture(ANGLE_TextureEnv<metal::texture2d<float>> _utex, int _ui, metal::float2 _udim)
---

It makes sense that `int(gl_VertexId)` works around the bug because that disambiguates the internal function call.

Surprising this didn't show up in the conformance tests.
Comment 3 Radar WebKit Bug Importer 2022-08-26 23:38:15 PDT
<rdar://problem/99218768>