Skip to content

Commit

Permalink
Fix element array bug
Browse files Browse the repository at this point in the history
BUG=164445


Review URL: https://chromiumcodereview.appspot.com/11450026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171748 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
gman@chromium.org committed Dec 7, 2012
1 parent c3cdc73 commit 9e7a2a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions gpu/command_buffer/client/vertex_array_object_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ void VertexArrayObject::UnbindBuffer(GLuint id) {
}
}
}
if (bound_element_array_buffer_id_ == id) {
bound_element_array_buffer_id_ = 0;
}
}

bool VertexArrayObject::BindElementArray(GLuint id) {
Expand Down
17 changes: 13 additions & 4 deletions gpu/command_buffer/client/vertex_array_object_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ TEST_F(VertexArrayObjectManagerTest, Basic) {
TEST_F(VertexArrayObjectManagerTest, UnbindBuffer) {
const GLuint kBufferToUnbind = 123;
const GLuint kBufferToRemain = 456;
const GLuint kElementArray = 789;
bool changed = false;
GLuint ids[2] = { 1, 3, };
manager_->GenVertexArrays(2, ids);
manager_->GenVertexArrays(arraysize(ids), ids);
// Bind buffers to attribs on 2 vaos.
for (size_t ii = 0; ii < arraysize(ids); ++ii) {
EXPECT_TRUE(manager_->BindVertexArray(ids[ii], &changed));
Expand All @@ -87,18 +88,23 @@ TEST_F(VertexArrayObjectManagerTest, UnbindBuffer) {
for (size_t jj = 0; jj < 4u; ++jj) {
manager_->SetAttribEnable(jj, true);
}
manager_->BindElementArray(kElementArray);
}
EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers());
EXPECT_TRUE(manager_->BindVertexArray(ids[0], &changed));
// Unbind the buffer.
manager_->UnbindBuffer(kBufferToUnbind);
manager_->UnbindBuffer(kElementArray);
// The attribs are still enabled but their buffer is 0.
EXPECT_TRUE(manager_->HaveEnabledClientSideBuffers());
// Check the status of the bindings.
uint32 expected[][4] = {
static const uint32 expected[][4] = {
{ 0, kBufferToRemain, 0, kBufferToRemain, },
{ kBufferToUnbind, kBufferToRemain, kBufferToUnbind, kBufferToRemain, },
};
static const GLuint expected_element_array[] = {
0, kElementArray,
};
for (size_t ii = 0; ii < arraysize(ids); ++ii) {
EXPECT_TRUE(manager_->BindVertexArray(ids[ii], &changed));
for (size_t jj = 0; jj < 4; ++jj) {
Expand All @@ -108,7 +114,10 @@ TEST_F(VertexArrayObjectManagerTest, UnbindBuffer) {
EXPECT_EQ(expected[ii][jj], param)
<< "id: " << ids[ii] << ", attrib: " << jj;
}
EXPECT_EQ(expected_element_array[ii],
manager_->bound_element_array_buffer());
}

// The vao that was not bound still has all service side bufferws.
EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers());
}
Expand Down Expand Up @@ -168,7 +177,7 @@ TEST_F(VertexArrayObjectManagerTest, HaveEnabledClientSideArrays) {
TEST_F(VertexArrayObjectManagerTest, BindElementArray) {
bool changed = false;
GLuint ids[2] = { 1, 3, };
manager_->GenVertexArrays(2, ids);
manager_->GenVertexArrays(arraysize(ids), ids);

// Check the default element array is 0.
EXPECT_EQ(0u, manager_->bound_element_array_buffer());
Expand Down Expand Up @@ -208,7 +217,7 @@ TEST_F(VertexArrayObjectManagerTest, GenBindDelete) {
EXPECT_FALSE(changed);

GLuint ids[2] = { 1, 3, };
manager_->GenVertexArrays(2, ids);
manager_->GenVertexArrays(arraysize(ids), ids);
// Check Genned arrays succeed.
EXPECT_TRUE(manager_->BindVertexArray(1, &changed));
EXPECT_TRUE(changed);
Expand Down

0 comments on commit 9e7a2a6

Please sign in to comment.