| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST_P(GLES2DecoderTest, IsTexture) { | 261 TEST_P(GLES2DecoderTest, IsTexture) { |
| 262 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 262 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
| 263 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 263 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 264 EXPECT_TRUE(DoIsTexture(client_texture_id_)); | 264 EXPECT_TRUE(DoIsTexture(client_texture_id_)); |
| 265 DoDeleteTexture(client_texture_id_, kServiceTextureId); | 265 DoDeleteTexture(client_texture_id_, kServiceTextureId); |
| 266 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 266 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
| 267 } | 267 } |
| 268 | 268 |
| 269 TEST_P(GLES2DecoderTest, GetMultipleIntegervCHROMIUMValidArgs) { | |
| 270 const GLsizei kCount = 3; | |
| 271 GLenum* pnames = GetSharedMemoryAs<GLenum*>(); | |
| 272 pnames[0] = GL_DEPTH_WRITEMASK; | |
| 273 pnames[1] = GL_COLOR_WRITEMASK; | |
| 274 pnames[2] = GL_STENCIL_WRITEMASK; | |
| 275 GLint* results = | |
| 276 GetSharedMemoryAsWithOffset<GLint*>(sizeof(*pnames) * kCount); | |
| 277 | |
| 278 GLsizei num_results = 0; | |
| 279 for (GLsizei ii = 0; ii < kCount; ++ii) { | |
| 280 num_results += decoder_->GetGLES2Util()->GLGetNumValuesReturned(pnames[ii]); | |
| 281 } | |
| 282 const GLsizei result_size = num_results * sizeof(*results); | |
| 283 memset(results, 0, result_size); | |
| 284 | |
| 285 const GLint kSentinel = 0x12345678; | |
| 286 results[num_results] = kSentinel; | |
| 287 | |
| 288 GetMultipleIntegervCHROMIUM cmd; | |
| 289 cmd.Init(kSharedMemoryId, | |
| 290 kSharedMemoryOffset, | |
| 291 kCount, | |
| 292 kSharedMemoryId, | |
| 293 kSharedMemoryOffset + sizeof(*pnames) * kCount, | |
| 294 result_size); | |
| 295 | |
| 296 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 297 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 298 EXPECT_EQ(1, results[0]); // Depth writemask | |
| 299 EXPECT_EQ(1, results[1]); // color writemask red | |
| 300 EXPECT_EQ(1, results[2]); // color writemask green | |
| 301 EXPECT_EQ(1, results[3]); // color writemask blue | |
| 302 EXPECT_EQ(1, results[4]); // color writemask alpha | |
| 303 EXPECT_EQ(-1, results[5]); // stencil writemask alpha | |
| 304 EXPECT_EQ(kSentinel, results[num_results]); // End of results | |
| 305 } | |
| 306 | |
| 307 TEST_P(GLES2DecoderTest, GetMultipleIntegervCHROMIUMInvalidArgs) { | |
| 308 const GLsizei kCount = 3; | |
| 309 // Offset the pnames because GLGetError will use the first uint32. | |
| 310 const uint32 kPnameOffset = sizeof(uint32); | |
| 311 const uint32 kResultsOffset = kPnameOffset + sizeof(GLint) * kCount; | |
| 312 GLenum* pnames = GetSharedMemoryAsWithOffset<GLenum*>(kPnameOffset); | |
| 313 pnames[0] = GL_DEPTH_WRITEMASK; | |
| 314 pnames[1] = GL_COLOR_WRITEMASK; | |
| 315 pnames[2] = GL_STENCIL_WRITEMASK; | |
| 316 GLint* results = GetSharedMemoryAsWithOffset<GLint*>(kResultsOffset); | |
| 317 | |
| 318 GLsizei num_results = 0; | |
| 319 for (GLsizei ii = 0; ii < kCount; ++ii) { | |
| 320 num_results += decoder_->GetGLES2Util()->GLGetNumValuesReturned(pnames[ii]); | |
| 321 } | |
| 322 const GLsizei result_size = num_results * sizeof(*results); | |
| 323 memset(results, 0, result_size); | |
| 324 | |
| 325 const GLint kSentinel = 0x12345678; | |
| 326 results[num_results] = kSentinel; | |
| 327 | |
| 328 GetMultipleIntegervCHROMIUM cmd; | |
| 329 // Check bad pnames pointer. | |
| 330 cmd.Init(kInvalidSharedMemoryId, | |
| 331 kSharedMemoryOffset + kPnameOffset, | |
| 332 kCount, | |
| 333 kSharedMemoryId, | |
| 334 kSharedMemoryOffset + kResultsOffset, | |
| 335 result_size); | |
| 336 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 337 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 338 // Check bad pnames pointer. | |
| 339 cmd.Init(kSharedMemoryId, | |
| 340 kInvalidSharedMemoryOffset, | |
| 341 kCount, | |
| 342 kSharedMemoryId, | |
| 343 kSharedMemoryOffset + kResultsOffset, | |
| 344 result_size); | |
| 345 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 346 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 347 // Check bad count. | |
| 348 cmd.Init(kSharedMemoryId, | |
| 349 kSharedMemoryOffset + kPnameOffset, | |
| 350 static_cast<GLuint>(-1), | |
| 351 kSharedMemoryId, | |
| 352 kSharedMemoryOffset + kResultsOffset, | |
| 353 result_size); | |
| 354 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 355 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 356 // Check bad results pointer. | |
| 357 cmd.Init(kSharedMemoryId, | |
| 358 kSharedMemoryOffset + kPnameOffset, | |
| 359 kCount, | |
| 360 kInvalidSharedMemoryId, | |
| 361 kSharedMemoryOffset + kResultsOffset, | |
| 362 result_size); | |
| 363 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 364 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 365 // Check bad results pointer. | |
| 366 cmd.Init(kSharedMemoryId, | |
| 367 kSharedMemoryOffset + kPnameOffset, | |
| 368 kCount, | |
| 369 kSharedMemoryId, | |
| 370 kInvalidSharedMemoryOffset, | |
| 371 result_size); | |
| 372 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 373 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 374 // Check bad size. | |
| 375 cmd.Init(kSharedMemoryId, | |
| 376 kSharedMemoryOffset + kPnameOffset, | |
| 377 kCount, | |
| 378 kSharedMemoryId, | |
| 379 kSharedMemoryOffset + kResultsOffset, | |
| 380 result_size + 1); | |
| 381 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 382 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 383 // Check bad size. | |
| 384 cmd.Init(kSharedMemoryId, | |
| 385 kSharedMemoryOffset + kPnameOffset, | |
| 386 kCount, | |
| 387 kSharedMemoryId, | |
| 388 kSharedMemoryOffset + kResultsOffset, | |
| 389 result_size - 1); | |
| 390 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 391 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 392 // Check bad enum. | |
| 393 cmd.Init(kSharedMemoryId, | |
| 394 kSharedMemoryOffset + kPnameOffset, | |
| 395 kCount, | |
| 396 kSharedMemoryId, | |
| 397 kSharedMemoryOffset + kResultsOffset, | |
| 398 result_size); | |
| 399 GLenum temp = pnames[2]; | |
| 400 pnames[2] = GL_TRUE; | |
| 401 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 402 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 403 pnames[2] = temp; | |
| 404 // Check results area has not been cleared by client. | |
| 405 results[1] = 1; | |
| 406 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); | |
| 407 // Check buffer is what we expect | |
| 408 EXPECT_EQ(0, results[0]); | |
| 409 EXPECT_EQ(1, results[1]); | |
| 410 EXPECT_EQ(0, results[2]); | |
| 411 EXPECT_EQ(0, results[3]); | |
| 412 EXPECT_EQ(0, results[4]); | |
| 413 EXPECT_EQ(0, results[5]); | |
| 414 EXPECT_EQ(kSentinel, results[num_results]); // End of results | |
| 415 } | |
| 416 | |
| 417 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { | 269 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { |
| 418 InitState init; | 270 InitState init; |
| 419 init.gl_version = "3.0"; | 271 init.gl_version = "3.0"; |
| 420 InitDecoder(init); | 272 InitDecoder(init); |
| 421 | 273 |
| 422 BindTexture cmd1; | 274 BindTexture cmd1; |
| 423 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); | 275 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); |
| 424 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | 276 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 425 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 277 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 426 | 278 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 .WillOnce(Return(GL_TRUE)) | 481 .WillOnce(Return(GL_TRUE)) |
| 630 .RetiresOnSaturation(); | 482 .RetiresOnSaturation(); |
| 631 #endif | 483 #endif |
| 632 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) | 484 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) |
| 633 .WillOnce(Return(GL_ALREADY_SIGNALED)) | 485 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 634 .RetiresOnSaturation(); | 486 .RetiresOnSaturation(); |
| 635 } | 487 } |
| 636 | 488 |
| 637 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); | 489 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); |
| 638 ASSERT_TRUE(query_manager != NULL); | 490 ASSERT_TRUE(query_manager != NULL); |
| 639 bool process_success = query_manager->ProcessPendingQueries(); | 491 bool process_success = query_manager->ProcessPendingQueries(false); |
| 640 | 492 |
| 641 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || | 493 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || |
| 642 !process_success); | 494 !process_success); |
| 643 | 495 |
| 644 if (query_type.is_gl) { | 496 if (query_type.is_gl) { |
| 645 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)).Times(1).RetiresOnSaturation(); | 497 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)).Times(1).RetiresOnSaturation(); |
| 646 } | 498 } |
| 647 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | 499 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 648 #if DCHECK_IS_ON | 500 #if DCHECK_IS_ON |
| 649 EXPECT_CALL(*gl, IsSync(kGlSync)) | 501 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 EXPECT_TRUE(query->pending()); | 642 EXPECT_TRUE(query->pending()); |
| 791 | 643 |
| 792 #if DCHECK_IS_ON | 644 #if DCHECK_IS_ON |
| 793 EXPECT_CALL(*gl_, IsSync(kGlSync)) | 645 EXPECT_CALL(*gl_, IsSync(kGlSync)) |
| 794 .WillOnce(Return(GL_TRUE)) | 646 .WillOnce(Return(GL_TRUE)) |
| 795 .RetiresOnSaturation(); | 647 .RetiresOnSaturation(); |
| 796 #endif | 648 #endif |
| 797 EXPECT_CALL(*gl_, ClientWaitSync(kGlSync, _, _)) | 649 EXPECT_CALL(*gl_, ClientWaitSync(kGlSync, _, _)) |
| 798 .WillOnce(Return(GL_TIMEOUT_EXPIRED)) | 650 .WillOnce(Return(GL_TIMEOUT_EXPIRED)) |
| 799 .RetiresOnSaturation(); | 651 .RetiresOnSaturation(); |
| 800 bool process_success = query_manager->ProcessPendingQueries(); | 652 bool process_success = query_manager->ProcessPendingQueries(false); |
| 801 | 653 |
| 802 EXPECT_TRUE(process_success); | 654 EXPECT_TRUE(process_success); |
| 803 EXPECT_TRUE(query->pending()); | 655 EXPECT_TRUE(query->pending()); |
| 804 | 656 |
| 805 #if DCHECK_IS_ON | 657 #if DCHECK_IS_ON |
| 806 EXPECT_CALL(*gl_, IsSync(kGlSync)) | 658 EXPECT_CALL(*gl_, IsSync(kGlSync)) |
| 807 .WillOnce(Return(GL_TRUE)) | 659 .WillOnce(Return(GL_TRUE)) |
| 808 .RetiresOnSaturation(); | 660 .RetiresOnSaturation(); |
| 809 #endif | 661 #endif |
| 810 EXPECT_CALL(*gl_, ClientWaitSync(kGlSync, _, _)) | 662 EXPECT_CALL(*gl_, ClientWaitSync(kGlSync, _, _)) |
| 811 .WillOnce(Return(GL_ALREADY_SIGNALED)) | 663 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 812 .RetiresOnSaturation(); | 664 .RetiresOnSaturation(); |
| 813 process_success = query_manager->ProcessPendingQueries(); | 665 process_success = query_manager->ProcessPendingQueries(false); |
| 814 | 666 |
| 815 EXPECT_TRUE(process_success); | 667 EXPECT_TRUE(process_success); |
| 816 EXPECT_FALSE(query->pending()); | 668 EXPECT_FALSE(query->pending()); |
| 817 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); | 669 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); |
| 818 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); | 670 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); |
| 819 | 671 |
| 820 #if DCHECK_IS_ON | 672 #if DCHECK_IS_ON |
| 821 EXPECT_CALL(*gl_, IsSync(kGlSync)) | 673 EXPECT_CALL(*gl_, IsSync(kGlSync)) |
| 822 .WillOnce(Return(GL_TRUE)) | 674 .WillOnce(Return(GL_TRUE)) |
| 823 .RetiresOnSaturation(); | 675 .RetiresOnSaturation(); |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); | 1160 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
| 1309 | 1161 |
| 1310 INSTANTIATE_TEST_CASE_P(Service, | 1162 INSTANTIATE_TEST_CASE_P(Service, |
| 1311 GLES2DecoderRGBBackbufferTest, | 1163 GLES2DecoderRGBBackbufferTest, |
| 1312 ::testing::Bool()); | 1164 ::testing::Bool()); |
| 1313 | 1165 |
| 1314 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1166 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
| 1315 | 1167 |
| 1316 } // namespace gles2 | 1168 } // namespace gles2 |
| 1317 } // namespace gpu | 1169 } // namespace gpu |
| OLD | NEW |