| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 {'name': 'blend'}, | 75 {'name': 'blend'}, |
| 76 {'name': 'cull_face'}, | 76 {'name': 'cull_face'}, |
| 77 {'name': 'depth_test', 'state_flag': 'framebuffer_state_.clear_state_dirty'}, | 77 {'name': 'depth_test', 'state_flag': 'framebuffer_state_.clear_state_dirty'}, |
| 78 {'name': 'dither', 'default': True}, | 78 {'name': 'dither', 'default': True}, |
| 79 {'name': 'polygon_offset_fill'}, | 79 {'name': 'polygon_offset_fill'}, |
| 80 {'name': 'sample_alpha_to_coverage'}, | 80 {'name': 'sample_alpha_to_coverage'}, |
| 81 {'name': 'sample_coverage'}, | 81 {'name': 'sample_coverage'}, |
| 82 {'name': 'scissor_test'}, | 82 {'name': 'scissor_test'}, |
| 83 {'name': 'stencil_test', | 83 {'name': 'stencil_test', |
| 84 'state_flag': 'framebuffer_state_.clear_state_dirty'}, | 84 'state_flag': 'framebuffer_state_.clear_state_dirty'}, |
| 85 {'name': 'primitive_restart_fixed_index', 'es3': True}, |
| 86 {'name': 'rasterizer_discard', 'es3': True}, |
| 85 ] | 87 ] |
| 86 | 88 |
| 87 _STATES = { | 89 _STATES = { |
| 88 'ClearColor': { | 90 'ClearColor': { |
| 89 'type': 'Normal', | 91 'type': 'Normal', |
| 90 'func': 'ClearColor', | 92 'func': 'ClearColor', |
| 91 'enum': 'GL_COLOR_CLEAR_VALUE', | 93 'enum': 'GL_COLOR_CLEAR_VALUE', |
| 92 'states': [ | 94 'states': [ |
| 93 {'name': 'color_clear_red', 'type': 'GLfloat', 'default': '0.0f'}, | 95 {'name': 'color_clear_red', 'type': 'GLfloat', 'default': '0.0f'}, |
| 94 {'name': 'color_clear_green', 'type': 'GLfloat', 'default': '0.0f'}, | 96 {'name': 'color_clear_green', 'type': 'GLfloat', 'default': '0.0f'}, |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 'GL_DST_ALPHA', | 873 'GL_DST_ALPHA', |
| 872 'GL_ONE_MINUS_DST_ALPHA', | 874 'GL_ONE_MINUS_DST_ALPHA', |
| 873 'GL_CONSTANT_COLOR', | 875 'GL_CONSTANT_COLOR', |
| 874 'GL_ONE_MINUS_CONSTANT_COLOR', | 876 'GL_ONE_MINUS_CONSTANT_COLOR', |
| 875 'GL_CONSTANT_ALPHA', | 877 'GL_CONSTANT_ALPHA', |
| 876 'GL_ONE_MINUS_CONSTANT_ALPHA', | 878 'GL_ONE_MINUS_CONSTANT_ALPHA', |
| 877 ], | 879 ], |
| 878 }, | 880 }, |
| 879 'Capability': { | 881 'Capability': { |
| 880 'type': 'GLenum', | 882 'type': 'GLenum', |
| 881 'valid': ["GL_%s" % cap['name'].upper() for cap in _CAPABILITY_FLAGS], | 883 'valid': ["GL_%s" % cap['name'].upper() for cap in _CAPABILITY_FLAGS |
| 884 if 'es3' not in cap or cap['es3'] != True], |
| 885 'valid_es3': ["GL_%s" % cap['name'].upper() for cap in _CAPABILITY_FLAGS |
| 886 if 'es3' in cap and cap['es3'] == True], |
| 882 'invalid': [ | 887 'invalid': [ |
| 883 'GL_CLIP_PLANE0', | 888 'GL_CLIP_PLANE0', |
| 884 'GL_POINT_SPRITE', | 889 'GL_POINT_SPRITE', |
| 885 ], | 890 ], |
| 886 }, | 891 }, |
| 887 'DrawMode': { | 892 'DrawMode': { |
| 888 'type': 'GLenum', | 893 'type': 'GLenum', |
| 889 'valid': [ | 894 'valid': [ |
| 890 'GL_POINTS', | 895 'GL_POINTS', |
| 891 'GL_LINE_STRIP', | 896 'GL_LINE_STRIP', |
| (...skipping 8439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9331 else: | 9336 else: |
| 9332 file.Write(" cached_%s = %s;\n" % (item['name'], item['default'])) | 9337 file.Write(" cached_%s = %s;\n" % (item['name'], item['default'])) |
| 9333 file.Write("}\n") | 9338 file.Write("}\n") |
| 9334 | 9339 |
| 9335 file.Write(""" | 9340 file.Write(""" |
| 9336 void ContextState::InitCapabilities(const ContextState* prev_state) const { | 9341 void ContextState::InitCapabilities(const ContextState* prev_state) const { |
| 9337 """) | 9342 """) |
| 9338 def WriteCapabilities(test_prev): | 9343 def WriteCapabilities(test_prev): |
| 9339 for capability in _CAPABILITY_FLAGS: | 9344 for capability in _CAPABILITY_FLAGS: |
| 9340 capability_name = capability['name'] | 9345 capability_name = capability['name'] |
| 9346 capability_es3 = 'es3' in capability and capability['es3'] == True |
| 9347 es3_test = 'feature_info_->IsES3Capable() && ' if capability_es3 else '' |
| 9341 if test_prev: | 9348 if test_prev: |
| 9342 file.Write(""" if (prev_state->enable_flags.cached_%s != | 9349 file.Write(""" if (%sprev_state->enable_flags.cached_%s != |
| 9343 enable_flags.cached_%s)\n""" % | 9350 enable_flags.cached_%s)\n""" % |
| 9344 (capability_name, capability_name)) | 9351 (es3_test, capability_name, capability_name)) |
| 9352 elif capability_es3: |
| 9353 file.Write(" if (feature_info_->IsES3Capable())\n") |
| 9345 file.Write(" EnableDisable(GL_%s, enable_flags.cached_%s);\n" % | 9354 file.Write(" EnableDisable(GL_%s, enable_flags.cached_%s);\n" % |
| 9346 (capability_name.upper(), capability_name)) | 9355 (capability_name.upper(), capability_name)) |
| 9347 | 9356 |
| 9348 file.Write(" if (prev_state) {") | 9357 file.Write(" if (prev_state) {") |
| 9349 WriteCapabilities(True) | 9358 WriteCapabilities(True) |
| 9350 file.Write(" } else {") | 9359 file.Write(" } else {") |
| 9351 WriteCapabilities(False) | 9360 WriteCapabilities(False) |
| 9352 file.Write(" }") | 9361 file.Write(" }") |
| 9353 | 9362 |
| 9354 file.Write("""} | 9363 file.Write("""} |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10291 Format(gen.generated_cpp_filenames) | 10300 Format(gen.generated_cpp_filenames) |
| 10292 | 10301 |
| 10293 if gen.errors > 0: | 10302 if gen.errors > 0: |
| 10294 print "%d errors" % gen.errors | 10303 print "%d errors" % gen.errors |
| 10295 return 1 | 10304 return 1 |
| 10296 return 0 | 10305 return 0 |
| 10297 | 10306 |
| 10298 | 10307 |
| 10299 if __name__ == '__main__': | 10308 if __name__ == '__main__': |
| 10300 sys.exit(main(sys.argv[1:])) | 10309 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |