Quest 2: GLSL error: extension 'GL_AMD_vertex_shader_layer' is not supported

I’m running into an issue where the build of the game finishes without any errors, but as soon as a certain scene is loaded on the device (a Quest 2), I get these errors:

ERROR: 0:2: '' :     GLSL error: extension 'GL_AMD_vertex_shader_layer' is not supported
ERROR: 0:60: 'gl_Layer' : undeclared identifier
ERROR: 0:60: 'assign' :  cannot convert from 'int' to 'float'
ERROR: 3 compilation errors.  No code generated.

Seemingly, this instruction is to do with Single Pass Instanced / Multiview mode. I tried enabling Multi Pass instead of Multiview in the Android Oculus XR Settings, but this did not fix the problem.

I get a rather long list of GLES extensions/commands in the beginning of the Android log, after it says “GLES: 3”. The extension GL_AMD_vertex_shader_layer is not among those listed.

The shaders with this error, if I interpret the log correctly, are these three, the errors come up multiple times for the same shaders.

'Hidden/InternalErrorShader'
'GUI/Text Shader'
'Hidden/InternalClear'

A full error log is here:

08-01 20:11:55.194 14046 14106 D Unity   : -------- Shader compilation failed
08-01 20:11:55.194 14046 14106 D Unity   : #version 320 es
08-01 20:11:55.194 14046 14106 D Unity   : #extension GL_AMD_vertex_shader_layer : require
08-01 20:11:55.194 14046 14106 D Unity   : #define HLSLCC_ENABLE_UNIFORM_BUFFERS 1
08-01 20:11:55.194 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_UNIFORM
08-01 20:11:55.194 14046 14106 D Unity   : #else
08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_UNIFORM uniform
08-01 20:11:55.194 14046 14106 D Unity   : #endif
08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_SUPPORTS_UNIFORM_LOCATION 1
08-01 20:11:55.194 14046 14106 D Unity   : #if UNITY_SUPPORTS_UNIFORM_LOCATION
08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_LOCATION(x) layout(location = x)
08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_BINDING(x) layout(binding = x, std140)
08-01 20:11:55.194 14046 14106 D Unity   : #else
08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_LOCATION(x)
08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_BINDING(x) layout(std140)
08-01 20:11:55.194 14046 14106 D Unity   : #endif
08-01 20:11:55.194 14046 14106 D Unity   : uniform     vec4 hlslcc_mtx4x4unity_ObjectToWorld[4];
08-01 20:11:55.194 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
08-01 20:11:55.194 14046 14106 D Unity   : UNITY_BINDING(0) uniform UnityStereoGlobals {
08-01 20:11:55.194 14046 14106 D Unity   : #endif
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixP[8];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixV[8];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixInvV[8];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixVP[8];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraProjection[8];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraInvProjection[8];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoWorldToCamera[8];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraToWorld[8];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec3 unity_StereoWorldSpaceCameraPos[2];
08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 unity_StereoScaleOffset[2];
08-01 20:11:55.194 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
08-01 20:11:55.194 14046 14106 D Unity   : };
08-01 20:11:55.194 14046 14106 D Unity   : #endif
08-01 20:11:55.194 14046 14106 D Unity   : in highp vec4 in_POSITION0;
08-01 20:11:55.194 14046 14106 D Unity   : in mediump vec4 in_COLOR0;
08-01 20:11:55.194 14046 14106 D Unity   : out mediump vec4 vs_COLOR0;
08-01 20:11:55.194 14046 14106 D Unity   : flat out highp uint vs_BLENDINDICES0;
08-01 20:11:55.194 14046 14106 D Unity   : float u_xlat0;
08-01 20:11:55.194 14046 14106 D Unity   : uint u_xlatu0;
08-01 20:11:55.194 14046 14106 D Unity   : vec4 u_xlat1;
08-01 20:11:55.194 14046 14106 D Unity   : vec4 u_xlat2;
08-01 20:11:55.194 14046 14106 D Unity   : int u_xlati3;
08-01 20:11:55.194 14046 14106 D Unity   : void main()
08-01 20:11:55.194 14046 14106 D Unity   : {
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = float(uint(gl_InstanceID));
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = u_xlat0 * 0.5;
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = fract(u_xlat0);
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = u_xlat0 + u_xlat0;
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = roundEven(u_xlat0);
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlatu0 = uint(u_xlat0);
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlati3 = int(int(u_xlatu0) << 2);
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat1 = in_POSITION0.yyyy * hlslcc_mtx4x4unity_ObjectToWorld[1];
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat1 = hlslcc_mtx4x4unity_ObjectToWorld[0] * in_POSITION0.xxxx + u_xlat1;
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat1 = hlslcc_mtx4x4unity_ObjectToWorld[2] * in_POSITION0.zzzz + u_xlat1;
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat1 = u_xlat1 + hlslcc_mtx4x4unity_ObjectToWorld[3];
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat2 = u_xlat1.yyyy * hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 1)];
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat2 = hlslcc_mtx4x4unity_StereoMatrixVP[u_xlati3] * u_xlat1.xxxx + u_xlat2;
08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat2 = hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 2)] * u_xlat1.zzzz + u_xlat2;
08-01 20:11:55.194 14046 14106 D Unity   :     gl_Position = hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 3)] * u_xlat1.wwww + u_xlat2;
08-01 20:11:55.194 14046 14106 D Unity   :     vs_COLOR0 = in_COLOR0;
08-01 20:11:55.194 14046 14106 D Unity   :     vs_BLENDINDICES0 = u_xlatu0;
08-01 20:11:55.194 14046 14106 D Unity   :     gl_Layer = int(u_xlatu0);
08-01 20:11:55.194 14046 14106 D Unity   :     return;
08-01 20:11:55.194 14046 14106 D Unity   : }
08-01 20:11:55.194 14046 14106 D Unity   : -------- failed compiling:
08-01 20:11:55.194 14046 14106 D Unity   : vertex shader
08-01 20:11:55.194 14046 14106 D Unity   : ERROR: 0:2: '' :     GLSL error: extension 'GL_AMD_vertex_shader_layer' is not supported
08-01 20:11:55.194 14046 14106 D Unity   : ERROR: 0:63: 'gl_Layer' : undeclared identifier
08-01 20:11:55.194 14046 14106 D Unity   : ERROR: 0:63: 'assign' :  cannot convert from 'int' to 'float'
08-01 20:11:55.194 14046 14106 D Unity   : ERROR: 3 compilation errors.  No code generated.
08-01 20:11:55.194 14046 14106 D Unity   :
08-01 20:11:55.194 14046 14106 D Unity   :
08-01 20:11:55.194 14046 14106 D Unity   : Note: Creation of internal variant of shader 'Hidden/InternalClear' failed.
08-01 20:11:55.194 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords STEREO_INSTANCING_ON
08-01 20:11:55.197 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords <no keywords>
08-01 20:11:55.197 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords <no keywords>
08-01 20:11:55.199 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords UNITY_SINGLE_PASS_STEREO
08-01 20:11:55.199 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords UNITY_SINGLE_PASS_STEREO
08-01 20:11:55.204 14046 14106 D Unity   : -------- Shader compilation failed
08-01 20:11:55.204 14046 14106 D Unity   : #version 320 es
08-01 20:11:55.204 14046 14106 D Unity   : #extension GL_AMD_vertex_shader_layer : require
08-01 20:11:55.204 14046 14106 D Unity   : #define HLSLCC_ENABLE_UNIFORM_BUFFERS 1
08-01 20:11:55.204 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_UNIFORM
08-01 20:11:55.204 14046 14106 D Unity   : #else
08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_UNIFORM uniform
08-01 20:11:55.204 14046 14106 D Unity   : #endif
08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_SUPPORTS_UNIFORM_LOCATION 1
08-01 20:11:55.204 14046 14106 D Unity   : #if UNITY_SUPPORTS_UNIFORM_LOCATION
08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_LOCATION(x) layout(location = x)
08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_BINDING(x) layout(binding = x, std140)
08-01 20:11:55.204 14046 14106 D Unity   : #else
08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_LOCATION(x)
08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_BINDING(x) layout(std140)
08-01 20:11:55.204 14046 14106 D Unity   : #endif
08-01 20:11:55.204 14046 14106 D Unity   : uniform     vec4 hlslcc_mtx4x4unity_ObjectToWorld[4];
08-01 20:11:55.204 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
08-01 20:11:55.204 14046 14106 D Unity   : UNITY_BINDING(0) uniform UnityStereoGlobals {
08-01 20:11:55.204 14046 14106 D Unity   : #endif
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixP[8];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixV[8];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixInvV[8];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixVP[8];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraProjection[8];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraInvProjection[8];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoWorldToCamera[8];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraToWorld[8];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec3 unity_StereoWorldSpaceCameraPos[2];
08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 unity_StereoScaleOffset[2];
08-01 20:11:55.204 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
08-01 20:11:55.204 14046 14106 D Unity   : };
08-01 20:11:55.204 14046 14106 D Unity   : #endif
08-01 20:11:55.204 14046 14106 D Unity   : in highp vec4 in_POSITION0;
08-01 20:11:55.204 14046 14106 D Unity   : in mediump vec4 in_COLOR0;
08-01 20:11:55.204 14046 14106 D Unity   : out mediump vec4 vs_COLOR0;
08-01 20:11:55.204 14046 14106 D Unity   : flat out highp uint vs_BLENDINDICES0;
08-01 20:11:55.204 14046 14106 D Unity   : float u_xlat0;
08-01 20:11:55.204 14046 14106 D Unity   : uint u_xlatu0;
08-01 20:11:55.204 14046 14106 D Unity   : vec4 u_xlat1;
08-01 20:11:55.204 14046 14106 D Unity   : vec4 u_xlat2;
08-01 20:11:55.204 14046 14106 D Unity   : int u_xlati3;
08-01 20:11:55.204 14046 14106 D Unity   : void main()
08-01 20:11:55.204 14046 14106 D Unity   : {
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = float(uint(gl_InstanceID));
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = u_xlat0 * 0.5;
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = fract(u_xlat0);
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = u_xlat0 + u_xlat0;
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = roundEven(u_xlat0);
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlatu0 = uint(u_xlat0);
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlati3 = int(int(u_xlatu0) << 2);
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat1 = in_POSITION0.yyyy * hlslcc_mtx4x4unity_ObjectToWorld[1];
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat1 = hlslcc_mtx4x4unity_ObjectToWorld[0] * in_POSITION0.xxxx + u_xlat1;
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat1 = hlslcc_mtx4x4unity_ObjectToWorld[2] * in_POSITION0.zzzz + u_xlat1;
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat1 = u_xlat1 + hlslcc_mtx4x4unity_ObjectToWorld[3];
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat2 = u_xlat1.yyyy * hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 1)];
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat2 = hlslcc_mtx4x4unity_StereoMatrixVP[u_xlati3] * u_xlat1.xxxx + u_xlat2;
08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat2 = hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 2)] * u_xlat1.zzzz + u_xlat2;
08-01 20:11:55.204 14046 14106 D Unity   :     gl_Position = hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 3)] * u_xlat1.wwww + u_xlat2;
08-01 20:11:55.204 14046 14106 D Unity   :     vs_COLOR0 = in_COLOR0;
08-01 20:11:55.204 14046 14106 D Unity   :     vs_BLENDINDICES0 = u_xlatu0;
08-01 20:11:55.204 14046 14106 D Unity   :     gl_Layer = int(u_xlatu0);
08-01 20:11:55.204 14046 14106 D Unity   :     return;
08-01 20:11:55.204 14046 14106 D Unity   : }
08-01 20:11:55.204 14046 14106 D Unity   : -------- failed compiling:
08-01 20:11:55.204 14046 14106 D Unity   : vertex shader
08-01 20:11:55.204 14046 14106 D Unity   : ERROR: 0:2: '' :     GLSL error: extension 'GL_AMD_vertex_shader_layer' is not supported
08-01 20:11:55.204 14046 14106 D Unity   : ERROR: 0:63: 'gl_Layer' : undeclared identifier
08-01 20:11:55.204 14046 14106 D Unity   : ERROR: 0:63: 'assign' :  cannot convert from 'int' to 'float'
08-01 20:11:55.204 14046 14106 D Unity   : ERROR: 3 compilation errors.  No code generated.
08-01 20:11:55.204 14046 14106 D Unity   :
08-01 20:11:55.204 14046 14106 D Unity   :
08-01 20:11:55.204 14046 14106 D Unity   : Note: Creation of internal variant of shader 'Hidden/InternalClear' failed.
08-01 20:11:55.204 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords STEREO_INSTANCING_ON

