Merge pull request #34099 from akien-mga/gles3-polygon-buffer-orphaning-fix-2

Properly orphan polygon index buffer after binding (take 2)
This commit is contained in:
Rémi Verschelde 2019-12-04 12:29:50 +01:00 committed by GitHub
commit 73fb08289a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -479,9 +479,8 @@ void RasterizerCanvasGLES3::_draw_generic_indices(GLuint p_primitive, const int
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL #ifndef GLES_OVER_GL
// Orphan the buffers to avoid CPU/GPU sync points caused by glBufferSubData // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
#endif #endif
uint32_t buffer_ofs = 0; uint32_t buffer_ofs = 0;
@ -532,6 +531,10 @@ void RasterizerCanvasGLES3::_draw_generic_indices(GLuint p_primitive, const int
//bind the indices buffer. //bind the indices buffer.
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
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
//draw the triangles. //draw the triangles.