Fixed broken TAA on desktop... grrr.

This commit is contained in:
Olivier Prat 2018-02-23 11:28:00 +01:00
parent 4636f43728
commit d316b6e074
4 changed files with 11 additions and 4 deletions

View file

@ -692,6 +692,9 @@ void OpenGLDisplayPlugin::present() {
incrementPresentCount();
if (_currentFrame) {
auto correction = getViewCorrection();
getGLBackend()->setCameraCorrection(correction, _prevRenderView);
_prevRenderView = correction * _currentFrame->view;
{
withPresentThreadLock([&] {
_renderRate.increment();

View file

@ -118,6 +118,7 @@ protected:
void renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer texture, glm::ivec4 viewport, const glm::ivec4 scissor, gpu::FramebufferPointer fbo);
void renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer texture, glm::ivec4 viewport, const glm::ivec4 scissor);
virtual void updateFrameData();
virtual glm::mat4 getViewCorrection() { return glm::mat4(); }
void withOtherThreadContext(std::function<void()> f) const;
@ -137,6 +138,7 @@ protected:
gpu::FramePointer _currentFrame;
gpu::Frame* _lastFrame { nullptr };
mat4 _prevRenderView;
gpu::FramebufferPointer _compositeFramebuffer;
gpu::PipelinePointer _hudPipeline;
gpu::PipelinePointer _mirrorHUDPipeline;

View file

@ -336,12 +336,14 @@ void HmdDisplayPlugin::updateFrameData() {
}
updatePresentPose();
}
glm::mat4 HmdDisplayPlugin::getViewCorrection() {
if (_currentFrame) {
auto batchPose = _currentFrame->pose;
auto correction = glm::inverse(_currentPresentFrameInfo.presentPose) * batchPose ;
getGLBackend()->setCameraCorrection(correction, _prevRenderView);
_prevRenderView = correction * _currentFrame->view;
return glm::inverse(_currentPresentFrameInfo.presentPose) * batchPose;
} else {
return glm::mat4();
}
}

View file

@ -59,6 +59,7 @@ protected:
void customizeContext() override;
void uncustomizeContext() override;
void updateFrameData() override;
glm::mat4 getViewCorrection() override;
std::array<mat4, 2> _eyeOffsets;
std::array<mat4, 2> _eyeProjections;
@ -79,7 +80,6 @@ protected:
QMap<uint32_t, FrameInfo> _frameInfos;
FrameInfo _currentPresentFrameInfo;
FrameInfo _currentRenderFrameInfo;
mat4 _prevRenderView;
RateCounter<> _stutterRate;
bool _disablePreview { true };