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 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
(...skipping 3739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3750 Cmds expected; | 3750 Cmds expected; |
3751 expected.insert_fence_sync.Init(kFenceSync); | 3751 expected.insert_fence_sync.Init(kFenceSync); |
3752 | 3752 |
3753 const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM(); | 3753 const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM(); |
3754 EXPECT_EQ(kFenceSync, fence_sync); | 3754 EXPECT_EQ(kFenceSync, fence_sync); |
3755 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3755 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
3756 } | 3756 } |
3757 | 3757 |
3758 TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) { | 3758 TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) { |
3759 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; | 3759 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; |
3760 const GLuint64 kCommandBufferId = 234u; | 3760 const CommandBufferId kCommandBufferId = |
| 3761 CommandBufferId::FromUnsafeValue(234u); |
3761 const GLuint64 kFenceSync = 123u; | 3762 const GLuint64 kFenceSync = 123u; |
3762 GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM]; | 3763 GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM]; |
3763 | 3764 |
3764 EXPECT_CALL(*gpu_control_, GetNamespaceID()) | 3765 EXPECT_CALL(*gpu_control_, GetNamespaceID()) |
3765 .WillRepeatedly(testing::Return(kNamespaceId)); | 3766 .WillRepeatedly(testing::Return(kNamespaceId)); |
3766 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) | 3767 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) |
3767 .WillRepeatedly(testing::Return(kCommandBufferId)); | 3768 .WillRepeatedly(testing::Return(kCommandBufferId)); |
3768 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()) | 3769 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()) |
3769 .WillRepeatedly(testing::Return(0)); | 3770 .WillRepeatedly(testing::Return(0)); |
3770 | 3771 |
(...skipping 24 matching lines...) Expand all Loading... |
3795 SyncToken sync_token; | 3796 SyncToken sync_token; |
3796 memcpy(&sync_token, sync_token_data, sizeof(SyncToken)); | 3797 memcpy(&sync_token, sync_token_data, sizeof(SyncToken)); |
3797 EXPECT_TRUE(sync_token.verified_flush()); | 3798 EXPECT_TRUE(sync_token.verified_flush()); |
3798 EXPECT_EQ(kNamespaceId, sync_token.namespace_id()); | 3799 EXPECT_EQ(kNamespaceId, sync_token.namespace_id()); |
3799 EXPECT_EQ(kCommandBufferId, sync_token.command_buffer_id()); | 3800 EXPECT_EQ(kCommandBufferId, sync_token.command_buffer_id()); |
3800 EXPECT_EQ(kFenceSync, sync_token.release_count()); | 3801 EXPECT_EQ(kFenceSync, sync_token.release_count()); |
3801 } | 3802 } |
3802 | 3803 |
3803 TEST_F(GLES2ImplementationTest, GenUnverifiedSyncTokenCHROMIUM) { | 3804 TEST_F(GLES2ImplementationTest, GenUnverifiedSyncTokenCHROMIUM) { |
3804 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; | 3805 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; |
3805 const GLuint64 kCommandBufferId = 234u; | 3806 const CommandBufferId kCommandBufferId = |
| 3807 CommandBufferId::FromUnsafeValue(234u); |
3806 const GLuint64 kFenceSync = 123u; | 3808 const GLuint64 kFenceSync = 123u; |
3807 GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM]; | 3809 GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM]; |
3808 | 3810 |
3809 EXPECT_CALL(*gpu_control_, GetNamespaceID()) | 3811 EXPECT_CALL(*gpu_control_, GetNamespaceID()) |
3810 .WillRepeatedly(testing::Return(kNamespaceId)); | 3812 .WillRepeatedly(testing::Return(kNamespaceId)); |
3811 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) | 3813 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) |
3812 .WillRepeatedly(testing::Return(kCommandBufferId)); | 3814 .WillRepeatedly(testing::Return(kCommandBufferId)); |
3813 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()) | 3815 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()) |
3814 .WillRepeatedly(testing::Return(0)); | 3816 .WillRepeatedly(testing::Return(0)); |
3815 | 3817 |
(...skipping 30 matching lines...) Expand all Loading... |
3846 } | 3848 } |
3847 | 3849 |
3848 TEST_F(GLES2ImplementationTest, VerifySyncTokensCHROMIUM) { | 3850 TEST_F(GLES2ImplementationTest, VerifySyncTokensCHROMIUM) { |
3849 ExpectedMemoryInfo result = | 3851 ExpectedMemoryInfo result = |
3850 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 3852 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
3851 EXPECT_CALL(*command_buffer(), OnFlush()) | 3853 EXPECT_CALL(*command_buffer(), OnFlush()) |
3852 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) | 3854 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) |
3853 .RetiresOnSaturation(); | 3855 .RetiresOnSaturation(); |
3854 | 3856 |
3855 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; | 3857 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; |
3856 const GLuint64 kCommandBufferId = 234u; | 3858 const CommandBufferId kCommandBufferId = |
| 3859 CommandBufferId::FromUnsafeValue(234u); |
3857 const GLuint64 kFenceSync = 123u; | 3860 const GLuint64 kFenceSync = 123u; |
3858 gpu::SyncToken sync_token; | 3861 gpu::SyncToken sync_token; |
3859 GLbyte* sync_token_datas[] = { sync_token.GetData() }; | 3862 GLbyte* sync_token_datas[] = { sync_token.GetData() }; |
3860 | 3863 |
3861 EXPECT_CALL(*gpu_control_, GetNamespaceID()) | 3864 EXPECT_CALL(*gpu_control_, GetNamespaceID()) |
3862 .WillRepeatedly(testing::Return(kNamespaceId)); | 3865 .WillRepeatedly(testing::Return(kNamespaceId)); |
3863 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) | 3866 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) |
3864 .WillRepeatedly(testing::Return(kCommandBufferId)); | 3867 .WillRepeatedly(testing::Return(kCommandBufferId)); |
3865 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()) | 3868 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()) |
3866 .WillRepeatedly(testing::Return(0)); | 3869 .WillRepeatedly(testing::Return(0)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3899 // To verify sync tokens, the sync tokens must all be verified after | 3902 // To verify sync tokens, the sync tokens must all be verified after |
3900 // CanWaitUnverifiedSyncTokens() are called. This test ensures the right | 3903 // CanWaitUnverifiedSyncTokens() are called. This test ensures the right |
3901 // sequence. | 3904 // sequence. |
3902 ExpectedMemoryInfo result = | 3905 ExpectedMemoryInfo result = |
3903 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 3906 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
3904 EXPECT_CALL(*command_buffer(), OnFlush()) | 3907 EXPECT_CALL(*command_buffer(), OnFlush()) |
3905 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) | 3908 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) |
3906 .RetiresOnSaturation(); | 3909 .RetiresOnSaturation(); |
3907 | 3910 |
3908 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; | 3911 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; |
3909 const GLuint64 kCommandBufferId = 234u; | 3912 const CommandBufferId kCommandBufferId = |
| 3913 CommandBufferId::FromUnsafeValue(234u); |
3910 const GLuint64 kFenceSync1 = 123u; | 3914 const GLuint64 kFenceSync1 = 123u; |
3911 const GLuint64 kFenceSync2 = 234u; | 3915 const GLuint64 kFenceSync2 = 234u; |
3912 gpu::SyncToken sync_token1; | 3916 gpu::SyncToken sync_token1; |
3913 gpu::SyncToken sync_token2; | 3917 gpu::SyncToken sync_token2; |
3914 GLbyte* sync_token_datas[] = { sync_token1.GetData(), sync_token2.GetData() }; | 3918 GLbyte* sync_token_datas[] = { sync_token1.GetData(), sync_token2.GetData() }; |
3915 | 3919 |
3916 EXPECT_CALL(*gpu_control_, GetNamespaceID()) | 3920 EXPECT_CALL(*gpu_control_, GetNamespaceID()) |
3917 .WillRepeatedly(Return(kNamespaceId)); | 3921 .WillRepeatedly(Return(kNamespaceId)); |
3918 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) | 3922 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) |
3919 .WillRepeatedly(Return(kCommandBufferId)); | 3923 .WillRepeatedly(Return(kCommandBufferId)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3951 gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas)); | 3955 gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas)); |
3952 EXPECT_TRUE(NoCommandsWritten()); | 3956 EXPECT_TRUE(NoCommandsWritten()); |
3953 EXPECT_EQ(GL_NO_ERROR, CheckError()); | 3957 EXPECT_EQ(GL_NO_ERROR, CheckError()); |
3954 | 3958 |
3955 EXPECT_TRUE(sync_token1.verified_flush()); | 3959 EXPECT_TRUE(sync_token1.verified_flush()); |
3956 EXPECT_TRUE(sync_token2.verified_flush()); | 3960 EXPECT_TRUE(sync_token2.verified_flush()); |
3957 } | 3961 } |
3958 | 3962 |
3959 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) { | 3963 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) { |
3960 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; | 3964 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; |
3961 const GLuint64 kCommandBufferId = 234u; | 3965 const CommandBufferId kCommandBufferId = |
| 3966 CommandBufferId::FromUnsafeValue(234u); |
3962 const GLuint64 kFenceSync = 456u; | 3967 const GLuint64 kFenceSync = 456u; |
3963 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM]; | 3968 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM]; |
3964 | 3969 |
3965 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync)) | 3970 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync)) |
3966 .WillOnce(testing::Return(true)); | 3971 .WillOnce(testing::Return(true)); |
3967 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync)) | 3972 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync)) |
3968 .WillOnce(testing::Return(true)); | 3973 .WillOnce(testing::Return(true)); |
3969 EXPECT_CALL(*gpu_control_, GetNamespaceID()) | 3974 EXPECT_CALL(*gpu_control_, GetNamespaceID()) |
3970 .WillOnce(testing::Return(kNamespaceId)); | 3975 .WillOnce(testing::Return(kNamespaceId)); |
3971 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) | 3976 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) |
3972 .WillOnce(testing::Return(kCommandBufferId)); | 3977 .WillOnce(testing::Return(kCommandBufferId)); |
3973 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()) | 3978 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()) |
3974 .WillOnce(testing::Return(0)); | 3979 .WillOnce(testing::Return(0)); |
3975 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token); | 3980 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token); |
3976 | 3981 |
3977 struct Cmds { | 3982 struct Cmds { |
3978 cmds::WaitSyncTokenCHROMIUM wait_sync_token; | 3983 cmds::WaitSyncTokenCHROMIUM wait_sync_token; |
3979 }; | 3984 }; |
3980 Cmds expected; | 3985 Cmds expected; |
3981 expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId, kFenceSync); | 3986 expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId.GetUnsafeValue(), |
| 3987 kFenceSync); |
3982 | 3988 |
3983 gl_->WaitSyncTokenCHROMIUM(sync_token); | 3989 gl_->WaitSyncTokenCHROMIUM(sync_token); |
3984 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3990 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
3985 } | 3991 } |
3986 | 3992 |
3987 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUMErrors) { | 3993 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUMErrors) { |
3988 ExpectedMemoryInfo result = | 3994 ExpectedMemoryInfo result = |
3989 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 3995 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
3990 EXPECT_CALL(*command_buffer(), OnFlush()) | 3996 EXPECT_CALL(*command_buffer(), OnFlush()) |
3991 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) | 3997 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) |
3992 .RetiresOnSaturation(); | 3998 .RetiresOnSaturation(); |
3993 | 3999 |
3994 // Empty sync tokens should be produce no error and be a nop. | 4000 // Empty sync tokens should be produce no error and be a nop. |
3995 ClearCommands(); | 4001 ClearCommands(); |
3996 gl_->WaitSyncTokenCHROMIUM(nullptr); | 4002 gl_->WaitSyncTokenCHROMIUM(nullptr); |
3997 EXPECT_TRUE(NoCommandsWritten()); | 4003 EXPECT_TRUE(NoCommandsWritten()); |
3998 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 4004 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
3999 | 4005 |
4000 // Invalid sync tokens should produce no error and be a nop. | 4006 // Invalid sync tokens should produce no error and be a nop. |
4001 ClearCommands(); | 4007 ClearCommands(); |
4002 gpu::SyncToken invalid_sync_token; | 4008 gpu::SyncToken invalid_sync_token; |
4003 gl_->WaitSyncTokenCHROMIUM(invalid_sync_token.GetConstData()); | 4009 gl_->WaitSyncTokenCHROMIUM(invalid_sync_token.GetConstData()); |
4004 EXPECT_TRUE(NoCommandsWritten()); | 4010 EXPECT_TRUE(NoCommandsWritten()); |
4005 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 4011 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
4006 | 4012 |
4007 // Unverified sync token should produce INVALID_OPERATION. | 4013 // Unverified sync token should produce INVALID_OPERATION. |
4008 ClearCommands(); | 4014 ClearCommands(); |
4009 gpu::SyncToken unverified_sync_token(CommandBufferNamespace::GPU_IO, 0, 0, 0); | 4015 gpu::SyncToken unverified_sync_token(CommandBufferNamespace::GPU_IO, 0, |
| 4016 gpu::CommandBufferId(), 0); |
4010 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_)) | 4017 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_)) |
4011 .WillOnce(testing::Return(false)); | 4018 .WillOnce(testing::Return(false)); |
4012 gl_->WaitSyncTokenCHROMIUM(unverified_sync_token.GetConstData()); | 4019 gl_->WaitSyncTokenCHROMIUM(unverified_sync_token.GetConstData()); |
4013 EXPECT_TRUE(NoCommandsWritten()); | 4020 EXPECT_TRUE(NoCommandsWritten()); |
4014 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 4021 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
4015 } | 4022 } |
4016 | 4023 |
4017 TEST_F(GLES2ImplementationTest, IsEnabled) { | 4024 TEST_F(GLES2ImplementationTest, IsEnabled) { |
4018 // If we use a valid enum, its state is cached on client side, so no command | 4025 // If we use a valid enum, its state is cached on client side, so no command |
4019 // is actually generated, and this test will fail. | 4026 // is actually generated, and this test will fail. |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4294 ContextInitOptions init_options; | 4301 ContextInitOptions init_options; |
4295 init_options.transfer_buffer_initialize_fail = true; | 4302 init_options.transfer_buffer_initialize_fail = true; |
4296 EXPECT_FALSE(Initialize(init_options)); | 4303 EXPECT_FALSE(Initialize(init_options)); |
4297 } | 4304 } |
4298 | 4305 |
4299 #include "base/macros.h" | 4306 #include "base/macros.h" |
4300 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 4307 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
4301 | 4308 |
4302 } // namespace gles2 | 4309 } // namespace gles2 |
4303 } // namespace gpu | 4310 } // namespace gpu |
OLD | NEW |