Search Unity

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

Discussion in 'VR' started by plmx, Aug 1, 2022.

  1. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    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:

    Code (CSharp):
    1. ERROR: 0:2: '' :     GLSL error: extension 'GL_AMD_vertex_shader_layer' is not supported
    2. ERROR: 0:60: 'gl_Layer' : undeclared identifier
    3. ERROR: 0:60: 'assign' :  cannot convert from 'int' to 'float'
    4. 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.

    Code (CSharp):
    1. 'Hidden/InternalErrorShader'
    2. 'GUI/Text Shader'
    3. 'Hidden/InternalClear'
    A full error log is here:

    Code (CSharp):
    1. 08-01 20:11:55.194 14046 14106 D Unity   : -------- Shader compilation failed
    2. 08-01 20:11:55.194 14046 14106 D Unity   : #version 320 es
    3. 08-01 20:11:55.194 14046 14106 D Unity   : #extension GL_AMD_vertex_shader_layer : require
    4. 08-01 20:11:55.194 14046 14106 D Unity   : #define HLSLCC_ENABLE_UNIFORM_BUFFERS 1
    5. 08-01 20:11:55.194 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
    6. 08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_UNIFORM
    7. 08-01 20:11:55.194 14046 14106 D Unity   : #else
    8. 08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_UNIFORM uniform
    9. 08-01 20:11:55.194 14046 14106 D Unity   : #endif
    10. 08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_SUPPORTS_UNIFORM_LOCATION 1
    11. 08-01 20:11:55.194 14046 14106 D Unity   : #if UNITY_SUPPORTS_UNIFORM_LOCATION
    12. 08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_LOCATION(x) layout(location = x)
    13. 08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_BINDING(x) layout(binding = x, std140)
    14. 08-01 20:11:55.194 14046 14106 D Unity   : #else
    15. 08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_LOCATION(x)
    16. 08-01 20:11:55.194 14046 14106 D Unity   : #define UNITY_BINDING(x) layout(std140)
    17. 08-01 20:11:55.194 14046 14106 D Unity   : #endif
    18. 08-01 20:11:55.194 14046 14106 D Unity   : uniform     vec4 hlslcc_mtx4x4unity_ObjectToWorld[4];
    19. 08-01 20:11:55.194 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
    20. 08-01 20:11:55.194 14046 14106 D Unity   : UNITY_BINDING(0) uniform UnityStereoGlobals {
    21. 08-01 20:11:55.194 14046 14106 D Unity   : #endif
    22. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixP[8];
    23. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixV[8];
    24. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixInvV[8];
    25. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixVP[8];
    26. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraProjection[8];
    27. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraInvProjection[8];
    28. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoWorldToCamera[8];
    29. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraToWorld[8];
    30. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec3 unity_StereoWorldSpaceCameraPos[2];
    31. 08-01 20:11:55.194 14046 14106 D Unity   :     UNITY_UNIFORM vec4 unity_StereoScaleOffset[2];
    32. 08-01 20:11:55.194 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
    33. 08-01 20:11:55.194 14046 14106 D Unity   : };
    34. 08-01 20:11:55.194 14046 14106 D Unity   : #endif
    35. 08-01 20:11:55.194 14046 14106 D Unity   : in highp vec4 in_POSITION0;
    36. 08-01 20:11:55.194 14046 14106 D Unity   : in mediump vec4 in_COLOR0;
    37. 08-01 20:11:55.194 14046 14106 D Unity   : out mediump vec4 vs_COLOR0;
    38. 08-01 20:11:55.194 14046 14106 D Unity   : flat out highp uint vs_BLENDINDICES0;
    39. 08-01 20:11:55.194 14046 14106 D Unity   : float u_xlat0;
    40. 08-01 20:11:55.194 14046 14106 D Unity   : uint u_xlatu0;
    41. 08-01 20:11:55.194 14046 14106 D Unity   : vec4 u_xlat1;
    42. 08-01 20:11:55.194 14046 14106 D Unity   : vec4 u_xlat2;
    43. 08-01 20:11:55.194 14046 14106 D Unity   : int u_xlati3;
    44. 08-01 20:11:55.194 14046 14106 D Unity   : void main()
    45. 08-01 20:11:55.194 14046 14106 D Unity   : {
    46. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = float(uint(gl_InstanceID));
    47. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = u_xlat0 * 0.5;
    48. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = fract(u_xlat0);
    49. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = u_xlat0 + u_xlat0;
    50. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat0 = roundEven(u_xlat0);
    51. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlatu0 = uint(u_xlat0);
    52. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlati3 = int(int(u_xlatu0) << 2);
    53. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat1 = in_POSITION0.yyyy * hlslcc_mtx4x4unity_ObjectToWorld[1];
    54. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat1 = hlslcc_mtx4x4unity_ObjectToWorld[0] * in_POSITION0.xxxx + u_xlat1;
    55. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat1 = hlslcc_mtx4x4unity_ObjectToWorld[2] * in_POSITION0.zzzz + u_xlat1;
    56. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat1 = u_xlat1 + hlslcc_mtx4x4unity_ObjectToWorld[3];
    57. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat2 = u_xlat1.yyyy * hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 1)];
    58. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat2 = hlslcc_mtx4x4unity_StereoMatrixVP[u_xlati3] * u_xlat1.xxxx + u_xlat2;
    59. 08-01 20:11:55.194 14046 14106 D Unity   :     u_xlat2 = hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 2)] * u_xlat1.zzzz + u_xlat2;
    60. 08-01 20:11:55.194 14046 14106 D Unity   :     gl_Position = hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 3)] * u_xlat1.wwww + u_xlat2;
    61. 08-01 20:11:55.194 14046 14106 D Unity   :     vs_COLOR0 = in_COLOR0;
    62. 08-01 20:11:55.194 14046 14106 D Unity   :     vs_BLENDINDICES0 = u_xlatu0;
    63. 08-01 20:11:55.194 14046 14106 D Unity   :     gl_Layer = int(u_xlatu0);
    64. 08-01 20:11:55.194 14046 14106 D Unity   :     return;
    65. 08-01 20:11:55.194 14046 14106 D Unity   : }
    66. 08-01 20:11:55.194 14046 14106 D Unity   : -------- failed compiling:
    67. 08-01 20:11:55.194 14046 14106 D Unity   : vertex shader
    68. 08-01 20:11:55.194 14046 14106 D Unity   : ERROR: 0:2: '' :     GLSL error: extension 'GL_AMD_vertex_shader_layer' is not supported
    69. 08-01 20:11:55.194 14046 14106 D Unity   : ERROR: 0:63: 'gl_Layer' : undeclared identifier
    70. 08-01 20:11:55.194 14046 14106 D Unity   : ERROR: 0:63: 'assign' :  cannot convert from 'int' to 'float'
    71. 08-01 20:11:55.194 14046 14106 D Unity   : ERROR: 3 compilation errors.  No code generated.
    72. 08-01 20:11:55.194 14046 14106 D Unity   :
    73. 08-01 20:11:55.194 14046 14106 D Unity   :
    74. 08-01 20:11:55.194 14046 14106 D Unity   : Note: Creation of internal variant of shader 'Hidden/InternalClear' failed.
    75. 08-01 20:11:55.194 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords STEREO_INSTANCING_ON
    76. 08-01 20:11:55.197 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords <no keywords>
    77. 08-01 20:11:55.197 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords <no keywords>
    78. 08-01 20:11:55.199 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords UNITY_SINGLE_PASS_STEREO
    79. 08-01 20:11:55.199 14046 14074 D Unity   : Compiled shader: Hidden/InternalClear, pass: <unnamed>, stage: all, keywords UNITY_SINGLE_PASS_STEREO
    80. 08-01 20:11:55.204 14046 14106 D Unity   : -------- Shader compilation failed
    81. 08-01 20:11:55.204 14046 14106 D Unity   : #version 320 es
    82. 08-01 20:11:55.204 14046 14106 D Unity   : #extension GL_AMD_vertex_shader_layer : require
    83. 08-01 20:11:55.204 14046 14106 D Unity   : #define HLSLCC_ENABLE_UNIFORM_BUFFERS 1
    84. 08-01 20:11:55.204 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
    85. 08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_UNIFORM
    86. 08-01 20:11:55.204 14046 14106 D Unity   : #else
    87. 08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_UNIFORM uniform
    88. 08-01 20:11:55.204 14046 14106 D Unity   : #endif
    89. 08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_SUPPORTS_UNIFORM_LOCATION 1
    90. 08-01 20:11:55.204 14046 14106 D Unity   : #if UNITY_SUPPORTS_UNIFORM_LOCATION
    91. 08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_LOCATION(x) layout(location = x)
    92. 08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_BINDING(x) layout(binding = x, std140)
    93. 08-01 20:11:55.204 14046 14106 D Unity   : #else
    94. 08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_LOCATION(x)
    95. 08-01 20:11:55.204 14046 14106 D Unity   : #define UNITY_BINDING(x) layout(std140)
    96. 08-01 20:11:55.204 14046 14106 D Unity   : #endif
    97. 08-01 20:11:55.204 14046 14106 D Unity   : uniform     vec4 hlslcc_mtx4x4unity_ObjectToWorld[4];
    98. 08-01 20:11:55.204 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
    99. 08-01 20:11:55.204 14046 14106 D Unity   : UNITY_BINDING(0) uniform UnityStereoGlobals {
    100. 08-01 20:11:55.204 14046 14106 D Unity   : #endif
    101. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixP[8];
    102. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixV[8];
    103. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixInvV[8];
    104. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoMatrixVP[8];
    105. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraProjection[8];
    106. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraInvProjection[8];
    107. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoWorldToCamera[8];
    108. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 hlslcc_mtx4x4unity_StereoCameraToWorld[8];
    109. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec3 unity_StereoWorldSpaceCameraPos[2];
    110. 08-01 20:11:55.204 14046 14106 D Unity   :     UNITY_UNIFORM vec4 unity_StereoScaleOffset[2];
    111. 08-01 20:11:55.204 14046 14106 D Unity   : #if HLSLCC_ENABLE_UNIFORM_BUFFERS
    112. 08-01 20:11:55.204 14046 14106 D Unity   : };
    113. 08-01 20:11:55.204 14046 14106 D Unity   : #endif
    114. 08-01 20:11:55.204 14046 14106 D Unity   : in highp vec4 in_POSITION0;
    115. 08-01 20:11:55.204 14046 14106 D Unity   : in mediump vec4 in_COLOR0;
    116. 08-01 20:11:55.204 14046 14106 D Unity   : out mediump vec4 vs_COLOR0;
    117. 08-01 20:11:55.204 14046 14106 D Unity   : flat out highp uint vs_BLENDINDICES0;
    118. 08-01 20:11:55.204 14046 14106 D Unity   : float u_xlat0;
    119. 08-01 20:11:55.204 14046 14106 D Unity   : uint u_xlatu0;
    120. 08-01 20:11:55.204 14046 14106 D Unity   : vec4 u_xlat1;
    121. 08-01 20:11:55.204 14046 14106 D Unity   : vec4 u_xlat2;
    122. 08-01 20:11:55.204 14046 14106 D Unity   : int u_xlati3;
    123. 08-01 20:11:55.204 14046 14106 D Unity   : void main()
    124. 08-01 20:11:55.204 14046 14106 D Unity   : {
    125. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = float(uint(gl_InstanceID));
    126. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = u_xlat0 * 0.5;
    127. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = fract(u_xlat0);
    128. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = u_xlat0 + u_xlat0;
    129. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat0 = roundEven(u_xlat0);
    130. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlatu0 = uint(u_xlat0);
    131. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlati3 = int(int(u_xlatu0) << 2);
    132. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat1 = in_POSITION0.yyyy * hlslcc_mtx4x4unity_ObjectToWorld[1];
    133. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat1 = hlslcc_mtx4x4unity_ObjectToWorld[0] * in_POSITION0.xxxx + u_xlat1;
    134. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat1 = hlslcc_mtx4x4unity_ObjectToWorld[2] * in_POSITION0.zzzz + u_xlat1;
    135. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat1 = u_xlat1 + hlslcc_mtx4x4unity_ObjectToWorld[3];
    136. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat2 = u_xlat1.yyyy * hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 1)];
    137. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat2 = hlslcc_mtx4x4unity_StereoMatrixVP[u_xlati3] * u_xlat1.xxxx + u_xlat2;
    138. 08-01 20:11:55.204 14046 14106 D Unity   :     u_xlat2 = hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 2)] * u_xlat1.zzzz + u_xlat2;
    139. 08-01 20:11:55.204 14046 14106 D Unity   :     gl_Position = hlslcc_mtx4x4unity_StereoMatrixVP[(u_xlati3 + 3)] * u_xlat1.wwww + u_xlat2;
    140. 08-01 20:11:55.204 14046 14106 D Unity   :     vs_COLOR0 = in_COLOR0;
    141. 08-01 20:11:55.204 14046 14106 D Unity   :     vs_BLENDINDICES0 = u_xlatu0;
    142. 08-01 20:11:55.204 14046 14106 D Unity   :     gl_Layer = int(u_xlatu0);
    143. 08-01 20:11:55.204 14046 14106 D Unity   :     return;
    144. 08-01 20:11:55.204 14046 14106 D Unity   : }
    145. 08-01 20:11:55.204 14046 14106 D Unity   : -------- failed compiling:
    146. 08-01 20:11:55.204 14046 14106 D Unity   : vertex shader
    147. 08-01 20:11:55.204 14046 14106 D Unity   : ERROR: 0:2: '' :     GLSL error: extension 'GL_AMD_vertex_shader_layer' is not supported
    148. 08-01 20:11:55.204 14046 14106 D Unity   : ERROR: 0:63: 'gl_Layer' : undeclared identifier
    149. 08-01 20:11:55.204 14046 14106 D Unity   : ERROR: 0:63: 'assign' :  cannot convert from 'int' to 'float'
    150. 08-01 20:11:55.204 14046 14106 D Unity   : ERROR: 3 compilation errors.  No code generated.
    151. 08-01 20:11:55.204 14046 14106 D Unity   :
    152. 08-01 20:11:55.204 14046 14106 D Unity   :
    153. 08-01 20:11:55.204 14046 14106 D Unity   : Note: Creation of internal variant of shader 'Hidden/InternalClear' failed.
    154. 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
     
    Last edited: Aug 2, 2022
  2. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    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?
     
  3. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    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
     
  4. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    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.