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

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

Issue 1822643002: [Command buffer] Enable primitive restart for WebGL 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix coding style and update webgl2_conformance_expectations.py 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
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 GLenum usage() const { 57 GLenum usage() const {
58 return usage_; 58 return usage_;
59 } 59 }
60 60
61 // Gets the maximum value in the buffer for the given range interpreted as 61 // Gets the maximum value in the buffer for the given range interpreted as
62 // the given type. Returns false if offset and count are out of range. 62 // the given type. Returns false if offset and count are out of range.
63 // offset is in bytes. 63 // offset is in bytes.
64 // count is in elements of type. 64 // count is in elements of type.
65 bool GetMaxValueForRange(GLuint offset, GLsizei count, GLenum type, 65 bool GetMaxValueForRange(GLuint offset, GLsizei count, GLenum type,
66 GLuint* max_value); 66 bool primitive_restart_enabled, GLuint* max_value);
67 67
68 // Returns a pointer to shadowed data. 68 // Returns a pointer to shadowed data.
69 const void* GetRange(GLintptr offset, GLsizeiptr size) const; 69 const void* GetRange(GLintptr offset, GLsizeiptr size) const;
70 70
71 bool IsDeleted() const { 71 bool IsDeleted() const {
72 return deleted_; 72 return deleted_;
73 } 73 }
74 74
75 bool IsValid() const { 75 bool IsValid() const {
76 return initial_target() && !IsDeleted(); 76 return initial_target() && !IsDeleted();
(...skipping 17 matching lines...) Expand all
94 } 94 }
95 95
96 private: 96 private:
97 friend class BufferManager; 97 friend class BufferManager;
98 friend class BufferManagerTestBase; 98 friend class BufferManagerTestBase;
99 friend class base::RefCounted<Buffer>; 99 friend class base::RefCounted<Buffer>;
100 100
101 // Represents a range in a buffer. 101 // Represents a range in a buffer.
102 class Range { 102 class Range {
103 public: 103 public:
104 Range(GLuint offset, GLsizei count, GLenum type) 104 Range(GLuint offset, GLsizei count, GLenum type,
105 bool primitive_restart_enabled)
105 : offset_(offset), 106 : offset_(offset),
106 count_(count), 107 count_(count),
107 type_(type) { 108 type_(type),
109 primitive_restart_enabled_(primitive_restart_enabled) {
108 } 110 }
109 111
110 // A less functor provided for std::map so it can find ranges. 112 // A less functor provided for std::map so it can find ranges.
111 struct Less { 113 struct Less {
112 bool operator() (const Range& lhs, const Range& rhs) const { 114 bool operator() (const Range& lhs, const Range& rhs) const {
113 if (lhs.offset_ != rhs.offset_) { 115 if (lhs.offset_ != rhs.offset_) {
114 return lhs.offset_ < rhs.offset_; 116 return lhs.offset_ < rhs.offset_;
115 } 117 }
116 if (lhs.count_ != rhs.count_) { 118 if (lhs.count_ != rhs.count_) {
117 return lhs.count_ < rhs.count_; 119 return lhs.count_ < rhs.count_;
118 } 120 }
119 return lhs.type_ < rhs.type_; 121 if (lhs.type_ != rhs.type_) {
122 return lhs.type_ < rhs.type_;
123 }
124 return lhs.primitive_restart_enabled_ < rhs.primitive_restart_enabled_;
120 } 125 }
121 }; 126 };
122 127
123 private: 128 private:
124 GLuint offset_; 129 GLuint offset_;
125 GLsizei count_; 130 GLsizei count_;
126 GLenum type_; 131 GLenum type_;
132 bool primitive_restart_enabled_;
127 }; 133 };
128 134
129 ~Buffer(); 135 ~Buffer();
130 136
131 GLenum initial_target() const { 137 GLenum initial_target() const {
132 return initial_target_; 138 return initial_target_;
133 } 139 }
134 140
135 void set_initial_target(GLenum target) { 141 void set_initial_target(GLenum target) {
136 DCHECK_EQ(0u, initial_target_); 142 DCHECK_EQ(0u, initial_target_);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 return memory_type_tracker_->GetMemRepresented(); 268 return memory_type_tracker_->GetMemRepresented();
263 } 269 }
264 270
265 // Tells for a given usage if this would be a client side array. 271 // Tells for a given usage if this would be a client side array.
266 bool IsUsageClientSideArray(GLenum usage); 272 bool IsUsageClientSideArray(GLenum usage);
267 273
268 // Tells whether a buffer that is emulated using client-side arrays should be 274 // Tells whether a buffer that is emulated using client-side arrays should be
269 // set to a non-zero size. 275 // set to a non-zero size.
270 bool UseNonZeroSizeForClientSideArrayBuffer(); 276 bool UseNonZeroSizeForClientSideArrayBuffer();
271 277
278 void SetPrimitiveRestartFixedIndexIfNecessary(GLenum type);
279
272 Buffer* GetBufferInfoForTarget(ContextState* state, GLenum target) const; 280 Buffer* GetBufferInfoForTarget(ContextState* state, GLenum target) const;
273 281
274 // base::trace_event::MemoryDumpProvider implementation. 282 // base::trace_event::MemoryDumpProvider implementation.
275 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, 283 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
276 base::trace_event::ProcessMemoryDump* pmd) override; 284 base::trace_event::ProcessMemoryDump* pmd) override;
277 285
278 private: 286 private:
279 friend class Buffer; 287 friend class Buffer;
280 friend class TestHelper; // Needs access to DoBufferData. 288 friend class TestHelper; // Needs access to DoBufferData.
281 friend class BufferManagerTestBase; // Needs access to DoBufferSubData. 289 friend class BufferManagerTestBase; // Needs access to DoBufferSubData.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // Whether or not buffers can be bound to multiple targets. 327 // Whether or not buffers can be bound to multiple targets.
320 bool allow_buffers_on_multiple_targets_; 328 bool allow_buffers_on_multiple_targets_;
321 329
322 // Whether or not allow using GL_FIXED type for vertex attribs. 330 // Whether or not allow using GL_FIXED type for vertex attribs.
323 bool allow_fixed_attribs_; 331 bool allow_fixed_attribs_;
324 332
325 // Counts the number of Buffer allocated with 'this' as its manager. 333 // Counts the number of Buffer allocated with 'this' as its manager.
326 // Allows to check no Buffer will outlive this. 334 // Allows to check no Buffer will outlive this.
327 unsigned int buffer_count_; 335 unsigned int buffer_count_;
328 336
337 GLuint primitive_restart_fixed_index_;
338
329 bool have_context_; 339 bool have_context_;
330 bool use_client_side_arrays_for_stream_buffers_; 340 bool use_client_side_arrays_for_stream_buffers_;
331 341
332 DISALLOW_COPY_AND_ASSIGN(BufferManager); 342 DISALLOW_COPY_AND_ASSIGN(BufferManager);
333 }; 343 };
334 344
335 } // namespace gles2 345 } // namespace gles2
336 } // namespace gpu 346 } // namespace gpu
337 347
338 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ 348 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/webgl2_conformance_expectations.py ('k') | gpu/command_buffer/service/buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698