Reduce number of blits required in stereo 3D by tracking current eye.
This commit is contained in:
parent
43ec2cf8f2
commit
0fb940632a
5 changed files with 40 additions and 26 deletions
|
|
@ -532,7 +532,7 @@ void FGLRenderBuffers::BlitSceneToTexture()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FGLRenderBuffers::BlitToEyeTexture(int eye)
|
||||
void FGLRenderBuffers::BlitToEyeTexture(int eye, bool allowInvalidate)
|
||||
{
|
||||
CreateEyeBuffers(eye);
|
||||
|
||||
|
|
@ -540,7 +540,7 @@ void FGLRenderBuffers::BlitToEyeTexture(int eye)
|
|||
glBindFramebuffer(GL_DRAW_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)
|
||||
if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0 && allowInvalidate)
|
||||
{
|
||||
GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT };
|
||||
glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments);
|
||||
|
|
@ -552,7 +552,7 @@ void FGLRenderBuffers::BlitToEyeTexture(int eye)
|
|||
|
||||
void FGLRenderBuffers::BlitFromEyeTexture(int eye)
|
||||
{
|
||||
CreateEyeBuffers(eye);
|
||||
if (mEyeFBs.Size() <= unsigned(eye)) return;
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture].handle);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, mEyeFBs[eye].handle);
|
||||
|
|
@ -1002,4 +1002,17 @@ void FGLRenderBuffers::RenderEffect(const FString &name)
|
|||
FGLDebug::PopGroup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Store the current stereo 3D eye buffer, and Load the next one
|
||||
|
||||
int FGLRenderBuffers::NextEye(int eyeCount)
|
||||
{
|
||||
int nextEye = (mCurrentEye + 1) % eyeCount;
|
||||
if (nextEye == mCurrentEye) return mCurrentEye;
|
||||
BlitToEyeTexture(mCurrentEye);
|
||||
mCurrentEye = nextEye;
|
||||
BlitFromEyeTexture(mCurrentEye);
|
||||
return mCurrentEye;
|
||||
}
|
||||
|
||||
} // namespace OpenGLRenderer
|
||||
Loading…
Add table
Add a link
Reference in a new issue