OLD | NEW |
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/service/gles2_cmd_decoder_unittest.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 init.gl_version = "3.0"; | 65 init.gl_version = "3.0"; |
66 init.bind_generates_resource = true; | 66 init.bind_generates_resource = true; |
67 InitDecoderWithCommandLine(init, &command_line); | 67 InitDecoderWithCommandLine(init, &command_line); |
68 SetupDefaultProgram(); | 68 SetupDefaultProgram(); |
69 } | 69 } |
70 | 70 |
71 // Override default setup so nothing gets setup. | 71 // Override default setup so nothing gets setup. |
72 void GLES2DecoderManualInitTest::SetUp() { | 72 void GLES2DecoderManualInitTest::SetUp() { |
73 } | 73 } |
74 | 74 |
75 TEST_F(GLES2DecoderTest, GetIntegervCached) { | 75 void GLES2DecoderManualInitTest::EnableDisableTest(GLenum cap, |
| 76 bool enable, |
| 77 bool expect_set) { |
| 78 if (expect_set) { |
| 79 SetupExpectationsForEnableDisable(cap, enable); |
| 80 } |
| 81 if (enable) { |
| 82 Enable cmd; |
| 83 cmd.Init(cap); |
| 84 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 85 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 86 } else { |
| 87 Disable cmd; |
| 88 cmd.Init(cap); |
| 89 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 90 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 91 } |
| 92 } |
| 93 |
| 94 TEST_P(GLES2DecoderTest, GetIntegervCached) { |
76 struct TestInfo { | 95 struct TestInfo { |
77 GLenum pname; | 96 GLenum pname; |
78 GLint expected; | 97 GLint expected; |
79 }; | 98 }; |
80 TestInfo tests[] = { | 99 TestInfo tests[] = { |
81 { | 100 { |
82 GL_MAX_TEXTURE_SIZE, TestHelper::kMaxTextureSize, | 101 GL_MAX_TEXTURE_SIZE, TestHelper::kMaxTextureSize, |
83 }, | 102 }, |
84 { | 103 { |
85 GL_MAX_CUBE_MAP_TEXTURE_SIZE, TestHelper::kMaxCubeMapTextureSize, | 104 GL_MAX_CUBE_MAP_TEXTURE_SIZE, TestHelper::kMaxCubeMapTextureSize, |
(...skipping 15 matching lines...) Expand all Loading... |
101 GetIntegerv cmd2; | 120 GetIntegerv cmd2; |
102 cmd2.Init(test.pname, shared_memory_id_, shared_memory_offset_); | 121 cmd2.Init(test.pname, shared_memory_id_, shared_memory_offset_); |
103 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 122 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
104 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(test.pname), | 123 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(test.pname), |
105 result->GetNumResults()); | 124 result->GetNumResults()); |
106 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 125 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
107 EXPECT_EQ(test.expected, result->GetData()[0]); | 126 EXPECT_EQ(test.expected, result->GetData()[0]); |
108 } | 127 } |
109 } | 128 } |
110 | 129 |
111 TEST_F(GLES2DecoderWithShaderTest, GetMaxValueInBufferCHROMIUM) { | 130 TEST_P(GLES2DecoderWithShaderTest, GetMaxValueInBufferCHROMIUM) { |
112 SetupIndexBuffer(); | 131 SetupIndexBuffer(); |
113 GetMaxValueInBufferCHROMIUM::Result* result = | 132 GetMaxValueInBufferCHROMIUM::Result* result = |
114 static_cast<GetMaxValueInBufferCHROMIUM::Result*>(shared_memory_address_); | 133 static_cast<GetMaxValueInBufferCHROMIUM::Result*>(shared_memory_address_); |
115 *result = 0; | 134 *result = 0; |
116 | 135 |
117 GetMaxValueInBufferCHROMIUM cmd; | 136 GetMaxValueInBufferCHROMIUM cmd; |
118 cmd.Init(client_element_buffer_id_, | 137 cmd.Init(client_element_buffer_id_, |
119 kValidIndexRangeCount, | 138 kValidIndexRangeCount, |
120 GL_UNSIGNED_SHORT, | 139 GL_UNSIGNED_SHORT, |
121 kValidIndexRangeStart * 2, | 140 kValidIndexRangeStart * 2, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 201 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
183 cmd.Init(client_element_buffer_id_, | 202 cmd.Init(client_element_buffer_id_, |
184 kValidIndexRangeCount + 1, | 203 kValidIndexRangeCount + 1, |
185 GL_UNSIGNED_SHORT, | 204 GL_UNSIGNED_SHORT, |
186 kValidIndexRangeStart * 2, | 205 kValidIndexRangeStart * 2, |
187 kSharedMemoryId, | 206 kSharedMemoryId, |
188 kInvalidSharedMemoryOffset); | 207 kInvalidSharedMemoryOffset); |
189 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 208 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
190 } | 209 } |
191 | 210 |
192 TEST_F(GLES2DecoderTest, SharedIds) { | 211 TEST_P(GLES2DecoderTest, SharedIds) { |
193 GenSharedIdsCHROMIUM gen_cmd; | 212 GenSharedIdsCHROMIUM gen_cmd; |
194 RegisterSharedIdsCHROMIUM reg_cmd; | 213 RegisterSharedIdsCHROMIUM reg_cmd; |
195 DeleteSharedIdsCHROMIUM del_cmd; | 214 DeleteSharedIdsCHROMIUM del_cmd; |
196 | 215 |
197 const GLuint kNamespaceId = id_namespaces::kTextures; | 216 const GLuint kNamespaceId = id_namespaces::kTextures; |
198 const GLuint kExpectedId1 = 1; | 217 const GLuint kExpectedId1 = 1; |
199 const GLuint kExpectedId2 = 2; | 218 const GLuint kExpectedId2 = 2; |
200 const GLuint kExpectedId3 = 4; | 219 const GLuint kExpectedId3 = 4; |
201 const GLuint kRegisterId = 3; | 220 const GLuint kRegisterId = 3; |
202 GLuint* ids = GetSharedMemoryAs<GLuint*>(); | 221 GLuint* ids = GetSharedMemoryAs<GLuint*>(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 272 |
254 // Check passing in an id_offset. | 273 // Check passing in an id_offset. |
255 ClearSharedMemory(); | 274 ClearSharedMemory(); |
256 const GLuint kOffset = 0xABCDEF; | 275 const GLuint kOffset = 0xABCDEF; |
257 gen_cmd.Init(kNamespaceId, kOffset, 2, kSharedMemoryId, kSharedMemoryOffset); | 276 gen_cmd.Init(kNamespaceId, kOffset, 2, kSharedMemoryId, kSharedMemoryOffset); |
258 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); | 277 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
259 EXPECT_EQ(kOffset, ids[0]); | 278 EXPECT_EQ(kOffset, ids[0]); |
260 EXPECT_EQ(kOffset + 1, ids[1]); | 279 EXPECT_EQ(kOffset + 1, ids[1]); |
261 } | 280 } |
262 | 281 |
263 TEST_F(GLES2DecoderTest, GenSharedIdsCHROMIUMBadArgs) { | 282 TEST_P(GLES2DecoderTest, GenSharedIdsCHROMIUMBadArgs) { |
264 const GLuint kNamespaceId = id_namespaces::kTextures; | 283 const GLuint kNamespaceId = id_namespaces::kTextures; |
265 GenSharedIdsCHROMIUM cmd; | 284 GenSharedIdsCHROMIUM cmd; |
266 cmd.Init(kNamespaceId, 0, -1, kSharedMemoryId, kSharedMemoryOffset); | 285 cmd.Init(kNamespaceId, 0, -1, kSharedMemoryId, kSharedMemoryOffset); |
267 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 286 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
268 cmd.Init(kNamespaceId, 0, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); | 287 cmd.Init(kNamespaceId, 0, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); |
269 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 288 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
270 cmd.Init(kNamespaceId, 0, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); | 289 cmd.Init(kNamespaceId, 0, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); |
271 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 290 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
272 } | 291 } |
273 | 292 |
274 TEST_F(GLES2DecoderTest, RegisterSharedIdsCHROMIUMBadArgs) { | 293 TEST_P(GLES2DecoderTest, RegisterSharedIdsCHROMIUMBadArgs) { |
275 const GLuint kNamespaceId = id_namespaces::kTextures; | 294 const GLuint kNamespaceId = id_namespaces::kTextures; |
276 RegisterSharedIdsCHROMIUM cmd; | 295 RegisterSharedIdsCHROMIUM cmd; |
277 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); | 296 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); |
278 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 297 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
279 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); | 298 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); |
280 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 299 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
281 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); | 300 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); |
282 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 301 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
283 } | 302 } |
284 | 303 |
285 TEST_F(GLES2DecoderTest, RegisterSharedIdsCHROMIUMDuplicateIds) { | 304 TEST_P(GLES2DecoderTest, RegisterSharedIdsCHROMIUMDuplicateIds) { |
286 const GLuint kNamespaceId = id_namespaces::kTextures; | 305 const GLuint kNamespaceId = id_namespaces::kTextures; |
287 const GLuint kRegisterId = 3; | 306 const GLuint kRegisterId = 3; |
288 RegisterSharedIdsCHROMIUM cmd; | 307 RegisterSharedIdsCHROMIUM cmd; |
289 GLuint* ids = GetSharedMemoryAs<GLuint*>(); | 308 GLuint* ids = GetSharedMemoryAs<GLuint*>(); |
290 ids[0] = kRegisterId; | 309 ids[0] = kRegisterId; |
291 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); | 310 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); |
292 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 311 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
293 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); | 312 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); |
294 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 313 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
295 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 314 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
296 } | 315 } |
297 | 316 |
298 TEST_F(GLES2DecoderTest, DeleteSharedIdsCHROMIUMBadArgs) { | 317 TEST_P(GLES2DecoderTest, DeleteSharedIdsCHROMIUMBadArgs) { |
299 const GLuint kNamespaceId = id_namespaces::kTextures; | 318 const GLuint kNamespaceId = id_namespaces::kTextures; |
300 DeleteSharedIdsCHROMIUM cmd; | 319 DeleteSharedIdsCHROMIUM cmd; |
301 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); | 320 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); |
302 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 321 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
303 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); | 322 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); |
304 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 323 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
305 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); | 324 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); |
306 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 325 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
307 } | 326 } |
308 | 327 |
309 TEST_F(GLES2DecoderTest, IsBuffer) { | 328 TEST_P(GLES2DecoderTest, IsBuffer) { |
310 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); | 329 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); |
311 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); | 330 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); |
312 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); | 331 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); |
313 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); | 332 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); |
314 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); | 333 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); |
315 } | 334 } |
316 | 335 |
317 TEST_F(GLES2DecoderTest, IsFramebuffer) { | 336 TEST_P(GLES2DecoderTest, IsFramebuffer) { |
318 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); | 337 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); |
319 DoBindFramebuffer( | 338 DoBindFramebuffer( |
320 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 339 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
321 EXPECT_TRUE(DoIsFramebuffer(client_framebuffer_id_)); | 340 EXPECT_TRUE(DoIsFramebuffer(client_framebuffer_id_)); |
322 DoDeleteFramebuffer(client_framebuffer_id_, | 341 DoDeleteFramebuffer(client_framebuffer_id_, |
323 kServiceFramebufferId, | 342 kServiceFramebufferId, |
324 true, | 343 true, |
325 GL_FRAMEBUFFER, | 344 GL_FRAMEBUFFER, |
326 0, | 345 0, |
327 true, | 346 true, |
328 GL_FRAMEBUFFER, | 347 GL_FRAMEBUFFER, |
329 0); | 348 0); |
330 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); | 349 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); |
331 } | 350 } |
332 | 351 |
333 TEST_F(GLES2DecoderTest, IsProgram) { | 352 TEST_P(GLES2DecoderTest, IsProgram) { |
334 // IsProgram is true as soon as the program is created. | 353 // IsProgram is true as soon as the program is created. |
335 EXPECT_TRUE(DoIsProgram(client_program_id_)); | 354 EXPECT_TRUE(DoIsProgram(client_program_id_)); |
336 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) | 355 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) |
337 .Times(1) | 356 .Times(1) |
338 .RetiresOnSaturation(); | 357 .RetiresOnSaturation(); |
339 DoDeleteProgram(client_program_id_, kServiceProgramId); | 358 DoDeleteProgram(client_program_id_, kServiceProgramId); |
340 EXPECT_FALSE(DoIsProgram(client_program_id_)); | 359 EXPECT_FALSE(DoIsProgram(client_program_id_)); |
341 } | 360 } |
342 | 361 |
343 TEST_F(GLES2DecoderTest, IsRenderbuffer) { | 362 TEST_P(GLES2DecoderTest, IsRenderbuffer) { |
344 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); | 363 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); |
345 DoBindRenderbuffer( | 364 DoBindRenderbuffer( |
346 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); | 365 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); |
347 EXPECT_TRUE(DoIsRenderbuffer(client_renderbuffer_id_)); | 366 EXPECT_TRUE(DoIsRenderbuffer(client_renderbuffer_id_)); |
348 DoDeleteRenderbuffer(client_renderbuffer_id_, kServiceRenderbufferId); | 367 DoDeleteRenderbuffer(client_renderbuffer_id_, kServiceRenderbufferId); |
349 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); | 368 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); |
350 } | 369 } |
351 | 370 |
352 TEST_F(GLES2DecoderTest, IsShader) { | 371 TEST_P(GLES2DecoderTest, IsShader) { |
353 // IsShader is true as soon as the program is created. | 372 // IsShader is true as soon as the program is created. |
354 EXPECT_TRUE(DoIsShader(client_shader_id_)); | 373 EXPECT_TRUE(DoIsShader(client_shader_id_)); |
355 DoDeleteShader(client_shader_id_, kServiceShaderId); | 374 DoDeleteShader(client_shader_id_, kServiceShaderId); |
356 EXPECT_FALSE(DoIsShader(client_shader_id_)); | 375 EXPECT_FALSE(DoIsShader(client_shader_id_)); |
357 } | 376 } |
358 | 377 |
359 TEST_F(GLES2DecoderTest, IsTexture) { | 378 TEST_P(GLES2DecoderTest, IsTexture) { |
360 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 379 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
361 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 380 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
362 EXPECT_TRUE(DoIsTexture(client_texture_id_)); | 381 EXPECT_TRUE(DoIsTexture(client_texture_id_)); |
363 DoDeleteTexture(client_texture_id_, kServiceTextureId); | 382 DoDeleteTexture(client_texture_id_, kServiceTextureId); |
364 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 383 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
365 } | 384 } |
366 | 385 |
367 TEST_F(GLES2DecoderTest, GetMultipleIntegervCHROMIUMValidArgs) { | 386 TEST_P(GLES2DecoderTest, GetMultipleIntegervCHROMIUMValidArgs) { |
368 const GLsizei kCount = 3; | 387 const GLsizei kCount = 3; |
369 GLenum* pnames = GetSharedMemoryAs<GLenum*>(); | 388 GLenum* pnames = GetSharedMemoryAs<GLenum*>(); |
370 pnames[0] = GL_DEPTH_WRITEMASK; | 389 pnames[0] = GL_DEPTH_WRITEMASK; |
371 pnames[1] = GL_COLOR_WRITEMASK; | 390 pnames[1] = GL_COLOR_WRITEMASK; |
372 pnames[2] = GL_STENCIL_WRITEMASK; | 391 pnames[2] = GL_STENCIL_WRITEMASK; |
373 GLint* results = | 392 GLint* results = |
374 GetSharedMemoryAsWithOffset<GLint*>(sizeof(*pnames) * kCount); | 393 GetSharedMemoryAsWithOffset<GLint*>(sizeof(*pnames) * kCount); |
375 | 394 |
376 GLsizei num_results = 0; | 395 GLsizei num_results = 0; |
377 for (GLsizei ii = 0; ii < kCount; ++ii) { | 396 for (GLsizei ii = 0; ii < kCount; ++ii) { |
(...skipping 17 matching lines...) Expand all Loading... |
395 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 414 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
396 EXPECT_EQ(1, results[0]); // Depth writemask | 415 EXPECT_EQ(1, results[0]); // Depth writemask |
397 EXPECT_EQ(1, results[1]); // color writemask red | 416 EXPECT_EQ(1, results[1]); // color writemask red |
398 EXPECT_EQ(1, results[2]); // color writemask green | 417 EXPECT_EQ(1, results[2]); // color writemask green |
399 EXPECT_EQ(1, results[3]); // color writemask blue | 418 EXPECT_EQ(1, results[3]); // color writemask blue |
400 EXPECT_EQ(1, results[4]); // color writemask alpha | 419 EXPECT_EQ(1, results[4]); // color writemask alpha |
401 EXPECT_EQ(-1, results[5]); // stencil writemask alpha | 420 EXPECT_EQ(-1, results[5]); // stencil writemask alpha |
402 EXPECT_EQ(kSentinel, results[num_results]); // End of results | 421 EXPECT_EQ(kSentinel, results[num_results]); // End of results |
403 } | 422 } |
404 | 423 |
405 TEST_F(GLES2DecoderTest, GetMultipleIntegervCHROMIUMInvalidArgs) { | 424 TEST_P(GLES2DecoderTest, GetMultipleIntegervCHROMIUMInvalidArgs) { |
406 const GLsizei kCount = 3; | 425 const GLsizei kCount = 3; |
407 // Offset the pnames because GLGetError will use the first uint32. | 426 // Offset the pnames because GLGetError will use the first uint32. |
408 const uint32 kPnameOffset = sizeof(uint32); | 427 const uint32 kPnameOffset = sizeof(uint32); |
409 const uint32 kResultsOffset = kPnameOffset + sizeof(GLint) * kCount; | 428 const uint32 kResultsOffset = kPnameOffset + sizeof(GLint) * kCount; |
410 GLenum* pnames = GetSharedMemoryAsWithOffset<GLenum*>(kPnameOffset); | 429 GLenum* pnames = GetSharedMemoryAsWithOffset<GLenum*>(kPnameOffset); |
411 pnames[0] = GL_DEPTH_WRITEMASK; | 430 pnames[0] = GL_DEPTH_WRITEMASK; |
412 pnames[1] = GL_COLOR_WRITEMASK; | 431 pnames[1] = GL_COLOR_WRITEMASK; |
413 pnames[2] = GL_STENCIL_WRITEMASK; | 432 pnames[2] = GL_STENCIL_WRITEMASK; |
414 GLint* results = GetSharedMemoryAsWithOffset<GLint*>(kResultsOffset); | 433 GLint* results = GetSharedMemoryAsWithOffset<GLint*>(kResultsOffset); |
415 | 434 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 // Check buffer is what we expect | 524 // Check buffer is what we expect |
506 EXPECT_EQ(0, results[0]); | 525 EXPECT_EQ(0, results[0]); |
507 EXPECT_EQ(1, results[1]); | 526 EXPECT_EQ(1, results[1]); |
508 EXPECT_EQ(0, results[2]); | 527 EXPECT_EQ(0, results[2]); |
509 EXPECT_EQ(0, results[3]); | 528 EXPECT_EQ(0, results[3]); |
510 EXPECT_EQ(0, results[4]); | 529 EXPECT_EQ(0, results[4]); |
511 EXPECT_EQ(0, results[5]); | 530 EXPECT_EQ(0, results[5]); |
512 EXPECT_EQ(kSentinel, results[num_results]); // End of results | 531 EXPECT_EQ(kSentinel, results[num_results]); // End of results |
513 } | 532 } |
514 | 533 |
515 TEST_F(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { | 534 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { |
516 InitState init; | 535 InitState init; |
517 init.gl_version = "3.0"; | 536 init.gl_version = "3.0"; |
518 InitDecoder(init); | 537 InitDecoder(init); |
519 | 538 |
520 BindTexture cmd1; | 539 BindTexture cmd1; |
521 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); | 540 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); |
522 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | 541 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
523 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 542 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
524 | 543 |
525 BindBuffer cmd2; | 544 BindBuffer cmd2; |
526 cmd2.Init(GL_ARRAY_BUFFER, kInvalidClientId); | 545 cmd2.Init(GL_ARRAY_BUFFER, kInvalidClientId); |
527 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 546 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
528 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 547 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
529 | 548 |
530 BindFramebuffer cmd3; | 549 BindFramebuffer cmd3; |
531 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); | 550 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); |
532 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3)); | 551 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3)); |
533 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 552 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
534 | 553 |
535 BindRenderbuffer cmd4; | 554 BindRenderbuffer cmd4; |
536 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); | 555 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); |
537 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4)); | 556 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4)); |
538 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 557 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
539 } | 558 } |
540 | 559 |
541 TEST_F(GLES2DecoderTest, EnableFeatureCHROMIUMBadBucket) { | 560 TEST_P(GLES2DecoderTest, EnableFeatureCHROMIUMBadBucket) { |
542 const uint32 kBadBucketId = 123; | 561 const uint32 kBadBucketId = 123; |
543 EnableFeatureCHROMIUM cmd; | 562 EnableFeatureCHROMIUM cmd; |
544 cmd.Init(kBadBucketId, shared_memory_id_, shared_memory_offset_); | 563 cmd.Init(kBadBucketId, shared_memory_id_, shared_memory_offset_); |
545 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 564 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
546 } | 565 } |
547 | 566 |
548 TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { | 567 TEST_P(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { |
549 const uint32 kBadBucketId = 123; | 568 const uint32 kBadBucketId = 123; |
550 RequestExtensionCHROMIUM cmd; | 569 RequestExtensionCHROMIUM cmd; |
551 cmd.Init(kBadBucketId); | 570 cmd.Init(kBadBucketId); |
552 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 571 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
553 } | 572 } |
554 | 573 |
555 TEST_F(GLES2DecoderTest, BeginQueryEXTDisabled) { | 574 TEST_P(GLES2DecoderTest, BeginQueryEXTDisabled) { |
556 // Test something fails if off. | 575 // Test something fails if off. |
557 } | 576 } |
558 | 577 |
559 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXT) { | 578 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXT) { |
560 InitState init; | 579 InitState init; |
561 init.extensions = "GL_EXT_occlusion_query_boolean"; | 580 init.extensions = "GL_EXT_occlusion_query_boolean"; |
562 init.gl_version = "opengl es 2.0"; | 581 init.gl_version = "opengl es 2.0"; |
563 init.has_alpha = true; | 582 init.has_alpha = true; |
564 init.request_alpha = true; | 583 init.request_alpha = true; |
565 init.bind_generates_resource = true; | 584 init.bind_generates_resource = true; |
566 InitDecoder(init); | 585 InitDecoder(init); |
567 | 586 |
568 // Test end fails if no begin. | 587 // Test end fails if no begin. |
569 EndQueryEXT end_cmd; | 588 EndQueryEXT end_cmd; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 !process_success); | 749 !process_success); |
731 | 750 |
732 if (query_type.is_gl) { | 751 if (query_type.is_gl) { |
733 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)).Times(1).RetiresOnSaturation(); | 752 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)).Times(1).RetiresOnSaturation(); |
734 } | 753 } |
735 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) | 754 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) |
736 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); | 755 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
737 test->ResetDecoder(); | 756 test->ResetDecoder(); |
738 } | 757 } |
739 | 758 |
740 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { | 759 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { |
741 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { | 760 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { |
742 CheckBeginEndQueryBadMemoryFails(this, | 761 CheckBeginEndQueryBadMemoryFails(this, |
743 kNewClientId, | 762 kNewClientId, |
744 kNewServiceId, | 763 kNewServiceId, |
745 kQueryTypes[i], | 764 kQueryTypes[i], |
746 kInvalidSharedMemoryId, | 765 kInvalidSharedMemoryId, |
747 kSharedMemoryOffset); | 766 kSharedMemoryOffset); |
748 } | 767 } |
749 } | 768 } |
750 | 769 |
751 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) { | 770 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) { |
752 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { | 771 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { |
753 // Out-of-bounds. | 772 // Out-of-bounds. |
754 CheckBeginEndQueryBadMemoryFails(this, | 773 CheckBeginEndQueryBadMemoryFails(this, |
755 kNewClientId, | 774 kNewClientId, |
756 kNewServiceId, | 775 kNewServiceId, |
757 kQueryTypes[i], | 776 kQueryTypes[i], |
758 kSharedMemoryId, | 777 kSharedMemoryId, |
759 kInvalidSharedMemoryOffset); | 778 kInvalidSharedMemoryOffset); |
760 // Overflow. | 779 // Overflow. |
761 CheckBeginEndQueryBadMemoryFails(this, | 780 CheckBeginEndQueryBadMemoryFails(this, |
762 kNewClientId, | 781 kNewClientId, |
763 kNewServiceId, | 782 kNewServiceId, |
764 kQueryTypes[i], | 783 kQueryTypes[i], |
765 kSharedMemoryId, | 784 kSharedMemoryId, |
766 0xfffffffcu); | 785 0xfffffffcu); |
767 } | 786 } |
768 } | 787 } |
769 | 788 |
770 TEST_F(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { | 789 TEST_P(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { |
771 BeginQueryEXT begin_cmd; | 790 BeginQueryEXT begin_cmd; |
772 | 791 |
773 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 792 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
774 | 793 |
775 // Test valid parameters work. | 794 // Test valid parameters work. |
776 begin_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, | 795 begin_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, |
777 kNewClientId, | 796 kNewClientId, |
778 kSharedMemoryId, | 797 kSharedMemoryId, |
779 kSharedMemoryOffset); | 798 kSharedMemoryOffset); |
780 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 799 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
781 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 800 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
782 | 801 |
783 QueryManager* query_manager = decoder_->GetQueryManager(); | 802 QueryManager* query_manager = decoder_->GetQueryManager(); |
784 ASSERT_TRUE(query_manager != NULL); | 803 ASSERT_TRUE(query_manager != NULL); |
785 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); | 804 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
786 ASSERT_TRUE(query != NULL); | 805 ASSERT_TRUE(query != NULL); |
787 EXPECT_FALSE(query->pending()); | 806 EXPECT_FALSE(query->pending()); |
788 | 807 |
789 // Test end succeeds | 808 // Test end succeeds |
790 EndQueryEXT end_cmd; | 809 EndQueryEXT end_cmd; |
791 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); | 810 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); |
792 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 811 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
793 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 812 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
794 EXPECT_FALSE(query->pending()); | 813 EXPECT_FALSE(query->pending()); |
795 } | 814 } |
796 | 815 |
797 TEST_F(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) { | 816 TEST_P(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) { |
798 BeginQueryEXT begin_cmd; | 817 BeginQueryEXT begin_cmd; |
799 | 818 |
800 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 819 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
801 | 820 |
802 // Test valid parameters work. | 821 // Test valid parameters work. |
803 begin_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, | 822 begin_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, |
804 kNewClientId, | 823 kNewClientId, |
805 kSharedMemoryId, | 824 kSharedMemoryId, |
806 kSharedMemoryOffset); | 825 kSharedMemoryOffset); |
807 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 826 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
(...skipping 14 matching lines...) Expand all Loading... |
822 | 841 |
823 EndQueryEXT end_cmd; | 842 EndQueryEXT end_cmd; |
824 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); | 843 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); |
825 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 844 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
826 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 845 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
827 EXPECT_FALSE(query->pending()); | 846 EXPECT_FALSE(query->pending()); |
828 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), | 847 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), |
829 static_cast<GLenum>(sync->result)); | 848 static_cast<GLenum>(sync->result)); |
830 } | 849 } |
831 | 850 |
832 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTCommandsCompletedCHROMIUM) { | 851 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTCommandsCompletedCHROMIUM) { |
833 InitState init; | 852 InitState init; |
834 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; | 853 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; |
835 init.gl_version = "opengl es 2.0"; | 854 init.gl_version = "opengl es 2.0"; |
836 init.has_alpha = true; | 855 init.has_alpha = true; |
837 init.request_alpha = true; | 856 init.request_alpha = true; |
838 init.bind_generates_resource = true; | 857 init.bind_generates_resource = true; |
839 InitDecoder(init); | 858 InitDecoder(init); |
840 | 859 |
841 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 860 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
842 | 861 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 | 900 |
882 EXPECT_TRUE(process_success); | 901 EXPECT_TRUE(process_success); |
883 EXPECT_FALSE(query->pending()); | 902 EXPECT_FALSE(query->pending()); |
884 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); | 903 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); |
885 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); | 904 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); |
886 | 905 |
887 EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); | 906 EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
888 ResetDecoder(); | 907 ResetDecoder(); |
889 } | 908 } |
890 | 909 |
891 TEST_F(GLES2DecoderTest, IsEnabledReturnsCachedValue) { | 910 TEST_P(GLES2DecoderTest, IsEnabledReturnsCachedValue) { |
892 // NOTE: There are no expectations because no GL functions should be | 911 // NOTE: There are no expectations because no GL functions should be |
893 // called for DEPTH_TEST or STENCIL_TEST | 912 // called for DEPTH_TEST or STENCIL_TEST |
894 static const GLenum kStates[] = { | 913 static const GLenum kStates[] = { |
895 GL_DEPTH_TEST, GL_STENCIL_TEST, | 914 GL_DEPTH_TEST, GL_STENCIL_TEST, |
896 }; | 915 }; |
897 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { | 916 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { |
898 Enable enable_cmd; | 917 Enable enable_cmd; |
899 GLenum state = kStates[ii]; | 918 GLenum state = kStates[ii]; |
900 enable_cmd.Init(state); | 919 enable_cmd.Init(state); |
901 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); | 920 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); |
902 IsEnabled::Result* result = | 921 IsEnabled::Result* result = |
903 static_cast<IsEnabled::Result*>(shared_memory_address_); | 922 static_cast<IsEnabled::Result*>(shared_memory_address_); |
904 IsEnabled is_enabled_cmd; | 923 IsEnabled is_enabled_cmd; |
905 is_enabled_cmd.Init(state, shared_memory_id_, shared_memory_offset_); | 924 is_enabled_cmd.Init(state, shared_memory_id_, shared_memory_offset_); |
906 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); | 925 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); |
907 EXPECT_NE(0u, *result); | 926 EXPECT_NE(0u, *result); |
908 Disable disable_cmd; | 927 Disable disable_cmd; |
909 disable_cmd.Init(state); | 928 disable_cmd.Init(state); |
910 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd)); | 929 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd)); |
911 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); | 930 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); |
912 EXPECT_EQ(0u, *result); | 931 EXPECT_EQ(0u, *result); |
913 } | 932 } |
914 } | 933 } |
915 | 934 |
916 TEST_F(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) { | 935 TEST_P(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) { |
917 InitState init; | 936 InitState init; |
918 init.extensions = "GL_ARB_texture_rectangle"; | 937 init.extensions = "GL_ARB_texture_rectangle"; |
919 init.gl_version = "3.0"; | 938 init.gl_version = "3.0"; |
920 init.bind_generates_resource = true; | 939 init.bind_generates_resource = true; |
921 InitDecoder(init); | 940 InitDecoder(init); |
922 | 941 |
923 Texture* texture = GetTexture(client_texture_id_)->texture(); | 942 Texture* texture = GetTexture(client_texture_id_)->texture(); |
924 EXPECT_TRUE(texture != NULL); | 943 EXPECT_TRUE(texture != NULL); |
925 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_UNMANAGED_CHROMIUM); | 944 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_UNMANAGED_CHROMIUM); |
926 | 945 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 struct PoolInfo { | 999 struct PoolInfo { |
981 PoolInfo() : initial_size(0), size(0) {} | 1000 PoolInfo() : initial_size(0), size(0) {} |
982 size_t initial_size; | 1001 size_t initial_size; |
983 size_t size; | 1002 size_t size; |
984 }; | 1003 }; |
985 std::map<Pool, PoolInfo> pool_infos_; | 1004 std::map<Pool, PoolInfo> pool_infos_; |
986 }; | 1005 }; |
987 | 1006 |
988 } // anonymous namespace. | 1007 } // anonymous namespace. |
989 | 1008 |
990 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerInitialSize) { | 1009 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerInitialSize) { |
991 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1010 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
992 new SizeOnlyMemoryTracker(); | 1011 new SizeOnlyMemoryTracker(); |
993 set_memory_tracker(memory_tracker.get()); | 1012 set_memory_tracker(memory_tracker.get()); |
994 InitState init; | 1013 InitState init; |
995 init.gl_version = "3.0"; | 1014 init.gl_version = "3.0"; |
996 init.bind_generates_resource = true; | 1015 init.bind_generates_resource = true; |
997 InitDecoder(init); | 1016 InitDecoder(init); |
998 // Expect that initial size - size is 0. | 1017 // Expect that initial size - size is 0. |
999 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1018 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
1000 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); | 1019 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); |
1001 } | 1020 } |
1002 | 1021 |
1003 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) { | 1022 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) { |
1004 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1023 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
1005 new SizeOnlyMemoryTracker(); | 1024 new SizeOnlyMemoryTracker(); |
1006 set_memory_tracker(memory_tracker.get()); | 1025 set_memory_tracker(memory_tracker.get()); |
1007 InitState init; | 1026 InitState init; |
1008 init.gl_version = "3.0"; | 1027 init.gl_version = "3.0"; |
1009 init.bind_generates_resource = true; | 1028 init.bind_generates_resource = true; |
1010 InitDecoder(init); | 1029 InitDecoder(init); |
1011 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1030 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
1012 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1031 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
1013 .WillOnce(Return(true)) | 1032 .WillOnce(Return(true)) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 0, | 1070 0, |
1052 GL_RGBA, | 1071 GL_RGBA, |
1053 GL_UNSIGNED_BYTE, | 1072 GL_UNSIGNED_BYTE, |
1054 kSharedMemoryId, | 1073 kSharedMemoryId, |
1055 kSharedMemoryOffset); | 1074 kSharedMemoryOffset); |
1056 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1075 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1057 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1076 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
1058 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1077 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
1059 } | 1078 } |
1060 | 1079 |
1061 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) { | 1080 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) { |
1062 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1081 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
1063 new SizeOnlyMemoryTracker(); | 1082 new SizeOnlyMemoryTracker(); |
1064 set_memory_tracker(memory_tracker.get()); | 1083 set_memory_tracker(memory_tracker.get()); |
1065 InitState init; | 1084 InitState init; |
1066 init.gl_version = "3.0"; | 1085 init.gl_version = "3.0"; |
1067 init.bind_generates_resource = true; | 1086 init.bind_generates_resource = true; |
1068 InitDecoder(init); | 1087 InitDecoder(init); |
1069 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1088 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
1070 // Check we get out of memory and no call to glTexStorage2DEXT | 1089 // Check we get out of memory and no call to glTexStorage2DEXT |
1071 // if Ensure fails. | 1090 // if Ensure fails. |
1072 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1091 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
1073 .WillOnce(Return(false)) | 1092 .WillOnce(Return(false)) |
1074 .RetiresOnSaturation(); | 1093 .RetiresOnSaturation(); |
1075 TexStorage2DEXT cmd; | 1094 TexStorage2DEXT cmd; |
1076 cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4); | 1095 cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4); |
1077 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1096 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1078 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1097 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
1079 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1098 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
1080 } | 1099 } |
1081 | 1100 |
1082 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) { | 1101 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) { |
1083 GLenum target = GL_TEXTURE_2D; | 1102 GLenum target = GL_TEXTURE_2D; |
1084 GLint level = 0; | 1103 GLint level = 0; |
1085 GLenum internal_format = GL_RGBA; | 1104 GLenum internal_format = GL_RGBA; |
1086 GLsizei width = 4; | 1105 GLsizei width = 4; |
1087 GLsizei height = 8; | 1106 GLsizei height = 8; |
1088 GLint border = 0; | 1107 GLint border = 0; |
1089 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1108 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
1090 new SizeOnlyMemoryTracker(); | 1109 new SizeOnlyMemoryTracker(); |
1091 set_memory_tracker(memory_tracker.get()); | 1110 set_memory_tracker(memory_tracker.get()); |
1092 InitState init; | 1111 InitState init; |
(...skipping 22 matching lines...) Expand all Loading... |
1115 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1134 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
1116 // Check we get out of memory and no call to glCopyTexImage2D if Ensure fails. | 1135 // Check we get out of memory and no call to glCopyTexImage2D if Ensure fails. |
1117 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1136 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
1118 .WillOnce(Return(false)) | 1137 .WillOnce(Return(false)) |
1119 .RetiresOnSaturation(); | 1138 .RetiresOnSaturation(); |
1120 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1139 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1121 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1140 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
1122 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1141 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
1123 } | 1142 } |
1124 | 1143 |
1125 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) { | 1144 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) { |
1126 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1145 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
1127 new SizeOnlyMemoryTracker(); | 1146 new SizeOnlyMemoryTracker(); |
1128 set_memory_tracker(memory_tracker.get()); | 1147 set_memory_tracker(memory_tracker.get()); |
1129 InitState init; | 1148 InitState init; |
1130 init.gl_version = "3.0"; | 1149 init.gl_version = "3.0"; |
1131 init.bind_generates_resource = true; | 1150 init.bind_generates_resource = true; |
1132 InitDecoder(init); | 1151 InitDecoder(init); |
1133 DoBindRenderbuffer( | 1152 DoBindRenderbuffer( |
1134 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); | 1153 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); |
1135 EXPECT_CALL(*gl_, GetError()) | 1154 EXPECT_CALL(*gl_, GetError()) |
(...skipping 14 matching lines...) Expand all Loading... |
1150 // Check we get out of memory and no call to glRenderbufferStorage if Ensure | 1169 // Check we get out of memory and no call to glRenderbufferStorage if Ensure |
1151 // fails. | 1170 // fails. |
1152 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1171 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
1153 .WillOnce(Return(false)) | 1172 .WillOnce(Return(false)) |
1154 .RetiresOnSaturation(); | 1173 .RetiresOnSaturation(); |
1155 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1174 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1156 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1175 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
1157 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1176 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
1158 } | 1177 } |
1159 | 1178 |
1160 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerBufferData) { | 1179 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerBufferData) { |
1161 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1180 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
1162 new SizeOnlyMemoryTracker(); | 1181 new SizeOnlyMemoryTracker(); |
1163 set_memory_tracker(memory_tracker.get()); | 1182 set_memory_tracker(memory_tracker.get()); |
1164 InitState init; | 1183 InitState init; |
1165 init.gl_version = "3.0"; | 1184 init.gl_version = "3.0"; |
1166 init.bind_generates_resource = true; | 1185 init.bind_generates_resource = true; |
1167 InitDecoder(init); | 1186 InitDecoder(init); |
1168 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); | 1187 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); |
1169 EXPECT_CALL(*gl_, GetError()) | 1188 EXPECT_CALL(*gl_, GetError()) |
1170 .WillOnce(Return(GL_NO_ERROR)) | 1189 .WillOnce(Return(GL_NO_ERROR)) |
(...skipping 13 matching lines...) Expand all Loading... |
1184 // Check we get out of memory and no call to glBufferData if Ensure | 1203 // Check we get out of memory and no call to glBufferData if Ensure |
1185 // fails. | 1204 // fails. |
1186 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1205 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
1187 .WillOnce(Return(false)) | 1206 .WillOnce(Return(false)) |
1188 .RetiresOnSaturation(); | 1207 .RetiresOnSaturation(); |
1189 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1208 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1190 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1209 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
1191 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); | 1210 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); |
1192 } | 1211 } |
1193 | 1212 |
| 1213 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool()); |
| 1214 |
| 1215 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool()); |
| 1216 |
| 1217 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
| 1218 |
| 1219 INSTANTIATE_TEST_CASE_P(Service, |
| 1220 GLES2DecoderRGBBackbufferTest, |
| 1221 ::testing::Bool()); |
| 1222 |
1194 } // namespace gles2 | 1223 } // namespace gles2 |
1195 } // namespace gpu | 1224 } // namespace gpu |
OLD | NEW |