From f166624eb205959b70e67134a022a1e8142fee38 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 12 Jun 2018 21:43:35 +0200 Subject: [PATCH] - some fixes to the PP shader interface. The binding point needs to be part of the ShaderUniforms class because Vulkan will need this value to generate the declaration in the shader source. There's still one issue here: Since OpenGL has no local render state, the buffer must be bound every time it is used. Once the code is better abstracted this should be moved to a higher level class that knows all associated data and how to set it up. --- src/gl/data/gl_uniformbuffer.cpp | 11 +++++++++++ src/gl/data/gl_uniformbuffer.h | 1 + src/gl/dynlights/gl_shadowmap.cpp | 2 +- src/gl/renderer/gl_postprocess.cpp | 24 ++++++++++++------------ src/gl/shaders/gl_ambientshader.cpp | 8 ++++---- src/gl/shaders/gl_ambientshader.h | 8 ++++---- src/gl/shaders/gl_bloomshader.cpp | 2 +- src/gl/shaders/gl_bloomshader.h | 2 +- src/gl/shaders/gl_colormapshader.cpp | 2 +- src/gl/shaders/gl_colormapshader.h | 2 +- src/gl/shaders/gl_fxaashader.cpp | 2 +- src/gl/shaders/gl_fxaashader.h | 2 +- src/gl/shaders/gl_lensshader.cpp | 2 +- src/gl/shaders/gl_lensshader.h | 2 +- src/gl/shaders/gl_presentshader.cpp | 2 +- src/gl/shaders/gl_presentshader.h | 2 +- src/gl/shaders/gl_shaderprogram.h | 19 +++++++++++++------ src/gl/shaders/gl_shadowmapshader.cpp | 2 +- src/gl/shaders/gl_shadowmapshader.h | 2 +- src/gl/shaders/gl_tonemapshader.cpp | 4 ++-- src/gl/shaders/gl_tonemapshader.h | 4 ++-- src/gl/stereo3d/gl_interleaved3d.cpp | 8 ++++---- src/hwrenderer/data/uniformbuffer.h | 1 + 23 files changed, 67 insertions(+), 47 deletions(-) diff --git a/src/gl/data/gl_uniformbuffer.cpp b/src/gl/data/gl_uniformbuffer.cpp index 3952b6352..010c0aff1 100644 --- a/src/gl/data/gl_uniformbuffer.cpp +++ b/src/gl/data/gl_uniformbuffer.cpp @@ -71,3 +71,14 @@ void GLUniformBuffer::SetData(const void *data) glBufferData(GL_UNIFORM_BUFFER, mSize, data, mStaticDraw? GL_STATIC_DRAW : GL_STREAM_DRAW); } } + +//========================================================================== +// +// This needs to go away later. +// +//========================================================================== + +void GLUniformBuffer::Bind(int bindingpoint) +{ + glBindBufferBase(GL_UNIFORM_BUFFER, bindingpoint, mBufferId); +} diff --git a/src/gl/data/gl_uniformbuffer.h b/src/gl/data/gl_uniformbuffer.h index 36c414428..64c1831be 100644 --- a/src/gl/data/gl_uniformbuffer.h +++ b/src/gl/data/gl_uniformbuffer.h @@ -14,6 +14,7 @@ public: ~GLUniformBuffer(); void SetData(const void *data) override; + void Bind(int bindingpoint) override; unsigned ID() const { diff --git a/src/gl/dynlights/gl_shadowmap.cpp b/src/gl/dynlights/gl_shadowmap.cpp index 13f534bb2..910b620d1 100644 --- a/src/gl/dynlights/gl_shadowmap.cpp +++ b/src/gl/dynlights/gl_shadowmap.cpp @@ -53,7 +53,7 @@ void FShadowMap::Update() GLRenderer->mShadowMapShader->Bind(); GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality; - GLRenderer->mShadowMapShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + GLRenderer->mShadowMapShader->Uniforms.Set(); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, mLightList); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, mNodesBuffer); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, mLinesBuffer); diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 6b7ce120c..06ac1cae3 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -125,7 +125,7 @@ void FGLRenderer::AmbientOccludeScene() mLinearDepthShader->Uniforms->InverseDepthRangeB = 0.0f; mLinearDepthShader->Uniforms->Scale = { sceneScaleX, sceneScaleY }; mLinearDepthShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY }; - mLinearDepthShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + mLinearDepthShader->Uniforms.Set(); RenderScreenQuad(); // Apply ambient occlusion @@ -148,7 +148,7 @@ void FGLRenderer::AmbientOccludeScene() mSSAOShader->Uniforms->AOStrength = aoStrength; mSSAOShader->Uniforms->Scale = { sceneScaleX, sceneScaleY }; mSSAOShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY }; - mSSAOShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + mSSAOShader->Uniforms.Set(); RenderScreenQuad(); // Blur SSAO texture @@ -159,7 +159,7 @@ void FGLRenderer::AmbientOccludeScene() mDepthBlurShader->Bind(false); mDepthBlurShader->Uniforms[false]->BlurSharpness = blurSharpness; mDepthBlurShader->Uniforms[false]->InvFullResolution = { 1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight }; - mDepthBlurShader->Uniforms[false].Set(POSTPROCESS_BINDINGPOINT); + mDepthBlurShader->Uniforms[false].Set(); RenderScreenQuad(); mBuffers->AmbientFB1.Bind(); @@ -168,7 +168,7 @@ void FGLRenderer::AmbientOccludeScene() mDepthBlurShader->Uniforms[true]->BlurSharpness = blurSharpness; mDepthBlurShader->Uniforms[true]->InvFullResolution = { 1.0f / mBuffers->AmbientWidth, 1.0f / mBuffers->AmbientHeight }; mDepthBlurShader->Uniforms[true]->PowExponent = gl_ssao_exponent; - mDepthBlurShader->Uniforms[true].Set(POSTPROCESS_BINDINGPOINT); + mDepthBlurShader->Uniforms[true].Set(); RenderScreenQuad(); } @@ -191,7 +191,7 @@ void FGLRenderer::AmbientOccludeScene() if (gl_multisample > 1) mSSAOCombineShader->Uniforms->SampleCount = gl_multisample; mSSAOCombineShader->Uniforms->Scale = { sceneScaleX, sceneScaleY }; mSSAOCombineShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY }; - mSSAOCombineShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + mSSAOCombineShader->Uniforms.Set(); RenderScreenQuad(); FGLDebug::PopGroup(); @@ -225,7 +225,7 @@ void FGLRenderer::UpdateCameraExposure() mExposureExtractShader->SceneTexture.Set(0); 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.Set(POSTPROCESS_BINDINGPOINT); + mExposureExtractShader->Uniforms.Set(); RenderScreenQuad(); // Find the average value: @@ -262,7 +262,7 @@ void FGLRenderer::UpdateCameraExposure() mExposureCombineShader->Uniforms->ExposureMin = gl_exposure_min; mExposureCombineShader->Uniforms->ExposureScale = gl_exposure_scale; mExposureCombineShader->Uniforms->ExposureSpeed = gl_exposure_speed; - mExposureCombineShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + mExposureCombineShader->Uniforms.Set(); RenderScreenQuad(); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); @@ -304,7 +304,7 @@ void FGLRenderer::BloomScene(int fixedcm) mBloomExtractShader->ExposureTexture.Set(1); 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.Set(POSTPROCESS_BINDINGPOINT); + mBloomExtractShader->Uniforms.Set(); RenderScreenQuad(); // Blur and downscale: @@ -534,7 +534,7 @@ void FGLRenderer::ColormapScene(int fixedcm) mColormapShader->Uniforms->MapStart = { scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f }; mColormapShader->Uniforms->MapRange = m; - mColormapShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + mColormapShader->Uniforms.Set(); RenderScreenQuad(); mBuffers->NextTexture(); @@ -590,7 +590,7 @@ void FGLRenderer::LensDistortScene() mLensShader->Uniforms->Scale = scale; mLensShader->Uniforms->LensDistortionCoefficient = k; mLensShader->Uniforms->CubicDistortionValue = kcube; - mLensShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + mLensShader->Uniforms.Set(); RenderScreenQuad(); mBuffers->NextTexture(); @@ -626,7 +626,7 @@ void FGLRenderer::ApplyFXAA() mFXAAShader->Bind(); mFXAAShader->InputTexture.Set(0); mFXAAShader->Uniforms->ReciprocalResolution = { 1.0f / mBuffers->GetWidth(), 1.0f / mBuffers->GetHeight() }; - mFXAAShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + mFXAAShader->Uniforms.Set(); RenderScreenQuad(); mBuffers->NextTexture(); @@ -745,7 +745,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma) mPresentShader->Uniforms->GrayFormula = static_cast(gl_satformula); } mPresentShader->Uniforms->Scale = { screen->mScreenViewport.width / (float)mBuffers->GetWidth(), screen->mScreenViewport.height / (float)mBuffers->GetHeight() }; - mPresentShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + mPresentShader->Uniforms.Set(); RenderScreenQuad(); } diff --git a/src/gl/shaders/gl_ambientshader.cpp b/src/gl/shaders/gl_ambientshader.cpp index c7242c82b..647910766 100644 --- a/src/gl/shaders/gl_ambientshader.cpp +++ b/src/gl/shaders/gl_ambientshader.cpp @@ -42,7 +42,7 @@ void FLinearDepthShader::Bind() mShader->SetFragDataLocation(0, "FragColor"); mShader->Link("shaders/glsl/lineardepth"); mShader->SetAttribLocation(0, "PositionInProjection"); - mShader->SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); DepthTexture.Init(*mShader, "DepthTexture"); ColorTexture.Init(*mShader, "ColorTexture"); Uniforms.Init(); @@ -68,7 +68,7 @@ void FSSAOShader::Bind() mShader->SetFragDataLocation(0, "FragColor"); mShader->Link("shaders/glsl/ssao"); mShader->SetAttribLocation(0, "PositionInProjection"); - mShader->SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); DepthTexture.Init(*mShader, "DepthTexture"); NormalTexture.Init(*mShader, "NormalTexture"); RandomTexture.Init(*mShader, "RandomTexture"); @@ -119,7 +119,7 @@ void FDepthBlurShader::Bind(bool vertical) shader.SetFragDataLocation(0, "FragColor"); shader.Link("shaders/glsl/depthblur"); shader.SetAttribLocation(0, "PositionInProjection"); - shader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + shader.SetUniformBufferLocation(Uniforms[vertical].BindingPoint(), "Uniforms"); AODepthTexture[vertical].Init(shader, "AODepthTexture"); Uniforms[vertical].Init(); } @@ -144,7 +144,7 @@ void FSSAOCombineShader::Bind() mShader->SetFragDataLocation(0, "FragColor"); mShader->Link("shaders/glsl/ssaocombine"); mShader->SetAttribLocation(0, "PositionInProjection"); - mShader->SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); AODepthTexture.Init(*mShader, "AODepthTexture"); SceneFogTexture.Init(*mShader, "SceneFogTexture"); Uniforms.Init(); diff --git a/src/gl/shaders/gl_ambientshader.h b/src/gl/shaders/gl_ambientshader.h index 0420c3e85..e3a7ef309 100644 --- a/src/gl/shaders/gl_ambientshader.h +++ b/src/gl/shaders/gl_ambientshader.h @@ -42,7 +42,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: std::unique_ptr mShader; @@ -94,7 +94,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: enum Quality @@ -137,7 +137,7 @@ public: } }; - ShaderUniforms Uniforms[2]; + ShaderUniforms Uniforms[2]; private: FShaderProgram mShader[2]; @@ -172,7 +172,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: std::unique_ptr mShader; diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp index 8e5a2f5ea..2ab14d3b4 100644 --- a/src/gl/shaders/gl_bloomshader.cpp +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -40,7 +40,7 @@ void FBloomExtractShader::Bind() mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/bloomextract"); mShader.SetAttribLocation(0, "PositionInProjection"); - mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); SceneTexture.Init(mShader, "SceneTexture"); ExposureTexture.Init(mShader, "ExposureTexture"); Uniforms.Init(); diff --git a/src/gl/shaders/gl_bloomshader.h b/src/gl/shaders/gl_bloomshader.h index e3473babb..a00ae638b 100644 --- a/src/gl/shaders/gl_bloomshader.h +++ b/src/gl/shaders/gl_bloomshader.h @@ -26,7 +26,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: FShaderProgram mShader; diff --git a/src/gl/shaders/gl_colormapshader.cpp b/src/gl/shaders/gl_colormapshader.cpp index 6979860d6..2a0f9d852 100644 --- a/src/gl/shaders/gl_colormapshader.cpp +++ b/src/gl/shaders/gl_colormapshader.cpp @@ -41,7 +41,7 @@ void FColormapShader::Bind() shader.SetFragDataLocation(0, "FragColor"); shader.Link("shaders/glsl/colormap"); shader.SetAttribLocation(0, "PositionInProjection"); - shader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + shader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); Uniforms.Init(); } shader.Bind(); diff --git a/src/gl/shaders/gl_colormapshader.h b/src/gl/shaders/gl_colormapshader.h index 80d4b3f11..c9b0e81ec 100644 --- a/src/gl/shaders/gl_colormapshader.h +++ b/src/gl/shaders/gl_colormapshader.h @@ -25,7 +25,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: diff --git a/src/gl/shaders/gl_fxaashader.cpp b/src/gl/shaders/gl_fxaashader.cpp index 2fbc0e2f0..96fea58f1 100644 --- a/src/gl/shaders/gl_fxaashader.cpp +++ b/src/gl/shaders/gl_fxaashader.cpp @@ -91,7 +91,7 @@ void FFXAAShader::Bind() shader.SetFragDataLocation(0, "FragColor"); shader.Link("shaders/glsl/fxaa"); shader.SetAttribLocation(0, "PositionInProjection"); - shader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + shader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); InputTexture.Init(shader, "InputTexture"); Uniforms.Init(); } diff --git a/src/gl/shaders/gl_fxaashader.h b/src/gl/shaders/gl_fxaashader.h index 126f0da79..d4e296a97 100644 --- a/src/gl/shaders/gl_fxaashader.h +++ b/src/gl/shaders/gl_fxaashader.h @@ -65,7 +65,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: FShaderProgram mShaders[Count]; diff --git a/src/gl/shaders/gl_lensshader.cpp b/src/gl/shaders/gl_lensshader.cpp index 7bfbbfa19..f9b733763 100644 --- a/src/gl/shaders/gl_lensshader.cpp +++ b/src/gl/shaders/gl_lensshader.cpp @@ -40,7 +40,7 @@ void FLensShader::Bind() mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/lensdistortion"); mShader.SetAttribLocation(0, "PositionInProjection"); - mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); InputTexture.Init(mShader, "InputTexture"); Uniforms.Init(); } diff --git a/src/gl/shaders/gl_lensshader.h b/src/gl/shaders/gl_lensshader.h index ace6054cb..fca227e16 100644 --- a/src/gl/shaders/gl_lensshader.h +++ b/src/gl/shaders/gl_lensshader.h @@ -32,7 +32,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: FShaderProgram mShader; diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 7f3ca148d..7ef250cba 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -39,7 +39,7 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program mShader.Link(program_name); mShader.SetAttribLocation(0, "PositionInProjection"); mShader.SetAttribLocation(1, "UV"); - mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); Uniforms.Init(); } diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h index f0e67d1cd..d3cbd2c32 100644 --- a/src/gl/shaders/gl_presentshader.h +++ b/src/gl/shaders/gl_presentshader.h @@ -34,7 +34,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; protected: virtual void Init(const char * vtx_shader_name, const char * program_name); diff --git a/src/gl/shaders/gl_shaderprogram.h b/src/gl/shaders/gl_shaderprogram.h index 64f337dcc..57d9ca644 100644 --- a/src/gl/shaders/gl_shaderprogram.h +++ b/src/gl/shaders/gl_shaderprogram.h @@ -20,6 +20,7 @@ enum class UniformType UVec2, UVec3, UVec4, + Mat4 }; class UniformFieldDesc @@ -33,7 +34,7 @@ public: std::size_t Offset; }; -template +template class ShaderUniforms { public: @@ -48,12 +49,17 @@ public: delete mBuffer; } + int BindingPoint() const + { + return bindingpoint; + } + FString CreateDeclaration(const char *name, const std::vector &fields) { mFields = fields; FString decl; - decl.Format("layout(%s) uniform %s\n{\n", screen->GetUniformLayoutString(mBindingPoint).GetChars(), name); + decl.Format("layout(%s) uniform %s\n{\n", screen->GetUniformLayoutString(bindingpoint).GetChars(), name); for (const auto &field : fields) { decl.AppendFormat("\t%s %s;\n", GetTypeStr(field.Type), field.Name); @@ -69,13 +75,14 @@ public: mBuffer = screen->CreateUniformBuffer(sizeof(T)); } - void Set(int index) + void Set(bool bind = true) { if (mBuffer != nullptr) mBuffer->SetData(&Values); - // Needs to be done in an API independent way! - glBindBufferBase(GL_UNIFORM_BUFFER, index, ((GLUniformBuffer*)mBuffer)->ID()); + // Let's hope this can be done better when things have moved further ahead. + // This really is not the best place to add something that depends on API behavior. + if (bind) mBuffer->Bind(bindingpoint); } T *operator->() { return &Values; } @@ -104,12 +111,12 @@ private: case UniformType::UVec2: return "uvec2"; case UniformType::UVec3: return "uvec3"; case UniformType::UVec4: return "uvec4"; + case UniformType::Mat4: return "mat4"; } } IUniformBuffer *mBuffer = nullptr; std::vector mFields; - int mBindingPoint; // Fixme: This needs to be known on init because Vulkan wants to put it into the block declaration. }; class FShaderProgram diff --git a/src/gl/shaders/gl_shadowmapshader.cpp b/src/gl/shaders/gl_shadowmapshader.cpp index 6541f59ac..0454801f5 100644 --- a/src/gl/shaders/gl_shadowmapshader.cpp +++ b/src/gl/shaders/gl_shadowmapshader.cpp @@ -35,7 +35,7 @@ void FShadowMapShader::Bind() mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/shadowmap"); mShader.SetAttribLocation(0, "PositionInProjection"); - mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); Uniforms.Init(); } mShader.Bind(); diff --git a/src/gl/shaders/gl_shadowmapshader.h b/src/gl/shaders/gl_shadowmapshader.h index a36ffabd0..7e6f26d74 100644 --- a/src/gl/shaders/gl_shadowmapshader.h +++ b/src/gl/shaders/gl_shadowmapshader.h @@ -25,7 +25,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: FShaderProgram mShader; diff --git a/src/gl/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp index 41c3c7297..ed50dd588 100644 --- a/src/gl/shaders/gl_tonemapshader.cpp +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -76,7 +76,7 @@ void FExposureExtractShader::Bind() mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/exposureextract"); mShader.SetAttribLocation(0, "PositionInProjection"); - mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); SceneTexture.Init(mShader, "SceneTexture"); Uniforms.Init(); } @@ -108,7 +108,7 @@ void FExposureCombineShader::Bind() mShader.SetFragDataLocation(0, "FragColor"); mShader.Link("shaders/glsl/exposurecombine"); mShader.SetAttribLocation(0, "PositionInProjection"); - mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms"); + mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms"); ExposureTexture.Init(mShader, "ExposureTexture"); Uniforms.Init(); } diff --git a/src/gl/shaders/gl_tonemapshader.h b/src/gl/shaders/gl_tonemapshader.h index 8240320b1..4902a8442 100644 --- a/src/gl/shaders/gl_tonemapshader.h +++ b/src/gl/shaders/gl_tonemapshader.h @@ -53,7 +53,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: FShaderProgram mShader; @@ -96,7 +96,7 @@ public: } }; - ShaderUniforms Uniforms; + ShaderUniforms Uniforms; private: FShaderProgram mShader; diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 3fc665931..ed1d6d381 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -118,7 +118,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader) screen->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), screen->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight() }; - shader.Uniforms.Set(POSTPROCESS_BINDINGPOINT); + shader.Uniforms.Set(); } // fixme: I don't know how to get absolute window position on Mac and Linux @@ -155,7 +155,7 @@ void CheckerInterleaved3D::Present() const + screen->mOutputLetterbox.height + 1 // +1 because of origin at bottom ) % 2; // because we want the top pixel offset, but gl_FragCoord.y is the bottom pixel offset - GLRenderer->mPresent3dCheckerShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + GLRenderer->mPresent3dCheckerShader->Uniforms.Set(); GLRenderer->RenderScreenQuad(); } @@ -193,7 +193,7 @@ void ColumnInterleaved3D::Present() const #endif // _WIN32 GLRenderer->mPresent3dColumnShader->Uniforms->WindowPositionParity = windowHOffset; - GLRenderer->mPresent3dColumnShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + GLRenderer->mPresent3dColumnShader->Uniforms.Set(); GLRenderer->RenderScreenQuad(); } @@ -220,7 +220,7 @@ void RowInterleaved3D::Present() const + screen->mOutputLetterbox.height + 1 // +1 because of origin at bottom ) % 2; - GLRenderer->mPresent3dColumnShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT); + GLRenderer->mPresent3dColumnShader->Uniforms.Set(); GLRenderer->RenderScreenQuad(); } diff --git a/src/hwrenderer/data/uniformbuffer.h b/src/hwrenderer/data/uniformbuffer.h index b3c914942..9aa078d3d 100644 --- a/src/hwrenderer/data/uniformbuffer.h +++ b/src/hwrenderer/data/uniformbuffer.h @@ -12,6 +12,7 @@ protected: public: virtual ~IUniformBuffer() {} virtual void SetData(const void *data) = 0; + virtual void Bind(int bindingpoint) = 0; // This is only here for OpenGL. Vulkan doesn't need the ability to bind this at run time. };