From 5337e58284aa9c727cdd66a1a79d968861a70839 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 10 Nov 2017 22:55:00 -0500 Subject: [PATCH] VideoConfig: Make StereoMode an enum class Makes for more strongly-typed identifiers (and doesn't pollute surrounding namespaces) --- Source/Core/Core/Analytics.cpp | 4 ++-- .../Config/Graphics/EnhancementsWidget.cpp | 2 +- Source/Core/DolphinQt2/HotkeyScheduler.cpp | 18 +++++++------- Source/Core/DolphinWX/Frame.cpp | 24 +++++++++---------- Source/Core/DolphinWX/VideoConfigDiag.cpp | 4 ++-- Source/Core/VideoBackends/D3D/D3DBase.cpp | 4 ++-- .../VideoBackends/D3D/FramebufferManager.cpp | 2 +- .../VideoBackends/D3D/GeometryShaderCache.cpp | 4 ++-- Source/Core/VideoBackends/D3D/Render.cpp | 15 ++++++------ .../VideoBackends/OGL/FramebufferManager.cpp | 2 +- Source/Core/VideoBackends/OGL/Render.cpp | 15 ++++++------ .../Core/VideoBackends/OGL/TextureCache.cpp | 2 +- Source/Core/VideoBackends/OGL/main.cpp | 2 +- .../Vulkan/FramebufferManager.cpp | 2 +- Source/Core/VideoBackends/Vulkan/Renderer.cpp | 7 +++--- .../Core/VideoBackends/Vulkan/ShaderCache.cpp | 4 ++-- .../Core/VideoBackends/Vulkan/SwapChain.cpp | 2 +- Source/Core/VideoCommon/GeometryShaderGen.cpp | 2 +- .../VideoCommon/GeometryShaderManager.cpp | 2 +- Source/Core/VideoCommon/PostProcessing.cpp | 3 ++- Source/Core/VideoCommon/RenderBase.cpp | 4 ++-- Source/Core/VideoCommon/ShaderGenCommon.cpp | 2 +- Source/Core/VideoCommon/TextureCacheBase.cpp | 4 ++-- Source/Core/VideoCommon/VideoConfig.cpp | 6 ++--- Source/Core/VideoCommon/VideoConfig.h | 16 ++++++------- 25 files changed, 78 insertions(+), 74 deletions(-) diff --git a/Source/Core/Core/Analytics.cpp b/Source/Core/Core/Analytics.cpp index 0a079c3e1f..39f62b3f13 100644 --- a/Source/Core/Core/Analytics.cpp +++ b/Source/Core/Core/Analytics.cpp @@ -220,7 +220,7 @@ void DolphinAnalytics::MakePerGameBuilder() builder.AddData("cfg-gfx-ssaa", g_Config.bSSAA); builder.AddData("cfg-gfx-anisotropy", g_Config.iMaxAnisotropy); builder.AddData("cfg-gfx-vsync", g_Config.bVSync); - builder.AddData("cfg-gfx-aspect-ratio", g_Config.iAspectRatio); + builder.AddData("cfg-gfx-aspect-ratio", static_cast(g_Config.aspect_mode)); builder.AddData("cfg-gfx-efb-access", g_Config.bEFBAccessEnable); builder.AddData("cfg-gfx-efb-copy-format-changes", g_Config.bEFBEmulateFormatChanges); builder.AddData("cfg-gfx-efb-copy-ram", !g_Config.bSkipEFBCopyToRam); @@ -229,7 +229,7 @@ void DolphinAnalytics::MakePerGameBuilder() builder.AddData("cfg-gfx-efb-copy-scaled", g_Config.bCopyEFBScaled); builder.AddData("cfg-gfx-internal-resolution", g_Config.iEFBScale); builder.AddData("cfg-gfx-tc-samples", g_Config.iSafeTextureCache_ColorSamples); - builder.AddData("cfg-gfx-stereo-mode", g_Config.iStereoMode); + builder.AddData("cfg-gfx-stereo-mode", static_cast(g_Config.stereo_mode)); builder.AddData("cfg-gfx-per-pixel-lighting", g_Config.bEnablePixelLighting); builder.AddData("cfg-gfx-ubershader-mode", GetUbershaderMode(g_Config)); builder.AddData("cfg-gfx-fast-depth", g_Config.bFastDepthCalc); diff --git a/Source/Core/DolphinQt2/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt2/Config/Graphics/EnhancementsWidget.cpp index c4f0c2dc93..19855f7a5e 100644 --- a/Source/Core/DolphinQt2/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt2/Config/Graphics/EnhancementsWidget.cpp @@ -146,7 +146,7 @@ void EnhancementsWidget::LoadSettings() // Post Processing Shader std::vector shaders = - g_Config.iStereoMode == STEREO_ANAGLYPH ? + g_Config.stereo_mode == StereoMode::Anaglyph ? PostProcessingShaderImplementation::GetAnaglyphShaderList( g_Config.backend_info.api_type) : PostProcessingShaderImplementation::GetShaderList(g_Config.backend_info.api_type); diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.cpp b/Source/Core/DolphinQt2/HotkeyScheduler.cpp index e8e4038779..b68bc4172e 100644 --- a/Source/Core/DolphinQt2/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt2/HotkeyScheduler.cpp @@ -264,46 +264,46 @@ void HotkeyScheduler::Run() // Stereoscopy if (IsHotkey(HK_TOGGLE_STEREO_SBS) || IsHotkey(HK_TOGGLE_STEREO_TAB)) { - if (g_Config.iStereoMode != STEREO_SBS) + if (g_Config.stereo_mode != StereoMode::SBS) { // Disable post-processing shader, as stereoscopy itself is currently a shader if (g_Config.sPostProcessingShader == DUBOIS_ALGORITHM_SHADER) g_Config.sPostProcessingShader = ""; - g_Config.iStereoMode = IsHotkey(HK_TOGGLE_STEREO_SBS) ? STEREO_SBS : STEREO_TAB; + g_Config.stereo_mode = IsHotkey(HK_TOGGLE_STEREO_SBS) ? StereoMode::SBS : StereoMode::TAB; } else { - g_Config.iStereoMode = STEREO_OFF; + g_Config.stereo_mode = StereoMode::Off; } } if (IsHotkey(HK_TOGGLE_STEREO_ANAGLYPH)) { - if (g_Config.iStereoMode != STEREO_ANAGLYPH) + if (g_Config.stereo_mode != StereoMode::Anaglyph) { - g_Config.iStereoMode = STEREO_ANAGLYPH; + g_Config.stereo_mode = StereoMode::Anaglyph; g_Config.sPostProcessingShader = DUBOIS_ALGORITHM_SHADER; } else { - g_Config.iStereoMode = STEREO_OFF; + g_Config.stereo_mode = StereoMode::Off; g_Config.sPostProcessingShader = ""; } } if (IsHotkey(HK_TOGGLE_STEREO_3DVISION)) { - if (g_Config.iStereoMode != STEREO_3DVISION) + if (g_Config.stereo_mode != StereoMode::Nvidia3DVision) { if (g_Config.sPostProcessingShader == DUBOIS_ALGORITHM_SHADER) g_Config.sPostProcessingShader = ""; - g_Config.iStereoMode = STEREO_3DVISION; + g_Config.stereo_mode = StereoMode::Nvidia3DVision; } else { - g_Config.iStereoMode = STEREO_OFF; + g_Config.stereo_mode = StereoMode::Off; } } } diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 1f89306a13..d1f8693417 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1549,7 +1549,7 @@ void CFrame::ParseHotkeys() if (IsHotkey(HK_TOGGLE_STEREO_SBS)) { - if (g_Config.iStereoMode != STEREO_SBS) + if (g_Config.stereo_mode != StereoMode::SBS) { // Current implementation of anaglyph stereoscopy uses a // post-processing shader. Thus the shader needs to be to be @@ -1558,56 +1558,56 @@ void CFrame::ParseHotkeys() { Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, std::string("")); } - Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(STEREO_SBS)); + Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(StereoMode::SBS)); } else { - Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(STEREO_OFF)); + Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(StereoMode::Off)); } } if (IsHotkey(HK_TOGGLE_STEREO_TAB)) { - if (g_Config.iStereoMode != STEREO_TAB) + if (g_Config.stereo_mode != StereoMode::TAB) { if (g_Config.sPostProcessingShader == "dubois") { Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, std::string("")); } - Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(STEREO_TAB)); + Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(StereoMode::TAB)); } else { - Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(STEREO_OFF)); + Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(StereoMode::Off)); } } if (IsHotkey(HK_TOGGLE_STEREO_ANAGLYPH)) { - if (g_Config.iStereoMode != STEREO_ANAGLYPH) + if (g_Config.stereo_mode != StereoMode::Anaglyph) { // Setting the anaglyph mode also requires a specific // post-processing shader to be activated. - Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(STEREO_ANAGLYPH)); + Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(StereoMode::Anaglyph)); Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, std::string("dubois")); } else { - Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(STEREO_OFF)); + Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(StereoMode::Off)); Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, std::string("")); } } if (IsHotkey(HK_TOGGLE_STEREO_3DVISION)) { - if (g_Config.iStereoMode != STEREO_3DVISION) + if (g_Config.stereo_mode != StereoMode::Nvidia3DVision) { if (g_Config.sPostProcessingShader == "dubois") { Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, std::string("")); } - Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(STEREO_3DVISION)); + Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(StereoMode::Nvidia3DVision)); } else { - Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(STEREO_OFF)); + Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast(StereoMode::Off)); } } diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index dad285a385..71c02c7ec7 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -1199,7 +1199,7 @@ void VideoConfigDiag::CreateDescriptionArea(wxPanel* const page, wxBoxSizer* con void VideoConfigDiag::PopulatePostProcessingShaders() { std::vector shaders = - vconfig.iStereoMode == STEREO_ANAGLYPH ? + vconfig.stereo_mode == StereoMode::Anaglyph ? PostProcessingShaderImplementation::GetAnaglyphShaderList(vconfig.backend_info.api_type) : PostProcessingShaderImplementation::GetShaderList(vconfig.backend_info.api_type); @@ -1223,7 +1223,7 @@ void VideoConfigDiag::PopulatePostProcessingShaders() // Invalid shader, reset it to default choice_ppshader->Select(0); - if (vconfig.iStereoMode == STEREO_ANAGLYPH) + if (vconfig.stereo_mode == StereoMode::Anaglyph) { Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, std::string("dubois")); choice_ppshader->SetStringSelection(StrToWxStr(vconfig.sPostProcessingShader)); diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp index 918b57c62d..4cf5fb7524 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp @@ -318,7 +318,7 @@ HRESULT Create(HWND wnd) swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; swap_chain_desc.Width = xres; swap_chain_desc.Height = yres; - swap_chain_desc.Stereo = g_ActiveConfig.iStereoMode == STEREO_QUADBUFFER; + swap_chain_desc.Stereo = g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer; // This flag is necessary if we want to use a flip-model swapchain without locking the framerate swap_chain_desc.Flags = allow_tearing_supported ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0; @@ -634,7 +634,7 @@ void Present() if (AllowTearingSupported() && !g_ActiveConfig.IsVSync() && !GetFullscreenState()) present_flags |= DXGI_PRESENT_ALLOW_TEARING; - if (swapchain->IsTemporaryMonoSupported() && g_ActiveConfig.iStereoMode != STEREO_QUADBUFFER) + if (swapchain->IsTemporaryMonoSupported() && g_ActiveConfig.stereo_mode != StereoMode::QuadBuffer) present_flags |= DXGI_PRESENT_STEREO_TEMPORARY_MONO; // TODO: Is 1 the correct value for vsyncing? diff --git a/Source/Core/VideoBackends/D3D/FramebufferManager.cpp b/Source/Core/VideoBackends/D3D/FramebufferManager.cpp index 4bd5a3fd60..30fbde261e 100644 --- a/Source/Core/VideoBackends/D3D/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/D3D/FramebufferManager.cpp @@ -137,7 +137,7 @@ FramebufferManager::FramebufferManager(int target_width, int target_height) D3D11_TEXTURE2D_DESC texdesc; HRESULT hr; - m_EFBLayers = m_efb.slices = (g_ActiveConfig.iStereoMode > 0) ? 2 : 1; + m_EFBLayers = m_efb.slices = (g_ActiveConfig.stereo_mode != StereoMode::Off) ? 2 : 1; // EFB color texture - primary render target texdesc = diff --git a/Source/Core/VideoBackends/D3D/GeometryShaderCache.cpp b/Source/Core/VideoBackends/D3D/GeometryShaderCache.cpp index ecb8b7b1bb..cc8a9ba7bc 100644 --- a/Source/Core/VideoBackends/D3D/GeometryShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D/GeometryShaderCache.cpp @@ -37,11 +37,11 @@ LinearDiskCache g_gs_disk_cache; ID3D11GeometryShader* GeometryShaderCache::GetClearGeometryShader() { - return (g_ActiveConfig.iStereoMode > 0) ? ClearGeometryShader : nullptr; + return (g_ActiveConfig.stereo_mode != StereoMode::Off) ? ClearGeometryShader : nullptr; } ID3D11GeometryShader* GeometryShaderCache::GetCopyGeometryShader() { - return (g_ActiveConfig.iStereoMode > 0) ? CopyGeometryShader : nullptr; + return (g_ActiveConfig.stereo_mode != StereoMode::Off) ? CopyGeometryShader : nullptr; } ID3D11Buffer* gscbuf = nullptr; diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 11bbea61c2..f3c3a9ffc9 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -209,7 +209,7 @@ static void Create3DVisionTexture(int width, int height) Renderer::Renderer() : ::Renderer(D3D::GetBackBufferWidth(), D3D::GetBackBufferHeight()) { s_last_multisamples = g_ActiveConfig.iMultisamples; - s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; + s_last_stereo_mode = g_ActiveConfig.stereo_mode != StereoMode::Off; s_last_fullscreen_mode = D3D::GetFullscreenState(); g_framebuffer_manager = std::make_unique(m_target_width, m_target_height); @@ -658,7 +658,7 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region // Resize the back buffers NOW to avoid flickering if (CalculateTargetSize() || window_resized || fs_changed || s_last_multisamples != g_ActiveConfig.iMultisamples || - s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0)) + s_last_stereo_mode != (g_ActiveConfig.stereo_mode != StereoMode::Off)) { s_last_multisamples = g_ActiveConfig.iMultisamples; s_last_fullscreen_mode = fullscreen; @@ -676,7 +676,7 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region UpdateDrawRectangle(); - s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; + s_last_stereo_mode = g_ActiveConfig.stereo_mode != StereoMode::Off; D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), nullptr); @@ -810,7 +810,8 @@ void Renderer::BBoxWrite(int index, u16 _value) void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, D3DTexture2D* src_texture, u32 src_width, u32 src_height, float Gamma) { - if (g_ActiveConfig.iStereoMode == STEREO_SBS || g_ActiveConfig.iStereoMode == STEREO_TAB) + if (g_ActiveConfig.stereo_mode == StereoMode::SBS || + g_ActiveConfig.stereo_mode == StereoMode::TAB) { TargetRectangle leftRc, rightRc; std::tie(leftRc, rightRc) = ConvertStereoRectangle(dst); @@ -832,7 +833,7 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, D3DTexture2D VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(), nullptr, Gamma, 1); } - else if (g_ActiveConfig.iStereoMode == STEREO_3DVISION) + else if (g_ActiveConfig.stereo_mode == StereoMode::Nvidia3DVision) { if (!s_3d_vision_texture) Create3DVisionTexture(m_backbuffer_width, m_backbuffer_height); @@ -872,10 +873,10 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, D3DTexture2D (float)dst.GetHeight()); D3D::context->RSSetViewports(1, &vp); - ID3D11PixelShader* pixelShader = (g_Config.iStereoMode == STEREO_ANAGLYPH) ? + ID3D11PixelShader* pixelShader = (g_Config.stereo_mode == StereoMode::Anaglyph) ? PixelShaderCache::GetAnaglyphProgram() : PixelShaderCache::GetColorCopyProgram(false); - ID3D11GeometryShader* geomShader = (g_ActiveConfig.iStereoMode == STEREO_QUADBUFFER) ? + ID3D11GeometryShader* geomShader = (g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer) ? GeometryShaderCache::GetCopyGeometryShader() : nullptr; D3D::drawShadedTexQuad(src_texture->GetSRV(), src.AsRECT(), src_width, src_height, pixelShader, diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp index a670a47111..af526fce36 100644 --- a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp @@ -133,7 +133,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms glActiveTexture(GL_TEXTURE9); - m_EFBLayers = (g_ActiveConfig.iStereoMode > 0) ? 2 : 1; + m_EFBLayers = (g_ActiveConfig.stereo_mode != StereoMode::Off) ? 2 : 1; m_efbFramebuffer.resize(m_EFBLayers); m_resolvedFramebuffer.resize(m_EFBLayers); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 2125102fe0..90952274e6 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -548,7 +548,7 @@ Renderer::Renderer() g_ogl_config.bSupports2DTextureStorageMultisample = true; g_Config.backend_info.bSupportsBitfield = true; g_Config.backend_info.bSupportsDynamicSamplerIndexing = g_ogl_config.bSupportsAEP; - if (g_ActiveConfig.iStereoMode > 0 && g_ActiveConfig.iMultisamples > 1 && + if (g_ActiveConfig.stereo_mode != StereoMode::Off && g_ActiveConfig.iMultisamples > 1 && !g_ogl_config.bSupports3DTextureStorageMultisample) { // GLES 3.1 can't support stereo rendering and MSAA @@ -725,7 +725,7 @@ Renderer::Renderer() s_last_multisamples = g_ActiveConfig.iMultisamples; s_MSAASamples = s_last_multisamples; - s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; + s_last_stereo_mode = g_ActiveConfig.stereo_mode != StereoMode::Off; // Handle VSync on/off s_vsync = g_ActiveConfig.IsVSync(); @@ -1216,12 +1216,13 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_t int src_width, int src_height) { OpenGLPostProcessing* post_processor = static_cast(m_post_processor.get()); - if (g_ActiveConfig.iStereoMode == STEREO_SBS || g_ActiveConfig.iStereoMode == STEREO_TAB) + if (g_ActiveConfig.stereo_mode == StereoMode::SBS || + g_ActiveConfig.stereo_mode == StereoMode::TAB) { TargetRectangle leftRc, rightRc; // Top-and-Bottom mode needs to compensate for inverted vertical screen coordinates. - if (g_ActiveConfig.iStereoMode == STEREO_TAB) + if (g_ActiveConfig.stereo_mode == StereoMode::TAB) std::tie(rightRc, leftRc) = ConvertStereoRectangle(dst); else std::tie(leftRc, rightRc) = ConvertStereoRectangle(dst); @@ -1229,7 +1230,7 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_t post_processor->BlitFromTexture(src, leftRc, src_texture, src_width, src_height, 0); post_processor->BlitFromTexture(src, rightRc, src_texture, src_width, src_height, 1); } - else if (g_ActiveConfig.iStereoMode == STEREO_QUADBUFFER) + else if (g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer) { glDrawBuffer(GL_BACK_LEFT); post_processor->BlitFromTexture(src, dst, src_texture, src_width, src_height, 0); @@ -1378,7 +1379,7 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region bool fb_needs_update = target_size_changed || s_last_multisamples != g_ActiveConfig.iMultisamples || stencil_buffer_enabled != BoundingBox::NeedsStencilBuffer() || - s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0); + s_last_stereo_mode != (g_ActiveConfig.stereo_mode != StereoMode::Off); if (window_resized || fb_needs_update) { @@ -1386,7 +1387,7 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region } if (fb_needs_update) { - s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; + s_last_stereo_mode = g_ActiveConfig.stereo_mode != StereoMode::Off; s_last_multisamples = g_ActiveConfig.iMultisamples; s_MSAASamples = s_last_multisamples; diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index aa2c60976b..8e4811bbc1 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -178,7 +178,7 @@ bool TextureCache::CompileShaders() " gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n" "}\n"; - const std::string geo_program = g_ActiveConfig.iStereoMode > 0 ? + const std::string geo_program = g_ActiveConfig.stereo_mode != StereoMode::Off ? "layout(triangles) in;\n" "layout(triangle_strip, max_vertices = 6) out;\n" "in vec3 v_uv0[3];\n" diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp index 10d37de6bc..25f8be7f6b 100644 --- a/Source/Core/VideoBackends/OGL/main.cpp +++ b/Source/Core/VideoBackends/OGL/main.cpp @@ -170,7 +170,7 @@ bool VideoBackend::Initialize(void* window_handle) InitInterface(); GLInterface->SetMode(GLInterfaceMode::MODE_DETECT); - if (!GLInterface->Create(window_handle, g_ActiveConfig.iStereoMode == STEREO_QUADBUFFER)) + if (!GLInterface->Create(window_handle, g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer)) return false; return true; diff --git a/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp b/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp index 305f0343f7..2efce3994f 100644 --- a/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp @@ -253,7 +253,7 @@ bool FramebufferManager::CreateEFBFramebuffer() { u32 efb_width = static_cast(std::max(g_renderer->GetTargetWidth(), 1)); u32 efb_height = static_cast(std::max(g_renderer->GetTargetHeight(), 1)); - u32 efb_layers = (g_ActiveConfig.iStereoMode != STEREO_OFF) ? 2 : 1; + u32 efb_layers = (g_ActiveConfig.stereo_mode != StereoMode::Off) ? 2 : 1; VkSampleCountFlagBits efb_samples = static_cast(g_ActiveConfig.iMultisamples); INFO_LOG(VIDEO, "EFB size: %ux%ux%u", efb_width, efb_height, efb_layers); diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index 18a0b415ed..e68c5d6b35 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -629,7 +629,8 @@ void Renderer::BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_r const TargetRectangle& src_rect, const Texture2D* src_tex) { VulkanPostProcessing* post_processor = static_cast(m_post_processor.get()); - if (g_ActiveConfig.iStereoMode == STEREO_SBS || g_ActiveConfig.iStereoMode == STEREO_TAB) + if (g_ActiveConfig.stereo_mode == StereoMode::SBS || + g_ActiveConfig.stereo_mode == StereoMode::TAB) { TargetRectangle left_rect; TargetRectangle right_rect; @@ -638,7 +639,7 @@ void Renderer::BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_r post_processor->BlitFromTexture(left_rect, src_rect, src_tex, 0, render_pass); post_processor->BlitFromTexture(right_rect, src_rect, src_tex, 1, render_pass); } - else if (g_ActiveConfig.iStereoMode == STEREO_QUADBUFFER) + else if (g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer) { post_processor->BlitFromTexture(dst_rect, src_rect, src_tex, -1, render_pass); } @@ -771,7 +772,7 @@ void Renderer::CheckForConfigChanges() // For quad-buffered stereo we need to change the layer count, so recreate the swap chain. if (m_swap_chain && - (g_ActiveConfig.iStereoMode == STEREO_QUADBUFFER) != m_swap_chain->IsStereoEnabled()) + (g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer) != m_swap_chain->IsStereoEnabled()) { g_command_buffer_mgr->WaitForGPUIdle(); m_swap_chain->RecreateSwapChain(); diff --git a/Source/Core/VideoBackends/Vulkan/ShaderCache.cpp b/Source/Core/VideoBackends/Vulkan/ShaderCache.cpp index ad5cdf523a..2c69267dfc 100644 --- a/Source/Core/VideoBackends/Vulkan/ShaderCache.cpp +++ b/Source/Core/VideoBackends/Vulkan/ShaderCache.cpp @@ -971,7 +971,7 @@ std::string ShaderCache::GetUtilityShaderHeader() const ss << "#define SSAA_ENABLED 1" << std::endl; } - u32 efb_layers = (g_ActiveConfig.iStereoMode != STEREO_OFF) ? 2 : 1; + u32 efb_layers = (g_ActiveConfig.stereo_mode != StereoMode::Off) ? 2 : 1; ss << "#define EFB_LAYERS " << efb_layers << std::endl; return ss.str(); @@ -1126,7 +1126,7 @@ bool ShaderCache::CompileSharedShaders() return false; } - if (g_ActiveConfig.iStereoMode != STEREO_OFF && g_vulkan_context->SupportsGeometryShaders()) + if (g_ActiveConfig.stereo_mode != StereoMode::Off && g_vulkan_context->SupportsGeometryShaders()) { m_screen_quad_geometry_shader = Util::CompileAndCreateGeometryShader(header + SCREEN_QUAD_GEOMETRY_SHADER_SOURCE); diff --git a/Source/Core/VideoBackends/Vulkan/SwapChain.cpp b/Source/Core/VideoBackends/Vulkan/SwapChain.cpp index abcd38c94a..58785130b0 100644 --- a/Source/Core/VideoBackends/Vulkan/SwapChain.cpp +++ b/Source/Core/VideoBackends/Vulkan/SwapChain.cpp @@ -321,7 +321,7 @@ bool SwapChain::CreateSwapChain() } // Select the number of image layers for Quad-Buffered stereoscopy - uint32_t image_layers = g_ActiveConfig.iStereoMode == STEREO_QUADBUFFER ? 2 : 1; + uint32_t image_layers = g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer ? 2 : 1; // Store the old/current swap chain when recreating for resize VkSwapchainKHR old_swap_chain = m_swap_chain; diff --git a/Source/Core/VideoCommon/GeometryShaderGen.cpp b/Source/Core/VideoCommon/GeometryShaderGen.cpp index 98335386fa..f5b7b1b35e 100644 --- a/Source/Core/VideoCommon/GeometryShaderGen.cpp +++ b/Source/Core/VideoCommon/GeometryShaderGen.cpp @@ -20,7 +20,7 @@ constexpr std::array primitives_d3d = {{"point", "line", "triang bool geometry_shader_uid_data::IsPassthrough() const { - const bool stereo = g_ActiveConfig.iStereoMode > 0; + const bool stereo = g_ActiveConfig.stereo_mode != StereoMode::Off; const bool wireframe = g_ActiveConfig.bWireFrame; return primitive_type >= static_cast(PrimitiveType::Triangles) && !stereo && !wireframe; } diff --git a/Source/Core/VideoCommon/GeometryShaderManager.cpp b/Source/Core/VideoCommon/GeometryShaderManager.cpp index 8a687d70d0..ca1dc992be 100644 --- a/Source/Core/VideoCommon/GeometryShaderManager.cpp +++ b/Source/Core/VideoCommon/GeometryShaderManager.cpp @@ -41,7 +41,7 @@ void GeometryShaderManager::Dirty() void GeometryShaderManager::SetConstants() { - if (s_projection_changed && g_ActiveConfig.iStereoMode > 0) + if (s_projection_changed && g_ActiveConfig.stereo_mode != StereoMode::Off) { s_projection_changed = false; diff --git a/Source/Core/VideoCommon/PostProcessing.cpp b/Source/Core/VideoCommon/PostProcessing.cpp index 0575402dd1..027ad85ab5 100644 --- a/Source/Core/VideoCommon/PostProcessing.cpp +++ b/Source/Core/VideoCommon/PostProcessing.cpp @@ -70,7 +70,8 @@ std::string PostProcessingShaderConfiguration::LoadShader(std::string shader) shader = g_ActiveConfig.sPostProcessingShader; m_current_shader = shader; - const std::string sub_dir = (g_Config.iStereoMode == STEREO_ANAGLYPH) ? ANAGLYPH_DIR DIR_SEP : ""; + const std::string sub_dir = + (g_Config.stereo_mode == StereoMode::Anaglyph) ? ANAGLYPH_DIR DIR_SEP : ""; // loading shader code std::string code; diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 2f6eccdf75..b0d7c07dd1 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -185,7 +185,7 @@ Renderer::ConvertStereoRectangle(const TargetRectangle& rc) const { // Resize target to half its original size TargetRectangle draw_rc = rc; - if (g_ActiveConfig.iStereoMode == STEREO_TAB) + if (g_ActiveConfig.stereo_mode == StereoMode::TAB) { // The height may be negative due to flipped rectangles int height = rc.bottom - rc.top; @@ -202,7 +202,7 @@ Renderer::ConvertStereoRectangle(const TargetRectangle& rc) const // Create two target rectangle offset to the sides of the backbuffer TargetRectangle left_rc = draw_rc; TargetRectangle right_rc = draw_rc; - if (g_ActiveConfig.iStereoMode == STEREO_TAB) + if (g_ActiveConfig.stereo_mode == StereoMode::TAB) { left_rc.top -= m_backbuffer_height / 4; left_rc.bottom -= m_backbuffer_height / 4; diff --git a/Source/Core/VideoCommon/ShaderGenCommon.cpp b/Source/Core/VideoCommon/ShaderGenCommon.cpp index 94819f3e34..c6b29c8088 100644 --- a/Source/Core/VideoCommon/ShaderGenCommon.cpp +++ b/Source/Core/VideoCommon/ShaderGenCommon.cpp @@ -13,7 +13,7 @@ ShaderHostConfig ShaderHostConfig::GetCurrent() bits.msaa = g_ActiveConfig.iMultisamples > 1; bits.ssaa = g_ActiveConfig.iMultisamples > 1 && g_ActiveConfig.bSSAA && g_ActiveConfig.backend_info.bSupportsSSAA; - bits.stereo = g_ActiveConfig.iStereoMode > 0; + bits.stereo = g_ActiveConfig.stereo_mode != StereoMode::Off; bits.wireframe = g_ActiveConfig.bWireFrame; bits.per_pixel_lighting = g_ActiveConfig.bEnablePixelLighting; bits.vertex_rounding = g_ActiveConfig.UseVertexRounding(); diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 07b6609282..313268715f 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -130,7 +130,7 @@ void TextureCacheBase::OnConfigChanged(VideoConfig& config) g_ActiveConfig.bTexFmtOverlayCenter); } - if ((config.iStereoMode > 0) != backup_config.stereo_3d || + if ((config.stereo_mode != StereoMode::Off) != backup_config.stereo_3d || config.bStereoEFBMonoDepth != backup_config.efb_mono_depth) { g_texture_cache->DeleteShaders(); @@ -222,7 +222,7 @@ void TextureCacheBase::SetBackupConfig(const VideoConfig& config) backup_config.texfmt_overlay_center = config.bTexFmtOverlayCenter; backup_config.hires_textures = config.bHiresTextures; backup_config.cache_hires_textures = config.bCacheHiresTextures; - backup_config.stereo_3d = config.iStereoMode > 0; + backup_config.stereo_3d = config.stereo_mode != StereoMode::Off; backup_config.efb_mono_depth = config.bStereoEFBMonoDepth; backup_config.gpu_texture_decoding = config.bEnableGPUTextureDecoding; } diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index fb9dd96130..5e5b313926 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -122,7 +122,7 @@ void VideoConfig::Refresh() sPostProcessingShader = Config::Get(Config::GFX_ENHANCE_POST_SHADER); bForceTrueColor = Config::Get(Config::GFX_ENHANCE_FORCE_TRUE_COLOR); - iStereoMode = Config::Get(Config::GFX_STEREO_MODE); + stereo_mode = static_cast(Config::Get(Config::GFX_STEREO_MODE)); iStereoDepth = Config::Get(Config::GFX_STEREO_DEPTH); iStereoConvergencePercentage = Config::Get(Config::GFX_STEREO_CONVERGENCE_PERCENTAGE); bStereoSwapEyes = Config::Get(Config::GFX_STEREO_SWAP_EYES); @@ -162,14 +162,14 @@ void VideoConfig::VerifyValidity() backend_info.AAModes.end()) iMultisamples = 1; - if (iStereoMode > 0) + if (stereo_mode != StereoMode::Off) { if (!backend_info.bSupportsGeometryShaders) { OSD::AddMessage( "Stereoscopic 3D isn't supported by your GPU, support for OpenGL 3.2 is required.", 10000); - iStereoMode = 0; + stereo_mode = StereoMode::Off; } } } diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 0a2f8d44f7..a0085ce809 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -32,14 +32,14 @@ enum class AspectMode Stretch, }; -enum StereoMode +enum class StereoMode { - STEREO_OFF = 0, - STEREO_SBS, - STEREO_TAB, - STEREO_ANAGLYPH, - STEREO_QUADBUFFER, - STEREO_3DVISION + Off, + SBS, + TAB, + Anaglyph, + QuadBuffer, + Nvidia3DVision }; struct ProjectionHackConfig final @@ -130,7 +130,7 @@ struct VideoConfig final int iSaveTargetId; // TODO: Should be dropped // Stereoscopy - int iStereoMode; + StereoMode stereo_mode; int iStereoDepth; int iStereoConvergence; int iStereoConvergencePercentage;