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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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 <map> 8 #include <map>
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "gpu/command_buffer/common/buffer.h"
14 #include "gpu/command_buffer/service/gl_utils.h" 15 #include "gpu/command_buffer/service/gl_utils.h"
15 #include "gpu/command_buffer/service/memory_tracking.h" 16 #include "gpu/command_buffer/service/memory_tracking.h"
16 #include "gpu/gpu_export.h" 17 #include "gpu/gpu_export.h"
17 18
18 namespace gpu { 19 namespace gpu {
19 namespace gles2 { 20 namespace gles2 {
20 21
21 class BufferManager; 22 class BufferManager;
22 struct ContextState; 23 struct ContextState;
23 class ErrorState; 24 class ErrorState;
24 class FeatureInfo; 25 class FeatureInfo;
25 class TestHelper; 26 class TestHelper;
26 27
27 // Info about Buffers currently in the system. 28 // Info about Buffers currently in the system.
28 class GPU_EXPORT Buffer : public base::RefCounted<Buffer> { 29 class GPU_EXPORT Buffer : public base::RefCounted<Buffer> {
29 public: 30 public:
31 struct MappedRange {
32 GLintptr offset;
33 GLsizeiptr size;
34 GLenum access;
35 void* pointer; // Pointer returned by driver.
36 scoped_refptr<gpu::Buffer> shm; // Client side mem.
37
38 MappedRange(GLintptr offset, GLsizeiptr size, GLenum access,
39 void* pointer, scoped_refptr<gpu::Buffer> shm);
40 ~MappedRange();
41 void* GetShmPointer() const;
42 };
43
30 Buffer(BufferManager* manager, GLuint service_id); 44 Buffer(BufferManager* manager, GLuint service_id);
31 45
32 GLuint service_id() const { 46 GLuint service_id() const {
33 return service_id_; 47 return service_id_;
34 } 48 }
35 49
36 GLenum target() const { 50 GLenum target() const {
37 return target_; 51 return target_;
38 } 52 }
39 53
(...skipping 20 matching lines...) Expand all
60 } 74 }
61 75
62 bool IsValid() const { 76 bool IsValid() const {
63 return target() && !IsDeleted(); 77 return target() && !IsDeleted();
64 } 78 }
65 79
66 bool IsClientSideArray() const { 80 bool IsClientSideArray() const {
67 return is_client_side_array_; 81 return is_client_side_array_;
68 } 82 }
69 83
84 void SetMappedRange(GLintptr offset, GLsizeiptr size, GLenum access,
85 void* pointer, scoped_refptr<gpu::Buffer> shm) {
86 mapped_range_.reset(new MappedRange(offset, size, access, pointer, shm));
87 }
88
89 void RemoveMappedRange() {
90 mapped_range_.reset(nullptr);
91 }
92
93 const MappedRange* GetMappedRange() const {
94 return mapped_range_.get();
95 }
96
70 private: 97 private:
71 friend class BufferManager; 98 friend class BufferManager;
72 friend class BufferManagerTestBase; 99 friend class BufferManagerTestBase;
73 friend class base::RefCounted<Buffer>; 100 friend class base::RefCounted<Buffer>;
74 101
75 // Represents a range in a buffer. 102 // Represents a range in a buffer.
76 class Range { 103 class Range {
77 public: 104 public:
78 Range(GLuint offset, GLsizei count, GLenum type) 105 Range(GLuint offset, GLsizei count, GLenum type)
79 : offset_(offset), 106 : offset_(offset),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 GLuint service_id_; 183 GLuint service_id_;
157 184
158 // The type of buffer. 0 = unset, GL_BUFFER_ARRAY = vertex data, 185 // The type of buffer. 0 = unset, GL_BUFFER_ARRAY = vertex data,
159 // GL_ELEMENT_BUFFER_ARRAY = index data. 186 // GL_ELEMENT_BUFFER_ARRAY = index data.
160 // Once set a buffer can not be used for something else. 187 // Once set a buffer can not be used for something else.
161 GLenum target_; 188 GLenum target_;
162 189
163 // Usage of buffer. 190 // Usage of buffer.
164 GLenum usage_; 191 GLenum usage_;
165 192
193 // Data cached from last glMapBufferRange call.
194 scoped_ptr<MappedRange> mapped_range_;
195
166 // A map of ranges to the highest value in that range of a certain type. 196 // A map of ranges to the highest value in that range of a certain type.
167 typedef std::map<Range, GLuint, Range::Less> RangeToMaxValueMap; 197 typedef std::map<Range, GLuint, Range::Less> RangeToMaxValueMap;
168 RangeToMaxValueMap range_set_; 198 RangeToMaxValueMap range_set_;
169 }; 199 };
170 200
171 // This class keeps track of the buffers and their sizes so we can do 201 // This class keeps track of the buffers and their sizes so we can do
172 // bounds checking. 202 // bounds checking.
173 // 203 //
174 // NOTE: To support shared resources an instance of this class will need to be 204 // NOTE: To support shared resources an instance of this class will need to be
175 // shared by multiple GLES2Decoders. 205 // shared by multiple GLES2Decoders.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return memory_tracker_->GetMemRepresented(); 255 return memory_tracker_->GetMemRepresented();
226 } 256 }
227 257
228 // Tells for a given usage if this would be a client side array. 258 // Tells for a given usage if this would be a client side array.
229 bool IsUsageClientSideArray(GLenum usage); 259 bool IsUsageClientSideArray(GLenum usage);
230 260
231 // Tells whether a buffer that is emulated using client-side arrays should be 261 // Tells whether a buffer that is emulated using client-side arrays should be
232 // set to a non-zero size. 262 // set to a non-zero size.
233 bool UseNonZeroSizeForClientSideArrayBuffer(); 263 bool UseNonZeroSizeForClientSideArrayBuffer();
234 264
265 Buffer* GetBufferInfoForTarget(ContextState* state, GLenum target) const;
266
235 private: 267 private:
236 friend class Buffer; 268 friend class Buffer;
237 friend class TestHelper; // Needs access to DoBufferData. 269 friend class TestHelper; // Needs access to DoBufferData.
238 friend class BufferManagerTestBase; // Needs access to DoBufferSubData. 270 friend class BufferManagerTestBase; // Needs access to DoBufferSubData.
271
239 void StartTracking(Buffer* buffer); 272 void StartTracking(Buffer* buffer);
240 void StopTracking(Buffer* buffer); 273 void StopTracking(Buffer* buffer);
241 274
242 Buffer* GetBufferInfoForTarget(ContextState* state, GLenum target);
243
244 // Does a glBufferSubData and updates the approriate accounting. 275 // Does a glBufferSubData and updates the approriate accounting.
245 // Assumes the values have already been validated. 276 // Assumes the values have already been validated.
246 void DoBufferSubData( 277 void DoBufferSubData(
247 ErrorState* error_state, 278 ErrorState* error_state,
248 Buffer* buffer, 279 Buffer* buffer,
249 GLintptr offset, 280 GLintptr offset,
250 GLsizeiptr size, 281 GLsizeiptr size,
251 const GLvoid* data); 282 const GLvoid* data);
252 283
253 // Does a glBufferData and updates the approprate accounting. Currently 284 // Does a glBufferData and updates the approprate accounting. Currently
(...skipping 30 matching lines...) Expand all
284 bool have_context_; 315 bool have_context_;
285 bool use_client_side_arrays_for_stream_buffers_; 316 bool use_client_side_arrays_for_stream_buffers_;
286 317
287 DISALLOW_COPY_AND_ASSIGN(BufferManager); 318 DISALLOW_COPY_AND_ASSIGN(BufferManager);
288 }; 319 };
289 320
290 } // namespace gles2 321 } // namespace gles2
291 } // namespace gpu 322 } // namespace gpu
292 323
293 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ 324 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h ('k') | gpu/command_buffer/service/buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698