A device refused for want of resources takes its least plan whatever the code: too many objects and host memory too

vkCreateDevice's answer where the device-specific resources a logical
device needs run out is VK_ERROR_TOO_MANY_OBJECTS (the Vulkan spec,
vkCreateDevice), and a driver short of host memory for the plan's
VkQueues may make a device of fewer: both now take the least plan, as
VK_ERROR_INITIALIZATION_FAILED (NVIDIA's channels) and
VK_ERROR_OUT_OF_DEVICE_MEMORY did. A device refused with both plans
is refused naming each attempt, as before.

Asked for by a device test on an RTX 2080 under parallel test load
(job m3-max-18589) that got OutOfMemory(Host) from
Device::system_default_with, where the least plan's three queues would
have fit: the 2080 held 10 devices of the plan's 18 VkQueues at once,
and 68 of the least plan's 3 (job m3-max-18774).

The pure test of made_within_resources takes each of the four codes.
This commit is contained in:
Anees Iqbal committed 2026-11-11 21:51:22 -08:00
1 parent 65c06e2e4c
commit 3aa410e2ab
6 files changed
+33 -18

No files matched your search

+5 -4
View File
@@ -194,9 +194,10 @@ Vulkan-side choices Metal has no counterpart for:
| `record_executions` | Keep, per command buffer, which pipeline each dispatch and draw ran (`CommandBuffer::executions`). Off by default. |
**A driver short of resources.** Where the driver refuses a device with its queue plan's `VkQueue`s
for want of its resources (`vkCreateDevice` answering `VK_ERROR_INITIALIZATION_FAILED` or
`VK_ERROR_OUT_OF_DEVICE_MEMORY`: on NVIDIA's driver, other devices of the GPU, in this process or
others, holding what it needs, such as its channels), the runtime asks once more with its least
for want of its resources (`vkCreateDevice` answering `VK_ERROR_TOO_MANY_OBJECTS`,
`VK_ERROR_INITIALIZATION_FAILED`, `VK_ERROR_OUT_OF_DEVICE_MEMORY` or `VK_ERROR_OUT_OF_HOST_MEMORY`:
on NVIDIA's driver, other devices of the GPU, in this process or others, holding what it needs,
such as its channels), the runtime asks once more with its least
plan's: a round robin of one `VkQueue` and none reserved for presenting, the reserved, extra,
staging and fill queues kept (`queue_limits` of one and none, without that option's messages). A
device made so announces `metal2vulkan-degrade-least-queue-plan` once, as it is made: its command
@@ -743,7 +744,7 @@ message text. The ones a consumer meets most:
| `OutOfMemory`, `DeviceLost`, `Vulkan`, `NoDevice` | The device's own failures. `NoDevice`: the loader opened but found no usable device. A device holding `maxMemoryAllocationCount` allocations live has the next refused (`Vulkan`, `VK_ERROR_TOO_MANY_OBJECTS`) without a call of the driver, counted in `WorkCounts::memory_allocations_refused_at_limit`, once the frees its releases posted to its free thread (which count until they run) completed. |
| `LoaderNotFound(LoaderNotFound)` | The Vulkan loader did not open; `tried` lists each path. |
| `DriverSetting(DriverSetting)` | A driver setting the runtime cannot run under, such as MoltenVK with `MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS` off. |
| `DeviceRefused(DeviceRefused)` | The driver refused to make the device for want of its resources (`VK_ERROR_INITIALIZATION_FAILED` or `VK_ERROR_OUT_OF_DEVICE_MEMORY`), with its queue plan's `VkQueue`s and then with its least plan's; `attempts` names each. Other devices of the GPU, in any process, hold what it lacks; once fewer are live it may be made. |
| `DeviceRefused(DeviceRefused)` | The driver refused to make the device for want of its resources (`VK_ERROR_TOO_MANY_OBJECTS`, `VK_ERROR_INITIALIZATION_FAILED`, `VK_ERROR_OUT_OF_DEVICE_MEMORY` or `VK_ERROR_OUT_OF_HOST_MEMORY`), with its queue plan's `VkQueue`s and then with its least plan's; `attempts` names each. Other devices of the GPU, in any process, hold what it lacks; once fewer are live it may be made. |
| `WaitWouldDeadlock(DeadlockCause)` | A command buffer wait that would deadlock, refused at once instead of hanging. |
| `ShaderCache(...)` | The shader cache directory cannot be made or written. |
@@ -2273,8 +2273,9 @@ degradations! {
records, with whatever it writes to disk and holds in memory for it; the pipelines \
made are the same";
/// A device the driver refused to make for want of its resources with the `VkQueue`s of
/// its queue plan (`vkCreateDevice` answering `VK_ERROR_INITIALIZATION_FAILED` or
/// `VK_ERROR_OUT_OF_DEVICE_MEMORY`: on NVIDIA's driver, other devices of the GPU, in this
/// its queue plan (`vkCreateDevice` answering `VK_ERROR_TOO_MANY_OBJECTS`,
/// `VK_ERROR_INITIALIZATION_FAILED`, `VK_ERROR_OUT_OF_DEVICE_MEMORY` or
/// `VK_ERROR_OUT_OF_HOST_MEMORY`: on NVIDIA's driver, other devices of the GPU, in this
/// process or others, holding what it needs, such as its channels), made with those of its
/// least plan: a round robin of one `VkQueue` and none reserved for presenting, beside the
/// plan's reserved, extra, staging and fill queues (`DeviceOptions::queue_limits` of one
@@ -1366,13 +1366,18 @@ pub(crate) struct LeastPlanTaken {
pub(crate) least: usize,
}
/// Whether `result` is a driver's refusal of a device for want of its resources:
/// `VK_ERROR_INITIALIZATION_FAILED` (NVIDIA's driver, what it needs, such as its GPU's channels,
/// held by other devices) or `VK_ERROR_OUT_OF_DEVICE_MEMORY`.
/// Whether `result` is a driver's refusal of a device for want of its resources, of which a
/// device of fewer `VkQueue`s needs less: `VK_ERROR_TOO_MANY_OBJECTS` (Vulkan's answer where the
/// device-specific resources a logical device needs run out), `VK_ERROR_INITIALIZATION_FAILED`
/// (NVIDIA's driver, what it needs, such as its GPU's channels, held by other devices),
/// `VK_ERROR_OUT_OF_DEVICE_MEMORY` or `VK_ERROR_OUT_OF_HOST_MEMORY`.
fn for_want_of_resources(result: vk::Result) -> bool {
matches!(
result,
vk::Result::ERROR_INITIALIZATION_FAILED | vk::Result::ERROR_OUT_OF_DEVICE_MEMORY
vk::Result::ERROR_TOO_MANY_OBJECTS
| vk::Result::ERROR_INITIALIZATION_FAILED
| vk::Result::ERROR_OUT_OF_DEVICE_MEMORY
| vk::Result::ERROR_OUT_OF_HOST_MEMORY
)
}
+5 -4
View File
@@ -399,10 +399,11 @@ impl fmt::Display for DriverSetting {
}
/// A device the driver refused to make for want of its resources ([`Error::DeviceRefused`]):
/// `vkCreateDevice` answered `VK_ERROR_INITIALIZATION_FAILED` or `VK_ERROR_OUT_OF_DEVICE_MEMORY`
/// for the `VkQueue`s of the device's queue plan, and again for those of its least plan (a round
/// robin of one `VkQueue` and none reserved for presenting, beside the plan's reserved, extra and
/// staging queues), or the least plan takes no fewer and the device was asked for once. Other
/// `vkCreateDevice` answered `VK_ERROR_TOO_MANY_OBJECTS`, `VK_ERROR_INITIALIZATION_FAILED`,
/// `VK_ERROR_OUT_OF_DEVICE_MEMORY` or `VK_ERROR_OUT_OF_HOST_MEMORY` for the `VkQueue`s of the
/// device's queue plan, and again for those of its least plan (a round robin of one `VkQueue` and
/// none reserved for presenting, beside the plan's reserved, extra and staging queues), or the
/// least plan takes no fewer and the device was asked for once. Other
/// devices of the GPU, in this process or others, hold what the driver lacks, on NVIDIA's driver
/// such as its channels, one or more a `VkQueue` (on an RTX 2080, NVIDIA 620.70.06, the kernel
/// logged that it could not allocate a channel's instance block). Its counterpart, Metal's
@@ -275,8 +275,9 @@ fn planned(families: &[vk::QueueFamilyProperties], options: &DeviceOptions) -> P
(plan, extra)
}
/// A device the driver refuses for want of its resources (`VK_ERROR_INITIALIZATION_FAILED`,
/// `VK_ERROR_OUT_OF_DEVICE_MEMORY`) with its queue plan's `VkQueue`s is asked for once more with
/// A device the driver refuses for want of its resources (`VK_ERROR_TOO_MANY_OBJECTS`,
/// `VK_ERROR_INITIALIZATION_FAILED`, `VK_ERROR_OUT_OF_DEVICE_MEMORY`,
/// `VK_ERROR_OUT_OF_HOST_MEMORY`) with its queue plan's `VkQueue`s is asked for once more with
/// its least plan's (the lane's limits: one for the round robin, none for presenting, the
/// reserved, extra, staging and fill queues kept), and made with them, saying what it took; refused
/// twice, it is refused naming both attempts, and where the least plan takes no fewer (RADV's and
@@ -321,7 +322,12 @@ fn a_device_refused_for_want_of_resources_is_asked_for_once_with_its_least_plan(
)
};
assert_eq!(run(&[]), (Ok(("made", 19, None)), vec![19]));
for refusal in [FAILED, MEMORY] {
for refusal in [
vk::Result::ERROR_TOO_MANY_OBJECTS,
FAILED,
MEMORY,
vk::Result::ERROR_OUT_OF_HOST_MEMORY,
] {
let took = LeastPlanTaken {
planned: 19,
refusal,
+2 -1
View File
@@ -3542,7 +3542,8 @@ bound.
pipelines made are the same.
- `metal2vulkan-degrade-least-queue-plan` (performance). `LeastQueuePlan`: A device the driver
refused to make for want of its resources with the `VkQueue`s of its queue plan (`vkCreateDevice`
answering `VK_ERROR_INITIALIZATION_FAILED` or `VK_ERROR_OUT_OF_DEVICE_MEMORY`; on NVIDIA's driver,
answering `VK_ERROR_TOO_MANY_OBJECTS`, `VK_ERROR_INITIALIZATION_FAILED`,
`VK_ERROR_OUT_OF_DEVICE_MEMORY` or `VK_ERROR_OUT_OF_HOST_MEMORY`; on NVIDIA's driver,
other devices of the GPU holding what it needs, such as its channels), made with those of its
least plan: a round robin of one `VkQueue` and none reserved for presenting, beside the reserved,
extra, staging and fill queues. Announced once, as the device is made, naming the `VkQueue`s of