Commit 0f34f3f2 by Jamie Madill Committed by Commit Bot

Use auto_script in run_code_generation.

Cleans up the generator scripts to prepare for listing outputs in the generated hashes file. Also reorganizes the scripts somewhat to make them a bit more maintainable. Bug: angleproject:3227 Change-Id: If40946c2004941d3f6cd51d5521c7db8cc0b52df Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1512052Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent f563fdc9
...@@ -6,24 +6,12 @@ ...@@ -6,24 +6,12 @@
# #
# generate_loader.py: # generate_loader.py:
# Generates dynamic loaders for various binding interfaces. # Generates dynamic loaders for various binding interfaces.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
import sys, os, pprint, json import sys, os, pprint, json
from datetime import date from datetime import date
import registry_xml import registry_xml
# Handle inputs/outputs for run_code_generation.py's auto_script
if len(sys.argv) == 2 and sys.argv[1] == 'inputs':
inputs = [
'egl.xml',
'egl_angle_ext.xml',
'registry_xml.py',
'wgl.xml',
]
print(",".join(inputs))
sys.exit(0)
def write_header(data_source_name, all_cmds, api, preamble, path, lib, ns = "", prefix = None, export = ""): def write_header(data_source_name, all_cmds, api, preamble, path, lib, ns = "", prefix = None, export = ""):
file_name = "%s_loader_autogen.h" % api file_name = "%s_loader_autogen.h" % api
header_path = registry_xml.path_to(path, file_name) header_path = registry_xml.path_to(path, file_name)
...@@ -175,10 +163,40 @@ def gen_wgl_loader(): ...@@ -175,10 +163,40 @@ def gen_wgl_loader():
write_source(source, all_cmds, "wgl", path, "_") write_source(source, all_cmds, "wgl", path, "_")
def main(): def main():
# Handle inputs/outputs for run_code_generation.py's auto_script
if len(sys.argv) > 1:
inputs = [
'egl.xml',
'egl_angle_ext.xml',
'registry_xml.py',
'wgl.xml',
]
outputs = [
'../src/libEGL/egl_loader_autogen.cpp',
'../src/libEGL/egl_loader_autogen.h',
'../util/egl_loader_autogen.cpp',
'../util/egl_loader_autogen.h',
'../util/gles_loader_autogen.cpp',
'../util/gles_loader_autogen.h',
'../util/windows/wgl_loader_autogen.cpp',
'../util/windows/wgl_loader_autogen.h',
]
if sys.argv[1] == 'inputs':
print ','.join(inputs)
elif sys.argv[1] == 'outputs':
print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
gen_libegl_loader() gen_libegl_loader()
gen_gl_loader() gen_gl_loader()
gen_egl_loader() gen_egl_loader()
gen_wgl_loader() gen_wgl_loader()
return 0
libegl_preamble = """#include <EGL/egl.h> libegl_preamble = """#include <EGL/egl.h>
......
...@@ -28,138 +28,65 @@ def clean_path_slashes(path): ...@@ -28,138 +28,65 @@ def clean_path_slashes(path):
# Takes a script input file name which is relative to the code generation script's directory and # Takes a script input file name which is relative to the code generation script's directory and
# changes it to be relative to the angle root directory # changes it to be relative to the angle root directory
def rebase_script_input_path(script_path, input_file_path): def rebase_script_path(script_path, input_file_path):
return os.path.relpath(os.path.join(os.path.dirname(script_path), input_file_path), root_dir); return os.path.relpath(os.path.join(os.path.dirname(script_path), input_file_path), root_dir)
def grab_from_script(script, param): def grab_from_script(script, param):
res = subprocess.check_output(['python', script, param]).strip() res = subprocess.check_output(['python', script, param]).strip()
return [clean_path_slashes(rebase_script_input_path(script, name)) for name in res.split(',')] if res == '':
return []
return [clean_path_slashes(rebase_script_path(script, name)) for name in res.split(',')]
def auto_script(script): def auto_script(script):
# Set the CWD to the script directory. # Set the CWD to the script directory.
os.chdir(get_child_script_dirname(script)) os.chdir(get_child_script_dirname(script))
base_script = os.path.basename(script) base_script = os.path.basename(script)
return { return {
'script': script,
'inputs': grab_from_script(base_script, 'inputs'), 'inputs': grab_from_script(base_script, 'inputs'),
'outputs': grab_from_script(base_script, 'outputs')
} }
hash_fname = "run_code_generation_hashes.json" hash_fname = "run_code_generation_hashes.json"
# TODO(jmadill): Convert everyting to auto-script.
generators = { generators = {
'ANGLE format': { 'ANGLE format':
'inputs': [ 'src/libANGLE/renderer/gen_angle_format_table.py',
'src/libANGLE/renderer/angle_format.py', 'ANGLE load functions table':
'src/libANGLE/renderer/angle_format_data.json', 'src/libANGLE/renderer/gen_load_functions_table.py',
'src/libANGLE/renderer/angle_format_map.json', 'D3D11 blit shader selection':
], 'src/libANGLE/renderer/d3d/d3d11/gen_blit11helper.py',
'script': 'src/libANGLE/renderer/gen_angle_format_table.py', 'D3D11 format':
}, 'src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py',
'ANGLE load functions table': { 'DXGI format':
'inputs': [ 'src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py',
'src/libANGLE/renderer/load_functions_data.json', 'DXGI format support':
], 'src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py',
'script': 'src/libANGLE/renderer/gen_load_functions_table.py', 'GL copy conversion table':
}, 'src/libANGLE/gen_copy_conversion_table.py',
'D3D11 blit shader selection': {
'inputs': [],
'script': 'src/libANGLE/renderer/d3d/d3d11/gen_blit11helper.py',
},
'D3D11 format': {
'inputs': [
'src/libANGLE/renderer/angle_format.py',
'src/libANGLE/renderer/d3d/d3d11/texture_format_data.json',
'src/libANGLE/renderer/d3d/d3d11/texture_format_map.json',
],
'script': 'src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py',
},
'DXGI format': {
'inputs': [
'src/libANGLE/renderer/angle_format.py',
'src/libANGLE/renderer/angle_format_map.json',
'src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json',
'src/libANGLE/renderer/gen_angle_format_table.py',
],
'script': 'src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py',
},
'DXGI format support': {
'inputs': [
'src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json',
],
'script': 'src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py',
},
'GL/EGL/WGL loader': 'GL/EGL/WGL loader':
auto_script('scripts/generate_loader.py'), 'scripts/generate_loader.py',
'GL/EGL entry points': 'GL/EGL entry points':
auto_script('scripts/generate_entry_points.py'), 'scripts/generate_entry_points.py',
'GL copy conversion table': { 'GL format map':
'inputs': [ 'src/libANGLE/gen_format_map.py',
'src/libANGLE/es3_copy_conversion_formats.json', 'uniform type':
], 'src/common/gen_uniform_type_table.py',
'script': 'src/libANGLE/gen_copy_conversion_table.py', 'OpenGL dispatch table':
}, 'src/libANGLE/renderer/gl/generate_gl_dispatch_table.py',
'GL format map': { 'packed enum':
'inputs': [ 'src/common/gen_packed_gl_enums.py',
'src/libANGLE/es3_format_type_combinations.json', 'proc table':
'src/libANGLE/format_map_data.json', 'src/libGLESv2/gen_proc_table.py',
], 'Vulkan format':
'script': 'src/libANGLE/gen_format_map.py', 'src/libANGLE/renderer/vulkan/gen_vk_format_table.py',
}, 'Vulkan mandatory format support table':
'uniform type': { 'src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py',
'inputs': [],
'script': 'src/common/gen_uniform_type_table.py',
},
'OpenGL dispatch table': {
'inputs': [
'scripts/gl.xml',
],
'script': 'src/libANGLE/renderer/gl/generate_gl_dispatch_table.py',
},
'packed enum': {
'inputs': [
'src/common/packed_gl_enums.json',
'src/common/packed_egl_enums.json',
],
'script': 'src/common/gen_packed_gl_enums.py',
},
'proc table': {
'inputs': [
'src/libGLESv2/proc_table_data.json',
],
'script': 'src/libGLESv2/gen_proc_table.py',
},
'Vulkan format': {
'inputs': [
'src/libANGLE/renderer/angle_format.py',
'src/libANGLE/renderer/angle_format_map.json',
'src/libANGLE/renderer/vulkan/vk_format_map.json',
],
'script': 'src/libANGLE/renderer/vulkan/gen_vk_format_table.py',
},
'Vulkan mandatory format support table': {
'inputs': [
'src/libANGLE/renderer/angle_format.py',
'third_party/vulkan-headers/src/registry/vk.xml',
'src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json',
],
'script': 'src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py',
},
'Vulkan internal shader programs': 'Vulkan internal shader programs':
auto_script('src/libANGLE/renderer/vulkan/gen_vk_internal_shaders.py'), 'src/libANGLE/renderer/vulkan/gen_vk_internal_shaders.py',
'Emulated HLSL functions': { 'Emulated HLSL functions':
'inputs': [ 'src/compiler/translator/gen_emulated_builtin_function_tables.py',
'src/compiler/translator/emulated_builtin_function_data_hlsl.json' 'ESSL static builtins':
], 'src/compiler/translator/gen_builtin_symbols.py',
'script': 'src/compiler/translator/gen_emulated_builtin_function_tables.py'
},
'ESSL static builtins': {
'inputs': [
'src/compiler/translator/builtin_function_declarations.txt',
'src/compiler/translator/builtin_variables.json',
],
'script': 'src/compiler/translator/gen_builtin_symbols.py',
},
} }
...@@ -198,11 +125,12 @@ def main(): ...@@ -198,11 +125,12 @@ def main():
if len(sys.argv) > 1 and sys.argv[1] == '--verify-no-dirty': if len(sys.argv) > 1 and sys.argv[1] == '--verify-no-dirty':
verify_only = True verify_only = True
for name, info in sorted(generators.iteritems()): for name, script in sorted(generators.iteritems()):
info = auto_script(script)
# Reset the CWD to the root ANGLE directory. # Reset the CWD to the root ANGLE directory.
os.chdir(root_dir) os.chdir(root_dir)
script = info['script']
if any_input_dirty(name, info['inputs'] + [script], new_hashes, old_hashes): if any_input_dirty(name, info['inputs'] + [script], new_hashes, old_hashes):
any_dirty = True any_dirty = True
......
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
"ANGLE format:src/libANGLE/renderer/angle_format_map.json": "ANGLE format:src/libANGLE/renderer/angle_format_map.json":
"be9f9bdbdf785dda05920146e8c55dbb", "be9f9bdbdf785dda05920146e8c55dbb",
"ANGLE format:src/libANGLE/renderer/gen_angle_format_table.py": "ANGLE format:src/libANGLE/renderer/gen_angle_format_table.py":
"00d5b2293e79d71e8d4212d1190a6426", "3d9f679b65f39ccf19bd7bdf5498f837",
"ANGLE load functions table:src/libANGLE/renderer/gen_load_functions_table.py": "ANGLE load functions table:src/libANGLE/renderer/gen_load_functions_table.py":
"8afc7eecce2a3ba9f0b4beacb1aa7fe2", "475de30b8552795ca928096543cec7f2",
"ANGLE load functions table:src/libANGLE/renderer/load_functions_data.json": "ANGLE load functions table:src/libANGLE/renderer/load_functions_data.json":
"4253e14cd3217f42b6fec75ee400655a", "4253e14cd3217f42b6fec75ee400655a",
"D3D11 blit shader selection:src/libANGLE/renderer/d3d/d3d11/gen_blit11helper.py": "D3D11 blit shader selection:src/libANGLE/renderer/d3d/d3d11/gen_blit11helper.py":
"fa59a0edd32890a018a7247e0484426c", "38bff72bc17ac25c6b42c98d40c76e20",
"D3D11 format:src/libANGLE/renderer/angle_format.py": "D3D11 format:src/libANGLE/renderer/angle_format.py":
"b18ca0fe4835114a4a2f54977b19e798", "b18ca0fe4835114a4a2f54977b19e798",
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py": "D3D11 format:src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py":
"15fb2a9b3f81e39a22090bce2f071185", "d3260e0390ad2cd8b07420b7426fad43",
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/texture_format_data.json": "D3D11 format:src/libANGLE/renderer/d3d/d3d11/texture_format_data.json":
"d7483ece817e819588f4ca157716dc7b", "d7483ece817e819588f4ca157716dc7b",
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/texture_format_map.json": "D3D11 format:src/libANGLE/renderer/d3d/d3d11/texture_format_map.json":
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
"DXGI format support:src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json": "DXGI format support:src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json":
"09195053f8829fc81efe08229b54a8b5", "09195053f8829fc81efe08229b54a8b5",
"DXGI format support:src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py": "DXGI format support:src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py":
"30158f76e168e014a1bee3925cd5910a", "389a6358534ebad5e232a44944b6123b",
"DXGI format:src/libANGLE/renderer/angle_format.py": "DXGI format:src/libANGLE/renderer/angle_format.py":
"b18ca0fe4835114a4a2f54977b19e798", "b18ca0fe4835114a4a2f54977b19e798",
"DXGI format:src/libANGLE/renderer/angle_format_map.json": "DXGI format:src/libANGLE/renderer/angle_format_map.json":
...@@ -32,29 +32,27 @@ ...@@ -32,29 +32,27 @@
"DXGI format:src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json": "DXGI format:src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json":
"24f525b05dc665fbbc8c6d68fb863719", "24f525b05dc665fbbc8c6d68fb863719",
"DXGI format:src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py": "DXGI format:src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py":
"8ea01df6cb7f160772d3c85dd5164890", "bed2688ca828fc9fd1904408d33ba007",
"DXGI format:src/libANGLE/renderer/gen_angle_format_table.py":
"00d5b2293e79d71e8d4212d1190a6426",
"ESSL static builtins:src/compiler/translator/builtin_function_declarations.txt": "ESSL static builtins:src/compiler/translator/builtin_function_declarations.txt":
"e5e567406476306ea06984d885be028d", "e5e567406476306ea06984d885be028d",
"ESSL static builtins:src/compiler/translator/builtin_variables.json": "ESSL static builtins:src/compiler/translator/builtin_variables.json":
"d07ec4348b35d0db1eeab3c99a5e91f9", "d07ec4348b35d0db1eeab3c99a5e91f9",
"ESSL static builtins:src/compiler/translator/gen_builtin_symbols.py": "ESSL static builtins:src/compiler/translator/gen_builtin_symbols.py":
"932aafd053b3a64affdc7ad31d0a3c42", "f056dba2fdeac5a5dbad9d8f7b17f55f",
"Emulated HLSL functions:src/compiler/translator/emulated_builtin_function_data_hlsl.json": "Emulated HLSL functions:src/compiler/translator/emulated_builtin_function_data_hlsl.json":
"002ad46d144c51fe98d73478aa554ba7", "002ad46d144c51fe98d73478aa554ba7",
"Emulated HLSL functions:src/compiler/translator/gen_emulated_builtin_function_tables.py": "Emulated HLSL functions:src/compiler/translator/gen_emulated_builtin_function_tables.py":
"6a00c1ba22c35a9b700a154efda6f861", "c24de0c9ce5f201985c852d2b4b12b98",
"GL copy conversion table:src/libANGLE/es3_copy_conversion_formats.json": "GL copy conversion table:src/libANGLE/es3_copy_conversion_formats.json":
"54608f6f7d9aa7c59a8458ccf3ab9935", "54608f6f7d9aa7c59a8458ccf3ab9935",
"GL copy conversion table:src/libANGLE/gen_copy_conversion_table.py": "GL copy conversion table:src/libANGLE/gen_copy_conversion_table.py":
"ac1afe23d9578bd1d2ef74f4a7aa927a", "92428cef9d97d33ee7063cfa387ccf56",
"GL format map:src/libANGLE/es3_format_type_combinations.json": "GL format map:src/libANGLE/es3_format_type_combinations.json":
"a232823cd6430f14e28793ccabb968ee", "a232823cd6430f14e28793ccabb968ee",
"GL format map:src/libANGLE/format_map_data.json": "GL format map:src/libANGLE/format_map_data.json":
"779798d4879e5f73a5a108e3e3fd3095", "779798d4879e5f73a5a108e3e3fd3095",
"GL format map:src/libANGLE/gen_format_map.py": "GL format map:src/libANGLE/gen_format_map.py":
"a383ee79a7bf929d145165f3e76c1079", "0fd8c00e8b5afb28a5f8b40d9628b9a4",
"GL/EGL entry points:scripts/egl.xml": "GL/EGL entry points:scripts/egl.xml":
"842e24514c4cfe09fba703c17a0fd292", "842e24514c4cfe09fba703c17a0fd292",
"GL/EGL entry points:scripts/egl_angle_ext.xml": "GL/EGL entry points:scripts/egl_angle_ext.xml":
...@@ -62,7 +60,7 @@ ...@@ -62,7 +60,7 @@
"GL/EGL entry points:scripts/entry_point_packed_gl_enums.json": "GL/EGL entry points:scripts/entry_point_packed_gl_enums.json":
"afe2284956be2360463d0d036ad9cdde", "afe2284956be2360463d0d036ad9cdde",
"GL/EGL entry points:scripts/generate_entry_points.py": "GL/EGL entry points:scripts/generate_entry_points.py":
"a959669b31f086510fb60c5b55de56d1", "7bd73a78c638334a114ed027d49cb6df",
"GL/EGL entry points:scripts/gl.xml": "GL/EGL entry points:scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708", "b470cb06b06cbbe7adb2c8129ec85708",
"GL/EGL entry points:scripts/gl_angle_ext.xml": "GL/EGL entry points:scripts/gl_angle_ext.xml":
...@@ -74,25 +72,29 @@ ...@@ -74,25 +72,29 @@
"GL/EGL/WGL loader:scripts/egl_angle_ext.xml": "GL/EGL/WGL loader:scripts/egl_angle_ext.xml":
"745534010f31fbe8e1a1fcddce15ed2d", "745534010f31fbe8e1a1fcddce15ed2d",
"GL/EGL/WGL loader:scripts/generate_loader.py": "GL/EGL/WGL loader:scripts/generate_loader.py":
"2d9be1d0f4f54905f3372411522133d1", "475030714c1644b6dfb1f6f08572039d",
"GL/EGL/WGL loader:scripts/registry_xml.py": "GL/EGL/WGL loader:scripts/registry_xml.py":
"be6628bdeb99e50868cf4af51ea63f54", "be6628bdeb99e50868cf4af51ea63f54",
"GL/EGL/WGL loader:scripts/wgl.xml": "GL/EGL/WGL loader:scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"OpenGL dispatch table:scripts/gl.xml": "OpenGL dispatch table:scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708", "b470cb06b06cbbe7adb2c8129ec85708",
"OpenGL dispatch table:src/libANGLE/renderer/angle_format.py":
"b18ca0fe4835114a4a2f54977b19e798",
"OpenGL dispatch table:src/libANGLE/renderer/gl/generate_gl_dispatch_table.py": "OpenGL dispatch table:src/libANGLE/renderer/gl/generate_gl_dispatch_table.py":
"f527232452ecf930cfb1276883581342", "8365d4130b9814eaa396915ae85734eb",
"OpenGL dispatch table:src/libANGLE/renderer/gl/gl_bindings_data.json":
"71079f089335ce1f67835d67a6d49d1a",
"Vulkan format:src/libANGLE/renderer/angle_format.py": "Vulkan format:src/libANGLE/renderer/angle_format.py":
"b18ca0fe4835114a4a2f54977b19e798", "b18ca0fe4835114a4a2f54977b19e798",
"Vulkan format:src/libANGLE/renderer/angle_format_map.json": "Vulkan format:src/libANGLE/renderer/angle_format_map.json":
"be9f9bdbdf785dda05920146e8c55dbb", "be9f9bdbdf785dda05920146e8c55dbb",
"Vulkan format:src/libANGLE/renderer/vulkan/gen_vk_format_table.py": "Vulkan format:src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"61a7752424595e24edff0c1f1784e18e", "9937d3c942f0a5fe08f1ca080d40d47e",
"Vulkan format:src/libANGLE/renderer/vulkan/vk_format_map.json": "Vulkan format:src/libANGLE/renderer/vulkan/vk_format_map.json":
"992749b88763adb66003fe5d801b5ded", "992749b88763adb66003fe5d801b5ded",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/gen_vk_internal_shaders.py": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/gen_vk_internal_shaders.py":
"1c64f7187357d7561c984ec57d251e74", "97e148951cbbf009ab963ca5a90ddf1a",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/BufferUtils.comp": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/BufferUtils.comp":
"0c8c050841543da0d7faca2559212aa8", "0c8c050841543da0d7faca2559212aa8",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ConvertVertex.comp": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ConvertVertex.comp":
...@@ -106,21 +108,21 @@ ...@@ -106,21 +108,21 @@
"Vulkan mandatory format support table:src/libANGLE/renderer/angle_format.py": "Vulkan mandatory format support table:src/libANGLE/renderer/angle_format.py":
"b18ca0fe4835114a4a2f54977b19e798", "b18ca0fe4835114a4a2f54977b19e798",
"Vulkan mandatory format support table:src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py": "Vulkan mandatory format support table:src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py":
"d647fcb39acb9a18e08e3e604b19cfee", "417772416d3082400ce05acc2f209c9f",
"Vulkan mandatory format support table:src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json": "Vulkan mandatory format support table:src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json":
"fa2bd54c1bb0ab2cf1d386061a4bc5c5", "fa2bd54c1bb0ab2cf1d386061a4bc5c5",
"Vulkan mandatory format support table:third_party/vulkan-headers/src/registry/vk.xml": "Vulkan mandatory format support table:third_party/vulkan-headers/src/registry/vk.xml":
"f5c8c9b8e521644ded34d44b1016c25e", "f5c8c9b8e521644ded34d44b1016c25e",
"packed enum:src/common/gen_packed_gl_enums.py": "packed enum:src/common/gen_packed_gl_enums.py":
"a9b1c38b4e4d8a1038e743be323f1a51", "0cd1a1cb6d5fde8cbac2994db24eb901",
"packed enum:src/common/packed_egl_enums.json": "packed enum:src/common/packed_egl_enums.json":
"5f591d220ee53b6e54a27d1523a3ab79", "5f591d220ee53b6e54a27d1523a3ab79",
"packed enum:src/common/packed_gl_enums.json": "packed enum:src/common/packed_gl_enums.json":
"6e2e2845f96754509b8add1f77e203b3", "6e2e2845f96754509b8add1f77e203b3",
"proc table:src/libGLESv2/gen_proc_table.py": "proc table:src/libGLESv2/gen_proc_table.py":
"ee265eada3dd238646010dd03874d242", "20ebe54894d613de42b0b15ca34078d9",
"proc table:src/libGLESv2/proc_table_data.json": "proc table:src/libGLESv2/proc_table_data.json":
"6deb74c7709ecb664b917a2f1e598399", "6deb74c7709ecb664b917a2f1e598399",
"uniform type:src/common/gen_uniform_type_table.py": "uniform type:src/common/gen_uniform_type_table.py":
"e185802e66950dfc5fc7a8fc19751206" "fa40444d496ac07cd9dc0cd239e4a499"
} }
\ No newline at end of file
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
# found in the LICENSE file. # found in the LICENSE file.
# #
# gen_packed_gl_enums.py: # gen_packed_gl_enums.py:
# Code generation for the packed enums. # Code generation for the packed enums.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
import datetime, json, os, sys import datetime, json, os, sys
from collections import namedtuple from collections import namedtuple
...@@ -204,7 +205,29 @@ def write_cpp(enums, path_prefix, file_name, data_source_name, namespace, api_en ...@@ -204,7 +205,29 @@ def write_cpp(enums, path_prefix, file_name, data_source_name, namespace, api_en
with (open(path_prefix + file_name, 'wt')) as f: with (open(path_prefix + file_name, 'wt')) as f:
f.write(cpp) f.write(cpp)
if __name__ == '__main__':
def main():
# auto_script parameters.
if len(sys.argv) > 1:
inputs = []
outputs = []
for generator in Generators:
inputs += [generator['json']]
outputs += [
generator['output'] + '_autogen.cpp',
generator['output'] + '_autogen.h',
]
if sys.argv[1] == 'inputs':
print ','.join(inputs)
elif sys.argv[1] == 'outputs':
print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
path_prefix = os.path.dirname(os.path.realpath(__file__)) + os.path.sep path_prefix = os.path.dirname(os.path.realpath(__file__)) + os.path.sep
for generator in Generators: for generator in Generators:
...@@ -215,3 +238,8 @@ if __name__ == '__main__': ...@@ -215,3 +238,8 @@ if __name__ == '__main__':
enums = load_enums(path_prefix + json_file) enums = load_enums(path_prefix + json_file)
write_header(enums, path_prefix, output_file + '_autogen.h', json_file, namespace, enum_type) write_header(enums, path_prefix, output_file + '_autogen.h', json_file, namespace, enum_type)
write_cpp(enums, path_prefix, output_file + '_autogen.cpp', json_file, namespace, enum_type) write_cpp(enums, path_prefix, output_file + '_autogen.cpp', json_file, namespace, enum_type)
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_uniform_type_table.py: # gen_uniform_type_table.py:
# Code generation for OpenGL uniform type info tables. # Code generation for OpenGL uniform type info tables.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
from datetime import date from datetime import date
...@@ -265,15 +266,37 @@ def gen_type_info(uniform_type): ...@@ -265,15 +266,37 @@ def gen_type_info(uniform_type):
def gen_type_index_case(index, uniform_type): def gen_type_index_case(index, uniform_type):
return "case " + uniform_type + ": return " + str(index) + ";" return "case " + uniform_type + ": return " + str(index) + ";"
uniform_type_info_data = ",\n".join([gen_type_info(uniform_type) for uniform_type in all_uniform_types])
uniform_type_index_cases = "\n".join([gen_type_index_case(index, uniform_type) for index, uniform_type in enumerate(all_uniform_types)]) def main():
with open('uniform_type_info_autogen.cpp', 'wt') as out_file: # auto_script parameters.
output_cpp = template_cpp.format( if len(sys.argv) > 1:
script_name = sys.argv[0], inputs = []
copyright_year = date.today().year, outputs = ['uniform_type_info_autogen.cpp']
total_count = len(all_uniform_types),
uniform_type_info_data = uniform_type_info_data, if sys.argv[1] == 'inputs':
uniform_type_index_cases = uniform_type_index_cases) print ','.join(inputs)
out_file.write(output_cpp) elif sys.argv[1] == 'outputs':
out_file.close() print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
uniform_type_info_data = ",\n".join([gen_type_info(uniform_type) for uniform_type in all_uniform_types])
uniform_type_index_cases = "\n".join([gen_type_index_case(index, uniform_type) for index, uniform_type in enumerate(all_uniform_types)])
with open('uniform_type_info_autogen.cpp', 'wt') as out_file:
output_cpp = template_cpp.format(
script_name = sys.argv[0],
copyright_year = date.today().year,
total_count = len(all_uniform_types),
uniform_type_info_data = uniform_type_info_data,
uniform_type_index_cases = uniform_type_index_cases)
out_file.write(output_cpp)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
// GENERATED FILE - DO NOT EDIT. // GENERATED FILE - DO NOT EDIT.
// Generated by gen_uniform_type_table.py. // Generated by gen_uniform_type_table.py.
// //
// Copyright 2018 The ANGLE Project Authors. All rights reserved. // Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
......
c0555364e16391744b56e1f5d9c614c0 0df8efe673974da147a740d6e084e0b5
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Generated by gen_emulated_builtin_function_tables.py using data from // Generated by gen_emulated_builtin_function_tables.py using data from
// emulated_builtin_function_data_hlsl.json. // emulated_builtin_function_data_hlsl.json.
// //
// Copyright 2018 The ANGLE Project Authors. All rights reserved. // Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_emulated_builtin_function_tables.py: # gen_emulated_builtin_function_tables.py:
# Generator for the builtin function maps. # Generator for the builtin function maps.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
from datetime import date from datetime import date
import json import json
...@@ -88,10 +89,6 @@ def enum_type(arg): ...@@ -88,10 +89,6 @@ def enum_type(arg):
return 'UI' + arg_type[2:] + suffix return 'UI' + arg_type[2:] + suffix
return arg_type.capitalize() + suffix return arg_type.capitalize() + suffix
input_script = "emulated_builtin_function_data_hlsl.json"
hlsl_json = load_json(input_script)
emulated_functions = []
def gen_emulated_function(data): def gen_emulated_function(data):
func = "" func = ""
...@@ -109,17 +106,44 @@ def gen_emulated_function(data): ...@@ -109,17 +106,44 @@ def gen_emulated_function(data):
func += "},\n" func += "},\n"
return [ func ] return [ func ]
for item in hlsl_json:
emulated_functions += gen_emulated_function(item)
hlsl_fname = "emulated_builtin_functions_hlsl_autogen.cpp" def main():
input_script = "emulated_builtin_function_data_hlsl.json"
hlsl_fname = "emulated_builtin_functions_hlsl_autogen.cpp"
# auto_script parameters.
if len(sys.argv) > 1:
inputs = [input_script]
outputs = [hlsl_fname]
if sys.argv[1] == 'inputs':
print ','.join(inputs)
elif sys.argv[1] == 'outputs':
print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
hlsl_json = load_json(input_script)
emulated_functions = []
for item in hlsl_json:
emulated_functions += gen_emulated_function(item)
hlsl_gen = template_emulated_builtin_functions_hlsl.format(
script_name = sys.argv[0],
data_source_name = input_script,
copyright_year = date.today().year,
emulated_functions = "".join(emulated_functions))
with open(hlsl_fname, 'wt') as f:
f.write(hlsl_gen)
f.close()
return 0
hlsl_gen = template_emulated_builtin_functions_hlsl.format(
script_name = sys.argv[0],
data_source_name = input_script,
copyright_year = date.today().year,
emulated_functions = "".join(emulated_functions))
with open(hlsl_fname, 'wt') as f: if __name__ == '__main__':
f.write(hlsl_gen) sys.exit(main())
f.close()
// GENERATED FILE - DO NOT EDIT. // GENERATED FILE - DO NOT EDIT.
// Generated by gen_copy_conversion_table.py using data from es3_copy_conversion_formats.json. // Generated by gen_copy_conversion_table.py using data from es3_copy_conversion_formats.json.
// //
// Copyright 2018 The ANGLE Project Authors. All rights reserved. // Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Generated by gen_format_map.py using data from format_map_data.json. // Generated by gen_format_map.py using data from format_map_data.json.
// ES3 format info from es3_format_type_combinations.json. // ES3 format info from es3_format_type_combinations.json.
// //
// Copyright 2018 The ANGLE Project Authors. All rights reserved. // Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_copy_conversion_table.py: # gen_copy_conversion_table.py:
# Code generation for ES3 valid copy conversions table format map. # Code generation for ES3 valid copy conversions table format map.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
from datetime import date from datetime import date
import sys import sys
...@@ -64,28 +65,51 @@ def parse_texture_format_case(texture_format, framebuffer_formats): ...@@ -64,28 +65,51 @@ def parse_texture_format_case(texture_format, framebuffer_formats):
return template_format_case.format( return template_format_case.format(
texture_format = texture_format, framebuffer_format_cases = framebuffer_format_cases) texture_format = texture_format, framebuffer_format_cases = framebuffer_format_cases)
data_source_name = 'es3_copy_conversion_formats.json'
json_data = angle_format.load_json(data_source_name) def main():
format_map = {} data_source_name = 'es3_copy_conversion_formats.json'
out_file_name = 'es3_copy_conversion_table_autogen.cpp'
for description, data in json_data.iteritems(): # auto_script parameters.
for texture_format, framebuffer_format in data: if len(sys.argv) > 1:
if texture_format not in format_map: inputs = [data_source_name]
format_map[texture_format] = [] outputs = [out_file_name]
format_map[texture_format] += [ framebuffer_format ]
texture_format_cases = "" if sys.argv[1] == 'inputs':
print ','.join(inputs)
elif sys.argv[1] == 'outputs':
print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
for texture_format, framebuffer_formats in sorted(format_map.iteritems()): json_data = angle_format.load_json(data_source_name)
texture_format_cases += parse_texture_format_case(texture_format, framebuffer_formats)
with open('es3_copy_conversion_table_autogen.cpp', 'wt') as out_file: format_map = {}
output_cpp = template_cpp.format(
script_name = sys.argv[0], for description, data in json_data.iteritems():
data_source_name = data_source_name, for texture_format, framebuffer_format in data:
copyright_year = date.today().year, if texture_format not in format_map:
texture_format_cases = texture_format_cases) format_map[texture_format] = []
out_file.write(output_cpp) format_map[texture_format] += [ framebuffer_format ]
out_file.close()
texture_format_cases = ""
for texture_format, framebuffer_formats in sorted(format_map.iteritems()):
texture_format_cases += parse_texture_format_case(texture_format, framebuffer_formats)
with open(out_file_name, 'wt') as out_file:
output_cpp = template_cpp.format(
script_name = sys.argv[0],
data_source_name = data_source_name,
copyright_year = date.today().year,
texture_format_cases = texture_format_cases)
out_file.write(output_cpp)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# gen_format_map.py: # gen_format_map.py:
# Code generation for GL format map. The format map matches between # Code generation for GL format map. The format map matches between
# {format,type} and internal format. # {format,type} and internal format.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
from datetime import date from datetime import date
import sys import sys
...@@ -110,10 +111,12 @@ template_es3_combo_type_case = """ case {type}: ...@@ -110,10 +111,12 @@ template_es3_combo_type_case = """ case {type}:
}} }}
""" """
def parse_type_case(type, result): def parse_type_case(type, result):
return template_simple_case.format( return template_simple_case.format(
key = type, result = result) key = type, result = result)
def parse_format_case(format, type_map): def parse_format_case(format, type_map):
type_cases = "" type_cases = ""
for type, internal_format in sorted(type_map.iteritems()): for type, internal_format in sorted(type_map.iteritems()):
...@@ -121,66 +124,88 @@ def parse_format_case(format, type_map): ...@@ -121,66 +124,88 @@ def parse_format_case(format, type_map):
return template_format_case.format( return template_format_case.format(
format = format, type_cases = type_cases) format = format, type_cases = type_cases)
input_script = 'format_map_data.json'
format_map = angle_format.load_json(input_script) def main():
# auto_script parameters.
if len(sys.argv) > 1:
inputs = ['es3_format_type_combinations.json', 'format_map_data.json']
outputs = ['format_map_autogen.cpp']
if sys.argv[1] == 'inputs':
print ','.join(inputs)
elif sys.argv[1] == 'outputs':
print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
input_script = 'format_map_data.json'
format_map = angle_format.load_json(input_script)
format_cases = ""
for format, type_map in sorted(format_map.iteritems()):
format_cases += parse_format_case(format, type_map)
format_cases = "" combo_data_file = 'es3_format_type_combinations.json'
es3_combo_data = angle_format.load_json(combo_data_file)
combo_data = [combo for sublist in es3_combo_data.values() for combo in sublist]
for format, type_map in sorted(format_map.iteritems()): types = set()
format_cases += parse_format_case(format, type_map) formats = set()
combos = {}
combo_data_file = 'es3_format_type_combinations.json' for internal_format, format, type in combo_data:
es3_combo_data = angle_format.load_json(combo_data_file) types.update([type])
combo_data = [combo for sublist in es3_combo_data.values() for combo in sublist] formats.update([format])
if format not in combos:
combos[format] = {}
if type not in combos[format]:
combos[format][type] = [internal_format]
else:
combos[format][type] += [internal_format]
types = set() es3_format_cases = ""
formats = set()
combos = {}
for internal_format, format, type in combo_data: for format in sorted(formats):
types.update([type]) es3_format_cases += " case " + format + ":\n"
formats.update([format])
if format not in combos:
combos[format] = {}
if type not in combos[format]:
combos[format][type] = [internal_format]
else:
combos[format][type] += [internal_format]
es3_format_cases = "" es3_type_cases = ""
for format in sorted(formats): for type in sorted(types):
es3_format_cases += " case " + format + ":\n" es3_type_cases += " case " + type + ":\n"
es3_type_cases = "" es3_combo_cases = ""
for type in sorted(types): for format, type_combos in combos.iteritems():
es3_type_cases += " case " + type + ":\n" this_type_cases = ""
for type, combos in type_combos.iteritems():
internal_format_cases = ""
for internal_format in combos:
internal_format_cases += " case " + internal_format + ":\n"
es3_combo_cases = "" this_type_cases += template_es3_combo_type_case.format(
type = type, internal_format_cases = internal_format_cases)
for format, type_combos in combos.iteritems(): es3_combo_cases += template_format_case.format(
this_type_cases = "" format = format, type_cases = this_type_cases)
for type, combos in type_combos.iteritems():
internal_format_cases = ""
for internal_format in combos:
internal_format_cases += " case " + internal_format + ":\n"
this_type_cases += template_es3_combo_type_case.format( with open('format_map_autogen.cpp', 'wt') as out_file:
type = type, internal_format_cases = internal_format_cases) output_cpp = template_cpp.format(
script_name = sys.argv[0],
data_source_name = input_script,
es3_data_source_name = combo_data_file,
copyright_year = date.today().year,
format_cases = format_cases,
es3_format_cases = es3_format_cases,
es3_type_cases = es3_type_cases,
es3_combo_cases = es3_combo_cases)
out_file.write(output_cpp)
return 0
es3_combo_cases += template_format_case.format(
format = format, type_cases = this_type_cases)
with open('format_map_autogen.cpp', 'wt') as out_file: if __name__ == '__main__':
output_cpp = template_cpp.format( sys.exit(main())
script_name = sys.argv[0],
data_source_name = input_script,
es3_data_source_name = combo_data_file,
copyright_year = date.today().year,
format_cases = format_cases,
es3_format_cases = es3_format_cases,
es3_type_cases = es3_type_cases,
es3_combo_cases = es3_combo_cases)
out_file.write(output_cpp)
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# #
# gen_blit11helper.py: # gen_blit11helper.py:
# Generates the code for retrieving the various blit shaders for D3D11 # Generates the code for retrieving the various blit shaders for D3D11
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
import sys, os, pprint import sys, os, pprint
from datetime import date from datetime import date
...@@ -335,22 +336,42 @@ def write_gni_file(shader_filename_list): ...@@ -335,22 +336,42 @@ def write_gni_file(shader_filename_list):
out.close() out.close()
map_blitshader_cases = [] def main():
shader_includes = []
blitshadertype_cases = [] # auto_script parameters.
blitshadertype_enums = [] if len(sys.argv) > 1:
blitshaderop_enums = [] inputs = []
shader_filenames = [] outputs = ['Blit11Helper_autogen.inc', 'd3d11_blit_shaders_autogen.gni']
map_blitshader_cases = get_map_blitshader_cases() if sys.argv[1] == 'inputs':
shader_includes = get_shader_includes() print ','.join(inputs)
blitshadertype_cases = get_blitshader_cases() elif sys.argv[1] == 'outputs':
blitshaderop_enums = get_blitshaderop_enums() print ','.join(outputs)
blitshadertype_enums = get_blitshadertype_enums() else:
shader_filenames = get_shader_filenames() print('Invalid script parameters')
return 1
write_inc_file("\n".join([d for d in blitshadertype_cases]), "\n".join( return 0
[c for c in map_blitshader_cases]), "\n".join([i for i in shader_includes]),
"\n".join([e for e in blitshaderop_enums]), "\n".join( map_blitshader_cases = []
[e for e in blitshadertype_enums])) shader_includes = []
write_gni_file("\n".join([s for s in shader_filenames])) blitshadertype_cases = []
blitshadertype_enums = []
blitshaderop_enums = []
shader_filenames = []
map_blitshader_cases = get_map_blitshader_cases()
shader_includes = get_shader_includes()
blitshadertype_cases = get_blitshader_cases()
blitshaderop_enums = get_blitshaderop_enums()
blitshadertype_enums = get_blitshadertype_enums()
shader_filenames = get_shader_filenames()
write_inc_file("\n".join([d for d in blitshadertype_cases]), "\n".join(
[c for c in map_blitshader_cases]), "\n".join([i for i in shader_includes]),
"\n".join([e for e in blitshaderop_enums]), "\n".join(
[e for e in blitshadertype_enums]))
write_gni_file("\n".join([s for s in shader_filenames]))
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_dxgi_format_table.py: # gen_dxgi_format_table.py:
# Code generation for DXGI format map. # Code generation for DXGI format map.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
from datetime import date from datetime import date
import sys import sys
...@@ -82,52 +83,78 @@ def format_case(dxgi_format, result): ...@@ -82,52 +83,78 @@ def format_case(dxgi_format, result):
def undefined_case(dxgi_format): def undefined_case(dxgi_format):
return template_undefined_case.format(dxgi_format = dxgi_format) return template_undefined_case.format(dxgi_format = dxgi_format)
component_cases = ""
format_cases = ""
input_data = 'dxgi_format_data.json' def main():
dxgi_map = angle_format.load_json(input_data) # auto_script parameters.
if len(sys.argv) > 1:
types = { inputs = [
'SNORM': 'GL_SIGNED_NORMALIZED', '../../angle_format.py',
'UNORM': 'GL_UNSIGNED_NORMALIZED', '../../angle_format_map.json',
'SINT': 'GL_INT', 'dxgi_format_data.json',
'UINT': 'GL_UNSIGNED_INT', ]
'FLOAT': 'GL_FLOAT', outputs = ['dxgi_format_map_autogen.cpp']
'SHAREDEXP': 'GL_FLOAT'
} if sys.argv[1] == 'inputs':
print ','.join(inputs)
all_angle = angle_format.get_all_angle_formats() elif sys.argv[1] == 'outputs':
print ','.join(outputs)
for dxgi_format, angle_format in sorted(dxgi_map.iteritems()): else:
print('Invalid script parameters')
found = [ctype in dxgi_format for ctype in types.keys()] return 1
count = reduce((lambda a, b: int(a) + int(b)), found) return 0
component_type = 'GL_NONE' component_cases = ""
format_cases = ""
if count == 1:
gltype = next(gltype for ctype, gltype in types.iteritems() if ctype in dxgi_format) input_data = 'dxgi_format_data.json'
component_cases += format_case(dxgi_format, gltype)
else: dxgi_map = angle_format.load_json(input_data)
component_cases += undefined_case(dxgi_format)
types = {
if angle_format == "": 'SNORM': 'GL_SIGNED_NORMALIZED',
angle_format = dxgi_format 'UNORM': 'GL_UNSIGNED_NORMALIZED',
'SINT': 'GL_INT',
if angle_format in all_angle: 'UINT': 'GL_UNSIGNED_INT',
angle_format = "Format::Get(FormatID::" + angle_format + ")" 'FLOAT': 'GL_FLOAT',
format_cases += format_case(dxgi_format, angle_format) 'SHAREDEXP': 'GL_FLOAT'
else: }
format_cases += undefined_case(dxgi_format)
all_angle = angle_format.get_all_angle_formats()
with open('dxgi_format_map_autogen.cpp', 'wt') as out_file:
output_cpp = template_cpp.format( for dxgi_format, a_format in sorted(dxgi_map.iteritems()):
script_name = sys.argv[0],
data_source_name = input_data, found = [ctype in dxgi_format for ctype in types.keys()]
copyright_year = date.today().year, count = reduce((lambda a, b: int(a) + int(b)), found)
component_type_cases = component_cases,
format_cases = format_cases) component_type = 'GL_NONE'
out_file.write(output_cpp)
out_file.close() if count == 1:
gltype = next(gltype for ctype, gltype in types.iteritems() if ctype in dxgi_format)
component_cases += format_case(dxgi_format, gltype)
else:
component_cases += undefined_case(dxgi_format)
if a_format == "":
a_format = dxgi_format
if a_format in all_angle:
a_format = "Format::Get(FormatID::" + a_format + ")"
format_cases += format_case(dxgi_format, a_format)
else:
format_cases += undefined_case(dxgi_format)
with open('dxgi_format_map_autogen.cpp', 'wt') as out_file:
output_cpp = template_cpp.format(
script_name = sys.argv[0],
data_source_name = input_data,
copyright_year = date.today().year,
component_type_cases = component_cases,
format_cases = format_cases)
out_file.write(output_cpp)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
# gen_dxgi_support_tables.py: # gen_dxgi_support_tables.py:
# Code generation for the DXGI support tables. Determines which formats # Code generation for the DXGI support tables. Determines which formats
# are natively support in D3D10+. # are natively support in D3D10+.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
# #
# TODO: The "never supported" formats should not be combined with the # NOTE: The "never supported" formats should not be combined with the
# "supported" and "optional" ones. At the moment, this does not cause # "supported" and "optional" ones. At the moment, this does not cause
# any issues as ANGLE does not internally check for "never supported". # any issues as ANGLE does not internally check for "never supported".
# #
...@@ -167,8 +168,6 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat ...@@ -167,8 +168,6 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat
}} // namespace rx }} // namespace rx
""" """
table_init = ""
def do_format(format_data): def do_format(format_data):
table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': '', '11_1': ''} table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': '', '11_1': ''}
...@@ -290,24 +289,45 @@ def join_table_data(table_data_1, table_data_2): ...@@ -290,24 +289,45 @@ def join_table_data(table_data_1, table_data_2):
'11_0': table_data_1['11_0'] + table_data_2['11_0'], '11_0': table_data_1['11_0'] + table_data_2['11_0'],
'11_1': table_data_1['11_1'] + table_data_2['11_1']} '11_1': table_data_1['11_1'] + table_data_2['11_1']}
with open('dxgi_support_data.json') as dxgi_file:
file_data = dxgi_file.read()
dxgi_file.close()
json_data = json.loads(file_data)
table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': '', '11_1': ''} def main():
# auto_script parameters.
if len(sys.argv) > 1:
inputs = ['dxgi_support_data.json']
outputs = ['dxgi_support_table_autogen.cpp']
if sys.argv[1] == 'inputs':
print ','.join(inputs)
elif sys.argv[1] == 'outputs':
print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
with open('dxgi_support_data.json') as dxgi_file:
file_data = dxgi_file.read()
dxgi_file.close()
json_data = json.loads(file_data)
table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': '', '11_1': ''}
for format_data in json_data:
table_data = join_table_data(table_data, do_format(format_data))
for format_data in json_data: out_data = template.format(prefix=macro_prefix,
table_data = join_table_data(table_data, do_format(format_data)) table_data_9_3=table_data['9_3'],
table_data_10_0=table_data['10_0'],
table_data_10_1=table_data['10_1'],
table_data_11_0=table_data['11_0'],
table_data_11_1=table_data['11_1'])
out_data = template.format(prefix=macro_prefix, with open('dxgi_support_table_autogen.cpp', 'wt') as out_file:
table_data_9_3=table_data['9_3'], out_file.write(out_data)
table_data_10_0=table_data['10_0'], out_file.close()
table_data_10_1=table_data['10_1'], return 0
table_data_11_0=table_data['11_0'],
table_data_11_1=table_data['11_1'])
with open('dxgi_support_table.cpp', 'wt') as out_file:
out_file.write(out_data)
out_file.close()
if __name__ == '__main__':
sys.exit(main())
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_texture_format_table.py: # gen_texture_format_table.py:
# Code generation for texture format map # Code generation for texture format map
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
# #
from datetime import date from datetime import date
...@@ -266,16 +267,38 @@ def parse_json_into_switch_angle_format_string(json_map, json_data): ...@@ -266,16 +267,38 @@ def parse_json_into_switch_angle_format_string(json_map, json_data):
return table_data return table_data
json_map = angle_format.load_with_override(os.path.abspath('texture_format_map.json'))
data_source_name = 'texture_format_data.json' def main():
json_data = angle_format.load_json(data_source_name)
# auto_script parameters.
angle_format_cases = parse_json_into_switch_angle_format_string(json_map, json_data) if len(sys.argv) > 1:
output_cpp = template_texture_format_table_autogen_cpp.format( inputs = ['../../angle_format.py', 'texture_format_data.json', 'texture_format_map.json']
script_name = sys.argv[0], outputs = ['texture_format_table_autogen.cpp']
copyright_year = date.today().year,
angle_format_info_cases = angle_format_cases, if sys.argv[1] == 'inputs':
data_source_name = data_source_name) print ','.join(inputs)
with open('texture_format_table_autogen.cpp', 'wt') as out_file: elif sys.argv[1] == 'outputs':
out_file.write(output_cpp) print ','.join(outputs)
out_file.close() else:
print('Invalid script parameters')
return 1
return 0
json_map = angle_format.load_with_override(os.path.abspath('texture_format_map.json'))
data_source_name = 'texture_format_data.json'
json_data = angle_format.load_json(data_source_name)
angle_format_cases = parse_json_into_switch_angle_format_string(json_map, json_data)
output_cpp = template_texture_format_table_autogen_cpp.format(
script_name = sys.argv[0],
copyright_year = date.today().year,
angle_format_info_cases = angle_format_cases,
data_source_name = data_source_name)
with open('texture_format_table_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
// GENERATED FILE - DO NOT EDIT. // GENERATED FILE - DO NOT EDIT.
// Generated by gen_texture_format_table.py using data from texture_format_data.json // Generated by gen_texture_format_table.py using data from texture_format_data.json
// //
// Copyright 2018 The ANGLE Project Authors. All rights reserved. // Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_angle_format_table.py: # gen_angle_format_table.py:
# Code generation for ANGLE format map. # Code generation for ANGLE format map.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
# #
import angle_format import angle_format
...@@ -90,11 +91,13 @@ const Format *GetFormatInfoTable() ...@@ -90,11 +91,13 @@ const Format *GetFormatInfoTable()
}} // namespace angle }} // namespace angle
""" """
def is_depth_stencil(angle_format): def is_depth_stencil(angle_format):
if not 'channels' in angle_format or not angle_format['channels']: if not 'channels' in angle_format or not angle_format['channels']:
return False return False
return 'd' in angle_format['channels'] or 's' in angle_format['channels'] return 'd' in angle_format['channels'] or 's' in angle_format['channels']
def get_component_suffix(angle_format): def get_component_suffix(angle_format):
if angle_format['componentType'] == 'float': if angle_format['componentType'] == 'float':
return 'F' return 'F'
...@@ -102,6 +105,7 @@ def get_component_suffix(angle_format): ...@@ -102,6 +105,7 @@ def get_component_suffix(angle_format):
return 'S' return 'S'
return "" return ""
def get_channel_struct(angle_format): def get_channel_struct(angle_format):
if 'bits' not in angle_format or angle_format['bits'] is None: if 'bits' not in angle_format or angle_format['bits'] is None:
return None return None
...@@ -136,12 +140,14 @@ def get_channel_struct(angle_format): ...@@ -136,12 +140,14 @@ def get_channel_struct(angle_format):
return struct_name return struct_name
def get_mip_generation_function(angle_format): def get_mip_generation_function(angle_format):
channel_struct = get_channel_struct(angle_format) channel_struct = get_channel_struct(angle_format)
if is_depth_stencil(angle_format) or channel_struct == None or "BLOCK" in angle_format["id"]: if is_depth_stencil(angle_format) or channel_struct == None or "BLOCK" in angle_format["id"]:
return 'nullptr' return 'nullptr'
return 'GenerateMip<' + channel_struct + '>' return 'GenerateMip<' + channel_struct + '>'
def get_color_read_write_component_type(angle_format): def get_color_read_write_component_type(angle_format):
component_type_map = { component_type_map = {
'uint': 'GLuint', 'uint': 'GLuint',
...@@ -152,6 +158,7 @@ def get_color_read_write_component_type(angle_format): ...@@ -152,6 +158,7 @@ def get_color_read_write_component_type(angle_format):
} }
return component_type_map[angle_format['componentType']] return component_type_map[angle_format['componentType']]
def get_color_read_function(angle_format): def get_color_read_function(angle_format):
channel_struct = get_channel_struct(angle_format) channel_struct = get_channel_struct(angle_format)
if channel_struct == None: if channel_struct == None:
...@@ -163,6 +170,7 @@ def get_color_read_function(angle_format): ...@@ -163,6 +170,7 @@ def get_color_read_function(angle_format):
read_component_type = get_color_read_write_component_type(angle_format) read_component_type = get_color_read_write_component_type(angle_format)
return 'ReadColor<' + channel_struct + ', '+ read_component_type + '>' return 'ReadColor<' + channel_struct + ', '+ read_component_type + '>'
def get_color_write_function(angle_format): def get_color_write_function(angle_format):
channel_struct = get_channel_struct(angle_format) channel_struct = get_channel_struct(angle_format)
if channel_struct == None: if channel_struct == None:
...@@ -194,6 +202,7 @@ def get_named_component_type(component_type): ...@@ -194,6 +202,7 @@ def get_named_component_type(component_type):
else: else:
raise ValueError("Unknown component type for " + component_type) raise ValueError("Unknown component type for " + component_type)
def get_component_alignment_mask(channels, bits): def get_component_alignment_mask(channels, bits):
if channels == None or bits == None: if channels == None or bits == None:
return "std::numeric_limits<GLuint>::max()" return "std::numeric_limits<GLuint>::max()"
...@@ -216,6 +225,7 @@ def get_component_alignment_mask(channels, bits): ...@@ -216,6 +225,7 @@ def get_component_alignment_mask(channels, bits):
# Can happen for 4-bit RGBA. # Can happen for 4-bit RGBA.
return "std::numeric_limits<GLuint>::max()" return "std::numeric_limits<GLuint>::max()"
def json_to_table_data(format_id, json, angle_to_gl): def json_to_table_data(format_id, json, angle_to_gl):
table_data = "" table_data = ""
...@@ -280,6 +290,7 @@ def json_to_table_data(format_id, json, angle_to_gl): ...@@ -280,6 +290,7 @@ def json_to_table_data(format_id, json, angle_to_gl):
return format_entry_template.format(**parsed) return format_entry_template.format(**parsed)
def parse_angle_format_table(all_angle, json_data, angle_to_gl): def parse_angle_format_table(all_angle, json_data, angle_to_gl):
table_data = '' table_data = ''
for format_id in sorted(all_angle): for format_id in sorted(all_angle):
...@@ -289,6 +300,7 @@ def parse_angle_format_table(all_angle, json_data, angle_to_gl): ...@@ -289,6 +300,7 @@ def parse_angle_format_table(all_angle, json_data, angle_to_gl):
return table_data return table_data
def gen_enum_string(all_angle): def gen_enum_string(all_angle):
enum_data = ' NONE' enum_data = ' NONE'
for format_id in sorted(all_angle): for format_id in sorted(all_angle):
...@@ -301,6 +313,7 @@ case_template = """ case {gl_format}: ...@@ -301,6 +313,7 @@ case_template = """ case {gl_format}:
return FormatID::{angle_format}; return FormatID::{angle_format};
""" """
def gen_map_switch_string(gl_to_angle): def gen_map_switch_string(gl_to_angle):
switch_data = ''; switch_data = '';
for gl_format in sorted(gl_to_angle.keys()): for gl_format in sorted(gl_to_angle.keys()):
...@@ -312,33 +325,56 @@ def gen_map_switch_string(gl_to_angle): ...@@ -312,33 +325,56 @@ def gen_map_switch_string(gl_to_angle):
switch_data += " return FormatID::NONE;" switch_data += " return FormatID::NONE;"
return switch_data; return switch_data;
gl_to_angle = angle_format.load_forward_table('angle_format_map.json')
angle_to_gl = angle_format.load_inverse_table('angle_format_map.json') def main():
data_source_name = 'angle_format_data.json'
json_data = angle_format.load_json(data_source_name) # auto_script parameters.
all_angle = angle_to_gl.keys() if len(sys.argv) > 1:
inputs = ['angle_format.py', 'angle_format_data.json', 'angle_format_map.json']
angle_format_cases = parse_angle_format_table( outputs = ['Format_table_autogen.cpp', 'FormatID_autogen.h']
all_angle, json_data, angle_to_gl)
switch_data = gen_map_switch_string(gl_to_angle) if sys.argv[1] == 'inputs':
output_cpp = template_autogen_inl.format( print ','.join(inputs)
script_name = sys.argv[0], elif sys.argv[1] == 'outputs':
copyright_year = date.today().year, print ','.join(outputs)
angle_format_info_cases = angle_format_cases, else:
angle_format_switch = switch_data, print('Invalid script parameters')
data_source_name = data_source_name) return 1
with open('Format_table_autogen.cpp', 'wt') as out_file: return 0
out_file.write(output_cpp)
out_file.close() gl_to_angle = angle_format.load_forward_table('angle_format_map.json')
angle_to_gl = angle_format.load_inverse_table('angle_format_map.json')
enum_data = gen_enum_string(all_angle) data_source_name = 'angle_format_data.json'
num_angle_formats = len(all_angle) json_data = angle_format.load_json(data_source_name)
output_h = template_autogen_h.format( all_angle = angle_to_gl.keys()
script_name = sys.argv[0],
copyright_year = date.today().year, angle_format_cases = parse_angle_format_table(
angle_format_enum = enum_data, all_angle, json_data, angle_to_gl)
data_source_name = data_source_name, switch_data = gen_map_switch_string(gl_to_angle)
num_angle_formats = num_angle_formats) output_cpp = template_autogen_inl.format(
with open('FormatID_autogen.h', 'wt') as out_file: script_name = sys.argv[0],
out_file.write(output_h) copyright_year = date.today().year,
out_file.close() angle_format_info_cases = angle_format_cases,
angle_format_switch = switch_data,
data_source_name = data_source_name)
with open('Format_table_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp)
out_file.close()
enum_data = gen_enum_string(all_angle)
num_angle_formats = len(all_angle)
output_h = template_autogen_h.format(
script_name = sys.argv[0],
copyright_year = date.today().year,
angle_format_enum = enum_data,
data_source_name = data_source_name,
num_angle_formats = num_angle_formats)
with open('FormatID_autogen.h', 'wt') as out_file:
out_file.write(output_h)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
# Code generation for the load function tables used for texture formats. These mappings are # Code generation for the load function tables used for texture formats. These mappings are
# not renderer specific. The mappings are done from the GL internal format, to the ANGLE # not renderer specific. The mappings are done from the GL internal format, to the ANGLE
# format ID, and then for the specific data type. # format ID, and then for the specific data type.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
# #
import json, sys import json, sys
...@@ -184,15 +185,35 @@ def parse_json(json_data): ...@@ -184,15 +185,35 @@ def parse_json(json_data):
return table_data, load_functions_data return table_data, load_functions_data
json_data = angle_format.load_json('load_functions_data.json') def main():
switch_data, load_functions_data = parse_json(json_data) # auto_script parameters.
output = template.format(internal_format = internal_format_param, if len(sys.argv) > 1:
angle_format = angle_format_param, inputs = ['load_functions_data.json']
switch_data = switch_data, outputs = ['load_functions_table_autogen.cpp']
load_functions_data = load_functions_data,
copyright_year = date.today().year)
with open('load_functions_table_autogen.cpp', 'wt') as out_file: if sys.argv[1] == 'inputs':
out_file.write(output) print ','.join(inputs)
out_file.close() elif sys.argv[1] == 'outputs':
print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
json_data = angle_format.load_json('load_functions_data.json')
switch_data, load_functions_data = parse_json(json_data)
output = template.format(internal_format = internal_format_param,
angle_format = angle_format_param,
switch_data = switch_data,
load_functions_data = load_functions_data,
copyright_year = date.today().year)
with open('load_functions_table_autogen.cpp', 'wt') as out_file:
out_file.write(output)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
// GENERATED FILE - DO NOT EDIT. // GENERATED FILE - DO NOT EDIT.
// Generated by gen_load_functions_table.py using data from load_functions_data.json // Generated by gen_load_functions_table.py using data from load_functions_data.json
// //
// Copyright 2018 The ANGLE Project Authors. All rights reserved. // Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_vk_format_table.py: # gen_vk_format_table.py:
# Code generation for vk format map. See vk_format_map.json for data source. # Code generation for vk format map. See vk_format_map.json for data source.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
from datetime import date from datetime import date
import json import json
...@@ -95,89 +96,115 @@ static constexpr BufferFormatInitInfo kInfo[] = {{{buffer_list}}}; ...@@ -95,89 +96,115 @@ static constexpr BufferFormatInitInfo kInfo[] = {{{buffer_list}}};
initBufferFallback(renderer, kInfo, ArraySize(kInfo)); initBufferFallback(renderer, kInfo, ArraySize(kInfo));
}}""" }}"""
def is_packed(format_id): def is_packed(format_id):
return "true" if "_PACK" in format_id else "false" return "true" if "_PACK" in format_id else "false"
def gen_format_case(angle, internal_format, vk_json_data): def gen_format_case(angle, internal_format, vk_json_data):
vk_map = vk_json_data["map"] vk_map = vk_json_data["map"]
vk_overrides = vk_json_data["overrides"] vk_overrides = vk_json_data["overrides"]
vk_fallbacks = vk_json_data["fallbacks"] vk_fallbacks = vk_json_data["fallbacks"]
args = dict( args = dict(
format_id=angle, format_id=angle,
internal_format=internal_format, internal_format=internal_format,
texture_template="", texture_template="",
buffer_template="") buffer_template="")
if ((angle not in vk_map) and (angle not in vk_overrides) and if ((angle not in vk_map) and (angle not in vk_overrides) and
(angle not in vk_fallbacks)) or angle == 'NONE': (angle not in vk_fallbacks)) or angle == 'NONE':
return empty_format_entry_template.format(**args) return empty_format_entry_template.format(**args)
def get_formats(format, type): def get_formats(format, type):
format = vk_overrides.get(format, {}).get(type, format) format = vk_overrides.get(format, {}).get(type, format)
if format not in vk_map: if format not in vk_map:
return [] return []
fallbacks = vk_fallbacks.get(format, {}).get(type, []) fallbacks = vk_fallbacks.get(format, {}).get(type, [])
if not isinstance(fallbacks, list): if not isinstance(fallbacks, list):
fallbacks = [fallbacks] fallbacks = [fallbacks]
return [format] + fallbacks return [format] + fallbacks
def texture_args(format): def texture_args(format):
return dict( return dict(
texture="angle::FormatID::" + format, texture="angle::FormatID::" + format,
vk_texture_format=vk_map[format], vk_texture_format=vk_map[format],
texture_initializer=angle_format.get_internal_format_initializer( texture_initializer=angle_format.get_internal_format_initializer(
internal_format, format)) internal_format, format))
def buffer_args(format): def buffer_args(format):
return dict( return dict(
buffer="angle::FormatID::" + format, buffer="angle::FormatID::" + format,
vk_buffer_format=vk_map[format], vk_buffer_format=vk_map[format],
vk_buffer_format_is_packed=is_packed(vk_map[format]), vk_buffer_format_is_packed=is_packed(vk_map[format]),
vertex_load_function=angle_format.get_vertex_copy_function( vertex_load_function=angle_format.get_vertex_copy_function(
angle, format), angle, format),
vertex_load_converts='false' if angle == format else 'true', vertex_load_converts='false' if angle == format else 'true',
) )
textures = get_formats(angle, "texture") textures = get_formats(angle, "texture")
if len(textures) == 1: if len(textures) == 1:
args.update(texture_template=texture_basic_template) args.update(texture_template=texture_basic_template)
args.update(texture_args(textures[0])) args.update(texture_args(textures[0]))
elif len(textures) > 1: elif len(textures) > 1:
args.update( args.update(
texture_template=texture_fallback_template, texture_template=texture_fallback_template,
texture_list=", ".join( texture_list=", ".join(
texture_struct_template.format(**texture_args(i)) texture_struct_template.format(**texture_args(i))
for i in textures)) for i in textures))
buffers = get_formats(angle, "buffer") buffers = get_formats(angle, "buffer")
if len(buffers) == 1: if len(buffers) == 1:
args.update(buffer_template=buffer_basic_template) args.update(buffer_template=buffer_basic_template)
args.update(buffer_args(buffers[0])) args.update(buffer_args(buffers[0]))
elif len(buffers) > 1: elif len(buffers) > 1:
args.update( args.update(
buffer_template=buffer_fallback_template, buffer_template=buffer_fallback_template,
buffer_list=", ".join( buffer_list=", ".join(
buffer_struct_template.format(**buffer_args(i)) for i in buffers)) buffer_struct_template.format(**buffer_args(i)) for i in buffers))
return format_entry_template.format(**args).format(**args) return format_entry_template.format(**args).format(**args)
input_file_name = 'vk_format_map.json' def main():
out_file_name = 'vk_format_table'
input_file_name = 'vk_format_map.json'
angle_to_gl = angle_format.load_inverse_table(os.path.join('..', 'angle_format_map.json')) out_file_name = 'vk_format_table_autogen.cpp'
vk_json_data = angle_format.load_json(input_file_name)
vk_cases = [gen_format_case(angle, gl, vk_json_data) # auto_script parameters.
for angle, gl in sorted(angle_to_gl.iteritems())] if len(sys.argv) > 1:
inputs = [
output_cpp = template_table_autogen_cpp.format( '../angle_format.py',
copyright_year = date.today().year, '../angle_format_map.json',
format_case_data = "\n".join(vk_cases), input_file_name
script_name = __file__, ]
out_file_name = out_file_name, outputs = [out_file_name]
input_file_name = input_file_name)
if sys.argv[1] == 'inputs':
with open(out_file_name + '_autogen.cpp', 'wt') as out_file: print ','.join(inputs)
out_file.write(output_cpp) elif sys.argv[1] == 'outputs':
out_file.close() print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
angle_to_gl = angle_format.load_inverse_table(os.path.join('..', 'angle_format_map.json'))
vk_json_data = angle_format.load_json(input_file_name)
vk_cases = [gen_format_case(angle, gl, vk_json_data)
for angle, gl in sorted(angle_to_gl.iteritems())]
output_cpp = template_table_autogen_cpp.format(
copyright_year = date.today().year,
format_case_data = "\n".join(vk_cases),
script_name = __file__,
out_file_name = out_file_name,
input_file_name = input_file_name)
with open(out_file_name, 'wt') as out_file:
out_file.write(output_cpp)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_vk_mandatory_format_support_table.py: # gen_vk_mandatory_format_support_table.py:
# Code generation for mandatory formats supported by Vulkan. # Code generation for mandatory formats supported by Vulkan.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
from datetime import date from datetime import date
import sys import sys
...@@ -85,30 +86,56 @@ def gen_format_case(index, vk_to_index_to_format_map, vk_map): ...@@ -85,30 +86,56 @@ def gen_format_case(index, vk_to_index_to_format_map, vk_map):
buffer_features = buffer_features_str) buffer_features = buffer_features_str)
input_file_name = 'vk_mandatory_format_support_data.json' def main():
out_file_name = 'vk_mandatory_format_support_table'
input_file_name = 'vk_mandatory_format_support_data.json'
tree = etree.parse(script_relative('../../../../third_party/vulkan-headers/src/registry/vk.xml')) out_file_name = 'vk_mandatory_format_support_table_autogen.cpp'
root = tree.getroot() vk_xml_file = '../../../../third_party/vulkan-headers/src/registry/vk.xml'
vk_format_enums = root.findall(".//enums[@name='VkFormat']/enum")
vk_format_name_to_index_map = {} # auto_script parameters.
num_formats = len(vk_format_enums) if len(sys.argv) > 1:
for format_enum in vk_format_enums: inputs = [
index = int(format_enum.attrib['value']) '../angle_format.py',
vk_format = format_enum.attrib['name'] input_file_name,
vk_format_name_to_index_map[index] = vk_format vk_xml_file,
]
vk_map = angle_format.load_json(input_file_name) outputs = [out_file_name]
vk_cases = [gen_format_case(index, vk_format_name_to_index_map, vk_map) for index in vk_format_name_to_index_map]
if sys.argv[1] == 'inputs':
output_cpp = template_table_autogen_cpp.format( print ','.join(inputs)
copyright_year = date.today().year, elif sys.argv[1] == 'outputs':
num_formats = num_formats, print ','.join(outputs)
format_case_data = "\n,".join(vk_cases), else:
script_name = __file__, print('Invalid script parameters')
out_file_name = out_file_name, return 1
input_file_name = input_file_name) return 0
with open(out_file_name + '_autogen.cpp', 'wt') as out_file: tree = etree.parse(script_relative(vk_xml_file))
out_file.write(output_cpp) root = tree.getroot()
out_file.close() vk_format_enums = root.findall(".//enums[@name='VkFormat']/enum")
vk_format_name_to_index_map = {}
num_formats = len(vk_format_enums)
for format_enum in vk_format_enums:
index = int(format_enum.attrib['value'])
vk_format = format_enum.attrib['name']
vk_format_name_to_index_map[index] = vk_format
vk_map = angle_format.load_json(input_file_name)
vk_cases = [gen_format_case(index, vk_format_name_to_index_map, vk_map) for index in vk_format_name_to_index_map]
output_cpp = template_table_autogen_cpp.format(
copyright_year = date.today().year,
num_formats = num_formats,
format_case_data = "\n,".join(vk_cases),
script_name = __file__,
out_file_name = out_file_name,
input_file_name = input_file_name)
with open(out_file_name, 'wt') as out_file:
out_file.write(output_cpp)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// vk_format_table: // vk_format_table_autogen.cpp:
// Queries for full Vulkan format information based on GL format. // Queries for full Vulkan format information based on GL format.
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// vk_mandatory_format_support_table: // vk_mandatory_format_support_table_autogen.cpp:
// Queries for full Vulkan mandatory format support information based on VK format. // Queries for full Vulkan mandatory format support information based on VK format.
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
......
...@@ -464,7 +464,7 @@ libangle_d3d11_sources = [ ...@@ -464,7 +464,7 @@ libangle_d3d11_sources = [
"src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp", "src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp",
"src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.h", "src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.h",
"src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp", "src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp",
"src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp", "src/libANGLE/renderer/d3d/d3d11/dxgi_support_table_autogen.cpp",
"src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.h", "src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.h",
"src/libANGLE/renderer/d3d/d3d11/Fence11.cpp", "src/libANGLE/renderer/d3d/d3d11/Fence11.cpp",
"src/libANGLE/renderer/d3d/d3d11/Fence11.h", "src/libANGLE/renderer/d3d/d3d11/Fence11.h",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
# gen_proc_table.py: # gen_proc_table.py:
# Code generation for entry point loading tables. # Code generation for entry point loading tables.
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
# TODO(jmadill): Should be part of entry point generation. # TODO(jmadill): Should be part of entry point generation.
...@@ -55,30 +56,51 @@ size_t g_numProcs = {num_procs}; ...@@ -55,30 +56,51 @@ size_t g_numProcs = {num_procs};
sys.path.append('../libANGLE/renderer') sys.path.append('../libANGLE/renderer')
import angle_format import angle_format
json_data = angle_format.load_json(data_source_name) def main():
all_functions = {} # auto_script parameters.
if len(sys.argv) > 1:
inputs = [data_source_name]
outputs = [out_file_name]
for description, functions in json_data.iteritems(): if sys.argv[1] == 'inputs':
for function in functions: print ','.join(inputs)
if function.startswith("gl"): elif sys.argv[1] == 'outputs':
all_functions[function] = "gl::" + function[2:] print ','.join(outputs)
# Special handling for EGL_ANGLE_explicit_context extension
if support_egl_ANGLE_explicit_context:
all_functions[function + "ContextANGLE"] = "gl::" + function[2:] + "ContextANGLE"
elif function.startswith("egl"):
all_functions[function] = "EGL_" + function[3:]
else: else:
all_functions[function] = function print('Invalid script parameters')
return 1
proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.iteritems())] return 0
with open(out_file_name, 'wb') as out_file: json_data = angle_format.load_json(data_source_name)
output_cpp = template_cpp.format(
script_name = sys.argv[0], all_functions = {}
data_source_name = data_source_name,
copyright_year = date.today().year, for description, functions in json_data.iteritems():
proc_data = ",\n".join(proc_data), for function in functions:
num_procs = len(proc_data)) if function.startswith("gl"):
out_file.write(output_cpp) all_functions[function] = "gl::" + function[2:]
out_file.close() # Special handling for EGL_ANGLE_explicit_context extension
\ No newline at end of file if support_egl_ANGLE_explicit_context:
all_functions[function + "ContextANGLE"] = "gl::" + function[2:] + "ContextANGLE"
elif function.startswith("egl"):
all_functions[function] = "EGL_" + function[3:]
else:
all_functions[function] = function
proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.iteritems())]
with open(out_file_name, 'w') as out_file:
output_cpp = template_cpp.format(
script_name = sys.argv[0],
data_source_name = data_source_name,
copyright_year = date.today().year,
proc_data = ",\n".join(proc_data),
num_procs = len(proc_data))
out_file.write(output_cpp)
out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
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