Enable menu blur in stereo 3d.

Use more blitting to avoid confusing framebuffer state management in stereo 3D.
This commit is contained in:
Christopher Bruns 2019-02-26 21:15:13 -08:00 committed by Christoph Oelckers
parent e719b9cf00
commit 8becc0e78d
4 changed files with 38 additions and 17 deletions

View file

@ -120,7 +120,22 @@ void FGLRenderer::BlurScene(float gameinfobluramount)
mBuffers->CompileEffectShaders();
mBuffers->UpdateEffectTextures();
auto vrmode = VRMode::GetVRMode(true);
if (vrmode->mEyeCount == 1)
{
mBuffers->RenderEffect("BlurScene");
}
else
{
for (int eye_ix = 0; eye_ix < vrmode->mEyeCount; ++eye_ix)
{
FGLDebug::PushGroup("EyeBlur");
mBuffers->BlitFromEyeTexture(eye_ix);
mBuffers->RenderEffect("BlurScene");
mBuffers->BlitToEyeTexture(eye_ix);
FGLDebug::PopGroup();
}
}
}
void FGLRenderer::ClearTonemapPalette()
@ -137,9 +152,6 @@ void FGLRenderer::ClearTonemapPalette()
void FGLRenderer::Flush()
{
auto vrmode = VRMode::GetVRMode(true);
const auto &mSceneViewport = screen->mSceneViewport;
const auto &mScreenViewport = screen->mScreenViewport;
if (vrmode->mEyeCount == 1)
{
CopyToBackbuffer(nullptr, true);
@ -150,10 +162,9 @@ void FGLRenderer::Flush()
for (int eye_ix = 0; eye_ix < vrmode->mEyeCount; ++eye_ix)
{
FGLDebug::PushGroup("Eye2D");
mBuffers->BindEyeFB(eye_ix);
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
mBuffers->BlitFromEyeTexture(eye_ix);
screen->Draw2D();
mBuffers->BlitToEyeTexture(eye_ix);
FGLDebug::PopGroup();
}
screen->Clear2D();

View file

@ -550,6 +550,24 @@ void FGLRenderBuffers::BlitToEyeTexture(int eye)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
void FGLRenderBuffers::BlitFromEyeTexture(int eye)
{
CreateEyeBuffers(eye);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture].handle);
glBindFramebuffer(GL_READ_FRAMEBUFFER, mEyeFBs[eye].handle);
glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0)
{
GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT };
glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments);
}
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
void FGLRenderBuffers::BindEyeTexture(int eye, int texunit)
{
CreateEyeBuffers(eye);
@ -557,12 +575,6 @@ void FGLRenderBuffers::BindEyeTexture(int eye, int texunit)
glBindTexture(GL_TEXTURE_2D, mEyeTextures[eye].handle);
}
void FGLRenderBuffers::BindEyeFB(int eye, bool readBuffer)
{
CreateEyeBuffers(eye);
glBindFramebuffer(readBuffer ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER, mEyeFBs[eye].handle);
}
void FGLRenderBuffers::BindDitherTexture(int texunit)
{
if (!mDitherTexture)

View file

@ -88,8 +88,8 @@ public:
void BindOutputFB();
void BlitToEyeTexture(int eye);
void BlitFromEyeTexture(int eye);
void BindEyeTexture(int eye, int texunit);
void BindEyeFB(int eye, bool readBuffer = false);
void BindDitherTexture(int texunit);

View file

@ -448,9 +448,7 @@ void OpenGLFrameBuffer::Draw2D()
if (GLRenderer != nullptr)
{
FGLDebug::PushGroup("Draw2D");
if (VRMode::GetVRMode(true)->mEyeCount == 1)
GLRenderer->mBuffers->BindCurrentFB();
::Draw2D(&m2DDrawer, gl_RenderState);
FGLDebug::PopGroup();
}