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

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

Issue 2471533003: Minor improvement in uniform block backing buffer validation. (Closed)
Patch Set: fix Created 4 years, 1 month 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_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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // doesn't exist, is mapped, or smaller than |variable_sizes[ii]| * |count|. 330 // doesn't exist, is mapped, or smaller than |variable_sizes[ii]| * |count|.
331 // Return true otherwise. 331 // Return true otherwise.
332 bool RequestBuffersAccess( 332 bool RequestBuffersAccess(
333 ErrorState* error_state, 333 ErrorState* error_state,
334 const IndexedBufferBindingHost* bindings, 334 const IndexedBufferBindingHost* bindings,
335 const std::vector<GLsizeiptr>& variable_sizes, 335 const std::vector<GLsizeiptr>& variable_sizes,
336 GLsizei count, 336 GLsizei count,
337 const char* func_name, 337 const char* func_name,
338 const char* message_tag); 338 const char* message_tag);
339 339
340 uint32_t mapped_buffer_count() const {
341 return mapped_buffer_count_;
342 }
343
344 private: 340 private:
345 friend class Buffer; 341 friend class Buffer;
346 friend class TestHelper; // Needs access to DoBufferData. 342 friend class TestHelper; // Needs access to DoBufferData.
347 friend class BufferManagerTestBase; // Needs access to DoBufferSubData. 343 friend class BufferManagerTestBase; // Needs access to DoBufferSubData.
348 friend class IndexedBufferBindingHostTest; // Needs access to SetInfo. 344 friend class IndexedBufferBindingHostTest; // Needs access to SetInfo.
349 345
350 void StartTracking(Buffer* buffer); 346 void StartTracking(Buffer* buffer);
351 void StopTracking(Buffer* buffer); 347 void StopTracking(Buffer* buffer);
352 348
353 // Does a glBufferSubData and updates the appropriate accounting. 349 // Does a glBufferSubData and updates the appropriate accounting.
(...skipping 30 matching lines...) Expand all
384 bool UseShadowBuffer(GLenum target, GLenum usage); 380 bool UseShadowBuffer(GLenum target, GLenum usage);
385 381
386 // Sets the size, usage and initial data of a buffer. 382 // Sets the size, usage and initial data of a buffer.
387 // If data is NULL buffer will be initialized to 0 if shadowed. 383 // If data is NULL buffer will be initialized to 0 if shadowed.
388 void SetInfo(Buffer* buffer, 384 void SetInfo(Buffer* buffer,
389 GLenum target, 385 GLenum target,
390 GLsizeiptr size, 386 GLsizeiptr size,
391 GLenum usage, 387 GLenum usage,
392 bool use_shadow); 388 bool use_shadow);
393 389
394 void IncreaseMappedBufferCount();
395 void DecreaseMappedBufferCount();
396
397 std::unique_ptr<MemoryTypeTracker> memory_type_tracker_; 390 std::unique_ptr<MemoryTypeTracker> memory_type_tracker_;
398 MemoryTracker* memory_tracker_; 391 MemoryTracker* memory_tracker_;
399 scoped_refptr<FeatureInfo> feature_info_; 392 scoped_refptr<FeatureInfo> feature_info_;
400 393
401 // Info for each buffer in the system. 394 // Info for each buffer in the system.
402 typedef base::hash_map<GLuint, scoped_refptr<Buffer> > BufferMap; 395 typedef base::hash_map<GLuint, scoped_refptr<Buffer> > BufferMap;
403 BufferMap buffers_; 396 BufferMap buffers_;
404 397
405 // The maximum size of buffers. 398 // The maximum size of buffers.
406 GLsizeiptr max_buffer_size_; 399 GLsizeiptr max_buffer_size_;
407 400
408 // Whether or not buffers can be bound to multiple targets. 401 // Whether or not buffers can be bound to multiple targets.
409 bool allow_buffers_on_multiple_targets_; 402 bool allow_buffers_on_multiple_targets_;
410 403
411 // Whether or not allow using GL_FIXED type for vertex attribs. 404 // Whether or not allow using GL_FIXED type for vertex attribs.
412 bool allow_fixed_attribs_; 405 bool allow_fixed_attribs_;
413 406
414 // Counts the number of Buffer allocated with 'this' as its manager. 407 // Counts the number of Buffer allocated with 'this' as its manager.
415 // Allows to check no Buffer will outlive this. 408 // Allows to check no Buffer will outlive this.
416 unsigned int buffer_count_; 409 unsigned int buffer_count_;
417 410
418 GLuint primitive_restart_fixed_index_; 411 GLuint primitive_restart_fixed_index_;
419 412
420 bool lost_context_; 413 bool lost_context_;
421 bool use_client_side_arrays_for_stream_buffers_; 414 bool use_client_side_arrays_for_stream_buffers_;
422 415
423 // Keep track of total mapped buffer count. In most use cases it should be 0,
424 // so we could bypass checking each individual buffer as an optimization.
425 uint32_t mapped_buffer_count_;
426
427 DISALLOW_COPY_AND_ASSIGN(BufferManager); 416 DISALLOW_COPY_AND_ASSIGN(BufferManager);
428 }; 417 };
429 418
430 } // namespace gles2 419 } // namespace gles2
431 } // namespace gpu 420 } // namespace gpu
432 421
433 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ 422 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/buffer_manager.cc » ('j') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698