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/angle_format.py',
'src/libANGLE/renderer/angle_format_data.json',
'src/libANGLE/renderer/angle_format_map.json',
],
'script': 'src/libANGLE/renderer/gen_angle_format_table.py',
},
'ANGLE load functions table': {
'inputs': [
'src/libANGLE/renderer/load_functions_data.json',
],
'script': 'src/libANGLE/renderer/gen_load_functions_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', 'src/libANGLE/renderer/gen_angle_format_table.py',
], 'ANGLE load functions table':
'script': 'src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py', 'src/libANGLE/renderer/gen_load_functions_table.py',
}, 'D3D11 blit shader selection':
'DXGI format support': { 'src/libANGLE/renderer/d3d/d3d11/gen_blit11helper.py',
'inputs': [ 'D3D11 format':
'src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json', 'src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py',
], 'DXGI format':
'script': 'src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py', 'src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py',
}, 'DXGI format support':
'src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py',
'GL copy conversion table':
'src/libANGLE/gen_copy_conversion_table.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
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# #
# 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,10 +266,27 @@ def gen_type_info(uniform_type): ...@@ -265,10 +266,27 @@ 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)])
with open('uniform_type_info_autogen.cpp', 'wt') as out_file: def main():
# auto_script parameters.
if len(sys.argv) > 1:
inputs = []
outputs = ['uniform_type_info_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
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( output_cpp = template_cpp.format(
script_name = sys.argv[0], script_name = sys.argv[0],
copyright_year = date.today().year, copyright_year = date.today().year,
...@@ -277,3 +295,8 @@ with open('uniform_type_info_autogen.cpp', 'wt') as out_file: ...@@ -277,3 +295,8 @@ with open('uniform_type_info_autogen.cpp', 'wt') as out_file:
uniform_type_index_cases = uniform_type_index_cases) uniform_type_index_cases = uniform_type_index_cases)
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() 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( hlsl_gen = template_emulated_builtin_functions_hlsl.format(
script_name = sys.argv[0], script_name = sys.argv[0],
data_source_name = input_script, data_source_name = input_script,
copyright_year = date.today().year, copyright_year = date.today().year,
emulated_functions = "".join(emulated_functions)) emulated_functions = "".join(emulated_functions))
with open(hlsl_fname, 'wt') as f: with open(hlsl_fname, 'wt') as f:
f.write(hlsl_gen) f.write(hlsl_gen)
f.close() f.close()
return 0
if __name__ == '__main__':
sys.exit(main())
// 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,24 +65,42 @@ def parse_texture_format_case(texture_format, framebuffer_formats): ...@@ -64,24 +65,42 @@ 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.
if len(sys.argv) > 1:
inputs = [data_source_name]
outputs = [out_file_name]
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
json_data = angle_format.load_json(data_source_name)
format_map = {}
for description, data in json_data.iteritems():
for texture_format, framebuffer_format in data: for texture_format, framebuffer_format in data:
if texture_format not in format_map: if texture_format not in format_map:
format_map[texture_format] = [] format_map[texture_format] = []
format_map[texture_format] += [ framebuffer_format ] format_map[texture_format] += [ framebuffer_format ]
texture_format_cases = "" texture_format_cases = ""
for texture_format, framebuffer_formats in sorted(format_map.iteritems()): for texture_format, framebuffer_formats in sorted(format_map.iteritems()):
texture_format_cases += parse_texture_format_case(texture_format, framebuffer_formats) texture_format_cases += parse_texture_format_case(texture_format, framebuffer_formats)
with open('es3_copy_conversion_table_autogen.cpp', 'wt') as out_file: with open(out_file_name, 'wt') as out_file:
output_cpp = template_cpp.format( output_cpp = template_cpp.format(
script_name = sys.argv[0], script_name = sys.argv[0],
data_source_name = data_source_name, data_source_name = data_source_name,
...@@ -89,3 +108,8 @@ with open('es3_copy_conversion_table_autogen.cpp', 'wt') as out_file: ...@@ -89,3 +108,8 @@ with open('es3_copy_conversion_table_autogen.cpp', 'wt') as out_file:
texture_format_cases = texture_format_cases) texture_format_cases = texture_format_cases)
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() 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,24 +124,41 @@ def parse_format_case(format, type_map): ...@@ -121,24 +124,41 @@ 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
format_cases = "" input_script = 'format_map_data.json'
for format, type_map in sorted(format_map.iteritems()): 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 += parse_format_case(format, type_map)
combo_data_file = 'es3_format_type_combinations.json' combo_data_file = 'es3_format_type_combinations.json'
es3_combo_data = angle_format.load_json(combo_data_file) es3_combo_data = angle_format.load_json(combo_data_file)
combo_data = [combo for sublist in es3_combo_data.values() for combo in sublist] combo_data = [combo for sublist in es3_combo_data.values() for combo in sublist]
types = set() types = set()
formats = set() formats = set()
combos = {} combos = {}
for internal_format, format, type in combo_data: for internal_format, format, type in combo_data:
types.update([type]) types.update([type])
formats.update([format]) formats.update([format])
if format not in combos: if format not in combos:
...@@ -148,19 +168,19 @@ for internal_format, format, type in combo_data: ...@@ -148,19 +168,19 @@ for internal_format, format, type in combo_data:
else: else:
combos[format][type] += [internal_format] combos[format][type] += [internal_format]
es3_format_cases = "" es3_format_cases = ""
for format in sorted(formats): for format in sorted(formats):
es3_format_cases += " case " + format + ":\n" es3_format_cases += " case " + format + ":\n"
es3_type_cases = "" es3_type_cases = ""
for type in sorted(types): for type in sorted(types):
es3_type_cases += " case " + type + ":\n" es3_type_cases += " case " + type + ":\n"
es3_combo_cases = "" es3_combo_cases = ""
for format, type_combos in combos.iteritems(): for format, type_combos in combos.iteritems():
this_type_cases = "" this_type_cases = ""
for type, combos in type_combos.iteritems(): for type, combos in type_combos.iteritems():
internal_format_cases = "" internal_format_cases = ""
...@@ -173,7 +193,7 @@ for format, type_combos in combos.iteritems(): ...@@ -173,7 +193,7 @@ for format, type_combos in combos.iteritems():
es3_combo_cases += template_format_case.format( es3_combo_cases += template_format_case.format(
format = format, type_cases = this_type_cases) format = format, type_cases = this_type_cases)
with open('format_map_autogen.cpp', 'wt') as out_file: with open('format_map_autogen.cpp', 'wt') as out_file:
output_cpp = template_cpp.format( output_cpp = template_cpp.format(
script_name = sys.argv[0], script_name = sys.argv[0],
data_source_name = input_script, data_source_name = input_script,
...@@ -184,3 +204,8 @@ with open('format_map_autogen.cpp', 'wt') as out_file: ...@@ -184,3 +204,8 @@ with open('format_map_autogen.cpp', 'wt') as out_file:
es3_type_cases = es3_type_cases, es3_type_cases = es3_type_cases,
es3_combo_cases = es3_combo_cases) es3_combo_cases = es3_combo_cases)
out_file.write(output_cpp) out_file.write(output_cpp)
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -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 = []
blitshadertype_enums = []
blitshaderop_enums = []
shader_filenames = []
map_blitshader_cases = get_map_blitshader_cases() # auto_script parameters.
shader_includes = get_shader_includes() if len(sys.argv) > 1:
blitshadertype_cases = get_blitshader_cases() inputs = []
blitshaderop_enums = get_blitshaderop_enums() outputs = ['Blit11Helper_autogen.inc', 'd3d11_blit_shaders_autogen.gni']
blitshadertype_enums = get_blitshadertype_enums()
shader_filenames = get_shader_filenames()
write_inc_file("\n".join([d for d in blitshadertype_cases]), "\n".join( 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
map_blitshader_cases = []
shader_includes = []
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]), [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( "\n".join([e for e in blitshaderop_enums]), "\n".join(
[e for e in blitshadertype_enums])) [e for e in blitshadertype_enums]))
write_gni_file("\n".join([s for s in shader_filenames])) 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,25 +83,46 @@ def format_case(dxgi_format, result): ...@@ -82,25 +83,46 @@ 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:
inputs = [
'../../angle_format.py',
'../../angle_format_map.json',
'dxgi_format_data.json',
]
outputs = ['dxgi_format_map_autogen.cpp']
types = { 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
component_cases = ""
format_cases = ""
input_data = 'dxgi_format_data.json'
dxgi_map = angle_format.load_json(input_data)
types = {
'SNORM': 'GL_SIGNED_NORMALIZED', 'SNORM': 'GL_SIGNED_NORMALIZED',
'UNORM': 'GL_UNSIGNED_NORMALIZED', 'UNORM': 'GL_UNSIGNED_NORMALIZED',
'SINT': 'GL_INT', 'SINT': 'GL_INT',
'UINT': 'GL_UNSIGNED_INT', 'UINT': 'GL_UNSIGNED_INT',
'FLOAT': 'GL_FLOAT', 'FLOAT': 'GL_FLOAT',
'SHAREDEXP': 'GL_FLOAT' 'SHAREDEXP': 'GL_FLOAT'
} }
all_angle = angle_format.get_all_angle_formats() all_angle = angle_format.get_all_angle_formats()
for dxgi_format, angle_format in sorted(dxgi_map.iteritems()): for dxgi_format, a_format in sorted(dxgi_map.iteritems()):
found = [ctype in dxgi_format for ctype in types.keys()] found = [ctype in dxgi_format for ctype in types.keys()]
count = reduce((lambda a, b: int(a) + int(b)), found) count = reduce((lambda a, b: int(a) + int(b)), found)
...@@ -113,16 +135,16 @@ for dxgi_format, angle_format in sorted(dxgi_map.iteritems()): ...@@ -113,16 +135,16 @@ for dxgi_format, angle_format in sorted(dxgi_map.iteritems()):
else: else:
component_cases += undefined_case(dxgi_format) component_cases += undefined_case(dxgi_format)
if angle_format == "": if a_format == "":
angle_format = dxgi_format a_format = dxgi_format
if angle_format in all_angle: if a_format in all_angle:
angle_format = "Format::Get(FormatID::" + angle_format + ")" a_format = "Format::Get(FormatID::" + a_format + ")"
format_cases += format_case(dxgi_format, angle_format) format_cases += format_case(dxgi_format, a_format)
else: else:
format_cases += undefined_case(dxgi_format) format_cases += undefined_case(dxgi_format)
with open('dxgi_format_map_autogen.cpp', 'wt') as out_file: with open('dxgi_format_map_autogen.cpp', 'wt') as out_file:
output_cpp = template_cpp.format( output_cpp = template_cpp.format(
script_name = sys.argv[0], script_name = sys.argv[0],
data_source_name = input_data, data_source_name = input_data,
...@@ -131,3 +153,8 @@ with open('dxgi_format_map_autogen.cpp', 'wt') as out_file: ...@@ -131,3 +153,8 @@ with open('dxgi_format_map_autogen.cpp', 'wt') as out_file:
format_cases = format_cases) format_cases = format_cases)
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() 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,7 +289,24 @@ def join_table_data(table_data_1, table_data_2): ...@@ -290,7 +289,24 @@ 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:
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() file_data = dxgi_file.read()
dxgi_file.close() dxgi_file.close()
json_data = json.loads(file_data) json_data = json.loads(file_data)
...@@ -307,7 +323,11 @@ with open('dxgi_support_data.json') as dxgi_file: ...@@ -307,7 +323,11 @@ with open('dxgi_support_data.json') as dxgi_file:
table_data_11_0=table_data['11_0'], table_data_11_0=table_data['11_0'],
table_data_11_1=table_data['11_1']) table_data_11_1=table_data['11_1'])
with open('dxgi_support_table.cpp', 'wt') as out_file: with open('dxgi_support_table_autogen.cpp', 'wt') as out_file:
out_file.write(out_data) out_file.write(out_data)
out_file.close() out_file.close()
return 0
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'
json_data = angle_format.load_json(data_source_name)
angle_format_cases = parse_json_into_switch_angle_format_string(json_map, json_data) def main():
output_cpp = template_texture_format_table_autogen_cpp.format(
# auto_script parameters.
if len(sys.argv) > 1:
inputs = ['../../angle_format.py', 'texture_format_data.json', 'texture_format_map.json']
outputs = ['texture_format_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
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], script_name = sys.argv[0],
copyright_year = date.today().year, copyright_year = date.today().year,
angle_format_info_cases = angle_format_cases, angle_format_info_cases = angle_format_cases,
data_source_name = data_source_name) data_source_name = data_source_name)
with open('texture_format_table_autogen.cpp', 'wt') as out_file: with open('texture_format_table_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() 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')
data_source_name = 'angle_format_data.json'
json_data = angle_format.load_json(data_source_name)
all_angle = angle_to_gl.keys()
angle_format_cases = parse_angle_format_table( def main():
# auto_script parameters.
if len(sys.argv) > 1:
inputs = ['angle_format.py', 'angle_format_data.json', 'angle_format_map.json']
outputs = ['Format_table_autogen.cpp', 'FormatID_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
gl_to_angle = angle_format.load_forward_table('angle_format_map.json')
angle_to_gl = angle_format.load_inverse_table('angle_format_map.json')
data_source_name = 'angle_format_data.json'
json_data = angle_format.load_json(data_source_name)
all_angle = angle_to_gl.keys()
angle_format_cases = parse_angle_format_table(
all_angle, json_data, angle_to_gl) all_angle, json_data, angle_to_gl)
switch_data = gen_map_switch_string(gl_to_angle) switch_data = gen_map_switch_string(gl_to_angle)
output_cpp = template_autogen_inl.format( output_cpp = template_autogen_inl.format(
script_name = sys.argv[0], script_name = sys.argv[0],
copyright_year = date.today().year, copyright_year = date.today().year,
angle_format_info_cases = angle_format_cases, angle_format_info_cases = angle_format_cases,
angle_format_switch = switch_data, angle_format_switch = switch_data,
data_source_name = data_source_name) data_source_name = data_source_name)
with open('Format_table_autogen.cpp', 'wt') as out_file: with open('Format_table_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() out_file.close()
enum_data = gen_enum_string(all_angle) enum_data = gen_enum_string(all_angle)
num_angle_formats = len(all_angle) num_angle_formats = len(all_angle)
output_h = template_autogen_h.format( output_h = template_autogen_h.format(
script_name = sys.argv[0], script_name = sys.argv[0],
copyright_year = date.today().year, copyright_year = date.today().year,
angle_format_enum = enum_data, angle_format_enum = enum_data,
data_source_name = data_source_name, data_source_name = data_source_name,
num_angle_formats = num_angle_formats) num_angle_formats = num_angle_formats)
with open('FormatID_autogen.h', 'wt') as out_file: with open('FormatID_autogen.h', 'wt') as out_file:
out_file.write(output_h) out_file.write(output_h)
out_file.close() 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:
inputs = ['load_functions_data.json']
outputs = ['load_functions_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
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, angle_format = angle_format_param,
switch_data = switch_data, switch_data = switch_data,
load_functions_data = load_functions_data, load_functions_data = load_functions_data,
copyright_year = date.today().year) copyright_year = date.today().year)
with open('load_functions_table_autogen.cpp', 'wt') as out_file: with open('load_functions_table_autogen.cpp', 'wt') as out_file:
out_file.write(output) out_file.write(output)
out_file.close() 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,6 +96,7 @@ static constexpr BufferFormatInitInfo kInfo[] = {{{buffer_list}}}; ...@@ -95,6 +96,7 @@ 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"
...@@ -163,21 +165,46 @@ def gen_format_case(angle, internal_format, vk_json_data): ...@@ -163,21 +165,46 @@ def gen_format_case(angle, internal_format, vk_json_data):
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.
if len(sys.argv) > 1:
inputs = [
'../angle_format.py',
'../angle_format_map.json',
input_file_name
]
outputs = [out_file_name]
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
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())] for angle, gl in sorted(angle_to_gl.iteritems())]
output_cpp = template_table_autogen_cpp.format( output_cpp = template_table_autogen_cpp.format(
copyright_year = date.today().year, copyright_year = date.today().year,
format_case_data = "\n".join(vk_cases), format_case_data = "\n".join(vk_cases),
script_name = __file__, script_name = __file__,
out_file_name = out_file_name, out_file_name = out_file_name,
input_file_name = input_file_name) input_file_name = input_file_name)
with open(out_file_name + '_autogen.cpp', 'wt') as out_file: with open(out_file_name, 'wt') as out_file:
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() out_file.close()
return 0
if __name__ == '__main__':
sys.exit(main())
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# gen_vk_internal_shaders.py: # gen_vk_internal_shaders.py:
# Code generation for internal Vulkan shaders. Should be run when an internal # Code generation for internal Vulkan shaders. Should be run when an internal
# shader program is changed, added or removed. # shader program is changed, added or removed.
# Because this script can be slow direct invocation is supported. But before
# code upload please run scripts/run_code_generation.py.
from datetime import date from datetime import date
import json import json
...@@ -248,48 +250,8 @@ compact_newlines_regex = re.compile(r"\n\s*\n", re.MULTILINE) ...@@ -248,48 +250,8 @@ compact_newlines_regex = re.compile(r"\n\s*\n", re.MULTILINE)
def cleanup_preprocessed_shader(shader_text): def cleanup_preprocessed_shader(shader_text):
return compact_newlines_regex.sub('\n\n', shader_text.strip()) return compact_newlines_regex.sub('\n\n', shader_text.strip())
# STEP 0: Handle inputs/outputs for run_code_generation.py's auto_script def compile_variation(glslang_path, shader_file, shader_basename, flags, enums,
shaders_dir = os.path.join('shaders', 'src') flags_active, enum_indices, flags_bits, enum_bits, output_shaders):
if not os.path.isdir(shaders_dir):
raise Exception("Could not find shaders directory")
print_inputs = len(sys.argv) == 2 and sys.argv[1] == 'inputs'
print_outputs = len(sys.argv) == 2 and sys.argv[1] == 'outputs'
# If an argument X is given that's not inputs or outputs, compile shaders that match *X*.
# This is useful in development to build only the shader of interest.
shader_files_to_compile = os.listdir(shaders_dir)
if not (print_inputs or print_outputs or len(sys.argv) < 2):
shader_files_to_compile = [f for f in shader_files_to_compile if f.find(sys.argv[1]) != -1]
valid_extensions = ['.vert', '.frag', '.comp']
input_shaders = sorted([os.path.join(shaders_dir, shader)
for shader in os.listdir(shaders_dir)
if any([os.path.splitext(shader)[1] == ext for ext in valid_extensions])])
if print_inputs:
print(",".join(input_shaders))
sys.exit(0)
# STEP 1: Call glslang to generate the internal shaders into small .inc files.
# a) Get the path to the glslang binary from the script directory.
build_path = find_build_path(".")
print("Using glslang_validator from '" + build_path + "'")
result = subprocess.call(['ninja', '-C', build_path, 'glslang_validator'])
if result != 0:
raise Exception("Error building glslang_validator")
glslang_binary = 'glslang_validator'
if os.name == 'nt':
glslang_binary += '.exe'
glslang_path = os.path.join(build_path, glslang_binary)
if not os.path.isfile(glslang_path):
raise Exception("Could not find " + glslang_binary)
# b) Iterate over the shaders and call glslang with the right arguments.
output_shaders = []
def compile_variation(shader_file, shader_basename, flags, enums,
flags_active, enum_indices, flags_bits, enum_bits, do_compile):
glslang_args = [glslang_path] glslang_args = [glslang_path]
...@@ -322,7 +284,7 @@ def compile_variation(shader_file, shader_basename, flags, enums, ...@@ -322,7 +284,7 @@ def compile_variation(shader_file, shader_basename, flags, enums,
output_path = get_output_path(output_name) output_path = get_output_path(output_name)
output_shaders.append(output_path) output_shaders.append(output_path)
if do_compile: if glslang_path is not None:
glslang_preprocessor_output_args = glslang_args + ['-E'] glslang_preprocessor_output_args = glslang_args + ['-E']
glslang_preprocessor_output_args.append(shader_file) # Input GLSL shader glslang_preprocessor_output_args.append(shader_file) # Input GLSL shader
...@@ -350,40 +312,7 @@ class ShaderAndVariations: ...@@ -350,40 +312,7 @@ class ShaderAndVariations:
get_variation_bits(self.flags, self.enums) get_variation_bits(self.flags, self.enums)
(self.flags_bits, self.enum_bits) = get_variation_bits(self.flags, self.enums) (self.flags_bits, self.enum_bits) = get_variation_bits(self.flags, self.enums)
input_shaders_and_variations = [ShaderAndVariations(shader_file) for shader_file in input_shaders]
for shader_and_variation in input_shaders_and_variations:
shader_file = shader_and_variation.shader_file
flags = shader_and_variation.flags
enums = shader_and_variation.enums
flags_bits = shader_and_variation.flags_bits
enum_bits = shader_and_variation.enum_bits
# an array where each element i is in [0, len(enums[i])),
# telling which enum is currently selected
enum_indices = [0] * len(enums)
output_name = os.path.basename(shader_file)
while True:
do_compile = not print_outputs and output_name in shader_files_to_compile
# a number where each bit says whether a flag is active or not,
# with values in [0, 2^len(flags))
for flags_active in range(1 << len(flags)):
compile_variation(shader_file, output_name, flags, enums,
flags_active, enum_indices, flags_bits, enum_bits, do_compile)
if not next_enum_variation(enums, enum_indices):
break
output_shaders = sorted(output_shaders)
outputs = output_shaders + [out_file_cpp, out_file_h]
if print_outputs:
print("\n".join(outputs))
sys.exit(0)
# STEP 2: Consolidate the .inc files into an auto-generated cpp/h library.
def get_variation_definition(shader_and_variation): def get_variation_definition(shader_and_variation):
shader_file = shader_and_variation.shader_file shader_file = shader_and_variation.shader_file
flags = shader_and_variation.flags flags = shader_and_variation.flags
...@@ -516,7 +445,85 @@ def get_destroy_call(shader_and_variation): ...@@ -516,7 +445,85 @@ def get_destroy_call(shader_and_variation):
destroy += '{\nshader.get().destroy(device);\n}' destroy += '{\nshader.get().destroy(device);\n}'
return destroy return destroy
with open(out_file_cpp, 'w') as outfile:
def main():
# STEP 0: Handle inputs/outputs for run_code_generation.py's auto_script
shaders_dir = os.path.join('shaders', 'src')
if not os.path.isdir(shaders_dir):
raise Exception("Could not find shaders directory")
print_inputs = len(sys.argv) == 2 and sys.argv[1] == 'inputs'
print_outputs = len(sys.argv) == 2 and sys.argv[1] == 'outputs'
# If an argument X is given that's not inputs or outputs, compile shaders that match *X*.
# This is useful in development to build only the shader of interest.
shader_files_to_compile = os.listdir(shaders_dir)
if not (print_inputs or print_outputs or len(sys.argv) < 2):
shader_files_to_compile = [f for f in shader_files_to_compile if f.find(sys.argv[1]) != -1]
valid_extensions = ['.vert', '.frag', '.comp']
input_shaders = sorted([os.path.join(shaders_dir, shader)
for shader in os.listdir(shaders_dir)
if any([os.path.splitext(shader)[1] == ext for ext in valid_extensions])])
if print_inputs:
print(",".join(input_shaders))
sys.exit(0)
# STEP 1: Call glslang to generate the internal shaders into small .inc files.
# a) Get the path to the glslang binary from the script directory.
glslang_path = None
if not print_outputs:
build_path = find_build_path(".")
print("Using glslang_validator from '" + build_path + "'")
result = subprocess.call(['ninja', '-C', build_path, 'glslang_validator'])
if result != 0:
raise Exception("Error building glslang_validator")
glslang_binary = 'glslang_validator'
if os.name == 'nt':
glslang_binary += '.exe'
glslang_path = os.path.join(build_path, glslang_binary)
if not os.path.isfile(glslang_path):
raise Exception("Could not find " + glslang_binary)
# b) Iterate over the shaders and call glslang with the right arguments.
output_shaders = []
input_shaders_and_variations = [ShaderAndVariations(shader_file) for shader_file in input_shaders]
for shader_and_variation in input_shaders_and_variations:
shader_file = shader_and_variation.shader_file
flags = shader_and_variation.flags
enums = shader_and_variation.enums
flags_bits = shader_and_variation.flags_bits
enum_bits = shader_and_variation.enum_bits
# an array where each element i is in [0, len(enums[i])),
# telling which enum is currently selected
enum_indices = [0] * len(enums)
output_name = os.path.basename(shader_file)
while True:
do_compile = not print_outputs and output_name in shader_files_to_compile
# a number where each bit says whether a flag is active or not,
# with values in [0, 2^len(flags))
for flags_active in range(1 << len(flags)):
compile_variation(glslang_path, shader_file, output_name, flags, enums,
flags_active, enum_indices, flags_bits, enum_bits, output_shaders)
if not next_enum_variation(enums, enum_indices):
break
output_shaders = sorted(output_shaders)
outputs = output_shaders + [out_file_cpp, out_file_h]
if print_outputs:
print(','.join(outputs))
sys.exit(0)
# STEP 2: Consolidate the .inc files into an auto-generated cpp/h library.
with open(out_file_cpp, 'w') as outfile:
includes = "\n".join([gen_shader_include(shader) for shader in output_shaders]) includes = "\n".join([gen_shader_include(shader) for shader in output_shaders])
shader_tables_cpp = '\n'.join([get_shader_table_cpp(s) shader_tables_cpp = '\n'.join([get_shader_table_cpp(s)
for s in input_shaders_and_variations]) for s in input_shaders_and_variations])
...@@ -537,7 +544,7 @@ with open(out_file_cpp, 'w') as outfile: ...@@ -537,7 +544,7 @@ with open(out_file_cpp, 'w') as outfile:
outfile.write(outcode) outfile.write(outcode)
outfile.close() outfile.close()
with open(out_file_h, 'w') as outfile: with open(out_file_h, 'w') as outfile:
shader_variation_definitions = '\n'.join([get_variation_definition(s) shader_variation_definitions = '\n'.join([get_variation_definition(s)
for s in input_shaders_and_variations]) for s in input_shaders_and_variations])
shader_get_functions_h = '\n'.join([get_get_function_h(s) shader_get_functions_h = '\n'.join([get_get_function_h(s)
...@@ -555,8 +562,8 @@ with open(out_file_h, 'w') as outfile: ...@@ -555,8 +562,8 @@ with open(out_file_h, 'w') as outfile:
outfile.write(outcode) outfile.write(outcode)
outfile.close() outfile.close()
# STEP 3: Create a gni file with the generated files. # STEP 3: Create a gni file with the generated files.
with open(out_file_gni, 'w') as outfile: with open(out_file_gni, 'w') as outfile:
outcode = template_shader_includes_gni.format( outcode = template_shader_includes_gni.format(
script_name = __file__, script_name = __file__,
copyright_year = date.today().year, copyright_year = date.today().year,
...@@ -565,3 +572,7 @@ with open(out_file_gni, 'w') as outfile: ...@@ -565,3 +572,7 @@ with open(out_file_gni, 'w') as outfile:
shaders_list = ',\n'.join([' "' + slash(shader) + '"' for shader in output_shaders])) shaders_list = ',\n'.join([' "' + slash(shader) + '"' for shader in output_shaders]))
outfile.write(outcode) outfile.write(outcode)
outfile.close() outfile.close()
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,23 +86,44 @@ def gen_format_case(index, vk_to_index_to_format_map, vk_map): ...@@ -85,23 +86,44 @@ 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'
tree = etree.parse(script_relative('../../../../third_party/vulkan-headers/src/registry/vk.xml')) input_file_name = 'vk_mandatory_format_support_data.json'
root = tree.getroot() out_file_name = 'vk_mandatory_format_support_table_autogen.cpp'
vk_format_enums = root.findall(".//enums[@name='VkFormat']/enum") vk_xml_file = '../../../../third_party/vulkan-headers/src/registry/vk.xml'
vk_format_name_to_index_map = {}
num_formats = len(vk_format_enums) # auto_script parameters.
for format_enum in vk_format_enums: if len(sys.argv) > 1:
inputs = [
'../angle_format.py',
input_file_name,
vk_xml_file,
]
outputs = [out_file_name]
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
tree = etree.parse(script_relative(vk_xml_file))
root = tree.getroot()
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']) index = int(format_enum.attrib['value'])
vk_format = format_enum.attrib['name'] vk_format = format_enum.attrib['name']
vk_format_name_to_index_map[index] = vk_format vk_format_name_to_index_map[index] = vk_format
vk_map = angle_format.load_json(input_file_name) 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] 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( output_cpp = template_table_autogen_cpp.format(
copyright_year = date.today().year, copyright_year = date.today().year,
num_formats = num_formats, num_formats = num_formats,
format_case_data = "\n,".join(vk_cases), format_case_data = "\n,".join(vk_cases),
...@@ -109,6 +131,11 @@ output_cpp = template_table_autogen_cpp.format( ...@@ -109,6 +131,11 @@ output_cpp = template_table_autogen_cpp.format(
out_file_name = out_file_name, out_file_name = out_file_name,
input_file_name = input_file_name) input_file_name = input_file_name)
with open(out_file_name + '_autogen.cpp', 'wt') as out_file: with open(out_file_name, 'wt') as out_file:
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() 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,11 +56,27 @@ size_t g_numProcs = {num_procs}; ...@@ -55,11 +56,27 @@ 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':
print ','.join(inputs)
elif sys.argv[1] == 'outputs':
print ','.join(outputs)
else:
print('Invalid script parameters')
return 1
return 0
json_data = angle_format.load_json(data_source_name)
all_functions = {}
for description, functions in json_data.iteritems():
for function in functions: for function in functions:
if function.startswith("gl"): if function.startswith("gl"):
all_functions[function] = "gl::" + function[2:] all_functions[function] = "gl::" + function[2:]
...@@ -71,9 +88,9 @@ for description, functions in json_data.iteritems(): ...@@ -71,9 +88,9 @@ for description, functions in json_data.iteritems():
else: else:
all_functions[function] = function all_functions[function] = function
proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.iteritems())] proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.iteritems())]
with open(out_file_name, 'wb') as out_file: with open(out_file_name, 'w') as out_file:
output_cpp = template_cpp.format( output_cpp = template_cpp.format(
script_name = sys.argv[0], script_name = sys.argv[0],
data_source_name = data_source_name, data_source_name = data_source_name,
...@@ -82,3 +99,8 @@ with open(out_file_name, 'wb') as out_file: ...@@ -82,3 +99,8 @@ with open(out_file_name, 'wb') as out_file:
num_procs = len(proc_data)) num_procs = len(proc_data))
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() 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