Device creation: a device the driver refuses for want of resources takes its least queue plan once, else Error::DeviceRefused

What: create_on makes the device through made_within_resources. Where vkCreateDevice answers
VK_ERROR_INITIALIZATION_FAILED or VK_ERROR_OUT_OF_DEVICE_MEMORY for the queue plan's VkQueues and
the least plan (LEAST_QUEUE_LIMITS: a round robin of one VkQueue, none reserved for presenting;
the reserved, extra and staging queues kept, as DeviceOptions::queue_limits of one and none
places them) takes fewer, it asks once more with the least plan's. A device made so announces the
new Performance degradation least-queue-plan (Degradation::LeastQueuePlan, naming both plans'
VkQueues and the driver's answer), sends none of the queue limits' informational messages (the
limits are the runtime's, not the caller's), and its presenting queue's shared-present-queue
notice says why it reserved none. A second refusal, or one where the least plan takes no fewer
(RADV's and lavapipe's one graphics queue), is the new typed Error::DeviceRefused(DeviceRefused
{ device, attempts }), naming each attempt's VkQueues and answer; before, it was Error::Vulkan(-3)
or Error::OutOfMemory(Device). Any other failure is the driver's as before. A recovery's new
VkDevice is made the same way.

Why: on an RTX 2080 (NVIDIA 620.70.06) devices of the plan's 17 VkQueues were refused from the
eighth live one, in one process and across processes alike (tests::many_devices at 655ed906fb:
seven made, p8 to p16 refused with VK_ERROR_INITIALIZATION_FAILED while BAR1 had 38 MiB free),
where a consumer measured the GPU's channel heap holding about 160 to 180 channels, raw 16-queue
devices refused from the 11th and 1-queue devices made 24 of 24.

Public surface (api_signatures.tsv blessed): Error::DeviceRefused and DeviceRefused are new, and
Degradation::LeastQueuePlan. A consumer that matched Error::Vulkan or Error::OutOfMemory from
Device::system_default* for a refused device now gets Error::DeviceRefused.

Tests: tests::queue_limits::a_device_refused_for_want_of_resources_is_asked_for_once_with_its_least_plan
(no device: NVIDIA's family shape with a reserved and an extra queue, 18 VkQueues then 4; made at
once, made with the least plan after either refusal, refused naming both attempts, any other
failure the driver's, and one attempt where the least plan takes no fewer). tests::least_queue_plan
(device tests, refuse_next_devices stands in for the driver's refusal on the creating thread):
refused once, a device whose plan takes more than one VkQueue is made with 1 + 0 and announces
least-queue-plan once, its presenting queue's shared-present-queue naming it; refused twice, it is
Error::DeviceRefused with an attempt per plan. Verified on lavapipe (ms01, job m3-max-16047): both
pass on the refused branch (llvmpipe's plan is one VkQueue: "ERROR_INITIALIZATION_FAILED with 1
VkQueue(s)"); the made branch runs on NVIDIA next. scripts/refusal-surface --check passes
(REFUSALS.md does not list top-level Error variants).

Docs: docs/API.md's catalogue entry for least-queue-plan; the runtime README's device opening
(the fallback) and error table (DeviceRefused). RUNTIME_VERSION is the orchestrator's to bump at
landing.
This commit is contained in:
Anees Iqbal committed 2026-11-11 08:31:42 -08:00
1 parent 6e5dc3b087
commit 21a01a4d7b
13 files changed
+546 -39

No files matched your search

+10
View File
@@ -3375,6 +3375,16 @@ bound.
which the extension requires. Cost: the driver keeps its own cache of the device's pipelines
beside the shader cache's records, with whatever it writes to disk and holds in memory for it; the
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, other devices of the GPU holding its channels or its BAR), made with those of
its least plan: a round robin of one `VkQueue` and none reserved for presenting, beside the
reserved, extra and staging queues. Announced once, as the device is made, naming the `VkQueue`s
of each plan and the driver's answer; a device the driver refuses with the least plan too is
refused, `Error::DeviceRefused`. Cost: its command queues, presenting ones included, share one
`VkQueue`, so one queue's command buffers wait behind another's whole command buffer where
Metal's run beside each other; what each command buffer does is the same.
- `metal2vulkan-degrade-device-recovered` (performance). `DeviceRecovered`: A device whose
`VkDevice` was lost made a new one behind it, as Metal's device survives its GPU's recovery: its
command buffers in flight failed, the oldest incomplete one as the hang (`GpuHang`, counted