mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 19:20:08 +01:00
zink: Factor out instance setup a bit more
The VkInstance is really display state not screen state, as is the loader version. Factor this out a bit further so that zink_create_instance fills in a zink_instance_info. The latter struct still lives in the zink_screen for now but that'll move soon. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8968>
This commit is contained in:
parent
f88d9c9d7c
commit
f2573760b4
3 changed files with 14 additions and 13 deletions
|
|
@ -32,7 +32,7 @@ import sys
|
|||
# constructor: Extension(name, core_since=None, functions=[])
|
||||
# The attributes:
|
||||
# - core_since: the Vulkan version where this extension is promoted to core.
|
||||
# When screen->loader_version is greater than or equal to this
|
||||
# When instance_info->loader_version is greater than or equal to this
|
||||
# instance_info.have_{name} is set to true unconditionally. This
|
||||
# is done because loading extensions that are promoted to core is
|
||||
# considered to be an error.
|
||||
|
|
@ -80,6 +80,8 @@ header_code = """
|
|||
struct zink_screen;
|
||||
|
||||
struct zink_instance_info {
|
||||
uint32_t loader_version;
|
||||
|
||||
%for ext in extensions:
|
||||
bool have_${ext.name_with_vendor()};
|
||||
%endfor
|
||||
|
|
@ -90,7 +92,7 @@ struct zink_instance_info {
|
|||
};
|
||||
|
||||
VkInstance
|
||||
zink_create_instance(struct zink_screen *screen);
|
||||
zink_create_instance(struct zink_instance_info *instance_info);
|
||||
|
||||
bool
|
||||
zink_load_instance_extensions(struct zink_screen *screen);
|
||||
|
|
@ -103,7 +105,7 @@ impl_code = """
|
|||
#include "zink_screen.h"
|
||||
|
||||
VkInstance
|
||||
zink_create_instance(struct zink_screen *screen)
|
||||
zink_create_instance(struct zink_instance_info *instance_info)
|
||||
{
|
||||
/* reserve one slot for MoltenVK */
|
||||
const char *layers[${len(extensions) + 1}] = { 0 };
|
||||
|
|
@ -138,7 +140,7 @@ zink_create_instance(struct zink_screen *screen)
|
|||
extensions[num_extensions++] = ${ext.extension_name_literal()};
|
||||
}
|
||||
%else:
|
||||
if (screen->loader_version < ${ext.core_since.version()}) {
|
||||
if (instance_info->loader_version < ${ext.core_since.version()}) {
|
||||
if (!strcmp(extension_props[i].extensionName, ${ext.extension_name_literal()})) {
|
||||
have_${ext.name_with_vendor()} = true;
|
||||
extensions[num_extensions++] = ${ext.extension_name_literal()};
|
||||
|
|
@ -185,7 +187,7 @@ zink_create_instance(struct zink_screen *screen)
|
|||
}
|
||||
|
||||
%for ext in extensions:
|
||||
screen->instance_info.have_${ext.name_with_vendor()} = have_${ext.name_with_vendor()};
|
||||
instance_info->have_${ext.name_with_vendor()} = have_${ext.name_with_vendor()};
|
||||
%endfor
|
||||
|
||||
%for layer in layers:
|
||||
|
|
@ -198,7 +200,7 @@ zink_create_instance(struct zink_screen *screen)
|
|||
%>\
|
||||
if (have_layer_${layer.pure_name()} ${conditions}) {
|
||||
layers[num_layers++] = ${layer.extension_name_literal()};
|
||||
screen->instance_info.have_layer_${layer.pure_name()} = true;
|
||||
instance_info->have_layer_${layer.pure_name()} = true;
|
||||
}
|
||||
%endfor
|
||||
|
||||
|
|
@ -212,7 +214,7 @@ zink_create_instance(struct zink_screen *screen)
|
|||
ai.pApplicationName = "unknown";
|
||||
|
||||
ai.pEngineName = "mesa zink";
|
||||
ai.apiVersion = screen->loader_version;
|
||||
ai.apiVersion = instance_info->loader_version;
|
||||
|
||||
VkInstanceCreateInfo ici = {};
|
||||
ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
|
|
@ -234,7 +236,7 @@ bool
|
|||
zink_load_instance_extensions(struct zink_screen *screen)
|
||||
{
|
||||
if (zink_debug & ZINK_DEBUG_VALIDATION) {
|
||||
printf("zink: Loader %d.%d.%d \\n", VK_VERSION_MAJOR(screen->loader_version), VK_VERSION_MINOR(screen->loader_version), VK_VERSION_PATCH(screen->loader_version));
|
||||
printf("zink: Loader %d.%d.%d \\n", VK_VERSION_MAJOR(screen->instance_info.loader_version), VK_VERSION_MINOR(screen->instance_info.loader_version), VK_VERSION_PATCH(screen->instance_info.loader_version));
|
||||
}
|
||||
|
||||
%for ext in extensions:
|
||||
|
|
@ -247,7 +249,7 @@ zink_load_instance_extensions(struct zink_screen *screen)
|
|||
}
|
||||
%elif bool(ext.instance_funcs):
|
||||
if (screen->instance_info.have_${ext.name_with_vendor()}) {
|
||||
if (screen->loader_version < ${ext.core_since.version()}) {
|
||||
if (screen->instance_info.loader_version < ${ext.core_since.version()}) {
|
||||
%for func in ext.instance_funcs:
|
||||
GET_PROC_ADDR_INSTANCE_LOCAL(screen->instance, ${func}${ext.vendor()});
|
||||
screen->vk_${func} = vk_${func}${ext.vendor()};
|
||||
|
|
|
|||
|
|
@ -1164,8 +1164,9 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
|
|||
|
||||
zink_debug = debug_get_option_zink_debug();
|
||||
|
||||
screen->loader_version = zink_get_loader_version();
|
||||
screen->instance = zink_create_instance(screen);
|
||||
screen->instance_info.loader_version = zink_get_loader_version();
|
||||
screen->instance = zink_create_instance(&screen->instance_info);
|
||||
|
||||
if (!screen->instance)
|
||||
goto fail;
|
||||
|
||||
|
|
|
|||
|
|
@ -73,8 +73,6 @@ struct zink_screen {
|
|||
|
||||
uint32_t cur_custom_border_color_samplers;
|
||||
|
||||
uint32_t loader_version;
|
||||
|
||||
bool needs_mesa_wsi;
|
||||
|
||||
PFN_vkGetPhysicalDeviceFeatures2 vk_GetPhysicalDeviceFeatures2;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue