1 // Copyright 2008 Dolphin Emulator Project 2 // Licensed under GPLv2+ 3 // Refer to the license.txt file included. 4 5 // IMPORTANT: UI etc should modify g_Config. Graphics code should read g_ActiveConfig. 6 // The reason for this is to get rid of race conditions etc when the configuration 7 // changes in the middle of a frame. This is done by copying g_Config to g_ActiveConfig 8 // at the start of every frame. Noone should ever change members of g_ActiveConfig 9 // directly. 10 11 #pragma once 12 13 #include <string> 14 #include <vector> 15 16 #include "Common/CommonTypes.h" 17 18 enum class APIType; 19 20 // Log in two categories, and save three other options in the same byte 21 #define CONF_LOG 1 22 #define CONF_PRIMLOG 2 23 #define CONF_SAVETARGETS 8 24 #define CONF_SAVESHADERS 16 25 26 constexpr int EFB_SCALE_AUTO_INTEGRAL = 0; 27 28 enum class AspectMode : int 29 { 30 Auto, 31 AnalogWide, 32 Analog, 33 Stretch, 34 }; 35 36 enum class StereoMode : int 37 { 38 Off, 39 SBS, 40 TAB, 41 Anaglyph, 42 QuadBuffer, 43 Passive 44 }; 45 46 enum class ShaderCompilationMode : int 47 { 48 Synchronous, 49 SynchronousUberShaders, 50 AsynchronousUberShaders, 51 AsynchronousSkipRendering 52 }; 53 54 enum class FreelookControlType : int 55 { 56 SixAxis, 57 FPS, 58 Orbital 59 }; 60 61 // NEVER inherit from this class. 62 struct VideoConfig final 63 { 64 VideoConfig(); 65 void Refresh(); 66 void VerifyValidity(); 67 68 // General 69 bool bVSync; 70 bool bVSyncActive; 71 bool bWidescreenHack; 72 AspectMode aspect_mode; 73 AspectMode suggested_aspect_mode; 74 bool bCrop; // Aspect ratio controls. 75 bool bShaderCache; 76 77 // Enhancements 78 u32 iMultisamples; 79 bool bSSAA; 80 int iEFBScale; 81 bool bForceFiltering; 82 int iMaxAnisotropy; 83 std::string sPostProcessingShader; 84 bool bForceTrueColor; 85 bool bDisableCopyFilter; 86 bool bArbitraryMipmapDetection; 87 float fArbitraryMipmapDetectionThreshold; 88 89 // Information 90 bool bShowFPS; 91 bool bShowNetPlayPing; 92 bool bShowNetPlayMessages; 93 bool bOverlayStats; 94 bool bOverlayProjStats; 95 bool bTexFmtOverlayEnable; 96 bool bTexFmtOverlayCenter; 97 bool bLogRenderTimeToFile; 98 99 // Render 100 bool bWireFrame; 101 bool bDisableFog; 102 103 // Utility 104 bool bDumpTextures; 105 bool bDumpMipmapTextures; 106 bool bDumpBaseTextures; 107 bool bHiresTextures; 108 bool bCacheHiresTextures; 109 bool bDumpEFBTarget; 110 bool bDumpXFBTarget; 111 bool bDumpFramesAsImages; 112 bool bUseFFV1; 113 std::string sDumpCodec; 114 std::string sDumpEncoder; 115 std::string sDumpFormat; 116 std::string sDumpPath; 117 bool bInternalResolutionFrameDumps; 118 bool bFreeLook; 119 FreelookControlType iFreelookControlType; 120 bool bBorderlessFullscreen; 121 bool bEnableGPUTextureDecoding; 122 int iBitrateKbps; 123 124 // Hacks 125 bool bEFBAccessEnable; 126 bool bEFBAccessDeferInvalidation; 127 bool bPerfQueriesEnable; 128 bool bBBoxEnable; 129 bool bForceProgressive; 130 131 bool bEFBEmulateFormatChanges; 132 bool bSkipEFBCopyToRam; 133 bool bSkipXFBCopyToRam; 134 bool bDisableCopyToVRAM; 135 bool bDeferEFBCopies; 136 bool bImmediateXFB; 137 bool bSkipPresentingDuplicateXFBs; 138 bool bCopyEFBScaled; 139 int iSafeTextureCache_ColorSamples; 140 float fAspectRatioHackW, fAspectRatioHackH; 141 bool bEnablePixelLighting; 142 bool bFastDepthCalc; 143 bool bVertexRounding; 144 int iEFBAccessTileSize; 145 int iLog; // CONF_ bits 146 int iSaveTargetId; // TODO: Should be dropped 147 148 // Stereoscopy 149 StereoMode stereo_mode; 150 int iStereoDepth; 151 int iStereoConvergence; 152 int iStereoConvergencePercentage; 153 bool bStereoSwapEyes; 154 bool bStereoEFBMonoDepth; 155 int iStereoDepthPercentage; 156 157 // D3D only config, mostly to be merged into the above 158 int iAdapter; 159 160 // VideoSW Debugging 161 int drawStart; 162 int drawEnd; 163 bool bZComploc; 164 bool bZFreeze; 165 bool bDumpObjects; 166 bool bDumpTevStages; 167 bool bDumpTevTextureFetches; 168 169 // Enable API validation layers, currently only supported with Vulkan. 170 bool bEnableValidationLayer; 171 172 // Multithreaded submission, currently only supported with Vulkan. 173 bool bBackendMultithreading; 174 175 // Early command buffer execution interval in number of draws. 176 // Currently only supported with Vulkan. 177 int iCommandBufferExecuteInterval; 178 179 // Shader compilation settings. 180 bool bWaitForShadersBeforeStarting; 181 ShaderCompilationMode iShaderCompilationMode; 182 183 // Number of shader compiler threads. 184 // 0 disables background compilation. 185 // -1 uses an automatic number based on the CPU threads. 186 int iShaderCompilerThreads; 187 int iShaderPrecompilerThreads; 188 189 // Static config per API 190 // TODO: Move this out of VideoConfig 191 struct 192 { 193 APIType api_type; 194 195 std::vector<std::string> Adapters; // for D3D 196 std::vector<u32> AAModes; 197 198 // TODO: merge AdapterName and Adapters array 199 std::string AdapterName; // for OpenGL 200 201 u32 MaxTextureSize; 202 bool bUsesLowerLeftOrigin; 203 204 bool bSupportsExclusiveFullscreen; 205 bool bSupportsDualSourceBlend; 206 bool bSupportsPrimitiveRestart; 207 bool bSupportsOversizedViewports; 208 bool bSupportsGeometryShaders; 209 bool bSupportsComputeShaders; 210 bool bSupports3DVision; 211 bool bSupportsEarlyZ; // needed by PixelShaderGen, so must stay in VideoCommon 212 bool bSupportsBindingLayout; // Needed by ShaderGen, so must stay in VideoCommon 213 bool bSupportsBBox; 214 bool bSupportsGSInstancing; // Needed by GeometryShaderGen, so must stay in VideoCommon 215 bool bSupportsPostProcessing; 216 bool bSupportsPaletteConversion; 217 bool bSupportsClipControl; // Needed by VertexShaderGen, so must stay in VideoCommon 218 bool bSupportsSSAA; 219 bool bSupportsFragmentStoresAndAtomics; // a.k.a. OpenGL SSBOs a.k.a. Direct3D UAVs 220 bool bSupportsDepthClamp; // Needed by VertexShaderGen, so must stay in VideoCommon 221 bool bSupportsReversedDepthRange; 222 bool bSupportsLogicOp; 223 bool bSupportsMultithreading; 224 bool bSupportsGPUTextureDecoding; 225 bool bSupportsST3CTextures; 226 bool bSupportsCopyToVram; 227 bool bSupportsBitfield; // Needed by UberShaders, so must stay in VideoCommon 228 bool bSupportsDynamicSamplerIndexing; // Needed by UberShaders, so must stay in VideoCommon 229 bool bSupportsBPTCTextures; 230 bool bSupportsFramebufferFetch; // Used as an alternative to dual-source blend on GLES 231 bool bSupportsBackgroundCompiling; 232 bool bSupportsLargePoints; 233 bool bSupportsPartialDepthCopies; 234 bool bSupportsDepthReadback; 235 bool bSupportsShaderBinaries; 236 bool bSupportsPipelineCacheData; 237 } backend_info; 238 239 // Utility MultisamplingEnabledfinal240 bool MultisamplingEnabled() const { return iMultisamples > 1; } ExclusiveFullscreenEnabledfinal241 bool ExclusiveFullscreenEnabled() const 242 { 243 return backend_info.bSupportsExclusiveFullscreen && !bBorderlessFullscreen; 244 } UseGPUTextureDecodingfinal245 bool UseGPUTextureDecoding() const 246 { 247 return backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding; 248 } UseVertexRoundingfinal249 bool UseVertexRounding() const { return bVertexRounding && iEFBScale != 1; } 250 bool UsingUberShaders() const; 251 u32 GetShaderCompilerThreads() const; 252 u32 GetShaderPrecompilerThreads() const; 253 }; 254 255 extern VideoConfig g_Config; 256 extern VideoConfig g_ActiveConfig; 257 258 // Called every frame. 259 void UpdateActiveConfig(); 260