Added history of view to try to adjust for GPU slower than game

This commit is contained in:
Olivier Prat 2018-02-22 23:03:33 +01:00
parent ebe05d1f6f
commit ae63610582
8 changed files with 21 additions and 4 deletions

View file

@ -5447,7 +5447,9 @@ void Application::update(float deltaTime) {
{ {
QMutexLocker viewLocker(&_viewMutex); QMutexLocker viewLocker(&_viewMutex);
appRenderArgs._prevView = glm::inverse(_displayViewFrustum.getView());
_myCamera.loadViewFrustum(_displayViewFrustum); _myCamera.loadViewFrustum(_displayViewFrustum);
appRenderArgs._view = glm::inverse(_displayViewFrustum.getView());
} }
{ {

View file

@ -617,6 +617,8 @@ private:
struct AppRenderArgs { struct AppRenderArgs {
render::Args _renderArgs; render::Args _renderArgs;
glm::mat4 _eyeToWorld; glm::mat4 _eyeToWorld;
glm::mat4 _view;
glm::mat4 _prevView;
glm::mat4 _eyeOffsets[2]; glm::mat4 _eyeOffsets[2];
glm::mat4 _eyeProjections[2]; glm::mat4 _eyeProjections[2];
glm::mat4 _headPose; glm::mat4 _headPose;

View file

@ -64,6 +64,7 @@ void Application::paintGL() {
glm::mat4 HMDSensorPose; glm::mat4 HMDSensorPose;
glm::mat4 HMDSensorPrevPose; glm::mat4 HMDSensorPrevPose;
glm::mat4 eyeToWorld; glm::mat4 eyeToWorld;
glm::mat4 prevEyeToWorld;
glm::mat4 sensorToWorld; glm::mat4 sensorToWorld;
bool isStereo; bool isStereo;
@ -92,7 +93,8 @@ void Application::paintGL() {
{ {
PROFILE_RANGE(render, "/gpuContextReset"); PROFILE_RANGE(render, "/gpuContextReset");
_gpuContext->beginFrame(HMDSensorPose, HMDSensorPrevPose); _gpuContext->beginFrame(_appRenderArgs._view, _appRenderArgs._prevView,
HMDSensorPose, HMDSensorPrevPose);
// Reset the gpu::Context Stages // Reset the gpu::Context Stages
// Back to the default framebuffer; // Back to the default framebuffer;
gpu::doInBatch("Application_render::gpuContextReset", _gpuContext, [&](gpu::Batch& batch) { gpu::doInBatch("Application_render::gpuContextReset", _gpuContext, [&](gpu::Batch& batch) {

View file

@ -341,10 +341,12 @@ void HmdDisplayPlugin::updateFrameData() {
auto invBatchPose = glm::inverse(_currentFrame->pose); auto invBatchPose = glm::inverse(_currentFrame->pose);
auto invPrevBatchPose = glm::inverse(_currentFrame->prevPose); auto invPrevBatchPose = glm::inverse(_currentFrame->prevPose);
auto correction = invBatchPose * _currentPresentFrameInfo.presentPose; auto correction = invBatchPose * _currentPresentFrameInfo.presentPose;
auto prevCorrection = invPrevBatchPose * _previousPresentFrameInfo.presentPose; auto prevCorrection = /*_currentFrame->prevView * glm::inverse(_prevRenderView) */ invPrevBatchPose * _previousPresentFrameInfo.presentPose;
getGLBackend()->setCameraCorrection(correction, prevCorrection); getGLBackend()->setCameraCorrection(correction, prevCorrection);
_previousPresentFrameInfo = _currentPresentFrameInfo; _previousPresentFrameInfo = _currentPresentFrameInfo;
_prevRenderView = _currentFrame->view;
} }
} }

View file

@ -80,6 +80,7 @@ protected:
FrameInfo _currentPresentFrameInfo; FrameInfo _currentPresentFrameInfo;
FrameInfo _previousPresentFrameInfo; FrameInfo _previousPresentFrameInfo;
FrameInfo _currentRenderFrameInfo; FrameInfo _currentRenderFrameInfo;
mat4 _prevRenderView;
RateCounter<> _stutterRate; RateCounter<> _stutterRate;
bool _disablePreview { true }; bool _disablePreview { true };

View file

@ -53,12 +53,15 @@ const std::string& Context::getBackendVersion() const {
return _backend->getVersion(); return _backend->getVersion();
} }
void Context::beginFrame(const glm::mat4& renderPose, const glm::mat4& prevRenderPose) { void Context::beginFrame(const glm::mat4& renderView, const glm::mat4& prevRenderView,
const glm::mat4& renderPose, const glm::mat4& prevRenderPose) {
assert(!_frameActive); assert(!_frameActive);
_frameActive = true; _frameActive = true;
_currentFrame = std::make_shared<Frame>(); _currentFrame = std::make_shared<Frame>();
_currentFrame->pose = renderPose; _currentFrame->pose = renderPose;
_currentFrame->prevPose = prevRenderPose; _currentFrame->prevPose = prevRenderPose;
_currentFrame->view = renderView;
_currentFrame->prevView = prevRenderView;
if (!_frameRangeTimer) { if (!_frameRangeTimer) {
_frameRangeTimer = std::make_shared<RangeTimer>("gpu::Context::Frame"); _frameRangeTimer = std::make_shared<RangeTimer>("gpu::Context::Frame");

View file

@ -161,7 +161,8 @@ public:
const std::string& getBackendVersion() const; const std::string& getBackendVersion() const;
void beginFrame(const glm::mat4& renderPose = glm::mat4(), const glm::mat4& prevRenderPose = glm::mat4()); void beginFrame(const glm::mat4& renderView = glm::mat4(), const glm::mat4& prevRenderView = glm::mat4(),
const glm::mat4& renderPose = glm::mat4(), const glm::mat4& prevRenderPose = glm::mat4());
void appendFrameBatch(Batch& batch); void appendFrameBatch(Batch& batch);
FramePointer endFrame(); FramePointer endFrame();

View file

@ -28,6 +28,10 @@ namespace gpu {
StereoState stereoState; StereoState stereoState;
uint32_t frameIndex{ 0 }; uint32_t frameIndex{ 0 };
/// The view matrix used for rendering the frame, only applicable for HMDs
Mat4 view;
/// The view matrix used for rendering the previous frame, only applicable for HMDs
Mat4 prevView;
/// The sensor pose used for rendering the frame, only applicable for HMDs /// The sensor pose used for rendering the frame, only applicable for HMDs
Mat4 pose; Mat4 pose;
/// The sensor pose used for rendering the previous frame, only applicable for HMDs /// The sensor pose used for rendering the previous frame, only applicable for HMDs