mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
Add floating point FBO support.
This commit is contained in:
parent
e326db8fb5
commit
773c511179
27
gfx/gl.c
27
gfx/gl.c
@ -518,10 +518,29 @@ static void gl_create_fbo_textures(void *data)
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter_type);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter_type);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter_type);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter_type);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
#if !defined(HAVE_OPENGLES2) && !defined(HAVE_PSGL)
|
||||||
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, gl->fbo_rect[i].width, gl->fbo_rect[i].height,
|
bool fp_fbo = gl->fbo_scale[i].valid && gl->fbo_scale[i].fp_fbo;
|
||||||
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
|
||||||
RARCH_GL_FORMAT32, NULL);
|
if (fp_fbo)
|
||||||
|
{
|
||||||
|
bool has_fp_fbo = gl_query_extension("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,
|
||||||
|
gl->fbo_rect[i].width, gl->fbo_rect[i].height,
|
||||||
|
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
|
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
||||||
|
gl->fbo_rect[i].width, gl->fbo_rect[i].height,
|
||||||
|
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||||
|
RARCH_GL_FORMAT32, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
@ -169,6 +169,7 @@ enum gl_scale_type
|
|||||||
|
|
||||||
struct gl_fbo_scale
|
struct gl_fbo_scale
|
||||||
{
|
{
|
||||||
|
bool fp_fbo;
|
||||||
enum gl_scale_type type_x;
|
enum gl_scale_type type_x;
|
||||||
enum gl_scale_type type_y;
|
enum gl_scale_type type_y;
|
||||||
float scale_x;
|
float scale_x;
|
||||||
|
@ -844,7 +844,6 @@ static bool load_shader_params(unsigned i, config_file_t *conf)
|
|||||||
prg[i + 1].frame_count_mod = strtoul(frame_count_mod, NULL, 0);
|
prg[i + 1].frame_count_mod = strtoul(frame_count_mod, NULL, 0);
|
||||||
|
|
||||||
char scale_name_buf[64];
|
char scale_name_buf[64];
|
||||||
|
|
||||||
print_buf(scale_name_buf, "scale_type%u", i);
|
print_buf(scale_name_buf, "scale_type%u", i);
|
||||||
config_get_array(conf, scale_name_buf, scale_type, sizeof(scale_type));
|
config_get_array(conf, scale_name_buf, scale_type, sizeof(scale_type));
|
||||||
|
|
||||||
@ -874,6 +873,11 @@ static bool load_shader_params(unsigned i, config_file_t *conf)
|
|||||||
scale->scale_x = 1.0;
|
scale->scale_x = 1.0;
|
||||||
scale->scale_y = 1.0;
|
scale->scale_y = 1.0;
|
||||||
|
|
||||||
|
char fp_fbo_buf[64];
|
||||||
|
print_buf(fp_fbo_buf, "float_framebuffer%u", i);
|
||||||
|
scale->fp_fbo = false;
|
||||||
|
config_get_bool(conf, fp_fbo_buf, &scale->fp_fbo);
|
||||||
|
|
||||||
const struct retro_game_geometry *geom = &g_extern.system.av_info.geometry;
|
const struct retro_game_geometry *geom = &g_extern.system.av_info.geometry;
|
||||||
scale->abs_x = geom->base_width;
|
scale->abs_x = geom->base_width;
|
||||||
scale->abs_y = geom->base_height;
|
scale->abs_y = geom->base_height;
|
||||||
|
@ -167,6 +167,7 @@ struct shader_program
|
|||||||
char *fragment;
|
char *fragment;
|
||||||
enum filter_type filter;
|
enum filter_type filter;
|
||||||
|
|
||||||
|
bool fp_fbo;
|
||||||
float scale_x;
|
float scale_x;
|
||||||
float scale_y;
|
float scale_y;
|
||||||
unsigned abs_x;
|
unsigned abs_x;
|
||||||
@ -303,6 +304,7 @@ static char *xml_replace_if_file(char *content, const char *path, xmlNodePtr nod
|
|||||||
static bool get_xml_attrs(struct shader_program *prog, xmlNodePtr ptr)
|
static bool get_xml_attrs(struct shader_program *prog, xmlNodePtr ptr)
|
||||||
{
|
{
|
||||||
prog->frame_count_mod = 0;
|
prog->frame_count_mod = 0;
|
||||||
|
prog->fp_fbo = false;
|
||||||
prog->scale_x = 1.0;
|
prog->scale_x = 1.0;
|
||||||
prog->scale_y = 1.0;
|
prog->scale_y = 1.0;
|
||||||
prog->type_x = prog->type_y = RARCH_SCALE_INPUT;
|
prog->type_x = prog->type_y = RARCH_SCALE_INPUT;
|
||||||
@ -332,7 +334,7 @@ static bool get_xml_attrs(struct shader_program *prog, xmlNodePtr ptr)
|
|||||||
char attr_scale[64], attr_scale_x[64], attr_scale_y[64];
|
char attr_scale[64], attr_scale_x[64], attr_scale_y[64];
|
||||||
char attr_size[64], attr_size_x[64], attr_size_y[64];
|
char attr_size[64], attr_size_x[64], attr_size_y[64];
|
||||||
char attr_outscale[64], attr_outscale_x[64], attr_outscale_y[64];
|
char attr_outscale[64], attr_outscale_x[64], attr_outscale_y[64];
|
||||||
char frame_count_mod[64];
|
char frame_count_mod[64], fp_fbo[64];
|
||||||
|
|
||||||
xml_get_prop(attr_scale, sizeof(attr_scale), ptr, "scale");
|
xml_get_prop(attr_scale, sizeof(attr_scale), ptr, "scale");
|
||||||
xml_get_prop(attr_scale_x, sizeof(attr_scale_x), ptr, "scale_x");
|
xml_get_prop(attr_scale_x, sizeof(attr_scale_x), ptr, "scale_x");
|
||||||
@ -344,6 +346,9 @@ static bool get_xml_attrs(struct shader_program *prog, xmlNodePtr ptr)
|
|||||||
xml_get_prop(attr_outscale_x, sizeof(attr_outscale_x), ptr, "outscale_x");
|
xml_get_prop(attr_outscale_x, sizeof(attr_outscale_x), ptr, "outscale_x");
|
||||||
xml_get_prop(attr_outscale_y, sizeof(attr_outscale_y), ptr, "outscale_y");
|
xml_get_prop(attr_outscale_y, sizeof(attr_outscale_y), ptr, "outscale_y");
|
||||||
xml_get_prop(frame_count_mod, sizeof(frame_count_mod), ptr, "frame_count_mod");
|
xml_get_prop(frame_count_mod, sizeof(frame_count_mod), ptr, "frame_count_mod");
|
||||||
|
xml_get_prop(fp_fbo, sizeof(fp_fbo), ptr, "float_framebuffer");
|
||||||
|
|
||||||
|
prog->fp_fbo = strcmp(fp_fbo, "true") == 0;
|
||||||
|
|
||||||
unsigned x_attr_cnt = 0, y_attr_cnt = 0;
|
unsigned x_attr_cnt = 0, y_attr_cnt = 0;
|
||||||
|
|
||||||
@ -1189,6 +1194,7 @@ bool gl_glsl_init(const char *path)
|
|||||||
for (unsigned i = 0; i < num_progs; i++)
|
for (unsigned i = 0; i < num_progs; i++)
|
||||||
{
|
{
|
||||||
gl_filter_type[i + 1] = progs[i].filter;
|
gl_filter_type[i + 1] = progs[i].filter;
|
||||||
|
gl_scale[i + 1].fp_fbo = progs[i].fp_fbo;
|
||||||
gl_scale[i + 1].type_x = progs[i].type_x;
|
gl_scale[i + 1].type_x = progs[i].type_x;
|
||||||
gl_scale[i + 1].type_y = progs[i].type_y;
|
gl_scale[i + 1].type_y = progs[i].type_y;
|
||||||
gl_scale[i + 1].scale_x = progs[i].scale_x;
|
gl_scale[i + 1].scale_x = progs[i].scale_x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user