Working on SDK vs client distortion performance differences

This commit is contained in:
Bradley Austin Davis 2015-04-01 13:23:55 -07:00
parent 51d3aba71c
commit a7dc1d26e6
2 changed files with 25 additions and 7 deletions

View file

@ -19,6 +19,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include <QScreen> #include <QScreen>
#include <QOpenGLTimerQuery>
#include <glm/glm.hpp> #include <glm/glm.hpp>
@ -424,13 +425,9 @@ void OculusManager::beginFrameTiming() {
} }
bool OculusManager::allowSwap() { bool OculusManager::allowSwap() {
#ifdef OVR_CLIENT_DISTORTION
return true;
#else
return false; return false;
#endif
} }
//Ends frame timing //Ends frame timing
void OculusManager::endFrameTiming() { void OculusManager::endFrameTiming() {
#ifdef OVR_CLIENT_DISTORTION #ifdef OVR_CLIENT_DISTORTION
@ -446,9 +443,18 @@ void OculusManager::configureCamera(Camera& camera, int screenWidth, int screenH
camera.setFieldOfView(atan(_eyeFov[0].UpTan) * DEGREES_PER_RADIAN * 2.0f); camera.setFieldOfView(atan(_eyeFov[0].UpTan) * DEGREES_PER_RADIAN * 2.0f);
} }
static bool timerActive = false;
//Displays everything for the oculus, frame timing must be active //Displays everything for the oculus, frame timing must be active
void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &position, Camera& whichCamera) { void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &position, Camera& whichCamera) {
auto glCanvas = Application::getInstance()->getGLWidget(); auto glCanvas = Application::getInstance()->getGLWidget();
static QOpenGLTimerQuery timerQuery;
if (!timerQuery.isCreated()) {
timerQuery.create();
}
if (timerActive && timerQuery.isResultAvailable()) {
qDebug() << timerQuery.waitForResult();
timerActive = false;
}
#ifdef OVR_DIRECT_MODE #ifdef OVR_DIRECT_MODE
static bool attached = false; static bool attached = false;
@ -603,7 +609,12 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
// restore our normal viewport // restore our normal viewport
glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
if (!timerActive) {
timerQuery.begin();
}
#ifdef OVR_CLIENT_DISTORTION #ifdef OVR_CLIENT_DISTORTION
//Wait till time-warp to reduce latency //Wait till time-warp to reduce latency
ovr_WaitTillTime(_hmdFrameTiming.TimewarpPointSeconds); ovr_WaitTillTime(_hmdFrameTiming.TimewarpPointSeconds);
@ -617,8 +628,10 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
renderDistortionMesh(eyeRenderPose); renderDistortionMesh(eyeRenderPose);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glCanvas->swapBuffers();
#else #else
for_each_eye([&](ovrEyeType eye) { for_each_eye([&](ovrEyeType eye) {
ovrGLTexture & glEyeTexture = reinterpret_cast<ovrGLTexture&>(_eyeTextures[eye]); ovrGLTexture & glEyeTexture = reinterpret_cast<ovrGLTexture&>(_eyeTextures[eye]);
glEyeTexture.OGL.TexId = finalFbo->texture(); glEyeTexture.OGL.TexId = finalFbo->texture();
@ -626,7 +639,12 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
}); });
ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures); ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures);
#endif #endif
if (!timerActive) {
timerQuery.end();
timerActive = true;
}
} }
#ifdef OVR_CLIENT_DISTORTION #ifdef OVR_CLIENT_DISTORTION

View file

@ -39,7 +39,7 @@ class Text3DOverlay;
// To enable Direct HMD mode, you can un-comment this, but with the // To enable Direct HMD mode, you can un-comment this, but with the
// caveat that it will break v-sync in NON-VR mode if you have an Oculus // caveat that it will break v-sync in NON-VR mode if you have an Oculus
// Rift connect and in Direct mode // Rift connect and in Direct mode
// #define OVR_DIRECT_MODE 1 #define OVR_DIRECT_MODE 1
/// Handles interaction with the Oculus Rift. /// Handles interaction with the Oculus Rift.