gsdx-ogl: drop support of GL_ARB_clear_texture extension

Extension is a bit slower.

We use it to clear the RT but we generally use it right away so
we don't avoid the FB attachment.
This commit is contained in:
Gregory Hainaut 2015-04-24 18:15:58 +02:00
parent 89d5e5637c
commit 03e72781aa
6 changed files with 33 additions and 83 deletions

View File

@ -105,7 +105,6 @@ PFNGLBINDIMAGETEXTUREPROC gl_BindImageTexture = NU
PFNGLMEMORYBARRIERPROC gl_MemoryBarrier = NULL;
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
// GL4.4
PFNGLCLEARTEXIMAGEPROC gl_ClearTexImage = NULL;
PFNGLBUFFERSTORAGEPROC gl_BufferStorage = NULL;
// GL_ARB_bindless_texture (GL5?)
PFNGLGETTEXTURESAMPLERHANDLEARBPROC gl_GetTextureSamplerHandleARB = NULL;
@ -157,7 +156,6 @@ namespace GLLoader {
// Optional
bool found_GL_ARB_separate_shader_objects = false; // Issue with Mesa and Catalyst...
bool found_geometry_shader = true; // we require GL3.3 so geometry must be supported by default
bool found_GL_ARB_clear_texture = false; // Don't know if GL3 GPU can support it
// Note: except Apple, all drivers support explicit uniform location
bool found_GL_ARB_explicit_uniform_location = false; // need by subroutine and bindless texture
// GL4 hardware
@ -297,7 +295,6 @@ namespace GLLoader {
if (ext.compare("GL_ARB_explicit_uniform_location") == 0) found_GL_ARB_explicit_uniform_location = true;
// GL4.4
if (ext.compare("GL_ARB_buffer_storage") == 0) found_GL_ARB_buffer_storage = true;
if (ext.compare("GL_ARB_clear_texture") == 0) found_GL_ARB_clear_texture = true;
// FIXME: I have a crash when I hit pause (debug build)
//if (ext.compare("GL_ARB_bindless_texture") == 0) found_GL_ARB_bindless_texture = true;
// GL4.5
@ -330,7 +327,6 @@ namespace GLLoader {
// GL4.4
status &= status_and_override(found_GL_ARB_buffer_storage,"GL_ARB_buffer_storage");
status &= status_and_override(found_GL_ARB_bindless_texture,"GL_ARB_bindless_texture");
status &= status_and_override(found_GL_ARB_clear_texture,"GL_ARB_clear_texture");
// GL4.5
status &= status_and_override(found_GL_ARB_clip_control, "GL_ARB_clip_control");
status &= status_and_override(found_GL_ARB_direct_state_access, "GL_ARB_direct_state_access");

View File

@ -293,7 +293,6 @@ extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
// GL4.3
extern PFNGLCOPYIMAGESUBDATAPROC gl_CopyImageSubData;
// GL4.4
extern PFNGLCLEARTEXIMAGEPROC gl_ClearTexImage;
extern PFNGLBUFFERSTORAGEPROC gl_BufferStorage;
// GL_ARB_bindless_texture (GL5?)
extern PFNGLGETTEXTURESAMPLERHANDLEARBPROC gl_GetTextureSamplerHandleARB;

View File

@ -463,33 +463,20 @@ void GSDeviceOGL::DrawIndexedPrimitive(int offset, int count)
void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c)
{
if (GLLoader::found_GL_ARB_clear_texture) {
if (static_cast<GSTextureOGL*>(t)->IsBackbuffer()) {
glDisable(GL_SCISSOR_TEST);
OMSetFBO(0);
// glDrawBuffer(GL_BACK); // this is the default when there is no FB
// 0 will select the first drawbuffer ie GL_BACK
gl_ClearBufferfv(GL_COLOR, 0, c.v);
glEnable(GL_SCISSOR_TEST);
} else {
static_cast<GSTextureOGL*>(t)->Clear((const void*)&c);
}
glDisable(GL_SCISSOR_TEST);
if (static_cast<GSTextureOGL*>(t)->IsBackbuffer()) {
OMSetFBO(0);
// glDrawBuffer(GL_BACK); // this is the default when there is no FB
// 0 will select the first drawbuffer ie GL_BACK
gl_ClearBufferfv(GL_COLOR, 0, c.v);
} else {
glDisable(GL_SCISSOR_TEST);
if (static_cast<GSTextureOGL*>(t)->IsBackbuffer()) {
OMSetFBO(0);
OMSetFBO(m_fbo);
OMAttachRt(static_cast<GSTextureOGL*>(t)->GetID());
// glDrawBuffer(GL_BACK); // this is the default when there is no FB
// 0 will select the first drawbuffer ie GL_BACK
gl_ClearBufferfv(GL_COLOR, 0, c.v);
} else {
OMSetFBO(m_fbo);
OMAttachRt(static_cast<GSTextureOGL*>(t)->GetID());
gl_ClearBufferfv(GL_COLOR, 0, c.v);
}
glEnable(GL_SCISSOR_TEST);
gl_ClearBufferfv(GL_COLOR, 0, c.v);
}
glEnable(GL_SCISSOR_TEST);
}
void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c)
@ -500,65 +487,43 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c)
void GSDeviceOGL::ClearRenderTarget_ui(GSTexture* t, uint32 c)
{
if (GLLoader::found_GL_ARB_clear_texture) {
static_cast<GSTextureOGL*>(t)->Clear((const void*)&c);
} else {
uint32 col[4] = {c, c, c, c};
uint32 col[4] = {c, c, c, c};
glDisable(GL_SCISSOR_TEST);
glDisable(GL_SCISSOR_TEST);
OMSetFBO(m_fbo);
OMAttachRt(static_cast<GSTextureOGL*>(t)->GetID());
OMSetFBO(m_fbo);
OMAttachRt(static_cast<GSTextureOGL*>(t)->GetID());
gl_ClearBufferuiv(GL_COLOR, 0, col);
gl_ClearBufferuiv(GL_COLOR, 0, col);
glEnable(GL_SCISSOR_TEST);
}
glEnable(GL_SCISSOR_TEST);
}
void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
{
// TODO is it possible with GL44 ClearTexture? no the API is garbage!
// It can't be used here because it will clear both depth and stencil
if (0 && GLLoader::found_GL_ARB_clear_texture) {
#ifndef ENABLE_GLES
ASSERT(c == 0.0f);
gl_ClearTexImage(static_cast<GSTextureOGL*>(t)->GetID(), GL_TEX_LEVEL_0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL);
#endif
} else {
OMSetFBO(m_fbo);
OMAttachDs(static_cast<GSTextureOGL*>(t)->GetID());
OMSetFBO(m_fbo);
OMAttachDs(static_cast<GSTextureOGL*>(t)->GetID());
glDisable(GL_SCISSOR_TEST);
if (GLState::depth_mask) {
gl_ClearBufferfv(GL_DEPTH, 0, &c);
} else {
glDepthMask(true);
gl_ClearBufferfv(GL_DEPTH, 0, &c);
glDepthMask(false);
}
glEnable(GL_SCISSOR_TEST);
glDisable(GL_SCISSOR_TEST);
if (GLState::depth_mask) {
gl_ClearBufferfv(GL_DEPTH, 0, &c);
} else {
glDepthMask(true);
gl_ClearBufferfv(GL_DEPTH, 0, &c);
glDepthMask(false);
}
glEnable(GL_SCISSOR_TEST);
}
void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c)
{
// TODO is it possible with GL44 ClearTexture? no the API is garbage!
// It can't be used here because it will clear both depth and stencil
if (0 && GLLoader::found_GL_ARB_clear_texture) {
#ifndef ENABLE_GLES
ASSERT(c == 0);
gl_ClearTexImage(static_cast<GSTextureOGL*>(t)->GetID(), GL_TEX_LEVEL_0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL);
#endif
} else {
OMSetFBO(m_fbo);
OMAttachDs(static_cast<GSTextureOGL*>(t)->GetID());
GLint color = c;
OMSetFBO(m_fbo);
OMAttachDs(static_cast<GSTextureOGL*>(t)->GetID());
GLint color = c;
glDisable(GL_SCISSOR_TEST);
gl_ClearBufferiv(GL_STENCIL, 0, &color);
glEnable(GL_SCISSOR_TEST);
}
glDisable(GL_SCISSOR_TEST);
gl_ClearBufferiv(GL_STENCIL, 0, &color);
glEnable(GL_SCISSOR_TEST);
}
GLuint GSDeviceOGL::CreateSampler(PSSamplerSelector sel)

View File

@ -275,13 +275,6 @@ GSTextureOGL::~GSTextureOGL()
glDeleteTextures(1, &m_texture_id);
}
void GSTextureOGL::Clear(const void *data)
{
#ifndef ENABLE_GLES
gl_ClearTexImage(m_texture_id, 0, m_int_format, m_int_type, data);
#endif
}
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
{
ASSERT(m_type != GSTexture::DepthStencil && m_type != GSTexture::Offscreen);

View File

@ -69,8 +69,6 @@ class GSTextureOGL : public GSTexture
void Save(const string& fn, const void* image, uint32 pitch);
void SaveRaw(const string& fn, const void* image, uint32 pitch);
void Clear(const void *data);
void EnableUnit();
bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); }

View File

@ -108,7 +108,6 @@ void GSWndGL::PopulateGlFunction()
// GL4.3
*(void**)&(gl_CopyImageSubData) = GetProcAddress("glCopyImageSubData", true);
// GL4.4
*(void**)&(gl_ClearTexImage) = GetProcAddress("glClearTexImage", true);
*(void**)&(gl_BufferStorage) = GetProcAddress("glBufferStorage", true);
// GL_ARB_bindless_texture (GL5?)
*(void**)&(gl_GetTextureSamplerHandleARB) = GetProcAddress("glGetTextureSamplerHandleARB", true);