v3dv: move extensions table to v3dv_device

So one less python generator. Based on anv (MR#8792) and radv
(MR#8900).

With this change v3dv doesn't have any more a custom python code
generator.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10484>
This commit is contained in:
Alejandro Piñeiro 2021-04-27 14:01:48 +02:00 committed by Marge Bot
parent 8d72992ed5
commit 79e4451430
5 changed files with 58 additions and 231 deletions

View File

@ -29,28 +29,6 @@ v3dv_entrypoints = custom_target(
depend_files : vk_entrypoints_gen_depend_files,
)
v3dv_extensions_c = custom_target(
'v3dv_extensions.c',
input : ['v3dv_extensions_gen.py', vk_api_xml],
output : 'v3dv_extensions.c',
command : [
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
'--out-c', '@OUTPUT@',
],
depend_files : [files('v3dv_extensions.py'), vk_extensions_gen],
)
v3dv_extensions_h = custom_target(
'v3dv_extensions.h',
input : ['v3dv_extensions_gen.py', vk_api_xml],
output : 'v3dv_extensions.h',
command : [
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
'--out-h', '@OUTPUT@',
],
depend_files : [files('v3dv_extensions.py'), vk_extensions_gen],
)
libv3dv_files = files(
'v3dv_bo.c',
'v3dv_cl.c',
@ -119,7 +97,7 @@ endif
libvulkan_broadcom = shared_library(
'vulkan_broadcom',
[libv3dv_files, v3dv_entrypoints, v3dv_extensions_c, v3dv_extensions_h, sha1_h],
[libv3dv_files, v3dv_entrypoints, sha1_h],
include_directories : [
inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_broadcom, inc_compiler, inc_util, inc_vulkan_wsi,
],

View File

@ -88,6 +88,59 @@ static const VkAllocationCallbacks default_alloc = {
.pfnFree = default_free_func,
};
#define V3DV_API_VERSION VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION)
VkResult
v3dv_EnumerateInstanceVersion(uint32_t *pApiVersion)
{
*pApiVersion = V3DV_API_VERSION;
return VK_SUCCESS;
}
#define V3DV_HAS_SURFACE (VK_USE_PLATFORM_WIN32_KHR || \
VK_USE_PLATFORM_WAYLAND_KHR || \
VK_USE_PLATFORM_XCB_KHR || \
VK_USE_PLATFORM_XLIB_KHR || \
VK_USE_PLATFORM_DISPLAY_KHR)
static const struct vk_instance_extension_table instance_extensions = {
#ifdef VK_USE_PLATFORM_DISPLAY_KHR
.KHR_display = true,
#endif
.KHR_external_memory_capabilities = true,
.KHR_get_physical_device_properties2 = true,
#ifdef V3DV_HAS_SURFACE
.KHR_get_surface_capabilities2 = true,
.KHR_surface = true,
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
.KHR_wayland_surface = true,
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
.KHR_xcb_surface = true,
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
.KHR_xlib_surface = true,
#endif
.EXT_debug_report = true,
};
static void
get_device_extensions(const struct v3dv_physical_device *device,
struct vk_device_extension_table *ext)
{
*ext = (struct vk_device_extension_table) {
.KHR_external_memory = true,
.KHR_external_memory_fd = true,
.KHR_maintenance1 = true,
#ifdef V3DV_HAS_SURFACE
.KHR_swapchain = true,
#endif
.EXT_external_memory_dma_buf = true,
.EXT_private_data = true,
};
}
VkResult
v3dv_EnumerateInstanceExtensionProperties(const char *pLayerName,
uint32_t *pPropertyCount,
@ -98,7 +151,7 @@ v3dv_EnumerateInstanceExtensionProperties(const char *pLayerName,
return vk_error(NULL, VK_ERROR_LAYER_NOT_PRESENT);
return vk_enumerate_instance_extension_properties(
&v3dv_instance_extensions_supported, pPropertyCount, pProperties);
&instance_extensions, pPropertyCount, pProperties);
}
VkResult
@ -124,7 +177,7 @@ v3dv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
&dispatch_table, &v3dv_instance_entrypoints, true);
result = vk_instance_init(&instance->vk,
&v3dv_instance_extensions_supported,
&instance_extensions,
&dispatch_table,
pCreateInfo, pAllocator);
@ -722,8 +775,7 @@ physical_device_init(struct v3dv_physical_device *device,
goto fail;
}
v3dv_physical_device_get_supported_extensions(device,
&device->vk.supported_extensions);
get_device_extensions(device, &device->vk.supported_extensions);
pthread_mutex_init(&device->mutex, NULL);
@ -1151,7 +1203,7 @@ v3dv_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
};
*pProperties = (VkPhysicalDeviceProperties) {
.apiVersion = v3dv_physical_device_api_version(pdevice),
.apiVersion = V3DV_API_VERSION,
.driverVersion = vk_get_driver_version(),
.vendorID = v3dv_physical_device_vendor_id(pdevice),
.deviceID = v3dv_physical_device_device_id(pdevice),

View File

@ -1,149 +0,0 @@
COPYRIGHT = """\
/*
* Copyright 2017 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
"""
import copy
import re
def _bool_to_c_expr(b):
if b is True:
return 'true'
if b is False:
return 'false'
return b
class Extension:
def __init__(self, name, ext_version, enable):
self.name = name
self.ext_version = int(ext_version)
self.enable = _bool_to_c_expr(enable)
class ApiVersion:
def __init__(self, version, enable):
self.version = version
self.enable = _bool_to_c_expr(enable)
API_PATCH_VERSION = 155
# Supported API versions. Each one is the maximum patch version for the given
# version. Version come in increasing order and each version is available if
# it's provided "enable" condition is true and all previous versions are
# available.
API_VERSIONS = [
ApiVersion('1.0', True),
ApiVersion('1.1', False),
]
MAX_API_VERSION = None # Computed later
EXTENSIONS = [
Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'),
Extension('VK_KHR_external_memory', 1, True),
Extension('VK_KHR_external_memory_capabilities', 1, True),
Extension('VK_KHR_external_memory_fd', 1, True),
Extension('VK_KHR_get_physical_device_properties2', 1, True),
Extension('VK_KHR_get_surface_capabilities2', 1, 'V3DV_HAS_SURFACE'),
Extension('VK_KHR_maintenance1', 2, True),
Extension('VK_KHR_surface', 25, 'V3DV_HAS_SURFACE'),
Extension('VK_KHR_swapchain', 68, 'V3DV_HAS_SURFACE'),
Extension('VK_KHR_wayland_surface', 6, 'VK_USE_PLATFORM_WAYLAND_KHR'),
Extension('VK_KHR_xcb_surface', 6, 'VK_USE_PLATFORM_XCB_KHR'),
Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'),
Extension('VK_EXT_debug_report', 9, True),
Extension('VK_EXT_external_memory_dma_buf', 1, True),
Extension('VK_EXT_image_drm_format_modifier', 1, False),
Extension('VK_EXT_private_data', 1, True),
]
# Sort the extension list the way we expect: KHR, then EXT, then vendors
# alphabetically. For digits, read them as a whole number sort that.
# eg.: VK_KHR_8bit_storage < VK_KHR_16bit_storage < VK_EXT_acquire_xlib_display
def extension_order(ext):
order = []
for substring in re.split('(KHR|EXT|[0-9]+)', ext.name):
if substring == 'KHR':
order.append(1)
if substring == 'EXT':
order.append(2)
elif substring.isdigit():
order.append(int(substring))
else:
order.append(substring)
return order
for i in range(len(EXTENSIONS) - 1):
if extension_order(EXTENSIONS[i + 1]) < extension_order(EXTENSIONS[i]):
print(EXTENSIONS[i + 1].name + ' should come before ' + EXTENSIONS[i].name)
exit(1)
class VkVersion:
def __init__(self, string):
split = string.split('.')
self.major = int(split[0])
self.minor = int(split[1])
if len(split) > 2:
assert len(split) == 3
self.patch = int(split[2])
else:
self.patch = None
# Sanity check. The range bits are required by the definition of the
# VK_MAKE_VERSION macro
assert self.major < 1024 and self.minor < 1024
assert self.patch is None or self.patch < 4096
assert str(self) == string
def __str__(self):
ver_list = [str(self.major), str(self.minor)]
if self.patch is not None:
ver_list.append(str(self.patch))
return '.'.join(ver_list)
def c_vk_version(self):
patch = self.patch if self.patch is not None else 0
ver_list = [str(self.major), str(self.minor), str(patch)]
return 'VK_MAKE_VERSION(' + ', '.join(ver_list) + ')'
def __int_ver(self):
# This is just an expansion of VK_VERSION
patch = self.patch if self.patch is not None else 0
return (self.major << 22) | (self.minor << 12) | patch
def __gt__(self, other):
# If only one of them has a patch version, "ignore" it by making
# other's patch version match self.
if (self.patch is None) != (other.patch is None):
other = copy.copy(other)
other.patch = self.patch
return self.__int_ver() > other.__int_ver()
MAX_API_VERSION = VkVersion('0.0.0')
for version in API_VERSIONS:
version.version = VkVersion(version.version)
version.version.patch = API_PATCH_VERSION
assert version.version > MAX_API_VERSION
MAX_API_VERSION = version.version

View File

@ -1,52 +0,0 @@
COPYRIGHT = """\
/*
* Copyright 2017 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
"""
import os.path
import sys
from v3dv_extensions import *
VULKAN_UTIL = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../vulkan/util'))
sys.path.append(VULKAN_UTIL)
from vk_extensions_gen import *
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--out-c', help='Output C file.')
parser.add_argument('--out-h', help='Output H file.')
parser.add_argument('--xml',
help='Vulkan API XML file.',
required=True,
action='append',
dest='xml_files')
args = parser.parse_args()
includes = [
]
gen_extensions('v3dv', args.xml_files, API_VERSIONS, MAX_API_VERSION,
EXTENSIONS, args.out_c, args.out_h)

View File

@ -69,7 +69,6 @@
#include "u_atomic.h"
#include "v3dv_entrypoints.h"
#include "v3dv_extensions.h"
#include "v3dv_bo.h"
#include "drm-uapi/v3d_drm.h"
@ -1878,7 +1877,6 @@ v3dv_get_internal_depth_type(VkFormat format)
}
}
uint32_t v3dv_physical_device_api_version(struct v3dv_physical_device *dev);
uint32_t v3dv_physical_device_vendor_id(struct v3dv_physical_device *dev);
uint32_t v3dv_physical_device_device_id(struct v3dv_physical_device *dev);