mirror of
https://github.com/libretro/RetroArch
synced 2025-02-23 15:40:35 +00:00
Path to check initial texture with GLSL.
This commit is contained in:
parent
8bc3d3ac5c
commit
f9c5c7c8a5
29
gfx/gl.c
29
gfx/gl.c
@ -110,12 +110,9 @@ static inline bool load_gl_proc(void)
|
|||||||
{
|
{
|
||||||
LOAD_SYM(glClientActiveTexture);
|
LOAD_SYM(glClientActiveTexture);
|
||||||
LOAD_SYM(glActiveTexture);
|
LOAD_SYM(glActiveTexture);
|
||||||
|
|
||||||
return pglClientActiveTexture && pglActiveTexture;
|
return pglClientActiveTexture && pglActiveTexture;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define pglClientActiveTexture glClientActiveTexture
|
|
||||||
#define pglActiveTexture glActiveTexture
|
|
||||||
static inline bool load_gl_proc(void) { return true; }
|
static inline bool load_gl_proc(void) { return true; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -251,14 +248,21 @@ static void gl_shader_set_proj_matrix(void)
|
|||||||
static void gl_shader_set_params(unsigned width, unsigned height,
|
static void gl_shader_set_params(unsigned width, unsigned height,
|
||||||
unsigned tex_width, unsigned tex_height,
|
unsigned tex_width, unsigned tex_height,
|
||||||
unsigned out_width, unsigned out_height,
|
unsigned out_width, unsigned out_height,
|
||||||
unsigned frame_count)
|
unsigned frame_count,
|
||||||
|
const struct gl_tex_info *info)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_CG
|
#ifdef HAVE_CG
|
||||||
gl_cg_set_params(width, height, tex_width, tex_height, out_width, out_height, frame_count);
|
gl_cg_set_params(width, height,
|
||||||
|
tex_width, tex_height,
|
||||||
|
out_width, out_height,
|
||||||
|
frame_count, info);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
gl_glsl_set_params(width, height, tex_width, tex_height, out_width, out_height, frame_count);
|
gl_glsl_set_params(width, height,
|
||||||
|
tex_width, tex_height,
|
||||||
|
out_width, out_height,
|
||||||
|
frame_count, info);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,8 +771,15 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct gl_tex_info tex_info = {
|
||||||
|
.tex = gl->texture,
|
||||||
|
.input_size = {width, height},
|
||||||
|
.tex_size = {gl->tex_w, gl->tex_h},
|
||||||
|
.coord = gl->tex_coords
|
||||||
|
};
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
gl_shader_set_params(width, height, gl->tex_w, gl->tex_h, gl->vp_width, gl->vp_height, gl->frame_count);
|
gl_shader_set_params(width, height, gl->tex_w, gl->tex_h, gl->vp_width, gl->vp_height, gl->frame_count, &tex_info);
|
||||||
|
|
||||||
if (width != gl->last_width || height != gl->last_height) // Res change. need to clear out texture.
|
if (width != gl->last_width || height != gl->last_height) // Res change. need to clear out texture.
|
||||||
{
|
{
|
||||||
@ -834,7 +845,7 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
|
|||||||
|
|
||||||
// Render to FBO with certain size.
|
// Render to FBO with certain size.
|
||||||
set_viewport(gl, rect->img_width, rect->img_height, true);
|
set_viewport(gl, rect->img_width, rect->img_height, true);
|
||||||
gl_shader_set_params(prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, gl->vp_width, gl->vp_height, gl->frame_count);
|
gl_shader_set_params(prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, gl->vp_width, gl->vp_height, gl->frame_count, &tex_info);
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -855,7 +866,7 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
gl->render_to_tex = false;
|
gl->render_to_tex = false;
|
||||||
set_viewport(gl, gl->win_width, gl->win_height, false);
|
set_viewport(gl, gl->win_width, gl->win_height, false);
|
||||||
gl_shader_set_params(prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, gl->vp_width, gl->vp_height, gl->frame_count);
|
gl_shader_set_params(prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, gl->vp_width, gl->vp_height, gl->frame_count, &tex_info);
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]);
|
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]);
|
||||||
|
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
@ -98,6 +98,14 @@ struct gl_fbo_scale
|
|||||||
bool valid;
|
bool valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct gl_tex_info
|
||||||
|
{
|
||||||
|
GLuint tex;
|
||||||
|
float input_size[2];
|
||||||
|
float tex_size[2];
|
||||||
|
const float *coord;
|
||||||
|
};
|
||||||
|
|
||||||
// Windows ... <_<
|
// Windows ... <_<
|
||||||
#if (defined(HAVE_XML) || defined(HAVE_CG)) && defined(_WIN32)
|
#if (defined(HAVE_XML) || defined(HAVE_CG)) && defined(_WIN32)
|
||||||
extern PFNGLCLIENTACTIVETEXTUREPROC pglClientActiveTexture;
|
extern PFNGLCLIENTACTIVETEXTUREPROC pglClientActiveTexture;
|
||||||
|
@ -93,8 +93,10 @@ void gl_cg_set_proj_matrix(void)
|
|||||||
void gl_cg_set_params(unsigned width, unsigned height,
|
void gl_cg_set_params(unsigned width, unsigned height,
|
||||||
unsigned tex_width, unsigned tex_height,
|
unsigned tex_width, unsigned tex_height,
|
||||||
unsigned out_width, unsigned out_height,
|
unsigned out_width, unsigned out_height,
|
||||||
unsigned frame_count)
|
unsigned frame_count,
|
||||||
|
const struct gl_tex_info *info)
|
||||||
{
|
{
|
||||||
|
(void)info;
|
||||||
if (cg_active)
|
if (cg_active)
|
||||||
{
|
{
|
||||||
cgGLSetParameter2f(prg[active_index].vid_size_f, width, height);
|
cgGLSetParameter2f(prg[active_index].vid_size_f, width, height);
|
||||||
|
@ -31,7 +31,8 @@ void gl_cg_set_proj_matrix(void);
|
|||||||
void gl_cg_set_params(unsigned width, unsigned height,
|
void gl_cg_set_params(unsigned width, unsigned height,
|
||||||
unsigned tex_width, unsigned tex_height,
|
unsigned tex_width, unsigned tex_height,
|
||||||
unsigned out_width, unsigned out_height,
|
unsigned out_width, unsigned out_height,
|
||||||
unsigned frame_count);
|
unsigned frame_count,
|
||||||
|
const struct gl_tex_info *info);
|
||||||
|
|
||||||
void gl_cg_use(unsigned index);
|
void gl_cg_use(unsigned index);
|
||||||
|
|
||||||
|
@ -61,6 +61,9 @@
|
|||||||
#define pglGetProgramInfoLog glGetProgramInfoLog
|
#define pglGetProgramInfoLog glGetProgramInfoLog
|
||||||
#define pglDeleteProgram glDeleteProgram
|
#define pglDeleteProgram glDeleteProgram
|
||||||
#define pglGetAttachedShaders glGetAttachedShaders
|
#define pglGetAttachedShaders glGetAttachedShaders
|
||||||
|
#define pglGetAttribLocation glGetAttribLocation
|
||||||
|
#define pglEnableVertexAttribArray glEnableVertexAttribArray
|
||||||
|
#define pglVertexAttribPointer glVertexAttribPointer
|
||||||
#else
|
#else
|
||||||
static PFNGLCREATEPROGRAMPROC pglCreateProgram = NULL;
|
static PFNGLCREATEPROGRAMPROC pglCreateProgram = NULL;
|
||||||
static PFNGLUSEPROGRAMPROC pglUseProgram = NULL;
|
static PFNGLUSEPROGRAMPROC pglUseProgram = NULL;
|
||||||
@ -81,6 +84,9 @@ static PFNGLGETPROGRAMIVPROC pglGetProgramiv = NULL;
|
|||||||
static PFNGLGETPROGRAMINFOLOGPROC pglGetProgramInfoLog = NULL;
|
static PFNGLGETPROGRAMINFOLOGPROC pglGetProgramInfoLog = NULL;
|
||||||
static PFNGLDELETEPROGRAMPROC pglDeleteProgram = NULL;
|
static PFNGLDELETEPROGRAMPROC pglDeleteProgram = NULL;
|
||||||
static PFNGLGETATTACHEDSHADERSPROC pglGetAttachedShaders = NULL;
|
static PFNGLGETATTACHEDSHADERSPROC pglGetAttachedShaders = NULL;
|
||||||
|
static PFNGLGETATTRIBLOCATIONPROC pglGetAttribLocation = NULL;
|
||||||
|
static PFNGLENABLEVERTEXATTRIBARRAYPROC pglEnableVertexAttribArray = NULL;
|
||||||
|
static PFNGLVERTEXATTRIBPOINTERPROC pglVertexAttribPointer = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_PROGRAMS 16
|
#define MAX_PROGRAMS 16
|
||||||
@ -597,6 +603,9 @@ bool gl_glsl_init(const char *path)
|
|||||||
LOAD_GL_SYM(GetProgramInfoLog);
|
LOAD_GL_SYM(GetProgramInfoLog);
|
||||||
LOAD_GL_SYM(DeleteProgram);
|
LOAD_GL_SYM(DeleteProgram);
|
||||||
LOAD_GL_SYM(GetAttachedShaders);
|
LOAD_GL_SYM(GetAttachedShaders);
|
||||||
|
LOAD_GL_SYM(GetAttribLocation);
|
||||||
|
LOAD_GL_SYM(EnableVertexAttribArray);
|
||||||
|
LOAD_GL_SYM(VertexAttribPointer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SSNES_LOG("Checking GLSL shader support ...\n");
|
SSNES_LOG("Checking GLSL shader support ...\n");
|
||||||
@ -608,7 +617,9 @@ bool gl_glsl_init(const char *path)
|
|||||||
&& pglDetachShader && pglLinkProgram && pglGetUniformLocation
|
&& pglDetachShader && pglLinkProgram && pglGetUniformLocation
|
||||||
&& pglUniform1i && pglUniform2fv && pglUniform4fv
|
&& pglUniform1i && pglUniform2fv && pglUniform4fv
|
||||||
&& pglGetShaderiv && pglGetShaderInfoLog && pglGetProgramiv && pglGetProgramInfoLog
|
&& pglGetShaderiv && pglGetShaderInfoLog && pglGetProgramiv && pglGetProgramInfoLog
|
||||||
&& pglDeleteProgram && pglGetAttachedShaders;
|
&& pglDeleteProgram && pglGetAttachedShaders
|
||||||
|
&& pglGetAttribLocation && pglEnableVertexAttribArray
|
||||||
|
&& pglVertexAttribPointer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!shader_support)
|
if (!shader_support)
|
||||||
@ -701,7 +712,8 @@ void gl_glsl_deinit(void)
|
|||||||
void gl_glsl_set_params(unsigned width, unsigned height,
|
void gl_glsl_set_params(unsigned width, unsigned height,
|
||||||
unsigned tex_width, unsigned tex_height,
|
unsigned tex_width, unsigned tex_height,
|
||||||
unsigned out_width, unsigned out_height,
|
unsigned out_width, unsigned out_height,
|
||||||
unsigned frame_count)
|
unsigned frame_count,
|
||||||
|
const struct gl_tex_info *info)
|
||||||
{
|
{
|
||||||
if (glsl_enable && gl_program[active_index] > 0)
|
if (glsl_enable && gl_program[active_index] > 0)
|
||||||
{
|
{
|
||||||
@ -727,6 +739,37 @@ void gl_glsl_set_params(unsigned width, unsigned height,
|
|||||||
location = pglGetUniformLocation(gl_program[active_index], gl_teximage_uniforms[i]);
|
location = pglGetUniformLocation(gl_program[active_index], gl_teximage_uniforms[i]);
|
||||||
pglUniform1i(location, i + 1);
|
pglUniform1i(location, i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set original texture unless we're in first pass (pointless).
|
||||||
|
if (active_index > 1)
|
||||||
|
{
|
||||||
|
pglActiveTexture(GL_TEXTURE0 + gl_teximage_cnt + 1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, info->tex);
|
||||||
|
|
||||||
|
location = pglGetUniformLocation(gl_program[active_index], "rubyOrigTexture");
|
||||||
|
pglUniform1i(location, gl_teximage_cnt + 1);
|
||||||
|
|
||||||
|
location = pglGetUniformLocation(gl_program[active_index], "rubyOrigTextureSize");
|
||||||
|
pglUniform2fv(location, 1, info->tex_size);
|
||||||
|
location = pglGetUniformLocation(gl_program[active_index], "rubyOrigInputSize");
|
||||||
|
pglUniform2fv(location, 1, info->input_size);
|
||||||
|
|
||||||
|
// Pass texture coordinates.
|
||||||
|
location = pglGetAttribLocation(gl_program[active_index], "rubyOrigTexCoord");
|
||||||
|
if (location >= 0)
|
||||||
|
{
|
||||||
|
pglEnableVertexAttribArray(location);
|
||||||
|
pglVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, 0, info->coord);
|
||||||
|
}
|
||||||
|
|
||||||
|
pglActiveTexture(GL_TEXTURE0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pglActiveTexture(GL_TEXTURE0 + gl_teximage_cnt + 1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
pglActiveTexture(GL_TEXTURE0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ void gl_glsl_set_proj_matrix(void);
|
|||||||
void gl_glsl_set_params(unsigned width, unsigned height,
|
void gl_glsl_set_params(unsigned width, unsigned height,
|
||||||
unsigned tex_width, unsigned tex_height,
|
unsigned tex_width, unsigned tex_height,
|
||||||
unsigned out_width, unsigned out_height,
|
unsigned out_width, unsigned out_height,
|
||||||
unsigned frame_counter);
|
unsigned frame_counter,
|
||||||
|
const struct gl_tex_info *info);
|
||||||
|
|
||||||
void gl_glsl_use(unsigned index);
|
void gl_glsl_use(unsigned index);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user