Skip to content

Commit

Permalink
opengl/gpu_tex: stop relying on GL_EXT_texture_integer
Browse files Browse the repository at this point in the history
While running the test suite I discovered that we rely on this extension
in a single place without checking it anywhere.
Instead of hiding uint support behind it we can better just use standard
functions to clear the framebuffer.
  • Loading branch information
sfan5 authored and haasn committed Nov 11, 2024
1 parent a075974 commit 04dae90
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
23 changes: 14 additions & 9 deletions src/opengl/gpu_tex.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,31 +807,36 @@ void gl_tex_clear_ex(pl_gpu gpu, pl_tex tex, const union pl_clear_color color)
struct pl_tex_gl *tex_gl = PL_PRIV(tex);
pl_assert(tex_gl->fbo || tex_gl->wrapped_fb);

const GLenum target = p->gles_ver && p->gles_ver < 30 ?
GL_FRAMEBUFFER : GL_DRAW_FRAMEBUFFER;

gl->BindFramebuffer(target, tex_gl->fbo);

switch (tex->params.format->type) {
case PL_FMT_UNKNOWN:
case PL_FMT_FLOAT:
case PL_FMT_UNORM:
case PL_FMT_SNORM:
gl->ClearColor(color.f[0], color.f[1], color.f[2], color.f[3]);
gl->Clear(GL_COLOR_BUFFER_BIT);
break;

case PL_FMT_UINT:
gl->ClearColorIuiEXT(color.u[0], color.u[1], color.u[2], color.u[3]);
case PL_FMT_UINT: {
GLuint gl_color[] = { color.u[0], color.u[1], color.u[2], color.u[3] };
gl->ClearBufferuiv(GL_COLOR, 0, gl_color);
break;
}

case PL_FMT_SINT:
gl->ClearColorIiEXT(color.i[0], color.i[1], color.i[2], color.i[3]);
case PL_FMT_SINT: {
GLint gl_color[] = { color.i[0], color.i[1], color.i[2], color.i[3] };
gl->ClearBufferiv(GL_COLOR, 0, gl_color);
break;
}

case PL_FMT_TYPE_COUNT:
pl_unreachable();
}

const GLenum target = p->gles_ver && p->gles_ver < 30 ?
GL_FRAMEBUFFER : GL_DRAW_FRAMEBUFFER;

gl->BindFramebuffer(target, tex_gl->fbo);
gl->Clear(GL_COLOR_BUFFER_BIT);
gl->BindFramebuffer(target, 0);
gl_check_err(gpu, "gl_tex_clear");
RELEASE_CURRENT();
Expand Down
1 change: 0 additions & 1 deletion src/opengl/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ if opengl_build.allowed()
'GL_EXT_color_buffer_float',
'GL_EXT_texture3D',
'GL_EXT_texture_format_BGRA8888',
'GL_EXT_texture_integer',
'GL_EXT_texture_norm16',
'GL_EXT_texture_rg',
'GL_EXT_unpack_subimage',
Expand Down

0 comments on commit 04dae90

Please sign in to comment.