Implementation using no additional frame buffers

This commit is contained in:
Simon 2023-02-13 11:26:44 +00:00
parent 578f7cfbcd
commit 06a99dbafb
8 changed files with 46 additions and 21 deletions

View file

@ -75,6 +75,8 @@ extern bool vid_hdr_active;
void DrawVersionString (); void DrawVersionString ();
void TBXR_prepareEyeBuffer(int eye );
namespace OpenGLRenderer namespace OpenGLRenderer
{ {
FGLRenderer *GLRenderer; FGLRenderer *GLRenderer;
@ -450,6 +452,7 @@ void OpenGLFrameBuffer::AmbientOccludeScene(float m5)
void OpenGLFrameBuffer::FirstEye() void OpenGLFrameBuffer::FirstEye()
{ {
GLRenderer->mBuffers->CurrentEye() = 0; // always begin at zero, in case eye count changed GLRenderer->mBuffers->CurrentEye() = 0; // always begin at zero, in case eye count changed
TBXR_prepareEyeBuffer(0);
} }
void OpenGLFrameBuffer::NextEye(int eyecount) void OpenGLFrameBuffer::NextEye(int eyecount)
@ -590,7 +593,9 @@ void OpenGLFrameBuffer::Draw2D()
void OpenGLFrameBuffer::PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) void OpenGLFrameBuffer::PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D)
{ {
#ifndef __MOBILE__
if (!swscene) GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture if (!swscene) GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture
#endif
GLRenderer->PostProcessScene(fixedcm, flash, afterBloomDrawEndScene2D); GLRenderer->PostProcessScene(fixedcm, flash, afterBloomDrawEndScene2D);
} }

View file

