| 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "base/atomicops.h" |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "gpu/command_buffer/service/feature_info.h" | 16 #include "gpu/command_buffer/service/feature_info.h" |
| 16 #include "gpu/command_buffer/service/gl_utils.h" | 17 #include "gpu/command_buffer/service/gl_utils.h" |
| 17 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
| 18 | 19 |
| 19 namespace gpu { | 20 namespace gpu { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 55 } |
| 55 | 56 |
| 56 uint32 shm_offset() const { | 57 uint32 shm_offset() const { |
| 57 return shm_offset_; | 58 return shm_offset_; |
| 58 } | 59 } |
| 59 | 60 |
| 60 // Returns false if shared memory for sync is invalid. | 61 // Returns false if shared memory for sync is invalid. |
| 61 virtual bool Begin() = 0; | 62 virtual bool Begin() = 0; |
| 62 | 63 |
| 63 // Returns false if shared memory for sync is invalid. | 64 // Returns false if shared memory for sync is invalid. |
| 64 virtual bool End(uint32 submit_count) = 0; | 65 virtual bool End(base::subtle::Atomic32 submit_count) = 0; |
| 65 | 66 |
| 66 // Returns false if shared memory for sync is invalid. | 67 // Returns false if shared memory for sync is invalid. |
| 67 virtual bool Process() = 0; | 68 virtual bool Process() = 0; |
| 68 | 69 |
| 69 virtual void Destroy(bool have_context) = 0; | 70 virtual void Destroy(bool have_context) = 0; |
| 70 | 71 |
| 71 void AddCallback(base::Closure callback); | 72 void AddCallback(base::Closure callback); |
| 72 | 73 |
| 73 protected: | 74 protected: |
| 74 virtual ~Query(); | 75 virtual ~Query(); |
| 75 | 76 |
| 76 QueryManager* manager() const { | 77 QueryManager* manager() const { |
| 77 return manager_; | 78 return manager_; |
| 78 } | 79 } |
| 79 | 80 |
| 80 void MarkAsDeleted() { | 81 void MarkAsDeleted() { |
| 81 deleted_ = true; | 82 deleted_ = true; |
| 82 } | 83 } |
| 83 | 84 |
| 84 // Returns false if shared memory for sync is invalid. | 85 // Returns false if shared memory for sync is invalid. |
| 85 bool MarkAsCompleted(uint64 result); | 86 bool MarkAsCompleted(uint64 result); |
| 86 | 87 |
| 87 void MarkAsPending(uint32 submit_count) { | 88 void MarkAsPending(base::subtle::Atomic32 submit_count) { |
| 88 DCHECK(!pending_); | 89 DCHECK(!pending_); |
| 89 pending_ = true; | 90 pending_ = true; |
| 90 submit_count_ = submit_count; | 91 submit_count_ = submit_count; |
| 91 } | 92 } |
| 92 | 93 |
| 93 void UnmarkAsPending() { | 94 void UnmarkAsPending() { |
| 94 DCHECK(pending_); | 95 DCHECK(pending_); |
| 95 pending_ = false; | 96 pending_ = false; |
| 96 } | 97 } |
| 97 | 98 |
| 98 // Returns false if shared memory for sync is invalid. | 99 // Returns false if shared memory for sync is invalid. |
| 99 bool AddToPendingQueue(uint32 submit_count) { | 100 bool AddToPendingQueue(base::subtle::Atomic32 submit_count) { |
| 100 return manager_->AddPendingQuery(this, submit_count); | 101 return manager_->AddPendingQuery(this, submit_count); |
| 101 } | 102 } |
| 102 | 103 |
| 103 // Returns false if shared memory for sync is invalid. | 104 // Returns false if shared memory for sync is invalid. |
| 104 bool AddToPendingTransferQueue(uint32 submit_count) { | 105 bool AddToPendingTransferQueue(base::subtle::Atomic32 submit_count) { |
| 105 return manager_->AddPendingTransferQuery(this, submit_count); | 106 return manager_->AddPendingTransferQuery(this, submit_count); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void BeginQueryHelper(GLenum target, GLuint id) { | 109 void BeginQueryHelper(GLenum target, GLuint id) { |
| 109 manager_->BeginQueryHelper(target, id); | 110 manager_->BeginQueryHelper(target, id); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void EndQueryHelper(GLenum target) { | 113 void EndQueryHelper(GLenum target) { |
| 113 manager_->EndQueryHelper(target); | 114 manager_->EndQueryHelper(target); |
| 114 } | 115 } |
| 115 | 116 |
| 116 uint32 submit_count() const { | 117 base::subtle::Atomic32 submit_count() const { return submit_count_; } |
| 117 return submit_count_; | |
| 118 } | |
| 119 | 118 |
| 120 private: | 119 private: |
| 121 friend class QueryManager; | 120 friend class QueryManager; |
| 122 friend class QueryManagerTest; | 121 friend class QueryManagerTest; |
| 123 friend class base::RefCounted<Query>; | 122 friend class base::RefCounted<Query>; |
| 124 | 123 |
| 125 void RunCallbacks(); | 124 void RunCallbacks(); |
| 126 | 125 |
| 127 // The manager that owns this Query. | 126 // The manager that owns this Query. |
| 128 QueryManager* manager_; | 127 QueryManager* manager_; |
| 129 | 128 |
| 130 // The type of query. | 129 // The type of query. |
| 131 GLenum target_; | 130 GLenum target_; |
| 132 | 131 |
| 133 // The shared memory used with this Query. | 132 // The shared memory used with this Query. |
| 134 int32 shm_id_; | 133 int32 shm_id_; |
| 135 uint32 shm_offset_; | 134 uint32 shm_offset_; |
| 136 | 135 |
| 137 // Count to set process count do when completed. | 136 // Count to set process count do when completed. |
| 138 uint32 submit_count_; | 137 base::subtle::Atomic32 submit_count_; |
| 139 | 138 |
| 140 // True if in the queue. | 139 // True if in the queue. |
| 141 bool pending_; | 140 bool pending_; |
| 142 | 141 |
| 143 // True if deleted. | 142 // True if deleted. |
| 144 bool deleted_; | 143 bool deleted_; |
| 145 | 144 |
| 146 // List of callbacks to run when result is available. | 145 // List of callbacks to run when result is available. |
| 147 std::vector<base::Closure> callbacks_; | 146 std::vector<base::Closure> callbacks_; |
| 148 }; | 147 }; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 162 // Gets the query info for the given query. | 161 // Gets the query info for the given query. |
| 163 Query* GetQuery(GLuint client_id); | 162 Query* GetQuery(GLuint client_id); |
| 164 | 163 |
| 165 // Removes a query info for the given query. | 164 // Removes a query info for the given query. |
| 166 void RemoveQuery(GLuint client_id); | 165 void RemoveQuery(GLuint client_id); |
| 167 | 166 |
| 168 // Returns false if any query is pointing to invalid shared memory. | 167 // Returns false if any query is pointing to invalid shared memory. |
| 169 bool BeginQuery(Query* query); | 168 bool BeginQuery(Query* query); |
| 170 | 169 |
| 171 // Returns false if any query is pointing to invalid shared memory. | 170 // Returns false if any query is pointing to invalid shared memory. |
| 172 bool EndQuery(Query* query, uint32 submit_count); | 171 bool EndQuery(Query* query, base::subtle::Atomic32 submit_count); |
| 173 | 172 |
| 174 // Processes pending queries. Returns false if any queries are pointing | 173 // Processes pending queries. Returns false if any queries are pointing |
| 175 // to invalid shared memory. | 174 // to invalid shared memory. |
| 176 bool ProcessPendingQueries(); | 175 bool ProcessPendingQueries(); |
| 177 | 176 |
| 178 // True if there are pending queries. | 177 // True if there are pending queries. |
| 179 bool HavePendingQueries(); | 178 bool HavePendingQueries(); |
| 180 | 179 |
| 181 // Processes pending transfer queries. Returns false if any queries are | 180 // Processes pending transfer queries. Returns false if any queries are |
| 182 // pointing to invalid shared memory. | 181 // pointing to invalid shared memory. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 193 void StartTracking(Query* query); | 192 void StartTracking(Query* query); |
| 194 void StopTracking(Query* query); | 193 void StopTracking(Query* query); |
| 195 | 194 |
| 196 // Wrappers for BeginQueryARB and EndQueryARB to hide differences between | 195 // Wrappers for BeginQueryARB and EndQueryARB to hide differences between |
| 197 // ARB_occlusion_query2 and EXT_occlusion_query_boolean. | 196 // ARB_occlusion_query2 and EXT_occlusion_query_boolean. |
| 198 void BeginQueryHelper(GLenum target, GLuint id); | 197 void BeginQueryHelper(GLenum target, GLuint id); |
| 199 void EndQueryHelper(GLenum target); | 198 void EndQueryHelper(GLenum target); |
| 200 | 199 |
| 201 // Adds to queue of queries waiting for completion. | 200 // Adds to queue of queries waiting for completion. |
| 202 // Returns false if any query is pointing to invalid shared memory. | 201 // Returns false if any query is pointing to invalid shared memory. |
| 203 bool AddPendingQuery(Query* query, uint32 submit_count); | 202 bool AddPendingQuery(Query* query, base::subtle::Atomic32 submit_count); |
| 204 | 203 |
| 205 // Adds to queue of transfer queries waiting for completion. | 204 // Adds to queue of transfer queries waiting for completion. |
| 206 // Returns false if any query is pointing to invalid shared memory. | 205 // Returns false if any query is pointing to invalid shared memory. |
| 207 bool AddPendingTransferQuery(Query* query, uint32 submit_count); | 206 bool AddPendingTransferQuery(Query* query, |
| 207 base::subtle::Atomic32 submit_count); |
| 208 | 208 |
| 209 // Removes a query from the queue of pending queries. | 209 // Removes a query from the queue of pending queries. |
| 210 // Returns false if any query is pointing to invalid shared memory. | 210 // Returns false if any query is pointing to invalid shared memory. |
| 211 bool RemovePendingQuery(Query* query); | 211 bool RemovePendingQuery(Query* query); |
| 212 | 212 |
| 213 // Returns a target used for the underlying GL extension | 213 // Returns a target used for the underlying GL extension |
| 214 // used to emulate a query. | 214 // used to emulate a query. |
| 215 GLenum AdjustTargetForEmulation(GLenum target); | 215 GLenum AdjustTargetForEmulation(GLenum target); |
| 216 | 216 |
| 217 // Used to validate shared memory and get GL errors. | 217 // Used to validate shared memory and get GL errors. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 235 // Async pixel transfer queries waiting for completion. | 235 // Async pixel transfer queries waiting for completion. |
| 236 QueryQueue pending_transfer_queries_; | 236 QueryQueue pending_transfer_queries_; |
| 237 | 237 |
| 238 DISALLOW_COPY_AND_ASSIGN(QueryManager); | 238 DISALLOW_COPY_AND_ASSIGN(QueryManager); |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 } // namespace gles2 | 241 } // namespace gles2 |
| 242 } // namespace gpu | 242 } // namespace gpu |
| 243 | 243 |
| 244 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ | 244 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
| OLD | NEW |