OLD | NEW |
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 Loading... |
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 GetFlushGeneration() { return helper_->flush_generation(); } |
| 111 |
110 scoped_ptr<CommandBuffer> command_buffer_; | 112 scoped_ptr<CommandBuffer> command_buffer_; |
111 scoped_ptr<GLES2CmdHelper> helper_; | 113 scoped_ptr<GLES2CmdHelper> helper_; |
112 scoped_ptr<MappedMemoryManager> mapped_memory_; | 114 scoped_ptr<MappedMemoryManager> mapped_memory_; |
113 scoped_ptr<QueryTracker> query_tracker_; | 115 scoped_ptr<QueryTracker> query_tracker_; |
114 }; | 116 }; |
115 | 117 |
116 TEST_F(QueryTrackerTest, Basic) { | 118 TEST_F(QueryTrackerTest, Basic) { |
117 const GLuint kId1 = 123; | 119 const GLuint kId1 = 123; |
118 const GLuint kId2 = 124; | 120 const GLuint kId2 = 124; |
119 | 121 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 EXPECT_FALSE(query->NeverUsed()); | 159 EXPECT_FALSE(query->NeverUsed()); |
158 EXPECT_TRUE(query->Pending()); | 160 EXPECT_TRUE(query->Pending()); |
159 EXPECT_EQ(kToken, query->token()); | 161 EXPECT_EQ(kToken, query->token()); |
160 EXPECT_EQ(1, query->submit_count()); | 162 EXPECT_EQ(1, query->submit_count()); |
161 | 163 |
162 // Check CheckResultsAvailable. | 164 // Check CheckResultsAvailable. |
163 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); | 165 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
164 EXPECT_FALSE(query->NeverUsed()); | 166 EXPECT_FALSE(query->NeverUsed()); |
165 EXPECT_TRUE(query->Pending()); | 167 EXPECT_TRUE(query->Pending()); |
166 | 168 |
| 169 // Flush only once if no more flushes happened between a call to |
| 170 // EndQuery command and CheckResultsAvailable |
| 171 // Advance put_ so flush calls in CheckResultsAvailable go through |
| 172 // and updates flush_generation count |
| 173 helper_->Noop(1); |
| 174 // Set Query in pending state_ to simulate EndQuery command is called |
| 175 query->MarkAsPending(kToken); |
| 176 EXPECT_TRUE(query->Pending()); |
| 177 // Store FlushGeneration count after EndQuery is called |
| 178 uint32 gen1 = GetFlushGeneration(); |
| 179 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
| 180 uint32 gen2 = GetFlushGeneration(); |
| 181 EXPECT_NE(gen1, gen2); |
| 182 // Repeated calls to CheckResultsAvailable should not flush unnecessarily |
| 183 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
| 184 gen1 = GetFlushGeneration(); |
| 185 EXPECT_EQ(gen1, gen2); |
| 186 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
| 187 gen1 = GetFlushGeneration(); |
| 188 EXPECT_EQ(gen1, gen2); |
| 189 |
167 // Simulate GPU process marking it as available. | 190 // Simulate GPU process marking it as available. |
168 QuerySync* sync = GetSync(query); | 191 QuerySync* sync = GetSync(query); |
169 sync->process_count = query->submit_count(); | 192 sync->process_count = query->submit_count(); |
170 sync->result = kResult; | 193 sync->result = kResult; |
171 | 194 |
172 // Check CheckResultsAvailable. | 195 // Check CheckResultsAvailable. |
173 EXPECT_TRUE(query->CheckResultsAvailable(helper_.get())); | 196 EXPECT_TRUE(query->CheckResultsAvailable(helper_.get())); |
174 EXPECT_EQ(kResult, query->GetResult()); | 197 EXPECT_EQ(kResult, query->GetResult()); |
175 EXPECT_FALSE(query->NeverUsed()); | 198 EXPECT_FALSE(query->NeverUsed()); |
176 EXPECT_FALSE(query->Pending()); | 199 EXPECT_FALSE(query->Pending()); |
(...skipping 29 matching lines...) Expand all Loading... |
206 | 229 |
207 // Check FreeCompletedQueries. | 230 // Check FreeCompletedQueries. |
208 query_tracker_->FreeCompletedQueries(); | 231 query_tracker_->FreeCompletedQueries(); |
209 EXPECT_EQ(0u, bucket->used_query_count); | 232 EXPECT_EQ(0u, bucket->used_query_count); |
210 } | 233 } |
211 | 234 |
212 } // namespace gles2 | 235 } // namespace gles2 |
213 } // namespace gpu | 236 } // namespace gpu |
214 | 237 |
215 | 238 |
OLD | NEW |