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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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
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 #ifndef GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ 6 #define GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_
7 7
8 #include <GLES2/gl2.h> 8 #include <GLES2/gl2.h>
9 #include <stddef.h>
10 #include <stdint.h>
9 11
10 #include <bitset> 12 #include <bitset>
11 #include <deque> 13 #include <deque>
12 #include <list> 14 #include <list>
13 15
14 #include "base/atomicops.h" 16 #include "base/atomicops.h"
15 #include "base/containers/hash_tables.h" 17 #include "base/containers/hash_tables.h"
18 #include "base/macros.h"
16 #include "gles2_impl_export.h" 19 #include "gles2_impl_export.h"
17 #include "gpu/command_buffer/common/gles2_cmd_format.h" 20 #include "gpu/command_buffer/common/gles2_cmd_format.h"
18 21
19 namespace gpu { 22 namespace gpu {
20 23
21 class CommandBufferHelper; 24 class CommandBufferHelper;
22 class MappedMemoryManager; 25 class MappedMemoryManager;
23 26
24 namespace gles2 { 27 namespace gles2 {
25 28
26 class GLES2Implementation; 29 class GLES2Implementation;
27 30
28 // Manages buckets of QuerySync instances in mapped memory. 31 // Manages buckets of QuerySync instances in mapped memory.
29 class GLES2_IMPL_EXPORT QuerySyncManager { 32 class GLES2_IMPL_EXPORT QuerySyncManager {
30 public: 33 public:
31 static const size_t kSyncsPerBucket = 256; 34 static const size_t kSyncsPerBucket = 256;
32 35
33 struct Bucket { 36 struct Bucket {
34 Bucket(QuerySync* sync_mem, int32 shm_id, uint32 shm_offset); 37 Bucket(QuerySync* sync_mem, int32_t shm_id, uint32_t shm_offset);
35 ~Bucket(); 38 ~Bucket();
36 QuerySync* syncs; 39 QuerySync* syncs;
37 int32 shm_id; 40 int32_t shm_id;
38 uint32 base_shm_offset; 41 uint32_t base_shm_offset;
39 std::bitset<kSyncsPerBucket> in_use_queries; 42 std::bitset<kSyncsPerBucket> in_use_queries;
40 }; 43 };
41 struct QueryInfo { 44 struct QueryInfo {
42 QueryInfo(Bucket* bucket, int32 id, uint32 offset, QuerySync* sync_mem) 45 QueryInfo(Bucket* bucket, int32_t id, uint32_t offset, QuerySync* sync_mem)
43 : bucket(bucket), 46 : bucket(bucket), shm_id(id), shm_offset(offset), sync(sync_mem) {}
44 shm_id(id),
45 shm_offset(offset),
46 sync(sync_mem) {
47 }
48 47
49 QueryInfo() 48 QueryInfo()
50 : bucket(NULL), 49 : bucket(NULL),
51 shm_id(0), 50 shm_id(0),
52 shm_offset(0), 51 shm_offset(0),
53 sync(NULL) { 52 sync(NULL) {
54 } 53 }
55 54
56 Bucket* bucket; 55 Bucket* bucket;
57 int32 shm_id; 56 int32_t shm_id;
58 uint32 shm_offset; 57 uint32_t shm_offset;
59 QuerySync* sync; 58 QuerySync* sync;
60 }; 59 };
61 60
62 explicit QuerySyncManager(MappedMemoryManager* manager); 61 explicit QuerySyncManager(MappedMemoryManager* manager);
63 ~QuerySyncManager(); 62 ~QuerySyncManager();
64 63
65 bool Alloc(QueryInfo* info); 64 bool Alloc(QueryInfo* info);
66 void Free(const QueryInfo& sync); 65 void Free(const QueryInfo& sync);
67 void Shrink(); 66 void Shrink();
68 67
(...skipping 19 matching lines...) Expand all
88 Query(GLuint id, GLenum target, const QuerySyncManager::QueryInfo& info); 87 Query(GLuint id, GLenum target, const QuerySyncManager::QueryInfo& info);
89 88
90 GLenum target() const { 89 GLenum target() const {
91 return target_; 90 return target_;
92 } 91 }
93 92
94 GLuint id() const { 93 GLuint id() const {
95 return id_; 94 return id_;
96 } 95 }
97 96
98 int32 shm_id() const { 97 int32_t shm_id() const { return info_.shm_id; }
99 return info_.shm_id;
100 }
101 98
102 uint32 shm_offset() const { 99 uint32_t shm_offset() const { return info_.shm_offset; }
103 return info_.shm_offset;
104 }
105 100
106 void MarkAsActive() { 101 void MarkAsActive() {
107 state_ = kActive; 102 state_ = kActive;
108 ++submit_count_; 103 ++submit_count_;
109 if (submit_count_ == INT_MAX) 104 if (submit_count_ == INT_MAX)
110 submit_count_ = 1; 105 submit_count_ = 1;
111 } 106 }
112 107
113 void MarkAsPending(int32 token) { 108 void MarkAsPending(int32_t token) {
114 token_ = token; 109 token_ = token;
115 state_ = kPending; 110 state_ = kPending;
116 } 111 }
117 112
118 base::subtle::Atomic32 submit_count() const { return submit_count_; } 113 base::subtle::Atomic32 submit_count() const { return submit_count_; }
119 114
120 int32 token() const { 115 int32_t token() const { return token_; }
121 return token_;
122 }
123 116
124 bool NeverUsed() const { 117 bool NeverUsed() const {
125 return state_ == kUninitialized; 118 return state_ == kUninitialized;
126 } 119 }
127 120
128 bool Active() const { 121 bool Active() const {
129 return state_ == kActive; 122 return state_ == kActive;
130 } 123 }
131 124
132 bool Pending() const { 125 bool Pending() const {
133 return state_ == kPending; 126 return state_ == kPending;
134 } 127 }
135 128
136 bool CheckResultsAvailable(CommandBufferHelper* helper); 129 bool CheckResultsAvailable(CommandBufferHelper* helper);
137 130
138 uint64 GetResult() const; 131 uint64_t GetResult() const;
139 132
140 private: 133 private:
141 friend class QueryTracker; 134 friend class QueryTracker;
142 friend class QueryTrackerTest; 135 friend class QueryTrackerTest;
143 136
144 void Begin(GLES2Implementation* gl); 137 void Begin(GLES2Implementation* gl);
145 void End(GLES2Implementation* gl); 138 void End(GLES2Implementation* gl);
146 void QueryCounter(GLES2Implementation* gl); 139 void QueryCounter(GLES2Implementation* gl);
147 140
148 GLuint id_; 141 GLuint id_;
149 GLenum target_; 142 GLenum target_;
150 QuerySyncManager::QueryInfo info_; 143 QuerySyncManager::QueryInfo info_;
151 State state_; 144 State state_;
152 base::subtle::Atomic32 submit_count_; 145 base::subtle::Atomic32 submit_count_;
153 int32 token_; 146 int32_t token_;
154 uint32 flush_count_; 147 uint32_t flush_count_;
155 uint64 client_begin_time_us_; // Only used for latency query target. 148 uint64_t client_begin_time_us_; // Only used for latency query target.
156 uint64 result_; 149 uint64_t result_;
157 }; 150 };
158 151
159 QueryTracker(MappedMemoryManager* manager); 152 QueryTracker(MappedMemoryManager* manager);
160 ~QueryTracker(); 153 ~QueryTracker();
161 154
162 Query* CreateQuery(GLuint id, GLenum target); 155 Query* CreateQuery(GLuint id, GLenum target);
163 Query* GetQuery(GLuint id); 156 Query* GetQuery(GLuint id);
164 Query* GetCurrentQuery(GLenum target); 157 Query* GetCurrentQuery(GLenum target);
165 void RemoveQuery(GLuint id); 158 void RemoveQuery(GLuint id);
166 void Shrink(); 159 void Shrink();
(...skipping 30 matching lines...) Expand all
197 DisjointValueSync* disjoint_count_sync_; 190 DisjointValueSync* disjoint_count_sync_;
198 uint32_t local_disjoint_count_; 191 uint32_t local_disjoint_count_;
199 192
200 DISALLOW_COPY_AND_ASSIGN(QueryTracker); 193 DISALLOW_COPY_AND_ASSIGN(QueryTracker);
201 }; 194 };
202 195
203 } // namespace gles2 196 } // namespace gles2
204 } // namespace gpu 197 } // namespace gpu
205 198
206 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ 199 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/program_info_manager_unittest.cc ('k') | gpu/command_buffer/client/query_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698