| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#pragma once |
| 11 |
|
| 12 |
#include <optional> |
| 13 |
#include <string> |
| 14 |
#include <vector> |
| 15 |
|
| 16 |
#include "Common/CommonTypes.h" |
| 17 |
#include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h" |
| 18 |
#include "VideoCommon/VideoCommon.h" |
| 19 |
|
| 20 |
constexpr int EFB_SCALE_AUTO_INTEGRAL = 0; |
| 21 |
|
| 22 |
enum class AspectMode : int |
| 23 |
{ |
| 24 |
Auto, |
| 25 |
ForceWide, |
| 26 |
ForceStandard, |
| 27 |
Stretch, |
| 28 |
Custom, |
| 29 |
CustomStretch, |
| 30 |
Raw, |
| 31 |
}; |
| 32 |
|
| 33 |
enum class StereoMode : int |
| 34 |
{ |
| 35 |
Off, |
| 36 |
SideBySide, |
| 37 |
TopAndBottom, |
| 38 |
Anaglyph, |
| 39 |
QuadBuffer, |
| 40 |
Passive |
| 41 |
}; |
| 42 |
|
| 43 |
enum class ShaderCompilationMode : int |
| 44 |
{ |
| 45 |
Synchronous, |
| 46 |
SynchronousUberShaders, |
| 47 |
AsynchronousUberShaders, |
| 48 |
AsynchronousSkipRendering |
| 49 |
}; |
| 50 |
|
| 51 |
enum class TextureFilteringMode : int |
| 52 |
{ |
| 53 |
Default, |
| 54 |
Nearest, |
| 55 |
Linear, |
| 56 |
}; |
| 57 |
|
| 58 |
enum class AnisotropicFilteringMode : int |
| 59 |
{ |
| 60 |
Default = -1, |
| 61 |
Force1x = 0, |
| 62 |
Force2x = 1, |
| 63 |
Force4x = 2, |
| 64 |
Force8x = 3, |
| 65 |
Force16x = 4, |
| 66 |
}; |
| 67 |
|
| 68 |
enum class OutputResamplingMode : int |
| 69 |
{ |
| 70 |
Default, |
| 71 |
Bilinear, |
| 72 |
BSpline, |
| 73 |
MitchellNetravali, |
| 74 |
CatmullRom, |
| 75 |
SharpBilinear, |
| 76 |
AreaSampling, |
| 77 |
}; |
| 78 |
|
| 79 |
enum class ColorCorrectionRegion : int |
| 80 |
{ |
| 81 |
SMPTE_NTSCM, |
| 82 |
SYSTEMJ_NTSCJ, |
| 83 |
EBU_PAL, |
| 84 |
}; |
| 85 |
|
| 86 |
enum class TriState : int |
| 87 |
{ |
| 88 |
Off, |
| 89 |
On, |
| 90 |
Auto |
| 91 |
}; |
| 92 |
|
| 93 |
enum class FrameDumpResolutionType : int |
| 94 |
{ |
| 95 |
|
| 96 |
WindowResolution, |
| 97 |
|
| 98 |
XFBAspectRatioCorrectedResolution, |
| 99 |
|
| 100 |
XFBRawResolution, |
| 101 |
}; |
| 102 |
|
| 103 |
enum class VertexLoaderType : int |
| 104 |
{ |
| 105 |
Native, |
| 106 |
Software, |
| 107 |
Compare |
| 108 |
}; |
| 109 |
|
| 110 |
|
| 111 |
enum ConfigChangeBits : u32 |
| 112 |
{ |
| 113 |
CONFIG_CHANGE_BIT_HOST_CONFIG = (1 << 0), |
| 114 |
CONFIG_CHANGE_BIT_MULTISAMPLES = (1 << 1), |
| 115 |
CONFIG_CHANGE_BIT_STEREO_MODE = (1 << 2), |
| 116 |
CONFIG_CHANGE_BIT_TARGET_SIZE = (1 << 3), |
| 117 |
CONFIG_CHANGE_BIT_ANISOTROPY = (1 << 4), |
| 118 |
CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING = (1 << 5), |
| 119 |
CONFIG_CHANGE_BIT_VSYNC = (1 << 6), |
| 120 |
CONFIG_CHANGE_BIT_BBOX = (1 << 7), |
| 121 |
CONFIG_CHANGE_BIT_ASPECT_RATIO = (1 << 8), |
| 122 |
CONFIG_CHANGE_BIT_POST_PROCESSING_SHADER = (1 << 9), |
| 123 |
CONFIG_CHANGE_BIT_HDR = (1 << 10), |
| 124 |
}; |
| 125 |
|
| 126 |
|
| 127 |
struct BackendInfo |
| 128 |
{ |
| 129 |
APIType api_type = APIType::Nothing; |
| 130 |
std::string DisplayName; |
| 131 |
|
| 132 |
std::vector<std::string> Adapters; |
| 133 |
std::vector<u32> AAModes; |
| 134 |
|
| 135 |
|
| 136 |
std::string AdapterName; |
| 137 |
|
| 138 |
u32 MaxTextureSize = 16384; |
| 139 |
bool bUsesLowerLeftOrigin = false; |
| 140 |
bool bUsesExplictQuadBuffering = false; |
| 141 |
bool bSupportsExclusiveFullscreen = false; |
| 142 |
bool bSupportsDualSourceBlend = false; |
| 143 |
bool bSupportsPrimitiveRestart = false; |
| 144 |
bool bSupportsGeometryShaders = false; |
| 145 |
bool bSupportsComputeShaders = false; |
| 146 |
bool bSupports3DVision = false; |
| 147 |
bool bSupportsEarlyZ = false; |
| 148 |
bool bSupportsBindingLayout = false; |
| 149 |
bool bSupportsBBox = false; |
| 150 |
bool bSupportsGSInstancing = false; |
| 151 |
bool bSupportsPostProcessing = false; |
| 152 |
bool bSupportsPaletteConversion = false; |
| 153 |
bool bSupportsClipControl = false; |
| 154 |
bool bSupportsSSAA = false; |
| 155 |
bool bSupportsFragmentStoresAndAtomics = false; |
| 156 |
bool bSupportsDepthClamp = false; |
| 157 |
bool bSupportsReversedDepthRange = false; |
| 158 |
bool bSupportsLogicOp = false; |
| 159 |
bool bSupportsMultithreading = false; |
| 160 |
bool bSupportsGPUTextureDecoding = false; |
| 161 |
bool bSupportsST3CTextures = false; |
| 162 |
bool bSupportsCopyToVram = false; |
| 163 |
bool bSupportsBitfield = false; |
| 164 |
|
| 165 |
bool bSupportsDynamicSamplerIndexing = false; |
| 166 |
bool bSupportsBPTCTextures = false; |
| 167 |
bool bSupportsFramebufferFetch = false; |
| 168 |
bool bSupportsBackgroundCompiling = false; |
| 169 |
bool bSupportsLargePoints = false; |
| 170 |
bool bSupportsPartialDepthCopies = false; |
| 171 |
bool bSupportsDepthReadback = false; |
| 172 |
bool bSupportsShaderBinaries = false; |
| 173 |
bool bSupportsPipelineCacheData = false; |
| 174 |
bool bSupportsCoarseDerivatives = false; |
| 175 |
bool bSupportsTextureQueryLevels = false; |
| 176 |
bool bSupportsLodBiasInSampler = false; |
| 177 |
bool bSupportsSettingObjectNames = false; |
| 178 |
bool bSupportsPartialMultisampleResolve = false; |
| 179 |
bool bSupportsDynamicVertexLoader = false; |
| 180 |
bool bSupportsVSLinePointExpand = false; |
| 181 |
bool bSupportsGLLayerInFS = true; |
| 182 |
bool bSupportsHDROutput = false; |
| 183 |
bool bSupportsUnrestrictedDepthRange = false; |
| 184 |
}; |
| 185 |
|
| 186 |
extern BackendInfo g_backend_info; |
| 187 |
|
| 188 |
|
| 189 |
struct VideoConfig final |
| 190 |
{ |
| 191 |
VideoConfig() = default; |
| 192 |
void Refresh(); |
| 193 |
void VerifyValidity(); |
| 194 |
static void Init(); |
| 195 |
static void Shutdown(); |
| 196 |
|
| 197 |
|
| 198 |
bool bVSync = false; |
| 199 |
bool bVSyncActive = false; |
| 200 |
bool bWidescreenHack = false; |
| 201 |
AspectMode aspect_mode{}; |
| 202 |
int custom_aspect_width = 1; |
| 203 |
int custom_aspect_height = 1; |
| 204 |
AspectMode suggested_aspect_mode{}; |
| 205 |
u32 widescreen_heuristic_transition_threshold = 0; |
| 206 |
float widescreen_heuristic_aspect_ratio_slop = 0.f; |
| 207 |
float widescreen_heuristic_standard_ratio = 0.f; |
| 208 |
float widescreen_heuristic_widescreen_ratio = 0.f; |
| 209 |
bool bCropToAspectRatio = false; |
| 210 |
bool bCropCustom = false; |
| 211 |
int iCropCustomLeft = 0; |
| 212 |
int iCropCustomTop = 0; |
| 213 |
int iCropCustomRight = 0; |
| 214 |
int iCropCustomBottom = 0; |
| 215 |
bool bShaderCache = false; |
| 216 |
|
| 217 |
|
| 218 |
u32 iMultisamples = 0; |
| 219 |
bool bSSAA = false; |
| 220 |
int iEFBScale = 0; |
| 221 |
TextureFilteringMode texture_filtering_mode = TextureFilteringMode::Default; |
| 222 |
OutputResamplingMode output_resampling_mode = OutputResamplingMode::Default; |
| 223 |
AnisotropicFilteringMode iMaxAnisotropy = AnisotropicFilteringMode::Default; |
| 224 |
std::string sPostProcessingShader; |
| 225 |
bool bForceTrueColor = false; |
| 226 |
bool bDisableCopyFilter = false; |
| 227 |
bool bArbitraryMipmapDetection = false; |
| 228 |
float fArbitraryMipmapDetectionThreshold = 0; |
| 229 |
bool bHDR = false; |
| 230 |
|
| 231 |
|
| 232 |
struct |
| 233 |
{ |
| 234 |
|
| 235 |
bool bCorrectColorSpace = false; |
| 236 |
ColorCorrectionRegion game_color_space = ColorCorrectionRegion::SMPTE_NTSCM; |
| 237 |
|
| 238 |
|
| 239 |
bool bCorrectGamma = false; |
| 240 |
float fGameGamma = 2.35f; |
| 241 |
bool bSDRDisplayGammaSRGB = true; |
| 242 |
|
| 243 |
float fSDRDisplayCustomGamma = 2.2f; |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
float fHDRPaperWhiteNits = 203.f; |
| 249 |
} color_correction; |
| 250 |
|
| 251 |
|
| 252 |
bool bShowFPS = false; |
| 253 |
bool bShowInternalResolution = false; |
| 254 |
bool bShowFTimes = false; |
| 255 |
bool bShowVPS = false; |
| 256 |
bool bShowVTimes = false; |
| 257 |
bool bShowGraphs = false; |
| 258 |
bool bShowSpeed = false; |
| 259 |
bool bShowSpeedColors = false; |
| 260 |
int iPerfSampleUSec = 0; |
| 261 |
bool bOverlayStats = false; |
| 262 |
bool bOverlayProjStats = false; |
| 263 |
bool bOverlayScissorStats = false; |
| 264 |
bool bTexFmtOverlayEnable = false; |
| 265 |
bool bTexFmtOverlayCenter = false; |
| 266 |
bool bLogRenderTimeToFile = false; |
| 267 |
|
| 268 |
|
| 269 |
bool bWireFrame = false; |
| 270 |
bool bDisableFog = false; |
| 271 |
|
| 272 |
|
| 273 |
bool bDumpTextures = false; |
| 274 |
bool bDumpMipmapTextures = false; |
| 275 |
bool bDumpBaseTextures = false; |
| 276 |
bool bHiresTextures = false; |
| 277 |
bool bCacheHiresTextures = false; |
| 278 |
bool bDumpEFBTarget = false; |
| 279 |
bool bDumpXFBTarget = false; |
| 280 |
bool bBorderlessFullscreen = false; |
| 281 |
bool bEnableGPUTextureDecoding = false; |
| 282 |
bool bPreferVSForLinePointExpansion = false; |
| 283 |
bool bGraphicMods = false; |
| 284 |
std::optional<GraphicsModGroupConfig> graphics_mod_config; |
| 285 |
|
| 286 |
|
| 287 |
bool bEFBAccessEnable = false; |
| 288 |
bool bEFBAccessDeferInvalidation = false; |
| 289 |
bool bPerfQueriesEnable = false; |
| 290 |
bool bBBoxEnable = false; |
| 291 |
bool bCPUCull = false; |
| 292 |
|
| 293 |
bool bEFBEmulateFormatChanges = false; |
| 294 |
bool bSkipEFBCopyToRam = false; |
| 295 |
bool bSkipXFBCopyToRam = false; |
| 296 |
bool bDisableCopyToVRAM = false; |
| 297 |
bool bDeferEFBCopies = false; |
| 298 |
bool bImmediateXFB = false; |
| 299 |
bool bSkipPresentingDuplicateXFBs = false; |
| 300 |
bool bCopyEFBScaled = false; |
| 301 |
int iSafeTextureCache_ColorSamples = 0; |
| 302 |
float fAspectRatioHackW = 1; |
| 303 |
float fAspectRatioHackH = 1; |
| 304 |
bool bEnablePixelLighting = false; |
| 305 |
bool bFastDepthCalc = false; |
| 306 |
bool bVertexRounding = false; |
| 307 |
bool bVISkip = false; |
| 308 |
int iEFBAccessTileSize = 0; |
| 309 |
int iSaveTargetId = 0; |
| 310 |
u32 iMissingColorValue = 0; |
| 311 |
bool bFastTextureSampling = false; |
| 312 |
#ifdef __APPLE__ |
| 313 |
bool bNoMipmapping = false; |
| 314 |
#endif |
| 315 |
|
| 316 |
|
| 317 |
StereoMode stereo_mode{}; |
| 318 |
bool stereo_per_eye_resolution_full = false; |
| 319 |
float stereo_depth = 0; |
| 320 |
float stereo_convergence = 0; |
| 321 |
bool bStereoSwapEyes = false; |
| 322 |
bool bStereoEFBMonoDepth = false; |
| 323 |
|
| 324 |
|
| 325 |
int iAdapter = 0; |
| 326 |
|
| 327 |
|
| 328 |
TriState iManuallyUploadBuffers = TriState::Auto; |
| 329 |
TriState iUsePresentDrawable = TriState::Auto; |
| 330 |
|
| 331 |
|
| 332 |
bool bEnableValidationLayer = false; |
| 333 |
|
| 334 |
|
| 335 |
bool bBackendMultithreading = true; |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
int iCommandBufferExecuteInterval = 0; |
| 340 |
|
| 341 |
|
| 342 |
bool bWaitForShadersBeforeStarting = false; |
| 343 |
ShaderCompilationMode iShaderCompilationMode{}; |
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
int iShaderCompilerThreads = 0; |
| 349 |
int iShaderPrecompilerThreads = 0; |
| 350 |
|
| 351 |
|
| 352 |
std::string customDriverLibraryName; |
| 353 |
|
| 354 |
|
| 355 |
VertexLoaderType vertex_loader_type; |
| 356 |
|
| 357 |
|
| 358 |
bool UseVSForLinePointExpand() const |
| 359 |
{ |
| 360 |
if (!g_backend_info.bSupportsVSLinePointExpand) |
| 361 |
return false; |
| 362 |
if (!g_backend_info.bSupportsGeometryShaders) |
| 363 |
return true; |
| 364 |
return bPreferVSForLinePointExpansion; |
| 365 |
} |
| 366 |
bool MultisamplingEnabled() const { return iMultisamples > 1; } |
| 367 |
bool ExclusiveFullscreenEnabled() const |
| 368 |
{ |
| 369 |
return g_backend_info.bSupportsExclusiveFullscreen && !bBorderlessFullscreen; |
| 370 |
} |
| 371 |
bool UseGPUTextureDecoding() const |
| 372 |
{ |
| 373 |
return g_backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding && |
| 374 |
!bArbitraryMipmapDetection; |
| 375 |
} |
| 376 |
bool UseVertexRounding() const { return bVertexRounding && iEFBScale != 1; } |
| 377 |
bool ManualTextureSamplingWithCustomTextureSizes() const |
| 378 |
{ |
| 379 |
|
| 380 |
if (bFastTextureSampling) |
| 381 |
return false; |
| 382 |
|
| 383 |
|
| 384 |
if (bHiresTextures) |
| 385 |
return true; |
| 386 |
|
| 387 |
|
| 388 |
if (iEFBScale != 1 && bCopyEFBScaled) |
| 389 |
return true; |
| 390 |
|
| 391 |
|
| 392 |
if (stereo_mode != StereoMode::Off) |
| 393 |
return true; |
| 394 |
|
| 395 |
return false; |
| 396 |
} |
| 397 |
bool UsingUberShaders() const; |
| 398 |
u32 GetShaderCompilerThreads() const; |
| 399 |
u32 GetShaderPrecompilerThreads() const; |
| 400 |
|
| 401 |
float GetCustomAspectRatio() const { return (float)custom_aspect_width / custom_aspect_height; } |
| 402 |
}; |
| 403 |
|
| 404 |
extern VideoConfig g_Config; |
| 405 |
extern VideoConfig g_ActiveConfig; |
| 406 |
|
| 407 |
|
| 408 |
void UpdateActiveConfig(); |
| 409 |
void CheckForConfigChanges(); |