| 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" |
| 11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" | 11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" |
| 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
| 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" |
| 14 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 14 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 15 #include "gpu/command_buffer/service/context_group.h" | 15 #include "gpu/command_buffer/service/context_group.h" |
| 16 #include "gpu/command_buffer/service/context_state.h" | 16 #include "gpu/command_buffer/service/context_state.h" |
| 17 #include "gpu/command_buffer/service/gl_surface_mock.h" | 17 #include "gpu/command_buffer/service/gl_surface_mock.h" |
| 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 19 #include "gpu/command_buffer/service/image_manager.h" | 19 #include "gpu/command_buffer/service/image_manager.h" |
| 20 #include "gpu/command_buffer/service/mailbox_manager.h" | 20 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 21 #include "gpu/command_buffer/service/mocks.h" | 21 #include "gpu/command_buffer/service/mocks.h" |
| 22 #include "gpu/command_buffer/service/program_manager.h" | 22 #include "gpu/command_buffer/service/program_manager.h" |
| 23 #include "gpu/command_buffer/service/test_helper.h" | 23 #include "gpu/command_buffer/service/test_helper.h" |
| 24 #include "gpu/config/gpu_switches.h" | 24 #include "gpu/config/gpu_switches.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "ui/gl/gl_implementation.h" | 26 #include "ui/gl/gl_implementation.h" |
| 27 #include "ui/gl/gl_mock.h" | 27 #include "ui/gl/gl_mock.h" |
| 28 #include "ui/gl/gl_surface_stub.h" | 28 #include "ui/gl/gl_surface_stub.h" |
| 29 #include "ui/gl/gpu_timing_fake.h" |
| 29 | 30 |
| 30 | 31 |
| 31 #if !defined(GL_DEPTH24_STENCIL8) | 32 #if !defined(GL_DEPTH24_STENCIL8) |
| 32 #define GL_DEPTH24_STENCIL8 0x88F0 | 33 #define GL_DEPTH24_STENCIL8 0x88F0 |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 using ::gfx::MockGLInterface; | 36 using ::gfx::MockGLInterface; |
| 36 using ::testing::_; | 37 using ::testing::_; |
| 37 using ::testing::AtLeast; | 38 using ::testing::AtLeast; |
| 38 using ::testing::DoAll; | 39 using ::testing::DoAll; |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); | 556 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); |
| 556 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 557 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 557 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 558 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 558 EXPECT_TRUE(query->pending()); | 559 EXPECT_TRUE(query->pending()); |
| 559 | 560 |
| 560 EXPECT_CALL(*gl_, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); | 561 EXPECT_CALL(*gl_, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); |
| 561 } | 562 } |
| 562 | 563 |
| 563 struct QueryType { | 564 struct QueryType { |
| 564 GLenum type; | 565 GLenum type; |
| 565 bool is_gl; | 566 bool is_counter; |
| 566 }; | 567 }; |
| 567 | 568 |
| 568 const QueryType kQueryTypes[] = { | 569 const QueryType kQueryTypes[] = { |
| 569 {GL_COMMANDS_ISSUED_CHROMIUM, false}, | 570 {GL_COMMANDS_ISSUED_CHROMIUM, false}, |
| 570 {GL_LATENCY_QUERY_CHROMIUM, false}, | 571 {GL_LATENCY_QUERY_CHROMIUM, false}, |
| 571 {GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false}, | 572 {GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false}, |
| 572 {GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false}, | 573 {GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false}, |
| 573 {GL_GET_ERROR_QUERY_CHROMIUM, false}, | 574 {GL_GET_ERROR_QUERY_CHROMIUM, false}, |
| 574 {GL_COMMANDS_COMPLETED_CHROMIUM, false}, | 575 {GL_COMMANDS_COMPLETED_CHROMIUM, false}, |
| 575 {GL_ANY_SAMPLES_PASSED_EXT, true}, | 576 {GL_ANY_SAMPLES_PASSED_EXT, false}, |
| 576 {GL_TIME_ELAPSED, true}, | 577 {GL_TIME_ELAPSED, false}, |
| 578 {GL_TIMESTAMP, true}, |
| 577 }; | 579 }; |
| 580 const GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); |
| 581 |
| 582 static void ExecuteGenerateQueryCmd(GLES2DecoderTestBase* test, |
| 583 ::gfx::MockGLInterface* gl, |
| 584 GLenum target, |
| 585 GLuint client_id, |
| 586 GLuint service_id) { |
| 587 test->GenHelper<GenQueriesEXTImmediate>(client_id); |
| 588 if (GL_ANY_SAMPLES_PASSED_EXT == target) { |
| 589 EXPECT_CALL(*gl, GenQueries(1, _)) |
| 590 .WillOnce(SetArgPointee<1>(service_id)) |
| 591 .RetiresOnSaturation(); |
| 592 } |
| 593 } |
| 594 |
| 595 static error::Error ExecuteBeginQueryCmd(GLES2DecoderTestBase* test, |
| 596 ::gfx::MockGLInterface* gl, |
| 597 ::gfx::GPUTimingFake* timing_queries, |
| 598 GLenum target, |
| 599 GLuint client_id, |
| 600 GLuint service_id, |
| 601 int32 shm_id, |
| 602 uint32 shm_offset) { |
| 603 if (GL_ANY_SAMPLES_PASSED_EXT == target) { |
| 604 EXPECT_CALL(*gl, BeginQuery(target, service_id)) |
| 605 .Times(1) |
| 606 .RetiresOnSaturation(); |
| 607 } else if (GL_TIME_ELAPSED == target) { |
| 608 timing_queries->ExpectGPUTimerQuery(*gl, true); |
| 609 } |
| 610 |
| 611 BeginQueryEXT begin_cmd; |
| 612 begin_cmd.Init(target, client_id, shm_id, shm_offset); |
| 613 return test->ExecuteCmd(begin_cmd); |
| 614 } |
| 615 |
| 616 static error::Error ExecuteEndQueryCmd(GLES2DecoderTestBase* test, |
| 617 ::gfx::MockGLInterface* gl, |
| 618 GLenum target, |
| 619 uint32_t submit_count) { |
| 620 if (GL_ANY_SAMPLES_PASSED_EXT == target) { |
| 621 EXPECT_CALL(*gl, EndQuery(target)) |
| 622 .Times(1) |
| 623 .RetiresOnSaturation(); |
| 624 } else if (GL_GET_ERROR_QUERY_CHROMIUM == target) { |
| 625 EXPECT_CALL(*gl, GetError()) |
| 626 .WillOnce(Return(GL_NO_ERROR)) |
| 627 .RetiresOnSaturation(); |
| 628 } else if (GL_COMMANDS_COMPLETED_CHROMIUM == target) { |
| 629 EXPECT_CALL(*gl, Flush()).RetiresOnSaturation(); |
| 630 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) |
| 631 .WillOnce(Return(kGlSync)) |
| 632 .RetiresOnSaturation(); |
| 633 #if DCHECK_IS_ON() |
| 634 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| 635 .WillRepeatedly(Return(GL_TRUE)); |
| 636 #endif |
| 637 } |
| 638 |
| 639 EndQueryEXT end_cmd; |
| 640 end_cmd.Init(target, submit_count); |
| 641 return test->ExecuteCmd(end_cmd); |
| 642 } |
| 643 |
| 644 static error::Error ExecuteQueryCounterCmd(GLES2DecoderTestBase* test, |
| 645 ::gfx::MockGLInterface* gl, |
| 646 ::gfx::GPUTimingFake* timing_queries, |
| 647 GLenum target, |
| 648 GLuint client_id, |
| 649 GLuint service_id, |
| 650 int32 shm_id, |
| 651 uint32 shm_offset, |
| 652 uint32_t submit_count) { |
| 653 if (GL_TIMESTAMP == target) { |
| 654 timing_queries->ExpectGPUTimeStampQuery(*gl, false); |
| 655 } |
| 656 |
| 657 QueryCounterEXT query_counter_cmd; |
| 658 query_counter_cmd.Init(client_id, |
| 659 target, |
| 660 shm_id, |
| 661 shm_offset, |
| 662 submit_count); |
| 663 return test->ExecuteCmd(query_counter_cmd); |
| 664 } |
| 665 |
| 666 static bool ProcessQuery(GLES2DecoderTestBase* test, |
| 667 ::gfx::MockGLInterface* gl, |
| 668 GLenum target, |
| 669 GLuint service_id) { |
| 670 if (GL_ANY_SAMPLES_PASSED_EXT == target) { |
| 671 EXPECT_CALL( |
| 672 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
| 673 .WillOnce(SetArgPointee<2>(1)) |
| 674 .RetiresOnSaturation(); |
| 675 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) |
| 676 .WillOnce(SetArgPointee<2>(1)) |
| 677 .RetiresOnSaturation(); |
| 678 } else if (GL_COMMANDS_COMPLETED_CHROMIUM == target) { |
| 679 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) |
| 680 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 681 .RetiresOnSaturation(); |
| 682 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
| 683 } |
| 684 |
| 685 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); |
| 686 EXPECT_TRUE(nullptr != query_manager); |
| 687 if (!query_manager) |
| 688 return false; |
| 689 |
| 690 return query_manager->ProcessPendingQueries(false); |
| 691 } |
| 578 | 692 |
| 579 static void CheckBeginEndQueryBadMemoryFails(GLES2DecoderTestBase* test, | 693 static void CheckBeginEndQueryBadMemoryFails(GLES2DecoderTestBase* test, |
| 580 GLuint client_id, | 694 GLuint client_id, |
| 581 GLuint service_id, | 695 GLuint service_id, |
| 582 const QueryType& query_type, | 696 const QueryType& query_type, |
| 583 int32 shm_id, | 697 int32 shm_id, |
| 584 uint32 shm_offset) { | 698 uint32 shm_offset) { |
| 585 // We need to reset the decoder on each iteration, because we lose the | 699 // We need to reset the decoder on each iteration, because we lose the |
| 586 // context every time. | 700 // context every time. |
| 587 GLES2DecoderTestBase::InitState init; | 701 GLES2DecoderTestBase::InitState init; |
| 588 init.extensions = "GL_EXT_occlusion_query_boolean" | 702 init.extensions = "GL_EXT_occlusion_query_boolean" |
| 589 " GL_ARB_sync" | 703 " GL_ARB_sync" |
| 590 " GL_ARB_timer_query"; | 704 " GL_ARB_timer_query"; |
| 591 init.gl_version = "opengl es 2.0"; | 705 init.gl_version = "opengl es 3.0"; |
| 592 init.has_alpha = true; | 706 init.has_alpha = true; |
| 593 init.request_alpha = true; | 707 init.request_alpha = true; |
| 594 init.bind_generates_resource = true; | 708 init.bind_generates_resource = true; |
| 595 test->InitDecoder(init); | 709 test->InitDecoder(init); |
| 596 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); | 710 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); |
| 711 ::gfx::GPUTimingFake gpu_timing_queries; |
| 597 | 712 |
| 598 BeginQueryEXT begin_cmd; | 713 ExecuteGenerateQueryCmd(test, gl, query_type.type, |
| 714 client_id, service_id); |
| 599 | 715 |
| 600 test->GenHelper<GenQueriesEXTImmediate>(client_id); | 716 // Test bad shared memory fails |
| 601 | 717 error::Error error1 = error::kNoError; |
| 602 if (query_type.is_gl) { | 718 error::Error error2 = error::kNoError; |
| 603 EXPECT_CALL(*gl, GenQueries(1, _)) | 719 if (query_type.is_counter) { |
| 604 .WillOnce(SetArgPointee<1>(service_id)) | 720 error1 = ExecuteQueryCounterCmd(test, gl, &gpu_timing_queries, |
| 605 .RetiresOnSaturation(); | 721 query_type.type, |
| 606 EXPECT_CALL(*gl, BeginQuery(query_type.type, service_id)) | 722 client_id, service_id, |
| 607 .Times(1) | 723 shm_id, shm_offset, 1); |
| 608 .RetiresOnSaturation(); | 724 } else { |
| 725 error1 = ExecuteBeginQueryCmd(test, gl, &gpu_timing_queries, |
| 726 query_type.type, |
| 727 client_id, service_id, |
| 728 shm_id, shm_offset); |
| 729 error2 = ExecuteEndQueryCmd(test, gl, query_type.type, 1); |
| 609 } | 730 } |
| 610 | 731 |
| 611 // Test bad shared memory fails | 732 bool process_success = ProcessQuery(test, gl, query_type.type, service_id); |
| 612 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset); | |
| 613 error::Error error1 = test->ExecuteCmd(begin_cmd); | |
| 614 | |
| 615 if (query_type.is_gl) { | |
| 616 EXPECT_CALL(*gl, EndQuery(query_type.type)) | |
| 617 .Times(1) | |
| 618 .RetiresOnSaturation(); | |
| 619 } | |
| 620 if (query_type.type == GL_GET_ERROR_QUERY_CHROMIUM) { | |
| 621 EXPECT_CALL(*gl, GetError()) | |
| 622 .WillOnce(Return(GL_NO_ERROR)) | |
| 623 .RetiresOnSaturation(); | |
| 624 } | |
| 625 GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); | |
| 626 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | |
| 627 EXPECT_CALL(*gl, Flush()).RetiresOnSaturation(); | |
| 628 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) | |
| 629 .WillOnce(Return(kGlSync)) | |
| 630 .RetiresOnSaturation(); | |
| 631 #if DCHECK_IS_ON() | |
| 632 EXPECT_CALL(*gl, IsSync(kGlSync)) | |
| 633 .WillOnce(Return(GL_TRUE)) | |
| 634 .RetiresOnSaturation(); | |
| 635 #endif | |
| 636 } | |
| 637 | |
| 638 EndQueryEXT end_cmd; | |
| 639 end_cmd.Init(query_type.type, 1); | |
| 640 error::Error error2 = test->ExecuteCmd(end_cmd); | |
| 641 | |
| 642 if (query_type.is_gl) { | |
| 643 EXPECT_CALL( | |
| 644 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | |
| 645 .WillOnce(SetArgPointee<2>(1)) | |
| 646 .RetiresOnSaturation(); | |
| 647 if (query_type.type == GL_TIME_ELAPSED) { | |
| 648 EXPECT_CALL(*gl, GetQueryObjectui64v(service_id, GL_QUERY_RESULT_EXT, _)) | |
| 649 .WillOnce(SetArgPointee<2>(1)) | |
| 650 .RetiresOnSaturation(); | |
| 651 } else { | |
| 652 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) | |
| 653 .WillOnce(SetArgPointee<2>(1)) | |
| 654 .RetiresOnSaturation(); | |
| 655 } | |
| 656 EXPECT_CALL(*gl, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); | |
| 657 } | |
| 658 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | |
| 659 #if DCHECK_IS_ON() | |
| 660 EXPECT_CALL(*gl, IsSync(kGlSync)) | |
| 661 .WillOnce(Return(GL_TRUE)) | |
| 662 .RetiresOnSaturation(); | |
| 663 #endif | |
| 664 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) | |
| 665 .WillOnce(Return(GL_ALREADY_SIGNALED)) | |
| 666 .RetiresOnSaturation(); | |
| 667 #if DCHECK_IS_ON() | |
| 668 EXPECT_CALL(*gl, IsSync(kGlSync)) | |
| 669 .WillOnce(Return(GL_TRUE)) | |
| 670 .RetiresOnSaturation(); | |
| 671 #endif | |
| 672 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); | |
| 673 } | |
| 674 | |
| 675 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); | |
| 676 ASSERT_TRUE(query_manager != NULL); | |
| 677 bool process_success = query_manager->ProcessPendingQueries(false); | |
| 678 | 733 |
| 679 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || | 734 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || |
| 680 !process_success); | 735 !process_success); |
| 736 |
| 737 if (GL_ANY_SAMPLES_PASSED_EXT == query_type.type) |
| 738 EXPECT_CALL(*gl, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); |
| 681 test->ResetDecoder(); | 739 test->ResetDecoder(); |
| 682 } | 740 } |
| 683 | 741 |
| 684 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { | 742 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { |
| 685 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { | 743 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { |
| 686 CheckBeginEndQueryBadMemoryFails(this, | 744 CheckBeginEndQueryBadMemoryFails(this, |
| 687 kNewClientId, | 745 kNewClientId, |
| 688 kNewServiceId, | 746 kNewServiceId, |
| 689 kQueryTypes[i], | 747 kQueryTypes[i], |
| 690 kInvalidSharedMemoryId, | 748 kInvalidSharedMemoryId, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 704 // Overflow. | 762 // Overflow. |
| 705 CheckBeginEndQueryBadMemoryFails(this, | 763 CheckBeginEndQueryBadMemoryFails(this, |
| 706 kNewClientId, | 764 kNewClientId, |
| 707 kNewServiceId, | 765 kNewServiceId, |
| 708 kQueryTypes[i], | 766 kQueryTypes[i], |
| 709 kSharedMemoryId, | 767 kSharedMemoryId, |
| 710 0xfffffffcu); | 768 0xfffffffcu); |
| 711 } | 769 } |
| 712 } | 770 } |
| 713 | 771 |
| 772 TEST_P(GLES2DecoderManualInitTest, QueryReuseTest) { |
| 773 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { |
| 774 const QueryType& query_type = kQueryTypes[i]; |
| 775 |
| 776 GLES2DecoderTestBase::InitState init; |
| 777 init.extensions = "GL_EXT_occlusion_query_boolean" |
| 778 " GL_ARB_sync" |
| 779 " GL_ARB_timer_query"; |
| 780 init.gl_version = "opengl es 3.0"; |
| 781 init.has_alpha = true; |
| 782 init.request_alpha = true; |
| 783 init.bind_generates_resource = true; |
| 784 InitDecoder(init); |
| 785 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = GetGLMock(); |
| 786 ::gfx::GPUTimingFake gpu_timing_queries; |
| 787 |
| 788 ExecuteGenerateQueryCmd(this, gl, query_type.type, |
| 789 kNewClientId, kNewServiceId); |
| 790 |
| 791 // Query once. |
| 792 if (query_type.is_counter) { |
| 793 EXPECT_EQ(error::kNoError, ExecuteQueryCounterCmd(this, gl, |
| 794 &gpu_timing_queries, |
| 795 query_type.type, |
| 796 kNewClientId, |
| 797 kNewServiceId, |
| 798 kSharedMemoryId, |
| 799 kSharedMemoryOffset, |
| 800 1)); |
| 801 } else { |
| 802 EXPECT_EQ(error::kNoError, ExecuteBeginQueryCmd(this, gl, |
| 803 &gpu_timing_queries, |
| 804 query_type.type, |
| 805 kNewClientId, |
| 806 kNewServiceId, |
| 807 kSharedMemoryId, |
| 808 kSharedMemoryOffset)); |
| 809 EXPECT_EQ(error::kNoError, ExecuteEndQueryCmd(this, gl, |
| 810 query_type.type, 1)); |
| 811 } |
| 812 |
| 813 EXPECT_TRUE(ProcessQuery(this, gl, query_type.type, kNewServiceId)); |
| 814 |
| 815 // Reuse query. |
| 816 if (query_type.is_counter) { |
| 817 EXPECT_EQ(error::kNoError, ExecuteQueryCounterCmd(this, gl, |
| 818 &gpu_timing_queries, |
| 819 query_type.type, |
| 820 kNewClientId, |
| 821 kNewServiceId, |
| 822 kSharedMemoryId, |
| 823 kSharedMemoryOffset, |
| 824 2)); |
| 825 } else { |
| 826 EXPECT_EQ(error::kNoError, ExecuteBeginQueryCmd(this, gl, |
| 827 &gpu_timing_queries, |
| 828 query_type.type, |
| 829 kNewClientId, |
| 830 kNewServiceId, |
| 831 kSharedMemoryId, |
| 832 kSharedMemoryOffset)); |
| 833 EXPECT_EQ(error::kNoError, ExecuteEndQueryCmd(this, gl, |
| 834 query_type.type, 2)); |
| 835 } |
| 836 |
| 837 EXPECT_TRUE(ProcessQuery(this, gl, query_type.type, kNewServiceId)); |
| 838 |
| 839 if (GL_ANY_SAMPLES_PASSED_EXT == query_type.type) |
| 840 EXPECT_CALL(*gl, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); |
| 841 ResetDecoder(); |
| 842 } |
| 843 } |
| 844 |
| 714 TEST_P(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { | 845 TEST_P(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { |
| 715 BeginQueryEXT begin_cmd; | 846 BeginQueryEXT begin_cmd; |
| 716 | 847 |
| 717 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 848 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 718 | 849 |
| 719 // Test valid parameters work. | 850 // Test valid parameters work. |
| 720 begin_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, | 851 begin_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, |
| 721 kNewClientId, | 852 kNewClientId, |
| 722 kSharedMemoryId, | 853 kSharedMemoryId, |
| 723 kSharedMemoryOffset); | 854 kSharedMemoryOffset); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 kSharedMemoryOffset); | 922 kSharedMemoryOffset); |
| 792 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 923 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 793 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 924 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 794 | 925 |
| 795 QueryManager* query_manager = decoder_->GetQueryManager(); | 926 QueryManager* query_manager = decoder_->GetQueryManager(); |
| 796 ASSERT_TRUE(query_manager != NULL); | 927 ASSERT_TRUE(query_manager != NULL); |
| 797 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); | 928 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
| 798 ASSERT_TRUE(query != NULL); | 929 ASSERT_TRUE(query != NULL); |
| 799 EXPECT_FALSE(query->pending()); | 930 EXPECT_FALSE(query->pending()); |
| 800 | 931 |
| 801 GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); | |
| 802 EXPECT_CALL(*gl_, Flush()).RetiresOnSaturation(); | 932 EXPECT_CALL(*gl_, Flush()).RetiresOnSaturation(); |
| 803 EXPECT_CALL(*gl_, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) | 933 EXPECT_CALL(*gl_, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) |
| 804 .WillOnce(Return(kGlSync)) | 934 .WillOnce(Return(kGlSync)) |
| 805 .RetiresOnSaturation(); | 935 .RetiresOnSaturation(); |
| 806 #if DCHECK_IS_ON() | 936 #if DCHECK_IS_ON() |
| 807 EXPECT_CALL(*gl_, IsSync(kGlSync)) | 937 EXPECT_CALL(*gl_, IsSync(kGlSync)) |
| 808 .WillOnce(Return(GL_TRUE)) | 938 .WillOnce(Return(GL_TRUE)) |
| 809 .RetiresOnSaturation(); | 939 .RetiresOnSaturation(); |
| 810 #endif | 940 #endif |
| 811 | 941 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 1006 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 877 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 1007 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 878 | 1008 |
| 879 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, | 1009 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, |
| 880 kNewClientId, | 1010 kNewClientId, |
| 881 kSharedMemoryId, | 1011 kSharedMemoryId, |
| 882 kSharedMemoryOffset); | 1012 kSharedMemoryOffset); |
| 883 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 1013 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 884 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 1014 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 885 | 1015 |
| 1016 begin_cmd.Init(GL_TIME_ELAPSED, |
| 1017 kNewClientId, |
| 1018 kSharedMemoryId, |
| 1019 kSharedMemoryOffset); |
| 1020 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 1021 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1022 |
| 886 begin_cmd.Init(0xdeadbeef, | 1023 begin_cmd.Init(0xdeadbeef, |
| 887 kNewClientId, | 1024 kNewClientId, |
| 888 kSharedMemoryId, | 1025 kSharedMemoryId, |
| 889 kSharedMemoryOffset); | 1026 kSharedMemoryOffset); |
| 890 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 1027 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 1028 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1029 } |
| 1030 |
| 1031 TEST_P(GLES2DecoderManualInitTest, QueryCounterEXTTimeStamp) { |
| 1032 InitState init; |
| 1033 init.extensions = "GL_ARB_timer_query"; |
| 1034 init.gl_version = "opengl 2.0"; |
| 1035 init.has_alpha = true; |
| 1036 init.request_alpha = true; |
| 1037 init.bind_generates_resource = true; |
| 1038 InitDecoder(init); |
| 1039 |
| 1040 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 1041 |
| 1042 EXPECT_CALL(*gl_, GenQueries(1, _)) |
| 1043 .WillOnce(SetArgPointee<1>(kNewServiceId)) |
| 1044 .RetiresOnSaturation(); |
| 1045 EXPECT_CALL(*gl_, QueryCounter(kNewServiceId, GL_TIMESTAMP)) |
| 1046 .Times(1) |
| 1047 .RetiresOnSaturation(); |
| 1048 QueryCounterEXT query_counter_cmd; |
| 1049 query_counter_cmd.Init(kNewClientId, |
| 1050 GL_TIMESTAMP, |
| 1051 kSharedMemoryId, |
| 1052 kSharedMemoryOffset, |
| 1053 1); |
| 1054 EXPECT_EQ(error::kNoError, ExecuteCmd(query_counter_cmd)); |
| 1055 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1056 |
| 1057 QueryManager* query_manager = decoder_->GetQueryManager(); |
| 1058 ASSERT_TRUE(query_manager != NULL); |
| 1059 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
| 1060 ASSERT_TRUE(query != NULL); |
| 1061 EXPECT_TRUE(query->pending()); |
| 1062 } |
| 1063 |
| 1064 TEST_P(GLES2DecoderManualInitTest, InvalidTargetQueryCounterFails) { |
| 1065 InitState init; |
| 1066 init.extensions = ""; |
| 1067 init.gl_version = "opengl es 2.0"; |
| 1068 init.has_alpha = true; |
| 1069 init.request_alpha = true; |
| 1070 init.bind_generates_resource = true; |
| 1071 InitDecoder(init); |
| 1072 |
| 1073 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 1074 |
| 1075 QueryCounterEXT query_counter_cmd; |
| 1076 query_counter_cmd.Init(kNewClientId, |
| 1077 GL_TIMESTAMP, |
| 1078 kSharedMemoryId, |
| 1079 kSharedMemoryOffset, |
| 1080 1); |
| 1081 EXPECT_EQ(error::kNoError, ExecuteCmd(query_counter_cmd)); |
| 891 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 1082 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1083 |
| 1084 query_counter_cmd.Init(kNewClientId, |
| 1085 0xdeadbeef, |
| 1086 kSharedMemoryId, |
| 1087 kSharedMemoryOffset, |
| 1088 1); |
| 1089 EXPECT_EQ(error::kNoError, ExecuteCmd(query_counter_cmd)); |
| 1090 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 892 } | 1091 } |
| 893 | 1092 |
| 894 TEST_P(GLES2DecoderTest, IsEnabledReturnsCachedValue) { | 1093 TEST_P(GLES2DecoderTest, IsEnabledReturnsCachedValue) { |
| 895 // NOTE: There are no expectations because no GL functions should be | 1094 // NOTE: There are no expectations because no GL functions should be |
| 896 // called for DEPTH_TEST or STENCIL_TEST | 1095 // called for DEPTH_TEST or STENCIL_TEST |
| 897 static const GLenum kStates[] = { | 1096 static const GLenum kStates[] = { |
| 898 GL_DEPTH_TEST, GL_STENCIL_TEST, | 1097 GL_DEPTH_TEST, GL_STENCIL_TEST, |
| 899 }; | 1098 }; |
| 900 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { | 1099 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { |
| 901 Enable enable_cmd; | 1100 Enable enable_cmd; |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 INSTANTIATE_TEST_CASE_P(Service, | 1579 INSTANTIATE_TEST_CASE_P(Service, |
| 1381 GLES2DecoderRGBBackbufferTest, | 1580 GLES2DecoderRGBBackbufferTest, |
| 1382 ::testing::Bool()); | 1581 ::testing::Bool()); |
| 1383 | 1582 |
| 1384 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1583 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
| 1385 | 1584 |
| 1386 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); | 1585 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); |
| 1387 | 1586 |
| 1388 } // namespace gles2 | 1587 } // namespace gles2 |
| 1389 } // namespace gpu | 1588 } // namespace gpu |
| OLD | NEW |