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

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

Issue 1131913004: More compact representation of the GL Query cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: And unittest Created 5 years, 7 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
« no previous file with comments | « gpu/command_buffer/client/query_tracker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 QuerySync* GetSync(QueryTracker::Query* query) { 102 QuerySync* GetSync(QueryTracker::Query* query) {
103 return query->info_.sync; 103 return query->info_.sync;
104 } 104 }
105 105
106 QuerySyncManager::Bucket* GetBucket(QueryTracker::Query* query) { 106 QuerySyncManager::Bucket* GetBucket(QueryTracker::Query* query) {
107 return query->info_.bucket; 107 return query->info_.bucket;
108 } 108 }
109 109
110 uint32 GetBucketUsedCount(QuerySyncManager::Bucket* bucket) {
111 return QuerySyncManager::kSyncsPerBucket - bucket->free_queries.size();
112 }
113
110 uint32 GetFlushGeneration() { return helper_->flush_generation(); } 114 uint32 GetFlushGeneration() { return helper_->flush_generation(); }
111 115
112 scoped_ptr<CommandBuffer> command_buffer_; 116 scoped_ptr<CommandBuffer> command_buffer_;
113 scoped_ptr<GLES2CmdHelper> helper_; 117 scoped_ptr<GLES2CmdHelper> helper_;
114 scoped_ptr<MappedMemoryManager> mapped_memory_; 118 scoped_ptr<MappedMemoryManager> mapped_memory_;
115 scoped_ptr<QueryTracker> query_tracker_; 119 scoped_ptr<QueryTracker> query_tracker_;
116 }; 120 };
117 121
118 TEST_F(QueryTrackerTest, Basic) { 122 TEST_F(QueryTrackerTest, Basic) {
119 const GLuint kId1 = 123; 123 const GLuint kId1 = 123;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 const GLuint kId1 = 123; 206 const GLuint kId1 = 123;
203 const int32 kToken = 46; 207 const int32 kToken = 46;
204 const uint32 kResult = 456; 208 const uint32 kResult = 456;
205 209
206 // Create a Query. 210 // Create a Query.
207 QueryTracker::Query* query = query_tracker_->CreateQuery( 211 QueryTracker::Query* query = query_tracker_->CreateQuery(
208 kId1, GL_ANY_SAMPLES_PASSED_EXT); 212 kId1, GL_ANY_SAMPLES_PASSED_EXT);
209 ASSERT_TRUE(query != NULL); 213 ASSERT_TRUE(query != NULL);
210 214
211 QuerySyncManager::Bucket* bucket = GetBucket(query); 215 QuerySyncManager::Bucket* bucket = GetBucket(query);
212 EXPECT_EQ(1u, bucket->used_query_count); 216 EXPECT_EQ(1u, GetBucketUsedCount(bucket));
213 217
214 query->MarkAsActive(); 218 query->MarkAsActive();
215 query->MarkAsPending(kToken); 219 query->MarkAsPending(kToken);
216 220
217 query_tracker_->RemoveQuery(kId1); 221 query_tracker_->RemoveQuery(kId1);
218 // Check we get nothing for a non-existent query. 222 // Check we get nothing for a non-existent query.
219 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL); 223 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL);
220 224
221 // Check that memory was not freed. 225 // Check that memory was not freed.
222 EXPECT_EQ(1u, bucket->used_query_count); 226 EXPECT_EQ(1u, GetBucketUsedCount(bucket));
223 227
224 // Simulate GPU process marking it as available. 228 // Simulate GPU process marking it as available.
225 QuerySync* sync = GetSync(query); 229 QuerySync* sync = GetSync(query);
226 sync->process_count = query->submit_count(); 230 sync->process_count = query->submit_count();
227 sync->result = kResult; 231 sync->result = kResult;
228 232
229 // Check FreeCompletedQueries. 233 // Check FreeCompletedQueries.
230 query_tracker_->FreeCompletedQueries(); 234 query_tracker_->FreeCompletedQueries();
231 EXPECT_EQ(0u, bucket->used_query_count); 235 EXPECT_EQ(0u, GetBucketUsedCount(bucket));
232 } 236 }
233 237
234 } // namespace gles2 238 } // namespace gles2
235 } // namespace gpu 239 } // namespace gpu
236 240
237 241
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/query_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698