From caaef06ba7c35c3922efad51924449b77925bb0f Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 2 Jan 2017 20:20:30 +0000 Subject: [PATCH] Handle C comments starting on a pre-processor line in GLSL patching --- renderdoc/driver/gl/gl_shader_refl.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/renderdoc/driver/gl/gl_shader_refl.cpp b/renderdoc/driver/gl/gl_shader_refl.cpp index a2fe9a978..a46616f9e 100644 --- a/renderdoc/driver/gl/gl_shader_refl.cpp +++ b/renderdoc/driver/gl/gl_shader_refl.cpp @@ -429,7 +429,18 @@ GLuint MakeSeparableShaderProgram(WrappedOpenGL &gl, GLenum type, vector // keep going until the next newline while(it < len && !isnewline(src[it])) + { + // if we encounter a C-style comment in the middle of a #define + // we can't consume it because then we'd miss the start of it. + // Instead we break out (although we're not technically at the + // end of the pre-processor line) and let it be consumed next. + // Note that we can discount C++-style comments because they + // want to consume to the end of the line too. + if(it + 1 < len && src[it] == '/' && src[it + 1] == '*') + break; + ++it; + } // skip more things continue;