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_BUFFER_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return lhs.type_ < rhs.type_; | 119 return lhs.type_ < rhs.type_; |
120 } | 120 } |
121 }; | 121 }; |
122 | 122 |
123 private: | 123 private: |
124 GLuint offset_; | 124 GLuint offset_; |
125 GLsizei count_; | 125 GLsizei count_; |
126 GLenum type_; | 126 GLenum type_; |
127 }; | 127 }; |
128 | 128 |
| 129 struct MaxValue { |
| 130 GLuint max_value_; |
| 131 GLuint max_value_pr_enabled_; |
| 132 |
| 133 MaxValue (GLuint value, GLuint value_enabled) |
| 134 : max_value_(value), |
| 135 max_value_pr_enabled_(value_enabled) { |
| 136 } |
| 137 }; |
| 138 |
129 ~Buffer(); | 139 ~Buffer(); |
130 | 140 |
131 GLenum initial_target() const { | 141 GLenum initial_target() const { |
132 return initial_target_; | 142 return initial_target_; |
133 } | 143 } |
134 | 144 |
135 void set_initial_target(GLenum target) { | 145 void set_initial_target(GLenum target) { |
136 DCHECK_EQ(0u, initial_target_); | 146 DCHECK_EQ(0u, initial_target_); |
137 initial_target_ = target; | 147 initial_target_ = target; |
138 } | 148 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // It is set the first time bindBuffer() is called and cannot be changed. | 199 // It is set the first time bindBuffer() is called and cannot be changed. |
190 GLenum initial_target_; | 200 GLenum initial_target_; |
191 | 201 |
192 // Usage of buffer. | 202 // Usage of buffer. |
193 GLenum usage_; | 203 GLenum usage_; |
194 | 204 |
195 // Data cached from last glMapBufferRange call. | 205 // Data cached from last glMapBufferRange call. |
196 scoped_ptr<MappedRange> mapped_range_; | 206 scoped_ptr<MappedRange> mapped_range_; |
197 | 207 |
198 // A map of ranges to the highest value in that range of a certain type. | 208 // A map of ranges to the highest value in that range of a certain type. |
199 typedef std::map<Range, GLuint, Range::Less> RangeToMaxValueMap; | 209 typedef std::map<Range, MaxValue, Range::Less> RangeToMaxValueMap; |
200 RangeToMaxValueMap range_set_; | 210 RangeToMaxValueMap range_set_; |
201 }; | 211 }; |
202 | 212 |
203 // This class keeps track of the buffers and their sizes so we can do | 213 // This class keeps track of the buffers and their sizes so we can do |
204 // bounds checking. | 214 // bounds checking. |
205 // | 215 // |
206 // NOTE: To support shared resources an instance of this class will need to be | 216 // NOTE: To support shared resources an instance of this class will need to be |
207 // shared by multiple GLES2Decoders. | 217 // shared by multiple GLES2Decoders. |
208 class GPU_EXPORT BufferManager : public base::trace_event::MemoryDumpProvider { | 218 class GPU_EXPORT BufferManager : public base::trace_event::MemoryDumpProvider { |
209 public: | 219 public: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // Tells whether a buffer that is emulated using client-side arrays should be | 278 // Tells whether a buffer that is emulated using client-side arrays should be |
269 // set to a non-zero size. | 279 // set to a non-zero size. |
270 bool UseNonZeroSizeForClientSideArrayBuffer(); | 280 bool UseNonZeroSizeForClientSideArrayBuffer(); |
271 | 281 |
272 Buffer* GetBufferInfoForTarget(ContextState* state, GLenum target) const; | 282 Buffer* GetBufferInfoForTarget(ContextState* state, GLenum target) const; |
273 | 283 |
274 // base::trace_event::MemoryDumpProvider implementation. | 284 // base::trace_event::MemoryDumpProvider implementation. |
275 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 285 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
276 base::trace_event::ProcessMemoryDump* pmd) override; | 286 base::trace_event::ProcessMemoryDump* pmd) override; |
277 | 287 |
| 288 void SetPrimitiveRestartState(bool enabled); |
| 289 |
278 private: | 290 private: |
279 friend class Buffer; | 291 friend class Buffer; |
280 friend class TestHelper; // Needs access to DoBufferData. | 292 friend class TestHelper; // Needs access to DoBufferData. |
281 friend class BufferManagerTestBase; // Needs access to DoBufferSubData. | 293 friend class BufferManagerTestBase; // Needs access to DoBufferSubData. |
282 | 294 |
283 void StartTracking(Buffer* buffer); | 295 void StartTracking(Buffer* buffer); |
284 void StopTracking(Buffer* buffer); | 296 void StopTracking(Buffer* buffer); |
285 | 297 |
286 // Does a glBufferSubData and updates the approriate accounting. | 298 // Does a glBufferSubData and updates the approriate accounting. |
287 // Assumes the values have already been validated. | 299 // Assumes the values have already been validated. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // Whether or not buffers can be bound to multiple targets. | 331 // Whether or not buffers can be bound to multiple targets. |
320 bool allow_buffers_on_multiple_targets_; | 332 bool allow_buffers_on_multiple_targets_; |
321 | 333 |
322 // Whether or not allow using GL_FIXED type for vertex attribs. | 334 // Whether or not allow using GL_FIXED type for vertex attribs. |
323 bool allow_fixed_attribs_; | 335 bool allow_fixed_attribs_; |
324 | 336 |
325 // Counts the number of Buffer allocated with 'this' as its manager. | 337 // Counts the number of Buffer allocated with 'this' as its manager. |
326 // Allows to check no Buffer will outlive this. | 338 // Allows to check no Buffer will outlive this. |
327 unsigned int buffer_count_; | 339 unsigned int buffer_count_; |
328 | 340 |
| 341 bool primitive_restart_enabled_; |
| 342 |
329 bool have_context_; | 343 bool have_context_; |
330 bool use_client_side_arrays_for_stream_buffers_; | 344 bool use_client_side_arrays_for_stream_buffers_; |
331 | 345 |
332 DISALLOW_COPY_AND_ASSIGN(BufferManager); | 346 DISALLOW_COPY_AND_ASSIGN(BufferManager); |
333 }; | 347 }; |
334 | 348 |
335 } // namespace gles2 | 349 } // namespace gles2 |
336 } // namespace gpu | 350 } // namespace gpu |
337 | 351 |
338 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 352 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
OLD | NEW |