- added a RenderQueue parameter to all Bind functions of the postprocessing shaders. This is unused for now. All places calling these pass a dummy NOQUEUE value which is just a nullptr.

This is for Vulkan preparation where all of this needs to run in a user-specified context so that this code can be moved out of the GL folder without depending on OpenGL's global state model.
This commit is contained in:
Christoph Oelckers 2018-06-13 20:30:51 +02:00
parent 0b9eaac5e1
commit 8bf009bd89
28 changed files with 91 additions and 88 deletions

View file

@ -51,7 +51,7 @@ void FShadowMap::Update()
GLRenderer->mBuffers->BindShadowMapFB(); GLRenderer->mBuffers->BindShadowMapFB();
GLRenderer->mShadowMapShader->Bind(); GLRenderer->mShadowMapShader->Bind(NOQUEUE);
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality; GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
GLRenderer->mShadowMapShader->Uniforms.Set(); GLRenderer->mShadowMapShader->Uniforms.Set();
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, mLightList); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, mLightList);

View file

@ -115,7 +115,7 @@ void FGLRenderer::AmbientOccludeScene()
glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight); glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight);
mBuffers->BindSceneDepthTexture(0); mBuffers->BindSceneDepthTexture(0);
mBuffers->BindSceneColorTexture(1); mBuffers->BindSceneColorTexture(1);
mLinearDepthShader->Bind(); mLinearDepthShader->Bind(NOQUEUE);
if (gl_multisample > 1) mLinearDepthShader->Uniforms->SampleIndex = 0; if (gl_multisample > 1) mLinearDepthShader->Uniforms->SampleIndex = 0;
mLinearDepthShader->Uniforms->LinearizeDepthA = 1.0f / GetZFar() - 1.0f / GetZNear(); mLinearDepthShader->Uniforms->LinearizeDepthA = 1.0f / GetZFar() - 1.0f / GetZNear();
mLinearDepthShader->Uniforms->LinearizeDepthB = MAX(1.0f / GetZNear(), 1.e-8f); mLinearDepthShader->Uniforms->LinearizeDepthB = MAX(1.0f / GetZNear(), 1.e-8f);
@ -131,7 +131,7 @@ void FGLRenderer::AmbientOccludeScene()
mBuffers->LinearDepthTexture.Bind(0); mBuffers->LinearDepthTexture.Bind(0);
mBuffers->AmbientRandomTexture[randomTexture].Bind(2, GL_NEAREST, GL_REPEAT); mBuffers->AmbientRandomTexture[randomTexture].Bind(2, GL_NEAREST, GL_REPEAT);
mBuffers->BindSceneNormalTexture(1); mBuffers->BindSceneNormalTexture(1);
mSSAOShader->Bind(); mSSAOShader->Bind(NOQUEUE);
if (gl_multisample > 1) mSSAOShader->Uniforms->SampleIndex = 0; if (gl_multisample > 1) mSSAOShader->Uniforms->SampleIndex = 0;
mSSAOShader->Uniforms->UVToViewA = { 2.0f * invFocalLenX, 2.0f * invFocalLenY }; mSSAOShader->Uniforms->UVToViewA = { 2.0f * invFocalLenX, 2.0f * invFocalLenY };
mSSAOShader->Uniforms->UVToViewB = { -invFocalLenX, -invFocalLenY }; mSSAOShader->Uniforms->UVToViewB = { -invFocalLenX, -invFocalLenY };
@ -151,7 +151,7 @@ void FGLRenderer::AmbientOccludeScene()
{ {
mBuffers->AmbientFB0.Bind(); mBuffers->AmbientFB0.Bind();
mBuffers->AmbientTexture1.Bind(0); mBuffers->AmbientTexture1.Bind(0);
mDepthBlurShader->Bind(false); mDepthBlurShader->Bind(NOQUEUE, false);
mDepthBlurShader->Uniforms[false]->BlurSharpness = blurSharpness; mDepthBlurShader->Uniforms[false]->BlurSharpness = blurSharpness;
mDepthBlurShader->Uniforms[false]->InvFullResolution = { 1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight }; mDepthBlurShader->Uniforms[false]->InvFullResolution = { 1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight };
mDepthBlurShader->Uniforms[false].Set(); mDepthBlurShader->Uniforms[false].Set();
@ -159,7 +159,7 @@ void FGLRenderer::AmbientOccludeScene()
mBuffers->AmbientFB1.Bind(); mBuffers->AmbientFB1.Bind();
mBuffers->AmbientTexture0.Bind(0); mBuffers->AmbientTexture0.Bind(0);
mDepthBlurShader->Bind(true); mDepthBlurShader->Bind(NOQUEUE, true);
mDepthBlurShader->Uniforms[true]->BlurSharpness = blurSharpness; mDepthBlurShader->Uniforms[true]->BlurSharpness = blurSharpness;
mDepthBlurShader->Uniforms[true]->InvFullResolution = { 1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight }; mDepthBlurShader->Uniforms[true]->InvFullResolution = { 1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight };
mDepthBlurShader->Uniforms[true]->PowExponent = gl_ssao_exponent; mDepthBlurShader->Uniforms[true]->PowExponent = gl_ssao_exponent;
@ -180,7 +180,7 @@ void FGLRenderer::AmbientOccludeScene()
} }
mBuffers->AmbientTexture1.Bind(0, GL_LINEAR); mBuffers->AmbientTexture1.Bind(0, GL_LINEAR);
mBuffers->BindSceneFogTexture(1); mBuffers->BindSceneFogTexture(1);
mSSAOCombineShader->Bind(); mSSAOCombineShader->Bind(NOQUEUE);
if (gl_multisample > 1) mSSAOCombineShader->Uniforms->SampleCount = gl_multisample; if (gl_multisample > 1) mSSAOCombineShader->Uniforms->SampleCount = gl_multisample;
mSSAOCombineShader->Uniforms->Scale = { sceneScaleX, sceneScaleY }; mSSAOCombineShader->Uniforms->Scale = { sceneScaleX, sceneScaleY };
mSSAOCombineShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY }; mSSAOCombineShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY };
@ -214,7 +214,7 @@ void FGLRenderer::UpdateCameraExposure()
level0.Framebuffer.Bind(); level0.Framebuffer.Bind();
glViewport(0, 0, level0.Width, level0.Height); glViewport(0, 0, level0.Width, level0.Height);
mBuffers->BindCurrentTexture(0, GL_LINEAR); mBuffers->BindCurrentTexture(0, GL_LINEAR);
mExposureExtractShader->Bind(); mExposureExtractShader->Bind(NOQUEUE);
mExposureExtractShader->Uniforms->Scale = { mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height }; mExposureExtractShader->Uniforms->Scale = { mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height };
mExposureExtractShader->Uniforms->Offset = { mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height }; mExposureExtractShader->Uniforms->Offset = { mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height };
mExposureExtractShader->Uniforms.Set(); mExposureExtractShader->Uniforms.Set();
@ -229,7 +229,7 @@ void FGLRenderer::UpdateCameraExposure()
next.Framebuffer.Bind(); next.Framebuffer.Bind();
glViewport(0, 0, next.Width, next.Height); glViewport(0, 0, next.Width, next.Height);
level.Texture.Bind(0); level.Texture.Bind(0);
mExposureAverageShader->Bind(); mExposureAverageShader->Bind(NOQUEUE);
RenderScreenQuad(); RenderScreenQuad();
} }
@ -247,7 +247,7 @@ void FGLRenderer::UpdateCameraExposure()
mBuffers->FirstExposureFrame = false; mBuffers->FirstExposureFrame = false;
} }
mBuffers->ExposureLevels.Last().Texture.Bind(0); mBuffers->ExposureLevels.Last().Texture.Bind(0);
mExposureCombineShader->Bind(); mExposureCombineShader->Bind(NOQUEUE);
mExposureCombineShader->Uniforms->ExposureBase = gl_exposure_base; mExposureCombineShader->Uniforms->ExposureBase = gl_exposure_base;
mExposureCombineShader->Uniforms->ExposureMin = gl_exposure_min; mExposureCombineShader->Uniforms->ExposureMin = gl_exposure_min;
mExposureCombineShader->Uniforms->ExposureScale = gl_exposure_scale; mExposureCombineShader->Uniforms->ExposureScale = gl_exposure_scale;
@ -296,7 +296,7 @@ static void RenderBlur(FGLRenderer *renderer, float blurAmount, PPTexture input,
{ {
ComputeBlurSamples(7, blurAmount, renderer->mBlurShader->Uniforms[vertical]->SampleWeights); ComputeBlurSamples(7, blurAmount, renderer->mBlurShader->Uniforms[vertical]->SampleWeights);
renderer->mBlurShader->Bind(vertical); renderer->mBlurShader->Bind(NOQUEUE, vertical);
renderer->mBlurShader->Uniforms[vertical].Set(POSTPROCESS_BINDINGPOINT); renderer->mBlurShader->Uniforms[vertical].Set(POSTPROCESS_BINDINGPOINT);
input.Bind(0); input.Bind(0);
@ -329,7 +329,7 @@ void FGLRenderer::BloomScene(int fixedcm)
glViewport(0, 0, level0.Width, level0.Height); glViewport(0, 0, level0.Width, level0.Height);
mBuffers->BindCurrentTexture(0, GL_LINEAR); mBuffers->BindCurrentTexture(0, GL_LINEAR);
mBuffers->ExposureTexture.Bind(1); mBuffers->ExposureTexture.Bind(1);
mBloomExtractShader->Bind(); mBloomExtractShader->Bind(NOQUEUE);
mBloomExtractShader->Uniforms->Scale = { mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height }; mBloomExtractShader->Uniforms->Scale = { mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height };
mBloomExtractShader->Uniforms->Offset = { mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height }; mBloomExtractShader->Uniforms->Offset = { mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height };
mBloomExtractShader->Uniforms.Set(); mBloomExtractShader->Uniforms.Set();
@ -357,7 +357,7 @@ void FGLRenderer::BloomScene(int fixedcm)
next.VFramebuffer.Bind(); next.VFramebuffer.Bind();
glViewport(0, 0, next.Width, next.Height); glViewport(0, 0, next.Width, next.Height);
level.VTexture.Bind(0, GL_LINEAR); level.VTexture.Bind(0, GL_LINEAR);
mBloomCombineShader->Bind(); mBloomCombineShader->Bind(NOQUEUE);
RenderScreenQuad(); RenderScreenQuad();
} }
@ -371,7 +371,7 @@ void FGLRenderer::BloomScene(int fixedcm)
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
level0.VTexture.Bind(0, GL_LINEAR); level0.VTexture.Bind(0, GL_LINEAR);
mBloomCombineShader->Bind(); mBloomCombineShader->Bind(NOQUEUE);
RenderScreenQuad(); RenderScreenQuad();
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
@ -434,7 +434,7 @@ void FGLRenderer::BlurScene(float gameinfobluramount)
next.VFramebuffer.Bind(); next.VFramebuffer.Bind();
glViewport(0, 0, next.Width, next.Height); glViewport(0, 0, next.Width, next.Height);
level.VTexture.Bind(0, GL_LINEAR); level.VTexture.Bind(0, GL_LINEAR);
mBloomCombineShader->Bind(); mBloomCombineShader->Bind(NOQUEUE);
RenderScreenQuad(); RenderScreenQuad();
} }
@ -469,7 +469,7 @@ void FGLRenderer::TonemapScene()
mBuffers->BindNextFB(); mBuffers->BindNextFB();
mBuffers->BindCurrentTexture(0); mBuffers->BindCurrentTexture(0);
mTonemapShader->Bind(); mTonemapShader->Bind(NOQUEUE);
if (mTonemapShader->IsPaletteMode()) if (mTonemapShader->IsPaletteMode())
{ {
@ -546,7 +546,7 @@ void FGLRenderer::ColormapScene(int fixedcm)
mBuffers->BindNextFB(); mBuffers->BindNextFB();
mBuffers->BindCurrentTexture(0); mBuffers->BindCurrentTexture(0);
mColormapShader->Bind(); mColormapShader->Bind(NOQUEUE);
FSpecialColormap *scm = &SpecialColormaps[fixedcm - CM_FIRSTSPECIALCOLORMAP]; FSpecialColormap *scm = &SpecialColormaps[fixedcm - CM_FIRSTSPECIALCOLORMAP];
float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0],
@ -604,7 +604,7 @@ void FGLRenderer::LensDistortScene()
mBuffers->BindNextFB(); mBuffers->BindNextFB();
mBuffers->BindCurrentTexture(0, GL_LINEAR); mBuffers->BindCurrentTexture(0, GL_LINEAR);
mLensShader->Bind(); mLensShader->Bind(NOQUEUE);
mLensShader->Uniforms->AspectRatio = aspect; mLensShader->Uniforms->AspectRatio = aspect;
mLensShader->Uniforms->Scale = scale; mLensShader->Uniforms->Scale = scale;
mLensShader->Uniforms->LensDistortionCoefficient = k; mLensShader->Uniforms->LensDistortionCoefficient = k;
@ -635,13 +635,13 @@ void FGLRenderer::ApplyFXAA()
mBuffers->BindNextFB(); mBuffers->BindNextFB();
mBuffers->BindCurrentTexture(0); mBuffers->BindCurrentTexture(0);
mFXAALumaShader->Bind(); mFXAALumaShader->Bind(NOQUEUE);
RenderScreenQuad(); RenderScreenQuad();
mBuffers->NextTexture(); mBuffers->NextTexture();
mBuffers->BindNextFB(); mBuffers->BindNextFB();
mBuffers->BindCurrentTexture(0, GL_LINEAR); mBuffers->BindCurrentTexture(0, GL_LINEAR);
mFXAAShader->Bind(); mFXAAShader->Bind(NOQUEUE);
mFXAAShader->Uniforms->ReciprocalResolution = { 1.0f / mBuffers->GetWidth(), 1.0f / mBuffers->GetHeight() }; mFXAAShader->Uniforms->ReciprocalResolution = { 1.0f / mBuffers->GetWidth(), 1.0f / mBuffers->GetHeight() };
mFXAAShader->Uniforms.Set(); mFXAAShader->Uniforms.Set();
RenderScreenQuad(); RenderScreenQuad();
@ -744,7 +744,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
} }
mPresentShader->Bind(); mPresentShader->Bind(NOQUEUE);
if (!applyGamma || framebuffer->IsHWGammaActive()) if (!applyGamma || framebuffer->IsHWGammaActive())
{ {
mPresentShader->Uniforms->InvGamma = 1.0f; mPresentShader->Uniforms->InvGamma = 1.0f;

View file

@ -50,6 +50,7 @@ class FShadowMapShader;
class FCustomPostProcessShaders; class FCustomPostProcessShaders;
class GLSceneDrawer; class GLSceneDrawer;
class SWSceneDrawer; class SWSceneDrawer;
#define NOQUEUE nullptr // just some token to be used as a placeholder
enum enum
{ {

View file

@ -25,7 +25,7 @@
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "gl/shaders/gl_ambientshader.h" #include "gl/shaders/gl_ambientshader.h"
void FLinearDepthShader::Bind() void FLinearDepthShader::Bind(IRenderQueue *q)
{ {
bool multisample = (gl_multisample > 1); bool multisample = (gl_multisample > 1);
if (mMultisample != multisample) if (mMultisample != multisample)
@ -44,10 +44,10 @@ void FLinearDepthShader::Bind()
Uniforms.Init(); Uniforms.Init();
mMultisample = multisample; mMultisample = multisample;
} }
mShader->Bind(); mShader->Bind(q);
} }
void FSSAOShader::Bind() void FSSAOShader::Bind(IRenderQueue *q)
{ {
bool multisample = (gl_multisample > 1); bool multisample = (gl_multisample > 1);
if (mCurrentQuality != gl_ssao || mMultisample != multisample) if (mCurrentQuality != gl_ssao || mMultisample != multisample)
@ -66,7 +66,7 @@ void FSSAOShader::Bind()
Uniforms.Init(); Uniforms.Init();
mMultisample = multisample; mMultisample = multisample;
} }
mShader->Bind(); mShader->Bind(q);
} }
FString FSSAOShader::GetDefines(int mode, bool multisample) FString FSSAOShader::GetDefines(int mode, bool multisample)
@ -94,7 +94,7 @@ FString FSSAOShader::GetDefines(int mode, bool multisample)
return defines; return defines;
} }
void FDepthBlurShader::Bind(bool vertical) void FDepthBlurShader::Bind(IRenderQueue *q, bool vertical)
{ {
auto &shader = mShader[vertical]; auto &shader = mShader[vertical];
if (!shader) if (!shader)
@ -111,10 +111,10 @@ void FDepthBlurShader::Bind(bool vertical)
shader.SetUniformBufferLocation(Uniforms[vertical].BindingPoint(), "Uniforms"); shader.SetUniformBufferLocation(Uniforms[vertical].BindingPoint(), "Uniforms");
Uniforms[vertical].Init(); Uniforms[vertical].Init();
} }
shader.Bind(); shader.Bind(q);
} }
void FSSAOCombineShader::Bind() void FSSAOCombineShader::Bind(IRenderQueue *q)
{ {
bool multisample = (gl_multisample > 1); bool multisample = (gl_multisample > 1);
if (mMultisample != multisample) if (mMultisample != multisample)
@ -134,5 +134,5 @@ void FSSAOCombineShader::Bind()
Uniforms.Init(); Uniforms.Init();
mMultisample = multisample; mMultisample = multisample;
} }
mShader->Bind(); mShader->Bind(q);
} }

