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

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

Issue 1474513003: Upgrade PixelStorei to ES3/WebGL2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: client side Created 5 years 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
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_implementation.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 itertools
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 'name': 'pack_alignment', 407 'name': 'pack_alignment',
408 'type': 'GLint', 408 'type': 'GLint',
409 'enum': 'GL_PACK_ALIGNMENT', 409 'enum': 'GL_PACK_ALIGNMENT',
410 'default': '4' 410 'default': '4'
411 }, 411 },
412 { 412 {
413 'name': 'unpack_alignment', 413 'name': 'unpack_alignment',
414 'type': 'GLint', 414 'type': 'GLint',
415 'enum': 'GL_UNPACK_ALIGNMENT', 415 'enum': 'GL_UNPACK_ALIGNMENT',
416 'default': '4' 416 'default': '4'
417 },
418 {
419 'name': 'pack_row_length',
420 'type': 'GLint',
421 'enum': 'GL_PACK_ROW_LENGTH',
422 'default': '0',
423 'es3': True
424 },
425 {
426 'name': 'pack_skip_pixels',
427 'type': 'GLint',
428 'enum': 'GL_PACK_SKIP_PIXELS',
429 'default': '0',
430 'es3': True
431 },
432 {
433 'name': 'pack_skip_rows',
434 'type': 'GLint',
435 'enum': 'GL_PACK_SKIP_ROWS',
436 'default': '0',
437 'es3': True
438 },
439 {
440 'name': 'unpack_row_length',
441 'type': 'GLint',
442 'enum': 'GL_UNPACK_ROW_LENGTH',
443 'default': '0',
444 'es3': True
445 },
446 {
447 'name': 'unpack_image_height',
448 'type': 'GLint',
449 'enum': 'GL_UNPACK_IMAGE_HEIGHT',
450 'default': '0',
451 'es3': True
452 },
453 {
454 'name': 'unpack_skip_pixels',
455 'type': 'GLint',
456 'enum': 'GL_UNPACK_SKIP_PIXELS',
457 'default': '0',
458 'es3': True
459 },
460 {
461 'name': 'unpack_skip_rows',
462 'type': 'GLint',
463 'enum': 'GL_UNPACK_SKIP_ROWS',
464 'default': '0',
465 'es3': True
466 },
467 {
468 'name': 'unpack_skip_images',
469 'type': 'GLint',
470 'enum': 'GL_UNPACK_SKIP_IMAGES',
471 'default': '0',
472 'es3': True
417 } 473 }
418 ], 474 ],
419 }, 475 },
420 # TODO: Consider implemenenting these states 476 # TODO: Consider implemenenting these states
421 # GL_ACTIVE_TEXTURE 477 # GL_ACTIVE_TEXTURE
422 'LineWidth': { 478 'LineWidth': {
423 'type': 'Normal', 479 'type': 'Normal',
424 'func': 'LineWidth', 480 'func': 'LineWidth',
425 'enum': 'GL_LINE_WIDTH', 481 'enum': 'GL_LINE_WIDTH',
426 'states': [ 482 'states': [
(...skipping 9739 matching lines...) Expand 10 before | Expand all | Expand 10 after
10166 if test_prev: 10222 if test_prev:
10167 f.write(")\n") 10223 f.write(")\n")
10168 f.write( 10224 f.write(
10169 " gl%s(%s, %s);\n" % 10225 " gl%s(%s, %s);\n" %
10170 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], 10226 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx],
10171 ", ".join(args))) 10227 ", ".join(args)))
10172 elif state['type'] == 'NamedParameter': 10228 elif state['type'] == 'NamedParameter':
10173 for item in state['states']: 10229 for item in state['states']:
10174 item_name = CachedStateName(item) 10230 item_name = CachedStateName(item)
10175 10231
10232 if 'es3' in item:
10233 assert item['es3']
10234 f.write(" if (feature_info_->IsES3Capable()) {\n");
10176 if 'extension_flag' in item: 10235 if 'extension_flag' in item:
10177 f.write(" if (feature_info_->feature_flags().%s) {\n " % 10236 f.write(" if (feature_info_->feature_flags().%s) {\n " %
10178 item['extension_flag']) 10237 item['extension_flag'])
10179 if test_prev: 10238 if test_prev:
10180 if isinstance(item['default'], list): 10239 if isinstance(item['default'], list):
10181 f.write(" if (memcmp(prev_state->%s, %s, " 10240 f.write(" if (memcmp(prev_state->%s, %s, "
10182 "sizeof(%s) * %d)) {\n" % 10241 "sizeof(%s) * %d)) {\n" %
10183 (item_name, item_name, item['type'], 10242 (item_name, item_name, item['type'],
10184 len(item['default']))) 10243 len(item['default'])))
10185 else: 10244 else:
10186 f.write(" if (prev_state->%s != %s) {\n " % 10245 f.write(" if (prev_state->%s != %s) {\n " %
10187 (item_name, item_name)) 10246 (item_name, item_name))
10188 if 'gl_version_flag' in item: 10247 if 'gl_version_flag' in item:
10189 item_name = item['gl_version_flag'] 10248 item_name = item['gl_version_flag']
10190 inverted = '' 10249 inverted = ''
10191 if item_name[0] == '!': 10250 if item_name[0] == '!':
10192 inverted = '!' 10251 inverted = '!'
10193 item_name = item_name[1:] 10252 item_name = item_name[1:]
10194 f.write(" if (%sfeature_info_->gl_version_info().%s) {\n" % 10253 f.write(" if (%sfeature_info_->gl_version_info().%s) {\n" %
10195 (inverted, item_name)) 10254 (inverted, item_name))
10196 f.write(" gl%s(%s, %s);\n" % 10255 f.write(" gl%s(%s, %s);\n" %
10197 (state['func'], 10256 (state['func'],
10198 (item['enum_set'] 10257 (item['enum_set']
10199 if 'enum_set' in item else item['enum']), 10258 if 'enum_set' in item else item['enum']),
10200 item['name'])) 10259 item['name']))
10201 if 'gl_version_flag' in item: 10260 if 'gl_version_flag' in item or 'es3' in item:
10202 f.write(" }\n") 10261 f.write(" }\n")
10203 if test_prev: 10262 if test_prev:
10204 if 'extension_flag' in item: 10263 if 'extension_flag' in item:
10205 f.write(" ") 10264 f.write(" ")
10206 f.write(" }") 10265 f.write(" }")
10207 if 'extension_flag' in item: 10266 if 'extension_flag' in item:
10208 f.write(" }") 10267 f.write(" }")
10209 else: 10268 else:
10210 if 'extension_flag' in state: 10269 if 'extension_flag' in state:
10211 f.write(" if (feature_info_->feature_flags().%s)\n " % 10270 f.write(" if (feature_info_->feature_flags().%s)\n " %
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
10388 f.write(" if (es3_capable) {") 10447 f.write(" if (es3_capable) {")
10389 for capability in _CAPABILITY_FLAGS: 10448 for capability in _CAPABILITY_FLAGS:
10390 capability_es3 = 'es3' in capability and capability['es3'] == True 10449 capability_es3 = 'es3' in capability and capability['es3'] == True
10391 if capability_es3: 10450 if capability_es3:
10392 f.write(" ExpectEnableDisable(GL_%s, %s);\n" % 10451 f.write(" ExpectEnableDisable(GL_%s, %s);\n" %
10393 (capability['name'].upper(), 10452 (capability['name'].upper(),
10394 ('false', 'true')['default' in capability])) 10453 ('false', 'true')['default' in capability]))
10395 f.write(""" } 10454 f.write(""" }
10396 } 10455 }
10397 10456
10398 void GLES2DecoderTestBase::SetupInitStateExpectations() { 10457 void GLES2DecoderTestBase::SetupInitStateExpectations(bool es3_capable) {
10399 """) 10458 """)
10400 # We need to sort the keys so the expectations match 10459 # We need to sort the keys so the expectations match
10401 for state_name in sorted(_STATES.keys()): 10460 for state_name in sorted(_STATES.keys()):
10402 state = _STATES[state_name] 10461 state = _STATES[state_name]
10403 if state['type'] == 'FrontBack': 10462 if state['type'] == 'FrontBack':
10404 num_states = len(state['states']) 10463 num_states = len(state['states'])
10405 for ndx, group in enumerate(Grouper(num_states / 2, state['states'])): 10464 for ndx, group in enumerate(Grouper(num_states / 2, state['states'])):
10406 args = [] 10465 args = []
10407 for item in group: 10466 for item in group:
10408 if 'expected' in item: 10467 if 'expected' in item:
10409 args.append(item['expected']) 10468 args.append(item['expected'])
10410 else: 10469 else:
10411 args.append(item['default']) 10470 args.append(item['default'])
10412 f.write( 10471 f.write(
10413 " EXPECT_CALL(*gl_, %s(%s, %s))\n" % 10472 " EXPECT_CALL(*gl_, %s(%s, %s))\n" %
10414 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args))) 10473 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args)))
10415 f.write(" .Times(1)\n") 10474 f.write(" .Times(1)\n")
10416 f.write(" .RetiresOnSaturation();\n") 10475 f.write(" .RetiresOnSaturation();\n")
10417 elif state['type'] == 'NamedParameter': 10476 elif state['type'] == 'NamedParameter':
10418 for item in state['states']: 10477 for item in state['states']:
10419 if 'extension_flag' in item: 10478 if 'extension_flag' in item:
10420 f.write(" if (group_->feature_info()->feature_flags().%s) {\n" % 10479 f.write(" if (group_->feature_info()->feature_flags().%s) {\n" %
10421 item['extension_flag']) 10480 item['extension_flag'])
10422 f.write(" ") 10481 f.write(" ")
10482 if 'es3' in item:
10483 assert item['es3']
10484 f.write(" if (es3_capable) {\n")
10485 f.write(" ")
10423 expect_value = item['default'] 10486 expect_value = item['default']
10424 if isinstance(expect_value, list): 10487 if isinstance(expect_value, list):
10425 # TODO: Currently we do not check array values. 10488 # TODO: Currently we do not check array values.
10426 expect_value = "_" 10489 expect_value = "_"
10427 10490
10428 f.write( 10491 f.write(
10429 " EXPECT_CALL(*gl_, %s(%s, %s))\n" % 10492 " EXPECT_CALL(*gl_, %s(%s, %s))\n" %
10430 (state['func'], 10493 (state['func'],
10431 (item['enum_set'] 10494 (item['enum_set']
10432 if 'enum_set' in item else item['enum']), 10495 if 'enum_set' in item else item['enum']),
10433 expect_value)) 10496 expect_value))
10434 f.write(" .Times(1)\n") 10497 f.write(" .Times(1)\n")
10435 f.write(" .RetiresOnSaturation();\n") 10498 f.write(" .RetiresOnSaturation();\n")
10436 if 'extension_flag' in item: 10499 if 'extension_flag' in item or 'es3' in item:
10437 f.write(" }\n") 10500 f.write(" }\n")
10438 else: 10501 else:
10439 if 'extension_flag' in state: 10502 if 'extension_flag' in state:
10440 f.write(" if (group_->feature_info()->feature_flags().%s) {\n" % 10503 f.write(" if (group_->feature_info()->feature_flags().%s) {\n" %
10441 state['extension_flag']) 10504 state['extension_flag'])
10442 f.write(" ") 10505 f.write(" ")
10443 args = [] 10506 args = []
10444 for item in state['states']: 10507 for item in state['states']:
10445 if 'expected' in item: 10508 if 'expected' in item:
10446 args.append(item['expected']) 10509 args.append(item['expected'])
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
10761 10824
10762 """) 10825 """)
10763 10826
10764 enums = sorted(_NAMED_TYPE_INFO.keys()) 10827 enums = sorted(_NAMED_TYPE_INFO.keys())
10765 for enum in enums: 10828 for enum in enums:
10766 if _NAMED_TYPE_INFO[enum]['type'] == 'GLenum': 10829 if _NAMED_TYPE_INFO[enum]['type'] == 'GLenum':
10767 f.write("std::string GLES2Util::GetString%s(uint32_t value) {\n" % 10830 f.write("std::string GLES2Util::GetString%s(uint32_t value) {\n" %
10768 enum) 10831 enum)
10769 valid_list = _NAMED_TYPE_INFO[enum]['valid'] 10832 valid_list = _NAMED_TYPE_INFO[enum]['valid']
10770 if 'valid_es3' in _NAMED_TYPE_INFO[enum]: 10833 if 'valid_es3' in _NAMED_TYPE_INFO[enum]:
10771 valid_list = valid_list + _NAMED_TYPE_INFO[enum]['valid_es3'] 10834 for es3_enum in _NAMED_TYPE_INFO[enum]['valid_es3']:
10835 if not es3_enum in valid_list:
10836 valid_list.append(es3_enum)
10772 assert len(valid_list) == len(set(valid_list)) 10837 assert len(valid_list) == len(set(valid_list))
10773 if len(valid_list) > 0: 10838 if len(valid_list) > 0:
10774 f.write(" static const EnumToString string_table[] = {\n") 10839 f.write(" static const EnumToString string_table[] = {\n")
10775 for value in valid_list: 10840 for value in valid_list:
10776 f.write(' { %s, "%s" },\n' % (value, value)) 10841 f.write(' { %s, "%s" },\n' % (value, value))
10777 f.write(""" }; 10842 f.write(""" };
10778 return GLES2Util::GetQualifiedEnumString( 10843 return GLES2Util::GetQualifiedEnumString(
10779 string_table, arraysize(string_table), value); 10844 string_table, arraysize(string_table), value);
10780 } 10845 }
10781 10846
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
11002 help="base directory for resulting files, under chrome/src. default is " 11067 help="base directory for resulting files, under chrome/src. default is "
11003 "empty. Use this if you want the result stored under gen.") 11068 "empty. Use this if you want the result stored under gen.")
11004 parser.add_option( 11069 parser.add_option(
11005 "-v", "--verbose", action="store_true", 11070 "-v", "--verbose", action="store_true",
11006 help="prints more output.") 11071 help="prints more output.")
11007 11072
11008 (options, args) = parser.parse_args(args=argv) 11073 (options, args) = parser.parse_args(args=argv)
11009 11074
11010 # Add in states and capabilites to GLState 11075 # Add in states and capabilites to GLState
11011 gl_state_valid = _NAMED_TYPE_INFO['GLState']['valid'] 11076 gl_state_valid = _NAMED_TYPE_INFO['GLState']['valid']
11077 gl_state_valid_es3 = _NAMED_TYPE_INFO['GLState']['valid_es3']
11012 for state_name in sorted(_STATES.keys()): 11078 for state_name in sorted(_STATES.keys()):
11013 state = _STATES[state_name] 11079 state = _STATES[state_name]
11014 if 'extension_flag' in state: 11080 if 'extension_flag' in state:
11015 continue 11081 continue
11016 if 'enum' in state: 11082 if 'enum' in state:
11017 if not state['enum'] in gl_state_valid: 11083 if not state['enum'] in gl_state_valid:
11018 gl_state_valid.append(state['enum']) 11084 gl_state_valid.append(state['enum'])
11019 else: 11085 else:
11020 for item in state['states']: 11086 for item in state['states']:
11021 if 'extension_flag' in item: 11087 if 'extension_flag' in item:
11022 continue 11088 continue
11023 if not item['enum'] in gl_state_valid: 11089 if 'es3' in item:
11024 gl_state_valid.append(item['enum']) 11090 assert item['es3']
11091 if not item['enum'] in gl_state_valid_es3:
11092 gl_state_valid_es3.append(item['enum'])
11093 else:
11094 if not item['enum'] in gl_state_valid:
11095 gl_state_valid.append(item['enum'])
11025 for capability in _CAPABILITY_FLAGS: 11096 for capability in _CAPABILITY_FLAGS:
11026 valid_value = "GL_%s" % capability['name'].upper() 11097 valid_value = "GL_%s" % capability['name'].upper()
11027 if not valid_value in gl_state_valid: 11098 if not valid_value in gl_state_valid:
11028 gl_state_valid.append(valid_value) 11099 gl_state_valid.append(valid_value)
11029 11100
11030 # This script lives under gpu/command_buffer, cd to base directory. 11101 # This script lives under gpu/command_buffer, cd to base directory.
11031 os.chdir(os.path.dirname(__file__) + "/../..") 11102 os.chdir(os.path.dirname(__file__) + "/../..")
11032 base_dir = os.getcwd() 11103 base_dir = os.getcwd()
11033 gen = GLGenerator(options.verbose) 11104 gen = GLGenerator(options.verbose)
11034 gen.ParseGLH("gpu/command_buffer/cmd_buffer_functions.txt") 11105 gen.ParseGLH("gpu/command_buffer/cmd_buffer_functions.txt")
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
11104 Format(gen.generated_cpp_filenames) 11175 Format(gen.generated_cpp_filenames)
11105 11176
11106 if gen.errors > 0: 11177 if gen.errors > 0:
11107 print "%d errors" % gen.errors 11178 print "%d errors" % gen.errors
11108 return 1 11179 return 1
11109 return 0 11180 return 0
11110 11181
11111 11182
11112 if __name__ == '__main__': 11183 if __name__ == '__main__':
11113 sys.exit(main(sys.argv[1:])) 11184 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698