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

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

Issue 1949303003: Improve indexed gl state related GL commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tex
Patch Set: fix a DCHECK failure Created 4 years, 7 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) 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"
(...skipping 28 matching lines...) Expand all
39 39
40 // This is called when the host become active. 40 // This is called when the host become active.
41 void OnBindHost(GLenum target); 41 void OnBindHost(GLenum target);
42 42
43 void RemoveBoundBuffer(Buffer* buffer); 43 void RemoveBoundBuffer(Buffer* buffer);
44 44
45 Buffer* GetBufferBinding(GLuint index) const; 45 Buffer* GetBufferBinding(GLuint index) const;
46 GLsizeiptr GetBufferSize(GLuint index) const; 46 GLsizeiptr GetBufferSize(GLuint index) const;
47 GLintptr GetBufferStart(GLuint index) const; 47 GLintptr GetBufferStart(GLuint index) const;
48 48
49 // This is used only for UNIFORM_BUFFER bindings in context switching.
50 void RestoreBindings(IndexedBufferBindingHost* prev);
51
49 protected: 52 protected:
50 friend class base::RefCounted<IndexedBufferBindingHost>; 53 friend class base::RefCounted<IndexedBufferBindingHost>;
51 54
52 virtual ~IndexedBufferBindingHost(); 55 virtual ~IndexedBufferBindingHost();
53 56
54 private: 57 private:
55 enum IndexedBufferBindingType { 58 enum IndexedBufferBindingType {
56 kBindBufferBase, 59 kBindBufferBase,
57 kBindBufferRange, 60 kBindBufferRange,
58 kBindBufferNone 61 kBindBufferNone
59 }; 62 };
60 63
61 struct IndexedBufferBinding { 64 struct IndexedBufferBinding {
62 IndexedBufferBindingType type; 65 IndexedBufferBindingType type;
63 scoped_refptr<Buffer> buffer; 66 scoped_refptr<Buffer> buffer;
64 67
65 // The following fields are only used if |type| is kBindBufferRange. 68 // The following fields are only used if |type| is kBindBufferRange.
66 GLintptr offset; 69 GLintptr offset;
67 GLsizeiptr size; 70 GLsizeiptr size;
68 // The full buffer size at the last successful glBindBufferRange call. 71 // The full buffer size at the last successful glBindBufferRange call.
69 GLsizeiptr effective_full_buffer_size; 72 GLsizeiptr effective_full_buffer_size;
70 73
71 IndexedBufferBinding(); 74 IndexedBufferBinding();
72 IndexedBufferBinding(const IndexedBufferBinding& other); 75 IndexedBufferBinding(const IndexedBufferBinding& other);
73 ~IndexedBufferBinding(); 76 ~IndexedBufferBinding();
74 77
78 bool operator==(const IndexedBufferBinding& other) const;
79
75 void SetBindBufferBase(Buffer* _buffer); 80 void SetBindBufferBase(Buffer* _buffer);
76 void SetBindBufferRange( 81 void SetBindBufferRange(
77 Buffer* _buffer, GLintptr _offset, GLsizeiptr _size); 82 Buffer* _buffer, GLintptr _offset, GLsizeiptr _size);
78 void Reset(); 83 void Reset();
79 }; 84 };
80 85
81 // This is called on Desktop GL lower than 4.2, where the range 86 // This is called on Desktop GL lower than 4.2, where the range
82 // (offset + size) can't go beyond the buffer's size. 87 // (offset + size) can't go beyond the buffer's size.
83 static void DoAdjustedBindBufferRange( 88 static void DoAdjustedBindBufferRange(
84 GLenum target, GLuint index, GLuint service_id, GLintptr offset, 89 GLenum target, GLuint index, GLuint service_id, GLintptr offset,
85 GLsizeiptr size, GLsizeiptr full_buffer_size); 90 GLsizeiptr size, GLsizeiptr full_buffer_size);
86 91
92 void UpdateMaxNonNullBindingIndex(size_t changed_index);
93
87 std::vector<IndexedBufferBinding> buffer_bindings_; 94 std::vector<IndexedBufferBinding> buffer_bindings_;
88 95
89 bool needs_emulation_; 96 bool needs_emulation_;
97
98 // This is used for optimization purpose in context switching.
99 size_t max_non_null_binding_index_plus_one_;
90 }; 100 };
91 101
92 } // namespace gles2 102 } // namespace gles2
93 } // namespace gpu 103 } // namespace gpu
94 104
95 #endif // GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_ 105 #endif // GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698