GSdx: New hack from KrossX lets users configure their own texture coordinate offset via hacks dialog. This can be used to fine tune correction of upscale glitches versus the problems that come with it. I guess this is able to correct nearly all ghosting and bad text issues games can have! Thanks for this nice patch, KrossX :)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5556 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
ramapcsx2 2013-02-12 10:57:48 +00:00
parent 45e3e6d549
commit 94cad4a61a
11 changed files with 104 additions and 50 deletions

View File

@ -96,6 +96,8 @@ public:
GSVector4 MinF_TA;
GSVector4i MskFix;
GSVector4 TC_OffsetHack;
struct PSConstantBuffer()
{
FogColor_AREF = GSVector4::zero();
@ -175,6 +177,7 @@ public:
uint32 colclip:2;
uint32 date:2;
uint32 spritehack:1;
uint32 tcoffsethack:1;
uint32 point_sampler:1;
};

View File

@ -31,8 +31,12 @@ GSRendererDX::GSRendererDX(GSTextureCache* tc, const GSVector2& pixelcenter)
m_fba = !!theApp.GetConfig("fba", 1);
UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0) && !!theApp.GetConfig("UserHacks", 0);
UserHacks_WildHack = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_WildHack", 0) : 0;
UserHacks_WildHack = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_WildHack", 0) : 0;
UserHacks_AlphaStencil = !!theApp.GetConfig("UserHacks_AlphaStencil", 0) && !!theApp.GetConfig("UserHacks", 0);
UserHacks_TCOffset = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_TCOffset", 0) : 0;
UserHacks_TCO_x = (UserHacks_TCOffset & 0xFFFF) / -1000.0f;
UserHacks_TCO_y = ((UserHacks_TCOffset >> 16) & 0xFFFF) / -1000.0f;
}
GSRendererDX::~GSRendererDX()
@ -287,10 +291,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc
ps_sel.wms = context->CLAMP.WMS;
ps_sel.wmt = context->CLAMP.WMT;
if (tex->m_palette)
ps_sel.fmt = cpsm.fmt | 4;
else
ps_sel.fmt = cpsm.fmt;
ps_sel.fmt = tex->m_palette? cpsm.fmt | 4 : cpsm.fmt;
ps_sel.aem = env.TEXA.AEM;
ps_sel.tfx = context->TEX0.TFX;
ps_sel.tcc = context->TEX0.TCC;
@ -319,6 +320,10 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc
ps_cb.HalfTexel = GSVector4(-0.5f, 0.5f).xxyy() / WH.zwzw();
ps_cb.MskFix = GSVector4i(context->CLAMP.MINU, context->CLAMP.MINV, context->CLAMP.MAXU, context->CLAMP.MAXV);
// TC Offset Hack
ps_sel.tcoffsethack = !!UserHacks_TCOffset;
ps_cb.TC_OffsetHack = GSVector4(UserHacks_TCO_x, UserHacks_TCO_y).xyxy() / WH.xyxy();
GSVector4 clamp(ps_cb.MskFix);
GSVector4 ta(env.TEXA & GSVector4i::x000000ff());

View File

@ -37,7 +37,9 @@ protected:
virtual void SetupIA() = 0;
virtual void UpdateFBA(GSTexture* rt) {}
int UserHacks_WildHack;
unsigned int UserHacks_WildHack;
unsigned int UserHacks_TCOffset;
float UserHacks_TCO_x, UserHacks_TCO_y;
public:
GSRendererDX(GSTextureCache* tc, const GSVector2& pixelcenter = GSVector2(0, 0));

View File

