OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <GLES2/gl2.h> |
| 6 #include <GLES2/gl2ext.h> |
| 7 #include <GLES2/gl2extchromium.h> |
| 8 |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 11 #include "gpu/command_buffer/tests/gl_manager.h" |
| 12 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 |
| 16 #define SHADER(Src) #Src |
| 17 |
| 18 namespace gpu { |
| 19 |
| 20 class GLFenceSyncTest : public testing::Test { |
| 21 protected: |
| 22 void SetUp() override { |
| 23 sync_point_manager_.reset(new SyncPointManager(false)); |
| 24 |
| 25 GLManager::Options options; |
| 26 options.sync_point_manager = sync_point_manager_.get(); |
| 27 gl1_.Initialize(options); |
| 28 gl2_.Initialize(options); |
| 29 } |
| 30 |
| 31 void TearDown() override { |
| 32 gl2_.Destroy(); |
| 33 gl1_.Destroy(); |
| 34 |
| 35 sync_point_manager_.reset(); |
| 36 } |
| 37 |
| 38 scoped_ptr<SyncPointManager> sync_point_manager_; |
| 39 GLManager gl1_; |
| 40 GLManager gl2_; |
| 41 }; |
| 42 |
| 43 TEST_F(GLFenceSyncTest, SimpleReleaseWait) { |
| 44 gl1_.MakeCurrent(); |
| 45 |
| 46 const GLuint64 fence_sync = glInsertFenceSyncCHROMIUM(); |
| 47 GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM]; |
| 48 glFlush(); |
| 49 glGenSyncTokenCHROMIUM(fence_sync, sync_token); |
| 50 ASSERT_TRUE(GL_NO_ERROR == glGetError()); |
| 51 |
| 52 // Make sure it is actually released. |
| 53 scoped_refptr<SyncPointClientState> gl1_client_state = |
| 54 sync_point_manager_->GetSyncPointClientState(gl1_.GetNamespaceID(), |
| 55 gl1_.GetCommandBufferID()); |
| 56 EXPECT_TRUE(gl1_client_state->IsFenceSyncReleased(fence_sync)); |
| 57 |
| 58 gl2_.MakeCurrent(); |
| 59 glWaitSyncTokenCHROMIUM(sync_token); |
| 60 glFinish(); |
| 61 |
| 62 // gl2 should not have released anything. |
| 63 scoped_refptr<SyncPointClientState> gl2_client_state = |
| 64 sync_point_manager_->GetSyncPointClientState(gl2_.GetNamespaceID(), |
| 65 gl2_.GetCommandBufferID()); |
| 66 EXPECT_EQ(0u, gl2_client_state->fence_sync_release()); |
| 67 } |
| 68 |
| 69 } // namespace gpu |
OLD | NEW |