| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #include <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
| 6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
| 7 #include <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "gpu/command_buffer/common/sync_token.h" | 12 #include "gpu/command_buffer/common/sync_token.h" |
| 13 #include "gpu/command_buffer/service/sync_point_manager.h" | 13 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 14 #include "gpu/command_buffer/tests/gl_manager.h" | 14 #include "gpu/command_buffer/tests/gl_manager.h" |
| 15 #include "gpu/command_buffer/tests/gl_test_utils.h" | 15 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 #define SHADER(Src) #Src | 19 #define SHADER(Src) #Src |
| 20 | 20 |
| 21 namespace gpu { | 21 namespace gpu { |
| 22 | 22 |
| 23 class GLFenceSyncTest : public testing::Test { | 23 class GLFenceSyncTest : public testing::Test { |
| 24 protected: | 24 protected: |
| 25 void SetUp() override { | 25 void SetUp() override { |
| 26 sync_point_manager_.reset(new SyncPointManager(false)); | 26 sync_point_manager_.reset(new SyncPointManager()); |
| 27 | 27 |
| 28 GLManager::Options options; | 28 GLManager::Options options; |
| 29 options.sync_point_manager = sync_point_manager_.get(); | 29 options.sync_point_manager = sync_point_manager_.get(); |
| 30 gl1_.Initialize(options); | 30 gl1_.Initialize(options); |
| 31 gl2_.Initialize(options); | 31 gl2_.Initialize(options); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void TearDown() override { | 34 void TearDown() override { |
| 35 gl2_.Destroy(); | 35 gl2_.Destroy(); |
| 36 gl1_.Destroy(); | 36 gl1_.Destroy(); |
| 37 | 37 |
| 38 sync_point_manager_.reset(); | 38 sync_point_manager_.reset(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 std::unique_ptr<SyncPointManager> sync_point_manager_; | 41 std::unique_ptr<SyncPointManager> sync_point_manager_; |
| 42 GLManager gl1_; | 42 GLManager gl1_; |
| 43 GLManager gl2_; | 43 GLManager gl2_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 TEST_F(GLFenceSyncTest, SimpleReleaseWait) { | 46 TEST_F(GLFenceSyncTest, SimpleReleaseWait) { |
| 47 gl1_.MakeCurrent(); | 47 gl1_.MakeCurrent(); |
| 48 | 48 |
| 49 const GLuint64 fence_sync = glInsertFenceSyncCHROMIUM(); | 49 const GLuint64 fence_sync = glInsertFenceSyncCHROMIUM(); |
| 50 SyncToken sync_token; | 50 SyncToken sync_token; |
| 51 glFlush(); | 51 glFlush(); |
| 52 glGenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 52 glGenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 53 ASSERT_TRUE(GL_NO_ERROR == glGetError()); | 53 ASSERT_TRUE(GL_NO_ERROR == glGetError()); |
| 54 | 54 |
| 55 // Make sure it is actually released. | 55 // Make sure it is actually released. |
| 56 scoped_refptr<SyncPointClientState> gl1_client_state = | 56 EXPECT_TRUE(sync_point_manager_->IsSyncTokenReleased(sync_token)); |
| 57 sync_point_manager_->GetSyncPointClientState(gl1_.GetNamespaceID(), | |
| 58 gl1_.GetCommandBufferID()); | |
| 59 EXPECT_TRUE(gl1_client_state->IsFenceSyncReleased(fence_sync)); | |
| 60 | 57 |
| 61 gl2_.MakeCurrent(); | 58 gl2_.MakeCurrent(); |
| 62 glWaitSyncTokenCHROMIUM(sync_token.GetConstData()); | 59 glWaitSyncTokenCHROMIUM(sync_token.GetConstData()); |
| 63 glFinish(); | 60 glFinish(); |
| 64 | |
| 65 // gl2 should not have released anything. | |
| 66 scoped_refptr<SyncPointClientState> gl2_client_state = | |
| 67 sync_point_manager_->GetSyncPointClientState(gl2_.GetNamespaceID(), | |
| 68 gl2_.GetCommandBufferID()); | |
| 69 EXPECT_EQ(0u, gl2_client_state->fence_sync_release()); | |
| 70 } | 61 } |
| 71 | 62 |
| 72 static void TestCallback(int* storage, int assign) { | 63 static void TestCallback(int* storage, int assign) { |
| 73 *storage = assign; | 64 *storage = assign; |
| 74 } | 65 } |
| 75 | 66 |
| 76 TEST_F(GLFenceSyncTest, SimpleReleaseSignal) { | 67 TEST_F(GLFenceSyncTest, SimpleReleaseSignal) { |
| 77 gl1_.MakeCurrent(); | 68 gl1_.MakeCurrent(); |
| 78 | 69 |
| 79 // Pause the command buffer so the fence sync does not immediately trigger. | 70 // Pause the command buffer so the fence sync does not immediately trigger. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 gl1_.MakeCurrent(); | 84 gl1_.MakeCurrent(); |
| 94 EXPECT_EQ(0, callback_called); | 85 EXPECT_EQ(0, callback_called); |
| 95 | 86 |
| 96 gl1_.SetCommandsPaused(false); | 87 gl1_.SetCommandsPaused(false); |
| 97 glFinish(); | 88 glFinish(); |
| 98 | 89 |
| 99 EXPECT_EQ(1, callback_called); | 90 EXPECT_EQ(1, callback_called); |
| 100 } | 91 } |
| 101 | 92 |
| 102 } // namespace gpu | 93 } // namespace gpu |
| OLD | NEW |