| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 'GLintptr': 'long long int', | 69 'GLintptr': 'long long int', |
| 70 'GLsizeiptr': 'long long int' | 70 'GLsizeiptr': 'long long int' |
| 71 } | 71 } |
| 72 | 72 |
| 73 # Capabilites selected with glEnable | 73 # Capabilites selected with glEnable |
| 74 _CAPABILITY_FLAGS = [ | 74 _CAPABILITY_FLAGS = [ |
| 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': 'framebuffer_srgb_ext', 'default': True, 'no_init': True, |
| 80 'extension_flag': 'ext_srgb_write_control'}, |
| 79 {'name': 'polygon_offset_fill'}, | 81 {'name': 'polygon_offset_fill'}, |
| 80 {'name': 'sample_alpha_to_coverage'}, | 82 {'name': 'sample_alpha_to_coverage'}, |
| 81 {'name': 'sample_coverage'}, | 83 {'name': 'sample_coverage'}, |
| 82 {'name': 'scissor_test'}, | 84 {'name': 'scissor_test'}, |
| 83 {'name': 'stencil_test', | 85 {'name': 'stencil_test', |
| 84 'state_flag': 'framebuffer_state_.clear_state_dirty'}, | 86 'state_flag': 'framebuffer_state_.clear_state_dirty'}, |
| 85 {'name': 'rasterizer_discard', 'es3': True}, | 87 {'name': 'rasterizer_discard', 'es3': True}, |
| 86 {'name': 'primitive_restart_fixed_index', 'es3': True}, | 88 {'name': 'primitive_restart_fixed_index', 'es3': True}, |
| 87 {'name': 'multisample_ext', 'default': True, | 89 {'name': 'multisample_ext', 'default': True, |
| 88 'extension_flag': 'ext_multisample_compatibility'}, | 90 'extension_flag': 'ext_multisample_compatibility'}, |
| (...skipping 10081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10170 else: | 10172 else: |
| 10171 f.write(" cached_%s = %s;\n" % (item['name'], item['default'])) | 10173 f.write(" cached_%s = %s;\n" % (item['name'], item['default'])) |
| 10172 f.write("}\n") | 10174 f.write("}\n") |
| 10173 | 10175 |
| 10174 f.write(""" | 10176 f.write(""" |
| 10175 void ContextState::InitCapabilities(const ContextState* prev_state) const { | 10177 void ContextState::InitCapabilities(const ContextState* prev_state) const { |
| 10176 """) | 10178 """) |
| 10177 def WriteCapabilities(test_prev, es3_caps): | 10179 def WriteCapabilities(test_prev, es3_caps): |
| 10178 for capability in _CAPABILITY_FLAGS: | 10180 for capability in _CAPABILITY_FLAGS: |
| 10179 capability_name = capability['name'] | 10181 capability_name = capability['name'] |
| 10182 capability_no_init = 'no_init' in capability and \ |
| 10183 capability['no_init'] == True |
| 10184 if capability_no_init: |
| 10185 continue |
| 10180 capability_es3 = 'es3' in capability and capability['es3'] == True | 10186 capability_es3 = 'es3' in capability and capability['es3'] == True |
| 10181 if capability_es3 and not es3_caps or not capability_es3 and es3_caps: | 10187 if capability_es3 and not es3_caps or not capability_es3 and es3_caps: |
| 10182 continue | 10188 continue |
| 10183 if 'extension_flag' in capability: | 10189 if 'extension_flag' in capability: |
| 10184 f.write(" if (feature_info_->feature_flags().%s) {\n " % | 10190 f.write(" if (feature_info_->feature_flags().%s) {\n " % |
| 10185 capability['extension_flag']) | 10191 capability['extension_flag']) |
| 10186 if test_prev: | 10192 if test_prev: |
| 10187 f.write(""" if (prev_state->enable_flags.cached_%s != | 10193 f.write(""" if (prev_state->enable_flags.cached_%s != |
| 10188 enable_flags.cached_%s) {\n""" % | 10194 enable_flags.cached_%s) {\n""" % |
| 10189 (capability_name, capability_name)) | 10195 (capability_name, capability_name)) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10455 }) | 10461 }) |
| 10456 self.generated_cpp_filenames.append(filename) | 10462 self.generated_cpp_filenames.append(filename) |
| 10457 | 10463 |
| 10458 comment = "// It is included by gles2_cmd_decoder_unittest_base.cc\n" | 10464 comment = "// It is included by gles2_cmd_decoder_unittest_base.cc\n" |
| 10459 filename = filename_pattern % 0 | 10465 filename = filename_pattern % 0 |
| 10460 with CHeaderWriter(filename, comment) as f: | 10466 with CHeaderWriter(filename, comment) as f: |
| 10461 f.write( | 10467 f.write( |
| 10462 """void GLES2DecoderTestBase::SetupInitCapabilitiesExpectations( | 10468 """void GLES2DecoderTestBase::SetupInitCapabilitiesExpectations( |
| 10463 bool es3_capable) {""") | 10469 bool es3_capable) {""") |
| 10464 for capability in _CAPABILITY_FLAGS: | 10470 for capability in _CAPABILITY_FLAGS: |
| 10471 capability_no_init = 'no_init' in capability and \ |
| 10472 capability['no_init'] == True |
| 10473 if capability_no_init: |
| 10474 continue |
| 10465 capability_es3 = 'es3' in capability and capability['es3'] == True | 10475 capability_es3 = 'es3' in capability and capability['es3'] == True |
| 10466 if capability_es3: | 10476 if capability_es3: |
| 10467 continue | 10477 continue |
| 10468 if 'extension_flag' in capability: | 10478 if 'extension_flag' in capability: |
| 10469 f.write(" if (group_->feature_info()->feature_flags().%s) {\n" % | 10479 f.write(" if (group_->feature_info()->feature_flags().%s) {\n" % |
| 10470 capability['extension_flag']) | 10480 capability['extension_flag']) |
| 10471 f.write(" ") | 10481 f.write(" ") |
| 10472 f.write(" ExpectEnableDisable(GL_%s, %s);\n" % | 10482 f.write(" ExpectEnableDisable(GL_%s, %s);\n" % |
| 10473 (capability['name'].upper(), | 10483 (capability['name'].upper(), |
| 10474 ('false', 'true')['default' in capability])) | 10484 ('false', 'true')['default' in capability])) |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11186 Format(gen.generated_cpp_filenames) | 11196 Format(gen.generated_cpp_filenames) |
| 11187 | 11197 |
| 11188 if gen.errors > 0: | 11198 if gen.errors > 0: |
| 11189 print "%d errors" % gen.errors | 11199 print "%d errors" % gen.errors |
| 11190 return 1 | 11200 return 1 |
| 11191 return 0 | 11201 return 0 |
| 11192 | 11202 |
| 11193 | 11203 |
| 11194 if __name__ == '__main__': | 11204 if __name__ == '__main__': |
| 11195 sys.exit(main(sys.argv[1:])) | 11205 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |