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 |
11 #include "base/atomicops.h" | 11 #include "base/atomicops.h" |
| 12 #include "base/numerics/safe_conversions.h" |
12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 13 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
13 #include "gpu/command_buffer/client/gles2_implementation.h" | 14 #include "gpu/command_buffer/client/gles2_implementation.h" |
14 #include "gpu/command_buffer/client/mapped_memory.h" | 15 #include "gpu/command_buffer/client/mapped_memory.h" |
15 #include "gpu/command_buffer/common/time.h" | 16 #include "gpu/command_buffer/common/time.h" |
16 | 17 |
17 namespace gpu { | 18 namespace gpu { |
18 namespace gles2 { | 19 namespace gles2 { |
19 | 20 |
20 QuerySyncManager::QuerySyncManager(MappedMemoryManager* manager) | 21 QuerySyncManager::QuerySyncManager(MappedMemoryManager* manager) |
21 : mapped_memory_(manager) { | 22 : mapped_memory_(manager) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 147 } |
147 | 148 |
148 bool QueryTracker::Query::CheckResultsAvailable( | 149 bool QueryTracker::Query::CheckResultsAvailable( |
149 CommandBufferHelper* helper) { | 150 CommandBufferHelper* helper) { |
150 if (Pending()) { | 151 if (Pending()) { |
151 if (base::subtle::Acquire_Load(&info_.sync->process_count) == | 152 if (base::subtle::Acquire_Load(&info_.sync->process_count) == |
152 submit_count_ || | 153 submit_count_ || |
153 helper->IsContextLost()) { | 154 helper->IsContextLost()) { |
154 switch (target()) { | 155 switch (target()) { |
155 case GL_COMMANDS_ISSUED_CHROMIUM: | 156 case GL_COMMANDS_ISSUED_CHROMIUM: |
156 result_ = std::min(info_.sync->result, | 157 result_ = base::saturated_cast<uint32>(info_.sync->result); |
157 static_cast<uint64>(0xFFFFFFFFL)); | |
158 break; | 158 break; |
159 case GL_LATENCY_QUERY_CHROMIUM: | 159 case GL_LATENCY_QUERY_CHROMIUM: |
160 // Disabled DCHECK because of http://crbug.com/419236. | 160 // Disabled DCHECK because of http://crbug.com/419236. |
161 //DCHECK(info_.sync->result >= client_begin_time_us_); | 161 //DCHECK(info_.sync->result >= client_begin_time_us_); |
162 result_ = std::min(info_.sync->result - client_begin_time_us_, | 162 result_ = base::saturated_cast<uint32>( |
163 static_cast<uint64>(0xFFFFFFFFL)); | 163 info_.sync->result - client_begin_time_us_); |
164 break; | 164 break; |
165 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: | 165 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: |
166 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: | 166 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: |
167 default: | 167 default: |
168 result_ = info_.sync->result; | 168 result_ = static_cast<uint32>(info_.sync->result); |
169 break; | 169 break; |
170 } | 170 } |
171 state_ = kComplete; | 171 state_ = kComplete; |
172 } else { | 172 } else { |
173 if ((helper->flush_generation() - flush_count_ - 1) >= 0x80000000) { | 173 if ((helper->flush_generation() - flush_count_ - 1) >= 0x80000000) { |
174 helper->Flush(); | 174 helper->Flush(); |
175 } else { | 175 } else { |
176 // Insert no-ops so that eventually the GPU process will see more work. | 176 // Insert no-ops so that eventually the GPU process will see more work. |
177 helper->Noop(1); | 177 helper->Noop(1); |
178 } | 178 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 | 253 |
254 query_sync_manager_.Free(query->info_); | 254 query_sync_manager_.Free(query->info_); |
255 it = removed_queries_.erase(it); | 255 it = removed_queries_.erase(it); |
256 delete query; | 256 delete query; |
257 } | 257 } |
258 } | 258 } |
259 | 259 |
260 } // namespace gles2 | 260 } // namespace gles2 |
261 } // namespace gpu | 261 } // namespace gpu |
OLD | NEW |