- specify fragment output locations in the shader source.

OpenGL has been supporting this since version 3.3 and Vulkan requires it so it's the way to go.
This commit is contained in:
Christoph Oelckers 2018-06-12 23:52:33 +02:00
commit ad7aaa8f2a
38 changed files with 28 additions and 65 deletions

View file

@ -39,7 +39,6 @@ void FLinearDepthShader::Bind()
mShader.reset(new FShaderProgram());
mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", prolog, 330);
mShader->SetFragDataLocation(0, "FragColor");
mShader->Link("shaders/glsl/lineardepth");
mShader->SetAttribLocation(0, "PositionInProjection");
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
@ -65,7 +64,6 @@ void FSSAOShader::Bind()
mShader.reset(new FShaderProgram());
mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", prolog, 330);
mShader->SetFragDataLocation(0, "FragColor");
mShader->Link("shaders/glsl/ssao");
mShader->SetAttribLocation(0, "PositionInProjection");
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
@ -116,7 +114,6 @@ void FDepthBlurShader::Bind(bool vertical)
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/depthblur.fp", prolog, 330);
shader.SetFragDataLocation(0, "FragColor");
shader.Link("shaders/glsl/depthblur");
shader.SetAttribLocation(0, "PositionInProjection");
shader.SetUniformBufferLocation(Uniforms[vertical].BindingPoint(), "Uniforms");
@ -141,7 +138,6 @@ void FSSAOCombineShader::Bind()
mShader.reset(new FShaderProgram());
mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", prolog, 330);
mShader->SetFragDataLocation(0, "FragColor");
mShader->Link("shaders/glsl/ssaocombine");
mShader->SetAttribLocation(0, "PositionInProjection");
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");

View file

@ -37,7 +37,6 @@ void FBloomExtractShader::Bind()
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomextract.fp", prolog, 330);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link("shaders/glsl/bloomextract");
mShader.SetAttribLocation(0, "PositionInProjection");
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
@ -54,7 +53,6 @@ void FBloomCombineShader::Bind()
{
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp", "", 330);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link("shaders/glsl/bloomcombine");
mShader.SetAttribLocation(0, "PositionInProjection");
BloomTexture.Init(mShader, "Bloom");

View file

@ -44,7 +44,6 @@ void FBlurShader::Bind(bool vertical)
mShader[vertical].Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader[vertical].Compile(FShaderProgram::Fragment, "shaders/glsl/blur.fp", prolog, 330);
mShader[vertical].SetFragDataLocation(0, "FragColor");
mShader[vertical].Link("shaders/glsl/blur");
mShader[vertical].SetAttribLocation(0, "PositionInProjection");
mShader[vertical].SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");

View file

@ -38,7 +38,6 @@ void FColormapShader::Bind()
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/colormap.fp", prolog, 330);
shader.SetFragDataLocation(0, "FragColor");
shader.Link("shaders/glsl/colormap");
shader.SetAttribLocation(0, "PositionInProjection");
shader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");

View file

@ -35,7 +35,6 @@ void FFXAALumaShader::Bind()
{
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/fxaa.fp", "#define FXAA_LUMA_PASS\n", 330);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link("shaders/glsl/fxaa");
mShader.SetAttribLocation(0, "PositionInProjection");
InputTexture.Init(mShader, "InputTexture");
@ -88,7 +87,6 @@ void FFXAAShader::Bind()
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/fxaa.fp", prolog, maxVersion);
shader.SetFragDataLocation(0, "FragColor");
shader.Link("shaders/glsl/fxaa");
shader.SetAttribLocation(0, "PositionInProjection");
shader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");

View file

@ -37,7 +37,6 @@ void FLensShader::Bind()
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lensdistortion.fp", prolog, 330);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link("shaders/glsl/lensdistortion");
mShader.SetAttribLocation(0, "PositionInProjection");
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");

View file

@ -168,7 +168,6 @@ void PostProcessShaderInstance::CompileShader()
mProgram.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", Desc->ShaderVersion);
mProgram.Compile(FShaderProgram::Fragment, lumpName, code, prolog.GetChars(), Desc->ShaderVersion);
mProgram.SetFragDataLocation(0, "FragColor");
mProgram.Link(Desc->ShaderLumpName.GetChars());
mProgram.SetAttribLocation(0, "PositionInProjection");
mInputTexture.Init(mProgram, "InputTexture");

View file

@ -35,7 +35,6 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", prolog, 330);
mShader.Compile(FShaderProgram::Fragment, vtx_shader_name, prolog, 330);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link(program_name);
mShader.SetAttribLocation(0, "PositionInProjection");
mShader.SetAttribLocation(1, "UV");

View file

@ -263,13 +263,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
{
vp_comb.Format("#version 300 es\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
}
else if (gl.glslversion < 1.4f) // This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary
{
vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
}
else
{
vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
vp_comb.Format("#version 330 core\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
}
}
else
@ -380,10 +376,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2");
glBindAttribLocation(hShader, VATTR_NORMAL, "aNormal");
glBindFragDataLocation(hShader, 0, "FragColor");
glBindFragDataLocation(hShader, 1, "FragFog");
glBindFragDataLocation(hShader, 2, "FragNormal");
glLinkProgram(hShader);
glGetShaderInfoLog(hVertProg, 10000, NULL, buffer);

View file

@ -118,17 +118,6 @@ void FShaderProgram::Compile(ShaderType type, const char *name, const FString &c
}
}
//==========================================================================
//
// Binds a fragment output variable to a frame buffer render target
//
//==========================================================================
void FShaderProgram::SetFragDataLocation(int index, const char *name)
{
glBindFragDataLocation(mProgram, index, name);
}
//==========================================================================
//
// Links a program with the compiled shaders

View file

@ -20,7 +20,6 @@ public:
void Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion);
void Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion);
void SetFragDataLocation(int index, const char *name);
void Link(const char *name);
void SetAttribLocation(int index, const char *name);
void SetUniformBufferLocation(int index, const char *name);

View file

@ -32,7 +32,6 @@ void FShadowMapShader::Bind()
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 430);
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/shadowmap.fp", prolog, 430);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link("shaders/glsl/shadowmap");
mShader.SetAttribLocation(0, "PositionInProjection");
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");

View file

@ -37,7 +37,6 @@ void FTonemapShader::Bind()
{
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp", GetDefines(gl_tonemap), 330);
shader.SetFragDataLocation(0, "FragColor");
shader.Link("shaders/glsl/tonemap");
shader.SetAttribLocation(0, "PositionInProjection");
SceneTexture.Init(shader, "InputTexture");
@ -73,7 +72,6 @@ void FExposureExtractShader::Bind()
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureextract.fp", prolog, 330);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link("shaders/glsl/exposureextract");
mShader.SetAttribLocation(0, "PositionInProjection");
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
@ -89,7 +87,6 @@ void FExposureAverageShader::Bind()
{
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 400);
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureaverage.fp", "", 400);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link("shaders/glsl/exposureaverage");
mShader.SetAttribLocation(0, "PositionInProjection");
ExposureTexture.Init(mShader, "ExposureTexture");
@ -105,7 +102,6 @@ void FExposureCombineShader::Bind()
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposurecombine.fp", prolog, 330);
mShader.SetFragDataLocation(0, "FragColor");
mShader.Link("shaders/glsl/exposurecombine");
mShader.SetAttribLocation(0, "PositionInProjection");
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");