mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-26 17:09:39 +00:00
Separate GLRC for OpenXR to ensure uncontested access.
Safety check on predictions to police that they are made only once per frame.
This commit is contained in:
parent
9ad910a8e7
commit
8f38f0536c
2 changed files with 30 additions and 3 deletions
|
@ -93,10 +93,16 @@ namespace MWVR
|
|||
|
||||
{ // Create Session
|
||||
// TODO: Platform dependent
|
||||
auto DC = wglGetCurrentDC();
|
||||
auto GLRC = wglGetCurrentContext();
|
||||
auto XRGLRC = wglCreateContext(DC);
|
||||
wglShareLists(GLRC, XRGLRC);
|
||||
wglMakeCurrent(DC, XRGLRC);
|
||||
|
||||
mGraphicsBinding.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR;
|
||||
mGraphicsBinding.next = nullptr;
|
||||
mGraphicsBinding.hDC = wglGetCurrentDC();
|
||||
mGraphicsBinding.hGLRC = wglGetCurrentContext();
|
||||
mGraphicsBinding.hDC = DC;
|
||||
mGraphicsBinding.hGLRC = XRGLRC;
|
||||
|
||||
if (!mGraphicsBinding.hDC)
|
||||
std::cout << "Missing DC" << std::endl;
|
||||
|
@ -108,6 +114,7 @@ namespace MWVR
|
|||
createInfo.systemId = mSystemId;
|
||||
CHECK_XRCMD(xrCreateSession(mInstance, &createInfo, &mSession));
|
||||
assert(mSession);
|
||||
wglMakeCurrent(DC, GLRC);
|
||||
}
|
||||
|
||||
LogLayersAndExtensions();
|
||||
|
@ -315,7 +322,11 @@ namespace MWVR
|
|||
int64_t predictedDisplayTime,
|
||||
TrackedSpace space)
|
||||
{
|
||||
|
||||
if (!mPredictionsEnabled)
|
||||
{
|
||||
Log(Debug::Error) << "Prediction out of order";
|
||||
throw std::logic_error("Prediction out of order");
|
||||
}
|
||||
std::array<XrView, 2> views{ {{XR_TYPE_VIEW}, {XR_TYPE_VIEW}} };
|
||||
XrViewState viewState{ XR_TYPE_VIEW_STATE };
|
||||
uint32_t viewCount = 2;
|
||||
|
@ -339,6 +350,11 @@ namespace MWVR
|
|||
|
||||
MWVR::Pose OpenXRManagerImpl::getPredictedLimbPose(int64_t predictedDisplayTime, TrackedLimb limb, TrackedSpace space)
|
||||
{
|
||||
if (!mPredictionsEnabled)
|
||||
{
|
||||
Log(Debug::Error) << "Prediction out of order";
|
||||
throw std::logic_error("Prediction out of order");
|
||||
}
|
||||
XrSpaceLocation location{ XR_TYPE_SPACE_LOCATION };
|
||||
XrSpaceVelocity velocity{ XR_TYPE_SPACE_VELOCITY };
|
||||
location.next = &velocity;
|
||||
|
@ -500,6 +516,14 @@ namespace MWVR
|
|||
referenceSpace = mReferenceSpaceView;
|
||||
return referenceSpace;
|
||||
}
|
||||
void OpenXRManagerImpl::enablePredictions()
|
||||
{
|
||||
mPredictionsEnabled = true;
|
||||
}
|
||||
void OpenXRManagerImpl::disablePredictions()
|
||||
{
|
||||
mPredictionsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
namespace osg
|
||||
|
|
|
@ -65,8 +65,11 @@ namespace MWVR
|
|||
void HandleSessionStateChanged(const XrEventDataSessionStateChanged& stateChangedEvent);
|
||||
XrFrameState frameState();
|
||||
XrSpace getReferenceSpace(TrackedSpace space);
|
||||
void enablePredictions();
|
||||
void disablePredictions();
|
||||
|
||||
bool initialized = false;
|
||||
bool mPredictionsEnabled = false;
|
||||
long long mFrameIndex = 0;
|
||||
XrInstance mInstance = XR_NULL_HANDLE;
|
||||
XrSession mSession = XR_NULL_HANDLE;
|
||||
|
|
Loading…
Reference in a new issue