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

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

Issue 2446773002: Always use Desktop GL 4.1 or less BindBufferRange behavior. (Closed)
Patch Set: fix comments 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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_INDEXED_BUFFER_BINDING_HOST_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "gpu/command_buffer/service/gl_utils.h" 11 #include "gpu/command_buffer/service/gl_utils.h"
12 #include "gpu/gpu_export.h" 12 #include "gpu/gpu_export.h"
13 13
14 namespace gpu { 14 namespace gpu {
15 namespace gles2 { 15 namespace gles2 {
16 16
17 class Buffer; 17 class Buffer;
18 18
19 // This is a base class for indexed buffer bindings tracking. 19 // This is a base class for indexed buffer bindings tracking.
20 // TransformFeedback and Program should inherit from this base class, 20 // TransformFeedback and Program should inherit from this base class,
21 // for tracking indexed TRANSFORM_FEEDBACK_BUFFER / UNIFORM_BUFFER bindings. 21 // for tracking indexed TRANSFORM_FEEDBACK_BUFFER / UNIFORM_BUFFER bindings.
22 class GPU_EXPORT IndexedBufferBindingHost : 22 class GPU_EXPORT IndexedBufferBindingHost :
23 public base::RefCounted<IndexedBufferBindingHost> { 23 public base::RefCounted<IndexedBufferBindingHost> {
24 public: 24 public:
25 // |needs_emulation| is set to true on Desktop GL 4.1 or lower. 25 // In theory |needs_emulation| needs to be true on Desktop GL 4.1 or lower.
26 // However, we set it to true everywhere, not to trust drivers to handle
27 // out-of-bounds buffer accesses.
26 IndexedBufferBindingHost(uint32_t max_bindings, bool needs_emulation); 28 IndexedBufferBindingHost(uint32_t max_bindings, bool needs_emulation);
27 29
28 // The following two functions do state update and call the underlying GL 30 // The following two functions do state update and call the underlying GL
29 // function. All validations have been done already and the GL function is 31 // function. All validations have been done already and the GL function is
30 // guaranteed to succeed. 32 // guaranteed to succeed.
31 void DoBindBufferBase(GLenum target, GLuint index, Buffer* buffer); 33 void DoBindBufferBase(GLenum target, GLuint index, Buffer* buffer);
32 void DoBindBufferRange( 34 void DoBindBufferRange(
33 GLenum target, GLuint index, Buffer* buffer, GLintptr offset, 35 GLenum target, GLuint index, Buffer* buffer, GLintptr offset,
34 GLsizeiptr size); 36 GLsizeiptr size);
35 37
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ~IndexedBufferBinding(); 84 ~IndexedBufferBinding();
83 85
84 bool operator==(const IndexedBufferBinding& other) const; 86 bool operator==(const IndexedBufferBinding& other) const;
85 87
86 void SetBindBufferBase(Buffer* _buffer); 88 void SetBindBufferBase(Buffer* _buffer);
87 void SetBindBufferRange( 89 void SetBindBufferRange(
88 Buffer* _buffer, GLintptr _offset, GLsizeiptr _size); 90 Buffer* _buffer, GLintptr _offset, GLsizeiptr _size);
89 void Reset(); 91 void Reset();
90 }; 92 };
91 93
92 // This is called on Desktop GL lower than 4.2, where the range 94 // This is called when |needs_emulation_| is true, where the range
93 // (offset + size) can't go beyond the buffer's size. 95 // (offset + size) can't go beyond the buffer's size.
94 static void DoAdjustedBindBufferRange( 96 static void DoAdjustedBindBufferRange(
95 GLenum target, GLuint index, GLuint service_id, GLintptr offset, 97 GLenum target, GLuint index, GLuint service_id, GLintptr offset,
96 GLsizeiptr size, GLsizeiptr full_buffer_size); 98 GLsizeiptr size, GLsizeiptr full_buffer_size);
97 99
98 void UpdateMaxNonNullBindingIndex(size_t changed_index); 100 void UpdateMaxNonNullBindingIndex(size_t changed_index);
99 101
100 std::vector<IndexedBufferBinding> buffer_bindings_; 102 std::vector<IndexedBufferBinding> buffer_bindings_;
101 103
102 bool needs_emulation_; 104 bool needs_emulation_;
103 105
104 // This is used for optimization purpose in context switching. 106 // This is used for optimization purpose in context switching.
105 size_t max_non_null_binding_index_plus_one_; 107 size_t max_non_null_binding_index_plus_one_;
106 }; 108 };
107 109
108 } // namespace gles2 110 } // namespace gles2
109 } // namespace gpu 111 } // namespace gpu
110 112
111 #endif // GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_ 113 #endif // GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698