2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """code generator for GLES2 command buffers."""
14 from optparse
import OptionParser
15 from subprocess
import call
18 _SIZE_OF_COMMAND_HEADER
= 4
19 _FIRST_SPECIFIC_COMMAND_ID
= 256
21 _LICENSE
= """// Copyright 2014 The Chromium Authors. All rights reserved.
22 // Use of this source code is governed by a BSD-style license that can be
23 // found in the LICENSE file.
27 _DO_NOT_EDIT_WARNING
= """// This file is auto-generated from
28 // gpu/command_buffer/build_gles2_cmd_buffer.py
29 // It's formatted by clang-format using chromium coding style:
30 // clang-format -i -style=chromium filename
35 # This string is copied directly out of the gl2.h file from GLES2.0
39 # *) Any argument that is a resourceID has been changed to GLid<Type>.
40 # (not pointer arguments) and if it's allowed to be zero it's GLidZero<Type>
41 # If it's allowed to not exist it's GLidBind<Type>
43 # *) All GLenums have been changed to GLenumTypeOfEnum
46 'GLenum': 'unsigned int',
47 'GLboolean': 'unsigned char',
48 'GLbitfield': 'unsigned int',
49 'GLbyte': 'signed char',
53 'GLubyte': 'unsigned char',
54 'GLushort': 'unsigned short',
55 'GLuint': 'unsigned int',
64 'GLintptr': 'long int',
65 'GLsizeiptr': 'long int'
69 'GLintptr': 'long long int',
70 'GLsizeiptr': 'long long int'
73 # Capabilites selected with glEnable
76 {'name': 'cull_face'},
77 {'name': 'depth_test', 'state_flag': 'framebuffer_state_.clear_state_dirty'},
78 {'name': 'dither', 'default': True},
79 {'name': 'polygon_offset_fill'},
80 {'name': 'sample_alpha_to_coverage'},
81 {'name': 'sample_coverage'},
82 {'name': 'scissor_test'},
83 {'name': 'stencil_test',
84 'state_flag': 'framebuffer_state_.clear_state_dirty'},
85 {'name': 'rasterizer_discard', 'es3': True},
92 'enum': 'GL_COLOR_CLEAR_VALUE',
94 {'name': 'color_clear_red', 'type': 'GLfloat', 'default': '0.0f'},
95 {'name': 'color_clear_green', 'type': 'GLfloat', 'default': '0.0f'},
96 {'name': 'color_clear_blue', 'type': 'GLfloat', 'default': '0.0f'},
97 {'name': 'color_clear_alpha', 'type': 'GLfloat', 'default': '0.0f'},
102 'func': 'ClearDepth',
103 'enum': 'GL_DEPTH_CLEAR_VALUE',
105 {'name': 'depth_clear', 'type': 'GLclampf', 'default': '1.0f'},
111 'enum': 'GL_COLOR_WRITEMASK',
114 'name': 'color_mask_red',
120 'name': 'color_mask_green',
126 'name': 'color_mask_blue',
132 'name': 'color_mask_alpha',
138 'state_flag': 'framebuffer_state_.clear_state_dirty',
142 'func': 'ClearStencil',
143 'enum': 'GL_STENCIL_CLEAR_VALUE',
145 {'name': 'stencil_clear', 'type': 'GLint', 'default': '0'},
150 'func': 'BlendColor',
151 'enum': 'GL_BLEND_COLOR',
153 {'name': 'blend_color_red', 'type': 'GLfloat', 'default': '0.0f'},
154 {'name': 'blend_color_green', 'type': 'GLfloat', 'default': '0.0f'},
155 {'name': 'blend_color_blue', 'type': 'GLfloat', 'default': '0.0f'},
156 {'name': 'blend_color_alpha', 'type': 'GLfloat', 'default': '0.0f'},
161 'func': 'BlendEquationSeparate',
164 'name': 'blend_equation_rgb',
166 'enum': 'GL_BLEND_EQUATION_RGB',
167 'default': 'GL_FUNC_ADD',
170 'name': 'blend_equation_alpha',
172 'enum': 'GL_BLEND_EQUATION_ALPHA',
173 'default': 'GL_FUNC_ADD',
179 'func': 'BlendFuncSeparate',
182 'name': 'blend_source_rgb',
184 'enum': 'GL_BLEND_SRC_RGB',
188 'name': 'blend_dest_rgb',
190 'enum': 'GL_BLEND_DST_RGB',
191 'default': 'GL_ZERO',
194 'name': 'blend_source_alpha',
196 'enum': 'GL_BLEND_SRC_ALPHA',
200 'name': 'blend_dest_alpha',
202 'enum': 'GL_BLEND_DST_ALPHA',
203 'default': 'GL_ZERO',
209 'func': 'PolygonOffset',
212 'name': 'polygon_offset_factor',
214 'enum': 'GL_POLYGON_OFFSET_FACTOR',
218 'name': 'polygon_offset_units',
220 'enum': 'GL_POLYGON_OFFSET_UNITS',
228 'enum': 'GL_CULL_FACE_MODE',
233 'default': 'GL_BACK',
240 'enum': 'GL_FRONT_FACE',
241 'states': [{'name': 'front_face', 'type': 'GLenum', 'default': 'GL_CCW'}],
246 'enum': 'GL_DEPTH_FUNC',
247 'states': [{'name': 'depth_func', 'type': 'GLenum', 'default': 'GL_LESS'}],
251 'func': 'DepthRange',
252 'enum': 'GL_DEPTH_RANGE',
254 {'name': 'z_near', 'type': 'GLclampf', 'default': '0.0f'},
255 {'name': 'z_far', 'type': 'GLclampf', 'default': '1.0f'},
260 'func': 'SampleCoverage',
263 'name': 'sample_coverage_value',
265 'enum': 'GL_SAMPLE_COVERAGE_VALUE',
269 'name': 'sample_coverage_invert',
271 'enum': 'GL_SAMPLE_COVERAGE_INVERT',
278 'func': 'StencilMaskSeparate',
279 'state_flag': 'framebuffer_state_.clear_state_dirty',
282 'name': 'stencil_front_writemask',
284 'enum': 'GL_STENCIL_WRITEMASK',
285 'default': '0xFFFFFFFFU',
289 'name': 'stencil_back_writemask',
291 'enum': 'GL_STENCIL_BACK_WRITEMASK',
292 'default': '0xFFFFFFFFU',
299 'func': 'StencilOpSeparate',
302 'name': 'stencil_front_fail_op',
304 'enum': 'GL_STENCIL_FAIL',
305 'default': 'GL_KEEP',
308 'name': 'stencil_front_z_fail_op',
310 'enum': 'GL_STENCIL_PASS_DEPTH_FAIL',
311 'default': 'GL_KEEP',
314 'name': 'stencil_front_z_pass_op',
316 'enum': 'GL_STENCIL_PASS_DEPTH_PASS',
317 'default': 'GL_KEEP',
320 'name': 'stencil_back_fail_op',
322 'enum': 'GL_STENCIL_BACK_FAIL',
323 'default': 'GL_KEEP',
326 'name': 'stencil_back_z_fail_op',
328 'enum': 'GL_STENCIL_BACK_PASS_DEPTH_FAIL',
329 'default': 'GL_KEEP',
332 'name': 'stencil_back_z_pass_op',
334 'enum': 'GL_STENCIL_BACK_PASS_DEPTH_PASS',
335 'default': 'GL_KEEP',
341 'func': 'StencilFuncSeparate',
344 'name': 'stencil_front_func',
346 'enum': 'GL_STENCIL_FUNC',
347 'default': 'GL_ALWAYS',
350 'name': 'stencil_front_ref',
352 'enum': 'GL_STENCIL_REF',
356 'name': 'stencil_front_mask',
358 'enum': 'GL_STENCIL_VALUE_MASK',
359 'default': '0xFFFFFFFFU',
362 'name': 'stencil_back_func',
364 'enum': 'GL_STENCIL_BACK_FUNC',
365 'default': 'GL_ALWAYS',
368 'name': 'stencil_back_ref',
370 'enum': 'GL_STENCIL_BACK_REF',
374 'name': 'stencil_back_mask',
376 'enum': 'GL_STENCIL_BACK_VALUE_MASK',
377 'default': '0xFFFFFFFFU',
382 'type': 'NamedParameter',
386 'name': 'hint_generate_mipmap',
388 'enum': 'GL_GENERATE_MIPMAP_HINT',
389 'default': 'GL_DONT_CARE',
390 'gl_version_flag': '!is_desktop_core_profile'
393 'name': 'hint_fragment_shader_derivative',
395 'enum': 'GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES',
396 'default': 'GL_DONT_CARE',
397 'extension_flag': 'oes_standard_derivatives'
402 'type': 'NamedParameter',
403 'func': 'PixelStorei',
406 'name': 'pack_alignment',
408 'enum': 'GL_PACK_ALIGNMENT',
412 'name': 'unpack_alignment',
414 'enum': 'GL_UNPACK_ALIGNMENT',
419 # TODO: Consider implemenenting these states
424 'enum': 'GL_LINE_WIDTH',
427 'name': 'line_width',
430 'range_checks': [{'check': "<= 0.0f", 'test_value': "0.0f"}],
437 'enum': 'GL_DEPTH_WRITEMASK',
440 'name': 'depth_mask',
446 'state_flag': 'framebuffer_state_.clear_state_dirty',
451 'enum': 'GL_SCISSOR_BOX',
453 # NOTE: These defaults reset at GLES2DecoderImpl::Initialization.
458 'expected': 'kViewportX',
464 'expected': 'kViewportY',
467 'name': 'scissor_width',
470 'expected': 'kViewportWidth',
473 'name': 'scissor_height',
476 'expected': 'kViewportHeight',
483 'enum': 'GL_VIEWPORT',
485 # NOTE: These defaults reset at GLES2DecoderImpl::Initialization.
487 'name': 'viewport_x',
490 'expected': 'kViewportX',
493 'name': 'viewport_y',
496 'expected': 'kViewportY',
499 'name': 'viewport_width',
502 'expected': 'kViewportWidth',
505 'name': 'viewport_height',
508 'expected': 'kViewportHeight',
512 'MatrixValuesCHROMIUM': {
513 'type': 'NamedParameter',
514 'func': 'MatrixLoadfEXT',
516 { 'enum': 'GL_PATH_MODELVIEW_MATRIX_CHROMIUM',
517 'enum_set': 'GL_PATH_MODELVIEW_CHROMIUM',
518 'name': 'modelview_matrix',
521 '1.0f', '0.0f','0.0f','0.0f',
522 '0.0f', '1.0f','0.0f','0.0f',
523 '0.0f', '0.0f','1.0f','0.0f',
524 '0.0f', '0.0f','0.0f','1.0f',
526 'extension_flag': 'chromium_path_rendering',
528 { 'enum': 'GL_PATH_PROJECTION_MATRIX_CHROMIUM',
529 'enum_set': 'GL_PATH_PROJECTION_CHROMIUM',
530 'name': 'projection_matrix',
533 '1.0f', '0.0f','0.0f','0.0f',
534 '0.0f', '1.0f','0.0f','0.0f',
535 '0.0f', '0.0f','1.0f','0.0f',
536 '0.0f', '0.0f','0.0f','1.0f',
538 'extension_flag': 'chromium_path_rendering',
544 # Named type info object represents a named type that is used in OpenGL call
545 # arguments. Each named type defines a set of valid OpenGL call arguments. The
546 # named types are used in 'cmd_buffer_functions.txt'.
547 # type: The actual GL type of the named type.
548 # valid: The list of values that are valid for both the client and the service.
549 # valid_es3: The list of values that are valid in OpenGL ES 3, but not ES 2.
550 # invalid: Examples of invalid values for the type. At least these values
551 # should be tested to be invalid.
552 # deprecated_es3: The list of values that are valid in OpenGL ES 2, but
553 # deprecated in ES 3.
554 # is_complete: The list of valid values of type are final and will not be
555 # modified during runtime.
564 'GL_LINEAR_MIPMAP_LINEAR',
567 'FrameBufferTarget': {
573 'GL_DRAW_FRAMEBUFFER' ,
574 'GL_READ_FRAMEBUFFER' ,
577 'RenderBufferTarget': {
590 'GL_ELEMENT_ARRAY_BUFFER',
593 'GL_COPY_READ_BUFFER',
594 'GL_COPY_WRITE_BUFFER',
595 'GL_PIXEL_PACK_BUFFER',
596 'GL_PIXEL_UNPACK_BUFFER',
597 'GL_TRANSFORM_FEEDBACK_BUFFER',
604 'IndexedBufferTarget': {
607 'GL_TRANSFORM_FEEDBACK_BUFFER',
619 'GL_MAP_INVALIDATE_RANGE_BIT',
620 'GL_MAP_INVALIDATE_BUFFER_BIT',
621 'GL_MAP_FLUSH_EXPLICIT_BIT',
622 'GL_MAP_UNSYNCHRONIZED_BIT',
625 'GL_SYNC_FLUSH_COMMANDS_BIT',
677 'CompressedTextureFormat': {
685 # NOTE: State an Capability entries added later.
687 'GL_ALIASED_LINE_WIDTH_RANGE',
688 'GL_ALIASED_POINT_SIZE_RANGE',
690 'GL_ARRAY_BUFFER_BINDING',
692 'GL_COMPRESSED_TEXTURE_FORMATS',
693 'GL_CURRENT_PROGRAM',
696 'GL_ELEMENT_ARRAY_BUFFER_BINDING',
697 'GL_FRAMEBUFFER_BINDING',
698 'GL_GENERATE_MIPMAP_HINT',
700 'GL_IMPLEMENTATION_COLOR_READ_FORMAT',
701 'GL_IMPLEMENTATION_COLOR_READ_TYPE',
702 'GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS',
703 'GL_MAX_CUBE_MAP_TEXTURE_SIZE',
704 'GL_MAX_FRAGMENT_UNIFORM_VECTORS',
705 'GL_MAX_RENDERBUFFER_SIZE',
706 'GL_MAX_TEXTURE_IMAGE_UNITS',
707 'GL_MAX_TEXTURE_SIZE',
708 'GL_MAX_VARYING_VECTORS',
709 'GL_MAX_VERTEX_ATTRIBS',
710 'GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS',
711 'GL_MAX_VERTEX_UNIFORM_VECTORS',
712 'GL_MAX_VIEWPORT_DIMS',
713 'GL_NUM_COMPRESSED_TEXTURE_FORMATS',
714 'GL_NUM_SHADER_BINARY_FORMATS',
717 'GL_RENDERBUFFER_BINDING',
719 'GL_SAMPLE_COVERAGE_INVERT',
720 'GL_SAMPLE_COVERAGE_VALUE',
723 'GL_SHADER_BINARY_FORMATS',
724 'GL_SHADER_COMPILER',
727 'GL_TEXTURE_BINDING_2D',
728 'GL_TEXTURE_BINDING_CUBE_MAP',
729 'GL_UNPACK_ALIGNMENT',
730 'GL_UNPACK_FLIP_Y_CHROMIUM',
731 'GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM',
732 'GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM',
733 'GL_BIND_GENERATES_RESOURCE_CHROMIUM',
734 # we can add this because we emulate it if the driver does not support it.
735 'GL_VERTEX_ARRAY_BINDING_OES',
742 'GetTexParamTarget': {
746 'GL_TEXTURE_CUBE_MAP',
749 'GL_PROXY_TEXTURE_CUBE_MAP',
756 'GL_TEXTURE_CUBE_MAP_POSITIVE_X',
757 'GL_TEXTURE_CUBE_MAP_NEGATIVE_X',
758 'GL_TEXTURE_CUBE_MAP_POSITIVE_Y',
759 'GL_TEXTURE_CUBE_MAP_NEGATIVE_Y',
760 'GL_TEXTURE_CUBE_MAP_POSITIVE_Z',
761 'GL_TEXTURE_CUBE_MAP_NEGATIVE_Z',
764 'GL_PROXY_TEXTURE_CUBE_MAP',
771 'GL_TEXTURE_2D_ARRAY',
777 'TextureBindTarget': {
781 'GL_TEXTURE_CUBE_MAP',
785 'GL_TEXTURE_2D_ARRAY',
792 'TransformFeedbackBindTarget': {
795 'GL_TRANSFORM_FEEDBACK',
801 'TransformFeedbackPrimitiveMode': {
816 'GL_FRAGMENT_SHADER',
819 'GL_GEOMETRY_SHADER',
855 'GL_FUNC_REVERSE_SUBTRACT',
868 'GL_ONE_MINUS_SRC_COLOR',
870 'GL_ONE_MINUS_DST_COLOR',
872 'GL_ONE_MINUS_SRC_ALPHA',
874 'GL_ONE_MINUS_DST_ALPHA',
876 'GL_ONE_MINUS_CONSTANT_COLOR',
878 'GL_ONE_MINUS_CONSTANT_ALPHA',
879 'GL_SRC_ALPHA_SATURATE',
888 'GL_ONE_MINUS_SRC_COLOR',
890 'GL_ONE_MINUS_DST_COLOR',
892 'GL_ONE_MINUS_SRC_ALPHA',
894 'GL_ONE_MINUS_DST_ALPHA',
896 'GL_ONE_MINUS_CONSTANT_COLOR',
898 'GL_ONE_MINUS_CONSTANT_ALPHA',
903 'valid': ["GL_%s" % cap
['name'].upper() for cap
in _CAPABILITY_FLAGS
904 if 'es3' not in cap
or cap
['es3'] != True],
905 'valid_es3': ["GL_%s" % cap
['name'].upper() for cap
in _CAPABILITY_FLAGS
906 if 'es3' in cap
and cap
['es3'] == True],
953 'GL_COLOR_ATTACHMENT0',
954 'GL_DEPTH_ATTACHMENT',
955 'GL_STENCIL_ATTACHMENT',
958 'BackbufferAttachment': {
973 'GL_PIXEL_PACK_BUFFER',
979 'GL_INTERLEAVED_ATTRIBS',
980 'GL_SEPARATE_ATTRIBS',
983 'GL_PIXEL_PACK_BUFFER',
986 'FrameBufferParameter': {
989 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE',
990 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME',
991 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL',
992 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE',
998 'GL_PATH_PROJECTION_CHROMIUM',
999 'GL_PATH_MODELVIEW_CHROMIUM',
1002 'ProgramParameter': {
1007 'GL_VALIDATE_STATUS',
1008 'GL_INFO_LOG_LENGTH',
1009 'GL_ATTACHED_SHADERS',
1010 'GL_ACTIVE_ATTRIBUTES',
1011 'GL_ACTIVE_ATTRIBUTE_MAX_LENGTH',
1012 'GL_ACTIVE_UNIFORMS',
1013 'GL_ACTIVE_UNIFORM_MAX_LENGTH',
1016 'QueryObjectParameter': {
1019 'GL_QUERY_RESULT_EXT',
1020 'GL_QUERY_RESULT_AVAILABLE_EXT',
1026 'GL_CURRENT_QUERY_EXT',
1032 'GL_ANY_SAMPLES_PASSED_EXT',
1033 'GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT',
1034 'GL_COMMANDS_ISSUED_CHROMIUM',
1035 'GL_LATENCY_QUERY_CHROMIUM',
1036 'GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM',
1037 'GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM',
1038 'GL_COMMANDS_COMPLETED_CHROMIUM',
1041 'RenderBufferParameter': {
1044 'GL_RENDERBUFFER_RED_SIZE',
1045 'GL_RENDERBUFFER_GREEN_SIZE',
1046 'GL_RENDERBUFFER_BLUE_SIZE',
1047 'GL_RENDERBUFFER_ALPHA_SIZE',
1048 'GL_RENDERBUFFER_DEPTH_SIZE',
1049 'GL_RENDERBUFFER_STENCIL_SIZE',
1050 'GL_RENDERBUFFER_WIDTH',
1051 'GL_RENDERBUFFER_HEIGHT',
1052 'GL_RENDERBUFFER_INTERNAL_FORMAT',
1055 'SamplerParameter': {
1058 'GL_TEXTURE_MAG_FILTER',
1059 'GL_TEXTURE_MIN_FILTER',
1060 'GL_TEXTURE_MIN_LOD',
1061 'GL_TEXTURE_MAX_LOD',
1062 'GL_TEXTURE_WRAP_S',
1063 'GL_TEXTURE_WRAP_T',
1064 'GL_TEXTURE_WRAP_R',
1065 'GL_TEXTURE_COMPARE_MODE',
1066 'GL_TEXTURE_COMPARE_FUNC',
1069 'GL_GENERATE_MIPMAP',
1072 'ShaderParameter': {
1077 'GL_COMPILE_STATUS',
1078 'GL_INFO_LOG_LENGTH',
1079 'GL_SHADER_SOURCE_LENGTH',
1080 'GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE',
1083 'ShaderPrecision': {
1100 'GL_SHADING_LANGUAGE_VERSION',
1104 'TextureParameter': {
1107 'GL_TEXTURE_MAG_FILTER',
1108 'GL_TEXTURE_MIN_FILTER',
1109 'GL_TEXTURE_POOL_CHROMIUM',
1110 'GL_TEXTURE_WRAP_S',
1111 'GL_TEXTURE_WRAP_T',
1114 'GL_GENERATE_MIPMAP',
1120 'GL_TEXTURE_POOL_MANAGED_CHROMIUM',
1121 'GL_TEXTURE_POOL_UNMANAGED_CHROMIUM',
1124 'TextureWrapMode': {
1128 'GL_MIRRORED_REPEAT',
1132 'TextureMinFilterMode': {
1137 'GL_NEAREST_MIPMAP_NEAREST',
1138 'GL_LINEAR_MIPMAP_NEAREST',
1139 'GL_NEAREST_MIPMAP_LINEAR',
1140 'GL_LINEAR_MIPMAP_LINEAR',
1143 'TextureMagFilterMode': {
1154 'GL_FRAMEBUFFER_ATTACHMENT_ANGLE',
1157 'VertexAttribute': {
1160 # some enum that the decoder actually passes through to GL needs
1161 # to be the first listed here since it's used in unit tests.
1162 'GL_VERTEX_ATTRIB_ARRAY_NORMALIZED',
1163 'GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING',
1164 'GL_VERTEX_ATTRIB_ARRAY_ENABLED',
1165 'GL_VERTEX_ATTRIB_ARRAY_SIZE',
1166 'GL_VERTEX_ATTRIB_ARRAY_STRIDE',
1167 'GL_VERTEX_ATTRIB_ARRAY_TYPE',
1168 'GL_CURRENT_VERTEX_ATTRIB',
1174 'GL_VERTEX_ATTRIB_ARRAY_POINTER',
1180 'GL_GENERATE_MIPMAP_HINT',
1183 'GL_PERSPECTIVE_CORRECTION_HINT',
1197 'GL_PACK_ALIGNMENT',
1198 'GL_UNPACK_ALIGNMENT',
1199 'GL_UNPACK_FLIP_Y_CHROMIUM',
1200 'GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM',
1201 'GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM',
1204 'GL_PACK_SWAP_BYTES',
1205 'GL_UNPACK_SWAP_BYTES',
1208 'PixelStoreAlignment': {
1221 'ReadPixelFormat': {
1233 'GL_UNSIGNED_SHORT_5_6_5',
1234 'GL_UNSIGNED_SHORT_4_4_4_4',
1235 'GL_UNSIGNED_SHORT_5_5_5_1',
1239 'GL_UNSIGNED_SHORT',
1245 'GL_UNSIGNED_INT_2_10_10_10_REV',
1246 'GL_UNSIGNED_INT_10F_11F_11F_REV',
1247 'GL_UNSIGNED_INT_5_9_9_9_REV',
1248 'GL_UNSIGNED_INT_24_8',
1249 'GL_FLOAT_32_UNSIGNED_INT_24_8_REV',
1252 'GL_UNSIGNED_BYTE_3_3_2',
1259 'GL_UNSIGNED_SHORT_5_6_5',
1260 'GL_UNSIGNED_SHORT_4_4_4_4',
1261 'GL_UNSIGNED_SHORT_5_5_5_1',
1268 'RenderBufferFormat': {
1274 'GL_DEPTH_COMPONENT16',
1275 'GL_STENCIL_INDEX8',
1278 'ShaderBinaryFormat': {
1301 'GL_LUMINANCE_ALPHA',
1312 'GL_DEPTH_COMPONENT',
1320 'TextureInternalFormat': {
1325 'GL_LUMINANCE_ALPHA',
1354 'GL_R11F_G11F_B10F',
1379 # The DEPTH/STENCIL formats are not supported in CopyTexImage2D.
1380 # We will reject them dynamically in GPU command buffer.
1381 'GL_DEPTH_COMPONENT16',
1382 'GL_DEPTH_COMPONENT24',
1383 'GL_DEPTH_COMPONENT32F',
1384 'GL_DEPTH24_STENCIL8',
1385 'GL_DEPTH32F_STENCIL8',
1392 'TextureInternalFormatStorage': {
1399 'GL_LUMINANCE8_EXT',
1400 'GL_LUMINANCE8_ALPHA8_EXT',
1427 'GL_R11F_G11F_B10F',
1449 'GL_DEPTH_COMPONENT16',
1450 'GL_DEPTH_COMPONENT24',
1451 'GL_DEPTH_COMPONENT32F',
1452 'GL_DEPTH24_STENCIL8',
1453 'GL_DEPTH32F_STENCIL8',
1454 'GL_COMPRESSED_R11_EAC',
1455 'GL_COMPRESSED_SIGNED_R11_EAC',
1456 'GL_COMPRESSED_RG11_EAC',
1457 'GL_COMPRESSED_SIGNED_RG11_EAC',
1458 'GL_COMPRESSED_RGB8_ETC2',
1459 'GL_COMPRESSED_SRGB8_ETC2',
1460 'GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2',
1461 'GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2',
1462 'GL_COMPRESSED_RGBA8_ETC2_EAC',
1463 'GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC',
1467 'GL_LUMINANCE8_EXT',
1468 'GL_LUMINANCE8_ALPHA8_EXT',
1470 'GL_LUMINANCE16F_EXT',
1471 'GL_LUMINANCE_ALPHA16F_EXT',
1473 'GL_LUMINANCE32F_EXT',
1474 'GL_LUMINANCE_ALPHA32F_EXT',
1477 'ImageInternalFormat': {
1488 'GL_SCANOUT_CHROMIUM'
1491 'ValueBufferTarget': {
1494 'GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM',
1497 'SubscriptionTarget': {
1500 'GL_MOUSE_POSITION_CHROMIUM',
1503 'UniformParameter': {
1508 'GL_UNIFORM_NAME_LENGTH',
1509 'GL_UNIFORM_BLOCK_INDEX',
1510 'GL_UNIFORM_OFFSET',
1511 'GL_UNIFORM_ARRAY_STRIDE',
1512 'GL_UNIFORM_MATRIX_STRIDE',
1513 'GL_UNIFORM_IS_ROW_MAJOR',
1516 'GL_UNIFORM_BLOCK_NAME_LENGTH',
1519 'UniformBlockParameter': {
1522 'GL_UNIFORM_BLOCK_BINDING',
1523 'GL_UNIFORM_BLOCK_DATA_SIZE',
1524 'GL_UNIFORM_BLOCK_NAME_LENGTH',
1525 'GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS',
1526 'GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES',
1527 'GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER',
1528 'GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER',
1534 'VertexAttribType': {
1540 'GL_UNSIGNED_SHORT',
1541 # 'GL_FIXED', // This is not available on Desktop GL.
1550 'is_complete': True,
1558 'VertexAttribSize': {
1573 'is_complete': True,
1582 'type': 'GLboolean',
1583 'is_complete': True,
1594 'GL_GUILTY_CONTEXT_RESET_ARB',
1595 'GL_INNOCENT_CONTEXT_RESET_ARB',
1596 'GL_UNKNOWN_CONTEXT_RESET_ARB',
1601 'is_complete': True,
1603 'GL_SYNC_GPU_COMMANDS_COMPLETE',
1610 'type': 'GLbitfield',
1611 'is_complete': True,
1620 'type': 'GLbitfield',
1622 'GL_SYNC_FLUSH_COMMANDS_BIT',
1632 'GL_SYNC_STATUS', # This needs to be the 1st; all others are cached.
1634 'GL_SYNC_CONDITION',
1643 # This table specifies the different pepper interfaces that are supported for
1644 # GL commands. 'dev' is true if it's a dev interface.
1645 _PEPPER_INTERFACES
= [
1646 {'name': '', 'dev': False},
1647 {'name': 'InstancedArrays', 'dev': False},
1648 {'name': 'FramebufferBlit', 'dev': False},
1649 {'name': 'FramebufferMultisample', 'dev': False},
1650 {'name': 'ChromiumEnableFeature', 'dev': False},
1651 {'name': 'ChromiumMapSub', 'dev': False},
1652 {'name': 'Query', 'dev': False},
1653 {'name': 'VertexArrayObject', 'dev': False},
1654 {'name': 'DrawBuffers', 'dev': True},
1657 # A function info object specifies the type and other special data for the
1658 # command that will be generated. A base function info object is generated by
1659 # parsing the "cmd_buffer_functions.txt", one for each function in the
1660 # file. These function info objects can be augmented and their values can be
1661 # overridden by adding an object to the table below.
1663 # Must match function names specified in "cmd_buffer_functions.txt".
1665 # cmd_comment: A comment added to the cmd format.
1666 # type: defines which handler will be used to generate code.
1667 # decoder_func: defines which function to call in the decoder to execute the
1668 # corresponding GL command. If not specified the GL command will
1669 # be called directly.
1670 # gl_test_func: GL function that is expected to be called when testing.
1671 # cmd_args: The arguments to use for the command. This overrides generating
1672 # them based on the GL function arguments.
1673 # gen_cmd: Whether or not this function geneates a command. Default = True.
1674 # data_transfer_methods: Array of methods that are used for transfering the
1675 # pointer data. Possible values: 'immediate', 'shm', 'bucket'.
1676 # The default is 'immediate' if the command has one pointer
1677 # argument, otherwise 'shm'. One command is generated for each
1678 # transfer method. Affects only commands which are not of type
1679 # 'HandWritten', 'GETn' or 'GLcharN'.
1680 # Note: the command arguments that affect this are the final args,
1681 # taking cmd_args override into consideration.
1682 # impl_func: Whether or not to generate the GLES2Implementation part of this
1684 # impl_decl: Whether or not to generate the GLES2Implementation declaration
1686 # needs_size: If True a data_size field is added to the command.
1687 # count: The number of units per element. For PUTn or PUT types.
1688 # use_count_func: If True the actual data count needs to be computed; the count
1689 # argument specifies the maximum count.
1690 # unit_test: If False no service side unit test will be generated.
1691 # client_test: If False no client side unit test will be generated.
1692 # expectation: If False the unit test will have no expected calls.
1693 # gen_func: Name of function that generates GL resource for corresponding
1695 # states: array of states that get set by this function corresponding to
1696 # the given arguments
1697 # state_flag: name of flag that is set to true when function is called.
1698 # no_gl: no GL function is called.
1699 # valid_args: A dictionary of argument indices to args to use in unit tests
1700 # when they can not be automatically determined.
1701 # pepper_interface: The pepper interface that is used for this extension
1702 # pepper_name: The name of the function as exposed to pepper.
1703 # pepper_args: A string representing the argument list (what would appear in
1704 # C/C++ between the parentheses for the function declaration)
1705 # that the Pepper API expects for this function. Use this only if
1706 # the stable Pepper API differs from the GLES2 argument list.
1707 # invalid_test: False if no invalid test needed.
1708 # shadowed: True = the value is shadowed so no glGetXXX call will be made.
1709 # first_element_only: For PUT types, True if only the first element of an
1710 # array is used and we end up calling the single value
1711 # corresponding function. eg. TexParameteriv -> TexParameteri
1712 # extension: Function is an extension to GL and should not be exposed to
1713 # pepper unless pepper_interface is defined.
1714 # extension_flag: Function is an extension and should be enabled only when
1715 # the corresponding feature info flag is enabled. Implies
1716 # 'extension': True.
1717 # not_shared: For GENn types, True if objects can't be shared between contexts
1718 # unsafe: True = no validation is implemented on the service side and the
1719 # command is only available with --enable-unsafe-es3-apis.
1720 # id_mapping: A list of resource type names whose client side IDs need to be
1721 # mapped to service side IDs. This is only used for unsafe APIs.
1725 'decoder_func': 'DoActiveTexture',
1728 'client_test': False,
1730 'AttachShader': {'decoder_func': 'DoAttachShader'},
1731 'BindAttribLocation': {
1733 'data_transfer_methods': ['bucket'],
1738 'decoder_func': 'DoBindBuffer',
1739 'gen_func': 'GenBuffersARB',
1743 'id_mapping': [ 'Buffer' ],
1744 'gen_func': 'GenBuffersARB',
1747 'BindBufferRange': {
1749 'id_mapping': [ 'Buffer' ],
1750 'gen_func': 'GenBuffersARB',
1757 'BindFramebuffer': {
1759 'decoder_func': 'DoBindFramebuffer',
1760 'gl_test_func': 'glBindFramebufferEXT',
1761 'gen_func': 'GenFramebuffersEXT',
1764 'BindRenderbuffer': {
1766 'decoder_func': 'DoBindRenderbuffer',
1767 'gl_test_func': 'glBindRenderbufferEXT',
1768 'gen_func': 'GenRenderbuffersEXT',
1772 'id_mapping': [ 'Sampler' ],
1777 'decoder_func': 'DoBindTexture',
1778 'gen_func': 'GenTextures',
1779 # TODO(gman): remove this once client side caching works.
1780 'client_test': False,
1783 'BindTransformFeedback': {
1785 'id_mapping': [ 'TransformFeedback' ],
1788 'BlitFramebufferCHROMIUM': {
1789 'decoder_func': 'DoBlitFramebufferCHROMIUM',
1791 'extension_flag': 'chromium_framebuffer_multisample',
1792 'pepper_interface': 'FramebufferBlit',
1793 'pepper_name': 'BlitFramebufferEXT',
1794 'defer_reads': True,
1795 'defer_draws': True,
1800 'data_transfer_methods': ['shm'],
1801 'client_test': False,
1805 'client_test': False,
1806 'decoder_func': 'DoBufferSubData',
1807 'data_transfer_methods': ['shm'],
1809 'CheckFramebufferStatus': {
1811 'decoder_func': 'DoCheckFramebufferStatus',
1812 'gl_test_func': 'glCheckFramebufferStatusEXT',
1813 'error_value': 'GL_FRAMEBUFFER_UNSUPPORTED',
1814 'result': ['GLenum'],
1817 'decoder_func': 'DoClear',
1818 'defer_draws': True,
1823 'use_count_func': True,
1834 'use_count_func': True,
1843 'state': 'ClearColor',
1847 'state': 'ClearDepthf',
1848 'decoder_func': 'glClearDepth',
1849 'gl_test_func': 'glClearDepth',
1856 'data_transfer_methods': ['shm'],
1857 'cmd_args': 'GLuint sync, GLbitfieldSyncFlushFlags flags, '
1858 'GLuint timeout_0, GLuint timeout_1, GLenum* result',
1860 'result': ['GLenum'],
1864 'state': 'ColorMask',
1866 'expectation': False,
1868 'ConsumeTextureCHROMIUM': {
1869 'decoder_func': 'DoConsumeTextureCHROMIUM',
1872 'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
1874 'client_test': False,
1875 'extension': "CHROMIUM_texture_mailbox",
1879 'CopyBufferSubData': {
1882 'CreateAndConsumeTextureCHROMIUM': {
1883 'decoder_func': 'DoCreateAndConsumeTextureCHROMIUM',
1885 'type': 'HandWritten',
1886 'data_transfer_methods': ['immediate'],
1888 'client_test': False,
1889 'extension': "CHROMIUM_texture_mailbox",
1892 'GenValuebuffersCHROMIUM': {
1894 'gl_test_func': 'glGenValuebuffersCHROMIUM',
1895 'resource_type': 'Valuebuffer',
1896 'resource_types': 'Valuebuffers',
1901 'DeleteValuebuffersCHROMIUM': {
1903 'gl_test_func': 'glDeleteValuebuffersCHROMIUM',
1904 'resource_type': 'Valuebuffer',
1905 'resource_types': 'Valuebuffers',
1910 'IsValuebufferCHROMIUM': {
1912 'decoder_func': 'DoIsValuebufferCHROMIUM',
1913 'expectation': False,
1917 'BindValuebufferCHROMIUM': {
1919 'decoder_func': 'DoBindValueBufferCHROMIUM',
1920 'gen_func': 'GenValueBuffersCHROMIUM',
1925 'SubscribeValueCHROMIUM': {
1926 'decoder_func': 'DoSubscribeValueCHROMIUM',
1931 'PopulateSubscribedValuesCHROMIUM': {
1932 'decoder_func': 'DoPopulateSubscribedValuesCHROMIUM',
1937 'UniformValuebufferCHROMIUM': {
1938 'decoder_func': 'DoUniformValueBufferCHROMIUM',
1945 'state': 'ClearStencil',
1947 'EnableFeatureCHROMIUM': {
1949 'data_transfer_methods': ['shm'],
1950 'decoder_func': 'DoEnableFeatureCHROMIUM',
1951 'expectation': False,
1952 'cmd_args': 'GLuint bucket_id, GLint* result',
1953 'result': ['GLint'],
1956 'pepper_interface': 'ChromiumEnableFeature',
1958 'CompileShader': {'decoder_func': 'DoCompileShader', 'unit_test': False},
1959 'CompressedTexImage2D': {
1961 'data_transfer_methods': ['bucket', 'shm'],
1963 'CompressedTexSubImage2D': {
1965 'data_transfer_methods': ['bucket', 'shm'],
1966 'decoder_func': 'DoCompressedTexSubImage2D',
1969 'decoder_func': 'DoCopyTexImage2D',
1971 'defer_reads': True,
1973 'CopyTexSubImage2D': {
1974 'decoder_func': 'DoCopyTexSubImage2D',
1975 'defer_reads': True,
1977 'CopyTexSubImage3D': {
1978 'defer_reads': True,
1981 'CreateImageCHROMIUM': {
1984 'ClientBuffer buffer, GLsizei width, GLsizei height, '
1985 'GLenum internalformat',
1986 'result': ['GLuint'],
1987 'client_test': False,
1989 'expectation': False,
1993 'DestroyImageCHROMIUM': {
1995 'client_test': False,
2000 'CreateGpuMemoryBufferImageCHROMIUM': {
2003 'GLsizei width, GLsizei height, GLenum internalformat, GLenum usage',
2004 'result': ['GLuint'],
2005 'client_test': False,
2007 'expectation': False,
2013 'client_test': False,
2017 'client_test': False,
2021 'state': 'BlendColor',
2024 'type': 'StateSetRGBAlpha',
2025 'state': 'BlendEquation',
2027 '0': 'GL_FUNC_SUBTRACT'
2030 'BlendEquationSeparate': {
2032 'state': 'BlendEquation',
2034 '0': 'GL_FUNC_SUBTRACT'
2038 'type': 'StateSetRGBAlpha',
2039 'state': 'BlendFunc',
2041 'BlendFuncSeparate': {
2043 'state': 'BlendFunc',
2045 'BlendBarrierKHR': {
2046 'gl_test_func': 'glBlendBarrierKHR',
2048 'extension_flag': 'blend_equation_advanced',
2049 'client_test': False,
2051 'SampleCoverage': {'decoder_func': 'DoSampleCoverage'},
2053 'type': 'StateSetFrontBack',
2054 'state': 'StencilFunc',
2056 'StencilFuncSeparate': {
2057 'type': 'StateSetFrontBackSeparate',
2058 'state': 'StencilFunc',
2061 'type': 'StateSetFrontBack',
2062 'state': 'StencilOp',
2067 'StencilOpSeparate': {
2068 'type': 'StateSetFrontBackSeparate',
2069 'state': 'StencilOp',
2075 'type': 'StateSetNamedParameter',
2078 'CullFace': {'type': 'StateSet', 'state': 'CullFace'},
2079 'FrontFace': {'type': 'StateSet', 'state': 'FrontFace'},
2080 'DepthFunc': {'type': 'StateSet', 'state': 'DepthFunc'},
2083 'state': 'LineWidth',
2090 'state': 'PolygonOffset',
2094 'gl_test_func': 'glDeleteBuffersARB',
2095 'resource_type': 'Buffer',
2096 'resource_types': 'Buffers',
2098 'DeleteFramebuffers': {
2100 'gl_test_func': 'glDeleteFramebuffersEXT',
2101 'resource_type': 'Framebuffer',
2102 'resource_types': 'Framebuffers',
2104 'DeleteProgram': { 'type': 'Delete' },
2105 'DeleteRenderbuffers': {
2107 'gl_test_func': 'glDeleteRenderbuffersEXT',
2108 'resource_type': 'Renderbuffer',
2109 'resource_types': 'Renderbuffers',
2113 'resource_type': 'Sampler',
2114 'resource_types': 'Samplers',
2117 'DeleteShader': { 'type': 'Delete' },
2120 'cmd_args': 'GLuint sync',
2121 'resource_type': 'Sync',
2126 'resource_type': 'Texture',
2127 'resource_types': 'Textures',
2129 'DeleteTransformFeedbacks': {
2131 'resource_type': 'TransformFeedback',
2132 'resource_types': 'TransformFeedbacks',
2136 'decoder_func': 'DoDepthRangef',
2137 'gl_test_func': 'glDepthRange',
2141 'state': 'DepthMask',
2143 'expectation': False,
2145 'DetachShader': {'decoder_func': 'DoDetachShader'},
2147 'decoder_func': 'DoDisable',
2149 'client_test': False,
2151 'DisableVertexAttribArray': {
2152 'decoder_func': 'DoDisableVertexAttribArray',
2157 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count',
2158 'defer_draws': True,
2163 'cmd_args': 'GLenumDrawMode mode, GLsizei count, '
2164 'GLenumIndexType type, GLuint index_offset',
2165 'client_test': False,
2166 'defer_draws': True,
2169 'DrawRangeElements': {
2175 'decoder_func': 'DoEnable',
2177 'client_test': False,
2179 'EnableVertexAttribArray': {
2180 'decoder_func': 'DoEnableVertexAttribArray',
2185 'client_test': False,
2190 'client_test': False,
2191 'decoder_func': 'DoFinish',
2192 'defer_reads': True,
2196 'decoder_func': 'DoFlush',
2198 'FramebufferRenderbuffer': {
2199 'decoder_func': 'DoFramebufferRenderbuffer',
2200 'gl_test_func': 'glFramebufferRenderbufferEXT',
2202 'FramebufferTexture2D': {
2203 'decoder_func': 'DoFramebufferTexture2D',
2204 'gl_test_func': 'glFramebufferTexture2DEXT',
2207 'FramebufferTexture2DMultisampleEXT': {
2208 'decoder_func': 'DoFramebufferTexture2DMultisample',
2209 'gl_test_func': 'glFramebufferTexture2DMultisampleEXT',
2210 'expectation': False,
2212 'extension_flag': 'multisampled_render_to_texture',
2215 'FramebufferTextureLayer': {
2216 'decoder_func': 'DoFramebufferTextureLayer',
2220 'decoder_func': 'DoGenerateMipmap',
2221 'gl_test_func': 'glGenerateMipmapEXT',
2225 'gl_test_func': 'glGenBuffersARB',
2226 'resource_type': 'Buffer',
2227 'resource_types': 'Buffers',
2229 'GenMailboxCHROMIUM': {
2230 'type': 'HandWritten',
2232 'extension': "CHROMIUM_texture_mailbox",
2235 'GenFramebuffers': {
2237 'gl_test_func': 'glGenFramebuffersEXT',
2238 'resource_type': 'Framebuffer',
2239 'resource_types': 'Framebuffers',
2241 'GenRenderbuffers': {
2242 'type': 'GENn', 'gl_test_func': 'glGenRenderbuffersEXT',
2243 'resource_type': 'Renderbuffer',
2244 'resource_types': 'Renderbuffers',
2248 'gl_test_func': 'glGenSamplers',
2249 'resource_type': 'Sampler',
2250 'resource_types': 'Samplers',
2255 'gl_test_func': 'glGenTextures',
2256 'resource_type': 'Texture',
2257 'resource_types': 'Textures',
2259 'GenTransformFeedbacks': {
2261 'gl_test_func': 'glGenTransformFeedbacks',
2262 'resource_type': 'TransformFeedback',
2263 'resource_types': 'TransformFeedbacks',
2266 'GetActiveAttrib': {
2268 'data_transfer_methods': ['shm'],
2270 'GLidProgram program, GLuint index, uint32_t name_bucket_id, '
2278 'GetActiveUniform': {
2280 'data_transfer_methods': ['shm'],
2282 'GLidProgram program, GLuint index, uint32_t name_bucket_id, '
2290 'GetActiveUniformBlockiv': {
2292 'data_transfer_methods': ['shm'],
2293 'result': ['SizedResult<GLint>'],
2296 'GetActiveUniformBlockName': {
2298 'data_transfer_methods': ['shm'],
2300 'GLidProgram program, GLuint index, uint32_t name_bucket_id, '
2302 'result': ['int32_t'],
2305 'GetActiveUniformsiv': {
2307 'data_transfer_methods': ['shm'],
2309 'GLidProgram program, uint32_t indices_bucket_id, GLenum pname, '
2311 'result': ['SizedResult<GLint>'],
2314 'GetAttachedShaders': {
2316 'data_transfer_methods': ['shm'],
2317 'cmd_args': 'GLidProgram program, void* result, uint32_t result_size',
2318 'result': ['SizedResult<GLuint>'],
2320 'GetAttribLocation': {
2322 'data_transfer_methods': ['shm'],
2324 'GLidProgram program, uint32_t name_bucket_id, GLint* location',
2325 'result': ['GLint'],
2328 'GetFragDataLocation': {
2330 'data_transfer_methods': ['shm'],
2332 'GLidProgram program, uint32_t name_bucket_id, GLint* location',
2333 'result': ['GLint'],
2339 'result': ['SizedResult<GLboolean>'],
2340 'decoder_func': 'DoGetBooleanv',
2341 'gl_test_func': 'glGetBooleanv',
2343 'GetBufferParameteriv': {
2345 'result': ['SizedResult<GLint>'],
2346 'decoder_func': 'DoGetBufferParameteriv',
2347 'expectation': False,
2352 'decoder_func': 'GetErrorState()->GetGLError',
2354 'result': ['GLenum'],
2355 'client_test': False,
2359 'result': ['SizedResult<GLfloat>'],
2360 'decoder_func': 'DoGetFloatv',
2361 'gl_test_func': 'glGetFloatv',
2363 'GetFramebufferAttachmentParameteriv': {
2365 'decoder_func': 'DoGetFramebufferAttachmentParameteriv',
2366 'gl_test_func': 'glGetFramebufferAttachmentParameterivEXT',
2367 'result': ['SizedResult<GLint>'],
2371 'result': ['SizedResult<GLint>'],
2372 'decoder_func': 'DoGetIntegerv',
2373 'client_test': False,
2375 'GetInternalformativ': {
2377 'result': ['SizedResult<GLint>'],
2380 'GetMaxValueInBufferCHROMIUM': {
2382 'decoder_func': 'DoGetMaxValueInBufferCHROMIUM',
2383 'result': ['GLuint'],
2385 'client_test': False,
2392 'decoder_func': 'DoGetProgramiv',
2393 'result': ['SizedResult<GLint>'],
2394 'expectation': False,
2396 'GetProgramInfoCHROMIUM': {
2398 'expectation': False,
2402 'client_test': False,
2403 'cmd_args': 'GLidProgram program, uint32_t bucket_id',
2405 'uint32_t link_status',
2406 'uint32_t num_attribs',
2407 'uint32_t num_uniforms',
2410 'GetProgramInfoLog': {
2412 'expectation': False,
2414 'GetRenderbufferParameteriv': {
2416 'decoder_func': 'DoGetRenderbufferParameteriv',
2417 'gl_test_func': 'glGetRenderbufferParameterivEXT',
2418 'result': ['SizedResult<GLint>'],
2420 'GetSamplerParameterfv': {
2422 'result': ['SizedResult<GLfloat>'],
2423 'id_mapping': [ 'Sampler' ],
2426 'GetSamplerParameteriv': {
2428 'result': ['SizedResult<GLint>'],
2429 'id_mapping': [ 'Sampler' ],
2434 'decoder_func': 'DoGetShaderiv',
2435 'result': ['SizedResult<GLint>'],
2437 'GetShaderInfoLog': {
2439 'get_len_func': 'glGetShaderiv',
2440 'get_len_enum': 'GL_INFO_LOG_LENGTH',
2443 'GetShaderPrecisionFormat': {
2445 'data_transfer_methods': ['shm'],
2447 'GLenumShaderType shadertype, GLenumShaderPrecision precisiontype, '
2451 'int32_t min_range',
2452 'int32_t max_range',
2453 'int32_t precision',
2456 'GetShaderSource': {
2458 'get_len_func': 'DoGetShaderiv',
2459 'get_len_enum': 'GL_SHADER_SOURCE_LENGTH',
2461 'client_test': False,
2465 'client_test': False,
2466 'cmd_args': 'GLenumStringType name, uint32_t bucket_id',
2470 'cmd_args': 'GLuint sync, GLenumSyncParameter pname, void* values',
2471 'result': ['SizedResult<GLint>'],
2472 'id_mapping': ['Sync'],
2475 'GetTexParameterfv': {
2477 'decoder_func': 'DoGetTexParameterfv',
2478 'result': ['SizedResult<GLfloat>']
2480 'GetTexParameteriv': {
2482 'decoder_func': 'DoGetTexParameteriv',
2483 'result': ['SizedResult<GLint>']
2485 'GetTranslatedShaderSourceANGLE': {
2487 'get_len_func': 'DoGetShaderiv',
2488 'get_len_enum': 'GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE',
2492 'GetUniformBlockIndex': {
2494 'data_transfer_methods': ['shm'],
2496 'GLidProgram program, uint32_t name_bucket_id, GLuint* index',
2497 'result': ['GLuint'],
2498 'error_return': 'GL_INVALID_INDEX',
2501 'GetUniformBlocksCHROMIUM': {
2503 'expectation': False,
2507 'client_test': False,
2508 'cmd_args': 'GLidProgram program, uint32_t bucket_id',
2509 'result': ['uint32_t'],
2512 'GetUniformsES3CHROMIUM': {
2514 'expectation': False,
2518 'client_test': False,
2519 'cmd_args': 'GLidProgram program, uint32_t bucket_id',
2520 'result': ['uint32_t'],
2523 'GetTransformFeedbackVarying': {
2525 'data_transfer_methods': ['shm'],
2527 'GLidProgram program, GLuint index, uint32_t name_bucket_id, '
2536 'GetTransformFeedbackVaryingsCHROMIUM': {
2538 'expectation': False,
2542 'client_test': False,
2543 'cmd_args': 'GLidProgram program, uint32_t bucket_id',
2544 'result': ['uint32_t'],
2549 'data_transfer_methods': ['shm'],
2550 'result': ['SizedResult<GLfloat>'],
2554 'data_transfer_methods': ['shm'],
2555 'result': ['SizedResult<GLint>'],
2557 'GetUniformIndices': {
2559 'data_transfer_methods': ['shm'],
2560 'result': ['SizedResult<GLuint>'],
2561 'cmd_args': 'GLidProgram program, uint32_t names_bucket_id, '
2565 'GetUniformLocation': {
2567 'data_transfer_methods': ['shm'],
2569 'GLidProgram program, uint32_t name_bucket_id, GLint* location',
2570 'result': ['GLint'],
2571 'error_return': -1, # http://www.opengl.org/sdk/docs/man/xhtml/glGetUniformLocation.xml
2573 'GetVertexAttribfv': {
2575 'result': ['SizedResult<GLfloat>'],
2577 'decoder_func': 'DoGetVertexAttribfv',
2578 'expectation': False,
2579 'client_test': False,
2581 'GetVertexAttribiv': {
2583 'result': ['SizedResult<GLint>'],
2585 'decoder_func': 'DoGetVertexAttribiv',
2586 'expectation': False,
2587 'client_test': False,
2589 'GetVertexAttribPointerv': {
2591 'data_transfer_methods': ['shm'],
2592 'result': ['SizedResult<GLuint>'],
2593 'client_test': False,
2595 'InvalidateFramebuffer': {
2598 'client_test': False,
2602 'InvalidateSubFramebuffer': {
2605 'client_test': False,
2611 'decoder_func': 'DoIsBuffer',
2612 'expectation': False,
2616 'decoder_func': 'DoIsEnabled',
2617 'client_test': False,
2619 'expectation': False,
2623 'decoder_func': 'DoIsFramebuffer',
2624 'expectation': False,
2628 'decoder_func': 'DoIsProgram',
2629 'expectation': False,
2633 'decoder_func': 'DoIsRenderbuffer',
2634 'expectation': False,
2638 'decoder_func': 'DoIsShader',
2639 'expectation': False,
2643 'id_mapping': [ 'Sampler' ],
2644 'expectation': False,
2649 'id_mapping': [ 'Sync' ],
2650 'cmd_args': 'GLuint sync',
2651 'expectation': False,
2656 'decoder_func': 'DoIsTexture',
2657 'expectation': False,
2659 'IsTransformFeedback': {
2661 'id_mapping': [ 'TransformFeedback' ],
2662 'expectation': False,
2666 'decoder_func': 'DoLinkProgram',
2669 'MapBufferCHROMIUM': {
2673 'client_test': False,
2675 'MapBufferSubDataCHROMIUM': {
2679 'client_test': False,
2680 'pepper_interface': 'ChromiumMapSub',
2682 'MapTexSubImage2DCHROMIUM': {
2684 'extension': "CHROMIUM_sub_image",
2686 'client_test': False,
2687 'pepper_interface': 'ChromiumMapSub',
2691 'data_transfer_methods': ['shm'],
2692 'cmd_args': 'GLenumBufferTarget target, GLintptrNotNegative offset, '
2693 'GLsizeiptr size, GLbitfieldMapBufferAccess access, '
2694 'uint32_t data_shm_id, uint32_t data_shm_offset, '
2695 'uint32_t result_shm_id, uint32_t result_shm_offset',
2697 'result': ['uint32_t'],
2699 'PauseTransformFeedback': {
2702 'PixelStorei': {'type': 'Manual'},
2703 'PostSubBufferCHROMIUM': {
2707 'client_test': False,
2711 'ProduceTextureCHROMIUM': {
2712 'decoder_func': 'DoProduceTextureCHROMIUM',
2715 'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
2717 'client_test': False,
2718 'extension': "CHROMIUM_texture_mailbox",
2722 'ProduceTextureDirectCHROMIUM': {
2723 'decoder_func': 'DoProduceTextureDirectCHROMIUM',
2726 'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
2728 'client_test': False,
2729 'extension': "CHROMIUM_texture_mailbox",
2733 'RenderbufferStorage': {
2734 'decoder_func': 'DoRenderbufferStorage',
2735 'gl_test_func': 'glRenderbufferStorageEXT',
2736 'expectation': False,
2738 'RenderbufferStorageMultisampleCHROMIUM': {
2740 '// GL_CHROMIUM_framebuffer_multisample\n',
2741 'decoder_func': 'DoRenderbufferStorageMultisampleCHROMIUM',
2742 'gl_test_func': 'glRenderbufferStorageMultisampleCHROMIUM',
2743 'expectation': False,
2745 'extension_flag': 'chromium_framebuffer_multisample',
2746 'pepper_interface': 'FramebufferMultisample',
2747 'pepper_name': 'RenderbufferStorageMultisampleEXT',
2749 'RenderbufferStorageMultisampleEXT': {
2751 '// GL_EXT_multisampled_render_to_texture\n',
2752 'decoder_func': 'DoRenderbufferStorageMultisampleEXT',
2753 'gl_test_func': 'glRenderbufferStorageMultisampleEXT',
2754 'expectation': False,
2756 'extension_flag': 'multisampled_render_to_texture',
2763 '// ReadPixels has the result separated from the pixel buffer so that\n'
2764 '// it is easier to specify the result going to some specific place\n'
2765 '// that exactly fits the rectangle of pixels.\n',
2767 'data_transfer_methods': ['shm'],
2769 'client_test': False,
2771 'GLint x, GLint y, GLsizei width, GLsizei height, '
2772 'GLenumReadPixelFormat format, GLenumReadPixelType type, '
2773 'uint32_t pixels_shm_id, uint32_t pixels_shm_offset, '
2774 'uint32_t result_shm_id, uint32_t result_shm_offset, '
2776 'result': ['uint32_t'],
2777 'defer_reads': True,
2779 'ReleaseShaderCompiler': {
2780 'decoder_func': 'DoReleaseShaderCompiler',
2783 'ResumeTransformFeedback': {
2786 'SamplerParameterf': {
2790 'id_mapping': [ 'Sampler' ],
2793 'SamplerParameterfv': {
2795 'data_value': 'GL_NEAREST',
2797 'gl_test_func': 'glSamplerParameterf',
2798 'decoder_func': 'DoSamplerParameterfv',
2799 'first_element_only': True,
2800 'id_mapping': [ 'Sampler' ],
2803 'SamplerParameteri': {
2807 'id_mapping': [ 'Sampler' ],
2810 'SamplerParameteriv': {
2812 'data_value': 'GL_NEAREST',
2814 'gl_test_func': 'glSamplerParameteri',
2815 'decoder_func': 'DoSamplerParameteriv',
2816 'first_element_only': True,
2821 'client_test': False,
2825 'decoder_func': 'DoShaderSource',
2826 'expectation': False,
2827 'data_transfer_methods': ['bucket'],
2829 'GLuint shader, const char** str',
2831 'GLuint shader, GLsizei count, const char** str, const GLint* length',
2834 'type': 'StateSetFrontBack',
2835 'state': 'StencilMask',
2837 'expectation': False,
2839 'StencilMaskSeparate': {
2840 'type': 'StateSetFrontBackSeparate',
2841 'state': 'StencilMask',
2843 'expectation': False,
2847 'decoder_func': 'DoSwapBuffers',
2849 'client_test': False,
2855 'decoder_func': 'DoSwapInterval',
2857 'client_test': False,
2863 'data_transfer_methods': ['shm'],
2864 'client_test': False,
2868 'data_transfer_methods': ['shm'],
2869 'client_test': False,
2873 'decoder_func': 'DoTexParameterf',
2879 'decoder_func': 'DoTexParameteri',
2886 'data_value': 'GL_NEAREST',
2888 'decoder_func': 'DoTexParameterfv',
2889 'gl_test_func': 'glTexParameterf',
2890 'first_element_only': True,
2894 'data_value': 'GL_NEAREST',
2896 'decoder_func': 'DoTexParameteriv',
2897 'gl_test_func': 'glTexParameteri',
2898 'first_element_only': True,
2905 'data_transfer_methods': ['shm'],
2906 'client_test': False,
2907 'cmd_args': 'GLenumTextureTarget target, GLint level, '
2908 'GLint xoffset, GLint yoffset, '
2909 'GLsizei width, GLsizei height, '
2910 'GLenumTextureFormat format, GLenumPixelType type, '
2911 'const void* pixels, GLboolean internal'
2915 'data_transfer_methods': ['shm'],
2916 'client_test': False,
2917 'cmd_args': 'GLenumTextureTarget target, GLint level, '
2918 'GLint xoffset, GLint yoffset, GLint zoffset, '
2919 'GLsizei width, GLsizei height, GLsizei depth, '
2920 'GLenumTextureFormat format, GLenumPixelType type, '
2921 'const void* pixels, GLboolean internal',
2924 'TransformFeedbackVaryings': {
2926 'data_transfer_methods': ['bucket'],
2927 'decoder_func': 'DoTransformFeedbackVaryings',
2929 'GLuint program, const char** varyings, GLenum buffermode',
2932 'Uniform1f': {'type': 'PUTXn', 'count': 1},
2936 'decoder_func': 'DoUniform1fv',
2938 'Uniform1i': {'decoder_func': 'DoUniform1i', 'unit_test': False},
2942 'decoder_func': 'DoUniform1iv',
2955 'Uniform2i': {'type': 'PUTXn', 'count': 2},
2956 'Uniform2f': {'type': 'PUTXn', 'count': 2},
2960 'decoder_func': 'DoUniform2fv',
2965 'decoder_func': 'DoUniform2iv',
2977 'Uniform3i': {'type': 'PUTXn', 'count': 3},
2978 'Uniform3f': {'type': 'PUTXn', 'count': 3},
2982 'decoder_func': 'DoUniform3fv',
2987 'decoder_func': 'DoUniform3iv',
2999 'Uniform4i': {'type': 'PUTXn', 'count': 4},
3000 'Uniform4f': {'type': 'PUTXn', 'count': 4},
3004 'decoder_func': 'DoUniform4fv',
3009 'decoder_func': 'DoUniform4iv',
3021 'UniformMatrix2fv': {
3024 'decoder_func': 'DoUniformMatrix2fv',
3026 'UniformMatrix2x3fv': {
3031 'UniformMatrix2x4fv': {
3036 'UniformMatrix3fv': {
3039 'decoder_func': 'DoUniformMatrix3fv',
3041 'UniformMatrix3x2fv': {
3046 'UniformMatrix3x4fv': {
3051 'UniformMatrix4fv': {
3054 'decoder_func': 'DoUniformMatrix4fv',
3056 'UniformMatrix4x2fv': {
3061 'UniformMatrix4x3fv': {
3066 'UniformBlockBinding': {
3071 'UnmapBufferCHROMIUM': {
3075 'client_test': False,
3077 'UnmapBufferSubDataCHROMIUM': {
3081 'client_test': False,
3082 'pepper_interface': 'ChromiumMapSub',
3088 'UnmapTexSubImage2DCHROMIUM': {
3090 'extension': "CHROMIUM_sub_image",
3092 'client_test': False,
3093 'pepper_interface': 'ChromiumMapSub',
3097 'decoder_func': 'DoUseProgram',
3099 'ValidateProgram': {'decoder_func': 'DoValidateProgram'},
3100 'VertexAttrib1f': {'decoder_func': 'DoVertexAttrib1f'},
3101 'VertexAttrib1fv': {
3104 'decoder_func': 'DoVertexAttrib1fv',
3106 'VertexAttrib2f': {'decoder_func': 'DoVertexAttrib2f'},
3107 'VertexAttrib2fv': {
3110 'decoder_func': 'DoVertexAttrib2fv',
3112 'VertexAttrib3f': {'decoder_func': 'DoVertexAttrib3f'},
3113 'VertexAttrib3fv': {
3116 'decoder_func': 'DoVertexAttrib3fv',
3118 'VertexAttrib4f': {'decoder_func': 'DoVertexAttrib4f'},
3119 'VertexAttrib4fv': {
3122 'decoder_func': 'DoVertexAttrib4fv',
3124 'VertexAttribI4i': {
3127 'VertexAttribI4iv': {
3132 'VertexAttribI4ui': {
3135 'VertexAttribI4uiv': {
3140 'VertexAttribIPointer': {
3142 'cmd_args': 'GLuint indx, GLintVertexAttribSize size, '
3143 'GLenumVertexAttribType type, GLsizei stride, '
3145 'client_test': False,
3148 'VertexAttribPointer': {
3150 'cmd_args': 'GLuint indx, GLintVertexAttribSize size, '
3151 'GLenumVertexAttribType type, GLboolean normalized, '
3152 'GLsizei stride, GLuint offset',
3153 'client_test': False,
3157 'cmd_args': 'GLuint sync, GLbitfieldSyncFlushFlags flags, '
3158 'GLuint timeout_0, GLuint timeout_1',
3160 'client_test': False,
3168 'decoder_func': 'DoViewport',
3177 'GetRequestableExtensionsCHROMIUM': {
3180 'cmd_args': 'uint32_t bucket_id',
3184 'RequestExtensionCHROMIUM': {
3187 'client_test': False,
3188 'cmd_args': 'uint32_t bucket_id',
3192 'RateLimitOffscreenContextCHROMIUM': {
3196 'client_test': False,
3198 'CreateStreamTextureCHROMIUM': {
3199 'type': 'HandWritten',
3205 'TexImageIOSurface2DCHROMIUM': {
3206 'decoder_func': 'DoTexImageIOSurface2DCHROMIUM',
3211 'CopyTextureCHROMIUM': {
3212 'decoder_func': 'DoCopyTextureCHROMIUM',
3217 'CopySubTextureCHROMIUM': {
3218 'decoder_func': 'DoCopySubTextureCHROMIUM',
3223 'TexStorage2DEXT': {
3226 'decoder_func': 'DoTexStorage2DEXT',
3228 'DrawArraysInstancedANGLE': {
3230 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count, '
3231 'GLsizei primcount',
3234 'pepper_interface': 'InstancedArrays',
3235 'defer_draws': True,
3239 'decoder_func': 'DoDrawBuffersEXT',
3241 'client_test': False,
3243 # could use 'extension_flag': 'ext_draw_buffers' but currently expected to
3246 'pepper_interface': 'DrawBuffers',
3248 'DrawElementsInstancedANGLE': {
3250 'cmd_args': 'GLenumDrawMode mode, GLsizei count, '
3251 'GLenumIndexType type, GLuint index_offset, GLsizei primcount',
3254 'client_test': False,
3255 'pepper_interface': 'InstancedArrays',
3256 'defer_draws': True,
3258 'VertexAttribDivisorANGLE': {
3260 'cmd_args': 'GLuint index, GLuint divisor',
3263 'pepper_interface': 'InstancedArrays',
3267 'gl_test_func': 'glGenQueriesARB',
3268 'resource_type': 'Query',
3269 'resource_types': 'Queries',
3271 'pepper_interface': 'Query',
3272 'not_shared': 'True',
3273 'extension': "occlusion_query_EXT",
3275 'DeleteQueriesEXT': {
3277 'gl_test_func': 'glDeleteQueriesARB',
3278 'resource_type': 'Query',
3279 'resource_types': 'Queries',
3281 'pepper_interface': 'Query',
3282 'extension': "occlusion_query_EXT",
3286 'client_test': False,
3287 'pepper_interface': 'Query',
3288 'extension': "occlusion_query_EXT",
3292 'cmd_args': 'GLenumQueryTarget target, GLidQuery id, void* sync_data',
3293 'data_transfer_methods': ['shm'],
3294 'gl_test_func': 'glBeginQuery',
3295 'pepper_interface': 'Query',
3296 'extension': "occlusion_query_EXT",
3298 'BeginTransformFeedback': {
3303 'cmd_args': 'GLenumQueryTarget target, GLuint submit_count',
3304 'gl_test_func': 'glEndnQuery',
3305 'client_test': False,
3306 'pepper_interface': 'Query',
3307 'extension': "occlusion_query_EXT",
3309 'EndTransformFeedback': {
3314 'client_test': False,
3315 'gl_test_func': 'glGetQueryiv',
3316 'pepper_interface': 'Query',
3317 'extension': "occlusion_query_EXT",
3319 'GetQueryObjectuivEXT': {
3321 'client_test': False,
3322 'gl_test_func': 'glGetQueryObjectuiv',
3323 'pepper_interface': 'Query',
3324 'extension': "occlusion_query_EXT",
3326 'BindUniformLocationCHROMIUM': {
3329 'data_transfer_methods': ['bucket'],
3331 'gl_test_func': 'DoBindUniformLocationCHROMIUM',
3333 'InsertEventMarkerEXT': {
3335 'decoder_func': 'DoInsertEventMarkerEXT',
3336 'expectation': False,
3339 'PushGroupMarkerEXT': {
3341 'decoder_func': 'DoPushGroupMarkerEXT',
3342 'expectation': False,
3345 'PopGroupMarkerEXT': {
3346 'decoder_func': 'DoPopGroupMarkerEXT',
3347 'expectation': False,
3352 'GenVertexArraysOES': {
3355 'gl_test_func': 'glGenVertexArraysOES',
3356 'resource_type': 'VertexArray',
3357 'resource_types': 'VertexArrays',
3359 'pepper_interface': 'VertexArrayObject',
3361 'BindVertexArrayOES': {
3364 'gl_test_func': 'glBindVertexArrayOES',
3365 'decoder_func': 'DoBindVertexArrayOES',
3366 'gen_func': 'GenVertexArraysOES',
3368 'client_test': False,
3369 'pepper_interface': 'VertexArrayObject',
3371 'DeleteVertexArraysOES': {
3374 'gl_test_func': 'glDeleteVertexArraysOES',
3375 'resource_type': 'VertexArray',
3376 'resource_types': 'VertexArrays',
3378 'pepper_interface': 'VertexArrayObject',
3380 'IsVertexArrayOES': {
3383 'gl_test_func': 'glIsVertexArrayOES',
3384 'decoder_func': 'DoIsVertexArrayOES',
3385 'expectation': False,
3387 'pepper_interface': 'VertexArrayObject',
3389 'BindTexImage2DCHROMIUM': {
3390 'decoder_func': 'DoBindTexImage2DCHROMIUM',
3395 'ReleaseTexImage2DCHROMIUM': {
3396 'decoder_func': 'DoReleaseTexImage2DCHROMIUM',
3401 'ShallowFinishCHROMIUM': {
3406 'client_test': False,
3408 'ShallowFlushCHROMIUM': {
3411 'extension': "CHROMIUM_miscellaneous",
3413 'client_test': False,
3415 'OrderingBarrierCHROMIUM': {
3420 'client_test': False,
3422 'TraceBeginCHROMIUM': {
3425 'client_test': False,
3426 'cmd_args': 'GLuint category_bucket_id, GLuint name_bucket_id',
3430 'TraceEndCHROMIUM': {
3432 'client_test': False,
3433 'decoder_func': 'DoTraceEndCHROMIUM',
3438 'AsyncTexImage2DCHROMIUM': {
3440 'data_transfer_methods': ['shm'],
3441 'client_test': False,
3442 'cmd_args': 'GLenumTextureTarget target, GLint level, '
3443 'GLintTextureInternalFormat internalformat, '
3444 'GLsizei width, GLsizei height, '
3445 'GLintTextureBorder border, '
3446 'GLenumTextureFormat format, GLenumPixelType type, '
3447 'const void* pixels, '
3448 'uint32_t async_upload_token, '
3453 'AsyncTexSubImage2DCHROMIUM': {
3455 'data_transfer_methods': ['shm'],
3456 'client_test': False,
3457 'cmd_args': 'GLenumTextureTarget target, GLint level, '
3458 'GLint xoffset, GLint yoffset, '
3459 'GLsizei width, GLsizei height, '
3460 'GLenumTextureFormat format, GLenumPixelType type, '
3461 'const void* data, '
3462 'uint32_t async_upload_token, '
3467 'WaitAsyncTexImage2DCHROMIUM': {
3469 'client_test': False,
3473 'WaitAllAsyncTexImage2DCHROMIUM': {
3475 'client_test': False,
3479 'DiscardFramebufferEXT': {
3482 'decoder_func': 'DoDiscardFramebufferEXT',
3484 'client_test': False,
3485 'extension_flag': 'ext_discard_framebuffer',
3487 'LoseContextCHROMIUM': {
3488 'decoder_func': 'DoLoseContextCHROMIUM',
3493 'InsertSyncPointCHROMIUM': {
3494 'type': 'HandWritten',
3496 'extension': "CHROMIUM_sync_point",
3499 'WaitSyncPointCHROMIUM': {
3502 'extension': "CHROMIUM_sync_point",
3506 'DiscardBackbufferCHROMIUM': {
3512 'ScheduleOverlayPlaneCHROMIUM': {
3516 'client_test': False,
3520 'MatrixLoadfCHROMIUM': {
3523 'data_type': 'GLfloat',
3524 'decoder_func': 'DoMatrixLoadfCHROMIUM',
3525 'gl_test_func': 'glMatrixLoadfEXT',
3528 'extension_flag': 'chromium_path_rendering',
3530 'MatrixLoadIdentityCHROMIUM': {
3531 'decoder_func': 'DoMatrixLoadIdentityCHROMIUM',
3532 'gl_test_func': 'glMatrixLoadIdentityEXT',
3535 'extension_flag': 'chromium_path_rendering',
3540 def Grouper(n
, iterable
, fillvalue
=None):
3541 """Collect data into fixed-length chunks or blocks"""
3542 args
= [iter(iterable
)] * n
3543 return itertools
.izip_longest(fillvalue
=fillvalue
, *args
)
3546 def SplitWords(input_string
):
3547 """Transforms a input_string into a list of lower-case components.
3550 input_string: the input string.
3553 a list of lower-case words.
3555 if input_string
.find('_') > -1:
3556 # 'some_TEXT_' -> 'some text'
3557 return input_string
.replace('_', ' ').strip().lower().split()
3559 if re
.search('[A-Z]', input_string
) and re
.search('[a-z]', input_string
):
3561 # look for capitalization to cut input_strings
3562 # 'SomeText' -> 'Some Text'
3563 input_string
= re
.sub('([A-Z])', r
' \1', input_string
).strip()
3564 # 'Vector3' -> 'Vector 3'
3565 input_string
= re
.sub('([^0-9])([0-9])', r
'\1 \2', input_string
)
3566 return input_string
.lower().split()
3570 """Makes a lower-case identifier from words.
3573 words: a list of lower-case words.
3576 the lower-case identifier.
3578 return '_'.join(words
)
3581 def ToUnderscore(input_string
):
3582 """converts CamelCase to camel_case."""
3583 words
= SplitWords(input_string
)
3586 def CachedStateName(item
):
3587 if item
.get('cached', False):
3588 return 'cached_' + item
['name']
3591 def ToGLExtensionString(extension_flag
):
3592 """Returns GL-type extension string of a extension flag."""
3593 if extension_flag
== "oes_compressed_etc1_rgb8_texture":
3594 return "OES_compressed_ETC1_RGB8_texture" # Fixup inconsitency with rgb8,
3596 uppercase_words
= [ 'img', 'ext', 'arb', 'chromium', 'oes', 'amd', 'bgra8888',
3597 'egl', 'atc', 'etc1', 'angle']
3598 parts
= extension_flag
.split('_')
3600 [part
.upper() if part
in uppercase_words
else part
for part
in parts
])
3602 def ToCamelCase(input_string
):
3603 """converts ABC_underscore_case to ABCUnderscoreCase."""
3604 return ''.join(w
[0].upper() + w
[1:] for w
in input_string
.split('_'))
3606 def GetGLGetTypeConversion(result_type
, value_type
, value
):
3607 """Makes a gl compatible type conversion string for accessing state variables.
3609 Useful when accessing state variables through glGetXXX calls.
3610 glGet documetation (for example, the manual pages):
3611 [...] If glGetIntegerv is called, [...] most floating-point values are
3612 rounded to the nearest integer value. [...]
3615 result_type: the gl type to be obtained
3616 value_type: the GL type of the state variable
3617 value: the name of the state variable
3620 String that converts the state variable to desired GL type according to GL
3624 if result_type
== 'GLint':
3625 if value_type
== 'GLfloat':
3626 return 'static_cast<GLint>(round(%s))' % value
3627 return 'static_cast<%s>(%s)' % (result_type
, value
)
3629 class CWriter(object):
3630 """Writes to a file formatting it for Google's style guidelines."""
3632 def __init__(self
, filename
):
3633 self
.filename
= filename
3636 def Write(self
, string
):
3637 """Writes a string to a file spliting if it's > 80 characters."""
3638 lines
= string
.splitlines()
3639 num_lines
= len(lines
)
3640 for ii
in range(0, num_lines
):
3641 self
.content
.append(lines
[ii
])
3642 if ii
< (num_lines
- 1) or string
[-1] == '\n':
3643 self
.content
.append('\n')
3646 """Close the file."""
3647 content
= "".join(self
.content
)
3649 if os
.path
.exists(self
.filename
):
3650 old_file
= open(self
.filename
, "rb");
3651 old_content
= old_file
.read()
3653 if content
== old_content
:
3656 file = open(self
.filename
, "wb")
3661 class CHeaderWriter(CWriter
):
3662 """Writes a C Header file."""
3664 _non_alnum_re
= re
.compile(r
'[^a-zA-Z0-9]')
3666 def __init__(self
, filename
, file_comment
= None):
3667 CWriter
.__init
__(self
, filename
)
3669 base
= os
.path
.abspath(filename
)
3670 while os
.path
.basename(base
) != 'src':
3671 new_base
= os
.path
.dirname(base
)
3672 assert new_base
!= base
# Prevent infinite loop.
3675 hpath
= os
.path
.relpath(filename
, base
)
3676 self
.guard
= self
._non
_alnum
_re
.sub('_', hpath
).upper() + '_'
3678 self
.Write(_LICENSE
)
3679 self
.Write(_DO_NOT_EDIT_WARNING
)
3680 if not file_comment
== None:
3681 self
.Write(file_comment
)
3682 self
.Write("#ifndef %s\n" % self
.guard
)
3683 self
.Write("#define %s\n\n" % self
.guard
)
3686 self
.Write("#endif // %s\n\n" % self
.guard
)
3689 class TypeHandler(object):
3690 """This class emits code for a particular type of function."""
3692 _remove_expected_call_re
= re
.compile(r
' EXPECT_CALL.*?;\n', re
.S
)
3697 def InitFunction(self
, func
):
3698 """Add or adjust anything type specific for this function."""
3699 if func
.GetInfo('needs_size') and not func
.name
.endswith('Bucket'):
3700 func
.AddCmdArg(DataSizeArgument('data_size'))
3702 def NeedsDataTransferFunction(self
, func
):
3703 """Overriden from TypeHandler."""
3704 return func
.num_pointer_args
>= 1
3706 def WriteStruct(self
, func
, file):
3707 """Writes a structure that matches the arguments to a function."""
3708 comment
= func
.GetInfo('cmd_comment')
3709 if not comment
== None:
3711 file.Write("struct %s {\n" % func
.name
)
3712 file.Write(" typedef %s ValueType;\n" % func
.name
)
3713 file.Write(" static const CommandId kCmdId = k%s;\n" % func
.name
)
3714 func
.WriteCmdArgFlag(file)
3715 func
.WriteCmdFlag(file)
3717 result
= func
.GetInfo('result')
3718 if not result
== None:
3719 if len(result
) == 1:
3720 file.Write(" typedef %s Result;\n\n" % result
[0])
3722 file.Write(" struct Result {\n")
3724 file.Write(" %s;\n" % line
)
3725 file.Write(" };\n\n")
3727 func
.WriteCmdComputeSize(file)
3728 func
.WriteCmdSetHeader(file)
3729 func
.WriteCmdInit(file)
3730 func
.WriteCmdSet(file)
3732 file.Write(" gpu::CommandHeader header;\n")
3733 args
= func
.GetCmdArgs()
3735 file.Write(" %s %s;\n" % (arg
.cmd_type
, arg
.name
))
3737 consts
= func
.GetCmdConstants()
3738 for const
in consts
:
3739 file.Write(" static const %s %s = %s;\n" %
3740 (const
.cmd_type
, const
.name
, const
.GetConstantValue()))
3745 size
= len(args
) * _SIZE_OF_UINT32
+ _SIZE_OF_COMMAND_HEADER
3746 file.Write("static_assert(sizeof(%s) == %d,\n" % (func
.name
, size
))
3747 file.Write(" \"size of %s should be %d\");\n" %
3749 file.Write("static_assert(offsetof(%s, header) == 0,\n" % func
.name
)
3750 file.Write(" \"offset of %s header should be 0\");\n" %
3752 offset
= _SIZE_OF_COMMAND_HEADER
3754 file.Write("static_assert(offsetof(%s, %s) == %d,\n" %
3755 (func
.name
, arg
.name
, offset
))
3756 file.Write(" \"offset of %s %s should be %d\");\n" %
3757 (func
.name
, arg
.name
, offset
))
3758 offset
+= _SIZE_OF_UINT32
3759 if not result
== None and len(result
) > 1:
3762 parts
= line
.split()
3765 static_assert(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
3766 "offset of %(cmd_name)s Result %(field_name)s should be "
3769 file.Write((check
.strip() + "\n") % {
3770 'cmd_name': func
.name
,
3774 offset
+= _SIZE_OF_UINT32
3777 def WriteHandlerImplementation(self
, func
, file):
3778 """Writes the handler implementation for this command."""
3779 if func
.IsUnsafe() and func
.GetInfo('id_mapping'):
3780 code_no_gen
= """ if (!group_->Get%(type)sServiceId(
3781 %(var)s, &%(service_var)s)) {
3782 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "%(func)s", "invalid %(var)s id");
3783 return error::kNoError;
3786 code_gen
= """ if (!group_->Get%(type)sServiceId(
3787 %(var)s, &%(service_var)s)) {
3788 if (!group_->bind_generates_resource()) {
3790 GL_INVALID_OPERATION, "%(func)s", "invalid %(var)s id");
3791 return error::kNoError;
3793 GLuint client_id = %(var)s;
3794 gl%(gen_func)s(1, &%(service_var)s);
3795 Create%(type)s(client_id, %(service_var)s);
3798 gen_func
= func
.GetInfo('gen_func')
3799 for id_type
in func
.GetInfo('id_mapping'):
3800 service_var
= id_type
.lower()
3801 if id_type
== 'Sync':
3802 service_var
= "service_%s" % service_var
3803 file.Write(" GLsync %s = 0;\n" % service_var
)
3804 if gen_func
and id_type
in gen_func
:
3805 file.Write(code_gen
% { 'type': id_type
,
3806 'var': id_type
.lower(),
3807 'service_var': service_var
,
3808 'func': func
.GetGLFunctionName(),
3809 'gen_func': gen_func
})
3811 file.Write(code_no_gen
% { 'type': id_type
,
3812 'var': id_type
.lower(),
3813 'service_var': service_var
,
3814 'func': func
.GetGLFunctionName() })
3816 for arg
in func
.GetOriginalArgs():
3817 if arg
.type == "GLsync":
3818 args
.append("service_%s" % arg
.name
)
3819 elif arg
.name
.endswith("size") and arg
.type == "GLsizei":
3820 args
.append("num_%s" % func
.GetLastOriginalArg().name
)
3821 elif arg
.name
== "length":
3822 args
.append("nullptr")
3824 args
.append(arg
.name
)
3825 file.Write(" %s(%s);\n" %
3826 (func
.GetGLFunctionName(), ", ".join(args
)))
3828 def WriteCmdSizeTest(self
, func
, file):
3829 """Writes the size test for a command."""
3830 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n")
3832 def WriteFormatTest(self
, func
, file):
3833 """Writes a format test for a command."""
3834 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func
.name
)
3835 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" %
3836 (func
.name
, func
.name
))
3837 file.Write(" void* next_cmd = cmd.Set(\n")
3839 args
= func
.GetCmdArgs()
3840 for value
, arg
in enumerate(args
):
3841 file.Write(",\n static_cast<%s>(%d)" % (arg
.type, value
+ 11))
3843 file.Write(" EXPECT_EQ(static_cast<uint32_t>(cmds::%s::kCmdId),\n" %
3845 file.Write(" cmd.header.command);\n")
3846 func
.type_handler
.WriteCmdSizeTest(func
, file)
3847 for value
, arg
in enumerate(args
):
3848 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" %
3849 (arg
.type, value
+ 11, arg
.name
))
3850 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n")
3851 file.Write(" next_cmd, sizeof(cmd));\n")
3855 def WriteImmediateFormatTest(self
, func
, file):
3856 """Writes a format test for an immediate version of a command."""
3859 def WriteBucketFormatTest(self
, func
, file):
3860 """Writes a format test for a bucket version of a command."""
3863 def WriteGetDataSizeCode(self
, func
, file):
3864 """Writes the code to set data_size used in validation"""
3867 def WriteImmediateCmdSizeTest(self
, func
, file):
3868 """Writes a size test for an immediate version of a command."""
3869 file.Write(" // TODO(gman): Compute correct size.\n")
3870 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n")
3872 def __WriteIdMapping(self
, func
, file):
3873 """Writes client side / service side ID mapping."""
3874 if not func
.IsUnsafe() or not func
.GetInfo('id_mapping'):
3876 for id_type
in func
.GetInfo('id_mapping'):
3877 file.Write(" group_->Get%sServiceId(%s, &%s);\n" %
3878 (id_type
, id_type
.lower(), id_type
.lower()))
3880 def WriteImmediateHandlerImplementation (self
, func
, file):
3881 """Writes the handler impl for the immediate version of a command."""
3882 self
.__WriteIdMapping
(func
, file)
3883 file.Write(" %s(%s);\n" %
3884 (func
.GetGLFunctionName(), func
.MakeOriginalArgString("")))
3886 def WriteBucketHandlerImplementation (self
, func
, file):
3887 """Writes the handler impl for the bucket version of a command."""
3888 self
.__WriteIdMapping
(func
, file)
3889 file.Write(" %s(%s);\n" %
3890 (func
.GetGLFunctionName(), func
.MakeOriginalArgString("")))
3892 def WriteServiceHandlerFunctionHeader(self
, func
, file):
3893 """Writes function header for service implementation handlers."""
3894 file.Write("""error::Error GLES2DecoderImpl::Handle%(name)s(
3895 uint32_t immediate_data_size, const void* cmd_data) {
3896 """ % {'name': func
.name
})
3898 file.Write("""if (!unsafe_es3_apis_enabled())
3899 return error::kUnknownCommand;
3901 file.Write("""const gles2::cmds::%(name)s& c =
3902 *static_cast<const gles2::cmds::%(name)s*>(cmd_data);
3904 """ % {'name': func
.name
})
3906 def WriteServiceImplementation(self
, func
, file):
3907 """Writes the service implementation for a command."""
3908 self
.WriteServiceHandlerFunctionHeader(func
, file)
3909 self
.WriteHandlerExtensionCheck(func
, file)
3910 self
.WriteHandlerDeferReadWrite(func
, file);
3911 if len(func
.GetOriginalArgs()) > 0:
3912 last_arg
= func
.GetLastOriginalArg()
3913 all_but_last_arg
= func
.GetOriginalArgs()[:-1]
3914 for arg
in all_but_last_arg
:
3915 arg
.WriteGetCode(file)
3916 self
.WriteGetDataSizeCode(func
, file)
3917 last_arg
.WriteGetCode(file)
3918 func
.WriteHandlerValidation(file)
3919 func
.WriteHandlerImplementation(file)
3920 file.Write(" return error::kNoError;\n")
3924 def WriteImmediateServiceImplementation(self
, func
, file):
3925 """Writes the service implementation for an immediate version of command."""
3926 self
.WriteServiceHandlerFunctionHeader(func
, file)
3927 self
.WriteHandlerExtensionCheck(func
, file)
3928 self
.WriteHandlerDeferReadWrite(func
, file);
3929 for arg
in func
.GetOriginalArgs():
3931 self
.WriteGetDataSizeCode(func
, file)
3932 arg
.WriteGetCode(file)
3933 func
.WriteHandlerValidation(file)
3934 func
.WriteHandlerImplementation(file)
3935 file.Write(" return error::kNoError;\n")
3939 def WriteBucketServiceImplementation(self
, func
, file):
3940 """Writes the service implementation for a bucket version of command."""
3941 self
.WriteServiceHandlerFunctionHeader(func
, file)
3942 self
.WriteHandlerExtensionCheck(func
, file)
3943 self
.WriteHandlerDeferReadWrite(func
, file);
3944 for arg
in func
.GetCmdArgs():
3945 arg
.WriteGetCode(file)
3946 func
.WriteHandlerValidation(file)
3947 func
.WriteHandlerImplementation(file)
3948 file.Write(" return error::kNoError;\n")
3952 def WriteHandlerExtensionCheck(self
, func
, file):
3953 if func
.GetInfo('extension_flag'):
3954 file.Write(" if (!features().%s) {\n" % func
.GetInfo('extension_flag'))
3955 file.Write(" LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, \"gl%s\","
3956 " \"function not available\");\n" % func
.original_name
)
3957 file.Write(" return error::kNoError;")
3958 file.Write(" }\n\n")
3960 def WriteHandlerDeferReadWrite(self
, func
, file):
3961 """Writes the code to handle deferring reads or writes."""
3962 defer_draws
= func
.GetInfo('defer_draws')
3963 defer_reads
= func
.GetInfo('defer_reads')
3964 if defer_draws
or defer_reads
:
3965 file.Write(" error::Error error;\n")
3967 file.Write(" error = WillAccessBoundFramebufferForDraw();\n")
3968 file.Write(" if (error != error::kNoError)\n")
3969 file.Write(" return error;\n")
3971 file.Write(" error = WillAccessBoundFramebufferForRead();\n")
3972 file.Write(" if (error != error::kNoError)\n")
3973 file.Write(" return error;\n")
3975 def WriteValidUnitTest(self
, func
, file, test
, *extras
):
3976 """Writes a valid unit test for the service implementation."""
3977 if func
.GetInfo('expectation') == False:
3978 test
= self
._remove
_expected
_call
_re
.sub('', test
)
3981 arg
.GetValidArg(func
) \
3982 for arg
in func
.GetOriginalArgs() if not arg
.IsConstant()
3985 arg
.GetValidGLArg(func
) \
3986 for arg
in func
.GetOriginalArgs()
3988 gl_func_name
= func
.GetGLTestFunctionName()
3991 'gl_func_name': gl_func_name
,
3992 'args': ", ".join(arg_strings
),
3993 'gl_args': ", ".join(gl_arg_strings
),
3995 for extra
in extras
:
3998 while (old_test
!= test
):
4001 file.Write(test
% vars)
4003 def WriteInvalidUnitTest(self
, func
, file, test
, *extras
):
4004 """Writes an invalid unit test for the service implementation."""
4007 for invalid_arg_index
, invalid_arg
in enumerate(func
.GetOriginalArgs()):
4008 # Service implementation does not test constants, as they are not part of
4009 # the call in the service side.
4010 if invalid_arg
.IsConstant():
4013 num_invalid_values
= invalid_arg
.GetNumInvalidValues(func
)
4014 for value_index
in range(0, num_invalid_values
):
4016 parse_result
= "kNoError"
4018 for arg
in func
.GetOriginalArgs():
4019 if arg
.IsConstant():
4021 if invalid_arg
is arg
:
4022 (arg_string
, parse_result
, gl_error
) = arg
.GetInvalidArg(
4025 arg_string
= arg
.GetValidArg(func
)
4026 arg_strings
.append(arg_string
)
4028 for arg
in func
.GetOriginalArgs():
4029 gl_arg_strings
.append("_")
4030 gl_func_name
= func
.GetGLTestFunctionName()
4032 if not gl_error
== None:
4033 gl_error_test
= '\n EXPECT_EQ(%s, GetGLError());' % gl_error
4037 'arg_index': invalid_arg_index
,
4038 'value_index': value_index
,
4039 'gl_func_name': gl_func_name
,
4040 'args': ", ".join(arg_strings
),
4041 'all_but_last_args': ", ".join(arg_strings
[:-1]),
4042 'gl_args': ", ".join(gl_arg_strings
),
4043 'parse_result': parse_result
,
4044 'gl_error_test': gl_error_test
,
4046 for extra
in extras
:
4048 file.Write(test
% vars)
4050 def WriteServiceUnitTest(self
, func
, file, *extras
):
4051 """Writes the service unit test for a command."""
4053 if func
.name
== 'Enable':
4055 TEST_P(%(test_name)s, %(name)sValidArgs) {
4056 SetupExpectationsForEnableDisable(%(gl_args)s, true);
4057 SpecializedSetup<cmds::%(name)s, 0>(true);
4059 cmd.Init(%(args)s);"""
4060 elif func
.name
== 'Disable':
4062 TEST_P(%(test_name)s, %(name)sValidArgs) {
4063 SetupExpectationsForEnableDisable(%(gl_args)s, false);
4064 SpecializedSetup<cmds::%(name)s, 0>(true);
4066 cmd.Init(%(args)s);"""
4069 TEST_P(%(test_name)s, %(name)sValidArgs) {
4070 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
4071 SpecializedSetup<cmds::%(name)s, 0>(true);
4073 cmd.Init(%(args)s);"""
4076 decoder_->set_unsafe_es3_apis_enabled(true);
4077 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4078 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4079 decoder_->set_unsafe_es3_apis_enabled(false);
4080 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
4085 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4086 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4089 self
.WriteValidUnitTest(func
, file, valid_test
, *extras
)
4091 if not func
.IsUnsafe():
4093 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
4094 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
4095 SpecializedSetup<cmds::%(name)s, 0>(false);
4098 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
4101 self
.WriteInvalidUnitTest(func
, file, invalid_test
, *extras
)
4103 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
4104 """Writes the service unit test for an immediate command."""
4105 file.Write("// TODO(gman): %s\n" % func
.name
)
4107 def WriteImmediateValidationCode(self
, func
, file):
4108 """Writes the validation code for an immediate version of a command."""
4111 def WriteBucketServiceUnitTest(self
, func
, file, *extras
):
4112 """Writes the service unit test for a bucket command."""
4113 file.Write("// TODO(gman): %s\n" % func
.name
)
4115 def WriteBucketValidationCode(self
, func
, file):
4116 """Writes the validation code for a bucket version of a command."""
4117 file.Write("// TODO(gman): %s\n" % func
.name
)
4119 def WriteGLES2ImplementationDeclaration(self
, func
, file):
4120 """Writes the GLES2 Implemention declaration."""
4121 impl_decl
= func
.GetInfo('impl_decl')
4122 if impl_decl
== None or impl_decl
== True:
4123 file.Write("%s %s(%s) override;\n" %
4124 (func
.return_type
, func
.original_name
,
4125 func
.MakeTypedOriginalArgString("")))
4128 def WriteGLES2CLibImplementation(self
, func
, file):
4129 file.Write("%s GLES2%s(%s) {\n" %
4130 (func
.return_type
, func
.name
,
4131 func
.MakeTypedOriginalArgString("")))
4132 result_string
= "return "
4133 if func
.return_type
== "void":
4135 file.Write(" %sgles2::GetGLContext()->%s(%s);\n" %
4136 (result_string
, func
.original_name
,
4137 func
.MakeOriginalArgString("")))
4140 def WriteGLES2Header(self
, func
, file):
4141 """Writes a re-write macro for GLES"""
4142 file.Write("#define gl%s GLES2_GET_FUN(%s)\n" %(func
.name
, func
.name
))
4144 def WriteClientGLCallLog(self
, func
, file):
4145 """Writes a logging macro for the client side code."""
4147 if len(func
.GetOriginalArgs()):
4150 ' GPU_CLIENT_LOG("[" << GetLogPrefix() << "] gl%s("%s%s << ")");\n' %
4151 (func
.original_name
, comma
, func
.MakeLogArgString()))
4153 def WriteClientGLReturnLog(self
, func
, file):
4154 """Writes the return value logging code."""
4155 if func
.return_type
!= "void":
4156 file.Write(' GPU_CLIENT_LOG("return:" << result)\n')
4158 def WriteGLES2ImplementationHeader(self
, func
, file):
4159 """Writes the GLES2 Implemention."""
4160 self
.WriteGLES2ImplementationDeclaration(func
, file)
4162 def WriteGLES2TraceImplementationHeader(self
, func
, file):
4163 """Writes the GLES2 Trace Implemention header."""
4164 file.Write("%s %s(%s) override;\n" %
4165 (func
.return_type
, func
.original_name
,
4166 func
.MakeTypedOriginalArgString("")))
4168 def WriteGLES2TraceImplementation(self
, func
, file):
4169 """Writes the GLES2 Trace Implemention."""
4170 file.Write("%s GLES2TraceImplementation::%s(%s) {\n" %
4171 (func
.return_type
, func
.original_name
,
4172 func
.MakeTypedOriginalArgString("")))
4173 result_string
= "return "
4174 if func
.return_type
== "void":
4176 file.Write(' TRACE_EVENT_BINARY_EFFICIENT0("gpu", "GLES2Trace::%s");\n' %
4178 file.Write(" %sgl_->%s(%s);\n" %
4179 (result_string
, func
.name
, func
.MakeOriginalArgString("")))
4183 def WriteGLES2Implementation(self
, func
, file):
4184 """Writes the GLES2 Implemention."""
4185 impl_func
= func
.GetInfo('impl_func')
4186 impl_decl
= func
.GetInfo('impl_decl')
4187 gen_cmd
= func
.GetInfo('gen_cmd')
4188 if (func
.can_auto_generate
and
4189 (impl_func
== None or impl_func
== True) and
4190 (impl_decl
== None or impl_decl
== True) and
4191 (gen_cmd
== None or gen_cmd
== True)):
4192 file.Write("%s GLES2Implementation::%s(%s) {\n" %
4193 (func
.return_type
, func
.original_name
,
4194 func
.MakeTypedOriginalArgString("")))
4195 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
4196 self
.WriteClientGLCallLog(func
, file)
4197 func
.WriteDestinationInitalizationValidation(file)
4198 for arg
in func
.GetOriginalArgs():
4199 arg
.WriteClientSideValidationCode(file, func
)
4200 file.Write(" helper_->%s(%s);\n" %
4201 (func
.name
, func
.MakeHelperArgString("")))
4202 file.Write(" CheckGLError();\n")
4203 self
.WriteClientGLReturnLog(func
, file)
4207 def WriteGLES2InterfaceHeader(self
, func
, file):
4208 """Writes the GLES2 Interface."""
4209 file.Write("virtual %s %s(%s) = 0;\n" %
4210 (func
.return_type
, func
.original_name
,
4211 func
.MakeTypedOriginalArgString("")))
4213 def WriteMojoGLES2ImplHeader(self
, func
, file):
4214 """Writes the Mojo GLES2 implementation header."""
4215 file.Write("%s %s(%s) override;\n" %
4216 (func
.return_type
, func
.original_name
,
4217 func
.MakeTypedOriginalArgString("")))
4219 def WriteMojoGLES2Impl(self
, func
, file):
4220 """Writes the Mojo GLES2 implementation."""
4221 file.Write("%s MojoGLES2Impl::%s(%s) {\n" %
4222 (func
.return_type
, func
.original_name
,
4223 func
.MakeTypedOriginalArgString("")))
4224 extensions
= ["CHROMIUM_sync_point", "CHROMIUM_texture_mailbox",
4225 "CHROMIUM_sub_image", "CHROMIUM_miscellaneous",
4226 "occlusion_query_EXT"]
4227 if func
.IsCoreGLFunction() or func
.GetInfo("extension") in extensions
:
4228 file.Write("MojoGLES2MakeCurrent(context_);");
4229 func_return
= "gl" + func
.original_name
+ "(" + \
4230 func
.MakeOriginalArgString("") + ");"
4231 if func
.return_type
== "void":
4232 file.Write(func_return
);
4234 file.Write("return " + func_return
);
4236 file.Write("NOTREACHED() << \"Unimplemented %s.\";\n" %
4237 func
.original_name
);
4238 if func
.return_type
!= "void":
4239 file.Write("return 0;")
4242 def WriteGLES2InterfaceStub(self
, func
, file):
4243 """Writes the GLES2 Interface stub declaration."""
4244 file.Write("%s %s(%s) override;\n" %
4245 (func
.return_type
, func
.original_name
,
4246 func
.MakeTypedOriginalArgString("")))
4248 def WriteGLES2InterfaceStubImpl(self
, func
, file):
4249 """Writes the GLES2 Interface stub declaration."""
4250 args
= func
.GetOriginalArgs()
4251 arg_string
= ", ".join(
4252 ["%s /* %s */" % (arg
.type, arg
.name
) for arg
in args
])
4253 file.Write("%s GLES2InterfaceStub::%s(%s) {\n" %
4254 (func
.return_type
, func
.original_name
, arg_string
))
4255 if func
.return_type
!= "void":
4256 file.Write(" return 0;\n")
4259 def WriteGLES2ImplementationUnitTest(self
, func
, file):
4260 """Writes the GLES2 Implemention unit test."""
4261 client_test
= func
.GetInfo('client_test')
4262 if (func
.can_auto_generate
and
4263 (client_test
== None or client_test
== True)):
4265 TEST_F(GLES2ImplementationTest, %(name)s) {
4270 expected.cmd.Init(%(cmd_args)s);
4272 gl_->%(name)s(%(args)s);
4273 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
4277 arg
.GetValidClientSideCmdArg(func
) for arg
in func
.GetCmdArgs()
4281 arg
.GetValidClientSideArg(func
) for arg
in func
.GetOriginalArgs()
4286 'args': ", ".join(gl_arg_strings
),
4287 'cmd_args': ", ".join(cmd_arg_strings
),
4290 # Test constants for invalid values, as they are not tested by the
4292 constants
= [arg
for arg
in func
.GetOriginalArgs() if arg
.IsConstant()]
4295 TEST_F(GLES2ImplementationTest, %(name)sInvalidConstantArg%(invalid_index)d) {
4296 gl_->%(name)s(%(args)s);
4297 EXPECT_TRUE(NoCommandsWritten());
4298 EXPECT_EQ(%(gl_error)s, CheckError());
4301 for invalid_arg
in constants
:
4303 invalid
= invalid_arg
.GetInvalidArg(func
)
4304 for arg
in func
.GetOriginalArgs():
4305 if arg
is invalid_arg
:
4306 gl_arg_strings
.append(invalid
[0])
4308 gl_arg_strings
.append(arg
.GetValidClientSideArg(func
))
4312 'invalid_index': func
.GetOriginalArgs().index(invalid_arg
),
4313 'args': ", ".join(gl_arg_strings
),
4314 'gl_error': invalid
[2],
4317 if client_test
!= False:
4318 file.Write("// TODO(zmo): Implement unit test for %s\n" % func
.name
)
4320 def WriteDestinationInitalizationValidation(self
, func
, file):
4321 """Writes the client side destintion initialization validation."""
4322 for arg
in func
.GetOriginalArgs():
4323 arg
.WriteDestinationInitalizationValidation(file, func
)
4325 def WriteTraceEvent(self
, func
, file):
4326 file.Write(' TRACE_EVENT0("gpu", "GLES2Implementation::%s");\n' %
4329 def WriteImmediateCmdComputeSize(self
, func
, file):
4330 """Writes the size computation code for the immediate version of a cmd."""
4331 file.Write(" static uint32_t ComputeSize(uint32_t size_in_bytes) {\n")
4332 file.Write(" return static_cast<uint32_t>(\n")
4333 file.Write(" sizeof(ValueType) + // NOLINT\n")
4334 file.Write(" RoundSizeToMultipleOfEntries(size_in_bytes));\n")
4338 def WriteImmediateCmdSetHeader(self
, func
, file):
4339 """Writes the SetHeader function for the immediate version of a cmd."""
4340 file.Write(" void SetHeader(uint32_t size_in_bytes) {\n")
4341 file.Write(" header.SetCmdByTotalSize<ValueType>(size_in_bytes);\n")
4345 def WriteImmediateCmdInit(self
, func
, file):
4346 """Writes the Init function for the immediate version of a command."""
4347 raise NotImplementedError(func
.name
)
4349 def WriteImmediateCmdSet(self
, func
, file):
4350 """Writes the Set function for the immediate version of a command."""
4351 raise NotImplementedError(func
.name
)
4353 def WriteCmdHelper(self
, func
, file):
4354 """Writes the cmd helper definition for a cmd."""
4355 code
= """ void %(name)s(%(typed_args)s) {
4356 gles2::cmds::%(name)s* c = GetCmdSpace<gles2::cmds::%(name)s>();
4365 "typed_args": func
.MakeTypedCmdArgString(""),
4366 "args": func
.MakeCmdArgString(""),
4369 def WriteImmediateCmdHelper(self
, func
, file):
4370 """Writes the cmd helper definition for the immediate version of a cmd."""
4371 code
= """ void %(name)s(%(typed_args)s) {
4372 const uint32_t s = 0; // TODO(gman): compute correct size
4373 gles2::cmds::%(name)s* c =
4374 GetImmediateCmdSpaceTotalSize<gles2::cmds::%(name)s>(s);
4383 "typed_args": func
.MakeTypedCmdArgString(""),
4384 "args": func
.MakeCmdArgString(""),
4388 class StateSetHandler(TypeHandler
):
4389 """Handler for commands that simply set state."""
4392 TypeHandler
.__init
__(self
)
4394 def WriteHandlerImplementation(self
, func
, file):
4395 """Overrriden from TypeHandler."""
4396 state_name
= func
.GetInfo('state')
4397 state
= _STATES
[state_name
]
4398 states
= state
['states']
4399 args
= func
.GetOriginalArgs()
4400 for ndx
,item
in enumerate(states
):
4402 if 'range_checks' in item
:
4403 for range_check
in item
['range_checks']:
4404 code
.append("%s %s" % (args
[ndx
].name
, range_check
['check']))
4405 if 'nan_check' in item
:
4406 # Drivers might generate an INVALID_VALUE error when a value is set
4407 # to NaN. This is allowed behavior under GLES 3.0 section 2.1.1 or
4408 # OpenGL 4.5 section 2.3.4.1 - providing NaN allows undefined results.
4409 # Make this behavior consistent within Chromium, and avoid leaking GL
4410 # errors by generating the error in the command buffer instead of
4411 # letting the GL driver generate it.
4412 code
.append("base::IsNaN(%s)" % args
[ndx
].name
)
4414 file.Write(" if (%s) {\n" % " ||\n ".join(code
))
4416 ' LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,'
4417 ' "%s", "%s out of range");\n' %
4418 (func
.name
, args
[ndx
].name
))
4419 file.Write(" return error::kNoError;\n")
4422 for ndx
,item
in enumerate(states
):
4423 code
.append("state_.%s != %s" % (item
['name'], args
[ndx
].name
))
4424 file.Write(" if (%s) {\n" % " ||\n ".join(code
))
4425 for ndx
,item
in enumerate(states
):
4426 file.Write(" state_.%s = %s;\n" % (item
['name'], args
[ndx
].name
))
4427 if 'state_flag' in state
:
4428 file.Write(" %s = true;\n" % state
['state_flag'])
4429 if not func
.GetInfo("no_gl"):
4430 for ndx
,item
in enumerate(states
):
4431 if item
.get('cached', False):
4432 file.Write(" state_.%s = %s;\n" %
4433 (CachedStateName(item
), args
[ndx
].name
))
4434 file.Write(" %s(%s);\n" %
4435 (func
.GetGLFunctionName(), func
.MakeOriginalArgString("")))
4438 def WriteServiceUnitTest(self
, func
, file, *extras
):
4439 """Overrriden from TypeHandler."""
4440 TypeHandler
.WriteServiceUnitTest(self
, func
, file, *extras
)
4441 state_name
= func
.GetInfo('state')
4442 state
= _STATES
[state_name
]
4443 states
= state
['states']
4444 for ndx
,item
in enumerate(states
):
4445 if 'range_checks' in item
:
4446 for check_ndx
, range_check
in enumerate(item
['range_checks']):
4448 TEST_P(%(test_name)s, %(name)sInvalidValue%(ndx)d_%(check_ndx)d) {
4449 SpecializedSetup<cmds::%(name)s, 0>(false);
4452 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4453 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
4458 arg
.GetValidArg(func
) \
4459 for arg
in func
.GetOriginalArgs() if not arg
.IsConstant()
4462 arg_strings
[ndx
] = range_check
['test_value']
4466 'check_ndx': check_ndx
,
4467 'args': ", ".join(arg_strings
),
4469 for extra
in extras
:
4471 file.Write(valid_test
% vars)
4472 if 'nan_check' in item
:
4474 TEST_P(%(test_name)s, %(name)sNaNValue%(ndx)d) {
4475 SpecializedSetup<cmds::%(name)s, 0>(false);
4478 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4479 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
4484 arg
.GetValidArg(func
) \
4485 for arg
in func
.GetOriginalArgs() if not arg
.IsConstant()
4488 arg_strings
[ndx
] = 'nanf("")'
4492 'args': ", ".join(arg_strings
),
4494 for extra
in extras
:
4496 file.Write(valid_test
% vars)
4499 class StateSetRGBAlphaHandler(TypeHandler
):
4500 """Handler for commands that simply set state that have rgb/alpha."""
4503 TypeHandler
.__init
__(self
)
4505 def WriteHandlerImplementation(self
, func
, file):
4506 """Overrriden from TypeHandler."""
4507 state_name
= func
.GetInfo('state')
4508 state
= _STATES
[state_name
]
4509 states
= state
['states']
4510 args
= func
.GetOriginalArgs()
4511 num_args
= len(args
)
4513 for ndx
,item
in enumerate(states
):
4514 code
.append("state_.%s != %s" % (item
['name'], args
[ndx
% num_args
].name
))
4515 file.Write(" if (%s) {\n" % " ||\n ".join(code
))
4516 for ndx
, item
in enumerate(states
):
4517 file.Write(" state_.%s = %s;\n" %
4518 (item
['name'], args
[ndx
% num_args
].name
))
4519 if 'state_flag' in state
:
4520 file.Write(" %s = true;\n" % state
['state_flag'])
4521 if not func
.GetInfo("no_gl"):
4522 file.Write(" %s(%s);\n" %
4523 (func
.GetGLFunctionName(), func
.MakeOriginalArgString("")))
4527 class StateSetFrontBackSeparateHandler(TypeHandler
):
4528 """Handler for commands that simply set state that have front/back."""
4531 TypeHandler
.__init
__(self
)
4533 def WriteHandlerImplementation(self
, func
, file):
4534 """Overrriden from TypeHandler."""
4535 state_name
= func
.GetInfo('state')
4536 state
= _STATES
[state_name
]
4537 states
= state
['states']
4538 args
= func
.GetOriginalArgs()
4540 num_args
= len(args
)
4541 file.Write(" bool changed = false;\n")
4542 for group_ndx
, group
in enumerate(Grouper(num_args
- 1, states
)):
4543 file.Write(" if (%s == %s || %s == GL_FRONT_AND_BACK) {\n" %
4544 (face
, ('GL_FRONT', 'GL_BACK')[group_ndx
], face
))
4546 for ndx
, item
in enumerate(group
):
4547 code
.append("state_.%s != %s" % (item
['name'], args
[ndx
+ 1].name
))
4548 file.Write(" changed |= %s;\n" % " ||\n ".join(code
))
4550 file.Write(" if (changed) {\n")
4551 for group_ndx
, group
in enumerate(Grouper(num_args
- 1, states
)):
4552 file.Write(" if (%s == %s || %s == GL_FRONT_AND_BACK) {\n" %
4553 (face
, ('GL_FRONT', 'GL_BACK')[group_ndx
], face
))
4554 for ndx
, item
in enumerate(group
):
4555 file.Write(" state_.%s = %s;\n" %
4556 (item
['name'], args
[ndx
+ 1].name
))
4558 if 'state_flag' in state
:
4559 file.Write(" %s = true;\n" % state
['state_flag'])
4560 if not func
.GetInfo("no_gl"):
4561 file.Write(" %s(%s);\n" %
4562 (func
.GetGLFunctionName(), func
.MakeOriginalArgString("")))
4566 class StateSetFrontBackHandler(TypeHandler
):
4567 """Handler for commands that simply set state that set both front/back."""
4570 TypeHandler
.__init
__(self
)
4572 def WriteHandlerImplementation(self
, func
, file):
4573 """Overrriden from TypeHandler."""
4574 state_name
= func
.GetInfo('state')
4575 state
= _STATES
[state_name
]
4576 states
= state
['states']
4577 args
= func
.GetOriginalArgs()
4578 num_args
= len(args
)
4580 for group_ndx
, group
in enumerate(Grouper(num_args
, states
)):
4581 for ndx
, item
in enumerate(group
):
4582 code
.append("state_.%s != %s" % (item
['name'], args
[ndx
].name
))
4583 file.Write(" if (%s) {\n" % " ||\n ".join(code
))
4584 for group_ndx
, group
in enumerate(Grouper(num_args
, states
)):
4585 for ndx
, item
in enumerate(group
):
4586 file.Write(" state_.%s = %s;\n" % (item
['name'], args
[ndx
].name
))
4587 if 'state_flag' in state
:
4588 file.Write(" %s = true;\n" % state
['state_flag'])
4589 if not func
.GetInfo("no_gl"):
4590 file.Write(" %s(%s);\n" %
4591 (func
.GetGLFunctionName(), func
.MakeOriginalArgString("")))
4595 class StateSetNamedParameter(TypeHandler
):
4596 """Handler for commands that set a state chosen with an enum parameter."""
4599 TypeHandler
.__init
__(self
)
4601 def WriteHandlerImplementation(self
, func
, file):
4602 """Overridden from TypeHandler."""
4603 state_name
= func
.GetInfo('state')
4604 state
= _STATES
[state_name
]
4605 states
= state
['states']
4606 args
= func
.GetOriginalArgs()
4607 num_args
= len(args
)
4608 assert num_args
== 2
4609 file.Write(" switch (%s) {\n" % args
[0].name
)
4610 for state
in states
:
4611 file.Write(" case %s:\n" % state
['enum'])
4612 file.Write(" if (state_.%s != %s) {\n" %
4613 (state
['name'], args
[1].name
))
4614 file.Write(" state_.%s = %s;\n" % (state
['name'], args
[1].name
))
4615 if not func
.GetInfo("no_gl"):
4616 file.Write(" %s(%s);\n" %
4617 (func
.GetGLFunctionName(), func
.MakeOriginalArgString("")))
4619 file.Write(" break;\n")
4620 file.Write(" default:\n")
4621 file.Write(" NOTREACHED();\n")
4625 class CustomHandler(TypeHandler
):
4626 """Handler for commands that are auto-generated but require minor tweaks."""
4629 TypeHandler
.__init
__(self
)
4631 def WriteServiceImplementation(self
, func
, file):
4632 """Overrriden from TypeHandler."""
4635 def WriteImmediateServiceImplementation(self
, func
, file):
4636 """Overrriden from TypeHandler."""
4639 def WriteBucketServiceImplementation(self
, func
, file):
4640 """Overrriden from TypeHandler."""
4643 def WriteServiceUnitTest(self
, func
, file, *extras
):
4644 """Overrriden from TypeHandler."""
4645 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4647 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
4648 """Overrriden from TypeHandler."""
4649 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4651 def WriteImmediateCmdGetTotalSize(self
, func
, file):
4652 """Overrriden from TypeHandler."""
4654 " uint32_t total_size = 0; // TODO(gman): get correct size.\n")
4656 def WriteImmediateCmdInit(self
, func
, file):
4657 """Overrriden from TypeHandler."""
4658 file.Write(" void Init(%s) {\n" % func
.MakeTypedCmdArgString("_"))
4659 self
.WriteImmediateCmdGetTotalSize(func
, file)
4660 file.Write(" SetHeader(total_size);\n")
4661 args
= func
.GetCmdArgs()
4663 file.Write(" %s = _%s;\n" % (arg
.name
, arg
.name
))
4667 def WriteImmediateCmdSet(self
, func
, file):
4668 """Overrriden from TypeHandler."""
4669 copy_args
= func
.MakeCmdArgString("_", False)
4670 file.Write(" void* Set(void* cmd%s) {\n" %
4671 func
.MakeTypedCmdArgString("_", True))
4672 self
.WriteImmediateCmdGetTotalSize(func
, file)
4673 file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % copy_args
)
4674 file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
4675 "cmd, total_size);\n")
4680 class TodoHandler(CustomHandler
):
4681 """Handle for commands that are not yet implemented."""
4683 def NeedsDataTransferFunction(self
, func
):
4684 """Overriden from TypeHandler."""
4687 def WriteImmediateFormatTest(self
, func
, file):
4688 """Overrriden from TypeHandler."""
4691 def WriteGLES2ImplementationUnitTest(self
, func
, file):
4692 """Overrriden from TypeHandler."""
4695 def WriteGLES2Implementation(self
, func
, file):
4696 """Overrriden from TypeHandler."""
4697 file.Write("%s GLES2Implementation::%s(%s) {\n" %
4698 (func
.return_type
, func
.original_name
,
4699 func
.MakeTypedOriginalArgString("")))
4700 file.Write(" // TODO: for now this is a no-op\n")
4703 "GL_INVALID_OPERATION, \"gl%s\", \"not implemented\");\n" %
4705 if func
.return_type
!= "void":
4706 file.Write(" return 0;\n")
4710 def WriteServiceImplementation(self
, func
, file):
4711 """Overrriden from TypeHandler."""
4712 self
.WriteServiceHandlerFunctionHeader(func
, file)
4713 file.Write(" // TODO: for now this is a no-op\n")
4715 " LOCAL_SET_GL_ERROR("
4716 "GL_INVALID_OPERATION, \"gl%s\", \"not implemented\");\n" %
4718 file.Write(" return error::kNoError;\n")
4723 class HandWrittenHandler(CustomHandler
):
4724 """Handler for comands where everything must be written by hand."""
4726 def InitFunction(self
, func
):
4727 """Add or adjust anything type specific for this function."""
4728 CustomHandler
.InitFunction(self
, func
)
4729 func
.can_auto_generate
= False
4731 def NeedsDataTransferFunction(self
, func
):
4732 """Overriden from TypeHandler."""
4733 # If specified explicitly, force the data transfer method.
4734 if func
.GetInfo('data_transfer_methods'):
4738 def WriteStruct(self
, func
, file):
4739 """Overrriden from TypeHandler."""
4742 def WriteDocs(self
, func
, file):
4743 """Overrriden from TypeHandler."""
4746 def WriteServiceUnitTest(self
, func
, file, *extras
):
4747 """Overrriden from TypeHandler."""
4748 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4750 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
4751 """Overrriden from TypeHandler."""
4752 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4754 def WriteBucketServiceUnitTest(self
, func
, file, *extras
):
4755 """Overrriden from TypeHandler."""
4756 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4758 def WriteServiceImplementation(self
, func
, file):
4759 """Overrriden from TypeHandler."""
4762 def WriteImmediateServiceImplementation(self
, func
, file):
4763 """Overrriden from TypeHandler."""
4766 def WriteBucketServiceImplementation(self
, func
, file):
4767 """Overrriden from TypeHandler."""
4770 def WriteImmediateCmdHelper(self
, func
, file):
4771 """Overrriden from TypeHandler."""
4774 def WriteCmdHelper(self
, func
, file):
4775 """Overrriden from TypeHandler."""
4778 def WriteFormatTest(self
, func
, file):
4779 """Overrriden from TypeHandler."""
4780 file.Write("// TODO(gman): Write test for %s\n" % func
.name
)
4782 def WriteImmediateFormatTest(self
, func
, file):
4783 """Overrriden from TypeHandler."""
4784 file.Write("// TODO(gman): Write test for %s\n" % func
.name
)
4786 def WriteBucketFormatTest(self
, func
, file):
4787 """Overrriden from TypeHandler."""
4788 file.Write("// TODO(gman): Write test for %s\n" % func
.name
)
4792 class ManualHandler(CustomHandler
):
4793 """Handler for commands who's handlers must be written by hand."""
4796 CustomHandler
.__init
__(self
)
4798 def InitFunction(self
, func
):
4799 """Overrriden from TypeHandler."""
4800 if (func
.name
== 'CompressedTexImage2DBucket'):
4801 func
.cmd_args
= func
.cmd_args
[:-1]
4802 func
.AddCmdArg(Argument('bucket_id', 'GLuint'))
4804 CustomHandler
.InitFunction(self
, func
)
4806 def WriteServiceImplementation(self
, func
, file):
4807 """Overrriden from TypeHandler."""
4810 def WriteBucketServiceImplementation(self
, func
, file):
4811 """Overrriden from TypeHandler."""
4814 def WriteServiceUnitTest(self
, func
, file, *extras
):
4815 """Overrriden from TypeHandler."""
4816 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4818 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
4819 """Overrriden from TypeHandler."""
4820 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4822 def WriteImmediateServiceImplementation(self
, func
, file):
4823 """Overrriden from TypeHandler."""
4826 def WriteImmediateFormatTest(self
, func
, file):
4827 """Overrriden from TypeHandler."""
4828 file.Write("// TODO(gman): Implement test for %s\n" % func
.name
)
4830 def WriteGLES2Implementation(self
, func
, file):
4831 """Overrriden from TypeHandler."""
4832 if func
.GetInfo('impl_func'):
4833 super(ManualHandler
, self
).WriteGLES2Implementation(func
, file)
4835 def WriteGLES2ImplementationHeader(self
, func
, file):
4836 """Overrriden from TypeHandler."""
4837 file.Write("%s %s(%s) override;\n" %
4838 (func
.return_type
, func
.original_name
,
4839 func
.MakeTypedOriginalArgString("")))
4842 def WriteImmediateCmdGetTotalSize(self
, func
, file):
4843 """Overrriden from TypeHandler."""
4844 # TODO(gman): Move this data to _FUNCTION_INFO?
4845 CustomHandler
.WriteImmediateCmdGetTotalSize(self
, func
, file)
4848 class DataHandler(TypeHandler
):
4849 """Handler for glBufferData, glBufferSubData, glTexImage2D, glTexSubImage2D,
4850 glCompressedTexImage2D, glCompressedTexImageSub2D."""
4852 TypeHandler
.__init
__(self
)
4854 def InitFunction(self
, func
):
4855 """Overrriden from TypeHandler."""
4856 if func
.name
== 'CompressedTexSubImage2DBucket':
4857 func
.cmd_args
= func
.cmd_args
[:-1]
4858 func
.AddCmdArg(Argument('bucket_id', 'GLuint'))
4860 def WriteGetDataSizeCode(self
, func
, file):
4861 """Overrriden from TypeHandler."""
4862 # TODO(gman): Move this data to _FUNCTION_INFO?
4864 if name
.endswith("Immediate"):
4866 if name
== 'BufferData' or name
== 'BufferSubData':
4867 file.Write(" uint32_t data_size = size;\n")
4868 elif (name
== 'CompressedTexImage2D' or
4869 name
== 'CompressedTexSubImage2D'):
4870 file.Write(" uint32_t data_size = imageSize;\n")
4871 elif (name
== 'CompressedTexSubImage2DBucket'):
4872 file.Write(" Bucket* bucket = GetBucket(c.bucket_id);\n")
4873 file.Write(" uint32_t data_size = bucket->size();\n")
4874 file.Write(" GLsizei imageSize = data_size;\n")
4875 elif name
== 'TexImage2D' or name
== 'TexSubImage2D':
4876 code
= """ uint32_t data_size;
4877 if (!GLES2Util::ComputeImageDataSize(
4878 width, height, format, type, unpack_alignment_, &data_size)) {
4879 return error::kOutOfBounds;
4885 "// uint32_t data_size = 0; // TODO(gman): get correct size!\n")
4887 def WriteImmediateCmdGetTotalSize(self
, func
, file):
4888 """Overrriden from TypeHandler."""
4891 def WriteImmediateCmdSizeTest(self
, func
, file):
4892 """Overrriden from TypeHandler."""
4893 file.Write(" EXPECT_EQ(sizeof(cmd), total_size);\n")
4895 def WriteImmediateCmdInit(self
, func
, file):
4896 """Overrriden from TypeHandler."""
4897 file.Write(" void Init(%s) {\n" % func
.MakeTypedCmdArgString("_"))
4898 self
.WriteImmediateCmdGetTotalSize(func
, file)
4899 file.Write(" SetHeader(total_size);\n")
4900 args
= func
.GetCmdArgs()
4902 file.Write(" %s = _%s;\n" % (arg
.name
, arg
.name
))
4906 def WriteImmediateCmdSet(self
, func
, file):
4907 """Overrriden from TypeHandler."""
4908 copy_args
= func
.MakeCmdArgString("_", False)
4909 file.Write(" void* Set(void* cmd%s) {\n" %
4910 func
.MakeTypedCmdArgString("_", True))
4911 self
.WriteImmediateCmdGetTotalSize(func
, file)
4912 file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % copy_args
)
4913 file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
4914 "cmd, total_size);\n")
4918 def WriteImmediateFormatTest(self
, func
, file):
4919 """Overrriden from TypeHandler."""
4920 # TODO(gman): Remove this exception.
4921 file.Write("// TODO(gman): Implement test for %s\n" % func
.name
)
4924 def WriteServiceUnitTest(self
, func
, file, *extras
):
4925 """Overrriden from TypeHandler."""
4926 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4928 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
4929 """Overrriden from TypeHandler."""
4930 file.Write("// TODO(gman): %s\n\n" % func
.name
)
4932 def WriteBucketServiceImplementation(self
, func
, file):
4933 """Overrriden from TypeHandler."""
4934 if not func
.name
== 'CompressedTexSubImage2DBucket':
4935 TypeHandler
.WriteBucketServiceImplemenation(self
, func
, file)
4938 class BindHandler(TypeHandler
):
4939 """Handler for glBind___ type functions."""
4942 TypeHandler
.__init
__(self
)
4944 def WriteServiceUnitTest(self
, func
, file, *extras
):
4945 """Overrriden from TypeHandler."""
4947 if len(func
.GetOriginalArgs()) == 1:
4949 TEST_P(%(test_name)s, %(name)sValidArgs) {
4950 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
4951 SpecializedSetup<cmds::%(name)s, 0>(true);
4953 cmd.Init(%(args)s);"""
4956 decoder_->set_unsafe_es3_apis_enabled(true);
4957 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4958 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4959 decoder_->set_unsafe_es3_apis_enabled(false);
4960 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
4965 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4966 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4969 if func
.GetInfo("gen_func"):
4971 TEST_P(%(test_name)s, %(name)sValidArgsNewId) {
4972 EXPECT_CALL(*gl_, %(gl_func_name)s(kNewServiceId));
4973 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _))
4974 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
4975 SpecializedSetup<cmds::%(name)s, 0>(true);
4977 cmd.Init(kNewClientId);
4978 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4979 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4980 EXPECT_TRUE(Get%(resource_type)s(kNewClientId) != NULL);
4983 self
.WriteValidUnitTest(func
, file, valid_test
, {
4984 'resource_type': func
.GetOriginalArgs()[0].resource_type
,
4985 'gl_gen_func_name': func
.GetInfo("gen_func"),
4989 TEST_P(%(test_name)s, %(name)sValidArgs) {
4990 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
4991 SpecializedSetup<cmds::%(name)s, 0>(true);
4993 cmd.Init(%(args)s);"""
4996 decoder_->set_unsafe_es3_apis_enabled(true);
4997 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4998 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4999 decoder_->set_unsafe_es3_apis_enabled(false);
5000 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
5005 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5006 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5009 if func
.GetInfo("gen_func"):
5011 TEST_P(%(test_name)s, %(name)sValidArgsNewId) {
5013 %(gl_func_name)s(%(gl_args_with_new_id)s));
5014 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _))
5015 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
5016 SpecializedSetup<cmds::%(name)s, 0>(true);
5018 cmd.Init(%(args_with_new_id)s);"""
5021 decoder_->set_unsafe_es3_apis_enabled(true);
5022 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5023 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5024 EXPECT_TRUE(Get%(resource_type)s(kNewClientId) != NULL);
5025 decoder_->set_unsafe_es3_apis_enabled(false);
5026 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
5031 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5032 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5033 EXPECT_TRUE(Get%(resource_type)s(kNewClientId) != NULL);
5037 gl_args_with_new_id
= []
5038 args_with_new_id
= []
5039 for arg
in func
.GetOriginalArgs():
5040 if hasattr(arg
, 'resource_type'):
5041 gl_args_with_new_id
.append('kNewServiceId')
5042 args_with_new_id
.append('kNewClientId')
5044 gl_args_with_new_id
.append(arg
.GetValidGLArg(func
))
5045 args_with_new_id
.append(arg
.GetValidArg(func
))
5046 self
.WriteValidUnitTest(func
, file, valid_test
, {
5047 'args_with_new_id': ", ".join(args_with_new_id
),
5048 'gl_args_with_new_id': ", ".join(gl_args_with_new_id
),
5049 'resource_type': func
.GetResourceIdArg().resource_type
,
5050 'gl_gen_func_name': func
.GetInfo("gen_func"),
5054 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
5055 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
5056 SpecializedSetup<cmds::%(name)s, 0>(false);
5059 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
5062 self
.WriteInvalidUnitTest(func
, file, invalid_test
, *extras
)
5064 def WriteGLES2Implementation(self
, func
, file):
5065 """Writes the GLES2 Implemention."""
5067 impl_func
= func
.GetInfo('impl_func')
5068 impl_decl
= func
.GetInfo('impl_decl')
5070 if (func
.can_auto_generate
and
5071 (impl_func
== None or impl_func
== True) and
5072 (impl_decl
== None or impl_decl
== True)):
5074 file.Write("%s GLES2Implementation::%s(%s) {\n" %
5075 (func
.return_type
, func
.original_name
,
5076 func
.MakeTypedOriginalArgString("")))
5077 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
5078 func
.WriteDestinationInitalizationValidation(file)
5079 self
.WriteClientGLCallLog(func
, file)
5080 for arg
in func
.GetOriginalArgs():
5081 arg
.WriteClientSideValidationCode(file, func
)
5083 code
= """ if (Is%(type)sReservedId(%(id)s)) {
5084 SetGLError(GL_INVALID_OPERATION, "%(name)s\", \"%(id)s reserved id");
5087 %(name)sHelper(%(arg_string)s);
5092 name_arg
= func
.GetResourceIdArg()
5095 'arg_string': func
.MakeOriginalArgString(""),
5096 'id': name_arg
.name
,
5097 'type': name_arg
.resource_type
,
5098 'lc_type': name_arg
.resource_type
.lower(),
5101 def WriteGLES2ImplementationUnitTest(self
, func
, file):
5102 """Overrriden from TypeHandler."""
5103 client_test
= func
.GetInfo('client_test')
5104 if client_test
== False:
5107 TEST_F(GLES2ImplementationTest, %(name)s) {
5112 expected.cmd.Init(%(cmd_args)s);
5114 gl_->%(name)s(%(args)s);
5115 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));"""
5116 if not func
.IsUnsafe():
5119 gl_->%(name)s(%(args)s);
5120 EXPECT_TRUE(NoCommandsWritten());"""
5125 arg
.GetValidClientSideCmdArg(func
) for arg
in func
.GetCmdArgs()
5128 arg
.GetValidClientSideArg(func
) for arg
in func
.GetOriginalArgs()
5133 'args': ", ".join(gl_arg_strings
),
5134 'cmd_args': ", ".join(cmd_arg_strings
),
5138 class GENnHandler(TypeHandler
):
5139 """Handler for glGen___ type functions."""
5142 TypeHandler
.__init
__(self
)
5144 def InitFunction(self
, func
):
5145 """Overrriden from TypeHandler."""
5148 def WriteGetDataSizeCode(self
, func
, file):
5149 """Overrriden from TypeHandler."""
5150 code
= """ uint32_t data_size;
5151 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
5152 return error::kOutOfBounds;
5157 def WriteHandlerImplementation (self
, func
, file):
5158 """Overrriden from TypeHandler."""
5159 file.Write(" if (!%sHelper(n, %s)) {\n"
5160 " return error::kInvalidArguments;\n"
5162 (func
.name
, func
.GetLastOriginalArg().name
))
5164 def WriteImmediateHandlerImplementation(self
, func
, file):
5165 """Overrriden from TypeHandler."""
5167 file.Write(""" for (GLsizei ii = 0; ii < n; ++ii) {
5168 if (group_->Get%(resource_name)sServiceId(%(last_arg_name)s[ii], NULL)) {
5169 return error::kInvalidArguments;
5172 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
5173 gl%(func_name)s(n, service_ids.get());
5174 for (GLsizei ii = 0; ii < n; ++ii) {
5175 group_->Add%(resource_name)sId(%(last_arg_name)s[ii], service_ids[ii]);
5177 """ % { 'func_name': func
.original_name
,
5178 'last_arg_name': func
.GetLastOriginalArg().name
,
5179 'resource_name': func
.GetInfo('resource_type') })
5181 file.Write(" if (!%sHelper(n, %s)) {\n"
5182 " return error::kInvalidArguments;\n"
5184 (func
.original_name
, func
.GetLastOriginalArg().name
))
5186 def WriteGLES2Implementation(self
, func
, file):
5187 """Overrriden from TypeHandler."""
5188 log_code
= (""" GPU_CLIENT_LOG_CODE_BLOCK({
5189 for (GLsizei i = 0; i < n; ++i) {
5190 GPU_CLIENT_LOG(" " << i << ": " << %s[i]);
5192 });""" % func
.GetOriginalArgs()[1].name
)
5194 'log_code': log_code
,
5195 'return_type': func
.return_type
,
5196 'name': func
.original_name
,
5197 'typed_args': func
.MakeTypedOriginalArgString(""),
5198 'args': func
.MakeOriginalArgString(""),
5199 'resource_types': func
.GetInfo('resource_types'),
5200 'count_name': func
.GetOriginalArgs()[0].name
,
5203 "%(return_type)s GLES2Implementation::%(name)s(%(typed_args)s) {\n" %
5205 func
.WriteDestinationInitalizationValidation(file)
5206 self
.WriteClientGLCallLog(func
, file)
5207 for arg
in func
.GetOriginalArgs():
5208 arg
.WriteClientSideValidationCode(file, func
)
5209 not_shared
= func
.GetInfo('not_shared')
5213 """ IdAllocator* id_allocator = GetIdAllocator(id_namespaces::k%s);
5214 for (GLsizei ii = 0; ii < n; ++ii)
5215 %s[ii] = id_allocator->AllocateID();""" %
5216 (func
.GetInfo('resource_types'), func
.GetOriginalArgs()[1].name
))
5218 alloc_code
= (""" GetIdHandler(id_namespaces::k%(resource_types)s)->
5219 MakeIds(this, 0, %(args)s);""" % args
)
5220 args
['alloc_code'] = alloc_code
5222 code
= """ GPU_CLIENT_SINGLE_THREAD_CHECK();
5224 %(name)sHelper(%(args)s);
5225 helper_->%(name)sImmediate(%(args)s);
5226 if (share_group_->bind_generates_resource())
5227 helper_->CommandBufferHelper::Flush();
5233 file.Write(code
% args
)
5235 def WriteGLES2ImplementationUnitTest(self
, func
, file):
5236 """Overrriden from TypeHandler."""
5238 TEST_F(GLES2ImplementationTest, %(name)s) {
5239 GLuint ids[2] = { 0, };
5241 cmds::%(name)sImmediate gen;
5245 expected.gen.Init(arraysize(ids), &ids[0]);
5246 expected.data[0] = k%(types)sStartId;
5247 expected.data[1] = k%(types)sStartId + 1;
5248 gl_->%(name)s(arraysize(ids), &ids[0]);
5249 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
5250 EXPECT_EQ(k%(types)sStartId, ids[0]);
5251 EXPECT_EQ(k%(types)sStartId + 1, ids[1]);
5256 'types': func
.GetInfo('resource_types'),
5259 def WriteServiceUnitTest(self
, func
, file, *extras
):
5260 """Overrriden from TypeHandler."""
5262 TEST_P(%(test_name)s, %(name)sValidArgs) {
5263 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _))
5264 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
5265 GetSharedMemoryAs<GLuint*>()[0] = kNewClientId;
5266 SpecializedSetup<cmds::%(name)s, 0>(true);
5269 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5270 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
5274 EXPECT_TRUE(Get%(resource_name)sServiceId(kNewClientId, &service_id));
5275 EXPECT_EQ(kNewServiceId, service_id)
5280 EXPECT_TRUE(Get%(resource_name)s(kNewClientId, &service_id) != NULL);
5283 self
.WriteValidUnitTest(func
, file, valid_test
, {
5284 'resource_name': func
.GetInfo('resource_type'),
5287 TEST_P(%(test_name)s, %(name)sInvalidArgs) {
5288 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0);
5289 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_;
5290 SpecializedSetup<cmds::%(name)s, 0>(false);
5293 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd));
5296 self
.WriteValidUnitTest(func
, file, invalid_test
, {
5297 'resource_name': func
.GetInfo('resource_type').lower(),
5300 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
5301 """Overrriden from TypeHandler."""
5303 TEST_P(%(test_name)s, %(name)sValidArgs) {
5304 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _))
5305 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
5306 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>();
5307 GLuint temp = kNewClientId;
5308 SpecializedSetup<cmds::%(name)s, 0>(true);"""
5311 decoder_->set_unsafe_es3_apis_enabled(true);"""
5313 cmd->Init(1, &temp);
5314 EXPECT_EQ(error::kNoError,
5315 ExecuteImmediateCmd(*cmd, sizeof(temp)));
5316 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
5320 EXPECT_TRUE(Get%(resource_name)sServiceId(kNewClientId, &service_id));
5321 EXPECT_EQ(kNewServiceId, service_id);
5322 decoder_->set_unsafe_es3_apis_enabled(false);
5323 EXPECT_EQ(error::kUnknownCommand,
5324 ExecuteImmediateCmd(*cmd, sizeof(temp)));
5329 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL);
5332 self
.WriteValidUnitTest(func
, file, valid_test
, {
5333 'resource_name': func
.GetInfo('resource_type'),
5336 TEST_P(%(test_name)s, %(name)sInvalidArgs) {
5337 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0);
5338 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>();
5339 SpecializedSetup<cmds::%(name)s, 0>(false);
5340 cmd->Init(1, &client_%(resource_name)s_id_);"""
5343 decoder_->set_unsafe_es3_apis_enabled(true);
5344 EXPECT_EQ(error::kInvalidArguments,
5345 ExecuteImmediateCmd(*cmd, sizeof(&client_%(resource_name)s_id_)));
5346 decoder_->set_unsafe_es3_apis_enabled(false);
5351 EXPECT_EQ(error::kInvalidArguments,
5352 ExecuteImmediateCmd(*cmd, sizeof(&client_%(resource_name)s_id_)));
5355 self
.WriteValidUnitTest(func
, file, invalid_test
, {
5356 'resource_name': func
.GetInfo('resource_type').lower(),
5359 def WriteImmediateCmdComputeSize(self
, func
, file):
5360 """Overrriden from TypeHandler."""
5361 file.Write(" static uint32_t ComputeDataSize(GLsizei n) {\n")
5363 " return static_cast<uint32_t>(sizeof(GLuint) * n); // NOLINT\n")
5366 file.Write(" static uint32_t ComputeSize(GLsizei n) {\n")
5367 file.Write(" return static_cast<uint32_t>(\n")
5368 file.Write(" sizeof(ValueType) + ComputeDataSize(n)); // NOLINT\n")
5372 def WriteImmediateCmdSetHeader(self
, func
, file):
5373 """Overrriden from TypeHandler."""
5374 file.Write(" void SetHeader(GLsizei n) {\n")
5375 file.Write(" header.SetCmdByTotalSize<ValueType>(ComputeSize(n));\n")
5379 def WriteImmediateCmdInit(self
, func
, file):
5380 """Overrriden from TypeHandler."""
5381 last_arg
= func
.GetLastOriginalArg()
5382 file.Write(" void Init(%s, %s _%s) {\n" %
5383 (func
.MakeTypedCmdArgString("_"),
5384 last_arg
.type, last_arg
.name
))
5385 file.Write(" SetHeader(_n);\n")
5386 args
= func
.GetCmdArgs()
5388 file.Write(" %s = _%s;\n" % (arg
.name
, arg
.name
))
5389 file.Write(" memcpy(ImmediateDataAddress(this),\n")
5390 file.Write(" _%s, ComputeDataSize(_n));\n" % last_arg
.name
)
5394 def WriteImmediateCmdSet(self
, func
, file):
5395 """Overrriden from TypeHandler."""
5396 last_arg
= func
.GetLastOriginalArg()
5397 copy_args
= func
.MakeCmdArgString("_", False)
5398 file.Write(" void* Set(void* cmd%s, %s _%s) {\n" %
5399 (func
.MakeTypedCmdArgString("_", True),
5400 last_arg
.type, last_arg
.name
))
5401 file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" %
5402 (copy_args
, last_arg
.name
))
5403 file.Write(" const uint32_t size = ComputeSize(_n);\n")
5404 file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
5409 def WriteImmediateCmdHelper(self
, func
, file):
5410 """Overrriden from TypeHandler."""
5411 code
= """ void %(name)s(%(typed_args)s) {
5412 const uint32_t size = gles2::cmds::%(name)s::ComputeSize(n);
5413 gles2::cmds::%(name)s* c =
5414 GetImmediateCmdSpaceTotalSize<gles2::cmds::%(name)s>(size);
5423 "typed_args": func
.MakeTypedOriginalArgString(""),
5424 "args": func
.MakeOriginalArgString(""),
5427 def WriteImmediateFormatTest(self
, func
, file):
5428 """Overrriden from TypeHandler."""
5429 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func
.name
)
5430 file.Write(" static GLuint ids[] = { 12, 23, 34, };\n")
5431 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" %
5432 (func
.name
, func
.name
))
5433 file.Write(" void* next_cmd = cmd.Set(\n")
5434 file.Write(" &cmd, static_cast<GLsizei>(arraysize(ids)), ids);\n")
5435 file.Write(" EXPECT_EQ(static_cast<uint32_t>(cmds::%s::kCmdId),\n" %
5437 file.Write(" cmd.header.command);\n")
5438 file.Write(" EXPECT_EQ(sizeof(cmd) +\n")
5439 file.Write(" RoundSizeToMultipleOfEntries(cmd.n * 4u),\n")
5440 file.Write(" cmd.header.size * 4u);\n")
5441 file.Write(" EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);\n");
5442 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n")
5443 file.Write(" next_cmd, sizeof(cmd) +\n")
5444 file.Write(" RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));\n")
5445 file.Write(" // TODO(gman): Check that ids were inserted;\n")
5450 class CreateHandler(TypeHandler
):
5451 """Handler for glCreate___ type functions."""
5454 TypeHandler
.__init
__(self
)
5456 def InitFunction(self
, func
):
5457 """Overrriden from TypeHandler."""
5458 func
.AddCmdArg(Argument("client_id", 'uint32_t'))
5460 def __GetResourceType(self
, func
):
5461 if func
.return_type
== "GLsync":
5464 return func
.name
[6:] # Create*
5466 def WriteServiceUnitTest(self
, func
, file, *extras
):
5467 """Overrriden from TypeHandler."""
5469 TEST_P(%(test_name)s, %(name)sValidArgs) {
5470 %(id_type_cast)sEXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s))
5471 .WillOnce(Return(%(const_service_id)s));
5472 SpecializedSetup<cmds::%(name)s, 0>(true);
5474 cmd.Init(%(args)s%(comma)skNewClientId);"""
5477 decoder_->set_unsafe_es3_apis_enabled(true);"""
5479 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5480 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
5483 %(return_type)s service_id = 0;
5484 EXPECT_TRUE(Get%(resource_type)sServiceId(kNewClientId, &service_id));
5485 EXPECT_EQ(%(const_service_id)s, service_id);
5486 decoder_->set_unsafe_es3_apis_enabled(false);
5487 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
5492 EXPECT_TRUE(Get%(resource_type)s(kNewClientId));
5497 for arg
in func
.GetOriginalArgs():
5498 if not arg
.IsConstant():
5502 if func
.return_type
== 'GLsync':
5503 id_type_cast
= ("const GLsync kNewServiceIdGLuint = reinterpret_cast"
5504 "<GLsync>(kNewServiceId);\n ")
5505 const_service_id
= "kNewServiceIdGLuint"
5508 const_service_id
= "kNewServiceId"
5509 self
.WriteValidUnitTest(func
, file, valid_test
, {
5511 'resource_type': self
.__GetResourceType
(func
),
5512 'return_type': func
.return_type
,
5513 'id_type_cast': id_type_cast
,
5514 'const_service_id': const_service_id
,
5517 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
5518 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
5519 SpecializedSetup<cmds::%(name)s, 0>(false);
5521 cmd.Init(%(args)s%(comma)skNewClientId);
5522 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));%(gl_error_test)s
5525 self
.WriteInvalidUnitTest(func
, file, invalid_test
, {
5529 def WriteHandlerImplementation (self
, func
, file):
5530 """Overrriden from TypeHandler."""
5532 code
= """ uint32_t client_id = c.client_id;
5533 %(return_type)s service_id = 0;
5534 if (group_->Get%(resource_name)sServiceId(client_id, &service_id)) {
5535 return error::kInvalidArguments;
5537 service_id = %(gl_func_name)s(%(gl_args)s);
5539 group_->Add%(resource_name)sId(client_id, service_id);
5543 code
= """ uint32_t client_id = c.client_id;
5544 if (Get%(resource_name)s(client_id)) {
5545 return error::kInvalidArguments;
5547 %(return_type)s service_id = %(gl_func_name)s(%(gl_args)s);
5549 Create%(resource_name)s(client_id, service_id%(gl_args_with_comma)s);
5553 'resource_name': self
.__GetResourceType
(func
),
5554 'return_type': func
.return_type
,
5555 'gl_func_name': func
.GetGLFunctionName(),
5556 'gl_args': func
.MakeOriginalArgString(""),
5557 'gl_args_with_comma': func
.MakeOriginalArgString("", True) })
5559 def WriteGLES2Implementation(self
, func
, file):
5560 """Overrriden from TypeHandler."""
5561 file.Write("%s GLES2Implementation::%s(%s) {\n" %
5562 (func
.return_type
, func
.original_name
,
5563 func
.MakeTypedOriginalArgString("")))
5564 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
5565 func
.WriteDestinationInitalizationValidation(file)
5566 self
.WriteClientGLCallLog(func
, file)
5567 for arg
in func
.GetOriginalArgs():
5568 arg
.WriteClientSideValidationCode(file, func
)
5569 file.Write(" GLuint client_id;\n")
5570 if func
.return_type
== "GLsync":
5572 " GetIdHandler(id_namespaces::kSyncs)->\n")
5575 " GetIdHandler(id_namespaces::kProgramsAndShaders)->\n")
5576 file.Write(" MakeIds(this, 0, 1, &client_id);\n")
5577 file.Write(" helper_->%s(%s);\n" %
5578 (func
.name
, func
.MakeCmdArgString("")))
5579 file.Write(' GPU_CLIENT_LOG("returned " << client_id);\n')
5580 file.Write(" CheckGLError();\n")
5581 if func
.return_type
== "GLsync":
5582 file.Write(" return reinterpret_cast<GLsync>(client_id);\n")
5584 file.Write(" return client_id;\n")
5589 class DeleteHandler(TypeHandler
):
5590 """Handler for glDelete___ single resource type functions."""
5593 TypeHandler
.__init
__(self
)
5595 def WriteServiceImplementation(self
, func
, file):
5596 """Overrriden from TypeHandler."""
5598 TypeHandler
.WriteServiceImplementation(self
, func
, file)
5599 # HandleDeleteShader and HandleDeleteProgram are manually written.
5602 def WriteGLES2Implementation(self
, func
, file):
5603 """Overrriden from TypeHandler."""
5604 file.Write("%s GLES2Implementation::%s(%s) {\n" %
5605 (func
.return_type
, func
.original_name
,
5606 func
.MakeTypedOriginalArgString("")))
5607 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
5608 func
.WriteDestinationInitalizationValidation(file)
5609 self
.WriteClientGLCallLog(func
, file)
5610 for arg
in func
.GetOriginalArgs():
5611 arg
.WriteClientSideValidationCode(file, func
)
5613 " GPU_CLIENT_DCHECK(%s != 0);\n" % func
.GetOriginalArgs()[-1].name
)
5614 file.Write(" %sHelper(%s);\n" %
5615 (func
.original_name
, func
.GetOriginalArgs()[-1].name
))
5616 file.Write(" CheckGLError();\n")
5620 def WriteHandlerImplementation (self
, func
, file):
5621 """Overrriden from TypeHandler."""
5622 assert len(func
.GetOriginalArgs()) == 1
5623 arg
= func
.GetOriginalArgs()[0]
5625 file.Write(""" %(arg_type)s service_id = 0;
5626 if (group_->Get%(resource_type)sServiceId(%(arg_name)s, &service_id)) {
5627 glDelete%(resource_type)s(service_id);
5628 group_->Remove%(resource_type)sId(%(arg_name)s);
5631 GL_INVALID_VALUE, "gl%(func_name)s", "unknown %(arg_name)s");
5633 """ % { 'resource_type': func
.GetInfo('resource_type'),
5634 'arg_name': arg
.name
,
5635 'arg_type': arg
.type,
5636 'func_name': func
.original_name
})
5638 file.Write(" %sHelper(%s);\n" % (func
.original_name
, arg
.name
))
5640 class DELnHandler(TypeHandler
):
5641 """Handler for glDelete___ type functions."""
5644 TypeHandler
.__init
__(self
)
5646 def WriteGetDataSizeCode(self
, func
, file):
5647 """Overrriden from TypeHandler."""
5648 code
= """ uint32_t data_size;
5649 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
5650 return error::kOutOfBounds;
5655 def WriteGLES2ImplementationUnitTest(self
, func
, file):
5656 """Overrriden from TypeHandler."""
5658 TEST_F(GLES2ImplementationTest, %(name)s) {
5659 GLuint ids[2] = { k%(types)sStartId, k%(types)sStartId + 1 };
5661 cmds::%(name)sImmediate del;
5665 expected.del.Init(arraysize(ids), &ids[0]);
5666 expected.data[0] = k%(types)sStartId;
5667 expected.data[1] = k%(types)sStartId + 1;
5668 gl_->%(name)s(arraysize(ids), &ids[0]);
5669 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
5674 'types': func
.GetInfo('resource_types'),
5677 def WriteServiceUnitTest(self
, func
, file, *extras
):
5678 """Overrriden from TypeHandler."""
5680 TEST_P(%(test_name)s, %(name)sValidArgs) {
5683 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId)))
5685 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_;
5686 SpecializedSetup<cmds::%(name)s, 0>(true);
5689 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5690 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5692 Get%(upper_resource_name)s(client_%(resource_name)s_id_) == NULL);
5695 self
.WriteValidUnitTest(func
, file, valid_test
, {
5696 'resource_name': func
.GetInfo('resource_type').lower(),
5697 'upper_resource_name': func
.GetInfo('resource_type'),
5700 TEST_P(%(test_name)s, %(name)sInvalidArgs) {
5701 GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId;
5702 SpecializedSetup<cmds::%(name)s, 0>(false);
5705 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5708 self
.WriteValidUnitTest(func
, file, invalid_test
, *extras
)
5710 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
5711 """Overrriden from TypeHandler."""
5713 TEST_P(%(test_name)s, %(name)sValidArgs) {
5716 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId)))
5718 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>();
5719 SpecializedSetup<cmds::%(name)s, 0>(true);
5720 cmd.Init(1, &client_%(resource_name)s_id_);"""
5723 decoder_->set_unsafe_es3_apis_enabled(true);"""
5725 EXPECT_EQ(error::kNoError,
5726 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_)));
5727 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
5730 EXPECT_FALSE(Get%(upper_resource_name)sServiceId(
5731 client_%(resource_name)s_id_, NULL));
5732 decoder_->set_unsafe_es3_apis_enabled(false);
5733 EXPECT_EQ(error::kUnknownCommand,
5734 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_)));
5740 Get%(upper_resource_name)s(client_%(resource_name)s_id_) == NULL);
5743 self
.WriteValidUnitTest(func
, file, valid_test
, {
5744 'resource_name': func
.GetInfo('resource_type').lower(),
5745 'upper_resource_name': func
.GetInfo('resource_type'),
5748 TEST_P(%(test_name)s, %(name)sInvalidArgs) {
5749 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>();
5750 SpecializedSetup<cmds::%(name)s, 0>(false);
5751 GLuint temp = kInvalidClientId;
5752 cmd.Init(1, &temp);"""
5755 decoder_->set_unsafe_es3_apis_enabled(true);
5756 EXPECT_EQ(error::kNoError,
5757 ExecuteImmediateCmd(cmd, sizeof(temp)));
5758 decoder_->set_unsafe_es3_apis_enabled(false);
5759 EXPECT_EQ(error::kUnknownCommand,
5760 ExecuteImmediateCmd(cmd, sizeof(temp)));
5765 EXPECT_EQ(error::kNoError,
5766 ExecuteImmediateCmd(cmd, sizeof(temp)));
5769 self
.WriteValidUnitTest(func
, file, invalid_test
, *extras
)
5771 def WriteHandlerImplementation (self
, func
, file):
5772 """Overrriden from TypeHandler."""
5773 file.Write(" %sHelper(n, %s);\n" %
5774 (func
.name
, func
.GetLastOriginalArg().name
))
5776 def WriteImmediateHandlerImplementation (self
, func
, file):
5777 """Overrriden from TypeHandler."""
5779 file.Write(""" for (GLsizei ii = 0; ii < n; ++ii) {
5780 GLuint service_id = 0;
5781 if (group_->Get%(resource_type)sServiceId(
5782 %(last_arg_name)s[ii], &service_id)) {
5783 glDelete%(resource_type)ss(1, &service_id);
5784 group_->Remove%(resource_type)sId(%(last_arg_name)s[ii]);
5787 """ % { 'resource_type': func
.GetInfo('resource_type'),
5788 'last_arg_name': func
.GetLastOriginalArg().name
})
5790 file.Write(" %sHelper(n, %s);\n" %
5791 (func
.original_name
, func
.GetLastOriginalArg().name
))
5793 def WriteGLES2Implementation(self
, func
, file):
5794 """Overrriden from TypeHandler."""
5795 impl_decl
= func
.GetInfo('impl_decl')
5796 if impl_decl
== None or impl_decl
== True:
5798 'return_type': func
.return_type
,
5799 'name': func
.original_name
,
5800 'typed_args': func
.MakeTypedOriginalArgString(""),
5801 'args': func
.MakeOriginalArgString(""),
5802 'resource_type': func
.GetInfo('resource_type').lower(),
5803 'count_name': func
.GetOriginalArgs()[0].name
,
5806 "%(return_type)s GLES2Implementation::%(name)s(%(typed_args)s) {\n" %
5808 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
5809 func
.WriteDestinationInitalizationValidation(file)
5810 self
.WriteClientGLCallLog(func
, file)
5811 file.Write(""" GPU_CLIENT_LOG_CODE_BLOCK({
5812 for (GLsizei i = 0; i < n; ++i) {
5813 GPU_CLIENT_LOG(" " << i << ": " << %s[i]);
5816 """ % func
.GetOriginalArgs()[1].name
)
5817 file.Write(""" GPU_CLIENT_DCHECK_CODE_BLOCK({
5818 for (GLsizei i = 0; i < n; ++i) {
5822 """ % func
.GetOriginalArgs()[1].name
)
5823 for arg
in func
.GetOriginalArgs():
5824 arg
.WriteClientSideValidationCode(file, func
)
5825 code
= """ %(name)sHelper(%(args)s);
5830 file.Write(code
% args
)
5832 def WriteImmediateCmdComputeSize(self
, func
, file):
5833 """Overrriden from TypeHandler."""
5834 file.Write(" static uint32_t ComputeDataSize(GLsizei n) {\n")
5836 " return static_cast<uint32_t>(sizeof(GLuint) * n); // NOLINT\n")
5839 file.Write(" static uint32_t ComputeSize(GLsizei n) {\n")
5840 file.Write(" return static_cast<uint32_t>(\n")
5841 file.Write(" sizeof(ValueType) + ComputeDataSize(n)); // NOLINT\n")
5845 def WriteImmediateCmdSetHeader(self
, func
, file):
5846 """Overrriden from TypeHandler."""
5847 file.Write(" void SetHeader(GLsizei n) {\n")
5848 file.Write(" header.SetCmdByTotalSize<ValueType>(ComputeSize(n));\n")
5852 def WriteImmediateCmdInit(self
, func
, file):
5853 """Overrriden from TypeHandler."""
5854 last_arg
= func
.GetLastOriginalArg()
5855 file.Write(" void Init(%s, %s _%s) {\n" %
5856 (func
.MakeTypedCmdArgString("_"),
5857 last_arg
.type, last_arg
.name
))
5858 file.Write(" SetHeader(_n);\n")
5859 args
= func
.GetCmdArgs()
5861 file.Write(" %s = _%s;\n" % (arg
.name
, arg
.name
))
5862 file.Write(" memcpy(ImmediateDataAddress(this),\n")
5863 file.Write(" _%s, ComputeDataSize(_n));\n" % last_arg
.name
)
5867 def WriteImmediateCmdSet(self
, func
, file):
5868 """Overrriden from TypeHandler."""
5869 last_arg
= func
.GetLastOriginalArg()
5870 copy_args
= func
.MakeCmdArgString("_", False)
5871 file.Write(" void* Set(void* cmd%s, %s _%s) {\n" %
5872 (func
.MakeTypedCmdArgString("_", True),
5873 last_arg
.type, last_arg
.name
))
5874 file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" %
5875 (copy_args
, last_arg
.name
))
5876 file.Write(" const uint32_t size = ComputeSize(_n);\n")
5877 file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
5882 def WriteImmediateCmdHelper(self
, func
, file):
5883 """Overrriden from TypeHandler."""
5884 code
= """ void %(name)s(%(typed_args)s) {
5885 const uint32_t size = gles2::cmds::%(name)s::ComputeSize(n);
5886 gles2::cmds::%(name)s* c =
5887 GetImmediateCmdSpaceTotalSize<gles2::cmds::%(name)s>(size);
5896 "typed_args": func
.MakeTypedOriginalArgString(""),
5897 "args": func
.MakeOriginalArgString(""),
5900 def WriteImmediateFormatTest(self
, func
, file):
5901 """Overrriden from TypeHandler."""
5902 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func
.name
)
5903 file.Write(" static GLuint ids[] = { 12, 23, 34, };\n")
5904 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" %
5905 (func
.name
, func
.name
))
5906 file.Write(" void* next_cmd = cmd.Set(\n")
5907 file.Write(" &cmd, static_cast<GLsizei>(arraysize(ids)), ids);\n")
5908 file.Write(" EXPECT_EQ(static_cast<uint32_t>(cmds::%s::kCmdId),\n" %
5910 file.Write(" cmd.header.command);\n")
5911 file.Write(" EXPECT_EQ(sizeof(cmd) +\n")
5912 file.Write(" RoundSizeToMultipleOfEntries(cmd.n * 4u),\n")
5913 file.Write(" cmd.header.size * 4u);\n")
5914 file.Write(" EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);\n");
5915 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n")
5916 file.Write(" next_cmd, sizeof(cmd) +\n")
5917 file.Write(" RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));\n")
5918 file.Write(" // TODO(gman): Check that ids were inserted;\n")
5923 class GETnHandler(TypeHandler
):
5924 """Handler for GETn for glGetBooleanv, glGetFloatv, ... type functions."""
5927 TypeHandler
.__init
__(self
)
5929 def NeedsDataTransferFunction(self
, func
):
5930 """Overriden from TypeHandler."""
5933 def WriteServiceImplementation(self
, func
, file):
5934 """Overrriden from TypeHandler."""
5935 self
.WriteServiceHandlerFunctionHeader(func
, file)
5936 last_arg
= func
.GetLastOriginalArg()
5937 # All except shm_id and shm_offset.
5938 all_but_last_args
= func
.GetCmdArgs()[:-2]
5939 for arg
in all_but_last_args
:
5940 arg
.WriteGetCode(file)
5942 code
= """ typedef cmds::%(func_name)s::Result Result;
5943 GLsizei num_values = 0;
5944 GetNumValuesReturnedForGLGet(pname, &num_values);
5945 Result* result = GetSharedMemoryAs<Result*>(
5946 c.%(last_arg_name)s_shm_id, c.%(last_arg_name)s_shm_offset,
5947 Result::ComputeSize(num_values));
5948 %(last_arg_type)s %(last_arg_name)s = result ? result->GetData() : NULL;
5951 'last_arg_type': last_arg
.type,
5952 'last_arg_name': last_arg
.name
,
5953 'func_name': func
.name
,
5955 func
.WriteHandlerValidation(file)
5956 code
= """ // Check that the client initialized the result.
5957 if (result->size != 0) {
5958 return error::kInvalidArguments;
5961 shadowed
= func
.GetInfo('shadowed')
5963 file.Write(' LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("%s");\n' % func
.name
)
5965 func
.WriteHandlerImplementation(file)
5967 code
= """ result->SetNumResults(num_values);
5968 return error::kNoError;
5972 code
= """ GLenum error = glGetError();
5973 if (error == GL_NO_ERROR) {
5974 result->SetNumResults(num_values);
5976 LOCAL_SET_GL_ERROR(error, "%(func_name)s", "");
5978 return error::kNoError;
5982 file.Write(code
% {'func_name': func
.name
})
5984 def WriteGLES2Implementation(self
, func
, file):
5985 """Overrriden from TypeHandler."""
5986 impl_decl
= func
.GetInfo('impl_decl')
5987 if impl_decl
== None or impl_decl
== True:
5988 file.Write("%s GLES2Implementation::%s(%s) {\n" %
5989 (func
.return_type
, func
.original_name
,
5990 func
.MakeTypedOriginalArgString("")))
5991 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
5992 func
.WriteDestinationInitalizationValidation(file)
5993 self
.WriteClientGLCallLog(func
, file)
5994 for arg
in func
.GetOriginalArgs():
5995 arg
.WriteClientSideValidationCode(file, func
)
5996 all_but_last_args
= func
.GetOriginalArgs()[:-1]
5998 has_length_arg
= False
5999 for arg
in all_but_last_args
:
6000 if arg
.type == 'GLsync':
6001 args
.append('ToGLuint(%s)' % arg
.name
)
6002 elif arg
.name
.endswith('size') and arg
.type == 'GLsizei':
6004 elif arg
.name
== 'length':
6005 has_length_arg
= True
6008 args
.append(arg
.name
)
6009 arg_string
= ", ".join(args
)
6013 for arg
in func
.GetOriginalArgs() if not arg
.IsConstant()]))
6014 self
.WriteTraceEvent(func
, file)
6015 code
= """ if (%(func_name)sHelper(%(all_arg_string)s)) {
6018 typedef cmds::%(func_name)s::Result Result;
6019 Result* result = GetResultAs<Result*>();
6023 result->SetNumResults(0);
6024 helper_->%(func_name)s(%(arg_string)s,
6025 GetResultShmId(), GetResultShmOffset());
6027 result->CopyResult(%(last_arg_name)s);
6028 GPU_CLIENT_LOG_CODE_BLOCK({
6029 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
6030 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
6036 *length = result->GetNumResults();
6043 'func_name': func
.name
,
6044 'arg_string': arg_string
,
6045 'all_arg_string': all_arg_string
,
6046 'last_arg_name': func
.GetLastOriginalArg().name
,
6049 def WriteGLES2ImplementationUnitTest(self
, func
, file):
6050 """Writes the GLES2 Implemention unit test."""
6052 TEST_F(GLES2ImplementationTest, %(name)s) {
6056 typedef cmds::%(name)s::Result Result;
6057 Result::Type result = 0;
6059 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
6060 expected.cmd.Init(%(cmd_args)s, result1.id, result1.offset);
6061 EXPECT_CALL(*command_buffer(), OnFlush())
6062 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
6063 .RetiresOnSaturation();
6064 gl_->%(name)s(%(args)s, &result);
6065 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
6066 EXPECT_EQ(static_cast<Result::Type>(1), result);
6069 first_cmd_arg
= func
.GetCmdArgs()[0].GetValidNonCachedClientSideCmdArg(func
)
6070 if not first_cmd_arg
:
6073 first_gl_arg
= func
.GetOriginalArgs()[0].GetValidNonCachedClientSideArg(
6076 cmd_arg_strings
= [first_cmd_arg
]
6077 for arg
in func
.GetCmdArgs()[1:-2]:
6078 cmd_arg_strings
.append(arg
.GetValidClientSideCmdArg(func
))
6079 gl_arg_strings
= [first_gl_arg
]
6080 for arg
in func
.GetOriginalArgs()[1:-1]:
6081 gl_arg_strings
.append(arg
.GetValidClientSideArg(func
))
6085 'args': ", ".join(gl_arg_strings
),
6086 'cmd_args': ", ".join(cmd_arg_strings
),
6089 def WriteServiceUnitTest(self
, func
, file, *extras
):
6090 """Overrriden from TypeHandler."""
6092 TEST_P(%(test_name)s, %(name)sValidArgs) {
6093 EXPECT_CALL(*gl_, GetError())
6094 .WillOnce(Return(GL_NO_ERROR))
6095 .WillOnce(Return(GL_NO_ERROR))
6096 .RetiresOnSaturation();
6097 SpecializedSetup<cmds::%(name)s, 0>(true);
6098 typedef cmds::%(name)s::Result Result;
6099 Result* result = static_cast<Result*>(shared_memory_address_);
6100 EXPECT_CALL(*gl_, %(gl_func_name)s(%(local_gl_args)s));
6103 cmd.Init(%(cmd_args)s);"""
6106 decoder_->set_unsafe_es3_apis_enabled(true);"""
6108 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6109 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(
6111 result->GetNumResults());
6112 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
6115 decoder_->set_unsafe_es3_apis_enabled(false);
6116 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));"""
6121 cmd_arg_strings
= []
6123 for arg
in func
.GetOriginalArgs()[:-1]:
6124 if arg
.name
== 'length':
6125 gl_arg_value
= 'nullptr'
6126 elif arg
.name
.endswith('size'):
6127 gl_arg_value
= ("decoder_->GetGLES2Util()->GLGetNumValuesReturned(%s)" %
6129 elif arg
.type == 'GLsync':
6130 gl_arg_value
= 'reinterpret_cast<GLsync>(kServiceSyncId)'
6132 gl_arg_value
= arg
.GetValidGLArg(func
)
6133 gl_arg_strings
.append(gl_arg_value
)
6134 if arg
.name
== 'pname':
6135 valid_pname
= gl_arg_value
6136 if arg
.name
.endswith('size') or arg
.name
== 'length':
6138 if arg
.type == 'GLsync':
6139 arg_value
= 'client_sync_id_'
6141 arg_value
= arg
.GetValidArg(func
)
6142 cmd_arg_strings
.append(arg_value
)
6143 if func
.GetInfo('gl_test_func') == 'glGetIntegerv':
6144 gl_arg_strings
.append("_")
6146 gl_arg_strings
.append("result->GetData()")
6147 cmd_arg_strings
.append("shared_memory_id_")
6148 cmd_arg_strings
.append("shared_memory_offset_")
6150 self
.WriteValidUnitTest(func
, file, valid_test
, {
6151 'local_gl_args': ", ".join(gl_arg_strings
),
6152 'cmd_args': ", ".join(cmd_arg_strings
),
6153 'valid_pname': valid_pname
,
6156 if not func
.IsUnsafe():
6158 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
6159 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
6160 SpecializedSetup<cmds::%(name)s, 0>(false);
6161 cmds::%(name)s::Result* result =
6162 static_cast<cmds::%(name)s::Result*>(shared_memory_address_);
6166 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));
6167 EXPECT_EQ(0u, result->size);%(gl_error_test)s
6170 self
.WriteInvalidUnitTest(func
, file, invalid_test
, *extras
)
6172 class ArrayArgTypeHandler(TypeHandler
):
6173 """Base class for type handlers that handle args that are arrays"""
6176 TypeHandler
.__init
__(self
)
6178 def GetArrayType(self
, func
):
6179 """Returns the type of the element in the element array being PUT to."""
6180 for arg
in func
.GetOriginalArgs():
6182 element_type
= arg
.GetPointedType()
6185 # Special case: array type handler is used for a function that is forwarded
6186 # to the actual array type implementation
6187 element_type
= func
.GetOriginalArgs()[-1].type
6188 assert all(arg
.type == element_type \
6189 for arg
in func
.GetOriginalArgs()[-self
.GetArrayCount(func
):])
6192 def GetArrayCount(self
, func
):
6193 """Returns the count of the elements in the array being PUT to."""
6194 return func
.GetInfo('count')
6196 class PUTHandler(ArrayArgTypeHandler
):
6197 """Handler for glTexParameter_v, glVertexAttrib_v functions."""
6200 ArrayArgTypeHandler
.__init
__(self
)
6202 def WriteServiceUnitTest(self
, func
, file, *extras
):
6203 """Writes the service unit test for a command."""
6204 expected_call
= "EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));"
6205 if func
.GetInfo("first_element_only"):
6207 arg
.GetValidGLArg(func
) for arg
in func
.GetOriginalArgs()
6209 gl_arg_strings
[-1] = "*" + gl_arg_strings
[-1]
6210 expected_call
= ("EXPECT_CALL(*gl_, %%(gl_func_name)s(%s));" %
6211 ", ".join(gl_arg_strings
))
6213 TEST_P(%(test_name)s, %(name)sValidArgs) {
6214 SpecializedSetup<cmds::%(name)s, 0>(true);
6217 GetSharedMemoryAs<%(data_type)s*>()[0] = %(data_value)s;
6219 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6220 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6224 'data_type': self
.GetArrayType(func
),
6225 'data_value': func
.GetInfo('data_value') or '0',
6226 'expected_call': expected_call
,
6228 self
.WriteValidUnitTest(func
, file, valid_test
, extra
, *extras
)
6231 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
6232 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
6233 SpecializedSetup<cmds::%(name)s, 0>(false);
6236 GetSharedMemoryAs<%(data_type)s*>()[0] = %(data_value)s;
6237 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
6240 self
.WriteInvalidUnitTest(func
, file, invalid_test
, extra
, *extras
)
6242 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
6243 """Writes the service unit test for a command."""
6245 TEST_P(%(test_name)s, %(name)sValidArgs) {
6246 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>();
6247 SpecializedSetup<cmds::%(name)s, 0>(true);
6248 %(data_type)s temp[%(data_count)s] = { %(data_value)s, };
6249 cmd.Init(%(gl_args)s, &temp[0]);
6252 %(gl_func_name)s(%(gl_args)s, %(data_ref)sreinterpret_cast<
6253 %(data_type)s*>(ImmediateDataAddress(&cmd))));"""
6256 decoder_->set_unsafe_es3_apis_enabled(true);"""
6258 EXPECT_EQ(error::kNoError,
6259 ExecuteImmediateCmd(cmd, sizeof(temp)));
6260 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
6263 decoder_->set_unsafe_es3_apis_enabled(false);
6264 EXPECT_EQ(error::kUnknownCommand,
6265 ExecuteImmediateCmd(cmd, sizeof(temp)));"""
6270 arg
.GetValidGLArg(func
) for arg
in func
.GetOriginalArgs()[0:-1]
6272 gl_any_strings
= ["_"] * len(gl_arg_strings
)
6275 'data_ref': ("*" if func
.GetInfo('first_element_only') else ""),
6276 'data_type': self
.GetArrayType(func
),
6277 'data_count': self
.GetArrayCount(func
),
6278 'data_value': func
.GetInfo('data_value') or '0',
6279 'gl_args': ", ".join(gl_arg_strings
),
6280 'gl_any_args': ", ".join(gl_any_strings
),
6282 self
.WriteValidUnitTest(func
, file, valid_test
, extra
, *extras
)
6285 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
6286 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>();"""
6289 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(1);
6293 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(0);
6296 SpecializedSetup<cmds::%(name)s, 0>(false);
6297 %(data_type)s temp[%(data_count)s] = { %(data_value)s, };
6298 cmd.Init(%(all_but_last_args)s, &temp[0]);"""
6301 decoder_->set_unsafe_es3_apis_enabled(true);
6302 EXPECT_EQ(error::%(parse_result)s,
6303 ExecuteImmediateCmd(cmd, sizeof(temp)));
6304 decoder_->set_unsafe_es3_apis_enabled(false);
6309 EXPECT_EQ(error::%(parse_result)s,
6310 ExecuteImmediateCmd(cmd, sizeof(temp)));
6314 self
.WriteInvalidUnitTest(func
, file, invalid_test
, extra
, *extras
)
6316 def WriteGetDataSizeCode(self
, func
, file):
6317 """Overrriden from TypeHandler."""
6318 code
= """ uint32_t data_size;
6319 if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) {
6320 return error::kOutOfBounds;
6323 file.Write(code
% (self
.GetArrayType(func
), self
.GetArrayCount(func
)))
6324 if func
.IsImmediate():
6325 file.Write(" if (data_size > immediate_data_size) {\n")
6326 file.Write(" return error::kOutOfBounds;\n")
6329 def __NeedsToCalcDataCount(self
, func
):
6330 use_count_func
= func
.GetInfo('use_count_func')
6331 return use_count_func
!= None and use_count_func
!= False
6333 def WriteGLES2Implementation(self
, func
, file):
6334 """Overrriden from TypeHandler."""
6335 impl_func
= func
.GetInfo('impl_func')
6336 if (impl_func
!= None and impl_func
!= True):
6338 file.Write("%s GLES2Implementation::%s(%s) {\n" %
6339 (func
.return_type
, func
.original_name
,
6340 func
.MakeTypedOriginalArgString("")))
6341 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
6342 func
.WriteDestinationInitalizationValidation(file)
6343 self
.WriteClientGLCallLog(func
, file)
6345 if self
.__NeedsToCalcDataCount
(func
):
6346 file.Write(" size_t count = GLES2Util::Calc%sDataCount(%s);\n" %
6347 (func
.name
, func
.GetOriginalArgs()[0].name
))
6348 file.Write(" DCHECK_LE(count, %du);\n" % self
.GetArrayCount(func
))
6350 file.Write(" size_t count = %d;" % self
.GetArrayCount(func
))
6351 file.Write(" for (size_t ii = 0; ii < count; ++ii)\n")
6352 file.Write(' GPU_CLIENT_LOG("value[" << ii << "]: " << %s[ii]);\n' %
6353 func
.GetLastOriginalArg().name
)
6354 for arg
in func
.GetOriginalArgs():
6355 arg
.WriteClientSideValidationCode(file, func
)
6356 file.Write(" helper_->%sImmediate(%s);\n" %
6357 (func
.name
, func
.MakeOriginalArgString("")))
6358 file.Write(" CheckGLError();\n")
6362 def WriteGLES2ImplementationUnitTest(self
, func
, file):
6363 """Writes the GLES2 Implemention unit test."""
6364 client_test
= func
.GetInfo('client_test')
6365 if (client_test
!= None and client_test
!= True):
6368 TEST_F(GLES2ImplementationTest, %(name)s) {
6369 %(type)s data[%(count)d] = {0};
6371 cmds::%(name)sImmediate cmd;
6372 %(type)s data[%(count)d];
6375 for (int jj = 0; jj < %(count)d; ++jj) {
6376 data[jj] = static_cast<%(type)s>(jj);
6379 expected.cmd.Init(%(cmd_args)s, &data[0]);
6380 gl_->%(name)s(%(args)s, &data[0]);
6381 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
6385 arg
.GetValidClientSideCmdArg(func
) for arg
in func
.GetCmdArgs()[0:-2]
6388 arg
.GetValidClientSideArg(func
) for arg
in func
.GetOriginalArgs()[0:-1]
6393 'type': self
.GetArrayType(func
),
6394 'count': self
.GetArrayCount(func
),
6395 'args': ", ".join(gl_arg_strings
),
6396 'cmd_args': ", ".join(cmd_arg_strings
),
6399 def WriteImmediateCmdComputeSize(self
, func
, file):
6400 """Overrriden from TypeHandler."""
6401 file.Write(" static uint32_t ComputeDataSize() {\n")
6402 file.Write(" return static_cast<uint32_t>(\n")
6403 file.Write(" sizeof(%s) * %d);\n" %
6404 (self
.GetArrayType(func
), self
.GetArrayCount(func
)))
6407 if self
.__NeedsToCalcDataCount
(func
):
6408 file.Write(" static uint32_t ComputeEffectiveDataSize(%s %s) {\n" %
6409 (func
.GetOriginalArgs()[0].type,
6410 func
.GetOriginalArgs()[0].name
))
6411 file.Write(" return static_cast<uint32_t>(\n")
6412 file.Write(" sizeof(%s) * GLES2Util::Calc%sDataCount(%s));\n" %
6413 (self
.GetArrayType(func
), func
.original_name
,
6414 func
.GetOriginalArgs()[0].name
))
6417 file.Write(" static uint32_t ComputeSize() {\n")
6418 file.Write(" return static_cast<uint32_t>(\n")
6420 " sizeof(ValueType) + ComputeDataSize());\n")
6424 def WriteImmediateCmdSetHeader(self
, func
, file):
6425 """Overrriden from TypeHandler."""
6426 file.Write(" void SetHeader() {\n")
6428 " header.SetCmdByTotalSize<ValueType>(ComputeSize());\n")
6432 def WriteImmediateCmdInit(self
, func
, file):
6433 """Overrriden from TypeHandler."""
6434 last_arg
= func
.GetLastOriginalArg()
6435 file.Write(" void Init(%s, %s _%s) {\n" %
6436 (func
.MakeTypedCmdArgString("_"),
6437 last_arg
.type, last_arg
.name
))
6438 file.Write(" SetHeader();\n")
6439 args
= func
.GetCmdArgs()
6441 file.Write(" %s = _%s;\n" % (arg
.name
, arg
.name
))
6442 file.Write(" memcpy(ImmediateDataAddress(this),\n")
6443 if self
.__NeedsToCalcDataCount
(func
):
6444 file.Write(" _%s, ComputeEffectiveDataSize(%s));" %
6445 (last_arg
.name
, func
.GetOriginalArgs()[0].name
))
6447 DCHECK_GE(ComputeDataSize(), ComputeEffectiveDataSize(%(arg)s));
6448 char* pointer = reinterpret_cast<char*>(ImmediateDataAddress(this)) +
6449 ComputeEffectiveDataSize(%(arg)s);
6450 memset(pointer, 0, ComputeDataSize() - ComputeEffectiveDataSize(%(arg)s));
6451 """ % { 'arg': func
.GetOriginalArgs()[0].name
, })
6453 file.Write(" _%s, ComputeDataSize());\n" % last_arg
.name
)
6457 def WriteImmediateCmdSet(self
, func
, file):
6458 """Overrriden from TypeHandler."""
6459 last_arg
= func
.GetLastOriginalArg()
6460 copy_args
= func
.MakeCmdArgString("_", False)
6461 file.Write(" void* Set(void* cmd%s, %s _%s) {\n" %
6462 (func
.MakeTypedCmdArgString("_", True),
6463 last_arg
.type, last_arg
.name
))
6464 file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" %
6465 (copy_args
, last_arg
.name
))
6466 file.Write(" const uint32_t size = ComputeSize();\n")
6467 file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
6472 def WriteImmediateCmdHelper(self
, func
, file):
6473 """Overrriden from TypeHandler."""
6474 code
= """ void %(name)s(%(typed_args)s) {
6475 const uint32_t size = gles2::cmds::%(name)s::ComputeSize();
6476 gles2::cmds::%(name)s* c =
6477 GetImmediateCmdSpaceTotalSize<gles2::cmds::%(name)s>(size);
6486 "typed_args": func
.MakeTypedOriginalArgString(""),
6487 "args": func
.MakeOriginalArgString(""),
6490 def WriteImmediateFormatTest(self
, func
, file):
6491 """Overrriden from TypeHandler."""
6492 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func
.name
)
6493 file.Write(" const int kSomeBaseValueToTestWith = 51;\n")
6494 file.Write(" static %s data[] = {\n" % self
.GetArrayType(func
))
6495 for v
in range(0, self
.GetArrayCount(func
)):
6496 file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" %
6497 (self
.GetArrayType(func
), v
))
6499 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" %
6500 (func
.name
, func
.name
))
6501 file.Write(" void* next_cmd = cmd.Set(\n")
6503 args
= func
.GetCmdArgs()
6504 for value
, arg
in enumerate(args
):
6505 file.Write(",\n static_cast<%s>(%d)" % (arg
.type, value
+ 11))
6506 file.Write(",\n data);\n")
6507 args
= func
.GetCmdArgs()
6508 file.Write(" EXPECT_EQ(static_cast<uint32_t>(cmds::%s::kCmdId),\n"
6510 file.Write(" cmd.header.command);\n")
6511 file.Write(" EXPECT_EQ(sizeof(cmd) +\n")
6512 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)),\n")
6513 file.Write(" cmd.header.size * 4u);\n")
6514 for value
, arg
in enumerate(args
):
6515 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" %
6516 (arg
.type, value
+ 11, arg
.name
))
6517 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n")
6518 file.Write(" next_cmd, sizeof(cmd) +\n")
6519 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n")
6520 file.Write(" // TODO(gman): Check that data was inserted;\n")
6525 class PUTnHandler(ArrayArgTypeHandler
):
6526 """Handler for PUTn 'glUniform__v' type functions."""
6529 ArrayArgTypeHandler
.__init
__(self
)
6531 def WriteServiceUnitTest(self
, func
, file, *extras
):
6532 """Overridden from TypeHandler."""
6533 ArrayArgTypeHandler
.WriteServiceUnitTest(self
, func
, file, *extras
)
6536 TEST_P(%(test_name)s, %(name)sValidArgsCountTooLarge) {
6537 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
6538 SpecializedSetup<cmds::%(name)s, 0>(true);
6541 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6542 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6547 for count
, arg
in enumerate(func
.GetOriginalArgs()):
6548 # hardcoded to match unit tests.
6550 # the location of the second element of the 2nd uniform.
6551 # defined in GLES2DecoderBase::SetupShaderForUniform
6552 gl_arg_strings
.append("3")
6553 arg_strings
.append("ProgramManager::MakeFakeLocation(1, 1)")
6555 # the number of elements that gl will be called with.
6556 gl_arg_strings
.append("3")
6557 # the number of elements requested in the command.
6558 arg_strings
.append("5")
6560 gl_arg_strings
.append(arg
.GetValidGLArg(func
))
6561 if not arg
.IsConstant():
6562 arg_strings
.append(arg
.GetValidArg(func
))
6564 'gl_args': ", ".join(gl_arg_strings
),
6565 'args': ", ".join(arg_strings
),
6567 self
.WriteValidUnitTest(func
, file, valid_test
, extra
, *extras
)
6569 def WriteImmediateServiceUnitTest(self
, func
, file, *extras
):
6570 """Overridden from TypeHandler."""
6572 TEST_P(%(test_name)s, %(name)sValidArgs) {
6573 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>();
6576 %(gl_func_name)s(%(gl_args)s,
6577 reinterpret_cast<%(data_type)s*>(ImmediateDataAddress(&cmd))));
6578 SpecializedSetup<cmds::%(name)s, 0>(true);
6579 %(data_type)s temp[%(data_count)s * 2] = { 0, };
6580 cmd.Init(%(args)s, &temp[0]);"""
6583 decoder_->set_unsafe_es3_apis_enabled(true);"""
6585 EXPECT_EQ(error::kNoError,
6586 ExecuteImmediateCmd(cmd, sizeof(temp)));
6587 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
6590 decoder_->set_unsafe_es3_apis_enabled(false);
6591 EXPECT_EQ(error::kUnknownCommand,
6592 ExecuteImmediateCmd(cmd, sizeof(temp)));"""
6599 for arg
in func
.GetOriginalArgs()[0:-1]:
6600 gl_arg_strings
.append(arg
.GetValidGLArg(func
))
6601 gl_any_strings
.append("_")
6602 if not arg
.IsConstant():
6603 arg_strings
.append(arg
.GetValidArg(func
))
6605 'data_type': self
.GetArrayType(func
),
6606 'data_count': self
.GetArrayCount(func
),
6607 'args': ", ".join(arg_strings
),
6608 'gl_args': ", ".join(gl_arg_strings
),
6609 'gl_any_args': ", ".join(gl_any_strings
),
6611 self
.WriteValidUnitTest(func
, file, valid_test
, extra
, *extras
)
6614 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
6615 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>();
6616 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(0);
6617 SpecializedSetup<cmds::%(name)s, 0>(false);
6618 %(data_type)s temp[%(data_count)s * 2] = { 0, };
6619 cmd.Init(%(all_but_last_args)s, &temp[0]);
6620 EXPECT_EQ(error::%(parse_result)s,
6621 ExecuteImmediateCmd(cmd, sizeof(temp)));%(gl_error_test)s
6624 self
.WriteInvalidUnitTest(func
, file, invalid_test
, extra
, *extras
)
6626 def WriteGetDataSizeCode(self
, func
, file):
6627 """Overrriden from TypeHandler."""
6628 code
= """ uint32_t data_size;
6629 if (!ComputeDataSize(count, sizeof(%s), %d, &data_size)) {
6630 return error::kOutOfBounds;
6633 file.Write(code
% (self
.GetArrayType(func
), self
.GetArrayCount(func
)))
6634 if func
.IsImmediate():
6635 file.Write(" if (data_size > immediate_data_size) {\n")
6636 file.Write(" return error::kOutOfBounds;\n")
6639 def WriteGLES2Implementation(self
, func
, file):
6640 """Overrriden from TypeHandler."""
6641 file.Write("%s GLES2Implementation::%s(%s) {\n" %
6642 (func
.return_type
, func
.original_name
,
6643 func
.MakeTypedOriginalArgString("")))
6644 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
6645 func
.WriteDestinationInitalizationValidation(file)
6646 self
.WriteClientGLCallLog(func
, file)
6647 last_pointer_name
= func
.GetLastOriginalPointerArg().name
6648 file.Write(""" GPU_CLIENT_LOG_CODE_BLOCK({
6649 for (GLsizei i = 0; i < count; ++i) {
6651 values_str
= ' << ", " << '.join(
6652 ["%s[%d + i * %d]" % (
6653 last_pointer_name
, ndx
, self
.GetArrayCount(func
)) for ndx
in range(
6654 0, self
.GetArrayCount(func
))])
6655 file.Write(' GPU_CLIENT_LOG(" " << i << ": " << %s);\n' % values_str
)
6656 file.Write(" }\n });\n")
6657 for arg
in func
.GetOriginalArgs():
6658 arg
.WriteClientSideValidationCode(file, func
)
6659 file.Write(" helper_->%sImmediate(%s);\n" %
6660 (func
.name
, func
.MakeInitString("")))
6661 file.Write(" CheckGLError();\n")
6665 def WriteGLES2ImplementationUnitTest(self
, func
, file):
6666 """Writes the GLES2 Implemention unit test."""
6668 TEST_F(GLES2ImplementationTest, %(name)s) {
6669 %(type)s data[%(count_param)d][%(count)d] = {{0}};
6671 cmds::%(name)sImmediate cmd;
6672 %(type)s data[%(count_param)d][%(count)d];
6676 for (int ii = 0; ii < %(count_param)d; ++ii) {
6677 for (int jj = 0; jj < %(count)d; ++jj) {
6678 data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj);
6681 expected.cmd.Init(%(cmd_args)s);
6682 gl_->%(name)s(%(args)s);
6683 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
6686 cmd_arg_strings
= []
6687 for arg
in func
.GetCmdArgs():
6688 if arg
.name
.endswith("_shm_id"):
6689 cmd_arg_strings
.append("&data[0][0]")
6690 elif arg
.name
.endswith("_shm_offset"):
6693 cmd_arg_strings
.append(arg
.GetValidClientSideCmdArg(func
))
6696 for arg
in func
.GetOriginalArgs():
6698 valid_value
= "&data[0][0]"
6700 valid_value
= arg
.GetValidClientSideArg(func
)
6701 gl_arg_strings
.append(valid_value
)
6702 if arg
.name
== "count":
6703 count_param
= int(valid_value
)
6706 'type': self
.GetArrayType(func
),
6707 'count': self
.GetArrayCount(func
),
6708 'args': ", ".join(gl_arg_strings
),
6709 'cmd_args': ", ".join(cmd_arg_strings
),
6710 'count_param': count_param
,
6713 # Test constants for invalid values, as they are not tested by the
6716 arg
for arg
in func
.GetOriginalArgs()[0:-1] if arg
.IsConstant()
6722 TEST_F(GLES2ImplementationTest, %(name)sInvalidConstantArg%(invalid_index)d) {
6723 %(type)s data[%(count_param)d][%(count)d] = {{0}};
6724 for (int ii = 0; ii < %(count_param)d; ++ii) {
6725 for (int jj = 0; jj < %(count)d; ++jj) {
6726 data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj);
6729 gl_->%(name)s(%(args)s);
6730 EXPECT_TRUE(NoCommandsWritten());
6731 EXPECT_EQ(%(gl_error)s, CheckError());
6734 for invalid_arg
in constants
:
6736 invalid
= invalid_arg
.GetInvalidArg(func
)
6737 for arg
in func
.GetOriginalArgs():
6738 if arg
is invalid_arg
:
6739 gl_arg_strings
.append(invalid
[0])
6740 elif arg
.IsPointer():
6741 gl_arg_strings
.append("&data[0][0]")
6743 valid_value
= arg
.GetValidClientSideArg(func
)
6744 gl_arg_strings
.append(valid_value
)
6745 if arg
.name
== "count":
6746 count_param
= int(valid_value
)
6750 'invalid_index': func
.GetOriginalArgs().index(invalid_arg
),
6751 'type': self
.GetArrayType(func
),
6752 'count': self
.GetArrayCount(func
),
6753 'args': ", ".join(gl_arg_strings
),
6754 'gl_error': invalid
[2],
6755 'count_param': count_param
,
6759 def WriteImmediateCmdComputeSize(self
, func
, file):
6760 """Overrriden from TypeHandler."""
6761 file.Write(" static uint32_t ComputeDataSize(GLsizei count) {\n")
6762 file.Write(" return static_cast<uint32_t>(\n")
6763 file.Write(" sizeof(%s) * %d * count); // NOLINT\n" %
6764 (self
.GetArrayType(func
), self
.GetArrayCount(func
)))
6767 file.Write(" static uint32_t ComputeSize(GLsizei count) {\n")
6768 file.Write(" return static_cast<uint32_t>(\n")
6770 " sizeof(ValueType) + ComputeDataSize(count)); // NOLINT\n")
6774 def WriteImmediateCmdSetHeader(self
, func
, file):
6775 """Overrriden from TypeHandler."""
6776 file.Write(" void SetHeader(GLsizei count) {\n")
6778 " header.SetCmdByTotalSize<ValueType>(ComputeSize(count));\n")
6782 def WriteImmediateCmdInit(self
, func
, file):
6783 """Overrriden from TypeHandler."""
6784 file.Write(" void Init(%s) {\n" %
6785 func
.MakeTypedInitString("_"))
6786 file.Write(" SetHeader(_count);\n")
6787 args
= func
.GetCmdArgs()
6789 file.Write(" %s = _%s;\n" % (arg
.name
, arg
.name
))
6790 file.Write(" memcpy(ImmediateDataAddress(this),\n")
6791 pointer_arg
= func
.GetLastOriginalPointerArg()
6792 file.Write(" _%s, ComputeDataSize(_count));\n" % pointer_arg
.name
)
6796 def WriteImmediateCmdSet(self
, func
, file):
6797 """Overrriden from TypeHandler."""
6798 file.Write(" void* Set(void* cmd%s) {\n" %
6799 func
.MakeTypedInitString("_", True))
6800 file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" %
6801 func
.MakeInitString("_"))
6802 file.Write(" const uint32_t size = ComputeSize(_count);\n")
6803 file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
6808 def WriteImmediateCmdHelper(self
, func
, file):
6809 """Overrriden from TypeHandler."""
6810 code
= """ void %(name)s(%(typed_args)s) {
6811 const uint32_t size = gles2::cmds::%(name)s::ComputeSize(count);
6812 gles2::cmds::%(name)s* c =
6813 GetImmediateCmdSpaceTotalSize<gles2::cmds::%(name)s>(size);
6822 "typed_args": func
.MakeTypedInitString(""),
6823 "args": func
.MakeInitString("")
6826 def WriteImmediateFormatTest(self
, func
, file):
6827 """Overrriden from TypeHandler."""
6828 args
= func
.GetOriginalArgs()
6831 if arg
.name
== "count":
6832 count_param
= int(arg
.GetValidClientSideCmdArg(func
))
6833 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func
.name
)
6834 file.Write(" const int kSomeBaseValueToTestWith = 51;\n")
6835 file.Write(" static %s data[] = {\n" % self
.GetArrayType(func
))
6836 for v
in range(0, self
.GetArrayCount(func
) * count_param
):
6837 file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" %
6838 (self
.GetArrayType(func
), v
))
6840 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" %
6841 (func
.name
, func
.name
))
6842 file.Write(" const GLsizei kNumElements = %d;\n" % count_param
)
6843 file.Write(" const size_t kExpectedCmdSize =\n")
6844 file.Write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" %
6845 (self
.GetArrayType(func
), self
.GetArrayCount(func
)))
6846 file.Write(" void* next_cmd = cmd.Set(\n")
6848 for value
, arg
in enumerate(args
):
6850 file.Write(",\n data")
6851 elif arg
.IsConstant():
6854 file.Write(",\n static_cast<%s>(%d)" % (arg
.type, value
+ 1))
6856 file.Write(" EXPECT_EQ(static_cast<uint32_t>(cmds::%s::kCmdId),\n" %
6858 file.Write(" cmd.header.command);\n")
6859 file.Write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n")
6860 for value
, arg
in enumerate(args
):
6861 if arg
.IsPointer() or arg
.IsConstant():
6863 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" %
6864 (arg
.type, value
+ 1, arg
.name
))
6865 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n")
6866 file.Write(" next_cmd, sizeof(cmd) +\n")
6867 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n")
6868 file.Write(" // TODO(gman): Check that data was inserted;\n")
6872 class PUTSTRHandler(ArrayArgTypeHandler
):
6873 """Handler for functions that pass a string array."""
6876 ArrayArgTypeHandler
.__init
__(self
)
6878 def __GetDataArg(self
, func
):
6879 """Return the argument that points to the 2D char arrays"""
6880 for arg
in func
.GetOriginalArgs():
6881 if arg
.IsPointer2D():
6885 def __GetLengthArg(self
, func
):
6886 """Return the argument that holds length for each char array"""
6887 for arg
in func
.GetOriginalArgs():
6888 if arg
.IsPointer() and not arg
.IsPointer2D():
6892 def WriteGLES2Implementation(self
, func
, file):
6893 """Overrriden from TypeHandler."""
6894 file.Write("%s GLES2Implementation::%s(%s) {\n" %
6895 (func
.return_type
, func
.original_name
,
6896 func
.MakeTypedOriginalArgString("")))
6897 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
6898 func
.WriteDestinationInitalizationValidation(file)
6899 self
.WriteClientGLCallLog(func
, file)
6900 data_arg
= self
.__GetDataArg
(func
)
6901 length_arg
= self
.__GetLengthArg
(func
)
6902 log_code_block
= """ GPU_CLIENT_LOG_CODE_BLOCK({
6903 for (GLsizei ii = 0; ii < count; ++ii) {
6904 if (%(data)s[ii]) {"""
6905 if length_arg
== None:
6906 log_code_block
+= """
6907 GPU_CLIENT_LOG(" " << ii << ": ---\\n" << %(data)s[ii] << "\\n---");"""
6909 log_code_block
+= """
6910 if (%(length)s && %(length)s[ii] >= 0) {
6911 const std::string my_str(%(data)s[ii], %(length)s[ii]);
6912 GPU_CLIENT_LOG(" " << ii << ": ---\\n" << my_str << "\\n---");
6914 GPU_CLIENT_LOG(" " << ii << ": ---\\n" << %(data)s[ii] << "\\n---");
6916 log_code_block
+= """
6918 GPU_CLIENT_LOG(" " << ii << ": NULL");
6923 file.Write(log_code_block
% {
6924 'data': data_arg
.name
,
6925 'length': length_arg
.name
if not length_arg
== None else ''
6927 for arg
in func
.GetOriginalArgs():
6928 arg
.WriteClientSideValidationCode(file, func
)
6931 for arg
in func
.GetOriginalArgs():
6932 if arg
.name
== 'count' or arg
== self
.__GetLengthArg
(func
):
6934 if arg
== self
.__GetDataArg
(func
):
6935 bucket_args
.append('kResultBucketId')
6937 bucket_args
.append(arg
.name
)
6939 if (!PackStringsToBucket(count, %(data)s, %(length)s, "gl%(func_name)s")) {
6942 helper_->%(func_name)sBucket(%(bucket_args)s);
6943 helper_->SetBucketSize(kResultBucketId, 0);
6948 file.Write(code_block
% {
6949 'data': data_arg
.name
,
6950 'length': length_arg
.name
if not length_arg
== None else 'NULL',
6951 'func_name': func
.name
,
6952 'bucket_args': ', '.join(bucket_args
),
6955 def WriteGLES2ImplementationUnitTest(self
, func
, file):
6956 """Overrriden from TypeHandler."""
6958 TEST_F(GLES2ImplementationTest, %(name)s) {
6959 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
6960 const char* kString1 = "happy";
6961 const char* kString2 = "ending";
6962 const size_t kString1Size = ::strlen(kString1) + 1;
6963 const size_t kString2Size = ::strlen(kString2) + 1;
6964 const size_t kHeaderSize = sizeof(GLint) * 3;
6965 const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
6966 const size_t kPaddedHeaderSize =
6967 transfer_buffer_->RoundToAlignment(kHeaderSize);
6968 const size_t kPaddedString1Size =
6969 transfer_buffer_->RoundToAlignment(kString1Size);
6970 const size_t kPaddedString2Size =
6971 transfer_buffer_->RoundToAlignment(kString2Size);
6973 cmd::SetBucketSize set_bucket_size;
6974 cmd::SetBucketData set_bucket_header;
6975 cmd::SetToken set_token1;
6976 cmd::SetBucketData set_bucket_data1;
6977 cmd::SetToken set_token2;
6978 cmd::SetBucketData set_bucket_data2;
6979 cmd::SetToken set_token3;
6980 cmds::%(name)sBucket cmd_bucket;
6981 cmd::SetBucketSize clear_bucket_size;
6984 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
6985 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
6986 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
6989 expected.set_bucket_size.Init(kBucketId, kSourceSize);
6990 expected.set_bucket_header.Init(
6991 kBucketId, 0, kHeaderSize, mem0.id, mem0.offset);
6992 expected.set_token1.Init(GetNextToken());
6993 expected.set_bucket_data1.Init(
6994 kBucketId, kHeaderSize, kString1Size, mem1.id, mem1.offset);
6995 expected.set_token2.Init(GetNextToken());
6996 expected.set_bucket_data2.Init(
6997 kBucketId, kHeaderSize + kString1Size, kString2Size, mem2.id,
6999 expected.set_token3.Init(GetNextToken());
7000 expected.cmd_bucket.Init(%(bucket_args)s);
7001 expected.clear_bucket_size.Init(kBucketId, 0);
7002 const char* kStrings[] = { kString1, kString2 };
7003 gl_->%(name)s(%(gl_args)s);
7004 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
7009 for arg
in func
.GetOriginalArgs():
7010 if arg
== self
.__GetDataArg
(func
):
7011 gl_args
.append('kStrings')
7012 bucket_args
.append('kBucketId')
7013 elif arg
== self
.__GetLengthArg
(func
):
7014 gl_args
.append('NULL')
7015 elif arg
.name
== 'count':
7018 gl_args
.append(arg
.GetValidClientSideArg(func
))
7019 bucket_args
.append(arg
.GetValidClientSideArg(func
))
7022 'gl_args': ", ".join(gl_args
),
7023 'bucket_args': ", ".join(bucket_args
),
7026 if self
.__GetLengthArg
(func
) == None:
7029 TEST_F(GLES2ImplementationTest, %(name)sWithLength) {
7030 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
7031 const char* kString = "foobar******";
7032 const size_t kStringSize = 6; // We only need "foobar".
7033 const size_t kHeaderSize = sizeof(GLint) * 2;
7034 const size_t kSourceSize = kHeaderSize + kStringSize + 1;
7035 const size_t kPaddedHeaderSize =
7036 transfer_buffer_->RoundToAlignment(kHeaderSize);
7037 const size_t kPaddedStringSize =
7038 transfer_buffer_->RoundToAlignment(kStringSize + 1);
7040 cmd::SetBucketSize set_bucket_size;
7041 cmd::SetBucketData set_bucket_header;
7042 cmd::SetToken set_token1;
7043 cmd::SetBucketData set_bucket_data;
7044 cmd::SetToken set_token2;
7045 cmds::ShaderSourceBucket shader_source_bucket;
7046 cmd::SetBucketSize clear_bucket_size;
7049 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
7050 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedStringSize);
7053 expected.set_bucket_size.Init(kBucketId, kSourceSize);
7054 expected.set_bucket_header.Init(
7055 kBucketId, 0, kHeaderSize, mem0.id, mem0.offset);
7056 expected.set_token1.Init(GetNextToken());
7057 expected.set_bucket_data.Init(
7058 kBucketId, kHeaderSize, kStringSize + 1, mem1.id, mem1.offset);
7059 expected.set_token2.Init(GetNextToken());
7060 expected.shader_source_bucket.Init(%(bucket_args)s);
7061 expected.clear_bucket_size.Init(kBucketId, 0);
7062 const char* kStrings[] = { kString };
7063 const GLint kLength[] = { kStringSize };
7064 gl_->%(name)s(%(gl_args)s);
7065 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
7069 for arg
in func
.GetOriginalArgs():
7070 if arg
== self
.__GetDataArg
(func
):
7071 gl_args
.append('kStrings')
7072 elif arg
== self
.__GetLengthArg
(func
):
7073 gl_args
.append('kLength')
7074 elif arg
.name
== 'count':
7077 gl_args
.append(arg
.GetValidClientSideArg(func
))
7080 'gl_args': ", ".join(gl_args
),
7081 'bucket_args': ", ".join(bucket_args
),
7084 def WriteBucketServiceUnitTest(self
, func
, file, *extras
):
7085 """Overrriden from TypeHandler."""
7087 cmd_args_with_invalid_id
= []
7089 for index
, arg
in enumerate(func
.GetOriginalArgs()):
7090 if arg
== self
.__GetLengthArg
(func
):
7092 elif arg
.name
== 'count':
7094 elif arg
== self
.__GetDataArg
(func
):
7095 cmd_args
.append('kBucketId')
7096 cmd_args_with_invalid_id
.append('kBucketId')
7098 elif index
== 0: # Resource ID arg
7099 cmd_args
.append(arg
.GetValidArg(func
))
7100 cmd_args_with_invalid_id
.append('kInvalidClientId')
7101 gl_args
.append(arg
.GetValidGLArg(func
))
7103 cmd_args
.append(arg
.GetValidArg(func
))
7104 cmd_args_with_invalid_id
.append(arg
.GetValidArg(func
))
7105 gl_args
.append(arg
.GetValidGLArg(func
))
7108 TEST_P(%(test_name)s, %(name)sValidArgs) {
7109 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
7110 const uint32 kBucketId = 123;
7111 const char kSource0[] = "hello";
7112 const char* kSource[] = { kSource0 };
7113 const char kValidStrEnd = 0;
7114 SetBucketAsCStrings(kBucketId, 1, kSource, 1, kValidStrEnd);
7116 cmd.Init(%(cmd_args)s);
7117 decoder_->set_unsafe_es3_apis_enabled(true);
7118 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));"""
7121 decoder_->set_unsafe_es3_apis_enabled(false);
7122 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
7127 self
.WriteValidUnitTest(func
, file, test
, {
7128 'cmd_args': ", ".join(cmd_args
),
7129 'gl_args': ", ".join(gl_args
),
7133 TEST_P(%(test_name)s, %(name)sInvalidArgs) {
7134 const uint32 kBucketId = 123;
7135 const char kSource0[] = "hello";
7136 const char* kSource[] = { kSource0 };
7137 const char kValidStrEnd = 0;
7138 decoder_->set_unsafe_es3_apis_enabled(true);
7141 cmd.Init(%(cmd_args)s);
7142 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
7143 // Test invalid client.
7144 SetBucketAsCStrings(kBucketId, 1, kSource, 1, kValidStrEnd);
7145 cmd.Init(%(cmd_args_with_invalid_id)s);
7146 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7147 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
7150 self
.WriteValidUnitTest(func
, file, test
, {
7151 'cmd_args': ", ".join(cmd_args
),
7152 'cmd_args_with_invalid_id': ", ".join(cmd_args_with_invalid_id
),
7156 TEST_P(%(test_name)s, %(name)sInvalidHeader) {
7157 const uint32 kBucketId = 123;
7158 const char kSource0[] = "hello";
7159 const char* kSource[] = { kSource0 };
7160 const char kValidStrEnd = 0;
7161 const GLsizei kCount = static_cast<GLsizei>(arraysize(kSource));
7162 const GLsizei kTests[] = {
7165 std::numeric_limits<GLsizei>::max(),
7168 decoder_->set_unsafe_es3_apis_enabled(true);
7169 for (size_t ii = 0; ii < arraysize(kTests); ++ii) {
7170 SetBucketAsCStrings(kBucketId, 1, kSource, kTests[ii], kValidStrEnd);
7172 cmd.Init(%(cmd_args)s);
7173 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd));
7177 self
.WriteValidUnitTest(func
, file, test
, {
7178 'cmd_args': ", ".join(cmd_args
),
7182 TEST_P(%(test_name)s, %(name)sInvalidStringEnding) {
7183 const uint32 kBucketId = 123;
7184 const char kSource0[] = "hello";
7185 const char* kSource[] = { kSource0 };
7186 const char kInvalidStrEnd = '*';
7187 SetBucketAsCStrings(kBucketId, 1, kSource, 1, kInvalidStrEnd);
7189 cmd.Init(%(cmd_args)s);
7190 decoder_->set_unsafe_es3_apis_enabled(true);
7191 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd));
7194 self
.WriteValidUnitTest(func
, file, test
, {
7195 'cmd_args': ", ".join(cmd_args
),
7199 class PUTXnHandler(ArrayArgTypeHandler
):
7200 """Handler for glUniform?f functions."""
7202 ArrayArgTypeHandler
.__init
__(self
)
7204 def WriteHandlerImplementation(self
, func
, file):
7205 """Overrriden from TypeHandler."""
7206 code
= """ %(type)s temp[%(count)s] = { %(values)s};"""
7209 gl%(name)sv(%(location)s, 1, &temp[0]);
7213 Do%(name)sv(%(location)s, 1, &temp[0]);
7216 args
= func
.GetOriginalArgs()
7217 count
= int(self
.GetArrayCount(func
))
7218 num_args
= len(args
)
7219 for ii
in range(count
):
7220 values
+= "%s, " % args
[len(args
) - count
+ ii
].name
7224 'count': self
.GetArrayCount(func
),
7225 'type': self
.GetArrayType(func
),
7226 'location': args
[0].name
,
7227 'args': func
.MakeOriginalArgString(""),
7231 def WriteServiceUnitTest(self
, func
, file, *extras
):
7232 """Overrriden from TypeHandler."""
7234 TEST_P(%(test_name)s, %(name)sValidArgs) {
7235 EXPECT_CALL(*gl_, %(name)sv(%(local_args)s));
7236 SpecializedSetup<cmds::%(name)s, 0>(true);
7238 cmd.Init(%(args)s);"""
7241 decoder_->set_unsafe_es3_apis_enabled(true);"""
7243 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7244 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
7247 decoder_->set_unsafe_es3_apis_enabled(false);
7248 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));"""
7252 args
= func
.GetOriginalArgs()
7253 local_args
= "%s, 1, _" % args
[0].GetValidGLArg(func
)
7254 self
.WriteValidUnitTest(func
, file, valid_test
, {
7256 'count': self
.GetArrayCount(func
),
7257 'local_args': local_args
,
7261 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
7262 EXPECT_CALL(*gl_, %(name)sv(_, _, _).Times(0);
7263 SpecializedSetup<cmds::%(name)s, 0>(false);
7266 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
7269 self
.WriteInvalidUnitTest(func
, file, invalid_test
, {
7270 'name': func
.GetInfo('name'),
7271 'count': self
.GetArrayCount(func
),
7275 class GLcharHandler(CustomHandler
):
7276 """Handler for functions that pass a single string ."""
7279 CustomHandler
.__init
__(self
)
7281 def WriteImmediateCmdComputeSize(self
, func
, file):
7282 """Overrriden from TypeHandler."""
7283 file.Write(" static uint32_t ComputeSize(uint32_t data_size) {\n")
7284 file.Write(" return static_cast<uint32_t>(\n")
7285 file.Write(" sizeof(ValueType) + data_size); // NOLINT\n")
7288 def WriteImmediateCmdSetHeader(self
, func
, file):
7289 """Overrriden from TypeHandler."""
7291 void SetHeader(uint32_t data_size) {
7292 header.SetCmdBySize<ValueType>(data_size);
7297 def WriteImmediateCmdInit(self
, func
, file):
7298 """Overrriden from TypeHandler."""
7299 last_arg
= func
.GetLastOriginalArg()
7300 args
= func
.GetCmdArgs()
7303 set_code
.append(" %s = _%s;" % (arg
.name
, arg
.name
))
7305 void Init(%(typed_args)s, uint32_t _data_size) {
7306 SetHeader(_data_size);
7308 memcpy(ImmediateDataAddress(this), _%(last_arg)s, _data_size);
7313 "typed_args": func
.MakeTypedArgString("_"),
7314 "set_code": "\n".join(set_code
),
7315 "last_arg": last_arg
.name
7318 def WriteImmediateCmdSet(self
, func
, file):
7319 """Overrriden from TypeHandler."""
7320 last_arg
= func
.GetLastOriginalArg()
7321 file.Write(" void* Set(void* cmd%s, uint32_t _data_size) {\n" %
7322 func
.MakeTypedCmdArgString("_", True))
7323 file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _data_size);\n" %
7324 func
.MakeCmdArgString("_"))
7325 file.Write(" return NextImmediateCmdAddress<ValueType>("
7326 "cmd, _data_size);\n")
7330 def WriteImmediateCmdHelper(self
, func
, file):
7331 """Overrriden from TypeHandler."""
7332 code
= """ void %(name)s(%(typed_args)s) {
7333 const uint32_t data_size = strlen(name);
7334 gles2::cmds::%(name)s* c =
7335 GetImmediateCmdSpace<gles2::cmds::%(name)s>(data_size);
7337 c->Init(%(args)s, data_size);
7344 "typed_args": func
.MakeTypedOriginalArgString(""),
7345 "args": func
.MakeOriginalArgString(""),
7349 def WriteImmediateFormatTest(self
, func
, file):
7350 """Overrriden from TypeHandler."""
7353 all_but_last_arg
= func
.GetCmdArgs()[:-1]
7354 for value
, arg
in enumerate(all_but_last_arg
):
7355 init_code
.append(" static_cast<%s>(%d)," % (arg
.type, value
+ 11))
7356 for value
, arg
in enumerate(all_but_last_arg
):
7357 check_code
.append(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);" %
7358 (arg
.type, value
+ 11, arg
.name
))
7360 TEST_F(GLES2FormatTest, %(func_name)s) {
7361 cmds::%(func_name)s& cmd = *GetBufferAs<cmds::%(func_name)s>();
7362 static const char* const test_str = \"test string\";
7363 void* next_cmd = cmd.Set(
7368 EXPECT_EQ(static_cast<uint32_t>(cmds::%(func_name)s::kCmdId),
7369 cmd.header.command);
7370 EXPECT_EQ(sizeof(cmd) +
7371 RoundSizeToMultipleOfEntries(strlen(test_str)),
7372 cmd.header.size * 4u);
7373 EXPECT_EQ(static_cast<char*>(next_cmd),
7374 reinterpret_cast<char*>(&cmd) + sizeof(cmd) +
7375 RoundSizeToMultipleOfEntries(strlen(test_str)));
7377 EXPECT_EQ(static_cast<uint32_t>(strlen(test_str)), cmd.data_size);
7378 EXPECT_EQ(0, memcmp(test_str, ImmediateDataAddress(&cmd), strlen(test_str)));
7381 sizeof(cmd) + RoundSizeToMultipleOfEntries(strlen(test_str)),
7382 sizeof(cmd) + strlen(test_str));
7387 'func_name': func
.name
,
7388 'init_code': "\n".join(init_code
),
7389 'check_code': "\n".join(check_code
),
7393 class GLcharNHandler(CustomHandler
):
7394 """Handler for functions that pass a single string with an optional len."""
7397 CustomHandler
.__init
__(self
)
7399 def InitFunction(self
, func
):
7400 """Overrriden from TypeHandler."""
7402 func
.AddCmdArg(Argument('bucket_id', 'GLuint'))
7404 def NeedsDataTransferFunction(self
, func
):
7405 """Overriden from TypeHandler."""
7408 def AddBucketFunction(self
, generator
, func
):
7409 """Overrriden from TypeHandler."""
7412 def WriteServiceImplementation(self
, func
, file):
7413 """Overrriden from TypeHandler."""
7414 self
.WriteServiceHandlerFunctionHeader(func
, file)
7416 GLuint bucket_id = static_cast<GLuint>(c.%(bucket_id)s);
7417 Bucket* bucket = GetBucket(bucket_id);
7418 if (!bucket || bucket->size() == 0) {
7419 return error::kInvalidArguments;
7422 if (!bucket->GetAsString(&str)) {
7423 return error::kInvalidArguments;
7425 %(gl_func_name)s(0, str.c_str());
7426 return error::kNoError;
7431 'gl_func_name': func
.GetGLFunctionName(),
7432 'bucket_id': func
.cmd_args
[0].name
,
7436 class IsHandler(TypeHandler
):
7437 """Handler for glIs____ type and glGetError functions."""
7440 TypeHandler
.__init
__(self
)
7442 def InitFunction(self
, func
):
7443 """Overrriden from TypeHandler."""
7444 func
.AddCmdArg(Argument("result_shm_id", 'uint32_t'))
7445 func
.AddCmdArg(Argument("result_shm_offset", 'uint32_t'))
7446 if func
.GetInfo('result') == None:
7447 func
.AddInfo('result', ['uint32_t'])
7449 def WriteServiceUnitTest(self
, func
, file, *extras
):
7450 """Overrriden from TypeHandler."""
7452 TEST_P(%(test_name)s, %(name)sValidArgs) {
7453 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
7454 SpecializedSetup<cmds::%(name)s, 0>(true);
7456 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);"""
7459 decoder_->set_unsafe_es3_apis_enabled(true);"""
7461 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7462 EXPECT_EQ(GL_NO_ERROR, GetGLError());"""
7465 decoder_->set_unsafe_es3_apis_enabled(false);
7466 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));"""
7471 if len(func
.GetOriginalArgs()):
7473 self
.WriteValidUnitTest(func
, file, valid_test
, {
7478 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
7479 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
7480 SpecializedSetup<cmds::%(name)s, 0>(false);
7482 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);
7483 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
7486 self
.WriteInvalidUnitTest(func
, file, invalid_test
, {
7491 TEST_P(%(test_name)s, %(name)sInvalidArgsBadSharedMemoryId) {
7492 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
7493 SpecializedSetup<cmds::%(name)s, 0>(false);"""
7496 decoder_->set_unsafe_es3_apis_enabled(true);"""
7499 cmd.Init(%(args)s%(comma)skInvalidSharedMemoryId, shared_memory_offset_);
7500 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
7501 cmd.Init(%(args)s%(comma)sshared_memory_id_, kInvalidSharedMemoryOffset);
7502 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));"""
7505 decoder_->set_unsafe_es3_apis_enabled(true);"""
7509 self
.WriteValidUnitTest(func
, file, invalid_test
, {
7513 def WriteServiceImplementation(self
, func
, file):
7514 """Overrriden from TypeHandler."""
7515 self
.WriteServiceHandlerFunctionHeader(func
, file)
7516 args
= func
.GetOriginalArgs()
7518 arg
.WriteGetCode(file)
7520 code
= """ typedef cmds::%(func_name)s::Result Result;
7521 Result* result_dst = GetSharedMemoryAs<Result*>(
7522 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
7524 return error::kOutOfBounds;
7527 file.Write(code
% {'func_name': func
.name
})
7528 func
.WriteHandlerValidation(file)
7530 assert func
.GetInfo('id_mapping')
7531 assert len(func
.GetInfo('id_mapping')) == 1
7532 assert len(args
) == 1
7533 id_type
= func
.GetInfo('id_mapping')[0]
7534 file.Write(" %s service_%s = 0;\n" % (args
[0].type, id_type
.lower()))
7535 file.Write(" *result_dst = group_->Get%sServiceId(%s, &service_%s);\n" %
7536 (id_type
, id_type
.lower(), id_type
.lower()))
7538 file.Write(" *result_dst = %s(%s);\n" %
7539 (func
.GetGLFunctionName(), func
.MakeOriginalArgString("")))
7540 file.Write(" return error::kNoError;\n")
7544 def WriteGLES2Implementation(self
, func
, file):
7545 """Overrriden from TypeHandler."""
7546 impl_func
= func
.GetInfo('impl_func')
7547 if impl_func
== None or impl_func
== True:
7548 error_value
= func
.GetInfo("error_value") or "GL_FALSE"
7549 file.Write("%s GLES2Implementation::%s(%s) {\n" %
7550 (func
.return_type
, func
.original_name
,
7551 func
.MakeTypedOriginalArgString("")))
7552 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
7553 self
.WriteTraceEvent(func
, file)
7554 func
.WriteDestinationInitalizationValidation(file)
7555 self
.WriteClientGLCallLog(func
, file)
7556 file.Write(" typedef cmds::%s::Result Result;\n" % func
.name
)
7557 file.Write(" Result* result = GetResultAs<Result*>();\n")
7558 file.Write(" if (!result) {\n")
7559 file.Write(" return %s;\n" % error_value
)
7561 file.Write(" *result = 0;\n")
7562 assert len(func
.GetOriginalArgs()) == 1
7563 id_arg
= func
.GetOriginalArgs()[0]
7564 if id_arg
.type == 'GLsync':
7565 arg_string
= "ToGLuint(%s)" % func
.MakeOriginalArgString("")
7567 arg_string
= func
.MakeOriginalArgString("")
7569 " helper_->%s(%s, GetResultShmId(), GetResultShmOffset());\n" %
7570 (func
.name
, arg_string
))
7571 file.Write(" WaitForCmd();\n")
7572 file.Write(" %s result_value = *result" % func
.return_type
)
7573 if func
.return_type
== "GLboolean":
7575 file.Write(';\n GPU_CLIENT_LOG("returned " << result_value);\n')
7576 file.Write(" CheckGLError();\n")
7577 file.Write(" return result_value;\n")
7581 def WriteGLES2ImplementationUnitTest(self
, func
, file):
7582 """Overrriden from TypeHandler."""
7583 client_test
= func
.GetInfo('client_test')
7584 if client_test
== None or client_test
== True:
7586 TEST_F(GLES2ImplementationTest, %(name)s) {
7592 ExpectedMemoryInfo result1 =
7593 GetExpectedResultMemory(sizeof(cmds::%(name)s::Result));
7594 expected.cmd.Init(%(cmd_id_value)s, result1.id, result1.offset);
7596 EXPECT_CALL(*command_buffer(), OnFlush())
7597 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
7598 .RetiresOnSaturation();
7600 GLboolean result = gl_->%(name)s(%(gl_id_value)s);
7601 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
7602 EXPECT_TRUE(result);
7605 args
= func
.GetOriginalArgs()
7606 assert len(args
) == 1
7609 'cmd_id_value': args
[0].GetValidClientSideCmdArg(func
),
7610 'gl_id_value': args
[0].GetValidClientSideArg(func
) })
7613 class STRnHandler(TypeHandler
):
7614 """Handler for GetProgramInfoLog, GetShaderInfoLog, GetShaderSource, and
7615 GetTranslatedShaderSourceANGLE."""
7618 TypeHandler
.__init
__(self
)
7620 def InitFunction(self
, func
):
7621 """Overrriden from TypeHandler."""
7622 # remove all but the first cmd args.
7623 cmd_args
= func
.GetCmdArgs()
7625 func
.AddCmdArg(cmd_args
[0])
7626 # add on a bucket id.
7627 func
.AddCmdArg(Argument('bucket_id', 'uint32_t'))
7629 def WriteGLES2Implementation(self
, func
, file):
7630 """Overrriden from TypeHandler."""
7631 code_1
= """%(return_type)s GLES2Implementation::%(func_name)s(%(args)s) {
7632 GPU_CLIENT_SINGLE_THREAD_CHECK();
7634 code_2
= """ GPU_CLIENT_LOG("[" << GetLogPrefix()
7635 << "] gl%(func_name)s" << "("
7638 << static_cast<void*>(%(arg2)s) << ", "
7639 << static_cast<void*>(%(arg3)s) << ")");
7640 helper_->SetBucketSize(kResultBucketId, 0);
7641 helper_->%(func_name)s(%(id_name)s, kResultBucketId);
7643 GLsizei max_size = 0;
7644 if (GetBucketAsString(kResultBucketId, &str)) {
7647 std::min(static_cast<size_t>(%(bufsize_name)s) - 1, str.size());
7648 memcpy(%(dest_name)s, str.c_str(), max_size);
7649 %(dest_name)s[max_size] = '\\0';
7650 GPU_CLIENT_LOG("------\\n" << %(dest_name)s << "\\n------");
7653 if (%(length_name)s != NULL) {
7654 *%(length_name)s = max_size;
7659 args
= func
.GetOriginalArgs()
7661 'return_type': func
.return_type
,
7662 'func_name': func
.original_name
,
7663 'args': func
.MakeTypedOriginalArgString(""),
7664 'id_name': args
[0].name
,
7665 'bufsize_name': args
[1].name
,
7666 'length_name': args
[2].name
,
7667 'dest_name': args
[3].name
,
7668 'arg0': args
[0].name
,
7669 'arg1': args
[1].name
,
7670 'arg2': args
[2].name
,
7671 'arg3': args
[3].name
,
7673 file.Write(code_1
% str_args
)
7674 func
.WriteDestinationInitalizationValidation(file)
7675 file.Write(code_2
% str_args
)
7677 def WriteServiceUnitTest(self
, func
, file, *extras
):
7678 """Overrriden from TypeHandler."""
7680 TEST_P(%(test_name)s, %(name)sValidArgs) {
7681 const char* kInfo = "hello";
7682 const uint32_t kBucketId = 123;
7683 SpecializedSetup<cmds::%(name)s, 0>(true);
7685 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s))
7686 .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)),
7687 SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1)));
7690 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7691 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
7692 ASSERT_TRUE(bucket != NULL);
7693 EXPECT_EQ(strlen(kInfo) + 1, bucket->size());
7694 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo,
7696 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7699 args
= func
.GetOriginalArgs()
7700 id_name
= args
[0].GetValidGLArg(func
)
7701 get_len_func
= func
.GetInfo('get_len_func')
7702 get_len_enum
= func
.GetInfo('get_len_enum')
7705 'get_len_func': get_len_func
,
7706 'get_len_enum': get_len_enum
,
7707 'gl_args': '%s, strlen(kInfo) + 1, _, _' %
7708 args
[0].GetValidGLArg(func
),
7709 'args': '%s, kBucketId' % args
[0].GetValidArg(func
),
7710 'expect_len_code': '',
7712 if get_len_func
and get_len_func
[0:2] == 'gl':
7713 sub
['expect_len_code'] = (
7714 " EXPECT_CALL(*gl_, %s(%s, %s, _))\n"
7715 " .WillOnce(SetArgumentPointee<2>(strlen(kInfo) + 1));") % (
7716 get_len_func
[2:], id_name
, get_len_enum
)
7717 self
.WriteValidUnitTest(func
, file, valid_test
, sub
, *extras
)
7720 TEST_P(%(test_name)s, %(name)sInvalidArgs) {
7721 const uint32_t kBucketId = 123;
7722 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _, _, _))
7725 cmd.Init(kInvalidClientId, kBucketId);
7726 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7727 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
7730 self
.WriteValidUnitTest(func
, file, invalid_test
, *extras
)
7732 def WriteServiceImplementation(self
, func
, file):
7733 """Overrriden from TypeHandler."""
7736 class NamedType(object):
7737 """A class that represents a type of an argument in a client function.
7739 A type of an argument that is to be passed through in the command buffer
7740 command. Currently used only for the arguments that are specificly named in
7741 the 'cmd_buffer_functions.txt' file, mostly enums.
7744 def __init__(self
, info
):
7745 assert not 'is_complete' in info
or info
['is_complete'] == True
7747 self
.valid
= info
['valid']
7748 if 'invalid' in info
:
7749 self
.invalid
= info
['invalid']
7752 if 'valid_es3' in info
:
7753 self
.valid_es3
= info
['valid_es3']
7756 if 'deprecated_es3' in info
:
7757 self
.deprecated_es3
= info
['deprecated_es3']
7759 self
.deprecated_es3
= []
7762 return self
.info
['type']
7764 def GetInvalidValues(self
):
7767 def GetValidValues(self
):
7770 def GetValidValuesES3(self
):
7771 return self
.valid_es3
7773 def GetDeprecatedValuesES3(self
):
7774 return self
.deprecated_es3
7776 def IsConstant(self
):
7777 if not 'is_complete' in self
.info
:
7780 return len(self
.GetValidValues()) == 1
7782 def GetConstantValue(self
):
7783 return self
.GetValidValues()[0]
7785 class Argument(object):
7786 """A class that represents a function argument."""
7789 'GLenum': 'uint32_t',
7791 'GLintptr': 'int32_t',
7792 'GLsizei': 'int32_t',
7793 'GLsizeiptr': 'int32_t',
7795 'GLclampf': 'float',
7797 need_validation_
= ['GLsizei*', 'GLboolean*', 'GLenum*', 'GLint*']
7799 def __init__(self
, name
, type):
7801 self
.optional
= type.endswith("Optional*")
7803 type = type[:-9] + "*"
7806 if type in self
.cmd_type_map_
:
7807 self
.cmd_type
= self
.cmd_type_map_
[type]
7809 self
.cmd_type
= 'uint32_t'
7811 def IsPointer(self
):
7812 """Returns true if argument is a pointer."""
7815 def IsPointer2D(self
):
7816 """Returns true if argument is a 2D pointer."""
7819 def IsConstant(self
):
7820 """Returns true if the argument has only one valid value."""
7823 def AddCmdArgs(self
, args
):
7824 """Adds command arguments for this argument to the given list."""
7825 if not self
.IsConstant():
7826 return args
.append(self
)
7828 def AddInitArgs(self
, args
):
7829 """Adds init arguments for this argument to the given list."""
7830 if not self
.IsConstant():
7831 return args
.append(self
)
7833 def GetValidArg(self
, func
):
7834 """Gets a valid value for this argument."""
7835 valid_arg
= func
.GetValidArg(self
)
7836 if valid_arg
!= None:
7839 index
= func
.GetOriginalArgs().index(self
)
7840 return str(index
+ 1)
7842 def GetValidClientSideArg(self
, func
):
7843 """Gets a valid value for this argument."""
7844 valid_arg
= func
.GetValidArg(self
)
7845 if valid_arg
!= None:
7848 if self
.IsPointer():
7850 index
= func
.GetOriginalArgs().index(self
)
7851 if self
.type == 'GLsync':
7852 return ("reinterpret_cast<GLsync>(%d)" % (index
+ 1))
7853 return str(index
+ 1)
7855 def GetValidClientSideCmdArg(self
, func
):
7856 """Gets a valid value for this argument."""
7857 valid_arg
= func
.GetValidArg(self
)
7858 if valid_arg
!= None:
7861 index
= func
.GetOriginalArgs().index(self
)
7862 return str(index
+ 1)
7865 index
= func
.GetCmdArgs().index(self
)
7866 return str(index
+ 1)
7868 def GetValidGLArg(self
, func
):
7869 """Gets a valid GL value for this argument."""
7870 value
= self
.GetValidArg(func
)
7871 if self
.type == 'GLsync':
7872 return ("reinterpret_cast<GLsync>(%s)" % value
)
7875 def GetValidNonCachedClientSideArg(self
, func
):
7876 """Returns a valid value for this argument in a GL call.
7877 Using the value will produce a command buffer service invocation.
7878 Returns None if there is no such value."""
7880 if self
.type == 'GLsync':
7881 return ("reinterpret_cast<GLsync>(%s)" % value
)
7884 def GetValidNonCachedClientSideCmdArg(self
, func
):
7885 """Returns a valid value for this argument in a command buffer command.
7886 Calling the GL function with the value returned by
7887 GetValidNonCachedClientSideArg will result in a command buffer command
7888 that contains the value returned by this function. """
7891 def GetNumInvalidValues(self
, func
):
7892 """returns the number of invalid values to be tested."""
7895 def GetInvalidArg(self
, index
):
7896 """returns an invalid value and expected parse result by index."""
7897 return ("---ERROR0---", "---ERROR2---", None)
7899 def GetLogArg(self
):
7900 """Get argument appropriate for LOG macro."""
7901 if self
.type == 'GLboolean':
7902 return 'GLES2Util::GetStringBool(%s)' % self
.name
7903 if self
.type == 'GLenum':
7904 return 'GLES2Util::GetStringEnum(%s)' % self
.name
7907 def WriteGetCode(self
, file):
7908 """Writes the code to get an argument from a command structure."""
7909 if self
.type == 'GLsync':
7913 file.Write(" %s %s = static_cast<%s>(c.%s);\n" %
7914 (my_type
, self
.name
, my_type
, self
.name
))
7916 def WriteValidationCode(self
, file, func
):
7917 """Writes the validation code for an argument."""
7920 def WriteClientSideValidationCode(self
, file, func
):
7921 """Writes the validation code for an argument."""
7924 def WriteDestinationInitalizationValidation(self
, file, func
):
7925 """Writes the client side destintion initialization validation."""
7928 def WriteDestinationInitalizationValidatationIfNeeded(self
, file, func
):
7929 """Writes the client side destintion initialization validation if needed."""
7930 parts
= self
.type.split(" ")
7933 if parts
[0] in self
.need_validation_
:
7935 " GPU_CLIENT_VALIDATE_DESTINATION_%sINITALIZATION(%s, %s);\n" %
7936 ("OPTIONAL_" if self
.optional
else "", self
.type[:-1], self
.name
))
7939 def WriteGetAddress(self
, file):
7940 """Writes the code to get the address this argument refers to."""
7943 def GetImmediateVersion(self
):
7944 """Gets the immediate version of this argument."""
7947 def GetBucketVersion(self
):
7948 """Gets the bucket version of this argument."""
7952 class BoolArgument(Argument
):
7953 """class for GLboolean"""
7955 def __init__(self
, name
, type):
7956 Argument
.__init
__(self
, name
, 'GLboolean')
7958 def GetValidArg(self
, func
):
7959 """Gets a valid value for this argument."""
7962 def GetValidClientSideArg(self
, func
):
7963 """Gets a valid value for this argument."""
7966 def GetValidClientSideCmdArg(self
, func
):
7967 """Gets a valid value for this argument."""
7970 def GetValidGLArg(self
, func
):
7971 """Gets a valid GL value for this argument."""
7975 class UniformLocationArgument(Argument
):
7976 """class for uniform locations."""
7978 def __init__(self
, name
):
7979 Argument
.__init
__(self
, name
, "GLint")
7981 def WriteGetCode(self
, file):
7982 """Writes the code to get an argument from a command structure."""
7983 code
= """ %s %s = static_cast<%s>(c.%s);
7985 file.Write(code
% (self
.type, self
.name
, self
.type, self
.name
))
7987 class DataSizeArgument(Argument
):
7988 """class for data_size which Bucket commands do not need."""
7990 def __init__(self
, name
):
7991 Argument
.__init
__(self
, name
, "uint32_t")
7993 def GetBucketVersion(self
):
7997 class SizeArgument(Argument
):
7998 """class for GLsizei and GLsizeiptr."""
8000 def __init__(self
, name
, type):
8001 Argument
.__init
__(self
, name
, type)
8003 def GetNumInvalidValues(self
, func
):
8004 """overridden from Argument."""
8005 if func
.IsImmediate():
8009 def GetInvalidArg(self
, index
):
8010 """overridden from Argument."""
8011 return ("-1", "kNoError", "GL_INVALID_VALUE")
8013 def WriteValidationCode(self
, file, func
):
8014 """overridden from Argument."""
8017 code
= """ if (%(var_name)s < 0) {
8018 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "gl%(func_name)s", "%(var_name)s < 0");
8019 return error::kNoError;
8023 "var_name": self
.name
,
8024 "func_name": func
.original_name
,
8027 def WriteClientSideValidationCode(self
, file, func
):
8028 """overridden from Argument."""
8029 code
= """ if (%(var_name)s < 0) {
8030 SetGLError(GL_INVALID_VALUE, "gl%(func_name)s", "%(var_name)s < 0");
8035 "var_name": self
.name
,
8036 "func_name": func
.original_name
,
8040 class SizeNotNegativeArgument(SizeArgument
):
8041 """class for GLsizeiNotNegative. It's NEVER allowed to be negative"""
8043 def __init__(self
, name
, type, gl_type
):
8044 SizeArgument
.__init
__(self
, name
, gl_type
)
8046 def GetInvalidArg(self
, index
):
8047 """overridden from SizeArgument."""
8048 return ("-1", "kOutOfBounds", "GL_NO_ERROR")
8050 def WriteValidationCode(self
, file, func
):
8051 """overridden from SizeArgument."""
8055 class EnumBaseArgument(Argument
):
8056 """Base class for EnumArgument, IntArgument, BitfieldArgument, and
8057 ValidatedBoolArgument."""
8059 def __init__(self
, name
, gl_type
, type, gl_error
):
8060 Argument
.__init
__(self
, name
, gl_type
)
8062 self
.local_type
= type
8063 self
.gl_error
= gl_error
8064 name
= type[len(gl_type
):]
8065 self
.type_name
= name
8066 self
.named_type
= NamedType(_NAMED_TYPE_INFO
[name
])
8068 def IsConstant(self
):
8069 return self
.named_type
.IsConstant()
8071 def GetConstantValue(self
):
8072 return self
.named_type
.GetConstantValue()
8074 def WriteValidationCode(self
, file, func
):
8077 if self
.named_type
.IsConstant():
8079 file.Write(" if (!validators_->%s.IsValid(%s)) {\n" %
8080 (ToUnderscore(self
.type_name
), self
.name
))
8081 if self
.gl_error
== "GL_INVALID_ENUM":
8083 " LOCAL_SET_GL_ERROR_INVALID_ENUM(\"gl%s\", %s, \"%s\");\n" %
8084 (func
.original_name
, self
.name
, self
.name
))
8087 " LOCAL_SET_GL_ERROR(%s, \"gl%s\", \"%s %s\");\n" %
8088 (self
.gl_error
, func
.original_name
, self
.name
, self
.gl_error
))
8089 file.Write(" return error::kNoError;\n")
8092 def WriteClientSideValidationCode(self
, file, func
):
8093 if not self
.named_type
.IsConstant():
8095 file.Write(" if (%s != %s) {" % (self
.name
,
8096 self
.GetConstantValue()))
8098 " SetGLError(%s, \"gl%s\", \"%s %s\");\n" %
8099 (self
.gl_error
, func
.original_name
, self
.name
, self
.gl_error
))
8100 if func
.return_type
== "void":
8101 file.Write(" return;\n")
8103 file.Write(" return %s;\n" % func
.GetErrorReturnString())
8106 def GetValidArg(self
, func
):
8107 valid_arg
= func
.GetValidArg(self
)
8108 if valid_arg
!= None:
8110 valid
= self
.named_type
.GetValidValues()
8112 num_valid
= len(valid
)
8115 index
= func
.GetOriginalArgs().index(self
)
8116 return str(index
+ 1)
8118 def GetValidClientSideArg(self
, func
):
8119 """Gets a valid value for this argument."""
8120 return self
.GetValidArg(func
)
8122 def GetValidClientSideCmdArg(self
, func
):
8123 """Gets a valid value for this argument."""
8124 valid_arg
= func
.GetValidArg(self
)
8125 if valid_arg
!= None:
8128 valid
= self
.named_type
.GetValidValues()
8130 num_valid
= len(valid
)
8134 index
= func
.GetOriginalArgs().index(self
)
8135 return str(index
+ 1)
8138 index
= func
.GetCmdArgs().index(self
)
8139 return str(index
+ 1)
8141 def GetValidGLArg(self
, func
):
8142 """Gets a valid value for this argument."""
8143 return self
.GetValidArg(func
)
8145 def GetNumInvalidValues(self
, func
):
8146 """returns the number of invalid values to be tested."""
8147 return len(self
.named_type
.GetInvalidValues())
8149 def GetInvalidArg(self
, index
):
8150 """returns an invalid value by index."""
8151 invalid
= self
.named_type
.GetInvalidValues()
8153 num_invalid
= len(invalid
)
8154 if index
>= num_invalid
:
8155 index
= num_invalid
- 1
8156 return (invalid
[index
], "kNoError", self
.gl_error
)
8157 return ("---ERROR1---", "kNoError", self
.gl_error
)
8160 class EnumArgument(EnumBaseArgument
):
8161 """A class that represents a GLenum argument"""
8163 def __init__(self
, name
, type):
8164 EnumBaseArgument
.__init
__(self
, name
, "GLenum", type, "GL_INVALID_ENUM")
8166 def GetLogArg(self
):
8167 """Overridden from Argument."""
8168 return ("GLES2Util::GetString%s(%s)" %
8169 (self
.type_name
, self
.name
))
8172 class IntArgument(EnumBaseArgument
):
8173 """A class for a GLint argument that can only accept specific values.
8175 For example glTexImage2D takes a GLint for its internalformat
8176 argument instead of a GLenum.
8179 def __init__(self
, name
, type):
8180 EnumBaseArgument
.__init
__(self
, name
, "GLint", type, "GL_INVALID_VALUE")
8183 class ValidatedBoolArgument(EnumBaseArgument
):
8184 """A class for a GLboolean argument that can only accept specific values.
8186 For example glUniformMatrix takes a GLboolean for it's transpose but it
8190 def __init__(self
, name
, type):
8191 EnumBaseArgument
.__init
__(self
, name
, "GLboolean", type, "GL_INVALID_VALUE")
8193 def GetLogArg(self
):
8194 """Overridden from Argument."""
8195 return 'GLES2Util::GetStringBool(%s)' % self
.name
8198 class BitFieldArgument(EnumBaseArgument
):
8199 """A class for a GLbitfield argument that can only accept specific values.
8201 For example glFenceSync takes a GLbitfield for its flags argument bit it
8205 def __init__(self
, name
, type):
8206 EnumBaseArgument
.__init
__(self
, name
, "GLbitfield", type,
8210 class ImmediatePointerArgument(Argument
):
8211 """A class that represents an immediate argument to a function.
8213 An immediate argument is one where the data follows the command.
8216 def __init__(self
, name
, type):
8217 Argument
.__init
__(self
, name
, type)
8219 def IsPointer(self
):
8222 def GetPointedType(self
):
8223 match
= re
.match('(const\s+)?(?P<element_type>[\w]+)\s*\*', self
.type)
8225 return match
.groupdict()['element_type']
8227 def AddCmdArgs(self
, args
):
8228 """Overridden from Argument."""
8231 def WriteGetCode(self
, file):
8232 """Overridden from Argument."""
8234 " %s %s = GetImmediateDataAs<%s>(\n" %
8235 (self
.type, self
.name
, self
.type))
8236 file.Write(" c, data_size, immediate_data_size);\n")
8238 def WriteValidationCode(self
, file, func
):
8239 """Overridden from Argument."""
8242 file.Write(" if (%s == NULL) {\n" % self
.name
)
8243 file.Write(" return error::kOutOfBounds;\n")
8246 def GetImmediateVersion(self
):
8247 """Overridden from Argument."""
8250 def WriteDestinationInitalizationValidation(self
, file, func
):
8251 """Overridden from Argument."""
8252 self
.WriteDestinationInitalizationValidatationIfNeeded(file, func
)
8254 def GetLogArg(self
):
8255 """Overridden from Argument."""
8256 return "static_cast<const void*>(%s)" % self
.name
8259 class PointerArgument(Argument
):
8260 """A class that represents a pointer argument to a function."""
8262 def __init__(self
, name
, type):
8263 Argument
.__init
__(self
, name
, type)
8265 def IsPointer(self
):
8266 """Overridden from Argument."""
8269 def IsPointer2D(self
):
8270 """Overridden from Argument."""
8271 return self
.type.count('*') == 2
8273 def GetPointedType(self
):
8274 match
= re
.match('(const\s+)?(?P<element_type>[\w]+)\s*\*', self
.type)
8276 return match
.groupdict()['element_type']
8278 def GetValidArg(self
, func
):
8279 """Overridden from Argument."""
8280 return "shared_memory_id_, shared_memory_offset_"
8282 def GetValidGLArg(self
, func
):
8283 """Overridden from Argument."""
8284 return "reinterpret_cast<%s>(shared_memory_address_)" % self
.type
8286 def GetNumInvalidValues(self
, func
):
8287 """Overridden from Argument."""
8290 def GetInvalidArg(self
, index
):
8291 """Overridden from Argument."""
8293 return ("kInvalidSharedMemoryId, 0", "kOutOfBounds", None)
8295 return ("shared_memory_id_, kInvalidSharedMemoryOffset",
8296 "kOutOfBounds", None)
8298 def GetLogArg(self
):
8299 """Overridden from Argument."""
8300 return "static_cast<const void*>(%s)" % self
.name
8302 def AddCmdArgs(self
, args
):
8303 """Overridden from Argument."""
8304 args
.append(Argument("%s_shm_id" % self
.name
, 'uint32_t'))
8305 args
.append(Argument("%s_shm_offset" % self
.name
, 'uint32_t'))
8307 def WriteGetCode(self
, file):
8308 """Overridden from Argument."""
8310 " %s %s = GetSharedMemoryAs<%s>(\n" %
8311 (self
.type, self
.name
, self
.type))
8313 " c.%s_shm_id, c.%s_shm_offset, data_size);\n" %
8314 (self
.name
, self
.name
))
8316 def WriteGetAddress(self
, file):
8317 """Overridden from Argument."""
8319 " %s %s = GetSharedMemoryAs<%s>(\n" %
8320 (self
.type, self
.name
, self
.type))
8322 " %s_shm_id, %s_shm_offset, %s_size);\n" %
8323 (self
.name
, self
.name
, self
.name
))
8325 def WriteValidationCode(self
, file, func
):
8326 """Overridden from Argument."""
8329 file.Write(" if (%s == NULL) {\n" % self
.name
)
8330 file.Write(" return error::kOutOfBounds;\n")
8333 def GetImmediateVersion(self
):
8334 """Overridden from Argument."""
8335 return ImmediatePointerArgument(self
.name
, self
.type)
8337 def GetBucketVersion(self
):
8338 """Overridden from Argument."""
8339 if self
.type.find('char') >= 0:
8340 if self
.IsPointer2D():
8341 return InputStringArrayBucketArgument(self
.name
, self
.type)
8342 return InputStringBucketArgument(self
.name
, self
.type)
8343 return BucketPointerArgument(self
.name
, self
.type)
8345 def WriteDestinationInitalizationValidation(self
, file, func
):
8346 """Overridden from Argument."""
8347 self
.WriteDestinationInitalizationValidatationIfNeeded(file, func
)
8350 class BucketPointerArgument(PointerArgument
):
8351 """A class that represents an bucket argument to a function."""
8353 def __init__(self
, name
, type):
8354 Argument
.__init
__(self
, name
, type)
8356 def AddCmdArgs(self
, args
):
8357 """Overridden from Argument."""
8360 def WriteGetCode(self
, file):
8361 """Overridden from Argument."""
8363 " %s %s = bucket->GetData(0, data_size);\n" %
8364 (self
.type, self
.name
))
8366 def WriteValidationCode(self
, file, func
):
8367 """Overridden from Argument."""
8370 def GetImmediateVersion(self
):
8371 """Overridden from Argument."""
8374 def WriteDestinationInitalizationValidation(self
, file, func
):
8375 """Overridden from Argument."""
8376 self
.WriteDestinationInitalizationValidatationIfNeeded(file, func
)
8378 def GetLogArg(self
):
8379 """Overridden from Argument."""
8380 return "static_cast<const void*>(%s)" % self
.name
8383 class InputStringBucketArgument(Argument
):
8384 """A string input argument where the string is passed in a bucket."""
8386 def __init__(self
, name
, type):
8387 Argument
.__init
__(self
, name
+ "_bucket_id", "uint32_t")
8389 def IsPointer(self
):
8390 """Overridden from Argument."""
8393 def IsPointer2D(self
):
8394 """Overridden from Argument."""
8398 class InputStringArrayBucketArgument(Argument
):
8399 """A string array input argument where the strings are passed in a bucket."""
8401 def __init__(self
, name
, type):
8402 Argument
.__init
__(self
, name
+ "_bucket_id", "uint32_t")
8403 self
._original
_name
= name
8405 def WriteGetCode(self
, file):
8406 """Overridden from Argument."""
8408 Bucket* bucket = GetBucket(c.%(name)s);
8410 return error::kInvalidArguments;
8413 std::vector<char*> strs;
8414 std::vector<GLint> len;
8415 if (!bucket->GetAsStrings(&count, &strs, &len)) {
8416 return error::kInvalidArguments;
8418 const char** %(original_name)s =
8419 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
8420 const GLint* length =
8421 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
8426 'original_name': self
._original
_name
,
8429 def GetValidArg(self
, func
):
8430 return "kNameBucketId"
8432 def GetValidGLArg(self
, func
):
8435 def IsPointer(self
):
8436 """Overridden from Argument."""
8439 def IsPointer2D(self
):
8440 """Overridden from Argument."""
8444 class ResourceIdArgument(Argument
):
8445 """A class that represents a resource id argument to a function."""
8447 def __init__(self
, name
, type):
8448 match
= re
.match("(GLid\w+)", type)
8449 self
.resource_type
= match
.group(1)[4:]
8450 if self
.resource_type
== "Sync":
8451 type = type.replace(match
.group(1), "GLsync")
8453 type = type.replace(match
.group(1), "GLuint")
8454 Argument
.__init
__(self
, name
, type)
8456 def WriteGetCode(self
, file):
8457 """Overridden from Argument."""
8458 if self
.type == "GLsync":
8462 file.Write(" %s %s = c.%s;\n" % (my_type
, self
.name
, self
.name
))
8464 def GetValidArg(self
, func
):
8465 return "client_%s_id_" % self
.resource_type
.lower()
8467 def GetValidGLArg(self
, func
):
8468 if self
.resource_type
== "Sync":
8469 return "reinterpret_cast<GLsync>(kService%sId)" % self
.resource_type
8470 return "kService%sId" % self
.resource_type
8473 class ResourceIdBindArgument(Argument
):
8474 """Represents a resource id argument to a bind function."""
8476 def __init__(self
, name
, type):
8477 match
= re
.match("(GLidBind\w+)", type)
8478 self
.resource_type
= match
.group(1)[8:]
8479 type = type.replace(match
.group(1), "GLuint")
8480 Argument
.__init
__(self
, name
, type)
8482 def WriteGetCode(self
, file):
8483 """Overridden from Argument."""
8484 code
= """ %(type)s %(name)s = c.%(name)s;
8486 file.Write(code
% {'type': self
.type, 'name': self
.name
})
8488 def GetValidArg(self
, func
):
8489 return "client_%s_id_" % self
.resource_type
.lower()
8491 def GetValidGLArg(self
, func
):
8492 return "kService%sId" % self
.resource_type
8495 class ResourceIdZeroArgument(Argument
):
8496 """Represents a resource id argument to a function that can be zero."""
8498 def __init__(self
, name
, type):
8499 match
= re
.match("(GLidZero\w+)", type)
8500 self
.resource_type
= match
.group(1)[8:]
8501 type = type.replace(match
.group(1), "GLuint")
8502 Argument
.__init
__(self
, name
, type)
8504 def WriteGetCode(self
, file):
8505 """Overridden from Argument."""
8506 file.Write(" %s %s = c.%s;\n" % (self
.type, self
.name
, self
.name
))
8508 def GetValidArg(self
, func
):
8509 return "client_%s_id_" % self
.resource_type
.lower()
8511 def GetValidGLArg(self
, func
):
8512 return "kService%sId" % self
.resource_type
8514 def GetNumInvalidValues(self
, func
):
8515 """returns the number of invalid values to be tested."""
8518 def GetInvalidArg(self
, index
):
8519 """returns an invalid value by index."""
8520 return ("kInvalidClientId", "kNoError", "GL_INVALID_VALUE")
8523 class Function(object):
8524 """A class that represents a function."""
8528 'Bind': BindHandler(),
8529 'Create': CreateHandler(),
8530 'Custom': CustomHandler(),
8531 'Data': DataHandler(),
8532 'Delete': DeleteHandler(),
8533 'DELn': DELnHandler(),
8534 'GENn': GENnHandler(),
8535 'GETn': GETnHandler(),
8536 'GLchar': GLcharHandler(),
8537 'GLcharN': GLcharNHandler(),
8538 'HandWritten': HandWrittenHandler(),
8540 'Manual': ManualHandler(),
8541 'PUT': PUTHandler(),
8542 'PUTn': PUTnHandler(),
8543 'PUTSTR': PUTSTRHandler(),
8544 'PUTXn': PUTXnHandler(),
8545 'StateSet': StateSetHandler(),
8546 'StateSetRGBAlpha': StateSetRGBAlphaHandler(),
8547 'StateSetFrontBack': StateSetFrontBackHandler(),
8548 'StateSetFrontBackSeparate': StateSetFrontBackSeparateHandler(),
8549 'StateSetNamedParameter': StateSetNamedParameter(),
8550 'STRn': STRnHandler(),
8551 'Todo': TodoHandler(),
8554 def __init__(self
, name
, info
):
8556 self
.original_name
= info
['original_name']
8558 self
.original_args
= self
.ParseArgs(info
['original_args'])
8560 if 'cmd_args' in info
:
8561 self
.args_for_cmds
= self
.ParseArgs(info
['cmd_args'])
8563 self
.args_for_cmds
= self
.original_args
[:]
8565 self
.return_type
= info
['return_type']
8566 if self
.return_type
!= 'void':
8567 self
.return_arg
= CreateArg(info
['return_type'] + " result")
8569 self
.return_arg
= None
8571 self
.num_pointer_args
= sum(
8572 [1 for arg
in self
.args_for_cmds
if arg
.IsPointer()])
8573 if self
.num_pointer_args
> 0:
8574 for arg
in reversed(self
.original_args
):
8576 self
.last_original_pointer_arg
= arg
8579 self
.last_original_pointer_arg
= None
8581 self
.type_handler
= self
.type_handlers
[info
['type']]
8582 self
.can_auto_generate
= (self
.num_pointer_args
== 0 and
8583 info
['return_type'] == "void")
8586 def ParseArgs(self
, arg_string
):
8587 """Parses a function arg string."""
8589 parts
= arg_string
.split(',')
8590 for arg_string
in parts
:
8591 arg
= CreateArg(arg_string
)
8596 def IsType(self
, type_name
):
8597 """Returns true if function is a certain type."""
8598 return self
.info
['type'] == type_name
8600 def InitFunction(self
):
8601 """Creates command args and calls the init function for the type handler.
8603 Creates argument lists for command buffer commands, eg. self.cmd_args and
8605 Calls the type function initialization.
8606 Override to create different kind of command buffer command argument lists.
8609 for arg
in self
.args_for_cmds
:
8610 arg
.AddCmdArgs(self
.cmd_args
)
8613 for arg
in self
.args_for_cmds
:
8614 arg
.AddInitArgs(self
.init_args
)
8617 self
.init_args
.append(self
.return_arg
)
8619 self
.type_handler
.InitFunction(self
)
8621 def IsImmediate(self
):
8622 """Returns whether the function is immediate data function or not."""
8626 """Returns whether the function has service side validation or not."""
8627 return self
.GetInfo('unsafe', False)
8629 def GetInfo(self
, name
, default
= None):
8630 """Returns a value from the function info for this function."""
8631 if name
in self
.info
:
8632 return self
.info
[name
]
8635 def GetValidArg(self
, arg
):
8636 """Gets a valid argument value for the parameter arg from the function info
8639 index
= self
.GetOriginalArgs().index(arg
)
8643 valid_args
= self
.GetInfo('valid_args')
8644 if valid_args
and str(index
) in valid_args
:
8645 return valid_args
[str(index
)]
8648 def AddInfo(self
, name
, value
):
8650 self
.info
[name
] = value
8652 def IsExtension(self
):
8653 return self
.GetInfo('extension') or self
.GetInfo('extension_flag')
8655 def IsCoreGLFunction(self
):
8656 return (not self
.IsExtension() and
8657 not self
.GetInfo('pepper_interface') and
8658 not self
.IsUnsafe())
8660 def InPepperInterface(self
, interface
):
8661 ext
= self
.GetInfo('pepper_interface')
8662 if not interface
.GetName():
8663 return self
.IsCoreGLFunction()
8664 return ext
== interface
.GetName()
8666 def InAnyPepperExtension(self
):
8667 return self
.IsCoreGLFunction() or self
.GetInfo('pepper_interface')
8669 def GetErrorReturnString(self
):
8670 if self
.GetInfo("error_return"):
8671 return self
.GetInfo("error_return")
8672 elif self
.return_type
== "GLboolean":
8674 elif "*" in self
.return_type
:
8678 def GetGLFunctionName(self
):
8679 """Gets the function to call to execute GL for this command."""
8680 if self
.GetInfo('decoder_func'):
8681 return self
.GetInfo('decoder_func')
8682 return "gl%s" % self
.original_name
8684 def GetGLTestFunctionName(self
):
8685 gl_func_name
= self
.GetInfo('gl_test_func')
8686 if gl_func_name
== None:
8687 gl_func_name
= self
.GetGLFunctionName()
8688 if gl_func_name
.startswith("gl"):
8689 gl_func_name
= gl_func_name
[2:]
8691 gl_func_name
= self
.original_name
8694 def GetDataTransferMethods(self
):
8695 return self
.GetInfo('data_transfer_methods',
8696 ['immediate' if self
.num_pointer_args
== 1 else 'shm'])
8698 def AddCmdArg(self
, arg
):
8699 """Adds a cmd argument to this function."""
8700 self
.cmd_args
.append(arg
)
8702 def GetCmdArgs(self
):
8703 """Gets the command args for this function."""
8704 return self
.cmd_args
8706 def ClearCmdArgs(self
):
8707 """Clears the command args for this function."""
8710 def GetCmdConstants(self
):
8711 """Gets the constants for this function."""
8712 return [arg
for arg
in self
.args_for_cmds
if arg
.IsConstant()]
8714 def GetInitArgs(self
):
8715 """Gets the init args for this function."""
8716 return self
.init_args
8718 def GetOriginalArgs(self
):
8719 """Gets the original arguments to this function."""
8720 return self
.original_args
8722 def GetLastOriginalArg(self
):
8723 """Gets the last original argument to this function."""
8724 return self
.original_args
[len(self
.original_args
) - 1]
8726 def GetLastOriginalPointerArg(self
):
8727 return self
.last_original_pointer_arg
8729 def GetResourceIdArg(self
):
8730 for arg
in self
.original_args
:
8731 if hasattr(arg
, 'resource_type'):
8735 def _MaybePrependComma(self
, arg_string
, add_comma
):
8736 """Adds a comma if arg_string is not empty and add_comma is true."""
8738 if add_comma
and len(arg_string
):
8740 return "%s%s" % (comma
, arg_string
)
8742 def MakeTypedOriginalArgString(self
, prefix
, add_comma
= False):
8743 """Gets a list of arguments as they are in GL."""
8744 args
= self
.GetOriginalArgs()
8745 arg_string
= ", ".join(
8746 ["%s %s%s" % (arg
.type, prefix
, arg
.name
) for arg
in args
])
8747 return self
._MaybePrependComma
(arg_string
, add_comma
)
8749 def MakeOriginalArgString(self
, prefix
, add_comma
= False, separator
= ", "):
8750 """Gets the list of arguments as they are in GL."""
8751 args
= self
.GetOriginalArgs()
8752 arg_string
= separator
.join(
8753 ["%s%s" % (prefix
, arg
.name
) for arg
in args
])
8754 return self
._MaybePrependComma
(arg_string
, add_comma
)
8756 def MakeTypedHelperArgString(self
, prefix
, add_comma
= False):
8757 """Gets a list of typed GL arguments after removing unneeded arguments."""
8758 args
= self
.GetOriginalArgs()
8759 arg_string
= ", ".join(
8764 ) for arg
in args
if not arg
.IsConstant()])
8765 return self
._MaybePrependComma
(arg_string
, add_comma
)
8767 def MakeHelperArgString(self
, prefix
, add_comma
= False, separator
= ", "):
8768 """Gets a list of GL arguments after removing unneeded arguments."""
8769 args
= self
.GetOriginalArgs()
8770 arg_string
= separator
.join(
8771 ["%s%s" % (prefix
, arg
.name
)
8772 for arg
in args
if not arg
.IsConstant()])
8773 return self
._MaybePrependComma
(arg_string
, add_comma
)
8775 def MakeTypedPepperArgString(self
, prefix
):
8776 """Gets a list of arguments as they need to be for Pepper."""
8777 if self
.GetInfo("pepper_args"):
8778 return self
.GetInfo("pepper_args")
8780 return self
.MakeTypedOriginalArgString(prefix
, False)
8782 def MapCTypeToPepperIdlType(self
, ctype
, is_for_return_type
=False):
8783 """Converts a C type name to the corresponding Pepper IDL type."""
8785 'char*': '[out] str_t',
8786 'const GLchar* const*': '[out] cstr_t',
8787 'const char*': 'cstr_t',
8788 'const void*': 'mem_t',
8789 'void*': '[out] mem_t',
8790 'void**': '[out] mem_ptr_t',
8792 # We use "GLxxx_ptr_t" for "GLxxx*".
8793 matched
= re
.match(r
'(const )?(GL\w+)\*$', ctype
)
8795 idltype
= matched
.group(2) + '_ptr_t'
8796 if not matched
.group(1):
8797 idltype
= '[out] ' + idltype
8798 # If an in/out specifier is not specified yet, prepend [in].
8799 if idltype
[0] != '[':
8800 idltype
= '[in] ' + idltype
8801 # Strip the in/out specifier for a return type.
8802 if is_for_return_type
:
8803 idltype
= re
.sub(r
'\[\w+\] ', '', idltype
)
8806 def MakeTypedPepperIdlArgStrings(self
):
8807 """Gets a list of arguments as they need to be for Pepper IDL."""
8808 args
= self
.GetOriginalArgs()
8809 return ["%s %s" % (self
.MapCTypeToPepperIdlType(arg
.type), arg
.name
)
8812 def GetPepperName(self
):
8813 if self
.GetInfo("pepper_name"):
8814 return self
.GetInfo("pepper_name")
8817 def MakeTypedCmdArgString(self
, prefix
, add_comma
= False):
8818 """Gets a typed list of arguments as they need to be for command buffers."""
8819 args
= self
.GetCmdArgs()
8820 arg_string
= ", ".join(
8821 ["%s %s%s" % (arg
.type, prefix
, arg
.name
) for arg
in args
])
8822 return self
._MaybePrependComma
(arg_string
, add_comma
)
8824 def MakeCmdArgString(self
, prefix
, add_comma
= False):
8825 """Gets the list of arguments as they need to be for command buffers."""
8826 args
= self
.GetCmdArgs()
8827 arg_string
= ", ".join(
8828 ["%s%s" % (prefix
, arg
.name
) for arg
in args
])
8829 return self
._MaybePrependComma
(arg_string
, add_comma
)
8831 def MakeTypedInitString(self
, prefix
, add_comma
= False):
8832 """Gets a typed list of arguments as they need to be for cmd Init/Set."""
8833 args
= self
.GetInitArgs()
8834 arg_string
= ", ".join(
8835 ["%s %s%s" % (arg
.type, prefix
, arg
.name
) for arg
in args
])
8836 return self
._MaybePrependComma
(arg_string
, add_comma
)
8838 def MakeInitString(self
, prefix
, add_comma
= False):
8839 """Gets the list of arguments as they need to be for cmd Init/Set."""
8840 args
= self
.GetInitArgs()
8841 arg_string
= ", ".join(
8842 ["%s%s" % (prefix
, arg
.name
) for arg
in args
])
8843 return self
._MaybePrependComma
(arg_string
, add_comma
)
8845 def MakeLogArgString(self
):
8846 """Makes a string of the arguments for the LOG macros"""
8847 args
= self
.GetOriginalArgs()
8848 return ' << ", " << '.join([arg
.GetLogArg() for arg
in args
])
8850 def WriteCommandDescription(self
, file):
8851 """Writes a description of the command."""
8852 file.Write("//! Command that corresponds to gl%s.\n" % self
.original_name
)
8854 def WriteHandlerValidation(self
, file):
8855 """Writes validation code for the function."""
8856 for arg
in self
.GetOriginalArgs():
8857 arg
.WriteValidationCode(file, self
)
8858 self
.WriteValidationCode(file)
8860 def WriteHandlerImplementation(self
, file):
8861 """Writes the handler implementation for this command."""
8862 self
.type_handler
.WriteHandlerImplementation(self
, file)
8864 def WriteValidationCode(self
, file):
8865 """Writes the validation code for a command."""
8868 def WriteCmdFlag(self
, file):
8869 """Writes the cmd cmd_flags constant."""
8871 # By default trace only at the highest level 3.
8872 trace_level
= int(self
.GetInfo('trace_level', default
= 3))
8873 if trace_level
not in xrange(0, 4):
8874 raise KeyError("Unhandled trace_level: %d" % trace_level
)
8876 flags
.append('CMD_FLAG_SET_TRACE_LEVEL(%d)' % trace_level
)
8879 cmd_flags
= ' | '.join(flags
)
8883 file.Write(" static const uint8 cmd_flags = %s;\n" % cmd_flags
)
8886 def WriteCmdArgFlag(self
, file):
8887 """Writes the cmd kArgFlags constant."""
8888 file.Write(" static const cmd::ArgFlags kArgFlags = cmd::kFixed;\n")
8890 def WriteCmdComputeSize(self
, file):
8891 """Writes the ComputeSize function for the command."""
8892 file.Write(" static uint32_t ComputeSize() {\n")
8894 " return static_cast<uint32_t>(sizeof(ValueType)); // NOLINT\n")
8898 def WriteCmdSetHeader(self
, file):
8899 """Writes the cmd's SetHeader function."""
8900 file.Write(" void SetHeader() {\n")
8901 file.Write(" header.SetCmd<ValueType>();\n")
8905 def WriteCmdInit(self
, file):
8906 """Writes the cmd's Init function."""
8907 file.Write(" void Init(%s) {\n" % self
.MakeTypedCmdArgString("_"))
8908 file.Write(" SetHeader();\n")
8909 args
= self
.GetCmdArgs()
8911 file.Write(" %s = _%s;\n" % (arg
.name
, arg
.name
))
8915 def WriteCmdSet(self
, file):
8916 """Writes the cmd's Set function."""
8917 copy_args
= self
.MakeCmdArgString("_", False)
8918 file.Write(" void* Set(void* cmd%s) {\n" %
8919 self
.MakeTypedCmdArgString("_", True))
8920 file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % copy_args
)
8921 file.Write(" return NextCmdAddress<ValueType>(cmd);\n")
8925 def WriteStruct(self
, file):
8926 self
.type_handler
.WriteStruct(self
, file)
8928 def WriteDocs(self
, file):
8929 self
.type_handler
.WriteDocs(self
, file)
8931 def WriteCmdHelper(self
, file):
8932 """Writes the cmd's helper."""
8933 self
.type_handler
.WriteCmdHelper(self
, file)
8935 def WriteServiceImplementation(self
, file):
8936 """Writes the service implementation for a command."""
8937 self
.type_handler
.WriteServiceImplementation(self
, file)
8939 def WriteServiceUnitTest(self
, file, *extras
):
8940 """Writes the service implementation for a command."""
8941 self
.type_handler
.WriteServiceUnitTest(self
, file, *extras
)
8943 def WriteGLES2CLibImplementation(self
, file):
8944 """Writes the GLES2 C Lib Implemention."""
8945 self
.type_handler
.WriteGLES2CLibImplementation(self
, file)
8947 def WriteGLES2InterfaceHeader(self
, file):
8948 """Writes the GLES2 Interface declaration."""
8949 self
.type_handler
.WriteGLES2InterfaceHeader(self
, file)
8951 def WriteMojoGLES2ImplHeader(self
, file):
8952 """Writes the Mojo GLES2 implementation header declaration."""
8953 self
.type_handler
.WriteMojoGLES2ImplHeader(self
, file)
8955 def WriteMojoGLES2Impl(self
, file):
8956 """Writes the Mojo GLES2 implementation declaration."""
8957 self
.type_handler
.WriteMojoGLES2Impl(self
, file)
8959 def WriteGLES2InterfaceStub(self
, file):
8960 """Writes the GLES2 Interface Stub declaration."""
8961 self
.type_handler
.WriteGLES2InterfaceStub(self
, file)
8963 def WriteGLES2InterfaceStubImpl(self
, file):
8964 """Writes the GLES2 Interface Stub declaration."""
8965 self
.type_handler
.WriteGLES2InterfaceStubImpl(self
, file)
8967 def WriteGLES2ImplementationHeader(self
, file):
8968 """Writes the GLES2 Implemention declaration."""
8969 self
.type_handler
.WriteGLES2ImplementationHeader(self
, file)
8971 def WriteGLES2Implementation(self
, file):
8972 """Writes the GLES2 Implemention definition."""
8973 self
.type_handler
.WriteGLES2Implementation(self
, file)
8975 def WriteGLES2TraceImplementationHeader(self
, file):
8976 """Writes the GLES2 Trace Implemention declaration."""
8977 self
.type_handler
.WriteGLES2TraceImplementationHeader(self
, file)
8979 def WriteGLES2TraceImplementation(self
, file):
8980 """Writes the GLES2 Trace Implemention definition."""
8981 self
.type_handler
.WriteGLES2TraceImplementation(self
, file)
8983 def WriteGLES2Header(self
, file):
8984 """Writes the GLES2 Implemention unit test."""
8985 self
.type_handler
.WriteGLES2Header(self
, file)
8987 def WriteGLES2ImplementationUnitTest(self
, file):
8988 """Writes the GLES2 Implemention unit test."""
8989 self
.type_handler
.WriteGLES2ImplementationUnitTest(self
, file)
8991 def WriteDestinationInitalizationValidation(self
, file):
8992 """Writes the client side destintion initialization validation."""
8993 self
.type_handler
.WriteDestinationInitalizationValidation(self
, file)
8995 def WriteFormatTest(self
, file):
8996 """Writes the cmd's format test."""
8997 self
.type_handler
.WriteFormatTest(self
, file)
9000 class PepperInterface(object):
9001 """A class that represents a function."""
9003 def __init__(self
, info
):
9004 self
.name
= info
["name"]
9005 self
.dev
= info
["dev"]
9010 def GetInterfaceName(self
):
9014 upperint
= "_" + self
.name
.upper()
9017 return "PPB_OPENGLES2%s%s_INTERFACE" % (upperint
, dev
)
9019 def GetInterfaceString(self
):
9023 return "PPB_OpenGLES2%s%s" % (self
.name
, dev
)
9025 def GetStructName(self
):
9029 return "PPB_OpenGLES2%s%s" % (self
.name
, dev
)
9032 class ImmediateFunction(Function
):
9033 """A class that represnets an immediate function command."""
9035 def __init__(self
, func
):
9038 "%sImmediate" % func
.name
,
9041 def InitFunction(self
):
9042 # Override args in original_args and args_for_cmds with immediate versions
9045 new_original_args
= []
9046 for arg
in self
.original_args
:
9047 new_arg
= arg
.GetImmediateVersion()
9049 new_original_args
.append(new_arg
)
9050 self
.original_args
= new_original_args
9052 new_args_for_cmds
= []
9053 for arg
in self
.args_for_cmds
:
9054 new_arg
= arg
.GetImmediateVersion()
9056 new_args_for_cmds
.append(new_arg
)
9058 self
.args_for_cmds
= new_args_for_cmds
9060 Function
.InitFunction(self
)
9062 def IsImmediate(self
):
9065 def WriteCommandDescription(self
, file):
9066 """Overridden from Function"""
9067 file.Write("//! Immediate version of command that corresponds to gl%s.\n" %
9070 def WriteServiceImplementation(self
, file):
9071 """Overridden from Function"""
9072 self
.type_handler
.WriteImmediateServiceImplementation(self
, file)
9074 def WriteHandlerImplementation(self
, file):
9075 """Overridden from Function"""
9076 self
.type_handler
.WriteImmediateHandlerImplementation(self
, file)
9078 def WriteServiceUnitTest(self
, file, *extras
):
9079 """Writes the service implementation for a command."""
9080 self
.type_handler
.WriteImmediateServiceUnitTest(self
, file, *extras
)
9082 def WriteValidationCode(self
, file):
9083 """Overridden from Function"""
9084 self
.type_handler
.WriteImmediateValidationCode(self
, file)
9086 def WriteCmdArgFlag(self
, file):
9087 """Overridden from Function"""
9088 file.Write(" static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;\n")
9090 def WriteCmdComputeSize(self
, file):
9091 """Overridden from Function"""
9092 self
.type_handler
.WriteImmediateCmdComputeSize(self
, file)
9094 def WriteCmdSetHeader(self
, file):
9095 """Overridden from Function"""
9096 self
.type_handler
.WriteImmediateCmdSetHeader(self
, file)
9098 def WriteCmdInit(self
, file):
9099 """Overridden from Function"""
9100 self
.type_handler
.WriteImmediateCmdInit(self
, file)
9102 def WriteCmdSet(self
, file):
9103 """Overridden from Function"""
9104 self
.type_handler
.WriteImmediateCmdSet(self
, file)
9106 def WriteCmdHelper(self
, file):
9107 """Overridden from Function"""
9108 self
.type_handler
.WriteImmediateCmdHelper(self
, file)
9110 def WriteFormatTest(self
, file):
9111 """Overridden from Function"""
9112 self
.type_handler
.WriteImmediateFormatTest(self
, file)
9115 class BucketFunction(Function
):
9116 """A class that represnets a bucket version of a function command."""
9118 def __init__(self
, func
):
9121 "%sBucket" % func
.name
,
9124 def InitFunction(self
):
9125 # Override args in original_args and args_for_cmds with bucket versions
9128 new_original_args
= []
9129 for arg
in self
.original_args
:
9130 new_arg
= arg
.GetBucketVersion()
9132 new_original_args
.append(new_arg
)
9133 self
.original_args
= new_original_args
9135 new_args_for_cmds
= []
9136 for arg
in self
.args_for_cmds
:
9137 new_arg
= arg
.GetBucketVersion()
9139 new_args_for_cmds
.append(new_arg
)
9141 self
.args_for_cmds
= new_args_for_cmds
9143 Function
.InitFunction(self
)
9145 def WriteCommandDescription(self
, file):
9146 """Overridden from Function"""
9147 file.Write("//! Bucket version of command that corresponds to gl%s.\n" %
9150 def WriteServiceImplementation(self
, file):
9151 """Overridden from Function"""
9152 self
.type_handler
.WriteBucketServiceImplementation(self
, file)
9154 def WriteHandlerImplementation(self
, file):
9155 """Overridden from Function"""
9156 self
.type_handler
.WriteBucketHandlerImplementation(self
, file)
9158 def WriteServiceUnitTest(self
, file, *extras
):
9159 """Overridden from Function"""
9160 self
.type_handler
.WriteBucketServiceUnitTest(self
, file, *extras
)
9162 def MakeOriginalArgString(self
, prefix
, add_comma
= False, separator
= ", "):
9163 """Overridden from Function"""
9164 args
= self
.GetOriginalArgs()
9165 arg_string
= separator
.join(
9166 ["%s%s" % (prefix
, arg
.name
[0:-10] if arg
.name
.endswith("_bucket_id")
9167 else arg
.name
) for arg
in args
])
9168 return super(BucketFunction
, self
)._MaybePrependComma
(arg_string
, add_comma
)
9171 def CreateArg(arg_string
):
9172 """Creates an Argument."""
9173 arg_parts
= arg_string
.split()
9174 if len(arg_parts
) == 1 and arg_parts
[0] == 'void':
9176 # Is this a pointer argument?
9177 elif arg_string
.find('*') >= 0:
9178 return PointerArgument(
9180 " ".join(arg_parts
[0:-1]))
9181 # Is this a resource argument? Must come after pointer check.
9182 elif arg_parts
[0].startswith('GLidBind'):
9183 return ResourceIdBindArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9184 elif arg_parts
[0].startswith('GLidZero'):
9185 return ResourceIdZeroArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9186 elif arg_parts
[0].startswith('GLid'):
9187 return ResourceIdArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9188 elif arg_parts
[0].startswith('GLenum') and len(arg_parts
[0]) > 6:
9189 return EnumArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9190 elif arg_parts
[0].startswith('GLbitfield') and len(arg_parts
[0]) > 10:
9191 return BitFieldArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9192 elif arg_parts
[0].startswith('GLboolean') and len(arg_parts
[0]) > 9:
9193 return ValidatedBoolArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9194 elif arg_parts
[0].startswith('GLboolean'):
9195 return BoolArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9196 elif arg_parts
[0].startswith('GLintUniformLocation'):
9197 return UniformLocationArgument(arg_parts
[-1])
9198 elif (arg_parts
[0].startswith('GLint') and len(arg_parts
[0]) > 5 and
9199 not arg_parts
[0].startswith('GLintptr')):
9200 return IntArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9201 elif (arg_parts
[0].startswith('GLsizeiNotNegative') or
9202 arg_parts
[0].startswith('GLintptrNotNegative')):
9203 return SizeNotNegativeArgument(arg_parts
[-1],
9204 " ".join(arg_parts
[0:-1]),
9205 arg_parts
[0][0:-11])
9206 elif arg_parts
[0].startswith('GLsize'):
9207 return SizeArgument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9209 return Argument(arg_parts
[-1], " ".join(arg_parts
[0:-1]))
9212 class GLGenerator(object):
9213 """A class to generate GL command buffers."""
9215 _function_re
= re
.compile(r
'GL_APICALL(.*?)GL_APIENTRY (.*?) \((.*?)\);')
9217 def __init__(self
, verbose
):
9218 self
.original_functions
= []
9220 self
.verbose
= verbose
9222 self
.pepper_interfaces
= []
9223 self
.interface_info
= {}
9224 self
.generated_cpp_filenames
= []
9226 for interface
in _PEPPER_INTERFACES
:
9227 interface
= PepperInterface(interface
)
9228 self
.pepper_interfaces
.append(interface
)
9229 self
.interface_info
[interface
.GetName()] = interface
9231 def AddFunction(self
, func
):
9232 """Adds a function."""
9233 self
.functions
.append(func
)
9235 def GetFunctionInfo(self
, name
):
9236 """Gets a type info for the given function name."""
9237 if name
in _FUNCTION_INFO
:
9238 func_info
= _FUNCTION_INFO
[name
].copy()
9242 if not 'type' in func_info
:
9243 func_info
['type'] = ''
9248 """Prints something if verbose is true."""
9252 def Error(self
, msg
):
9253 """Prints an error."""
9254 print "Error: %s" % msg
9257 def WriteLicense(self
, file):
9258 """Writes the license."""
9259 file.Write(_LICENSE
)
9261 def WriteNamespaceOpen(self
, file):
9262 """Writes the code for the namespace."""
9263 file.Write("namespace gpu {\n")
9264 file.Write("namespace gles2 {\n")
9267 def WriteNamespaceClose(self
, file):
9268 """Writes the code to close the namespace."""
9269 file.Write("} // namespace gles2\n")
9270 file.Write("} // namespace gpu\n")
9273 def ParseGLH(self
, filename
):
9274 """Parses the cmd_buffer_functions.txt file and extracts the functions"""
9275 f
= open(filename
, "r")
9276 functions
= f
.read()
9278 for line
in functions
.splitlines():
9279 match
= self
._function
_re
.match(line
)
9281 func_name
= match
.group(2)[2:]
9282 func_info
= self
.GetFunctionInfo(func_name
)
9283 if func_info
['type'] == 'Noop':
9286 parsed_func_info
= {
9287 'original_name': func_name
,
9288 'original_args': match
.group(3),
9289 'return_type': match
.group(1).strip(),
9292 for k
in parsed_func_info
.keys():
9293 if not k
in func_info
:
9294 func_info
[k
] = parsed_func_info
[k
]
9296 f
= Function(func_name
, func_info
)
9297 self
.original_functions
.append(f
)
9299 #for arg in f.GetOriginalArgs():
9300 # if not isinstance(arg, EnumArgument) and arg.type == 'GLenum':
9301 # self.Log("%s uses bare GLenum %s." % (func_name, arg.name))
9303 gen_cmd
= f
.GetInfo('gen_cmd')
9304 if gen_cmd
== True or gen_cmd
== None:
9305 if f
.type_handler
.NeedsDataTransferFunction(f
):
9306 methods
= f
.GetDataTransferMethods()
9307 if 'immediate' in methods
:
9308 self
.AddFunction(ImmediateFunction(f
))
9309 if 'bucket' in methods
:
9310 self
.AddFunction(BucketFunction(f
))
9311 if 'shm' in methods
:
9316 self
.Log("Auto Generated Functions : %d" %
9317 len([f
for f
in self
.functions
if f
.can_auto_generate
or
9318 (not f
.IsType('') and not f
.IsType('Custom') and
9319 not f
.IsType('Todo'))]))
9321 funcs
= [f
for f
in self
.functions
if not f
.can_auto_generate
and
9322 (f
.IsType('') or f
.IsType('Custom') or f
.IsType('Todo'))]
9323 self
.Log("Non Auto Generated Functions: %d" % len(funcs
))
9326 self
.Log(" %-10s %-20s gl%s" % (f
.info
['type'], f
.return_type
, f
.name
))
9328 def WriteCommandIds(self
, filename
):
9329 """Writes the command buffer format"""
9330 file = CHeaderWriter(filename
)
9331 file.Write("#define GLES2_COMMAND_LIST(OP) \\\n")
9333 for func
in self
.functions
:
9334 file.Write(" %-60s /* %d */ \\\n" %
9335 ("OP(%s)" % func
.name
, id))
9339 file.Write("enum CommandId {\n")
9340 file.Write(" kStartPoint = cmd::kLastCommonId, "
9341 "// All GLES2 commands start after this.\n")
9342 file.Write("#define GLES2_CMD_OP(name) k ## name,\n")
9343 file.Write(" GLES2_COMMAND_LIST(GLES2_CMD_OP)\n")
9344 file.Write("#undef GLES2_CMD_OP\n")
9345 file.Write(" kNumCommands\n")
9349 self
.generated_cpp_filenames
.append(file.filename
)
9351 def WriteFormat(self
, filename
):
9352 """Writes the command buffer format"""
9353 file = CHeaderWriter(filename
)
9354 # Forward declaration of a few enums used in constant argument
9355 # to avoid including GL header files.
9357 'GL_SYNC_GPU_COMMANDS_COMPLETE': '0x9117',
9358 'GL_SYNC_FLUSH_COMMANDS_BIT': '0x00000001',
9361 for enum
in enum_defines
:
9362 file.Write("#define %s %s\n" % (enum
, enum_defines
[enum
]))
9364 for func
in self
.functions
:
9366 #gen_cmd = func.GetInfo('gen_cmd')
9367 #if gen_cmd == True or gen_cmd == None:
9368 func
.WriteStruct(file)
9371 self
.generated_cpp_filenames
.append(file.filename
)
9373 def WriteDocs(self
, filename
):
9374 """Writes the command buffer doc version of the commands"""
9375 file = CWriter(filename
)
9376 for func
in self
.functions
:
9378 #gen_cmd = func.GetInfo('gen_cmd')
9379 #if gen_cmd == True or gen_cmd == None:
9380 func
.WriteDocs(file)
9383 self
.generated_cpp_filenames
.append(file.filename
)
9385 def WriteFormatTest(self
, filename
):
9386 """Writes the command buffer format test."""
9387 file = CHeaderWriter(
9389 "// This file contains unit tests for gles2 commmands\n"
9390 "// It is included by gles2_cmd_format_test.cc\n"
9393 for func
in self
.functions
:
9395 #gen_cmd = func.GetInfo('gen_cmd')
9396 #if gen_cmd == True or gen_cmd == None:
9397 func
.WriteFormatTest(file)
9400 self
.generated_cpp_filenames
.append(file.filename
)
9402 def WriteCmdHelperHeader(self
, filename
):
9403 """Writes the gles2 command helper."""
9404 file = CHeaderWriter(filename
)
9406 for func
in self
.functions
:
9408 #gen_cmd = func.GetInfo('gen_cmd')
9409 #if gen_cmd == True or gen_cmd == None:
9410 func
.WriteCmdHelper(file)
9413 self
.generated_cpp_filenames
.append(file.filename
)
9415 def WriteServiceContextStateHeader(self
, filename
):
9416 """Writes the service context state header."""
9417 file = CHeaderWriter(
9419 "// It is included by context_state.h\n")
9420 file.Write("struct EnableFlags {\n")
9421 file.Write(" EnableFlags();\n")
9422 for capability
in _CAPABILITY_FLAGS
:
9423 file.Write(" bool %s;\n" % capability
['name'])
9424 file.Write(" bool cached_%s;\n" % capability
['name'])
9425 file.Write("};\n\n")
9427 for state_name
in sorted(_STATES
.keys()):
9428 state
= _STATES
[state_name
]
9429 for item
in state
['states']:
9430 if isinstance(item
['default'], list):
9431 file.Write("%s %s[%d];\n" % (item
['type'], item
['name'],
9432 len(item
['default'])))
9434 file.Write("%s %s;\n" % (item
['type'], item
['name']))
9436 if item
.get('cached', False):
9437 if isinstance(item
['default'], list):
9438 file.Write("%s cached_%s[%d];\n" % (item
['type'], item
['name'],
9439 len(item
['default'])))
9441 file.Write("%s cached_%s;\n" % (item
['type'], item
['name']))
9446 inline void SetDeviceCapabilityState(GLenum cap, bool enable) {
9449 for capability
in _CAPABILITY_FLAGS
:
9452 """ % capability
['name'].upper())
9454 if (enable_flags.cached_%(name)s == enable &&
9455 !ignore_cached_state)
9457 enable_flags.cached_%(name)s = enable;
9474 self
.generated_cpp_filenames
.append(file.filename
)
9476 def WriteClientContextStateHeader(self
, filename
):
9477 """Writes the client context state header."""
9478 file = CHeaderWriter(
9480 "// It is included by client_context_state.h\n")
9481 file.Write("struct EnableFlags {\n")
9482 file.Write(" EnableFlags();\n")
9483 for capability
in _CAPABILITY_FLAGS
:
9484 file.Write(" bool %s;\n" % capability
['name'])
9485 file.Write("};\n\n")
9488 self
.generated_cpp_filenames
.append(file.filename
)
9490 def WriteContextStateGetters(self
, file, class_name
):
9491 """Writes the state getters."""
9492 for gl_type
in ["GLint", "GLfloat"]:
9494 bool %s::GetStateAs%s(
9495 GLenum pname, %s* params, GLsizei* num_written) const {
9497 """ % (class_name
, gl_type
, gl_type
))
9498 for state_name
in sorted(_STATES
.keys()):
9499 state
= _STATES
[state_name
]
9501 file.Write(" case %s:\n" % state
['enum'])
9502 file.Write(" *num_written = %d;\n" % len(state
['states']))
9503 file.Write(" if (params) {\n")
9504 for ndx
,item
in enumerate(state
['states']):
9505 file.Write(" params[%d] = static_cast<%s>(%s);\n" %
9506 (ndx
, gl_type
, item
['name']))
9508 file.Write(" return true;\n")
9510 for item
in state
['states']:
9511 file.Write(" case %s:\n" % item
['enum'])
9512 if isinstance(item
['default'], list):
9513 item_len
= len(item
['default'])
9514 file.Write(" *num_written = %d;\n" % item_len
)
9515 file.Write(" if (params) {\n")
9516 if item
['type'] == gl_type
:
9517 file.Write(" memcpy(params, %s, sizeof(%s) * %d);\n" %
9518 (item
['name'], item
['type'], item_len
))
9520 file.Write(" for (size_t i = 0; i < %s; ++i) {\n" %
9522 file.Write(" params[i] = %s;\n" %
9523 (GetGLGetTypeConversion(gl_type
, item
['type'],
9524 "%s[i]" % item
['name'])))
9527 file.Write(" *num_written = 1;\n")
9528 file.Write(" if (params) {\n")
9529 file.Write(" params[0] = %s;\n" %
9530 (GetGLGetTypeConversion(gl_type
, item
['type'],
9533 file.Write(" return true;\n")
9534 for capability
in _CAPABILITY_FLAGS
:
9535 file.Write(" case GL_%s:\n" % capability
['name'].upper())
9536 file.Write(" *num_written = 1;\n")
9537 file.Write(" if (params) {\n")
9539 " params[0] = static_cast<%s>(enable_flags.%s);\n" %
9540 (gl_type
, capability
['name']))
9542 file.Write(" return true;\n")
9543 file.Write(""" default:
9549 def WriteServiceContextStateImpl(self
, filename
):
9550 """Writes the context state service implementation."""
9551 file = CHeaderWriter(
9553 "// It is included by context_state.cc\n")
9555 for capability
in _CAPABILITY_FLAGS
:
9556 code
.append("%s(%s)" %
9557 (capability
['name'],
9558 ('false', 'true')['default' in capability
]))
9559 code
.append("cached_%s(%s)" %
9560 (capability
['name'],
9561 ('false', 'true')['default' in capability
]))
9562 file.Write("ContextState::EnableFlags::EnableFlags()\n : %s {\n}\n" %
9566 file.Write("void ContextState::Initialize() {\n")
9567 for state_name
in sorted(_STATES
.keys()):
9568 state
= _STATES
[state_name
]
9569 for item
in state
['states']:
9570 if isinstance(item
['default'], list):
9571 for ndx
, value
in enumerate(item
['default']):
9572 file.Write(" %s[%d] = %s;\n" % (item
['name'], ndx
, value
))
9574 file.Write(" %s = %s;\n" % (item
['name'], item
['default']))
9575 if item
.get('cached', False):
9576 if isinstance(item
['default'], list):
9577 for ndx
, value
in enumerate(item
['default']):
9578 file.Write(" cached_%s[%d] = %s;\n" % (item
['name'], ndx
, value
))
9580 file.Write(" cached_%s = %s;\n" % (item
['name'], item
['default']))
9584 void ContextState::InitCapabilities(const ContextState* prev_state) const {
9586 def WriteCapabilities(test_prev
, es3_caps
):
9587 for capability
in _CAPABILITY_FLAGS
:
9588 capability_name
= capability
['name']
9589 capability_es3
= 'es3' in capability
and capability
['es3'] == True
9590 if capability_es3
and not es3_caps
or not capability_es3
and es3_caps
:
9593 file.Write(""" if (prev_state->enable_flags.cached_%s !=
9594 enable_flags.cached_%s) {\n""" %
9595 (capability_name
, capability_name
))
9596 file.Write(" EnableDisable(GL_%s, enable_flags.cached_%s);\n" %
9597 (capability_name
.upper(), capability_name
))
9601 file.Write(" if (prev_state) {")
9602 WriteCapabilities(True, False)
9603 file.Write(" if (feature_info_->IsES3Capable()) {\n")
9604 WriteCapabilities(True, True)
9606 file.Write(" } else {")
9607 WriteCapabilities(False, False)
9608 file.Write(" if (feature_info_->IsES3Capable()) {\n")
9609 WriteCapabilities(False, True)
9615 void ContextState::InitState(const ContextState *prev_state) const {
9618 def WriteStates(test_prev
):
9619 # We need to sort the keys so the expectations match
9620 for state_name
in sorted(_STATES
.keys()):
9621 state
= _STATES
[state_name
]
9622 if state
['type'] == 'FrontBack':
9623 num_states
= len(state
['states'])
9624 for ndx
, group
in enumerate(Grouper(num_states
/ 2, state
['states'])):
9628 for place
, item
in enumerate(group
):
9629 item_name
= CachedStateName(item
)
9630 args
.append('%s' % item_name
)
9634 file.Write("(%s != prev_state->%s)" % (item_name
, item_name
))
9638 " gl%s(%s, %s);\n" %
9639 (state
['func'], ('GL_FRONT', 'GL_BACK')[ndx
], ", ".join(args
)))
9640 elif state
['type'] == 'NamedParameter':
9641 for item
in state
['states']:
9642 item_name
= CachedStateName(item
)
9644 if 'extension_flag' in item
:
9645 file.Write(" if (feature_info_->feature_flags().%s) {\n " %
9646 item
['extension_flag'])
9648 if isinstance(item
['default'], list):
9649 file.Write(" if (memcmp(prev_state->%s, %s, "
9650 "sizeof(%s) * %d)) {\n" %
9651 (item_name
, item_name
, item
['type'],
9652 len(item
['default'])))
9654 file.Write(" if (prev_state->%s != %s) {\n " %
9655 (item_name
, item_name
))
9656 if 'gl_version_flag' in item
:
9657 item_name
= item
['gl_version_flag']
9659 if item_name
[0] == '!':
9661 item_name
= item_name
[1:]
9662 file.Write(" if (%sfeature_info_->gl_version_info().%s) {\n" %
9663 (inverted
, item_name
))
9664 file.Write(" gl%s(%s, %s);\n" %
9667 if 'enum_set' in item
else item
['enum']),
9669 if 'gl_version_flag' in item
:
9672 if 'extension_flag' in item
:
9675 if 'extension_flag' in item
:
9678 if 'extension_flag' in state
:
9679 file.Write(" if (feature_info_->feature_flags().%s)\n " %
9680 state
['extension_flag'])
9684 for place
, item
in enumerate(state
['states']):
9685 item_name
= CachedStateName(item
)
9686 args
.append('%s' % item_name
)
9690 file.Write("(%s != prev_state->%s)" %
9691 (item_name
, item_name
))
9694 file.Write(" gl%s(%s);\n" % (state
['func'], ", ".join(args
)))
9696 file.Write(" if (prev_state) {")
9698 file.Write(" } else {")
9703 file.Write("""bool ContextState::GetEnabled(GLenum cap) const {
9706 for capability
in _CAPABILITY_FLAGS
:
9707 file.Write(" case GL_%s:\n" % capability
['name'].upper())
9708 file.Write(" return enable_flags.%s;\n" % capability
['name'])
9709 file.Write(""" default:
9716 self
.WriteContextStateGetters(file, "ContextState")
9718 self
.generated_cpp_filenames
.append(file.filename
)
9720 def WriteClientContextStateImpl(self
, filename
):
9721 """Writes the context state client side implementation."""
9722 file = CHeaderWriter(
9724 "// It is included by client_context_state.cc\n")
9726 for capability
in _CAPABILITY_FLAGS
:
9727 code
.append("%s(%s)" %
9728 (capability
['name'],
9729 ('false', 'true')['default' in capability
]))
9731 "ClientContextState::EnableFlags::EnableFlags()\n : %s {\n}\n" %
9736 bool ClientContextState::SetCapabilityState(
9737 GLenum cap, bool enabled, bool* changed) {
9741 for capability
in _CAPABILITY_FLAGS
:
9742 file.Write(" case GL_%s:\n" % capability
['name'].upper())
9743 file.Write(""" if (enable_flags.%(name)s != enabled) {
9745 enable_flags.%(name)s = enabled;
9749 file.Write(""" default:
9754 file.Write("""bool ClientContextState::GetEnabled(
9755 GLenum cap, bool* enabled) const {
9758 for capability
in _CAPABILITY_FLAGS
:
9759 file.Write(" case GL_%s:\n" % capability
['name'].upper())
9760 file.Write(" *enabled = enable_flags.%s;\n" % capability
['name'])
9761 file.Write(" return true;\n")
9762 file.Write(""" default:
9768 self
.generated_cpp_filenames
.append(file.filename
)
9770 def WriteServiceImplementation(self
, filename
):
9771 """Writes the service decorder implementation."""
9772 file = CHeaderWriter(
9774 "// It is included by gles2_cmd_decoder.cc\n")
9776 for func
in self
.functions
:
9778 #gen_cmd = func.GetInfo('gen_cmd')
9779 #if gen_cmd == True or gen_cmd == None:
9780 func
.WriteServiceImplementation(file)
9783 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) {
9786 for capability
in _CAPABILITY_FLAGS
:
9787 file.Write(" case GL_%s:\n" % capability
['name'].upper())
9788 if 'state_flag' in capability
:
9791 state_.enable_flags.%(name)s = enabled;
9792 if (state_.enable_flags.cached_%(name)s != enabled
9793 || state_.ignore_cached_state) {
9794 %(state_flag)s = true;
9800 state_.enable_flags.%(name)s = enabled;
9801 if (state_.enable_flags.cached_%(name)s != enabled
9802 || state_.ignore_cached_state) {
9803 state_.enable_flags.cached_%(name)s = enabled;
9808 file.Write(""" default:
9815 self
.generated_cpp_filenames
.append(file.filename
)
9817 def WriteServiceUnitTests(self
, filename
):
9818 """Writes the service decorder unit tests."""
9819 num_tests
= len(self
.functions
)
9820 FUNCTIONS_PER_FILE
= 98 # hard code this so it doesn't change.
9822 for test_num
in range(0, num_tests
, FUNCTIONS_PER_FILE
):
9824 name
= filename
% count
9825 file = CHeaderWriter(
9827 "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" % count
)
9828 test_name
= 'GLES2DecoderTest%d' % count
9829 end
= test_num
+ FUNCTIONS_PER_FILE
9832 for idx
in range(test_num
, end
):
9833 func
= self
.functions
[idx
]
9835 # Do any filtering of the functions here, so that the functions
9836 # will not move between the numbered files if filtering properties
9838 if func
.GetInfo('extension_flag'):
9842 #gen_cmd = func.GetInfo('gen_cmd')
9843 #if gen_cmd == True or gen_cmd == None:
9844 if func
.GetInfo('unit_test') == False:
9845 file.Write("// TODO(gman): %s\n" % func
.name
)
9847 func
.WriteServiceUnitTest(file, {
9848 'test_name': test_name
9851 self
.generated_cpp_filenames
.append(file.filename
)
9852 file = CHeaderWriter(
9854 "// It is included by gles2_cmd_decoder_unittest_base.cc\n")
9856 """void GLES2DecoderTestBase::SetupInitCapabilitiesExpectations(
9857 bool es3_capable) {""")
9858 for capability
in _CAPABILITY_FLAGS
:
9859 capability_es3
= 'es3' in capability
and capability
['es3'] == True
9860 if not capability_es3
:
9861 file.Write(" ExpectEnableDisable(GL_%s, %s);\n" %
9862 (capability
['name'].upper(),
9863 ('false', 'true')['default' in capability
]))
9865 file.Write(" if (es3_capable) {")
9866 for capability
in _CAPABILITY_FLAGS
:
9867 capability_es3
= 'es3' in capability
and capability
['es3'] == True
9869 file.Write(" ExpectEnableDisable(GL_%s, %s);\n" %
9870 (capability
['name'].upper(),
9871 ('false', 'true')['default' in capability
]))
9875 void GLES2DecoderTestBase::SetupInitStateExpectations() {
9878 # We need to sort the keys so the expectations match
9879 for state_name
in sorted(_STATES
.keys()):
9880 state
= _STATES
[state_name
]
9881 if state
['type'] == 'FrontBack':
9882 num_states
= len(state
['states'])
9883 for ndx
, group
in enumerate(Grouper(num_states
/ 2, state
['states'])):
9886 if 'expected' in item
:
9887 args
.append(item
['expected'])
9889 args
.append(item
['default'])
9891 " EXPECT_CALL(*gl_, %s(%s, %s))\n" %
9892 (state
['func'], ('GL_FRONT', 'GL_BACK')[ndx
], ", ".join(args
)))
9893 file.Write(" .Times(1)\n")
9894 file.Write(" .RetiresOnSaturation();\n")
9895 elif state
['type'] == 'NamedParameter':
9896 for item
in state
['states']:
9897 if 'extension_flag' in item
:
9898 file.Write(" if (group_->feature_info()->feature_flags().%s) {\n" %
9899 item
['extension_flag'])
9901 expect_value
= item
['default']
9902 if isinstance(expect_value
, list):
9903 # TODO: Currently we do not check array values.
9907 " EXPECT_CALL(*gl_, %s(%s, %s))\n" %
9910 if 'enum_set' in item
else item
['enum']),
9912 file.Write(" .Times(1)\n")
9913 file.Write(" .RetiresOnSaturation();\n")
9914 if 'extension_flag' in item
:
9917 if 'extension_flag' in state
:
9918 file.Write(" if (group_->feature_info()->feature_flags().%s) {\n" %
9919 state
['extension_flag'])
9922 for item
in state
['states']:
9923 if 'expected' in item
:
9924 args
.append(item
['expected'])
9926 args
.append(item
['default'])
9927 # TODO: Currently we do not check array values.
9928 args
= ["_" if isinstance(arg
, list) else arg
for arg
in args
]
9929 file.Write(" EXPECT_CALL(*gl_, %s(%s))\n" %
9930 (state
['func'], ", ".join(args
)))
9931 file.Write(" .Times(1)\n")
9932 file.Write(" .RetiresOnSaturation();\n")
9933 if 'extension_flag' in state
:
9938 self
.generated_cpp_filenames
.append(file.filename
)
9940 def WriteServiceUnitTestsForExtensions(self
, filename
):
9941 """Writes the service decorder unit tests for functions with extension_flag.
9943 The functions are special in that they need a specific unit test
9944 baseclass to turn on the extension.
9946 functions
= [f
for f
in self
.functions
if f
.GetInfo('extension_flag')]
9947 file = CHeaderWriter(
9949 "// It is included by gles2_cmd_decoder_unittest_extensions.cc\n")
9950 for func
in functions
:
9952 if func
.GetInfo('unit_test') == False:
9953 file.Write("// TODO(gman): %s\n" % func
.name
)
9955 extension
= ToCamelCase(
9956 ToGLExtensionString(func
.GetInfo('extension_flag')))
9957 func
.WriteServiceUnitTest(file, {
9958 'test_name': 'GLES2DecoderTestWith%s' % extension
9962 self
.generated_cpp_filenames
.append(file.filename
)
9964 def WriteGLES2Header(self
, filename
):
9965 """Writes the GLES2 header."""
9966 file = CHeaderWriter(
9968 "// This file contains Chromium-specific GLES2 declarations.\n\n")
9970 for func
in self
.original_functions
:
9971 func
.WriteGLES2Header(file)
9975 self
.generated_cpp_filenames
.append(file.filename
)
9977 def WriteGLES2CLibImplementation(self
, filename
):
9978 """Writes the GLES2 c lib implementation."""
9979 file = CHeaderWriter(
9981 "// These functions emulate GLES2 over command buffers.\n")
9983 for func
in self
.original_functions
:
9984 func
.WriteGLES2CLibImplementation(file)
9989 extern const NameToFunc g_gles2_function_table[] = {
9991 for func
in self
.original_functions
:
9993 ' { "gl%s", reinterpret_cast<GLES2FunctionPointer>(gl%s), },\n' %
9994 (func
.name
, func
.name
))
9995 file.Write(""" { NULL, NULL, },
9998 } // namespace gles2
10001 self
.generated_cpp_filenames
.append(file.filename
)
10003 def WriteGLES2InterfaceHeader(self
, filename
):
10004 """Writes the GLES2 interface header."""
10005 file = CHeaderWriter(
10007 "// This file is included by gles2_interface.h to declare the\n"
10008 "// GL api functions.\n")
10009 for func
in self
.original_functions
:
10010 func
.WriteGLES2InterfaceHeader(file)
10012 self
.generated_cpp_filenames
.append(file.filename
)
10014 def WriteMojoGLES2ImplHeader(self
, filename
):
10015 """Writes the Mojo GLES2 implementation header."""
10016 file = CHeaderWriter(
10018 "// This file is included by gles2_interface.h to declare the\n"
10019 "// GL api functions.\n")
10022 #include "gpu/command_buffer/client/gles2_interface.h"
10023 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h"
10027 class MojoGLES2Impl : public gpu::gles2::GLES2Interface {
10029 explicit MojoGLES2Impl(MojoGLES2Context context) {
10030 context_ = context;
10032 ~MojoGLES2Impl() override {}
10035 for func
in self
.original_functions
:
10036 func
.WriteMojoGLES2ImplHeader(file)
10039 MojoGLES2Context context_;
10042 } // namespace mojo
10046 self
.generated_cpp_filenames
.append(file.filename
)
10048 def WriteMojoGLES2Impl(self
, filename
):
10049 """Writes the Mojo GLES2 implementation."""
10050 file = CWriter(filename
)
10051 file.Write(_LICENSE
)
10052 file.Write(_DO_NOT_EDIT_WARNING
)
10055 #include "mojo/gpu/mojo_gles2_impl_autogen.h"
10057 #include "base/logging.h"
10058 #include "third_party/mojo/src/mojo/public/c/gles2/chromium_miscellaneous.h"
10059 #include "third_party/mojo/src/mojo/public/c/gles2/chromium_sub_image.h"
10060 #include "third_party/mojo/src/mojo/public/c/gles2/chromium_sync_point.h"
10061 #include "third_party/mojo/src/mojo/public/c/gles2/chromium_texture_mailbox.h"
10062 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h"
10063 #include "third_party/mojo/src/mojo/public/c/gles2/occlusion_query_ext.h"
10069 for func
in self
.original_functions
:
10070 func
.WriteMojoGLES2Impl(file)
10073 } // namespace mojo
10077 self
.generated_cpp_filenames
.append(file.filename
)
10079 def WriteGLES2InterfaceStub(self
, filename
):
10080 """Writes the GLES2 interface stub header."""
10081 file = CHeaderWriter(
10083 "// This file is included by gles2_interface_stub.h.\n")
10084 for func
in self
.original_functions
:
10085 func
.WriteGLES2InterfaceStub(file)
10087 self
.generated_cpp_filenames
.append(file.filename
)
10089 def WriteGLES2InterfaceStubImpl(self
, filename
):
10090 """Writes the GLES2 interface header."""
10091 file = CHeaderWriter(
10093 "// This file is included by gles2_interface_stub.cc.\n")
10094 for func
in self
.original_functions
:
10095 func
.WriteGLES2InterfaceStubImpl(file)
10097 self
.generated_cpp_filenames
.append(file.filename
)
10099 def WriteGLES2ImplementationHeader(self
, filename
):
10100 """Writes the GLES2 Implementation header."""
10101 file = CHeaderWriter(
10103 "// This file is included by gles2_implementation.h to declare the\n"
10104 "// GL api functions.\n")
10105 for func
in self
.original_functions
:
10106 func
.WriteGLES2ImplementationHeader(file)
10108 self
.generated_cpp_filenames
.append(file.filename
)
10110 def WriteGLES2Implementation(self
, filename
):
10111 """Writes the GLES2 Implementation."""
10112 file = CHeaderWriter(
10114 "// This file is included by gles2_implementation.cc to define the\n"
10115 "// GL api functions.\n")
10116 for func
in self
.original_functions
:
10117 func
.WriteGLES2Implementation(file)
10119 self
.generated_cpp_filenames
.append(file.filename
)
10121 def WriteGLES2TraceImplementationHeader(self
, filename
):
10122 """Writes the GLES2 Trace Implementation header."""
10123 file = CHeaderWriter(
10125 "// This file is included by gles2_trace_implementation.h\n")
10126 for func
in self
.original_functions
:
10127 func
.WriteGLES2TraceImplementationHeader(file)
10129 self
.generated_cpp_filenames
.append(file.filename
)
10131 def WriteGLES2TraceImplementation(self
, filename
):
10132 """Writes the GLES2 Trace Implementation."""
10133 file = CHeaderWriter(
10135 "// This file is included by gles2_trace_implementation.cc\n")
10136 for func
in self
.original_functions
:
10137 func
.WriteGLES2TraceImplementation(file)
10139 self
.generated_cpp_filenames
.append(file.filename
)
10141 def WriteGLES2ImplementationUnitTests(self
, filename
):
10142 """Writes the GLES2 helper header."""
10143 file = CHeaderWriter(
10145 "// This file is included by gles2_implementation.h to declare the\n"
10146 "// GL api functions.\n")
10147 for func
in self
.original_functions
:
10148 func
.WriteGLES2ImplementationUnitTest(file)
10150 self
.generated_cpp_filenames
.append(file.filename
)
10152 def WriteServiceUtilsHeader(self
, filename
):
10153 """Writes the gles2 auto generated utility header."""
10154 file = CHeaderWriter(filename
)
10155 for name
in sorted(_NAMED_TYPE_INFO
.keys()):
10156 named_type
= NamedType(_NAMED_TYPE_INFO
[name
])
10157 if named_type
.IsConstant():
10159 file.Write("ValueValidator<%s> %s;\n" %
10160 (named_type
.GetType(), ToUnderscore(name
)))
10163 self
.generated_cpp_filenames
.append(file.filename
)
10165 def WriteServiceUtilsImplementation(self
, filename
):
10166 """Writes the gles2 auto generated utility implementation."""
10167 file = CHeaderWriter(filename
)
10168 names
= sorted(_NAMED_TYPE_INFO
.keys())
10170 named_type
= NamedType(_NAMED_TYPE_INFO
[name
])
10171 if named_type
.IsConstant():
10173 if named_type
.GetValidValues():
10174 file.Write("static const %s valid_%s_table[] = {\n" %
10175 (named_type
.GetType(), ToUnderscore(name
)))
10176 for value
in named_type
.GetValidValues():
10177 file.Write(" %s,\n" % value
)
10180 if named_type
.GetValidValuesES3():
10181 file.Write("static const %s valid_%s_table_es3[] = {\n" %
10182 (named_type
.GetType(), ToUnderscore(name
)))
10183 for value
in named_type
.GetValidValuesES3():
10184 file.Write(" %s,\n" % value
)
10187 if named_type
.GetDeprecatedValuesES3():
10188 file.Write("static const %s deprecated_%s_table_es3[] = {\n" %
10189 (named_type
.GetType(), ToUnderscore(name
)))
10190 for value
in named_type
.GetDeprecatedValuesES3():
10191 file.Write(" %s,\n" % value
)
10194 file.Write("Validators::Validators()")
10196 for count
, name
in enumerate(names
):
10197 named_type
= NamedType(_NAMED_TYPE_INFO
[name
])
10198 if named_type
.IsConstant():
10200 if named_type
.GetValidValues():
10201 code
= """%(pre)s%(name)s(
10202 valid_%(name)s_table, arraysize(valid_%(name)s_table))"""
10204 code
= "%(pre)s%(name)s()"
10205 file.Write(code
% {
10206 'name': ToUnderscore(name
),
10210 file.Write(" {\n");
10211 file.Write("}\n\n");
10213 file.Write("void Validators::UpdateValuesES3() {\n")
10215 named_type
= NamedType(_NAMED_TYPE_INFO
[name
])
10216 if named_type
.GetDeprecatedValuesES3():
10217 code
= """ %(name)s.RemoveValues(
10218 deprecated_%(name)s_table_es3, arraysize(deprecated_%(name)s_table_es3));
10220 file.Write(code
% {
10221 'name': ToUnderscore(name
),
10223 if named_type
.GetValidValuesES3():
10224 code
= """ %(name)s.AddValues(
10225 valid_%(name)s_table_es3, arraysize(valid_%(name)s_table_es3));
10227 file.Write(code
% {
10228 'name': ToUnderscore(name
),
10230 file.Write("}\n\n");
10232 self
.generated_cpp_filenames
.append(file.filename
)
10234 def WriteCommonUtilsHeader(self
, filename
):
10235 """Writes the gles2 common utility header."""
10236 file = CHeaderWriter(filename
)
10237 type_infos
= sorted(_NAMED_TYPE_INFO
.keys())
10238 for type_info
in type_infos
:
10239 if _NAMED_TYPE_INFO
[type_info
]['type'] == 'GLenum':
10240 file.Write("static std::string GetString%s(uint32_t value);\n" %
10244 self
.generated_cpp_filenames
.append(file.filename
)
10246 def WriteCommonUtilsImpl(self
, filename
):
10247 """Writes the gles2 common utility header."""
10248 enum_re
= re
.compile(r
'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)')
10250 for fname
in ['third_party/khronos/GLES2/gl2.h',
10251 'third_party/khronos/GLES2/gl2ext.h',
10252 'third_party/khronos/GLES3/gl3.h',
10253 'gpu/GLES2/gl2chromium.h',
10254 'gpu/GLES2/gl2extchromium.h']:
10255 lines
= open(fname
).readlines()
10257 m
= enum_re
.match(line
)
10261 if len(value
) <= 10:
10262 if not value
in dict:
10264 # check our own _CHROMIUM macro conflicts with khronos GL headers.
10265 elif dict[value
] != name
and (name
.endswith('_CHROMIUM') or
10266 dict[value
].endswith('_CHROMIUM')):
10267 self
.Error("code collision: %s and %s have the same code %s" %
10268 (dict[value
], name
, value
))
10270 file = CHeaderWriter(filename
)
10271 file.Write("static const GLES2Util::EnumToString "
10272 "enum_to_string_table[] = {\n")
10274 file.Write(' { %s, "%s", },\n' % (value
, dict[value
]))
10277 const GLES2Util::EnumToString* const GLES2Util::enum_to_string_table_ =
10278 enum_to_string_table;
10279 const size_t GLES2Util::enum_to_string_table_len_ =
10280 sizeof(enum_to_string_table) / sizeof(enum_to_string_table[0]);
10284 enums
= sorted(_NAMED_TYPE_INFO
.keys())
10286 if _NAMED_TYPE_INFO
[enum
]['type'] == 'GLenum':
10287 file.Write("std::string GLES2Util::GetString%s(uint32_t value) {\n" %
10289 valid_list
= _NAMED_TYPE_INFO
[enum
]['valid']
10290 if 'valid_es3' in _NAMED_TYPE_INFO
[enum
]:
10291 valid_list
= valid_list
+ _NAMED_TYPE_INFO
[enum
]['valid_es3']
10292 assert len(valid_list
) == len(set(valid_list
))
10293 if len(valid_list
) > 0:
10294 file.Write(" static const EnumToString string_table[] = {\n")
10295 for value
in valid_list
:
10296 file.Write(' { %s, "%s" },\n' % (value
, value
))
10298 return GLES2Util::GetQualifiedEnumString(
10299 string_table, arraysize(string_table), value);
10304 file.Write(""" return GLES2Util::GetQualifiedEnumString(
10310 self
.generated_cpp_filenames
.append(file.filename
)
10312 def WritePepperGLES2Interface(self
, filename
, dev
):
10313 """Writes the Pepper OpenGLES interface definition."""
10314 file = CWriter(filename
)
10315 file.Write(_LICENSE
)
10316 file.Write(_DO_NOT_EDIT_WARNING
)
10318 file.Write("label Chrome {\n")
10319 file.Write(" M39 = 1.0\n")
10320 file.Write("};\n\n")
10323 # Declare GL types.
10324 file.Write("[version=1.0]\n")
10325 file.Write("describe {\n")
10326 for gltype
in ['GLbitfield', 'GLboolean', 'GLbyte', 'GLclampf',
10327 'GLclampx', 'GLenum', 'GLfixed', 'GLfloat', 'GLint',
10328 'GLintptr', 'GLshort', 'GLsizei', 'GLsizeiptr',
10329 'GLubyte', 'GLuint', 'GLushort']:
10330 file.Write(" %s;\n" % gltype
)
10331 file.Write(" %s_ptr_t;\n" % gltype
)
10332 file.Write("};\n\n")
10334 # C level typedefs.
10335 file.Write("#inline c\n")
10336 file.Write("#include \"ppapi/c/pp_resource.h\"\n")
10338 file.Write("#include \"ppapi/c/ppb_opengles2.h\"\n\n")
10340 file.Write("\n#ifndef __gl2_h_\n")
10341 for (k
, v
) in _GL_TYPES
.iteritems():
10342 file.Write("typedef %s %s;\n" % (v
, k
))
10343 file.Write("#ifdef _WIN64\n")
10344 for (k
, v
) in _GL_TYPES_64
.iteritems():
10345 file.Write("typedef %s %s;\n" % (v
, k
))
10346 file.Write("#else\n")
10347 for (k
, v
) in _GL_TYPES_32
.iteritems():
10348 file.Write("typedef %s %s;\n" % (v
, k
))
10349 file.Write("#endif // _WIN64\n")
10350 file.Write("#endif // __gl2_h_\n\n")
10351 file.Write("#endinl\n")
10353 for interface
in self
.pepper_interfaces
:
10354 if interface
.dev
!= dev
:
10356 # Historically, we provide OpenGLES2 interfaces with struct
10357 # namespace. Not to break code which uses the interface as
10358 # "struct OpenGLES2", we put it in struct namespace.
10359 file.Write('\n[macro="%s", force_struct_namespace]\n' %
10360 interface
.GetInterfaceName())
10361 file.Write("interface %s {\n" % interface
.GetStructName())
10362 for func
in self
.original_functions
:
10363 if not func
.InPepperInterface(interface
):
10366 ret_type
= func
.MapCTypeToPepperIdlType(func
.return_type
,
10367 is_for_return_type
=True)
10368 func_prefix
= " %s %s(" % (ret_type
, func
.GetPepperName())
10369 file.Write(func_prefix
)
10370 file.Write("[in] PP_Resource context")
10371 for arg
in func
.MakeTypedPepperIdlArgStrings():
10372 file.Write(",\n" + " " * len(func_prefix
) + arg
)
10374 file.Write("};\n\n")
10379 def WritePepperGLES2Implementation(self
, filename
):
10380 """Writes the Pepper OpenGLES interface implementation."""
10382 file = CWriter(filename
)
10383 file.Write(_LICENSE
)
10384 file.Write(_DO_NOT_EDIT_WARNING
)
10386 file.Write("#include \"ppapi/shared_impl/ppb_opengles2_shared.h\"\n\n")
10387 file.Write("#include \"base/logging.h\"\n")
10388 file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n")
10389 file.Write("#include \"ppapi/shared_impl/ppb_graphics_3d_shared.h\"\n")
10390 file.Write("#include \"ppapi/thunk/enter.h\"\n\n")
10392 file.Write("namespace ppapi {\n\n")
10393 file.Write("namespace {\n\n")
10395 file.Write("typedef thunk::EnterResource<thunk::PPB_Graphics3D_API>"
10398 file.Write("gpu::gles2::GLES2Implementation* ToGles2Impl(Enter3D*"
10400 file.Write(" DCHECK(enter);\n")
10401 file.Write(" DCHECK(enter->succeeded());\n")
10402 file.Write(" return static_cast<PPB_Graphics3D_Shared*>(enter->object())->"
10403 "gles2_impl();\n");
10404 file.Write("}\n\n");
10406 for func
in self
.original_functions
:
10407 if not func
.InAnyPepperExtension():
10410 original_arg
= func
.MakeTypedPepperArgString("")
10411 context_arg
= "PP_Resource context_id"
10412 if len(original_arg
):
10413 arg
= context_arg
+ ", " + original_arg
10416 file.Write("%s %s(%s) {\n" %
10417 (func
.return_type
, func
.GetPepperName(), arg
))
10418 file.Write(" Enter3D enter(context_id, true);\n")
10419 file.Write(" if (enter.succeeded()) {\n")
10421 return_str
= "" if func
.return_type
== "void" else "return "
10422 file.Write(" %sToGles2Impl(&enter)->%s(%s);\n" %
10423 (return_str
, func
.original_name
,
10424 func
.MakeOriginalArgString("")))
10426 if func
.return_type
== "void":
10429 file.Write(" else {\n")
10430 file.Write(" return %s;\n" % func
.GetErrorReturnString())
10432 file.Write("}\n\n")
10434 file.Write("} // namespace\n")
10436 for interface
in self
.pepper_interfaces
:
10437 file.Write("const %s* PPB_OpenGLES2_Shared::Get%sInterface() {\n" %
10438 (interface
.GetStructName(), interface
.GetName()))
10439 file.Write(" static const struct %s "
10440 "ppb_opengles2 = {\n" % interface
.GetStructName())
10442 file.Write(",\n &".join(
10443 f
.GetPepperName() for f
in self
.original_functions
10444 if f
.InPepperInterface(interface
)))
10447 file.Write(" };\n")
10448 file.Write(" return &ppb_opengles2;\n")
10451 file.Write("} // namespace ppapi\n")
10453 self
.generated_cpp_filenames
.append(file.filename
)
10455 def WriteGLES2ToPPAPIBridge(self
, filename
):
10456 """Connects GLES2 helper library to PPB_OpenGLES2 interface"""
10458 file = CWriter(filename
)
10459 file.Write(_LICENSE
)
10460 file.Write(_DO_NOT_EDIT_WARNING
)
10462 file.Write("#ifndef GL_GLEXT_PROTOTYPES\n")
10463 file.Write("#define GL_GLEXT_PROTOTYPES\n")
10464 file.Write("#endif\n")
10465 file.Write("#include <GLES2/gl2.h>\n")
10466 file.Write("#include <GLES2/gl2ext.h>\n")
10467 file.Write("#include \"ppapi/lib/gl/gles2/gl2ext_ppapi.h\"\n\n")
10469 for func
in self
.original_functions
:
10470 if not func
.InAnyPepperExtension():
10473 interface
= self
.interface_info
[func
.GetInfo('pepper_interface') or '']
10475 file.Write("%s GL_APIENTRY gl%s(%s) {\n" %
10476 (func
.return_type
, func
.GetPepperName(),
10477 func
.MakeTypedPepperArgString("")))
10478 return_str
= "" if func
.return_type
== "void" else "return "
10479 interface_str
= "glGet%sInterfacePPAPI()" % interface
.GetName()
10480 original_arg
= func
.MakeOriginalArgString("")
10481 context_arg
= "glGetCurrentContextPPAPI()"
10482 if len(original_arg
):
10483 arg
= context_arg
+ ", " + original_arg
10486 if interface
.GetName():
10487 file.Write(" const struct %s* ext = %s;\n" %
10488 (interface
.GetStructName(), interface_str
))
10489 file.Write(" if (ext)\n")
10490 file.Write(" %sext->%s(%s);\n" %
10491 (return_str
, func
.GetPepperName(), arg
))
10493 file.Write(" %s0;\n" % return_str
)
10495 file.Write(" %s%s->%s(%s);\n" %
10496 (return_str
, interface_str
, func
.GetPepperName(), arg
))
10497 file.Write("}\n\n")
10499 self
.generated_cpp_filenames
.append(file.filename
)
10501 def WriteMojoGLCallVisitor(self
, filename
):
10502 """Provides the GL implementation for mojo"""
10503 file = CWriter(filename
)
10504 file.Write(_LICENSE
)
10505 file.Write(_DO_NOT_EDIT_WARNING
)
10507 for func
in self
.original_functions
:
10508 if not func
.IsCoreGLFunction():
10510 file.Write("VISIT_GL_CALL(%s, %s, (%s), (%s))\n" %
10511 (func
.name
, func
.return_type
,
10512 func
.MakeTypedOriginalArgString(""),
10513 func
.MakeOriginalArgString("")))
10516 self
.generated_cpp_filenames
.append(file.filename
)
10518 def WriteMojoGLCallVisitorForExtension(self
, filename
, extension
):
10519 """Provides the GL implementation for mojo for a particular extension"""
10520 file = CWriter(filename
)
10521 file.Write(_LICENSE
)
10522 file.Write(_DO_NOT_EDIT_WARNING
)
10524 for func
in self
.original_functions
:
10525 if func
.GetInfo("extension") != extension
:
10527 file.Write("VISIT_GL_CALL(%s, %s, (%s), (%s))\n" %
10528 (func
.name
, func
.return_type
,
10529 func
.MakeTypedOriginalArgString(""),
10530 func
.MakeOriginalArgString("")))
10533 self
.generated_cpp_filenames
.append(file.filename
)
10535 def Format(generated_files
):
10536 formatter
= "clang-format"
10537 if platform
.system() == "Windows":
10538 formatter
+= ".bat"
10539 for filename
in generated_files
:
10540 call([formatter
, "-i", "-style=chromium", filename
])
10543 """This is the main function."""
10544 parser
= OptionParser()
10547 help="base directory for resulting files, under chrome/src. default is "
10548 "empty. Use this if you want the result stored under gen.")
10550 "-v", "--verbose", action
="store_true",
10551 help="prints more output.")
10553 (options
, args
) = parser
.parse_args(args
=argv
)
10555 # Add in states and capabilites to GLState
10556 gl_state_valid
= _NAMED_TYPE_INFO
['GLState']['valid']
10557 for state_name
in sorted(_STATES
.keys()):
10558 state
= _STATES
[state_name
]
10559 if 'extension_flag' in state
:
10561 if 'enum' in state
:
10562 if not state
['enum'] in gl_state_valid
:
10563 gl_state_valid
.append(state
['enum'])
10565 for item
in state
['states']:
10566 if 'extension_flag' in item
:
10568 if not item
['enum'] in gl_state_valid
:
10569 gl_state_valid
.append(item
['enum'])
10570 for capability
in _CAPABILITY_FLAGS
:
10571 valid_value
= "GL_%s" % capability
['name'].upper()
10572 if not valid_value
in gl_state_valid
:
10573 gl_state_valid
.append(valid_value
)
10575 # This script lives under gpu/command_buffer, cd to base directory.
10576 os
.chdir(os
.path
.dirname(__file__
) + "/../..")
10577 base_dir
= os
.getcwd()
10578 gen
= GLGenerator(options
.verbose
)
10579 gen
.ParseGLH("gpu/command_buffer/cmd_buffer_functions.txt")
10581 # Support generating files under gen/
10582 if options
.output_dir
!= None:
10583 os
.chdir(options
.output_dir
)
10585 gen
.WritePepperGLES2Interface("ppapi/api/ppb_opengles2.idl", False)
10586 gen
.WritePepperGLES2Interface("ppapi/api/dev/ppb_opengles2ext_dev.idl", True)
10587 gen
.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c")
10588 gen
.WritePepperGLES2Implementation(
10589 "ppapi/shared_impl/ppb_opengles2_shared.cc")
10591 gen
.WriteCommandIds("gpu/command_buffer/common/gles2_cmd_ids_autogen.h")
10592 gen
.WriteFormat("gpu/command_buffer/common/gles2_cmd_format_autogen.h")
10593 gen
.WriteFormatTest(
10594 "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h")
10595 gen
.WriteGLES2InterfaceHeader(
10596 "gpu/command_buffer/client/gles2_interface_autogen.h")
10597 gen
.WriteMojoGLES2ImplHeader(
10598 "mojo/gpu/mojo_gles2_impl_autogen.h")
10599 gen
.WriteMojoGLES2Impl(
10600 "mojo/gpu/mojo_gles2_impl_autogen.cc")
10601 gen
.WriteGLES2InterfaceStub(
10602 "gpu/command_buffer/client/gles2_interface_stub_autogen.h")
10603 gen
.WriteGLES2InterfaceStubImpl(
10604 "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h")
10605 gen
.WriteGLES2ImplementationHeader(
10606 "gpu/command_buffer/client/gles2_implementation_autogen.h")
10607 gen
.WriteGLES2Implementation(
10608 "gpu/command_buffer/client/gles2_implementation_impl_autogen.h")
10609 gen
.WriteGLES2ImplementationUnitTests(
10610 "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h")
10611 gen
.WriteGLES2TraceImplementationHeader(
10612 "gpu/command_buffer/client/gles2_trace_implementation_autogen.h")
10613 gen
.WriteGLES2TraceImplementation(
10614 "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h")
10615 gen
.WriteGLES2CLibImplementation(
10616 "gpu/command_buffer/client/gles2_c_lib_autogen.h")
10617 gen
.WriteCmdHelperHeader(
10618 "gpu/command_buffer/client/gles2_cmd_helper_autogen.h")
10619 gen
.WriteServiceImplementation(
10620 "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h")
10621 gen
.WriteServiceContextStateHeader(
10622 "gpu/command_buffer/service/context_state_autogen.h")
10623 gen
.WriteServiceContextStateImpl(
10624 "gpu/command_buffer/service/context_state_impl_autogen.h")
10625 gen
.WriteClientContextStateHeader(
10626 "gpu/command_buffer/client/client_context_state_autogen.h")
10627 gen
.WriteClientContextStateImpl(
10628 "gpu/command_buffer/client/client_context_state_impl_autogen.h")
10629 gen
.WriteServiceUnitTests(
10630 "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h")
10631 gen
.WriteServiceUnitTestsForExtensions(
10632 "gpu/command_buffer/service/"
10633 "gles2_cmd_decoder_unittest_extensions_autogen.h")
10634 gen
.WriteServiceUtilsHeader(
10635 "gpu/command_buffer/service/gles2_cmd_validation_autogen.h")
10636 gen
.WriteServiceUtilsImplementation(
10637 "gpu/command_buffer/service/"
10638 "gles2_cmd_validation_implementation_autogen.h")
10639 gen
.WriteCommonUtilsHeader(
10640 "gpu/command_buffer/common/gles2_cmd_utils_autogen.h")
10641 gen
.WriteCommonUtilsImpl(
10642 "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h")
10643 gen
.WriteGLES2Header("gpu/GLES2/gl2chromium_autogen.h")
10644 mojo_gles2_prefix
= ("third_party/mojo/src/mojo/public/c/gles2/"
10645 "gles2_call_visitor")
10646 gen
.WriteMojoGLCallVisitor(mojo_gles2_prefix
+ "_autogen.h")
10647 gen
.WriteMojoGLCallVisitorForExtension(
10648 mojo_gles2_prefix
+ "_chromium_texture_mailbox_autogen.h",
10649 "CHROMIUM_texture_mailbox")
10650 gen
.WriteMojoGLCallVisitorForExtension(
10651 mojo_gles2_prefix
+ "_chromium_sync_point_autogen.h",
10652 "CHROMIUM_sync_point")
10653 gen
.WriteMojoGLCallVisitorForExtension(
10654 mojo_gles2_prefix
+ "_chromium_sub_image_autogen.h",
10655 "CHROMIUM_sub_image")
10656 gen
.WriteMojoGLCallVisitorForExtension(
10657 mojo_gles2_prefix
+ "_chromium_miscellaneous_autogen.h",
10658 "CHROMIUM_miscellaneous")
10659 gen
.WriteMojoGLCallVisitorForExtension(
10660 mojo_gles2_prefix
+ "_occlusion_query_ext_autogen.h",
10661 "occlusion_query_EXT")
10663 Format(gen
.generated_cpp_filenames
)
10666 print "%d errors" % gen
.errors
10671 if __name__
== '__main__':
10672 sys
.exit(main(sys
.argv
[1:]))