This is on Unity 2019.4 LTS. It is an older project which I upgraded from 5.5. Built-in pipeline. Seems to run OK despite these issues, and works fine on PC (Quest-via-Link). I have the feeling, however, that the incredibly large load time has to do with the shader issues.

I am unsure how to proceed here. It seems to me that this extension (“GL_AMD_vertex_shader_layer”) really is not supported on GLES3/Quest, which means the shaders should not use it. I’m not completely certain but is the “Compiled Shader” line ABOVE the errors the one which was problematic? If so, is the issue the UNITY_SINGLE_PASS_STEREO keyword, which shouldn’t be enabled on Quest ( this thread here seems to imply this).

What can I do to figure out what is going on here?

Thanks!

Philip

I’ve tried disabling UNITY_SINGLE_PASS_STEREO keyword with Shader.DisableKeyword() in my first scene, but this is ignored and the Shader is still being compiled by Unity when starting the scene.

Can I do anything else to control what shaders, and with which keywords Unity compiles when starting a scene at runtime?

Follow-Up:

I have also tried copying the internal shaders from Unity’s source code into my project and added them as “always included”. I’ve then tried to use an IPreprocessShaders implementation to strip the variants with the keyword UNITY_SINGLE_PASS_STEREO. The shader itself shows up in that implementation, but not with that keyword. At runtime, the keyword is still there.

If I remove the keywords from the shader code itself, they STILL are back at runtime.

How, and why, does Unity sneak in that keyword? Is there any reason for this? Is this a bug? Is this fixed in later version of Unity?

Philip

Whatever is happening in 2019 LTS, it also still happens in 2020 LTS, but it no longer happens in 2021 LTS. So, whatever weird is happening in earlier versions, it is seemingly fixed now.