mirror of
https://github.com/libretro/RetroArch
synced 2025-03-04 07:13:26 +00:00
Merge pull request #3987 from heuripedes/shader-things
(shader_glsl.c) Don't allocate/clear more than needed in gl_glsl_set_coords()
This commit is contained in:
commit
4e901457a2
@ -1354,17 +1354,26 @@ static bool gl_glsl_set_coords(void *handle_data, void *shader_data, const struc
|
||||
if (!glsl || !glsl->shader->modern || !coords)
|
||||
goto fallback;
|
||||
|
||||
attr = attribs;
|
||||
uni = &glsl->uniforms[glsl->active_idx];
|
||||
|
||||
buffer = short_buffer;
|
||||
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)
|
||||
goto fallback;
|
||||
|
||||
attr = attribs;
|
||||
uni = &glsl->uniforms[glsl->active_idx];
|
||||
|
||||
if (uni->tex_coord >= 0)
|
||||
gl_glsl_set_coord_array(attr, uni->tex_coord, coords->tex_coord, coords, size, 2);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user