Commit 30a1acd5 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Use a fixed sized buffer for simulated attrib 0 uploads

This avoids allocating arbitrary large buffers, which could fail or cause
unnecessary fragmentation.

Bug: 844854
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ib7f0f14628fdb26c7efad08c26aba77d4b20095c
Reviewed-on: https://chromium-review.googlesource.com/1096296Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566981}
parent 99231f82
...@@ -10411,8 +10411,16 @@ bool GLES2DecoderImpl::SimulateAttrib0( ...@@ -10411,8 +10411,16 @@ bool GLES2DecoderImpl::SimulateAttrib0(
// casting to float type, but it is a corner case and once we migrate to // casting to float type, but it is a corner case and once we migrate to
// core profiles on desktop GL, it is no longer relevant. // core profiles on desktop GL, it is no longer relevant.
Vec4f fvalue(value); Vec4f fvalue(value);
std::vector<Vec4f> temp(num_vertices, fvalue); constexpr GLuint kMaxVerticesPerLoop = 32u << 10;
api()->glBufferSubDataFn(GL_ARRAY_BUFFER, 0, size_needed, &temp[0].v[0]); const GLuint vertices_per_loop =
std::min(num_vertices, kMaxVerticesPerLoop);
std::vector<Vec4f> temp(vertices_per_loop, fvalue);
for (GLuint offset = 0; offset < num_vertices;) {
size_t count = std::min(num_vertices - offset, vertices_per_loop);
api()->glBufferSubDataFn(GL_ARRAY_BUFFER, offset * sizeof(Vec4f),
count * sizeof(Vec4f), temp.data());
offset += count;
}
attrib_0_buffer_matches_value_ = true; attrib_0_buffer_matches_value_ = true;
attrib_0_value_ = value; attrib_0_value_ = value;
attrib_0_size_ = size_needed; attrib_0_size_ = size_needed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment