Skip to content

Commit

Permalink
gsdx-ogl: avoid to clean fully texture in DATE
Browse files Browse the repository at this point in the history
Is is useless and it has a small impact on performance for big upscale
  • Loading branch information
gregory38 committed Apr 24, 2015
1 parent 03e7278 commit 6e386df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 4 additions & 6 deletions plugins/GSdx/GSDeviceOGL.cpp
Expand Up @@ -487,20 +487,20 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c)

void GSDeviceOGL::ClearRenderTarget_ui(GSTexture* t, uint32 c)
{
// Keep SCISSOR_TEST enabled on purpose to reduce the size
// of clean in DATE (impact big upscaling)
uint32 col[4] = {c, c, c, c};

glDisable(GL_SCISSOR_TEST);

OMSetFBO(m_fbo);
OMAttachRt(static_cast<GSTextureOGL*>(t)->GetID());

gl_ClearBufferuiv(GL_COLOR, 0, col);

glEnable(GL_SCISSOR_TEST);
}

void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
{
// Keep SCISSOR_TEST enabled on purpose to reduce the size
// of clean in DATE (impact big upscaling)
OMSetFBO(m_fbo);
OMAttachDs(static_cast<GSTextureOGL*>(t)->GetID());

Expand All @@ -521,9 +521,7 @@ void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c)
OMAttachDs(static_cast<GSTextureOGL*>(t)->GetID());
GLint color = c;

glDisable(GL_SCISSOR_TEST);
gl_ClearBufferiv(GL_STENCIL, 0, &color);
glEnable(GL_SCISSOR_TEST);
}

GLuint GSDeviceOGL::CreateSampler(PSSamplerSelector sel)
Expand Down
16 changes: 14 additions & 2 deletions plugins/GSdx/GSRendererOGL.cpp
Expand Up @@ -216,13 +216,21 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour

if(DATE)
{
// TODO: do I need to clamp the value (if yes how? rintersect with rt?)
GSVector4 si = GSVector4(rtscale.x, rtscale.y);
GSVector4 o = GSVector4(-1.0f, 1.0f); // Round value
GSVector4 b = m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy();
GSVector4i ri = GSVector4i(b * si.xyxy());

// Reduce the quantity of clean function
glScissor( ri.x, ri.y, ri.width(), ri.height() );

// Note at the moment OGL has always stencil. Rt can be disabled
if(dev->HasStencil() && !advance_DATE)
{
GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y);
GSVector4 o = GSVector4(-1.0f, 1.0f);

GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy());
GSVector4 src = (b * s.xyxy()).sat(o.zzyy());
GSVector4 dst = src * 2.0f + o.xxxx();

GSVertexPT1 vertices[] =
Expand All @@ -240,6 +248,10 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
// Create an r32ui image that will containt primitive ID
if (advance_DATE)
dev->InitPrimDateTexture(rtsize.x, rtsize.y);

// Restore the scissor state
ri = GLState::scissor;
glScissor( ri.x, ri.y, ri.width(), ri.height() );
}

//
Expand Down

0 comments on commit 6e386df

Please sign in to comment.