mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Disable used attributes on shader change.
This commit is contained in:
parent
45fa6795c3
commit
face42a888
@ -66,6 +66,7 @@
|
|||||||
#define pglGetAttachedShaders glGetAttachedShaders
|
#define pglGetAttachedShaders glGetAttachedShaders
|
||||||
#define pglGetAttribLocation glGetAttribLocation
|
#define pglGetAttribLocation glGetAttribLocation
|
||||||
#define pglEnableVertexAttribArray glEnableVertexAttribArray
|
#define pglEnableVertexAttribArray glEnableVertexAttribArray
|
||||||
|
#define pglDisableVertexAttribArray glDisableVertexAttribArray
|
||||||
#define pglVertexAttribPointer glVertexAttribPointer
|
#define pglVertexAttribPointer glVertexAttribPointer
|
||||||
#else
|
#else
|
||||||
static PFNGLCREATEPROGRAMPROC pglCreateProgram = NULL;
|
static PFNGLCREATEPROGRAMPROC pglCreateProgram = NULL;
|
||||||
@ -90,6 +91,7 @@ static PFNGLDELETEPROGRAMPROC pglDeleteProgram = NULL;
|
|||||||
static PFNGLGETATTACHEDSHADERSPROC pglGetAttachedShaders = NULL;
|
static PFNGLGETATTACHEDSHADERSPROC pglGetAttachedShaders = NULL;
|
||||||
static PFNGLGETATTRIBLOCATIONPROC pglGetAttribLocation = NULL;
|
static PFNGLGETATTRIBLOCATIONPROC pglGetAttribLocation = NULL;
|
||||||
static PFNGLENABLEVERTEXATTRIBARRAYPROC pglEnableVertexAttribArray = NULL;
|
static PFNGLENABLEVERTEXATTRIBARRAYPROC pglEnableVertexAttribArray = NULL;
|
||||||
|
static PFNGLDISABLEVERTEXATTRIBARRAYPROC pglDisableVertexAttribArray = NULL;
|
||||||
static PFNGLVERTEXATTRIBPOINTERPROC pglVertexAttribPointer = NULL;
|
static PFNGLVERTEXATTRIBPOINTERPROC pglVertexAttribPointer = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -123,6 +125,10 @@ static char gl_tracker_script[256];
|
|||||||
static char gl_tracker_script_class[64];
|
static char gl_tracker_script_class[64];
|
||||||
static xmlChar *gl_script_program = NULL;
|
static xmlChar *gl_script_program = NULL;
|
||||||
|
|
||||||
|
static GLint gl_attribs[PREV_TEXTURES + 1 + MAX_PROGRAMS];
|
||||||
|
static unsigned gl_attrib_index = 0;
|
||||||
|
|
||||||
|
|
||||||
struct shader_program
|
struct shader_program
|
||||||
{
|
{
|
||||||
char *vertex;
|
char *vertex;
|
||||||
@ -841,6 +847,13 @@ static bool compile_programs(GLuint *gl_prog, struct shader_program *progs, size
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gl_glsl_reset_attrib(void)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < gl_attrib_index; i++)
|
||||||
|
pglDisableVertexAttribArray(gl_attribs[i]);
|
||||||
|
gl_attrib_index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#define LOAD_GL_SYM(SYM) if (!pgl##SYM) { SDL_SYM_WRAP(pgl##SYM, "gl" #SYM) }
|
#define LOAD_GL_SYM(SYM) if (!pgl##SYM) { SDL_SYM_WRAP(pgl##SYM, "gl" #SYM) }
|
||||||
|
|
||||||
bool gl_glsl_init(const char *path)
|
bool gl_glsl_init(const char *path)
|
||||||
@ -869,6 +882,7 @@ bool gl_glsl_init(const char *path)
|
|||||||
LOAD_GL_SYM(GetAttachedShaders);
|
LOAD_GL_SYM(GetAttachedShaders);
|
||||||
LOAD_GL_SYM(GetAttribLocation);
|
LOAD_GL_SYM(GetAttribLocation);
|
||||||
LOAD_GL_SYM(EnableVertexAttribArray);
|
LOAD_GL_SYM(EnableVertexAttribArray);
|
||||||
|
LOAD_GL_SYM(DisableVertexAttribArray);
|
||||||
LOAD_GL_SYM(VertexAttribPointer);
|
LOAD_GL_SYM(VertexAttribPointer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -882,7 +896,7 @@ bool gl_glsl_init(const char *path)
|
|||||||
&& pglUniform1i && pglUniform1f && pglUniform2fv && pglUniform4fv
|
&& pglUniform1i && pglUniform1f && pglUniform2fv && pglUniform4fv
|
||||||
&& pglGetShaderiv && pglGetShaderInfoLog && pglGetProgramiv && pglGetProgramInfoLog
|
&& pglGetShaderiv && pglGetShaderInfoLog && pglGetProgramiv && pglGetProgramInfoLog
|
||||||
&& pglDeleteProgram && pglGetAttachedShaders
|
&& pglDeleteProgram && pglGetAttachedShaders
|
||||||
&& pglGetAttribLocation && pglEnableVertexAttribArray
|
&& pglGetAttribLocation && pglEnableVertexAttribArray && pglDisableVertexAttribArray
|
||||||
&& pglVertexAttribPointer;
|
&& pglVertexAttribPointer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -974,6 +988,9 @@ bool gl_glsl_init(const char *path)
|
|||||||
glsl_enable = true;
|
glsl_enable = true;
|
||||||
gl_num_programs = num_progs;
|
gl_num_programs = num_progs;
|
||||||
gl_program[gl_num_programs + 1] = gl_program[0];
|
gl_program[gl_num_programs + 1] = gl_program[0];
|
||||||
|
|
||||||
|
gl_glsl_reset_attrib();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,6 +1040,8 @@ void gl_glsl_deinit(void)
|
|||||||
snes_tracker_free(gl_snes_tracker);
|
snes_tracker_free(gl_snes_tracker);
|
||||||
gl_snes_tracker = NULL;
|
gl_snes_tracker = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gl_glsl_reset_attrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_glsl_set_params(unsigned width, unsigned height,
|
void gl_glsl_set_params(unsigned width, unsigned height,
|
||||||
@ -1092,6 +1111,7 @@ void gl_glsl_set_params(unsigned width, unsigned height,
|
|||||||
{
|
{
|
||||||
pglEnableVertexAttribArray(location);
|
pglEnableVertexAttribArray(location);
|
||||||
pglVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, 0, info->coord);
|
pglVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, 0, info->coord);
|
||||||
|
gl_attribs[gl_attrib_index++] = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind new texture in the chain.
|
// Bind new texture in the chain.
|
||||||
@ -1124,6 +1144,7 @@ void gl_glsl_set_params(unsigned width, unsigned height,
|
|||||||
{
|
{
|
||||||
pglEnableVertexAttribArray(location);
|
pglEnableVertexAttribArray(location);
|
||||||
pglVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, 0, fbo_info[i].coord);
|
pglVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, 0, fbo_info[i].coord);
|
||||||
|
gl_attribs[gl_attrib_index++] = location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1186,6 +1207,7 @@ void gl_glsl_set_params(unsigned width, unsigned height,
|
|||||||
{
|
{
|
||||||
pglEnableVertexAttribArray(location);
|
pglEnableVertexAttribArray(location);
|
||||||
pglVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, 0, prev_info[i].coord);
|
pglVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, 0, prev_info[i].coord);
|
||||||
|
gl_attribs[gl_attrib_index++] = location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1214,6 +1236,8 @@ void gl_glsl_use(unsigned index)
|
|||||||
{
|
{
|
||||||
if (glsl_enable)
|
if (glsl_enable)
|
||||||
{
|
{
|
||||||
|
gl_glsl_reset_attrib();
|
||||||
|
|
||||||
active_index = index;
|
active_index = index;
|
||||||
pglUseProgram(gl_program[index]);
|
pglUseProgram(gl_program[index]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user