mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl:
* port KrossX patch from r5556 to openGL * add a basic gui entry, would love an additional description * also add the pointsampler hack but don't activate it yet git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5570 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
4cada4d0ff
commit
d3d9b520f0
|
@ -301,6 +301,8 @@ class GSDeviceOGL : public GSDevice
|
|||
GSVector4 MinF_TA;
|
||||
GSVector4i MskFix;
|
||||
|
||||
GSVector4 TC_OffsetHack;
|
||||
|
||||
PSConstantBuffer()
|
||||
{
|
||||
FogColor_AREF = GSVector4::zero();
|
||||
|
@ -380,6 +382,7 @@ class GSDeviceOGL : public GSDevice
|
|||
uint32 colclip:2;
|
||||
uint32 date:2;
|
||||
uint32 spritehack:1;
|
||||
uint32 tcoffsethack:1;
|
||||
uint32 point_sampler:1;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,8 +29,6 @@ GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check, *native_res_
|
|||
GtkWidget *sb_contrast, *sb_brightness, *sb_saturation;
|
||||
GtkWidget *resx_spin, *resy_spin;
|
||||
|
||||
GtkWidget *hack_alpha_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check;
|
||||
|
||||
static void SysMessage(const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
@ -212,6 +210,21 @@ void toggle_widget_states( GtkWidget *widget, gpointer callback_data )
|
|||
}
|
||||
}
|
||||
|
||||
void set_hex_entry(GtkWidget *text_box, int hex_value) {
|
||||
gchar* data=(gchar *)g_malloc(sizeof(gchar)*40);
|
||||
sprintf(data,"%X", hex_value);
|
||||
gtk_entry_set_text(GTK_ENTRY(text_box),data);
|
||||
}
|
||||
|
||||
int get_hex_entry(GtkWidget *text_box) {
|
||||
int hex_value = 0;
|
||||
const gchar *data = gtk_entry_get_text(GTK_ENTRY(text_box));
|
||||
|
||||
sscanf(data,"%X",&hex_value);
|
||||
|
||||
return hex_value;
|
||||
}
|
||||
|
||||
bool RunLinuxDialog()
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
@ -222,6 +235,9 @@ bool RunLinuxDialog()
|
|||
GtkWidget *interlace_label, *threads_label, *native_label, *msaa_label, *rexy_label, *render_label, *filter_label;
|
||||
|
||||
GtkWidget *hack_table, *hack_skipdraw_label, *hack_box, *hack_frame;
|
||||
GtkWidget *hack_alpha_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check;
|
||||
GtkWidget *hack_tco_label, *hack_tco_entry;
|
||||
|
||||
int return_value;
|
||||
|
||||
GdkPixbuf* logo_pixmap;
|
||||
|
@ -324,15 +340,20 @@ bool RunLinuxDialog()
|
|||
gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5);
|
||||
|
||||
// Create our hack settings.
|
||||
hack_alpha_check = gtk_check_button_new_with_label("Alpha Hack");
|
||||
hack_offset_check = gtk_check_button_new_with_label("Offset Hack");
|
||||
hack_alpha_check = gtk_check_button_new_with_label("Alpha Hack");
|
||||
hack_offset_check = gtk_check_button_new_with_label("Offset Hack");
|
||||
hack_skipdraw_label = gtk_label_new("Skipdraw:");
|
||||
hack_skipdraw_spin = gtk_spin_button_new_with_range(0,1000,1);
|
||||
hack_enble_check = gtk_check_button_new_with_label("Enable User Hacks");
|
||||
hack_wild_check = gtk_check_button_new_with_label("Wild arm Hack");
|
||||
hack_sprite_check = gtk_check_button_new_with_label("Sprite Hack");
|
||||
hack_msaa_check = gtk_check_button_new_with_label("Msaa Hack");
|
||||
hack_skipdraw_spin = gtk_spin_button_new_with_range(0,1000,1);
|
||||
hack_enble_check = gtk_check_button_new_with_label("Enable User Hacks");
|
||||
hack_wild_check = gtk_check_button_new_with_label("Wild arm Hack");
|
||||
hack_sprite_check = gtk_check_button_new_with_label("Sprite Hack");
|
||||
hack_msaa_check = gtk_check_button_new_with_label("Msaa Hack");
|
||||
hack_tco_label = gtk_label_new("Texture offset: 0x");
|
||||
hack_tco_entry = gtk_entry_new();
|
||||
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(hack_skipdraw_spin), theApp.GetConfig("UserHacks_SkipDraw", 0));
|
||||
set_hex_entry(hack_tco_entry, theApp.GetConfig("UserHacks_TCOffset", 0));
|
||||
|
||||
// Tables are strange. The numbers are for their position: left, right, top, bottom.
|
||||
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_alpha_check, 0, 1, 0, 1);
|
||||
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_offset_check, 1, 2, 0, 1);
|
||||
|
@ -342,6 +363,8 @@ bool RunLinuxDialog()
|
|||
//gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_msaa_check, 2, 3, 1, 2);
|
||||
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_label, 0, 1, 2, 3);
|
||||
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_spin, 1, 2, 2, 3);
|
||||
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_label, 0, 1, 3, 4);
|
||||
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_entry, 1, 2, 3, 4);
|
||||
|
||||
// Create our checkboxes.
|
||||
shadeboost_check = gtk_check_button_new_with_label("Shade boost");
|
||||
|
@ -473,6 +496,7 @@ bool RunLinuxDialog()
|
|||
theApp.SetConfig("UserHacks_WildHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_wild_check)));
|
||||
theApp.SetConfig("UserHacks_SpriteHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_sprite_check)));
|
||||
theApp.SetConfig("UserHacks", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_enble_check)));
|
||||
theApp.SetConfig("UserHacks_TCOffset", get_hex_entry(hack_tco_entry));
|
||||
|
||||
// Let's just be windowed for the moment.
|
||||
theApp.SetConfig("windowed", 1);
|
||||
|
|
|
@ -32,6 +32,10 @@ GSRendererOGL::GSRendererOGL()
|
|||
UserHacks_WildHack = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_WildHack", 0) : 0;
|
||||
UserHacks_AlphaStencil = !!theApp.GetConfig("UserHacks_AlphaStencil", 0) && !!theApp.GetConfig("UserHacks", 0);
|
||||
m_pixelcenter = GSVector2(-0.5f, -0.5f);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool GSRendererOGL::CreateDevice(GSDevice* dev)
|
||||
|
@ -60,7 +64,7 @@ void GSRendererOGL::SetupIA()
|
|||
|
||||
for(unsigned int i = 0; i < m_vertex.next; i++, d++)
|
||||
if(PRIM->TME && PRIM->FST)
|
||||
d->UV &= UserHacks_WildHack == 1 ? 0x3FEF3FEF : 0x3FF73FF7;
|
||||
d->UV &= 0x3FEF3FEF;
|
||||
}
|
||||
|
||||
dev->IAUnmapVertexBuffer();
|
||||
|
@ -353,10 +357,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
|||
|
||||
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;
|
||||
|
@ -385,6 +386,10 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
|||
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());
|
||||
|
||||
|
|
|
@ -39,7 +39,9 @@ class GSRendererOGL : public GSRendererHW
|
|||
bool m_fba;
|
||||
bool UserHacks_AlphaHack;
|
||||
bool UserHacks_AlphaStencil;
|
||||
int UserHacks_WildHack;
|
||||
unsigned int UserHacks_WildHack;
|
||||
unsigned int UserHacks_TCOffset;
|
||||
float UserHacks_TCO_x, UserHacks_TCO_y;
|
||||
|
||||
protected:
|
||||
void SetupIA();
|
||||
|
|
|
@ -153,7 +153,9 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS
|
|||
+ format("#define PS_LTF %d\n", sel.ltf)
|
||||
+ format("#define PS_COLCLIP %d\n", sel.colclip)
|
||||
+ format("#define PS_DATE %d\n", sel.date)
|
||||
+ format("#define PS_SPRITEHACK %d\n", sel.spritehack);
|
||||
+ format("#define PS_SPRITEHACK %d\n", sel.spritehack)
|
||||
+ format("#define PS_TCOFFSETHACK %d\n", sel.tcoffsethack)
|
||||
+ format("#define PS_POINT_SAMPLER %d\n", sel.point_sampler);
|
||||
|
||||
CompileShaderFromSource("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, &ps, macro);
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
#define FMT_16 2
|
||||
#define FMT_PAL 4 /* flag bit */
|
||||
|
||||
// Not sure we have same issue on opengl. Doesn't work anyway on ATI card
|
||||
// And I say this as an ATI user.
|
||||
#define ATI_SUCKS 0
|
||||
|
||||
#ifndef VS_BPPZ
|
||||
#define VS_BPPZ 0
|
||||
#define VS_TME 1
|
||||
|
@ -36,6 +40,8 @@
|
|||
#define PS_COLCLIP 0
|
||||
#define PS_DATE 0
|
||||
#define PS_SPRITEHACK 0
|
||||
#define PS_POINT_SAMPLER 0
|
||||
#define PS_TCOFFSETHACK 0
|
||||
#endif
|
||||
|
||||
struct vertex
|
||||
|
@ -282,10 +288,22 @@ layout(std140, binding = 5) uniform cb1
|
|||
vec2 MinF;
|
||||
vec2 TA;
|
||||
uvec4 MskFix;
|
||||
vec4 TC_OffsetHack;
|
||||
};
|
||||
|
||||
vec4 sample_c(vec2 uv)
|
||||
{
|
||||
// FIXME: check the issue on openGL
|
||||
if (ATI_SUCKS == 1 && PS_POINT_SAMPLER == 1)
|
||||
{
|
||||
// Weird issue with ATI cards (happens on at least HD 4xxx and 5xxx),
|
||||
// it looks like they add 127/128 of a texel to sampling coordinates
|
||||
// occasionally causing point sampling to erroneously round up.
|
||||
// I'm manually adjusting coordinates to the centre of texels here,
|
||||
// though the centre is just paranoia, the top left corner works fine.
|
||||
uv = (trunc(uv * WH.zw) + vec2(0.5, 0.5)) / WH.zw;
|
||||
}
|
||||
|
||||
// FIXME I'm not sure it is a good solution to flip texture
|
||||
return texture(TextureSampler, uv);
|
||||
//FIXME another way to FLIP vertically
|
||||
|
@ -403,10 +421,9 @@ mat4 sample_4p(vec4 u)
|
|||
|
||||
vec4 sample_color(vec2 st, float q)
|
||||
{
|
||||
if(PS_FST == 0)
|
||||
{
|
||||
st /= q;
|
||||
}
|
||||
if(PS_FST == 0) st /= q;
|
||||
|
||||
if(PS_TCOFFSETHACK == 1) st += TC_OffsetHack.xy;
|
||||
|
||||
vec4 t;
|
||||
mat4 c;
|
||||
|
|
Loading…
Reference in New Issue