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

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

Issue 1331843005: Implemented new fence syncs which replaces the old sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted mojo readme, changed wait() to take a pointer Created 5 years, 2 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
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 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after
3734 EXPECT_EQ(GL_NO_ERROR, CheckError()); 3734 EXPECT_EQ(GL_NO_ERROR, CheckError());
3735 3735
3736 gl_->TraceEndCHROMIUM(); 3736 gl_->TraceEndCHROMIUM();
3737 EXPECT_EQ(GL_NO_ERROR, CheckError()); 3737 EXPECT_EQ(GL_NO_ERROR, CheckError());
3738 3738
3739 // No more corresponding begin tracer marker should error. 3739 // No more corresponding begin tracer marker should error.
3740 gl_->TraceEndCHROMIUM(); 3740 gl_->TraceEndCHROMIUM();
3741 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); 3741 EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
3742 } 3742 }
3743 3743
3744 TEST_F(GLES2ImplementationTest, InsertFenceSyncCHROMIUM) {
3745 const GLuint64 kFenceSync = 123u;
3746 EXPECT_CALL(*gpu_control_, GenerateFenceSyncRelease())
3747 .WillOnce(testing::Return(kFenceSync));
3748
3749 struct Cmds {
3750 cmds::InsertFenceSyncCHROMIUM insert_fence_sync;
3751 };
3752 Cmds expected;
3753 expected.insert_fence_sync.Init(kFenceSync);
3754
3755 const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM();
3756 EXPECT_EQ(kFenceSync, fence_sync);
3757 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3758 }
3759
3760 TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) {
3761 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
3762 const GLuint64 kCommandBufferId = 234u;
3763 const GLuint64 kFenceSync = 123u;
3764 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM];
3765
3766 EXPECT_CALL(*gpu_control_, GetNamespaceID())
3767 .WillRepeatedly(testing::Return(kNamespaceId));
3768 EXPECT_CALL(*gpu_control_, GetCommandBufferID())
3769 .WillRepeatedly(testing::Return(kCommandBufferId));
3770
3771 gl_->GenSyncTokenCHROMIUM(kFenceSync, nullptr);
3772 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
3773
3774 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
3775 .WillOnce(testing::Return(false));
3776 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token);
3777 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
3778
3779 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
3780 .WillOnce(testing::Return(true));
3781 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushed(kFenceSync))
3782 .WillOnce(testing::Return(false));
3783 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token);
3784 EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
3785
3786 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
3787 .WillOnce(testing::Return(true));
3788 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushed(kFenceSync))
3789 .WillOnce(testing::Return(true));
3790 ClearCommands();
3791 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token);
3792 EXPECT_TRUE(NoCommandsWritten());
3793 EXPECT_EQ(GL_NO_ERROR, CheckError());
3794 }
3795
3796 TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) {
3797 const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
3798 const GLuint64 kCommandBufferId = 234u;
3799 const GLuint64 kFenceSync = 456u;
3800 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM];
3801
3802 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
3803 .WillOnce(testing::Return(true));
3804 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushed(kFenceSync))
3805 .WillOnce(testing::Return(true));
3806 EXPECT_CALL(*gpu_control_, GetNamespaceID())
3807 .WillOnce(testing::Return(kNamespaceId));
3808 EXPECT_CALL(*gpu_control_, GetCommandBufferID())
3809 .WillOnce(testing::Return(kCommandBufferId));
3810 gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token);
3811
3812 struct Cmds {
3813 cmds::WaitSyncTokenCHROMIUM wait_sync_token;
3814 };
3815 Cmds expected;
3816 expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId, kFenceSync);
3817
3818 gl_->WaitSyncTokenCHROMIUM(sync_token);
3819 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3820 }
3821
3744 TEST_F(GLES2ImplementationTest, IsEnabled) { 3822 TEST_F(GLES2ImplementationTest, IsEnabled) {
3745 // If we use a valid enum, its state is cached on client side, so no command 3823 // If we use a valid enum, its state is cached on client side, so no command
3746 // is actually generated, and this test will fail. 3824 // is actually generated, and this test will fail.
3747 // TODO(zmo): it seems we never need the command. Maybe remove it. 3825 // TODO(zmo): it seems we never need the command. Maybe remove it.
3748 GLenum kCap = 1; 3826 GLenum kCap = 1;
3749 struct Cmds { 3827 struct Cmds {
3750 cmds::IsEnabled cmd; 3828 cmds::IsEnabled cmd;
3751 }; 3829 };
3752 3830
3753 Cmds expected; 3831 Cmds expected;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
4022 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { 4100 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) {
4023 ContextInitOptions init_options; 4101 ContextInitOptions init_options;
4024 init_options.transfer_buffer_initialize_fail = true; 4102 init_options.transfer_buffer_initialize_fail = true;
4025 EXPECT_FALSE(Initialize(init_options)); 4103 EXPECT_FALSE(Initialize(init_options));
4026 } 4104 }
4027 4105
4028 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 4106 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
4029 4107
4030 } // namespace gles2 4108 } // namespace gles2
4031 } // namespace gpu 4109 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698