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 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 cmds_[1].header.size += 1; | 1685 cmds_[1].header.size += 1; |
1686 int num_processed = -1; | 1686 int num_processed = -1; |
1687 SetExpectationsForNCommands(1); | 1687 SetExpectationsForNCommands(1); |
1688 EXPECT_EQ(error::kInvalidArguments, | 1688 EXPECT_EQ(error::kInvalidArguments, |
1689 decoder_->DoCommands( | 1689 decoder_->DoCommands( |
1690 2, &cmds_, entries_per_cmd_ * 2 + 1, &num_processed)); | 1690 2, &cmds_, entries_per_cmd_ * 2 + 1, &num_processed)); |
1691 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1691 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
1692 EXPECT_EQ(entries_per_cmd_ + cmds_[1].header.size, num_processed); | 1692 EXPECT_EQ(entries_per_cmd_ + cmds_[1].header.size, num_processed); |
1693 } | 1693 } |
1694 | 1694 |
| 1695 class GLES2DecoderDescheduleUntilFinishedTest : public GLES2DecoderTest { |
| 1696 public: |
| 1697 GLES2DecoderDescheduleUntilFinishedTest() { |
| 1698 } |
| 1699 |
| 1700 void SetUp() override { |
| 1701 InitState init; |
| 1702 init.gl_version = "4.4"; |
| 1703 init.extensions += " GL_ARB_compatibility GL_ARB_sync"; |
| 1704 InitDecoder(init); |
| 1705 |
| 1706 GetDecoder()->SetDescheduleUntilFinishedCallback( |
| 1707 base::Bind(&GLES2DecoderDescheduleUntilFinishedTest:: |
| 1708 DescheduleUntilFinishedCallback, |
| 1709 base::Unretained(this))); |
| 1710 GetDecoder()->SetRescheduleAfterFinishedCallback( |
| 1711 base::Bind(&GLES2DecoderDescheduleUntilFinishedTest:: |
| 1712 RescheduleAfterFinishedCallback, |
| 1713 base::Unretained(this))); |
| 1714 |
| 1715 EXPECT_CALL(*gl_, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) |
| 1716 .Times(1) |
| 1717 .WillOnce(Return(sync_service_id_)) |
| 1718 .RetiresOnSaturation(); |
| 1719 EXPECT_CALL(*gl_, IsSync(sync_service_id_)).WillRepeatedly(Return(GL_TRUE)); |
| 1720 EXPECT_CALL(*gl_, Flush()).RetiresOnSaturation(); |
| 1721 EXPECT_CALL(*gl_, DeleteSync(sync_service_id_)) |
| 1722 .Times(1) |
| 1723 .RetiresOnSaturation(); |
| 1724 } |
| 1725 |
| 1726 void DescheduleUntilFinishedCallback() { |
| 1727 deschedule_until_finished_callback_count_++; |
| 1728 } |
| 1729 void RescheduleAfterFinishedCallback() { |
| 1730 reschedule_after_finished_callback_count_++; |
| 1731 } |
| 1732 |
| 1733 protected: |
| 1734 int deschedule_until_finished_callback_count_ = 0; |
| 1735 int reschedule_after_finished_callback_count_ = 0; |
| 1736 GLsync sync_service_id_ = reinterpret_cast<GLsync>(0x15); |
| 1737 }; |
| 1738 |
| 1739 TEST_P(GLES2DecoderDescheduleUntilFinishedTest, AlreadySignalled) { |
| 1740 EXPECT_CALL(*gl_, ClientWaitSync(sync_service_id_, 0, 0)) |
| 1741 .Times(1) |
| 1742 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 1743 .RetiresOnSaturation(); |
| 1744 |
| 1745 cmds::DescheduleUntilFinishedCHROMIUM cmd; |
| 1746 cmd.Init(); |
| 1747 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1748 EXPECT_EQ(0, deschedule_until_finished_callback_count_); |
| 1749 EXPECT_EQ(0, reschedule_after_finished_callback_count_); |
| 1750 } |
| 1751 |
| 1752 TEST_P(GLES2DecoderDescheduleUntilFinishedTest, NotYetSignalled) { |
| 1753 EXPECT_CALL(*gl_, ClientWaitSync(sync_service_id_, 0, 0)) |
| 1754 .Times(1) |
| 1755 .WillOnce(Return(GL_TIMEOUT_EXPIRED)) |
| 1756 .RetiresOnSaturation(); |
| 1757 |
| 1758 cmds::DescheduleUntilFinishedCHROMIUM cmd; |
| 1759 cmd.Init(); |
| 1760 EXPECT_EQ(error::kDeferLaterCommands, ExecuteCmd(cmd)); |
| 1761 EXPECT_EQ(1, deschedule_until_finished_callback_count_); |
| 1762 EXPECT_EQ(0, reschedule_after_finished_callback_count_); |
| 1763 } |
| 1764 |
1695 void GLES3DecoderWithESSL3ShaderTest::SetUp() { | 1765 void GLES3DecoderWithESSL3ShaderTest::SetUp() { |
1696 base::CommandLine command_line(0, nullptr); | 1766 base::CommandLine command_line(0, nullptr); |
1697 command_line.AppendSwitch(switches::kEnableUnsafeES3APIs); | 1767 command_line.AppendSwitch(switches::kEnableUnsafeES3APIs); |
1698 InitState init; | 1768 InitState init; |
1699 init.gl_version = "OpenGL ES 3.0"; | 1769 init.gl_version = "OpenGL ES 3.0"; |
1700 init.bind_generates_resource = true; | 1770 init.bind_generates_resource = true; |
1701 init.context_type = CONTEXT_TYPE_OPENGLES3; | 1771 init.context_type = CONTEXT_TYPE_OPENGLES3; |
1702 InitDecoderWithCommandLine(init, &command_line); | 1772 InitDecoderWithCommandLine(init, &command_line); |
1703 SetupDefaultProgram(); | 1773 SetupDefaultProgram(); |
1704 } | 1774 } |
1705 | 1775 |
1706 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool()); | 1776 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool()); |
1707 | 1777 |
1708 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool()); | 1778 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool()); |
1709 | 1779 |
1710 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); | 1780 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
1711 | 1781 |
1712 INSTANTIATE_TEST_CASE_P(Service, | 1782 INSTANTIATE_TEST_CASE_P(Service, |
1713 GLES2DecoderRGBBackbufferTest, | 1783 GLES2DecoderRGBBackbufferTest, |
1714 ::testing::Bool()); | 1784 ::testing::Bool()); |
1715 | 1785 |
1716 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1786 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
1717 | 1787 |
| 1788 INSTANTIATE_TEST_CASE_P(Service, |
| 1789 GLES2DecoderDescheduleUntilFinishedTest, |
| 1790 ::testing::Bool()); |
| 1791 |
1718 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); | 1792 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); |
1719 | 1793 |
1720 INSTANTIATE_TEST_CASE_P(Service, | 1794 INSTANTIATE_TEST_CASE_P(Service, |
1721 GLES3DecoderWithESSL3ShaderTest, | 1795 GLES3DecoderWithESSL3ShaderTest, |
1722 ::testing::Bool()); | 1796 ::testing::Bool()); |
1723 | 1797 |
1724 } // namespace gles2 | 1798 } // namespace gles2 |
1725 } // namespace gpu | 1799 } // namespace gpu |
OLD | NEW |