diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index 55ce4fdcd1..5f45573408 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -100,13 +100,16 @@ typedef struct cg_shader_data { struct shader_program_cg_data prg[GFX_MAX_SHADERS]; unsigned active_idx; - unsigned cg_attrib_idx; + struct + { + CGparameter elems[32 * PREV_TEXTURES + 2 + 4 + GFX_MAX_SHADERS]; + unsigned index; + } attribs; CGprofile cgVProf; CGprofile cgFProf; struct video_shader *shader; state_tracker_t *state_tracker; GLuint lut_textures[GFX_MAX_TEXTURES]; - CGparameter cg_attribs[32 * PREV_TEXTURES + 2 + 4 + GFX_MAX_SHADERS]; char cg_alias_define[GFX_MAX_SHADERS][128]; CGcontext cgCtx; } cg_shader_data_t; @@ -220,11 +223,11 @@ static void gl_cg_reset_attrib(void *data) cg_shader_data_t *cg_data = (cg_shader_data_t*)data; /* Add sanity check that we did not overflow. */ - retro_assert(cg_data->cg_attrib_idx <= ARRAY_SIZE(cg_data->cg_attribs)); + retro_assert(cg_data->attribs.index <= ARRAY_SIZE(cg_data->attribs.elems)); - for (i = 0; i < cg_data->cg_attrib_idx; i++) - cgGLDisableClientState(cg_data->cg_attribs[i]); - cg_data->cg_attrib_idx = 0; + for (i = 0; i < cg_data->attribs.index; i++) + cgGLDisableClientState(cg_data->attribs.elems[i]); + cg_data->attribs.index = 0; } static bool gl_cg_set_mvp(void *data, void *shader_data, const math_matrix_4x4 *mat) @@ -246,7 +249,7 @@ fallback: { \ cgGLSetParameterPointer(cg_data->prg[cg_data->active_idx].name, len, GL_FLOAT, 0, coords->coords_name); \ cgGLEnableClientState(cg_data->prg[cg_data->active_idx].name); \ - cg_data->cg_attribs[cg_data->cg_attrib_idx++] = cg_data->prg[cg_data->active_idx].name; \ + cg_data->attribs.elems[cg_data->attribs.index++] = cg_data->prg[cg_data->active_idx].name; \ } \ } while(0) @@ -321,7 +324,7 @@ static void gl_cg_set_texture_info( cgGLSetParameterPointer(params->coord, 2, GL_FLOAT, 0, info->coord); cgGLEnableClientState(params->coord); - cg_data->cg_attribs[cg_data->cg_attrib_idx++] = params->coord; + cg_data->attribs.elems[cg_data->attribs.index++] = params->coord; } } diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 5fa30d931e..24fc29761d 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -134,10 +134,14 @@ typedef struct glsl_shader_data struct cache_vbo vbo[GFX_MAX_SHADERS]; char glsl_alias_define[1024]; unsigned glsl_active_index; - unsigned gl_attrib_index; + struct + { + GLint elems[PREV_TEXTURES + 2 + 4 + GFX_MAX_SHADERS]; + unsigned index; + } attribs; + struct shader_program_glsl_data prg[GFX_MAX_SHADERS]; GLuint gl_teximage[GFX_MAX_TEXTURES]; - GLint gl_attribs[PREV_TEXTURES + 2 + 4 + GFX_MAX_SHADERS]; state_tracker_t *gl_state_tracker; } glsl_shader_data_t; @@ -457,11 +461,11 @@ static void gl_glsl_reset_attrib(glsl_shader_data_t *glsl) unsigned i; /* Add sanity check that we did not overflow. */ - retro_assert(glsl->gl_attrib_index <= ARRAY_SIZE(glsl->gl_attribs)); + retro_assert(glsl->attribs.index <= ARRAY_SIZE(glsl->attribs.elems)); - for (i = 0; i < glsl->gl_attrib_index; i++) - glDisableVertexAttribArray(glsl->gl_attribs[i]); - glsl->gl_attrib_index = 0; + for (i = 0; i < glsl->attribs.index; i++) + glDisableVertexAttribArray(glsl->attribs.elems[i]); + glsl->attribs.index = 0; } static void gl_glsl_set_vbo(GLfloat **buffer, size_t *buffer_elems, @@ -501,12 +505,12 @@ static void gl_glsl_set_attribs(glsl_shader_data_t *glsl, { GLint loc = attrs[i].loc; - if (glsl->gl_attrib_index < ARRAY_SIZE(glsl->gl_attribs)) + if (glsl->attribs.index < ARRAY_SIZE(glsl->attribs.elems)) { glEnableVertexAttribArray(loc); glVertexAttribPointer(loc, attrs[i].size, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)(uintptr_t)attrs[i].offset); - glsl->gl_attribs[glsl->gl_attrib_index++] = loc; + glsl->attribs.elems[glsl->attribs.index++] = loc; } else RARCH_WARN("Attrib array buffer was overflown!\n");