View file

@ -8,7 +8,7 @@
class FLinearDepthShader class FLinearDepthShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {
@ -49,7 +49,7 @@ private:
class FSSAOShader class FSSAOShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {
@ -109,7 +109,7 @@ private:
class FDepthBlurShader class FDepthBlurShader
{ {
public: public:
void Bind(bool vertical); void Bind(IRenderQueue *q, bool vertical);
struct UniformBlock struct UniformBlock
{ {
@ -137,7 +137,7 @@ private:
class FSSAOCombineShader class FSSAOCombineShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {

View file

@ -29,7 +29,7 @@
#include "v_video.h" #include "v_video.h"
#include "gl/shaders/gl_bloomshader.h" #include "gl/shaders/gl_bloomshader.h"
void FBloomExtractShader::Bind() void FBloomExtractShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
@ -41,10 +41,10 @@ void FBloomExtractShader::Bind()
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
Uniforms.Init(); Uniforms.Init();
} }
mShader.Bind(); mShader.Bind(q);
} }
void FBloomCombineShader::Bind() void FBloomCombineShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
@ -52,5 +52,5 @@ void FBloomCombineShader::Bind()
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp", "", 330); mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp", "", 330);
mShader.Link("shaders/glsl/bloomcombine"); mShader.Link("shaders/glsl/bloomcombine");
} }
mShader.Bind(); mShader.Bind(q);
} }

