Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
ysern's avatar
ysern
Honored Guest
11 years ago

Render on different threads QUESTION

Hi,

my 3D engine renders the scene on different threads, where main thread prepares data for rendering (saves the position of objects and camera at this moment, performs view culling) and render thread renders prepared data.

from Oculus Developer Guide DOC we have an example:

8.4.2 Render on different threads


void MainThreadProcessing()
{
frameIndex++;
// Ask the API for the times when this frame is expected to be displayed.
ovrFrameTiming frameTiming = ovrHmd_GetFrameTiming(hmd, frameIndex);
// Get the corresponding predicted pose state.
ovrTrackingState state = ovrHmd_GetTrackingState(hmd, frameTiming.ScanoutMidpointSeconds);
ovrPosef pose = state.HeadPose.ThePose;
SetFrameHMDData(frameIndex, pose);
// Do render pre-processing for this frame.
...
}

void RenderThreadProcessing()
{
int frameIndex;
ovrPosef pose;
GetFrameHMDData(&frameIndex, &pose);
// Call begin frame and pass in frameIndex.
ovrFrameTiming hmdFrameTiming = ovrHmd_BeginFrame(hmd, frameIndex);
// Execute actual rendering to eye textures.
ovrTexture eyeTexture[2]);
...
ovrPosef renderPose[2] = fpose, poseg;
ovrHmd_EndFrame(hmd, pose, eyeTexture);
}


So, the question is: how to organize rendering process that i can get pose for each eye (not head pose) by main thread but call ovrHmd_BeginFrame()/ovrHmd_EndFrame() by render thread in mind of proper OVR time warp?

1 Reply

  • ysern's avatar
    ysern
    Honored Guest
    Here is the illustration of my rendering process:
    ovr.jpg

    As you can see ovrHmd_GetEyePose invoked from another thread, outside ovrHmd_BeginFrameTiming()/ovrHmd_EndFrameTiming(). Is it normal, will OVR time warp works properly in such case?