mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-02 21:50:34 +01:00
zink: use device select layer settings to disable device selection
In the case where we have a device that we want to choose after
probing, there is no point in asking the device select layer to do
any reordering at all.
This helps avoid a deadlock inside compositors where we don't need
device selection anyways.
Cc: mesa-stable
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
(cherry picked from commit 04071c5f9a)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39462>
This commit is contained in:
parent
ed2e176073
commit
6d3eb4cfa6
3 changed files with 27 additions and 2 deletions
|
|
@ -194,7 +194,7 @@
|
|||
"description": "zink: use device select layer settings to disable device selection",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import platform
|
|||
# - nonstandard: Disables validation (cross-checking with vk.xml) if True.
|
||||
EXTENSIONS = [
|
||||
Extension("VK_EXT_debug_utils"),
|
||||
Extension("VK_EXT_layer_settings"),
|
||||
Extension("VK_KHR_get_physical_device_properties2"),
|
||||
Extension("VK_KHR_external_memory_capabilities"),
|
||||
Extension("VK_KHR_external_semaphore_capabilities"),
|
||||
|
|
@ -62,8 +63,10 @@ LAYERS = [
|
|||
conditions=["zink_debug & ZINK_DEBUG_VALIDATION"]),
|
||||
Layer("VK_LAYER_LUNARG_standard_validation",
|
||||
conditions=["zink_debug & ZINK_DEBUG_VALIDATION", "!have_layer_KHRONOS_validation"]),
|
||||
Layer("VK_LAYER_MESA_device_select")
|
||||
]
|
||||
|
||||
|
||||
REPLACEMENTS = {
|
||||
"VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES2_EXTENSION_NAME" : "VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME"
|
||||
}
|
||||
|
|
@ -87,6 +90,7 @@ struct zink_screen;
|
|||
|
||||
struct zink_instance_info {
|
||||
uint32_t loader_version;
|
||||
bool no_device_select;
|
||||
|
||||
%for ext in extensions:
|
||||
bool have_${ext.name_with_vendor()};
|
||||
|
|
@ -261,6 +265,20 @@ zink_create_instance(struct zink_screen *screen, struct zink_instance_info *inst
|
|||
ici.ppEnabledLayerNames = layers;
|
||||
ici.enabledLayerCount = num_layers;
|
||||
|
||||
VkLayerSettingEXT ds_layer = {0};
|
||||
VkLayerSettingsCreateInfoEXT lsci = {0};
|
||||
uint32_t no_device_select_value = instance_info->no_device_select;
|
||||
if (have_EXT_layer_settings && have_layer_MESA_device_select) {
|
||||
ds_layer.pLayerName = "MESA_device_select";
|
||||
ds_layer.pSettingName = "no_device_select";
|
||||
ds_layer.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT;
|
||||
ds_layer.valueCount = 1;
|
||||
ds_layer.pValues = &no_device_select_value;
|
||||
lsci.sType = VK_STRUCTURE_TYPE_LAYER_SETTINGS_CREATE_INFO_EXT;
|
||||
lsci.settingCount = 1;
|
||||
lsci.pSettings = &ds_layer;
|
||||
ici.pNext = &lsci;
|
||||
}
|
||||
GET_PROC_ADDR_INSTANCE_LOCAL(screen, NULL, CreateInstance);
|
||||
assert(vk_CreateInstance);
|
||||
|
||||
|
|
|
|||
|
|
@ -1652,6 +1652,12 @@ zink_destroy_screen(struct pipe_screen *pscreen)
|
|||
glsl_type_singleton_decref();
|
||||
}
|
||||
|
||||
static bool
|
||||
zink_picks_device(int dev_major, uint64_t adapter_luid)
|
||||
{
|
||||
return (dev_major > 0 && dev_major < 255) || adapter_luid;
|
||||
}
|
||||
|
||||
static int
|
||||
zink_get_display_device(const struct zink_screen *screen, uint32_t pdev_count,
|
||||
const VkPhysicalDevice *pdevs, int64_t dev_major,
|
||||
|
|
@ -1723,7 +1729,7 @@ choose_pdev(struct zink_screen *screen, int64_t dev_major, int64_t dev_minor, ui
|
|||
bool cpu = debug_get_bool_option("LIBGL_ALWAYS_SOFTWARE", false) ||
|
||||
debug_get_bool_option("D3D_ALWAYS_SOFTWARE", false);
|
||||
|
||||
if (cpu || (dev_major > 0 && dev_major < 255) || adapter_luid) {
|
||||
if (cpu || zink_picks_device(dev_major, adapter_luid)) {
|
||||
uint32_t pdev_count;
|
||||
int idx;
|
||||
VkPhysicalDevice *pdevs;
|
||||
|
|
@ -3383,6 +3389,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev
|
|||
simple_mtx_lock(&instance_lock);
|
||||
if (++instance_refcount == 1) {
|
||||
instance_info.loader_version = zink_get_loader_version(screen);
|
||||
instance_info.no_device_select = zink_picks_device(dev_major, adapter_luid);
|
||||
instance = zink_create_instance(screen, &instance_info);
|
||||
}
|
||||
if (!instance) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue