-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Environment: Mesa driver
Note this issue has only popped up with Mesa drivers so far but it's not a Mesa drivers bug/problem, it's a Blender limitation / consequence of a f64render hack. See Explanation below for more details
Compiling shader
ERROR (gpu.shader): pyGPU_Shader FragShader:
|
538 | #extension GL_ARB_fragment_shader_interlock : enable
| ^
| Error: #extension directive is not allowed in the middle of a shader
Traceback (most recent call last):
[...]
self.shader = gpu.shader.create_from_info(shader_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception: Shader Compile Error, see console for more details
Workarounds
Workaround 1: Allow mid-shader extension directives
Set environment variable allow_glsl_extension_directive_midshader=true (source: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7850 )
For example, allow_glsl_extension_directive_midshader=true blender
Workaround 2: Make f64render not use the extension
Change shader_interlock_support to False
Line 75 in 6a5a4b1
| self.shader_interlock_support = 'GL_ARB_fragment_shader_interlock' in ext_list |
->
self.shader_interlock_support = FalseExplanation
The Blender gpu Python module prepends some stuff to the shader source, causing the #extension directive from f64render to not be at the start of the final shader source that's sent to the driver.
However per spec the #extension directives should be at the start of the shader.
Some drivers are lax enough to allow #extension anywhere, which is not the case of Mesa drivers by default. This can be overriden with the allow_glsl_extension_directive_midshader environment variable as indicated in the Workaround 1 above.
The Blender gpu Python module does not support enabling extensions like this in the shader source, because shaders should be platform agnostic. And using #extension only works with OpenGL, not Metal nor Vulkan apparently. (source: https://projects.blender.org/blender/blender/issues/126071 )