Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 1495893005: Revert of Added an extra sync token field for extra command buffer identification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3764 matching lines...) Expand 10 before | Expand all | Expand 10 after
3775 TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) { 3775 TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) {
3776 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; 3776 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
3777 const GLuint64 kCommandBufferId = 234u; 3777 const GLuint64 kCommandBufferId = 234u;
3778 const GLuint64 kFenceSync = 123u; 3778 const GLuint64 kFenceSync = 123u;
3779 GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM]; 3779 GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM];
3780 3780
3781 EXPECT_CALL(*gpu_control_, GetNamespaceID()) 3781 EXPECT_CALL(*gpu_control_, GetNamespaceID())
3782 .WillRepeatedly(testing::Return(kNamespaceId)); 3782 .WillRepeatedly(testing::Return(kNamespaceId));
3783 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) 3783 EXPECT_CALL(*gpu_control_, GetCommandBufferID())
3784 .WillRepeatedly(testing::Return(kCommandBufferId)); 3784 .WillRepeatedly(testing::Return(kCommandBufferId));
3785 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData())
3786 .WillRepeatedly(testing::Return(0));
3787 3785
3788 gl_->GenSyncTokenCHROMIUM(kFenceSync, nullptr); 3786 gl_->GenSyncTokenCHROMIUM(kFenceSync, nullptr);
3789 EXPECT_EQ(GL_INVALID_VALUE, CheckError()); 3787 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
3790 3788
3791 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync)) 3789 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
3792 .WillOnce(testing::Return(false)); 3790 .WillOnce(testing::Return(false));
3793 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token_data); 3791 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token_data);
3794 EXPECT_EQ(GL_INVALID_VALUE, CheckError()); 3792 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
3795 3793
3796 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync)) 3794 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
(...skipping 23 matching lines...) Expand all
3820 TEST_F(GLES2ImplementationTest, GenUnverifiedSyncTokenCHROMIUM) { 3818 TEST_F(GLES2ImplementationTest, GenUnverifiedSyncTokenCHROMIUM) {
3821 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; 3819 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
3822 const GLuint64 kCommandBufferId = 234u; 3820 const GLuint64 kCommandBufferId = 234u;
3823 const GLuint64 kFenceSync = 123u; 3821 const GLuint64 kFenceSync = 123u;
3824 GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM]; 3822 GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM];
3825 3823
3826 EXPECT_CALL(*gpu_control_, GetNamespaceID()) 3824 EXPECT_CALL(*gpu_control_, GetNamespaceID())
3827 .WillRepeatedly(testing::Return(kNamespaceId)); 3825 .WillRepeatedly(testing::Return(kNamespaceId));
3828 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) 3826 EXPECT_CALL(*gpu_control_, GetCommandBufferID())
3829 .WillRepeatedly(testing::Return(kCommandBufferId)); 3827 .WillRepeatedly(testing::Return(kCommandBufferId));
3830 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData())
3831 .WillRepeatedly(testing::Return(0));
3832 3828
3833 gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync, nullptr); 3829 gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync, nullptr);
3834 EXPECT_EQ(GL_INVALID_VALUE, CheckError()); 3830 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
3835 3831
3836 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync)) 3832 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
3837 .WillOnce(testing::Return(false)); 3833 .WillOnce(testing::Return(false));
3838 gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync, sync_token_data); 3834 gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync, sync_token_data);
3839 EXPECT_EQ(GL_INVALID_VALUE, CheckError()); 3835 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
3840 3836
3841 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync)) 3837 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
(...skipping 27 matching lines...) Expand all
3869 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM]; 3865 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM];
3870 3866
3871 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync)) 3867 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
3872 .WillOnce(testing::Return(true)); 3868 .WillOnce(testing::Return(true));
3873 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync)) 3869 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync))
3874 .WillOnce(testing::Return(true)); 3870 .WillOnce(testing::Return(true));
3875 EXPECT_CALL(*gpu_control_, GetNamespaceID()) 3871 EXPECT_CALL(*gpu_control_, GetNamespaceID())
3876 .WillOnce(testing::Return(kNamespaceId)); 3872 .WillOnce(testing::Return(kNamespaceId));
3877 EXPECT_CALL(*gpu_control_, GetCommandBufferID()) 3873 EXPECT_CALL(*gpu_control_, GetCommandBufferID())
3878 .WillOnce(testing::Return(kCommandBufferId)); 3874 .WillOnce(testing::Return(kCommandBufferId));
3879 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData())
3880 .WillOnce(testing::Return(0));
3881 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token); 3875 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token);
3882 3876
3883 struct Cmds { 3877 struct Cmds {
3884 cmds::WaitSyncTokenCHROMIUM wait_sync_token; 3878 cmds::WaitSyncTokenCHROMIUM wait_sync_token;
3885 }; 3879 };
3886 Cmds expected; 3880 Cmds expected;
3887 expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId, kFenceSync); 3881 expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId, kFenceSync);
3888 3882
3889 gl_->WaitSyncTokenCHROMIUM(sync_token); 3883 gl_->WaitSyncTokenCHROMIUM(sync_token);
3890 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 3884 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3891 } 3885 }
3892 3886
3893 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUMErrors) { 3887 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUMErrors) {
3894 ExpectedMemoryInfo result = 3888 ExpectedMemoryInfo result =
3895 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); 3889 GetExpectedResultMemory(sizeof(cmds::GetError::Result));
3896 EXPECT_CALL(*command_buffer(), OnFlush()) 3890 EXPECT_CALL(*command_buffer(), OnFlush())
3897 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) 3891 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR)))
3898 .RetiresOnSaturation(); 3892 .RetiresOnSaturation();
3899 3893
3900 // Empty sync tokens should be produce no error and be a nop. 3894 // Empty sync tokens should be produce no error and be a nop.
3901 ClearCommands(); 3895 ClearCommands();
3902 gl_->WaitSyncTokenCHROMIUM(nullptr); 3896 gl_->WaitSyncTokenCHROMIUM(nullptr);
3903 EXPECT_TRUE(NoCommandsWritten()); 3897 EXPECT_TRUE(NoCommandsWritten());
3904 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); 3898 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError());
3905 3899
3906 // Invalid sync tokens should produce no error and be a nop. 3900 // Invalid sync tokens should produce no error and be a nop.
3907 ClearCommands(); 3901 ClearCommands();
3908 gpu::SyncToken invalid_sync_token; 3902 gpu::SyncToken invalid_sync_token(CommandBufferNamespace::INVALID, 0, 0);
3909 gl_->WaitSyncTokenCHROMIUM(invalid_sync_token.GetConstData()); 3903 gl_->WaitSyncTokenCHROMIUM(invalid_sync_token.GetConstData());
3910 EXPECT_TRUE(NoCommandsWritten()); 3904 EXPECT_TRUE(NoCommandsWritten());
3911 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); 3905 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError());
3912 3906
3913 // Unverified sync token should produce INVALID_OPERATION. 3907 // Unverified sync token should produce INVALID_OPERATION.
3914 ClearCommands(); 3908 ClearCommands();
3915 gpu::SyncToken unverified_sync_token(CommandBufferNamespace::GPU_IO, 0, 0, 0); 3909 gpu::SyncToken unverified_sync_token(CommandBufferNamespace::GPU_IO, 0, 0);
3916 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_)) 3910 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_))
3917 .WillOnce(testing::Return(false)); 3911 .WillOnce(testing::Return(false));
3918 gl_->WaitSyncTokenCHROMIUM(unverified_sync_token.GetConstData()); 3912 gl_->WaitSyncTokenCHROMIUM(unverified_sync_token.GetConstData());
3919 EXPECT_TRUE(NoCommandsWritten()); 3913 EXPECT_TRUE(NoCommandsWritten());
3920 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); 3914 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError());
3921 } 3915 }
3922 3916
3923 TEST_F(GLES2ImplementationTest, IsEnabled) { 3917 TEST_F(GLES2ImplementationTest, IsEnabled) {
3924 // If we use a valid enum, its state is cached on client side, so no command 3918 // If we use a valid enum, its state is cached on client side, so no command
3925 // is actually generated, and this test will fail. 3919 // is actually generated, and this test will fail.
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
4203 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { 4197 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) {
4204 ContextInitOptions init_options; 4198 ContextInitOptions init_options;
4205 init_options.transfer_buffer_initialize_fail = true; 4199 init_options.transfer_buffer_initialize_fail = true;
4206 EXPECT_FALSE(Initialize(init_options)); 4200 EXPECT_FALSE(Initialize(init_options));
4207 } 4201 }
4208 4202
4209 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 4203 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
4210 4204
4211 } // namespace gles2 4205 } // namespace gles2
4212 } // namespace gpu 4206 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | gpu/command_buffer/client/gpu_control.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698