From d09af2dbba4f375cd4e0577124a422ffc8669398 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sat, 20 Dec 2014 13:01:37 +0100 Subject: [PATCH] GeometryShaderManager: Set stereo parameters in a SetConstants() call. Doing it in SetProjectionChanged() is too early because the projection type is not set yet. --- .../VideoCommon/GeometryShaderManager.cpp | 38 ++++++++++++------- .../Core/VideoCommon/GeometryShaderManager.h | 1 + Source/Core/VideoCommon/VertexManagerBase.cpp | 1 + 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Source/Core/VideoCommon/GeometryShaderManager.cpp b/Source/Core/VideoCommon/GeometryShaderManager.cpp index 09adad56c0..957a1a65ca 100644 --- a/Source/Core/VideoCommon/GeometryShaderManager.cpp +++ b/Source/Core/VideoCommon/GeometryShaderManager.cpp @@ -19,6 +19,8 @@ static const int LINE_PT_TEX_OFFSETS[8] = { GeometryShaderConstants GeometryShaderManager::constants; bool GeometryShaderManager::dirty; +static bool s_projection_changed; + void GeometryShaderManager::Init() { memset(&constants, 0, sizeof(constants)); @@ -42,6 +44,28 @@ void GeometryShaderManager::Dirty() dirty = true; } +void GeometryShaderManager::SetConstants() +{ + if (s_projection_changed && g_ActiveConfig.iStereoMode > 0) + { + s_projection_changed = false; + + if (xfmem.projection.type == GX_PERSPECTIVE) + { + float offset = (g_ActiveConfig.iStereoSeparation / 1000.0f) * (g_ActiveConfig.iStereoSeparationPercent / 100.0f); + constants.stereoparams[0] = (g_ActiveConfig.bStereoSwapEyes) ? offset : -offset; + constants.stereoparams[1] = (g_ActiveConfig.bStereoSwapEyes) ? -offset : offset; + constants.stereoparams[2] = (g_ActiveConfig.iStereoConvergence / 10.0f) * (g_ActiveConfig.iStereoConvergencePercent / 100.0f); + } + else + { + constants.stereoparams[0] = constants.stereoparams[1] = 0; + } + + dirty = true; + } +} + void GeometryShaderManager::SetViewportChanged() { constants.lineptparams[0] = 2.0f * xfmem.viewport.wd; @@ -51,19 +75,7 @@ void GeometryShaderManager::SetViewportChanged() void GeometryShaderManager::SetProjectionChanged() { - if (g_ActiveConfig.iStereoMode > 0 && xfmem.projection.type == GX_PERSPECTIVE) - { - float offset = (g_ActiveConfig.iStereoSeparation / 1000.0f) * (g_ActiveConfig.iStereoSeparationPercent / 100.0f); - constants.stereoparams[0] = (g_ActiveConfig.bStereoSwapEyes) ? offset : -offset; - constants.stereoparams[1] = (g_ActiveConfig.bStereoSwapEyes) ? -offset : offset; - constants.stereoparams[2] = (g_ActiveConfig.iStereoConvergence / 10.0f) * (g_ActiveConfig.iStereoConvergencePercent / 100.0f); - } - else - { - constants.stereoparams[0] = constants.stereoparams[1] = 0; - } - - dirty = true; + s_projection_changed = true; } void GeometryShaderManager::SetLinePtWidthChanged() diff --git a/Source/Core/VideoCommon/GeometryShaderManager.h b/Source/Core/VideoCommon/GeometryShaderManager.h index eab036fd7e..56dec7a666 100644 --- a/Source/Core/VideoCommon/GeometryShaderManager.h +++ b/Source/Core/VideoCommon/GeometryShaderManager.h @@ -18,6 +18,7 @@ public: static void Shutdown(); static void DoState(PointerWrap &p); + static void SetConstants(); static void SetViewportChanged(); static void SetProjectionChanged(); static void SetLinePtWidthChanged(); diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index b1bc049fe5..c6191a587f 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -223,6 +223,7 @@ void VertexManager::Flush() // set global constants VertexShaderManager::SetConstants(); + GeometryShaderManager::SetConstants(); PixelShaderManager::SetConstants(); bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass &&