mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
- change ShaderUniforms so that it just contains the uniform block and not the binding point
This commit is contained in:
parent
49073489e5
commit
9155b773cc
13 changed files with 59 additions and 41 deletions
|
@ -53,7 +53,7 @@ void FShadowMap::Update()
|
||||||
|
|
||||||
GLRenderer->mShadowMapShader->Bind();
|
GLRenderer->mShadowMapShader->Bind();
|
||||||
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
|
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
|
||||||
GLRenderer->mShadowMapShader->Uniforms.Set();
|
GLRenderer->mShadowMapShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, mLightList);
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, mLightList);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, mNodesBuffer);
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, mNodesBuffer);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, mLinesBuffer);
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, mLinesBuffer);
|
||||||
|
|
|
@ -125,7 +125,7 @@ void FGLRenderer::AmbientOccludeScene()
|
||||||
mLinearDepthShader->Uniforms->InverseDepthRangeB = 0.0f;
|
mLinearDepthShader->Uniforms->InverseDepthRangeB = 0.0f;
|
||||||
mLinearDepthShader->Uniforms->Scale = { sceneScaleX, sceneScaleY };
|
mLinearDepthShader->Uniforms->Scale = { sceneScaleX, sceneScaleY };
|
||||||
mLinearDepthShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY };
|
mLinearDepthShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY };
|
||||||
mLinearDepthShader->Uniforms.Set();
|
mLinearDepthShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
|
|
||||||
// Apply ambient occlusion
|
// Apply ambient occlusion
|
||||||
|
@ -148,7 +148,7 @@ void FGLRenderer::AmbientOccludeScene()
|
||||||
mSSAOShader->Uniforms->AOStrength = aoStrength;
|
mSSAOShader->Uniforms->AOStrength = aoStrength;
|
||||||
mSSAOShader->Uniforms->Scale = { sceneScaleX, sceneScaleY };
|
mSSAOShader->Uniforms->Scale = { sceneScaleX, sceneScaleY };
|
||||||
mSSAOShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY };
|
mSSAOShader->Uniforms->Offset = { sceneOffsetX, sceneOffsetY };
|
||||||
mSSAOShader->Uniforms.Set();
|
mSSAOShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
|
|
||||||
// Blur SSAO texture
|
// Blur SSAO texture
|
||||||
|
@ -159,7 +159,7 @@ void FGLRenderer::AmbientOccludeScene()
|
||||||
mDepthBlurShader->Bind(false);
|
mDepthBlurShader->Bind(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(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
|
|
||||||
mBuffers->AmbientFB1.Bind();
|
mBuffers->AmbientFB1.Bind();
|
||||||
|
@ -168,7 +168,7 @@ void FGLRenderer::AmbientOccludeScene()
|
||||||
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;
|
||||||
mDepthBlurShader->Uniforms[true].Set();
|
mDepthBlurShader->Uniforms[true].Set(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ void FGLRenderer::AmbientOccludeScene()
|
||||||
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 };
|
||||||
mSSAOCombineShader->Uniforms.Set();
|
mSSAOCombineShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
|
|
||||||
FGLDebug::PopGroup();
|
FGLDebug::PopGroup();
|
||||||
|
@ -225,7 +225,7 @@ void FGLRenderer::UpdateCameraExposure()
|
||||||
mExposureExtractShader->SceneTexture.Set(0);
|
mExposureExtractShader->SceneTexture.Set(0);
|
||||||
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(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
|
|
||||||
// Find the average value:
|
// Find the average value:
|
||||||
|
@ -262,7 +262,7 @@ void FGLRenderer::UpdateCameraExposure()
|
||||||
mExposureCombineShader->Uniforms->ExposureMin = gl_exposure_min;
|
mExposureCombineShader->Uniforms->ExposureMin = gl_exposure_min;
|
||||||
mExposureCombineShader->Uniforms->ExposureScale = gl_exposure_scale;
|
mExposureCombineShader->Uniforms->ExposureScale = gl_exposure_scale;
|
||||||
mExposureCombineShader->Uniforms->ExposureSpeed = gl_exposure_speed;
|
mExposureCombineShader->Uniforms->ExposureSpeed = gl_exposure_speed;
|
||||||
mExposureCombineShader->Uniforms.Set();
|
mExposureCombineShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ void FGLRenderer::BloomScene(int fixedcm)
|
||||||
mBloomExtractShader->ExposureTexture.Set(1);
|
mBloomExtractShader->ExposureTexture.Set(1);
|
||||||
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(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
|
|
||||||
// Blur and downscale:
|
// 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->MapStart = { scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f };
|
||||||
mColormapShader->Uniforms->MapRange = m;
|
mColormapShader->Uniforms->MapRange = m;
|
||||||
mColormapShader->Uniforms.Set();
|
mColormapShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
|
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
mBuffers->NextTexture();
|
mBuffers->NextTexture();
|
||||||
|
@ -590,7 +590,7 @@ void FGLRenderer::LensDistortScene()
|
||||||
mLensShader->Uniforms->Scale = scale;
|
mLensShader->Uniforms->Scale = scale;
|
||||||
mLensShader->Uniforms->LensDistortionCoefficient = k;
|
mLensShader->Uniforms->LensDistortionCoefficient = k;
|
||||||
mLensShader->Uniforms->CubicDistortionValue = kcube;
|
mLensShader->Uniforms->CubicDistortionValue = kcube;
|
||||||
mLensShader->Uniforms.Set();
|
mLensShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
mBuffers->NextTexture();
|
mBuffers->NextTexture();
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ void FGLRenderer::ApplyFXAA()
|
||||||
mFXAAShader->Bind();
|
mFXAAShader->Bind();
|
||||||
mFXAAShader->InputTexture.Set(0);
|
mFXAAShader->InputTexture.Set(0);
|
||||||
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(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
mBuffers->NextTexture();
|
mBuffers->NextTexture();
|
||||||
|
|
||||||
|
@ -745,7 +745,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
|
||||||
mPresentShader->Uniforms->GrayFormula = static_cast<int>(gl_satformula);
|
mPresentShader->Uniforms->GrayFormula = static_cast<int>(gl_satformula);
|
||||||
}
|
}
|
||||||
mPresentShader->Uniforms->Scale = { screen->mScreenViewport.width / (float)mBuffers->GetWidth(), screen->mScreenViewport.height / (float)mBuffers->GetHeight() };
|
mPresentShader->Uniforms->Scale = { screen->mScreenViewport.width / (float)mBuffers->GetWidth(), screen->mScreenViewport.height / (float)mBuffers->GetHeight() };
|
||||||
mPresentShader->Uniforms.Set();
|
mPresentShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
RenderScreenQuad();
|
RenderScreenQuad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,10 @@ void FLinearDepthShader::Bind()
|
||||||
mShader->SetFragDataLocation(0, "FragColor");
|
mShader->SetFragDataLocation(0, "FragColor");
|
||||||
mShader->Link("shaders/glsl/lineardepth");
|
mShader->Link("shaders/glsl/lineardepth");
|
||||||
mShader->SetAttribLocation(0, "PositionInProjection");
|
mShader->SetAttribLocation(0, "PositionInProjection");
|
||||||
|
mShader->SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
DepthTexture.Init(*mShader, "DepthTexture");
|
DepthTexture.Init(*mShader, "DepthTexture");
|
||||||
ColorTexture.Init(*mShader, "ColorTexture");
|
ColorTexture.Init(*mShader, "ColorTexture");
|
||||||
Uniforms.Init(*mShader);
|
Uniforms.Init();
|
||||||
mMultisample = multisample;
|
mMultisample = multisample;
|
||||||
}
|
}
|
||||||
mShader->Bind();
|
mShader->Bind();
|
||||||
|
@ -67,10 +68,11 @@ void FSSAOShader::Bind()
|
||||||
mShader->SetFragDataLocation(0, "FragColor");
|
mShader->SetFragDataLocation(0, "FragColor");
|
||||||
mShader->Link("shaders/glsl/ssao");
|
mShader->Link("shaders/glsl/ssao");
|
||||||
mShader->SetAttribLocation(0, "PositionInProjection");
|
mShader->SetAttribLocation(0, "PositionInProjection");
|
||||||
|
mShader->SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
DepthTexture.Init(*mShader, "DepthTexture");
|
DepthTexture.Init(*mShader, "DepthTexture");
|
||||||
NormalTexture.Init(*mShader, "NormalTexture");
|
NormalTexture.Init(*mShader, "NormalTexture");
|
||||||
RandomTexture.Init(*mShader, "RandomTexture");
|
RandomTexture.Init(*mShader, "RandomTexture");
|
||||||
Uniforms.Init(*mShader);
|
Uniforms.Init();
|
||||||
mMultisample = multisample;
|
mMultisample = multisample;
|
||||||
}
|
}
|
||||||
mShader->Bind();
|
mShader->Bind();
|
||||||
|
@ -117,8 +119,9 @@ void FDepthBlurShader::Bind(bool vertical)
|
||||||
shader.SetFragDataLocation(0, "FragColor");
|
shader.SetFragDataLocation(0, "FragColor");
|
||||||
shader.Link("shaders/glsl/depthblur");
|
shader.Link("shaders/glsl/depthblur");
|
||||||
shader.SetAttribLocation(0, "PositionInProjection");
|
shader.SetAttribLocation(0, "PositionInProjection");
|
||||||
|
shader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
AODepthTexture[vertical].Init(shader, "AODepthTexture");
|
AODepthTexture[vertical].Init(shader, "AODepthTexture");
|
||||||
Uniforms[vertical].Init(shader);
|
Uniforms[vertical].Init();
|
||||||
}
|
}
|
||||||
shader.Bind();
|
shader.Bind();
|
||||||
}
|
}
|
||||||
|
@ -141,9 +144,10 @@ void FSSAOCombineShader::Bind()
|
||||||
mShader->SetFragDataLocation(0, "FragColor");
|
mShader->SetFragDataLocation(0, "FragColor");
|
||||||
mShader->Link("shaders/glsl/ssaocombine");
|
mShader->Link("shaders/glsl/ssaocombine");
|
||||||
mShader->SetAttribLocation(0, "PositionInProjection");
|
mShader->SetAttribLocation(0, "PositionInProjection");
|
||||||
|
mShader->SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
AODepthTexture.Init(*mShader, "AODepthTexture");
|
AODepthTexture.Init(*mShader, "AODepthTexture");
|
||||||
SceneFogTexture.Init(*mShader, "SceneFogTexture");
|
SceneFogTexture.Init(*mShader, "SceneFogTexture");
|
||||||
Uniforms.Init(*mShader);
|
Uniforms.Init();
|
||||||
mMultisample = multisample;
|
mMultisample = multisample;
|
||||||
}
|
}
|
||||||
mShader->Bind();
|
mShader->Bind();
|
||||||
|
|
|
@ -40,9 +40,10 @@ void FBloomExtractShader::Bind()
|
||||||
mShader.SetFragDataLocation(0, "FragColor");
|
mShader.SetFragDataLocation(0, "FragColor");
|
||||||
mShader.Link("shaders/glsl/bloomextract");
|
mShader.Link("shaders/glsl/bloomextract");
|
||||||
mShader.SetAttribLocation(0, "PositionInProjection");
|
mShader.SetAttribLocation(0, "PositionInProjection");
|
||||||
|
mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
SceneTexture.Init(mShader, "SceneTexture");
|
SceneTexture.Init(mShader, "SceneTexture");
|
||||||
ExposureTexture.Init(mShader, "ExposureTexture");
|
ExposureTexture.Init(mShader, "ExposureTexture");
|
||||||
Uniforms.Init(mShader);
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind();
|
mShader.Bind();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ void FColormapShader::Bind()
|
||||||
shader.SetFragDataLocation(0, "FragColor");
|
shader.SetFragDataLocation(0, "FragColor");
|
||||||
shader.Link("shaders/glsl/colormap");
|
shader.Link("shaders/glsl/colormap");
|
||||||
shader.SetAttribLocation(0, "PositionInProjection");
|
shader.SetAttribLocation(0, "PositionInProjection");
|
||||||
Uniforms.Init(shader);
|
shader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
shader.Bind();
|
shader.Bind();
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,9 @@ void FFXAAShader::Bind()
|
||||||
shader.SetFragDataLocation(0, "FragColor");
|
shader.SetFragDataLocation(0, "FragColor");
|
||||||
shader.Link("shaders/glsl/fxaa");
|
shader.Link("shaders/glsl/fxaa");
|
||||||
shader.SetAttribLocation(0, "PositionInProjection");
|
shader.SetAttribLocation(0, "PositionInProjection");
|
||||||
|
shader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
InputTexture.Init(shader, "InputTexture");
|
InputTexture.Init(shader, "InputTexture");
|
||||||
Uniforms.Init(shader);
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
shader.Bind();
|
shader.Bind();
|
||||||
|
|
|
@ -40,8 +40,9 @@ void FLensShader::Bind()
|
||||||
mShader.SetFragDataLocation(0, "FragColor");
|
mShader.SetFragDataLocation(0, "FragColor");
|
||||||
mShader.Link("shaders/glsl/lensdistortion");
|
mShader.Link("shaders/glsl/lensdistortion");
|
||||||
mShader.SetAttribLocation(0, "PositionInProjection");
|
mShader.SetAttribLocation(0, "PositionInProjection");
|
||||||
|
mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
InputTexture.Init(mShader, "InputTexture");
|
InputTexture.Init(mShader, "InputTexture");
|
||||||
Uniforms.Init(mShader);
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind();
|
mShader.Bind();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
|
||||||
mShader.Link(program_name);
|
mShader.Link(program_name);
|
||||||
mShader.SetAttribLocation(0, "PositionInProjection");
|
mShader.SetAttribLocation(0, "PositionInProjection");
|
||||||
mShader.SetAttribLocation(1, "UV");
|
mShader.SetAttribLocation(1, "UV");
|
||||||
Uniforms.Init(mShader);
|
mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FPresentShader::Bind()
|
void FPresentShader::Bind()
|
||||||
|
|
|
@ -159,6 +159,19 @@ void FShaderProgram::SetAttribLocation(int index, const char *name)
|
||||||
glBindAttribLocation(mProgram, index, name);
|
glBindAttribLocation(mProgram, index, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Set uniform buffer location
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FShaderProgram::SetUniformBufferLocation(int index, const char *name)
|
||||||
|
{
|
||||||
|
GLuint uniformBlockIndex = glGetUniformBlockIndex(mProgram, name);
|
||||||
|
if (uniformBlockIndex != GL_INVALID_INDEX)
|
||||||
|
glUniformBlockBinding(mProgram, uniformBlockIndex, index);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Makes the shader the active program
|
// Makes the shader the active program
|
||||||
|
|
|
@ -47,7 +47,6 @@ public:
|
||||||
|
|
||||||
FString CreateDeclaration(const char *name, const std::vector<UniformFieldDesc> &fields)
|
FString CreateDeclaration(const char *name, const std::vector<UniformFieldDesc> &fields)
|
||||||
{
|
{
|
||||||
mName = name;
|
|
||||||
mFields = fields;
|
mFields = fields;
|
||||||
|
|
||||||
FString decl;
|
FString decl;
|
||||||
|
@ -61,23 +60,18 @@ public:
|
||||||
return decl;
|
return decl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(GLuint hShader, int index = POSTPROCESS_BINDINGPOINT)
|
void Init()
|
||||||
{
|
{
|
||||||
GLuint uniformBlockIndex = glGetUniformBlockIndex(hShader, mName);
|
if (!mBufferHandle)
|
||||||
if (uniformBlockIndex != GL_INVALID_INDEX)
|
|
||||||
{
|
|
||||||
glUniformBlockBinding(hShader, uniformBlockIndex, index);
|
|
||||||
glGenBuffers(1, (GLuint*)&mBufferHandle);
|
glGenBuffers(1, (GLuint*)&mBufferHandle);
|
||||||
mIndex = index;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set()
|
void Set(int index)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, mBufferHandle);
|
glBindBuffer(GL_UNIFORM_BUFFER, mBufferHandle);
|
||||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(T), &Values, GL_STREAM_DRAW);
|
glBufferData(GL_UNIFORM_BUFFER, sizeof(T), &Values, GL_STREAM_DRAW);
|
||||||
|
|
||||||
glBindBufferBase(GL_UNIFORM_BUFFER, mIndex, mBufferHandle);
|
glBindBufferBase(GL_UNIFORM_BUFFER, index, mBufferHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
T *operator->() { return &Values; }
|
T *operator->() { return &Values; }
|
||||||
|
@ -109,8 +103,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *mName = nullptr;
|
|
||||||
int mIndex = -1;
|
|
||||||
GLuint mBufferHandle = 0;
|
GLuint mBufferHandle = 0;
|
||||||
std::vector<UniformFieldDesc> mFields;
|
std::vector<UniformFieldDesc> mFields;
|
||||||
std::vector<int> mUniformLocations;
|
std::vector<int> mUniformLocations;
|
||||||
|
@ -134,6 +126,7 @@ public:
|
||||||
void SetFragDataLocation(int index, const char *name);
|
void SetFragDataLocation(int index, const char *name);
|
||||||
void Link(const char *name);
|
void Link(const char *name);
|
||||||
void SetAttribLocation(int index, const char *name);
|
void SetAttribLocation(int index, const char *name);
|
||||||
|
void SetUniformBufferLocation(int index, const char *name);
|
||||||
void Bind();
|
void Bind();
|
||||||
|
|
||||||
operator GLuint() const { return mProgram; }
|
operator GLuint() const { return mProgram; }
|
||||||
|
|
|
@ -35,7 +35,8 @@ void FShadowMapShader::Bind()
|
||||||
mShader.SetFragDataLocation(0, "FragColor");
|
mShader.SetFragDataLocation(0, "FragColor");
|
||||||
mShader.Link("shaders/glsl/shadowmap");
|
mShader.Link("shaders/glsl/shadowmap");
|
||||||
mShader.SetAttribLocation(0, "PositionInProjection");
|
mShader.SetAttribLocation(0, "PositionInProjection");
|
||||||
Uniforms.Init(mShader);
|
mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind();
|
mShader.Bind();
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,9 @@ void FExposureExtractShader::Bind()
|
||||||
mShader.SetFragDataLocation(0, "FragColor");
|
mShader.SetFragDataLocation(0, "FragColor");
|
||||||
mShader.Link("shaders/glsl/exposureextract");
|
mShader.Link("shaders/glsl/exposureextract");
|
||||||
mShader.SetAttribLocation(0, "PositionInProjection");
|
mShader.SetAttribLocation(0, "PositionInProjection");
|
||||||
|
mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
SceneTexture.Init(mShader, "SceneTexture");
|
SceneTexture.Init(mShader, "SceneTexture");
|
||||||
Uniforms.Init(mShader);
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind();
|
mShader.Bind();
|
||||||
}
|
}
|
||||||
|
@ -107,8 +108,9 @@ void FExposureCombineShader::Bind()
|
||||||
mShader.SetFragDataLocation(0, "FragColor");
|
mShader.SetFragDataLocation(0, "FragColor");
|
||||||
mShader.Link("shaders/glsl/exposurecombine");
|
mShader.Link("shaders/glsl/exposurecombine");
|
||||||
mShader.SetAttribLocation(0, "PositionInProjection");
|
mShader.SetAttribLocation(0, "PositionInProjection");
|
||||||
|
mShader.SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
ExposureTexture.Init(mShader, "ExposureTexture");
|
ExposureTexture.Init(mShader, "ExposureTexture");
|
||||||
Uniforms.Init(mShader);
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind();
|
mShader.Bind();
|
||||||
}
|
}
|
|
@ -118,7 +118,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader)
|
||||||
screen->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
|
screen->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
|
||||||
screen->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()
|
screen->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()
|
||||||
};
|
};
|
||||||
shader.Uniforms.Set();
|
shader.Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixme: I don't know how to get absolute window position on Mac and Linux
|
// 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
|
+ 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
|
) % 2; // because we want the top pixel offset, but gl_FragCoord.y is the bottom pixel offset
|
||||||
|
|
||||||
GLRenderer->mPresent3dCheckerShader->Uniforms.Set();
|
GLRenderer->mPresent3dCheckerShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
GLRenderer->RenderScreenQuad();
|
GLRenderer->RenderScreenQuad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ void ColumnInterleaved3D::Present() const
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
GLRenderer->mPresent3dColumnShader->Uniforms->WindowPositionParity = windowHOffset;
|
GLRenderer->mPresent3dColumnShader->Uniforms->WindowPositionParity = windowHOffset;
|
||||||
GLRenderer->mPresent3dColumnShader->Uniforms.Set();
|
GLRenderer->mPresent3dColumnShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
|
|
||||||
GLRenderer->RenderScreenQuad();
|
GLRenderer->RenderScreenQuad();
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ void RowInterleaved3D::Present() const
|
||||||
+ screen->mOutputLetterbox.height + 1 // +1 because of origin at bottom
|
+ screen->mOutputLetterbox.height + 1 // +1 because of origin at bottom
|
||||||
) % 2;
|
) % 2;
|
||||||
|
|
||||||
GLRenderer->mPresent3dColumnShader->Uniforms.Set();
|
GLRenderer->mPresent3dColumnShader->Uniforms.Set(POSTPROCESS_BINDINGPOINT);
|
||||||
GLRenderer->RenderScreenQuad();
|
GLRenderer->RenderScreenQuad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue