Hash :
0cec82a5
Author :
Date :
2018-03-14T09:21:07
Vulkan: Implement basic depth/stencil buffers. This implements basic depth/stencil states and clearing. This also implements "fallback" texture formats in the texture generation. Fallback formats are those that are chosen at runtime for replacements for main formats which lack driver support. They are different from override formats, which are always used because we assume there is no driver support. The Vulkan spec only asserts that one of the two of D32 or D24 has mandatory support. In the case of AMD, D24 is not supported fully, and we need the fallback format support emulation. Bug: angleproject:2357 Change-Id: Ic86cede3c69ff9893a06b3a55c3b5d2d897fa55f Reviewed-on: https://chromium-review.googlesource.com/916701 Commit-Queue: Jamie Madill <jmadill@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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
#!/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. See vk_format_map.json for data source.
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/vk_format_utils.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};
{space} vkTextureFormat = {vk_texture_format};
{space} bufferFormatID = angle::Format::ID::{buffer};
{space} vkBufferFormat = {vk_buffer_format};
{space} dataInitializerFunction = {initializer};
{space} break;
{space}}}
"""
# This currently only handles texture fallback formats.
fallback_format_entry_template = """{space}case angle::Format::ID::{format_id}:
{space}{{
{space} internalFormat = {internal_format};
{space} if (!HasFullFormatSupport(physicalDevice, {vk_texture_format}))
{space} {{
{space} textureFormatID = angle::Format::ID::{fallback_texture};
{space} vkTextureFormat = {fallback_vk_texture_format};
{space} dataInitializerFunction = {fallback_initializer};
{space} ASSERT(HasFullFormatSupport(physicalDevice, {fallback_vk_texture_format}));
{space} }}
{space} else
{space} {{
{space} textureFormatID = angle::Format::ID::{texture};
{space} vkTextureFormat = {vk_texture_format};
{space} dataInitializerFunction = {initializer};
{space} }}
{space} bufferFormatID = angle::Format::ID::{buffer};
{space} vkBufferFormat = {vk_buffer_format};
{space} break;
{space}}}
"""
def gen_format_case(angle, internal_format, vk_json_data):
vk_map = vk_json_data["map"]
vk_overrides = vk_json_data["overrides"]
vk_fallbacks = vk_json_data["fallbacks"]
args = {
"space": " ",
"format_id": angle,
"internal_format": internal_format
}
if ((angle not in vk_map) and (angle not in vk_overrides) and
(angle not in vk_fallbacks)) or angle == 'NONE':
return empty_format_entry_template.format(**args)
template = format_entry_template
if angle in vk_map:
args["buffer"] = angle
args["texture"] = angle
if angle in vk_overrides:
args.update(vk_overrides[angle])
if angle in vk_fallbacks:
template = fallback_format_entry_template
fallback = vk_fallbacks[angle]
assert not "buffer" in fallback, "Buffer fallbacks not yet supported"
assert "texture" in fallback, "Fallback must have a texture fallback"
args["fallback_texture"] = fallback["texture"]
args["fallback_vk_texture_format"] = vk_map[fallback["texture"]]
args["fallback_initializer"] = angle_format.get_internal_format_initializer(
internal_format, fallback["texture"])
assert "buffer" in args, "Missing buffer format for " + angle
assert "texture" in args, "Missing texture format for " + angle
args["vk_buffer_format"] = vk_map[args["buffer"]]
args["vk_texture_format"] = vk_map[args["texture"]]
args["initializer"] = angle_format.get_internal_format_initializer(
internal_format, args["texture"])
return template.format(**args)
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_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 + '_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp)
out_file.close()