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

Side by Side Diff: gpu/command_buffer/client/vertex_array_object_manager_unittest.cc

Issue 1131273005: Fine tune vertex attrib commands handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: working Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/client/vertex_array_object_manager.h" 5 #include "gpu/command_buffer/client/vertex_array_object_manager.h"
6 6
7 #include <GLES2/gl2ext.h> 7 #include <GLES2/gl2ext.h>
8 #include <GLES3/gl3.h>
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 namespace gpu { 11 namespace gpu {
11 namespace gles2 { 12 namespace gles2 {
12 13
13 class VertexArrayObjectManagerTest : public testing::Test { 14 class VertexArrayObjectManagerTest : public testing::Test {
14 protected: 15 protected:
15 static const GLuint kMaxAttribs = 4; 16 static const GLuint kMaxAttribs = 4;
16 static const GLuint kClientSideArrayBuffer = 0x1234; 17 static const GLuint kClientSideArrayBuffer = 0x1234;
17 static const GLuint kClientSideElementArrayBuffer = 0x1235; 18 static const GLuint kClientSideElementArrayBuffer = 0x1235;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const GLuint kBufferToUnbind = 123; 73 const GLuint kBufferToUnbind = 123;
73 const GLuint kBufferToRemain = 456; 74 const GLuint kBufferToRemain = 456;
74 const GLuint kElementArray = 789; 75 const GLuint kElementArray = 789;
75 bool changed = false; 76 bool changed = false;
76 GLuint ids[2] = { 1, 3, }; 77 GLuint ids[2] = { 1, 3, };
77 manager_->GenVertexArrays(arraysize(ids), ids); 78 manager_->GenVertexArrays(arraysize(ids), ids);
78 // Bind buffers to attribs on 2 vaos. 79 // Bind buffers to attribs on 2 vaos.
79 for (size_t ii = 0; ii < arraysize(ids); ++ii) { 80 for (size_t ii = 0; ii < arraysize(ids); ++ii) {
80 EXPECT_TRUE(manager_->BindVertexArray(ids[ii], &changed)); 81 EXPECT_TRUE(manager_->BindVertexArray(ids[ii], &changed));
81 EXPECT_TRUE(manager_->SetAttribPointer( 82 EXPECT_TRUE(manager_->SetAttribPointer(
82 kBufferToUnbind, 0, 4, GL_FLOAT, false, 0, 0)); 83 kBufferToUnbind, 0, 4, GL_FLOAT, false, 0, 0, GL_FALSE));
83 EXPECT_TRUE(manager_->SetAttribPointer( 84 EXPECT_TRUE(manager_->SetAttribPointer(
84 kBufferToRemain, 1, 4, GL_FLOAT, false, 0, 0)); 85 kBufferToRemain, 1, 4, GL_FLOAT, false, 0, 0, GL_FALSE));
85 EXPECT_TRUE(manager_->SetAttribPointer( 86 EXPECT_TRUE(manager_->SetAttribPointer(
86 kBufferToUnbind, 2, 4, GL_FLOAT, false, 0, 0)); 87 kBufferToUnbind, 2, 4, GL_FLOAT, false, 0, 0, GL_FALSE));
87 EXPECT_TRUE(manager_->SetAttribPointer( 88 EXPECT_TRUE(manager_->SetAttribPointer(
88 kBufferToRemain, 3, 4, GL_FLOAT, false, 0, 0)); 89 kBufferToRemain, 3, 4, GL_FLOAT, false, 0, 0, GL_FALSE));
89 for (size_t jj = 0; jj < 4u; ++jj) { 90 for (size_t jj = 0; jj < 4u; ++jj) {
90 manager_->SetAttribEnable(jj, true); 91 manager_->SetAttribEnable(jj, true);
91 } 92 }
92 manager_->BindElementArray(kElementArray); 93 manager_->BindElementArray(kElementArray);
93 } 94 }
94 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers()); 95 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers());
95 EXPECT_TRUE(manager_->BindVertexArray(ids[0], &changed)); 96 EXPECT_TRUE(manager_->BindVertexArray(ids[0], &changed));
96 // Unbind the buffer. 97 // Unbind the buffer.
97 manager_->UnbindBuffer(kBufferToUnbind); 98 manager_->UnbindBuffer(kBufferToUnbind);
98 manager_->UnbindBuffer(kElementArray); 99 manager_->UnbindBuffer(kElementArray);
(...skipping 29 matching lines...) Expand all
128 manager_->SetAttribEnable(2, true); 129 manager_->SetAttribEnable(2, true);
129 manager_->UnbindBuffer(0); 130 manager_->UnbindBuffer(0);
130 manager_->SetAttribEnable(2, false); 131 manager_->SetAttribEnable(2, false);
131 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers()); 132 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers());
132 } 133 }
133 134
134 TEST_F(VertexArrayObjectManagerTest, GetSet) { 135 TEST_F(VertexArrayObjectManagerTest, GetSet) {
135 const char* dummy = "dummy"; 136 const char* dummy = "dummy";
136 const void* p = reinterpret_cast<const void*>(dummy); 137 const void* p = reinterpret_cast<const void*>(dummy);
137 manager_->SetAttribEnable(1, true); 138 manager_->SetAttribEnable(1, true);
138 manager_->SetAttribPointer(123, 1, 3, GL_BYTE, true, 3, p); 139 manager_->SetAttribPointer(123, 1, 3, GL_BYTE, true, 3, p, GL_TRUE);
139 uint32 param; 140 uint32 param;
140 void* ptr; 141 void* ptr;
141 EXPECT_TRUE(manager_->GetVertexAttrib( 142 EXPECT_TRUE(manager_->GetVertexAttrib(
142 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &param)); 143 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &param));
143 EXPECT_EQ(123u, param); 144 EXPECT_EQ(123u, param);
144 EXPECT_TRUE(manager_->GetVertexAttrib( 145 EXPECT_TRUE(manager_->GetVertexAttrib(
145 1, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &param)); 146 1, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &param));
146 EXPECT_NE(0u, param); 147 EXPECT_NE(0u, param);
147 EXPECT_TRUE(manager_->GetVertexAttrib( 148 EXPECT_TRUE(manager_->GetVertexAttrib(
148 1, GL_VERTEX_ATTRIB_ARRAY_SIZE, &param)); 149 1, GL_VERTEX_ATTRIB_ARRAY_SIZE, &param));
149 EXPECT_EQ(3u, param); 150 EXPECT_EQ(3u, param);
150 EXPECT_TRUE(manager_->GetVertexAttrib( 151 EXPECT_TRUE(manager_->GetVertexAttrib(
151 1, GL_VERTEX_ATTRIB_ARRAY_TYPE, &param)); 152 1, GL_VERTEX_ATTRIB_ARRAY_TYPE, &param));
152 EXPECT_EQ(static_cast<uint32>(GL_BYTE), param); 153 EXPECT_EQ(static_cast<uint32>(GL_BYTE), param);
153 EXPECT_TRUE(manager_->GetVertexAttrib( 154 EXPECT_TRUE(manager_->GetVertexAttrib(
154 1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &param)); 155 1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &param));
155 EXPECT_NE(0u, param); 156 EXPECT_NE(0u, param);
157 EXPECT_TRUE(manager_->GetVertexAttrib(
158 1, GL_VERTEX_ATTRIB_ARRAY_INTEGER, &param));
159 EXPECT_EQ(1u, param);
156 EXPECT_TRUE(manager_->GetAttribPointer( 160 EXPECT_TRUE(manager_->GetAttribPointer(
157 1, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr)); 161 1, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr));
158 EXPECT_EQ(p, ptr); 162 EXPECT_EQ(p, ptr);
159 163
160 // Check that getting the divisor is passed to the service. 164 // Check that getting the divisor is passed to the service.
161 // This is because the divisor is an optional feature which 165 // This is because the divisor is an optional feature which
162 // only the service can validate. 166 // only the service can validate.
163 EXPECT_FALSE(manager_->GetVertexAttrib( 167 EXPECT_FALSE(manager_->GetVertexAttrib(
164 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE, &param)); 168 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE, &param));
165 } 169 }
166 170
167 TEST_F(VertexArrayObjectManagerTest, HaveEnabledClientSideArrays) { 171 TEST_F(VertexArrayObjectManagerTest, HaveEnabledClientSideArrays) {
168 // Check turning on an array. 172 // Check turning on an array.
169 manager_->SetAttribEnable(1, true); 173 manager_->SetAttribEnable(1, true);
170 EXPECT_TRUE(manager_->HaveEnabledClientSideBuffers()); 174 EXPECT_TRUE(manager_->HaveEnabledClientSideBuffers());
171 // Check turning off an array. 175 // Check turning off an array.
172 manager_->SetAttribEnable(1, false); 176 manager_->SetAttribEnable(1, false);
173 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers()); 177 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers());
174 // Check turning on an array and assigning a buffer. 178 // Check turning on an array and assigning a buffer.
175 manager_->SetAttribEnable(1, true); 179 manager_->SetAttribEnable(1, true);
176 manager_->SetAttribPointer(123, 1, 3, GL_BYTE, true, 3, NULL); 180 manager_->SetAttribPointer(123, 1, 3, GL_BYTE, true, 3, NULL, GL_FALSE);
177 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers()); 181 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers());
178 // Check unassigning a buffer. 182 // Check unassigning a buffer.
179 manager_->SetAttribPointer(0, 1, 3, GL_BYTE, true, 3, NULL); 183 manager_->SetAttribPointer(0, 1, 3, GL_BYTE, true, 3, NULL, GL_FALSE);
180 EXPECT_TRUE(manager_->HaveEnabledClientSideBuffers()); 184 EXPECT_TRUE(manager_->HaveEnabledClientSideBuffers());
181 // Check disabling the array. 185 // Check disabling the array.
182 manager_->SetAttribEnable(1, false); 186 manager_->SetAttribEnable(1, false);
183 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers()); 187 EXPECT_FALSE(manager_->HaveEnabledClientSideBuffers());
184 } 188 }
185 189
186 TEST_F(VertexArrayObjectManagerTest, BindElementArray) { 190 TEST_F(VertexArrayObjectManagerTest, BindElementArray) {
187 bool changed = false; 191 bool changed = false;
188 GLuint ids[2] = { 1, 3, }; 192 GLuint ids[2] = { 1, 3, };
189 manager_->GenVertexArrays(arraysize(ids), ids); 193 manager_->GenVertexArrays(arraysize(ids), ids);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 EXPECT_TRUE(manager_->IsReservedId(kClientSideArrayBuffer)); 258 EXPECT_TRUE(manager_->IsReservedId(kClientSideArrayBuffer));
255 EXPECT_TRUE(manager_->IsReservedId(kClientSideElementArrayBuffer)); 259 EXPECT_TRUE(manager_->IsReservedId(kClientSideElementArrayBuffer));
256 EXPECT_FALSE(manager_->IsReservedId(0)); 260 EXPECT_FALSE(manager_->IsReservedId(0));
257 EXPECT_FALSE(manager_->IsReservedId(1)); 261 EXPECT_FALSE(manager_->IsReservedId(1));
258 EXPECT_FALSE(manager_->IsReservedId(2)); 262 EXPECT_FALSE(manager_->IsReservedId(2));
259 } 263 }
260 264
261 } // namespace gles2 265 } // namespace gles2
262 } // namespace gpu 266 } // namespace gpu
263 267
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/vertex_array_object_manager.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698