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 05:25:12 +00:00
|
|
|
|
2021-12-10 02:22:16 +00:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
|
2015-12-12 12:00:08 +00:00
|
|
|
#include <algorithm>
|
2009-09-13 08:21:35 +00:00
|
|
|
|
2017-06-13 10:07:09 +00:00
|
|
|
#include "Common/CPUDetect.h"
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2017-06-24 08:55:08 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2023-01-29 16:06:25 +00:00
|
|
|
|
2023-08-16 19:16:41 +00:00
|
|
|
#include "Core/CPUThreadConfigCallback.h"
|
2017-05-18 12:59:38 +00:00
|
|
|
#include "Core/Config/GraphicsSettings.h"
|
2022-01-05 22:22:07 +00:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2023-01-29 16:06:25 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/Movie.h"
|
2023-01-31 04:26:46 +00:00
|
|
|
#include "Core/System.h"
|
2023-01-29 16:06:25 +00:00
|
|
|
|
|
|
|
#include "VideoCommon/AbstractGfx.h"
|
|
|
|
#include "VideoCommon/BPFunctions.h"
|
2021-06-03 14:03:37 +00:00
|
|
|
#include "VideoCommon/DriverDetails.h"
|
2023-08-16 19:16:41 +00:00
|
|
|
#include "VideoCommon/Fifo.h"
|
2023-01-29 16:06:25 +00:00
|
|
|
#include "VideoCommon/FramebufferManager.h"
|
|
|
|
#include "VideoCommon/FreeLookCamera.h"
|
|
|
|
#include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h"
|
|
|
|
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
2023-01-31 04:26:46 +00:00
|
|
|
#include "VideoCommon/PixelShaderManager.h"
|
2023-01-31 04:29:16 +00:00
|
|
|
#include "VideoCommon/Present.h"
|
2023-01-29 16:06:25 +00:00
|
|
|
#include "VideoCommon/ShaderGenCommon.h"
|
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
|
|
|
#include "VideoCommon/VertexManagerBase.h"
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
VideoConfig g_Config;
|
|
|
|
VideoConfig g_ActiveConfig;
|
2017-05-18 12:59:38 +00:00
|
|
|
static bool s_has_registered_callback = false;
|
2009-09-13 08:21:35 +00:00
|
|
|
|
2019-01-27 02:24:53 +00:00
|
|
|
static bool IsVSyncActive(bool enabled)
|
|
|
|
{
|
|
|
|
// Vsync is disabled when the throttler is disabled by the tab key.
|
|
|
|
return enabled && !Core::GetIsThrottlerTempDisabled() &&
|
2022-01-05 22:22:07 +00:00
|
|
|
Config::Get(Config::MAIN_EMULATION_SPEED) == 1.0;
|
2019-01-27 02:24:53 +00:00
|
|
|
}
|
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
void UpdateActiveConfig()
|
2009-09-13 08:21:35 +00:00
|
|
|
{
|
2013-05-21 23:20:22 +00:00
|
|
|
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
|
|
|
|
Movie::SetGraphicsConfig();
|
2009-09-13 08:21:35 +00:00
|
|
|
g_ActiveConfig = g_Config;
|
2019-01-27 02:24:53 +00:00
|
|
|
g_ActiveConfig.bVSyncActive = IsVSyncActive(g_ActiveConfig.bVSync);
|
2009-09-13 08:21:35 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2017-05-18 12:59:38 +00:00
|
|
|
void VideoConfig::Refresh()
|
2008-10-22 21:23:40 +00:00
|
|
|
{
|
2017-05-18 12:59:38 +00:00
|
|
|
if (!s_has_registered_callback)
|
|
|
|
{
|
2017-10-10 13:52:17 +00:00
|
|
|
// There was a race condition between the video thread and the host thread here, if
|
|
|
|
// corrections need to be made by VerifyValidity(). Briefly, the config will contain
|
2023-08-16 19:16:41 +00:00
|
|
|
// invalid values. Instead, pause the video thread first, update the config and correct
|
|
|
|
// it, then resume emulation, after which the video thread will detect the config has
|
|
|
|
// changed and act accordingly.
|
|
|
|
CPUThreadConfigCallback::AddConfigChangedCallback([]() {
|
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
|
|
|
|
const bool lock_gpu_thread = Core::IsRunningAndStarted();
|
|
|
|
if (lock_gpu_thread)
|
|
|
|
system.GetFifo().PauseAndLock(system, true, false);
|
|
|
|
|
|
|
|
g_Config.Refresh();
|
|
|
|
g_Config.VerifyValidity();
|
|
|
|
|
|
|
|
if (lock_gpu_thread)
|
|
|
|
system.GetFifo().PauseAndLock(system, false, true);
|
2022-05-16 23:59:23 +00:00
|
|
|
});
|
2017-05-18 12:59:38 +00:00
|
|
|
s_has_registered_callback = true;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-05-18 12:59:38 +00:00
|
|
|
bVSync = Config::Get(Config::GFX_VSYNC);
|
|
|
|
iAdapter = Config::Get(Config::GFX_ADAPTER);
|
2022-07-23 22:27:24 +00:00
|
|
|
iManuallyUploadBuffers = Config::Get(Config::GFX_MTL_MANUALLY_UPLOAD_BUFFERS);
|
2022-10-24 22:40:32 +00:00
|
|
|
iUsePresentDrawable = Config::Get(Config::GFX_MTL_USE_PRESENT_DRAWABLE);
|
2017-05-18 12:59:38 +00:00
|
|
|
|
|
|
|
bWidescreenHack = Config::Get(Config::GFX_WIDESCREEN_HACK);
|
2019-02-23 15:00:18 +00:00
|
|
|
aspect_mode = Config::Get(Config::GFX_ASPECT_RATIO);
|
2018-11-07 18:00:24 +00:00
|
|
|
suggested_aspect_mode = Config::Get(Config::GFX_SUGGESTED_ASPECT_RATIO);
|
2023-01-09 05:25:11 +00:00
|
|
|
widescreen_heuristic_transition_threshold =
|
|
|
|
Config::Get(Config::GFX_WIDESCREEN_HEURISTIC_TRANSITION_THRESHOLD);
|
2017-05-18 12:59:38 +00:00
|
|
|
bCrop = Config::Get(Config::GFX_CROP);
|
|
|
|
iSafeTextureCache_ColorSamples = Config::Get(Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES);
|
|
|
|
bShowFPS = Config::Get(Config::GFX_SHOW_FPS);
|
2022-12-24 00:52:53 +00:00
|
|
|
bShowFTimes = Config::Get(Config::GFX_SHOW_FTIMES);
|
2022-10-26 19:17:15 +00:00
|
|
|
bShowVPS = Config::Get(Config::GFX_SHOW_VPS);
|
2022-12-24 00:52:53 +00:00
|
|
|
bShowVTimes = Config::Get(Config::GFX_SHOW_VTIMES);
|
|
|
|
bShowGraphs = Config::Get(Config::GFX_SHOW_GRAPHS);
|
2022-10-26 19:17:15 +00:00
|
|
|
bShowSpeed = Config::Get(Config::GFX_SHOW_SPEED);
|
|
|
|
bShowSpeedColors = Config::Get(Config::GFX_SHOW_SPEED_COLORS);
|
|
|
|
iPerfSampleUSec = Config::Get(Config::GFX_PERF_SAMP_WINDOW) * 1000;
|
2017-05-18 12:59:38 +00:00
|
|
|
bShowNetPlayPing = Config::Get(Config::GFX_SHOW_NETPLAY_PING);
|
|
|
|
bShowNetPlayMessages = Config::Get(Config::GFX_SHOW_NETPLAY_MESSAGES);
|
|
|
|
bLogRenderTimeToFile = Config::Get(Config::GFX_LOG_RENDER_TIME_TO_FILE);
|
|
|
|
bOverlayStats = Config::Get(Config::GFX_OVERLAY_STATS);
|
|
|
|
bOverlayProjStats = Config::Get(Config::GFX_OVERLAY_PROJ_STATS);
|
2021-11-28 01:09:55 +00:00
|
|
|
bOverlayScissorStats = Config::Get(Config::GFX_OVERLAY_SCISSOR_STATS);
|
2017-05-18 12:59:38 +00:00
|
|
|
bDumpTextures = Config::Get(Config::GFX_DUMP_TEXTURES);
|
2020-05-05 04:07:06 +00:00
|
|
|
bDumpMipmapTextures = Config::Get(Config::GFX_DUMP_MIP_TEXTURES);
|
|
|
|
bDumpBaseTextures = Config::Get(Config::GFX_DUMP_BASE_TEXTURES);
|
2017-05-18 12:59:38 +00:00
|
|
|
bHiresTextures = Config::Get(Config::GFX_HIRES_TEXTURES);
|
|
|
|
bCacheHiresTextures = Config::Get(Config::GFX_CACHE_HIRES_TEXTURES);
|
|
|
|
bDumpEFBTarget = Config::Get(Config::GFX_DUMP_EFB_TARGET);
|
2017-06-03 01:33:26 +00:00
|
|
|
bDumpXFBTarget = Config::Get(Config::GFX_DUMP_XFB_TARGET);
|
2017-05-18 12:59:38 +00:00
|
|
|
bDumpFramesAsImages = Config::Get(Config::GFX_DUMP_FRAMES_AS_IMAGES);
|
|
|
|
bUseFFV1 = Config::Get(Config::GFX_USE_FFV1);
|
|
|
|
sDumpFormat = Config::Get(Config::GFX_DUMP_FORMAT);
|
|
|
|
sDumpCodec = Config::Get(Config::GFX_DUMP_CODEC);
|
2022-04-08 22:45:49 +00:00
|
|
|
sDumpPixelFormat = Config::Get(Config::GFX_DUMP_PIXEL_FORMAT);
|
2017-12-29 14:00:55 +00:00
|
|
|
sDumpEncoder = Config::Get(Config::GFX_DUMP_ENCODER);
|
2017-05-18 12:59:38 +00:00
|
|
|
sDumpPath = Config::Get(Config::GFX_DUMP_PATH);
|
|
|
|
iBitrateKbps = Config::Get(Config::GFX_BITRATE_KBPS);
|
|
|
|
bInternalResolutionFrameDumps = Config::Get(Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS);
|
|
|
|
bEnableGPUTextureDecoding = Config::Get(Config::GFX_ENABLE_GPU_TEXTURE_DECODING);
|
2022-07-24 08:51:22 +00:00
|
|
|
bPreferVSForLinePointExpansion = Config::Get(Config::GFX_PREFER_VS_FOR_LINE_POINT_EXPANSION);
|
2017-05-18 12:59:38 +00:00
|
|
|
bEnablePixelLighting = Config::Get(Config::GFX_ENABLE_PIXEL_LIGHTING);
|
|
|
|
bFastDepthCalc = Config::Get(Config::GFX_FAST_DEPTH_CALC);
|
|
|
|
iMultisamples = Config::Get(Config::GFX_MSAA);
|
|
|
|
bSSAA = Config::Get(Config::GFX_SSAA);
|
|
|
|
iEFBScale = Config::Get(Config::GFX_EFB_SCALE);
|
|
|
|
bTexFmtOverlayEnable = Config::Get(Config::GFX_TEXFMT_OVERLAY_ENABLE);
|
|
|
|
bTexFmtOverlayCenter = Config::Get(Config::GFX_TEXFMT_OVERLAY_CENTER);
|
|
|
|
bWireFrame = Config::Get(Config::GFX_ENABLE_WIREFRAME);
|
|
|
|
bDisableFog = Config::Get(Config::GFX_DISABLE_FOG);
|
|
|
|
bBorderlessFullscreen = Config::Get(Config::GFX_BORDERLESS_FULLSCREEN);
|
|
|
|
bEnableValidationLayer = Config::Get(Config::GFX_ENABLE_VALIDATION_LAYER);
|
|
|
|
bBackendMultithreading = Config::Get(Config::GFX_BACKEND_MULTITHREADING);
|
|
|
|
iCommandBufferExecuteInterval = Config::Get(Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL);
|
|
|
|
bShaderCache = Config::Get(Config::GFX_SHADER_CACHE);
|
2018-03-01 09:21:06 +00:00
|
|
|
bWaitForShadersBeforeStarting = Config::Get(Config::GFX_WAIT_FOR_SHADERS_BEFORE_STARTING);
|
2018-05-11 20:38:44 +00:00
|
|
|
iShaderCompilationMode = Config::Get(Config::GFX_SHADER_COMPILATION_MODE);
|
2017-06-13 10:07:09 +00:00
|
|
|
iShaderCompilerThreads = Config::Get(Config::GFX_SHADER_COMPILER_THREADS);
|
2017-07-27 03:15:38 +00:00
|
|
|
iShaderPrecompilerThreads = Config::Get(Config::GFX_SHADER_PRECOMPILER_THREADS);
|
2022-07-26 08:57:30 +00:00
|
|
|
bCPUCull = Config::Get(Config::GFX_CPU_CULL);
|
2017-05-18 12:59:38 +00:00
|
|
|
|
2022-11-14 05:01:19 +00:00
|
|
|
texture_filtering_mode = Config::Get(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING);
|
2017-05-18 12:59:38 +00:00
|
|
|
iMaxAnisotropy = Config::Get(Config::GFX_ENHANCE_MAX_ANISOTROPY);
|
2023-06-27 00:23:08 +00:00
|
|
|
output_resampling_mode = Config::Get(Config::GFX_ENHANCE_OUTPUT_RESAMPLING);
|
2017-05-18 12:59:38 +00:00
|
|
|
sPostProcessingShader = Config::Get(Config::GFX_ENHANCE_POST_SHADER);
|
|
|
|
bForceTrueColor = Config::Get(Config::GFX_ENHANCE_FORCE_TRUE_COLOR);
|
2018-04-29 08:52:30 +00:00
|
|
|
bDisableCopyFilter = Config::Get(Config::GFX_ENHANCE_DISABLE_COPY_FILTER);
|
2018-05-17 00:12:56 +00:00
|
|
|
bArbitraryMipmapDetection = Config::Get(Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION);
|
2018-05-17 00:45:10 +00:00
|
|
|
fArbitraryMipmapDetectionThreshold =
|
|
|
|
Config::Get(Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION_THRESHOLD);
|
Video: implement color correction to match the NTSC and PAL color spaces (and gamma) that GC and Wii targeted.
To further increase the accuracy of the post process phase, I've added (scRGB) HDR support, which is necessary
to fully display the PAL and NTSC-J color spaces, and also to improve the quality of post process texture samplings and
do them in linear space instead of gamma space (which is very important when playing at low resolutions).
For SDR, the quality is also slightly increased, at least if any post process runs, as the buffer is now
R10G10B10A2 (on Vulkan, DX11 and DX12) if supported; previously it was R8G8B8A8 but the alpha bits were wasted.
Gamma correction is arguably the most important thing as Dolphin on Windows outputted in "sRGB" (implicitly)
as that's what Windows expects by default, though sRGB gamma is very different from the gamma commonly used
by video standards dating to the pre HDR era (roughly gamma 2.35).
Additionally, the addition of HDR support (which is pretty straight forward and minimal), added support for
our own custom AutoHDR shaders, which would allow us to achieve decent looking HDR in Dolphin games without
having to use SpecialK or Windows 11 AutoHDR. Both of which don't necessarily play nice with older games
with strongly different and simpler lighting. HDR should also be supported in Linux.
Development of my own AutoHDR shader is almost complete and will come next.
This has been carefully tested and there should be no regression in any of the different features that Dolphin
offers, like multisampling, stereo rendering, other post processes, etc etc.
Fixes: https://bugs.dolphin-emu.org/issues/8941
Co-authored-by: EndlesslyFlowering <EndlesslyFlowering@protonmail.com>
Co-authored-by: Dogway <lin_ares@hotmail.com>
2023-06-10 08:48:05 +00:00
|
|
|
bHDR = Config::Get(Config::GFX_ENHANCE_HDR_OUTPUT);
|
|
|
|
|
|
|
|
color_correction.bCorrectColorSpace = Config::Get(Config::GFX_CC_CORRECT_COLOR_SPACE);
|
|
|
|
color_correction.game_color_space = Config::Get(Config::GFX_CC_GAME_COLOR_SPACE);
|
|
|
|
color_correction.bCorrectGamma = Config::Get(Config::GFX_CC_CORRECT_GAMMA);
|
|
|
|
color_correction.fGameGamma = Config::Get(Config::GFX_CC_GAME_GAMMA);
|
|
|
|
color_correction.bSDRDisplayGammaSRGB = Config::Get(Config::GFX_CC_SDR_DISPLAY_GAMMA_SRGB);
|
|
|
|
color_correction.fSDRDisplayCustomGamma = Config::Get(Config::GFX_CC_SDR_DISPLAY_CUSTOM_GAMMA);
|
|
|
|
color_correction.fHDRPaperWhiteNits = Config::Get(Config::GFX_CC_HDR_PAPER_WHITE_NITS);
|
2017-05-18 12:59:38 +00:00
|
|
|
|
2018-05-11 20:38:44 +00:00
|
|
|
stereo_mode = Config::Get(Config::GFX_STEREO_MODE);
|
2017-05-18 12:59:38 +00:00
|
|
|
iStereoDepth = Config::Get(Config::GFX_STEREO_DEPTH);
|
|
|
|
iStereoConvergencePercentage = Config::Get(Config::GFX_STEREO_CONVERGENCE_PERCENTAGE);
|
|
|
|
bStereoSwapEyes = Config::Get(Config::GFX_STEREO_SWAP_EYES);
|
|
|
|
iStereoConvergence = Config::Get(Config::GFX_STEREO_CONVERGENCE);
|
|
|
|
bStereoEFBMonoDepth = Config::Get(Config::GFX_STEREO_EFB_MONO_DEPTH);
|
|
|
|
iStereoDepthPercentage = Config::Get(Config::GFX_STEREO_DEPTH_PERCENTAGE);
|
|
|
|
|
|
|
|
bEFBAccessEnable = Config::Get(Config::GFX_HACK_EFB_ACCESS_ENABLE);
|
2019-03-02 07:05:38 +00:00
|
|
|
bEFBAccessDeferInvalidation = Config::Get(Config::GFX_HACK_EFB_DEFER_INVALIDATION);
|
2017-05-18 12:59:38 +00:00
|
|
|
bBBoxEnable = Config::Get(Config::GFX_HACK_BBOX_ENABLE);
|
|
|
|
bForceProgressive = Config::Get(Config::GFX_HACK_FORCE_PROGRESSIVE);
|
|
|
|
bSkipEFBCopyToRam = Config::Get(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM);
|
2017-06-26 03:23:47 +00:00
|
|
|
bSkipXFBCopyToRam = Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM);
|
2018-02-11 05:36:49 +00:00
|
|
|
bDisableCopyToVRAM = Config::Get(Config::GFX_HACK_DISABLE_COPY_TO_VRAM);
|
2018-11-02 14:17:00 +00:00
|
|
|
bDeferEFBCopies = Config::Get(Config::GFX_HACK_DEFER_EFB_COPIES);
|
2017-08-13 04:10:21 +00:00
|
|
|
bImmediateXFB = Config::Get(Config::GFX_HACK_IMMEDIATE_XFB);
|
2023-01-14 06:56:37 +00:00
|
|
|
bVISkip = Config::Get(Config::GFX_HACK_VI_SKIP);
|
|
|
|
bSkipPresentingDuplicateXFBs = bVISkip || Config::Get(Config::GFX_HACK_SKIP_DUPLICATE_XFBS);
|
2017-12-16 21:18:13 +00:00
|
|
|
bCopyEFBScaled = Config::Get(Config::GFX_HACK_COPY_EFB_SCALED);
|
2017-05-18 12:59:38 +00:00
|
|
|
bEFBEmulateFormatChanges = Config::Get(Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES);
|
2022-01-26 23:48:12 +00:00
|
|
|
bVertexRounding = Config::Get(Config::GFX_HACK_VERTEX_ROUNDING);
|
2019-03-02 05:11:47 +00:00
|
|
|
iEFBAccessTileSize = Config::Get(Config::GFX_HACK_EFB_ACCESS_TILE_SIZE);
|
2021-02-23 03:03:06 +00:00
|
|
|
iMissingColorValue = Config::Get(Config::GFX_HACK_MISSING_COLOR_VALUE);
|
2021-07-30 00:43:35 +00:00
|
|
|
bFastTextureSampling = Config::Get(Config::GFX_HACK_FAST_TEXTURE_SAMPLING);
|
2022-11-07 05:28:46 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
bNoMipmapping = Config::Get(Config::GFX_HACK_NO_MIPMAPPING);
|
|
|
|
#endif
|
2017-05-18 12:59:38 +00:00
|
|
|
|
|
|
|
bPerfQueriesEnable = Config::Get(Config::GFX_PERF_QUERIES_ENABLE);
|
2022-04-07 05:00:38 +00:00
|
|
|
|
|
|
|
bGraphicMods = Config::Get(Config::GFX_MODS_ENABLE);
|
2023-05-31 22:05:06 +00:00
|
|
|
|
|
|
|
customDriverLibraryName = Config::Get(Config::GFX_DRIVER_LIB_NAME);
|
2008-10-22 21:23:40 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2011-02-13 13:42:59 +00:00
|
|
|
void VideoConfig::VerifyValidity()
|
|
|
|
{
|
|
|
|
// TODO: Check iMaxAnisotropy value
|
2015-12-12 12:00:08 +00:00
|
|
|
if (iAdapter < 0 || iAdapter > ((int)backend_info.Adapters.size() - 1))
|
|
|
|
iAdapter = 0;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-12-12 12:00:08 +00:00
|
|
|
if (std::find(backend_info.AAModes.begin(), backend_info.AAModes.end(), iMultisamples) ==
|
|
|
|
backend_info.AAModes.end())
|
|
|
|
iMultisamples = 1;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-11-11 03:55:00 +00:00
|
|
|
if (stereo_mode != StereoMode::Off)
|
2014-12-20 18:54:00 +00:00
|
|
|
{
|
2014-12-20 21:14:45 +00:00
|
|
|
if (!backend_info.bSupportsGeometryShaders)
|
|
|
|
{
|
|
|
|
OSD::AddMessage(
|
|
|
|
"Stereoscopic 3D isn't supported by your GPU, support for OpenGL 3.2 is required.",
|
|
|
|
10000);
|
2017-11-11 03:55:00 +00:00
|
|
|
stereo_mode = StereoMode::Off;
|
2014-12-20 21:14:45 +00:00
|
|
|
}
|
2014-12-20 18:54:00 +00:00
|
|
|
}
|
2009-03-20 11:51:22 +00:00
|
|
|
}
|
|
|
|
|
2018-03-16 13:10:22 +00:00
|
|
|
bool VideoConfig::UsingUberShaders() const
|
|
|
|
{
|
|
|
|
return iShaderCompilationMode == ShaderCompilationMode::SynchronousUberShaders ||
|
|
|
|
iShaderCompilationMode == ShaderCompilationMode::AsynchronousUberShaders;
|
|
|
|
}
|
|
|
|
|
2017-07-27 03:15:38 +00:00
|
|
|
static u32 GetNumAutoShaderCompilerThreads()
|
|
|
|
{
|
2022-07-19 04:45:27 +00:00
|
|
|
// Automatic number.
|
|
|
|
return static_cast<u32>(std::clamp(cpu_info.num_cores - 3, 1, 4));
|
2017-07-27 03:15:38 +00:00
|
|
|
}
|
|
|
|
|
2021-01-02 12:47:18 +00:00
|
|
|
static u32 GetNumAutoShaderPreCompilerThreads()
|
|
|
|
{
|
|
|
|
// Automatic number. We use clamp(cpus - 2, 1, infty) here.
|
|
|
|
// We chose this because we don't want to limit our speed-up
|
|
|
|
// and at the same time leave two logical cores for the dolphin UI and the rest of the OS.
|
|
|
|
return static_cast<u32>(std::max(cpu_info.num_cores - 2, 1));
|
|
|
|
}
|
|
|
|
|
2017-06-13 10:07:09 +00:00
|
|
|
u32 VideoConfig::GetShaderCompilerThreads() const
|
|
|
|
{
|
2018-02-25 07:56:09 +00:00
|
|
|
if (!backend_info.bSupportsBackgroundCompiling)
|
2018-02-24 15:15:35 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-06-13 10:07:09 +00:00
|
|
|
if (iShaderCompilerThreads >= 0)
|
|
|
|
return static_cast<u32>(iShaderCompilerThreads);
|
2017-07-27 03:15:38 +00:00
|
|
|
else
|
|
|
|
return GetNumAutoShaderCompilerThreads();
|
|
|
|
}
|
2017-06-13 10:07:09 +00:00
|
|
|
|
2017-07-27 03:15:38 +00:00
|
|
|
u32 VideoConfig::GetShaderPrecompilerThreads() const
|
|
|
|
{
|
2018-03-01 09:21:06 +00:00
|
|
|
// When using background compilation, always keep the same thread count.
|
2018-03-11 04:24:45 +00:00
|
|
|
if (!bWaitForShadersBeforeStarting)
|
2018-03-01 09:21:06 +00:00
|
|
|
return GetShaderCompilerThreads();
|
|
|
|
|
2018-02-25 07:56:09 +00:00
|
|
|
if (!backend_info.bSupportsBackgroundCompiling)
|
2018-02-24 15:15:35 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-07-27 03:15:38 +00:00
|
|
|
if (iShaderPrecompilerThreads >= 0)
|
|
|
|
return static_cast<u32>(iShaderPrecompilerThreads);
|
2022-01-05 02:40:07 +00:00
|
|
|
else if (!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_MULTITHREADED_SHADER_PRECOMPILATION))
|
2021-01-02 12:47:18 +00:00
|
|
|
return GetNumAutoShaderPreCompilerThreads();
|
2017-07-27 03:15:38 +00:00
|
|
|
else
|
2021-06-03 14:03:37 +00:00
|
|
|
return 1;
|
2017-06-13 10:07:09 +00:00
|
|
|
}
|
2023-01-29 16:06:25 +00:00
|
|
|
|
|
|
|
void CheckForConfigChanges()
|
|
|
|
{
|
|
|
|
const ShaderHostConfig old_shader_host_config = ShaderHostConfig::GetCurrent();
|
|
|
|
const StereoMode old_stereo = g_ActiveConfig.stereo_mode;
|
|
|
|
const u32 old_multisamples = g_ActiveConfig.iMultisamples;
|
|
|
|
const int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
|
|
|
|
const int old_efb_access_tile_size = g_ActiveConfig.iEFBAccessTileSize;
|
|
|
|
const auto old_texture_filtering_mode = g_ActiveConfig.texture_filtering_mode;
|
|
|
|
const bool old_vsync = g_ActiveConfig.bVSyncActive;
|
|
|
|
const bool old_bbox = g_ActiveConfig.bBBoxEnable;
|
2023-01-31 04:26:46 +00:00
|
|
|
const int old_efb_scale = g_ActiveConfig.iEFBScale;
|
2023-01-29 16:06:25 +00:00
|
|
|
const u32 old_game_mod_changes =
|
|
|
|
g_ActiveConfig.graphics_mod_config ? g_ActiveConfig.graphics_mod_config->GetChangeCount() : 0;
|
|
|
|
const bool old_graphics_mods_enabled = g_ActiveConfig.bGraphicMods;
|
2023-01-30 11:49:23 +00:00
|
|
|
const AspectMode old_suggested_aspect_mode = g_ActiveConfig.suggested_aspect_mode;
|
|
|
|
const bool old_widescreen_hack = g_ActiveConfig.bWidescreenHack;
|
|
|
|
const auto old_post_processing_shader = g_ActiveConfig.sPostProcessingShader;
|
Video: implement color correction to match the NTSC and PAL color spaces (and gamma) that GC and Wii targeted.
To further increase the accuracy of the post process phase, I've added (scRGB) HDR support, which is necessary
to fully display the PAL and NTSC-J color spaces, and also to improve the quality of post process texture samplings and
do them in linear space instead of gamma space (which is very important when playing at low resolutions).
For SDR, the quality is also slightly increased, at least if any post process runs, as the buffer is now
R10G10B10A2 (on Vulkan, DX11 and DX12) if supported; previously it was R8G8B8A8 but the alpha bits were wasted.
Gamma correction is arguably the most important thing as Dolphin on Windows outputted in "sRGB" (implicitly)
as that's what Windows expects by default, though sRGB gamma is very different from the gamma commonly used
by video standards dating to the pre HDR era (roughly gamma 2.35).
Additionally, the addition of HDR support (which is pretty straight forward and minimal), added support for
our own custom AutoHDR shaders, which would allow us to achieve decent looking HDR in Dolphin games without
having to use SpecialK or Windows 11 AutoHDR. Both of which don't necessarily play nice with older games
with strongly different and simpler lighting. HDR should also be supported in Linux.
Development of my own AutoHDR shader is almost complete and will come next.
This has been carefully tested and there should be no regression in any of the different features that Dolphin
offers, like multisampling, stereo rendering, other post processes, etc etc.
Fixes: https://bugs.dolphin-emu.org/issues/8941
Co-authored-by: EndlesslyFlowering <EndlesslyFlowering@protonmail.com>
Co-authored-by: Dogway <lin_ares@hotmail.com>
2023-06-10 08:48:05 +00:00
|
|
|
const auto old_hdr = g_ActiveConfig.bHDR;
|
2023-01-29 16:06:25 +00:00
|
|
|
|
|
|
|
UpdateActiveConfig();
|
|
|
|
FreeLook::UpdateActiveConfig();
|
|
|
|
g_vertex_manager->OnConfigChange();
|
|
|
|
|
|
|
|
g_freelook_camera.SetControlType(FreeLook::GetActiveConfig().camera_config.control_type);
|
|
|
|
|
|
|
|
if (g_ActiveConfig.bGraphicMods && !old_graphics_mods_enabled)
|
|
|
|
{
|
|
|
|
g_ActiveConfig.graphics_mod_config = GraphicsModGroupConfig(SConfig::GetInstance().GetGameID());
|
|
|
|
g_ActiveConfig.graphics_mod_config->Load();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_ActiveConfig.graphics_mod_config &&
|
|
|
|
(old_game_mod_changes != g_ActiveConfig.graphics_mod_config->GetChangeCount()))
|
|
|
|
{
|
|
|
|
g_graphics_mod_manager->Load(*g_ActiveConfig.graphics_mod_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update texture cache settings with any changed options.
|
|
|
|
g_texture_cache->OnConfigChanged(g_ActiveConfig);
|
|
|
|
|
|
|
|
// EFB tile cache doesn't need to notify the backend.
|
|
|
|
if (old_efb_access_tile_size != g_ActiveConfig.iEFBAccessTileSize)
|
|
|
|
g_framebuffer_manager->SetEFBCacheTileSize(std::max(g_ActiveConfig.iEFBAccessTileSize, 0));
|
|
|
|
|
|
|
|
// Determine which (if any) settings have changed.
|
|
|
|
ShaderHostConfig new_host_config = ShaderHostConfig::GetCurrent();
|
|
|
|
u32 changed_bits = 0;
|
|
|
|
if (old_shader_host_config.bits != new_host_config.bits)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_HOST_CONFIG;
|
|
|
|
if (old_stereo != g_ActiveConfig.stereo_mode)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_STEREO_MODE;
|
|
|
|
if (old_multisamples != g_ActiveConfig.iMultisamples)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_MULTISAMPLES;
|
|
|
|
if (old_anisotropy != g_ActiveConfig.iMaxAnisotropy)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_ANISOTROPY;
|
|
|
|
if (old_texture_filtering_mode != g_ActiveConfig.texture_filtering_mode)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING;
|
|
|
|
if (old_vsync != g_ActiveConfig.bVSyncActive)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_VSYNC;
|
|
|
|
if (old_bbox != g_ActiveConfig.bBBoxEnable)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_BBOX;
|
2023-01-31 04:26:46 +00:00
|
|
|
if (old_efb_scale != g_ActiveConfig.iEFBScale)
|
2023-01-29 16:06:25 +00:00
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_TARGET_SIZE;
|
2023-01-30 11:49:23 +00:00
|
|
|
if (old_suggested_aspect_mode != g_ActiveConfig.suggested_aspect_mode)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_ASPECT_RATIO;
|
|
|
|
if (old_widescreen_hack != g_ActiveConfig.bWidescreenHack)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_ASPECT_RATIO;
|
|
|
|
if (old_post_processing_shader != g_ActiveConfig.sPostProcessingShader)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_POST_PROCESSING_SHADER;
|
Video: implement color correction to match the NTSC and PAL color spaces (and gamma) that GC and Wii targeted.
To further increase the accuracy of the post process phase, I've added (scRGB) HDR support, which is necessary
to fully display the PAL and NTSC-J color spaces, and also to improve the quality of post process texture samplings and
do them in linear space instead of gamma space (which is very important when playing at low resolutions).
For SDR, the quality is also slightly increased, at least if any post process runs, as the buffer is now
R10G10B10A2 (on Vulkan, DX11 and DX12) if supported; previously it was R8G8B8A8 but the alpha bits were wasted.
Gamma correction is arguably the most important thing as Dolphin on Windows outputted in "sRGB" (implicitly)
as that's what Windows expects by default, though sRGB gamma is very different from the gamma commonly used
by video standards dating to the pre HDR era (roughly gamma 2.35).
Additionally, the addition of HDR support (which is pretty straight forward and minimal), added support for
our own custom AutoHDR shaders, which would allow us to achieve decent looking HDR in Dolphin games without
having to use SpecialK or Windows 11 AutoHDR. Both of which don't necessarily play nice with older games
with strongly different and simpler lighting. HDR should also be supported in Linux.
Development of my own AutoHDR shader is almost complete and will come next.
This has been carefully tested and there should be no regression in any of the different features that Dolphin
offers, like multisampling, stereo rendering, other post processes, etc etc.
Fixes: https://bugs.dolphin-emu.org/issues/8941
Co-authored-by: EndlesslyFlowering <EndlesslyFlowering@protonmail.com>
Co-authored-by: Dogway <lin_ares@hotmail.com>
2023-06-10 08:48:05 +00:00
|
|
|
if (old_hdr != g_ActiveConfig.bHDR)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_HDR;
|
2023-01-29 16:06:25 +00:00
|
|
|
|
|
|
|
// No changes?
|
|
|
|
if (changed_bits == 0)
|
|
|
|
return;
|
|
|
|
|
2023-01-31 04:26:46 +00:00
|
|
|
float old_scale = g_framebuffer_manager->GetEFBScale();
|
2023-01-29 16:06:25 +00:00
|
|
|
|
|
|
|
// Framebuffer changed?
|
|
|
|
if (changed_bits & (CONFIG_CHANGE_BIT_MULTISAMPLES | CONFIG_CHANGE_BIT_STEREO_MODE |
|
Video: implement color correction to match the NTSC and PAL color spaces (and gamma) that GC and Wii targeted.
To further increase the accuracy of the post process phase, I've added (scRGB) HDR support, which is necessary
to fully display the PAL and NTSC-J color spaces, and also to improve the quality of post process texture samplings and
do them in linear space instead of gamma space (which is very important when playing at low resolutions).
For SDR, the quality is also slightly increased, at least if any post process runs, as the buffer is now
R10G10B10A2 (on Vulkan, DX11 and DX12) if supported; previously it was R8G8B8A8 but the alpha bits were wasted.
Gamma correction is arguably the most important thing as Dolphin on Windows outputted in "sRGB" (implicitly)
as that's what Windows expects by default, though sRGB gamma is very different from the gamma commonly used
by video standards dating to the pre HDR era (roughly gamma 2.35).
Additionally, the addition of HDR support (which is pretty straight forward and minimal), added support for
our own custom AutoHDR shaders, which would allow us to achieve decent looking HDR in Dolphin games without
having to use SpecialK or Windows 11 AutoHDR. Both of which don't necessarily play nice with older games
with strongly different and simpler lighting. HDR should also be supported in Linux.
Development of my own AutoHDR shader is almost complete and will come next.
This has been carefully tested and there should be no regression in any of the different features that Dolphin
offers, like multisampling, stereo rendering, other post processes, etc etc.
Fixes: https://bugs.dolphin-emu.org/issues/8941
Co-authored-by: EndlesslyFlowering <EndlesslyFlowering@protonmail.com>
Co-authored-by: Dogway <lin_ares@hotmail.com>
2023-06-10 08:48:05 +00:00
|
|
|
CONFIG_CHANGE_BIT_TARGET_SIZE | CONFIG_CHANGE_BIT_HDR))
|
2023-01-29 16:06:25 +00:00
|
|
|
{
|
|
|
|
g_framebuffer_manager->RecreateEFBFramebuffer();
|
|
|
|
}
|
|
|
|
|
2023-01-31 04:26:46 +00:00
|
|
|
if (old_scale != g_framebuffer_manager->GetEFBScale())
|
|
|
|
{
|
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
|
|
|
pixel_shader_manager.Dirty();
|
|
|
|
}
|
|
|
|
|
2023-01-29 16:06:25 +00:00
|
|
|
// Reload shaders if host config has changed.
|
|
|
|
if (changed_bits & (CONFIG_CHANGE_BIT_HOST_CONFIG | CONFIG_CHANGE_BIT_MULTISAMPLES))
|
|
|
|
{
|
|
|
|
OSD::AddMessage("Video config changed, reloading shaders.", OSD::Duration::NORMAL);
|
|
|
|
g_vertex_manager->InvalidatePipelineObject();
|
2023-02-10 01:39:40 +00:00
|
|
|
g_vertex_manager->NotifyCustomShaderCacheOfHostChange(new_host_config);
|
2023-01-29 16:06:25 +00:00
|
|
|
g_shader_cache->SetHostConfig(new_host_config);
|
|
|
|
g_shader_cache->Reload();
|
|
|
|
g_framebuffer_manager->RecompileShaders();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Viewport and scissor rect have to be reset since they will be scaled differently.
|
|
|
|
if (changed_bits & CONFIG_CHANGE_BIT_TARGET_SIZE)
|
|
|
|
{
|
|
|
|
BPFunctions::SetScissorAndViewport();
|
|
|
|
}
|
2023-01-31 04:26:46 +00:00
|
|
|
|
|
|
|
// Notify all listeners
|
|
|
|
ConfigChangedEvent::Trigger(changed_bits);
|
|
|
|
|
|
|
|
// TODO: Move everything else to the ConfigChanged event
|
2023-01-29 16:06:25 +00:00
|
|
|
}
|
2023-01-30 11:46:10 +00:00
|
|
|
|
2023-02-03 00:18:37 +00:00
|
|
|
static Common::EventHook s_check_config_event =
|
2023-01-31 06:21:15 +00:00
|
|
|
AfterFrameEvent::Register([] { CheckForConfigChanges(); }, "CheckForConfigChanges");
|