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

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

Issue 7866006: Revert 100453 - Revert "Revert 100384 - Fix bug in SimulateAttrib0 that did not check for out of ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
===================================================================
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 100472)
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy)
@@ -1064,9 +1064,8 @@
// Checks if the current program and vertex attributes are valid for drawing.
bool IsDrawValid(GLuint max_vertex_accessed);
- // Returns true if successful, simulated will be true if attrib0 was
- // simulated.
- bool SimulateAttrib0(GLuint max_vertex_accessed, bool* simulated);
+ // Returns true if attrib0 was simulated.
+ bool SimulateAttrib0(GLuint max_vertex_accessed);
void RestoreStateForSimulatedAttrib0();
// Returns true if textures were set.
@@ -4263,46 +4262,30 @@
return true;
}
-bool GLES2DecoderImpl::SimulateAttrib0(
- GLuint max_vertex_accessed, bool* simulated) {
- DCHECK(simulated);
- *simulated = false;
-
+bool GLES2DecoderImpl::SimulateAttrib0(GLuint max_vertex_accessed) {
if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
- return true;
+ return false;
const VertexAttribManager::VertexAttribInfo* info =
vertex_attrib_manager_.GetVertexAttribInfo(0);
// If it's enabled or it's not used then we don't need to do anything.
bool attrib_0_used = current_program_->GetAttribInfoByLocation(0) != NULL;
if (info->enabled() && attrib_0_used) {
- return true;
+ return false;
}
- // Make a buffer with a single repeated vec4 value enough to
- // simulate the constant value that is supposed to be here.
- // This is required to emulate GLES2 on GL.
typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4;
- GLsizei num_vertices = max_vertex_accessed + 1;
- GLsizei size_needed = 0;
-
- if (num_vertices < 0 || !SafeMultiply(
- num_vertices, static_cast<GLsizei>(sizeof(Vec4)), &size_needed)) {
- SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0");
- return false;
- }
-
- CopyRealGLErrorsToWrapper();
glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_);
+ // Make a buffer with a single repeated vec4 value enough to
+ // simulate the constant value that is supposed to be here.
+ // This is required to emulate GLES2 on GL.
+ GLsizei num_vertices = max_vertex_accessed + 1;
+ GLsizei size_needed = num_vertices * sizeof(Vec4); // NOLINT
if (size_needed > attrib_0_size_) {
glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW);
- GLenum error = glGetError();
- if (error != GL_NO_ERROR) {
- SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0");
- return false;
- }
+ // TODO(gman): check for error here?
attrib_0_buffer_matches_value_ = false;
}
if (attrib_0_used &&
@@ -4320,7 +4303,6 @@
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL);
- *simulated = true;
return true;
}
@@ -4355,12 +4337,7 @@
// tests so we just add to the buffer attrib used.
// Compute the number of elements needed.
- GLsizei num_vertices = max_vertex_accessed + 1;
- if (num_vertices < 0) {
- SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0");
- return false;
- }
-
+ int num_vertices = max_vertex_accessed + 1;
int elements_needed = 0;
const VertexAttribManager::VertexAttribInfoList& infos =
vertex_attrib_manager_.GetEnabledVertexAttribInfos();
@@ -4390,16 +4367,10 @@
return false;
}
- CopyRealGLErrorsToWrapper();
glBindBuffer(GL_ARRAY_BUFFER, fixed_attrib_buffer_id_);
if (size_needed > fixed_attrib_buffer_size_) {
glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW);
- GLenum error = glGetError();
- if (error != GL_NO_ERROR) {
- SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: simulating GL_FIXED attribs");
- return false;
- }
}
// Copy the elements and convert to float
@@ -4469,10 +4440,7 @@
GLuint max_vertex_accessed = first + count - 1;
if (IsDrawValid(max_vertex_accessed)) {
- bool simulated_attrib_0 = false;
- if (!SimulateAttrib0(max_vertex_accessed, &simulated_attrib_0)) {
- return error::kNoError;
- }
+ bool simulated_attrib_0 = SimulateAttrib0(max_vertex_accessed);
bool simulated_fixed_attribs = false;
if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs)) {
bool textures_set = SetBlackTextureForNonRenderableTextures();
@@ -4543,10 +4511,7 @@
}
if (IsDrawValid(max_vertex_accessed)) {
- bool simulated_attrib_0 = false;
- if (!SimulateAttrib0(max_vertex_accessed, &simulated_attrib_0)) {
- return error::kNoError;
- }
+ bool simulated_attrib_0 = SimulateAttrib0(max_vertex_accessed);
bool simulated_fixed_attribs = false;
if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs)) {
bool textures_set = SetBlackTextureForNonRenderableTextures();
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698