View file

@ -6,7 +6,7 @@
class FBloomExtractShader class FBloomExtractShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {
@ -32,7 +32,7 @@ private:
class FBloomCombineShader class FBloomCombineShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
private: private:
FShaderProgram mShader; FShaderProgram mShader;

View file

@ -32,7 +32,7 @@
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
void FBlurShader::Bind(bool vertical) void FBlurShader::Bind(IRenderQueue *q, bool vertical)
{ {
if (!mShader[vertical]) if (!mShader[vertical])
{ {
@ -49,5 +49,5 @@ void FBlurShader::Bind(bool vertical)
Uniforms[vertical].Init(); Uniforms[vertical].Init();
} }
mShader[vertical].Bind(); mShader[vertical].Bind(q);
} }

View file

@ -11,7 +11,7 @@ class PPTexture;
class FBlurShader class FBlurShader
{ {
public: public:
void Bind(bool vertical); void Bind(IRenderQueue *q, bool vertical);
struct UniformBlock struct UniformBlock
{ {

View file

@ -29,7 +29,7 @@
#include "v_video.h" #include "v_video.h"
#include "gl/shaders/gl_colormapshader.h" #include "gl/shaders/gl_colormapshader.h"
void FColormapShader::Bind() void FColormapShader::Bind(IRenderQueue *q)
{ {
auto &shader = mShader; auto &shader = mShader;
if (!shader) if (!shader)
@ -41,6 +41,6 @@ void FColormapShader::Bind()
shader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); shader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
Uniforms.Init(); Uniforms.Init();
} }
shader.Bind(); shader.Bind(q);
} }

View file

@ -6,7 +6,7 @@
class FColormapShader class FColormapShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {

View file

@ -29,7 +29,7 @@
EXTERN_CVAR(Int, gl_fxaa) EXTERN_CVAR(Int, gl_fxaa)
void FFXAALumaShader::Bind() void FFXAALumaShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
@ -38,7 +38,7 @@ void FFXAALumaShader::Bind()
mShader.Link("shaders/glsl/fxaa"); mShader.Link("shaders/glsl/fxaa");
} }
mShader.Bind(); mShader.Bind(q);
} }
static int GetMaxVersion() static int GetMaxVersion()
@ -73,7 +73,7 @@ static FString GetDefines()
return result; return result;
} }
void FFXAAShader::Bind() void FFXAAShader::Bind(IRenderQueue *q)
{ {
assert(gl_fxaa > 0 && gl_fxaa < Count); assert(gl_fxaa > 0 && gl_fxaa < Count);
FShaderProgram &shader = mShaders[gl_fxaa]; FShaderProgram &shader = mShaders[gl_fxaa];
@ -90,5 +90,5 @@ void FFXAAShader::Bind()
Uniforms.Init(); Uniforms.Init();
} }
shader.Bind(); shader.Bind(q);
} }

