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

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

Issue 1922633002: Implement TransformFeedbackManager in GPU command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_
7
8 #include <vector>
9
10 #include "base/memory/ref_counted.h"
11 #include "gpu/command_buffer/service/gl_utils.h"
12 #include "gpu/gpu_export.h"
13
14 namespace gpu {
15 namespace gles2 {
16
17 class Buffer;
18
19 // This is a base class for indexed buffer bindings tracking.
20 // TransformFeedback and Program should inherit from this base class,
21 // for tracking indexed TRANSFORM_FEEDBACK_BUFFER / UNIFORM_BUFFER bindings.
22 class GPU_EXPORT IndexedBufferBindingHost :
23 public base::RefCounted<IndexedBufferBindingHost> {
24 public:
25 // |needs_emulation| is set to true on Desktop GL 4.1 or lower.
26 IndexedBufferBindingHost(uint32_t max_bindings, bool needs_emulation);
27
28 // The following two functions do state update and call the underlying GL
29 // function. All validations have been done already and the GL function is
30 // guaranteed to succeed.
31 void DoBindBufferBase(GLenum target, GLuint index, Buffer* buffer);
32 void DoBindBufferRange(
33 GLenum target, GLuint index, Buffer* buffer, GLintptr offset,
34 GLsizeiptr size);
35
36 // This is called on the active host when glBufferData is called and buffer
37 // size might change.
38 void OnBufferData(GLenum target, Buffer* buffer);
39
40 // This is called when the host become active.
41 void OnBindHost(GLenum target);
42
43 void RemoveBoundBuffer(Buffer* buffer);
44
45 Buffer* GetBufferBinding(GLuint index) const;
46 GLsizeiptr GetBufferSize(GLuint index) const;
47 GLintptr GetBufferStart(GLuint index) const;
48
49 protected:
50 friend class base::RefCounted<IndexedBufferBindingHost>;
51
52 virtual ~IndexedBufferBindingHost();
53
54 private:
55 enum IndexedBufferBindingType {
56 kBindBufferBase,
57 kBindBufferRange,
58 kBindBufferNone
59 };
60
61 struct IndexedBufferBinding {
62 IndexedBufferBindingType type;
63 scoped_refptr<Buffer> buffer;
64
65 // The following fields are only used if |type| is kBindBufferRange.
66 GLintptr offset;
67 GLsizeiptr size;
68 // The full buffer size at the last successful glBindBufferRange call.
69 GLsizeiptr effective_full_buffer_size;
70
71 IndexedBufferBinding();
72 IndexedBufferBinding(const IndexedBufferBinding& other);
73 ~IndexedBufferBinding();
74
75 void SetBindBufferBase(Buffer* _buffer);
76 void SetBindBufferRange(
77 Buffer* _buffer, GLintptr _offset, GLsizeiptr _size);
78 void Reset();
79 };
80
81 // This is called on Desktop GL lower than 4.2, where the range
82 // (offset + size) can't go beyond the buffer's size.
83 static void DoAdjustedBindBufferRange(
84 GLenum target, GLuint index, GLuint service_id, GLintptr offset,
85 GLsizeiptr size, GLsizeiptr full_buffer_size);
86
87 std::vector<IndexedBufferBinding> buffer_bindings_;
88
89 bool needs_emulation_;
90 };
91
92 } // namespace gles2
93 } // namespace gpu
94
95 #endif // GPU_COMMAND_BUFFER_SERVICE_INDEXED_BUFFER_BINDING_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698