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
|
|
|
|
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"
|
2021-09-03 22:43:19 -06:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2009-07-12 15:58:32 -06:00
|
|
|
|
2009-02-04 10:33:59 -07:00
|
|
|
// Log in two categories, and save three other options in the same byte
|
2014-02-16 13:30:18 -07:00
|
|
|
#define CONF_LOG 1
|
|
|
|
#define CONF_PRIMLOG 2
|
|
|
|
#define CONF_SAVETARGETS 8
|
|
|
|
#define CONF_SAVESHADERS 16
|
2008-12-07 21:46:09 -07: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
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
bool bForceFiltering = false;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
int iBitrateKbps = 0;
|
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;
|
|
|
|
|
|
|
|
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 iLog = 0; // CONF_ bits
|
|
|
|
int iSaveTargetId = 0; // TODO: Should be dropped
|
|
|
|
u32 iMissingColorValue = 0;
|
2021-07-29 18:43:35 -06:00
|
|
|
bool bFastTextureSampling = false;
|
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
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
// VideoSW Debugging
|
2021-09-03 22:43:19 -06:00
|
|
|
int drawStart = 0;
|
|
|
|
int drawEnd = 0;
|
|
|
|
bool bDumpObjects = false;
|
|
|
|
bool bDumpTevStages = false;
|
|
|
|
bool bDumpTevTextureFetches = false;
|
2016-06-24 02:43:46 -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
|
|
|
#if defined(ANDROID)
|
|
|
|
bool bBackendMultithreading = false;
|
|
|
|
#else
|
|
|
|
bool bBackendMultithreading = true;
|
|
|
|
#endif
|
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;
|
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;
|
|
|
|
|
|
|
|
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;
|
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
|
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; }
|
2021-08-01 18:31:40 -06: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 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();
|