blob: c3906c8f0462bd58a41d9b13fc4c760a4702216b [file] [log] [blame]
gman@chromium.orge259eb412012-10-13 05:47:241// 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
3// found in the LICENSE file.
4
5// This file contains the ContextState class.
6
7#ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_
8#define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_
9
mostynb6682b1c42016-04-19 10:17:3010#include <memory>
gman@chromium.org1868a342012-11-07 15:56:0211#include <vector>
mostynb6682b1c42016-04-19 10:17:3012
Hans Wennborgd3aef50c2020-06-19 21:29:1413#include "base/check_op.h"
Keishi Hattori0e45c022021-11-27 09:25:5214#include "base/memory/raw_ptr.h"
Hans Wennborgd3aef50c2020-06-19 21:29:1415#include "base/notreached.h"
gman@chromium.orge259eb412012-10-13 05:47:2416#include "gpu/command_buffer/service/gl_utils.h"
bajones5141d032015-12-07 21:13:3917#include "gpu/command_buffer/service/sampler_manager.h"
zmoeaae3bb2016-07-15 19:23:1918#include "gpu/command_buffer/service/shader_manager.h"
gman@chromium.orge259eb412012-10-13 05:47:2419#include "gpu/command_buffer/service/texture_manager.h"
gman@chromium.orge259eb412012-10-13 05:47:2420#include "gpu/command_buffer/service/vertex_array_manager.h"
mostynb6682b1c42016-04-19 10:17:3021#include "gpu/command_buffer/service/vertex_attrib_manager.h"
Antoine Labour83a0aed12018-01-10 04:52:3822#include "gpu/gpu_gles2_export.h"
gman@chromium.orge259eb412012-10-13 05:47:2423
24namespace gpu {
25namespace gles2 {
26
gman@chromium.org31494b82013-02-28 10:10:2627class Buffer;
sievers@chromium.orgb3cbad12012-12-05 19:56:3628class FeatureInfo;
zmo48ee6d3f2016-05-06 20:33:2629class IndexedBufferBindingHost;
gman@chromium.org31494b82013-02-28 10:10:2630class Program;
31class Renderbuffer;
zmo6c468ba2016-05-04 20:00:5132class TransformFeedback;
sievers@chromium.orgb3cbad12012-12-05 19:56:3633
gman@chromium.orge259eb412012-10-13 05:47:2434// State associated with each texture unit.
Antoine Labour83a0aed12018-01-10 04:52:3835struct GPU_GLES2_EXPORT TextureUnit {
gman@chromium.orge259eb412012-10-13 05:47:2436 TextureUnit();
vmpstr3b7b8b22016-03-01 23:00:2037 TextureUnit(const TextureUnit& other);
gman@chromium.orge259eb412012-10-13 05:47:2438 ~TextureUnit();
39
40 // The last target that was bound to this texture unit.
41 GLenum bind_target;
42
43 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture
piman@chromium.org370eaf12013-05-18 09:19:4944 scoped_refptr<TextureRef> bound_texture_2d;
gman@chromium.orge259eb412012-10-13 05:47:2445
46 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with
47 // glBindTexture
piman@chromium.org370eaf12013-05-18 09:19:4948 scoped_refptr<TextureRef> bound_texture_cube_map;
gman@chromium.orge259eb412012-10-13 05:47:2449
50 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with
51 // glBindTexture
piman@chromium.org370eaf12013-05-18 09:19:4952 scoped_refptr<TextureRef> bound_texture_external_oes;
gman@chromium.orge259eb412012-10-13 05:47:2453
54 // texture currently bound to this unit's GL_TEXTURE_RECTANGLE_ARB with
55 // glBindTexture
piman@chromium.org370eaf12013-05-18 09:19:4956 scoped_refptr<TextureRef> bound_texture_rectangle_arb;
gman@chromium.orge259eb412012-10-13 05:47:2457
zmoea06a6f2015-04-30 01:15:4658 // texture currently bound to this unit's GL_TEXTURE_3D with glBindTexture
59 scoped_refptr<TextureRef> bound_texture_3d;
60
61 // texture currently bound to this unit's GL_TEXTURE_2D_ARRAY with
62 // glBindTexture
63 scoped_refptr<TextureRef> bound_texture_2d_array;
64
Peng Huangc6a76072018-11-27 23:17:3165 bool AnyTargetBound() const {
66 return bound_texture_2d || bound_texture_cube_map ||
67 bound_texture_external_oes || bound_texture_rectangle_arb ||
68 bound_texture_3d || bound_texture_2d_array;
69 }
70
zmoebb409812017-02-08 19:13:5871 TextureRef* GetInfoForSamplerType(GLenum type) {
gman@chromium.orge259eb412012-10-13 05:47:2472 switch (type) {
73 case GL_SAMPLER_2D:
zmo5e6600b2016-11-17 04:27:4474 case GL_SAMPLER_2D_SHADOW:
75 case GL_INT_SAMPLER_2D:
76 case GL_UNSIGNED_INT_SAMPLER_2D:
zmoebb409812017-02-08 19:13:5877 return bound_texture_2d.get();
gman@chromium.orge259eb412012-10-13 05:47:2478 case GL_SAMPLER_CUBE:
zmo5e6600b2016-11-17 04:27:4479 case GL_SAMPLER_CUBE_SHADOW:
80 case GL_INT_SAMPLER_CUBE:
81 case GL_UNSIGNED_INT_SAMPLER_CUBE:
zmoebb409812017-02-08 19:13:5882 return bound_texture_cube_map.get();
gman@chromium.orge259eb412012-10-13 05:47:2483 case GL_SAMPLER_EXTERNAL_OES:
zmoebb409812017-02-08 19:13:5884 return bound_texture_external_oes.get();
gman@chromium.orge259eb412012-10-13 05:47:2485 case GL_SAMPLER_2D_RECT_ARB:
zmoebb409812017-02-08 19:13:5886 return bound_texture_rectangle_arb.get();
zmoea06a6f2015-04-30 01:15:4687 case GL_SAMPLER_3D:
zmo5e6600b2016-11-17 04:27:4488 case GL_INT_SAMPLER_3D:
89 case GL_UNSIGNED_INT_SAMPLER_3D:
zmoebb409812017-02-08 19:13:5890 return bound_texture_3d.get();
zmoea06a6f2015-04-30 01:15:4691 case GL_SAMPLER_2D_ARRAY:
zmo5e6600b2016-11-17 04:27:4492 case GL_SAMPLER_2D_ARRAY_SHADOW:
93 case GL_INT_SAMPLER_2D_ARRAY:
94 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
zmoebb409812017-02-08 19:13:5895 return bound_texture_2d_array.get();
96 default:
97 NOTREACHED();
98 return nullptr;
gman@chromium.orge259eb412012-10-13 05:47:2499 }
gman@chromium.orge259eb412012-10-13 05:47:24100 }
erikchenffe273b2015-12-17 03:48:13101
zmoebb409812017-02-08 19:13:58102 TextureRef* GetInfoForTarget(GLenum target) {
erikchenffe273b2015-12-17 03:48:13103 switch (target) {
104 case GL_TEXTURE_2D:
zmoebb409812017-02-08 19:13:58105 return bound_texture_2d.get();
erikchenffe273b2015-12-17 03:48:13106 case GL_TEXTURE_CUBE_MAP:
zmoebb409812017-02-08 19:13:58107 return bound_texture_cube_map.get();
erikchenffe273b2015-12-17 03:48:13108 case GL_TEXTURE_EXTERNAL_OES:
zmoebb409812017-02-08 19:13:58109 return bound_texture_external_oes.get();
erikchenffe273b2015-12-17 03:48:13110 case GL_TEXTURE_RECTANGLE_ARB:
zmoebb409812017-02-08 19:13:58111 return bound_texture_rectangle_arb.get();
erikchenffe273b2015-12-17 03:48:13112 case GL_TEXTURE_3D:
zmoebb409812017-02-08 19:13:58113 return bound_texture_3d.get();
erikchenffe273b2015-12-17 03:48:13114 case GL_TEXTURE_2D_ARRAY:
zmoebb409812017-02-08 19:13:58115 return bound_texture_2d_array.get();
116 default:
117 NOTREACHED();
118 return nullptr;
erikchenffe273b2015-12-17 03:48:13119 }
zmoebb409812017-02-08 19:13:58120 }
erikchenffe273b2015-12-17 03:48:13121
zmoebb409812017-02-08 19:13:58122 void SetInfoForTarget(GLenum target, TextureRef* texture_ref) {
123 switch (target) {
124 case GL_TEXTURE_2D:
125 bound_texture_2d = texture_ref;
126 break;
127 case GL_TEXTURE_CUBE_MAP:
128 bound_texture_cube_map = texture_ref;
129 break;
130 case GL_TEXTURE_EXTERNAL_OES:
131 bound_texture_external_oes = texture_ref;
132 break;
133 case GL_TEXTURE_RECTANGLE_ARB:
134 bound_texture_rectangle_arb = texture_ref;
135 break;
136 case GL_TEXTURE_3D:
137 bound_texture_3d = texture_ref;
138 break;
139 case GL_TEXTURE_2D_ARRAY:
140 bound_texture_2d_array = texture_ref;
141 break;
142 default:
143 NOTREACHED();
144 }
erikchenffe273b2015-12-17 03:48:13145 }
gman@chromium.orge259eb412012-10-13 05:47:24146};
147
Antoine Labour83a0aed12018-01-10 04:52:38148class GPU_GLES2_EXPORT Vec4 {
zmo5ee097e2015-05-14 19:13:52149 public:
gman@chromium.orgaf6380962012-11-29 23:24:13150 Vec4() {
zmo5ee097e2015-05-14 19:13:52151 v_[0].float_value = 0.0f;
152 v_[1].float_value = 0.0f;
153 v_[2].float_value = 0.0f;
154 v_[3].float_value = 1.0f;
zmoeaae3bb2016-07-15 19:23:19155 type_ = SHADER_VARIABLE_FLOAT;
gman@chromium.orgaf6380962012-11-29 23:24:13156 }
zmo5ee097e2015-05-14 19:13:52157
158 template <typename T>
159 void GetValues(T* values) const;
160
161 template <typename T>
162 void SetValues(const T* values);
163
Peng Huangc6a76072018-11-27 23:17:31164 ShaderVariableBaseType type() const { return type_; }
zmo5ee097e2015-05-14 19:13:52165
166 bool Equal(const Vec4& other) const;
167
168 private:
169 union ValueUnion {
170 GLfloat float_value;
171 GLint int_value;
172 GLuint uint_value;
173 };
174
175 ValueUnion v_[4];
zmoeaae3bb2016-07-15 19:23:19176 ShaderVariableBaseType type_;
gman@chromium.orgaf6380962012-11-29 23:24:13177};
gman@chromium.orge259eb412012-10-13 05:47:24178
zmo5ee097e2015-05-14 19:13:52179template <>
Antoine Labour83a0aed12018-01-10 04:52:38180GPU_GLES2_EXPORT void Vec4::GetValues<GLfloat>(GLfloat* values) const;
zmo5ee097e2015-05-14 19:13:52181template <>
Antoine Labour83a0aed12018-01-10 04:52:38182GPU_GLES2_EXPORT void Vec4::GetValues<GLint>(GLint* values) const;
zmo5ee097e2015-05-14 19:13:52183template <>
Antoine Labour83a0aed12018-01-10 04:52:38184GPU_GLES2_EXPORT void Vec4::GetValues<GLuint>(GLuint* values) const;
zmo5ee097e2015-05-14 19:13:52185
186template <>
Antoine Labour83a0aed12018-01-10 04:52:38187GPU_GLES2_EXPORT void Vec4::SetValues<GLfloat>(const GLfloat* values);
zmo5ee097e2015-05-14 19:13:52188template <>
Antoine Labour83a0aed12018-01-10 04:52:38189GPU_GLES2_EXPORT void Vec4::SetValues<GLint>(const GLint* values);
zmo5ee097e2015-05-14 19:13:52190template <>
Antoine Labour83a0aed12018-01-10 04:52:38191GPU_GLES2_EXPORT void Vec4::SetValues<GLuint>(const GLuint* values);
zmo5ee097e2015-05-14 19:13:52192
Antoine Labour83a0aed12018-01-10 04:52:38193struct GPU_GLES2_EXPORT ContextState {
Peng Huangc6a76072018-11-27 23:17:31194 enum Dimension { k2D, k3D };
zmo2b9c47392015-12-11 02:21:32195
danakj@chromium.org828a3932014-04-02 14:43:13196 ContextState(FeatureInfo* feature_info,
Peng Huangc6a76072018-11-27 23:17:31197 bool track_texture_and_sampler_units = true);
gman@chromium.orge259eb412012-10-13 05:47:24198 ~ContextState();
199
Antoine Labour2c1ad962017-10-24 23:32:56200 void set_api(gl::GLApi* api) { api_ = api; }
201 gl::GLApi* api() const { return api_; }
202
gman@chromium.orgf731b9462012-10-30 00:35:22203 void Initialize();
204
Zhenyao Mo60fe7722018-03-23 16:26:45205 void MarkContextLost() { context_lost_ = true; }
206
lof84d5e36962016-11-10 00:35:54207 void SetLineWidthBounds(GLfloat min, GLfloat max);
208
vmiura@chromium.org454157e2014-05-03 02:49:45209 void SetIgnoreCachedStateForTest(bool ignore) {
210 ignore_cached_state = ignore;
211 }
212
vmiura@chromium.org8875a5f2014-06-27 08:33:47213 void RestoreState(const ContextState* prev_state);
vmiura@chromium.org88ba52f2014-04-09 12:39:34214 void InitCapabilities(const ContextState* prev_state) const;
215 void InitState(const ContextState* prev_state) const;
gman@chromium.orgf731b9462012-10-30 00:35:22216
gman@chromium.org29a4d902013-02-26 20:18:06217 void RestoreActiveTexture() const;
kbr69c721ec2017-04-26 23:58:51218 void RestoreAllTextureUnitAndSamplerBindings(
219 const ContextState* prev_state) const;
epenner@chromium.org4b2d2b262014-03-21 22:05:27220 void RestoreActiveTextureUnitBinding(unsigned int target) const;
vmiura@chromium.org81f20a622014-04-18 01:54:52221 void RestoreVertexAttribValues() const;
222 void RestoreVertexAttribArrays(
223 const scoped_refptr<VertexAttribManager> attrib_manager) const;
Zhenyao Mo22a5f662018-04-17 00:33:55224 void RestoreVertexAttribs(const ContextState* prev_state) const;
gman@chromium.org29a4d902013-02-26 20:18:06225 void RestoreBufferBindings() const;
vmiura@chromium.org88ba52f2014-04-09 12:39:34226 void RestoreGlobalState(const ContextState* prev_state) const;
zmo744d40e2016-05-10 20:56:22227 void RestoreProgramSettings(const ContextState* prev_state,
228 bool restore_transform_feedback_bindings) const;
vmiura@chromium.org8875a5f2014-06-27 08:33:47229 void RestoreRenderbufferBindings();
zmo48ee6d3f2016-05-06 20:33:26230 void RestoreIndexedUniformBufferBindings(const ContextState* prev_state);
Peng Huangc6a76072018-11-27 23:17:31231 void RestoreTextureUnitBindings(GLuint unit,
232 const ContextState* prev_state) const;
kbr69c721ec2017-04-26 23:58:51233 void RestoreSamplerBinding(GLuint unit, const ContextState* prev_state) const;
gman@chromium.org29a4d902013-02-26 20:18:06234
Zhenyao Mo5f72df0c2017-12-08 21:46:26235 void PushTextureUnpackState() const;
geofflang398fb212016-07-13 16:27:42236 void RestoreUnpackState() const;
lof84d5e36962016-11-10 00:35:54237 void DoLineWidth(GLfloat width) const;
geofflang398fb212016-07-13 16:27:42238
gman@chromium.orgd058bca2012-11-26 10:27:26239 // Helper for getting cached state.
Peng Huangc6a76072018-11-27 23:17:31240 bool GetStateAsGLint(GLenum pname, GLint* params, GLsizei* num_written) const;
241 bool GetStateAsGLfloat(GLenum pname,
242 GLfloat* params,
243 GLsizei* num_written) const;
gman@chromium.orgd058bca2012-11-26 10:27:26244 bool GetEnabled(GLenum cap) const;
245
vmiura@chromium.org454157e2014-05-03 02:49:45246 inline void SetDeviceColorMask(GLboolean red,
247 GLboolean green,
248 GLboolean blue,
249 GLboolean alpha) {
250 if (cached_color_mask_red == red && cached_color_mask_green == green &&
251 cached_color_mask_blue == blue && cached_color_mask_alpha == alpha &&
252 !ignore_cached_state)
253 return;
254 cached_color_mask_red = red;
255 cached_color_mask_green = green;
256 cached_color_mask_blue = blue;
257 cached_color_mask_alpha = alpha;
Antoine Labour2c1ad962017-10-24 23:32:56258 api()->glColorMaskFn(red, green, blue, alpha);
vmiura@chromium.org454157e2014-05-03 02:49:45259 }
260
261 inline void SetDeviceDepthMask(GLboolean mask) {
262 if (cached_depth_mask == mask && !ignore_cached_state)
263 return;
264 cached_depth_mask = mask;
Antoine Labour2c1ad962017-10-24 23:32:56265 api()->glDepthMaskFn(mask);
vmiura@chromium.org454157e2014-05-03 02:49:45266 }
267
268 inline void SetDeviceStencilMaskSeparate(GLenum op, GLuint mask) {
269 if (op == GL_FRONT) {
270 if (cached_stencil_front_writemask == mask && !ignore_cached_state)
271 return;
272 cached_stencil_front_writemask = mask;
273 } else if (op == GL_BACK) {
274 if (cached_stencil_back_writemask == mask && !ignore_cached_state)
275 return;
276 cached_stencil_back_writemask = mask;
277 } else {
278 NOTREACHED();
279 return;
280 }
Antoine Labour2c1ad962017-10-24 23:32:56281 api()->glStencilMaskSeparateFn(op, mask);
vmiura@chromium.org454157e2014-05-03 02:49:45282 }
283
zmo4c0c3532015-05-22 20:04:48284 void SetBoundBuffer(GLenum target, Buffer* buffer);
285 void RemoveBoundBuffer(Buffer* buffer);
286
zmo773ceaef52016-07-26 05:09:57287 void InitGenericAttribs(GLuint max_vertex_attribs) {
288 attrib_values.resize(max_vertex_attribs);
yunchao.hec4875312016-07-22 16:11:07289
zmo773ceaef52016-07-26 05:09:57290 uint32_t packed_size = max_vertex_attribs / 16;
291 packed_size += (max_vertex_attribs % 16 == 0) ? 0 : 1;
292 generic_attrib_base_type_mask_.resize(packed_size);
293 for (uint32_t i = 0; i < packed_size; ++i) {
294 // All generic attribs are float type by default.
295 generic_attrib_base_type_mask_[i] = 0x55555555u * SHADER_VARIABLE_FLOAT;
296 }
yunchao.hec4875312016-07-22 16:11:07297 }
298
299 void SetGenericVertexAttribBaseType(GLuint index, GLenum base_type) {
zmo773ceaef52016-07-26 05:09:57300 DCHECK_LT(index, attrib_values.size());
yunchao.hec4875312016-07-22 16:11:07301 int shift_bits = (index % 16) * 2;
302 generic_attrib_base_type_mask_[index / 16] &= ~(0x3 << shift_bits);
303 generic_attrib_base_type_mask_[index / 16] |= (base_type << shift_bits);
304 }
305
zmo773ceaef52016-07-26 05:09:57306 const std::vector<uint32_t>& generic_attrib_base_type_mask() const {
307 return generic_attrib_base_type_mask_;
yunchao.hec4875312016-07-22 16:11:07308 }
309
bajones2b98b2a2015-09-15 02:27:36310 void UnbindTexture(TextureRef* texture);
bajones5141d032015-12-07 21:13:39311 void UnbindSampler(Sampler* sampler);
bajones2b98b2a2015-09-15 02:27:36312
zmo2b9c47392015-12-11 02:21:32313 PixelStoreParams GetPackParams();
314 PixelStoreParams GetUnpackParams(Dimension dimension);
315
c.padhib0a7f412017-04-06 06:56:10316 // If a buffer object is bound to PIXEL_PACK_BUFFER, set all pack parameters
317 // user values; otherwise, set them to 0.
318 void UpdatePackParameters() const;
319 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack
320 // parameters user values; otherwise, set them to 0.
321 void UpdateUnpackParameters() const;
322
Kai Ninomiyabcbefdab2017-11-03 19:57:27323 void SetMaxWindowRectangles(size_t max);
324 size_t GetMaxWindowRectangles() const;
325 void SetWindowRectangles(GLenum mode,
326 size_t count,
327 const volatile GLint* box);
328 template <typename T>
329 void GetWindowRectangle(GLuint index, T* box) {
330 for (size_t i = 0; i < 4; ++i) {
331 box[i] = window_rectangles_[4 * index + i];
332 }
333 }
334 void UpdateWindowRectangles() const;
335 void UpdateWindowRectanglesForBoundDrawFramebufferClientID(GLuint client_id);
336
zmo0ed71922016-06-23 01:18:42337 void EnableDisableFramebufferSRGB(bool enable);
338
Peng Huangc6a76072018-11-27 23:17:31339#include "gpu/command_buffer/service/context_state_autogen.h"
340
341 // if false, we will not track individual texture and sampler units, instead
342 // we only track if all units are in ground state or not.
343 const bool track_texture_and_sampler_units;
gman@chromium.orgf731b9462012-10-30 00:35:22344
345 EnableFlags enable_flags;
346
gman@chromium.orge259eb412012-10-13 05:47:24347 // Current active texture by 0 - n index.
348 // In other words, if we call glActiveTexture(GL_TEXTURE2) this value would
349 // be 2.
Peng Huangc6a76072018-11-27 23:17:31350 GLuint active_texture_unit = 0u;
gman@chromium.orge259eb412012-10-13 05:47:24351
gman@chromium.orge259eb412012-10-13 05:47:24352 // The currently bound array buffer. If this is 0 it is illegal to call
353 // glVertexAttribPointer.
gman@chromium.org16ccec12013-02-28 03:40:21354 scoped_refptr<Buffer> bound_array_buffer;
gman@chromium.orge259eb412012-10-13 05:47:24355
zmo4c0c3532015-05-22 20:04:48356 scoped_refptr<Buffer> bound_copy_read_buffer;
357 scoped_refptr<Buffer> bound_copy_write_buffer;
358 scoped_refptr<Buffer> bound_pixel_pack_buffer;
359 scoped_refptr<Buffer> bound_pixel_unpack_buffer;
360 scoped_refptr<Buffer> bound_transform_feedback_buffer;
361 scoped_refptr<Buffer> bound_uniform_buffer;
362
gman@chromium.orge259eb412012-10-13 05:47:24363 // Which textures are bound to texture units through glActiveTexture.
gman@chromium.org1868a342012-11-07 15:56:02364 std::vector<TextureUnit> texture_units;
Peng Huangc6a76072018-11-27 23:17:31365 mutable bool texture_units_in_ground_state = true;
gman@chromium.orge259eb412012-10-13 05:47:24366
bajones5141d032015-12-07 21:13:39367 // Which samplers are bound to each texture unit;
368 std::vector<scoped_refptr<Sampler>> sampler_units;
369
zmo6c468ba2016-05-04 20:00:51370 // We create a transform feedback as the default one per ES3 enabled context
371 // instead of using GL's default one to make context switching easier.
372 // For other context, we will never change the default transform feedback's
373 // states, so we can just use the GL's default one.
374 scoped_refptr<TransformFeedback> default_transform_feedback;
375
376 scoped_refptr<TransformFeedback> bound_transform_feedback;
377
zmo48ee6d3f2016-05-06 20:33:26378 scoped_refptr<IndexedBufferBindingHost> indexed_uniform_buffer_bindings;
379
gman@chromium.orgaf6380962012-11-29 23:24:13380 // The values for each attrib.
381 std::vector<Vec4> attrib_values;
382
gman@chromium.orge259eb412012-10-13 05:47:24383 // Class that manages vertex attribs.
gman@chromium.orged9f9cd2013-02-27 21:12:35384 scoped_refptr<VertexAttribManager> vertex_attrib_manager;
vmiura@chromium.org81f20a622014-04-18 01:54:52385 scoped_refptr<VertexAttribManager> default_vertex_attrib_manager;
gman@chromium.orge259eb412012-10-13 05:47:24386
387 // The program in use by glUseProgram
gman@chromium.orged9f9cd2013-02-27 21:12:35388 scoped_refptr<Program> current_program;
gman@chromium.orge259eb412012-10-13 05:47:24389
gman@chromium.orge259eb412012-10-13 05:47:24390 // The currently bound renderbuffer
gman@chromium.orged9f9cd2013-02-27 21:12:35391 scoped_refptr<Renderbuffer> bound_renderbuffer;
Peng Huangc6a76072018-11-27 23:17:31392 bool bound_renderbuffer_valid = false;
gman@chromium.orge259eb412012-10-13 05:47:24393
Peng Huangc6a76072018-11-27 23:17:31394 bool pack_reverse_row_order = false;
395 bool ignore_cached_state = false;
sievers@chromium.orgb3cbad12012-12-05 19:56:36396
Peng Huangc6a76072018-11-27 23:17:31397 mutable bool fbo_binding_for_scissor_workaround_dirty = false;
Kai Ninomiyaf1c92daa2018-04-16 20:54:33398 mutable bool stencil_state_changed_since_validation = true;
kloveless@chromium.orgd3eba342013-04-18 21:11:50399
Kai Ninomiyabcbefdab2017-11-03 19:57:27400 GLuint current_draw_framebuffer_client_id = 0;
401
kloveless@chromium.orgd3eba342013-04-18 21:11:50402 private:
zmo8ac3bab2015-04-18 02:30:58403 void EnableDisable(GLenum pname, bool enable) const;
404
zmob730f32b2016-01-06 20:39:08405 void InitStateManual(const ContextState* prev_state) const;
406
ccameronddaa56a2016-12-02 04:05:46407 // EnableDisableFramebufferSRGB is called at very high frequency. Cache the
408 // true value of FRAMEBUFFER_SRGB, if we know it, to elide some of these
409 // calls.
410 bool framebuffer_srgb_valid_ = false;
411 bool framebuffer_srgb_ = false;
zmo0ed71922016-06-23 01:18:42412
yunchao.hec4875312016-07-22 16:11:07413 // Generic vertex attrib base types: FLOAT, INT, or UINT.
414 // Each base type is encoded into 2 bits, the lowest 2 bits for location 0,
zmo773ceaef52016-07-26 05:09:57415 // the highest 2 bits for location (max_vertex_attribs - 1).
yunchao.hec4875312016-07-22 16:11:07416 std::vector<uint32_t> generic_attrib_base_type_mask_;
417
lof84d5e36962016-11-10 00:35:54418 GLfloat line_width_min_ = 0.0f;
419 GLfloat line_width_max_ = 1.0f;
420
Kai Ninomiyabcbefdab2017-11-03 19:57:27421 // Stores the list of N window rectangles as N*4 GLints, like
422 // vector<[x,y,w,h]>. Always has space for MAX_WINDOW_RECTANGLES rectangles.
423 std::vector<GLint> window_rectangles_;
424
Keishi Hattori0e45c022021-11-27 09:25:52425 raw_ptr<gl::GLApi> api_ = nullptr;
426 raw_ptr<FeatureInfo> feature_info_;
Zhenyao Mo60fe7722018-03-23 16:26:45427
428 bool context_lost_ = false;
gman@chromium.orge259eb412012-10-13 05:47:24429};
430
431} // namespace gles2
432} // namespace gpu
433
434#endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_