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

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

Issue 2012533004: Add generated and hand-written passthrough command handlers with stub Doers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 // This file contains the GLES2DecoderPassthroughImpl class. 5 // This file contains the GLES2DecoderPassthroughImpl class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_H_ 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_H_
8 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_H_ 8 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_H_
9 9
10 #include "base/memory/ref_counted.h"
11 #include "gpu/command_buffer/common/debug_marker_manager.h"
12 #include "gpu/command_buffer/common/gles2_cmd_format.h"
13 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
14 #include "gpu/command_buffer/common/mailbox.h"
15 #include "gpu/command_buffer/service/context_group.h"
16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
17 #include "gpu/command_buffer/service/image_manager.h"
18 #include "gpu/command_buffer/service/logger.h"
19 #include "ui/gl/gl_bindings.h"
20 #include "ui/gl/gl_context.h"
21 #include "ui/gl/gl_image.h"
22 #include "ui/gl/gl_surface.h"
23
10 namespace gpu { 24 namespace gpu {
11
12 namespace gles2 { 25 namespace gles2 {
13 26
14 class ContextGroup; 27 class ContextGroup;
15 class GLES2Decoder; 28
16 29 class GLES2DecoderPassthroughImpl : public GLES2Decoder {
17 GLES2Decoder* CreateGLES2DecoderPassthroughImpl(ContextGroup* group); 30 public:
31 explicit GLES2DecoderPassthroughImpl(ContextGroup* group);
32 ~GLES2DecoderPassthroughImpl() override;
33
34 Error DoCommands(unsigned int num_commands,
35 const void* buffer,
36 int num_entries,
37 int* entries_processed) override;
38
39 const char* GetCommandName(unsigned int command_id) const override;
40
41 bool Initialize(const scoped_refptr<gl::GLSurface>& surface,
42 const scoped_refptr<gl::GLContext>& context,
43 bool offscreen,
44 const gfx::Size& offscreen_size,
45 const DisallowedFeatures& disallowed_features,
46 const ContextCreationAttribHelper& attrib_helper) override;
47
48 // Destroys the graphics context.
49 void Destroy(bool have_context) override;
50
51 // Set the surface associated with the default FBO.
52 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override;
53
54 // Releases the surface associated with the GL context.
55 // The decoder should not be used until a new surface is set.
56 void ReleaseSurface() override;
57
58 void TakeFrontBuffer(const Mailbox& mailbox) override;
59
60 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override;
61
62 // Resize an offscreen frame buffer.
63 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override;
64
65 // Make this decoder's GL context current.
66 bool MakeCurrent() override;
67
68 // Gets the GLES2 Util which holds info.
69 GLES2Util* GetGLES2Util() override;
70
71 // Gets the associated GLContext.
72 gl::GLContext* GetGLContext() override;
73
74 // Gets the associated ContextGroup
75 ContextGroup* GetContextGroup() override;
76
77 Capabilities GetCapabilities() override;
78
79 // Restores all of the decoder GL state.
80 void RestoreState(const ContextState* prev_state) override;
81
82 // Restore States.
83 void RestoreActiveTexture() const override;
84 void RestoreAllTextureUnitBindings(
85 const ContextState* prev_state) const override;
86 void RestoreActiveTextureUnitBinding(unsigned int target) const override;
87 void RestoreBufferBindings() const override;
88 void RestoreFramebufferBindings() const override;
89 void RestoreRenderbufferBindings() override;
90 void RestoreGlobalState() const override;
91 void RestoreProgramBindings() const override;
92 void RestoreTextureState(unsigned service_id) const override;
93 void RestoreTextureUnitBindings(unsigned unit) const override;
94 void RestoreAllExternalTextureBindingsIfNeeded() override;
95
96 void ClearAllAttributes() const override;
97 void RestoreAllAttributes() const override;
98
99 void SetIgnoreCachedStateForTest(bool ignore) override;
100 void SetForceShaderNameHashingForTest(bool force) override;
101 size_t GetSavedBackTextureCountForTest() override;
102 size_t GetCreatedBackTextureCountForTest() override;
103
104 // Sets the callback for fence sync release and wait calls. The wait call
105 // returns true if the channel is still scheduled.
106 void SetFenceSyncReleaseCallback(
107 const FenceSyncReleaseCallback& callback) override;
108 void SetWaitFenceSyncCallback(const WaitFenceSyncCallback& callback) override;
109 void SetDescheduleUntilFinishedCallback(
110 const NoParamCallback& callback) override;
111 void SetRescheduleAfterFinishedCallback(
112 const NoParamCallback& callback) override;
113
114 // Gets the QueryManager for this context.
115 QueryManager* GetQueryManager() override;
116
117 // Gets the TransformFeedbackManager for this context.
118 TransformFeedbackManager* GetTransformFeedbackManager() override;
119
120 // Gets the VertexArrayManager for this context.
121 VertexArrayManager* GetVertexArrayManager() override;
122
123 // Gets the ImageManager for this context.
124 ImageManager* GetImageManager() override;
125
126 // Returns false if there are no pending queries.
127 bool HasPendingQueries() const override;
128
129 // Process any pending queries.
130 void ProcessPendingQueries(bool did_finish) override;
131
132 // Returns false if there is no idle work to be made.
133 bool HasMoreIdleWork() const override;
134
135 // Perform any idle work that needs to be made.
136 void PerformIdleWork() override;
137
138 bool GetServiceTextureId(uint32_t client_texture_id,
139 uint32_t* service_texture_id) override;
140
141 // Provides detail about a lost context if one occurred.
142 error::ContextLostReason GetContextLostReason() override;
143
144 // Clears a level sub area of a texture
145 // Returns false if a GL error should be generated.
146 bool ClearLevel(Texture* texture,
147 unsigned target,
148 int level,
149 unsigned format,
150 unsigned type,
151 int xoffset,
152 int yoffset,
153 int width,
154 int height) override;
155
156 // Clears a level sub area of a compressed 2D texture.
157 // Returns false if a GL error should be generated.
158 bool ClearCompressedTextureLevel(Texture* texture,
159 unsigned target,
160 int level,
161 unsigned format,
162 int width,
163 int height) override;
164
165 // Indicates whether a given internal format is one for a compressed
166 // texture.
167 bool IsCompressedTextureFormat(unsigned format) override;
168
169 // Clears a level of a 3D texture.
170 // Returns false if a GL error should be generated.
171 bool ClearLevel3D(Texture* texture,
172 unsigned target,
173 int level,
174 unsigned format,
175 unsigned type,
176 int width,
177 int height,
178 int depth) override;
179
180 ErrorState* GetErrorState() override;
181
182 void SetShaderCacheCallback(const ShaderCacheCallback& callback) override;
183
184 void WaitForReadPixels(base::Closure callback) override;
185
186 uint32_t GetTextureUploadCount() override;
187
188 base::TimeDelta GetTotalTextureUploadTime() override;
189
190 base::TimeDelta GetTotalProcessingCommandsTime() override;
191
192 void AddProcessingCommandsTime(base::TimeDelta) override;
193
194 // Returns true if the context was lost either by GL_ARB_robustness, forced
195 // context loss or command buffer parse error.
196 bool WasContextLost() const override;
197
198 // Returns true if the context was lost specifically by GL_ARB_robustness.
199 bool WasContextLostByRobustnessExtension() const override;
200
201 // Lose this context.
202 void MarkContextLost(error::ContextLostReason reason) override;
203
204 Logger* GetLogger() override;
205
206 const ContextState* GetContextState() override;
207
208 private:
209 int commands_to_process_;
210
211 DebugMarkerManager debug_marker_manager_;
212 Logger logger_;
213
214 #define GLES2_CMD_OP(name) \
215 Error Handle##name(uint32_t immediate_data_size, const void* data);
216
217 GLES2_COMMAND_LIST(GLES2_CMD_OP)
218 #undef GLES2_CMD_OP
219
220 using CmdHandler =
221 Error (GLES2DecoderPassthroughImpl::*)(uint32_t immediate_data_size,
222 const void* data);
223
224 // A struct to hold info about each command.
225 struct CommandInfo {
226 CmdHandler cmd_handler;
227 uint8_t arg_flags; // How to handle the arguments for this scommand
228 uint8_t cmd_flags; // How to handle this command
229 uint16_t arg_count; // How many arguments are expected for this command.
230 };
231
232 // A table of CommandInfo for all the commands.
233 static const CommandInfo command_info[kNumCommands - kFirstGLES2Command];
234
235 // The GL context this decoder renders to on behalf of the client.
236 scoped_refptr<gl::GLSurface> surface_;
237 scoped_refptr<gl::GLContext> context_;
238
239 // Managers
240 std::unique_ptr<ImageManager> image_manager_;
241
242 // The ContextGroup for this decoder uses to track resources.
243 scoped_refptr<ContextGroup> group_;
244 scoped_refptr<FeatureInfo> feature_info_;
245
246 // Include the prototypes of all the doer functions from a separate header to
247 // keep this file clean.
248 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doer_prototyp es.h"
249 };
18 250
19 } // namespace gles2 251 } // namespace gles2
20 } // namespace gpu 252 } // namespace gpu
21 253
22 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_H_ 254 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698