From 0085b24fd5b080c57a176ffe1bbae7fa5b272fd9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 8 Nov 2017 00:49:01 +0100 Subject: [PATCH] Cut down on gl_check_capability calls --- gfx/common/gl_common.h | 1 + gfx/drivers/gl.c | 8 +++++--- gfx/drivers_renderchain/gl2_renderchain.c | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 19c3712bd1..8cac2884a2 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -63,6 +63,7 @@ typedef struct gl bool support_unpack_row_length; bool have_es2_compat; bool have_full_npot_support; + bool have_mipmap; bool egl_images; #ifdef HAVE_OVERLAY diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index dc76d522de..1e604f5c93 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -827,12 +827,13 @@ void gl_load_texture_data( bool rgb32 = (base_size == (sizeof(uint32_t))); GLenum wrap = gl_wrap_type_to_enum(wrap_type); GLuint id = (GLuint)id_data; + bool have_mipmap = gl_check_capability(GL_CAPS_MIPMAP); glBindTexture(GL_TEXTURE_2D, id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); - if (!gl_check_capability(GL_CAPS_MIPMAP)) + if (!have_mipmap) { /* Assume no mipmapping support. */ switch (filter_type) @@ -882,7 +883,7 @@ void gl_load_texture_data( (use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, (rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame); - if (want_mipmap && gl_check_capability(GL_CAPS_MIPMAP)) + if (want_mipmap && have_mipmap) glGenerateMipmap(GL_TEXTURE_2D); } @@ -1249,7 +1250,7 @@ static bool gl_frame(void *data, const void *frame, /* No point regenerating mipmaps * if there are no new frames. */ - if (gl->tex_mipmap && gl_check_capability(GL_CAPS_MIPMAP)) + if (gl->tex_mipmap && gl->have_mipmap) glGenerateMipmap(GL_TEXTURE_2D); } @@ -1591,6 +1592,7 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident) */ gl->have_full_npot_support = gl_check_capability(GL_CAPS_FULL_NPOT_SUPPORT); #endif + gl->have_mipmap = gl_check_capability(GL_CAPS_MIPMAP); gl->have_es2_compat = gl_check_capability(GL_CAPS_ES2_COMPAT); gl->have_sync = gl_check_capability(GL_CAPS_SYNC); diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index e1ad84918b..dcaa6c0e2f 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -294,7 +294,7 @@ static void gl2_renderchain_render( mip_level = i + 1; if (video_shader_driver_mipmap_input(&mip_level) - && gl_check_capability(GL_CAPS_MIPMAP)) + && gl->have_mipmap) glGenerateMipmap(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT); @@ -371,7 +371,7 @@ static void gl2_renderchain_render( mip_level = gl->fbo_pass + 1; if (video_shader_driver_mipmap_input(&mip_level) - && gl_check_capability(GL_CAPS_MIPMAP)) + && gl->have_mipmap) glGenerateMipmap(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT);