mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 09:31:14 +00:00
- patch in/out layout declarations for OpenGL
This commit is contained in:
parent
c70aff99e7
commit
c137e868de
3 changed files with 51 additions and 2 deletions
|
@ -360,8 +360,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
vp_comb << "#line 1\n";
|
vp_comb << "#line 1\n";
|
||||||
fp_comb << "#line 1\n";
|
fp_comb << "#line 1\n";
|
||||||
|
|
||||||
vp_comb << vp_data.GetString().GetChars() << "\n";
|
vp_comb << RemoveLayoutLocationDecl(vp_data.GetString(), "out").GetChars() << "\n";
|
||||||
fp_comb << fp_data.GetString().GetChars() << "\n";
|
fp_comb << RemoveLayoutLocationDecl(fp_data.GetString(), "in").GetChars() << "\n";
|
||||||
|
|
||||||
if (proc_prog_lump != NULL)
|
if (proc_prog_lump != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,6 +185,54 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
|
||||||
|
{
|
||||||
|
long len = (long)code.Len();
|
||||||
|
char *chars = code.LockBuffer();
|
||||||
|
|
||||||
|
long startIndex = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
long matchIndex = code.IndexOf("layout(location", startIndex);
|
||||||
|
if (matchIndex == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
long endIndex = startIndex;
|
||||||
|
|
||||||
|
// Find end of layout declaration
|
||||||
|
while (chars[endIndex] != ')' && chars[endIndex] != 0)
|
||||||
|
endIndex++;
|
||||||
|
|
||||||
|
// Skip whitespace
|
||||||
|
while (IsGlslWhitespace(chars[endIndex]))
|
||||||
|
endIndex++;
|
||||||
|
|
||||||
|
// keyword following the declaration?
|
||||||
|
bool keywordFound = true;
|
||||||
|
long i;
|
||||||
|
for (i = 0; inoutkeyword[i] != 0; i++)
|
||||||
|
{
|
||||||
|
if (chars[endIndex + i] != inoutkeyword[i])
|
||||||
|
{
|
||||||
|
keywordFound = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (keywordFound && IsGlslWhitespace(chars[endIndex + i]))
|
||||||
|
{
|
||||||
|
// yes - replace declaration with spaces
|
||||||
|
for (long i = startIndex; i < endIndex; i++)
|
||||||
|
chars[i] = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
startIndex = endIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
code.UnlockBuffer();
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Note: the MaterialShaderIndex enum in gl_shader.h needs to be updated whenever this array is modified.
|
// Note: the MaterialShaderIndex enum in gl_shader.h needs to be updated whenever this array is modified.
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
FString RemoveLegacyUserUniforms(FString code);
|
FString RemoveLegacyUserUniforms(FString code);
|
||||||
FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &samplerstobind); // For GL 3.3 compatibility which cannot declare sampler bindings in the sampler source.
|
FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &samplerstobind); // For GL 3.3 compatibility which cannot declare sampler bindings in the sampler source.
|
||||||
|
FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword);
|
||||||
|
|
||||||
struct FDefaultShader
|
struct FDefaultShader
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue