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

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

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