@ -56,6 +56,11 @@ void FGLRenderer::RenderScreenQuad()
void FGLRenderer::PostProcessScene(int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) void FGLRenderer::PostProcessScene(int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D)
{ {
#ifdef __MOBILE__
if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D();
return;
#endif
int sceneWidth = mBuffers->GetSceneWidth(); int sceneWidth = mBuffers->GetSceneWidth();
int sceneHeight = mBuffers->GetSceneHeight(); int sceneHeight = mBuffers->GetSceneHeight();
@ -84,11 +89,15 @@ void FGLRenderer::AmbientOccludeScene(float m5)
void FGLRenderer::BlurScene(float gameinfobluramount) void FGLRenderer::BlurScene(float gameinfobluramount)
{ {
if (gameinfobluramount == 0)
return;
int sceneWidth = mBuffers->GetSceneWidth(); int sceneWidth = mBuffers->GetSceneWidth();
int sceneHeight = mBuffers->GetSceneHeight(); int sceneHeight = mBuffers->GetSceneHeight();
GLPPRenderState renderstate(mBuffers); GLPPRenderState renderstate(mBuffers);
screen->FirstEye();
auto vrmode = VRMode::GetVRMode(true); auto vrmode = VRMode::GetVRMode(true);
int eyeCount = vrmode->mEyeCount; int eyeCount = vrmode->mEyeCount;
for (int i = 0; i < eyeCount; ++i) for (int i = 0; i < eyeCount; ++i)
@ -118,6 +127,7 @@ void FGLRenderer::Flush()
} }
else else
{ {
screen->FirstEye();
// Render 2D to eye textures // Render 2D to eye textures
int eyeCount = vrmode->mEyeCount; int eyeCount = vrmode->mEyeCount;
for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix) for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix)

View file

@ -36,6 +36,8 @@
EXTERN_CVAR(Int, gl_debug_level) EXTERN_CVAR(Int, gl_debug_level)
CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
void TBXR_prepareEyeBuffer(int eye );
namespace OpenGLRenderer namespace OpenGLRenderer
{ {
@ -672,7 +674,9 @@ void FGLRenderBuffers::CreateShadowMap()
void FGLRenderBuffers::BindSceneFB(bool sceneData) void FGLRenderBuffers::BindSceneFB(bool sceneData)
{ {
#ifndef __MOBILE__
glBindFramebuffer(GL_FRAMEBUFFER, sceneData ? mSceneDataFB.handle : mSceneFB.handle); glBindFramebuffer(GL_FRAMEBUFFER, sceneData ? mSceneDataFB.handle : mSceneFB.handle);
#endif
} }
//========================================================================== //==========================================================================
@ -754,7 +758,9 @@ void FGLRenderBuffers::BindCurrentTexture(int index, int filter, int wrap)
void FGLRenderBuffers::BindCurrentFB() void FGLRenderBuffers::BindCurrentFB()
{ {
#ifndef __MOBILE__
mPipelineFB[mCurrentPipelineTexture].Bind(); mPipelineFB[mCurrentPipelineTexture].Bind();
#endif
} }
//========================================================================== //==========================================================================
@ -765,8 +771,10 @@ void FGLRenderBuffers::BindCurrentFB()
void FGLRenderBuffers::BindNextFB() void FGLRenderBuffers::BindNextFB()
{ {
#ifndef __MOBILE__
int out = (mCurrentPipelineTexture + 1) % NumPipelineTextures; int out = (mCurrentPipelineTexture + 1) % NumPipelineTextures;
mPipelineFB[out].Bind(); mPipelineFB[out].Bind();
#endif
} }
//========================================================================== //==========================================================================
@ -788,7 +796,9 @@ void FGLRenderBuffers::NextTexture()
void FGLRenderBuffers::BindOutputFB() void FGLRenderBuffers::BindOutputFB()
{ {
#ifndef __MOBILE__
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
#endif
} }
//========================================================================== //==========================================================================
@ -999,12 +1009,17 @@ void GLPPRenderState::PopGroup()
int FGLRenderBuffers::NextEye(int eyeCount) int FGLRenderBuffers::NextEye(int eyeCount)
{ {
#ifndef __MOBILE__
int nextEye = (mCurrentEye + 1) % eyeCount; int nextEye = (mCurrentEye + 1) % eyeCount;
if (nextEye == mCurrentEye) return mCurrentEye; if (nextEye == mCurrentEye) return mCurrentEye;
BlitToEyeTexture(mCurrentEye); BlitToEyeTexture(mCurrentEye);
mCurrentEye = nextEye; mCurrentEye = nextEye;
BlitFromEyeTexture(mCurrentEye); BlitFromEyeTexture(mCurrentEye);
return mCurrentEye; return mCurrentEye;
#else
TBXR_prepareEyeBuffer(1);
return 1;
#endif
} }
} // namespace OpenGLRenderer } // namespace OpenGLRenderer

View file

@ -48,7 +48,6 @@
bool TBXR_IsFrameSetup(); bool TBXR_IsFrameSetup();
void TBXR_prepareEyeBuffer(int eye ); void TBXR_prepareEyeBuffer(int eye );
void TBXR_finishEyeBuffer(int eye );
void TBXR_submitFrame(); void TBXR_submitFrame();
EXTERN_CVAR(Int, vr_mode) EXTERN_CVAR(Int, vr_mode)
@ -381,22 +380,6 @@ bool FGLRenderer::QuadStereoCheckInitialRenderContextState()
void FGLRenderer::PresentOpenXR() void FGLRenderer::PresentOpenXR()
{ {
if (!TBXR_IsFrameSetup())
{
return;
}
for (int eye = 0; eye < 2; ++eye)
{
TBXR_prepareEyeBuffer(eye);
ClearBorders();
mBuffers->BindEyeTexture(eye, 0);
DrawPresentTexture(screen->mOutputLetterbox, true);
TBXR_finishEyeBuffer(eye);
}
TBXR_submitFrame(); TBXR_submitFrame();
} }

View file

@ -255,7 +255,7 @@ VSMatrix VREyeInfo::GetHUDProjection(int width, int height) const
VSMatrix new_projection; VSMatrix new_projection;
new_projection.loadIdentity(); new_projection.loadIdentity();
float stereo_separation = (vr_ipd * 0.5) * vr_hunits_per_meter() * vr_hud_stereo * (getEye() == 1 ? 1.0 : -1.0); float stereo_separation = getStereoSeparation(vr_hud_stereo);
new_projection.translate(stereo_separation, 0, 0); new_projection.translate(stereo_separation, 0, 0);
// doom_units from meters // doom_units from meters
@ -296,6 +296,12 @@ VSMatrix VREyeInfo::GetHUDProjection(int width, int height) const
return new_projection; return new_projection;
} }
float VREyeInfo::getStereoSeparation(double stereoLevel) const
{
float stereo_separation = (vr_ipd * 0.5) * vr_hunits_per_meter() * stereoLevel * (getEye() == 1 ? -1.0 : 1.0);
return stereo_separation;
}
VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const
{ {
// now render the main view // now render the main view
@ -314,8 +320,7 @@ VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const
new_projection.loadIdentity(); new_projection.loadIdentity();
float weapon_stereo_effect = 2.8f; float weapon_stereo_effect = 2.8f;
float stereo_separation = (vr_ipd * 0.5) * vr_hunits_per_meter() * weapon_stereo_effect * (getEye() == 1 ? -1.0 : 1.0); new_projection.translate(getStereoSeparation(weapon_stereo_effect), 0, 0);
new_projection.translate(stereo_separation, 0, 0);
// doom_units from meters // doom_units from meters
new_projection.scale( new_projection.scale(

View file

@ -36,6 +36,8 @@ struct VREyeInfo
private: private:
float getShift() const; float getShift() const;
int getEye() const; int getEye() const;
float getStereoSeparation(double stereoLevel) const;
}; };
struct VRMode struct VRMode

View file

@ -68,7 +68,7 @@ CUSTOM_CVAR(Int, gl_ssao, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
self = 0; self = 0;
} }
CUSTOM_CVAR(Int, gl_ssao_portals, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CUSTOM_CVAR(Int, gl_ssao_portals, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{ {
if (self < 0) if (self < 0)
self = 0; self = 0;

View file

@ -136,7 +136,12 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
auto vrmode = VRMode::GetVRMode(mainview && toscreen); auto vrmode = VRMode::GetVRMode(mainview && toscreen);
const int eyeCount = vrmode->mEyeCount; const int eyeCount = vrmode->mEyeCount;
screen->FirstEye(); screen->FirstEye();
#ifndef __MOBILE__
hw_int_useindexedcolortextures = eyeCount > 1? false : *hw_useindexedcolortextures; hw_int_useindexedcolortextures = eyeCount > 1? false : *hw_useindexedcolortextures;
#else
hw_int_useindexedcolortextures = false;
#endif
for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix) for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix)
{ {