Pass through include paths properly when compiling shaders. Closes #2646

This commit is contained in:
baldurk
2022-07-11 13:03:54 +01:00
parent c14fad42c0
commit 5ef8294375
4 changed files with 21 additions and 12 deletions
+11 -2
View File
@@ -1224,9 +1224,18 @@ bool GLResourceManager::Serialise_InitialState(SerialiserType &ser, ResourceId i
for(size_t s = 0; s < shadDetails.sources.size(); s++)
srcs[s] = (char *)shadDetails.sources[s].c_str();
drv.glShaderSource(shad, (GLsizei)shadDetails.sources.size(), srcs, NULL);
SAFE_DELETE_ARRAY(srcs);
drv.glCompileShader(shad);
char **includes = new char *[shadDetails.includepaths.size()];
for(size_t s = 0; s < shadDetails.includepaths.size(); s++)
includes[s] = (char *)shadDetails.includepaths[s].c_str();
if(shadDetails.includepaths.empty())
drv.glCompileShader(shad);
else
drv.glCompileShaderIncludeARB(shad, (GLsizei)shadDetails.includepaths.size(), includes,
NULL);
SAFE_DELETE_ARRAY(includes);
drv.glAttachShader(initProg, shad);
drv.glDeleteShader(shad);
}
+7 -7
View File
@@ -180,8 +180,8 @@ static bool iswhitespace(char c)
return isspacetab(c) || isnewline(c);
}
GLuint MakeSeparableShaderProgram(WrappedOpenGL &drv, GLenum type, rdcarray<rdcstr> sources,
rdcarray<rdcstr> *includepaths)
GLuint MakeSeparableShaderProgram(WrappedOpenGL &drv, GLenum type, const rdcarray<rdcstr> &sources,
const rdcarray<rdcstr> &includepaths)
{
// in and out blocks are added separately, in case one is there already
const char *blockIdentifiers[2] = {"in gl_PerVertex", "out gl_PerVertex"};
@@ -216,13 +216,13 @@ GLuint MakeSeparableShaderProgram(WrappedOpenGL &drv, GLenum type, rdcarray<rdcs
const char **paths = NULL;
GLsizei numPaths = 0;
if(includepaths)
if(!includepaths.empty())
{
numPaths = (GLsizei)includepaths->size();
numPaths = (GLsizei)includepaths.size();
paths = new const char *[includepaths->size()];
for(size_t i = 0; i < includepaths->size(); i++)
paths[i] = (*includepaths)[i].c_str();
paths = new const char *[includepaths.size()];
for(size_t i = 0; i < includepaths.size(); i++)
paths[i] = includepaths[i].c_str();
}
GLuint sepProg = CreateSepProgram(drv, type, (GLsizei)sources.size(), strings, numPaths, paths);
+2 -2
View File
@@ -56,6 +56,6 @@ struct FixedFunctionVertexOutputs
int ParseVersionStatement(const char *version);
void MakeShaderReflection(GLenum shadType, GLuint sepProg, ShaderReflection &refl,
const FixedFunctionVertexOutputs &outputUsage);
GLuint MakeSeparableShaderProgram(WrappedOpenGL &drv, GLenum type, rdcarray<rdcstr> sources,
rdcarray<rdcstr> *includepaths);
GLuint MakeSeparableShaderProgram(WrappedOpenGL &drv, GLenum type, const rdcarray<rdcstr> &sources,
const rdcarray<rdcstr> &includepaths);
void CheckVertexOutputUses(const rdcarray<rdcstr> &sources, FixedFunctionVertexOutputs &outputUsage);
@@ -225,7 +225,7 @@ void WrappedOpenGL::ShaderData::ProcessCompilation(WrappedOpenGL &drv, ResourceI
// - this may or may not be emulated depending on if ARB_program_interface_query is supported.
if(HasExt[ARB_separate_shader_objects])
{
GLuint sepProg = MakeSeparableShaderProgram(drv, type, sources, NULL);
GLuint sepProg = MakeSeparableShaderProgram(drv, type, sources, includepaths);
if(sepProg == 0)
{