From 46c3dd6d20b635b0583dab7646630bb487cd5bfc Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 4 Dec 2013 12:55:51 +0100 Subject: [PATCH] Clean up float FBO handling a bit. Fallback to UNORM if not supported. --- gfx/gl.c | 22 ++++++++++------------ gfx/gl_common.h | 1 + 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index 67e37df68a..77dd4c44f0 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -483,25 +483,19 @@ static void gl_create_fbo_textures(void *data) bool fp_fbo = gl->fbo_scale[i].valid && gl->fbo_scale[i].fp_fbo; - if (fp_fbo) + if (fp_fbo && !gl->has_fp_fbo) + RARCH_ERR("Floating-point FBO was requested, but is not supported. Falling back to UNORM.\n"); + + if (fp_fbo && gl->has_fp_fbo) { + RARCH_LOG("FBO pass #%d is floating-point.\n", i); // GLES and GL are inconsistent in which arguments to pass. #ifdef HAVE_OPENGLES2 - bool has_fp_fbo = gl_query_extension(gl, "OES_texture_float_linear"); - if (!has_fp_fbo) - RARCH_ERR("OES_texture_float_linear extension not found.\n"); - - RARCH_LOG("FBO pass #%d is floating-point.\n", i); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0, GL_RGBA, GL_FLOAT, NULL); #else - bool has_fp_fbo = gl_query_extension(gl, "ARB_texture_float"); - if (!has_fp_fbo) - RARCH_ERR("ARB_texture_float extension was not found.\n"); - - RARCH_LOG("FBO pass #%d is floating-point.\n", i); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); #endif @@ -1697,6 +1691,10 @@ static bool resolve_extensions(gl_t *gl) RARCH_LOG("[GL]: Extension GL_EXT_unpack_subimage, can copy textures faster using UNPACK_ROW_LENGTH.\n"); gl->support_unpack_row_length = true; } + gl->has_fp_fbo = gl_query_extension(gl, "OES_texture_float_linear"); +#else + // Float FBO is core in 3.2. + gl->has_fp_fbo = gl->core_context || gl_query_extension(gl, "ARB_texture_float"); #endif #ifdef GL_DEBUG diff --git a/gfx/gl_common.h b/gfx/gl_common.h index ab0e5c184e..9a1ad05996 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -176,6 +176,7 @@ typedef struct gl GLuint hw_render_depth[MAX_TEXTURES]; bool hw_render_fbo_init; bool hw_render_depth_init; + bool has_fp_fbo; #endif bool hw_render_use;