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

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

Issue 1131913004: More compact representation of the GL Query cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Smaller patch still. Created 5 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
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 <deque> 10 #include <deque>
11 #include <list> 11 #include <list>
12 #include <vector>
12 13
13 #include "base/atomicops.h" 14 #include "base/atomicops.h"
14 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
15 #include "gles2_impl_export.h" 16 #include "gles2_impl_export.h"
16 #include "gpu/command_buffer/common/gles2_cmd_format.h" 17 #include "gpu/command_buffer/common/gles2_cmd_format.h"
17 18
18 namespace gpu { 19 namespace gpu {
19 20
20 class CommandBufferHelper; 21 class CommandBufferHelper;
21 class MappedMemoryManager; 22 class MappedMemoryManager;
22 23
23 namespace gles2 { 24 namespace gles2 {
24 25
25 class GLES2Implementation; 26 class GLES2Implementation;
26 27
27 // Manages buckets of QuerySync instances in mapped memory. 28 // Manages buckets of QuerySync instances in mapped memory.
28 class GLES2_IMPL_EXPORT QuerySyncManager { 29 class GLES2_IMPL_EXPORT QuerySyncManager {
29 public: 30 public:
30 static const size_t kSyncsPerBucket = 4096; 31 static const size_t kSyncsPerBucket = 4096;
31 32
32 struct Bucket { 33 struct Bucket {
33 explicit Bucket(QuerySync* sync_mem) 34 Bucket(QuerySync* sync_mem, int32 shm_id, unsigned int shm_offset);
34 : syncs(sync_mem), 35 ~Bucket();
35 used_query_count(0) {
36 }
37 QuerySync* syncs; 36 QuerySync* syncs;
38 unsigned used_query_count; 37 unsigned used_query_count;
reveman 2015/05/11 17:13:07 is |used_query_count| still needed?
Daniel Bratell 2015/05/12 16:16:40 It can be replaced by |kSyncsPerBucket - bucket->f
reveman 2015/05/12 16:45:05 I generally prefer unnecessary state when possible
38 int32 shm_id;
39 unsigned int base_shm_offset;
reveman 2015/05/11 17:13:08 nit: uint32 base_shm_offset to be consistent with
Daniel Bratell 2015/05/12 16:16:40 Done.
40 std::vector<unsigned short> free_queries;
reveman 2015/05/11 17:13:08 can we just use vector<size_t> here instead? that'
jbauman 2015/05/11 19:12:53 Could you add a COMPILE_ASSERT that kSyncsPerBucke
Daniel Bratell 2015/05/12 16:16:40 This is the main source of memory usage in the cac
Daniel Bratell 2015/05/12 16:16:40 Done.
reveman 2015/05/12 16:45:05 Acknowledged. Btw, have you considered using std:
39 }; 41 };
40 struct QueryInfo { 42 struct QueryInfo {
41 QueryInfo(Bucket* bucket, int32 id, uint32 offset, QuerySync* sync_mem) 43 QueryInfo(Bucket* bucket, int32 id, uint32 offset, QuerySync* sync_mem)
42 : bucket(bucket), 44 : bucket(bucket),
43 shm_id(id), 45 shm_id(id),
44 shm_offset(offset), 46 shm_offset(offset),
45 sync(sync_mem) { 47 sync(sync_mem) {
46 } 48 }
47 49
48 QueryInfo() 50 QueryInfo()
(...skipping 12 matching lines...) Expand all
61 explicit QuerySyncManager(MappedMemoryManager* manager); 63 explicit QuerySyncManager(MappedMemoryManager* manager);
62 ~QuerySyncManager(); 64 ~QuerySyncManager();
63 65
64 bool Alloc(QueryInfo* info); 66 bool Alloc(QueryInfo* info);
65 void Free(const QueryInfo& sync); 67 void Free(const QueryInfo& sync);
66 void Shrink(); 68 void Shrink();
67 69
68 private: 70 private:
69 MappedMemoryManager* mapped_memory_; 71 MappedMemoryManager* mapped_memory_;
70 std::deque<Bucket*> buckets_; 72 std::deque<Bucket*> buckets_;
71 std::deque<QueryInfo> free_queries_;
72 73
73 DISALLOW_COPY_AND_ASSIGN(QuerySyncManager); 74 DISALLOW_COPY_AND_ASSIGN(QuerySyncManager);
74 }; 75 };
75 76
76 // Tracks queries for client side of command buffer. 77 // Tracks queries for client side of command buffer.
77 class GLES2_IMPL_EXPORT QueryTracker { 78 class GLES2_IMPL_EXPORT QueryTracker {
78 public: 79 public:
79 class GLES2_IMPL_EXPORT Query { 80 class GLES2_IMPL_EXPORT Query {
80 public: 81 public:
81 enum State { 82 enum State {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 QueryList removed_queries_; 169 QueryList removed_queries_;
169 QuerySyncManager query_sync_manager_; 170 QuerySyncManager query_sync_manager_;
170 171
171 DISALLOW_COPY_AND_ASSIGN(QueryTracker); 172 DISALLOW_COPY_AND_ASSIGN(QueryTracker);
172 }; 173 };
173 174
174 } // namespace gles2 175 } // namespace gles2
175 } // namespace gpu 176 } // namespace gpu
176 177
177 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ 178 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/query_tracker.cc » ('j') | gpu/command_buffer/client/query_tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698