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

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

Issue 1845963003: Make sure we call glBufferData on the same data we store internally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "Fixed comment." Created 4 years, 8 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_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
11 #include <map> 11 #include <map>
12 #include <vector>
13
12 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
14 #include "base/macros.h" 16 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "gpu/command_buffer/common/buffer.h" 19 #include "gpu/command_buffer/common/buffer.h"
18 #include "gpu/command_buffer/service/gl_utils.h" 20 #include "gpu/command_buffer/service/gl_utils.h"
19 #include "gpu/command_buffer/service/memory_tracking.h" 21 #include "gpu/command_buffer/service/memory_tracking.h"
20 #include "gpu/gpu_export.h" 22 #include "gpu/gpu_export.h"
21 23
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 GLenum initial_target() const { 139 GLenum initial_target() const {
138 return initial_target_; 140 return initial_target_;
139 } 141 }
140 142
141 void set_initial_target(GLenum target) { 143 void set_initial_target(GLenum target) {
142 DCHECK_EQ(0u, initial_target_); 144 DCHECK_EQ(0u, initial_target_);
143 initial_target_ = target; 145 initial_target_ = target;
144 } 146 }
145 147
146 bool shadowed() const { 148 bool shadowed() const {
147 return shadowed_; 149 return !shadow_.empty();
148 } 150 }
149 151
150 void MarkAsDeleted() { 152 void MarkAsDeleted() {
151 deleted_ = true; 153 deleted_ = true;
152 } 154 }
153 155
156 // Setup the shadow buffer. This will either initialize the shadow buffer
157 // with the passed data or clear the shadow buffer if no shadow required. This
158 // will return a pointer to the shadowed data if using shadow, otherwise will
159 // return the original data pointer.
160 const GLvoid* StageShadow(bool use_shadow, GLsizeiptr size,
161 const GLvoid* data);
162
154 // Sets the size, usage and initial data of a buffer. 163 // Sets the size, usage and initial data of a buffer.
155 // If shadow is true then if data is NULL buffer will be initialized to 0. 164 // If shadow is true then if data is NULL buffer will be initialized to 0.
156 void SetInfo( 165 void SetInfo(
157 GLsizeiptr size, GLenum usage, bool shadow, const GLvoid* data, 166 GLsizeiptr size, GLenum usage, bool shadow, bool is_client_side_array);
158 bool is_client_side_array);
159 167
160 // Sets a range of data for this buffer. Returns false if the offset or size 168 // Sets a range of data for this buffer. Returns false if the offset or size
161 // is out of range. 169 // is out of range.
162 bool SetRange( 170 bool SetRange(
163 GLintptr offset, GLsizeiptr size, const GLvoid * data); 171 GLintptr offset, GLsizeiptr size, const GLvoid * data);
164 172
165 // Clears any cache of index ranges. 173 // Clears any cache of index ranges.
166 void ClearCache(); 174 void ClearCache();
167 175
168 // Check if an offset, size range is valid for the current buffer. 176 // Check if an offset, size range is valid for the current buffer.
169 bool CheckRange(GLintptr offset, GLsizeiptr size) const; 177 bool CheckRange(GLintptr offset, GLsizeiptr size) const;
170 178
171 // The manager that owns this Buffer. 179 // The manager that owns this Buffer.
172 BufferManager* manager_; 180 BufferManager* manager_;
173 181
174 // A copy of the data in the buffer. This data is only kept if the target 182 // A copy of the data in the buffer. This data is only kept if the conditions
175 // is backed_ = true. 183 // checked in UseShadowBuffer() are true.
176 scoped_ptr<int8_t[]> shadow_; 184 std::vector<uint8_t> shadow_;
177 185
178 // Size of buffer. 186 // Size of buffer.
179 GLsizeiptr size_; 187 GLsizeiptr size_;
180 188
181 // True if deleted. 189 // True if deleted.
182 bool deleted_; 190 bool deleted_;
183 191
184 // Whether or not the data is shadowed.
185 bool shadowed_;
186
187 // Whether or not this Buffer is not uploaded to the GPU but just 192 // Whether or not this Buffer is not uploaded to the GPU but just
188 // sitting in local memory. 193 // sitting in local memory.
189 bool is_client_side_array_; 194 bool is_client_side_array_;
190 195
191 // Service side buffer id. 196 // Service side buffer id.
192 GLuint service_id_; 197 GLuint service_id_;
193 198
194 // The first target of buffer. 0 = unset. 199 // The first target of buffer. 0 = unset.
195 // It is set the first time bindBuffer() is called and cannot be changed. 200 // It is set the first time bindBuffer() is called and cannot be changed.
196 GLenum initial_target_; 201 GLenum initial_target_;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Does a glBufferData and updates the approprate accounting. Currently 309 // Does a glBufferData and updates the approprate accounting. Currently
305 // Assumes the values have already been validated. 310 // Assumes the values have already been validated.
306 void DoBufferData( 311 void DoBufferData(
307 ErrorState* error_state, 312 ErrorState* error_state,
308 Buffer* buffer, 313 Buffer* buffer,
309 GLenum target, 314 GLenum target,
310 GLsizeiptr size, 315 GLsizeiptr size,
311 GLenum usage, 316 GLenum usage,
312 const GLvoid* data); 317 const GLvoid* data);
313 318
319 // Tests whether a shadow buffer needs to be used.
320 bool UseShadowBuffer(GLenum target, GLenum usage);
321
314 // Sets the size, usage and initial data of a buffer. 322 // Sets the size, usage and initial data of a buffer.
315 // If data is NULL buffer will be initialized to 0 if shadowed. 323 // If data is NULL buffer will be initialized to 0 if shadowed.
316 void SetInfo(Buffer* buffer, GLenum target, GLsizeiptr size, GLenum usage, 324 void SetInfo(Buffer* buffer, GLenum target, GLsizeiptr size, GLenum usage,
317 const GLvoid* data); 325 bool use_shadow);
318 326
319 scoped_ptr<MemoryTypeTracker> memory_type_tracker_; 327 scoped_ptr<MemoryTypeTracker> memory_type_tracker_;
320 MemoryTracker* memory_tracker_; 328 MemoryTracker* memory_tracker_;
321 scoped_refptr<FeatureInfo> feature_info_; 329 scoped_refptr<FeatureInfo> feature_info_;
322 330
323 // Info for each buffer in the system. 331 // Info for each buffer in the system.
324 typedef base::hash_map<GLuint, scoped_refptr<Buffer> > BufferMap; 332 typedef base::hash_map<GLuint, scoped_refptr<Buffer> > BufferMap;
325 BufferMap buffers_; 333 BufferMap buffers_;
326 334
327 // Whether or not buffers can be bound to multiple targets. 335 // Whether or not buffers can be bound to multiple targets.
(...skipping 11 matching lines...) Expand all
339 bool have_context_; 347 bool have_context_;
340 bool use_client_side_arrays_for_stream_buffers_; 348 bool use_client_side_arrays_for_stream_buffers_;
341 349
342 DISALLOW_COPY_AND_ASSIGN(BufferManager); 350 DISALLOW_COPY_AND_ASSIGN(BufferManager);
343 }; 351 };
344 352
345 } // namespace gles2 353 } // namespace gles2
346 } // namespace gpu 354 } // namespace gpu
347 355
348 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ 356 #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/buffer_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698