From b30b93f40f03051aea6dd73f1da7d6bdbc287f0e Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 23 Jul 2017 06:09:20 -0400 Subject: [PATCH] - made postprocess shader parsing a little more strict, will error out more frequently with common mistakes. --- src/gl/shaders/gl_shader.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index b0b3ea32b..c508fd301 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -683,6 +683,13 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) PostProcessShader shaderdesc; shaderdesc.Target = sc.String; + bool validTarget = false; + if (sc.Compare("beforebloom")) validTarget = true; + if (sc.Compare("scene")) validTarget = true; + if (sc.Compare("screen")) validTarget = true; + if (!validTarget) + sc.ScriptError("Invalid target '%s' for postprocess shader",sc.String); + sc.MustGetToken('{'); while (!sc.CheckToken('}')) { @@ -694,6 +701,8 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) sc.MustGetNumber(); shaderdesc.ShaderVersion = sc.Number; + if (sc.Number > 450 || sc.Number < 330) + sc.ScriptError("Shader version must be in range 330 to 450!"); } else if (sc.Compare("name")) { @@ -719,6 +728,8 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) parsedType = PostProcessUniformType::Vec2; else if (uniformType.Compare("vec3") == 0) parsedType = PostProcessUniformType::Vec3; + else + sc.ScriptError("Unrecognized uniform type '%s'", sc.String); if (parsedType != PostProcessUniformType::Undefined) shaderdesc.Uniforms[uniformName].Type = parsedType; @@ -727,6 +738,10 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) { shaderdesc.Enabled = true; } + else + { + sc.ScriptError("Unknown keyword '%s'", sc.String); + } } PostProcessShaders.Push(shaderdesc);