Refactor sRGB FBO handling a bit.

This commit is contained in:
Themaister 2014-05-11 19:35:54 +02:00
parent 9d8654cfe2
commit 7559ca12ef
7 changed files with 15 additions and 43 deletions

View File

@ -352,7 +352,6 @@ void gl_shader_set_coords(void *data, const struct gl_coords *coords, const math
#define gl_shader_filter_type(gl, index, smooth) ((gl->shader) ? gl->shader->filter_type(index, smooth) : false)
#define gl_shader_wrap_type(gl, index) ((gl->shader) ? gl->shader->wrap_type(index) : RARCH_WRAP_BORDER)
#define gl_shader_mipmap_input(gl, index) ((gl->shader) ? gl->shader->mipmap_input(index) : false)
#define gl_shader_srgb_output(gl, index) ((gl->shader) ? gl->shader->srgb_output(index) : false)
#ifdef IOS
// There is no default frame buffer on IOS.
@ -490,7 +489,6 @@ static void gl_create_fbo_textures(void *data)
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i]);
bool mipmapped = gl_shader_mipmap_input(gl, i + 2);
bool srgb_output = gl_shader_srgb_output(gl, i + 1); // From previous pass.
GLenum min_filter = mipmapped ? base_mip_filt : base_filt;
bool smooth = false;
@ -507,23 +505,23 @@ static void gl_create_fbo_textures(void *data)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_enum);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_enum);
bool fp_fbo = gl->fbo_scale[i].valid && gl->fbo_scale[i].fp_fbo;
bool srgb_fbo = gl->fbo_scale[i].valid && srgb_output;
bool fp_fbo = gl->fbo_scale[i].fp_fbo;
bool srgb_fbo = gl->fbo_scale[i].srgb_fbo;
if (srgb_fbo)
{
if (!gl->has_srgb_fbo)
RARCH_ERR("sRGB FBO was requested, but it is not supported. Falling back to UNORM. Result will look odd!\n");
RARCH_ERR("[GL]: sRGB FBO was requested, but it is not supported. Falling back to UNORM. Result will look odd!\n");
}
else if (fp_fbo)
{
if (!gl->has_fp_fbo)
RARCH_ERR("Floating-point FBO was requested, but is not supported. Falling back to UNORM.\n");
RARCH_ERR("[GL]: Floating-point FBO was requested, but is not supported. Falling back to UNORM.\n");
}
if (srgb_fbo && gl->has_srgb_fbo)
{
RARCH_LOG("FBO pass #%d is sRGB.\n", i);
RARCH_LOG("[GL]: FBO pass #%d is sRGB.\n", i);
#ifdef HAVE_OPENGLES2
glTexImage2D(GL_TEXTURE_2D,
0, GL_SRGB_ALPHA_EXT,
@ -541,7 +539,7 @@ static void gl_create_fbo_textures(void *data)
#ifndef HAVE_OPENGLES2
if (fp_fbo && gl->has_fp_fbo)
{
RARCH_LOG("FBO pass #%d is floating-point.\n", i);
RARCH_LOG("[GL]: FBO pass #%d is floating-point.\n", i);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
gl->fbo_rect[i].width, gl->fbo_rect[i].height,
0, GL_RGBA, GL_FLOAT, NULL);

View File

@ -898,14 +898,6 @@ static bool gl_cg_mipmap_input(unsigned index)
return false;
}
static bool gl_cg_srgb_output(unsigned index)
{
if (cg_active && index)
return cg_shader->pass[index - 1].srgb_fbo;
else
return false;
}
void gl_cg_set_compiler_args(const char **argv)
{
cg_arguments = argv;
@ -929,7 +921,6 @@ const gl_shader_backend_t gl_cg_backend = {
gl_cg_set_mvp,
gl_cg_get_prev_textures,
gl_cg_mipmap_input,
gl_cg_srgb_output,
RARCH_SHADER_CG,
};

View File

@ -53,7 +53,6 @@ struct gl_shader_backend
bool (*set_mvp)(void *data, const math_matrix *mat);
unsigned (*get_prev_textures)(void);
bool (*mipmap_input)(unsigned index);
bool (*srgb_output)(unsigned index);
enum rarch_shader_type type;
};

View File

@ -1166,14 +1166,6 @@ static bool gl_glsl_mipmap_input(unsigned index)
return false;
}
static bool gl_glsl_srgb_output(unsigned index)
{
if (glsl_enable && index)
return glsl_shader->pass[index - 1].srgb_fbo;
else
return false;
}
void gl_glsl_set_get_proc_address(gfx_ctx_proc_t (*proc)(const char*))
{
glsl_get_proc_address = proc;
@ -1199,7 +1191,6 @@ const gl_shader_backend_t gl_glsl_backend = {
gl_glsl_set_mvp,
gl_glsl_get_prev_textures,
gl_glsl_mipmap_input,
gl_glsl_srgb_output,
RARCH_SHADER_GLSL,
};

View File

@ -435,12 +435,6 @@ static bool hlsl_mipmap_input(unsigned index)
return false;
}
static bool hlsl_srgb_output(unsigned index)
{
(void)index;
return false;
}
const gl_shader_backend_t hlsl_backend = {
hlsl_init,
hlsl_deinit,
@ -454,7 +448,6 @@ const gl_shader_backend_t hlsl_backend = {
hlsl_set_mvp,
NULL, /* hlsl_get_prev_textures */
hlsl_mipmap_input,
hlsl_srgb_output,
RARCH_SHADER_HLSL,
};

View File

@ -100,10 +100,14 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass,
if (config_get_array(conf, frame_count_mod_buf, frame_count_mod, sizeof(frame_count_mod)))
pass->frame_count_mod = strtoul(frame_count_mod, NULL, 0);
// SRGB and mipmapping
// FBO types and mipmapping
char srgb_output_buf[64];
print_buf(srgb_output_buf, "srgb_framebuffer%u", i);
config_get_bool(conf, srgb_output_buf, &pass->srgb_fbo);
config_get_bool(conf, srgb_output_buf, &pass->fbo.srgb_fbo);
char fp_fbo_buf[64];
print_buf(fp_fbo_buf, "float_framebuffer%u", i);
config_get_bool(conf, fp_fbo_buf, &pass->fbo.fp_fbo);
char mipmap_buf[64];
print_buf(mipmap_buf, "mipmap_input%u", i);
@ -143,10 +147,6 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass,
scale->scale_x = 1.0;
scale->scale_y = 1.0;
char fp_fbo_buf[64];
print_buf(fp_fbo_buf, "float_framebuffer%u", i);
config_get_bool(conf, fp_fbo_buf, &scale->fp_fbo);
if (*scale_type_x)
{
if (strcmp(scale_type_x, "source") == 0)
@ -978,6 +978,8 @@ static void shader_write_fbo(config_file_t *conf, const struct gfx_fbo_scale *fb
char key[64];
print_buf(key, "float_framebuffer%u", i);
config_set_bool(conf, key, fbo->fp_fbo);
print_buf(key, "srgb_framebuffer%u", i);
config_set_bool(conf, key, fbo->srgb_fbo);
if (!fbo->valid)
return;
@ -1074,8 +1076,6 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, const struct gfx_shader *sha
config_set_int(conf, key, pass->frame_count_mod);
}
print_buf(key, "srgb_framebuffer%u", i);
config_set_bool(conf, key, pass->srgb_fbo);
print_buf(key, "mipmap_input%u", i);
config_set_bool(conf, key, pass->mipmap);

View File

@ -61,6 +61,7 @@ struct gfx_fbo_scale
unsigned abs_x;
unsigned abs_y;
bool fp_fbo;
bool srgb_fbo;
bool valid;
};
@ -80,7 +81,6 @@ struct gfx_shader_pass
enum gfx_filter_type filter;
enum gfx_wrap_type wrap;
unsigned frame_count_mod;
bool srgb_fbo;
bool mipmap;
};