gsdx:hw: Enable skipdraw hack to skip a range of draw calls

Enhance the skipdraw hack by allowing skipdraw to skip a range of draw
calls.

For example: When the broken effects are at frames 90-100, the default
skipdraw always skips 0-100, possibly skipping several functioning
effects as well. By enhancing the skipdraw feature, it is now possible
to skip just frames 90-100.

For the example given above set the first box to 90 and the second box
to 100 to skip frames 90-100.

coauthor:turtleli (Linux GUI + tidy/simplify Windows GUI code)
This commit is contained in:
FlatOutPS2 2018-08-02 20:55:14 +01:00 committed by Jonathan Li
parent fc1d88cb51
commit 1498f538dd
12 changed files with 142 additions and 33 deletions

View File

@ -2364,7 +2364,8 @@ bool GSState::IsBadFrame()
// General, often problematic post processing
if (GSLocalMemory::m_psm[fi.TPSM].depth || GSUtil::HasSharedBits(fi.FBP, fi.FPSM, fi.TBP0, fi.TPSM))
{
m_skip = m_userhacks_skipdraw;
m_skip_offset = m_userhacks_skipdraw_offset;
m_skip = std::max(m_userhacks_skipdraw, m_skip_offset);
}
}
}
@ -2373,7 +2374,10 @@ bool GSState::IsBadFrame()
{
m_skip--;
return true;
if (m_skip_offset > 1)
m_skip_offset--;
else
return true;
}
return false;

View File

@ -388,12 +388,53 @@ void populate_shader_table(GtkWidget* shader_table)
InsertWidgetInTable(shader_table , tv_shader_label , tv_shader);
}
static GtkWidget* s_hack_skipdraw_offset_spin;
static GtkWidget* s_hack_skipdraw_spin;
static void CB_SkipdrawRange(GtkSpinButton*, gpointer)
{
int skipdraw_offset = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(s_hack_skipdraw_offset_spin));
int skipdraw = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(s_hack_skipdraw_spin));
bool skipdraw_offset_changed = skipdraw_offset != theApp.GetConfigI("UserHacks_SkipDraw_Offset");
bool skipdraw_changed = skipdraw != theApp.GetConfigI("UserHacks_SkipDraw");
if (skipdraw_offset == 0 && skipdraw_offset_changed || skipdraw == 0 && skipdraw_changed) {
skipdraw_offset = 0;
skipdraw = 0;
} else if (skipdraw_offset > skipdraw) {
if (skipdraw_offset_changed)
skipdraw = skipdraw_offset;
if (skipdraw_changed)
skipdraw_offset = skipdraw;
} else if (skipdraw > 0 && skipdraw_offset == 0) {
skipdraw_offset = 1;
}
theApp.SetConfig("UserHacks_SkipDraw_Offset", skipdraw_offset);
theApp.SetConfig("UserHacks_SkipDraw", skipdraw);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(s_hack_skipdraw_offset_spin), skipdraw_offset);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(s_hack_skipdraw_spin), skipdraw);
}
static void CreateSkipdrawSpinButtons(double min, double max)
{
s_hack_skipdraw_offset_spin = gtk_spin_button_new_with_range(min, max, 1);
s_hack_skipdraw_spin = gtk_spin_button_new_with_range(min, max, 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(s_hack_skipdraw_offset_spin), theApp.GetConfigI("UserHacks_SkipDraw_Offset"));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(s_hack_skipdraw_spin), theApp.GetConfigI("UserHacks_SkipDraw"));
g_signal_connect(s_hack_skipdraw_offset_spin, "value-changed", G_CALLBACK(CB_SkipdrawRange), nullptr);
g_signal_connect(s_hack_skipdraw_spin, "value-changed", G_CALLBACK(CB_SkipdrawRange), nullptr);
}
void populate_hack_table(GtkWidget* hack_table)
{
GtkWidget* hack_offset_label = left_label("Half-pixel Offset:");
GtkWidget* hack_offset_box = CreateComboBoxFromVector(theApp.m_gs_offset_hack, "UserHacks_HalfPixelOffset");
GtkWidget* hack_skipdraw_label = left_label("Skipdraw:");
GtkWidget* hack_skipdraw_spin = CreateSpinButton(0, 10000, "UserHacks_SkipDraw");
GtkWidget* hack_skipdraw_label = left_label("Skipdraw Range:");
CreateSkipdrawSpinButtons(0, 10000);
GtkWidget* hack_wild_check = CreateCheckBox("Wild Arms Hack", "UserHacks_WildHack");
GtkWidget* hack_tco_label = left_label("Texture Offset: 0x");
GtkWidget* hack_tco_entry = CreateTextBox("UserHacks_TCOffset");
@ -418,7 +459,8 @@ void populate_hack_table(GtkWidget* hack_table)
AddTooltip(hack_offset_label, IDC_OFFSETHACK);
AddTooltip(hack_offset_box, IDC_OFFSETHACK);
AddTooltip(hack_skipdraw_label, IDC_SKIPDRAWHACK);
AddTooltip(hack_skipdraw_spin, IDC_SKIPDRAWHACK);
AddTooltip(s_hack_skipdraw_offset_spin, IDC_SKIPDRAWHACK);
AddTooltip(s_hack_skipdraw_spin, IDC_SKIPDRAWHACK);
AddTooltip(hack_wild_check, IDC_WILDHACK);
AddTooltip(hack_sprite_label, hack_sprite_box, IDC_SPRITEHACK);
AddTooltip(hack_tco_label, IDC_TCOFFSETX);
@ -450,7 +492,7 @@ void populate_hack_table(GtkWidget* hack_table)
InsertWidgetInTable(hack_table , hack_offset_label , hack_offset_box);
InsertWidgetInTable(hack_table , hack_sprite_label , hack_sprite_box );
InsertWidgetInTable(hack_table , stretch_hack_label , stretch_hack_box );
InsertWidgetInTable(hack_table , hack_skipdraw_label , hack_skipdraw_spin);
InsertWidgetInTable(hack_table , hack_skipdraw_label , s_hack_skipdraw_offset_spin, s_hack_skipdraw_spin);
InsertWidgetInTable(hack_table , hack_tco_label , hack_tco_entry);
}

