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

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

Issue 12278025: Shrink QueryTracker when freeing everything (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore buckets Created 7 years, 10 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 #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 9
10 #include <queue> 10 #include <deque>
11 #include "../client/hash_tables.h" 11 #include "../client/hash_tables.h"
12 #include "../common/gles2_cmd_format.h" 12 #include "../common/gles2_cmd_format.h"
13 #include "gles2_impl_export.h" 13 #include "gles2_impl_export.h"
14 14
15 namespace gpu { 15 namespace gpu {
16 16
17 class CommandBufferHelper; 17 class CommandBufferHelper;
18 class MappedMemoryManager; 18 class MappedMemoryManager;
19 19
20 namespace gles2 { 20 namespace gles2 {
21 21
22 class GLES2Implementation; 22 class GLES2Implementation;
23 23
24 // Manages buckets of QuerySync instances in mapped memory. 24 // Manages buckets of QuerySync instances in mapped memory.
25 class GLES2_IMPL_EXPORT QuerySyncManager { 25 class GLES2_IMPL_EXPORT QuerySyncManager {
26 public: 26 public:
27 static const size_t kSyncsPerBucket = 4096; 27 static const size_t kSyncsPerBucket = 4096;
28 28
29 struct Bucket {
30 explicit Bucket(QuerySync* sync_mem)
31 : syncs(sync_mem),
32 used_query_count(0) {
33 }
34 QuerySync* syncs;
35 unsigned used_query_count;
36 };
29 struct QueryInfo { 37 struct QueryInfo {
30 QueryInfo(int32 id, uint32 offset, QuerySync* sync_mem) 38 QueryInfo(Bucket* bucket, int32 id, uint32 offset, QuerySync* sync_mem)
31 : shm_id(id), 39 : bucket(bucket),
40 shm_id(id),
32 shm_offset(offset), 41 shm_offset(offset),
33 sync(sync_mem) { 42 sync(sync_mem) {
34 } 43 }
35 44
36 QueryInfo() 45 QueryInfo()
37 : shm_id(0), 46 : bucket(NULL),
47 shm_id(0),
38 shm_offset(0), 48 shm_offset(0),
39 sync(NULL) { 49 sync(NULL) {
40 } 50 }
41 51
52 Bucket* bucket;
42 int32 shm_id; 53 int32 shm_id;
43 uint32 shm_offset; 54 uint32 shm_offset;
44 QuerySync* sync; 55 QuerySync* sync;
45 }; 56 };
46 57
47 explicit QuerySyncManager(MappedMemoryManager* manager); 58 explicit QuerySyncManager(MappedMemoryManager* manager);
48 ~QuerySyncManager(); 59 ~QuerySyncManager();
49 60
50 bool Alloc(QueryInfo* info); 61 bool Alloc(QueryInfo* info);
51 void Free(const QueryInfo& sync); 62 void Free(const QueryInfo& sync);
63 void Shrink();
52 64
53 private: 65 private:
54 MappedMemoryManager* mapped_memory_; 66 MappedMemoryManager* mapped_memory_;
55 std::queue<QuerySync*> buckets_; 67 std::deque<Bucket*> buckets_;
56 std::queue<QueryInfo> free_queries_; 68 std::deque<QueryInfo> free_queries_;
57 69
58 DISALLOW_COPY_AND_ASSIGN(QuerySyncManager); 70 DISALLOW_COPY_AND_ASSIGN(QuerySyncManager);
59 }; 71 };
60 72
61 // Tracks queries for client side of command buffer. 73 // Tracks queries for client side of command buffer.
62 class GLES2_IMPL_EXPORT QueryTracker { 74 class GLES2_IMPL_EXPORT QueryTracker {
63 public: 75 public:
64 class GLES2_IMPL_EXPORT Query { 76 class GLES2_IMPL_EXPORT Query {
65 public: 77 public:
66 enum State { 78 enum State {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 uint64 client_begin_time_us_; // Only used for latency query target. 148 uint64 client_begin_time_us_; // Only used for latency query target.
137 uint32 result_; 149 uint32 result_;
138 }; 150 };
139 151
140 QueryTracker(MappedMemoryManager* manager); 152 QueryTracker(MappedMemoryManager* manager);
141 ~QueryTracker(); 153 ~QueryTracker();
142 154
143 Query* CreateQuery(GLuint id, GLenum target); 155 Query* CreateQuery(GLuint id, GLenum target);
144 Query* GetQuery(GLuint id); 156 Query* GetQuery(GLuint id);
145 void RemoveQuery(GLuint id, bool context_lost); 157 void RemoveQuery(GLuint id, bool context_lost);
158 void Shrink();
146 159
147 private: 160 private:
148 typedef gpu::hash_map<GLuint, Query*> QueryMap; 161 typedef gpu::hash_map<GLuint, Query*> QueryMap;
149 162
150 QueryMap queries_; 163 QueryMap queries_;
151 QuerySyncManager query_sync_manager_; 164 QuerySyncManager query_sync_manager_;
152 165
153 DISALLOW_COPY_AND_ASSIGN(QueryTracker); 166 DISALLOW_COPY_AND_ASSIGN(QueryTracker);
154 }; 167 };
155 168
156 } // namespace gles2 169 } // namespace gles2
157 } // namespace gpu 170 } // namespace gpu
158 171
159 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ 172 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | gpu/command_buffer/client/query_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698