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

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

Issue 1479673003: Verify resource provider sync tokens before sending to parent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit test so it doesn't expect dummy fence sync Created 4 years, 11 months 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
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
28 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS 28 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS
29 #endif 29 #endif
30 30
31 using testing::_; 31 using testing::_;
32 using testing::AtLeast; 32 using testing::AtLeast;
33 using testing::AnyNumber; 33 using testing::AnyNumber;
34 using testing::DoAll; 34 using testing::DoAll;
35 using testing::InSequence; 35 using testing::InSequence;
36 using testing::Invoke; 36 using testing::Invoke;
37 using testing::Mock; 37 using testing::Mock;
38 using testing::Pointee;
38 using testing::Sequence; 39 using testing::Sequence;
39 using testing::StrictMock; 40 using testing::StrictMock;
40 using testing::Truly; 41 using testing::Truly;
41 using testing::Return; 42 using testing::Return;
42 43
43 namespace gpu { 44 namespace gpu {
44 namespace gles2 { 45 namespace gles2 {
45 46
46 ACTION_P2(SetMemory, dst, obj) { 47 ACTION_P2(SetMemory, dst, obj) {
47 memcpy(dst, &obj, sizeof(obj)); 48 memcpy(dst, &obj, sizeof(obj));
(...skipping 3826 matching lines...) Expand 10 before | Expand all | Expand 10 after
3874 3875
3875 ClearCommands(); 3876 ClearCommands();
3876 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_)) 3877 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_))
3877 .WillOnce(testing::Return(false)); 3878 .WillOnce(testing::Return(false));
3878 gl_->VerifySyncTokensCHROMIUM(sync_token_datas, 1); 3879 gl_->VerifySyncTokensCHROMIUM(sync_token_datas, 1);
3879 EXPECT_TRUE(NoCommandsWritten()); 3880 EXPECT_TRUE(NoCommandsWritten());
3880 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); 3881 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError());
3881 EXPECT_FALSE(sync_token.verified_flush()); 3882 EXPECT_FALSE(sync_token.verified_flush());
3882 3883
3883 ClearCommands(); 3884 ClearCommands();
3884 const GLuint64 kVerifyFenceSync = 234u;
3885 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_)) 3885 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_))
3886 .WillOnce(testing::Return(true)); 3886 .WillOnce(testing::Return(true));
3887 EXPECT_CALL(*gpu_control_, GenerateFenceSyncRelease()) 3887 EXPECT_CALL(*gpu_control_, EnsureWorkVisible());
3888 .WillOnce(testing::Return(kVerifyFenceSync)); 3888 gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas));
3889 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kVerifyFenceSync))
3890 .WillOnce(testing::Return(true));
3891 gl_->VerifySyncTokensCHROMIUM(sync_token_datas, 1);
3892 EXPECT_TRUE(NoCommandsWritten()); 3889 EXPECT_TRUE(NoCommandsWritten());
3893 EXPECT_EQ(GL_NO_ERROR, CheckError()); 3890 EXPECT_EQ(GL_NO_ERROR, CheckError());
3894 3891
3895 EXPECT_EQ(kNamespaceId, sync_token.namespace_id()); 3892 EXPECT_EQ(kNamespaceId, sync_token.namespace_id());
3896 EXPECT_EQ(kCommandBufferId, sync_token.command_buffer_id()); 3893 EXPECT_EQ(kCommandBufferId, sync_token.command_buffer_id());
3897 EXPECT_EQ(kFenceSync, sync_token.release_count()); 3894 EXPECT_EQ(kFenceSync, sync_token.release_count());
3898 EXPECT_TRUE(sync_token.verified_flush()); 3895 EXPECT_TRUE(sync_token.verified_flush());
3899 } 3896 }
3900 3897
3898 TEST_F(GLES2ImplementationTest, VerifySyncTokensCHROMIUM_Sequence) {
3899 // To verify sync tokens, the sync tokens must all be verified after
3900 // CanWaitUnverifiedSyncTokens() are called. This test ensures the right
3901 // sequence.
3902 ExpectedMemoryInfo result =
3903 GetExpectedResultMemory(sizeof(cmds::GetError::Result));
3904 EXPECT_CALL(*command_buffer(), OnFlush())
3905 .WillRepeatedly(SetMemory(result.ptr, GLuint(GL_NO_ERROR)))
3906 .RetiresOnSaturation();
3907
3908 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
3909 const GLuint64 kCommandBufferId = 234u;
3910 const GLuint64 kFenceSync1 = 123u;
3911 const GLuint64 kFenceSync2 = 234u;
3912 gpu::SyncToken sync_token1;
3913 gpu::SyncToken sync_token2;
3914 GLbyte* sync_token_datas[] = { sync_token1.GetData(), sync_token2.GetData() };
3915
3916 EXPECT_CALL(*gpu_control_, GetNamespaceID())
3917 .WillRepeatedly(Return(kNamespaceId));
3918 EXPECT_CALL(*gpu_control_, GetCommandBufferID())
3919 .WillRepeatedly(Return(kCommandBufferId));
3920 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData())
3921 .WillRepeatedly(Return(0));
3922
3923 // Generate sync token 1.
3924 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync1))
3925 .WillOnce(Return(true));
3926 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushed(kFenceSync1))
3927 .WillOnce(Return(true));
3928 gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync1, sync_token1.GetData());
3929 ASSERT_TRUE(sync_token1.HasData());
3930 ASSERT_FALSE(sync_token1.verified_flush());
3931
3932 // Generate sync token 2.
3933 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync2))
3934 .WillOnce(Return(true));
3935 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushed(kFenceSync2))
3936 .WillOnce(Return(true));
3937 gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync2, sync_token2.GetData());
3938 ASSERT_TRUE(sync_token2.HasData());
3939 ASSERT_FALSE(sync_token2.verified_flush());
3940
3941 // Ensure proper sequence of checking and validating.
3942 Sequence sequence;
3943 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(Pointee(sync_token1)))
3944 .InSequence(sequence)
3945 .WillOnce(Return(true));
3946 EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(Pointee(sync_token2)))
3947 .InSequence(sequence)
3948 .WillOnce(Return(true));
3949 EXPECT_CALL(*gpu_control_, EnsureWorkVisible())
3950 .InSequence(sequence);
3951 gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas));
3952 EXPECT_TRUE(NoCommandsWritten());
3953 EXPECT_EQ(GL_NO_ERROR, CheckError());
3954
3955 EXPECT_TRUE(sync_token1.verified_flush());
3956 EXPECT_TRUE(sync_token2.verified_flush());
3957 }
3958
3901 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) { 3959 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) {
3902 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO; 3960 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
3903 const GLuint64 kCommandBufferId = 234u; 3961 const GLuint64 kCommandBufferId = 234u;
3904 const GLuint64 kFenceSync = 456u; 3962 const GLuint64 kFenceSync = 456u;
3905 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM]; 3963 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM];
3906 3964
3907 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync)) 3965 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
3908 .WillOnce(testing::Return(true)); 3966 .WillOnce(testing::Return(true));
3909 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync)) 3967 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync))
3910 .WillOnce(testing::Return(true)); 3968 .WillOnce(testing::Return(true));
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
4236 ContextInitOptions init_options; 4294 ContextInitOptions init_options;
4237 init_options.transfer_buffer_initialize_fail = true; 4295 init_options.transfer_buffer_initialize_fail = true;
4238 EXPECT_FALSE(Initialize(init_options)); 4296 EXPECT_FALSE(Initialize(init_options));
4239 } 4297 }
4240 4298
4241 #include "base/macros.h" 4299 #include "base/macros.h"
4242 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 4300 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
4243 4301
4244 } // namespace gles2 4302 } // namespace gles2
4245 } // namespace gpu 4303 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698