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

Side by Side Diff: gpu/command_buffer/service/transform_feedback_manager.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_TRANSFORM_FEEDBACK_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TRANSFORM_FEEDBACK_MANAGER_H_
7
8 #include <vector>
9
10 #include "base/containers/hash_tables.h"
11 #include "base/memory/ref_counted.h"
12 #include "gpu/command_buffer/service/gl_utils.h"
13 #include "gpu/command_buffer/service/indexed_buffer_binding_host.h"
14 #include "gpu/gpu_export.h"
15
16 namespace gfx {
17 struct GLVersionInfo;
18 };
19
20 namespace gpu {
21 namespace gles2 {
22
23 class Buffer;
24 class TransformFeedbackManager;
25
26 // Info about TransformFeedbacks currently in the system.
27 class GPU_EXPORT TransformFeedback : public IndexedBufferBindingHost {
28 public:
29 TransformFeedback(TransformFeedbackManager* manager, GLuint service_id);
30
31 // All the following functions do state update and call the underlying GL
32 // function. All validations have been done already and the GL function is
33 // guaranteed to succeed.
34 void DoBindTransformFeedback(GLenum target);
35 void DoBeginTransformFeedback(GLenum primitive_mode);
36 void DoEndTransformFeedback();
37 void DoPauseTransformFeedback();
38 void DoResumeTransformFeedback();
39
40 GLuint service_id() const {
41 return service_id_;
42 }
43
44 bool has_been_bound() const {
45 return has_been_bound_;
46 }
47
48 bool active() const {
49 return active_;
50 }
51
52 bool paused() const {
53 return paused_;
54 }
55
56 GLenum primitive_mode() const {
57 return primitive_mode_;
58 }
59
60 private:
61 ~TransformFeedback() override;
62
63 // The manager that owns this Buffer.
64 TransformFeedbackManager* manager_;
65
66 GLuint service_id_;
67
68 bool has_been_bound_;
69
70 bool active_;
71 bool paused_;
72
73 GLenum primitive_mode_;
74 };
75
76 // This class keeps tracks of the transform feedbacks and their states.
77 class GPU_EXPORT TransformFeedbackManager {
78 public:
79 // |needs_emulation| is true on Desktop GL 4.1 or lower.
80 TransformFeedbackManager(GLuint max_transform_feedback_separate_attribs,
81 bool needs_emulation);
82 ~TransformFeedbackManager();
83
84 void MarkContextLost() {
85 lost_context_ = true;
86 }
87
88 // Must call before destruction.
89 void Destroy();
90
91 // Creates a TransformFeedback from the given client/service IDs and
92 // insert it into the list.
93 TransformFeedback* CreateTransformFeedback(
94 GLuint client_id, GLuint service_id);
95
96 TransformFeedback* GetTransformFeedback(GLuint client_id);
97
98 // Removes a TransformFeedback info for the given client ID.
99 void RemoveTransformFeedback(GLuint client_id);
100
101 void RemoveBoundBuffer(Buffer* buffer);
102
103 GLuint max_transform_feedback_separate_attribs() const {
104 return max_transform_feedback_separate_attribs_;
105 }
106
107 bool needs_emulation() const {
108 return needs_emulation_;
109 }
110
111 bool lost_context() const {
112 return lost_context_;
113 }
114
115 private:
116 // Info for each transform feedback in the system.
117 base::hash_map<GLuint,
118 scoped_refptr<TransformFeedback> > transform_feedbacks_;
119
120 GLuint max_transform_feedback_separate_attribs_;
121
122 bool needs_emulation_;
123 bool lost_context_;
124
125 DISALLOW_COPY_AND_ASSIGN(TransformFeedbackManager);
126 };
127
128 } // namespace gles2
129 } // namespace gpu
130
131 #endif // GPU_COMMAND_BUFFER_SERVICE_TRANSFORM_FEEDBACK_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698