Shader not working on Mac blender 3.5 - works in Windows #106698
Operating system: macOS-13.3-arm64-arm-64bit 64 Bits
Graphics card: Metal API Apple M1 Max 1.2
Broken: version: 3.5.0, branch: blender-v3.5-release, commit date: 2023-03-29 02:56, hash:
Worked: (newest version of Blender that worked as expected)
Short description of error
I have been trying to install the Weight Paint Tools paid addon https://bartoszstyperek.gumroad.com/l/weight_paint_tools?layout=profile&recommended_by=library
This worked fine for years, up till 3.5, now it crashes upon activation. The developer has attempted to update it for metal, but it still wont work. He's sent me a simplified script that he says should work without errors.. but still errors out. See attached blend file.
Run the script
Exact steps for others to reproduce the error
Run the script
Description of error
To clarify, bug is related to shader compilation error on Mac, using Metal gpu backend. Shader is working ok on linux nad window, thus I think this may be bug in new blender 3.5 API. Shader is using new gpu.types.ShaderCreateInfo() for drawing.
**Steps to reproduce: **
Switch to Metal gpu backend in blender system preferences.
Run above attached blend file, that contains simple script with gpu drawing, that will give 'shader compilation error' on Metal gpu backend.
The error itself has noting to do with any addon (it was found by Weight Paint Tool addon user though)
Hi, thanks for the report. Unable to repro this on Windows.
AFAICS, new shader API is used in python code.
Thanks @PratikPB2123 I can have a look into this, likely an issue with the create-info setup, but will see which path it is hitting in Metal.
Is there way to see the content of the Shader error message? Right now error just says to look into console, but there is no info about which line in shader is causing the problem.
If running Blender from command line, the compilation error will show in-place. Please note that the code will not map 1:1 with the source provided as GPUShaderCreateInfo generates an entry point wrapper.
The issue caused by this piece of code is that the uniform name
col has a namespace conflict with an internal Blender library function parameter which also uses
col. Changing the uniform name to
This is a small limitation with Metal shaders that each variable name, whether uniform, attribute or local/global variable must be uniquely named.
https://wiki.blender.org/wiki/Style_Guide/GLSL May outline some of the considerations for Metal compatibility.
So every time I declare uniforms, I have to check if it is not conflicting with blender library parameters? I did not see anything about it in https://wiki.blender.org/wiki/Style_Guide/GLSL, is there list of taken 'names', so we can avoid them? I mean, I do not have mac, so I'm working blind here (maybe u have link to blender source code, that is affecting this issue) . @Michael-Parkin-White-Apple
I guess this issue can be closed, if it is not considered bug.
Not a high priority issue, but maybe it deserves some attention or documentation showing names that can't be used as uniforms.
Yeah, there's definitely room for follow-up here. Perhaps we can more elegantly communicate the compilation failure and at the very least extend the GLSL documentation with a list of constraints which may run into problems with Metal, as the shaders are not GLSL, but semantically similar when compiled to Metal shading language.
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?