Commit 7b5fc46b by Jamie Madill

Vulkan: Add Vk format overrides table.

This generalizes the overriding mechanism in gen_Vk_format_table.py. Instead of defining overrides inline, we keep the vk_format_map as a 1:1 mapping from angle format to vk format, and use the overrides map to specify any additional emulation or features we need to support OpenGL textures on Vulkan. This will simplify the implementation for Depth/Stencil formats by making the generator script a bit easier to work with. No code changes, generator script refactor only. Bug: angleproject:2357 Change-Id: I7132d991795eb91d6ad838481c52545c891215bc Reviewed-on: https://chromium-review.googlesource.com/957433Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent 67ae6c58
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# found in the LICENSE file. # found in the LICENSE file.
# #
# gen_vk_format_table.py: # gen_vk_format_table.py:
# Code generation for vk format map # Code generation for vk format map. See vk_format_map.json for data source.
from datetime import date from datetime import date
import json import json
...@@ -65,65 +65,52 @@ empty_format_entry_template = """{space}case angle::Format::ID::{format_id}: ...@@ -65,65 +65,52 @@ empty_format_entry_template = """{space}case angle::Format::ID::{format_id}:
format_entry_template = """{space}case angle::Format::ID::{format_id}: format_entry_template = """{space}case angle::Format::ID::{format_id}:
{space}{{ {space}{{
{space} internalFormat = {internal_format}; {space} internalFormat = {internal_format};
{space} textureFormatID = angle::Format::ID::{texture_format_id}; {space} textureFormatID = angle::Format::ID::{texture};
{space} vkTextureFormat = {vk_texture_format}; {space} vkTextureFormat = {vk_texture_format};
{space} bufferFormatID = angle::Format::ID::{buffer_format_id}; {space} bufferFormatID = angle::Format::ID::{buffer};
{space} vkBufferFormat = {vk_buffer_format}; {space} vkBufferFormat = {vk_buffer_format};
{space} dataInitializerFunction = {initializer}; {space} dataInitializerFunction = {initializer};
{space} break; {space} break;
{space}}} {space}}}
""" """
def gen_format_case(angle, internal_format, vk_map): def gen_format_case(angle, internal_format, vk_map, vk_overrides):
if angle not in vk_map or angle == 'NONE': args = {
return empty_format_entry_template.format( "space": " ",
space = ' ', "format_id": angle,
format_id = angle) "internal_format": internal_format
}
texture_format_id = angle
buffer_format_id = angle if (angle not in vk_map and angle not in vk_overrides) or angle == 'NONE':
return empty_format_entry_template.format(**args)
vk_format_name = vk_map[angle]
vk_buffer_format = vk_format_name if angle in vk_map:
vk_texture_format = vk_format_name args["buffer"] = angle
args["texture"] = angle
if isinstance(vk_format_name, dict):
info = vk_format_name if angle in vk_overrides:
args.update(vk_overrides[angle])
if "buffer" in info:
buffer_format_id = info["buffer"] assert "buffer" in args, "Missing buffer format for " + angle
vk_buffer_format = vk_map[buffer_format_id] assert "texture" in args, "Missing texture format for " + angle
assert(not isinstance(vk_buffer_format, dict))
else: args["vk_buffer_format"] = vk_map[args["buffer"]]
vk_buffer_format = info["native"] args["vk_texture_format"] = vk_map[args["texture"]]
if "texture" in info: args["initializer"] = angle_format.get_internal_format_initializer(
texture_format_id = info["texture"] internal_format, args["texture"])
vk_texture_format = vk_map[texture_format_id]
assert(not isinstance(vk_texture_format, dict)) return format_entry_template.format(**args)
else:
vk_texture_format = info["native"]
initializer = angle_format.get_internal_format_initializer(
internal_format, texture_format_id)
return format_entry_template.format(
space = ' ',
internal_format = internal_format,
format_id = angle,
texture_format_id = texture_format_id,
buffer_format_id = buffer_format_id,
vk_buffer_format = vk_buffer_format,
vk_texture_format = vk_texture_format,
initializer = initializer)
input_file_name = 'vk_format_map.json' input_file_name = 'vk_format_map.json'
out_file_name = 'vk_format_table' out_file_name = 'vk_format_table'
angle_to_gl = angle_format.load_inverse_table(os.path.join('..', 'angle_format_map.json')) angle_to_gl = angle_format.load_inverse_table(os.path.join('..', 'angle_format_map.json'))
vk_map = angle_format.load_json(input_file_name) vk_json_data = angle_format.load_json(input_file_name)
vk_cases = [gen_format_case(angle, gl, vk_map) for angle, gl in sorted(angle_to_gl.iteritems())] vk_map = vk_json_data["map"]
vk_overrides = vk_json_data["overrides"]
vk_cases = [gen_format_case(angle, gl, vk_map, vk_overrides) 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,
......
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