Skip to content

Commit 022d46a

Browse files
magciusbaldurk
authored andcommitted
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.
1 parent c87dfeb commit 022d46a

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,25 @@ void WrappedOpenGL::ShaderData::Compile(WrappedOpenGL &gl, ResourceId id)
3535
if(type == eGL_VERTEX_SHADER)
3636
CheckVertexOutputUses(sources, pointSizeUsed, clipDistanceUsed);
3737

38-
{
39-
string concatenated;
38+
string concatenated;
4039

41-
for(size_t i = 0; i < sources.size(); i++)
40+
for(size_t i = 0; i < sources.size(); i++)
41+
{
42+
if(sources.size() > 1)
4243
{
43-
if(sources.size() > 1)
44-
{
45-
if(i > 0)
46-
concatenated += "\n";
47-
concatenated += "/////////////////////////////";
48-
concatenated += StringFormat::Fmt("// Source file %u", (uint32_t)i);
49-
concatenated += "/////////////////////////////";
44+
if(i > 0)
5045
concatenated += "\n";
51-
}
52-
53-
concatenated += sources[i];
46+
concatenated += "/////////////////////////////";
47+
concatenated += StringFormat::Fmt("// Source file %u", (uint32_t)i);
48+
concatenated += "/////////////////////////////";
49+
concatenated += "\n";
5450
}
5551

56-
create_array_init(reflection.RawBytes, concatenated.size(), (byte *)concatenated.c_str());
52+
concatenated += sources[i];
5753
}
5854

55+
create_array_init(reflection.RawBytes, concatenated.size(), (byte *)concatenated.c_str());
56+
5957
GLuint sepProg = prog;
6058

6159
if(sepProg == 0)
@@ -85,13 +83,9 @@ void WrappedOpenGL::ShaderData::Compile(WrappedOpenGL &gl, ResourceId id)
8583
reflection.ID = id;
8684
reflection.EntryPoint = "main";
8785

88-
// TODO sort these so that the first file contains the entry point
89-
create_array_uninit(reflection.DebugInfo.files, sources.size());
90-
for(size_t i = 0; i < sources.size(); i++)
91-
{
92-
reflection.DebugInfo.files[i].first = StringFormat::Fmt("source%u.glsl", (uint32_t)i);
93-
reflection.DebugInfo.files[i].second = sources[i];
94-
}
86+
create_array_uninit(reflection.DebugInfo.files, 1);
87+
reflection.DebugInfo.files[0].first = "main.glsl";
88+
reflection.DebugInfo.files[0].second = concatenated;
9589
}
9690
}
9791

0 commit comments

Comments
 (0)