summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 02:16:31 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 02:16:31 +0000
commit6c788fb783b855d5af6374e2649b9a3e7d99cedf (patch)
tree9d04da2412a3f3aa1110690a24d53e7b9f7a43f5 /gpu/command_buffer/service
parent4d34a6b3003d963621790d7fb74094de35cd7bf5 (diff)
downloadchromium_src-6c788fb783b855d5af6374e2649b9a3e7d99cedf.zip
chromium_src-6c788fb783b855d5af6374e2649b9a3e7d99cedf.tar.gz
chromium_src-6c788fb783b855d5af6374e2649b9a3e7d99cedf.tar.bz2
Fix issue with count=0 for DrawArrays and DrawElements
TEST=unit tests BUG=52752 Review URL: http://codereview.chromium.org/3180025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc9
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc26
2 files changed, 35 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 7fdb582..6940f8d 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -2839,6 +2839,11 @@ void GLES2DecoderImpl::DoDrawArrays(
SetGLError(GL_INVALID_ENUM, "glDrawArrays: first < 0");
return;
}
+
+ if (count == 0) {
+ return;
+ }
+
if (IsDrawValid(first + count - 1)) {
bool simulated_attrib_0 = SimulateAttrib0(first + count - 1);
bool textures_set = SetBlackTextureForNonRenderableTextures();
@@ -3602,6 +3607,10 @@ error::Error GLES2DecoderImpl::HandleDrawElements(
return error::kNoError;
}
+ if (count == 0) {
+ return error::kNoError;
+ }
+
GLuint max_vertex_accessed;
if (!bound_element_array_buffer_->GetMaxValueForRange(
offset, count, type, &max_vertex_accessed)) {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index c282507..c929847 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -131,6 +131,18 @@ TEST_F(GLES2DecoderWithShaderTest, DrawArraysMissingAttributesFails) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
+TEST_F(GLES2DecoderWithShaderTest,
+ DrawArraysMissingAttributesZeroCountSucceeds) {
+ DoEnableVertexAttribArray(1);
+
+ EXPECT_CALL(*gl_, DrawArrays(_, _, _))
+ .Times(0);
+ DrawArrays cmd;
+ cmd.Init(GL_TRIANGLES, 0, 0);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+
TEST_F(GLES2DecoderWithShaderTest, DrawArraysValidAttributesSucceeds) {
SetupTexture();
SetupVertexBuffer();
@@ -256,6 +268,20 @@ TEST_F(GLES2DecoderWithShaderTest, DrawElementsMissingAttributesFails) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
+TEST_F(GLES2DecoderWithShaderTest,
+ DrawElementsMissingAttributesZeroCountSucceeds) {
+ SetupIndexBuffer();
+ DoEnableVertexAttribArray(1);
+
+ EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
+ .Times(0);
+ DrawElements cmd;
+ cmd.Init(GL_TRIANGLES, 0, GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+
TEST_F(GLES2DecoderWithShaderTest, DrawElementsExtraAttributesFails) {
SetupIndexBuffer();
DoEnableVertexAttribArray(6);