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

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

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: [WIP] Review comments follow-up Created 6 years, 11 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 the QueryTracker. 5 // Tests for the QueryTracker.
6 6
7 #include "gpu/command_buffer/client/query_tracker.h" 7 #include "gpu/command_buffer/client/query_tracker.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 scoped_ptr<MappedMemoryManager> mapped_memory_; 107 scoped_ptr<MappedMemoryManager> mapped_memory_;
108 scoped_ptr<QueryTracker> query_tracker_; 108 scoped_ptr<QueryTracker> query_tracker_;
109 }; 109 };
110 110
111 TEST_F(QueryTrackerTest, Basic) { 111 TEST_F(QueryTrackerTest, Basic) {
112 const GLuint kId1 = 123; 112 const GLuint kId1 = 123;
113 const GLuint kId2 = 124; 113 const GLuint kId2 = 124;
114 114
115 // Check we can create a Query. 115 // Check we can create a Query.
116 QueryTracker::Query* query = query_tracker_->CreateQuery( 116 QueryTracker::Query* query = query_tracker_->CreateQuery(
117 kId1, GL_ANY_SAMPLES_PASSED_EXT); 117 kId1, GL_ANY_SAMPLES_PASSED_EXT, false);
118 ASSERT_TRUE(query != NULL); 118 ASSERT_TRUE(query != NULL);
119 // Check we can get the same Query. 119 // Check we can get the same Query.
120 EXPECT_EQ(query, query_tracker_->GetQuery(kId1)); 120 EXPECT_EQ(query, query_tracker_->GetQuery(kId1));
121 // Check we get nothing for a non-existent query. 121 // Check we get nothing for a non-existent query.
122 EXPECT_TRUE(query_tracker_->GetQuery(kId2) == NULL); 122 EXPECT_TRUE(query_tracker_->GetQuery(kId2) == NULL);
123 // Check we can delete the query. 123 // Check we can delete the query.
124 query_tracker_->RemoveQuery(kId1); 124 query_tracker_->RemoveQuery(kId1);
125 // Check we get nothing for a non-existent query. 125 // Check we get nothing for a non-existent query.
126 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL); 126 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL);
127 } 127 }
128 128
129 TEST_F(QueryTrackerTest, Query) { 129 TEST_F(QueryTrackerTest, Query) {
130 const GLuint kId1 = 123; 130 const GLuint kId1 = 123;
131 const int32 kToken = 46; 131 const int32 kToken = 46;
132 const uint32 kResult = 456; 132 const uint32 kResult = 456;
133 133
134 // Create a Query. 134 // Create a Query.
135 QueryTracker::Query* query = query_tracker_->CreateQuery( 135 QueryTracker::Query* query = query_tracker_->CreateQuery(
136 kId1, GL_ANY_SAMPLES_PASSED_EXT); 136 kId1, GL_ANY_SAMPLES_PASSED_EXT, false);
137 ASSERT_TRUE(query != NULL); 137 ASSERT_TRUE(query != NULL);
138 EXPECT_TRUE(query->NeverUsed()); 138 EXPECT_TRUE(query->NeverUsed());
139 EXPECT_FALSE(query->Pending()); 139 EXPECT_FALSE(query->Pending());
140 EXPECT_EQ(0, query->token()); 140 EXPECT_EQ(0, query->token());
141 EXPECT_EQ(0u, query->submit_count()); 141 EXPECT_EQ(0u, query->submit_count());
142 142
143 // Check MarkAsActive. 143 // Check MarkAsActive.
144 query->MarkAsActive(); 144 query->MarkAsActive();
145 EXPECT_FALSE(query->NeverUsed()); 145 EXPECT_FALSE(query->NeverUsed());
146 EXPECT_FALSE(query->Pending()); 146 EXPECT_FALSE(query->Pending());
(...skipping 24 matching lines...) Expand all
171 EXPECT_FALSE(query->Pending()); 171 EXPECT_FALSE(query->Pending());
172 } 172 }
173 173
174 TEST_F(QueryTrackerTest, Remove) { 174 TEST_F(QueryTrackerTest, Remove) {
175 const GLuint kId1 = 123; 175 const GLuint kId1 = 123;
176 const int32 kToken = 46; 176 const int32 kToken = 46;
177 const uint32 kResult = 456; 177 const uint32 kResult = 456;
178 178
179 // Create a Query. 179 // Create a Query.
180 QueryTracker::Query* query = query_tracker_->CreateQuery( 180 QueryTracker::Query* query = query_tracker_->CreateQuery(
181 kId1, GL_ANY_SAMPLES_PASSED_EXT); 181 kId1, GL_ANY_SAMPLES_PASSED_EXT, false);
182 ASSERT_TRUE(query != NULL); 182 ASSERT_TRUE(query != NULL);
183 183
184 QuerySyncManager::Bucket* bucket = GetBucket(query); 184 QuerySyncManager::Bucket* bucket = GetBucket(query);
185 EXPECT_EQ(1u, bucket->used_query_count); 185 EXPECT_EQ(1u, bucket->used_query_count);
186 186
187 query->MarkAsActive(); 187 query->MarkAsActive();
188 query->MarkAsPending(kToken); 188 query->MarkAsPending(kToken);
189 189
190 query_tracker_->RemoveQuery(kId1); 190 query_tracker_->RemoveQuery(kId1);
191 // Check we get nothing for a non-existent query. 191 // Check we get nothing for a non-existent query.
192 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL); 192 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL);
193 193
194 // Check that memory was not freed. 194 // Check that memory was not freed.
195 EXPECT_EQ(1u, bucket->used_query_count); 195 EXPECT_EQ(1u, bucket->used_query_count);
196 196
197 // Simulate GPU process marking it as available. 197 // Simulate GPU process marking it as available.
198 QuerySync* sync = GetSync(query); 198 QuerySync* sync = GetSync(query);
199 sync->process_count = query->submit_count(); 199 sync->process_count = query->submit_count();
200 sync->result = kResult; 200 sync->result = kResult;
201 201
202 // Check FreeCompletedQueries. 202 // Check FreeCompletedQueries.
203 query_tracker_->FreeCompletedQueries(); 203 query_tracker_->FreeCompletedQueries();
204 EXPECT_EQ(0u, bucket->used_query_count); 204 EXPECT_EQ(0u, bucket->used_query_count);
205 } 205 }
206 206
207 } // namespace gles2 207 } // namespace gles2
208 } // namespace gpu 208 } // namespace gpu
209 209
210 210
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698