Page MenuHome

Blender won't start - GPUShader: compile error - AWS Elastic Graphics
Closed, ResolvedPublic

Description

System Information
Operating system: Windows Server 2019
Graphics card: Amazon Elastic Graphics (eg1.medium) (OpenGL 4.3)

Blender Version
Broken: blender-2.81-windows64.msi (still broken in 2.83)
Worked: blender-2.80rc3-windows64.msi (last version it works in)

Short description of error
The following zip contains output.txt (STDERR/STDOUT when attempted to launch with --debug-all) and also shaders.txt and sub folder when attempting launch with that debug info:

I am looking to run a Blender workload in Amazon Web Services (AWS).
For this, I am testing on a Windows Server image on a non-GPU compute resource.
Instead of GPU I am attaching AWS Elastic Graphics to the instance.
This provides OpenGL 4.3 which is working really well for another workload which uses Unity (in which case I need to force OpenGL mode).

When I open blender.exe (2.83), it immediately exits. Running it from the command line I am able to capture the following output, which indicates some sort of shader error on startup:

Vertex shader failed to compile with the following errors:
ERROR: 5:445: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:445: error(#102) #error: Builtin Name not supported
ERROR: 5:454: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:454: error(#102) #error: Builtin Name not supported
ERROR: 5:459: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:459: error(#102) #error: Builtin Name not supported
ERROR: 5:469: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:469: error(#102) #error: Builtin Name not supported
ERROR: error(#273) 8 compilation errors.  No code generated

system-info.txt from 2.79b:

Exact steps for others to reproduce the error

  1. Launch an EC2 Instance of Windows server 2019 with Elastic Graphics in AWS
  2. Install Blender and open it

Event Timeline

Looks like GLEW_ARB_shader_draw_parameters is not true, which is why GL_ARB_shader_draw_parameters doesn't get defined in gpu_shader_standard_extensions.

This and that you have to force the legacy backend for Unity with -force-opengl (if that is what you meant) seems to me that it doesn't provide the OpenGL version as described. Have you verified that OpenGL 4.3 is actually available?

Sorry, no, I don't have to use --force-opengl. I just have to build a Unity app to use OpenGL instead of DirectX.
OpenGL 4.3 is available and working.
Blender 2.79b fires up fine. This eeems to be a 2.8+ issue.
Any way to fix this compile issue so Blender. 2.8+ can open?

Also other 3D programs work fine, like NetFabb.

Is this helpful? Attached are outputs from glewinfo.exe

and visualinfo.exe from glew
Is gl_BaseInstanceARB even required?

@Luther Miller (af_luther) Thank you for the additional information. I'll have to let one of the GPUs devs take a look, since I'm not an expert on the subject matter.

This system is not listed among the supported GPUs. So I fear this can't be confirmed as a valid bug report.

This is apparently a driver error.

If "GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'" then, in theory, GLEW_ARB_base_instance should not be marked as supported by the driver.

Perhaps this change can solve the problem. (It enables a workaround used by some GPUs):

diff --git a/source/blender/gpu/intern/gpu_extensions.cc b/source/blender/gpu/intern/gpu_extensions.cc
index e35ab93d370..85353d22c1b 100644
--- a/source/blender/gpu/intern/gpu_extensions.cc
+++ b/source/blender/gpu/intern/gpu_extensions.cc
@@ -325,7 +325,8 @@ void gpu_extensions_init(void)
    *
    * We use it as a target for glMapBuffer(Range) what is part of the OpenGL 4 API. So better
    * disable it when we don't have an OpenGL4 context (See T77657) */
-  GG.glew_arb_base_instance_is_supported = GLEW_ARB_base_instance && GLEW_VERSION_4_0;
+  GG.glew_arb_base_instance_is_supported = GLEW_ARB_base_instance &&
+                                           GLEW_ARB_shader_draw_parameters && GLEW_VERSION_4_0;
   GG.glew_arb_texture_cube_map_array_is_supported = GLEW_ARB_texture_cube_map_array;
   gpu_detect_mip_render_workaround();

But I am also not an expert in this area and I fear that this would not be the ideal solution.

I see -- it's not clear to me from the standards documents I can find that if gl_BaseInstanceARB is supplied then GL_ARB_shader_draw_parameters must be supplied. I will reach out to AWS support.
In the meantime, how I can test the workaround you proposed above? Would this build from 7/27 https://builder.blender.org/download/branches/ include that change:
https://builder.blender.org/download/temp-remesh-octree/temp-remesh-octree-blender-2.91.0-4a38856327a9-windows64.zip ?
Thank you

... how I can test the workaround you proposed above?

You would need to apply the patch (or redo the same changes indicated in the source code) and compile from source.
See: https://wiki.blender.org/wiki/Building_Blender

I tried this change with a custom build but the same error message occurred.
I wonder if there may be a possible fix by changing source/blender/draw/modes/shaders/common_view_lib.glsl lines 29-55:

I'm not sure what the change would be, though.

#ifdef GPU_VERTEX_SHADER
#  ifdef GL_ARB_shader_draw_parameters
#    define baseInstance gl_BaseInstanceARB
#  else /* no ARB_shader_draw_parameters */
uniform int baseInstance;
#  endif

#  ifdef IN_PLACE_INSTANCES
/* When drawing instances of an object at the same position. */
#    define instanceId 0
#  elif defined(GPU_CRAPPY_AMD_DRIVER)
/* NOTE: This does contain the baseInstance ofset */
in int _instanceId;
#    define instanceId (_instanceId - baseInstance)
#  else
#    define instanceId gl_InstanceID
#  endif

#  define resource_id (baseInstance + instanceId)

/* Use this to declare and pass the value if
 * the fragment shader uses the resource_id. */
#  define RESOURCE_ID_VARYING flat out int resourceIDFrag;
#  define RESOURCE_ID_VARYING_GEOM flat out int resourceIDGeom;
#  define PASS_RESOURCE_ID resourceIDFrag = resource_id;
#  define PASS_RESOURCE_ID_GEOM resourceIDGeom = resource_id;
#endif

I found this after my test, maybe this is helpful:

Another question I have is that it appears the error is a Python compile error. I assume that means that Blender is using OpenGL configuration to create some Python code and compile it. Is this the case? Is that actually where the error is? Because I can only find one instance of "gl_baseInstanceARB" anywhere in the source code for Blender.

I tried this change with a custom build but the same error message occurred.

Try putting GG.glew_arb_base_instance_is_supported = false;

Another question I have is that it appears the error is a Python compile error. I assume that means that Blender is using OpenGL configuration to create some Python code and compile it. Is this the case? Is that actually where the error is? Because I can only find one instance of "gl_baseInstanceARB" anywhere in the source code for Blender.

It may be a little confusing, but those error messages are unrelated to Python.

Try putting GG.glew_arb_base_instance_is_supported = false;

Thank you for the suggestion. I tried this and did another build, and I am still getting the same error.

Based on the stack trace and error messages, it appears to when it compiles the code for the vertex shader. It appears to be the code from source/blender/draw/modes/shaders/common_view_lib.glsl which is getting compiled and causing the error. I'm not quite sure how this code works, but lines 29-55 seem to be the place where the same variables mentioned in the error message are defined/checked.

I wonder if there may be a possible fix by changing source/blender/draw/modes/shaders/common_view_lib.glsl lines 29-55.

I'm just not sure what the change would be as I don't understand the whole system here. I would really appreciate any suggestions. Thank you.

I'm not sure how to help.
The bug tracker is not the best place for these doubts.
I suggest contacting the developers on blender.chat:
https://wiki.blender.org/wiki/Communication/Contact#Contact_Developers

FYI, 2.80rc3 does work with AWS Elastic Graphics also. It might be this commit that broke it: D4997

@Clément Foucault (fclem), is #ifdef GL_ARB_shader_draw_parameters correct?

It assumes that GL_ARB_shader_draw_parameters gets defined when #extension GL_ARB_shader_draw_parameters : enable successfully enables the extension, but I'm not sure that's how it works? At least I don't see anything about that in the GLSL spec. Maybe we should add our own define similar to #define GPU_ARB_texture_cube_map_array and test that instead.

There's a few cases where we have #ifdefs like this:

draw/engines/workbench/shaders/workbench_shadow_geom.glsl:#ifdef GL_ARB_gpu_shader5
draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl:#ifdef GL_ARB_gpu_shader5
draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl:#ifdef GL_ARB_conservative_depth
draw/intern/shaders/common_view_lib.glsl:#  ifdef GL_ARB_shader_draw_parameters

@Brecht Van Lommel (brecht) I think you are on to something. When I run glew on this device, it tells me it doesn't have don't have GL_ARB_shader_draw_parameters. However when I make the following change and do a new build, blender works perfectly fine:

blender\source\blender\draw\intern\shaders\common_view_lib.glsl 77-82
from:

#ifdef GPU_VERTEX_SHADER
#  ifdef GL_ARB_shader_draw_parameters
#    define baseInstance gl_BaseInstanceARB
#  else /* no ARB_shader_draw_parameters */
uniform int baseInstance;
#  endif

to:

#ifdef GPU_VERTEX_SHADER
uniform int baseInstance;

Obviously, this isn't the desired final change to the code because then GL_ARB_shader_draw_parameters would never be turned on for devices that support it. But something is setting this to true when it should not be set to true. I'm just not sure where/how to fix that code myself.

@Clément Foucault (fclem) per chat conversation here are the changes proposed by LazyDodo that I tested and confirmed fix this issue:

diff --git a/source/blender/draw/intern/shaders/common_view_lib.glsl b/source/blender/draw/intern/shaders/common_view_lib.glsl
index 095bc64a19e..c77537bbe48 100644
--- a/source/blender/draw/intern/shaders/common_view_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_view_lib.glsl
@@ -75,7 +75,7 @@ vec4 pack_line_data(vec2 frag_co, vec2 edge_start, vec2 edge_pos)
 uniform int resourceChunk;

 #ifdef GPU_VERTEX_SHADER
-#  ifdef GL_ARB_shader_draw_parameters
+#  ifdef GPU_ARB_shader_draw_parameters
 #    define baseInstance gl_BaseInstanceARB
 #  else /* no ARB_shader_draw_parameters */
 uniform int baseInstance;
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 9ea798e5669..46f016ab14a 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -230,6 +230,7 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH])
   }
   if (GLEW_ARB_shader_draw_parameters) {
     strcat(defines, "#extension GL_ARB_shader_draw_parameters : enable\n");
+       strcat(defines, "#define GPU_ARB_shader_draw_parameters\n");
   }
   if (GPU_arb_texture_cube_map_array_is_supported()) {
     strcat(defines, "#extension GL_ARB_texture_cube_map_array : enable\n");