Commit 54294c9a by Alexey Knyazev Committed by Commit Bot

Partially upgrade codegen to Python 3

Bug: angleproject:5707 Change-Id: I4e26c2c7ba4a36185b28ecd6e87be1161b60431a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2729567 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 8b55a3e5
{
"src/compiler/translator/ImmutableString_ESSL_autogen.cpp":
"fde39e0f48a46f22745815601f8c73aa",
"a60ac3aafb91de4358c1d811494c95c9",
"src/compiler/translator/ImmutableString_autogen.cpp":
"5c77d1341ef8f3d506aa918c646a90af",
"16e37e1ca019440226125af698783034",
"src/compiler/translator/ParseContext_ESSL_autogen.h":
"f11464c29f93b216b36561931fc6413f",
"9efd14cccb9bc5a099ac5c24b87b01b0",
"src/compiler/translator/ParseContext_complete_autogen.h":
"2db8d7d0efd13afdd4b971c89f785f7e",
"5d70fc2310654e6bcb04fe27f883b6cd",
"src/compiler/translator/SymbolTable_ESSL_autogen.cpp":
"a43e41c822e17c3887750f773539096f",
"a9526c6a57d0d7afa73ea1f19d49d5be",
"src/compiler/translator/SymbolTable_autogen.cpp":
"eda3a3410d738d3bc3eb23c8c466869f",
"bb5e4fe2438b7138ba79b31fa4bef4d4",
"src/compiler/translator/SymbolTable_autogen.h":
"d43593050c4d1b31b0be9cdd3a2d0ea5",
"src/compiler/translator/builtin_function_declarations.txt":
......@@ -18,13 +18,13 @@
"src/compiler/translator/builtin_variables.json":
"032da55c155d149d1930b4995d76e951",
"src/compiler/translator/gen_builtin_symbols.py":
"0b997ff6e25c823a62264ad618b070ed",
"eb24e6333408abf3a0e7b42818dce507",
"src/compiler/translator/tree_util/BuiltIn_ESSL_autogen.h":
"34d93fcd5085a4f4bc81c4b537828bef",
"fb0e00d60b60f6c01b7e75d93c5a1fc3",
"src/compiler/translator/tree_util/BuiltIn_complete_autogen.h":
"d812e52abb0baf983be9b0ccb4375885",
"b7ba5f755b1708adc6658351a2ac960c",
"src/tests/compiler_tests/ImmutableString_test_ESSL_autogen.cpp":
"b0ce4e0905740d612471ca1ad68cfaba",
"19e3e2225d3decd5f212944fa3634abf",
"src/tests/compiler_tests/ImmutableString_test_autogen.cpp":
"0f9030c08262caae7b45a3ad38d3417f"
"e947fe40ee401b2927a5d7832283a676"
}
\ No newline at end of file
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright 2017 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
......@@ -55,7 +55,7 @@ def grab_from_script(script, param):
f = open(os.path.basename(script), 'r')
exe = get_executable_name(f.readline())
try:
res = subprocess.check_output([exe, script, param]).strip()
res = subprocess.check_output([exe, script, param]).decode().strip()
except Exception:
print('Error grabbing script output: %s, executable %s' % (script, exe))
raise
......@@ -143,8 +143,8 @@ generators = {
def md5(fname):
hash_md5 = hashlib.md5()
with open(fname, "r") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
for chunk in iter(lambda: f.read(4096), ""):
hash_md5.update(chunk.encode())
return hash_md5.hexdigest()
......@@ -169,12 +169,12 @@ def any_hash_dirty(name, filenames, new_hashes, old_hashes):
def any_old_hash_missing(all_new_hashes, all_old_hashes):
result = False
for file, old_hashes in all_old_hashes.iteritems():
for file, old_hashes in all_old_hashes.items():
if file not in all_new_hashes:
print('"%s" does not exist. Code gen dirty.' % file)
result = True
else:
for name, _ in old_hashes.iteritems():
for name, _ in old_hashes.items():
if name not in all_new_hashes[file]:
print('Hash for %s is missing from "%s". Code gen is dirty.' % (name, file))
result = True
......@@ -212,7 +212,7 @@ def main():
if len(sys.argv) > 1 and sys.argv[1] == '--verify-no-dirty':
verify_only = True
for name, script in sorted(generators.iteritems()):
for name, script in sorted(generators.items()):
info = auto_script(script)
fname = get_hash_file_name(name)
filenames = info['inputs'] + info['outputs'] + [script]
......@@ -251,14 +251,14 @@ def main():
sys.exit(1)
# Update the output hashes again since they can be formatted.
for name, script in sorted(generators.iteritems()):
for name, script in sorted(generators.items()):
info = auto_script(script)
fname = get_hash_file_name(name)
update_output_hashes(name, info['outputs'], all_new_hashes[fname])
os.chdir(script_dir)
for fname, new_hashes in all_new_hashes.iteritems():
for fname, new_hashes in all_new_hashes.items():
hash_fname = os.path.join(hash_dir, fname)
json.dump(
new_hashes,
......
......@@ -28,35 +28,35 @@ bool isTextureOffsetBias(const TFunction *func)
int id = func->uniqueId().get();
return id >= 3865 && id <= 3884;
}
bool isTextureGatherOffsetsComp(const TFunction *func)
bool isTextureGatherOffsetNoComp(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 3922 && id <= 3934;
return id >= 3922 && id <= 3929;
}
bool isTextureGatherOffsetsNoComp(const TFunction *func)
bool isTextureGatherOffsetComp(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 3935 && id <= 3950;
return id >= 3930 && id <= 3935;
}
bool isTextureGatherOffsets(const TFunction *func)
bool isTextureGatherOffset(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 3922 && id <= 3950;
return id >= 3922 && id <= 3935;
}
bool isTextureGatherOffsetComp(const TFunction *func)
bool isTextureGatherOffsetsNoComp(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 3951 && id <= 3956;
return id >= 3936 && id <= 3952;
}
bool isTextureGatherOffsetNoComp(const TFunction *func)
bool isTextureGatherOffsetsComp(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 3957 && id <= 3964;
return id >= 3953 && id <= 3964;
}
bool isTextureGatherOffset(const TFunction *func)
bool isTextureGatherOffsets(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 3951 && id <= 3964;
return id >= 3936 && id <= 3964;
}
bool isTextureGather(const TFunction *func)
{
......@@ -73,20 +73,20 @@ bool isAtomicMemory(const TFunction *func)
int id = func->uniqueId().get();
return id >= 4005 && id <= 4022;
}
bool isImageLoad(const TFunction *func)
bool isImageStore(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 4059 && id <= 4076;
}
bool isImageAtomic(const TFunction *func)
bool isImageLoad(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 4077 && id <= 4652;
return id >= 4077 && id <= 4094;
}
bool isImageStore(const TFunction *func)
bool isImageAtomic(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 4653 && id <= 4670;
return id >= 4095 && id <= 4670;
}
bool isImage(const TFunction *func)
{
......
......@@ -28,35 +28,35 @@ bool isTextureOffsetBias(const TFunction *func)
int id = func->uniqueId().get();
return id >= 1279 && id <= 1313;
}
bool isTextureGatherOffsetsComp(const TFunction *func)
bool isTextureGatherOffsetNoComp(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 1358 && id <= 1373;
return id >= 1358 && id <= 1369;
}
bool isTextureGatherOffsetsNoComp(const TFunction *func)
bool isTextureGatherOffsetComp(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 1374 && id <= 1393;
return id >= 1370 && id <= 1378;
}
bool isTextureGatherOffsets(const TFunction *func)
bool isTextureGatherOffset(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 1358 && id <= 1393;
return id >= 1358 && id <= 1378;
}
bool isTextureGatherOffsetComp(const TFunction *func)
bool isTextureGatherOffsetsNoComp(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 1394 && id <= 1402;
return id >= 1379 && id <= 1399;
}
bool isTextureGatherOffsetNoComp(const TFunction *func)
bool isTextureGatherOffsetsComp(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 1403 && id <= 1414;
return id >= 1400 && id <= 1414;
}
bool isTextureGatherOffset(const TFunction *func)
bool isTextureGatherOffsets(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 1394 && id <= 1414;
return id >= 1379 && id <= 1414;
}
bool isTextureGather(const TFunction *func)
{
......@@ -73,20 +73,20 @@ bool isAtomicMemory(const TFunction *func)
int id = func->uniqueId().get();
return id >= 1488 && id <= 1505;
}
bool isImageLoad(const TFunction *func)
bool isImageStore(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 1578 && id <= 1613;
}
bool isImageAtomic(const TFunction *func)
bool isImageLoad(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 1614 && id <= 2735;
return id >= 1614 && id <= 1646;
}
bool isImageStore(const TFunction *func)
bool isImageAtomic(const TFunction *func)
{
int id = func->uniqueId().get();
return id >= 2736 && id <= 2768;
return id >= 1647 && id <= 2768;
}
bool isImage(const TFunction *func)
{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/usr/bin/env vpython
#!/usr/bin/env vpython3
#
# [VPYTHON:BEGIN]
# wheel: <
......@@ -880,7 +880,7 @@ class UnmangledGroupedList:
class TType:
def __init__(self, glsl_header_type):
if isinstance(glsl_header_type, basestring):
if isinstance(glsl_header_type, str):
self.data = self.parse_type(glsl_header_type)
else:
self.data = glsl_header_type
......@@ -1189,16 +1189,16 @@ def get_function_names(group, mangled_names, unmangled_names):
parameters = get_parameters(function_props)
mangled_names.append(get_function_mangled_name(function_name, parameters))
if 'subgroups' in group:
for subgroup_name, subgroup in group['subgroups'].iteritems():
for subgroup_name, subgroup in group['subgroups'].items():
get_function_names(subgroup, mangled_names, unmangled_names)
def get_variable_names(group, mangled_names):
if 'variables' in group:
for variable_name, props in group['variables'].iteritems():
for variable_name, props in group['variables'].items():
mangled_names.append(variable_name)
if 'subgroups' in group:
for subgroup_name, subgroup in group['subgroups'].iteritems():
for subgroup_name, subgroup in group['subgroups'].items():
get_variable_names(subgroup, mangled_names)
......@@ -1578,7 +1578,7 @@ def process_function_group(
unmangled_script_generated_hash_tests, mangled_builtins)
if 'subgroups' in group:
for subgroup_name, subgroup in group['subgroups'].iteritems():
for subgroup_name, subgroup in group['subgroups'].items():
process_function_group(
group_name + subgroup_name, subgroup, parameter_declarations, name_declarations,
unmangled_function_if_statements, defined_function_variants,
......@@ -1602,7 +1602,7 @@ def prune_parameters_arrays(parameter_declarations, function_declarations):
parameter_variable_name_replacements = {}
used_param_variable_names = set()
for param_variable_name, param_declaration in sorted(
parameter_declarations.iteritems(), key=lambda item: -len(item[0])):
parameter_declarations.items(), key=lambda item: -len(item[0])):
replaced = False
for used in used_param_variable_names:
if used.startswith(param_variable_name):
......@@ -1612,14 +1612,13 @@ def prune_parameters_arrays(parameter_declarations, function_declarations):
if not replaced:
used_param_variable_names.add(param_variable_name)
for i in xrange(len(function_declarations)):
for replaced, replacement in parameter_variable_name_replacements.iteritems():
for i in range(len(function_declarations)):
for replaced, replacement in parameter_variable_name_replacements.items():
function_declarations[i] = function_declarations[i].replace(
'BuiltInParameters::' + replaced + ',', 'BuiltInParameters::' + replacement + ',')
return [
value for key, value in parameter_declarations.iteritems()
if key in used_param_variable_names
value for key, value in parameter_declarations.items() if key in used_param_variable_names
]
......@@ -1678,7 +1677,7 @@ def process_single_variable(shader_type, variable_name, props, builtin_id_declar
template_args['fields'] = 'fields_{name_with_suffix}'.format(**template_args)
init_member_variables.append(
' TFieldList *{fields} = new TFieldList();'.format(**template_args))
for field_name, field_type in props['fields'].iteritems():
for field_name, field_type in props['fields'].items():
template_args['field_name'] = field_name
template_args['field_type'] = TType(field_type).get_dynamic_type_string()
template_name_declaration = 'constexpr const ImmutableString {field_name}("{field_name}");'
......@@ -1780,7 +1779,7 @@ def process_single_variable_group(shader_type, group, builtin_id_declarations,
global id_counter
if 'variables' not in group:
return
for variable_name, props in group['variables'].iteritems():
for variable_name, props in group['variables'].items():
process_single_variable(shader_type, variable_name, props, builtin_id_declarations,
builtin_id_definitions, name_declarations, init_member_variables,
get_variable_declarations, mangled_builtins,
......@@ -1824,7 +1823,7 @@ def process_variable_group(shader_type, group_name, group, builtin_id_declaratio
get_variable_definitions, script_generated_hash_tests)
if 'subgroups' in group:
for subgroup_name, subgroup in group['subgroups'].iteritems():
for subgroup_name, subgroup in group['subgroups'].items():
process_variable_group(
shader_type, subgroup_name, subgroup, builtin_id_declarations,
builtin_id_definitions, name_declarations, init_member_variables,
......@@ -1899,9 +1898,9 @@ def generate_files(essl_only, args, functions_txt_filename, variables_json_filen
# This script uses a perfect hash function to avoid dealing with collisions
mangled_names = []
unmangled_names = []
for group_name, group in parsed_functions.iteritems():
for group_name, group in parsed_functions.items():
get_function_names(group, mangled_names, unmangled_names)
for group_name, group in parsed_variables.iteritems():
for group_name, group in parsed_variables.items():
get_variable_names(group, mangled_names)
# Hashing mangled names
......@@ -1928,7 +1927,7 @@ def generate_files(essl_only, args, functions_txt_filename, variables_json_filen
# Array for querying unmangled builtins
unmangled_function_if_statements = UnmangledGroupedList(unmangled_hashfn, num_unmangled_names)
for group_name, group in parsed_functions.iteritems():
for group_name, group in parsed_functions.items():
process_function_group(
group_name, group, parameter_declarations, name_declarations,
unmangled_function_if_statements, defined_function_variants, builtin_id_declarations,
......@@ -1938,7 +1937,7 @@ def generate_files(essl_only, args, functions_txt_filename, variables_json_filen
parameter_declarations = prune_parameters_arrays(parameter_declarations, function_declarations)
for group_name, group in parsed_variables.iteritems():
for group_name, group in parsed_variables.items():
process_variable_group('NONE', group_name, group, builtin_id_declarations,
builtin_id_definitions, name_declarations, init_member_variables,
get_variable_declarations, mangled_builtins,
......@@ -1997,9 +1996,9 @@ def generate_files(essl_only, args, functions_txt_filename, variables_json_filen
'num_mangled_names':
num_mangled_names,
'script_generated_hash_tests':
'\n'.join(script_generated_hash_tests.iterkeys()),
'\n'.join(script_generated_hash_tests.keys()),
'unmangled_script_generated_hash_tests':
'\n'.join(unmangled_script_generated_hash_tests.iterkeys()),
'\n'.join(unmangled_script_generated_hash_tests.keys()),
'mangled_S1':
str(mangled_S1).replace('[', ' ').replace(']', ' '),
'mangled_S2':
......@@ -2090,9 +2089,9 @@ def main():
]
if args.auto_script_command == 'inputs':
print ','.join(inputs)
print(','.join(inputs))
elif args.auto_script_command == 'outputs':
print ','.join(outputs)
print(','.join(outputs))
else:
print('Invalid script parameters')
return 1
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment