From af28fabe97f7f1dcc3e2e7c84e7c76269003b9da Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 01:07:05 -0800 Subject: [PATCH] rt floor: independentBlend and fragmentStoresAndAtomics required and enabled In Metal, each of a render pipeline's color attachments blends by its own state, and a fragment function may write and atomically update device memory. The translator asks Feature(IndependentBlend) for the first (it refuses with Unsupported(IndependentBlending) without it) and Feature(FragmentStoresAndAtomics) for the second. The floor enabled neither, so the translator, which sees only what device creation enables, refused them. Vulkan 1.4 requires both of every graphics device (55.1), Roadmap 2022 lists both, and every lab profile reports both (RADV, ANV, NVIDIA, lavapipe). The planner ruled them required floor features. The README's floor table names them. The floor test's at-floor device reports them; the test refuses a device that lacks either one, and checks that device creation and the translator's enable set include both. Found by the render census under the floor's real enable set (job 45000, on the draws branch with robustBufferAccess): gb translated 144 of 274 render pipelines, with 123 refused as IndependentBlending and 1 needing FragmentStoresAndAtomics (b2: 141 of 266, 118 and 1). With both enabled (job 45063), gb translates 267 and b2 259, the same counts as under the profile's whole feature set. Verified: lint of this commit (floor tests); census 45063 for the counts. --- crates/metal2vulkan-rt/README.md | 2 ++ crates/metal2vulkan-rt/src/floor.rs | 5 +++++ crates/metal2vulkan-rt/src/tests/floor.rs | 23 ++++++++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index 8798c5760..f271fa184 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -1193,6 +1193,8 @@ Presenting runs on the runtime's own device; nothing is exported or imported. | `subgroupSizeControl` | `VkPhysicalDeviceVulkan13Features` | a kernel's SIMD groups at Metal's width of 32, where the device lists compute in `requiredSubgroupSizeStages` | | `computeFullSubgroups` | `VkPhysicalDeviceVulkan13Features` | a kernel's subgroups required full, so each SIMD group is one subgroup | | `robustImageAccess` | `VkPhysicalDeviceVulkan13Features` | an image write or atomic out of range dropped and a read out of range zero, with no guard in the shader | +| `independentBlend` | `VkPhysicalDeviceFeatures` | each color attachment of a render pipeline blended by its own state, as Metal's are | +| `fragmentStoresAndAtomics` | `VkPhysicalDeviceFeatures` | a fragment function's writes and atomics on device memory | | `timelineSemaphore` | `VkPhysicalDeviceVulkan12Features` | submission and completion | | `hostQueryReset` | `VkPhysicalDeviceVulkan12Features` | a command buffer's timestamp queries reset on the host as it retires | | `synchronization2` | `VkPhysicalDeviceVulkan13Features` | barriers, layout changes and submission | diff --git a/crates/metal2vulkan-rt/src/floor.rs b/crates/metal2vulkan-rt/src/floor.rs index 30014ca10..d5bcb6836 100644 --- a/crates/metal2vulkan-rt/src/floor.rs +++ b/crates/metal2vulkan-rt/src/floor.rs @@ -269,6 +269,11 @@ pub(crate) const REQUIRED: &[Feature] = &[ // An image access out of range: a write or an atomic is dropped and a read answers zero, as // Metal's, with no guard in the shader. Vulkan 1.3's. feature!(vulkan13.robust_image_access => RobustImageAccess), + // A render pipeline's color attachments blend each by its own state, as Metal's do, and a + // fragment function writes and atomically updates device memory, as Metal's may. Vulkan 1.4 + // requires both of every graphics device. + feature!(core.independent_blend => IndependentBlend), + feature!(core.fragment_stores_and_atomics => FragmentStoresAndAtomics), // Submission, barriers and render passes. feature!(vulkan12.timeline_semaphore), // GPU times: a command buffer's two timestamp queries reset on the host as it retires, so no diff --git a/crates/metal2vulkan-rt/src/tests/floor.rs b/crates/metal2vulkan-rt/src/tests/floor.rs index 7bf7830ce..0523b3dab 100644 --- a/crates/metal2vulkan-rt/src/tests/floor.rs +++ b/crates/metal2vulkan-rt/src/tests/floor.rs @@ -66,6 +66,8 @@ fn at_the_floor() -> Queried { features.vulkan13.subgroup_size_control = vk::TRUE; features.vulkan13.compute_full_subgroups = vk::TRUE; features.vulkan13.robust_image_access = vk::TRUE; + features.core.independent_blend = vk::TRUE; + features.core.fragment_stores_and_atomics = vk::TRUE; features.vulkan12.timeline_semaphore = vk::TRUE; features.vulkan12.host_query_reset = vk::TRUE; features.vulkan13.synchronization2 = vk::TRUE; @@ -132,8 +134,9 @@ fn holds(features: &Features, feature: &crate::floor::Feature) -> bool { /// The translator's description is restricted to what device creation enables: a feature or an /// extension the device reports beyond the floor is outside the enable set, so the translator's -/// profile never relies on it, and the floor's `robustImageAccess` and `nullDescriptor` are in it. -/// `VK_EXT_robustness2`'s robust buffer and image access stay off where the device reports them. +/// profile never relies on it, and the floor's `robustImageAccess`, `independentBlend`, +/// `fragmentStoresAndAtomics` and `nullDescriptor` are in it. `VK_EXT_robustness2`'s robust buffer +/// and image access stay off where the device reports them. #[test] fn the_translator_sees_only_what_device_creation_enables() { use crate::floor::shader_enables; @@ -155,6 +158,10 @@ fn the_translator_sees_only_what_device_creation_enables() { ); let enables = shader_enables(&capabilities); assert!(enables.features.contains(&VkFeature::RobustImageAccess)); + assert!(enables.features.contains(&VkFeature::IndependentBlend)); + assert!(enables + .features + .contains(&VkFeature::FragmentStoresAndAtomics)); assert!(enables.features.contains(&VkFeature::NullDescriptor)); for reported in [ VkFeature::GeometryShader, @@ -209,6 +216,8 @@ fn a_device_at_the_floor_is_above_it() { assert_eq!(enabled.vulkan11.storage_input_output16, vk::FALSE); assert_eq!(enabled.vulkan12.sampler_mirror_clamp_to_edge, vk::FALSE); assert_eq!(enabled.vulkan13.robust_image_access, vk::TRUE); + assert_eq!(enabled.core.independent_blend, vk::TRUE); + assert_eq!(enabled.core.fragment_stores_and_atomics, vk::TRUE); } #[test] @@ -219,7 +228,7 @@ fn each_missing_feature_is_named() { const CORE: &str = "VkPhysicalDeviceFeatures"; const ROBUSTNESS2: &str = "VkPhysicalDeviceRobustness2FeaturesEXT"; type Clear = fn(&mut Features); - let cases: [(Clear, Missing); 29] = [ + let cases: [(Clear, Missing); 31] = [ ( |f| f.vulkan12.buffer_device_address = vk::FALSE, feature(V12, "bufferDeviceAddress"), @@ -326,6 +335,14 @@ fn each_missing_feature_is_named() { |f| f.vulkan13.robust_image_access = vk::FALSE, feature(V13, "robustImageAccess"), ), + ( + |f| f.core.independent_blend = vk::FALSE, + feature(CORE, "independentBlend"), + ), + ( + |f| f.core.fragment_stores_and_atomics = vk::FALSE, + feature(CORE, "fragmentStoresAndAtomics"), + ), ( |f| f.vulkan13.synchronization2 = vk::FALSE, feature(V13, "synchronization2"),