mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl: drop hack that rescale primitive (to avoid upscale glitch)
Rendering is bad. It renders sprites at native resolution.
This commit is contained in:
parent
6d65867b26
commit
530e4ce776
|
@ -121,7 +121,6 @@ GSDeviceOGL::~GSDeviceOGL()
|
|||
|
||||
// Delete HW FX
|
||||
delete m_vs_cb;
|
||||
delete m_gs_cb;
|
||||
delete m_ps_cb;
|
||||
gl_DeleteSamplers(1, &m_palette_ss);
|
||||
m_shader->Delete(m_apitrace);
|
||||
|
@ -567,12 +566,7 @@ GLuint GSDeviceOGL::CompileVS(VSSelector sel, int logz)
|
|||
/* Note: must be here because tfx_glsl is static */
|
||||
GLuint GSDeviceOGL::CompileGS()
|
||||
{
|
||||
// Don't use a dynamic selector to only compile a single GS.
|
||||
// If configuration is updated, shader will be recompiled
|
||||
int unscale_sprite = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_UnscaleSprite", 0) : 0;
|
||||
std::string macro = format("#define GS_SPRITE %d\n", unscale_sprite);
|
||||
|
||||
return m_shader->Compile("tfx_vgs.glsl", "gs_main", GL_GEOMETRY_SHADER, tfx_vgs_glsl, macro);
|
||||
return m_shader->Compile("tfx_vgs.glsl", "gs_main", GL_GEOMETRY_SHADER, tfx_vgs_glsl, "");
|
||||
}
|
||||
|
||||
/* Note: must be here because tfx_glsl is static */
|
||||
|
@ -597,7 +591,6 @@ GLuint GSDeviceOGL::CompilePS(PSSelector sel)
|
|||
+ format("#define PS_TCOFFSETHACK %d\n", sel.tcoffsethack)
|
||||
//+ format("#define PS_POINT_SAMPLER %d\n", sel.point_sampler)
|
||||
+ format("#define PS_IIP %d\n", sel.iip)
|
||||
+ format("#define PS_SPRITE %d\n", sel.sprite)
|
||||
;
|
||||
|
||||
return m_shader->Compile("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, tfx_fs_all_glsl, macro);
|
||||
|
|
|
@ -287,31 +287,6 @@ class GSDeviceOGL : public GSDevice
|
|||
}
|
||||
};
|
||||
|
||||
__aligned(struct, 32) GSConstantBuffer
|
||||
{
|
||||
GSVector4 rt_size;
|
||||
|
||||
GSConstantBuffer()
|
||||
{
|
||||
rt_size = GSVector4::zero();
|
||||
}
|
||||
|
||||
__forceinline bool Update(const GSConstantBuffer* cb)
|
||||
{
|
||||
GSVector4i* a = (GSVector4i*)this;
|
||||
GSVector4i* b = (GSVector4i*)cb;
|
||||
|
||||
if(!(a[0] == b[0]).alltrue())
|
||||
{
|
||||
a[0] = b[0];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct PSSelector
|
||||
{
|
||||
union
|
||||
|
@ -330,7 +305,6 @@ class GSDeviceOGL : public GSDevice
|
|||
uint32 tcoffsethack:1;
|
||||
//uint32 point_sampler:1; Not tested, so keep the bit for blend
|
||||
uint32 iip:1;
|
||||
uint32 sprite:1;
|
||||
// Next param will be handle by subroutine
|
||||
uint32 colclip:2;
|
||||
uint32 atst:3;
|
||||
|
@ -528,11 +502,9 @@ class GSDeviceOGL : public GSDevice
|
|||
GLuint m_rt_ss;
|
||||
|
||||
GSUniformBufferOGL* m_vs_cb;
|
||||
GSUniformBufferOGL* m_gs_cb;
|
||||
GSUniformBufferOGL* m_ps_cb;
|
||||
|
||||
VSConstantBuffer m_vs_cb_cache;
|
||||
GSConstantBuffer m_gs_cb_cache;
|
||||
PSConstantBuffer m_ps_cb_cache;
|
||||
|
||||
GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format);
|
||||
|
@ -627,7 +599,7 @@ class GSDeviceOGL : public GSDevice
|
|||
void SetupVS(VSSelector sel);
|
||||
void SetupGS(bool enable);
|
||||
void SetupPS(PSSelector sel);
|
||||
void SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb, const GSConstantBuffer* gs_cb);
|
||||
void SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb);
|
||||
void SetupSampler(PSSamplerSelector ssel);
|
||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||
GLuint GetSamplerID(PSSamplerSelector ssel);
|
||||
|
|
|
@ -195,8 +195,6 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
|||
GSDeviceOGL::VSSelector vs_sel;
|
||||
GSDeviceOGL::VSConstantBuffer vs_cb;
|
||||
|
||||
GSDeviceOGL::GSConstantBuffer gs_cb;
|
||||
|
||||
GSDeviceOGL::PSSelector ps_sel;
|
||||
GSDeviceOGL::PSConstantBuffer ps_cb;
|
||||
GSDeviceOGL::PSSamplerSelector ps_ssel;
|
||||
|
@ -307,16 +305,6 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
|||
om_dssel.fba = context->FBA.FBA;
|
||||
}
|
||||
|
||||
bool hack_enabled = (UserHacks_Unscale_sprite > 1) || ((UserHacks_Unscale_sprite == 1) && !m_vt.IsLinear());
|
||||
if (hack_enabled && (m_vt.m_primclass == GS_SPRITE_CLASS) && GLLoader::found_geometry_shader) {
|
||||
bool blit = tex && (tex->m_texture->GetWidth() == rtsize.x) && (tex->m_texture->GetHeight() == rtsize.y);
|
||||
if (!blit) {
|
||||
ps_sel.sprite = 1;
|
||||
gs_cb.rt_size = GSVector4(rtsize.x / rtscale.x, rtsize.y / rtscale.y) / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// vs
|
||||
|
||||
vs_sel.tme = PRIM->TME;
|
||||
|
@ -530,7 +518,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
|||
|
||||
dev->OMSetColorMaskState(om_csel);
|
||||
dev->SetupOM(om_dssel, om_bsel, afix);
|
||||
dev->SetupCB(&vs_cb, &ps_cb, ps_sel.sprite ? &gs_cb : NULL);
|
||||
dev->SetupCB(&vs_cb, &ps_cb);
|
||||
|
||||
if (DATE_GL42) {
|
||||
// It could be good idea to use stencil in the same time.
|
||||
|
|
|
@ -30,7 +30,6 @@ static const uint32 g_gs_cb_index = 22;
|
|||
void GSDeviceOGL::CreateTextureFX()
|
||||
{
|
||||
m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer));
|
||||
m_gs_cb = new GSUniformBufferOGL(g_gs_cb_index, sizeof(GSConstantBuffer));
|
||||
m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer));
|
||||
|
||||
// warning 1 sampler by image unit. So you cannot reuse m_ps_ss...
|
||||
|
@ -129,7 +128,7 @@ GSBlendStateOGL* GSDeviceOGL::CreateBlend(OMBlendSelector bsel, uint8 afix)
|
|||
return bs;
|
||||
}
|
||||
|
||||
void GSDeviceOGL::SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb, const GSConstantBuffer* gs_cb)
|
||||
void GSDeviceOGL::SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb)
|
||||
{
|
||||
if(m_vs_cb_cache.Update(vs_cb)) {
|
||||
m_vs_cb->upload(vs_cb);
|
||||
|
@ -138,11 +137,6 @@ void GSDeviceOGL::SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer*
|
|||
if(m_ps_cb_cache.Update(ps_cb)) {
|
||||
m_ps_cb->upload(ps_cb);
|
||||
}
|
||||
|
||||
if (gs_cb && m_gs_cb_cache.Update(gs_cb)) {
|
||||
m_gs_cb->upload(gs_cb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GSDeviceOGL::SetupVS(VSSelector sel)
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#define PS_POINT_SAMPLER 0
|
||||
#define PS_TCOFFSETHACK 0
|
||||
#define PS_IIP 1
|
||||
#define PS_SPRITE 0
|
||||
#endif
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
|
@ -48,11 +47,6 @@ in SHADER
|
|||
vec4 t;
|
||||
vec4 c;
|
||||
flat vec4 fc;
|
||||
#if PS_SPRITE == 1
|
||||
flat vec4 flat_T;
|
||||
flat vec2 flat_P;
|
||||
vec2 alpha;
|
||||
#endif
|
||||
} PSin;
|
||||
|
||||
#define PSin_t (PSin.t)
|
||||
|
@ -375,21 +369,7 @@ void fog(inout vec4 c, float f)
|
|||
|
||||
vec4 ps_color()
|
||||
{
|
||||
#if PS_SPRITE == 1
|
||||
// Reinterpolate manually the texture coordinate.
|
||||
// trunc => native resolution. Maybe we can add an option to choose a value between
|
||||
// trunc and current.
|
||||
vec2 factor = vec2(trunc(PSin.alpha.x), floor(PSin.alpha.y));
|
||||
//vec2 factor = trunc(PSin.alpha);
|
||||
factor *= PSin.flat_P;
|
||||
vec2 txy;
|
||||
txy.x = mix(PSin.flat_T.x, PSin.flat_T.y, factor.x);
|
||||
txy.y = mix(PSin.flat_T.z, PSin.flat_T.w, factor.y);
|
||||
|
||||
#else
|
||||
vec2 txy = PSin_t.xy;
|
||||
#endif
|
||||
vec4 t = sample_color(txy, PSin_t.w);
|
||||
vec4 t = sample_color(PSin_t.xy, PSin_t.w);
|
||||
|
||||
vec4 zero = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
vec4 one = vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
|
|
@ -152,10 +152,6 @@ void vs_main()
|
|||
|
||||
#ifdef GEOMETRY_SHADER
|
||||
|
||||
#ifndef GS_SPRITE
|
||||
#define GS_SPRITE 0
|
||||
#endif
|
||||
|
||||
in gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
float gl_PointSize;
|
||||
|
@ -186,11 +182,6 @@ out SHADER
|
|||
vec4 t;
|
||||
vec4 c;
|
||||
flat vec4 fc;
|
||||
#if GS_SPRITE > 0
|
||||
flat vec4 flat_T;
|
||||
flat vec2 flat_P;
|
||||
vec2 alpha;
|
||||
#endif
|
||||
} GSout;
|
||||
|
||||
layout(std140, binding = 22) uniform cb22
|
||||
|
@ -210,9 +201,6 @@ void out_vertex(in vertex v)
|
|||
{
|
||||
GSout.t = v.t;
|
||||
GSout.c = v.c;
|
||||
#if GS_SPRITE > 0
|
||||
GSout.alpha = v.a;
|
||||
#endif
|
||||
gl_PrimitiveID = gl_PrimitiveIDIn;
|
||||
EmitVertex();
|
||||
}
|
||||
|
@ -221,10 +209,6 @@ void out_flat(in vec2 dp)
|
|||
{
|
||||
// Flat output
|
||||
GSout.fc = GSin[1].fc;
|
||||
#if GS_SPRITE > 0
|
||||
GSout.flat_T = vec4(GSin[0].t.x, GSin[1].t.x, GSin[0].t.y, GSin[1].t.y);
|
||||
GSout.flat_P = 1.0f / dp;
|
||||
#endif
|
||||
}
|
||||
|
||||
layout(lines) in;
|
||||
|
@ -233,11 +217,7 @@ layout(triangle_strip, max_vertices = 6) out;
|
|||
void gs_main()
|
||||
{
|
||||
// Rescale from -1 1 to 0:1 (require window size)
|
||||
#if GS_SPRITE > 0
|
||||
vec2 dp = (gl_in[1].gl_Position.xy - gl_in[0].gl_Position.xy) * rt_size.xy;
|
||||
#else
|
||||
vec2 dp = vec2(0.0f, 0.0f);
|
||||
#endif
|
||||
|
||||
// left top => GSin[0];
|
||||
// right bottom => GSin[1];
|
||||
|
|
|
@ -595,10 +595,6 @@ static const char* tfx_vgs_glsl =
|
|||
"\n"
|
||||
"#ifdef GEOMETRY_SHADER\n"
|
||||
"\n"
|
||||
"#ifndef GS_SPRITE\n"
|
||||
"#define GS_SPRITE 0\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"in gl_PerVertex {\n"
|
||||
" vec4 gl_Position;\n"
|
||||
" float gl_PointSize;\n"
|
||||
|
@ -629,11 +625,6 @@ static const char* tfx_vgs_glsl =
|
|||
" vec4 t;\n"
|
||||
" vec4 c;\n"
|
||||
" flat vec4 fc;\n"
|
||||
"#if GS_SPRITE > 0\n"
|
||||
" flat vec4 flat_T;\n"
|
||||
" flat vec2 flat_P;\n"
|
||||
" vec2 alpha;\n"
|
||||
"#endif\n"
|
||||
"} GSout;\n"
|
||||
"\n"
|
||||
"layout(std140, binding = 22) uniform cb22\n"
|
||||
|
@ -653,9 +644,6 @@ static const char* tfx_vgs_glsl =
|
|||
"{\n"
|
||||
" GSout.t = v.t;\n"
|
||||
" GSout.c = v.c;\n"
|
||||
"#if GS_SPRITE > 0\n"
|
||||
" GSout.alpha = v.a;\n"
|
||||
"#endif\n"
|
||||
" gl_PrimitiveID = gl_PrimitiveIDIn;\n"
|
||||
" EmitVertex();\n"
|
||||
"}\n"
|
||||
|
@ -664,10 +652,6 @@ static const char* tfx_vgs_glsl =
|
|||
"{\n"
|
||||
" // Flat output\n"
|
||||
" GSout.fc = GSin[1].fc;\n"
|
||||
"#if GS_SPRITE > 0\n"
|
||||
" GSout.flat_T = vec4(GSin[0].t.x, GSin[1].t.x, GSin[0].t.y, GSin[1].t.y);\n"
|
||||
" GSout.flat_P = 1.0f / dp;\n"
|
||||
"#endif\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"layout(lines) in;\n"
|
||||
|
@ -676,11 +660,7 @@ static const char* tfx_vgs_glsl =
|
|||
"void gs_main()\n"
|
||||
"{\n"
|
||||
" // Rescale from -1 1 to 0:1 (require window size)\n"
|
||||
"#if GS_SPRITE > 0\n"
|
||||
" vec2 dp = (gl_in[1].gl_Position.xy - gl_in[0].gl_Position.xy) * rt_size.xy;\n"
|
||||
"#else\n"
|
||||
" vec2 dp = vec2(0.0f, 0.0f);\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
" // left top => GSin[0];\n"
|
||||
" // right bottom => GSin[1];\n"
|
||||
|
@ -779,7 +759,6 @@ static const char* tfx_fs_all_glsl =
|
|||
"#define PS_POINT_SAMPLER 0\n"
|
||||
"#define PS_TCOFFSETHACK 0\n"
|
||||
"#define PS_IIP 1\n"
|
||||
"#define PS_SPRITE 0\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
|
@ -789,11 +768,6 @@ static const char* tfx_fs_all_glsl =
|
|||
" vec4 t;\n"
|
||||
" vec4 c;\n"
|
||||
" flat vec4 fc;\n"
|
||||
"#if PS_SPRITE == 1\n"
|
||||
" flat vec4 flat_T;\n"
|
||||
" flat vec2 flat_P;\n"
|
||||
" vec2 alpha;\n"
|
||||
"#endif\n"
|
||||
"} PSin;\n"
|
||||
"\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
|
@ -1116,21 +1090,7 @@ static const char* tfx_fs_all_glsl =
|
|||
"\n"
|
||||
"vec4 ps_color()\n"
|
||||
"{\n"
|
||||
"#if PS_SPRITE == 1\n"
|
||||
" // Reinterpolate manually the texture coordinate.\n"
|
||||
" // trunc => native resolution. Maybe we can add an option to choose a value between\n"
|
||||
" // trunc and current.\n"
|
||||
" vec2 factor = vec2(trunc(PSin.alpha.x), floor(PSin.alpha.y));\n"
|
||||
" //vec2 factor = trunc(PSin.alpha);\n"
|
||||
" factor *= PSin.flat_P;\n"
|
||||
" vec2 txy;\n"
|
||||
" txy.x = mix(PSin.flat_T.x, PSin.flat_T.y, factor.x);\n"
|
||||
" txy.y = mix(PSin.flat_T.z, PSin.flat_T.w, factor.y);\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
" vec2 txy = PSin_t.xy;\n"
|
||||
"#endif\n"
|
||||
" vec4 t = sample_color(txy, PSin_t.w);\n"
|
||||
" vec4 t = sample_color(PSin_t.xy, PSin_t.w);\n"
|
||||
"\n"
|
||||
" vec4 zero = vec4(0.0f, 0.0f, 0.0f, 0.0f);\n"
|
||||
" vec4 one = vec4(1.0f, 1.0f, 1.0f, 1.0f);\n"
|
||||
|
|
Loading…
Reference in New Issue