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

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

Issue 18340003: gpu: Fix removal of pending queries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 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 | Annotate | Revision Log
« 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 query_tracker_.reset(); 89 query_tracker_.reset();
90 mapped_memory_.reset(); 90 mapped_memory_.reset();
91 helper_.reset(); 91 helper_.reset();
92 command_buffer_.reset(); 92 command_buffer_.reset();
93 } 93 }
94 94
95 QuerySync* GetSync(QueryTracker::Query* query) { 95 QuerySync* GetSync(QueryTracker::Query* query) {
96 return query->info_.sync; 96 return query->info_.sync;
97 } 97 }
98 98
99 QuerySyncManager::Bucket* GetBucket(QueryTracker::Query* query) {
100 return query->info_.bucket;
101 }
102
99 scoped_ptr<CommandBuffer> command_buffer_; 103 scoped_ptr<CommandBuffer> command_buffer_;
100 scoped_ptr<GLES2CmdHelper> helper_; 104 scoped_ptr<GLES2CmdHelper> helper_;
101 scoped_ptr<MappedMemoryManager> mapped_memory_; 105 scoped_ptr<MappedMemoryManager> mapped_memory_;
102 scoped_ptr<QueryTracker> query_tracker_; 106 scoped_ptr<QueryTracker> query_tracker_;
103 }; 107 };
104 108
105 TEST_F(QueryTrackerTest, Basic) { 109 TEST_F(QueryTrackerTest, Basic) {
106 const GLuint kId1 = 123; 110 const GLuint kId1 = 123;
107 const GLuint kId2 = 124; 111 const GLuint kId2 = 124;
108 112
109 // Check we can create a Query. 113 // Check we can create a Query.
110 QueryTracker::Query* query = query_tracker_->CreateQuery( 114 QueryTracker::Query* query = query_tracker_->CreateQuery(
111 kId1, GL_ANY_SAMPLES_PASSED_EXT); 115 kId1, GL_ANY_SAMPLES_PASSED_EXT);
112 ASSERT_TRUE(query != NULL); 116 ASSERT_TRUE(query != NULL);
113 // Check we can get the same Query. 117 // Check we can get the same Query.
114 EXPECT_EQ(query, query_tracker_->GetQuery(kId1)); 118 EXPECT_EQ(query, query_tracker_->GetQuery(kId1));
115 // Check we get nothing for a non-existent query. 119 // Check we get nothing for a non-existent query.
116 EXPECT_TRUE(query_tracker_->GetQuery(kId2) == NULL); 120 EXPECT_TRUE(query_tracker_->GetQuery(kId2) == NULL);
117 // Check we can delete the query. 121 // Check we can delete the query.
118 query_tracker_->RemoveQuery(kId1, false); 122 query_tracker_->RemoveQuery(kId1);
119 // Check we get nothing for a non-existent query. 123 // Check we get nothing for a non-existent query.
120 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL); 124 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL);
121 } 125 }
122 126
123 TEST_F(QueryTrackerTest, Query) { 127 TEST_F(QueryTrackerTest, Query) {
124 const GLuint kId1 = 123; 128 const GLuint kId1 = 123;
125 const int32 kToken = 46; 129 const int32 kToken = 46;
126 const uint32 kResult = 456; 130 const uint32 kResult = 456;
127 131
128 // Create a Query. 132 // Create a Query.
(...skipping 29 matching lines...) Expand all
158 sync->process_count = query->submit_count(); 162 sync->process_count = query->submit_count();
159 sync->result = kResult; 163 sync->result = kResult;
160 164
161 // Check CheckResultsAvailable. 165 // Check CheckResultsAvailable.
162 EXPECT_TRUE(query->CheckResultsAvailable(helper_.get())); 166 EXPECT_TRUE(query->CheckResultsAvailable(helper_.get()));
163 EXPECT_EQ(kResult, query->GetResult()); 167 EXPECT_EQ(kResult, query->GetResult());
164 EXPECT_FALSE(query->NeverUsed()); 168 EXPECT_FALSE(query->NeverUsed());
165 EXPECT_FALSE(query->Pending()); 169 EXPECT_FALSE(query->Pending());
166 } 170 }
167 171
172 TEST_F(QueryTrackerTest, Remove) {
173 const GLuint kId1 = 123;
174 const int32 kToken = 46;
175 const uint32 kResult = 456;
176
177 // Create a Query.
178 QueryTracker::Query* query = query_tracker_->CreateQuery(
179 kId1, GL_ANY_SAMPLES_PASSED_EXT);
180 ASSERT_TRUE(query != NULL);
181
182 QuerySyncManager::Bucket* bucket = GetBucket(query);
183 EXPECT_EQ(1u, bucket->used_query_count);
184
185 query->MarkAsActive();
186 query->MarkAsPending(kToken);
187
188 query_tracker_->RemoveQuery(kId1);
189 // Check we get nothing for a non-existent query.
190 EXPECT_TRUE(query_tracker_->GetQuery(kId1) == NULL);
191
192 // Check that memory was not freed.
193 EXPECT_EQ(1u, bucket->used_query_count);
194
195 // Simulate GPU process marking it as available.
196 QuerySync* sync = GetSync(query);
197 sync->process_count = query->submit_count();
198 sync->result = kResult;
199
200 // Check FreeCompletedQueries.
201 query_tracker_->FreeCompletedQueries();
202 EXPECT_EQ(0u, bucket->used_query_count);
203 }
204
168 } // namespace gles2 205 } // namespace gles2
169 } // namespace gpu 206 } // namespace gpu
170 207
171 208
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