View File

@ -278,6 +278,7 @@ void GSRendererHW::VSync(int field)
m_dev->PrintMemoryUsage();
m_skip = 0;
m_skip_offset = 0;
}
void GSRendererHW::ResetDevice()

View File

@ -57,9 +57,13 @@ const char* dialog_message(int ID, bool* updateText) {
"Works as a speedhack for: BleachBB, Kunoichi, Steambot Chronicles, The Simpsons Game.";
case IDC_SKIPDRAWHACK:
case IDC_SKIPDRAWHACKEDIT:
return "Skips drawing n surfaces completely. "
"Use it, for example, to try and get rid of bad post processing effects."
" Try values between 1 and 100.";
case IDC_SKIPDRAWOFFSET:
case IDC_SKIPDRAWOFFSETEDIT:
return "Completely skips drawing surfaces from the surface in the left box up to the surface specified in the box on the right.\n\n"
"Use it, for example, to try and get rid of bad post processing effects.\n"
"Step 1: Increase the value in the left box and keep the value in the right box set to the same value as the left box to find and remove a bad effect.\n"
"Step 2: If a bad effect found with Step 1 is not completely removed yet, then without changing the value in the left box, try increasing the value in the box to right until the effect is completely gone.\n"
"Note: Increase the value in the right box and keep the value in the left box set to \"1\" to reproduce the old skipdraw behaviour.";
case IDC_ALPHAHACK:
return "Different alpha handling. Can work around some shadow problems.";
case IDC_OFFSETHACK:

View File

@ -46,6 +46,8 @@ enum {
IDC_TRI_FILTER,
IDC_SKIPDRAWHACK,
IDC_SKIPDRAWHACKEDIT,
IDC_SKIPDRAWOFFSET,
IDC_SKIPDRAWOFFSETEDIT,
IDC_ALPHAHACK,
IDC_OFFSETHACK,
IDC_SPRITEHACK,

View File

@ -713,6 +713,10 @@ void GSHacksDlg::OnInit()
ComboBoxInit(IDC_GEOMETRY_SHADER_OVERRIDE, theApp.m_gs_gl_ext, theApp.GetConfigI("override_geometry_shader"));
ComboBoxInit(IDC_IMAGE_LOAD_STORE, theApp.m_gs_gl_ext, theApp.GetConfigI("override_GL_ARB_shader_image_load_store"));
m_old_skipdraw_offset = 0;
m_old_skipdraw = 0;
SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWOFFSET), UDM_SETRANGE, 0, MAKELPARAM(10000, 0));
SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWOFFSET), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfigI("UserHacks_SkipDraw_Offset"), 0));
SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_SETRANGE, 0, MAKELPARAM(10000, 0));
SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfigI("UserHacks_SkipDraw"), 0));
@ -753,6 +757,8 @@ void GSHacksDlg::OnInit()
AddTooltip(IDC_SKIPDRAWHACKEDIT);
AddTooltip(IDC_SKIPDRAWHACK);
AddTooltip(IDC_SKIPDRAWOFFSETEDIT);
AddTooltip(IDC_SKIPDRAWOFFSET);
AddTooltip(IDC_ALPHAHACK);
AddTooltip(IDC_OFFSETHACK);
AddTooltip(IDC_SPRITEHACK);
@ -776,10 +782,38 @@ void GSHacksDlg::OnInit()
AddTooltip(IDC_MERGE_PP_SPRITE);
AddTooltip(IDC_GEOMETRY_SHADER_OVERRIDE);
AddTooltip(IDC_IMAGE_LOAD_STORE);
UpdateControls();
}
void GSHacksDlg::UpdateControls()
{}
{
int skipdraw_offset = SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWOFFSET), UDM_GETPOS, 0, 0);
int skipdraw = SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_GETPOS, 0, 0);
bool skipdraw_offset_changed = skipdraw_offset != m_old_skipdraw_offset;
bool skipdraw_changed = skipdraw != m_old_skipdraw;
if (skipdraw_offset == 0 && skipdraw_offset_changed || skipdraw == 0 && skipdraw_changed)
{
skipdraw_offset = 0;
skipdraw = 0;
}
else if (skipdraw_offset > skipdraw)
{
if (skipdraw_offset_changed)
skipdraw = skipdraw_offset;
}
else if (skipdraw > 0 && skipdraw_offset == 0)
{
skipdraw_offset = 1;
}
SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWOFFSET), UDM_SETPOS, 0, MAKELPARAM(skipdraw_offset, 0));
SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_SETPOS, 0, MAKELPARAM(skipdraw, 0));
m_old_skipdraw_offset = skipdraw_offset;
m_old_skipdraw = skipdraw;
}
bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
@ -791,7 +825,12 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
switch(id)
{
case IDOK:
case IDC_SKIPDRAWHACKEDIT:
case IDC_SKIPDRAWOFFSETEDIT:
if (HIWORD(wParam) == EN_CHANGE)
UpdateControls();
break;
case IDOK:
{
INT_PTR data;
if (ComboBoxGetSelData(IDC_TRI_FILTER, data))
@ -818,9 +857,17 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
theApp.SetConfig("override_GL_ARB_shader_image_load_store", (int)data);
}
// It's more user friendly to lower the skipdraw offset value here - it prevents the skipdraw offset
// value from decreasing unnecessarily if the user types a skipdraw value that is temporarily lower
// than the skipdraw offset value.
int skipdraw_offset = SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWOFFSET), UDM_GETPOS, 0, 0);
int skipdraw = SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_GETPOS, 0, 0);
theApp.SetConfig("UserHacks_SkipDraw_Offset", std::min(skipdraw_offset, skipdraw));
theApp.SetConfig("UserHacks_SkipDraw", skipdraw);
theApp.SetConfig("UserHacks_MSAA", cb2msaa[(int)SendMessage(GetDlgItem(m_hWnd, IDC_MSAACB), CB_GETCURSEL, 0, 0)]);
theApp.SetConfig("UserHacks_AlphaHack", (int)IsDlgButtonChecked(m_hWnd, IDC_ALPHAHACK));
theApp.SetConfig("UserHacks_SkipDraw", (int)SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_GETPOS, 0, 0));
theApp.SetConfig("UserHacks_WildHack", (int)IsDlgButtonChecked(m_hWnd, IDC_WILDHACK));
theApp.SetConfig("UserHacks_AlphaStencil", (int)IsDlgButtonChecked(m_hWnd, IDC_ALPHASTENCIL));
theApp.SetConfig("preload_frame_with_gs_data", (int)IsDlgButtonChecked(m_hWnd, IDC_PRELOAD_GS));