View file

@ -33,7 +33,7 @@
class FFXAALumaShader class FFXAALumaShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
private: private:
FShaderProgram mShader; FShaderProgram mShader;
@ -43,7 +43,7 @@ private:
class FFXAAShader : public IFXAAShader class FFXAAShader : public IFXAAShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {

View file

@ -29,7 +29,7 @@
#include "v_video.h" #include "v_video.h"
#include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_lensshader.h"
void FLensShader::Bind() void FLensShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
@ -41,5 +41,5 @@ void FLensShader::Bind()
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
Uniforms.Init(); Uniforms.Init();
} }
mShader.Bind(); mShader.Bind(q);
} }

View file

@ -6,7 +6,7 @@
class FLensShader class FLensShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {

View file

@ -55,7 +55,7 @@ void FCustomPostProcessShaders::Run(FString target)
{ {
if (shader->Desc->Target == target) if (shader->Desc->Target == target)
{ {
shader->Run(); shader->Run(NOQUEUE);
} }
} }
} }
@ -68,7 +68,7 @@ PostProcessShaderInstance::~PostProcessShaderInstance()
glDeleteTextures(1, (GLuint*)&it.second); glDeleteTextures(1, (GLuint*)&it.second);
} }
void PostProcessShaderInstance::Run() void PostProcessShaderInstance::Run(IRenderQueue *q)
{ {
if (!IsShaderSupported()) if (!IsShaderSupported())
return; return;
@ -88,7 +88,7 @@ void PostProcessShaderInstance::Run()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
mProgram.Bind(); mProgram.Bind(q);
UpdateUniforms(); UpdateUniforms();
BindTextures(); BindTextures();

View file

@ -11,7 +11,7 @@ public:
PostProcessShaderInstance(PostProcessShader *desc) : Desc(desc) { } PostProcessShaderInstance(PostProcessShader *desc) : Desc(desc) { }
~PostProcessShaderInstance(); ~PostProcessShaderInstance();
void Run(); void Run(IRenderQueue *q);
PostProcessShader *Desc; PostProcessShader *Desc;

View file

@ -30,29 +30,29 @@
#include "gl_load/gl_system.h" #include "gl_load/gl_system.h"
#include "gl/shaders/gl_present3dRowshader.h" #include "gl/shaders/gl_present3dRowshader.h"
void FPresent3DCheckerShader::Bind() void FPresent3DCheckerShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
Init("shaders/glsl/present_checker3d.fp", "shaders/glsl/presentChecker3d"); Init("shaders/glsl/present_checker3d.fp", "shaders/glsl/presentChecker3d");
} }
mShader.Bind(); mShader.Bind(q);
} }
void FPresent3DColumnShader::Bind() void FPresent3DColumnShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
Init("shaders/glsl/present_column3d.fp", "shaders/glsl/presentColumn3d"); Init("shaders/glsl/present_column3d.fp", "shaders/glsl/presentColumn3d");
} }
mShader.Bind(); mShader.Bind(q);
} }
void FPresent3DRowShader::Bind() void FPresent3DRowShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
Init("shaders/glsl/present_row3d.fp", "shaders/glsl/presentRow3d"); Init("shaders/glsl/present_row3d.fp", "shaders/glsl/presentRow3d");
} }
mShader.Bind(); mShader.Bind(q);
} }

