| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 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 #include "ui/gl/gpu_timing_fake.h" |
| 30 | 30 |
| 31 | 31 |
| 32 #if !defined(GL_DEPTH24_STENCIL8) | 32 #if !defined(GL_DEPTH24_STENCIL8) |
| 33 #define GL_DEPTH24_STENCIL8 0x88F0 | 33 #define GL_DEPTH24_STENCIL8 0x88F0 |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 using ::gfx::MockGLInterface; | 36 using ::gl::MockGLInterface; |
| 37 using ::testing::_; | 37 using ::testing::_; |
| 38 using ::testing::AtLeast; | 38 using ::testing::AtLeast; |
| 39 using ::testing::DoAll; | 39 using ::testing::DoAll; |
| 40 using ::testing::InSequence; | 40 using ::testing::InSequence; |
| 41 using ::testing::Invoke; | 41 using ::testing::Invoke; |
| 42 using ::testing::MatcherCast; | 42 using ::testing::MatcherCast; |
| 43 using ::testing::Mock; | 43 using ::testing::Mock; |
| 44 using ::testing::Pointee; | 44 using ::testing::Pointee; |
| 45 using ::testing::Return; | 45 using ::testing::Return; |
| 46 using ::testing::SaveArg; | 46 using ::testing::SaveArg; |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 {GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false}, | 599 {GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false}, |
| 600 {GL_GET_ERROR_QUERY_CHROMIUM, false}, | 600 {GL_GET_ERROR_QUERY_CHROMIUM, false}, |
| 601 {GL_COMMANDS_COMPLETED_CHROMIUM, false}, | 601 {GL_COMMANDS_COMPLETED_CHROMIUM, false}, |
| 602 {GL_ANY_SAMPLES_PASSED_EXT, false}, | 602 {GL_ANY_SAMPLES_PASSED_EXT, false}, |
| 603 {GL_TIME_ELAPSED, false}, | 603 {GL_TIME_ELAPSED, false}, |
| 604 {GL_TIMESTAMP, true}, | 604 {GL_TIMESTAMP, true}, |
| 605 }; | 605 }; |
| 606 const GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); | 606 const GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); |
| 607 | 607 |
| 608 static void ExecuteGenerateQueryCmd(GLES2DecoderTestBase* test, | 608 static void ExecuteGenerateQueryCmd(GLES2DecoderTestBase* test, |
| 609 ::gfx::MockGLInterface* gl, | 609 ::gl::MockGLInterface* gl, |
| 610 GLenum target, | 610 GLenum target, |
| 611 GLuint client_id, | 611 GLuint client_id, |
| 612 GLuint service_id) { | 612 GLuint service_id) { |
| 613 test->GenHelper<GenQueriesEXTImmediate>(client_id); | 613 test->GenHelper<GenQueriesEXTImmediate>(client_id); |
| 614 if (GL_ANY_SAMPLES_PASSED_EXT == target) { | 614 if (GL_ANY_SAMPLES_PASSED_EXT == target) { |
| 615 EXPECT_CALL(*gl, GenQueries(1, _)) | 615 EXPECT_CALL(*gl, GenQueries(1, _)) |
| 616 .WillOnce(SetArgPointee<1>(service_id)) | 616 .WillOnce(SetArgPointee<1>(service_id)) |
| 617 .RetiresOnSaturation(); | 617 .RetiresOnSaturation(); |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 static error::Error ExecuteBeginQueryCmd(GLES2DecoderTestBase* test, | 621 static error::Error ExecuteBeginQueryCmd(GLES2DecoderTestBase* test, |
| 622 ::gfx::MockGLInterface* gl, | 622 ::gl::MockGLInterface* gl, |
| 623 ::gfx::GPUTimingFake* timing_queries, | 623 ::gl::GPUTimingFake* timing_queries, |
| 624 GLenum target, | 624 GLenum target, |
| 625 GLuint client_id, | 625 GLuint client_id, |
| 626 GLuint service_id, | 626 GLuint service_id, |
| 627 int32_t shm_id, | 627 int32_t shm_id, |
| 628 uint32_t shm_offset) { | 628 uint32_t shm_offset) { |
| 629 if (GL_ANY_SAMPLES_PASSED_EXT == target) { | 629 if (GL_ANY_SAMPLES_PASSED_EXT == target) { |
| 630 EXPECT_CALL(*gl, BeginQuery(target, service_id)) | 630 EXPECT_CALL(*gl, BeginQuery(target, service_id)) |
| 631 .Times(1) | 631 .Times(1) |
| 632 .RetiresOnSaturation(); | 632 .RetiresOnSaturation(); |
| 633 } else if (GL_TIME_ELAPSED == target) { | 633 } else if (GL_TIME_ELAPSED == target) { |
| 634 timing_queries->ExpectGPUTimerQuery(*gl, true); | 634 timing_queries->ExpectGPUTimerQuery(*gl, true); |
| 635 } | 635 } |
| 636 | 636 |
| 637 BeginQueryEXT begin_cmd; | 637 BeginQueryEXT begin_cmd; |
| 638 begin_cmd.Init(target, client_id, shm_id, shm_offset); | 638 begin_cmd.Init(target, client_id, shm_id, shm_offset); |
| 639 return test->ExecuteCmd(begin_cmd); | 639 return test->ExecuteCmd(begin_cmd); |
| 640 } | 640 } |
| 641 | 641 |
| 642 static error::Error ExecuteEndQueryCmd(GLES2DecoderTestBase* test, | 642 static error::Error ExecuteEndQueryCmd(GLES2DecoderTestBase* test, |
| 643 ::gfx::MockGLInterface* gl, | 643 ::gl::MockGLInterface* gl, |
| 644 GLenum target, | 644 GLenum target, |
| 645 uint32_t submit_count) { | 645 uint32_t submit_count) { |
| 646 if (GL_ANY_SAMPLES_PASSED_EXT == target) { | 646 if (GL_ANY_SAMPLES_PASSED_EXT == target) { |
| 647 EXPECT_CALL(*gl, EndQuery(target)) | 647 EXPECT_CALL(*gl, EndQuery(target)) |
| 648 .Times(1) | 648 .Times(1) |
| 649 .RetiresOnSaturation(); | 649 .RetiresOnSaturation(); |
| 650 } else if (GL_GET_ERROR_QUERY_CHROMIUM == target) { | 650 } else if (GL_GET_ERROR_QUERY_CHROMIUM == target) { |
| 651 EXPECT_CALL(*gl, GetError()) | 651 EXPECT_CALL(*gl, GetError()) |
| 652 .WillOnce(Return(GL_NO_ERROR)) | 652 .WillOnce(Return(GL_NO_ERROR)) |
| 653 .RetiresOnSaturation(); | 653 .RetiresOnSaturation(); |
| 654 } else if (GL_COMMANDS_COMPLETED_CHROMIUM == target) { | 654 } else if (GL_COMMANDS_COMPLETED_CHROMIUM == target) { |
| 655 EXPECT_CALL(*gl, Flush()).RetiresOnSaturation(); | 655 EXPECT_CALL(*gl, Flush()).RetiresOnSaturation(); |
| 656 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) | 656 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) |
| 657 .WillOnce(Return(kGlSync)) | 657 .WillOnce(Return(kGlSync)) |
| 658 .RetiresOnSaturation(); | 658 .RetiresOnSaturation(); |
| 659 #if DCHECK_IS_ON() | 659 #if DCHECK_IS_ON() |
| 660 EXPECT_CALL(*gl, IsSync(kGlSync)) | 660 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| 661 .WillRepeatedly(Return(GL_TRUE)); | 661 .WillRepeatedly(Return(GL_TRUE)); |
| 662 #endif | 662 #endif |
| 663 } | 663 } |
| 664 | 664 |
| 665 EndQueryEXT end_cmd; | 665 EndQueryEXT end_cmd; |
| 666 end_cmd.Init(target, submit_count); | 666 end_cmd.Init(target, submit_count); |
| 667 return test->ExecuteCmd(end_cmd); | 667 return test->ExecuteCmd(end_cmd); |
| 668 } | 668 } |
| 669 | 669 |
| 670 static error::Error ExecuteQueryCounterCmd(GLES2DecoderTestBase* test, | 670 static error::Error ExecuteQueryCounterCmd(GLES2DecoderTestBase* test, |
| 671 ::gfx::MockGLInterface* gl, | 671 ::gl::MockGLInterface* gl, |
| 672 ::gfx::GPUTimingFake* timing_queries, | 672 ::gl::GPUTimingFake* timing_queries, |
| 673 GLenum target, | 673 GLenum target, |
| 674 GLuint client_id, | 674 GLuint client_id, |
| 675 GLuint service_id, | 675 GLuint service_id, |
| 676 int32_t shm_id, | 676 int32_t shm_id, |
| 677 uint32_t shm_offset, | 677 uint32_t shm_offset, |
| 678 uint32_t submit_count) { | 678 uint32_t submit_count) { |
| 679 if (GL_TIMESTAMP == target) { | 679 if (GL_TIMESTAMP == target) { |
| 680 timing_queries->ExpectGPUTimeStampQuery(*gl, false); | 680 timing_queries->ExpectGPUTimeStampQuery(*gl, false); |
| 681 } | 681 } |
| 682 | 682 |
| 683 QueryCounterEXT query_counter_cmd; | 683 QueryCounterEXT query_counter_cmd; |
| 684 query_counter_cmd.Init(client_id, | 684 query_counter_cmd.Init(client_id, |
| 685 target, | 685 target, |
| 686 shm_id, | 686 shm_id, |
| 687 shm_offset, | 687 shm_offset, |
| 688 submit_count); | 688 submit_count); |
| 689 return test->ExecuteCmd(query_counter_cmd); | 689 return test->ExecuteCmd(query_counter_cmd); |
| 690 } | 690 } |
| 691 | 691 |
| 692 static bool ProcessQuery(GLES2DecoderTestBase* test, | 692 static bool ProcessQuery(GLES2DecoderTestBase* test, |
| 693 ::gfx::MockGLInterface* gl, | 693 ::gl::MockGLInterface* gl, |
| 694 GLenum target, | 694 GLenum target, |
| 695 GLuint service_id) { | 695 GLuint service_id) { |
| 696 if (GL_ANY_SAMPLES_PASSED_EXT == target) { | 696 if (GL_ANY_SAMPLES_PASSED_EXT == target) { |
| 697 EXPECT_CALL( | 697 EXPECT_CALL( |
| 698 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 698 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
| 699 .WillOnce(SetArgPointee<2>(1)) | 699 .WillOnce(SetArgPointee<2>(1)) |
| 700 .RetiresOnSaturation(); | 700 .RetiresOnSaturation(); |
| 701 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) | 701 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) |
| 702 .WillOnce(SetArgPointee<2>(1)) | 702 .WillOnce(SetArgPointee<2>(1)) |
| 703 .RetiresOnSaturation(); | 703 .RetiresOnSaturation(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 726 // context every time. | 726 // context every time. |
| 727 GLES2DecoderTestBase::InitState init; | 727 GLES2DecoderTestBase::InitState init; |
| 728 init.extensions = "GL_EXT_occlusion_query_boolean" | 728 init.extensions = "GL_EXT_occlusion_query_boolean" |
| 729 " GL_ARB_sync" | 729 " GL_ARB_sync" |
| 730 " GL_ARB_timer_query"; | 730 " GL_ARB_timer_query"; |
| 731 init.gl_version = "opengl es 3.0"; | 731 init.gl_version = "opengl es 3.0"; |
| 732 init.has_alpha = true; | 732 init.has_alpha = true; |
| 733 init.request_alpha = true; | 733 init.request_alpha = true; |
| 734 init.bind_generates_resource = true; | 734 init.bind_generates_resource = true; |
| 735 test->InitDecoder(init); | 735 test->InitDecoder(init); |
| 736 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); | 736 ::testing::StrictMock<::gl::MockGLInterface>* gl = test->GetGLMock(); |
| 737 ::gfx::GPUTimingFake gpu_timing_queries; | 737 ::gl::GPUTimingFake gpu_timing_queries; |
| 738 | 738 |
| 739 ExecuteGenerateQueryCmd(test, gl, query_type.type, | 739 ExecuteGenerateQueryCmd(test, gl, query_type.type, |
| 740 client_id, service_id); | 740 client_id, service_id); |
| 741 | 741 |
| 742 // Test bad shared memory fails | 742 // Test bad shared memory fails |
| 743 error::Error error1 = error::kNoError; | 743 error::Error error1 = error::kNoError; |
| 744 error::Error error2 = error::kNoError; | 744 error::Error error2 = error::kNoError; |
| 745 if (query_type.is_counter) { | 745 if (query_type.is_counter) { |
| 746 error1 = | 746 error1 = |
| 747 ExecuteQueryCounterCmd(test, gl, &gpu_timing_queries, query_type.type, | 747 ExecuteQueryCounterCmd(test, gl, &gpu_timing_queries, query_type.type, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 | 800 |
| 801 GLES2DecoderTestBase::InitState init; | 801 GLES2DecoderTestBase::InitState init; |
| 802 init.extensions = "GL_EXT_occlusion_query_boolean" | 802 init.extensions = "GL_EXT_occlusion_query_boolean" |
| 803 " GL_ARB_sync" | 803 " GL_ARB_sync" |
| 804 " GL_ARB_timer_query"; | 804 " GL_ARB_timer_query"; |
| 805 init.gl_version = "opengl es 3.0"; | 805 init.gl_version = "opengl es 3.0"; |
| 806 init.has_alpha = true; | 806 init.has_alpha = true; |
| 807 init.request_alpha = true; | 807 init.request_alpha = true; |
| 808 init.bind_generates_resource = true; | 808 init.bind_generates_resource = true; |
| 809 InitDecoder(init); | 809 InitDecoder(init); |
| 810 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = GetGLMock(); | 810 ::testing::StrictMock<::gl::MockGLInterface>* gl = GetGLMock(); |
| 811 ::gfx::GPUTimingFake gpu_timing_queries; | 811 ::gl::GPUTimingFake gpu_timing_queries; |
| 812 | 812 |
| 813 ExecuteGenerateQueryCmd(this, gl, query_type.type, | 813 ExecuteGenerateQueryCmd(this, gl, query_type.type, |
| 814 kNewClientId, kNewServiceId); | 814 kNewClientId, kNewServiceId); |
| 815 | 815 |
| 816 // Query once. | 816 // Query once. |
| 817 if (query_type.is_counter) { | 817 if (query_type.is_counter) { |
| 818 EXPECT_EQ( | 818 EXPECT_EQ( |
| 819 error::kNoError, | 819 error::kNoError, |
| 820 ExecuteQueryCounterCmd(this, gl, &gpu_timing_queries, query_type.type, | 820 ExecuteQueryCounterCmd(this, gl, &gpu_timing_queries, query_type.type, |
| 821 kNewClientId, kNewServiceId, kSharedMemoryId, | 821 kNewClientId, kNewServiceId, kSharedMemoryId, |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1716 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
| 1717 | 1717 |
| 1718 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); | 1718 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); |
| 1719 | 1719 |
| 1720 INSTANTIATE_TEST_CASE_P(Service, | 1720 INSTANTIATE_TEST_CASE_P(Service, |
| 1721 GLES3DecoderWithESSL3ShaderTest, | 1721 GLES3DecoderWithESSL3ShaderTest, |
| 1722 ::testing::Bool()); | 1722 ::testing::Bool()); |
| 1723 | 1723 |
| 1724 } // namespace gles2 | 1724 } // namespace gles2 |
| 1725 } // namespace gpu | 1725 } // namespace gpu |
| OLD | NEW |