From 0cf9bcfc4fd68b9f4bb2ba55565af33e680177b0 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 20 Jul 2017 15:14:35 -0700 Subject: Require extension when using `gl_Layer` in VS The requirements for using `gl_Layer` differ by stage, and so we need to pick an appropriate GL version based on the target stage, and then also require a specific extension for anything other than geometry or fragment. --- source/slang/lower.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/slang/lower.cpp') diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index 54afc283c..174c93c1d 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -3458,10 +3458,22 @@ struct LoweringVisitor } else if (ns == "sv_rendertargetarrayindex") { - if (info.direction == VaryingParameterDirection::Input) + switch (shared->entryPointRequest->profile.GetStage()) { + case Stage::Geometry: + requireGLSLVersion(ProfileVersion::GLSL_150); + break; + + case Stage::Fragment: requireGLSLVersion(ProfileVersion::GLSL_430); + break; + + default: + requireGLSLVersion(ProfileVersion::GLSL_450); + requireGLSLExtension(shared->extensionUsageTracker, "GL_ARB_shader_viewport_layer_array"); + break; } + globalVarExpr = createGLSLBuiltinRef("gl_Layer", getIntType()); } else if (ns == "sv_sampleindex") -- cgit v1.2.3