Skip to content

Commit

Permalink
Merge pull request #2438 from KhronosGroup/fix-2432
Browse files Browse the repository at this point in the history
GLSL: Deal with gl_Layer in vert/tese.
  • Loading branch information
HansKristian-Work authored Jan 23, 2025
2 parents 597881e + a07b462 commit ae9ee0e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions reference/shaders-no-opt/vert/vertex-layer.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#version 450
#ifdef GL_ARB_shader_draw_parameters
#extension GL_ARB_shader_draw_parameters : enable
#endif
#extension GL_ARB_shader_viewport_layer_array : require

#ifdef GL_ARB_shader_draw_parameters
#define SPIRV_Cross_BaseInstance gl_BaseInstanceARB
#else
uniform int SPIRV_Cross_BaseInstance;
#endif

void main()
{
gl_Layer = (gl_InstanceID + SPIRV_Cross_BaseInstance);
}

7 changes: 7 additions & 0 deletions shaders-no-opt/vert/vertex-layer.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#version 450
#extension GL_ARB_shader_viewport_layer_array : require

void main()
{
gl_Layer = gl_InstanceIndex;
}
10 changes: 10 additions & 0 deletions spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9824,7 +9824,17 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage)
case BuiltInInvocationId:
return "gl_InvocationID";
case BuiltInLayer:
{
auto model = get_execution_model();
if (model == ExecutionModelVertex || model == ExecutionModelTessellationEvaluation)
{
if (options.es)
require_extension_internal("GL_NV_viewport_array2");
else
require_extension_internal("GL_ARB_shader_viewport_layer_array");
}
return "gl_Layer";
}
case BuiltInViewportIndex:
return "gl_ViewportIndex";
case BuiltInTessLevelOuter:
Expand Down

0 comments on commit ae9ee0e

Please sign in to comment.