mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 01:15:31 +00:00
Tightened prediction point
This commit is contained in:
parent
3984e2030a
commit
fea964a6f3
3 changed files with 19 additions and 12 deletions
|
@ -262,7 +262,7 @@ namespace MWVR
|
||||||
// In some implementations xrWaitFrame might not return immediately when it should.
|
// In some implementations xrWaitFrame might not return immediately when it should.
|
||||||
// So i let it wait in a separate thread. xrBeginFrame() should wait on xrWaitFrame()
|
// So i let it wait in a separate thread. xrBeginFrame() should wait on xrWaitFrame()
|
||||||
// and xrWaitFrame() doesn't happen again until xrEndFrame() so synchronization is not necessary.
|
// and xrWaitFrame() doesn't happen again until xrEndFrame() so synchronization is not necessary.
|
||||||
std::thread([this]() {
|
//std::thread([this]() {
|
||||||
static std::mutex waitFrameMutex;
|
static std::mutex waitFrameMutex;
|
||||||
std::unique_lock<std::mutex> lock(waitFrameMutex);
|
std::unique_lock<std::mutex> lock(waitFrameMutex);
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ namespace MWVR
|
||||||
|
|
||||||
mTimeKeeper.progressToNextFrame(frameState);
|
mTimeKeeper.progressToNextFrame(frameState);
|
||||||
|
|
||||||
}).detach();
|
//}).detach();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ namespace MWVR
|
||||||
beginInfo.primaryViewConfigurationType = mViewConfigType;
|
beginInfo.primaryViewConfigurationType = mViewConfigType;
|
||||||
CHECK_XRCMD(xrBeginSession(mSession, &beginInfo));
|
CHECK_XRCMD(xrBeginSession(mSession, &beginInfo));
|
||||||
mSessionRunning = true;
|
mSessionRunning = true;
|
||||||
waitFrame();
|
//waitFrame();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XR_SESSION_STATE_STOPPING:
|
case XR_SESSION_STATE_STOPPING:
|
||||||
|
@ -480,16 +480,20 @@ namespace MWVR
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mMutex);
|
std::unique_lock<std::mutex> lock(mMutex);
|
||||||
|
|
||||||
auto prediction = mPredictedFrameTime;
|
//auto prediction = mPredictedFrameTime;
|
||||||
auto predictedPeriod = mPredictedPeriod;
|
//auto predictedPeriod = mPredictedPeriod;
|
||||||
|
|
||||||
auto futureFrames = frameIndex - OpenXRFrameIndexer::instance().renderIndex();
|
//auto futureFrames = frameIndex - OpenXRFrameIndexer::instance().renderIndex();
|
||||||
|
|
||||||
prediction += ( 0 + futureFrames) * predictedPeriod;
|
//prediction += ( 0 + futureFrames) * predictedPeriod;
|
||||||
|
|
||||||
Log(Debug::Verbose) << "Predicted: displayTime[" << futureFrames << "]=" << prediction;
|
//Log(Debug::Verbose) << "Predicted: displayTime[" << futureFrames << "]=" << prediction;
|
||||||
|
|
||||||
return prediction;
|
//return prediction;
|
||||||
|
|
||||||
|
//return mFrameState.predictedDisplayTime;
|
||||||
|
|
||||||
|
return mPredictedFrameTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenXRTimeKeeper::progressToNextFrame(XrFrameState frameState)
|
void OpenXRTimeKeeper::progressToNextFrame(XrFrameState frameState)
|
||||||
|
@ -515,8 +519,8 @@ namespace MWVR
|
||||||
{
|
{
|
||||||
// predictedDisplayTime refers to the midpoint of the display period
|
// predictedDisplayTime refers to the midpoint of the display period
|
||||||
// The upjustment must therefore only be half the magnitude
|
// The upjustment must therefore only be half the magnitude
|
||||||
// mPredictedFrameTime += (realPeriod - mFrameState.predictedDisplayPeriod);
|
mPredictedFrameTime += (realPeriod - mFrameState.predictedDisplayPeriod) / 2;
|
||||||
// mPredictedPeriod = realPeriod;
|
mPredictedPeriod = realPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,10 @@ namespace MWVR {
|
||||||
|
|
||||||
void OpenXRView::prerenderCallback(osg::RenderInfo& renderInfo)
|
void OpenXRView::prerenderCallback(osg::RenderInfo& renderInfo)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(mName == "LeftEye")
|
||||||
|
mXR->waitFrame();
|
||||||
|
|
||||||
Log(Debug::Verbose) << mName << ": prerenderCallback";
|
Log(Debug::Verbose) << mName << ": prerenderCallback";
|
||||||
if (mSwapchain)
|
if (mSwapchain)
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,7 +185,6 @@ namespace MWVR
|
||||||
mViews[OpenXRWorldView::RIGHT_VIEW]->swapchain().endFrame(gc);
|
mViews[OpenXRWorldView::RIGHT_VIEW]->swapchain().endFrame(gc);
|
||||||
mXRMenu->swapchain().endFrame(gc);
|
mXRMenu->swapchain().endFrame(gc);
|
||||||
mXR->endFrame();
|
mXR->endFrame();
|
||||||
mXR->waitFrame();
|
|
||||||
//gl->glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0);
|
//gl->glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0);
|
||||||
|
|
||||||
//mMirrorTextureSwapchain->renderBuffer()->blit(gc, 0, 0, mMirrorTextureSwapchain->width(), mMirrorTextureSwapchain->height());
|
//mMirrorTextureSwapchain->renderBuffer()->blit(gc, 0, 0, mMirrorTextureSwapchain->width(), mMirrorTextureSwapchain->height());
|
||||||
|
|
Loading…
Reference in a new issue