Create gl_add_lut

This commit is contained in:
twinaphex 2019-02-02 17:25:27 +01:00
parent 1796d359c5
commit 7c74f0abe8
4 changed files with 69 additions and 47 deletions

View File

@ -75,6 +75,55 @@ void gl_load_texture_image(GLenum target,
if (gl_check_capability(GL_CAPS_GLES3_SUPPORTED))
#endif
gl_size_format(&internalFormat);
glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
glTexImage2D(target, level, internalFormat, width,
height, border, format, type, data);
}
}
bool gl_add_lut(
const char *lut_path,
bool lut_mipmap,
unsigned lut_filter,
enum gfx_wrap_type lut_wrap_type,
unsigned i, void *textures_data)
{
struct texture_image img;
GLuint *textures_lut = (GLuint*)textures_data;
enum texture_filter_type filter_type = TEXTURE_FILTER_LINEAR;
img.width = 0;
img.height = 0;
img.pixels = NULL;
img.supports_rgba = video_driver_supports_rgba();
if (!image_texture_load(&img, lut_path))
{
RARCH_ERR("[GL]: Failed to load texture image from: \"%s\"\n",
lut_path);
return false;
}
RARCH_LOG("[GL]: Loaded texture image from: \"%s\" ...\n",
lut_path);
if (lut_filter == RARCH_FILTER_NEAREST)
filter_type = TEXTURE_FILTER_NEAREST;
if (lut_mipmap)
{
if (filter_type == TEXTURE_FILTER_NEAREST)
filter_type = TEXTURE_FILTER_MIPMAP_NEAREST;
else
filter_type = TEXTURE_FILTER_MIPMAP_LINEAR;
}
gl_load_texture_data(
textures_lut[i],
lut_wrap_type,
filter_type, 4,
img.width, img.height,
img.pixels, sizeof(uint32_t));
image_texture_free(&img);
return true;
}

View File

@ -408,6 +408,13 @@ static INLINE bool gl_set_core_context(enum retro_hw_context_type ctx_type)
return true;
}
bool gl_add_lut(
const char *lut_path,
bool lut_mipmap,
unsigned lut_filter,
enum gfx_wrap_type lut_wrap_type,
unsigned i, void *textures_data);
RETRO_END_DECLS
#endif

View File

@ -761,50 +761,6 @@ static bool gl_cg_load_shader(void *data, unsigned i)
return true;
}
static bool gl_cg_add_lut(
const struct video_shader *shader,
unsigned i, void *textures_data)
{
struct texture_image img;
GLuint *textures_lut = (GLuint*)textures_data;
enum texture_filter_type filter_type = TEXTURE_FILTER_LINEAR;
img.width = 0;
img.height = 0;
img.pixels = NULL;
img.supports_rgba = video_driver_supports_rgba();
if (!image_texture_load(&img, shader->lut[i].path))
{
RARCH_ERR("[GL]: Failed to load texture image from: \"%s\"\n",
shader->lut[i].path);
return false;
}
RARCH_LOG("[GL]: Loaded texture image from: \"%s\" ...\n",
shader->lut[i].path);
if (shader->lut[i].filter == RARCH_FILTER_NEAREST)
filter_type = TEXTURE_FILTER_NEAREST;
if (shader->lut[i].mipmap)
{
if (filter_type == TEXTURE_FILTER_NEAREST)
filter_type = TEXTURE_FILTER_MIPMAP_NEAREST;
else
filter_type = TEXTURE_FILTER_MIPMAP_LINEAR;
}
gl_load_texture_data(textures_lut[i],
shader->lut[i].wrap,
filter_type, 4,
img.width, img.height,
img.pixels, sizeof(uint32_t));
image_texture_free(&img);
return true;
}
static bool gl_cg_load_luts(
const struct video_shader *shader,
GLuint *textures_lut)
@ -819,7 +775,12 @@ static bool gl_cg_load_luts(
for (i = 0; i < num_luts; i++)
{
if (!gl_cg_add_lut(shader, i, textures_lut))
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;
}

View File

@ -216,7 +216,12 @@ static bool gl_glsl_load_luts(
for (i = 0; i < num_luts; i++)
{
if (!gl_glsl_add_lut(shader, i, textures_lut))
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;
}