Hash :
1d7be50a
Author :
Date :
2017-10-29T18:06:50
Vulkan: Upgrade RGB8 textures to RGBA8. It's unlikely any real hardware supports this format. Hack in a fixed fallback format for RGB8. We could consider implementing conditional support by checking the VkPhysicalDevice properties. This extends the Vulkan format support info in the RendererVk class to distinguish between a Buffer and Texture format. This is closely related to how Vulkan has separate format support bits for Linear Textures, Optimal Textures, and Buffers. We probably won't need to keep separate caps for Linear/Optimal, but it makes sense for Buffers to eventually use the same format tables. BUG=angleproject:2207 Change-Id: I8d427a99db15b314b13dd99f31aa1ac5055f0881 Reviewed-on: https://chromium-review.googlesource.com/742376 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
#!/usr/bin/python
# Copyright 2016 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# gen_vk_format_table.py:
# Code generation for vk format map
from datetime import date
import json
import math
import pprint
import os
import re
import sys
sys.path.append('..')
import angle_format
template_table_autogen_cpp = """// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {input_file_name}
//
// Copyright {copyright_year} The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// {out_file_name}:
// Queries for full Vulkan format information based on GL format.
#include "libANGLE/renderer/vulkan/formatutilsvk.h"
#include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
using namespace angle;
namespace rx
{{
namespace vk
{{
void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &angleFormat)
{{
switch (angleFormat.id)
{{
{format_case_data}
default:
UNREACHABLE();
break;
}}
}}
}} // namespace vk
}} // namespace rx
"""
empty_format_entry_template = """{space}case angle::Format::ID::{format_id}:
{space} // This format is not implemented in Vulkan.
{space} break;
"""
format_entry_template = """{space}case angle::Format::ID::{format_id}:
{space}{{
{space} internalFormat = {internal_format};
{space} textureFormatID = angle::Format::ID::{texture_format_id};
{space} vkTextureFormat = {vk_texture_format};
{space} bufferFormatID = angle::Format::ID::{buffer_format_id};
{space} vkBufferFormat = {vk_buffer_format};
{space} dataInitializerFunction = {initializer};
{space} break;
{space}}}
"""
def gen_format_case(angle, internal_format, vk_map):
if angle not in vk_map or angle == 'NONE':
return empty_format_entry_template.format(
space = ' ',
format_id = angle)
texture_format_id = angle
buffer_format_id = angle
vk_format_name = vk_map[angle]
vk_buffer_format = vk_format_name
vk_texture_format = vk_format_name
if isinstance(vk_format_name, dict):
info = vk_format_name
vk_format_name = info["native"]
if "buffer" in info:
buffer_format_id = info["buffer"]
vk_buffer_format = vk_map[buffer_format_id]
assert(not isinstance(vk_buffer_format, dict))
else:
vk_buffer_format = vk_format_name
if "texture" in info:
texture_format_id = info["texture"]
vk_texture_format = vk_map[texture_format_id]
assert(not isinstance(vk_texture_format, dict))
else:
vk_texture_format = vk_format_name
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'
out_file_name = 'vk_format_table'
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_cases = [gen_format_case(angle, gl, vk_map) 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 + '_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp)
out_file.close()