From 55a29042a2826f26272c9e1b65cd3745bad3ee31 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 19 Jul 2017 10:10:17 -0700 Subject: Fix up translation of `GetDimensions()` Fixes #122 - In cases with an explicit mip level being specified, there was a mistake in how the argument for setting the mip level in the GLSL code was constructed that led to a parse error in GLSL - Also, that argument is a `uint` in HLSL and an `int` in GLSL, so an explicit cast was needed - The GLSL functions here seem to require a newer GLSL (at least higher than `420`), so I had to add in a capability for builtins to specify a required GLSL version. For now I made these ones require `450`. - Added a test case to confirm that our lowering works (for some definition of "works") --- source/slang/lower.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'source/slang/lower.cpp') diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index 127ef75ca..c61003bc6 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -291,6 +291,10 @@ static void attachLayout( addModifier(syntax, modifier); } +void requireGLSLVersion( + EntryPointRequest* entryPoint, + ProfileVersion version); + struct LoweringVisitor : ExprVisitor> , StmtVisitor @@ -2958,23 +2962,7 @@ struct LoweringVisitor return; auto entryPoint = shared->entryPointRequest; - auto profile = entryPoint->profile; - auto currentVersion = profile.GetVersion(); - if (profile.getFamily() == ProfileFamily::GLSL) - { - // Check if this profile is newer - if ((UInt)version > (UInt)profile.GetVersion()) - { - profile.setVersion(version); - entryPoint->profile = profile; - } - } - else - { - // Non-GLSL target? Set it to a GLSL one. - profile.setVersion(version); - entryPoint->profile = profile; - } + Slang::requireGLSLVersion(entryPoint, version); } RefPtr lowerSimpleShaderParameterToGLSLGlobal( -- cgit v1.2.3