Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: gpu/command_buffer/client/query_tracker.cc

Issue 184223003: gpu: Use explicit atomics instead of assuming that 32bit read/writes are atomic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-upload Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "gpu/command_buffer/client/gles2_cmd_helper.h" 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
12 #include "gpu/command_buffer/client/gles2_implementation.h" 13 #include "gpu/command_buffer/client/gles2_implementation.h"
13 #include "gpu/command_buffer/client/mapped_memory.h" 14 #include "gpu/command_buffer/client/mapped_memory.h"
14 #include "gpu/command_buffer/common/time.h" 15 #include "gpu/command_buffer/common/time.h"
15 16
16 namespace gpu { 17 namespace gpu {
17 namespace gles2 { 18 namespace gles2 {
18 19
19 QuerySyncManager::QuerySyncManager(MappedMemoryManager* manager) 20 QuerySyncManager::QuerySyncManager(MappedMemoryManager* manager)
20 : mapped_memory_(manager) { 21 : mapped_memory_(manager) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 140 }
140 } 141 }
141 } 142 }
142 gl->helper()->EndQueryEXT(target(), submit_count()); 143 gl->helper()->EndQueryEXT(target(), submit_count());
143 MarkAsPending(gl->helper()->InsertToken()); 144 MarkAsPending(gl->helper()->InsertToken());
144 } 145 }
145 146
146 bool QueryTracker::Query::CheckResultsAvailable( 147 bool QueryTracker::Query::CheckResultsAvailable(
147 CommandBufferHelper* helper) { 148 CommandBufferHelper* helper) {
148 if (Pending()) { 149 if (Pending()) {
149 if (info_.sync->process_count == submit_count_ || 150 if (base::subtle::Acquire_Load(
151 &info_.sync->process_count) == submit_count_ ||
150 helper->IsContextLost()) { 152 helper->IsContextLost()) {
151 // Need a MemoryBarrier here so that sync->result read after
152 // sync->process_count.
153 base::subtle::MemoryBarrier();
154 switch (target()) { 153 switch (target()) {
155 case GL_COMMANDS_ISSUED_CHROMIUM: 154 case GL_COMMANDS_ISSUED_CHROMIUM:
156 result_ = std::min(info_.sync->result, 155 result_ = std::min(info_.sync->result,
157 static_cast<uint64>(0xFFFFFFFFL)); 156 static_cast<uint64>(0xFFFFFFFFL));
158 break; 157 break;
159 case GL_LATENCY_QUERY_CHROMIUM: 158 case GL_LATENCY_QUERY_CHROMIUM:
160 DCHECK(info_.sync->result >= client_begin_time_us_); 159 DCHECK(info_.sync->result >= client_begin_time_us_);
161 result_ = std::min(info_.sync->result - client_begin_time_us_, 160 result_ = std::min(info_.sync->result - client_begin_time_us_,
162 static_cast<uint64>(0xFFFFFFFFL)); 161 static_cast<uint64>(0xFFFFFFFFL));
163 break; 162 break;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 void QueryTracker::Shrink() { 241 void QueryTracker::Shrink() {
243 FreeCompletedQueries(); 242 FreeCompletedQueries();
244 query_sync_manager_.Shrink(); 243 query_sync_manager_.Shrink();
245 } 244 }
246 245
247 void QueryTracker::FreeCompletedQueries() { 246 void QueryTracker::FreeCompletedQueries() {
248 QueryList::iterator it = removed_queries_.begin(); 247 QueryList::iterator it = removed_queries_.begin();
249 while (it != removed_queries_.end()) { 248 while (it != removed_queries_.end()) {
250 Query* query = *it; 249 Query* query = *it;
251 if (query->Pending() && 250 if (query->Pending() &&
252 query->info_.sync->process_count != query->submit_count()) { 251 base::subtle::Acquire_Load(
252 &query->info_.sync->process_count) != query->submit_count()) {
253 ++it; 253 ++it;
254 continue; 254 continue;
255 } 255 }
256 256
257 query_sync_manager_.Free(query->info_); 257 query_sync_manager_.Free(query->info_);
258 it = removed_queries_.erase(it); 258 it = removed_queries_.erase(it);
259 delete query; 259 delete query;
260 } 260 }
261 } 261 }
262 262
263 } // namespace gles2 263 } // namespace gles2
264 } // namespace gpu 264 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698