mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-25 08:59:58 +00:00
106 lines
3.8 KiB
Diff
106 lines
3.8 KiB
Diff
diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c
|
|
index 203f0c6..6cb5f9a 100644
|
|
--- a/gfx/drivers_shader/shader_glsl.c
|
|
+++ b/gfx/drivers_shader/shader_glsl.c
|
|
@@ -1330,15 +1330,13 @@ fallback:
|
|
|
|
#define gl_glsl_set_coord_array(attr, coord1, coord2, coords, size, multiplier) \
|
|
{ \
|
|
- unsigned y; \
|
|
- attr->loc = coord1; \
|
|
- attr->size = multiplier; \
|
|
- attr->offset = size * sizeof(GLfloat); \
|
|
- attribs_size++; \
|
|
- attr++; \
|
|
- for (y = 0; y < (multiplier * coords->vertices); y++) \
|
|
- buffer[y + size] = coord2[y]; \
|
|
- size += multiplier * coords->vertices; \
|
|
+ attr->loc = coord1; \
|
|
+ attr->size = multiplier; \
|
|
+ attr->offset = size * sizeof(GLfloat); \
|
|
+ attribs_size++; \
|
|
+ glBufferSubData(GL_ARRAY_BUFFER, attr->offset, multiplier * coords->vertices * sizeof(GLfloat), coord2); \
|
|
+ size += multiplier * coords->vertices; \
|
|
+ attr++; \
|
|
}
|
|
|
|
static bool gl_glsl_set_coords(void *handle_data, void *shader_data, const struct video_coords *coords)
|
|
@@ -1357,35 +1355,56 @@ static bool gl_glsl_set_coords(void *handle_data, void *shader_data, const struc
|
|
goto fallback;
|
|
|
|
buffer = short_buffer;
|
|
- if (coords->vertices > 4)
|
|
- buffer = (GLfloat*)calloc(coords->vertices *
|
|
- (2 + 2 + 4 + 2), sizeof(*buffer));
|
|
-
|
|
- 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);
|
|
+ glBindBuffer(GL_ARRAY_BUFFER, glsl->vbo[glsl->active_idx].vbo_primary);
|
|
+ {
|
|
+ size_t i;
|
|
+ size_t elems = 0;
|
|
|
|
- if (uni->vertex_coord >= 0)
|
|
- gl_glsl_set_coord_array(attr, uni->vertex_coord, coords->vertex, coords, size, 2);
|
|
+ elems += (uni->color >= 0) * 4;
|
|
+ elems += (uni->tex_coord >= 0) * 2;
|
|
+ elems += (uni->vertex_coord >= 0) * 2;
|
|
+ elems += (uni->lut_tex_coord >= 0) * 2;
|
|
|
|
- if (uni->color >= 0)
|
|
- gl_glsl_set_coord_array(attr, uni->color, coords->color, coords, size, 4);
|
|
+ elems *= coords->vertices;
|
|
|
|
- if (uni->lut_tex_coord >= 0)
|
|
- gl_glsl_set_coord_array(attr, uni->lut_tex_coord, coords->lut_tex_coord, coords, size, 2);
|
|
+ if (elems) {
|
|
|
|
- if (size)
|
|
- gl_glsl_set_attribs(glsl,
|
|
- glsl->vbo[glsl->active_idx].vbo_primary,
|
|
- &glsl->vbo[glsl->active_idx].buffer_primary,
|
|
- &glsl->vbo[glsl->active_idx].size_primary,
|
|
- buffer, size,
|
|
- attribs, attribs_size);
|
|
+ glBufferData(GL_ARRAY_BUFFER, elems * sizeof(GLfloat), NULL, GL_STREAM_DRAW);
|
|
+
|
|
+ if (uni->tex_coord >= 0)
|
|
+ gl_glsl_set_coord_array(attr, uni->tex_coord, coords->tex_coord, coords, size, 2);
|
|
+
|
|
+ if (uni->vertex_coord >= 0)
|
|
+ gl_glsl_set_coord_array(attr, uni->vertex_coord, coords->vertex, coords, size, 2);
|
|
+
|
|
+ if (uni->color >= 0)
|
|
+ gl_glsl_set_coord_array(attr, uni->color, coords->color, coords, size, 4);
|
|
+
|
|
+ if (uni->lut_tex_coord >= 0)
|
|
+ gl_glsl_set_coord_array(attr, uni->lut_tex_coord, coords->lut_tex_coord, coords, size, 2);
|
|
+
|
|
+ for (i = 0; i < attribs_size; i++)
|
|
+ {
|
|
+ GLint loc = attribs[i].loc;
|
|
+
|
|
+ if (glsl->attribs.index < ARRAY_SIZE(glsl->attribs.elems))
|
|
+ {
|
|
+ glEnableVertexAttribArray(loc);
|
|
+ glVertexAttribPointer(loc, attribs[i].size, GL_FLOAT, GL_FALSE, 0,
|
|
+ (const GLvoid*)(uintptr_t)attribs[i].offset);
|
|
+ glsl->attribs.elems[glsl->attribs.index++] = loc;
|
|
+ }
|
|
+ else
|
|
+ RARCH_WARN("Attrib array buffer was overflown!\n");
|
|
+ }
|
|
+ }
|
|
+
|
|
+ }
|
|
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
if (buffer != short_buffer)
|
|
free(buffer);
|