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

Side by Side Diff: gpu/command_buffer/service/valuebuffer_manager.h

Issue 780133002: Add optimization for CHROMIUM_subscribe_uniform extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: piman@ review 3 Created 6 years 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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_VALUEBUFFER_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
12 #include "gpu/command_buffer/common/value_state.h" 13 #include "gpu/command_buffer/common/value_state.h"
13 #include "gpu/gpu_export.h" 14 #include "gpu/gpu_export.h"
15 #include "ipc/ipc_sender.h"
16
17 namespace content {
18 class GpuChannel;
19 }
14 20
15 namespace gpu { 21 namespace gpu {
16 namespace gles2 { 22 namespace gles2 {
17 23
18 class ValuebufferManager; 24 class ValuebufferManager;
19 25
26 class GPU_EXPORT SubscriptionRefSet
27 : public base::RefCounted<SubscriptionRefSet> {
28 public:
29 class GPU_EXPORT Observer {
30 public:
31 virtual ~Observer();
32
33 virtual void OnAddSubscription(unsigned int target) = 0;
34 virtual void OnRemoveSubscription(unsigned int target) = 0;
35 };
36
37 SubscriptionRefSet();
38
39 void AddObserver(Observer* observer);
40 void RemoveObserver(Observer* observer);
41
42 protected:
43 virtual ~SubscriptionRefSet();
44
45 private:
46 friend class base::RefCounted<SubscriptionRefSet>;
47 friend class ValuebufferManager;
48
49 typedef base::hash_map<unsigned int, int> RefSet;
50
51 void AddSubscription(unsigned int target);
52 void RemoveSubscription(unsigned int target);
53
54 RefSet reference_set_;
55
56 ObserverList<Observer, true> observers_;
57
58 DISALLOW_COPY_AND_ASSIGN(SubscriptionRefSet);
59 };
60
20 class GPU_EXPORT Valuebuffer : public base::RefCounted<Valuebuffer> { 61 class GPU_EXPORT Valuebuffer : public base::RefCounted<Valuebuffer> {
21 public: 62 public:
22 Valuebuffer(ValuebufferManager* manager, unsigned int client_id); 63 Valuebuffer(ValuebufferManager* manager, unsigned int client_id);
23 64
24 unsigned int client_id() const { return client_id_; } 65 unsigned int client_id() const { return client_id_; }
25 66
26 bool IsDeleted() const { return client_id_ == 0; } 67 bool IsDeleted() const { return client_id_ == 0; }
27 68
28 void MarkAsValid() { has_been_bound_ = true; } 69 void MarkAsValid() { has_been_bound_ = true; }
29 70
(...skipping 30 matching lines...) Expand all
60 // Whether this Valuebuffer has ever been bound. 101 // Whether this Valuebuffer has ever been bound.
61 bool has_been_bound_; 102 bool has_been_bound_;
62 103
63 SubscriptionSet subscriptions_; 104 SubscriptionSet subscriptions_;
64 105
65 scoped_refptr<ValueStateMap> active_state_map_; 106 scoped_refptr<ValueStateMap> active_state_map_;
66 }; 107 };
67 108
68 class GPU_EXPORT ValuebufferManager { 109 class GPU_EXPORT ValuebufferManager {
69 public: 110 public:
70 ValuebufferManager(ValueStateMap* state_map); 111 ValuebufferManager(SubscriptionRefSet* ref_set, ValueStateMap* state_map);
71 ~ValuebufferManager(); 112 ~ValuebufferManager();
72 113
73 // Must call before destruction. 114 // Must call before destruction.
74 void Destroy(); 115 void Destroy();
75 116
76 // Creates a Valuebuffer for the given Valuebuffer ids. 117 // Creates a Valuebuffer for the given Valuebuffer ids.
77 void CreateValuebuffer(unsigned int client_id); 118 void CreateValuebuffer(unsigned int client_id);
78 119
79 // Gets the Valuebuffer for the given Valuebuffer id. 120 // Gets the Valuebuffer for the given Valuebuffer id.
80 Valuebuffer* GetValuebuffer(unsigned int client_id); 121 Valuebuffer* GetValuebuffer(unsigned int client_id);
81 122
82 // Removes a Valuebuffer for the given Valuebuffer id. 123 // Removes a Valuebuffer for the given Valuebuffer id.
83 void RemoveValuebuffer(unsigned int client_id); 124 void RemoveValuebuffer(unsigned int client_id);
84 125
85 // Updates the value state for the given Valuebuffer 126 // Updates the value state for the given Valuebuffer
86 void UpdateValuebufferState(Valuebuffer* valuebuffer); 127 void UpdateValuebufferState(Valuebuffer* valuebuffer);
87 128
88 static uint32 ApiTypeForSubscriptionTarget(unsigned int target); 129 static uint32 ApiTypeForSubscriptionTarget(unsigned int target);
89 130
90 private: 131 private:
91 friend class Valuebuffer; 132 friend class Valuebuffer;
92 133
93 typedef base::hash_map<unsigned int, scoped_refptr<Valuebuffer>> 134 typedef base::hash_map<unsigned int, scoped_refptr<Valuebuffer>>
94 ValuebufferMap; 135 ValuebufferMap;
95 136
96 void StartTracking(Valuebuffer* valuebuffer); 137 void StartTracking(Valuebuffer* valuebuffer);
97 void StopTracking(Valuebuffer* valuebuffer); 138 void StopTracking(Valuebuffer* valuebuffer);
98 139
140 void NotifyAddSubscription(unsigned int target);
141 void NotifyRemoveSubscription(unsigned int target);
142
99 // Counts the number of Valuebuffer allocated with 'this' as its manager. 143 // Counts the number of Valuebuffer allocated with 'this' as its manager.
100 // Allows to check no Valuebuffer will outlive this. 144 // Allows to check no Valuebuffer will outlive this.
101 unsigned int valuebuffer_count_; 145 unsigned int valuebuffer_count_;
102 146
103 // Info for each Valuebuffer in the system. 147 // Info for each Valuebuffer in the system.
104 ValuebufferMap valuebuffer_map_; 148 ValuebufferMap valuebuffer_map_;
105 149
106 // Current value state in the system 150 // Current value state in the system
107 // Updated by GpuChannel 151 // Updated by GpuChannel
108 scoped_refptr<ValueStateMap> pending_state_map_; 152 scoped_refptr<ValueStateMap> pending_state_map_;
109 153
154 // Subscription targets which are currently subscribed and how
155 // many value buffers are currently subscribed to each
156 scoped_refptr<SubscriptionRefSet> subscription_ref_set_;
157
110 DISALLOW_COPY_AND_ASSIGN(ValuebufferManager); 158 DISALLOW_COPY_AND_ASSIGN(ValuebufferManager);
111 }; 159 };
112 160
113 } // namespace gles2 161 } // namespace gles2
114 } // namespace gpu 162 } // namespace gpu
115 163
116 #endif // GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_ 164 #endif // GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.cc ('k') | gpu/command_buffer/service/valuebuffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698