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

Side by Side Diff: gpu/command_buffer/service/query_manager.cc

Issue 10389107: Implement GL_EXT_occlusion_query_boolean on OSX (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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/service/query_manager.h" 5 #include "gpu/command_buffer/service/query_manager.h"
6 #include "base/atomicops.h" 6 #include "base/atomicops.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/service/common_decoder.h" 10 #include "gpu/command_buffer/service/common_decoder.h"
11 #include "gpu/command_buffer/service/feature_info.h"
11 12
12 namespace gpu { 13 namespace gpu {
13 namespace gles2 { 14 namespace gles2 {
14 15
15 class AllSamplesPassedQuery : public QueryManager::Query { 16 class AllSamplesPassedQuery : public QueryManager::Query {
16 public: 17 public:
17 AllSamplesPassedQuery( 18 AllSamplesPassedQuery(
18 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, 19 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset,
19 GLuint service_id); 20 GLuint service_id);
20 virtual ~AllSamplesPassedQuery(); 21 virtual ~AllSamplesPassedQuery();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 GLuint available = 0; 60 GLuint available = 0;
60 glGetQueryObjectuivARB( 61 glGetQueryObjectuivARB(
61 service_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); 62 service_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available);
62 if (!available) { 63 if (!available) {
63 return true; 64 return true;
64 } 65 }
65 GLuint result = 0; 66 GLuint result = 0;
66 glGetQueryObjectuivARB( 67 glGetQueryObjectuivARB(
67 service_id_, GL_QUERY_RESULT_EXT, &result); 68 service_id_, GL_QUERY_RESULT_EXT, &result);
68 69
69 return MarkAsCompleted(result); 70 return MarkAsCompleted(result != 0);
Nico 2014/01/08 04:17:09 Why this change? Should MarkAsCompleted() get a bo
Zhenyao Mo 2014/01/08 18:55:11 This should actually be MarkAsCompleted(result ==
Zhenyao Mo 2014/01/08 19:08:18 If I understand this correctly (without going thro
70 } 71 }
71 72
72 class CommandsIssuedQuery : public QueryManager::Query { 73 class CommandsIssuedQuery : public QueryManager::Query {
73 public: 74 public:
74 CommandsIssuedQuery( 75 CommandsIssuedQuery(
75 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); 76 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset);
76 virtual ~CommandsIssuedQuery(); 77 virtual ~CommandsIssuedQuery();
77 78
78 virtual bool Begin() OVERRIDE; 79 virtual bool Begin() OVERRIDE;
79 virtual bool End(uint32 submit_count) OVERRIDE; 80 virtual bool End(uint32 submit_count) OVERRIDE;
(...skipping 30 matching lines...) Expand all
110 } 111 }
111 112
112 void CommandsIssuedQuery::Destroy(bool /* have_context */) { 113 void CommandsIssuedQuery::Destroy(bool /* have_context */) {
113 if (!IsDeleted()) { 114 if (!IsDeleted()) {
114 MarkAsDeleted(); 115 MarkAsDeleted();
115 } 116 }
116 } 117 }
117 118
118 QueryManager::QueryManager( 119 QueryManager::QueryManager(
119 CommonDecoder* decoder, 120 CommonDecoder* decoder,
120 bool use_arb_occlusion_query2_for_occlusion_query_boolean) 121 FeatureInfo* feature_info)
121 : decoder_(decoder), 122 : decoder_(decoder),
122 use_arb_occlusion_query2_for_occlusion_query_boolean_( 123 use_arb_occlusion_query2_for_occlusion_query_boolean_(
123 use_arb_occlusion_query2_for_occlusion_query_boolean), 124 feature_info->feature_flags(
125 ).use_arb_occlusion_query2_for_occlusion_query_boolean),
126 use_arb_occlusion_query_for_occlusion_query_boolean_(
127 feature_info->feature_flags(
128 ).use_arb_occlusion_query_for_occlusion_query_boolean),
124 query_count_(0) { 129 query_count_(0) {
130 DCHECK(!(use_arb_occlusion_query_for_occlusion_query_boolean_ &&
131 use_arb_occlusion_query2_for_occlusion_query_boolean_));
125 } 132 }
126 133
127 QueryManager::~QueryManager() { 134 QueryManager::~QueryManager() {
128 DCHECK(queries_.empty()); 135 DCHECK(queries_.empty());
129 136
130 // If this triggers, that means something is keeping a reference to 137 // If this triggers, that means something is keeping a reference to
131 // a Query belonging to this. 138 // a Query belonging to this.
132 CHECK_EQ(query_count_, 0u); 139 CHECK_EQ(query_count_, 0u);
133 } 140 }
134 141
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 187 }
181 188
182 void QueryManager::StartTracking(QueryManager::Query* /* query */) { 189 void QueryManager::StartTracking(QueryManager::Query* /* query */) {
183 ++query_count_; 190 ++query_count_;
184 } 191 }
185 192
186 void QueryManager::StopTracking(QueryManager::Query* /* query */) { 193 void QueryManager::StopTracking(QueryManager::Query* /* query */) {
187 --query_count_; 194 --query_count_;
188 } 195 }
189 196
197 GLenum QueryManager::AdjustTargetForEmulation(GLenum target) {
198 switch (target) {
199 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
200 case GL_ANY_SAMPLES_PASSED_EXT:
201 if (use_arb_occlusion_query2_for_occlusion_query_boolean_) {
202 // ARB_occlusion_query2 does not have a
203 // GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT
204 // target.
205 target = GL_ANY_SAMPLES_PASSED_EXT;
206 } else if (use_arb_occlusion_query_for_occlusion_query_boolean_) {
207 // ARB_occlusion_query does not have a
208 // GL_ANY_SAMPLES_PASSED_EXT
209 // target.
210 target = GL_SAMPLES_PASSED_ARB;
211 }
212 break;
213 default:
214 break;
215 }
216 return target;
217 }
218
190 void QueryManager::BeginQueryHelper(GLenum target, GLuint id) { 219 void QueryManager::BeginQueryHelper(GLenum target, GLuint id) {
191 // ARB_occlusion_query2 does not have a GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 220 target = AdjustTargetForEmulation(target);
192 // target.
193 if (use_arb_occlusion_query2_for_occlusion_query_boolean_) {
194 target = GL_ANY_SAMPLES_PASSED_EXT;
195 }
196 glBeginQueryARB(target, id); 221 glBeginQueryARB(target, id);
197 } 222 }
198 223
199 void QueryManager::EndQueryHelper(GLenum target) { 224 void QueryManager::EndQueryHelper(GLenum target) {
200 // ARB_occlusion_query2 does not have a GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 225 target = AdjustTargetForEmulation(target);
201 // target.
202 if (use_arb_occlusion_query2_for_occlusion_query_boolean_) {
203 target = GL_ANY_SAMPLES_PASSED_EXT;
204 }
205 glEndQueryARB(target); 226 glEndQueryARB(target);
206 } 227 }
207 228
208 QueryManager::Query::Query( 229 QueryManager::Query::Query(
209 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) 230 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset)
210 : manager_(manager), 231 : manager_(manager),
211 target_(target), 232 target_(target),
212 shm_id_(shm_id), 233 shm_id_(shm_id),
213 shm_offset_(shm_offset), 234 shm_offset_(shm_offset),
214 submit_count_(0), 235 submit_count_(0),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 if (!RemovePendingQuery(query)) { 327 if (!RemovePendingQuery(query)) {
307 return false; 328 return false;
308 } 329 }
309 return query->End(submit_count); 330 return query->End(submit_count);
310 } 331 }
311 332
312 } // namespace gles2 333 } // namespace gles2
313 } // namespace gpu 334 } // namespace gpu
314 335
315 336
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager.h ('k') | gpu/command_buffer/service/query_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698