@ -45,17 +45,16 @@ void GSRendererDX11::SetupIA()
if(dev->IAMapVertexBuffer(&ptr, sizeof(GSVertex), m_vertex.next))
{
GSVector4i::storent(ptr, m_vertex.buff, sizeof(GSVertex) * m_vertex.next);
if(UserHacks_WildHack && !isPackedUV_HackFlag)
{
GSVertex* RESTRICT d = (GSVertex*)ptr;
for(unsigned int i = 0; i < m_vertex.next; i++, d++)
if(PRIM->TME && PRIM->FST)
d->UV &= UserHacks_WildHack == 1 ? 0x3FEF3FEF : 0x3FF73FF7;
}
GSVector4i::storent(ptr, m_vertex.buff, sizeof(GSVertex) * m_vertex.next);
if(UserHacks_WildHack && !isPackedUV_HackFlag)
{
GSVertex* RESTRICT d = (GSVertex*)ptr;
for(unsigned int i = 0; i < m_vertex.next; i++, d++)
if(PRIM->TME && PRIM->FST) d->UV &= 0x3FEF3FEF;
}
dev->IAUnmapVertexBuffer();
}

View File

@ -199,15 +199,13 @@ void GSRendererDX9::SetupIA()
{
if(PRIM->FST)
{
if(UserHacks_WildHack && !isPackedUV_HackFlag)
{
t = GSVector4(GSVector4i::load(UserHacks_WildHack == 1?
s->UV & 0x3FEF3FEF : s->UV & 0x3FF73FF7).upl16());
//printf("GSDX: %08X | D3D9(%d) %s\n", s->UV & 0x3FEF3FEF, m_vertex.next, i == 0 ? "*" : "");
}
else
t = GSVector4(GSVector4i::load(s->UV).upl16());
if(UserHacks_WildHack && !isPackedUV_HackFlag)
{
t = GSVector4(GSVector4i::load(s->UV & 0x3FEF3FEF).upl16());
//printf("GSDX: %08X | D3D9(%d) %s\n", s->UV & 0x3FEF3FEF, m_vertex.next, i == 0 ? "*" : "");
}
else
t = GSVector4(GSVector4i::load(s->UV).upl16());
}
else
{

View File

@ -522,6 +522,11 @@ void GSHacksDlg::OnInit()
SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_SETRANGE, 0, MAKELPARAM(1000, 0));
SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("UserHacks_SkipDraw", 0), 0));
SendMessage(GetDlgItem(m_hWnd, IDC_TCOFFSETX), UDM_SETRANGE, 0, MAKELPARAM(10000, 0));
SendMessage(GetDlgItem(m_hWnd, IDC_TCOFFSETX), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("UserHacks_TCOffset", 0) & 0xFFFF, 0));
SendMessage(GetDlgItem(m_hWnd, IDC_TCOFFSETY), UDM_SETRANGE, 0, MAKELPARAM(10000, 0));
SendMessage(GetDlgItem(m_hWnd, IDC_TCOFFSETY), UDM_SETPOS, 0, MAKELPARAM((theApp.GetConfig("UserHacks_TCOffset", 0) >> 16) & 0xFFFF, 0));
// Hacks descriptions
SetWindowText(GetDlgItem(m_hWnd, IDC_HACK_DESCRIPTION), "Hover over an item to get a description.");
@ -537,6 +542,7 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
case WM_SETCURSOR:
{
const char *helpstr = "";
bool updateText = true;
POINT pos;
GetCursorPos(&pos);
@ -597,12 +603,26 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
"CrcHacksExclusions=all\n"
"CrcHacksExclusions=0x0F0C4A9C, 0x0EE5646B, 0x7ACF7E03";
break;
case IDC_TCOFFSETX:
case IDC_TCOFFSETX2:
case IDC_STATIC_TCOFFSETX:
case IDC_TCOFFSETY:
case IDC_TCOFFSETY2:
case IDC_STATIC_TCOFFSETY:
helpstr = "Texture Coordinates Offset Hack\n\n"
"Offset for the ST/UV texture coordinates. Fixes some odd texture issues and might fix some post processing alignment too.\n\n"
" 0500 0500, fixes Persona 3 minimap, helps Haunting Ground.\n"
" 0000 1000, fixes Xenosaga hair edges (DX10+ Issue)\n";
break;
default:
helpstr = "Hover over an item to get a description.";
updateText = false;
break;
}
SetWindowText(GetDlgItem(m_hWnd, IDC_HACK_DESCRIPTION), helpstr);
if(updateText)
SetWindowText(GetDlgItem(m_hWnd, IDC_HACK_DESCRIPTION), helpstr);
} break;
@ -623,6 +643,12 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
theApp.SetConfig("UserHacks_AggressiveCRC", (int)IsDlgButtonChecked(m_hWnd, IDC_AGGRESSIVECRC));
theApp.SetConfig("UserHacks_AlphaStencil", (int)IsDlgButtonChecked(m_hWnd, IDC_ALPHASTENCIL));
theApp.SetConfig("UserHacks_DisableCrcHacks", (int)IsDlgButtonChecked(m_hWnd, IDC_CHECK_DISABLE_ALL_HACKS));
unsigned int TCOFFSET = SendMessage(GetDlgItem(m_hWnd, IDC_TCOFFSETX), UDM_GETPOS, 0, 0) & 0xFFFF;
TCOFFSET |= (SendMessage(GetDlgItem(m_hWnd, IDC_TCOFFSETY), UDM_GETPOS, 0, 0) & 0xFFFF) << 16;
theApp.SetConfig("UserHacks_TCOffset", TCOFFSET);
EndDialog(m_hWnd, id);
} break;
}

