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

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: rebase on master 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
7 #include <memory>
7 #include <queue> 8 #include <queue>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "gpu/command_buffer/service/sync_point_manager.h" 11 #include "gpu/command_buffer/service/sync_point_manager.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace gpu { 14 namespace gpu {
14 15
15 class SyncPointManagerTest : public testing::Test { 16 class SyncPointManagerTest : public testing::Test {
16 public: 17 public:
(...skipping 13 matching lines...) Expand all
30 31
31 // Simple static function used for testing OnWaitCallback. 32 // Simple static function used for testing OnWaitCallback.
32 static void OnWait(CommandBufferNamespace* namespace_id_ptr, 33 static void OnWait(CommandBufferNamespace* namespace_id_ptr,
33 CommandBufferId* client_id_ptr, 34 CommandBufferId* client_id_ptr,
34 CommandBufferNamespace namespace_id, 35 CommandBufferNamespace namespace_id,
35 CommandBufferId client_id) { 36 CommandBufferId client_id) {
36 *namespace_id_ptr = namespace_id; 37 *namespace_id_ptr = namespace_id;
37 *client_id_ptr = client_id; 38 *client_id_ptr = client_id;
38 } 39 }
39 40
40 scoped_ptr<SyncPointManager> sync_point_manager_; 41 std::unique_ptr<SyncPointManager> sync_point_manager_;
41 }; 42 };
42 43
43 struct SyncPointStream { 44 struct SyncPointStream {
44 scoped_refptr<SyncPointOrderData> order_data; 45 scoped_refptr<SyncPointOrderData> order_data;
45 scoped_ptr<SyncPointClient> client; 46 std::unique_ptr<SyncPointClient> client;
46 std::queue<uint32_t> order_numbers; 47 std::queue<uint32_t> order_numbers;
47 48
48 SyncPointStream(SyncPointManager* sync_point_manager, 49 SyncPointStream(SyncPointManager* sync_point_manager,
49 CommandBufferNamespace namespace_id, 50 CommandBufferNamespace namespace_id,
50 CommandBufferId command_buffer_id) 51 CommandBufferId command_buffer_id)
51 : order_data(SyncPointOrderData::Create()), 52 : order_data(SyncPointOrderData::Create()),
52 client(sync_point_manager->CreateSyncPointClient(order_data, 53 client(sync_point_manager->CreateSyncPointClient(order_data,
53 namespace_id, 54 namespace_id,
54 command_buffer_id)) {} 55 command_buffer_id)) {}
55 56
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 const CommandBufferNamespace kNamespaceId = 114 const CommandBufferNamespace kNamespaceId =
114 gpu::CommandBufferNamespace::GPU_IO; 115 gpu::CommandBufferNamespace::GPU_IO;
115 const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123); 116 const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123);
116 117
117 scoped_refptr<SyncPointClientState> empty_state = 118 scoped_refptr<SyncPointClientState> empty_state =
118 sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId); 119 sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId);
119 EXPECT_FALSE(empty_state); 120 EXPECT_FALSE(empty_state);
120 121
121 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create(); 122 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create();
122 123
123 scoped_ptr<SyncPointClient> client = 124 std::unique_ptr<SyncPointClient> client =
124 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId, 125 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId,
125 kBufferId); 126 kBufferId);
126 127
127 EXPECT_EQ(order_data, client->client_state()->order_data()); 128 EXPECT_EQ(order_data, client->client_state()->order_data());
128 EXPECT_EQ( 129 EXPECT_EQ(
129 client->client_state(), 130 client->client_state(),
130 sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId)); 131 sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId));
131 } 132 }
132 133
133 TEST_F(SyncPointManagerTest, BasicFenceSyncRelease) { 134 TEST_F(SyncPointManagerTest, BasicFenceSyncRelease) {
134 const CommandBufferNamespace kNamespaceId = 135 const CommandBufferNamespace kNamespaceId =
135 gpu::CommandBufferNamespace::GPU_IO; 136 gpu::CommandBufferNamespace::GPU_IO;
136 const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123); 137 const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123);
137 138
138 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create(); 139 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create();
139 scoped_ptr<SyncPointClient> client = 140 std::unique_ptr<SyncPointClient> client =
140 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId, 141 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId,
141 kBufferId); 142 kBufferId);
142 scoped_refptr<SyncPointClientState> client_state = client->client_state(); 143 scoped_refptr<SyncPointClientState> client_state = client->client_state();
143 144
144 EXPECT_EQ(0u, client_state->fence_sync_release()); 145 EXPECT_EQ(0u, client_state->fence_sync_release());
145 EXPECT_FALSE(client_state->IsFenceSyncReleased(1)); 146 EXPECT_FALSE(client_state->IsFenceSyncReleased(1));
146 147
147 const uint32_t order_num = 148 const uint32_t order_num =
148 order_data->GenerateUnprocessedOrderNumber(sync_point_manager_.get()); 149 order_data->GenerateUnprocessedOrderNumber(sync_point_manager_.get());
149 order_data->BeginProcessingOrderNumber(order_num); 150 order_data->BeginProcessingOrderNumber(order_num);
150 client->ReleaseFenceSync(1); 151 client->ReleaseFenceSync(1);
151 order_data->FinishProcessingOrderNumber(order_num); 152 order_data->FinishProcessingOrderNumber(order_num);
152 153
153 EXPECT_EQ(1u, client_state->fence_sync_release()); 154 EXPECT_EQ(1u, client_state->fence_sync_release());
154 EXPECT_TRUE(client_state->IsFenceSyncReleased(1)); 155 EXPECT_TRUE(client_state->IsFenceSyncReleased(1));
155 } 156 }
156 157
157 TEST_F(SyncPointManagerTest, MultipleClientsPerOrderData) { 158 TEST_F(SyncPointManagerTest, MultipleClientsPerOrderData) {
158 const CommandBufferNamespace kNamespaceId = 159 const CommandBufferNamespace kNamespaceId =
159 gpu::CommandBufferNamespace::GPU_IO; 160 gpu::CommandBufferNamespace::GPU_IO;
160 const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123); 161 const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
161 const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234); 162 const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
162 163
163 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create(); 164 scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create();
164 scoped_ptr<SyncPointClient> client1 = 165 std::unique_ptr<SyncPointClient> client1 =
165 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId, 166 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId,
166 kBufferId1); 167 kBufferId1);
167 scoped_ptr<SyncPointClient> client2 = 168 std::unique_ptr<SyncPointClient> client2 =
168 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId, 169 sync_point_manager_->CreateSyncPointClient(order_data, kNamespaceId,
169 kBufferId2); 170 kBufferId2);
170 171
171 scoped_refptr<SyncPointClientState> client_state1 = client1->client_state(); 172 scoped_refptr<SyncPointClientState> client_state1 = client1->client_state();
172 scoped_refptr<SyncPointClientState> client_state2 = client2->client_state(); 173 scoped_refptr<SyncPointClientState> client_state2 = client2->client_state();
173 174
174 const uint32_t order_num = 175 const uint32_t order_num =
175 order_data->GenerateUnprocessedOrderNumber(sync_point_manager_.get()); 176 order_data->GenerateUnprocessedOrderNumber(sync_point_manager_.get());
176 order_data->BeginProcessingOrderNumber(order_num); 177 order_data->BeginProcessingOrderNumber(order_num);
177 client1->ReleaseFenceSync(1); 178 client1->ReleaseFenceSync(1);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 EXPECT_TRUE(valid_wait); 485 EXPECT_TRUE(valid_wait);
485 EXPECT_EQ(10, test_num); 486 EXPECT_EQ(10, test_num);
486 EXPECT_EQ(kNamespaceId, namespace_id); 487 EXPECT_EQ(kNamespaceId, namespace_id);
487 EXPECT_EQ(kBufferId2, client_id); 488 EXPECT_EQ(kBufferId2, client_id);
488 489
489 release_stream.client->ReleaseFenceSync(2); 490 release_stream.client->ReleaseFenceSync(2);
490 EXPECT_EQ(123, test_num); 491 EXPECT_EQ(123, test_num);
491 } 492 }
492 493
493 } // namespace gpu 494 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/sync_point_manager.cc ('k') | gpu/command_buffer/service/texture_definition.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698