mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
(shader_glsl.c) Don't allocate/clear more than needed in gl_glsl_set_coords()
This commit is contained in:
parent
8551cc4f9b
commit
8977968b6d
@ -1354,17 +1354,26 @@ static bool gl_glsl_set_coords(void *handle_data, void *shader_data, const struc
|
|||||||
if (!glsl || !glsl->shader->modern || !coords)
|
if (!glsl || !glsl->shader->modern || !coords)
|
||||||
goto fallback;
|
goto fallback;
|
||||||
|
|
||||||
|
attr = attribs;
|
||||||
|
uni = &glsl->uniforms[glsl->active_idx];
|
||||||
|
|
||||||
buffer = short_buffer;
|
buffer = short_buffer;
|
||||||
if (coords->vertices > 4)
|
if (coords->vertices > 4)
|
||||||
buffer = (GLfloat*)calloc(coords->vertices *
|
{
|
||||||
(2 + 2 + 4 + 2), sizeof(*buffer));
|
size_t elems = 0;
|
||||||
|
elems += (uni->color >= 0) * 4;
|
||||||
|
elems += (uni->tex_coord >= 0) * 2;
|
||||||
|
elems += (uni->vertex_coord >= 0) * 2;
|
||||||
|
elems += (uni->lut_tex_coord >= 0) * 2;
|
||||||
|
|
||||||
|
elems *= coords->vertices * sizeof(GLfloat);
|
||||||
|
|
||||||
|
buffer = (GLfloat*)malloc(elems);
|
||||||
|
}
|
||||||
|
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
goto fallback;
|
goto fallback;
|
||||||
|
|
||||||
attr = attribs;
|
|
||||||
uni = &glsl->uniforms[glsl->active_idx];
|
|
||||||
|
|
||||||
if (uni->tex_coord >= 0)
|
if (uni->tex_coord >= 0)
|
||||||
gl_glsl_set_coord_array(attr, uni->tex_coord, coords->tex_coord, coords, size, 2);
|
gl_glsl_set_coord_array(attr, uni->tex_coord, coords->tex_coord, coords, size, 2);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user