Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Side by Side Diff: gpu/command_buffer/client/vertex_array_object_manager.cc

Issue 1708983002: Command buffer: Fix bugs for drawing when the type of vertex attrib is a packed type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/client/vertex_array_object_manager.h" 5 #include "gpu/command_buffer/client/vertex_array_object_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 508 }
509 *simulated = true; 509 *simulated = true;
510 GLsizei total_size = 0; 510 GLsizei total_size = 0;
511 // Compute the size of the buffer we need. 511 // Compute the size of the buffer we need.
512 const VertexArrayObject::VertexAttribs& vertex_attribs = 512 const VertexArrayObject::VertexAttribs& vertex_attribs =
513 bound_vertex_array_object_->vertex_attribs(); 513 bound_vertex_array_object_->vertex_attribs();
514 for (GLuint ii = 0; ii < vertex_attribs.size(); ++ii) { 514 for (GLuint ii = 0; ii < vertex_attribs.size(); ++ii) {
515 const VertexArrayObject::VertexAttrib& attrib = vertex_attribs[ii]; 515 const VertexArrayObject::VertexAttrib& attrib = vertex_attribs[ii];
516 if (attrib.IsClientSide() && attrib.enabled()) { 516 if (attrib.IsClientSide() && attrib.enabled()) {
517 size_t bytes_per_element = 517 size_t bytes_per_element =
518 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(attrib.type()) * 518 GLES2Util::GetGroupSizeForBufferType(attrib.size(), attrib.type());
519 attrib.size();
520 GLsizei elements = (primcount && attrib.divisor() > 0) ? 519 GLsizei elements = (primcount && attrib.divisor() > 0) ?
521 ((primcount - 1) / attrib.divisor() + 1) : num_elements; 520 ((primcount - 1) / attrib.divisor() + 1) : num_elements;
522 total_size += RoundUpToMultipleOf4(bytes_per_element * elements); 521 total_size += RoundUpToMultipleOf4(bytes_per_element * elements);
523 } 522 }
524 } 523 }
525 gl_helper->BindBuffer(GL_ARRAY_BUFFER, array_buffer_id_); 524 gl_helper->BindBuffer(GL_ARRAY_BUFFER, array_buffer_id_);
526 array_buffer_offset_ = 0; 525 array_buffer_offset_ = 0;
527 if (total_size > array_buffer_size_) { 526 if (total_size > array_buffer_size_) {
528 gl->BufferDataHelper(GL_ARRAY_BUFFER, total_size, NULL, GL_DYNAMIC_DRAW); 527 gl->BufferDataHelper(GL_ARRAY_BUFFER, total_size, NULL, GL_DYNAMIC_DRAW);
529 array_buffer_size_ = total_size; 528 array_buffer_size_ = total_size;
530 } 529 }
531 for (GLuint ii = 0; ii < vertex_attribs.size(); ++ii) { 530 for (GLuint ii = 0; ii < vertex_attribs.size(); ++ii) {
532 const VertexArrayObject::VertexAttrib& attrib = vertex_attribs[ii]; 531 const VertexArrayObject::VertexAttrib& attrib = vertex_attribs[ii];
533 if (attrib.IsClientSide() && attrib.enabled()) { 532 if (attrib.IsClientSide() && attrib.enabled()) {
534 size_t bytes_per_element = 533 size_t bytes_per_element =
535 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(attrib.type()) * 534 GLES2Util::GetGroupSizeForBufferType(attrib.size(), attrib.type());
536 attrib.size();
537 GLsizei real_stride = attrib.stride() ? 535 GLsizei real_stride = attrib.stride() ?
538 attrib.stride() : static_cast<GLsizei>(bytes_per_element); 536 attrib.stride() : static_cast<GLsizei>(bytes_per_element);
539 GLsizei elements = (primcount && attrib.divisor() > 0) ? 537 GLsizei elements = (primcount && attrib.divisor() > 0) ?
540 ((primcount - 1) / attrib.divisor() + 1) : num_elements; 538 ((primcount - 1) / attrib.divisor() + 1) : num_elements;
541 GLsizei bytes_collected = CollectData( 539 GLsizei bytes_collected = CollectData(
542 attrib.pointer(), bytes_per_element, real_stride, elements); 540 attrib.pointer(), bytes_per_element, real_stride, elements);
543 gl->BufferSubDataHelper( 541 gl->BufferSubDataHelper(
544 GL_ARRAY_BUFFER, array_buffer_offset_, bytes_collected, 542 GL_ARRAY_BUFFER, array_buffer_offset_, bytes_collected,
545 collection_buffer_.get()); 543 collection_buffer_.get());
546 gl_helper->VertexAttribPointer( 544 gl_helper->VertexAttribPointer(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if (signed_index > max_index) { 607 if (signed_index > max_index) {
610 max_index = signed_index; 608 max_index = signed_index;
611 } 609 }
612 } 610 }
613 break; 611 break;
614 } 612 }
615 default: 613 default:
616 break; 614 break;
617 } 615 }
618 gl_helper->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, element_array_buffer_id_); 616 gl_helper->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, element_array_buffer_id_);
619 GLsizei bytes_per_element = 617 GLsizei bytes_per_element = GLES2Util::GetGLTypeSizeForBuffers(type);
620 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type);
621 GLsizei bytes_needed = bytes_per_element * count; 618 GLsizei bytes_needed = bytes_per_element * count;
622 if (bytes_needed > element_array_buffer_size_) { 619 if (bytes_needed > element_array_buffer_size_) {
623 element_array_buffer_size_ = bytes_needed; 620 element_array_buffer_size_ = bytes_needed;
624 gl->BufferDataHelper( 621 gl->BufferDataHelper(
625 GL_ELEMENT_ARRAY_BUFFER, bytes_needed, NULL, GL_DYNAMIC_DRAW); 622 GL_ELEMENT_ARRAY_BUFFER, bytes_needed, NULL, GL_DYNAMIC_DRAW);
626 } 623 }
627 gl->BufferSubDataHelper( 624 gl->BufferSubDataHelper(
628 GL_ELEMENT_ARRAY_BUFFER, 0, bytes_needed, indices); 625 GL_ELEMENT_ARRAY_BUFFER, 0, bytes_needed, indices);
629 626
630 num_elements = max_index + 1; 627 num_elements = max_index + 1;
(...skipping 12 matching lines...) Expand all
643 function_name, gl, gl_helper, num_elements, primcount, 640 function_name, gl, gl_helper, num_elements, primcount,
644 &simulated_client_side_buffers); 641 &simulated_client_side_buffers);
645 *simulated = *simulated || simulated_client_side_buffers; 642 *simulated = *simulated || simulated_client_side_buffers;
646 return true; 643 return true;
647 } 644 }
648 645
649 } // namespace gles2 646 } // namespace gles2
650 } // namespace gpu 647 } // namespace gpu
651 648
652 649
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698