From 2dd9531199a8101b8b47de2fc0b8de348be5de82 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 1 Feb 2018 11:09:47 -0800 Subject: [PATCH] Fix GLSL shader editing The "files" system expects other files to be #included, which won't make sense for GLSL sources, which are expected to be concatenated. Use the concatenated string as a single "main.glsl" file. --- .../driver/gl/wrappers/gl_shader_funcs.cpp | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp index 83a3ea3cf..9841dea8d 100644 --- a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp @@ -60,28 +60,26 @@ void WrappedOpenGL::ShaderData::Compile(WrappedOpenGL &gl, ResourceId id, GLuint if(type == eGL_VERTEX_SHADER) CheckVertexOutputUses(sources, pointSizeUsed, clipDistanceUsed); + string concatenated; + + for(size_t i = 0; i < sources.size(); i++) { - string concatenated; - - for(size_t i = 0; i < sources.size(); i++) + if(sources.size() > 1) { - if(sources.size() > 1) - { - if(i > 0) - concatenated += "\n"; - concatenated += "/////////////////////////////"; - concatenated += StringFormat::Fmt("// Source file %u", (uint32_t)i); - concatenated += "/////////////////////////////"; + if(i > 0) concatenated += "\n"; - } - - concatenated += sources[i]; + concatenated += "/////////////////////////////"; + concatenated += StringFormat::Fmt("// Source file %u", (uint32_t)i); + concatenated += "/////////////////////////////"; + concatenated += "\n"; } - reflection.encoding = ShaderEncoding::GLSL; - reflection.rawBytes.assign((byte *)concatenated.c_str(), concatenated.size()); + concatenated += sources[i]; } + reflection.encoding = ShaderEncoding::GLSL; + reflection.rawBytes.assign((byte *)concatenated.c_str(), concatenated.size()); + GLuint sepProg = prog; GLint status = 0; @@ -123,13 +121,9 @@ void WrappedOpenGL::ShaderData::Compile(WrappedOpenGL &gl, ResourceId id, GLuint reflection.stage = MakeShaderStage(type); - // TODO sort these so that the first file contains the entry point - reflection.debugInfo.files.resize(sources.size()); - for(size_t i = 0; i < sources.size(); i++) - { - reflection.debugInfo.files[i].filename = StringFormat::Fmt("source%u.glsl", (uint32_t)i); - reflection.debugInfo.files[i].contents = sources[i]; - } + reflection.debugInfo.files.resize(1); + reflection.debugInfo.files[0].filename = "main.glsl"; + reflection.debugInfo.files[0].contents = concatenated; } }