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 #include "gpu/command_buffer/client/query_tracker.h" | 5 #include "gpu/command_buffer/client/query_tracker.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 #include <GLES2/gl2extchromium.h> | 9 #include <GLES2/gl2extchromium.h> |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 | 168 |
169 bool QueryTracker::Query::CheckResultsAvailable( | 169 bool QueryTracker::Query::CheckResultsAvailable( |
170 CommandBufferHelper* helper) { | 170 CommandBufferHelper* helper) { |
171 if (Pending()) { | 171 if (Pending()) { |
172 if (base::subtle::Acquire_Load(&info_.sync->process_count) == | 172 if (base::subtle::Acquire_Load(&info_.sync->process_count) == |
173 submit_count_ || | 173 submit_count_ || |
174 helper->IsContextLost()) { | 174 helper->IsContextLost()) { |
175 switch (target()) { | 175 switch (target()) { |
176 case GL_COMMANDS_ISSUED_CHROMIUM: | 176 case GL_COMMANDS_ISSUED_CHROMIUM: |
177 result_ = info_.sync->result; | 177 result_ = base::saturated_cast<uint32>(info_.sync->result); |
178 break; | 178 break; |
179 case GL_LATENCY_QUERY_CHROMIUM: | 179 case GL_LATENCY_QUERY_CHROMIUM: |
180 // Disabled DCHECK because of http://crbug.com/419236. | 180 // Disabled DCHECK because of http://crbug.com/419236. |
181 //DCHECK(info_.sync->result >= client_begin_time_us_); | 181 //DCHECK(info_.sync->result >= client_begin_time_us_); |
182 result_ = info_.sync->result - client_begin_time_us_; | 182 result_ = base::saturated_cast<uint32>( |
| 183 info_.sync->result - client_begin_time_us_); |
183 break; | 184 break; |
184 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: | 185 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: |
185 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: | 186 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: |
186 default: | 187 default: |
187 result_ = info_.sync->result; | 188 result_ = static_cast<uint32>(info_.sync->result); |
188 break; | 189 break; |
189 } | 190 } |
190 state_ = kComplete; | 191 state_ = kComplete; |
191 } else { | 192 } else { |
192 if ((helper->flush_generation() - flush_count_ - 1) >= 0x80000000) { | 193 if ((helper->flush_generation() - flush_count_ - 1) >= 0x80000000) { |
193 helper->Flush(); | 194 helper->Flush(); |
194 } else { | 195 } else { |
195 // Insert no-ops so that eventually the GPU process will see more work. | 196 // Insert no-ops so that eventually the GPU process will see more work. |
196 helper->Noop(1); | 197 helper->Noop(1); |
197 } | 198 } |
198 } | 199 } |
199 } | 200 } |
200 return state_ == kComplete; | 201 return state_ == kComplete; |
201 } | 202 } |
202 | 203 |
203 uint64 QueryTracker::Query::GetResult() const { | 204 uint32 QueryTracker::Query::GetResult() const { |
204 DCHECK(state_ == kComplete || state_ == kUninitialized); | 205 DCHECK(state_ == kComplete || state_ == kUninitialized); |
205 return result_; | 206 return result_; |
206 } | 207 } |
207 | 208 |
208 QueryTracker::QueryTracker(MappedMemoryManager* manager) | 209 QueryTracker::QueryTracker(MappedMemoryManager* manager) |
209 : query_sync_manager_(manager) { | 210 : query_sync_manager_(manager) { |
210 } | 211 } |
211 | 212 |
212 QueryTracker::~QueryTracker() { | 213 QueryTracker::~QueryTracker() { |
213 while (!queries_.empty()) { | 214 while (!queries_.empty()) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 return false; | 320 return false; |
320 } | 321 } |
321 | 322 |
322 target_it->second->End(gl); | 323 target_it->second->End(gl); |
323 current_queries_.erase(target_it); | 324 current_queries_.erase(target_it); |
324 return true; | 325 return true; |
325 } | 326 } |
326 | 327 |
327 } // namespace gles2 | 328 } // namespace gles2 |
328 } // namespace gpu | 329 } // namespace gpu |
OLD | NEW |