This commit is contained in:
twinaphex 2017-11-07 21:03:29 +01:00
parent fe2bf47b98
commit fc43a14637
6 changed files with 142 additions and 74 deletions

View File

@ -175,9 +175,6 @@ typedef struct gl
void *renderchain_data;
} gl_t;
bool gl_load_luts(const struct video_shader *generic_shader,
GLuint *lut_textures);
#ifdef NO_GL_FF_VERTEX
#define gl_ff_vertex(coords) ((void)0)
#else
@ -246,6 +243,14 @@ void gl_load_texture_image(GLenum target,
GLenum type,
const GLvoid * data);
void gl_load_texture_data(
uint32_t id_data,
enum gfx_wrap_type wrap_type,
enum texture_filter_type filter_type,
unsigned alignment,
unsigned width, unsigned height,
const void *frame, unsigned base_size);
RETRO_END_DECLS
#endif

View File

@ -2522,28 +2522,6 @@ unsigned *height_p, size_t *pitch_p)
}
#endif
bool gl_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 (!gl2_renderchain_add_lut(shader, i, textures_lut))
return false;
}
glBindTexture(GL_TEXTURE_2D, 0);
return true;
}
#ifdef HAVE_OVERLAY
static bool gl_overlay_load(void *data,
const void *image_data, unsigned num_images)

View File

@ -962,50 +962,6 @@ static void gl2_renderchain_bind_prev_texture(
#endif
}
bool gl2_renderchain_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 void gl2_renderchain_viewport_info(
void *data, struct video_viewport *vp)
{

View File

@ -25,9 +25,6 @@
RETRO_BEGIN_DECLS
bool gl2_renderchain_add_lut(const struct video_shader *shader,
unsigned i, void *textures_lut);
void gl2_renderchain_deinit_fbo(void *data);
void context_bind_hw_render(bool enable);

View File

@ -781,6 +781,72 @@ 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)
{
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_cg_add_lut(shader, 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;
@ -841,7 +907,7 @@ static bool gl_cg_load_preset(void *data, const char *path)
}
}
if (!gl_load_luts(cg->shader, cg->lut_textures))
if (!gl_cg_load_luts(cg->shader, cg->lut_textures))
{
RARCH_ERR("Failed to load lookup textures ...\n");
return false;

View File

@ -157,6 +157,72 @@ static float* current_mat_data_pointer[GFX_MAX_SHADERS];
static float current_mat_data[GFX_MAX_SHADERS];
static unsigned current_idx;
static bool gl_glsl_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_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_glsl_add_lut(shader, 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)
{
@ -876,7 +942,7 @@ static void *gl_glsl_init(void *data, const char *path)
if (!gl_glsl_compile_programs(glsl, &glsl->prg[1]))
goto error;
if (!gl_load_luts(glsl->shader, glsl->lut_textures))
if (!gl_glsl_load_luts(glsl->shader, glsl->lut_textures))
{
RARCH_ERR("[GL]: Failed to load LUTs.\n");
goto error;