Merge branch 'hrydgard:master' into feature_openxr_vulkan

This commit is contained in:
Luboš Vonásek 2022-09-15 00:23:36 +02:00 committed by GitHub
commit 6c50fc5b35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 17 deletions

View File

@ -235,11 +235,29 @@ bool GLRenderManager::ThreadFrame() {
INFO_LOG(G3D, "Running first frame (%d)", threadFrame_);
firstFrame = false;
}
// Start of an OpenXR frame. This updates user's head pose and VR timestamps.
// For fluent rendering, delay between StartVRRender and FinishVRRender must be very short.
if (IsVRBuild() && !vrRenderStarted) {
if (StartVRRender()) {
vrRenderStarted = true;
} else {
return false;
}
}
// Render the scene.
Run(threadFrame_);
VLOG("PULL: Finished frame %d", threadFrame_);
} while (!nextFrame);
// Post OpenXR frame on a screen.
if (IsVRBuild() && vrRenderStarted) {
FinishVRRender();
vrRenderStarted = false;
}
return true;
}
@ -579,17 +597,14 @@ void GLRenderManager::Run(int frame) {
}
if (IsVRBuild()) {
if (PreVRRender()) {
int passes = 1;
if (!IsMultiviewSupported() && g_Config.bEnableStereo) {
passes = 2;
}
for (int i = 0; i < passes; i++) {
PreVRFrameRender(i);
queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, i < passes - 1);
PostVRFrameRender();
}
PostVRRender();
int passes = 1;
if (!IsMultiviewSupported() && g_Config.bEnableStereo) {
passes = 2;
}
for (int i = 0; i < passes; i++) {
PreVRFrameRender(i);
queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, i < passes - 1);
PostVRFrameRender();
}
} else {
queueRunner_.RunSteps(stepsOnThread, skipGLCalls_);

View File

@ -1041,6 +1041,7 @@ private:
bool nextFrame = false;
bool firstFrame = true;
bool vrRenderStarted = false;
GLDeleter deleter_;
bool skipGLCalls_ = false;

View File

@ -238,7 +238,7 @@ void BindVRFramebuffer() {
VR_BindFramebuffer(VR_GetEngine());
}
bool PreVRRender() {
bool StartVRRender() {
if (!VR_GetConfig(VR_CONFIG_VIEWPORT_VALID)) {
VR_InitRenderer(VR_GetEngine(), IsMultiviewSupported());
VR_SetConfig(VR_CONFIG_VIEWPORT_VALID, true);
@ -263,7 +263,7 @@ bool PreVRRender() {
return false;
}
void PostVRRender() {
void FinishVRRender() {
VR_FinishFrame(VR_GetEngine());
}

View File

@ -15,8 +15,8 @@ void UpdateVRScreenKey(const KeyInput &key);
// VR rendering integration
void BindVRFramebuffer();
bool PreVRRender();
void PostVRRender();
bool StartVRRender();
void FinishVRRender();
void PreVRFrameRender(int fboIndex);
void PostVRFrameRender();
int GetVRFBOIndex();
@ -38,8 +38,8 @@ inline void UpdateVRScreenKey(const KeyInput &key) {}
// VR rendering integration
inline void BindVRFramebuffer() {}
inline bool PreVRRender() { return false; }
inline void PostVRRender() {}
inline bool StartVRRender() { return false; }
inline void FinishVRRender() {}
inline void PreVRFrameRender(int fboIndex) {}
inline void PostVRFrameRender() {}
inline int GetVRFBOIndex() { return 0; }