2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2009-09-13 02:21:35 -06:00
|
|
|
// IMPORTANT: UI etc should modify g_Config. Graphics code should read g_ActiveConfig.
|
|
|
|
// The reason for this is to get rid of race conditions etc when the configuration
|
|
|
|
// changes in the middle of a frame. This is done by copying g_Config to g_ActiveConfig
|
|
|
|
// at the start of every frame. Noone should ever change members of g_ActiveConfig
|
|
|
|
// directly.
|
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2022-03-15 00:46:58 -06:00
|
|
|
#include <optional>
|
2009-07-12 15:58:32 -06:00
|
|
|
#include <string>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <vector>
|
|
|
|
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2022-03-15 00:46:58 -06:00
|
|
|
#include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h"
|
2021-09-03 22:43:19 -06:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2009-07-12 15:58:32 -06:00
|
|
|
|
2017-07-03 08:32:02 -06:00
|
|
|
constexpr int EFB_SCALE_AUTO_INTEGRAL = 0;
|
|
|
|
|
2018-01-08 04:04:12 -07:00
|
|
|
enum class AspectMode : int
|
2010-01-13 14:11:02 -07:00
|
|
|
{
|
2017-11-10 20:45:32 -07:00
|
|
|
Auto,
|
|
|
|
AnalogWide,
|
|
|
|
Analog,
|
|
|
|
Stretch,
|
2010-01-13 14:11:02 -07:00
|
|
|
};
|
|
|
|
|
2018-01-08 04:04:12 -07:00
|
|
|
enum class StereoMode : int
|
2014-10-31 08:25:42 -06:00
|
|
|
{
|
2017-11-10 20:55:00 -07:00
|
|
|
Off,
|
|
|
|
SBS,
|
|
|
|
TAB,
|
|
|
|
Anaglyph,
|
|
|
|
QuadBuffer,
|
2019-10-01 19:07:17 -06:00
|
|
|
Passive
|
2014-10-31 08:25:42 -06:00
|
|
|
};
|
|
|
|
|
2018-03-16 07:10:22 -06:00
|
|
|
enum class ShaderCompilationMode : int
|
2018-03-01 01:03:24 -07:00
|
|
|
{
|
2018-03-16 07:10:22 -06:00
|
|
|
Synchronous,
|
|
|
|
SynchronousUberShaders,
|
|
|
|
AsynchronousUberShaders,
|
|
|
|
AsynchronousSkipRendering
|
2018-03-01 01:03:24 -07:00
|
|
|
};
|
|
|
|
|
2022-11-13 22:01:19 -07:00
|
|
|
enum class TextureFilteringMode : int
|
|
|
|
{
|
|
|
|
Default,
|
|
|
|
Nearest,
|
|
|
|
Linear,
|
|
|
|
};
|
|
|
|
|
2022-07-23 16:27:24 -06:00
|
|
|
enum class TriState : int
|
|
|
|
{
|
|
|
|
Off,
|
|
|
|
On,
|
|
|
|
Auto
|
|
|
|
};
|
|
|
|
|
2023-01-29 09:06:25 -07:00
|
|
|
// Bitmask containing information about which configuration has changed for the backend.
|
|
|
|
enum ConfigChangeBits : u32
|
|
|
|
{
|
|
|
|
CONFIG_CHANGE_BIT_HOST_CONFIG = (1 << 0),
|
|
|
|
CONFIG_CHANGE_BIT_MULTISAMPLES = (1 << 1),
|
|
|
|
CONFIG_CHANGE_BIT_STEREO_MODE = (1 << 2),
|
|
|
|
CONFIG_CHANGE_BIT_TARGET_SIZE = (1 << 3),
|
|
|
|
CONFIG_CHANGE_BIT_ANISOTROPY = (1 << 4),
|
|
|
|
CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING = (1 << 5),
|
|
|
|
CONFIG_CHANGE_BIT_VSYNC = (1 << 6),
|
2023-01-30 04:49:23 -07:00
|
|
|
CONFIG_CHANGE_BIT_BBOX = (1 << 7),
|
|
|
|
CONFIG_CHANGE_BIT_ASPECT_RATIO = (1 << 8),
|
|
|
|
CONFIG_CHANGE_BIT_POST_PROCESSING_SHADER = (1 << 9),
|
2023-01-29 09:06:25 -07:00
|
|
|
};
|
|
|
|
|
2009-02-28 09:33:59 -07:00
|
|
|
// NEVER inherit from this class.
|
2014-03-16 15:00:29 -06:00
|
|
|
struct VideoConfig final
|
2008-10-22 15:23:40 -06:00
|
|
|
{
|
2021-09-03 22:43:19 -06:00
|
|
|
VideoConfig() = default;
|
2017-05-18 06:59:38 -06:00
|
|
|
void Refresh();
|
2011-02-13 06:42:59 -07:00
|
|
|
void VerifyValidity();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2010-06-04 19:38:22 -06:00
|
|
|
// General
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bVSync = false;
|
|
|
|
bool bVSyncActive = false;
|
|
|
|
bool bWidescreenHack = false;
|
|
|
|
AspectMode aspect_mode{};
|
|
|
|
AspectMode suggested_aspect_mode{};
|
|
|
|
bool bCrop = false; // Aspect ratio controls.
|
|
|
|
bool bShaderCache = false;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2008-10-26 07:35:34 -06:00
|
|
|
// Enhancements
|
2021-09-03 22:43:19 -06:00
|
|
|
u32 iMultisamples = 0;
|
|
|
|
bool bSSAA = false;
|
|
|
|
int iEFBScale = 0;
|
2022-11-13 22:01:19 -07:00
|
|
|
TextureFilteringMode texture_filtering_mode = TextureFilteringMode::Default;
|
2021-09-03 22:43:19 -06:00
|
|
|
int iMaxAnisotropy = 0;
|
2009-06-08 13:42:25 -06:00
|
|
|
std::string sPostProcessingShader;
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bForceTrueColor = false;
|
|
|
|
bool bDisableCopyFilter = false;
|
|
|
|
bool bArbitraryMipmapDetection = false;
|
|
|
|
float fArbitraryMipmapDetectionThreshold = 0;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2008-10-26 07:35:34 -06:00
|
|
|
// Information
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bShowFPS = false;
|
2022-12-23 17:52:53 -07:00
|
|
|
bool bShowFTimes = false;
|
2022-10-26 13:17:15 -06:00
|
|
|
bool bShowVPS = false;
|
2022-12-23 17:52:53 -07:00
|
|
|
bool bShowVTimes = false;
|
|
|
|
bool bShowGraphs = false;
|
2022-10-26 13:17:15 -06:00
|
|
|
bool bShowSpeed = false;
|
|
|
|
bool bShowSpeedColors = false;
|
|
|
|
int iPerfSampleUSec = 0;
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bShowNetPlayPing = false;
|
|
|
|
bool bShowNetPlayMessages = false;
|
|
|
|
bool bOverlayStats = false;
|
|
|
|
bool bOverlayProjStats = false;
|
2021-11-27 18:09:55 -07:00
|
|
|
bool bOverlayScissorStats = false;
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bTexFmtOverlayEnable = false;
|
|
|
|
bool bTexFmtOverlayCenter = false;
|
|
|
|
bool bLogRenderTimeToFile = false;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2010-06-04 19:38:22 -06:00
|
|
|
// Render
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bWireFrame = false;
|
|
|
|
bool bDisableFog = false;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2010-06-04 19:38:22 -06:00
|
|
|
// Utility
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bDumpTextures = false;
|
|
|
|
bool bDumpMipmapTextures = false;
|
|
|
|
bool bDumpBaseTextures = false;
|
|
|
|
bool bHiresTextures = false;
|
|
|
|
bool bCacheHiresTextures = false;
|
|
|
|
bool bDumpEFBTarget = false;
|
|
|
|
bool bDumpXFBTarget = false;
|
|
|
|
bool bDumpFramesAsImages = false;
|
|
|
|
bool bUseFFV1 = false;
|
2017-02-21 12:04:22 -07:00
|
|
|
std::string sDumpCodec;
|
2022-04-08 16:45:49 -06:00
|
|
|
std::string sDumpPixelFormat;
|
2017-12-29 07:00:55 -07:00
|
|
|
std::string sDumpEncoder;
|
2017-02-21 03:43:49 -07:00
|
|
|
std::string sDumpFormat;
|
2017-02-21 12:37:36 -07:00
|
|
|
std::string sDumpPath;
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bInternalResolutionFrameDumps = false;
|
|
|
|
bool bBorderlessFullscreen = false;
|
|
|
|
bool bEnableGPUTextureDecoding = false;
|
2022-07-24 02:51:22 -06:00
|
|
|
bool bPreferVSForLinePointExpansion = false;
|
2021-09-03 22:43:19 -06:00
|
|
|
int iBitrateKbps = 0;
|
2022-04-06 23:00:38 -06:00
|
|
|
bool bGraphicMods = false;
|
2022-03-15 00:46:58 -06:00
|
|
|
std::optional<GraphicsModGroupConfig> graphics_mod_config;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2010-06-04 19:38:22 -06:00
|
|
|
// Hacks
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bEFBAccessEnable = false;
|
|
|
|
bool bEFBAccessDeferInvalidation = false;
|
|
|
|
bool bPerfQueriesEnable = false;
|
|
|
|
bool bBBoxEnable = false;
|
|
|
|
bool bForceProgressive = false;
|
2022-07-26 02:57:30 -06:00
|
|
|
bool bCPUCull = false;
|
2021-09-03 22:43:19 -06:00
|
|
|
|
|
|
|
bool bEFBEmulateFormatChanges = false;
|
|
|
|
bool bSkipEFBCopyToRam = false;
|
|
|
|
bool bSkipXFBCopyToRam = false;
|
|
|
|
bool bDisableCopyToVRAM = false;
|
|
|
|
bool bDeferEFBCopies = false;
|
|
|
|
bool bImmediateXFB = false;
|
|
|
|
bool bSkipPresentingDuplicateXFBs = false;
|
|
|
|
bool bCopyEFBScaled = false;
|
|
|
|
int iSafeTextureCache_ColorSamples = 0;
|
|
|
|
float fAspectRatioHackW = 1; // Initial value needed for the first frame
|
|
|
|
float fAspectRatioHackH = 1;
|
|
|
|
bool bEnablePixelLighting = false;
|
|
|
|
bool bFastDepthCalc = false;
|
|
|
|
bool bVertexRounding = false;
|
2023-01-13 23:56:37 -07:00
|
|
|
bool bVISkip = false;
|
2021-09-03 22:43:19 -06:00
|
|
|
int iEFBAccessTileSize = 0;
|
|
|
|
int iSaveTargetId = 0; // TODO: Should be dropped
|
|
|
|
u32 iMissingColorValue = 0;
|
2021-07-29 18:43:35 -06:00
|
|
|
bool bFastTextureSampling = false;
|
2022-11-06 22:28:46 -07:00
|
|
|
#ifdef __APPLE__
|
|
|
|
bool bNoMipmapping = false; // Used by macOS fifoci to work around an M1 bug
|
|
|
|
#endif
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2014-11-24 04:01:21 -07:00
|
|
|
// Stereoscopy
|
2021-09-03 22:43:19 -06:00
|
|
|
StereoMode stereo_mode{};
|
|
|
|
int iStereoDepth = 0;
|
|
|
|
int iStereoConvergence = 0;
|
|
|
|
int iStereoConvergencePercentage = 0;
|
|
|
|
bool bStereoSwapEyes = false;
|
|
|
|
bool bStereoEFBMonoDepth = false;
|
|
|
|
int iStereoDepthPercentage = 0;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2009-09-13 02:21:35 -06:00
|
|
|
// D3D only config, mostly to be merged into the above
|
2021-09-03 22:43:19 -06:00
|
|
|
int iAdapter = 0;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2022-07-23 16:27:24 -06:00
|
|
|
// Metal only config
|
|
|
|
TriState iManuallyUploadBuffers = TriState::Auto;
|
2022-10-24 16:40:32 -06:00
|
|
|
TriState iUsePresentDrawable = TriState::Auto;
|
2022-07-23 16:27:24 -06:00
|
|
|
|
2016-08-13 06:08:46 -06:00
|
|
|
// Enable API validation layers, currently only supported with Vulkan.
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bEnableValidationLayer = false;
|
2016-08-13 06:08:46 -06:00
|
|
|
|
|
|
|
// Multithreaded submission, currently only supported with Vulkan.
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bBackendMultithreading = true;
|
2016-08-13 06:08:46 -06:00
|
|
|
|
2016-08-13 06:57:50 -06:00
|
|
|
// Early command buffer execution interval in number of draws.
|
|
|
|
// Currently only supported with Vulkan.
|
2021-09-03 22:43:19 -06:00
|
|
|
int iCommandBufferExecuteInterval = 0;
|
2016-08-13 06:57:50 -06:00
|
|
|
|
2018-03-01 01:03:24 -07:00
|
|
|
// Shader compilation settings.
|
2021-09-03 22:43:19 -06:00
|
|
|
bool bWaitForShadersBeforeStarting = false;
|
|
|
|
ShaderCompilationMode iShaderCompilationMode{};
|
2017-06-13 04:07:09 -06:00
|
|
|
|
|
|
|
// Number of shader compiler threads.
|
|
|
|
// 0 disables background compilation.
|
|
|
|
// -1 uses an automatic number based on the CPU threads.
|
2021-09-03 22:43:19 -06:00
|
|
|
int iShaderCompilerThreads = 0;
|
|
|
|
int iShaderPrecompilerThreads = 0;
|
2017-06-13 04:07:09 -06:00
|
|
|
|
2009-09-13 15:18:04 -06:00
|
|
|
// Static config per API
|
2011-05-31 14:16:59 -06:00
|
|
|
// TODO: Move this out of VideoConfig
|
2011-03-21 13:57:31 -06:00
|
|
|
struct
|
2010-11-21 07:47:28 -07:00
|
|
|
{
|
2021-09-03 22:43:19 -06:00
|
|
|
APIType api_type = APIType::Nothing;
|
2022-10-22 18:48:50 -06:00
|
|
|
std::string DisplayName;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2013-09-22 09:49:26 -06:00
|
|
|
std::vector<std::string> Adapters; // for D3D
|
2017-06-07 05:30:39 -06:00
|
|
|
std::vector<u32> AAModes;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-06-20 05:54:44 -06:00
|
|
|
// TODO: merge AdapterName and Adapters array
|
|
|
|
std::string AdapterName; // for OpenGL
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2021-09-03 22:43:19 -06:00
|
|
|
u32 MaxTextureSize = 16384;
|
|
|
|
bool bUsesLowerLeftOrigin = false;
|
2023-01-25 23:06:39 -07:00
|
|
|
bool bUsesExplictQuadBuffering = false;
|
2021-09-03 22:43:19 -06:00
|
|
|
|
|
|
|
bool bSupportsExclusiveFullscreen = false;
|
|
|
|
bool bSupportsDualSourceBlend = false;
|
|
|
|
bool bSupportsPrimitiveRestart = false;
|
|
|
|
bool bSupportsGeometryShaders = false;
|
|
|
|
bool bSupportsComputeShaders = false;
|
|
|
|
bool bSupports3DVision = false;
|
|
|
|
bool bSupportsEarlyZ = false; // needed by PixelShaderGen, so must stay in VideoCommon
|
|
|
|
bool bSupportsBindingLayout = false; // Needed by ShaderGen, so must stay in VideoCommon
|
|
|
|
bool bSupportsBBox = false;
|
|
|
|
bool bSupportsGSInstancing = false; // Needed by GeometryShaderGen, so must stay in VideoCommon
|
|
|
|
bool bSupportsPostProcessing = false;
|
|
|
|
bool bSupportsPaletteConversion = false;
|
|
|
|
bool bSupportsClipControl = false; // Needed by VertexShaderGen, so must stay in VideoCommon
|
|
|
|
bool bSupportsSSAA = false;
|
|
|
|
bool bSupportsFragmentStoresAndAtomics = false; // a.k.a. OpenGL SSBOs a.k.a. Direct3D UAVs
|
|
|
|
bool bSupportsDepthClamp = false; // Needed by VertexShaderGen, so must stay in VideoCommon
|
|
|
|
bool bSupportsReversedDepthRange = false;
|
|
|
|
bool bSupportsLogicOp = false;
|
|
|
|
bool bSupportsMultithreading = false;
|
|
|
|
bool bSupportsGPUTextureDecoding = false;
|
|
|
|
bool bSupportsST3CTextures = false;
|
|
|
|
bool bSupportsCopyToVram = false;
|
|
|
|
bool bSupportsBitfield = false; // Needed by UberShaders, so must stay in VideoCommon
|
|
|
|
// Needed by UberShaders, so must stay in VideoCommon
|
|
|
|
bool bSupportsDynamicSamplerIndexing = false;
|
|
|
|
bool bSupportsBPTCTextures = false;
|
|
|
|
bool bSupportsFramebufferFetch = false; // Used as an alternative to dual-source blend on GLES
|
|
|
|
bool bSupportsBackgroundCompiling = false;
|
|
|
|
bool bSupportsLargePoints = false;
|
|
|
|
bool bSupportsPartialDepthCopies = false;
|
|
|
|
bool bSupportsDepthReadback = false;
|
|
|
|
bool bSupportsShaderBinaries = false;
|
|
|
|
bool bSupportsPipelineCacheData = false;
|
2021-11-13 21:10:20 -07:00
|
|
|
bool bSupportsCoarseDerivatives = false;
|
2021-11-13 21:10:55 -07:00
|
|
|
bool bSupportsTextureQueryLevels = false;
|
2021-08-06 21:26:51 -06:00
|
|
|
bool bSupportsLodBiasInSampler = false;
|
2022-01-30 19:44:57 -07:00
|
|
|
bool bSupportsSettingObjectNames = false;
|
2022-06-21 01:07:35 -06:00
|
|
|
bool bSupportsPartialMultisampleResolve = false;
|
2022-06-18 00:09:35 -06:00
|
|
|
bool bSupportsDynamicVertexLoader = false;
|
2022-07-22 23:47:04 -06:00
|
|
|
bool bSupportsVSLinePointExpand = false;
|
2022-12-11 00:15:15 -07:00
|
|
|
bool bSupportsGLLayerInFS = true;
|
2010-11-21 07:47:28 -07:00
|
|
|
} backend_info;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2012-09-28 15:19:50 -06:00
|
|
|
// Utility
|
2022-07-22 23:47:04 -06:00
|
|
|
bool UseVSForLinePointExpand() const
|
|
|
|
{
|
|
|
|
if (!backend_info.bSupportsVSLinePointExpand)
|
|
|
|
return false;
|
2022-07-24 02:51:22 -06:00
|
|
|
if (!backend_info.bSupportsGeometryShaders)
|
|
|
|
return true;
|
|
|
|
return bPreferVSForLinePointExpansion;
|
2022-07-22 23:47:04 -06:00
|
|
|
}
|
2017-04-30 02:07:57 -06:00
|
|
|
bool MultisamplingEnabled() const { return iMultisamples > 1; }
|
2014-10-07 08:43:32 -06:00
|
|
|
bool ExclusiveFullscreenEnabled() const
|
|
|
|
{
|
|
|
|
return backend_info.bSupportsExclusiveFullscreen && !bBorderlessFullscreen;
|
|
|
|
}
|
2016-11-27 01:14:57 -07:00
|
|
|
bool UseGPUTextureDecoding() const
|
|
|
|
{
|
|
|
|
return backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding;
|
|
|
|
}
|
2017-07-03 08:32:02 -06:00
|
|
|
bool UseVertexRounding() const { return bVertexRounding && iEFBScale != 1; }
|
2022-12-27 14:45:13 -07:00
|
|
|
bool ManualTextureSamplingWithCustomTextureSizes() const
|
2021-08-01 18:31:40 -06:00
|
|
|
{
|
2022-12-27 14:45:13 -07:00
|
|
|
// If manual texture sampling is disabled, we don't need to do anything.
|
2021-08-01 18:31:40 -06:00
|
|
|
if (bFastTextureSampling)
|
|
|
|
return false;
|
2022-12-27 14:45:13 -07:00
|
|
|
// Hi-res textures break the wrapping logic used by manual texture sampling, as a texture's
|
|
|
|
// size won't match the size the game sets.
|
|
|
|
if (bHiresTextures)
|
|
|
|
return true;
|
|
|
|
// Hi-res EFB copies (but not native-resolution EFB copies at higher internal resolutions)
|
|
|
|
// also result in different texture sizes that need special handling.
|
2021-08-01 18:31:40 -06:00
|
|
|
if (iEFBScale != 1 && bCopyEFBScaled)
|
|
|
|
return true;
|
2022-12-27 14:45:13 -07:00
|
|
|
// Stereoscopic 3D changes the number of layers some textures have (EFB copies have 2 layers,
|
|
|
|
// while game textures still have 1), meaning bounds checks need to be added.
|
|
|
|
if (stereo_mode != StereoMode::Off)
|
|
|
|
return true;
|
|
|
|
// Otherwise, manual texture sampling can use the sizes games specify directly.
|
|
|
|
return false;
|
2021-08-01 18:31:40 -06:00
|
|
|
}
|
2018-03-16 07:10:22 -06:00
|
|
|
bool UsingUberShaders() const;
|
2017-06-13 04:07:09 -06:00
|
|
|
u32 GetShaderCompilerThreads() const;
|
2017-07-26 21:15:38 -06:00
|
|
|
u32 GetShaderPrecompilerThreads() const;
|
2008-10-22 15:23:40 -06:00
|
|
|
};
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2009-09-13 04:18:01 -06:00
|
|
|
extern VideoConfig g_Config;
|
|
|
|
extern VideoConfig g_ActiveConfig;
|
2009-09-13 02:21:35 -06:00
|
|
|
|
|
|
|
// Called every frame.
|
|
|
|
void UpdateActiveConfig();
|
2023-01-29 09:06:25 -07:00
|
|
|
void CheckForConfigChanges();
|