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

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

Issue 245923008: Optimize GLES2DecoderImpl::ApplyDirtyState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on refactored gles2_cmd_decoder_unittest.cc Created 6 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) 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 // This file contains the ContextState class. 5 // This file contains the ContextState class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_
8 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ 8 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_
9 9
10 #include <vector> 10 #include <vector>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 }; 94 };
95 95
96 struct GPU_EXPORT ContextState { 96 struct GPU_EXPORT ContextState {
97 ContextState(FeatureInfo* feature_info, 97 ContextState(FeatureInfo* feature_info,
98 ErrorStateClient* error_state_client, 98 ErrorStateClient* error_state_client,
99 Logger* logger); 99 Logger* logger);
100 ~ContextState(); 100 ~ContextState();
101 101
102 void Initialize(); 102 void Initialize();
103 103
104 void SetIgnoreCachedStateForTest(bool ignore) {
105 ignore_cached_state = ignore;
106 }
107
104 void RestoreState(const ContextState* prev_state) const; 108 void RestoreState(const ContextState* prev_state) const;
105 void InitCapabilities(const ContextState* prev_state) const; 109 void InitCapabilities(const ContextState* prev_state) const;
106 void InitState(const ContextState* prev_state) const; 110 void InitState(const ContextState* prev_state) const;
107 111
108 void RestoreActiveTexture() const; 112 void RestoreActiveTexture() const;
109 void RestoreAllTextureUnitBindings(const ContextState* prev_state) const; 113 void RestoreAllTextureUnitBindings(const ContextState* prev_state) const;
110 void RestoreActiveTextureUnitBinding(unsigned int target) const; 114 void RestoreActiveTextureUnitBinding(unsigned int target) const;
111 void RestoreVertexAttribValues() const; 115 void RestoreVertexAttribValues() const;
112 void RestoreVertexAttribArrays( 116 void RestoreVertexAttribArrays(
113 const scoped_refptr<VertexAttribManager> attrib_manager) const; 117 const scoped_refptr<VertexAttribManager> attrib_manager) const;
114 void RestoreVertexAttribs() const; 118 void RestoreVertexAttribs() const;
115 void RestoreBufferBindings() const; 119 void RestoreBufferBindings() const;
116 void RestoreGlobalState(const ContextState* prev_state) const; 120 void RestoreGlobalState(const ContextState* prev_state) const;
117 void RestoreProgramBindings() const; 121 void RestoreProgramBindings() const;
118 void RestoreRenderbufferBindings() const; 122 void RestoreRenderbufferBindings() const;
119 void RestoreTextureUnitBindings( 123 void RestoreTextureUnitBindings(
120 GLuint unit, const ContextState* prev_state) const; 124 GLuint unit, const ContextState* prev_state) const;
121 125
122 // Helper for getting cached state. 126 // Helper for getting cached state.
123 bool GetStateAsGLint( 127 bool GetStateAsGLint(
124 GLenum pname, GLint* params, GLsizei* num_written) const; 128 GLenum pname, GLint* params, GLsizei* num_written) const;
125 bool GetStateAsGLfloat( 129 bool GetStateAsGLfloat(
126 GLenum pname, GLfloat* params, GLsizei* num_written) const; 130 GLenum pname, GLfloat* params, GLsizei* num_written) const;
127 bool GetEnabled(GLenum cap) const; 131 bool GetEnabled(GLenum cap) const;
128 132
133 inline void SetDeviceColorMask(GLboolean red,
134 GLboolean green,
135 GLboolean blue,
136 GLboolean alpha) {
137 if (cached_color_mask_red == red && cached_color_mask_green == green &&
138 cached_color_mask_blue == blue && cached_color_mask_alpha == alpha &&
139 !ignore_cached_state)
140 return;
141 cached_color_mask_red = red;
142 cached_color_mask_green = green;
143 cached_color_mask_blue = blue;
144 cached_color_mask_alpha = alpha;
145 glColorMask(red, green, blue, alpha);
146 }
147
148 inline void SetDeviceDepthMask(GLboolean mask) {
149 if (cached_depth_mask == mask && !ignore_cached_state)
150 return;
151 cached_depth_mask = mask;
152 glDepthMask(mask);
153 }
154
155 inline void SetDeviceStencilMaskSeparate(GLenum op, GLuint mask) {
156 if (op == GL_FRONT) {
157 if (cached_stencil_front_writemask == mask && !ignore_cached_state)
158 return;
159 cached_stencil_front_writemask = mask;
160 } else if (op == GL_BACK) {
161 if (cached_stencil_back_writemask == mask && !ignore_cached_state)
162 return;
163 cached_stencil_back_writemask = mask;
164 } else {
165 NOTREACHED();
166 return;
167 }
168 glStencilMaskSeparate(op, mask);
169 }
170
129 ErrorState* GetErrorState(); 171 ErrorState* GetErrorState();
130 172
131 #include "gpu/command_buffer/service/context_state_autogen.h" 173 #include "gpu/command_buffer/service/context_state_autogen.h"
132 174
133 EnableFlags enable_flags; 175 EnableFlags enable_flags;
134 176
135 // Current active texture by 0 - n index. 177 // Current active texture by 0 - n index.
136 // In other words, if we call glActiveTexture(GL_TEXTURE2) this value would 178 // In other words, if we call glActiveTexture(GL_TEXTURE2) this value would
137 // be 2. 179 // be 2.
138 GLuint active_texture_unit; 180 GLuint active_texture_unit;
(...skipping 16 matching lines...) Expand all
155 scoped_refptr<Program> current_program; 197 scoped_refptr<Program> current_program;
156 198
157 // The currently bound renderbuffer 199 // The currently bound renderbuffer
158 scoped_refptr<Renderbuffer> bound_renderbuffer; 200 scoped_refptr<Renderbuffer> bound_renderbuffer;
159 201
160 // A map of of target -> Query for current queries 202 // A map of of target -> Query for current queries
161 typedef std::map<GLuint, scoped_refptr<QueryManager::Query> > QueryMap; 203 typedef std::map<GLuint, scoped_refptr<QueryManager::Query> > QueryMap;
162 QueryMap current_queries; 204 QueryMap current_queries;
163 205
164 bool pack_reverse_row_order; 206 bool pack_reverse_row_order;
207 bool ignore_cached_state;
165 208
166 mutable bool fbo_binding_for_scissor_workaround_dirty_; 209 mutable bool fbo_binding_for_scissor_workaround_dirty_;
167 FeatureInfo* feature_info_; 210 FeatureInfo* feature_info_;
168 211
169 private: 212 private:
170 scoped_ptr<ErrorState> error_state_; 213 scoped_ptr<ErrorState> error_state_;
171 }; 214 };
172 215
173 } // namespace gles2 216 } // namespace gles2
174 } // namespace gpu 217 } // namespace gpu
175 218
176 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ 219 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_
177 220
OLDNEW
« no previous file with comments | « gpu/command_buffer/build_gles2_cmd_buffer.py ('k') | gpu/command_buffer/service/context_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698