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

Unified Diff: gpu/command_buffer/service/vertex_attrib_manager.cc

Issue 2435803004: Initialize buffers before allowing access to them. (Closed)
Patch Set: win failure Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/vertex_attrib_manager.cc
diff --git a/gpu/command_buffer/service/vertex_attrib_manager.cc b/gpu/command_buffer/service/vertex_attrib_manager.cc
index 6336c5462d1bebaea112143923626b74b38c1558..abaecea39018b6c13321f7ab7fa10c9becb41b36 100644
--- a/gpu/command_buffer/service/vertex_attrib_manager.cc
+++ b/gpu/command_buffer/service/vertex_attrib_manager.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
@@ -76,10 +77,7 @@ bool VertexAttrib::CanAccess(GLuint index) const {
return true;
}
- if (!buffer_.get() || buffer_->IsDeleted()) {
- return false;
- }
-
+ DCHECK(buffer_.get() && !buffer_->IsDeleted());
// The number of elements that can be accessed.
GLsizeiptr buffer_size = buffer_->size();
if (offset_ > buffer_size || real_stride_ == 0) {
@@ -182,6 +180,7 @@ bool VertexAttribManager::ValidateBindings(
const char* function_name,
GLES2Decoder* decoder,
FeatureInfo* feature_info,
+ BufferManager* buffer_manager,
Program* current_program,
GLuint max_vertex_accessed,
bool instanced,
@@ -202,6 +201,13 @@ bool VertexAttribManager::ValidateBindings(
for (VertexAttribList::iterator it = enabled_vertex_attribs_.begin();
it != enabled_vertex_attribs_.end(); ++it) {
VertexAttrib* attrib = *it;
+ Buffer* buffer = attrib->buffer();
+ std::string msg_tag = base::StringPrintf(
+ "attached to enabled attrib %u", attrib->index());
+ if (!buffer_manager->RequestBufferAccess(
+ error_state, buffer, function_name, msg_tag.c_str())) {
+ return false;
+ }
const Program::VertexAttrib* attrib_info =
current_program->GetAttribInfoByLocation(attrib->index());
if (attrib_info) {
@@ -218,7 +224,6 @@ bool VertexAttribManager::ValidateBindings(
return false;
}
if (use_client_side_arrays_for_stream_buffers) {
- Buffer* buffer = attrib->buffer();
glEnableVertexAttribArray(attrib->index());
if (buffer->IsClientSideArray()) {
if (current_buffer_id != 0) {
@@ -254,16 +259,7 @@ bool VertexAttribManager::ValidateBindings(
}
} else {
// This attrib is not used in the current program.
- if (!attrib->buffer()) {
- ERRORSTATE_SET_GL_ERROR(
- error_state, GL_INVALID_OPERATION, function_name,
- (std::string(
- "attempt to render with no buffer attached to "
- "enabled attribute ") +
- base::UintToString(attrib->index())).c_str());
- return false;
- } else if (use_client_side_arrays_for_stream_buffers) {
- Buffer* buffer = attrib->buffer();
+ if (use_client_side_arrays_for_stream_buffers) {
// Disable client side arrays for unused attributes else we'll
// read bad memory
if (buffer->IsClientSideArray()) {

Powered by Google App Engine
This is Rietveld 408576698