diff --git a/crates/metal2vulkan-validation/src/candidate/engine/graphics/tests.rs b/crates/metal2vulkan-validation/src/candidate/engine/graphics/tests.rs index c191ce61d..39386c9b3 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/graphics/tests.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/graphics/tests.rs @@ -68,10 +68,11 @@ pub(crate) fn reflected_imageblock( .fragment_imageblock } -/// A fragment case's authored depth and stencil aspects are its depth/stencil attachment (the -/// oracle's `Depth32Float` and `Stencil8`), its depth-stencil state is the one its outputs imply, -/// and each aspect is an observable output; a vertex case's attachment, which the oracle does not -/// attach, is refused. +/// A fragment case's authored aspect is its depth/stencil attachment (the oracle's `Stencil8` here, +/// as its `Depth32Float` for a depth), its depth-stencil state is the one its outputs imply, and +/// each aspect is an observable output; an attachment of both aspects, the oracle's two textures, +/// is the runtime's limit (`SeparateDepthStencil`); a vertex case's attachment, which the oracle +/// does not attach, is refused. #[test] fn a_fragment_cases_depth_stencil_attachment_and_state_are_the_oracles() { use crate::literal::LiteralDepthStencil; @@ -95,6 +96,17 @@ fn a_fragment_cases_depth_stencil_attachment_and_state_are_the_oracles() { dimensions: [1, 1], }; let (interface, companion) = checked_companion(&authored, &bitcode); + assert_eq!( + requirements(render_case( + &authored, + &interface, + WITHOUT_SLICE, + companion.as_ref(), + None + )), + [crate::requirement::ToolingRequirement::SeparateDepthStencil].into() + ); + authored.depth_stencil.as_mut().unwrap().initial_depth_b64 = None; let render = render_case( &authored, &interface, @@ -109,7 +121,7 @@ fn a_fragment_cases_depth_stencil_attachment_and_state_are_the_oracles() { Some(LiteralDepthStencil { dimensions: [1, 1], samples: 1, - depth: Some(1.0f32.to_le_bytes().to_vec()), + depth: None, stencil: Some(vec![0xab]), }) ); @@ -128,10 +140,7 @@ fn a_fragment_cases_depth_stencil_attachment_and_state_are_the_oracles() { let template = render_template(&render); assert_eq!( (template.depth_format, template.stencil_format), - ( - Some(metal::PixelFormat::Depth32Float), - Some(metal::PixelFormat::Stencil8) - ) + (None, Some(metal::PixelFormat::Stencil8)) ); let finals = RenderFinals { @@ -213,7 +222,7 @@ fn a_stencil_output_case_plans_its_shadow_where_the_device_lacks_export() { authored.render_targets.clear(); authored.depth_stencil = Some(crate::case::DepthStencilResource { dimensions: [1, 1], - initial_depth_b64: Some("AACAPw==".into()), + initial_depth_b64: None, initial_stencil_b64: Some("qw==".into()), state: None, }); @@ -222,7 +231,7 @@ fn a_stencil_output_case_plans_its_shadow_where_the_device_lacks_export() { dimensions: [1, 1], }; let (interface, companion) = checked_companion(&authored, &bitcode); - let render = render_case( + let mut render = render_case( &authored, &interface, WITHOUT_SLICE, @@ -230,6 +239,10 @@ fn a_stencil_output_case_plans_its_shadow_where_the_device_lacks_export() { None, ) .unwrap(); + // Both aspects are the runtime's limit (`SeparateDepthStencil`), which stops such a case + // before the engine plans it; the plan below is the translator's for both, so the case maps + // with its stencil and takes its depth after. + render.depth_stencil.as_mut().unwrap().depth = Some(1.0f32.to_le_bytes().to_vec()); let companion_bitcode = render.companion.as_ref().unwrap().opaque_bitcode().unwrap(); let libraries = RenderLibraries { vertex: &companion_bitcode, @@ -306,7 +319,7 @@ fn a_multisampled_stencil_output_case_plans_a_shadow_of_its_samples() { authored.raster_sample_count = Some(4); authored.depth_stencil = Some(crate::case::DepthStencilResource { dimensions: [1, 1], - initial_depth_b64: Some(b64(&[1.0f32.to_le_bytes(); 4].concat())), + initial_depth_b64: None, initial_stencil_b64: Some(b64(&[0xab; 4])), state: None, }); @@ -315,7 +328,7 @@ fn a_multisampled_stencil_output_case_plans_a_shadow_of_its_samples() { dimensions: [1, 1], }; let (interface, companion) = checked_companion(&authored, &bitcode); - let render = render_case( + let mut render = render_case( &authored, &interface, WITHOUT_SLICE, @@ -323,6 +336,10 @@ fn a_multisampled_stencil_output_case_plans_a_shadow_of_its_samples() { None, ) .unwrap(); + // Both aspects are the runtime's limit (`SeparateDepthStencil`), which stops such a case + // before the engine plans it; the plan below is the translator's for both, so the case maps + // with its stencil and takes its depth after. + render.depth_stencil.as_mut().unwrap().depth = Some([1.0f32.to_le_bytes(); 4].concat()); assert_eq!( render.attachment_transfer(), AttachmentTransfer::PerSample { samples: 4 } diff --git a/crates/metal2vulkan-validation/src/candidate/tests/engine_render.rs b/crates/metal2vulkan-validation/src/candidate/tests/engine_render.rs index d13001066..3091e0747 100644 --- a/crates/metal2vulkan-validation/src/candidate/tests/engine_render.rs +++ b/crates/metal2vulkan-validation/src/candidate/tests/engine_render.rs @@ -282,10 +282,14 @@ fn a_fragment_case_draws_through_its_generated_passthrough_vertex() { } } -/// A fragment case with a depth/stencil attachment: `fragment_depth_stencil` writes depth 0.5 under -/// `depth(any)` and stencil 7, and the oracle's depth-stencil state (always-pass depth test with -/// writes, always-pass stencil test that replaces) stores both over the attachment's authored 1.0 -/// and 0xab, as the oracle does for case 685a8d84; through the runtime, each aspect alone. +/// A fragment case with a depth/stencil attachment of one aspect draws it as the executor's own +/// context does, through the runtime, which gives it no texture index (shaders neither read nor +/// write it): depth under `sample_rate_depth` (0.125 at one sample, over the authored 1.0), stencil +/// under `fragment_no_writes` (the oracle's always-pass stencil test replaces the authored 0xab with +/// the state's reference). An attachment of both aspects is the oracle's two textures, which the +/// runtime renders into in no one pass, so `render_case` refuses it as the runtime's limit +/// (`SeparateDepthStencil`); and a fragment function's stencil output, `fragment_depth_stencil`'s, +/// the runtime refuses at creation (its README's known gaps of render pipeline states). #[cfg(any(target_os = "linux", target_os = "macos"))] #[test] fn a_fragment_case_writes_its_depth_and_stencil_attachment() { @@ -296,71 +300,45 @@ fn a_fragment_case_writes_its_depth_and_stencil_attachment() { TextureFormat::Rgba32Float, ); authored.render_targets.clear(); - authored.depth_stencil = Some(crate::case::DepthStencilResource { + let depth_stencil = |depth: bool, stencil: bool| { + Some(crate::case::DepthStencilResource { + dimensions: [1, 1], + initial_depth_b64: depth.then(|| b64(&1.0f32.to_le_bytes())), + initial_stencil_b64: stencil.then(|| b64(&[0xab])), + state: None, + }) + }; + let stencil = OutputSelection::Stencil { + origin: [0, 0], dimensions: [1, 1], - initial_depth_b64: Some(b64(&1.0f32.to_le_bytes())), - initial_stencil_b64: Some(b64(&[0xab])), - state: None, - }); - for (output, expected) in [ - ( - OutputSelection::Stencil { - origin: [0, 0], - dimensions: [1, 1], - }, - vec![7], + }; + authored.depth_stencil = depth_stencil(true, true); + authored.output = stencil.clone(); + let (interface, companion) = checked_companion(&authored, &fragment); + match render_case( + &authored, + &interface, + WITHOUT_SLICE, + companion.as_ref(), + None, + ) { + Err(ExecutorError::NotSupported(crate::check::admission::NotSupported::Requirements( + requirements, + ))) => assert_eq!( + requirements, + [crate::requirement::ToolingRequirement::SeparateDepthStencil].into() ), - ( - OutputSelection::Depth { - origin: [0, 0], - dimensions: [1, 1], - }, - 0.5f32.to_le_bytes().to_vec(), - ), - ] { - authored.output = output; - let (case, companion) = with_companion(&authored, &fragment); - let run = run( - &case, - RenderLibraries { - vertex: &companion, - fragment: Some(&fragment), - }, - ) - .unwrap(); - assert_eq!(run.output, expected, "{:?}", authored.output); - assert_eq!( - run.status, - Some(metal2vulkan::bind::StatusReport::default()) - ); + other => panic!("both aspects: {:?}", other.map(|_| ())), } - // Through the runtime, each aspect alone, as the executor's own context draws it: depth under - // `sample_rate_depth` (an eighth at one sample), stencil under `fragment_no_writes` (the state's - // reference replaces it). Neither takes a texture index: shaders neither read nor - // write it. An attachment of both is the oracle's two textures, which the runtime renders - // into in no one pass; a fragment function's stencil output, `fragment_depth_stencil`'s, it - // refuses at creation (its README's known gaps of render pipeline states). #[cfg(target_os = "linux")] { - let depth_stencil = |of_depth: bool| { - Some(crate::case::DepthStencilResource { - dimensions: [1, 1], - initial_depth_b64: of_depth.then(|| b64(&1.0f32.to_le_bytes())), - initial_stencil_b64: (!of_depth).then(|| b64(&[0xab])), - state: None, - }) - }; + let attachmentless = + metal2vulkan_devtools::llvm_assemble_text(crate::case::ATTACHMENTLESS_FRAGMENT_AIR) + .expect("llvm-as on the device lane"); let depth = OutputSelection::Depth { origin: [0, 0], dimensions: [1, 1], }; - let stencil = OutputSelection::Stencil { - origin: [0, 0], - dimensions: [1, 1], - }; - let attachmentless = - metal2vulkan_devtools::llvm_assemble_text(crate::case::ATTACHMENTLESS_FRAGMENT_AIR) - .expect("llvm-as on the device lane"); for (own, entry, aspect, output) in [ ( public("engine/sample_rate.ll"), @@ -373,7 +351,7 @@ fn a_fragment_case_writes_its_depth_and_stencil_attachment() { let mut authored = crate::companion::tests::case(Stage::Fragment, entry, TextureFormat::Rgba32Float); authored.render_targets.clear(); - authored.depth_stencil = depth_stencil(aspect); + authored.depth_stencil = depth_stencil(aspect, !aspect); authored.output = output; let (case, companion) = with_companion(&authored, &own); assert!(crate::candidate::engine::runs_render_through_runtime( @@ -393,8 +371,7 @@ fn a_fragment_case_writes_its_depth_and_stencil_attachment() { assert_eq!(through.output, 0.125f32.to_le_bytes().to_vec()); } } - authored.depth_stencil = depth_stencil(false); - authored.output = stencil; + authored.depth_stencil = depth_stencil(false, true); let (case, companion) = with_companion(&authored, &fragment); assert!(crate::candidate::engine::runs_render_through_runtime( &authored, &case diff --git a/crates/metal2vulkan-validation/src/triage.rs b/crates/metal2vulkan-validation/src/triage.rs index a66371bd8..af62bac6d 100644 --- a/crates/metal2vulkan-validation/src/triage.rs +++ b/crates/metal2vulkan-validation/src/triage.rs @@ -1228,14 +1228,18 @@ entry: ); assert!(imageblock.sample_rate.is_empty() && rate_map.sample_rate.is_empty()); assert!(sample_rate.tooling_requirements.is_empty()); - // A row that operates on a `ulong` texture: described, and no executor's gap. + // A row that operates on a `ulong` texture: described, and the runtime's limit alone + // (`UlongTextureAtomic`), which the focused audit selects by the structure all the same. let mut ulong_row = source(include_str!( "../fixtures/public/engine/unk_ulong_atomics.ll" )); ulong_row.entry = "unk_ulong_atomic_rw".into(); let ulong = classify(&ulong_row).unwrap(); assert!(ulong.ulong_texture); - assert!(ulong.tooling_requirements.is_empty()); + assert_eq!( + ulong.tooling_requirements, + [crate::requirement::ToolingRequirement::UlongTextureAtomic] + ); assert!(!sample_rate.ulong_texture && !tile.ulong_texture); // A fragment function that reads a varying: described with the varying's declared type, // and no requirement selects it. The fragment functions above read none.