View File

@ -177,7 +177,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe
if(i == m_ps.end())
{
string str[17];
string str[18];
str[0] = format("%d", sel.fst);
str[1] = format("%d", sel.wms);
@ -195,7 +195,8 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe
str[13] = format("%d", sel.colclip);
str[14] = format("%d", sel.date);
str[15] = format("%d", sel.spritehack);
str[16] = format("%d", sel.point_sampler);
str[16] = format("%d", sel.tcoffsethack);
str[17] = format("%d", sel.point_sampler);
D3D11_SHADER_MACRO macro[] =
{
@ -215,7 +216,8 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe
{"PS_COLCLIP", str[13].c_str()},
{"PS_DATE", str[14].c_str()},
{"PS_SPRITEHACK", str[15].c_str()},
{"PS_POINT_SAMPLER", str[16].c_str()},
{"PS_TCOFFSETHACK", str[16].c_str()},
{"PS_POINT_SAMPLER", str[17].c_str()},
{NULL, NULL},
};

View File

@ -135,7 +135,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel
if(i == m_ps.end())
{
string str[16];
string str[17];
str[0] = format("%d", sel.fst);
str[1] = format("%d", sel.wms);
@ -152,7 +152,8 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel
str[12] = format("%d", sel.colclip);
str[13] = format("%d", sel.date);
str[14] = format("%d", sel.spritehack);
str[15] = format("%d", sel.point_sampler);
str[15] = format("%d", sel.tcoffsethack);
str[16] = format("%d", sel.point_sampler);
D3DXMACRO macro[] =
{
@ -171,7 +172,8 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel
{"PS_COLCLIP", str[12].c_str()},
{"PS_DATE", str[13].c_str()},
{"PS_SPRITEHACK", str[14].c_str()},
{"PS_POINT_SAMPLER", str[15].c_str()},
{"PS_TCOFFSETHACK", str[15].c_str()},
{"PS_POINT_SAMPLER", str[16].c_str()},
{NULL, NULL},
};

View File

@ -74,28 +74,34 @@ IDB_LOGO10 BITMAP "res\\logo10.bmp"
// Dialog
//
IDD_HACKS DIALOGEX 0, 0, 315, 203
IDD_HACKS DIALOGEX 0, 0, 315, 236
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Hacks Configuration"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,258,182,50,14
GROUPBOX "Hack",IDC_STATIC,7,7,76,165,0,WS_EX_TRANSPARENT
GROUPBOX "Description",IDC_STATIC,85,7,223,165
DEFPUSHBUTTON "OK",IDOK,258,215,50,14
GROUPBOX "Hack",IDC_STATIC,7,7,86,201,0,WS_EX_TRANSPARENT
GROUPBOX "Description",IDC_STATIC,96,7,212,201
LTEXT "MSAA",IDC_STATIC_MSAA,14,20,20,8
LTEXT "Skipdraw",IDC_STATIC_SKIPDRAW,14,37,30,8
EDITTEXT IDC_SKIPDRAWHACKEDIT,45,35,24,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_SKIPDRAWHACK,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,68,35,10,14
EDITTEXT IDC_SKIPDRAWHACKEDIT,53,35,35,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_SKIPDRAWHACK,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,88,35,10,14
CONTROL "Alpha",IDC_ALPHAHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,54,34,10
CONTROL "Half-pixel Offset",IDC_OFFSETHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,71,65,10
CONTROL "Sprite",IDC_SPRITEHACK,"Button",BS_AUTO3STATE | WS_TABSTOP,14,88,35,10
LTEXT "USE AT YOUR OWN RISK!",IDC_STATIC,7,182,84,8,WS_DISABLED
COMBOBOX IDC_MSAACB,35,18,44,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "USE AT YOUR OWN RISK!",IDC_STATIC,7,218,84,11,WS_DISABLED
COMBOBOX IDC_MSAACB,35,18,54,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "WildArmsOffset",IDC_WILDHACK,"Button",BS_AUTO3STATE | WS_TABSTOP,14,105,64,10
LTEXT "TEXT_GOES_HERE",IDC_HACK_DESCRIPTION,92,20,209,145
LTEXT "TEXT_GOES_HERE",IDC_HACK_DESCRIPTION,102,20,199,183
CONTROL "Aggressive-CRC",IDC_AGGRESSIVECRC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,122,66,10
CONTROL "Alpha Stencil",IDC_ALPHASTENCIL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,139,66,10
CONTROL "Disable CRCs",IDC_CHECK_DISABLE_ALL_HACKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,156,58,10
LTEXT "TC Offset X",IDC_STATIC_TCOFFSETX,14,173,37,8
EDITTEXT IDC_TCOFFSETX2,53,171,35,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_TCOFFSETX,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,87,171,11,14
EDITTEXT IDC_TCOFFSETY2,53,188,35,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_TCOFFSETY,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,86,188,11,14
LTEXT "TC Offset Y",IDC_STATIC_TCOFFSETY,14,190,37,8
END
IDD_SHADEBOOST DIALOGEX 0, 0, 316, 129
@ -262,7 +268,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 308
TOPMARGIN, 7
BOTTOMMARGIN, 196
BOTTOMMARGIN, 229
END
IDD_SHADEBOOST, DIALOG

View File

@ -37,6 +37,7 @@
#define PS_COLCLIP 0
#define PS_DATE 0
#define PS_SPRITEHACK 0
#define PS_TCOFFSETHACK 0
#define PS_POINT_SAMPLER 0
#endif
@ -101,6 +102,7 @@ cbuffer cb1
float2 MinF;
float2 TA;
uint4 MskFix;
float4 TC_OffsetHack;
};
float4 sample_c(float2 uv)
@ -202,6 +204,8 @@ float4 ps_params[7];
#define MinF ps_params[4].xy
#define TA ps_params[4].zw
#define TC_OffsetHack ps_params[5]
float4 sample_c(float2 uv)
{
return tex2D(Texture, uv);
@ -365,10 +369,11 @@ float4x4 sample_4p(float4 u)
float4 sample(float2 st, float q)
{
if(!PS_FST)
{
st /= q;
}
if(!PS_FST) st /= q;
#if PS_TCOFFSETHACK
st += TC_OffsetHack.xy;
#endif
float4 t;
float4x4 c;

View File

@ -80,7 +80,13 @@
#define IDC_AGGRESSIVECRC 2076
#define IDC_CHECK_DISABLE_ALL_HACKS 2077
#define IDC_ALPHASTENCIL 2078
#define IDC_ADAPTER 2078
#define IDC_ADAPTER 2079
#define IDC_STATIC_TCOFFSETX 2080
#define IDC_STATIC_TCOFFSETY 2081
#define IDC_TCOFFSETX 2082
#define IDC_TCOFFSETX2 2083
#define IDC_TCOFFSETY 2084
#define IDC_TCOFFSETY2 2085
#define IDC_COLORSPACE 3000
#define IDR_CONVERT_FX 10000
#define IDR_TFX_FX 10001
@ -99,7 +105,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 10012
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 2079
#define _APS_NEXT_CONTROL_VALUE 2086
#define _APS_NEXT_SYMED_VALUE 5000
#endif
#endif