OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """code generator for GLES2 command buffers.""" | 6 """code generator for GLES2 command buffers.""" |
7 | 7 |
| 8 import itertools |
8 import os | 9 import os |
9 import os.path | 10 import os.path |
10 import sys | 11 import sys |
11 import re | 12 import re |
12 from optparse import OptionParser | 13 from optparse import OptionParser |
13 | 14 |
14 _SIZE_OF_UINT32 = 4 | 15 _SIZE_OF_UINT32 = 4 |
15 _SIZE_OF_COMMAND_HEADER = 4 | 16 _SIZE_OF_COMMAND_HEADER = 4 |
16 _FIRST_SPECIFIC_COMMAND_ID = 256 | 17 _FIRST_SPECIFIC_COMMAND_ID = 256 |
17 | 18 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 'GLuint': 'unsigned int', | 51 'GLuint': 'unsigned int', |
51 'GLfloat': 'float', | 52 'GLfloat': 'float', |
52 'GLclampf': 'float', | 53 'GLclampf': 'float', |
53 'GLvoid': 'void', | 54 'GLvoid': 'void', |
54 'GLfixed': 'int', | 55 'GLfixed': 'int', |
55 'GLclampx': 'int', | 56 'GLclampx': 'int', |
56 'GLintptr': 'long int', | 57 'GLintptr': 'long int', |
57 'GLsizeiptr': 'long int', | 58 'GLsizeiptr': 'long int', |
58 } | 59 } |
59 | 60 |
| 61 # Capabilites selected with glEnable |
| 62 _CAPABILITY_FLAGS = [ |
| 63 {'name': 'blend'}, |
| 64 {'name': 'cull_face'}, |
| 65 {'name': 'depth_test', 'state_flag': 'clear_state_dirty_'}, |
| 66 {'name': 'dither', 'default': True}, |
| 67 {'name': 'polygon_offset_fill'}, |
| 68 {'name': 'sample_alpha_to_coverage'}, |
| 69 {'name': 'sample_coverage'}, |
| 70 {'name': 'scissor_test'}, |
| 71 {'name': 'stencil_test', 'state_flag': 'clear_state_dirty_'}, |
| 72 ] |
| 73 |
| 74 _STATES = { |
| 75 'ClearColor': { |
| 76 'type': 'Normal', |
| 77 'func': 'ClearColor', |
| 78 'enum': 'GL_COLOR_CLEAR_VALUE', |
| 79 'states': [ |
| 80 {'name': 'color_clear_red', 'type': 'GLfloat', 'default': '0.0f'}, |
| 81 {'name': 'color_clear_green', 'type': 'GLfloat', 'default': '0.0f'}, |
| 82 {'name': 'color_clear_blue', 'type': 'GLfloat', 'default': '0.0f'}, |
| 83 {'name': 'color_clear_alpha', 'type': 'GLfloat', 'default': '0.0f'}, |
| 84 ], |
| 85 }, |
| 86 'ClearDepthf': { |
| 87 'type': 'Normal', |
| 88 'func': 'ClearDepth', |
| 89 'enum': 'GL_DEPTH_CLEAR_VALUE', |
| 90 'states': [ |
| 91 {'name': 'depth_clear', 'type': 'GLclampf', 'default': '1.0f'}, |
| 92 ], |
| 93 }, |
| 94 'ColorMask': { |
| 95 'type': 'Normal', |
| 96 'func': 'ColorMask', |
| 97 'enum': 'GL_COLOR_WRITEMASK', |
| 98 'states': [ |
| 99 {'name': 'color_mask_red', 'type': 'GLboolean', 'default': 'true'}, |
| 100 {'name': 'color_mask_green', 'type': 'GLboolean', 'default': 'true'}, |
| 101 {'name': 'color_mask_blue', 'type': 'GLboolean', 'default': 'true'}, |
| 102 {'name': 'color_mask_alpha', 'type': 'GLboolean', 'default': 'true'}, |
| 103 ], |
| 104 'state_flag': 'clear_state_dirty_', |
| 105 }, |
| 106 'ClearStencil': { |
| 107 'type': 'Normal', |
| 108 'func': 'ClearStencil', |
| 109 'enum': 'GL_STENCIL_CLEAR_VALUE', |
| 110 'states': [ |
| 111 {'name': 'stencil_clear', 'type': 'GLint', 'default': '0'}, |
| 112 ], |
| 113 }, |
| 114 'BlendColor': { |
| 115 'type': 'Normal', |
| 116 'func': 'BlendColor', |
| 117 'enum': 'GL_BLEND_COLOR', |
| 118 'states': [ |
| 119 {'name': 'blend_color_red', 'type': 'GLfloat', 'default': '0.0f'}, |
| 120 {'name': 'blend_color_green', 'type': 'GLfloat', 'default': '0.0f'}, |
| 121 {'name': 'blend_color_blue', 'type': 'GLfloat', 'default': '0.0f'}, |
| 122 {'name': 'blend_color_alpha', 'type': 'GLfloat', 'default': '0.0f'}, |
| 123 ], |
| 124 }, |
| 125 'BlendEquation': { |
| 126 'type': 'SrcDst', |
| 127 'func': 'BlendEquationSeparate', |
| 128 'states': [ |
| 129 { |
| 130 'name': 'blend_equation_rgb', |
| 131 'type': 'GLenum', |
| 132 'enum': 'GL_BLEND_EQUATION_RGB', |
| 133 'default': 'GL_FUNC_ADD', |
| 134 }, |
| 135 { |
| 136 'name': 'blend_equation_alpha', |
| 137 'type': 'GLenum', |
| 138 'enum': 'GL_BLEND_EQUATION_ALPHA', |
| 139 'default': 'GL_FUNC_ADD', |
| 140 }, |
| 141 ], |
| 142 }, |
| 143 'BlendFunc': { |
| 144 'type': 'SrcDst', |
| 145 'func': 'BlendFuncSeparate', |
| 146 'states': [ |
| 147 { |
| 148 'name': 'blend_source_rgb', |
| 149 'type': 'GLenum', |
| 150 'enum': 'GL_BLEND_SRC_RGB', |
| 151 'default': 'GL_ONE', |
| 152 }, |
| 153 { |
| 154 'name': 'blend_dest_rgb', |
| 155 'type': 'GLenum', |
| 156 'enum': 'GL_BLEND_DST_RGB', |
| 157 'default': 'GL_ZERO', |
| 158 }, |
| 159 { |
| 160 'name': 'blend_source_alpha', |
| 161 'type': 'GLenum', |
| 162 'enum': 'GL_BLEND_SRC_ALPHA', |
| 163 'default': 'GL_ONE', |
| 164 }, |
| 165 { |
| 166 'name': 'blend_dest_alpha', |
| 167 'type': 'GLenum', |
| 168 'enum': 'GL_BLEND_DST_ALPHA', |
| 169 'default': 'GL_ZERO', |
| 170 }, |
| 171 ], |
| 172 }, |
| 173 'PolygonOffset': { |
| 174 'type': 'Normal', |
| 175 'func': 'PolygonOffset', |
| 176 'states': [ |
| 177 { |
| 178 'name': 'polygon_offset_factor', |
| 179 'type': 'GLfloat', |
| 180 'enum': 'GL_POLYGON_OFFSET_FACTOR', |
| 181 'default': '0.0f', |
| 182 }, |
| 183 { |
| 184 'name': 'polygon_offset_units', |
| 185 'type': 'GLfloat', |
| 186 'enum': 'GL_POLYGON_OFFSET_UNITS', |
| 187 'default': '0.0f', |
| 188 }, |
| 189 ], |
| 190 }, |
| 191 'CullFace': { |
| 192 'type': 'Normal', |
| 193 'func': 'CullFace', |
| 194 'enum': 'GL_CULL_FACE_MODE', |
| 195 'states': [ |
| 196 { |
| 197 'name': 'cull_mode', |
| 198 'type': 'GLenum', |
| 199 'default': 'GL_BACK', |
| 200 }, |
| 201 ], |
| 202 }, |
| 203 'FrontFace': { |
| 204 'type': 'Normal', |
| 205 'func': 'FrontFace', |
| 206 'enum': 'GL_FRONT_FACE', |
| 207 'states': [{'name': 'front_face', 'type': 'GLenum', 'default': 'GL_CCW'}], |
| 208 }, |
| 209 'DepthFunc': { |
| 210 'type': 'Normal', |
| 211 'func': 'DepthFunc', |
| 212 'enum': 'GL_DEPTH_FUNC', |
| 213 'states': [{'name': 'depth_func', 'type': 'GLenum', 'default': 'GL_LESS'}], |
| 214 }, |
| 215 'DepthRange': { |
| 216 'type': 'Normal', |
| 217 'func': 'DepthRange', |
| 218 'enum': 'GL_DEPTH_RANGE', |
| 219 'states': [ |
| 220 {'name': 'z_near', 'type': 'GLclampf', 'default': '0.0f'}, |
| 221 {'name': 'z_far', 'type': 'GLclampf', 'default': '1.0f'}, |
| 222 ], |
| 223 }, |
| 224 'SampleCoverage': { |
| 225 'type': 'Normal', |
| 226 'func': 'SampleCoverage', |
| 227 'states': [ |
| 228 { |
| 229 'name': 'sample_coverage_value', |
| 230 'type': 'GLclampf', |
| 231 'enum': 'GL_SAMPLE_COVERAGE_VALUE', |
| 232 'default': '0.0f', |
| 233 }, |
| 234 { |
| 235 'name': 'sample_coverage_invert', |
| 236 'type': 'GLboolean', |
| 237 'enum': 'GL_SAMPLE_COVERAGE_INVERT', |
| 238 'default': 'false', |
| 239 }, |
| 240 ], |
| 241 }, |
| 242 'StencilMask': { |
| 243 'type': 'FrontBack', |
| 244 'func': 'StencilMaskSeparate', |
| 245 'state_flag': 'clear_state_dirty_', |
| 246 'states': [ |
| 247 { |
| 248 'name': 'stencil_front_writemask', |
| 249 'type': 'GLuint', |
| 250 'enum': 'GL_STENCIL_WRITEMASK', |
| 251 'default': '0xFFFFFFFFU', |
| 252 }, |
| 253 { |
| 254 'name': 'stencil_back_writemask', |
| 255 'type': 'GLuint', |
| 256 'enum': 'GL_STENCIL_BACK_WRITEMASK', |
| 257 'default': '0xFFFFFFFFU', |
| 258 }, |
| 259 ], |
| 260 }, |
| 261 'StencilOp': { |
| 262 'type': 'FrontBack', |
| 263 'func': 'StencilOpSeparate', |
| 264 'states': [ |
| 265 { |
| 266 'name': 'stencil_front_fail_op', |
| 267 'type': 'GLenum', |
| 268 'enum': 'GL_STENCIL_FAIL', |
| 269 'default': 'GL_KEEP', |
| 270 }, |
| 271 { |
| 272 'name': 'stencil_front_z_fail_op', |
| 273 'type': 'GLenum', |
| 274 'enum': 'GL_STENCIL_PASS_DEPTH_FAIL', |
| 275 'default': 'GL_KEEP', |
| 276 }, |
| 277 { |
| 278 'name': 'stencil_front_z_pass_op', |
| 279 'type': 'GLenum', |
| 280 'enum': 'GL_STENCIL_PASS_DEPTH_PASS', |
| 281 'default': 'GL_KEEP', |
| 282 }, |
| 283 { |
| 284 'name': 'stencil_back_fail_op', |
| 285 'type': 'GLenum', |
| 286 'enum': 'GL_STENCIL_BACK_FAIL', |
| 287 'default': 'GL_KEEP', |
| 288 }, |
| 289 { |
| 290 'name': 'stencil_back_z_fail_op', |
| 291 'type': 'GLenum', |
| 292 'enum': 'GL_STENCIL_BACK_PASS_DEPTH_FAIL', |
| 293 'default': 'GL_KEEP', |
| 294 }, |
| 295 { |
| 296 'name': 'stencil_back_z_pass_op', |
| 297 'type': 'GLenum', |
| 298 'enum': 'GL_STENCIL_BACK_PASS_DEPTH_PASS', |
| 299 'default': 'GL_KEEP', |
| 300 }, |
| 301 ], |
| 302 }, |
| 303 'StencilFunc': { |
| 304 'type': 'FrontBack', |
| 305 'func': 'StencilFuncSeparate', |
| 306 'states': [ |
| 307 { |
| 308 'name': 'stencil_front_func', |
| 309 'type': 'GLenum', |
| 310 'enum': 'GL_STENCIL_FUNC', |
| 311 'default': 'GL_ALWAYS', |
| 312 }, |
| 313 { |
| 314 'name': 'stencil_front_ref', |
| 315 'type': 'GLint', |
| 316 'enum': 'GL_STENCIL_REF', |
| 317 'default': '0', |
| 318 }, |
| 319 { |
| 320 'name': 'stencil_front_mask', |
| 321 'type': 'GLuint', |
| 322 'enum': 'GL_STENCIL_VALUE_MASK', |
| 323 'default': '0xFFFFFFFFU', |
| 324 }, |
| 325 { |
| 326 'name': 'stencil_back_func', |
| 327 'type': 'GLenum', |
| 328 'enum': 'GL_STENCIL_BACK_FUNC', |
| 329 'default': 'GL_ALWAYS', |
| 330 }, |
| 331 { |
| 332 'name': 'stencil_back_ref', |
| 333 'type': 'GLint', |
| 334 'enum': 'GL_STENCIL_BACK_REF', |
| 335 'default': '0', |
| 336 }, |
| 337 { |
| 338 'name': 'stencil_back_mask', |
| 339 'type': 'GLuint', |
| 340 'enum': 'GL_STENCIL_BACK_VALUE_MASK', |
| 341 'default': '0xFFFFFFFFU', |
| 342 }, |
| 343 ], |
| 344 }, |
| 345 # TODO: Consider implemenenting these states |
| 346 # GL_GENERATE_MIPMAP_HINT |
| 347 # GL_ACTIVE_TEXTURE, |
| 348 # GL_PACK_ALIGNMENT, |
| 349 # GL_UNPACK_ALIGNMENT |
| 350 # GL_SAMPLE_BUFFERS, |
| 351 # GL_SAMPLES |
| 352 'LineWidth': { |
| 353 'type': 'Normal', |
| 354 'func': 'LineWidth', |
| 355 'enum': 'GL_LINE_WIDTH', |
| 356 'states': [{'name': 'line_width', 'type': 'GLfloat', 'default': '1.0f'}], |
| 357 }, |
| 358 'DepthMask': { |
| 359 'type': 'Normal', |
| 360 'func': 'DepthMask', |
| 361 'enum': 'GL_DEPTH_WRITEMASK', |
| 362 'states': [ |
| 363 {'name': 'depth_mask', 'type': 'GLboolean', 'default': 'true'}, |
| 364 ], |
| 365 'state_flag': 'clear_state_dirty_', |
| 366 }, |
| 367 'Scissor': { |
| 368 'type': 'Normal', |
| 369 'func': 'Scissor', |
| 370 'enum': 'GL_SCISSOR_BOX', |
| 371 'states': [ |
| 372 # NOTE: These defaults reset at GLES2DecoderImpl::Initialization. |
| 373 { |
| 374 'name': 'scissor_x', |
| 375 'type': 'GLfloat', |
| 376 'default': '0.0f', |
| 377 'expected': 'kViewportX', |
| 378 }, |
| 379 { |
| 380 'name': 'scissor_y', |
| 381 'type': 'GLfloat', |
| 382 'default': '0.0f', |
| 383 'expected': 'kViewportY', |
| 384 }, |
| 385 { |
| 386 'name': 'scissor_width', |
| 387 'type': 'GLfloat', |
| 388 'default': '1.0f', |
| 389 'expected': 'kViewportWidth', |
| 390 }, |
| 391 { |
| 392 'name': 'scissor_height', |
| 393 'type': 'GLfloat', |
| 394 'default': '1.0f', |
| 395 'expected': 'kViewportHeight', |
| 396 }, |
| 397 ], |
| 398 }, |
| 399 'Viewport': { |
| 400 'type': 'Normal', |
| 401 'func': 'Viewport', |
| 402 'enum': 'GL_VIEWPORT', |
| 403 'states': [ |
| 404 # NOTE: These defaults reset at GLES2DecoderImpl::Initialization. |
| 405 { |
| 406 'name': 'viewport_x', |
| 407 'type': 'GLfloat', |
| 408 'default': '0.0f', |
| 409 'expected': 'kViewportX', |
| 410 }, |
| 411 { |
| 412 'name': 'viewport_y', |
| 413 'type': 'GLfloat', |
| 414 'default': '0.0f', |
| 415 'expected': 'kViewportY', |
| 416 }, |
| 417 { |
| 418 'name': 'viewport_width', |
| 419 'type': 'GLfloat', |
| 420 'default': '1.0f', |
| 421 'expected': 'kViewportWidth', |
| 422 }, |
| 423 { |
| 424 'name': 'viewport_height', |
| 425 'type': 'GLfloat', |
| 426 'default': '1.0f', |
| 427 'expected': 'kViewportHeight', |
| 428 }, |
| 429 ], |
| 430 }, |
| 431 } |
| 432 |
60 # This is a list of enum names and their valid values. It is used to map | 433 # This is a list of enum names and their valid values. It is used to map |
61 # GLenum arguments to a specific set of valid values. | 434 # GLenum arguments to a specific set of valid values. |
62 _ENUM_LISTS = { | 435 _ENUM_LISTS = { |
63 'BlitFilter': { | 436 'BlitFilter': { |
64 'type': 'GLenum', | 437 'type': 'GLenum', |
65 'valid': [ | 438 'valid': [ |
66 'GL_NEAREST', | 439 'GL_NEAREST', |
67 'GL_LINEAR', | 440 'GL_LINEAR', |
68 ], | 441 ], |
69 'invalid': [ | 442 'invalid': [ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 ], | 484 ], |
112 }, | 485 }, |
113 'CompressedTextureFormat': { | 486 'CompressedTextureFormat': { |
114 'type': 'GLenum', | 487 'type': 'GLenum', |
115 'valid': [ | 488 'valid': [ |
116 ], | 489 ], |
117 }, | 490 }, |
118 'GLState': { | 491 'GLState': { |
119 'type': 'GLenum', | 492 'type': 'GLenum', |
120 'valid': [ | 493 'valid': [ |
| 494 # NOTE: State an Capability entries added later. |
121 'GL_ACTIVE_TEXTURE', | 495 'GL_ACTIVE_TEXTURE', |
122 'GL_ALIASED_LINE_WIDTH_RANGE', | 496 'GL_ALIASED_LINE_WIDTH_RANGE', |
123 'GL_ALIASED_POINT_SIZE_RANGE', | 497 'GL_ALIASED_POINT_SIZE_RANGE', |
124 'GL_ALPHA_BITS', | 498 'GL_ALPHA_BITS', |
125 'GL_ARRAY_BUFFER_BINDING', | 499 'GL_ARRAY_BUFFER_BINDING', |
126 'GL_BLEND', | |
127 'GL_BLEND_COLOR', | |
128 'GL_BLEND_DST_ALPHA', | |
129 'GL_BLEND_DST_RGB', | |
130 'GL_BLEND_EQUATION_ALPHA', | |
131 'GL_BLEND_EQUATION_RGB', | |
132 'GL_BLEND_SRC_ALPHA', | |
133 'GL_BLEND_SRC_RGB', | |
134 'GL_BLUE_BITS', | 500 'GL_BLUE_BITS', |
135 'GL_COLOR_CLEAR_VALUE', | |
136 'GL_COLOR_WRITEMASK', | |
137 'GL_COMPRESSED_TEXTURE_FORMATS', | 501 'GL_COMPRESSED_TEXTURE_FORMATS', |
138 'GL_CULL_FACE', | |
139 'GL_CULL_FACE_MODE', | |
140 'GL_CURRENT_PROGRAM', | 502 'GL_CURRENT_PROGRAM', |
141 'GL_DEPTH_BITS', | 503 'GL_DEPTH_BITS', |
142 'GL_DEPTH_CLEAR_VALUE', | |
143 'GL_DEPTH_FUNC', | |
144 'GL_DEPTH_RANGE', | 504 'GL_DEPTH_RANGE', |
145 'GL_DEPTH_TEST', | |
146 'GL_DEPTH_WRITEMASK', | |
147 'GL_DITHER', | |
148 'GL_ELEMENT_ARRAY_BUFFER_BINDING', | 505 'GL_ELEMENT_ARRAY_BUFFER_BINDING', |
149 'GL_FRAMEBUFFER_BINDING', | 506 'GL_FRAMEBUFFER_BINDING', |
150 'GL_FRONT_FACE', | |
151 'GL_GENERATE_MIPMAP_HINT', | 507 'GL_GENERATE_MIPMAP_HINT', |
152 'GL_GREEN_BITS', | 508 'GL_GREEN_BITS', |
153 'GL_IMPLEMENTATION_COLOR_READ_FORMAT', | 509 'GL_IMPLEMENTATION_COLOR_READ_FORMAT', |
154 'GL_IMPLEMENTATION_COLOR_READ_TYPE', | 510 'GL_IMPLEMENTATION_COLOR_READ_TYPE', |
155 'GL_LINE_WIDTH', | |
156 'GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS', | 511 'GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS', |
157 'GL_MAX_CUBE_MAP_TEXTURE_SIZE', | 512 'GL_MAX_CUBE_MAP_TEXTURE_SIZE', |
158 'GL_MAX_FRAGMENT_UNIFORM_VECTORS', | 513 'GL_MAX_FRAGMENT_UNIFORM_VECTORS', |
159 'GL_MAX_RENDERBUFFER_SIZE', | 514 'GL_MAX_RENDERBUFFER_SIZE', |
160 'GL_MAX_TEXTURE_IMAGE_UNITS', | 515 'GL_MAX_TEXTURE_IMAGE_UNITS', |
161 'GL_MAX_TEXTURE_SIZE', | 516 'GL_MAX_TEXTURE_SIZE', |
162 'GL_MAX_VARYING_VECTORS', | 517 'GL_MAX_VARYING_VECTORS', |
163 'GL_MAX_VERTEX_ATTRIBS', | 518 'GL_MAX_VERTEX_ATTRIBS', |
164 'GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS', | 519 'GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS', |
165 'GL_MAX_VERTEX_UNIFORM_VECTORS', | 520 'GL_MAX_VERTEX_UNIFORM_VECTORS', |
166 'GL_MAX_VIEWPORT_DIMS', | 521 'GL_MAX_VIEWPORT_DIMS', |
167 'GL_NUM_COMPRESSED_TEXTURE_FORMATS', | 522 'GL_NUM_COMPRESSED_TEXTURE_FORMATS', |
168 'GL_NUM_SHADER_BINARY_FORMATS', | 523 'GL_NUM_SHADER_BINARY_FORMATS', |
169 'GL_PACK_ALIGNMENT', | 524 'GL_PACK_ALIGNMENT', |
170 'GL_POLYGON_OFFSET_FACTOR', | |
171 'GL_POLYGON_OFFSET_FILL', | |
172 'GL_POLYGON_OFFSET_UNITS', | |
173 'GL_RED_BITS', | 525 'GL_RED_BITS', |
174 'GL_RENDERBUFFER_BINDING', | 526 'GL_RENDERBUFFER_BINDING', |
175 'GL_SAMPLE_BUFFERS', | 527 'GL_SAMPLE_BUFFERS', |
176 'GL_SAMPLE_COVERAGE_INVERT', | 528 'GL_SAMPLE_COVERAGE_INVERT', |
177 'GL_SAMPLE_COVERAGE_VALUE', | 529 'GL_SAMPLE_COVERAGE_VALUE', |
178 'GL_SAMPLES', | 530 'GL_SAMPLES', |
179 'GL_SCISSOR_BOX', | 531 'GL_SCISSOR_BOX', |
180 'GL_SCISSOR_TEST', | |
181 'GL_SHADER_BINARY_FORMATS', | 532 'GL_SHADER_BINARY_FORMATS', |
182 'GL_SHADER_COMPILER', | 533 'GL_SHADER_COMPILER', |
183 'GL_STENCIL_BACK_FAIL', | 534 'GL_SUBPIXEL_BITS', |
184 'GL_STENCIL_BACK_FUNC', | |
185 'GL_STENCIL_BACK_PASS_DEPTH_FAIL', | |
186 'GL_STENCIL_BACK_PASS_DEPTH_PASS', | |
187 'GL_STENCIL_BACK_REF', | |
188 'GL_STENCIL_BACK_VALUE_MASK', | |
189 'GL_STENCIL_BACK_WRITEMASK', | |
190 'GL_STENCIL_BITS', | 535 'GL_STENCIL_BITS', |
191 'GL_STENCIL_CLEAR_VALUE', | |
192 'GL_STENCIL_FAIL', | |
193 'GL_STENCIL_FUNC', | |
194 'GL_STENCIL_PASS_DEPTH_FAIL', | |
195 'GL_STENCIL_PASS_DEPTH_PASS', | |
196 'GL_STENCIL_REF', | |
197 'GL_STENCIL_TEST', | |
198 'GL_STENCIL_VALUE_MASK', | |
199 'GL_STENCIL_WRITEMASK', | |
200 'GL_SUBPIXEL_BITS', | |
201 'GL_TEXTURE_BINDING_2D', | 536 'GL_TEXTURE_BINDING_2D', |
202 'GL_TEXTURE_BINDING_CUBE_MAP', | 537 'GL_TEXTURE_BINDING_CUBE_MAP', |
203 'GL_UNPACK_ALIGNMENT', | 538 'GL_UNPACK_ALIGNMENT', |
204 'GL_UNPACK_FLIP_Y_CHROMIUM', | 539 'GL_UNPACK_FLIP_Y_CHROMIUM', |
205 'GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM', | 540 'GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM', |
206 'GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM', | 541 'GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM', |
207 'GL_VIEWPORT', | 542 'GL_VIEWPORT', |
208 ], | 543 ], |
209 'invalid': [ | 544 'invalid': [ |
210 'GL_FOG_HINT', | 545 'GL_FOG_HINT', |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 'GL_DST_ALPHA', | 665 'GL_DST_ALPHA', |
331 'GL_ONE_MINUS_DST_ALPHA', | 666 'GL_ONE_MINUS_DST_ALPHA', |
332 'GL_CONSTANT_COLOR', | 667 'GL_CONSTANT_COLOR', |
333 'GL_ONE_MINUS_CONSTANT_COLOR', | 668 'GL_ONE_MINUS_CONSTANT_COLOR', |
334 'GL_CONSTANT_ALPHA', | 669 'GL_CONSTANT_ALPHA', |
335 'GL_ONE_MINUS_CONSTANT_ALPHA', | 670 'GL_ONE_MINUS_CONSTANT_ALPHA', |
336 ], | 671 ], |
337 }, | 672 }, |
338 'Capability': { | 673 'Capability': { |
339 'type': 'GLenum', | 674 'type': 'GLenum', |
340 'valid': [ | 675 'valid': ["GL_%s" % cap['name'].upper() for cap in _CAPABILITY_FLAGS], |
341 'GL_DITHER', # 1st one is a non-cached value so autogen unit tests work. | |
342 'GL_BLEND', | |
343 'GL_CULL_FACE', | |
344 'GL_DEPTH_TEST', | |
345 'GL_POLYGON_OFFSET_FILL', | |
346 'GL_SAMPLE_ALPHA_TO_COVERAGE', | |
347 'GL_SAMPLE_COVERAGE', | |
348 'GL_SCISSOR_TEST', | |
349 'GL_STENCIL_TEST', | |
350 ], | |
351 'invalid': [ | 676 'invalid': [ |
352 'GL_CLIP_PLANE0', | 677 'GL_CLIP_PLANE0', |
353 'GL_POINT_SPRITE', | 678 'GL_POINT_SPRITE', |
354 ], | 679 ], |
355 }, | 680 }, |
356 'DrawMode': { | 681 'DrawMode': { |
357 'type': 'GLenum', | 682 'type': 'GLenum', |
358 'valid': [ | 683 'valid': [ |
359 'GL_POINTS', | 684 'GL_POINTS', |
360 'GL_LINE_STRIP', | 685 'GL_LINE_STRIP', |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 'gl_test_func': 'glCheckFramebufferStatusEXT', | 1199 'gl_test_func': 'glCheckFramebufferStatusEXT', |
875 'error_value': 'GL_FRAMEBUFFER_UNSUPPORTED', | 1200 'error_value': 'GL_FRAMEBUFFER_UNSUPPORTED', |
876 'result': ['GLenum'], | 1201 'result': ['GLenum'], |
877 }, | 1202 }, |
878 'Clear': { | 1203 'Clear': { |
879 'type': 'Manual', | 1204 'type': 'Manual', |
880 'cmd_args': 'GLbitfield mask' | 1205 'cmd_args': 'GLbitfield mask' |
881 }, | 1206 }, |
882 'ClearColor': { | 1207 'ClearColor': { |
883 'type': 'StateSet', | 1208 'type': 'StateSet', |
884 'states': [ | 1209 'state': 'ClearColor', |
885 {'name': 'color_clear_red'}, | |
886 {'name': 'color_clear_green'}, | |
887 {'name': 'color_clear_blue'}, | |
888 {'name': 'color_clear_alpha'}, | |
889 ], | |
890 }, | 1210 }, |
891 'ClearDepthf': { | 1211 'ClearDepthf': { |
892 'type': 'StateSet', | 1212 'type': 'StateSet', |
893 'states': [ | 1213 'state': 'ClearDepthf', |
894 {'name': 'depth_clear'}, | |
895 ], | |
896 'decoder_func': 'glClearDepth', | 1214 'decoder_func': 'glClearDepth', |
897 'gl_test_func': 'glClearDepth', | 1215 'gl_test_func': 'glClearDepth', |
898 }, | 1216 }, |
899 'ColorMask': { | 1217 'ColorMask': { |
900 'type': 'StateSet', | 1218 'type': 'StateSet', |
901 'states': [ | 1219 'state': 'ColorMask', |
902 {'name': 'color_mask_red'}, | |
903 {'name': 'color_mask_green'}, | |
904 {'name': 'color_mask_blue'}, | |
905 {'name': 'color_mask_alpha'}, | |
906 ], | |
907 'state_flag': 'clear_state_dirty_', | |
908 'no_gl': True, | 1220 'no_gl': True, |
909 'expectation': False, | 1221 'expectation': False, |
910 }, | 1222 }, |
911 'ConsumeTextureCHROMIUM': { | 1223 'ConsumeTextureCHROMIUM': { |
912 'decoder_func': 'DoConsumeTextureCHROMIUM', | 1224 'decoder_func': 'DoConsumeTextureCHROMIUM', |
913 'type': 'PUT', | 1225 'type': 'PUT', |
914 'data_type': 'GLbyte', | 1226 'data_type': 'GLbyte', |
915 'count': 64, | 1227 'count': 64, |
916 'unit_test': False, | 1228 'unit_test': False, |
917 'extension': True, | 1229 'extension': True, |
918 'chromium': True, | 1230 'chromium': True, |
919 }, | 1231 }, |
920 'ClearStencil': { | 1232 'ClearStencil': { |
921 'type': 'StateSet', | 1233 'type': 'StateSet', |
922 'states': [ | 1234 'state': 'ClearStencil', |
923 {'name': 'stencil_clear'}, | |
924 ], | |
925 }, | 1235 }, |
926 'EnableFeatureCHROMIUM': { | 1236 'EnableFeatureCHROMIUM': { |
927 'type': 'Custom', | 1237 'type': 'Custom', |
928 'immediate': False, | 1238 'immediate': False, |
929 'decoder_func': 'DoEnableFeatureCHROMIUM', | 1239 'decoder_func': 'DoEnableFeatureCHROMIUM', |
930 'expectation': False, | 1240 'expectation': False, |
931 'cmd_args': 'GLuint bucket_id, GLint* result', | 1241 'cmd_args': 'GLuint bucket_id, GLint* result', |
932 'result': ['GLint'], | 1242 'result': ['GLint'], |
933 'extension': True, | 1243 'extension': True, |
934 'chromium': True, | 1244 'chromium': True, |
(...skipping 20 matching lines...) Expand all Loading... |
955 'CreateProgram': { | 1265 'CreateProgram': { |
956 'type': 'Create', | 1266 'type': 'Create', |
957 'client_test': False, | 1267 'client_test': False, |
958 }, | 1268 }, |
959 'CreateShader': { | 1269 'CreateShader': { |
960 'type': 'Create', | 1270 'type': 'Create', |
961 'client_test': False, | 1271 'client_test': False, |
962 }, | 1272 }, |
963 'BlendColor': { | 1273 'BlendColor': { |
964 'type': 'StateSet', | 1274 'type': 'StateSet', |
965 'states': [ | 1275 'state': 'BlendColor', |
966 {'name': 'blend_color_red'}, | |
967 {'name': 'blend_color_green'}, | |
968 {'name': 'blend_color_blue'}, | |
969 {'name': 'blend_color_alpha'}, | |
970 ], | |
971 }, | 1276 }, |
972 'BlendEquation': {'decoder_func': 'DoBlendEquation'}, | 1277 'BlendEquation': { |
| 1278 'type': 'StateSetRGBAlpha', |
| 1279 'state': 'BlendEquation', |
| 1280 }, |
973 'BlendEquationSeparate': { | 1281 'BlendEquationSeparate': { |
974 'type': 'StateSet', | 1282 'type': 'StateSet', |
975 'states': [ | 1283 'state': 'BlendEquation', |
976 {'name': 'blend_equation_rgb'}, | |
977 {'name': 'blend_equation_alpha'}, | |
978 ], | |
979 }, | 1284 }, |
980 'BlendFunc': {'decoder_func': 'DoBlendFunc'}, | 1285 'BlendFunc': { |
| 1286 'type': 'StateSetRGBAlpha', |
| 1287 'state': 'BlendFunc', |
| 1288 }, |
981 'BlendFuncSeparate': { | 1289 'BlendFuncSeparate': { |
982 'type': 'StateSet', | 1290 'type': 'StateSet', |
983 'states': [ | 1291 'state': 'BlendFunc', |
984 {'name': 'blend_source_rgb'}, | |
985 {'name': 'blend_dest_rgb'}, | |
986 {'name': 'blend_source_alpha'}, | |
987 {'name': 'blend_dest_alpha'}, | |
988 ], | |
989 }, | 1292 }, |
990 'SampleCoverage': {'decoder_func': 'DoSampleCoverage'}, | 1293 'SampleCoverage': {'decoder_func': 'DoSampleCoverage'}, |
991 'StencilFunc': {'decoder_func': 'DoStencilFunc'}, | 1294 'StencilFunc': { |
992 'StencilFuncSeparate': {'decoder_func': 'DoStencilFuncSeparate'}, | 1295 'type': 'StencilFrontBack', |
993 'StencilOp': {'decoder_func': 'DoStencilOp'}, | 1296 'state': 'StencilFunc', |
994 'StencilOpSeparate': {'decoder_func': 'DoStencilOpSeparate'}, | 1297 }, |
| 1298 'StencilFuncSeparate': { |
| 1299 'type': 'StencilFrontBack', |
| 1300 'state': 'StencilFunc', |
| 1301 }, |
| 1302 'StencilOp': { |
| 1303 'type': 'StateSetFrontBack', |
| 1304 'state': 'StencilOp', |
| 1305 }, |
| 1306 'StencilOpSeparate': { |
| 1307 'type': 'StateSetFrontBackSeparate', |
| 1308 'state': 'StencilOp', |
| 1309 }, |
995 'Hint': {'decoder_func': 'DoHint'}, | 1310 'Hint': {'decoder_func': 'DoHint'}, |
996 'CullFace': {'type': 'StateSet', 'states': [{'name': 'cull_mode'}]}, | 1311 'CullFace': {'type': 'StateSet', 'state': 'CullFace'}, |
997 'FrontFace': {'type': 'StateSet', 'states': [{'name': 'front_face'}]}, | 1312 'FrontFace': {'type': 'StateSet', 'state': 'FrontFace'}, |
998 'DepthFunc': {'type': 'StateSet', 'states': [{'name': 'depth_func'}]}, | 1313 'DepthFunc': {'type': 'StateSet', 'state': 'DepthFunc'}, |
999 'LineWidth': {'type': 'StateSet', 'states': [{'name': 'line_width'}]}, | 1314 'LineWidth': {'type': 'StateSet', 'state': 'LineWidth'}, |
1000 'PolygonOffset': { | 1315 'PolygonOffset': { |
1001 'type': 'StateSet', | 1316 'type': 'StateSet', |
1002 'states': [ | 1317 'state': 'PolygonOffset', |
1003 {'name': 'polygon_offset_factor'}, | |
1004 {'name': 'polygon_offset_units'}, | |
1005 ], | |
1006 }, | 1318 }, |
1007 'DeleteBuffers': { | 1319 'DeleteBuffers': { |
1008 'type': 'DELn', | 1320 'type': 'DELn', |
1009 'gl_test_func': 'glDeleteBuffersARB', | 1321 'gl_test_func': 'glDeleteBuffersARB', |
1010 'resource_type': 'Buffer', | 1322 'resource_type': 'Buffer', |
1011 'resource_types': 'Buffers', | 1323 'resource_types': 'Buffers', |
1012 }, | 1324 }, |
1013 'DeleteFramebuffers': { | 1325 'DeleteFramebuffers': { |
1014 'type': 'DELn', | 1326 'type': 'DELn', |
1015 'gl_test_func': 'glDeleteFramebuffersEXT', | 1327 'gl_test_func': 'glDeleteFramebuffersEXT', |
(...skipping 21 matching lines...) Expand all Loading... |
1037 'type': 'DELn', | 1349 'type': 'DELn', |
1038 'resource_type': 'Texture', | 1350 'resource_type': 'Texture', |
1039 'resource_types': 'Textures', | 1351 'resource_types': 'Textures', |
1040 }, | 1352 }, |
1041 'DepthRangef': { | 1353 'DepthRangef': { |
1042 'decoder_func': 'DoDepthRangef', | 1354 'decoder_func': 'DoDepthRangef', |
1043 'gl_test_func': 'glDepthRange', | 1355 'gl_test_func': 'glDepthRange', |
1044 }, | 1356 }, |
1045 'DepthMask': { | 1357 'DepthMask': { |
1046 'type': 'StateSet', | 1358 'type': 'StateSet', |
1047 'states': [ | 1359 'state': 'DepthMask', |
1048 {'name': 'depth_mask'}, | |
1049 ], | |
1050 'state_flag': 'clear_state_dirty_', | |
1051 'no_gl': True, | 1360 'no_gl': True, |
1052 'expectation': False, | 1361 'expectation': False, |
1053 }, | 1362 }, |
1054 'DetachShader': {'decoder_func': 'DoDetachShader'}, | 1363 'DetachShader': {'decoder_func': 'DoDetachShader'}, |
1055 'Disable': { | 1364 'Disable': { |
1056 'decoder_func': 'DoDisable', | 1365 'decoder_func': 'DoDisable', |
1057 'impl_func': False, | 1366 'impl_func': False, |
1058 }, | 1367 }, |
1059 'DisableVertexAttribArray': { | 1368 'DisableVertexAttribArray': { |
1060 'decoder_func': 'DoDisableVertexAttribArray', | 1369 'decoder_func': 'DoDisableVertexAttribArray', |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 }, | 1782 }, |
1474 'ShaderSource': { | 1783 'ShaderSource': { |
1475 'type': 'Manual', | 1784 'type': 'Manual', |
1476 'immediate': True, | 1785 'immediate': True, |
1477 'bucket': True, | 1786 'bucket': True, |
1478 'needs_size': True, | 1787 'needs_size': True, |
1479 'client_test': False, | 1788 'client_test': False, |
1480 'cmd_args': | 1789 'cmd_args': |
1481 'GLuint shader, const char* data', | 1790 'GLuint shader, const char* data', |
1482 }, | 1791 }, |
1483 'StencilMask': {'decoder_func': 'DoStencilMask', 'expectation': False}, | 1792 'StencilMask': { |
| 1793 'type': 'StateSetFrontBack', |
| 1794 'state': 'StencilMask', |
| 1795 'no_gl': True, |
| 1796 'expectation': False, |
| 1797 }, |
1484 'StencilMaskSeparate': { | 1798 'StencilMaskSeparate': { |
1485 'decoder_func': 'DoStencilMaskSeparate', | 1799 'type': 'StateSetFrontBackSeparate', |
| 1800 'state': 'StencilMask', |
| 1801 'no_gl': True, |
1486 'expectation': False, | 1802 'expectation': False, |
1487 }, | 1803 }, |
1488 'SwapBuffers': { | 1804 'SwapBuffers': { |
1489 'type': 'Custom', | 1805 'type': 'Custom', |
1490 'impl_func': False, | 1806 'impl_func': False, |
1491 'unit_test': False, | 1807 'unit_test': False, |
1492 'client_test': False, | 1808 'client_test': False, |
1493 'extension': True, | 1809 'extension': True, |
1494 }, | 1810 }, |
1495 'TexImage2D': { | 1811 'TexImage2D': { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 }, | 2172 }, |
1857 'ReleaseTexImage2DCHROMIUM': { | 2173 'ReleaseTexImage2DCHROMIUM': { |
1858 'decoder_func': 'DoReleaseTexImage2DCHROMIUM', | 2174 'decoder_func': 'DoReleaseTexImage2DCHROMIUM', |
1859 'unit_test': False, | 2175 'unit_test': False, |
1860 'extension': True, | 2176 'extension': True, |
1861 'chromium': True, | 2177 'chromium': True, |
1862 }, | 2178 }, |
1863 } | 2179 } |
1864 | 2180 |
1865 | 2181 |
| 2182 def Grouper(n, iterable, fillvalue=None): |
| 2183 """Collect data into fixed-length chunks or blocks""" |
| 2184 args = [iter(iterable)] * n |
| 2185 return itertools.izip_longest(fillvalue=fillvalue, *args) |
| 2186 |
| 2187 |
1866 def SplitWords(input_string): | 2188 def SplitWords(input_string): |
1867 """Transforms a input_string into a list of lower-case components. | 2189 """Transforms a input_string into a list of lower-case components. |
1868 | 2190 |
1869 Args: | 2191 Args: |
1870 input_string: the input string. | 2192 input_string: the input string. |
1871 | 2193 |
1872 Returns: | 2194 Returns: |
1873 a list of lower-case words. | 2195 a list of lower-case words. |
1874 """ | 2196 """ |
1875 if input_string.find('_') > -1: | 2197 if input_string.find('_') > -1: |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2128 """Writes the size test for a command.""" | 2450 """Writes the size test for a command.""" |
2129 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") | 2451 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") |
2130 | 2452 |
2131 def WriteFormatTest(self, func, file): | 2453 def WriteFormatTest(self, func, file): |
2132 """Writes a format test for a command.""" | 2454 """Writes a format test for a command.""" |
2133 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) | 2455 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) |
2134 file.Write(" %s& cmd = *GetBufferAs<%s>();\n" % (func.name, func.name)) | 2456 file.Write(" %s& cmd = *GetBufferAs<%s>();\n" % (func.name, func.name)) |
2135 file.Write(" void* next_cmd = cmd.Set(\n") | 2457 file.Write(" void* next_cmd = cmd.Set(\n") |
2136 file.Write(" &cmd") | 2458 file.Write(" &cmd") |
2137 args = func.GetCmdArgs() | 2459 args = func.GetCmdArgs() |
2138 value = 11 | 2460 for value, arg in enumerate(args): |
2139 for arg in args: | 2461 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 11)) |
2140 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) | |
2141 value += 1 | |
2142 file.Write(");\n") | 2462 file.Write(");\n") |
2143 value = 11 | |
2144 file.Write(" EXPECT_EQ(static_cast<uint32>(%s::kCmdId),\n" % func.name) | 2463 file.Write(" EXPECT_EQ(static_cast<uint32>(%s::kCmdId),\n" % func.name) |
2145 file.Write(" cmd.header.command);\n") | 2464 file.Write(" cmd.header.command);\n") |
2146 func.type_handler.WriteCmdSizeTest(func, file) | 2465 func.type_handler.WriteCmdSizeTest(func, file) |
2147 for arg in args: | 2466 for value, arg in enumerate(args): |
2148 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % | 2467 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % |
2149 (arg.type, value, arg.name)) | 2468 (arg.type, value + 11, arg.name)) |
2150 value += 1 | |
2151 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") | 2469 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") |
2152 file.Write(" next_cmd, sizeof(cmd));\n") | 2470 file.Write(" next_cmd, sizeof(cmd));\n") |
2153 file.Write("}\n") | 2471 file.Write("}\n") |
2154 file.Write("\n") | 2472 file.Write("\n") |
2155 | 2473 |
2156 def WriteImmediateFormatTest(self, func, file): | 2474 def WriteImmediateFormatTest(self, func, file): |
2157 """Writes a format test for an immediate version of a command.""" | 2475 """Writes a format test for an immediate version of a command.""" |
2158 pass | 2476 pass |
2159 | 2477 |
2160 def WriteBucketFormatTest(self, func, file): | 2478 def WriteBucketFormatTest(self, func, file): |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 file.Write(" return error::kNoError;\n") | 2552 file.Write(" return error::kNoError;\n") |
2235 file.Write("}\n") | 2553 file.Write("}\n") |
2236 file.Write("\n") | 2554 file.Write("\n") |
2237 | 2555 |
2238 def WriteValidUnitTest(self, func, file, test, extra = {}): | 2556 def WriteValidUnitTest(self, func, file, test, extra = {}): |
2239 """Writes a valid unit test.""" | 2557 """Writes a valid unit test.""" |
2240 if func.GetInfo('expectation') == False: | 2558 if func.GetInfo('expectation') == False: |
2241 test = self._remove_expected_call_re.sub('', test) | 2559 test = self._remove_expected_call_re.sub('', test) |
2242 name = func.name | 2560 name = func.name |
2243 arg_strings = [] | 2561 arg_strings = [] |
2244 count = 0 | 2562 for count, arg in enumerate(func.GetOriginalArgs()): |
2245 for arg in func.GetOriginalArgs(): | |
2246 arg_strings.append(arg.GetValidArg(func, count, 0)) | 2563 arg_strings.append(arg.GetValidArg(func, count, 0)) |
2247 count += 1 | |
2248 gl_arg_strings = [] | 2564 gl_arg_strings = [] |
2249 count = 0 | 2565 for count, arg in enumerate(func.GetOriginalArgs()): |
2250 for arg in func.GetOriginalArgs(): | |
2251 gl_arg_strings.append(arg.GetValidGLArg(func, count, 0)) | 2566 gl_arg_strings.append(arg.GetValidGLArg(func, count, 0)) |
2252 count += 1 | |
2253 gl_func_name = func.GetGLTestFunctionName() | 2567 gl_func_name = func.GetGLTestFunctionName() |
2254 vars = { | 2568 vars = { |
2255 'test_name': 'GLES2DecoderTest%d' % file.file_num, | 2569 'test_name': 'GLES2DecoderTest%d' % file.file_num, |
2256 'name':name, | 2570 'name':name, |
2257 'gl_func_name': gl_func_name, | 2571 'gl_func_name': gl_func_name, |
2258 'args': ", ".join(arg_strings), | 2572 'args': ", ".join(arg_strings), |
2259 'gl_args': ", ".join(gl_arg_strings), | 2573 'gl_args': ", ".join(gl_arg_strings), |
2260 } | 2574 } |
2261 vars.update(extra) | 2575 vars.update(extra) |
2262 file.Write(test % vars) | 2576 file.Write(test % vars) |
2263 | 2577 |
2264 def WriteInvalidUnitTest(self, func, file, test, extra = {}): | 2578 def WriteInvalidUnitTest(self, func, file, test, extra = {}): |
2265 """Writes a invalid unit test.""" | 2579 """Writes a invalid unit test.""" |
2266 arg_index = 0 | 2580 for arg_index, arg in enumerate(func.GetOriginalArgs()): |
2267 for arg in func.GetOriginalArgs(): | |
2268 num_invalid_values = arg.GetNumInvalidValues(func) | 2581 num_invalid_values = arg.GetNumInvalidValues(func) |
2269 for value_index in range(0, num_invalid_values): | 2582 for value_index in range(0, num_invalid_values): |
2270 arg_strings = [] | 2583 arg_strings = [] |
2271 parse_result = "kNoError" | 2584 parse_result = "kNoError" |
2272 gl_error = None | 2585 gl_error = None |
2273 count = 0 | 2586 for count, arg in enumerate(func.GetOriginalArgs()): |
2274 for arg in func.GetOriginalArgs(): | |
2275 if count == arg_index: | 2587 if count == arg_index: |
2276 (arg_string, parse_result, gl_error) = arg.GetInvalidArg( | 2588 (arg_string, parse_result, gl_error) = arg.GetInvalidArg( |
2277 count, value_index) | 2589 count, value_index) |
2278 else: | 2590 else: |
2279 arg_string = arg.GetValidArg(func, count, 0) | 2591 arg_string = arg.GetValidArg(func, count, 0) |
2280 arg_strings.append(arg_string) | 2592 arg_strings.append(arg_string) |
2281 count += 1 | |
2282 gl_arg_strings = [] | 2593 gl_arg_strings = [] |
2283 count = 0 | |
2284 for arg in func.GetOriginalArgs(): | 2594 for arg in func.GetOriginalArgs(): |
2285 gl_arg_strings.append("_") | 2595 gl_arg_strings.append("_") |
2286 count += 1 | |
2287 gl_func_name = func.GetGLTestFunctionName() | 2596 gl_func_name = func.GetGLTestFunctionName() |
2288 gl_error_test = '' | 2597 gl_error_test = '' |
2289 if not gl_error == None: | 2598 if not gl_error == None: |
2290 gl_error_test = '\n EXPECT_EQ(%s, GetGLError());' % gl_error | 2599 gl_error_test = '\n EXPECT_EQ(%s, GetGLError());' % gl_error |
2291 | 2600 |
2292 vars = { | 2601 vars = { |
2293 'test_name': 'GLES2DecoderTest%d' % file.file_num , | 2602 'test_name': 'GLES2DecoderTest%d' % file.file_num , |
2294 'name': func.name, | 2603 'name': func.name, |
2295 'arg_index': arg_index, | 2604 'arg_index': arg_index, |
2296 'value_index': value_index, | 2605 'value_index': value_index, |
2297 'gl_func_name': gl_func_name, | 2606 'gl_func_name': gl_func_name, |
2298 'args': ", ".join(arg_strings), | 2607 'args': ", ".join(arg_strings), |
2299 'all_but_last_args': ", ".join(arg_strings[:-1]), | 2608 'all_but_last_args': ", ".join(arg_strings[:-1]), |
2300 'gl_args': ", ".join(gl_arg_strings), | 2609 'gl_args': ", ".join(gl_arg_strings), |
2301 'parse_result': parse_result, | 2610 'parse_result': parse_result, |
2302 'gl_error_test': gl_error_test, | 2611 'gl_error_test': gl_error_test, |
2303 } | 2612 } |
2304 vars.update(extra) | 2613 vars.update(extra) |
2305 file.Write(test % vars) | 2614 file.Write(test % vars) |
2306 arg_index += 1 | |
2307 | 2615 |
2308 def WriteServiceUnitTest(self, func, file): | 2616 def WriteServiceUnitTest(self, func, file): |
2309 """Writes the service unit test for a command.""" | 2617 """Writes the service unit test for a command.""" |
2310 valid_test = """ | 2618 valid_test = """ |
2311 TEST_F(%(test_name)s, %(name)sValidArgs) { | 2619 TEST_F(%(test_name)s, %(name)sValidArgs) { |
2312 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 2620 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
2313 SpecializedSetup<%(name)s, 0>(true); | 2621 SpecializedSetup<%(name)s, 0>(true); |
2314 %(name)s cmd; | 2622 %(name)s cmd; |
2315 cmd.Init(%(args)s); | 2623 cmd.Init(%(args)s); |
2316 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2624 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2442 %(name)s cmd; | 2750 %(name)s cmd; |
2443 }; | 2751 }; |
2444 Cmds expected; | 2752 Cmds expected; |
2445 expected.cmd.Init(%(cmd_args)s); | 2753 expected.cmd.Init(%(cmd_args)s); |
2446 | 2754 |
2447 gl_->%(name)s(%(args)s); | 2755 gl_->%(name)s(%(args)s); |
2448 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2756 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
2449 } | 2757 } |
2450 """ | 2758 """ |
2451 cmd_arg_strings = [] | 2759 cmd_arg_strings = [] |
2452 count = 0 | 2760 for count, arg in enumerate(func.GetCmdArgs()): |
2453 for arg in func.GetCmdArgs(): | |
2454 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) | 2761 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) |
2455 count += 1 | 2762 count += 1 |
2456 gl_arg_strings = [] | 2763 gl_arg_strings = [] |
2457 count = 0 | 2764 for count, arg in enumerate(func.GetOriginalArgs()): |
2458 for arg in func.GetOriginalArgs(): | |
2459 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) | 2765 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) |
2460 count += 1 | |
2461 file.Write(code % { | 2766 file.Write(code % { |
2462 'name': func.name, | 2767 'name': func.name, |
2463 'args': ", ".join(gl_arg_strings), | 2768 'args': ", ".join(gl_arg_strings), |
2464 'cmd_args': ", ".join(cmd_arg_strings), | 2769 'cmd_args': ", ".join(cmd_arg_strings), |
2465 }) | 2770 }) |
2466 else: | 2771 else: |
2467 if client_test != False: | 2772 if client_test != False: |
2468 file.Write("// TODO: Implement unit test for %s\n" % func.name) | 2773 file.Write("// TODO: Implement unit test for %s\n" % func.name) |
2469 | 2774 |
2470 def WriteDestinationInitalizationValidation(self, func, file): | 2775 def WriteDestinationInitalizationValidation(self, func, file): |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2532 | 2837 |
2533 | 2838 |
2534 class StateSetHandler(TypeHandler): | 2839 class StateSetHandler(TypeHandler): |
2535 """Handler for commands that simply set state.""" | 2840 """Handler for commands that simply set state.""" |
2536 | 2841 |
2537 def __init__(self): | 2842 def __init__(self): |
2538 TypeHandler.__init__(self) | 2843 TypeHandler.__init__(self) |
2539 | 2844 |
2540 def WriteHandlerImplementation(self, func, file): | 2845 def WriteHandlerImplementation(self, func, file): |
2541 """Overrriden from TypeHandler.""" | 2846 """Overrriden from TypeHandler.""" |
2542 states = func.GetInfo('states') | 2847 state_name = func.GetInfo('state') |
| 2848 state = _STATES[state_name] |
| 2849 states = state['states'] |
2543 args = func.GetOriginalArgs() | 2850 args = func.GetOriginalArgs() |
2544 ndx = 0 | 2851 for ndx,state in enumerate(states): |
2545 for state in states: | |
2546 file.Write(" state_.%s = %s;\n" % (state['name'], args[ndx].name)) | 2852 file.Write(" state_.%s = %s;\n" % (state['name'], args[ndx].name)) |
2547 ndx += 1 | 2853 if 'state_flag' in state: |
2548 state_flag = func.GetInfo('state_flag') | 2854 file.Write(" %s = true;\n" % state['state_flag']) |
2549 if state_flag: | |
2550 file.Write(" %s = true;\n" % state_flag) | |
2551 if not func.GetInfo("no_gl"): | 2855 if not func.GetInfo("no_gl"): |
2552 file.Write(" %s(%s);\n" % | 2856 file.Write(" %s(%s);\n" % |
2553 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 2857 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
2554 | 2858 |
2555 | 2859 |
| 2860 class StateSetRGBAlphaHandler(TypeHandler): |
| 2861 """Handler for commands that simply set state that have rgb/alpha.""" |
| 2862 |
| 2863 def __init__(self): |
| 2864 TypeHandler.__init__(self) |
| 2865 |
| 2866 def WriteHandlerImplementation(self, func, file): |
| 2867 """Overrriden from TypeHandler.""" |
| 2868 state_name = func.GetInfo('state') |
| 2869 state = _STATES[state_name] |
| 2870 states = state['states'] |
| 2871 args = func.GetOriginalArgs() |
| 2872 num_args = len(args) |
| 2873 for ndx, item in enumerate(states): |
| 2874 file.Write(" state_.%s = %s;\n" % |
| 2875 (item['name'], args[ndx % num_args].name)) |
| 2876 if 'state_flag' in state: |
| 2877 file.Write(" %s = true;\n" % state['state_flag']) |
| 2878 if not func.GetInfo("no_gl"): |
| 2879 file.Write(" %s(%s);\n" % |
| 2880 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
| 2881 |
| 2882 |
| 2883 class StateSetFrontBackSeparateHandler(TypeHandler): |
| 2884 """Handler for commands that simply set state that have front/back.""" |
| 2885 |
| 2886 def __init__(self): |
| 2887 TypeHandler.__init__(self) |
| 2888 |
| 2889 def WriteHandlerImplementation(self, func, file): |
| 2890 """Overrriden from TypeHandler.""" |
| 2891 state_name = func.GetInfo('state') |
| 2892 state = _STATES[state_name] |
| 2893 states = state['states'] |
| 2894 args = func.GetOriginalArgs() |
| 2895 face = args[0].name |
| 2896 num_args = len(args) |
| 2897 for group_ndx, group in enumerate(Grouper(num_args - 1, states)): |
| 2898 file.Write(" if (%s == %s || %s == GL_FRONT_AND_BACK) {\n" % |
| 2899 (face, ('GL_FRONT', 'GL_BACK')[group_ndx], face)) |
| 2900 for ndx, item in enumerate(group): |
| 2901 file.Write(" state_.%s = %s;\n" % (item['name'], args[ndx + 1].name)) |
| 2902 file.Write(" }\n") |
| 2903 if 'state_flag' in state: |
| 2904 file.Write(" %s = true;\n" % state['state_flag']) |
| 2905 if not func.GetInfo("no_gl"): |
| 2906 file.Write(" %s(%s);\n" % |
| 2907 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
| 2908 |
| 2909 |
| 2910 class StateSetFrontBackHandler(TypeHandler): |
| 2911 """Handler for commands that simply set state that set both front/back.""" |
| 2912 |
| 2913 def __init__(self): |
| 2914 TypeHandler.__init__(self) |
| 2915 |
| 2916 def WriteHandlerImplementation(self, func, file): |
| 2917 """Overrriden from TypeHandler.""" |
| 2918 state_name = func.GetInfo('state') |
| 2919 state = _STATES[state_name] |
| 2920 states = state['states'] |
| 2921 args = func.GetOriginalArgs() |
| 2922 face = args[0].name |
| 2923 num_args = len(args) |
| 2924 for group_ndx, group in enumerate(Grouper(num_args, states)): |
| 2925 for ndx, item in enumerate(group): |
| 2926 file.Write(" state_.%s = %s;\n" % (item['name'], args[ndx].name)) |
| 2927 if 'state_flag' in state: |
| 2928 file.Write(" %s = true;\n" % state['state_flag']) |
| 2929 if not func.GetInfo("no_gl"): |
| 2930 file.Write(" %s(%s);\n" % |
| 2931 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
| 2932 |
2556 class CustomHandler(TypeHandler): | 2933 class CustomHandler(TypeHandler): |
2557 """Handler for commands that are auto-generated but require minor tweaks.""" | 2934 """Handler for commands that are auto-generated but require minor tweaks.""" |
2558 | 2935 |
2559 def __init__(self): | 2936 def __init__(self): |
2560 TypeHandler.__init__(self) | 2937 TypeHandler.__init__(self) |
2561 | 2938 |
2562 def WriteServiceImplementation(self, func, file): | 2939 def WriteServiceImplementation(self, func, file): |
2563 """Overrriden from TypeHandler.""" | 2940 """Overrriden from TypeHandler.""" |
2564 pass | 2941 pass |
2565 | 2942 |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3718 expected.cmd.Init(%(cmd_args)s, result1.id, result1.offset); | 4095 expected.cmd.Init(%(cmd_args)s, result1.id, result1.offset); |
3719 EXPECT_CALL(*command_buffer(), OnFlush()) | 4096 EXPECT_CALL(*command_buffer(), OnFlush()) |
3720 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) | 4097 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
3721 .RetiresOnSaturation(); | 4098 .RetiresOnSaturation(); |
3722 gl_->%(name)s(%(args)s, &result); | 4099 gl_->%(name)s(%(args)s, &result); |
3723 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 4100 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
3724 EXPECT_EQ(static_cast<Result::Type>(1), result); | 4101 EXPECT_EQ(static_cast<Result::Type>(1), result); |
3725 } | 4102 } |
3726 """ | 4103 """ |
3727 cmd_arg_strings = [] | 4104 cmd_arg_strings = [] |
3728 count = 0 | 4105 for count, arg in enumerate(func.GetCmdArgs()[0:-2]): |
3729 for arg in func.GetCmdArgs()[0:-2]: | |
3730 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) | 4106 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) |
3731 count += 1 | |
3732 cmd_arg_strings[0] = '123' | 4107 cmd_arg_strings[0] = '123' |
3733 gl_arg_strings = [] | 4108 gl_arg_strings = [] |
3734 count = 0 | 4109 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]): |
3735 for arg in func.GetOriginalArgs()[0:-1]: | |
3736 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) | 4110 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) |
3737 count += 1 | |
3738 gl_arg_strings[0] = '123' | 4111 gl_arg_strings[0] = '123' |
3739 file.Write(code % { | 4112 file.Write(code % { |
3740 'name': func.name, | 4113 'name': func.name, |
3741 'args': ", ".join(gl_arg_strings), | 4114 'args': ", ".join(gl_arg_strings), |
3742 'cmd_args': ", ".join(cmd_arg_strings), | 4115 'cmd_args': ", ".join(cmd_arg_strings), |
3743 }) | 4116 }) |
3744 | 4117 |
3745 def WriteServiceUnitTest(self, func, file): | 4118 def WriteServiceUnitTest(self, func, file): |
3746 """Overrriden from TypeHandler.""" | 4119 """Overrriden from TypeHandler.""" |
3747 valid_test = """ | 4120 valid_test = """ |
(...skipping 11 matching lines...) Expand all Loading... |
3759 cmd.Init(%(args)s); | 4132 cmd.Init(%(args)s); |
3760 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4133 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
3761 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( | 4134 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( |
3762 %(valid_pname)s), | 4135 %(valid_pname)s), |
3763 result->GetNumResults()); | 4136 result->GetNumResults()); |
3764 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4137 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
3765 } | 4138 } |
3766 """ | 4139 """ |
3767 gl_arg_strings = [] | 4140 gl_arg_strings = [] |
3768 valid_pname = '' | 4141 valid_pname = '' |
3769 count = 0 | 4142 for count, arg in enumerate(func.GetOriginalArgs()[:-1]): |
3770 for arg in func.GetOriginalArgs()[:-1]: | |
3771 arg_value = arg.GetValidGLArg(func, count, 0) | 4143 arg_value = arg.GetValidGLArg(func, count, 0) |
3772 gl_arg_strings.append(arg_value) | 4144 gl_arg_strings.append(arg_value) |
3773 if arg.name == 'pname': | 4145 if arg.name == 'pname': |
3774 valid_pname = arg_value | 4146 valid_pname = arg_value |
3775 count += 1 | |
3776 if func.GetInfo('gl_test_func') == 'glGetIntegerv': | 4147 if func.GetInfo('gl_test_func') == 'glGetIntegerv': |
3777 gl_arg_strings.append("_") | 4148 gl_arg_strings.append("_") |
3778 else: | 4149 else: |
3779 gl_arg_strings.append("result->GetData()") | 4150 gl_arg_strings.append("result->GetData()") |
3780 | 4151 |
3781 self.WriteValidUnitTest(func, file, valid_test, { | 4152 self.WriteValidUnitTest(func, file, valid_test, { |
3782 'local_gl_args': ", ".join(gl_arg_strings), | 4153 'local_gl_args': ", ".join(gl_arg_strings), |
3783 'valid_pname': valid_pname, | 4154 'valid_pname': valid_pname, |
3784 }) | 4155 }) |
3785 | 4156 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3848 SpecializedSetup<%(name)s, 0>(true); | 4219 SpecializedSetup<%(name)s, 0>(true); |
3849 %(data_type)s temp[%(data_count)s] = { %(data_value)s, }; | 4220 %(data_type)s temp[%(data_count)s] = { %(data_value)s, }; |
3850 cmd.Init(%(gl_args)s, &temp[0]); | 4221 cmd.Init(%(gl_args)s, &temp[0]); |
3851 EXPECT_EQ(error::kNoError, | 4222 EXPECT_EQ(error::kNoError, |
3852 ExecuteImmediateCmd(cmd, sizeof(temp))); | 4223 ExecuteImmediateCmd(cmd, sizeof(temp))); |
3853 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4224 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
3854 } | 4225 } |
3855 """ | 4226 """ |
3856 gl_arg_strings = [] | 4227 gl_arg_strings = [] |
3857 gl_any_strings = [] | 4228 gl_any_strings = [] |
3858 count = 0 | 4229 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]): |
3859 for arg in func.GetOriginalArgs()[0:-1]: | |
3860 gl_arg_strings.append(arg.GetValidGLArg(func, count, 0)) | 4230 gl_arg_strings.append(arg.GetValidGLArg(func, count, 0)) |
3861 gl_any_strings.append("_") | 4231 gl_any_strings.append("_") |
3862 count += 1 | |
3863 extra = { | 4232 extra = { |
3864 'data_type': func.GetInfo('data_type'), | 4233 'data_type': func.GetInfo('data_type'), |
3865 'data_count': func.GetInfo('count'), | 4234 'data_count': func.GetInfo('count'), |
3866 'data_value': func.GetInfo('data_value') or '0', | 4235 'data_value': func.GetInfo('data_value') or '0', |
3867 'gl_args': ", ".join(gl_arg_strings), | 4236 'gl_args': ", ".join(gl_arg_strings), |
3868 'gl_any_args': ", ".join(gl_any_strings), | 4237 'gl_any_args': ", ".join(gl_any_strings), |
3869 } | 4238 } |
3870 self.WriteValidUnitTest(func, file, valid_test, extra) | 4239 self.WriteValidUnitTest(func, file, valid_test, extra) |
3871 | 4240 |
3872 invalid_test = """ | 4241 invalid_test = """ |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3926 Cmds expected; | 4295 Cmds expected; |
3927 for (int jj = 0; jj < %(count)d; ++jj) { | 4296 for (int jj = 0; jj < %(count)d; ++jj) { |
3928 expected.data[jj] = static_cast<%(type)s>(jj); | 4297 expected.data[jj] = static_cast<%(type)s>(jj); |
3929 } | 4298 } |
3930 expected.cmd.Init(%(cmd_args)s, &expected.data[0]); | 4299 expected.cmd.Init(%(cmd_args)s, &expected.data[0]); |
3931 gl_->%(name)s(%(args)s, &expected.data[0]); | 4300 gl_->%(name)s(%(args)s, &expected.data[0]); |
3932 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 4301 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
3933 } | 4302 } |
3934 """ | 4303 """ |
3935 cmd_arg_strings = [] | 4304 cmd_arg_strings = [] |
3936 count = 0 | 4305 for count, arg in enumerate(func.GetCmdArgs()[0:-2]): |
3937 for arg in func.GetCmdArgs()[0:-2]: | |
3938 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) | 4306 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) |
3939 count += 1 | |
3940 gl_arg_strings = [] | 4307 gl_arg_strings = [] |
3941 count = 0 | 4308 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]): |
3942 for arg in func.GetOriginalArgs()[0:-1]: | |
3943 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) | 4309 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) |
3944 count += 1 | |
3945 file.Write(code % { | 4310 file.Write(code % { |
3946 'name': func.name, | 4311 'name': func.name, |
3947 'type': func.GetInfo('data_type'), | 4312 'type': func.GetInfo('data_type'), |
3948 'count': func.GetInfo('count'), | 4313 'count': func.GetInfo('count'), |
3949 'args': ", ".join(gl_arg_strings), | 4314 'args': ", ".join(gl_arg_strings), |
3950 'cmd_args': ", ".join(cmd_arg_strings), | 4315 'cmd_args': ", ".join(cmd_arg_strings), |
3951 }) | 4316 }) |
3952 | 4317 |
3953 def WriteImmediateCmdComputeSize(self, func, file): | 4318 def WriteImmediateCmdComputeSize(self, func, file): |
3954 """Overrriden from TypeHandler.""" | 4319 """Overrriden from TypeHandler.""" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4027 file.Write(" const int kSomeBaseValueToTestWith = 51;\n") | 4392 file.Write(" const int kSomeBaseValueToTestWith = 51;\n") |
4028 file.Write(" static %s data[] = {\n" % func.info.data_type) | 4393 file.Write(" static %s data[] = {\n" % func.info.data_type) |
4029 for v in range(0, func.info.count): | 4394 for v in range(0, func.info.count): |
4030 file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" % | 4395 file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" % |
4031 (func.info.data_type, v)) | 4396 (func.info.data_type, v)) |
4032 file.Write(" };\n") | 4397 file.Write(" };\n") |
4033 file.Write(" %s& cmd = *GetBufferAs<%s>();\n" % (func.name, func.name)) | 4398 file.Write(" %s& cmd = *GetBufferAs<%s>();\n" % (func.name, func.name)) |
4034 file.Write(" void* next_cmd = cmd.Set(\n") | 4399 file.Write(" void* next_cmd = cmd.Set(\n") |
4035 file.Write(" &cmd") | 4400 file.Write(" &cmd") |
4036 args = func.GetCmdArgs() | 4401 args = func.GetCmdArgs() |
4037 value = 11 | 4402 for value, arg in enumerate(args): |
4038 for arg in args: | 4403 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 11)) |
4039 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) | |
4040 value += 1 | |
4041 file.Write(",\n data);\n") | 4404 file.Write(",\n data);\n") |
4042 args = func.GetCmdArgs() | 4405 args = func.GetCmdArgs() |
4043 value = 11 | |
4044 file.Write(" EXPECT_EQ(static_cast<uint32>(%s::kCmdId),\n" % func.name) | 4406 file.Write(" EXPECT_EQ(static_cast<uint32>(%s::kCmdId),\n" % func.name) |
4045 file.Write(" cmd.header.command);\n") | 4407 file.Write(" cmd.header.command);\n") |
4046 file.Write(" EXPECT_EQ(sizeof(cmd) +\n") | 4408 file.Write(" EXPECT_EQ(sizeof(cmd) +\n") |
4047 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)),\n") | 4409 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)),\n") |
4048 file.Write(" cmd.header.size * 4u);\n") | 4410 file.Write(" cmd.header.size * 4u);\n") |
4049 for arg in args: | 4411 for value, arg in enumerate(args): |
4050 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % | 4412 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % |
4051 (arg.type, value, arg.name)) | 4413 (arg.type, value + 11, arg.name)) |
4052 value += 1 | |
4053 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") | 4414 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") |
4054 file.Write(" next_cmd, sizeof(cmd) +\n") | 4415 file.Write(" next_cmd, sizeof(cmd) +\n") |
4055 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") | 4416 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") |
4056 file.Write(" // TODO(gman): Check that data was inserted;\n") | 4417 file.Write(" // TODO(gman): Check that data was inserted;\n") |
4057 file.Write("}\n") | 4418 file.Write("}\n") |
4058 file.Write("\n") | 4419 file.Write("\n") |
4059 | 4420 |
4060 | 4421 |
4061 class PUTnHandler(TypeHandler): | 4422 class PUTnHandler(TypeHandler): |
4062 """Handler for PUTn 'glUniform__v' type functions.""" | 4423 """Handler for PUTn 'glUniform__v' type functions.""" |
(...skipping 10 matching lines...) Expand all Loading... |
4073 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 4434 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
4074 SpecializedSetup<%(name)s, 0>(true); | 4435 SpecializedSetup<%(name)s, 0>(true); |
4075 %(name)s cmd; | 4436 %(name)s cmd; |
4076 cmd.Init(%(args)s); | 4437 cmd.Init(%(args)s); |
4077 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4438 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
4078 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4439 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
4079 } | 4440 } |
4080 """ | 4441 """ |
4081 gl_arg_strings = [] | 4442 gl_arg_strings = [] |
4082 arg_strings = [] | 4443 arg_strings = [] |
4083 count = 0 | 4444 for count, arg in enumerate(func.GetOriginalArgs()): |
4084 for arg in func.GetOriginalArgs(): | |
4085 # hardcoded to match unit tests. | 4445 # hardcoded to match unit tests. |
4086 if count == 0: | 4446 if count == 0: |
4087 # the location of the second element of the 2nd uniform. | 4447 # the location of the second element of the 2nd uniform. |
4088 # defined in GLES2DecoderBase::SetupShaderForUniform | 4448 # defined in GLES2DecoderBase::SetupShaderForUniform |
4089 gl_arg_strings.append("3") | 4449 gl_arg_strings.append("3") |
4090 arg_strings.append("ProgramManager::MakeFakeLocation(1, 1)") | 4450 arg_strings.append("ProgramManager::MakeFakeLocation(1, 1)") |
4091 elif count == 1: | 4451 elif count == 1: |
4092 # the number of elements that gl will be called with. | 4452 # the number of elements that gl will be called with. |
4093 gl_arg_strings.append("3") | 4453 gl_arg_strings.append("3") |
4094 # the number of elements requested in the command. | 4454 # the number of elements requested in the command. |
4095 arg_strings.append("5") | 4455 arg_strings.append("5") |
4096 else: | 4456 else: |
4097 gl_arg_strings.append(arg.GetValidGLArg(func, count, 0)) | 4457 gl_arg_strings.append(arg.GetValidGLArg(func, count, 0)) |
4098 arg_strings.append(arg.GetValidArg(func, count, 0)) | 4458 arg_strings.append(arg.GetValidArg(func, count, 0)) |
4099 count += 1 | |
4100 extra = { | 4459 extra = { |
4101 'gl_args': ", ".join(gl_arg_strings), | 4460 'gl_args': ", ".join(gl_arg_strings), |
4102 'args': ", ".join(arg_strings), | 4461 'args': ", ".join(arg_strings), |
4103 } | 4462 } |
4104 self.WriteValidUnitTest(func, file, valid_test, extra) | 4463 self.WriteValidUnitTest(func, file, valid_test, extra) |
4105 | 4464 |
4106 def WriteImmediateServiceUnitTest(self, func, file): | 4465 def WriteImmediateServiceUnitTest(self, func, file): |
4107 """Overridden from TypeHandler.""" | 4466 """Overridden from TypeHandler.""" |
4108 valid_test = """ | 4467 valid_test = """ |
4109 TEST_F(%(test_name)s, %(name)sValidArgs) { | 4468 TEST_F(%(test_name)s, %(name)sValidArgs) { |
4110 %(name)s& cmd = *GetImmediateAs<%(name)s>(); | 4469 %(name)s& cmd = *GetImmediateAs<%(name)s>(); |
4111 EXPECT_CALL( | 4470 EXPECT_CALL( |
4112 *gl_, | 4471 *gl_, |
4113 %(gl_func_name)s(%(gl_args)s, | 4472 %(gl_func_name)s(%(gl_args)s, |
4114 reinterpret_cast<%(data_type)s*>(ImmediateDataAddress(&cmd)))); | 4473 reinterpret_cast<%(data_type)s*>(ImmediateDataAddress(&cmd)))); |
4115 SpecializedSetup<%(name)s, 0>(true); | 4474 SpecializedSetup<%(name)s, 0>(true); |
4116 %(data_type)s temp[%(data_count)s * 2] = { 0, }; | 4475 %(data_type)s temp[%(data_count)s * 2] = { 0, }; |
4117 cmd.Init(%(args)s, &temp[0]); | 4476 cmd.Init(%(args)s, &temp[0]); |
4118 EXPECT_EQ(error::kNoError, | 4477 EXPECT_EQ(error::kNoError, |
4119 ExecuteImmediateCmd(cmd, sizeof(temp))); | 4478 ExecuteImmediateCmd(cmd, sizeof(temp))); |
4120 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4479 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
4121 } | 4480 } |
4122 """ | 4481 """ |
4123 gl_arg_strings = [] | 4482 gl_arg_strings = [] |
4124 gl_any_strings = [] | 4483 gl_any_strings = [] |
4125 arg_strings = [] | 4484 arg_strings = [] |
4126 count = 0 | 4485 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]): |
4127 for arg in func.GetOriginalArgs()[0:-1]: | |
4128 gl_arg_strings.append(arg.GetValidGLArg(func, count, 0)) | 4486 gl_arg_strings.append(arg.GetValidGLArg(func, count, 0)) |
4129 gl_any_strings.append("_") | 4487 gl_any_strings.append("_") |
4130 arg_strings.append(arg.GetValidArg(func, count, 0)) | 4488 arg_strings.append(arg.GetValidArg(func, count, 0)) |
4131 count += 1 | |
4132 extra = { | 4489 extra = { |
4133 'data_type': func.GetInfo('data_type'), | 4490 'data_type': func.GetInfo('data_type'), |
4134 'data_count': func.GetInfo('count'), | 4491 'data_count': func.GetInfo('count'), |
4135 'args': ", ".join(arg_strings), | 4492 'args': ", ".join(arg_strings), |
4136 'gl_args': ", ".join(gl_arg_strings), | 4493 'gl_args': ", ".join(gl_arg_strings), |
4137 'gl_any_args': ", ".join(gl_any_strings), | 4494 'gl_any_args': ", ".join(gl_any_strings), |
4138 } | 4495 } |
4139 self.WriteValidUnitTest(func, file, valid_test, extra) | 4496 self.WriteValidUnitTest(func, file, valid_test, extra) |
4140 | 4497 |
4141 invalid_test = """ | 4498 invalid_test = """ |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4203 for (int jj = 0; jj < %(count)d; ++jj) { | 4560 for (int jj = 0; jj < %(count)d; ++jj) { |
4204 expected.data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj); | 4561 expected.data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj); |
4205 } | 4562 } |
4206 } | 4563 } |
4207 expected.cmd.Init(%(cmd_args)s, &expected.data[0][0]); | 4564 expected.cmd.Init(%(cmd_args)s, &expected.data[0][0]); |
4208 gl_->%(name)s(%(args)s, &expected.data[0][0]); | 4565 gl_->%(name)s(%(args)s, &expected.data[0][0]); |
4209 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 4566 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
4210 } | 4567 } |
4211 """ | 4568 """ |
4212 cmd_arg_strings = [] | 4569 cmd_arg_strings = [] |
4213 count = 0 | 4570 for count, arg in enumerate(func.GetCmdArgs()[0:-2]): |
4214 for arg in func.GetCmdArgs()[0:-2]: | |
4215 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) | 4571 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) |
4216 count += 1 | |
4217 gl_arg_strings = [] | 4572 gl_arg_strings = [] |
4218 count = 0 | 4573 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]): |
4219 for arg in func.GetOriginalArgs()[0:-1]: | |
4220 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) | 4574 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) |
4221 count += 1 | |
4222 file.Write(code % { | 4575 file.Write(code % { |
4223 'name': func.name, | 4576 'name': func.name, |
4224 'type': func.GetInfo('data_type'), | 4577 'type': func.GetInfo('data_type'), |
4225 'count': func.GetInfo('count'), | 4578 'count': func.GetInfo('count'), |
4226 'args': ", ".join(gl_arg_strings), | 4579 'args': ", ".join(gl_arg_strings), |
4227 'cmd_args': ", ".join(cmd_arg_strings), | 4580 'cmd_args': ", ".join(cmd_arg_strings), |
4228 }) | 4581 }) |
4229 | 4582 |
4230 def WriteImmediateCmdComputeSize(self, func, file): | 4583 def WriteImmediateCmdComputeSize(self, func, file): |
4231 """Overrriden from TypeHandler.""" | 4584 """Overrriden from TypeHandler.""" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4308 (func.info.data_type, v)) | 4661 (func.info.data_type, v)) |
4309 file.Write(" };\n") | 4662 file.Write(" };\n") |
4310 file.Write(" %s& cmd = *GetBufferAs<%s>();\n" % (func.name, func.name)) | 4663 file.Write(" %s& cmd = *GetBufferAs<%s>();\n" % (func.name, func.name)) |
4311 file.Write(" const GLsizei kNumElements = 2;\n") | 4664 file.Write(" const GLsizei kNumElements = 2;\n") |
4312 file.Write(" const size_t kExpectedCmdSize =\n") | 4665 file.Write(" const size_t kExpectedCmdSize =\n") |
4313 file.Write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" % | 4666 file.Write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" % |
4314 (func.info.data_type, func.info.count)) | 4667 (func.info.data_type, func.info.count)) |
4315 file.Write(" void* next_cmd = cmd.Set(\n") | 4668 file.Write(" void* next_cmd = cmd.Set(\n") |
4316 file.Write(" &cmd") | 4669 file.Write(" &cmd") |
4317 args = func.GetCmdArgs() | 4670 args = func.GetCmdArgs() |
4318 value = 1 | 4671 for value, arg in enumerate(args): |
4319 for arg in args: | 4672 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 1)) |
4320 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) | |
4321 value += 1 | |
4322 file.Write(",\n data);\n") | 4673 file.Write(",\n data);\n") |
4323 args = func.GetCmdArgs() | 4674 args = func.GetCmdArgs() |
4324 value = 1 | |
4325 file.Write(" EXPECT_EQ(static_cast<uint32>(%s::kCmdId),\n" % func.name) | 4675 file.Write(" EXPECT_EQ(static_cast<uint32>(%s::kCmdId),\n" % func.name) |
4326 file.Write(" cmd.header.command);\n") | 4676 file.Write(" cmd.header.command);\n") |
4327 file.Write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n") | 4677 file.Write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n") |
4328 for arg in args: | 4678 for value, arg in enumerate(args): |
4329 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % | 4679 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % |
4330 (arg.type, value, arg.name)) | 4680 (arg.type, value + 1, arg.name)) |
4331 value += 1 | |
4332 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") | 4681 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") |
4333 file.Write(" next_cmd, sizeof(cmd) +\n") | 4682 file.Write(" next_cmd, sizeof(cmd) +\n") |
4334 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") | 4683 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") |
4335 file.Write(" // TODO(gman): Check that data was inserted;\n") | 4684 file.Write(" // TODO(gman): Check that data was inserted;\n") |
4336 file.Write("}\n") | 4685 file.Write("}\n") |
4337 file.Write("\n") | 4686 file.Write("\n") |
4338 | 4687 |
4339 | 4688 |
4340 class PUTXnHandler(TypeHandler): | 4689 class PUTXnHandler(TypeHandler): |
4341 """Handler for glUniform?f functions.""" | 4690 """Handler for glUniform?f functions.""" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4469 "typed_args": func.MakeTypedOriginalArgString(""), | 4818 "typed_args": func.MakeTypedOriginalArgString(""), |
4470 "args": func.MakeOriginalArgString(""), | 4819 "args": func.MakeOriginalArgString(""), |
4471 }) | 4820 }) |
4472 | 4821 |
4473 | 4822 |
4474 def WriteImmediateFormatTest(self, func, file): | 4823 def WriteImmediateFormatTest(self, func, file): |
4475 """Overrriden from TypeHandler.""" | 4824 """Overrriden from TypeHandler.""" |
4476 init_code = [] | 4825 init_code = [] |
4477 check_code = [] | 4826 check_code = [] |
4478 all_but_last_arg = func.GetCmdArgs()[:-1] | 4827 all_but_last_arg = func.GetCmdArgs()[:-1] |
4479 value = 11 | 4828 for value, arg in enumerate(all_but_last_arg): |
4480 for arg in all_but_last_arg: | 4829 init_code.append(" static_cast<%s>(%d)," % (arg.type, value + 11)) |
4481 init_code.append(" static_cast<%s>(%d)," % (arg.type, value)) | 4830 for value, arg in enumerate(all_but_last_arg): |
4482 value += 1 | |
4483 value = 11 | |
4484 for arg in all_but_last_arg: | |
4485 check_code.append(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);" % | 4831 check_code.append(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);" % |
4486 (arg.type, value, arg.name)) | 4832 (arg.type, value + 11, arg.name)) |
4487 value += 1 | |
4488 code = """ | 4833 code = """ |
4489 TEST_F(GLES2FormatTest, %(func_name)s) { | 4834 TEST_F(GLES2FormatTest, %(func_name)s) { |
4490 %(func_name)s& cmd = *GetBufferAs<%(func_name)s>(); | 4835 %(func_name)s& cmd = *GetBufferAs<%(func_name)s>(); |
4491 static const char* const test_str = \"test string\"; | 4836 static const char* const test_str = \"test string\"; |
4492 void* next_cmd = cmd.Set( | 4837 void* next_cmd = cmd.Set( |
4493 &cmd, | 4838 &cmd, |
4494 %(init_code)s | 4839 %(init_code)s |
4495 test_str, | 4840 test_str, |
4496 strlen(test_str)); | 4841 strlen(test_str)); |
4497 EXPECT_EQ(static_cast<uint32>(%(func_name)s::kCmdId), | 4842 EXPECT_EQ(static_cast<uint32>(%(func_name)s::kCmdId), |
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5934 'GETn': GETnHandler(), | 6279 'GETn': GETnHandler(), |
5935 'GLchar': GLcharHandler(), | 6280 'GLchar': GLcharHandler(), |
5936 'GLcharN': GLcharNHandler(), | 6281 'GLcharN': GLcharNHandler(), |
5937 'HandWritten': HandWrittenHandler(), | 6282 'HandWritten': HandWrittenHandler(), |
5938 'Is': IsHandler(), | 6283 'Is': IsHandler(), |
5939 'Manual': ManualHandler(), | 6284 'Manual': ManualHandler(), |
5940 'PUT': PUTHandler(), | 6285 'PUT': PUTHandler(), |
5941 'PUTn': PUTnHandler(), | 6286 'PUTn': PUTnHandler(), |
5942 'PUTXn': PUTXnHandler(), | 6287 'PUTXn': PUTXnHandler(), |
5943 'StateSet': StateSetHandler(), | 6288 'StateSet': StateSetHandler(), |
| 6289 'StateSetRGBAlpha': StateSetRGBAlphaHandler(), |
| 6290 'StateSetFrontBack': StateSetFrontBackHandler(), |
| 6291 'StateSetFrontBackSeparate': StateSetFrontBackSeparateHandler(), |
5944 'STRn': STRnHandler(), | 6292 'STRn': STRnHandler(), |
5945 'Todo': TodoHandler(), | 6293 'Todo': TodoHandler(), |
5946 } | 6294 } |
5947 | 6295 |
5948 for func_name in _FUNCTION_INFO: | 6296 for func_name in _FUNCTION_INFO: |
5949 info = _FUNCTION_INFO[func_name] | 6297 info = _FUNCTION_INFO[func_name] |
5950 type = '' | 6298 type = '' |
5951 if 'type' in info: | 6299 if 'type' in info: |
5952 type = info['type'] | 6300 type = info['type'] |
5953 self._function_info[func_name] = FunctionInfo(info, | 6301 self._function_info[func_name] = FunctionInfo(info, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6131 file = CHeaderWriter(filename) | 6479 file = CHeaderWriter(filename) |
6132 | 6480 |
6133 for func in self.functions: | 6481 for func in self.functions: |
6134 if True: | 6482 if True: |
6135 #gen_cmd = func.GetInfo('gen_cmd') | 6483 #gen_cmd = func.GetInfo('gen_cmd') |
6136 #if gen_cmd == True or gen_cmd == None: | 6484 #if gen_cmd == True or gen_cmd == None: |
6137 func.WriteCmdHelper(file) | 6485 func.WriteCmdHelper(file) |
6138 | 6486 |
6139 file.Close() | 6487 file.Close() |
6140 | 6488 |
| 6489 def WriteContextStateHeader(self, filename): |
| 6490 """Writes the context state header.""" |
| 6491 file = CHeaderWriter( |
| 6492 filename, |
| 6493 "// It is included by context_state.h\n") |
| 6494 file.Write("struct EnableFlags {\n") |
| 6495 file.Write(" EnableFlags();\n") |
| 6496 for capability in _CAPABILITY_FLAGS: |
| 6497 file.Write(" bool %s;\n" % capability['name']) |
| 6498 file.Write("};\n\n") |
| 6499 |
| 6500 for state_name in sorted(_STATES.keys()): |
| 6501 state = _STATES[state_name] |
| 6502 for item in state['states']: |
| 6503 file.Write("%s %s;\n" % (item['type'], item['name'])) |
| 6504 file.Write("\n") |
| 6505 |
| 6506 file.Close() |
| 6507 |
| 6508 def WriteContextStateImpl(self, filename): |
| 6509 """Writes the context state implementation.""" |
| 6510 file = CHeaderWriter( |
| 6511 filename, |
| 6512 "// It is included by context_state.cc\n") |
| 6513 code = [] |
| 6514 for capability in _CAPABILITY_FLAGS: |
| 6515 code.append("%s(%s)" % |
| 6516 (capability['name'], |
| 6517 ('false', 'true')['default' in capability])) |
| 6518 file.Write("ContextState::EnableFlags::EnableFlags()\n : %s {\n}\n" % |
| 6519 ",\n ".join(code)) |
| 6520 file.Write("\n") |
| 6521 |
| 6522 file.Write("void ContextState::Initialize() {\n") |
| 6523 for state_name in sorted(_STATES.keys()): |
| 6524 state = _STATES[state_name] |
| 6525 for item in state['states']: |
| 6526 file.Write(" %s = %s;\n" % (item['name'], item['default'])) |
| 6527 file.Write("}\n\n"); |
| 6528 |
| 6529 file.Close() |
| 6530 |
6141 def WriteServiceImplementation(self, filename): | 6531 def WriteServiceImplementation(self, filename): |
6142 """Writes the service decorder implementation.""" | 6532 """Writes the service decorder implementation.""" |
6143 file = CHeaderWriter( | 6533 file = CHeaderWriter( |
6144 filename, | 6534 filename, |
6145 "// It is included by gles2_cmd_decoder.cc\n") | 6535 "// It is included by gles2_cmd_decoder.cc\n") |
6146 | 6536 |
6147 for func in self.functions: | 6537 for func in self.functions: |
6148 if True: | 6538 if True: |
6149 #gen_cmd = func.GetInfo('gen_cmd') | 6539 #gen_cmd = func.GetInfo('gen_cmd') |
6150 #if gen_cmd == True or gen_cmd == None: | 6540 #if gen_cmd == True or gen_cmd == None: |
6151 func.WriteServiceImplementation(file) | 6541 func.WriteServiceImplementation(file) |
6152 | 6542 |
| 6543 file.Write(""" |
| 6544 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { |
| 6545 switch (cap) { |
| 6546 """) |
| 6547 for capability in _CAPABILITY_FLAGS: |
| 6548 file.Write(" case GL_%s:\n" % capability['name'].upper()) |
| 6549 if 'state_flag' in capability: |
| 6550 file.Write(""" if (state_.enable_flags.%(name)s != enabled) { |
| 6551 state_.enable_flags.%(name)s = enabled; |
| 6552 %(state_flag)s = true; |
| 6553 } |
| 6554 return false; |
| 6555 """ % capability) |
| 6556 else: |
| 6557 file.Write(""" state_.enable_flags.%(name)s = enabled; |
| 6558 return true; |
| 6559 """ % capability) |
| 6560 file.Write(""" default: |
| 6561 NOTREACHED(); |
| 6562 return false; |
| 6563 } |
| 6564 } |
| 6565 |
| 6566 bool GLES2DecoderImpl::DoIsEnabled(GLenum cap) { |
| 6567 switch (cap) { |
| 6568 """) |
| 6569 for capability in _CAPABILITY_FLAGS: |
| 6570 file.Write(" case GL_%s:\n" % capability['name'].upper()) |
| 6571 file.Write(" return state_.enable_flags.%s;\n" % |
| 6572 capability['name']) |
| 6573 file.Write(""" default: |
| 6574 NOTREACHED(); |
| 6575 return false; |
| 6576 } |
| 6577 } |
| 6578 |
| 6579 void GLES2DecoderImpl::InitCapabilities() { |
| 6580 """) |
| 6581 for capability in _CAPABILITY_FLAGS: |
| 6582 file.Write(" EnableDisable(GL_%s, state_.enable_flags.%s);\n" % |
| 6583 (capability['name'].upper(), capability['name'])) |
| 6584 file.Write("""} |
| 6585 |
| 6586 void GLES2DecoderImpl::InitState() { |
| 6587 """) |
| 6588 |
| 6589 # We need to sort the keys so the expectations match |
| 6590 for state_name in sorted(_STATES.keys()): |
| 6591 state = _STATES[state_name] |
| 6592 if state['type'] == 'FrontBack': |
| 6593 num_states = len(state['states']) |
| 6594 for ndx, group in enumerate(Grouper(num_states / 2, state['states'])): |
| 6595 args = [] |
| 6596 for item in group: |
| 6597 args.append('state_.%s' % item['name']) |
| 6598 file.Write( |
| 6599 " gl%s(%s, %s);\n" % |
| 6600 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args))) |
| 6601 else: |
| 6602 args = [] |
| 6603 for item in state['states']: |
| 6604 args.append('state_.%s' % item['name']) |
| 6605 file.Write(" gl%s(%s);\n" % (state['func'], ", ".join(args))) |
| 6606 file.Write("""} |
| 6607 |
| 6608 bool GLES2DecoderImpl::GetState( |
| 6609 GLenum pname, GLint* params, GLsizei* num_written) { |
| 6610 switch (pname) { |
| 6611 """) |
| 6612 for state_name in _STATES.keys(): |
| 6613 state = _STATES[state_name] |
| 6614 if 'enum' in state: |
| 6615 file.Write(" case %s:\n" % state['enum']) |
| 6616 file.Write(" *num_written = %d;\n" % len(state['states'])) |
| 6617 file.Write(" if (params) {\n") |
| 6618 for ndx,item in enumerate(state['states']): |
| 6619 file.Write(" params[%d] = state_.%s;\n" % (ndx, item['name'])) |
| 6620 file.Write(" }\n") |
| 6621 file.Write(" return true;\n") |
| 6622 else: |
| 6623 for item in state['states']: |
| 6624 file.Write(" case %s:\n" % item['enum']) |
| 6625 file.Write(" *num_written = 1;\n") |
| 6626 file.Write(" if (params) {\n") |
| 6627 file.Write(" params[0] = state_.%s;\n" % item['name']) |
| 6628 file.Write(" }\n") |
| 6629 file.Write(" return true;\n") |
| 6630 for capability in _CAPABILITY_FLAGS: |
| 6631 file.Write(" case GL_%s:\n" % capability['name'].upper()) |
| 6632 file.Write(" *num_written = 1;\n") |
| 6633 file.Write(" if (params) {\n") |
| 6634 file.Write(" params[0] = state_.enable_flags.%s;\n" % |
| 6635 capability['name']) |
| 6636 file.Write(" }\n") |
| 6637 file.Write(" return true;\n") |
| 6638 file.Write(""" default: |
| 6639 return false; |
| 6640 } |
| 6641 } |
| 6642 """) |
6153 file.Close() | 6643 file.Close() |
6154 | 6644 |
6155 def WriteServiceUnitTests(self, filename): | 6645 def WriteServiceUnitTests(self, filename): |
6156 """Writes the service decorder unit tests.""" | 6646 """Writes the service decorder unit tests.""" |
6157 num_tests = len(self.functions) | 6647 num_tests = len(self.functions) |
6158 FUNCTIONS_PER_FILE = 98 # hard code this so it doesn't change. | 6648 FUNCTIONS_PER_FILE = 98 # hard code this so it doesn't change. |
6159 count = 0 | 6649 count = 0 |
6160 for test_num in range(0, num_tests, FUNCTIONS_PER_FILE): | 6650 for test_num in range(0, num_tests, FUNCTIONS_PER_FILE): |
6161 count += 1 | 6651 count += 1 |
6162 name = filename % count | 6652 name = filename % count |
6163 file = CHeaderWriter( | 6653 file = CHeaderWriter( |
6164 name, | 6654 name, |
6165 "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" % count) | 6655 "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" % count) |
6166 file.SetFileNum(count) | 6656 file.SetFileNum(count) |
6167 end = test_num + FUNCTIONS_PER_FILE | 6657 end = test_num + FUNCTIONS_PER_FILE |
6168 if end > num_tests: | 6658 if end > num_tests: |
6169 end = num_tests | 6659 end = num_tests |
6170 for idx in range(test_num, end): | 6660 for idx in range(test_num, end): |
6171 func = self.functions[idx] | 6661 func = self.functions[idx] |
6172 if True: | 6662 if True: |
6173 #gen_cmd = func.GetInfo('gen_cmd') | 6663 #gen_cmd = func.GetInfo('gen_cmd') |
6174 #if gen_cmd == True or gen_cmd == None: | 6664 #if gen_cmd == True or gen_cmd == None: |
6175 if func.GetInfo('unit_test') == False: | 6665 if func.GetInfo('unit_test') == False: |
6176 file.Write("// TODO(gman): %s\n" % func.name) | 6666 file.Write("// TODO(gman): %s\n" % func.name) |
6177 else: | 6667 else: |
6178 func.WriteServiceUnitTest(file) | 6668 func.WriteServiceUnitTest(file) |
6179 | 6669 |
6180 file.Close() | 6670 file.Close() |
| 6671 file = CHeaderWriter( |
| 6672 filename % 0, |
| 6673 "// It is included by gles2_cmd_decoder_unittest_base.cc\n") |
| 6674 file.Write( |
| 6675 """void GLES2DecoderTestBase::SetupInitCapabilitiesExpectations() { |
| 6676 """) |
| 6677 for capability in _CAPABILITY_FLAGS: |
| 6678 file.Write(" ExpectEnableDisable(GL_%s, %s);\n" % |
| 6679 (capability['name'].upper(), |
| 6680 ('false', 'true')['default' in capability])) |
| 6681 file.Write("""} |
| 6682 |
| 6683 void GLES2DecoderTestBase::SetupInitStateExpectations() { |
| 6684 """) |
| 6685 |
| 6686 # We need to sort the keys so the expectations match |
| 6687 for state_name in sorted(_STATES.keys()): |
| 6688 state = _STATES[state_name] |
| 6689 if state['type'] == 'FrontBack': |
| 6690 num_states = len(state['states']) |
| 6691 for ndx, group in enumerate(Grouper(num_states / 2, state['states'])): |
| 6692 args = [] |
| 6693 for item in group: |
| 6694 if 'expected' in item: |
| 6695 args.append(item['expected']) |
| 6696 else: |
| 6697 args.append(item['default']) |
| 6698 file.Write( |
| 6699 " EXPECT_CALL(*gl_, %s(%s, %s))\n" % |
| 6700 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args))) |
| 6701 file.Write(" .Times(1)\n") |
| 6702 file.Write(" .RetiresOnSaturation();\n") |
| 6703 else: |
| 6704 args = [] |
| 6705 for item in state['states']: |
| 6706 if 'expected' in item: |
| 6707 args.append(item['expected']) |
| 6708 else: |
| 6709 args.append(item['default']) |
| 6710 file.Write(" EXPECT_CALL(*gl_, %s(%s))\n" % |
| 6711 (state['func'], ", ".join(args))) |
| 6712 file.Write(" .Times(1)\n") |
| 6713 file.Write(" .RetiresOnSaturation();\n") |
| 6714 file.Write("""} |
| 6715 """) |
| 6716 file.Close() |
6181 | 6717 |
6182 | 6718 |
6183 def WriteGLES2CLibImplementation(self, filename): | 6719 def WriteGLES2CLibImplementation(self, filename): |
6184 """Writes the GLES2 c lib implementation.""" | 6720 """Writes the GLES2 c lib implementation.""" |
6185 file = CHeaderWriter( | 6721 file = CHeaderWriter( |
6186 filename, | 6722 filename, |
6187 "// These functions emulate GLES2 over command buffers.\n") | 6723 "// These functions emulate GLES2 over command buffers.\n") |
6188 | 6724 |
6189 for func in self.original_functions: | 6725 for func in self.original_functions: |
6190 func.WriteGLES2CLibImplementation(file) | 6726 func.WriteGLES2CLibImplementation(file) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6267 if len(_ENUM_LISTS[enum]['valid']) > 0: | 6803 if len(_ENUM_LISTS[enum]['valid']) > 0: |
6268 file.Write("static %s valid_%s_table[] = {\n" % | 6804 file.Write("static %s valid_%s_table[] = {\n" % |
6269 (_ENUM_LISTS[enum]['type'], ToUnderscore(enum))) | 6805 (_ENUM_LISTS[enum]['type'], ToUnderscore(enum))) |
6270 for value in _ENUM_LISTS[enum]['valid']: | 6806 for value in _ENUM_LISTS[enum]['valid']: |
6271 file.Write(" %s,\n" % value) | 6807 file.Write(" %s,\n" % value) |
6272 file.Write("};\n") | 6808 file.Write("};\n") |
6273 file.Write("\n") | 6809 file.Write("\n") |
6274 file.Write("Validators::Validators()\n") | 6810 file.Write("Validators::Validators()\n") |
6275 pre = ': ' | 6811 pre = ': ' |
6276 post = ',' | 6812 post = ',' |
6277 count = 0 | 6813 for count, enum in enumerate(enums): |
6278 for enum in enums: | 6814 if count + 1 == len(enums): |
6279 count += 1 | |
6280 if count == len(enums): | |
6281 post = ' {' | 6815 post = ' {' |
6282 if len(_ENUM_LISTS[enum]['valid']) > 0: | 6816 if len(_ENUM_LISTS[enum]['valid']) > 0: |
6283 code = """ %(pre)s%(name)s( | 6817 code = """ %(pre)s%(name)s( |
6284 valid_%(name)s_table, arraysize(valid_%(name)s_table))%(post)s | 6818 valid_%(name)s_table, arraysize(valid_%(name)s_table))%(post)s |
6285 """ | 6819 """ |
6286 else: | 6820 else: |
6287 code = """ %(pre)s%(name)s()%(post)s | 6821 code = """ %(pre)s%(name)s()%(post)s |
6288 """ | 6822 """ |
6289 file.Write(code % { | 6823 file.Write(code % { |
6290 'name': ToUnderscore(enum), | 6824 'name': ToUnderscore(enum), |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6575 parser.add_option( | 7109 parser.add_option( |
6576 "--output-dir", | 7110 "--output-dir", |
6577 help="base directory for resulting files, under chrome/src. default is " | 7111 help="base directory for resulting files, under chrome/src. default is " |
6578 "empty. Use this if you want the result stored under gen.") | 7112 "empty. Use this if you want the result stored under gen.") |
6579 parser.add_option( | 7113 parser.add_option( |
6580 "-v", "--verbose", action="store_true", | 7114 "-v", "--verbose", action="store_true", |
6581 help="prints more output.") | 7115 help="prints more output.") |
6582 | 7116 |
6583 (options, args) = parser.parse_args(args=argv) | 7117 (options, args) = parser.parse_args(args=argv) |
6584 | 7118 |
| 7119 # Add in states and capabilites to GLState |
| 7120 for state_name in sorted(_STATES.keys()): |
| 7121 state = _STATES[state_name] |
| 7122 if 'enum' in state: |
| 7123 _ENUM_LISTS['GLState']['valid'].append(state['enum']) |
| 7124 else: |
| 7125 for item in state['states']: |
| 7126 _ENUM_LISTS['GLState']['valid'].append(item['enum']) |
| 7127 for capability in _CAPABILITY_FLAGS: |
| 7128 _ENUM_LISTS['GLState']['valid'].append("GL_%s" % capability['name'].upper()) |
| 7129 |
6585 # This script lives under gpu/command_buffer, cd to base directory. | 7130 # This script lives under gpu/command_buffer, cd to base directory. |
6586 os.chdir(os.path.dirname(__file__) + "/../..") | 7131 os.chdir(os.path.dirname(__file__) + "/../..") |
6587 | 7132 |
6588 gen = GLGenerator(options.verbose) | 7133 gen = GLGenerator(options.verbose) |
6589 gen.ParseGLH("common/GLES2/gl2.h") | 7134 gen.ParseGLH("common/GLES2/gl2.h") |
6590 | 7135 |
6591 # Support generating files under gen/ | 7136 # Support generating files under gen/ |
6592 if options.output_dir != None: | 7137 if options.output_dir != None: |
6593 os.chdir(options.output_dir) | 7138 os.chdir(options.output_dir) |
6594 | 7139 |
(...skipping 23 matching lines...) Expand all Loading... |
6618 gen.WriteGLES2InterfaceStub("client/gles2_interface_stub_autogen.h") | 7163 gen.WriteGLES2InterfaceStub("client/gles2_interface_stub_autogen.h") |
6619 gen.WriteGLES2InterfaceStubImpl( | 7164 gen.WriteGLES2InterfaceStubImpl( |
6620 "client/gles2_interface_stub_impl_autogen.h") | 7165 "client/gles2_interface_stub_impl_autogen.h") |
6621 gen.WriteGLES2ImplementationHeader("client/gles2_implementation_autogen.h") | 7166 gen.WriteGLES2ImplementationHeader("client/gles2_implementation_autogen.h") |
6622 gen.WriteGLES2Implementation("client/gles2_implementation_impl_autogen.h") | 7167 gen.WriteGLES2Implementation("client/gles2_implementation_impl_autogen.h") |
6623 gen.WriteGLES2ImplementationUnitTests( | 7168 gen.WriteGLES2ImplementationUnitTests( |
6624 "client/gles2_implementation_unittest_autogen.h") | 7169 "client/gles2_implementation_unittest_autogen.h") |
6625 gen.WriteGLES2CLibImplementation("client/gles2_c_lib_autogen.h") | 7170 gen.WriteGLES2CLibImplementation("client/gles2_c_lib_autogen.h") |
6626 gen.WriteCmdHelperHeader("client/gles2_cmd_helper_autogen.h") | 7171 gen.WriteCmdHelperHeader("client/gles2_cmd_helper_autogen.h") |
6627 gen.WriteServiceImplementation("service/gles2_cmd_decoder_autogen.h") | 7172 gen.WriteServiceImplementation("service/gles2_cmd_decoder_autogen.h") |
| 7173 gen.WriteContextStateHeader("service/context_state_autogen.h") |
| 7174 gen.WriteContextStateImpl("service/context_state_impl_autogen.h") |
6628 gen.WriteServiceUnitTests("service/gles2_cmd_decoder_unittest_%d_autogen.h") | 7175 gen.WriteServiceUnitTests("service/gles2_cmd_decoder_unittest_%d_autogen.h") |
6629 gen.WriteServiceUtilsHeader("service/gles2_cmd_validation_autogen.h") | 7176 gen.WriteServiceUtilsHeader("service/gles2_cmd_validation_autogen.h") |
6630 gen.WriteServiceUtilsImplementation( | 7177 gen.WriteServiceUtilsImplementation( |
6631 "service/gles2_cmd_validation_implementation_autogen.h") | 7178 "service/gles2_cmd_validation_implementation_autogen.h") |
6632 gen.WriteCommonUtilsHeader("common/gles2_cmd_utils_autogen.h") | 7179 gen.WriteCommonUtilsHeader("common/gles2_cmd_utils_autogen.h") |
6633 gen.WriteCommonUtilsImpl("common/gles2_cmd_utils_implementation_autogen.h") | 7180 gen.WriteCommonUtilsImpl("common/gles2_cmd_utils_implementation_autogen.h") |
6634 | 7181 |
6635 if gen.errors > 0: | 7182 if gen.errors > 0: |
6636 print "%d errors" % gen.errors | 7183 print "%d errors" % gen.errors |
6637 return 1 | 7184 return 1 |
6638 return 0 | 7185 return 0 |
6639 | 7186 |
6640 | 7187 |
6641 if __name__ == '__main__': | 7188 if __name__ == '__main__': |
6642 sys.exit(main(sys.argv[1:])) | 7189 sys.exit(main(sys.argv[1:])) |
OLD | NEW |