vulkan: Add framework for common entrypoints

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
This commit is contained in:
Jason Ekstrand 2021-01-24 14:26:23 -06:00 committed by Marge Bot
parent 0be8200839
commit 94d02e8dea
6 changed files with 50 additions and 5 deletions

View File

@ -66,6 +66,17 @@ $(intermediates)/util/vk_enum_to_str.c: $(MESA_TOP)/src/vulkan/util/gen_enum_to_
$(intermediates)/util/vk_enum_to_str.h: $(intermediates)/util/vk_enum_to_str.c
$(intermediates)/util/vk_common_entrypoints.c: $(MESA_TOP)/src/vulkan/util/vk_entrypoints_gen.py \
$(vulkan_api_xml)
@echo "target Generated: $(PRIVATE_MODULE) <= $(notdir $(@))"
@mkdir -p $(dir $@)
$(hide) $(MESA_PYTHON2) $< \
--xml $(vulkan_api_xml) \
--proto --weak --prefix vk_common \
--out-c $@ --out-h $(dir $@)/vk_common_entrypoints.h
$(intermediates)/util/vk_common_entrypoints.h: $(intermediates)/util/vk_common_entrypoints.c
$(intermediates)/util/vk_dispatch_table.c: $(MESA_TOP)/src/vulkan/util/vk_dispatch_table_gen.py \
$(vulkan_api_xml)
@echo "target Generated: $(PRIVATE_MODULE) <= $(notdir $(@))"

View File

@ -44,6 +44,8 @@ VULKAN_UTIL_FILES := \
VULKAN_UTIL_GENERATED_FILES := \
util/vk_enum_to_str.c \
util/vk_enum_to_str.h \
util/vk_common_entrypoints.c \
util/vk_common_entrypoints.h \
util/vk_dispatch_table.c \
util/vk_dispatch_table.h \
util/vk_extensions.c \

View File

@ -40,6 +40,16 @@ files_vulkan_util = files(
'vk_util.h',
)
vk_common_entrypoints = custom_target(
'vk_common_entrypoints',
input : [vk_entrypoints_gen, vk_api_xml],
output : ['vk_common_entrypoints.h', 'vk_common_entrypoints.c'],
command : [
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'vk_common',
],
)
vk_dispatch_table = custom_target(
'vk_dispatch_table',
input : ['vk_dispatch_table_gen.py', vk_api_xml],
@ -73,7 +83,8 @@ vk_extensions = custom_target(
libvulkan_util = static_library(
'vulkan_util',
[files_vulkan_util, vk_dispatch_table, vk_enum_to_str, vk_extensions],
[files_vulkan_util, vk_common_entrypoints, vk_dispatch_table,
vk_enum_to_str, vk_extensions],
include_directories : [inc_include, inc_src, inc_gallium],
dependencies : [vulkan_wsi_deps, idep_mesautil],
c_args : [vulkan_wsi_args],
@ -87,6 +98,8 @@ idep_vulkan_util_headers = declare_dependency(
)
idep_vulkan_util = declare_dependency(
link_with : libvulkan_util,
# Instruct users of this library to link with --whole-archive. Otherwise,
# our weak function overloads may not resolve properly.
link_whole : libvulkan_util,
dependencies : idep_vulkan_util_headers
)

View File

@ -23,6 +23,7 @@
#include "vk_device.h"
#include "vk_common_entrypoints.h"
#include "vk_instance.h"
#include "vk_physical_device.h"
#include "util/hash_table.h"
@ -45,9 +46,14 @@ vk_device_init(struct vk_device *device,
device->physical = physical_device;
if (dispatch_table != NULL)
if (dispatch_table != NULL) {
device->dispatch_table = *dispatch_table;
/* Add common entrypoints without overwriting driver-provided ones. */
vk_device_dispatch_table_from_entrypoints(
&device->dispatch_table, &vk_common_device_entrypoints, false);
}
if (physical_device != NULL) {
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
int idx;

View File

@ -24,6 +24,7 @@
#include "vk_instance.h"
#include "vk_alloc.h"
#include "vk_common_entrypoints.h"
VkResult
vk_instance_init(struct vk_instance *instance,
@ -75,9 +76,14 @@ vk_instance_init(struct vk_instance *instance,
}
}
if (dispatch_table != NULL)
if (dispatch_table != NULL) {
instance->dispatch_table = *dispatch_table;
/* Add common entrypoints without overwriting driver-provided ones. */
vk_instance_dispatch_table_from_entrypoints(
&instance->dispatch_table, &vk_common_instance_entrypoints, false);
}
return VK_SUCCESS;
}

View File

@ -23,6 +23,8 @@
#include "vk_physical_device.h"
#include "vk_common_entrypoints.h"
VkResult
vk_physical_device_init(struct vk_physical_device *pdevice,
struct vk_instance *instance,
@ -36,9 +38,14 @@ vk_physical_device_init(struct vk_physical_device *pdevice,
if (supported_extensions != NULL)
pdevice->supported_extensions = *supported_extensions;
if (dispatch_table != NULL)
if (dispatch_table != NULL) {
pdevice->dispatch_table = *dispatch_table;
/* Add common entrypoints without overwriting driver-provided ones. */
vk_physical_device_dispatch_table_from_entrypoints(
&pdevice->dispatch_table, &vk_common_physical_device_entrypoints, false);
}
return VK_SUCCESS;
}