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

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

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

Powered by Google App Engine
This is Rietveld 408576698