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

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: shadow->use_shadow, Format, vector Clear+Insert/Resize 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/buffer_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 138
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 { return !shadow_.empty(); }
147 return shadowed_;
148 }
149 149
150 void MarkAsDeleted() { 150 void MarkAsDeleted() {
151 deleted_ = true; 151 deleted_ = true;
152 } 152 }
153 153
154 // Setup the shadow buffer. This will either initialize the shadow buffer
155 // with the passed data or clear the shadow buffer if no shadow required. This
156 // will return a pointer to the shadowed data if using shadow, otherwise will
157 // return the original data pointer.
158 const GLvoid* StageShadow(bool use_shadow,
159 GLsizeiptr size,
160 const GLvoid* data);
161
154 // Sets the size, usage and initial data of a buffer. 162 // 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. 163 // If shadow is true then if data is NULL buffer will be initialized to 0.
156 void SetInfo( 164 void SetInfo(GLsizeiptr size,
157 GLsizeiptr size, GLenum usage, bool shadow, const GLvoid* data, 165 GLenum usage,
158 bool is_client_side_array); 166 bool use_shadow,
167 bool is_client_side_array);
159 168
160 // Sets a range of data for this buffer. Returns false if the offset or size 169 // Sets a range of data for this buffer. Returns false if the offset or size
161 // is out of range. 170 // is out of range.
162 bool SetRange( 171 bool SetRange(
163 GLintptr offset, GLsizeiptr size, const GLvoid * data); 172 GLintptr offset, GLsizeiptr size, const GLvoid * data);
164 173
165 // Clears any cache of index ranges. 174 // Clears any cache of index ranges.
166 void ClearCache(); 175 void ClearCache();
167 176
168 // Check if an offset, size range is valid for the current buffer. 177 // Check if an offset, size range is valid for the current buffer.
169 bool CheckRange(GLintptr offset, GLsizeiptr size) const; 178 bool CheckRange(GLintptr offset, GLsizeiptr size) const;
170 179
171 // The manager that owns this Buffer. 180 // The manager that owns this Buffer.
172 BufferManager* manager_; 181 BufferManager* manager_;
173 182
174 // A copy of the data in the buffer. This data is only kept if the target 183 // A copy of the data in the buffer. This data is only kept if the conditions
175 // is backed_ = true. 184 // checked in UseShadowBuffer() are true.
176 scoped_ptr<int8_t[]> shadow_; 185 std::vector<uint8_t> shadow_;
177 186
178 // Size of buffer. 187 // Size of buffer.
179 GLsizeiptr size_; 188 GLsizeiptr size_;
180 189
181 // True if deleted. 190 // True if deleted.
182 bool deleted_; 191 bool deleted_;
183 192
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 193 // Whether or not this Buffer is not uploaded to the GPU but just
188 // sitting in local memory. 194 // sitting in local memory.
189 bool is_client_side_array_; 195 bool is_client_side_array_;
190 196
191 // Service side buffer id. 197 // Service side buffer id.
192 GLuint service_id_; 198 GLuint service_id_;
193 199
194 // The first target of buffer. 0 = unset. 200 // The first target of buffer. 0 = unset.
195 // It is set the first time bindBuffer() is called and cannot be changed. 201 // It is set the first time bindBuffer() is called and cannot be changed.
196 GLenum initial_target_; 202 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 310 // Does a glBufferData and updates the approprate accounting. Currently
305 // Assumes the values have already been validated. 311 // Assumes the values have already been validated.
306 void DoBufferData( 312 void DoBufferData(
307 ErrorState* error_state, 313 ErrorState* error_state,
308 Buffer* buffer, 314 Buffer* buffer,
309 GLenum target, 315 GLenum target,
310 GLsizeiptr size, 316 GLsizeiptr size,
311 GLenum usage, 317 GLenum usage,
312 const GLvoid* data); 318 const GLvoid* data);
313 319
320 // Tests whether a shadow buffer needs to be used.
321 bool UseShadowBuffer(GLenum target, GLenum usage);
322
314 // Sets the size, usage and initial data of a buffer. 323 // Sets the size, usage and initial data of a buffer.
315 // If data is NULL buffer will be initialized to 0 if shadowed. 324 // If data is NULL buffer will be initialized to 0 if shadowed.
316 void SetInfo(Buffer* buffer, GLenum target, GLsizeiptr size, GLenum usage, 325 void SetInfo(Buffer* buffer,
317 const GLvoid* data); 326 GLenum target,
327 GLsizeiptr size,
328 GLenum usage,
329 bool use_shadow);
318 330
319 scoped_ptr<MemoryTypeTracker> memory_type_tracker_; 331 scoped_ptr<MemoryTypeTracker> memory_type_tracker_;
320 MemoryTracker* memory_tracker_; 332 MemoryTracker* memory_tracker_;
321 scoped_refptr<FeatureInfo> feature_info_; 333 scoped_refptr<FeatureInfo> feature_info_;
322 334
323 // Info for each buffer in the system. 335 // Info for each buffer in the system.
324 typedef base::hash_map<GLuint, scoped_refptr<Buffer> > BufferMap; 336 typedef base::hash_map<GLuint, scoped_refptr<Buffer> > BufferMap;
325 BufferMap buffers_; 337 BufferMap buffers_;
326 338
327 // Whether or not buffers can be bound to multiple targets. 339 // Whether or not buffers can be bound to multiple targets.
(...skipping 11 matching lines...) Expand all
339 bool have_context_; 351 bool have_context_;
340 bool use_client_side_arrays_for_stream_buffers_; 352 bool use_client_side_arrays_for_stream_buffers_;
341 353
342 DISALLOW_COPY_AND_ASSIGN(BufferManager); 354 DISALLOW_COPY_AND_ASSIGN(BufferManager);
343 }; 355 };
344 356
345 } // namespace gles2 357 } // namespace gles2
346 } // namespace gpu 358 } // namespace gpu
347 359
348 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ 360 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698