2020-09-10 14:18:12 +00:00
# include "enhancementsettingswidget.h"
# include "core/gpu.h"
# include "core/settings.h"
# include "qtutils.h"
# include "settingsdialog.h"
# include "settingwidgetbinder.h"
2022-07-11 13:03:29 +00:00
EnhancementSettingsWidget : : EnhancementSettingsWidget ( SettingsDialog * dialog , QWidget * parent )
: QWidget ( parent ) , m_dialog ( dialog )
2020-09-10 14:18:12 +00:00
{
2022-07-11 13:03:29 +00:00
SettingsInterface * sif = dialog - > getSettingsInterface ( ) ;
2020-09-10 14:18:12 +00:00
m_ui . setupUi ( this ) ;
setupAdditionalUi ( ) ;
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToIntSetting ( sif , m_ui . resolutionScale , " GPU " , " ResolutionScale " , 1 ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . trueColor , " GPU " , " TrueColor " , false ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . scaledDithering , " GPU " , " ScaledDithering " , false ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . disableInterlacing , " GPU " , " DisableInterlacing " ,
2021-01-28 13:52:23 +00:00
true ) ;
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . forceNTSCTimings , " GPU " , " ForceNTSCTimings " ,
2021-01-28 13:52:23 +00:00
false ) ;
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . force43For24Bit , " Display " , " Force4_3For24Bit " ,
2021-01-28 13:52:23 +00:00
false ) ;
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . chromaSmoothingFor24Bit , " GPU " ,
2021-01-28 13:52:23 +00:00
" ChromaSmoothing24Bit " , false ) ;
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToEnumSetting ( sif , m_ui . textureFiltering , " GPU " , " TextureFilter " ,
2020-11-10 14:14:58 +00:00
& Settings : : ParseTextureFilterName , & Settings : : GetTextureFilterName ,
Settings : : DEFAULT_GPU_TEXTURE_FILTER ) ;
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . widescreenHack , " GPU " , " WidescreenHack " , false ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . useSoftwareRendererForReadbacks , " GPU " ,
2021-06-30 05:40:31 +00:00
" UseSoftwareRendererForReadbacks " , false ) ;
2020-09-10 14:18:12 +00:00
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . pgxpEnable , " GPU " , " PGXPEnable " , false ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . pgxpCulling , " GPU " , " PGXPCulling " , true ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . pgxpTextureCorrection , " GPU " ,
2020-09-10 14:18:12 +00:00
" PGXPTextureCorrection " , true ) ;
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . pgxpDepthBuffer , " GPU " , " PGXPDepthBuffer " , false ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . pgxpPreserveProjPrecision , " GPU " ,
2021-02-17 16:05:27 +00:00
" PGXPPreserveProjFP " , false ) ;
2022-07-11 13:03:29 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . pgxpCPU , " GPU " , " PGXPCPU " , false ) ;
2020-09-10 14:18:12 +00:00
connect ( m_ui . resolutionScale , QOverload < int > : : of ( & QComboBox : : currentIndexChanged ) , this ,
& EnhancementSettingsWidget : : updateScaledDitheringEnabled ) ;
connect ( m_ui . trueColor , & QCheckBox : : stateChanged , this , & EnhancementSettingsWidget : : updateScaledDitheringEnabled ) ;
updateScaledDitheringEnabled ( ) ;
connect ( m_ui . pgxpEnable , & QCheckBox : : stateChanged , this , & EnhancementSettingsWidget : : updatePGXPSettingsEnabled ) ;
updatePGXPSettingsEnabled ( ) ;
dialog - > registerWidgetHelp (
m_ui . disableInterlacing , tr ( " Disable Interlacing (force progressive render/scan) " ) , tr ( " Unchecked " ) ,
tr (
" Forces the rendering and display of frames to progressive mode. <br>This removes the \" combing \" effect seen in "
" 480i games by rendering them in 480p. Usually safe to enable.<br> "
" <b><u>May not be compatible with all games.</u></b> " ) ) ;
dialog - > registerWidgetHelp (
m_ui . resolutionScale , tr ( " Resolution Scale " ) , " 1x " ,
tr ( " Setting this beyond 1x will enhance the resolution of rendered 3D polygons and lines. Only applies "
" to the hardware backends. <br>This option is usually safe, with most games looking fine at "
" higher resolutions. Higher resolutions require a more powerful GPU. " ) ) ;
dialog - > registerWidgetHelp (
m_ui . trueColor , tr ( " True Color Rendering (24-bit, disables dithering) " ) , tr ( " Unchecked " ) ,
tr ( " Forces the precision of colours output to the console's framebuffer to use the full 8 bits of precision per "
" channel. This produces nicer looking gradients at the cost of making some colours look slightly different. "
" Disabling the option also enables dithering, which makes the transition between colours less sharp by applying "
" a pattern around those pixels. Most games are compatible with this option, but there is a number which aren't "
" and will have broken effects with it enabled. Only applies to the hardware renderers. " ) ) ;
dialog - > registerWidgetHelp (
m_ui . scaledDithering , tr ( " Scaled Dithering (scale dither pattern to resolution) " ) , tr ( " Checked " ) ,
tr ( " Scales the dither pattern to the resolution scale of the emulated GPU. This makes the dither pattern much less "
" obvious at higher resolutions. <br>Usually safe to enable, and only supported by the hardware renderers. " ) ) ;
dialog - > registerWidgetHelp ( m_ui . forceNTSCTimings , tr ( " Force NTSC Timings (60hz-on-PAL) " ) , tr ( " Unchecked " ) ,
tr ( " Uses NTSC frame timings when the console is in PAL mode, forcing PAL games to run at "
" 60hz. <br>For most games which "
" have a speed tied to the framerate, this will result in the game running "
" approximately 17% faster. <br>For variable "
" frame rate games, it may not affect the speed. " ) ) ;
2020-09-26 05:11:45 +00:00
dialog - > registerWidgetHelp (
m_ui . force43For24Bit , tr ( " Force 4:3 For 24-bit Display " ) , tr ( " Unchecked " ) ,
tr ( " Switches back to 4:3 display aspect ratio when displaying 24-bit content, usually FMVs. " ) ) ;
2020-11-03 04:17:51 +00:00
dialog - > registerWidgetHelp ( m_ui . chromaSmoothingFor24Bit , tr ( " Chroma Smoothing For 24-Bit Display " ) , tr ( " Unchecked " ) ,
tr ( " Smooths out blockyness between colour transitions in 24-bit content, usually FMVs. "
" Only applies to the hardware renderers. " ) ) ;
2020-09-10 14:18:12 +00:00
dialog - > registerWidgetHelp (
2020-10-28 07:32:24 +00:00
m_ui . textureFiltering , tr ( " Texture Filtering " ) ,
qApp - > translate ( " GPUTextureFilter " , Settings : : GetTextureFilterDisplayName ( GPUTextureFilter : : Nearest ) ) ,
2022-09-22 12:23:31 +00:00
tr ( " Smooths out the blockiness of magnified textures on 3D object by using filtering. <br>Will have a "
" greater effect on higher resolution scales. Only applies to the hardware renderers. <br>The JINC2 and especially xBR filtering modes are very demanding, and may not be worth the speed penalty. " ) ) ;
2020-09-10 14:18:12 +00:00
dialog - > registerWidgetHelp (
m_ui . widescreenHack , tr ( " Widescreen Hack " ) , tr ( " Unchecked " ) ,
tr ( " Scales vertex positions in screen-space to a widescreen aspect ratio, essentially "
2020-11-10 14:14:58 +00:00
" increasing the field of view from 4:3 to the chosen display aspect ratio in 3D games. <br>For 2D games, or "
" games which use pre-rendered backgrounds, this enhancement will not work as expected. <br><b><u>May not be "
" compatible with all games.</u></b> " ) ) ;
2021-06-30 05:40:31 +00:00
dialog - > registerWidgetHelp (
m_ui . useSoftwareRendererForReadbacks , tr ( " Use Software Renderer For Readbacks " ) , tr ( " Unchecked " ) ,
tr ( " Runs the software renderer in parallel for VRAM readbacks. On some systems, this may result in greater "
" performance when using graphical enhancements with the hardware renderer. " ) ) ;
2020-09-10 14:18:12 +00:00
dialog - > registerWidgetHelp (
m_ui . pgxpEnable , tr ( " Geometry Correction " ) , tr ( " Unchecked " ) ,
tr ( " Reduces \" wobbly \" polygons and \" warping \" textures that are common in PS1 games. <br>Only "
" works with the hardware renderers. <b><u>May not be compatible with all games.</u></b> " ) ) ;
dialog - > registerWidgetHelp ( m_ui . pgxpCulling , tr ( " Culling Correction " ) , tr ( " Checked " ) ,
tr ( " Increases the precision of polygon culling, reducing the number of holes in geometry. "
" Requires geometry correction enabled. " ) ) ;
dialog - > registerWidgetHelp ( m_ui . pgxpTextureCorrection , tr ( " Texture Correction " ) , tr ( " Checked " ) ,
tr ( " Uses perspective-correct interpolation for texture coordinates and colors, "
" straightening out warped textures. Requires geometry correction enabled. " ) ) ;
2020-12-22 15:17:10 +00:00
dialog - > registerWidgetHelp (
2021-02-17 16:05:27 +00:00
m_ui . pgxpDepthBuffer , tr ( " Depth Buffer (Low Compatibility) " ) , tr ( " Unchecked " ) ,
2020-12-22 15:17:10 +00:00
tr ( " Attempts to reduce polygon Z-fighting by testing pixels against the depth values from PGXP. Low compatibility, "
" but can work well in some games. Other games may need a threshold adjustment. " ) ) ;
2021-02-17 16:05:27 +00:00
dialog - > registerWidgetHelp (
m_ui . pgxpPreserveProjPrecision , tr ( " Preserve Projection Precision " ) , tr ( " Unchecked " ) ,
tr ( " Adds additional precision to PGXP data post-projection. May improve visuals in some games. " ) ) ;
dialog - > registerWidgetHelp ( m_ui . pgxpCPU , tr ( " CPU Mode (Very Slow) " ) , tr ( " Unchecked " ) ,
tr ( " Uses PGXP for all instructions, not just memory operations. Required for PGXP to "
" correct wobble in some games, but has a very high performance cost. " ) ) ;
2020-09-10 14:18:12 +00:00
}
EnhancementSettingsWidget : : ~ EnhancementSettingsWidget ( ) = default ;
void EnhancementSettingsWidget : : updateScaledDitheringEnabled ( )
{
const int resolution_scale = m_ui . resolutionScale - > currentIndex ( ) ;
const bool true_color = m_ui . trueColor - > isChecked ( ) ;
const bool allow_scaled_dithering = ( resolution_scale ! = 1 & & ! true_color ) ;
m_ui . scaledDithering - > setEnabled ( allow_scaled_dithering ) ;
}
void EnhancementSettingsWidget : : setupAdditionalUi ( )
{
QtUtils : : FillComboBoxWithResolutionScales ( m_ui . resolutionScale ) ;
2020-09-11 12:20:19 +00:00
for ( u32 i = 0 ; i < static_cast < u32 > ( GPUTextureFilter : : Count ) ; i + + )
{
m_ui . textureFiltering - > addItem (
qApp - > translate ( " GPUTextureFilter " , Settings : : GetTextureFilterDisplayName ( static_cast < GPUTextureFilter > ( i ) ) ) ) ;
}
2020-09-10 14:18:12 +00:00
}
void EnhancementSettingsWidget : : updatePGXPSettingsEnabled ( )
{
const bool enabled = m_ui . pgxpEnable - > isChecked ( ) ;
m_ui . pgxpCulling - > setEnabled ( enabled ) ;
m_ui . pgxpTextureCorrection - > setEnabled ( enabled ) ;
2020-12-22 15:17:10 +00:00
m_ui . pgxpDepthBuffer - > setEnabled ( enabled ) ;
2021-02-17 16:05:27 +00:00
m_ui . pgxpPreserveProjPrecision - > setEnabled ( enabled ) ;
m_ui . pgxpCPU - > setEnabled ( enabled ) ;
2020-09-10 14:18:12 +00:00
}