From e2750b6723ee76cdfe0c1fbb2562bd1c09d8e5eb Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 09:53:09 -0800 Subject: [PATCH] rt test: a portability device gives the translator each portability feature it states (red) The floor's PORTABILITY table enables only the four portability features it requires (imageViewFormatSwizzle, mutableComparisonSamplers, multisampleArrayImage, imageView2DOn3DImage), so on a device that lists VK_KHR_portability_subset, shader_enables passes the translator none of the six other portability features it names (constantAlphaColorBlendFactors, vertexAttributeAccessBeyondStride, samplerMipLodBias, shaderSampleRateInterpolationFunctions, separateStencilMaskRef, pointPolygons). The translator then refuses what they carry (sample-rate interpolation in census 65547 on MoltenVK) though the device states them. A unit test on the floor's queries: a device at the floor listing the subset and stating every portability feature; it asks that each portability feature the translator names reach shader_enables. Expected red until creation enables them where the device states them. --- .../src/tests/feature_enables.rs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/crates/metal2vulkan-runtime/src/tests/feature_enables.rs b/crates/metal2vulkan-runtime/src/tests/feature_enables.rs index d18179a55..cb7987093 100644 --- a/crates/metal2vulkan-runtime/src/tests/feature_enables.rs +++ b/crates/metal2vulkan-runtime/src/tests/feature_enables.rs @@ -132,6 +132,57 @@ fn every_feature_creation_enables_reaches_the_translator() { ); } +/// On a device that lists `VK_KHR_portability_subset`, each portability feature the translator +/// names and the device states reaches the translator's description, as on a device without the +/// subset, which offers each by Vulkan's definition: the translator then refuses only what the +/// device lacks. +#[test] +fn a_portability_device_gives_the_translator_each_portability_feature_it_states() { + let mut device = at_the_floor(); + device + .extensions + .push(ash::khr::portability_subset::NAME.to_owned()); + device.features.portability = vk::PhysicalDevicePortabilitySubsetFeaturesKHR { + constant_alpha_color_blend_factors: vk::TRUE, + events: vk::TRUE, + image_view_format_reinterpretation: vk::TRUE, + image_view_format_swizzle: vk::TRUE, + image_view2_d_on3_d_image: vk::TRUE, + multisample_array_image: vk::TRUE, + mutable_comparison_samplers: vk::TRUE, + point_polygons: vk::TRUE, + sampler_mip_lod_bias: vk::TRUE, + separate_stencil_mask_ref: vk::TRUE, + shader_sample_rate_interpolation_functions: vk::TRUE, + tessellation_isolines: vk::TRUE, + tessellation_point_mode: vk::TRUE, + triangle_fans: vk::TRUE, + vertex_attribute_access_beyond_stride: vk::TRUE, + ..Default::default() + }; + let capabilities = decide(&device).unwrap_or_else(|below| panic!("{below}")); + let enables = shader_enables(&capabilities); + let named = [ + VkFeature::ConstantAlphaColorBlendFactors, + VkFeature::VertexAttributeAccessBeyondStride, + VkFeature::SamplerMipLodBias, + VkFeature::MutableComparisonSamplers, + VkFeature::ShaderSampleRateInterpolationFunctions, + VkFeature::MultisampleArrayImage, + VkFeature::ImageView2DOn3DImage, + VkFeature::SeparateStencilMaskRef, + VkFeature::ImageViewFormatSwizzle, + VkFeature::PointPolygons, + ]; + let unstated: Vec = (named.into_iter()) + .filter(|feature| !enables.features.contains(feature)) + .collect(); + assert!( + unstated.is_empty(), + "stated by the device and named by the translator, not passed: {unstated:?}" + ); +} + /// The enable set is what the translator's description states as enabled on a device that /// reports every feature of creation's tables, lists every extension creation may enable and has /// the descriptor room of the attachment reads and of set 0's kernel storage buffers: it holds