From 56a86dcc14f7ebefef43fb36d73af9a3d5f614d3 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 16:54:36 -0800 Subject: [PATCH] Tests: indexed patches beside instanced or scaled factors name their cause (red) TessellationCause gains IndexedPatchFactors: a control-point index type beside a per-instance factor step or a factor scale where pointers are device addresses used directly. The link test asserts it for each such pair on every committed profile of the identity domains, and that each pair without the index type is planned. The address form's refusal (pipeline/link/tessellation control_plan) still names no cause, so the test fails. --- crates/metal2vulkan/src/error/mod.rs | 5 +++ .../src/pipeline/link/tessellation/tests.rs | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/crates/metal2vulkan/src/error/mod.rs b/crates/metal2vulkan/src/error/mod.rs index f3b0b4267..cc839f42c 100644 --- a/crates/metal2vulkan/src/error/mod.rs +++ b/crates/metal2vulkan/src/error/mod.rs @@ -1217,6 +1217,11 @@ pub enum TessellationCause { /// A post-tessellation vertex function's control-point input used other than as the operand of /// a call to its control-point function, or that function called on another pointer. ControlPointInput, + /// A control-point index type beside tessellation factors that step per instance or are + /// scaled, on a device whose pointers are device addresses used directly: there the + /// control-point indices' address takes the control stage's push words that hold the + /// factors' instance stride and scale. + IndexedPatchFactors, /// A patch attribute that steps per instance at a rate above 1. InstanceStepRate, /// A patch input (a patch's or its control points' stage input) or a patch builtin (the diff --git a/crates/metal2vulkan/src/pipeline/link/tessellation/tests.rs b/crates/metal2vulkan/src/pipeline/link/tessellation/tests.rs index 18273a8b7..be3b0d2a7 100644 --- a/crates/metal2vulkan/src/pipeline/link/tessellation/tests.rs +++ b/crates/metal2vulkan/src/pipeline/link/tessellation/tests.rs @@ -109,6 +109,43 @@ fn a_control_point_index_type_binds_its_index_buffer() { } } +/// Where pointers are device addresses used directly, the control-point indices' address takes +/// the control stage's push words that hold the factors' instance stride and scale: a +/// control-point index type beside a per-instance factor step or a factor scale is refused by that +/// structure (`IndexedPatchFactors`), and each of those without the index type is planned. +#[test] +fn indexed_patches_with_instanced_or_scaled_factors_name_their_cause_on_the_address_form() { + use crate::error::TessellationCause; + use crate::metal::TessellationFactorStepFunction as Step; + let mut tried = 0; + for (stem, p) in crate::spirv::testing::committed_profiles().expect("committed profiles") { + if !crate::lower::access::identity(&p) { + continue; + } + for (step, scale) in [ + (Step::PerInstance, false), + (Step::PerPatchAndPerInstance, false), + (Step::PerPatch, true), + ] { + let mut d = TessellationDescriptor { + factor_step_function: step, + factor_scale_enabled: scale, + ..TessellationDescriptor::default() + }; + control_plan(Some(&d), stage(), 1, &p) + .unwrap_or_else(|e| panic!("{stem}: {step:?}, scale {scale}: {e}")); + d.control_point_index_type = TessellationControlPointIndexType::UInt32; + assert_eq!( + control_plan(Some(&d), stage(), 1, &p).err(), + Some(Unsupported::tessellation(TessellationCause::IndexedPatchFactors).into()), + "{stem}: {step:?}, scale {scale}" + ); + } + tried += 1; + } + assert!(tried > 0, "a committed profile takes the identity domains"); +} + /// A factor maximum above the device's generation level needs the level. #[test] fn the_generation_level_is_refused_typed() {