rt: under direct driver loading, an instance extension counts only where a given driver lists it, or the loader implements it

Instance::with_drivers gives the loader the consumer's drivers in its exclusive mode, so no driver a
manifest names is loaded. But the loader's vkEnumerateInstanceExtensionProperties still lists those
manifest drivers' extensions, and enabled() counted an extension as offered where the loader OR a
given driver listed it. On the Mac host, with KosmicKrisp loaded directly and MoltenVK's manifest
installed, a consumer asking for VK_EXT_headless_surface got it enabled because MoltenVK lists it,
and vkCreateInstance failed with VK_ERROR_EXTENSION_NOT_PRESENT: every rt test of reims's Mac leg
failed at the instance (its batch 329b, m3-max-58452).

Now, with drivers given, a consumer's extension counts only where a given driver lists it. The
optional floor extension VK_KHR_portability_enumeration, which the specification says "is
implemented in the loader", still counts on the loader's list. Without drivers nothing changes: the
loader's list is the system drivers'.

Verified: the floor test's new cases (a manifest driver's extension counted without drivers, left
out with drivers that do not list it, portability enumeration kept) beside the existing ones; the
compile job named in the landing.
This commit is contained in:
Anees Iqbal committed 2026-11-20 05:41:23 -08:00
1 parent f07c86db30
commit bdbcdd539d
2 files changed
+34 -14

No files matched your search

+20 -14
View File
@@ -64,8 +64,12 @@ impl Instance {
/// instance then enables `VK_LUNARG_direct_driver_loading` and gives the loader the list in
/// its exclusive mode (`VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG`): no driver the system
/// installed, or that the loader's variables name, is loaded. An instance extension is offered
/// where the loader or one of the drivers lists it, as the loader does not ask such drivers
/// for theirs. With no loader and no driver, it is [`Instance::new`].
/// where one of the drivers lists it, as the loader does not ask such drivers for theirs, or,
/// for one the loader implements itself (`VK_KHR_portability_enumeration`: "This extension is
/// implemented in the loader"), where the loader lists it. The loader's own list also holds
/// the extensions of the drivers its manifests name, which the exclusive mode does not load,
/// so no other extension counts for being on it. With no loader and no driver, it is
/// [`Instance::new`].
///
/// Err: as [`Instance::new`], [`Error::Loader`] where the library at `loader` does not load;
/// [`Error::NoDirectDriverLoading`] where a driver is given and the loader does not offer
@@ -235,10 +239,13 @@ fn names(listed: Result<Vec<vk::ExtensionProperties>, vk::Result>) -> Result<Vec
}
/// The instance extensions instance creation enables: the floor's, then each of the optional
/// ones' and of `extensions` that the `loader` or the consumer's drivers (`drivers`) list,
/// once each, and where the consumer gives drivers (`direct`), direct driver loading, which only
/// the loader offers. Err: [`Error::NoDirectDriverLoading`] where `direct` and the loader does
/// not list it.
/// ones' and of `extensions` that is offered, once each, and where the consumer gives drivers
/// (`direct`), direct driver loading, which only the loader offers. Without drivers, an extension
/// is offered where the `loader` lists it. With them (`drivers`, the names they list), the loader
/// loads no driver its manifests name, though its list holds their extensions too: there an
/// extension is offered where a given driver lists it, or, for the optional ones, which the loader
/// implements itself (`VK_KHR_portability_enumeration`), where the loader lists it. Err:
/// [`Error::NoDirectDriverLoading`] where `direct` and the loader does not list it.
pub(crate) fn enabled(
loader: &[CString],
drivers: &[CString],
@@ -248,14 +255,13 @@ pub(crate) fn enabled(
let mut names: Vec<CString> = (floor::INSTANCE_EXTENSIONS.iter())
.map(|&name| name.to_owned())
.collect();
let listed = |name: &CStr| {
loader
.iter()
.chain(drivers)
.any(|offered| offered.as_c_str() == name)
};
for &name in floor::OPTIONAL_INSTANCE_EXTENSIONS.iter().chain(extensions) {
if listed(name) && !names.iter().any(|enabled| enabled.as_c_str() == name) {
let lists =
|list: &[CString], name: &CStr| list.iter().any(|offered| offered.as_c_str() == name);
let optional = (floor::OPTIONAL_INSTANCE_EXTENSIONS.iter()).map(|&name| (name, true));
let asked = extensions.iter().map(|&name| (name, false));
for (name, in_the_loader) in optional.chain(asked) {
let offered = lists(drivers, name) || ((!direct || in_the_loader) && lists(loader, name));
if offered && !names.iter().any(|enabled| enabled.as_c_str() == name) {
names.push(name.to_owned());
}
}
+14
View File
@@ -195,6 +195,20 @@ fn an_instance_enables_what_the_loader_or_the_drivers_offer_and_direct_loading_w
enabled(&owned(&[portability]), &drivers, &[], true),
Err(Error::NoDirectDriverLoading)
));
// The loader also lists a manifest driver's extension (`headless`). Without drivers it is the
// system's driver's, and counts; with drivers that do not list it, the exclusive mode loads no
// driver that offers it, so it is left out, while the loader's own portability enumeration
// still counts.
let headless = ash::ext::headless_surface::NAME;
let loader = owned(&[direct, portability, headless]);
assert_eq!(
names(enabled(&loader, &[], &[headless], false)),
owned(&[surface, portability, headless])
);
assert_eq!(
names(enabled(&loader, &drivers, &[headless], true)),
owned(&[surface, portability, direct])
);
}
/// The consumer's loader is the library at its path, alone: a path that holds none is refused by