| 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 436 |
| 437 // Test id = 0 fails. | 437 // Test id = 0 fails. |
| 438 begin_cmd.Init( | 438 begin_cmd.Init( |
| 439 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset); | 439 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset); |
| 440 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 440 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 441 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 441 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 442 | 442 |
| 443 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 443 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 444 | 444 |
| 445 // Test valid parameters work. | 445 // Test valid parameters work. |
| 446 EXPECT_CALL(*gl_, GenQueriesARB(1, _)) | 446 EXPECT_CALL(*gl_, GenQueries(1, _)) |
| 447 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) | 447 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 448 .RetiresOnSaturation(); | 448 .RetiresOnSaturation(); |
| 449 EXPECT_CALL(*gl_, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) | 449 EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) |
| 450 .Times(1) | 450 .Times(1) |
| 451 .RetiresOnSaturation(); | 451 .RetiresOnSaturation(); |
| 452 | 452 |
| 453 // Query object should not be created untill BeginQueriesEXT. | 453 // Query object should not be created untill BeginQueriesEXT. |
| 454 QueryManager* query_manager = decoder_->GetQueryManager(); | 454 QueryManager* query_manager = decoder_->GetQueryManager(); |
| 455 ASSERT_TRUE(query_manager != NULL); | 455 ASSERT_TRUE(query_manager != NULL); |
| 456 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); | 456 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
| 457 EXPECT_TRUE(query == NULL); | 457 EXPECT_TRUE(query == NULL); |
| 458 | 458 |
| 459 // BeginQueryEXT should fail if id is not generated from GenQueriesEXT. | 459 // BeginQueryEXT should fail if id is not generated from GenQueriesEXT. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 479 // Test trying begin again fails | 479 // Test trying begin again fails |
| 480 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 480 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 481 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 481 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 482 | 482 |
| 483 // Test end fails with different target | 483 // Test end fails with different target |
| 484 end_cmd.Init(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, 1); | 484 end_cmd.Init(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, 1); |
| 485 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 485 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 486 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 486 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 487 | 487 |
| 488 // Test end succeeds | 488 // Test end succeeds |
| 489 EXPECT_CALL(*gl_, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT)) | 489 EXPECT_CALL(*gl_, EndQuery(GL_ANY_SAMPLES_PASSED_EXT)) |
| 490 .Times(1) | 490 .Times(1) |
| 491 .RetiresOnSaturation(); | 491 .RetiresOnSaturation(); |
| 492 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); | 492 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); |
| 493 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 493 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 494 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 494 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 495 EXPECT_TRUE(query->pending()); | 495 EXPECT_TRUE(query->pending()); |
| 496 | 496 |
| 497 EXPECT_CALL(*gl_, DeleteQueriesARB(1, _)).Times(1).RetiresOnSaturation(); | 497 EXPECT_CALL(*gl_, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); |
| 498 } | 498 } |
| 499 | 499 |
| 500 struct QueryType { | 500 struct QueryType { |
| 501 GLenum type; | 501 GLenum type; |
| 502 bool is_gl; | 502 bool is_gl; |
| 503 }; | 503 }; |
| 504 | 504 |
| 505 const QueryType kQueryTypes[] = { | 505 const QueryType kQueryTypes[] = { |
| 506 {GL_COMMANDS_ISSUED_CHROMIUM, false}, | 506 {GL_COMMANDS_ISSUED_CHROMIUM, false}, |
| 507 {GL_LATENCY_QUERY_CHROMIUM, false}, | 507 {GL_LATENCY_QUERY_CHROMIUM, false}, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 527 init.request_alpha = true; | 527 init.request_alpha = true; |
| 528 init.bind_generates_resource = true; | 528 init.bind_generates_resource = true; |
| 529 test->InitDecoder(init); | 529 test->InitDecoder(init); |
| 530 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); | 530 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); |
| 531 | 531 |
| 532 BeginQueryEXT begin_cmd; | 532 BeginQueryEXT begin_cmd; |
| 533 | 533 |
| 534 test->GenHelper<GenQueriesEXTImmediate>(client_id); | 534 test->GenHelper<GenQueriesEXTImmediate>(client_id); |
| 535 | 535 |
| 536 if (query_type.is_gl) { | 536 if (query_type.is_gl) { |
| 537 EXPECT_CALL(*gl, GenQueriesARB(1, _)) | 537 EXPECT_CALL(*gl, GenQueries(1, _)) |
| 538 .WillOnce(SetArgumentPointee<1>(service_id)) | 538 .WillOnce(SetArgumentPointee<1>(service_id)) |
| 539 .RetiresOnSaturation(); | 539 .RetiresOnSaturation(); |
| 540 EXPECT_CALL(*gl, BeginQueryARB(query_type.type, service_id)) | 540 EXPECT_CALL(*gl, BeginQuery(query_type.type, service_id)) |
| 541 .Times(1) | 541 .Times(1) |
| 542 .RetiresOnSaturation(); | 542 .RetiresOnSaturation(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 // Test bad shared memory fails | 545 // Test bad shared memory fails |
| 546 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset); | 546 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset); |
| 547 error::Error error1 = test->ExecuteCmd(begin_cmd); | 547 error::Error error1 = test->ExecuteCmd(begin_cmd); |
| 548 | 548 |
| 549 if (query_type.is_gl) { | 549 if (query_type.is_gl) { |
| 550 EXPECT_CALL(*gl, EndQueryARB(query_type.type)) | 550 EXPECT_CALL(*gl, EndQuery(query_type.type)) |
| 551 .Times(1) | 551 .Times(1) |
| 552 .RetiresOnSaturation(); | 552 .RetiresOnSaturation(); |
| 553 } | 553 } |
| 554 if (query_type.type == GL_GET_ERROR_QUERY_CHROMIUM) { | 554 if (query_type.type == GL_GET_ERROR_QUERY_CHROMIUM) { |
| 555 EXPECT_CALL(*gl, GetError()) | 555 EXPECT_CALL(*gl, GetError()) |
| 556 .WillOnce(Return(GL_NO_ERROR)) | 556 .WillOnce(Return(GL_NO_ERROR)) |
| 557 .RetiresOnSaturation(); | 557 .RetiresOnSaturation(); |
| 558 } | 558 } |
| 559 GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); | 559 GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); |
| 560 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | 560 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 561 EXPECT_CALL(*gl, Flush()).RetiresOnSaturation(); | 561 EXPECT_CALL(*gl, Flush()).RetiresOnSaturation(); |
| 562 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) | 562 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) |
| 563 .WillOnce(Return(kGlSync)) | 563 .WillOnce(Return(kGlSync)) |
| 564 .RetiresOnSaturation(); | 564 .RetiresOnSaturation(); |
| 565 #if DCHECK_IS_ON() | 565 #if DCHECK_IS_ON() |
| 566 EXPECT_CALL(*gl, IsSync(kGlSync)) | 566 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| 567 .WillOnce(Return(GL_TRUE)) | 567 .WillOnce(Return(GL_TRUE)) |
| 568 .RetiresOnSaturation(); | 568 .RetiresOnSaturation(); |
| 569 #endif | 569 #endif |
| 570 } | 570 } |
| 571 | 571 |
| 572 EndQueryEXT end_cmd; | 572 EndQueryEXT end_cmd; |
| 573 end_cmd.Init(query_type.type, 1); | 573 end_cmd.Init(query_type.type, 1); |
| 574 error::Error error2 = test->ExecuteCmd(end_cmd); | 574 error::Error error2 = test->ExecuteCmd(end_cmd); |
| 575 | 575 |
| 576 if (query_type.is_gl) { | 576 if (query_type.is_gl) { |
| 577 EXPECT_CALL( | 577 EXPECT_CALL( |
| 578 *gl, GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 578 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
| 579 .WillOnce(SetArgumentPointee<2>(1)) | 579 .WillOnce(SetArgumentPointee<2>(1)) |
| 580 .RetiresOnSaturation(); | 580 .RetiresOnSaturation(); |
| 581 EXPECT_CALL(*gl, GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _)) | 581 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) |
| 582 .WillOnce(SetArgumentPointee<2>(1)) | 582 .WillOnce(SetArgumentPointee<2>(1)) |
| 583 .RetiresOnSaturation(); | 583 .RetiresOnSaturation(); |
| 584 } | 584 } |
| 585 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | 585 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 586 #if DCHECK_IS_ON() | 586 #if DCHECK_IS_ON() |
| 587 EXPECT_CALL(*gl, IsSync(kGlSync)) | 587 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| 588 .WillOnce(Return(GL_TRUE)) | 588 .WillOnce(Return(GL_TRUE)) |
| 589 .RetiresOnSaturation(); | 589 .RetiresOnSaturation(); |
| 590 #endif | 590 #endif |
| 591 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) | 591 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) |
| 592 .WillOnce(Return(GL_ALREADY_SIGNALED)) | 592 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 593 .RetiresOnSaturation(); | 593 .RetiresOnSaturation(); |
| 594 } | 594 } |
| 595 | 595 |
| 596 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); | 596 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); |
| 597 ASSERT_TRUE(query_manager != NULL); | 597 ASSERT_TRUE(query_manager != NULL); |
| 598 bool process_success = query_manager->ProcessPendingQueries(false); | 598 bool process_success = query_manager->ProcessPendingQueries(false); |
| 599 | 599 |
| 600 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || | 600 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || |
| 601 !process_success); | 601 !process_success); |
| 602 | 602 |
| 603 if (query_type.is_gl) { | 603 if (query_type.is_gl) { |
| 604 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)).Times(1).RetiresOnSaturation(); | 604 EXPECT_CALL(*gl, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); |
| 605 } | 605 } |
| 606 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | 606 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 607 #if DCHECK_IS_ON() | 607 #if DCHECK_IS_ON() |
| 608 EXPECT_CALL(*gl, IsSync(kGlSync)) | 608 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| 609 .WillOnce(Return(GL_TRUE)) | 609 .WillOnce(Return(GL_TRUE)) |
| 610 .RetiresOnSaturation(); | 610 .RetiresOnSaturation(); |
| 611 #endif | 611 #endif |
| 612 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); | 612 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
| 613 } | 613 } |
| 614 test->ResetDecoder(); | 614 test->ResetDecoder(); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); | 1257 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
| 1258 | 1258 |
| 1259 INSTANTIATE_TEST_CASE_P(Service, | 1259 INSTANTIATE_TEST_CASE_P(Service, |
| 1260 GLES2DecoderRGBBackbufferTest, | 1260 GLES2DecoderRGBBackbufferTest, |
| 1261 ::testing::Bool()); | 1261 ::testing::Bool()); |
| 1262 | 1262 |
| 1263 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1263 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
| 1264 | 1264 |
| 1265 } // namespace gles2 | 1265 } // namespace gles2 |
| 1266 } // namespace gpu | 1266 } // namespace gpu |
| OLD | NEW |