Skip to content
Permalink
Browse files
Merge pull request #6186 from lioncash/enum-class
VideoConfig: Make AspectMode and StereoMode enum classes
  • Loading branch information
leoetlino committed Nov 19, 2017
2 parents a755467 + 5337e58 commit 80bcc0d
Show file tree
Hide file tree
Showing 26 changed files with 123 additions and 115 deletions.
@@ -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<int>(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<int>(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);
@@ -22,9 +22,9 @@ const ConfigInfo<int> GFX_ADAPTER{{System::GFX, "Hardware", "Adapter"}, 0};

const ConfigInfo<bool> GFX_WIDESCREEN_HACK{{System::GFX, "Settings", "wideScreenHack"}, false};
const ConfigInfo<int> GFX_ASPECT_RATIO{{System::GFX, "Settings", "AspectRatio"},
static_cast<int>(ASPECT_AUTO)};
static_cast<int>(AspectMode::Auto)};
const ConfigInfo<int> GFX_SUGGESTED_ASPECT_RATIO{{System::GFX, "Settings", "SuggestedAspectRatio"},
static_cast<int>(ASPECT_AUTO)};
static_cast<int>(AspectMode::Auto)};
const ConfigInfo<bool> GFX_CROP{{System::GFX, "Settings", "Crop"}, false};
const ConfigInfo<int> GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES{
{System::GFX, "Settings", "SafeTextureCacheColorSamples"}, 128};
@@ -146,7 +146,7 @@ void EnhancementsWidget::LoadSettings()

// Post Processing Shader
std::vector<std::string> 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);
@@ -221,7 +221,10 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_TOGGLE_CROP))
g_Config.bCrop = !g_Config.bCrop;
if (IsHotkey(HK_TOGGLE_AR))
g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3;
{
g_Config.aspect_mode =
static_cast<AspectMode>((static_cast<int>(g_Config.aspect_mode) + 1) & 3);
}
if (IsHotkey(HK_TOGGLE_EFBCOPIES))
g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam;
if (IsHotkey(HK_TOGGLE_XFBCOPIES))
@@ -261,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;
}
}
}
@@ -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<int>(STEREO_SBS));
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(StereoMode::SBS));
}
else
{
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(STEREO_OFF));
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(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<int>(STEREO_TAB));
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(StereoMode::TAB));
}
else
{
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(STEREO_OFF));
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(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<int>(STEREO_ANAGLYPH));
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(StereoMode::Anaglyph));
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, std::string("dubois"));
}
else
{
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(STEREO_OFF));
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(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<int>(STEREO_3DVISION));
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(StereoMode::Nvidia3DVision));
}
else
{
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(STEREO_OFF));
Config::SetCurrent(Config::GFX_STEREO_MODE, static_cast<int>(StereoMode::Off));
}
}

@@ -1199,7 +1199,7 @@ void VideoConfigDiag::CreateDescriptionArea(wxPanel* const page, wxBoxSizer* con
void VideoConfigDiag::PopulatePostProcessingShaders()
{
std::vector<std::string> 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));
@@ -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?
@@ -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 =
@@ -37,11 +37,11 @@ LinearDiskCache<GeometryShaderUid, u8> 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;
@@ -205,7 +205,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<FramebufferManager>(m_target_width, m_target_height);
@@ -654,7 +654,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;
@@ -672,7 +672,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);

@@ -806,7 +806,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);
@@ -828,7 +829,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);
@@ -868,10 +869,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,
@@ -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);

@@ -546,7 +546,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
@@ -723,7 +723,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();
@@ -1214,20 +1214,21 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_t
int src_width, int src_height)
{
OpenGLPostProcessing* post_processor = static_cast<OpenGLPostProcessing*>(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);

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);
@@ -1376,15 +1377,15 @@ 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)
{
UpdateDrawRectangle();
}
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;

@@ -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"
@@ -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;
@@ -251,7 +251,7 @@ bool FramebufferManager::CreateEFBFramebuffer()
{
u32 efb_width = static_cast<u32>(std::max(g_renderer->GetTargetWidth(), 1));
u32 efb_height = static_cast<u32>(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<VkSampleCountFlagBits>(g_ActiveConfig.iMultisamples);
INFO_LOG(VIDEO, "EFB size: %ux%ux%u", efb_width, efb_height, efb_layers);

0 comments on commit 80bcc0d

Please sign in to comment.