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

Side by Side Diff: gpu/command_buffer/service/sync_point_manager_unittest.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo part of clang-format Created 4 years, 8 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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stdint.h> 5 #include <stdint.h>
6 6
no sievers 2016/04/05 19:02:41 #include <memory>
Mostyn Bramley-Moore 2016/04/05 21:35:32 Done.
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "gpu/command_buffer/service/sync_point_manager.h" 10 #include "gpu/command_buffer/service/sync_point_manager.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace gpu { 13 namespace gpu {
14 14
15 class SyncPointManagerTest : public testing::Test { 15 class SyncPointManagerTest : public testing::Test {
16 public: 16 public:
(...skipping 13 matching lines...) Expand all
30 30
31 // Simple static function used for testing OnWaitCallback. 31 // Simple static function used for testing OnWaitCallback.
32 static void OnWait(CommandBufferNamespace* namespace_id_ptr, 32 static void OnWait(CommandBufferNamespace* namespace_id_ptr,
33 CommandBufferId* client_id_ptr, 33 CommandBufferId* client_id_ptr,
34 CommandBufferNamespace namespace_id, 34 CommandBufferNamespace namespace_id,
35 CommandBufferId client_id) { 35 CommandBufferId client_id) {
36 *namespace_id_ptr = namespace_id; 36 *namespace_id_ptr = namespace_id;
37 *client_id_ptr = client_id; 37 *client_id_ptr = client_id;
38 } 38 }
39 39
40 scoped_ptr<SyncPointManager> sync_point_manager_; 40 std::unique_ptr<SyncPointManager> sync_point_manager_;
41 }; 41 };
42 42
43 struct SyncPointStream { 43 struct SyncPointStream {
44 scoped_refptr<SyncPointOrderData> order_data; 44 scoped_refptr<SyncPointOrderData> order_data;
45 scoped_ptr<SyncPointClient> client; 45 std::unique_ptr<SyncPointClient> client;
46 std::queue<uint32_t> order_numbers; 46 std::queue<uint32_t> order_numbers;
47 47
48 SyncPointStream(SyncPointManager* sync_point_manager, 48 SyncPointStream(SyncPointManager* sync_point_manager,
49 CommandBufferNamespace namespace_id, 49 CommandBufferNamespace namespace_id,
50 CommandBufferId command_buffer_id) 50 CommandBufferId command_buffer_id)
51 : order_data(SyncPointOrderData::Create()), 51 : order_data(SyncPointOrderData::Create()),
52 client(sync_point_manager->CreateSyncPointClient(order_data, 52 client(sync_point_manager->CreateSyncPointClient(order_data,
53 namespace_id, 53 namespace_id,
54 command_buffer_id)) {} 54 command_buffer_id)) {}
55 55
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 const CommandBufferNamespace kNamespaceId = 113 const CommandBufferNamespace kNamespaceId =
114 gpu::CommandBufferNamespace::GPU_IO; 114 gpu::CommandBufferNamespace::GPU_IO;
115 const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123); 115 const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123);
116 116
117 scoped_refptr<SyncPointClientState> empty_state = 117 scoped_refptr<SyncPointClientState> empty_state =
118 sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId); 118 sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId);
119 EXPECT_FALSE(empty_state); 119 EXPECT_FALSE(empty_state);
120 120
121 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create(); 121 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create();
122 122
123 scoped_ptr<SyncPointClient> client = 123 std::unique_ptr<SyncPointClient> client =
124 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId, 124 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId,
125 kBufferId); 125 kBufferId);
126 126
127 EXPECT_EQ(order_data, client->client_state()->order_data()); 127 EXPECT_EQ(order_data, client->client_state()->order_data());
128 EXPECT_EQ( 128 EXPECT_EQ(
129 client->client_state(), 129 client->client_state(),
130 sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId)); 130 sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId));
131 } 131 }
132 132
133 TEST_F(SyncPointManagerTest, BasicFenceSyncRelease) { 133 TEST_F(SyncPointManagerTest, BasicFenceSyncRelease) {
134 const CommandBufferNamespace kNamespaceId = 134 const CommandBufferNamespace kNamespaceId =
135 gpu::CommandBufferNamespace::GPU_IO; 135 gpu::CommandBufferNamespace::GPU_IO;
136 const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123); 136 const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123);
137 137
138 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create(); 138 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create();
139 scoped_ptr<SyncPointClient> client = 139 std::unique_ptr<SyncPointClient> client =
140 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId, 140 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId,
141 kBufferId); 141 kBufferId);
142 scoped_refptr<SyncPointClientState> client_state = client->client_state(); 142 scoped_refptr<SyncPointClientState> client_state = client->client_state();
143 143
144 EXPECT_EQ(0u, client_state->fence_sync_release()); 144 EXPECT_EQ(0u, client_state->fence_sync_release());
145 EXPECT_FALSE(client_state->IsFenceSyncReleased(1)); 145 EXPECT_FALSE(client_state->IsFenceSyncReleased(1));
146 146
147 const uint32_t order_num = 147 const uint32_t order_num =
148 order_data->GenerateUnprocessedOrderNumber(sync_point_manager_.get()); 148 order_data->GenerateUnprocessedOrderNumber(sync_point_manager_.get());
149 order_data->BeginProcessingOrderNumber(order_num); 149 order_data->BeginProcessingOrderNumber(order_num);
150 client->ReleaseFenceSync(1); 150 client->ReleaseFenceSync(1);
151 order_data->FinishProcessingOrderNumber(order_num); 151 order_data->FinishProcessingOrderNumber(order_num);
152 152
153 EXPECT_EQ(1u, client_state->fence_sync_release()); 153 EXPECT_EQ(1u, client_state->fence_sync_release());
154 EXPECT_TRUE(client_state->IsFenceSyncReleased(1)); 154 EXPECT_TRUE(client_state->IsFenceSyncReleased(1));
155 } 155 }
156 156
157 TEST_F(SyncPointManagerTest, MultipleClientsPerOrderData) { 157 TEST_F(SyncPointManagerTest, MultipleClientsPerOrderData) {
158 const CommandBufferNamespace kNamespaceId = 158 const CommandBufferNamespace kNamespaceId =
159 gpu::CommandBufferNamespace::GPU_IO; 159 gpu::CommandBufferNamespace::GPU_IO;
160 const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123); 160 const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
161 const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234); 161 const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
162 162
163 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create(); 163 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create();
164 scoped_ptr<SyncPointClient> client1 = 164 std::unique_ptr<SyncPointClient> client1 =
165 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId, 165 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId,
166 kBufferId1); 166 kBufferId1);
167 scoped_ptr<SyncPointClient> client2 = 167 std::unique_ptr<SyncPointClient> client2 =
168 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId, 168 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId,
169 kBufferId2); 169 kBufferId2);
170 170
171 scoped_refptr<SyncPointClientState> client_state1 = client1->client_state(); 171 scoped_refptr<SyncPointClientState> client_state1 = client1->client_state();
172 scoped_refptr<SyncPointClientState> client_state2 = client2->client_state(); 172 scoped_refptr<SyncPointClientState> client_state2 = client2->client_state();
173 173
174 const uint32_t order_num = 174 const uint32_t order_num =
175 order_data->GenerateUnprocessedOrderNumber(sync_point_manager_.get()); 175 order_data->GenerateUnprocessedOrderNumber(sync_point_manager_.get());
176 order_data->BeginProcessingOrderNumber(order_num); 176 order_data->BeginProcessingOrderNumber(order_num);
177 client1->ReleaseFenceSync(1); 177 client1->ReleaseFenceSync(1);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 EXPECT_TRUE(valid_wait); 484 EXPECT_TRUE(valid_wait);
485 EXPECT_EQ(10, test_num); 485 EXPECT_EQ(10, test_num);
486 EXPECT_EQ(kNamespaceId, namespace_id); 486 EXPECT_EQ(kNamespaceId, namespace_id);
487 EXPECT_EQ(kBufferId2, client_id); 487 EXPECT_EQ(kBufferId2, client_id);
488 488
489 release_stream.client->ReleaseFenceSync(2); 489 release_stream.client->ReleaseFenceSync(2);
490 EXPECT_EQ(123, test_num); 490 EXPECT_EQ(123, test_num);
491 } 491 }
492 492
493 } // namespace gpu 493 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698