Chromium Code Reviews| Index: gpu/command_buffer/client/gles2_implementation.cc |
| diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc |
| index b4628a0b0735a2810c760d9044a84b2f0bb8768b..6eb03786a8197d7ccb623f5808c0aeeb2108ff41 100644 |
| --- a/gpu/command_buffer/client/gles2_implementation.cc |
| +++ b/gpu/command_buffer/client/gles2_implementation.cc |
| @@ -701,6 +701,15 @@ bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) { |
| return true; |
| } |
| return false; |
| + case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| + *params = capabilities_.max_uniform_buffer_bindings; |
| + return true; |
| + case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| + *params = capabilities_.max_transform_feedback_separate_attribs; |
| + return true; |
| + case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| + *params = capabilities_.uniform_buffer_offset_alignment; |
| + return true; |
| default: |
| return false; |
| } |
| @@ -2650,11 +2659,9 @@ void GLES2Implementation::BindBufferHelper( |
| bound_pixel_unpack_transfer_buffer_id_ = buffer_id; |
| break; |
| default: |
| - changed = true; |
| - break; |
| + SetGLErrorInvalidEnum("glBindBuffer", target, "target"); |
| + return; |
| } |
| - // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| - // used even though it's marked it as used here. |
| if (changed) { |
| GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
| this, target, buffer_id, &GLES2Implementation::BindBufferStub); |
| @@ -2670,8 +2677,28 @@ void GLES2Implementation::BindBufferStub(GLenum target, GLuint buffer) { |
| void GLES2Implementation::BindBufferBaseHelper( |
| GLenum target, GLuint index, GLuint buffer_id) { |
| // TODO(zmo): See note #1 above. |
| - // TODO(zmo): There's a bug here. If the target or index is invalid the ID |
| - // will not be used even though it's marked it as used here. |
| + switch (target) { |
| + case GL_TRANSFORM_FEEDBACK_BUFFER: |
| + if (index >= static_cast<GLuint>( |
| + capabilities_.max_transform_feedback_separate_attribs)) { |
| + SetGLError(GL_INVALID_VALUE, "glBindBufferBase", |
| + "index larger than max limit"); |
| + return; |
| + } |
| + break; |
| + case GL_UNIFORM_BUFFER: |
| + if (index >= |
| + static_cast<GLuint>(capabilities_.max_uniform_buffer_bindings)) { |
| + SetGLError(GL_INVALID_VALUE, "glBindBufferBase", |
| + "index larger than max limit"); |
| + return; |
| + } |
| + break; |
| + default: |
| + SetGLErrorInvalidEnum("glBindBufferBase", target, "target"); |
| + return; |
| + } |
| + |
| GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
| this, target, index, buffer_id, &GLES2Implementation::BindBufferBaseStub); |
| } |
| @@ -2687,8 +2714,44 @@ void GLES2Implementation::BindBufferRangeHelper( |
| GLenum target, GLuint index, GLuint buffer_id, |
| GLintptr offset, GLsizeiptr size) { |
| // TODO(zmo): See note #1 above. |
| - // TODO(zmo): There's a bug here. If an arguments is invalid the ID will not |
| - // be used even though it's marked it as used here. |
| + switch (target) { |
| + case GL_TRANSFORM_FEEDBACK_BUFFER: |
| + if (index >= static_cast<GLuint>( |
| + capabilities_.max_transform_feedback_separate_attribs)) { |
| + SetGLError(GL_INVALID_VALUE, "glBindBufferRange", |
| + "index larget than max limit"); |
| + return; |
| + } |
| + if (offset % 4 != 0 || size % 4 != 0) { |
| + SetGLError(GL_INVALID_VALUE, "glBindBufferRange", |
| + "offset and size must be multiples of 4"); |
| + return; |
| + } |
| + break; |
| + case GL_UNIFORM_BUFFER: |
| + if (index >= |
| + static_cast<GLuint>(capabilities_.max_uniform_buffer_bindings)) { |
| + SetGLError(GL_INVALID_VALUE, "glBindBufferRange", |
| + "index larger than max limit"); |
| + return; |
| + } |
| + if (capabilities_.uniform_buffer_offset_alignment != 0 && |
| + offset % capabilities_.uniform_buffer_offset_alignment != 0) { |
| + SetGLError(GL_INVALID_VALUE, "glBindBufferRange", |
| + "offset must be multiples of alignment"); |
| + return; |
| + } |
| + break; |
| + default: |
| + SetGLErrorInvalidEnum("glBindBufferRange", target, "target"); |
| + return; |
| + } |
| + if (buffer_id != 0 && size <= 0) { |
| + SetGLError(GL_INVALID_VALUE, "glBindBufferRange", |
| + "size must be larger than 0"); |
| + return; |
| + } |
| + |
| GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
| this, target, index, buffer_id, offset, size, |
| &GLES2Implementation::BindBufferRangeStub); |
| @@ -2765,11 +2828,9 @@ void GLES2Implementation::BindRenderbufferHelper( |
| } |
| break; |
| default: |
| - changed = true; |
| - break; |
| + SetGLErrorInvalidEnum("glBindRenderbuffer", target, "target"); |
| + return; |
| } |
| - // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| - // used even though it's marked it as used here. |
| if (changed) { |
| GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind( |
| this, target, renderbuffer, |
| @@ -2815,11 +2876,9 @@ void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { |
| } |
| break; |
| default: |
| - changed = true; |
| - break; |
| + SetGLErrorInvalidEnum("glBindTexture", target, "target."); |
| + return; |
| } |
| - // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| - // used. even though it's marked it as used here. |
|
piman
2015/02/04 00:43:19
note: this is still true. For example, we don't kn
|
| if (changed) { |
| GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind( |
| this, target, texture, &GLES2Implementation::BindTextureStub); |
| @@ -2838,7 +2897,6 @@ void GLES2Implementation::BindTransformFeedbackHelper( |
| } |
| void GLES2Implementation::BindVertexArrayOESHelper(GLuint array) { |
| - // TODO(gman): See note #1 above. |
| bool changed = false; |
| if (vertex_array_object_manager_->BindVertexArray(array, &changed)) { |
| if (changed) { |
| @@ -2866,11 +2924,9 @@ void GLES2Implementation::BindValuebufferCHROMIUMHelper(GLenum target, |
| } |
| break; |
| default: |
| - changed = true; |
| - break; |
| + SetGLErrorInvalidEnum("glBindValuebufferCHROMIUM", target, "target"); |
| + return; |
| } |
| - // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| - // used even though it's marked it as used here. |
| if (changed) { |
| GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind( |
| this, target, valuebuffer, |