@@ -624,7 +624,8 @@ void Renderer::BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_r
const TargetRectangle& src_rect, const Texture2D* src_tex)
{
VulkanPostProcessing* post_processor = static_cast<VulkanPostProcessing*>(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;
@@ -633,7 +634,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);
}
@@ -712,21 +713,22 @@ void Renderer::CheckForSurfaceChange()
void Renderer::CheckForConfigChanges()
{
// Save the video config so we can compare against to determine which settings have changed.
int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
int old_aspect_ratio = g_ActiveConfig.iAspectRatio;
int old_efb_scale = g_ActiveConfig.iEFBScale;
bool old_force_filtering = g_ActiveConfig.bForceFiltering;
const int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
const AspectMode old_aspect_mode = g_ActiveConfig.aspect_mode;
const int old_efb_scale = g_ActiveConfig.iEFBScale;
const bool old_force_filtering = g_ActiveConfig.bForceFiltering;

// Copy g_Config to g_ActiveConfig.
// NOTE: This can potentially race with the UI thread, however if it does, the changes will be
// delayed until the next time CheckForConfigChanges is called.
UpdateActiveConfig();

// Determine which (if any) settings have changed.
bool anisotropy_changed = old_anisotropy != g_ActiveConfig.iMaxAnisotropy;
bool force_texture_filtering_changed = old_force_filtering != g_ActiveConfig.bForceFiltering;
bool efb_scale_changed = old_efb_scale != g_ActiveConfig.iEFBScale;
bool aspect_changed = old_aspect_ratio != g_ActiveConfig.iAspectRatio;
const bool anisotropy_changed = old_anisotropy != g_ActiveConfig.iMaxAnisotropy;
const bool force_texture_filtering_changed =
old_force_filtering != g_ActiveConfig.bForceFiltering;
const bool efb_scale_changed = old_efb_scale != g_ActiveConfig.iEFBScale;
const bool aspect_changed = old_aspect_mode != g_ActiveConfig.aspect_mode;

// Update texture cache settings with any changed options.
TextureCache::GetInstance()->OnConfigChanged(g_ActiveConfig);
@@ -765,7 +767,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();
@@ -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);
@@ -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;
@@ -20,7 +20,7 @@ constexpr std::array<const char*, 4> 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<u32>(PrimitiveType::Triangles) && !stereo && !wireframe;
}
@@ -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;

@@ -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;
@@ -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;
@@ -312,19 +312,20 @@ void Renderer::DrawDebugText()
break;
}
const char* ar_text = "";
switch (g_ActiveConfig.iAspectRatio)
switch (g_ActiveConfig.aspect_mode)
{
case ASPECT_AUTO:
case AspectMode::Auto:
ar_text = "Auto";
break;
case ASPECT_STRETCH:
case AspectMode::Stretch:
ar_text = "Stretch";
break;
case ASPECT_ANALOG:
case AspectMode::Analog:
ar_text = "Force 4:3";
break;
case ASPECT_ANALOG_WIDE:
case AspectMode::AnalogWide:
ar_text = "Force 16:9";
break;
}

const char* const efbcopy_text = g_ActiveConfig.bSkipEFBCopyToRam ? "to Texture" : "to RAM";
@@ -381,15 +382,15 @@ void Renderer::DrawDebugText()

float Renderer::CalculateDrawAspectRatio() const
{
if (g_ActiveConfig.iAspectRatio == ASPECT_STRETCH)
if (g_ActiveConfig.aspect_mode == AspectMode::Stretch)
{
// If stretch is enabled, we prefer the aspect ratio of the window.
return (static_cast<float>(m_backbuffer_width) / static_cast<float>(m_backbuffer_height));
}

// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
if (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE ||
(g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide))
if (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
(g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide))
{
return AspectToWidescreen(VideoInterface::GetAspectRatio());
}
@@ -428,21 +429,20 @@ void Renderer::UpdateDrawRectangle()
float source_aspect = VideoInterface::GetAspectRatio();
if (m_aspect_wide)
source_aspect = AspectToWidescreen(source_aspect);
float target_aspect;
float target_aspect = 0.0f;

switch (g_ActiveConfig.iAspectRatio)
switch (g_ActiveConfig.aspect_mode)
{
case ASPECT_STRETCH:
case AspectMode::Stretch:
target_aspect = win_width / win_height;
break;
case ASPECT_ANALOG:
case AspectMode::Analog:
target_aspect = VideoInterface::GetAspectRatio();
break;
case ASPECT_ANALOG_WIDE:
case AspectMode::AnalogWide:
target_aspect = AspectToWidescreen(VideoInterface::GetAspectRatio());
break;
default:
// ASPECT_AUTO
case AspectMode::Auto:
target_aspect = source_aspect;
break;
}
@@ -475,10 +475,10 @@ void Renderer::UpdateDrawRectangle()
draw_height = crop_height = 1;

// crop the picture to a standard aspect ratio
if (g_ActiveConfig.bCrop && g_ActiveConfig.iAspectRatio != ASPECT_STRETCH)
if (g_ActiveConfig.bCrop && g_ActiveConfig.aspect_mode != AspectMode::Stretch)
{
float expected_aspect = (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE ||
(g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide)) ?
float expected_aspect = (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
(g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide)) ?
(16.0f / 9.0f) :
(4.0f / 3.0f);
if (crop_width / crop_height >= expected_aspect)
@@ -550,8 +550,8 @@ std::tuple<int, int> Renderer::CalculateOutputDimensions(int width, int height)
{
// Force 4:3 or 16:9 by cropping the image.
float current_aspect = scaled_width / scaled_height;
float expected_aspect = (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE ||
(g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide)) ?
float expected_aspect = (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
(g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide)) ?
(16.0f / 9.0f) :
(4.0f / 3.0f);
if (current_aspect > expected_aspect)
@@ -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();
@@ -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;
}
@@ -61,11 +61,11 @@ void VideoConfig::Refresh()
iAdapter = Config::Get(Config::GFX_ADAPTER);

bWidescreenHack = Config::Get(Config::GFX_WIDESCREEN_HACK);
const int aspect_ratio = Config::Get(Config::GFX_ASPECT_RATIO);
if (aspect_ratio == ASPECT_AUTO)
iAspectRatio = Config::Get(Config::GFX_SUGGESTED_ASPECT_RATIO);
const auto config_aspect_mode = static_cast<AspectMode>(Config::Get(Config::GFX_ASPECT_RATIO));
if (config_aspect_mode == AspectMode::Auto)
aspect_mode = static_cast<AspectMode>(Config::Get(Config::GFX_SUGGESTED_ASPECT_RATIO));
else
iAspectRatio = aspect_ratio;
aspect_mode = config_aspect_mode;
bCrop = Config::Get(Config::GFX_CROP);
iSafeTextureCache_ColorSamples = Config::Get(Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES);
bShowFPS = Config::Get(Config::GFX_SHOW_FPS);
@@ -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<StereoMode>(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;
}
}
}
@@ -24,22 +24,22 @@

constexpr int EFB_SCALE_AUTO_INTEGRAL = 0;

enum AspectMode
enum class AspectMode
{
ASPECT_AUTO = 0,
ASPECT_ANALOG_WIDE = 1,
ASPECT_ANALOG = 2,
ASPECT_STRETCH = 3,
Auto,
AnalogWide,
Analog,
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
@@ -63,7 +63,7 @@ struct VideoConfig final
// General
bool bVSync;
bool bWidescreenHack;
int iAspectRatio;
AspectMode aspect_mode;
bool bCrop; // Aspect ratio controls.
bool bShaderCache;

@@ -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;