|
@@ -430,14 +430,10 @@ void RasterizerCanvasBaseGLES2::_copy_texscreen(const Rect2 &p_rect) {
|
|
void RasterizerCanvasBaseGLES2::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) {
|
|
void RasterizerCanvasBaseGLES2::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) {
|
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
|
-#ifndef GLES_OVER_GL
|
|
|
|
- // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
|
|
|
|
- glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
uint32_t buffer_ofs = 0;
|
|
uint32_t buffer_ofs = 0;
|
|
|
|
+ storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
|
|
|
|
|
|
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
|
|
|
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
|
@@ -482,13 +478,9 @@ void RasterizerCanvasBaseGLES2::_draw_polygon(const int *p_indices, int p_index_
|
|
}
|
|
}
|
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
|
|
-#ifndef GLES_OVER_GL
|
|
|
|
- // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
|
|
|
|
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
if (storage->config.support_32_bits_indices) { //should check for
|
|
if (storage->config.support_32_bits_indices) { //should check for
|
|
- glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
|
|
|
|
|
|
+ storage->buffer_orphan_and_upload(data.polygon_index_buffer_size, 0, sizeof(int) * p_index_count, p_indices, GL_ELEMENT_ARRAY_BUFFER);
|
|
glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_INT, 0);
|
|
glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_INT, 0);
|
|
storage->info.render._2d_draw_call_count++;
|
|
storage->info.render._2d_draw_call_count++;
|
|
} else {
|
|
} else {
|
|
@@ -496,7 +488,7 @@ void RasterizerCanvasBaseGLES2::_draw_polygon(const int *p_indices, int p_index_
|
|
for (int i = 0; i < p_index_count; i++) {
|
|
for (int i = 0; i < p_index_count; i++) {
|
|
index16[i] = uint16_t(p_indices[i]);
|
|
index16[i] = uint16_t(p_indices[i]);
|
|
}
|
|
}
|
|
- glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(uint16_t) * p_index_count, index16);
|
|
|
|
|
|
+ storage->buffer_orphan_and_upload(data.polygon_index_buffer_size, 0, sizeof(uint16_t) * p_index_count, index16, GL_ELEMENT_ARRAY_BUFFER);
|
|
glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_SHORT, 0);
|
|
glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_SHORT, 0);
|
|
storage->info.render._2d_draw_call_count++;
|
|
storage->info.render._2d_draw_call_count++;
|
|
}
|
|
}
|
|
@@ -508,14 +500,10 @@ void RasterizerCanvasBaseGLES2::_draw_polygon(const int *p_indices, int p_index_
|
|
void RasterizerCanvasBaseGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
|
void RasterizerCanvasBaseGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
|
-#ifndef GLES_OVER_GL
|
|
|
|
- // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
|
|
|
|
- glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
uint32_t buffer_ofs = 0;
|
|
uint32_t buffer_ofs = 0;
|
|
|
|
+ storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
|
|
|
|
|
|
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
|
|
|
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
|
@@ -551,14 +539,10 @@ void RasterizerCanvasBaseGLES2::_draw_generic(GLuint p_primitive, int p_vertex_c
|
|
void RasterizerCanvasBaseGLES2::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
|
void RasterizerCanvasBaseGLES2::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
|
-#ifndef GLES_OVER_GL
|
|
|
|
- // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
|
|
|
|
- glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
uint32_t buffer_ofs = 0;
|
|
uint32_t buffer_ofs = 0;
|
|
|
|
+ storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
|
|
|
|
|
|
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
|
|
|
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
|
@@ -587,13 +571,9 @@ void RasterizerCanvasBaseGLES2::_draw_generic_indices(GLuint p_primitive, const
|
|
}
|
|
}
|
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
|
|
-#ifndef GLES_OVER_GL
|
|
|
|
- // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
|
|
|
|
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
if (storage->config.support_32_bits_indices) { //should check for
|
|
if (storage->config.support_32_bits_indices) { //should check for
|
|
- glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
|
|
|
|
|
|
+ storage->buffer_orphan_and_upload(data.polygon_index_buffer_size, 0, sizeof(int) * p_index_count, p_indices, GL_ELEMENT_ARRAY_BUFFER);
|
|
glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_INT, 0);
|
|
glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_INT, 0);
|
|
storage->info.render._2d_draw_call_count++;
|
|
storage->info.render._2d_draw_call_count++;
|
|
} else {
|
|
} else {
|
|
@@ -601,7 +581,7 @@ void RasterizerCanvasBaseGLES2::_draw_generic_indices(GLuint p_primitive, const
|
|
for (int i = 0; i < p_index_count; i++) {
|
|
for (int i = 0; i < p_index_count; i++) {
|
|
index16[i] = uint16_t(p_indices[i]);
|
|
index16[i] = uint16_t(p_indices[i]);
|
|
}
|
|
}
|
|
- glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(uint16_t) * p_index_count, index16);
|
|
|
|
|
|
+ storage->buffer_orphan_and_upload(data.polygon_index_buffer_size, 0, sizeof(uint16_t) * p_index_count, index16, GL_ELEMENT_ARRAY_BUFFER);
|
|
glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_SHORT, 0);
|
|
glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_SHORT, 0);
|
|
storage->info.render._2d_draw_call_count++;
|
|
storage->info.render._2d_draw_call_count++;
|
|
}
|
|
}
|
|
@@ -664,11 +644,7 @@ void RasterizerCanvasBaseGLES2::_draw_gui_primitive(int p_points, const Vector2
|
|
}
|
|
}
|
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
|
-#ifndef GLES_OVER_GL
|
|
|
|
- // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
|
|
|
|
- glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
|
|
|
-#endif
|
|
|
|
- glBufferSubData(GL_ARRAY_BUFFER, 0, p_points * stride * 4 * sizeof(float), buffer_data);
|
|
|
|
|
|
+ storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, p_points * stride * 4 * sizeof(float), buffer_data);
|
|
|
|
|
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL);
|
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL);
|
|
|
|
|