Forum Discussion
Mecrof
10 years agoExplorer
[SOLVED]Rendering lags if no double commit texture swap chain in the render pass
Hi,
I got something strange since I upgraded my Engine to support the new SDK 1.3. I'm working with the DK2.
When I move my head, the tracking randomly lags. I fix it by calling twice "ovr_CommitTextureSwapChain(session, textureChain);" before to submit the frame to the Rift. It's quite strange because the OculusRoomTinyGL works well with just one commit. :/
I have two differences with the Oculus' sample:
- I render stereo views in the same buffer instead of two separated;
- I call "ovr_Initialize", "ovr_Create" and "ovr_GetHmdDesc" from the main thread and everything else from another thread (the "engine's thread")
To retrieve the Pose, I tried two methods:
I checked if the compositor was dropping some frames during lags, but not, everything is fine at 75Hz.
My code is wrong somewhere but I don't understand where. Any suggestions, please?
Here's my rendering code:
Here's my code to submit my frames:
I got something strange since I upgraded my Engine to support the new SDK 1.3. I'm working with the DK2.
When I move my head, the tracking randomly lags. I fix it by calling twice "ovr_CommitTextureSwapChain(session, textureChain);" before to submit the frame to the Rift. It's quite strange because the OculusRoomTinyGL works well with just one commit. :/
I have two differences with the Oculus' sample:
- I render stereo views in the same buffer instead of two separated;
- I call "ovr_Initialize", "ovr_Create" and "ovr_GetHmdDesc" from the main thread and everything else from another thread (the "engine's thread")
To retrieve the Pose, I tried two methods:
#ifdef POSE_METHOD1
double ftiming = ovr_GetPredictedDisplayTime(session_, frameIndex_);
ovrTrackingState hmdState = ovr_GetTrackingState(session_, ftiming, ovrTrue);
ovr_CalcEyePoses(hmdState.HeadPose.ThePose, hmdToEyeOffset, eyeRenderPose);
#else
double sensorSampleTime;no difference.
ovr_GetEyePoses(session_, frameIndex_, ovrTrue, hmdToEyeOffset, eyeRenderPose, &sensorSampleTime);
#endif
I checked if the compositor was dropping some frames during lags, but not, everything is fine at 75Hz.
My code is wrong somewhere but I don't understand where. Any suggestions, please?
Here's my rendering code:
GLuint curTexId;
int curIndex;
ovr_GetTextureSwapChainCurrentIndex(session, textureChain, &curIndex);
ovr_GetTextureSwapChainBufferGL(session, textureChain, curIndex, &curTexId);
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, curTexId, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, dbuffer->texId, 0);
glViewport(0, 0, texSize.w, texSize.h);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// ... do render stereo views
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
ovr_CommitTextureSwapChain(session, textureChain);
//ovr_CommitTextureSwapChain(session, textureChain); // two commits fix the issue..
Here's my code to submit my frames:
ovrLayerEyeFov ld;
ld.Header.Type = ovrLayerType_EyeFov;
ld.Header.Flags = ovrLayerFlag_HighQuality | ovrLayerFlag_TextureOriginAtBottomLeft;
OVR::Sizei size = eyeRenderTexture_->getSize();
OVR::Recti vpL(0, 0, size.w / 2, size.h);
OVR::Recti vpR(vpL.w, 0, vpL.w, vpL.h);
for (int eye = 0; eye < 2; ++eye)
{
ld.ColorTexture[eye] = eyeRenderTexture_->textureChain;
ld.Viewport[eye] = eye == ovrEye_Left ? vpL : vpR;
ld.Fov[eye] = hmdDesc_.DefaultEyeFov[eye];
ld.RenderPose[eye] = eyeRenderPose[eye];
#ifdef POSE_METHOD1
ld.SensorSampleTime = ovr_GetTimeInSeconds();
#else
ld.SensorSampleTime = sensorSampleTime;
#endif
}
ovrLayerHeader* layers = &ld.Header;
ovrResult result = ovr_SubmitFrame(session_, frameIndex_, nullptr, &layers, 1);
3 Replies
- albertojoseHonored GuestI have a similar issue. Also using a different render thread and a single texture with both eyes on it.
However, I also render from yet another thread and that one renders fine. The difference is that I'm using the oculus calculated matrices on this one and camera math on the one with the issue.
In short, my current theory is that my camera math is calculating rotations slightly different (perhaps a floating point bug somewhere in my code) which makes the rotation not match what ATW expects.
By the way, I tried doing the commit twice and didn't help in my case. - MecrofExplorerI didn't find the bug in my code yet. But doing commit twice, I do not have the problem. So I put this issue to a low priority in my dev.
What does the commit function really do (in fore and background)? - MecrofExplorerI got it! I share my solution for some others with the same issue.I calledAnd now, everything is smooth.
glFinish()
beforeovr_CommitTextureSwapChain(session_, textureChain_);
I don't really know what does ovr_CommitTextureSwapChain, but it doesn't take care if previous OpenGL calls are done. Am I wrong?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 21 days ago
- 10 days ago
- 9 months ago
- 4 months ago
- 9 months ago