View File

@ -45,8 +45,8 @@ class GSHacksDlg : public GSDialog
unsigned short cb2msaa[17];
unsigned short msaa2cb[17];
std::string adapter_id;
bool isdx9;
int m_old_skipdraw_offset;
int m_old_skipdraw;
void UpdateControls();

View File

@ -36,6 +36,7 @@ GSState::GSState()
, m_init_read_fifo_supported(false)
, m_gsc(NULL)
, m_skip(0)
, m_skip_offset(0)
, m_q(1.0f)
, m_texflush(true)
, m_vt(this)
@ -50,6 +51,7 @@ GSState::GSState()
m_mipmap = theApp.GetConfigI("mipmap");
m_NTSC_Saturation = theApp.GetConfigB("NTSC_Saturation");
m_userhacks_skipdraw = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_SkipDraw") : 0;
m_userhacks_skipdraw_offset = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_SkipDraw_Offset") : 0;
m_userhacks_auto_flush = theApp.GetConfigB("UserHacks") ? theApp.GetConfigB("UserHacks_AutoFlush") : 0;
m_clut_load_before_draw = theApp.GetConfigB("clut_load_before_draw");

View File

@ -163,7 +163,9 @@ protected:
CRCHackLevel m_crc_hack_level;
GetSkipCount m_gsc;
int m_skip;
int m_skip_offset;
int m_userhacks_skipdraw;
int m_userhacks_skipdraw_offset;
bool m_userhacks_auto_flush;
GSVertex m_v;

