diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index aa387df70..7f9b4a2a9 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -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. | diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index c6061f3d4..0ef799ea0 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -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 diff --git a/crates/metal2vulkan-runtime/src/device/create.rs b/crates/metal2vulkan-runtime/src/device/create.rs index 51477e52f..dadd1b45a 100644 --- a/crates/metal2vulkan-runtime/src/device/create.rs +++ b/crates/metal2vulkan-runtime/src/device/create.rs @@ -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 ) } diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index 04986618a..1248f940a 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -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 diff --git a/crates/metal2vulkan-runtime/src/tests/queue_limits.rs b/crates/metal2vulkan-runtime/src/tests/queue_limits.rs index e9729bedf..997e9ebff 100644 --- a/crates/metal2vulkan-runtime/src/tests/queue_limits.rs +++ b/crates/metal2vulkan-runtime/src/tests/queue_limits.rs @@ -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, diff --git a/docs/API.md b/docs/API.md index 09ecb8994..4ce0c7081 100644 --- a/docs/API.md +++ b/docs/API.md @@ -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