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 itertools |
9 import os | 9 import os |
10 import os.path | 10 import os.path |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 'LineWidth': { | 418 'LineWidth': { |
419 'type': 'Normal', | 419 'type': 'Normal', |
420 'func': 'LineWidth', | 420 'func': 'LineWidth', |
421 'enum': 'GL_LINE_WIDTH', | 421 'enum': 'GL_LINE_WIDTH', |
422 'states': [ | 422 'states': [ |
423 { | 423 { |
424 'name': 'line_width', | 424 'name': 'line_width', |
425 'type': 'GLfloat', | 425 'type': 'GLfloat', |
426 'default': '1.0f', | 426 'default': '1.0f', |
427 'range_checks': [{'check': "<= 0.0f", 'test_value': "0.0f"}], | 427 'range_checks': [{'check': "<= 0.0f", 'test_value': "0.0f"}], |
| 428 # This works around an NVIDIA driver bug, where an INVALID_VALUE error |
| 429 # is generated if line width is set to NaN. The consequences of setting |
| 430 # line width to NaN are undefined, so we just set it to an arbitrary |
| 431 # valid value. |
| 432 'convert_nan': '1.0f', |
428 }], | 433 }], |
429 }, | 434 }, |
430 'DepthMask': { | 435 'DepthMask': { |
431 'type': 'Normal', | 436 'type': 'Normal', |
432 'func': 'DepthMask', | 437 'func': 'DepthMask', |
433 'enum': 'GL_DEPTH_WRITEMASK', | 438 'enum': 'GL_DEPTH_WRITEMASK', |
434 'states': [ | 439 'states': [ |
435 { | 440 { |
436 'name': 'depth_mask', | 441 'name': 'depth_mask', |
437 'type': 'GLboolean', | 442 'type': 'GLboolean', |
(...skipping 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3343 file.Write(" if (%s) {\n" % " ||\n ".join(code)) | 3348 file.Write(" if (%s) {\n" % " ||\n ".join(code)) |
3344 for ndx,item in enumerate(states): | 3349 for ndx,item in enumerate(states): |
3345 file.Write(" state_.%s = %s;\n" % (item['name'], args[ndx].name)) | 3350 file.Write(" state_.%s = %s;\n" % (item['name'], args[ndx].name)) |
3346 if 'state_flag' in state: | 3351 if 'state_flag' in state: |
3347 file.Write(" %s = true;\n" % state['state_flag']) | 3352 file.Write(" %s = true;\n" % state['state_flag']) |
3348 if not func.GetInfo("no_gl"): | 3353 if not func.GetInfo("no_gl"): |
3349 for ndx,item in enumerate(states): | 3354 for ndx,item in enumerate(states): |
3350 if item.get('cached', False): | 3355 if item.get('cached', False): |
3351 file.Write(" state_.%s = %s;\n" % | 3356 file.Write(" state_.%s = %s;\n" % |
3352 (CachedStateName(item), args[ndx].name)) | 3357 (CachedStateName(item), args[ndx].name)) |
| 3358 if 'convert_nan' in item: |
| 3359 file.Write(' if (base::IsNaN(%s)) {' % args[ndx].name) |
| 3360 file.Write(' %s = %s;' % (args[ndx].name, item['convert_nan'])) |
| 3361 file.Write(' }\n') |
| 3362 |
3353 file.Write(" %s(%s);\n" % | 3363 file.Write(" %s(%s);\n" % |
3354 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 3364 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
3355 file.Write(" }\n") | 3365 file.Write(" }\n") |
3356 | 3366 |
3357 def WriteServiceUnitTest(self, func, file): | 3367 def WriteServiceUnitTest(self, func, file): |
3358 """Overrriden from TypeHandler.""" | 3368 """Overrriden from TypeHandler.""" |
3359 TypeHandler.WriteServiceUnitTest(self, func, file) | 3369 TypeHandler.WriteServiceUnitTest(self, func, file) |
3360 state_name = func.GetInfo('state') | 3370 state_name = func.GetInfo('state') |
3361 state = _STATES[state_name] | 3371 state = _STATES[state_name] |
3362 states = state['states'] | 3372 states = state['states'] |
(...skipping 4242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7605 args = [] | 7615 args = [] |
7606 for place, item in enumerate(state['states']): | 7616 for place, item in enumerate(state['states']): |
7607 item_name = CachedStateName(item) | 7617 item_name = CachedStateName(item) |
7608 args.append('%s' % item_name) | 7618 args.append('%s' % item_name) |
7609 if test_prev: | 7619 if test_prev: |
7610 if place > 0: | 7620 if place > 0: |
7611 file.Write(' ||\n') | 7621 file.Write(' ||\n') |
7612 file.Write("(%s != prev_state->%s)" % | 7622 file.Write("(%s != prev_state->%s)" % |
7613 (item_name, item_name)) | 7623 (item_name, item_name)) |
7614 if test_prev: | 7624 if test_prev: |
7615 file.Write(" )\n") | 7625 file.Write(" ) {\n") |
| 7626 for place, item in enumerate(state['states']): |
| 7627 if 'convert_nan' in item: |
| 7628 item_name = CachedStateName(item) |
| 7629 args[place] = 'sanitized_%s' % item_name |
| 7630 file.Write(' %s %s = %s;' % |
| 7631 (item['type'], args[place], item_name)) |
| 7632 file.Write(' if (base::IsNaN(%s))' % item_name) |
| 7633 file.Write(' %s = %s;' % (args[place], item['convert_nan'])) |
7616 file.Write(" gl%s(%s);\n" % (state['func'], ", ".join(args))) | 7634 file.Write(" gl%s(%s);\n" % (state['func'], ", ".join(args))) |
| 7635 if test_prev: |
| 7636 file.Write(" }\n") |
7617 | 7637 |
7618 file.Write(" if (prev_state) {") | 7638 file.Write(" if (prev_state) {") |
7619 WriteStates(True) | 7639 WriteStates(True) |
7620 file.Write(" } else {") | 7640 file.Write(" } else {") |
7621 WriteStates(False) | 7641 WriteStates(False) |
7622 file.Write(" }") | 7642 file.Write(" }") |
7623 | 7643 |
7624 file.Write("}\n") | 7644 file.Write("}\n") |
7625 | 7645 |
7626 file.Write("""bool ContextState::GetEnabled(GLenum cap) const { | 7646 file.Write("""bool ContextState::GetEnabled(GLenum cap) const { |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8346 "ppapi/shared_impl/ppb_opengles2_shared.cc"]) | 8366 "ppapi/shared_impl/ppb_opengles2_shared.cc"]) |
8347 | 8367 |
8348 if gen.errors > 0: | 8368 if gen.errors > 0: |
8349 print "%d errors" % gen.errors | 8369 print "%d errors" % gen.errors |
8350 return 1 | 8370 return 1 |
8351 return 0 | 8371 return 0 |
8352 | 8372 |
8353 | 8373 |
8354 if __name__ == '__main__': | 8374 if __name__ == '__main__': |
8355 sys.exit(main(sys.argv[1:])) | 8375 sys.exit(main(sys.argv[1:])) |
OLD | NEW |