View File

@ -442,6 +442,7 @@ void GSdxApp::Init()
m_default_configuration["UserHacks_unscale_point_line"] = "0";
m_default_configuration["UserHacks_round_sprite_offset"] = "0";
m_default_configuration["UserHacks_SkipDraw"] = "0";
m_default_configuration["UserHacks_SkipDraw_Offset"] = "0";
m_default_configuration["UserHacks_SpriteHack"] = "0";
m_default_configuration["UserHacks_TCOffset"] = "0";
m_default_configuration["UserHacks_TextureInsideRt"] = "0";

View File

@ -127,7 +127,7 @@ CAPTION "Advanced Settings & Hacks"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
// Hacks settings:
GROUPBOX "Hacks",IDC_STATIC,7,7,196,215,0,WS_EX_TRANSPARENT
GROUPBOX "Hacks",IDC_STATIC,7,7,196,217,0,WS_EX_TRANSPARENT
// Column one - HW Hacks
CONTROL "Align Sprite",IDC_ALIGN_SPRITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,19,58,8
CONTROL "Alpha",IDC_ALPHAHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,32,34,8
@ -154,24 +154,26 @@ BEGIN
COMBOBOX IDC_SPRITEHACK,80,141,116,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Round Sprite:",IDC_ROUND_SPRITE_TEXT,31,159,45,8
COMBOBOX IDC_ROUND_SPRITE,80,156,116,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Skipdraw:",IDC_STATIC,44,174,32,8
EDITTEXT IDC_SKIPDRAWHACKEDIT,80,171,116,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_SKIPDRAWHACK,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,105,169,11,14
RTEXT "TC Offset X:",IDC_STATIC,32,189,44,8
EDITTEXT IDC_TCOFFSETX2,80,186,116,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_TCOFFSETX,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,127,184,11,14
RTEXT "TC Offset Y:",IDC_STATIC,32,204,44,8
EDITTEXT IDC_TCOFFSETY2,80,201,116,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_TCOFFSETY,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,127,199,11,14
RTEXT "Skipdraw Range:",IDC_STATIC,14,174,62,8
EDITTEXT IDC_SKIPDRAWOFFSETEDIT,80,171,58,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
CONTROL "",IDC_SKIPDRAWOFFSET,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,0,0,11,14
EDITTEXT IDC_SKIPDRAWHACKEDIT,138,171,58,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
CONTROL "",IDC_SKIPDRAWHACK,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,0,0,11,14
RTEXT "TC Offset X:",IDC_STATIC,32,190,44,8
EDITTEXT IDC_TCOFFSETX2,80,187,116,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
CONTROL "",IDC_TCOFFSETX,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,127,185,11,14
RTEXT "TC Offset Y:",IDC_STATIC,32,206,44,8
EDITTEXT IDC_TCOFFSETY2,80,203,116,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
CONTROL "",IDC_TCOFFSETY,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,127,201,11,14
// OpenGL Advanced Settings:
GROUPBOX "OpenGL Advanced Settings",IDC_STATIC,7,225,196,48,0,WS_EX_TRANSPARENT
RTEXT "Geometry Shader:",IDC_GEOMETRY_SHADER_TEXT,14,240,62,8
COMBOBOX IDC_GEOMETRY_SHADER_OVERRIDE,80,237,97,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Image Load Store:",IDC_IMAGE_LOAD_STORE_TEXT,14,255,62,8
COMBOBOX IDC_IMAGE_LOAD_STORE,80,252,97,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "OpenGL Advanced Settings",IDC_STATIC,7,226,196,48,0,WS_EX_TRANSPARENT
RTEXT "Geometry Shader:",IDC_GEOMETRY_SHADER_TEXT,14,241,62,8
COMBOBOX IDC_GEOMETRY_SHADER_OVERRIDE,80,238,116,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Image Load Store:",IDC_IMAGE_LOAD_STORE_TEXT,14,256,62,8
COMBOBOX IDC_IMAGE_LOAD_STORE,80,253,116,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
// General Settings:
DEFPUSHBUTTON "OK",IDOK,52,278,50,14
DEFPUSHBUTTON "Cancel",IDCANCEL,108,278,50,14
DEFPUSHBUTTON "OK",IDOK,52,279,50,14
DEFPUSHBUTTON "Cancel",IDCANCEL,108,279,50,14
END
IDD_SHADER DIALOGEX 0, 0, 248, 230

View File

@ -80,8 +80,6 @@
#define IDC_ALPHAHACK 2101
#define IDC_OFFSETHACK 2102
#define IDC_OFFSETHACK_TEXT 2103
#define IDC_SKIPDRAWHACK 2104
#define IDC_SKIPDRAWHACKEDIT 2105
#define IDC_SPRITEHACK 2106
#define IDC_SPRITEHACK_TEXT 2107
#define IDC_MSAACB 2108
@ -104,6 +102,10 @@
#define IDC_UNSCALE_POINT_LINE 2125
#define IDC_MERGE_PP_SPRITE 2126
#define IDC_CPU_FB_CONVERSION 2127
#define IDC_SKIPDRAWHACK 2128
#define IDC_SKIPDRAWHACKEDIT 2129
#define IDC_SKIPDRAWOFFSET 2130
#define IDC_SKIPDRAWOFFSETEDIT 2131
// Shader:
#define IDC_SHADEBOOST 2140
#define IDC_FXAA 2141