Cut down on code duplication - create gl_load_luts

This commit is contained in:
twinaphex 2019-02-02 21:32:37 +01:00
parent 9262effbf9
commit 90f1317498
4 changed files with 35 additions and 56 deletions

View File

@ -415,6 +415,10 @@ bool gl_add_lut(
enum gfx_wrap_type lut_wrap_type,
unsigned i, void *textures_data);
bool gl_load_luts(
const void *shader_data,
GLuint *textures_lut);
RETRO_END_DECLS
#endif

View File

@ -128,6 +128,35 @@ void context_bind_hw_render(void *data, bool enable)
gl_context_bind_hw_render(gl, enable);
}
bool gl_load_luts(
const void *shader_data,
GLuint *textures_lut)
{
unsigned i;
const struct video_shader *shader =
(const struct video_shader*)shader_data;
unsigned num_luts = MIN(shader->luts, GFX_MAX_TEXTURES);
if (!shader->luts)
return true;
glGenTextures(num_luts, textures_lut);
for (i = 0; i < num_luts; i++)
{
if (!gl_add_lut(
shader->lut[i].path,
shader->lut[i].mipmap,
shader->lut[i].filter,
shader->lut[i].wrap,
i, textures_lut))
return false;
}
glBindTexture(GL_TEXTURE_2D, 0);
return true;
}
#ifdef HAVE_OVERLAY
static void gl_free_overlay(gl_t *gl)
{

View File

@ -761,33 +761,6 @@ static bool gl_cg_load_shader(void *data, unsigned i)
return true;
}
static bool gl_cg_load_luts(
const struct video_shader *shader,
GLuint *textures_lut)
{
unsigned i;
unsigned num_luts = MIN(shader->luts, GFX_MAX_TEXTURES);
if (!shader->luts)
return true;
glGenTextures(num_luts, textures_lut);
for (i = 0; i < num_luts; i++)
{
if (!gl_add_lut(
shader->lut[i].path,
shader->lut[i].mipmap,
shader->lut[i].filter,
shader->lut[i].wrap,
i, textures_lut))
return false;
}
glBindTexture(GL_TEXTURE_2D, 0);
return true;
}
static bool gl_cg_load_preset(void *data, const char *path)
{
unsigned i;
@ -848,7 +821,7 @@ static bool gl_cg_load_preset(void *data, const char *path)
}
}
if (!gl_cg_load_luts(cg->shader, cg->lut_textures))
if (!gl_load_luts(cg->shader, cg->lut_textures))
{
RARCH_ERR("Failed to load lookup textures ...\n");
return false;

View File

@ -158,33 +158,6 @@ static bool glsl_core;
static unsigned glsl_major;
static unsigned glsl_minor;
static bool gl_glsl_load_luts(
const struct video_shader *shader,
GLuint *textures_lut)
{
unsigned i;
unsigned num_luts = MIN(shader->luts, GFX_MAX_TEXTURES);
if (!shader->luts)
return true;
glGenTextures(num_luts, textures_lut);
for (i = 0; i < num_luts; i++)
{
if (!gl_add_lut(
shader->lut[i].path,
shader->lut[i].mipmap,
shader->lut[i].filter,
shader->lut[i].wrap,
i, textures_lut))
return false;
}
glBindTexture(GL_TEXTURE_2D, 0);
return true;
}
static GLint gl_glsl_get_uniform(glsl_shader_data_t *glsl,
GLuint prog, const char *base)
{
@ -1020,7 +993,7 @@ static void *gl_glsl_init(void *data, const char *path)
if (!gl_glsl_compile_programs(glsl, &glsl->prg[1]))
goto error;
if (!gl_glsl_load_luts(glsl->shader, glsl->lut_textures))
if (!gl_load_luts(glsl->shader, glsl->lut_textures))
{
RARCH_ERR("[GL]: Failed to load LUTs.\n");
goto error;