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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 EXPECT_EQ(0, query->token()); | 154 EXPECT_EQ(0, query->token()); |
155 EXPECT_EQ(1, query->submit_count()); | 155 EXPECT_EQ(1, query->submit_count()); |
156 | 156 |
157 // Check MarkAsPending. | 157 // Check MarkAsPending. |
158 query->MarkAsPending(kToken); | 158 query->MarkAsPending(kToken); |
159 EXPECT_FALSE(query->NeverUsed()); | 159 EXPECT_FALSE(query->NeverUsed()); |
160 EXPECT_TRUE(query->Pending()); | 160 EXPECT_TRUE(query->Pending()); |
161 EXPECT_EQ(kToken, query->token()); | 161 EXPECT_EQ(kToken, query->token()); |
162 EXPECT_EQ(1, query->submit_count()); | 162 EXPECT_EQ(1, query->submit_count()); |
163 | 163 |
| 164 // Flush only once if no more flushes happened between a call to |
| 165 // EndQuery command and CheckResultsAvailable |
| 166 // Advance put_ so flush calls in CheckResultsAvailable go through |
| 167 // and updates flush_generation count |
| 168 helper_->Noop(1); |
| 169 |
| 170 // Store FlushGeneration count after EndQuery is called |
| 171 uint32 gen1 = GetFlushGeneration(); |
| 172 |
164 // Check CheckResultsAvailable. | 173 // Check CheckResultsAvailable. |
165 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); | 174 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
166 EXPECT_FALSE(query->NeverUsed()); | 175 EXPECT_FALSE(query->NeverUsed()); |
167 EXPECT_TRUE(query->Pending()); | 176 EXPECT_TRUE(query->Pending()); |
168 | 177 |
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(); | 178 uint32 gen2 = GetFlushGeneration(); |
181 EXPECT_NE(gen1, gen2); | 179 EXPECT_NE(gen1, gen2); |
| 180 |
182 // Repeated calls to CheckResultsAvailable should not flush unnecessarily | 181 // Repeated calls to CheckResultsAvailable should not flush unnecessarily |
183 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); | 182 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
184 gen1 = GetFlushGeneration(); | 183 gen1 = GetFlushGeneration(); |
185 EXPECT_EQ(gen1, gen2); | 184 EXPECT_EQ(gen1, gen2); |
186 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); | 185 EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
187 gen1 = GetFlushGeneration(); | 186 gen1 = GetFlushGeneration(); |
188 EXPECT_EQ(gen1, gen2); | 187 EXPECT_EQ(gen1, gen2); |
189 | 188 |
190 // Simulate GPU process marking it as available. | 189 // Simulate GPU process marking it as available. |
191 QuerySync* sync = GetSync(query); | 190 QuerySync* sync = GetSync(query); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 228 |
230 // Check FreeCompletedQueries. | 229 // Check FreeCompletedQueries. |
231 query_tracker_->FreeCompletedQueries(); | 230 query_tracker_->FreeCompletedQueries(); |
232 EXPECT_EQ(0u, bucket->used_query_count); | 231 EXPECT_EQ(0u, bucket->used_query_count); |
233 } | 232 } |
234 | 233 |
235 } // namespace gles2 | 234 } // namespace gles2 |
236 } // namespace gpu | 235 } // namespace gpu |
237 | 236 |
238 | 237 |
OLD | NEW |