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

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

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