Skip to content

Commit

Permalink
Fix incorrect buffer upload size in GLES2 draw_gui_primitive
Browse files Browse the repository at this point in the history
The buffer upload size appears to have been incorrect for quite some time, which causes uploading from undefined memory.

(cherry picked from commit 3dc0e97)
  • Loading branch information
lawnjelly authored and akien-mga committed Mar 11, 2022
1 parent ecac71f commit 6c3cfc7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/gles2/rasterizer_canvas_base_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ void RasterizerCanvasBaseGLES2::_draw_gui_primitive(int p_points, const Vector2
}

glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, p_points * stride * 4 * sizeof(float), buffer_data, GL_ARRAY_BUFFER, _buffer_upload_usage_flag, true);
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, p_points * stride * sizeof(float), buffer_data, GL_ARRAY_BUFFER, _buffer_upload_usage_flag, true);

glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), nullptr);

Expand Down
3 changes: 1 addition & 2 deletions drivers/gles3/rasterizer_canvas_base_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,7 @@ void RasterizerCanvasBaseGLES3::_draw_gui_primitive(int p_points, const Vector2
}

glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
//TODO the below call may need to be replaced with: p_points * stride * 4 * sizeof(float), &b[0]);
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, p_points * stride * 4, &b[0], GL_ARRAY_BUFFER, _buffer_upload_usage_flag);
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, p_points * stride * sizeof(float), &b[0], GL_ARRAY_BUFFER, _buffer_upload_usage_flag);

glBindVertexArray(data.polygon_buffer_quad_arrays[version]);
glDrawArrays(prim[p_points], 0, p_points);
Expand Down

0 comments on commit 6c3cfc7

Please sign in to comment.