gsdx-ogl: * implement shadeboost (only test the compilation)

Note: gui must be updated with new user hack


git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5181 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2012-04-26 21:42:16 +00:00
parent 300ea42977
commit 6fd47b2907
7 changed files with 74 additions and 12 deletions

View File

@ -200,17 +200,15 @@ endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "")
if(PACKAGE_MODE)
install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${PLUGIN_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${PLUGIN_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${PLUGIN_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${PLUGIN_DIR})
foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/${glsl} DESTINATION ${PLUGIN_DIR})
endforeach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl)
else(PACKAGE_MODE)
install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/${glsl} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
endforeach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl)
endif(PACKAGE_MODE)
################################### Replay Loader

View File

@ -46,7 +46,7 @@ GSDeviceOGL::GSDeviceOGL()
, m_srv_changed(false)
, m_ss_changed(false)
{
m_msaa = theApp.GetConfig("msaa", 0);
m_msaa = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_MSAA", 0) : 0;
memset(&m_merge_obj, 0, sizeof(m_merge_obj));
memset(&m_interlace, 0, sizeof(m_interlace));
@ -299,6 +299,19 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
for(int i = 0; i < countof(m_interlace.ps); i++)
CompileShaderFromSource("interlace.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_interlace.ps[i]);
// ****************************************************************
// Shade boost
// ****************************************************************
m_shadeboost.cb = new GSUniformBufferOGL(6, sizeof(ShadeBoostConstantBuffer));
int ShadeBoost_Contrast = theApp.GetConfig("ShadeBoost_Contrast", 50);
int ShadeBoost_Brightness = theApp.GetConfig("ShadeBoost_Brightness", 50);
int ShadeBoost_Saturation = theApp.GetConfig("ShadeBoost_Saturation", 50);
std::string macro = format("#define SB_SATURATION %d\n", ShadeBoost_Saturation)
+ format("#define SB_BRIGHTNESS %d\n", ShadeBoost_Brightness)
+ format("#define SB_CONTRAST %d\n", ShadeBoost_Contrast);
CompileShaderFromSource("shadeboost.glsl", "ps_main", GL_FRAGMENT_SHADER, &m_shadeboost.ps, macro);
// ****************************************************************
// rasterization configuration
@ -912,6 +925,24 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin
StretchRect(st, sr, dt, dr, m_interlace.ps[shader], linear);
}
void GSDeviceOGL::DoShadeBoost(GSTexture* st, GSTexture* dt)
{
GSVector2i s = dt->GetSize();
GSVector4 sr(0, 0, 1, 1);
GSVector4 dr(0, 0, s.x, s.y);
ShadeBoostConstantBuffer cb;
cb.rcpFrame = GSVector4(1.0f / s.x, 1.0f / s.y, 0.0f, 0.0f);
cb.rcpFrameOpt = GSVector4::zero();
SetUniformBuffer(m_shadeboost.cb);
m_shadeboost.cb->upload(&cb);
StretchRect(st, sr, dt, dr, m_shadeboost.ps, m_shadeboost.cb);
}
void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm)
{
const GSVector2i& size = rt->GetSize();

View File

@ -552,6 +552,7 @@ class GSDeviceOGL : public GSDevice
uint32 fst:1;
uint32 logz:1;
uint32 rtcopy:1;
uint32 wildhack:2;
};
uint32 key;
@ -649,6 +650,7 @@ class GSDeviceOGL : public GSDevice
uint32 ltf:1;
uint32 colclip:2;
uint32 date:2;
uint32 spritehack:1;
};
uint32 key;
@ -783,6 +785,14 @@ class GSDeviceOGL : public GSDevice
GSBlendStateOGL* bs;
} m_date;
struct
{
GLuint ps;
GSUniformBufferOGL *cb;
} m_shadeboost;
struct {
GSVertexBufferStateOGL* vb;
GLuint vs; // program
@ -832,6 +842,7 @@ class GSDeviceOGL : public GSDevice
GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format);
void DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c);
void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0);
void DoShadeBoost(GSTexture* st, GSTexture* dt);
public:
GSDeviceOGL();

View File

@ -28,7 +28,8 @@ GSRendererOGL::GSRendererOGL()
{
m_logz = !!theApp.GetConfig("logz", 0);
m_fba = !!theApp.GetConfig("fba", 1);
UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0);
UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0) && !!theApp.GetConfig("UserHacks", 0);
UserHacks_WildHack = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_WildHack", 0) : 0;
m_pixelcenter = GSVector2(-0.5f, -0.5f);
}
@ -51,6 +52,15 @@ void GSRendererOGL::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;
}
dev->IAUnmapVertexBuffer();
}

View File

@ -38,6 +38,7 @@ class GSRendererOGL : public GSRendererHW
bool m_logz;
bool m_fba;
bool UserHacks_AlphaHack;
int UserHacks_WildHack;
protected:
void SetupIA();

View File

@ -163,7 +163,8 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS
+ format("#define PS_AOUT %d\n", sel.aout)
+ 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_DATE %d\n", sel.date)
+ format("#define PS_SPRITEHACK %d\n", sel.spritehack);
CompileShaderFromSource("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, &ps, macro);

View File

@ -37,6 +37,7 @@
#define PS_LTF 1
#define PS_COLCLIP 0
#define PS_DATE 0
#define PS_SPRITEHACK 0
#endif
struct vertex
@ -554,7 +555,16 @@ void atst(vec4 c)
{
// nothing to do
}
else if(PS_ATST == 2 || PS_ATST == 3) // l, le
else if(PS_ATST == 2)
{
}
else if(PS_ATST == 2 ) // l
{
if (PS_SPRITEHACK == 0)
if ((AREF - a) < 0.0f)
discard;
}
else if(PS_ATST == 2 ) // le
{
if ((AREF - a) < 0.0f)
discard;