2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-09-13 08:21:35 +00: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 18:54:46 +00:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2022-03-15 06:46:58 +00:00
|
|
|
#include <optional>
|
2009-07-12 21:58:32 +00:00
|
|
|
#include <string>
|
2014-02-17 10:18:15 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2022-03-15 06:46:58 +00:00
|
|
|
#include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h"
|
2021-09-04 04:43:19 +00:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2009-07-12 21:58:32 +00:00
|
|
|
|
2017-07-03 14:32:02 +00:00
|
|
|
constexpr int EFB_SCALE_AUTO_INTEGRAL = 0;
|
|
|
|
|
2018-01-08 11:04:12 +00:00
|
|
|
enum class AspectMode : int
|
2010-01-13 21:11:02 +00:00
|
|
|
{
|
2017-11-11 03:45:32 +00:00
|
|
|
Auto,
|
|
|
|
AnalogWide,
|
|
|
|
Analog,
|
|
|
|
Stretch,
|
2010-01-13 21:11:02 +00:00
|
|
|
};
|
|
|
|
|
2018-01-08 11:04:12 +00:00
|
|
|
enum class StereoMode : int
|
2014-10-31 14:25:42 +00:00
|
|
|
{
|
2017-11-11 03:55:00 +00:00
|
|
|
Off,
|
|
|
|
SBS,
|
|
|
|
TAB,
|
|
|
|
Anaglyph,
|
|
|
|
QuadBuffer,
|
2019-10-02 01:07:17 +00:00
|
|
|
Passive
|
2014-10-31 14:25:42 +00:00
|
|
|
};
|
|
|
|
|
2018-03-16 13:10:22 +00:00
|
|
|
enum class ShaderCompilationMode : int
|
2018-03-01 08:03:24 +00:00
|
|
|
{
|
2018-03-16 13:10:22 +00:00
|
|
|
Synchronous,
|
|
|
|
SynchronousUberShaders,
|
|
|
|
AsynchronousUberShaders,
|
|
|
|
AsynchronousSkipRendering
|
2018-03-01 08:03:24 +00:00
|
|
|
};
|
|
|
|
|
2009-02-28 16:33:59 +00:00
|
|
|
// NEVER inherit from this class.
|
2014-03-16 21:00:29 +00:00
|
|
|
struct VideoConfig final
|
2008-10-22 21:23:40 +00:00
|
|
|
{
|
2021-09-04 04:43:19 +00:00
|
|
|
VideoConfig() = default;
|
2017-05-18 12:59:38 +00:00
|
|
|
void Refresh();
|
2011-02-13 13:42:59 +00:00
|
|
|
void VerifyValidity();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
// General
|
2021-09-04 04:43:19 +00: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 08:43:46 +00:00
|
|
|
|
2008-10-26 13:35:34 +00:00
|
|
|
// Enhancements
|
2021-09-04 04:43:19 +00:00
|
|
|
u32 iMultisamples = 0;
|
|
|
|
bool bSSAA = false;
|
|
|
|
int iEFBScale = 0;
|
|
|
|
bool bForceFiltering = false;
|
|
|
|
int iMaxAnisotropy = 0;
|
2009-06-08 19:42:25 +00:00
|
|
|
std::string sPostProcessingShader;
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bForceTrueColor = false;
|
|
|
|
bool bDisableCopyFilter = false;
|
|
|
|
bool bArbitraryMipmapDetection = false;
|
|
|
|
float fArbitraryMipmapDetectionThreshold = 0;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2008-10-26 13:35:34 +00:00
|
|
|
// Information
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bShowFPS = false;
|
|
|
|
bool bShowNetPlayPing = false;
|
|
|
|
bool bShowNetPlayMessages = false;
|
|
|
|
bool bOverlayStats = false;
|
|
|
|
bool bOverlayProjStats = false;
|
2021-11-28 01:09:55 +00:00
|
|
|
bool bOverlayScissorStats = false;
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bTexFmtOverlayEnable = false;
|
|
|
|
bool bTexFmtOverlayCenter = false;
|
|
|
|
bool bLogRenderTimeToFile = false;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
// Render
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bWireFrame = false;
|
|
|
|
bool bDisableFog = false;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
// Utility
|
2021-09-04 04:43:19 +00: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 19:04:22 +00:00
|
|
|
std::string sDumpCodec;
|
2022-04-08 22:45:49 +00:00
|
|
|
std::string sDumpPixelFormat;
|
2017-12-29 14:00:55 +00:00
|
|
|
std::string sDumpEncoder;
|
2017-02-21 10:43:49 +00:00
|
|
|
std::string sDumpFormat;
|
2017-02-21 19:37:36 +00:00
|
|
|
std::string sDumpPath;
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bInternalResolutionFrameDumps = false;
|
|
|
|
bool bBorderlessFullscreen = false;
|
|
|
|
bool bEnableGPUTextureDecoding = false;
|
|
|
|
int iBitrateKbps = 0;
|
2022-04-07 05:00:38 +00:00
|
|
|
bool bGraphicMods = false;
|
2022-03-15 06:46:58 +00:00
|
|
|
std::optional<GraphicsModGroupConfig> graphics_mod_config;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
// Hacks
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bEFBAccessEnable = false;
|
|
|
|
bool bEFBAccessDeferInvalidation = false;
|
|
|
|
bool bPerfQueriesEnable = false;
|
|
|
|
bool bBBoxEnable = false;
|
|
|
|
bool bForceProgressive = false;
|
|
|
|
|
|
|
|
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;
|
|
|
|
int iEFBAccessTileSize = 0;
|
|
|
|
int iSaveTargetId = 0; // TODO: Should be dropped
|
|
|
|
u32 iMissingColorValue = 0;
|
2021-07-30 00:43:35 +00:00
|
|
|
bool bFastTextureSampling = false;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-11-24 11:01:21 +00:00
|
|
|
// Stereoscopy
|
2021-09-04 04:43:19 +00: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 08:43:46 +00:00
|
|
|
|
2009-09-13 08:21:35 +00:00
|
|
|
// D3D only config, mostly to be merged into the above
|
2021-09-04 04:43:19 +00:00
|
|
|
int iAdapter = 0;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-08-13 12:08:46 +00:00
|
|
|
// Enable API validation layers, currently only supported with Vulkan.
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bEnableValidationLayer = false;
|
2016-08-13 12:08:46 +00:00
|
|
|
|
|
|
|
// Multithreaded submission, currently only supported with Vulkan.
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bBackendMultithreading = true;
|
2016-08-13 12:08:46 +00:00
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
// Early command buffer execution interval in number of draws.
|
|
|
|
// Currently only supported with Vulkan.
|
2021-09-04 04:43:19 +00:00
|
|
|
int iCommandBufferExecuteInterval = 0;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
2018-03-01 08:03:24 +00:00
|
|
|
// Shader compilation settings.
|
2021-09-04 04:43:19 +00:00
|
|
|
bool bWaitForShadersBeforeStarting = false;
|
|
|
|
ShaderCompilationMode iShaderCompilationMode{};
|
2017-06-13 10:07:09 +00:00
|
|
|
|
|
|
|
// Number of shader compiler threads.
|
|
|
|
// 0 disables background compilation.
|
|
|
|
// -1 uses an automatic number based on the CPU threads.
|
2021-09-04 04:43:19 +00:00
|
|
|
int iShaderCompilerThreads = 0;
|
|
|
|
int iShaderPrecompilerThreads = 0;
|
2017-06-13 10:07:09 +00:00
|
|
|
|
2009-09-13 21:18:04 +00:00
|
|
|
// Static config per API
|
2011-05-31 20:16:59 +00:00
|
|
|
// TODO: Move this out of VideoConfig
|
2011-03-21 19:57:31 +00:00
|
|
|
struct
|
2010-11-21 14:47:28 +00:00
|
|
|
{
|
2021-09-04 04:43:19 +00:00
|
|
|
APIType api_type = APIType::Nothing;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2013-09-22 15:49:26 +00:00
|
|
|
std::vector<std::string> Adapters; // for D3D
|
2017-06-07 11:30:39 +00:00
|
|
|
std::vector<u32> AAModes;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-06-20 11:54:44 +00:00
|
|
|
// TODO: merge AdapterName and Adapters array
|
|
|
|
std::string AdapterName; // for OpenGL
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-09-04 04:43:19 +00:00
|
|
|
u32 MaxTextureSize = 16384;
|
|
|
|
bool bUsesLowerLeftOrigin = false;
|
|
|
|
|
|
|
|
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-14 04:10:20 +00:00
|
|
|
bool bSupportsCoarseDerivatives = false;
|
2021-11-14 04:10:55 +00:00
|
|
|
bool bSupportsTextureQueryLevels = false;
|
2021-08-07 03:26:51 +00:00
|
|
|
bool bSupportsLodBiasInSampler = false;
|
2022-01-31 02:44:57 +00:00
|
|
|
bool bSupportsSettingObjectNames = false;
|
2022-06-21 07:07:35 +00:00
|
|
|
bool bSupportsPartialMultisampleResolve = false;
|
2022-06-18 06:09:35 +00:00
|
|
|
bool bSupportsDynamicVertexLoader = false;
|
2010-11-21 14:47:28 +00:00
|
|
|
} backend_info;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2012-09-28 21:19:50 +00:00
|
|
|
// Utility
|
2017-04-30 08:07:57 +00:00
|
|
|
bool MultisamplingEnabled() const { return iMultisamples > 1; }
|
2014-10-07 14:43:32 +00:00
|
|
|
bool ExclusiveFullscreenEnabled() const
|
|
|
|
{
|
|
|
|
return backend_info.bSupportsExclusiveFullscreen && !bBorderlessFullscreen;
|
|
|
|
}
|
2016-11-27 08:14:57 +00:00
|
|
|
bool UseGPUTextureDecoding() const
|
|
|
|
{
|
|
|
|
return backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding;
|
|
|
|
}
|
2017-07-03 14:32:02 +00:00
|
|
|
bool UseVertexRounding() const { return bVertexRounding && iEFBScale != 1; }
|
2021-08-02 00:31:40 +00:00
|
|
|
bool ManualTextureSamplingWithHiResTextures() const
|
|
|
|
{
|
|
|
|
// Hi-res textures (including hi-res EFB copies, but not native-resolution EFB copies at higher
|
|
|
|
// internal resolutions) breaks the wrapping logic used by manual texture sampling.
|
|
|
|
if (bFastTextureSampling)
|
|
|
|
return false;
|
|
|
|
if (iEFBScale != 1 && bCopyEFBScaled)
|
|
|
|
return true;
|
|
|
|
return bHiresTextures;
|
|
|
|
}
|
2018-03-16 13:10:22 +00:00
|
|
|
bool UsingUberShaders() const;
|
2017-06-13 10:07:09 +00:00
|
|
|
u32 GetShaderCompilerThreads() const;
|
2017-07-27 03:15:38 +00:00
|
|
|
u32 GetShaderPrecompilerThreads() const;
|
2008-10-22 21:23:40 +00:00
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
extern VideoConfig g_Config;
|
|
|
|
extern VideoConfig g_ActiveConfig;
|
2009-09-13 08:21:35 +00:00
|
|
|
|
|
|
|
// Called every frame.
|
|
|
|
void UpdateActiveConfig();
|