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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 86 } |
87 | 87 |
88 QueryTracker::Query::Query(GLuint id, GLenum target, | 88 QueryTracker::Query::Query(GLuint id, GLenum target, |
89 const QuerySyncManager::QueryInfo& info) | 89 const QuerySyncManager::QueryInfo& info) |
90 : id_(id), | 90 : id_(id), |
91 target_(target), | 91 target_(target), |
92 info_(info), | 92 info_(info), |
93 state_(kUninitialized), | 93 state_(kUninitialized), |
94 submit_count_(0), | 94 submit_count_(0), |
95 token_(0), | 95 token_(0), |
96 flushed_(false), | 96 flush_count_(0), |
97 client_begin_time_us_(0), | 97 client_begin_time_us_(0), |
98 result_(0) { | 98 result_(0) { |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 void QueryTracker::Query::Begin(GLES2Implementation* gl) { | 102 void QueryTracker::Query::Begin(GLES2Implementation* gl) { |
103 // init memory, inc count | 103 // init memory, inc count |
104 MarkAsActive(); | 104 MarkAsActive(); |
105 | 105 |
106 switch (target()) { | 106 switch (target()) { |
(...skipping 26 matching lines...) Expand all Loading... |
133 // There's an error on the client, no need to bother the service. just | 133 // There's an error on the client, no need to bother the service. just |
134 // set the query as completed and return the error. | 134 // set the query as completed and return the error. |
135 if (error != GL_NO_ERROR) { | 135 if (error != GL_NO_ERROR) { |
136 state_ = kComplete; | 136 state_ = kComplete; |
137 result_ = error; | 137 result_ = error; |
138 return; | 138 return; |
139 } | 139 } |
140 } | 140 } |
141 } | 141 } |
142 } | 142 } |
| 143 flush_count_ = gl->helper()->flush_generation(); |
143 gl->helper()->EndQueryEXT(target(), submit_count()); | 144 gl->helper()->EndQueryEXT(target(), submit_count()); |
144 MarkAsPending(gl->helper()->InsertToken()); | 145 MarkAsPending(gl->helper()->InsertToken()); |
145 } | 146 } |
146 | 147 |
147 bool QueryTracker::Query::CheckResultsAvailable( | 148 bool QueryTracker::Query::CheckResultsAvailable( |
148 CommandBufferHelper* helper) { | 149 CommandBufferHelper* helper) { |
149 if (Pending()) { | 150 if (Pending()) { |
150 if (base::subtle::Acquire_Load(&info_.sync->process_count) == | 151 if (base::subtle::Acquire_Load(&info_.sync->process_count) == |
151 submit_count_ || | 152 submit_count_ || |
152 helper->IsContextLost()) { | 153 helper->IsContextLost()) { |
153 switch (target()) { | 154 switch (target()) { |
154 case GL_COMMANDS_ISSUED_CHROMIUM: | 155 case GL_COMMANDS_ISSUED_CHROMIUM: |
155 result_ = std::min(info_.sync->result, | 156 result_ = std::min(info_.sync->result, |
156 static_cast<uint64>(0xFFFFFFFFL)); | 157 static_cast<uint64>(0xFFFFFFFFL)); |
157 break; | 158 break; |
158 case GL_LATENCY_QUERY_CHROMIUM: | 159 case GL_LATENCY_QUERY_CHROMIUM: |
159 DCHECK(info_.sync->result >= client_begin_time_us_); | 160 DCHECK(info_.sync->result >= client_begin_time_us_); |
160 result_ = std::min(info_.sync->result - client_begin_time_us_, | 161 result_ = std::min(info_.sync->result - client_begin_time_us_, |
161 static_cast<uint64>(0xFFFFFFFFL)); | 162 static_cast<uint64>(0xFFFFFFFFL)); |
162 break; | 163 break; |
163 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: | 164 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: |
164 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: | 165 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: |
165 default: | 166 default: |
166 result_ = info_.sync->result; | 167 result_ = info_.sync->result; |
167 break; | 168 break; |
168 } | 169 } |
169 state_ = kComplete; | 170 state_ = kComplete; |
170 } else { | 171 } else { |
171 if (!flushed_) { | 172 if ((helper->flush_generation() - flush_count_ - 1) >= 0x80000000) { |
172 // TODO(gman): We could reduce the number of flushes by having a | |
173 // flush count, recording that count at the time we insert the | |
174 // EndQuery command and then only flushing here if we've have not | |
175 // passed that count yet. | |
176 flushed_ = true; | |
177 helper->Flush(); | 173 helper->Flush(); |
178 } else { | 174 } else { |
179 // Insert no-ops so that eventually the GPU process will see more work. | 175 // Insert no-ops so that eventually the GPU process will see more work. |
180 helper->Noop(1); | 176 helper->Noop(1); |
181 } | 177 } |
182 } | 178 } |
183 } | 179 } |
184 return state_ == kComplete; | 180 return state_ == kComplete; |
185 } | 181 } |
186 | 182 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 251 } |
256 | 252 |
257 query_sync_manager_.Free(query->info_); | 253 query_sync_manager_.Free(query->info_); |
258 it = removed_queries_.erase(it); | 254 it = removed_queries_.erase(it); |
259 delete query; | 255 delete query; |
260 } | 256 } |
261 } | 257 } |
262 | 258 |
263 } // namespace gles2 | 259 } // namespace gles2 |
264 } // namespace gpu | 260 } // namespace gpu |
OLD | NEW |