diff --git a/crates/metal2vulkan-runtime/src/tests/draw.rs b/crates/metal2vulkan-runtime/src/tests/draw.rs index 36a04ed2d..615b6e491 100644 --- a/crates/metal2vulkan-runtime/src/tests/draw.rs +++ b/crates/metal2vulkan-runtime/src/tests/draw.rs @@ -4041,7 +4041,10 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" { /// Vulkan's standard locations are Metal's and the floor requires them /// (`standardSampleLocations`). /// A state of one sample drawn in the pass is `DrawKind::AttachmentFormats`, and a pass of a - /// 4-sample and a 1-sample attachment `RenderPassKind::SampleCounts`. + /// 4-sample and a 1-sample attachment `RenderPassKind::SampleCounts`. The device renders each + /// of Metal's counts, 1, 2, 4 and 8, that its `framebufferColorSampleCounts`, + /// `framebufferDepthSampleCounts` and `framebufferStencilSampleCounts` all hold, and no other + /// (`supportsTextureSampleCount:`). #[test] fn every_device_draws_four_samples_where_metal_places_them() { let (Some(library), Some(kernels)) = ( @@ -4062,10 +4065,23 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" { device.supports_texture_sample_count(1), "{name}: Vulkan requires 1" ); - for count in [0, 3, 8, 16] { - assert!( - !device.supports_texture_sample_count(count), - "{name}: {count}" + // Metal's counts (1, 2, 4 and 8) the device renders into a colour, a depth and a + // stencil attachment, and nothing else. + let raw = device.raw(); + // SAFETY: the physical device is the instance's. + let limits = + unsafe { (raw.instance).get_physical_device_properties(raw.physical_device) } + .limits; + let renders = (limits.framebuffer_color_sample_counts + & limits.framebuffer_depth_sample_counts + & limits.framebuffer_stencil_sample_counts) + .as_raw(); + for count in 0..=64 { + let metal = matches!(count, 1 | 2 | 4 | 8); + assert_eq!( + device.supports_texture_sample_count(count), + metal && renders & count != 0, + "{name}: {count} samples, of the framebuffer counts {renders:#x}" ); } (device.grant_indices(IndexClass::Texture, 1, 1)) diff --git a/crates/metal2vulkan-runtime/src/tests/sample_positions.rs b/crates/metal2vulkan-runtime/src/tests/sample_positions.rs index 881da373a..889854903 100644 --- a/crates/metal2vulkan-runtime/src/tests/sample_positions.rs +++ b/crates/metal2vulkan-runtime/src/tests/sample_positions.rs @@ -40,7 +40,8 @@ //! the device's `sampleLocationSampleCounts` lacks, and a pass with a depth attachment, are the //! runtime's gap. //! - The standard locations the runtime answers `getDefaultSamplePositions:count:` with are plain -//! Metal's answers on an Apple M3 Max at 1, 2 and 4 samples, bit for bit. +//! Metal's answers on an Apple M3 Max at 1, 2 and 4 samples, and on an AMD Radeon Pro 5300M at +//! 8, bit for bit. /// The placement and the answer's gates, with no device. mod placed { @@ -343,7 +344,7 @@ mod placed { /// Plain Metal's answers to `getDefaultSamplePositions:count:` at each count an Apple M3 Max /// renders, macOS 27.0.1 (the conformance crate's `probes/default_sample_positions.m`, job /// m3-max-78953), sample `i` at `i`. - pub(crate) const METAL_DEFAULTS: [(u32, &[[f32; 2]]); 3] = [ + pub(crate) const METAL_DEFAULTS: [(u32, &[[f32; 2]]); 4] = [ (1, &[[0.5, 0.5]]), (2, &[[0.75, 0.75], [0.25, 0.25]]), ( @@ -355,6 +356,21 @@ mod placed { [0.625, 0.875], ], ), + // An AMD Radeon Pro 5300M's, macOS 26.7.1 (job 82204): the oracle, an Apple M3 Max, + // renders no 8 samples. + ( + 8, + &[ + [0.5625, 0.3125], + [0.4375, 0.6875], + [0.8125, 0.5625], + [0.3125, 0.1875], + [0.1875, 0.8125], + [0.0625, 0.4375], + [0.6875, 0.9375], + [0.9375, 0.0625], + ], + ), ]; /// The standard locations the runtime answers Metal's default positions with are Metal's own, diff --git a/crates/metal2vulkan/src/device/tests/subgroup.rs b/crates/metal2vulkan/src/device/tests/subgroup.rs index d512d38ce..c324c0f58 100644 --- a/crates/metal2vulkan/src/device/tests/subgroup.rs +++ b/crates/metal2vulkan/src/device/tests/subgroup.rs @@ -521,12 +521,14 @@ fn a_class_measured_nowhere_in_a_stage_names_the_stage() { /// No device answers more than an Apple GPU: each answer a vendor's limit could raise past Apple's /// is the lower of the two. Every profile below has at least an Apple GPU's limits, and the /// profiles of other vendors' GPUs more of some, so each answers exactly the Apple GPU's: 1024 -/// threads, 32 KiB of threadgroup memory, 16384 texels a side, and no sample count above 4. +/// threads, 32 KiB of threadgroup memory and 16384 texels a side. Its sample counts are Metal's +/// (1, 2, 4 and 8) that the device renders into a colour, a depth and a stencil attachment. #[test] fn no_profile_answers_more_than_an_apple_gpu() { - let apple = vk::SampleCountFlags::COUNT_1 + let metal = vk::SampleCountFlags::COUNT_1 | vk::SampleCountFlags::COUNT_2 - | vk::SampleCountFlags::COUNT_4; + | vk::SampleCountFlags::COUNT_4 + | vk::SampleCountFlags::COUNT_8; // (profile, its own [threads, threadgroup memory, most samples, 2D texture size]) for (stem, own) in [ ("nvidia-pascal-linux", [1536, 49152, 8, 32768]), @@ -562,7 +564,8 @@ fn no_profile_answers_more_than_an_apple_gpu() { "{stem}" ); assert_eq!(m.max_threadgroup_memory_length, 32 * 1024, "{stem}"); - assert_eq!(m.raster_sample_counts, both & apple, "{stem}"); + let renders = both & l.framebuffer_stencil_sample_counts; + assert_eq!(m.raster_sample_counts, renders & metal, "{stem}"); assert_eq!(m.max_texture_dimension_2d, 16_384, "{stem}"); } let pascal = device("nvidia-pascal-linux"); @@ -573,7 +576,16 @@ fn no_profile_answers_more_than_an_apple_gpu() { let lavapipe = device("lavapipe"); assert_eq!( lavapipe.metal_properties().raster_sample_counts, - vk::SampleCountFlags::COUNT_1 | vk::SampleCountFlags::COUNT_4 + vk::SampleCountFlags::COUNT_1 + | vk::SampleCountFlags::COUNT_4 + | vk::SampleCountFlags::COUNT_8 + ); + let m3 = device("moltenvk-m3"); + assert_eq!( + m3.metal_properties().raster_sample_counts, + vk::SampleCountFlags::COUNT_1 + | vk::SampleCountFlags::COUNT_2 + | vk::SampleCountFlags::COUNT_4 ); } @@ -597,9 +609,11 @@ fn metal_properties_report_d3_d4_values() { m.raster_sample_counts, l.framebuffer_color_sample_counts & l.framebuffer_depth_sample_counts + & l.framebuffer_stencil_sample_counts & (vk::SampleCountFlags::COUNT_1 | vk::SampleCountFlags::COUNT_2 - | vk::SampleCountFlags::COUNT_4), + | vk::SampleCountFlags::COUNT_4 + | vk::SampleCountFlags::COUNT_8), "{stem}" ); assert_eq!(