View file

@ -34,19 +34,19 @@
class FPresent3DCheckerShader : public FPresentShaderBase class FPresent3DCheckerShader : public FPresentShaderBase
{ {
public: public:
void Bind() override; void Bind(IRenderQueue *q) override;
}; };
class FPresent3DColumnShader : public FPresentShaderBase class FPresent3DColumnShader : public FPresentShaderBase
{ {
public: public:
void Bind() override; void Bind(IRenderQueue *q) override;
}; };
class FPresent3DRowShader : public FPresentShaderBase class FPresent3DRowShader : public FPresentShaderBase
{ {
public: public:
void Bind() override; void Bind(IRenderQueue *q) override;
}; };
// GL_PRESENT3DROWSHADER_H_ // GL_PRESENT3DROWSHADER_H_

View file

@ -40,11 +40,11 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
Uniforms.Init(); Uniforms.Init();
} }
void FPresentShader::Bind() void FPresentShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
Init("shaders/glsl/present.fp", "shaders/glsl/present"); Init("shaders/glsl/present.fp", "shaders/glsl/present");
} }
mShader.Bind(); mShader.Bind(q);
} }

View file

@ -7,7 +7,7 @@ class FPresentShaderBase
{ {
public: public:
virtual ~FPresentShaderBase() {} virtual ~FPresentShaderBase() {}
virtual void Bind() = 0; virtual void Bind(IRenderQueue *q) = 0;
struct UniformBlock struct UniformBlock
{ {
@ -44,7 +44,7 @@ protected:
class FPresentShader : public FPresentShaderBase class FPresentShader : public FPresentShaderBase
{ {
public: public:
void Bind() override; void Bind(IRenderQueue *q) override;
}; };

View file

@ -176,7 +176,7 @@ void FShaderProgram::SetUniformBufferLocation(int index, const char *name)
// //
//========================================================================== //==========================================================================
void FShaderProgram::Bind() void FShaderProgram::Bind(IRenderQueue *)
{ {
glUseProgram(mProgram); glUseProgram(mProgram);
} }

View file

@ -5,6 +5,8 @@
#include "gl_shader.h" #include "gl_shader.h"
#include "hwrenderer/data/shaderuniforms.h" #include "hwrenderer/data/shaderuniforms.h"
class IRenderQueue;
class FShaderProgram class FShaderProgram
{ {
public: public:
@ -23,7 +25,7 @@ public:
void Link(const char *name); void Link(const char *name);
void SetUniformBufferLocation(int index, const char *name); void SetUniformBufferLocation(int index, const char *name);
void Bind(); void Bind(IRenderQueue *q); // the parameter here is just a preparation for Vulkan
operator GLuint() const { return mProgram; } operator GLuint() const { return mProgram; }
explicit operator bool() const { return mProgram != 0; } explicit operator bool() const { return mProgram != 0; }

View file

@ -24,7 +24,7 @@
#include "files.h" #include "files.h"
#include "gl/shaders/gl_shadowmapshader.h" #include "gl/shaders/gl_shadowmapshader.h"
void FShadowMapShader::Bind() void FShadowMapShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
@ -36,5 +36,5 @@ void FShadowMapShader::Bind()
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
Uniforms.Init(); Uniforms.Init();
} }
mShader.Bind(); mShader.Bind(q);
} }

View file

@ -6,7 +6,7 @@
class FShadowMapShader class FShadowMapShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {

View file

@ -30,7 +30,7 @@
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "gl/shaders/gl_tonemapshader.h" #include "gl/shaders/gl_tonemapshader.h"
void FTonemapShader::Bind() void FTonemapShader::Bind(IRenderQueue *q)
{ {
auto &shader = mShader[gl_tonemap]; auto &shader = mShader[gl_tonemap];
if (!shader) if (!shader)
@ -41,7 +41,7 @@ void FTonemapShader::Bind()
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp", prolog, 330); shader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp", prolog, 330);
shader.Link("shaders/glsl/tonemap"); shader.Link("shaders/glsl/tonemap");
} }
shader.Bind(); shader.Bind(q);
} }
bool FTonemapShader::IsPaletteMode() bool FTonemapShader::IsPaletteMode()
@ -62,7 +62,7 @@ const char *FTonemapShader::GetDefines(int mode)
} }
} }
void FExposureExtractShader::Bind() void FExposureExtractShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
@ -74,10 +74,10 @@ void FExposureExtractShader::Bind()
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
Uniforms.Init(); Uniforms.Init();
} }
mShader.Bind(); mShader.Bind(q);
} }
void FExposureAverageShader::Bind() void FExposureAverageShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
@ -85,10 +85,10 @@ void FExposureAverageShader::Bind()
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureaverage.fp", "", 400); mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureaverage.fp", "", 400);
mShader.Link("shaders/glsl/exposureaverage"); mShader.Link("shaders/glsl/exposureaverage");
} }
mShader.Bind(); mShader.Bind(q);
} }
void FExposureCombineShader::Bind() void FExposureCombineShader::Bind(IRenderQueue *q)
{ {
if (!mShader) if (!mShader)
{ {
@ -100,5 +100,5 @@ void FExposureCombineShader::Bind()
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
Uniforms.Init(); Uniforms.Init();
} }
mShader.Bind(); mShader.Bind(q);
} }

View file

@ -6,7 +6,7 @@
class FTonemapShader class FTonemapShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
static bool IsPaletteMode(); static bool IsPaletteMode();
@ -30,7 +30,7 @@ private:
class FExposureExtractShader class FExposureExtractShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {
@ -56,7 +56,7 @@ private:
class FExposureAverageShader class FExposureAverageShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
private: private:
FShaderProgram mShader; FShaderProgram mShader;
@ -65,7 +65,7 @@ private:
class FExposureCombineShader class FExposureCombineShader
{ {
public: public:
void Bind(); void Bind(IRenderQueue *q);
struct UniformBlock struct UniformBlock
{ {

View file

@ -95,7 +95,7 @@ static void prepareInterleavedPresent(FPresentShaderBase& shader)
const IntRect& box = screen->mOutputLetterbox; const IntRect& box = screen->mOutputLetterbox;
glViewport(box.left, box.top, box.width, box.height); glViewport(box.left, box.top, box.width, box.height);
shader.Bind(); shader.Bind(NOQUEUE);
if ( GLRenderer->framebuffer->IsHWGammaActive() ) if ( GLRenderer->framebuffer->IsHWGammaActive() )
{ {