gsdx ogl: replace ClearRenderTarget_i by glClearTexSubImage

Avoid state change, avoid potential texture buffer reallocation

Note: require GL_ARB_clear_texture
This commit is contained in:
Gregory Hainaut 2016-05-15 15:54:29 +02:00
parent 82060320ef
commit 5b061e062c
4 changed files with 13 additions and 5 deletions

View File

@ -565,6 +565,9 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c)
void GSDeviceOGL::ClearRenderTarget_i(GSTexture* t, int32 c)
{
// Hopefully AMD mesa will support this extension soon
ASSERT(!GLLoader::found_GL_ARB_clear_texture);
if (!t) return;
GSTextureOGL* T = static_cast<GSTextureOGL*>(t);
@ -715,7 +718,7 @@ GSDepthStencilOGL* GSDeviceOGL::CreateDepthStencil(OMDepthStencilSelector dssel)
return dss;
}
void GSDeviceOGL::InitPrimDateTexture(GSTexture* rt)
void GSDeviceOGL::InitPrimDateTexture(GSTexture* rt, const GSVector4i& area)
{
const GSVector2i& rtsize = rt->GetSize();
@ -724,7 +727,12 @@ void GSDeviceOGL::InitPrimDateTexture(GSTexture* rt)
m_date.t = CreateTexture(rtsize.x, rtsize.y, GL_R32I);
// Clean with the max signed value
ClearRenderTarget_i(m_date.t, 0x7FFFFFFF);
int max_int = 0x7FFFFFFF;
if (GLLoader::found_GL_ARB_clear_texture) {
static_cast<GSTextureOGL*>(m_date.t)->Clear(&max_int, area);
} else {
ClearRenderTarget_i(m_date.t, max_int);
}
glBindImageTexture(2, static_cast<GSTextureOGL*>(m_date.t)->GetID(), 0, false, 0, GL_READ_WRITE, GL_R32I);
#ifdef ENABLE_OGL_DEBUG

View File

@ -501,7 +501,7 @@ class GSDeviceOGL final : public GSDevice
GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0) final;
GSTexture* CreateTexture(int w, int h, int format = 0) final;
GSTexture* CreateOffscreen(int w, int h, int format = 0) final;
void InitPrimDateTexture(GSTexture* rt);
void InitPrimDateTexture(GSTexture* rt, const GSVector4i& area);
void RecycleDateTexture();
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) final;

View File

@ -858,7 +858,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
// Must be done here to avoid any GL state pertubation (clear function...)
// Create an r32ui image that will containt primitive ID
if (DATE_GL42) {
dev->InitPrimDateTexture(rt);
dev->InitPrimDateTexture(rt, dRect);
} else {
GSVector4 src = GSVector4(dRect) / GSVector4(rtsize.x, rtsize.y).xyxy();
GSVector4 dst = src * 2.0f - 1.0f;

View File

@ -293,7 +293,7 @@ void GSTextureOGL::Clear(const void* data)
void GSTextureOGL::Clear(const void* data, const GSVector4i& area)
{
glClearTexSubImage(m_texture_id, area.x, area.y, 0, area.width(), area.height(), 1, GL_TEX_LEVEL_0, m_int_format, m_int_type, data);
glClearTexSubImage(m_texture_id, GL_TEX_LEVEL_0, area.x, area.y, 0, area.width(), area.height(), 1, m_int_format, m_int_type, data);
}
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)