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
3 // found in the LICENSE file.
5 // This file is auto-generated from
6 // gpu/command_buffer/build_gles2_cmd_buffer.py
9 // It is included by context_state.cc
10 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_
11 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_
13 ContextState::EnableFlags::EnableFlags()
18 polygon_offset_fill(false),
19 sample_alpha_to_coverage(false),
20 sample_coverage(false),
25 void ContextState::Initialize() {
26 blend_color_red = 0.0f;
27 blend_color_green = 0.0f;
28 blend_color_blue = 0.0f;
29 blend_color_alpha = 0.0f;
30 blend_equation_rgb = GL_FUNC_ADD;
31 blend_equation_alpha = GL_FUNC_ADD;
32 blend_source_rgb = GL_ONE;
33 blend_dest_rgb = GL_ZERO;
34 blend_source_alpha = GL_ONE;
35 blend_dest_alpha = GL_ZERO;
36 color_clear_red = 0.0f;
37 color_clear_green = 0.0f;
38 color_clear_blue = 0.0f;
39 color_clear_alpha = 0.0f;
42 color_mask_red = true;
43 color_mask_green = true;
44 color_mask_blue = true;
45 color_mask_alpha = true;
52 hint_generate_mipmap = GL_DONT_CARE;
53 hint_fragment_shader_derivative = GL_DONT_CARE;
57 polygon_offset_factor = 0.0f;
58 polygon_offset_units = 0.0f;
59 sample_coverage_value = 1.0f;
60 sample_coverage_invert = false;
65 stencil_front_func = GL_ALWAYS;
66 stencil_front_ref = 0;
67 stencil_front_mask = 0xFFFFFFFFU;
68 stencil_back_func = GL_ALWAYS;
70 stencil_back_mask = 0xFFFFFFFFU;
71 stencil_front_writemask = 0xFFFFFFFFU;
72 stencil_back_writemask = 0xFFFFFFFFU;
73 stencil_front_fail_op = GL_KEEP;
74 stencil_front_z_fail_op = GL_KEEP;
75 stencil_front_z_pass_op = GL_KEEP;
76 stencil_back_fail_op = GL_KEEP;
77 stencil_back_z_fail_op = GL_KEEP;
78 stencil_back_z_pass_op = GL_KEEP;
85 void ContextState::InitCapabilities() const {
86 EnableDisable(GL_BLEND, enable_flags.blend);
87 EnableDisable(GL_CULL_FACE, enable_flags.cull_face);
88 EnableDisable(GL_DEPTH_TEST, enable_flags.depth_test);
89 EnableDisable(GL_DITHER, enable_flags.dither);
90 EnableDisable(GL_POLYGON_OFFSET_FILL, enable_flags.polygon_offset_fill);
92 GL_SAMPLE_ALPHA_TO_COVERAGE, enable_flags.sample_alpha_to_coverage);
93 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.sample_coverage);
94 EnableDisable(GL_SCISSOR_TEST, enable_flags.scissor_test);
95 EnableDisable(GL_STENCIL_TEST, enable_flags.stencil_test);
98 void ContextState::InitState() const {
100 blend_color_red, blend_color_green, blend_color_blue, blend_color_alpha);
101 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
103 blend_source_rgb, blend_dest_rgb, blend_source_alpha, blend_dest_alpha);
105 color_clear_red, color_clear_green, color_clear_blue, color_clear_alpha);
106 glClearDepth(depth_clear);
107 glClearStencil(stencil_clear);
109 color_mask_red, color_mask_green, color_mask_blue, color_mask_alpha);
110 glCullFace(cull_mode);
111 glDepthFunc(depth_func);
112 glDepthMask(depth_mask);
113 glDepthRange(z_near, z_far);
114 glFrontFace(front_face);
115 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
116 if (feature_info_->feature_flags().oes_standard_derivatives)
118 GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES, hint_fragment_shader_derivative);
119 glLineWidth(line_width);
120 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
121 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
122 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
123 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
124 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
125 glStencilFuncSeparate(
126 GL_FRONT, stencil_front_func, stencil_front_ref, stencil_front_mask);
127 glStencilFuncSeparate(
128 GL_BACK, stencil_back_func, stencil_back_ref, stencil_back_mask);
129 glStencilMaskSeparate(GL_FRONT, stencil_front_writemask);
130 glStencilMaskSeparate(GL_BACK, stencil_back_writemask);
132 GL_FRONT, stencil_front_fail_op, stencil_front_z_fail_op,
133 stencil_front_z_pass_op);
135 GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
136 stencil_back_z_pass_op);
137 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
139 bool ContextState::GetEnabled(GLenum cap) const {
142 return enable_flags.blend;
144 return enable_flags.cull_face;
146 return enable_flags.depth_test;
148 return enable_flags.dither;
149 case GL_POLYGON_OFFSET_FILL:
150 return enable_flags.polygon_offset_fill;
151 case GL_SAMPLE_ALPHA_TO_COVERAGE:
152 return enable_flags.sample_alpha_to_coverage;
153 case GL_SAMPLE_COVERAGE:
154 return enable_flags.sample_coverage;
155 case GL_SCISSOR_TEST:
156 return enable_flags.scissor_test;
157 case GL_STENCIL_TEST:
158 return enable_flags.stencil_test;
165 bool ContextState::GetStateAsGLint(
166 GLenum pname, GLint* params, GLsizei* num_written) const {
171 params[0] = static_cast<GLint>(blend_color_red);
172 params[1] = static_cast<GLint>(blend_color_green);
173 params[2] = static_cast<GLint>(blend_color_blue);
174 params[3] = static_cast<GLint>(blend_color_alpha);
177 case GL_BLEND_EQUATION_RGB:
180 params[0] = static_cast<GLint>(blend_equation_rgb);
183 case GL_BLEND_EQUATION_ALPHA:
186 params[0] = static_cast<GLint>(blend_equation_alpha);
189 case GL_BLEND_SRC_RGB:
192 params[0] = static_cast<GLint>(blend_source_rgb);
195 case GL_BLEND_DST_RGB:
198 params[0] = static_cast<GLint>(blend_dest_rgb);
201 case GL_BLEND_SRC_ALPHA:
204 params[0] = static_cast<GLint>(blend_source_alpha);
207 case GL_BLEND_DST_ALPHA:
210 params[0] = static_cast<GLint>(blend_dest_alpha);
213 case GL_COLOR_CLEAR_VALUE:
216 params[0] = static_cast<GLint>(color_clear_red);
217 params[1] = static_cast<GLint>(color_clear_green);
218 params[2] = static_cast<GLint>(color_clear_blue);
219 params[3] = static_cast<GLint>(color_clear_alpha);
222 case GL_DEPTH_CLEAR_VALUE:
225 params[0] = static_cast<GLint>(depth_clear);
228 case GL_STENCIL_CLEAR_VALUE:
231 params[0] = static_cast<GLint>(stencil_clear);
234 case GL_COLOR_WRITEMASK:
237 params[0] = static_cast<GLint>(color_mask_red);
238 params[1] = static_cast<GLint>(color_mask_green);
239 params[2] = static_cast<GLint>(color_mask_blue);
240 params[3] = static_cast<GLint>(color_mask_alpha);
243 case GL_CULL_FACE_MODE:
246 params[0] = static_cast<GLint>(cull_mode);
252 params[0] = static_cast<GLint>(depth_func);
255 case GL_DEPTH_WRITEMASK:
258 params[0] = static_cast<GLint>(depth_mask);
264 params[0] = static_cast<GLint>(z_near);
265 params[1] = static_cast<GLint>(z_far);
271 params[0] = static_cast<GLint>(front_face);
274 case GL_GENERATE_MIPMAP_HINT:
277 params[0] = static_cast<GLint>(hint_generate_mipmap);
280 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
283 params[0] = static_cast<GLint>(hint_fragment_shader_derivative);
289 params[0] = static_cast<GLint>(line_width);
292 case GL_PACK_ALIGNMENT:
295 params[0] = static_cast<GLint>(pack_alignment);
298 case GL_UNPACK_ALIGNMENT:
301 params[0] = static_cast<GLint>(unpack_alignment);
304 case GL_POLYGON_OFFSET_FACTOR:
307 params[0] = static_cast<GLint>(polygon_offset_factor);
310 case GL_POLYGON_OFFSET_UNITS:
313 params[0] = static_cast<GLint>(polygon_offset_units);
316 case GL_SAMPLE_COVERAGE_VALUE:
319 params[0] = static_cast<GLint>(sample_coverage_value);
322 case GL_SAMPLE_COVERAGE_INVERT:
325 params[0] = static_cast<GLint>(sample_coverage_invert);
331 params[0] = static_cast<GLint>(scissor_x);
332 params[1] = static_cast<GLint>(scissor_y);
333 params[2] = static_cast<GLint>(scissor_width);
334 params[3] = static_cast<GLint>(scissor_height);
337 case GL_STENCIL_FUNC:
340 params[0] = static_cast<GLint>(stencil_front_func);
346 params[0] = static_cast<GLint>(stencil_front_ref);
349 case GL_STENCIL_VALUE_MASK:
352 params[0] = static_cast<GLint>(stencil_front_mask);
355 case GL_STENCIL_BACK_FUNC:
358 params[0] = static_cast<GLint>(stencil_back_func);
361 case GL_STENCIL_BACK_REF:
364 params[0] = static_cast<GLint>(stencil_back_ref);
367 case GL_STENCIL_BACK_VALUE_MASK:
370 params[0] = static_cast<GLint>(stencil_back_mask);
373 case GL_STENCIL_WRITEMASK:
376 params[0] = static_cast<GLint>(stencil_front_writemask);
379 case GL_STENCIL_BACK_WRITEMASK:
382 params[0] = static_cast<GLint>(stencil_back_writemask);
385 case GL_STENCIL_FAIL:
388 params[0] = static_cast<GLint>(stencil_front_fail_op);
391 case GL_STENCIL_PASS_DEPTH_FAIL:
394 params[0] = static_cast<GLint>(stencil_front_z_fail_op);
397 case GL_STENCIL_PASS_DEPTH_PASS:
400 params[0] = static_cast<GLint>(stencil_front_z_pass_op);
403 case GL_STENCIL_BACK_FAIL:
406 params[0] = static_cast<GLint>(stencil_back_fail_op);
409 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
412 params[0] = static_cast<GLint>(stencil_back_z_fail_op);
415 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
418 params[0] = static_cast<GLint>(stencil_back_z_pass_op);
424 params[0] = static_cast<GLint>(viewport_x);
425 params[1] = static_cast<GLint>(viewport_y);
426 params[2] = static_cast<GLint>(viewport_width);
427 params[3] = static_cast<GLint>(viewport_height);
433 params[0] = static_cast<GLint>(enable_flags.blend);
439 params[0] = static_cast<GLint>(enable_flags.cull_face);
445 params[0] = static_cast<GLint>(enable_flags.depth_test);
451 params[0] = static_cast<GLint>(enable_flags.dither);
454 case GL_POLYGON_OFFSET_FILL:
457 params[0] = static_cast<GLint>(enable_flags.polygon_offset_fill);
460 case GL_SAMPLE_ALPHA_TO_COVERAGE:
463 params[0] = static_cast<GLint>(enable_flags.sample_alpha_to_coverage);
466 case GL_SAMPLE_COVERAGE:
469 params[0] = static_cast<GLint>(enable_flags.sample_coverage);
472 case GL_SCISSOR_TEST:
475 params[0] = static_cast<GLint>(enable_flags.scissor_test);
478 case GL_STENCIL_TEST:
481 params[0] = static_cast<GLint>(enable_flags.stencil_test);
489 bool ContextState::GetStateAsGLfloat(
490 GLenum pname, GLfloat* params, GLsizei* num_written) const {
495 params[0] = static_cast<GLfloat>(blend_color_red);
496 params[1] = static_cast<GLfloat>(blend_color_green);
497 params[2] = static_cast<GLfloat>(blend_color_blue);
498 params[3] = static_cast<GLfloat>(blend_color_alpha);
501 case GL_BLEND_EQUATION_RGB:
504 params[0] = static_cast<GLfloat>(blend_equation_rgb);
507 case GL_BLEND_EQUATION_ALPHA:
510 params[0] = static_cast<GLfloat>(blend_equation_alpha);
513 case GL_BLEND_SRC_RGB:
516 params[0] = static_cast<GLfloat>(blend_source_rgb);
519 case GL_BLEND_DST_RGB:
522 params[0] = static_cast<GLfloat>(blend_dest_rgb);
525 case GL_BLEND_SRC_ALPHA:
528 params[0] = static_cast<GLfloat>(blend_source_alpha);
531 case GL_BLEND_DST_ALPHA:
534 params[0] = static_cast<GLfloat>(blend_dest_alpha);
537 case GL_COLOR_CLEAR_VALUE:
540 params[0] = static_cast<GLfloat>(color_clear_red);
541 params[1] = static_cast<GLfloat>(color_clear_green);
542 params[2] = static_cast<GLfloat>(color_clear_blue);
543 params[3] = static_cast<GLfloat>(color_clear_alpha);
546 case GL_DEPTH_CLEAR_VALUE:
549 params[0] = static_cast<GLfloat>(depth_clear);
552 case GL_STENCIL_CLEAR_VALUE:
555 params[0] = static_cast<GLfloat>(stencil_clear);
558 case GL_COLOR_WRITEMASK:
561 params[0] = static_cast<GLfloat>(color_mask_red);
562 params[1] = static_cast<GLfloat>(color_mask_green);
563 params[2] = static_cast<GLfloat>(color_mask_blue);
564 params[3] = static_cast<GLfloat>(color_mask_alpha);
567 case GL_CULL_FACE_MODE:
570 params[0] = static_cast<GLfloat>(cull_mode);
576 params[0] = static_cast<GLfloat>(depth_func);
579 case GL_DEPTH_WRITEMASK:
582 params[0] = static_cast<GLfloat>(depth_mask);
588 params[0] = static_cast<GLfloat>(z_near);
589 params[1] = static_cast<GLfloat>(z_far);
595 params[0] = static_cast<GLfloat>(front_face);
598 case GL_GENERATE_MIPMAP_HINT:
601 params[0] = static_cast<GLfloat>(hint_generate_mipmap);
604 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
607 params[0] = static_cast<GLfloat>(hint_fragment_shader_derivative);
613 params[0] = static_cast<GLfloat>(line_width);
616 case GL_PACK_ALIGNMENT:
619 params[0] = static_cast<GLfloat>(pack_alignment);
622 case GL_UNPACK_ALIGNMENT:
625 params[0] = static_cast<GLfloat>(unpack_alignment);
628 case GL_POLYGON_OFFSET_FACTOR:
631 params[0] = static_cast<GLfloat>(polygon_offset_factor);
634 case GL_POLYGON_OFFSET_UNITS:
637 params[0] = static_cast<GLfloat>(polygon_offset_units);
640 case GL_SAMPLE_COVERAGE_VALUE:
643 params[0] = static_cast<GLfloat>(sample_coverage_value);
646 case GL_SAMPLE_COVERAGE_INVERT:
649 params[0] = static_cast<GLfloat>(sample_coverage_invert);
655 params[0] = static_cast<GLfloat>(scissor_x);
656 params[1] = static_cast<GLfloat>(scissor_y);
657 params[2] = static_cast<GLfloat>(scissor_width);
658 params[3] = static_cast<GLfloat>(scissor_height);
661 case GL_STENCIL_FUNC:
664 params[0] = static_cast<GLfloat>(stencil_front_func);
670 params[0] = static_cast<GLfloat>(stencil_front_ref);
673 case GL_STENCIL_VALUE_MASK:
676 params[0] = static_cast<GLfloat>(stencil_front_mask);
679 case GL_STENCIL_BACK_FUNC:
682 params[0] = static_cast<GLfloat>(stencil_back_func);
685 case GL_STENCIL_BACK_REF:
688 params[0] = static_cast<GLfloat>(stencil_back_ref);
691 case GL_STENCIL_BACK_VALUE_MASK:
694 params[0] = static_cast<GLfloat>(stencil_back_mask);
697 case GL_STENCIL_WRITEMASK:
700 params[0] = static_cast<GLfloat>(stencil_front_writemask);
703 case GL_STENCIL_BACK_WRITEMASK:
706 params[0] = static_cast<GLfloat>(stencil_back_writemask);
709 case GL_STENCIL_FAIL:
712 params[0] = static_cast<GLfloat>(stencil_front_fail_op);
715 case GL_STENCIL_PASS_DEPTH_FAIL:
718 params[0] = static_cast<GLfloat>(stencil_front_z_fail_op);
721 case GL_STENCIL_PASS_DEPTH_PASS:
724 params[0] = static_cast<GLfloat>(stencil_front_z_pass_op);
727 case GL_STENCIL_BACK_FAIL:
730 params[0] = static_cast<GLfloat>(stencil_back_fail_op);
733 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
736 params[0] = static_cast<GLfloat>(stencil_back_z_fail_op);
739 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
742 params[0] = static_cast<GLfloat>(stencil_back_z_pass_op);
748 params[0] = static_cast<GLfloat>(viewport_x);
749 params[1] = static_cast<GLfloat>(viewport_y);
750 params[2] = static_cast<GLfloat>(viewport_width);
751 params[3] = static_cast<GLfloat>(viewport_height);
757 params[0] = static_cast<GLfloat>(enable_flags.blend);
763 params[0] = static_cast<GLfloat>(enable_flags.cull_face);
769 params[0] = static_cast<GLfloat>(enable_flags.depth_test);
775 params[0] = static_cast<GLfloat>(enable_flags.dither);
778 case GL_POLYGON_OFFSET_FILL:
781 params[0] = static_cast<GLfloat>(enable_flags.polygon_offset_fill);
784 case GL_SAMPLE_ALPHA_TO_COVERAGE:
788 static_cast<GLfloat>(enable_flags.sample_alpha_to_coverage);
791 case GL_SAMPLE_COVERAGE:
794 params[0] = static_cast<GLfloat>(enable_flags.sample_coverage);
797 case GL_SCISSOR_TEST:
800 params[0] = static_cast<GLfloat>(enable_flags.scissor_test);
803 case GL_STENCIL_TEST:
806 params[0] = static_cast<GLfloat>(enable_flags.stencil_test);
813 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_