diff --git a/.config/nextest.toml b/.config/nextest.toml index b48828105..50e3ca355 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -12,3 +12,14 @@ slow-timeout = { period = "60s", terminate-after = 20 } [[profile.default.overrides]] filter = 'test(/::soak_/)' slow-timeout = { period = "300s", terminate-after = 24 } + +# The exit lanes' timing checks each run alone. Each measures a child process's exit, from its +# last line to its end, against 1.5 s: below the exit hook's own bound, so a hook that waited it +# out fails. That time holds the driver's device destruction and process teardown, which the +# runtime does not set: on an RTX 3090 (NVIDIA 615.71.09) `vkDestroyDevice` took 54 ms alone (63 +# devices, at most 57 ms) and up to 2 s while other lane processes used the GPU (over 500 ms for +# 39 of 72 beside `runtime_lane::framebuffer_fetch`); exits that took 87 to 97 ms alone took 0.3 +# to 3.1 s beside other lanes there, and 1.8 to 2 s in an RTX 5080 Laptop GPU's whole suite. +[[profile.default.overrides]] +filter = 'package(metal2vulkan-validation) & test(/^runtime_lane::exits::(pending_work_stays_pending_at_exit|exits_from_the_runtime_s_threads_are_clean|an_exit_while_a_host_step_waits_is_clean|an_exit_waits_for_a_cpu_device_s_work|an_exit_while_submitting_is_clean|exits_right_after_learning_of_completion_are_clean)$/)' +threads-required = 'num-test-threads' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ea0cadf9..a3ed30a36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,10 +88,10 @@ fixture entry point on every committed profile, in `crates/metal2vulkan/tests/go fixture and profile are unchanged must bump `SEMANTICS_VERSION` (`crates/metal2vulkan/src/cache/mod.rs`) in the same change. New, removed or edited fixtures and profiles need only the bless. The table records cells only, no version: a `SEMANTICS_VERSION` bump -alone leaves it unchanged, and the bless on `master` refuses a cell that moved under an unchanged -fixture and profile when `SEMANTICS_VERSION` is still its value at the table's last bless. +alone leaves it unchanged, and the bless on `development` refuses a cell that moved under an +unchanged fixture and profile when `SEMANTICS_VERSION` is still its value at the table's last bless. -The table is re-blessed on `master` after merges, so a change need not carry its own bless. To +The table is re-blessed on `development` after merges, so a change need not carry its own bless. To bless by hand (on macOS, which has `xcrun metal-as`): ```sh @@ -99,7 +99,7 @@ PATH=/opt/homebrew/opt/llvm/bin:$PATH cargo nextest run -p metal2vulkan --all-fe --run-ignored ignored-only -E 'test(bless_golden_hashes)' ``` -Never merge the table by hand: after a merge take `master`'s table and bless again. The other +Never merge the table by hand: after a merge take `development`'s table and bless again. The other versions move the same way when their behavior changes: `ARTIFACT_FORMAT_VERSION` (the artifact encoding) and `RUNTIME_VERSION` (what the runtime does with an unchanged artifact). diff --git a/crates/metal2vulkan-runtime/src/driver_defects.rs b/crates/metal2vulkan-runtime/src/driver_defects.rs index 55e111b4a..7baa371d8 100644 --- a/crates/metal2vulkan-runtime/src/driver_defects.rs +++ b/crates/metal2vulkan-runtime/src/driver_defects.rs @@ -175,6 +175,26 @@ pub(super) struct Affected { /// driver ends a command buffer at its value alone: Vulkan makes the value enough, and their /// fences are signaled with it, so a fence there only added a `vkCreateFence` to the commit /// path, which NVIDIA's 615.71.09 held for up to 1.9 s while other processes' work ran. +/// +/// `ImplicitPreprocessAfterExecutionSet`: +/// - Mesa's RADV (`MESA_RADV`): `vkCmdExecuteGeneratedCommandsEXT` of a layout not made for +/// explicit preprocessing dispatches the layout's preprocessing pipeline itself +/// (`radv_prepare_dgc`), and `radv_emit_compute_pipeline` skips a pipeline equal to +/// `emitted_compute_pipeline`. The execution's own commands then bind each sequence's pipeline +/// of the execution set on the GPU, which that field does not see, so the next execution's +/// preprocessing in the command buffer, with nothing dispatched between, runs the shader the +/// execution set bound last with the preprocessing's arguments. A range of two commands, an +/// execution each, faulted (`[gfxhub] page fault`, client `TCP`, permission faults) and timed out +/// the ring (`runtime_lane::generated_executions`, both of its tests that execute, on every run), +/// where explicit preprocessing runs them right. Read in 25.0.0's, +/// 26.0.8's and 26.1.5's source (the field is tracked alike); 26.2.0 tracks a dirty bit instead, +/// which the preprocessing's own bind sets. Measured on 26.0.8 (driverVersion 0x6800008) on the +/// Radeon 780M (`deviceID` 0x15bf) and the RX 7900 XTX (0x744c): known broken through 26.0.8. +/// Measured clean on 26.2.4 (driverVersion 0x6802004) on both. Nothing is refused: the runtime +/// preprocesses every execution of the range apart, before the first runs +/// (`generated_execute.rs`). Every RADV GPU and release but the measured identity found clean, +/// the 780M at 26.2.4, takes it; the RX 7900 XTX is no measured identity, so it takes it at +/// every release. pub(super) const AFFECTED: &[Affected] = &[ Affected { defect: RuntimeDriverDefect::MultisampledDepthStencilColourCopies, @@ -232,6 +252,12 @@ pub(super) const AFFECTED: &[Affected] = &[ driver: DriverId::MOLTENVK, clean: &[], }, + Affected { + defect: RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet, + driver: DriverId::MESA_RADV, + // The Radeon 780M at 26.2.4, measured clean. + clean: &[(0x15bf, (26 << 22) | (2 << 12) | 4)], + }, ]; /// The defects of the driver and device `description` names. diff --git a/crates/metal2vulkan-runtime/src/generated_commands.rs b/crates/metal2vulkan-runtime/src/generated_commands.rs index cd8d378b2..02eac999d 100644 --- a/crates/metal2vulkan-runtime/src/generated_commands.rs +++ b/crates/metal2vulkan-runtime/src/generated_commands.rs @@ -9,6 +9,8 @@ use crate::release::{self, Generated}; use ash::vk; +use metal2vulkan::device::DeviceDescription; +use metal2vulkan::error::RuntimeDriverDefect; use std::ffi::{c_void, CStr}; /// `VkIndirectExecutionSetEXT` and `VkIndirectCommandsLayoutEXT`: non-dispatchable handles. @@ -31,10 +33,26 @@ pub const INDIRECT_BINDABLE: vk::PipelineCreateFlags2KHR = /// `VK_BUFFER_USAGE_2_PREPROCESS_BUFFER_BIT_EXT`. pub const PREPROCESS_BUFFER: vk::BufferUsageFlags2KHR = vk::BufferUsageFlags2KHR::from_raw(0x8000_0000); -/// `VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_EXT` and `VK_ACCESS_COMMAND_PREPROCESS_READ_BIT_EXT` -/// (the values of the `NV` names `ash` has). +/// `VK_INDIRECT_COMMANDS_LAYOUT_USAGE_EXPLICIT_PREPROCESS_BIT_EXT`: an execution of the layout +/// is preprocessed apart (`vkCmdPreprocessGeneratedCommandsEXT`) before it runs. +const LAYOUT_EXPLICIT_PREPROCESS: u32 = 0x1; +/// `VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_EXT`, `VK_ACCESS_COMMAND_PREPROCESS_READ_BIT_EXT` and +/// `VK_ACCESS_COMMAND_PREPROCESS_WRITE_BIT_EXT` (the values of the `NV` names `ash` has). pub const PREPROCESS_STAGE: vk::PipelineStageFlags = vk::PipelineStageFlags::COMMAND_PREPROCESS_NV; pub const PREPROCESS_READ: vk::AccessFlags = vk::AccessFlags::COMMAND_PREPROCESS_READ_NV; +pub const PREPROCESS_WRITE: vk::AccessFlags = vk::AccessFlags::COMMAND_PREPROCESS_WRITE_NV; + +/// Whether the executions of a range are preprocessed apart on the device `description` names: +/// where its driver's own preprocessing of an execution recorded after another runs the wrong +/// shader (`RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet`, `driver_defects.rs`), the +/// commands layout is made [`explicitly_preprocessed`](LayoutCreateInfo::explicitly_preprocessed), +/// every execution of the range is preprocessed ([`Commands::preprocess`]) before the first runs, +/// and each runs preprocessed ([`Commands::execute_preprocessed`]). Validation's executor decides +/// its device replay's executions by it too. +pub fn preprocess_apart(description: &DeviceDescription) -> bool { + crate::driver_defects::of(description) + .contains(&RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet) +} /// `VkIndirectExecutionSetPipelineInfoEXT`. #[repr(C)] @@ -162,6 +180,14 @@ impl LayoutCreateInfo { tokens: tokens.as_ptr(), } } + + /// The layout with `VK_INDIRECT_COMMANDS_LAYOUT_USAGE_EXPLICIT_PREPROCESS_BIT_EXT`: each of + /// its executions is preprocessed apart ([`Commands::preprocess`]) and runs preprocessed + /// ([`Commands::execute_preprocessed`]). + pub fn explicitly_preprocessed(mut self) -> Self { + self.flags |= LAYOUT_EXPLICIT_PREPROCESS; + self + } } /// `VkGeneratedCommandsMemoryRequirementsInfoEXT`. @@ -255,6 +281,8 @@ type MemoryRequirements = unsafe extern "system" fn( ); type Execute = unsafe extern "system" fn(vk::CommandBuffer, vk::Bool32, *const GeneratedCommandsInfo); +type Preprocess = + unsafe extern "system" fn(vk::CommandBuffer, *const GeneratedCommandsInfo, vk::CommandBuffer); /// The extension's commands, loaded for one device. #[derive(Clone, Copy)] @@ -267,6 +295,7 @@ pub struct Commands { pub(crate) destroy_commands_layout: DestroyHandle, memory_requirements: MemoryRequirements, execute: Execute, + preprocess: Preprocess, } impl Commands { @@ -304,6 +333,7 @@ impl Commands { MemoryRequirements ), execute: command!(c"vkCmdExecuteGeneratedCommandsEXT", Execute), + preprocess: command!(c"vkCmdPreprocessGeneratedCommandsEXT", Preprocess), }) } @@ -401,4 +431,31 @@ impl Commands { // SAFETY: the caller's contract. unsafe { (self.execute)(command, vk::FALSE, info) } } + + /// `vkCmdPreprocessGeneratedCommandsEXT` of `info` into `command`, the state taken from + /// `command` itself. + /// + /// # Safety + /// `command` is recording, with the execution set's initial pipeline bound; `info`'s commands + /// layout is [`explicitly_preprocessed`](LayoutCreateInfo::explicitly_preprocessed), and its + /// handles and addresses are live until the work completes. + pub unsafe fn preprocess(&self, command: vk::CommandBuffer, info: &GeneratedCommandsInfo) { + // SAFETY: the caller's contract. + unsafe { (self.preprocess)(command, info, command) } + } + + /// `vkCmdExecuteGeneratedCommandsEXT` of commands [`preprocess`](Self::preprocess) wrote. + /// + /// # Safety + /// As [`execute`](Self::execute); and `info` was preprocessed in `command`, with the same + /// contents and the same state bound, a barrier ordering that preprocessing's writes before + /// this execution. + pub unsafe fn execute_preprocessed( + &self, + command: vk::CommandBuffer, + info: &GeneratedCommandsInfo, + ) { + // SAFETY: the caller's contract. + unsafe { (self.execute)(command, vk::TRUE, info) } + } } diff --git a/crates/metal2vulkan-runtime/src/generated_execute.rs b/crates/metal2vulkan-runtime/src/generated_execute.rs index b2b5ffcb7..61e9449ca 100644 --- a/crates/metal2vulkan-runtime/src/generated_execute.rs +++ b/crates/metal2vulkan-runtime/src/generated_execute.rs @@ -22,10 +22,15 @@ //! owned kernel) over the range, reading the records where the GPU and the CPU left them and //! writing each command's slot table, region record and sequences; a barrier; then per command //! of the range one `vkCmdExecuteGeneratedCommandsEXT` of the sequences the preprocess counted -//! for it, a compute barrier before each but the first. A record the preprocess cannot run (a -//! header with the producers' fault, a record that does not decode or names no variant's -//! state) runs nothing, and the command buffer's execution report states why, from the status -//! words the preprocess wrote (`bind::ReplayFaults`): an invalid record is a skip on the GPU. +//! for it, a compute barrier before each but the first. Where the driver's own preprocessing of +//! an execution after another goes wrong (`generated_commands::preprocess_apart`), the +//! commands layout is made for explicit preprocessing: every execution of the range is +//! preprocessed (`vkCmdPreprocessGeneratedCommandsEXT`) after the barrier, then a barrier, then +//! the executions run preprocessed, so no preprocessing follows an execution. A record the +//! preprocess cannot run (a header with the producers' fault, a record that does not decode or +//! names no variant's state) runs nothing, and the command buffer's execution report states +//! why, from the status words the preprocess wrote (`bind::ReplayFaults`): an invalid record is +//! a skip on the GPU. //! - **What the commands reach.** The replay's resident set, which the preprocess resolves each //! record's buffer addresses in and the commands' kernels search for the pointers they load, //! holds the resources the command buffer's encoders made resident and the device's live @@ -49,10 +54,10 @@ use super::executed_commands::RecordsRead; use super::execution::{ExecutedPipeline, Execution}; use super::fetch_reach; use super::generated_commands::{ - Commands, Execution as GeneratedExecution, ExecutionSetCreateInfo, ExecutionSetPipelineInfo, - ExecutionSetToken, GeneratedCommandsInfo, Handle, LayoutCreateInfo, LayoutToken, - MemoryRequirementsInfo, PushConstantToken, WriteExecutionSetPipeline, EXECUTION_SET_PIPELINES, - TOKEN_DISPATCH, TOKEN_EXECUTION_SET, TOKEN_PUSH_CONSTANT, + preprocess_apart, Commands, Execution as GeneratedExecution, ExecutionSetCreateInfo, + ExecutionSetPipelineInfo, ExecutionSetToken, GeneratedCommandsInfo, Handle, LayoutCreateInfo, + LayoutToken, MemoryRequirementsInfo, PushConstantToken, WriteExecutionSetPipeline, + EXECUTION_SET_PIPELINES, TOKEN_DISPATCH, TOKEN_EXECUTION_SET, TOKEN_PUSH_CONSTANT, }; use super::indirect_execute::{Execute, ExecutionRange}; use super::live_buffers::LiveTable; @@ -292,12 +297,13 @@ impl Drop for GeneratedObjects { impl GeneratedObjects { /// The execution set of `pipelines` (the first its initial pipeline, each at its variant's /// index) and the commands layout of `layout`'s three tokens under `pipeline_layout`, which - /// every pipeline's layout is defined as. + /// every pipeline's layout is defined as, made for explicit preprocessing where `explicit`. fn create( device: &Device, pipelines: &[RawPipeline], pipeline_layout: vk::PipelineLayout, layout: &GeneratedLayout, + explicit: bool, ) -> Result { let commands = device .shared() @@ -351,6 +357,10 @@ impl GeneratedObjects { LayoutToken::new(TOKEN_DISPATCH, std::ptr::null(), layout.dispatch_offset()), ]; let info = LayoutCreateInfo::new(layout.stride, pipeline_layout, &tokens); + let info = match explicit { + true => info.explicitly_preprocessed(), + false => info, + }; // SAFETY: `info`, its tokens, and their data are live for the call. objects.commands_layout = unsafe { commands.create_commands_layout(&info) }.map_err(vulkan)?; @@ -497,7 +507,11 @@ fn record_total( .first() .ok_or_else(|| internal("a replay of no variant"))? .layout(); - let generated = GeneratedObjects::create(&device, &pipelines, pipeline_layout, &layout)?; + // Where the driver's own preprocessing of an execution after another runs the wrong shader, + // every execution is preprocessed apart before the first runs. + let explicit = preprocess_apart(&device.properties().description); + let generated = + GeneratedObjects::create(&device, &pipelines, pipeline_layout, &layout, explicit)?; let (memory, reserved) = generated.preprocess_memory(&device, &layout)?; let kernel = device.owned_kernel(OwnedModule::ReplayPreprocess)?; let no_address = || internal("a replay on a device without device addresses"); @@ -589,15 +603,27 @@ fn record_total( let zeros = vec![0u8; layout.push_bytes as usize]; let initial = pipelines[0].raw; let (execution_set, commands_layout) = (generated.execution_set, generated.commands_layout); + // Each command's execution: its sequences, its count and its own preprocess memory. + let execution = |slot: u32| { + let sequences = layout.max_sequences(slot); + GeneratedExecution { + indirect: ( + scratch + layout.sequence_offset(slot, 0), + u64::from(layout.stride) * u64::from(sequences), + ), + preprocess: reserved[slot as usize], + max_sequences: sequences, + count_address: scratch + layout.count_offset(slot), + } + }; core.command(compute, &uses, |raw, command_buffer| { - // SAFETY: as above; every object the executions name is held until the command buffer - // completes, and each command's preprocess memory is its own. - unsafe { - for slot in 0..layout.slots { - if slot > 0 { - Barrier::between_dispatches().record(raw, command_buffer); - } - // An execution leaves the bound pipeline and push constants undefined. + // The state every preprocessing and execution takes: the execution set's initial + // pipeline and zeroed push constants (the tokens write every byte). An execution leaves + // the bound pipeline and push constants undefined. + let bind = || { + // SAFETY: the segment's command buffer is recording; the pipeline and its layout are + // held until the command buffer completes. + unsafe { raw.cmd_bind_pipeline(command_buffer, vk::PipelineBindPoint::COMPUTE, initial); raw.cmd_push_constants( command_buffer, @@ -606,18 +632,36 @@ fn record_total( 0, &zeros, ); - let sequences = layout.max_sequences(slot); - let execution = GeneratedExecution { - indirect: ( - scratch + layout.sequence_offset(slot, 0), - u64::from(layout.stride) * u64::from(sequences), - ), - preprocess: reserved[slot as usize], - max_sequences: sequences, - count_address: scratch + layout.count_offset(slot), - }; - let info = GeneratedCommandsInfo::new(execution_set, commands_layout, &execution); - commands.execute(command_buffer, &info); + } + }; + // SAFETY: as above; every object the executions name is held until the command buffer + // completes, and each command's preprocess memory is its own. Where `explicit`, the + // layout was made for explicit preprocessing, every execution is preprocessed with the + // state it then runs with, and a barrier orders those writes before every execution. + unsafe { + if explicit { + bind(); + for slot in 0..layout.slots { + let info = GeneratedCommandsInfo::new( + execution_set, + commands_layout, + &execution(slot), + ); + commands.preprocess(command_buffer, &info); + } + Barrier::everything().record(raw, command_buffer); + } + for slot in 0..layout.slots { + if slot > 0 { + Barrier::between_dispatches().record(raw, command_buffer); + } + bind(); + let info = + GeneratedCommandsInfo::new(execution_set, commands_layout, &execution(slot)); + match explicit { + true => commands.execute_preprocessed(command_buffer, &info), + false => commands.execute(command_buffer, &info), + } } } }); diff --git a/crates/metal2vulkan-runtime/src/tests/completion.rs b/crates/metal2vulkan-runtime/src/tests/completion.rs index ee87eafd7..142101df6 100644 --- a/crates/metal2vulkan-runtime/src/tests/completion.rs +++ b/crates/metal2vulkan-runtime/src/tests/completion.rs @@ -8,15 +8,31 @@ //! wait ran out. This test makes that shape: four queues, three of them in use and idle, and the //! fourth committing a few fills back to back each round, then waiting for the last. The //! completion thread finishes the first and waits again while the next one's signal lands, its -//! moment swept across rounds by the fills' sizes, which is when a wait for any loses it. Every -//! round must be seen completed well within the wait's 100 ms slice; a lost wake shows as a round -//! of about 100 ms. A summary of the rounds' times is printed (`ROUNDS`). +//! moment swept across rounds by the fills' sizes, which is when a wait for any loses it. +//! +//! Every command buffer must be seen completed well within the wait's 100 ms slice of the moment +//! it could first be seen, once its work ended and the submission that signals its end returned; +//! a lost wake shows as about 100 ms. That moment is the later of its GPU end time and its kernel +//! end time where the device places its timestamps on the host's clock by a calibration +//! (`gpu_time.rs`), and the round's commit elsewhere, which comes before it: a device that answers +//! its GPU times from the host, or calibrates none, ends them where the completion was seen. The +//! round's own time is no measure of the completion, as neither the GPU's other work nor the +//! driver's submission is the completion thread's: on an RTX 3090 (NVIDIA 615.71.09) beside the +//! lane tests' busy kernels, rounds of 190 to 202 ms were submitted within 0.1 ms, their GPU work +//! begun as long after the commit, as another process's busy kernel runs, and each command buffer +//! seen within 0.7 ms of its GPU end; and rounds of 57 to 64 ms ran their first command buffer's +//! work at the commit while the driver's submission of it returned 57 to 64 ms later, each command +//! buffer seen within 0.3 ms of that. A summary of the rounds' times and of how late each round's +//! command buffers were seen is printed (`ROUNDS`), and each round that took 50 ms or more with +//! its command buffers' kernel start and end, GPU start and end, and the moment each was seen, from +//! the round's commit (`SLOW-ROUND`). //! //! A device test: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`, //! `m2v_cpu_icd`), on the kind of device the cfg selects. use crate::{ - CommandBufferStatus, Device, DeviceKind, DeviceOptions, ResourceOptions, ShaderCacheOptions, + host_time, CommandBuffer, CommandBufferStatus, Device, DeviceKind, DeviceOptions, + ResourceOptions, ShaderCacheOptions, }; use std::path::{Path, PathBuf}; use std::time::{Duration, Instant}; @@ -41,8 +57,8 @@ const SIZES: [u64; 7] = [ 8 << 20, ]; -/// The longest a round may take: half the completion wait's 100 ms slice, far above a round's -/// own time (three fills of at most 8 MiB). +/// The latest a command buffer may be seen completed after it could first be seen: half the +/// completion wait's 100 ms slice. const STALL: Duration = Duration::from_millis(50); /// A scratch directory for the device's shader cache, removed when dropped. @@ -83,10 +99,36 @@ fn device(cache: &Path) -> Device { Device::system_default_with(&options).unwrap() } +/// Whether `device`'s GPU end times are when the GPU ended the work: its timestamps, placed on +/// the host's clock by a calibration (`gpu_time.rs`). +fn calibrated(device: &Device) -> bool { + let timing = &device.shared().timing; + !timing.answers_from_host() + && timing + .clock() + .is_some_and(|clock| clock.calibration.is_some()) +} + +/// A completed command buffer's times, in milliseconds from `from`, a host time: its kernel start +/// and end, GPU start and end, and `seen`, when its wait returned. +fn times(command_buffer: &CommandBuffer, from: f64, seen: f64) -> String { + let ms = |at: f64| (at - from) * 1e3; + let gpu = |at: Result| at.map_or("-".to_owned(), |at| format!("{:.1}", ms(at))); + format!( + "[ks {:.1} ke {:.1} gs {} ge {} seen {:.1}]", + ms(command_buffer.kernel_start_time()), + ms(command_buffer.kernel_end_time()), + gpu(command_buffer.gpu_start_time()), + gpu(command_buffer.gpu_end_time()), + ms(seen) + ) +} + #[test] fn a_completion_on_one_queue_is_seen_while_other_queues_are_waited_for() { let scratch = Scratch::new(); let device = device(&scratch.0); + let calibrated = calibrated(&device); let buffer = device .new_buffer(SIZES[SIZES.len() - 1], ResourceOptions::private()) .unwrap(); @@ -110,39 +152,80 @@ fn a_completion_on_one_queue_is_seen_while_other_queues_are_waited_for() { assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); } let mut times = Vec::with_capacity(ROUNDS); + let mut lates = Vec::with_capacity(ROUNDS); for round in 0..ROUNDS { let size = SIZES[round % SIZES.len()]; let command_buffers: Vec<_> = (0..IN_FLIGHT) .map(|_| fill(&queues[0], size, round as u8)) .collect(); let start = Instant::now(); + let committed = host_time(); for command_buffer in &command_buffers { command_buffer.commit().unwrap(); } + let mut seen = Vec::with_capacity(IN_FLIGHT); for command_buffer in &command_buffers { command_buffer.wait_until_completed_for(WAIT).unwrap(); + seen.push(host_time()); assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); } - times.push(start.elapsed()); + let took = start.elapsed(); + // How late each was seen after it could first be seen: the latest of the round. + let late = (command_buffers.iter().zip(&seen)) + .map(|(command_buffer, &seen)| { + let seeable = match calibrated { + true => (command_buffer.gpu_end_time().unwrap()) + .max(command_buffer.kernel_end_time()), + false => committed, + }; + Duration::from_secs_f64((seen - seeable).max(0.0)) + }) + .max() + .unwrap(); + if took >= STALL || late >= STALL { + let each: Vec = (command_buffers.iter().zip(&seen)) + .map(|(command_buffer, &seen)| self::times(command_buffer, committed, seen)) + .collect(); + println!( + "SLOW-ROUND {round} ({size} bytes a fill): {took:?}, seen {late:?} late; ms from \ + the commit: {}", + each.join(" ") + ); + } + times.push(took); + lates.push(late); } - let stalls: Vec<(usize, Duration)> = times + let stalls: Vec<(usize, Duration)> = lates .iter() .copied() .enumerate() - .filter(|&(_, time)| time >= STALL) + .filter(|&(_, late)| late >= STALL) .collect(); - let mut sorted = times.clone(); - sorted.sort(); + let summary = |durations: &[Duration]| { + let mut sorted = durations.to_vec(); + sorted.sort(); + format!( + "p50 {:?} p90 {:?} p99 {:?} max {:?}", + sorted[ROUNDS / 2], + sorted[ROUNDS * 9 / 10], + sorted[ROUNDS * 99 / 100], + sorted[ROUNDS - 1], + ) + }; + let after = match calibrated { + true => "the later of its GPU end and kernel end", + false => "the round's commit", + }; println!( - "ROUNDS {ROUNDS}: p50 {:?} p90 {:?} p99 {:?} max {:?}; {} at or over {STALL:?}", - sorted[ROUNDS / 2], - sorted[ROUNDS * 9 / 10], - sorted[ROUNDS * 99 / 100], - sorted[ROUNDS - 1], + "ROUNDS {ROUNDS}: {}, {} at or over {STALL:?}; seen after {after}: {}, {} at or over \ + {STALL:?}", + summary(×), + times.iter().filter(|&&took| took >= STALL).count(), + summary(&lates), stalls.len() ); assert!( stalls.is_empty(), - "commits seen completed only after {STALL:?} or more (round, time): {stalls:?}" + "command buffers seen completed {STALL:?} or more after {after} (round, time): {stalls:?}" ); } diff --git a/crates/metal2vulkan-runtime/src/tests/driver_defects.rs b/crates/metal2vulkan-runtime/src/tests/driver_defects.rs index d028e02eb..fa4c01962 100644 --- a/crates/metal2vulkan-runtime/src/tests/driver_defects.rs +++ b/crates/metal2vulkan-runtime/src/tests/driver_defects.rs @@ -17,14 +17,16 @@ const CACHE_LOAD: RuntimeDriverDefect = RuntimeDriverDefect::PipelineCacheDataCo const COPY_REWRITES: RuntimeDriverDefect = RuntimeDriverDefect::CompressedImageCopiesRewriteTexels; const NAN_COPIES: RuntimeDriverDefect = RuntimeDriverDefect::MultisampledCopiesConvertFloatNans; const LATE_READS: RuntimeDriverDefect = RuntimeDriverDefect::ReadsCommandBuffersAfterTheirSignal; +const PREPROCESS: RuntimeDriverDefect = RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet; /// Every committed profile's driver has its defects at every release and GPU but those a probe /// found clean: MoltenVK the multisampled depth/stencil colour copies, the inexact depths past /// `[0, 1]`, the crashing 2D views of a 3D image in lazily allocated memory, the pipeline cache /// compiled at load, the copies of compressed images that rewrite texels and the reads of command /// buffers after their signal; lavapipe the colour copies and the depth/stencil resolve of the -/// first layer and level; RADV the multisampled copies that convert float NaNs; ANV the -/// compressed image's short size on every GPU (Arrow Lake's, not measured, too); NVIDIA's the +/// first layer and level; RADV the multisampled copies that convert float NaNs, and the implicit +/// preprocessing after an execution set on every GPU but the 780M at 26.2.4, measured clean; ANV +/// the compressed image's short size on every GPU (Arrow Lake's, not measured, too); NVIDIA's the /// stencil colour copies on every GPU but the RTX 5080 Laptop GPU at 615.71.09, measured clean (the /// GTX 1060 and the RTX 5080 desktop GPU, not measured, take them); SwiftShader none. #[test] @@ -50,7 +52,12 @@ fn the_committed_profiles_drivers_have_their_defects() { ] } Some(DriverId::MESA_LLVMPIPE) => vec![COPIES, RESOLVES], - Some(DriverId::MESA_RADV) => vec![NAN_COPIES], + Some(DriverId::MESA_RADV) + if (desc.device_id, desc.driver_version) == (0x15bf, MESA_26_2_4) => + { + vec![NAN_COPIES] + } + Some(DriverId::MESA_RADV) => vec![NAN_COPIES, PREPROCESS], Some(DriverId::INTEL_OPEN_SOURCE_MESA) => vec![COMPRESSION], Some(DriverId::NVIDIA_PROPRIETARY) if (desc.device_id, desc.driver_version) == (0x2c19, NVIDIA_615_71_09) => @@ -70,6 +77,9 @@ fn the_committed_profiles_drivers_have_their_defects() { ); } +/// Mesa's `driverVersion` of 26.2.4: `VK_MAKE_API_VERSION(0, 26, 2, 4)`. +const MESA_26_2_4: u32 = (26 << 22) | (2 << 12) | 4; + /// NVIDIA's `driverVersion` of 615.71.09: the release's major, minor and patch in 10, 8 and 6 bits /// from bit 22, 14 and 6. const NVIDIA_615_71_09: u32 = (615 << 22) | (71 << 14) | (9 << 6); @@ -124,6 +134,36 @@ fn nvidia_s_colour_copies_are_clean_on_the_identity_measured_alone() { assert!(!radv.contains(&COPIES) && !radv.contains(&STENCIL_COPIES)); } +/// RADV's implicit preprocessing after an execution set, measured broken on the Radeon 780M +/// (`deviceID` 0x15bf) and the RX 7900 XTX (0x744c) at 26.0.8, is every RADV GPU's at every release +/// but the 780M's at 26.2.4, measured clean: the 780M at 26.0.8 and 26.2.5 and the RX 7900 XTX at +/// 26.2.4 (not a measured identity) take it; a device that runs another driver has none. +#[test] +fn radv_s_preprocessing_is_clean_on_the_identity_measured_alone() { + let radv = Some(DriverId::MESA_RADV); + let of = |device, release| among(AFFECTED, radv, device, release); + let mesa_26_0_8 = (26 << 22) | 8; + for (device, release) in [ + (0x15bf, mesa_26_0_8), + (0x744c, mesa_26_0_8), + (0x744c, MESA_26_2_4), + (0x15bf, MESA_26_2_4 + 1), + ] { + assert!( + of(device, release).contains(&PREPROCESS), + "{device:#x} {release:#x}" + ); + } + assert!(!of(0x15bf, MESA_26_2_4).contains(&PREPROCESS)); + let nvidia = among( + AFFECTED, + Some(DriverId::NVIDIA_PROPRIETARY), + 0x15bf, + mesa_26_0_8, + ); + assert!(!nvidia.contains(&PREPROCESS)); +} + /// Each clean identity is a measured one: a committed profile of the driver, GPU and release /// that the device layer takes as measured (`DeviceDescription::measured_identity`). #[test] diff --git a/crates/metal2vulkan-validation/runtime-sources.sha256 b/crates/metal2vulkan-validation/runtime-sources.sha256 index 1cf410a4b..f9bf9e48d 100644 --- a/crates/metal2vulkan-validation/runtime-sources.sha256 +++ b/crates/metal2vulkan-validation/runtime-sources.sha256 @@ -1 +1 @@ -1ee043f7d07744e154b15ec5ef954f9df4fac116d46b893e734a4462c7555464 +2cc15b1b463b764d64cb94ba80d61856a0bf5371c8a93b494b0ddd8261a3adbf diff --git a/crates/metal2vulkan-validation/src/candidate/engine.rs b/crates/metal2vulkan-validation/src/candidate/engine.rs index 7f79cb2cc..90bbdfd8d 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine.rs @@ -121,7 +121,7 @@ use tables::{function_tables, table_buffers, FunctionTable, TableBuffers}; /// how it decides a match. A change no recorded row can observe (a case kind no earlier executor /// ran, or one it refused) needs no bump; its commit says why. The commit that bumps it says what /// changed; this comment keeps no history. -pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v180"; +pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v181"; /// One kernel case in the terms the binder takes: what this executor supports of an /// [`AuthoredCase`] (buffers, device buffer arrays, argument-buffer buffers and textures, command @@ -971,9 +971,11 @@ pub fn records_ids(case: &ComputeCase) -> Result, Stri } /// A bound buffer's addresses: the Metal `gpuAddress` the guest sees and the host Vulkan device -/// address when the buffer has one. The executor's allocations are their own guests: with -/// device addresses the two are equal (no pointer bytes are authored in the buffers this -/// executor supports), without them the guest address is a distinct synthetic base. +/// address when the buffer has one. With device addresses an allocation's guest address is its +/// device address, read as a signed number, moved up by [`BufferAddress::GUEST_OFFSET`] +/// ([`BufferAddress::addressed`]): a Metal address whatever the device hands out, which the +/// product translates through the resident set as it does the runtime's own address space. +/// Without them the guest address is a distinct synthetic base. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct BufferAddress { pub guest: u64, @@ -981,6 +983,42 @@ pub struct BufferAddress { } impl BufferAddress { + /// How far above its device address, read as a signed number, an allocation's guest address + /// lies: 2^47 + 2^32. Vulkan bounds no device address, and devices hand out different ones: + /// NVIDIA's lie under 2^32 (0x5020000 for a vertex buffer on an RTX 3090 and 0x4af0000 on an + /// RTX 5080 Laptop GPU, 615.71.09), below the lowest address that names a buffer + /// (`BufferBinding::MIN_BUFFER_ADDRESS`, 2^32; below it a record's address is a nil buffer's + /// offset, as on Apple silicon, whose buffers all lie above it), and RADV gives the upper half + /// of its 48-bit space sign-extended (0xffff800100040000 on a Radeon 780M), where the records + /// of indirect command buffers lie (`records_address`, from 2^63). Read as signed, every + /// 48-bit sign-extended address and every address under 2^63 less this offset moves into + /// [2^32, 2^63), where Metal's buffers lie. One offset for every allocation keeps their guest + /// ranges as disjoint as their device ranges. + pub const GUEST_OFFSET: u64 = + (1 << 47) + metal2vulkan::bind::indirect_commands::BufferBinding::MIN_BUFFER_ADDRESS; + + /// The addresses of an allocation at device address `host`: its guest address + /// [`GUEST_OFFSET`](Self::GUEST_OFFSET) above it, read as a signed number. Refused where that + /// guest address would lie below 2^32 (a device address sign-extended past 48 bits) or reach + /// 2^63, where the records of indirect command buffers and the synthetic windows of + /// [`BufferAddress::synthetic_used`] lie. + pub fn addressed(host: u64) -> Result { + let lowest = metal2vulkan::bind::indirect_commands::BufferBinding::MIN_BUFFER_ADDRESS; + match host + .cast_signed() + .checked_add(Self::GUEST_OFFSET.cast_signed()) + { + Some(guest) if guest >= lowest.cast_signed() => Ok(BufferAddress { + guest: guest.cast_unsigned(), + host: Some(host), + }), + _ => Err(format!( + "device address {host:#x} has no guest address in [2^32, 2^63), where Metal's \ + buffers lie" + )), + } + } + /// The synthetic guest base of Metal buffer `index` on a device without device addresses: /// disjoint 4-GiB windows, never 0. pub fn synthetic(index: u32) -> BufferAddress { diff --git a/crates/metal2vulkan-validation/src/candidate/engine/runtime_run/tests.rs b/crates/metal2vulkan-validation/src/candidate/engine/runtime_run/tests.rs index 2829ed2b9..1639ade04 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/runtime_run/tests.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/runtime_run/tests.rs @@ -392,6 +392,60 @@ fn render_commands_and_render_states_run_as_the_executor_compiles_them() { } } +/// Public cases whose command buffers execute ranges of two or more compute commands, a kernel's +/// and the host's, run through the runtime path and on the executor's own context (its device +/// replay), each output Metal's. Where the context enables `VK_EXT_device_generated_commands`, the +/// executor runs each range as one command buffer's executions, one after another, as the runtime +/// does: on RADV before 26.2 the driver's own preprocessing of every execution after the first ran +/// the shader the one before bound last, and the device faulted +/// (`RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet`), so both preprocess the +/// executions apart there. The rows' artifacts are not compared: the executor's digests what it +/// compiled for the commands, and the runtime path's records no digest (as +/// [`runs_as_the_executor_compiles_it`] states). +#[cfg(any(m2v_gpu, m2v_cpu_icd))] +#[test] +fn compute_command_ranges_run_on_both_paths_as_metal_ran_them() { + use crate::candidate::tests::compile_worker; + use crate::candidate::tests::engine_compute::BACKEND; + let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus"); + let device = crate::gpu::TEST_DEVICE; + let store = CorpusStore::new(&root); + let cases = store.read_all_cases().unwrap(); + for name in [ + "execute-two-gpu-encoded-template-dispatches", + "gpu-encoded-buffers-keep-the-host-encoded-dispatches", + "gpu-encoded-ragged-grids-replay-with-the-inherited-pipeline-and-buffers", + "host-encoded-over-limit-and-ragged-dispatches-in-two-command-buffers", + ] { + let case = cases + .iter() + .find(|case| case.name == name) + .expect("the committed public case") + .clone(); + assert!(case.out_of_bounds.is_none(), "{name}"); + let metal = crate::runtime_lane::metal_output(&store, &case).unwrap(); + let admitted = admit(&root, case, ExecutionRequest::EngineCandidate { device }).unwrap(); + let prepared = super::super::prepare_case(device, admitted).unwrap(); + assert_eq!(route(&prepared), Route::Runtime, "{name}"); + let RuntimeOutcome::Ran(attempt) = run(&prepared, BACKEND) else { + panic!("{name}: the runtime raised a gap"); + }; + let ran = attempt + .result + .unwrap_or_else(|error| panic!("{name}: {error}")); + assert_eq!(ran.output, metal, "{name}: the runtime path's output"); + let on_context = super::super::run_on_context(&prepared, BACKEND, compile_worker()) + .result + .unwrap_or_else(|error| panic!("{name}: {error}")); + // Which replay ran each command buffer the case executes, for the lane's record. + eprintln!( + "{name}: the executor's command replay {}", + on_context.environment["command_replay"] + ); + assert_eq!(on_context.output, metal, "{name}: the executor's output"); + } +} + /// A public render case runs through the runtime path, drawn as the case runner draws it /// (`runtime_case::encoded_render`), as /// [`a_public_kernel_case_runs_through_the_runtime_as_the_executor_compiles_it`] runs its case: diff --git a/crates/metal2vulkan-validation/src/candidate/engine/tests.rs b/crates/metal2vulkan-validation/src/candidate/engine/tests.rs index a08ad1532..39a7ca106 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/tests.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/tests.rs @@ -2482,3 +2482,41 @@ fn only_the_default_fetch_policys_runs_are_stored() { false )); } + +/// An allocation's guest address names a buffer whatever device address it has: NVIDIA's lie +/// below 2^32 (a vertex buffer at 0x5020000 on an RTX 3090), where a guest address equal to it +/// was a nil buffer's offset to a record, and RADV's sign-extended upper half +/// (0xffff800100040000 on a Radeon 780M) lies among the records, from 2^63. One offset for all, +/// on the address read as signed, keeps them apart and in [2^32, 2^63); an address it cannot move +/// there is refused. +#[test] +fn addressed_allocations_take_metal_addresses() { + use metal2vulkan::bind::indirect_commands::{records_address, BufferBinding}; + let metal = |address: BufferAddress| { + let names = BufferBinding { + address: address.guest, + attribute_stride: None, + } + .names_buffer(); + names && address.guest < records_address(0) + }; + let low = BufferAddress::addressed(0x502_0000).unwrap(); + assert_eq!(low.host, Some(0x502_0000)); + assert!(metal(low), "{low:x?}"); + let next = BufferAddress::addressed(0x502_0000 + 256).unwrap(); + assert_eq!(next.guest - low.guest, 256); + let radv = BufferAddress::addressed(0xffff_8001_0004_0000).unwrap(); + assert!(metal(radv) && radv.guest < low.guest, "{radv:x?}"); + // The top of the device's space and its bottom stay next to each other. + let top = BufferAddress::addressed(u64::MAX).unwrap(); + let bottom = BufferAddress::addressed(0).unwrap(); + assert!(metal(top) && metal(bottom), "{top:x?} {bottom:x?}"); + assert_eq!(bottom.guest - top.guest, 1); + let lowest = BufferAddress::addressed(0xffff_8000_0000_0000).unwrap(); + assert_eq!(lowest.guest, BufferBinding::MIN_BUFFER_ADDRESS); + let highest = BufferAddress::addressed(records_address(0) - BufferAddress::GUEST_OFFSET - 1); + assert_eq!(highest.unwrap().guest, records_address(0) - 1); + assert!(BufferAddress::addressed(0xffff_7fff_ffff_ffff).is_err()); + assert!(BufferAddress::addressed(records_address(0) - BufferAddress::GUEST_OFFSET).is_err()); + assert!(BufferAddress::addressed(records_address(1)).is_err()); +} diff --git a/crates/metal2vulkan-validation/src/candidate/platform/compute.rs b/crates/metal2vulkan-validation/src/candidate/platform/compute.rs index b6ffa711a..c914a3934 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/compute.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/compute.rs @@ -593,13 +593,11 @@ fn execute( .enabled .features .contains(&VkFeature::BufferDeviceAddress); - // An allocation is its own guest: with a device address the guest address is that address. + // With a device address an allocation's guest address lies a fixed offset above it + // (`BufferAddress::addressed`), else at its synthetic base. let own_guest = |allocation: &Allocation, synthetic: BufferAddress| match allocation.address { - Some(host) => BufferAddress { - guest: host, - host: Some(host), - }, - None => synthetic, + Some(host) => BufferAddress::addressed(host).map_err(ExecutorError::Failed), + None => Ok(synthetic), }; let synthetic_used = synthetic_used_addresses(case).map_err(ExecutorError::Failed)?; let records = records_ids(case).map_err(ExecutorError::Failed)?; @@ -618,7 +616,7 @@ fn execute( // A command buffer's record storage lies at its ID's records address. let address = match records.get(&key) { Some(&id) => records_storage(id, allocation.address), - None => own_guest(&allocation, synthetic_used[&key]), + None => own_guest(&allocation, synthetic_used[&key])?, }; embedded_addresses.insert(key, address); embedded.insert(key, allocation); @@ -662,12 +660,12 @@ fn execute( .iter() .chain(&table_buffers) .map(|(&index, allocation)| { - ( + Ok(( index, - own_guest(allocation, BufferAddress::synthetic(index)), - ) + own_guest(allocation, BufferAddress::synthetic(index))?, + )) }) - .collect(); + .collect::>()?; // The commands the host encodes, written into their record storage before the producer runs, // each buffer at its case buffer's guest address. for (key, command) in &case.command_buffers { diff --git a/crates/metal2vulkan-validation/src/candidate/platform/compute/device_replay/generated.rs b/crates/metal2vulkan-validation/src/candidate/platform/compute/device_replay/generated.rs index 1c7922160..f4b686912 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/compute/device_replay/generated.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/compute/device_replay/generated.rs @@ -14,7 +14,13 @@ //! - after the preprocess and its barrier, the descriptor sets are bound once and, per command, a //! barrier (as K14c's between commands), the initial pipeline, zeroed push constants (the tokens //! write every byte), and `vkCmdExecuteGeneratedCommandsEXT` over its sequences with the count -//! the preprocess wrote ([`record_executions`]). +//! the preprocess wrote ([`record_executions`]); +//! - where the driver's own preprocessing of an execution recorded after another runs the wrong +//! shader, as the runtime decides it (`generated_commands::preprocess_apart`, +//! `RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet`), the commands layout is made for +//! explicit preprocessing, every command's execution is preprocessed +//! (`vkCmdPreprocessGeneratedCommandsEXT`) before the first runs, a barrier orders those writes +//! before the executions, and each runs preprocessed: no preprocessing follows an execution. use super::*; use metal2vulkan::bind::GeneratedReplay; @@ -22,7 +28,7 @@ use metal2vulkan_runtime::generated_commands::{ Commands, Execution, ExecutionSetCreateInfo, ExecutionSetPipelineInfo, ExecutionSetToken, GeneratedCommandsInfo, Handle, LayoutCreateInfo, LayoutToken, MemoryRequirementsInfo, PushConstantToken, WriteExecutionSetPipeline, EXECUTION_SET_PIPELINES, INDIRECT_BINDABLE, - PREPROCESS_BUFFER, TOKEN_DISPATCH, TOKEN_EXECUTION_SET, TOKEN_PUSH_CONSTANT, + PREPROCESS_BUFFER, PREPROCESS_WRITE, TOKEN_DISPATCH, TOKEN_EXECUTION_SET, TOKEN_PUSH_CONSTANT, }; pub(super) use metal2vulkan_runtime::generated_commands::{PREPROCESS_READ, PREPROCESS_STAGE}; use std::collections::btree_map::Entry; @@ -40,6 +46,9 @@ pub(super) struct Generated<'c> { pipelines: Vec, execution_set: Handle, commands_layout: Handle, + /// Whether the commands layout is made for explicit preprocessing: every command's execution + /// is preprocessed apart before the first runs ([`record_executions`]). + explicit: bool, /// The preprocess memory's buffer and allocation ([`Generated::reserve_preprocess`]). preprocess: Option<(vk::Buffer, vk::DeviceMemory)>, /// Each command's preprocess memory, by slot: its address and size (`(0, 0)` where the @@ -108,6 +117,7 @@ impl<'c> Generated<'c> { pipelines: Vec::with_capacity(prepared.len()), execution_set: 0, commands_layout: 0, + explicit: context.preprocesses_generated_commands_apart(), preprocess: None, reserved: Vec::new(), sets: Vec::new(), @@ -174,6 +184,10 @@ impl<'c> Generated<'c> { LayoutToken::new(TOKEN_DISPATCH, std::ptr::null(), layout.dispatch_offset()), ]; let info = LayoutCreateInfo::new(layout.stride, generated.layout.pipeline_layout, &tokens); + let info = match generated.explicit { + true => info.explicitly_preprocessed(), + false => info, + }; // SAFETY: `info`, its tokens, and their data are live for the call. generated.commands_layout = unsafe { commands.create_commands_layout(&info) } .map_err(|error| fail(format!("create the indirect commands layout: {error}")))?; @@ -337,8 +351,13 @@ fn bindable_pipeline( /// initial pipeline, zeroed push constants (the tokens write every byte of them), and the /// command's `vkCmdExecuteGeneratedCommandsEXT` over its sequences in the scratch at /// `scratch_address`, with the count the preprocess wrote and its own preprocess memory. A -/// command that starts no segment has the count 0: its execution runs nothing. A range whose -/// preprocess memory was not reserved for every command records nothing and fails. +/// command that starts no segment has the count 0: its execution runs nothing. Where the layout +/// is made for explicit preprocessing ([`Generated::explicit`]), the initial pipeline and zeroed +/// push constants are bound first, every command's execution is preprocessed +/// (`vkCmdPreprocessGeneratedCommandsEXT`) with that state, a barrier orders the preprocessing's +/// writes before the executions' preprocess and indirect reads, and each execution runs +/// preprocessed. A range whose preprocess memory was not reserved for every command records +/// nothing and fails. /// /// # Safety /// `command` is recording on `device`, every object of `generated` is live until the submission @@ -360,7 +379,41 @@ pub(super) unsafe fn record_executions( } let pipeline_layout = generated.layout.pipeline_layout; let zeros = vec![0u8; layout.push_bytes as usize]; - // SAFETY: the caller's contract. + // The state every preprocessing and execution takes: the execution set's initial pipeline and + // zeroed push constants (the tokens write every byte). An execution leaves the bound pipeline + // and push constants undefined. + let bind = || { + // SAFETY: the caller's contract. + unsafe { + device.cmd_bind_pipeline( + command, + vk::PipelineBindPoint::COMPUTE, + generated.pipelines[0], + ); + device.cmd_push_constants( + command, + pipeline_layout, + vk::ShaderStageFlags::COMPUTE, + 0, + &zeros, + ); + } + }; + // Each command's execution: its sequences, the count the preprocess wrote, and its own + // preprocess memory. + let execution = |slot: u32| { + let sequences = layout.max_sequences(slot); + Execution { + indirect: ( + scratch_address + layout.sequence_offset(slot, 0), + u64::from(layout.stride) * u64::from(sequences), + ), + preprocess: generated.reserved[slot as usize], + max_sequences: sequences, + count_address: scratch_address + layout.count_offset(slot), + } + }; + // SAFETY: the caller's contract; each command's preprocess memory is its own. unsafe { if !generated.sets.is_empty() { device.cmd_bind_descriptor_sets( @@ -372,6 +425,30 @@ pub(super) unsafe fn record_executions( &[], ); } + if generated.explicit { + bind(); + for slot in 0..layout.slots { + let execution = execution(slot); + let info = GeneratedCommandsInfo::new( + generated.execution_set, + generated.commands_layout, + &execution, + ); + generated.commands.preprocess(command, &info); + } + let preprocessed = vk::MemoryBarrier::default() + .src_access_mask(PREPROCESS_WRITE) + .dst_access_mask(vk::AccessFlags::INDIRECT_COMMAND_READ | PREPROCESS_READ); + device.cmd_pipeline_barrier( + command, + PREPROCESS_STAGE, + vk::PipelineStageFlags::DRAW_INDIRECT | PREPROCESS_STAGE, + vk::DependencyFlags::empty(), + &[preprocessed], + &[], + &[], + ); + } for slot in 0..layout.slots { if slot > 0 { device.cmd_pipeline_barrier( @@ -384,35 +461,17 @@ pub(super) unsafe fn record_executions( &[], ); } - // An execution leaves the bound pipeline and push constants undefined. - device.cmd_bind_pipeline( - command, - vk::PipelineBindPoint::COMPUTE, - generated.pipelines[0], - ); - device.cmd_push_constants( - command, - pipeline_layout, - vk::ShaderStageFlags::COMPUTE, - 0, - &zeros, - ); - let sequences = layout.max_sequences(slot); - let execution = Execution { - indirect: ( - scratch_address + layout.sequence_offset(slot, 0), - u64::from(layout.stride) * u64::from(sequences), - ), - preprocess: generated.reserved[slot as usize], - max_sequences: sequences, - count_address: scratch_address + layout.count_offset(slot), - }; + bind(); + let execution = execution(slot); let info = GeneratedCommandsInfo::new( generated.execution_set, generated.commands_layout, &execution, ); - generated.commands.execute(command, &info); + match generated.explicit { + true => generated.commands.execute_preprocessed(command, &info), + false => generated.commands.execute(command, &info), + } } } Ok(()) diff --git a/crates/metal2vulkan-validation/src/candidate/platform/device.rs b/crates/metal2vulkan-validation/src/candidate/platform/device.rs index 3d75ee31a..8061c8eec 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/device.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/device.rs @@ -1432,6 +1432,19 @@ impl VulkanContext { .unwrap_or_default() } + /// Whether the device replay's generated-commands executions are preprocessed apart, as the + /// runtime's are on the driver that executes (`generated_commands::preprocess_apart` of its + /// queried description, the device as it is, under a restriction too); also where the query + /// failed, since preprocessing apart runs right on every driver. + pub(super) fn preprocesses_generated_commands_apart(&self) -> bool { + match &self.queried_description { + Ok(description) => { + metal2vulkan_runtime::generated_commands::preprocess_apart(description) + } + Err(_) => true, + } + } + /// Open a device of `device_type` for `purpose`: the only Vulkan device creation in this crate, /// and with its probes the only caller of [`create_instance`]. fn new(device_type: DeviceType, purpose: Purpose) -> Result { diff --git a/crates/metal2vulkan-validation/src/candidate/platform/render.rs b/crates/metal2vulkan-validation/src/candidate/platform/render.rs index 32d3b952b..1cc8f85da 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/render.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/render.rs @@ -287,13 +287,11 @@ fn execute( class, index, }; - // An allocation is its own guest: with a device address the guest address is that address. + // With a device address an allocation's guest address lies a fixed offset above it + // (`BufferAddress::addressed`), else at its synthetic base. let own_guest = |allocation: &Allocation, synthetic: BufferAddress| match allocation.address { - Some(host) => BufferAddress { - guest: host, - host: Some(host), - }, - None => synthetic, + Some(host) => BufferAddress::addressed(host).map_err(ExecutorError::Failed), + None => Ok(synthetic), }; let synthetic_used = graphics::synthetic_used_addresses(case).map_err(ExecutorError::Failed)?; let records = graphics::records_ids(case).map_err(ExecutorError::Failed)?; @@ -312,7 +310,7 @@ fn execute( // A command buffer's record storage lies at its ID's records address. let address = match records.get(&key) { Some(&id) => records_storage(id, allocation.address), - None => own_guest(&allocation, synthetic_used[&key]), + None => own_guest(&allocation, synthetic_used[&key])?, }; embedded_addresses.insert(key, address); embedded.insert(key, allocation); @@ -406,12 +404,10 @@ fn execute( .iter() .chain(&table_buffers) .map(|(&(stage, index), allocation)| { - ( - (stage, index), - own_guest(allocation, graphics::synthetic_address(stage, index)), - ) + let address = own_guest(allocation, graphics::synthetic_address(stage, index))?; + Ok(((stage, index), address)) }) - .collect(); + .collect::>()?; // The guest address of a case buffer of the stage that owns a command buffer. let case_address = |(stage, _, _): (Stage, u32, u32), buffer: u32| { addresses.get(&(stage, buffer)).map(|a| a.guest) diff --git a/crates/metal2vulkan-validation/src/candidate/platform/runtime_probe/tests.rs b/crates/metal2vulkan-validation/src/candidate/platform/runtime_probe/tests.rs index 265b8e74c..d8072ce69 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/runtime_probe/tests.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/runtime_probe/tests.rs @@ -120,14 +120,59 @@ fn the_dispatch_words_are_distinct_and_their_results_are_three_x_plus_one() { } } +/// The GPUs (`VkPhysicalDeviceDriverProperties::driverID`, `deviceID`) whose driver, measured, does +/// not make a copy's write into a linear image visible to a later copy out of a buffer over the +/// same memory in the same submission, across a global memory barrier from the transfer stage's +/// writes to its reads: Vulkan makes the two host-accessible aliases (a buffer, and a linear image +/// in `GENERAL`) read each other's writes, and the barrier orders all memory. The copy out reads +/// the bytes from before the image's copy (the alias's `buffer_reads_image` mismatches every byte +/// whose old and new values differ: 68 of 68 for `R8`, 271 of 272 for `RGBA8`), while the host +/// reads the image's new texels once the submission completed (`host_reads_image`). +/// +/// - NVIDIA's (`NVIDIA_PROPRIETARY`) 615.71.09 on the RTX 3090 (0x2204, Ampere's GA102): every +/// format the probe aliases; `R8` and `RGBA8` in each of the three host-visible memory types, +/// with a buffer and an image barrier in place of the global one or beside it; `R8` in 20 runs +/// of 20, also with the barrier's stages every stage for the transfer accesses. A submission +/// between the two copies, a barrier from every stage's memory writes, or one from the transfer +/// and a shader stage's writes made the texels visible, 20 runs of 20. The RTX 5080 Laptop GPU +/// (0x2c19, Blackwell) on the same release reads them. +/// +/// The runtime records no such pair: a blit naming a texture over a buffer copies the buffer's +/// bytes, whatever image aliases them (`blit_texture.rs`). +#[cfg(any(m2v_gpu, m2v_cpu_icd))] +const STALE_LINEAR_IMAGE_COPIES: &[(i32, u64)] = &[(4, 0x2204)]; + +/// The drivers (`driverID`) that, measured, accept an explicit `DRM_FORMAT_MOD_LINEAR` layout of a +/// row pitch they do not lay images out at and lay the image out at their own linear pitch for its +/// width, which `vkGetImageSubresourceLayout` then reports, where Vulkan has them refuse the layout +/// (`VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT`): +/// +/// - NVIDIA's (`NVIDIA_PROPRIETARY`) 615.71.09 on the RTX 5080 Laptop GPU and the RTX 3090: every +/// pitch short of its own or off a multiple of 128 bytes (a 17-texel `R8` row asked at 17, 20, 32 +/// or 64 bytes lies 128 apart; a 100-texel `RGBA8` row asked at 400 or 448 lies 512 apart), while +/// multiples of 128 from its own up are laid out as asked. +/// +/// The runtime takes the image's own report of its pitch (`linear_plan::aliases`), so such an image +/// aliases nothing, and the probe's alias round trip runs only at a pitch the driver kept. +#[cfg(any(m2v_gpu, m2v_cpu_icd))] +const LINEAR_PITCH_FOR_EXPLICIT: &[i32] = &[4]; + /// On the test device the probe runs to the end without a validation message, and what it measured /// holds together: where the context imported host memory, both dispatches wrote every word into /// the host's own allocation; every linear row holds its packed texels; every alias round trip that -/// ran matched both ways; and every explicit layout the driver accepted has the pitch asked for. +/// ran matched both ways (but for a copy out of the buffer behind a copy into the image on a GPU +/// of [`STALE_LINEAR_IMAGE_COPIES`], which reads the bytes from before it); and every explicit +/// layout the driver accepted has the pitch asked for (or, on a driver of +/// [`LINEAR_PITCH_FOR_EXPLICIT`], its own linear pitch for the width). #[cfg(any(m2v_gpu, m2v_cpu_icd))] #[test] fn the_runtime_probe_measures_the_test_device_consistently() { let report = probe_runtime(crate::gpu::TEST_DEVICE).unwrap(); + let identity = &report["device"]; + let driver = identity["driver_id"].as_i64().unwrap() as i32; + let stale = + STALE_LINEAR_IMAGE_COPIES.contains(&(driver, identity["device_id"].as_u64().unwrap())); + let linear_pitch = LINEAR_PITCH_FOR_EXPLICIT.contains(&driver); eprintln!("{}", serde_json::to_string_pretty(&report).unwrap()); assert_eq!(report["validation_messages"], 0, "{report:#}"); let host = &report["host_memory"]; @@ -144,7 +189,8 @@ fn the_runtime_probe_measures_the_test_device_consistently() { assert_eq!(textures["error"], serde_json::Value::Null); for format in textures["formats"].as_array().unwrap() { assert_eq!(format["error"], serde_json::Value::Null, "{format:#}"); - for pitch in format["pitches"].as_array().unwrap() { + let pitches = format["pitches"].as_array().unwrap(); + for pitch in pitches { assert!(pitch["row_pitch"].as_u64() >= pitch["packed"].as_u64()); } let aliases = [&format["alias"], &format["drm_linear"]["alias"]]; @@ -155,13 +201,29 @@ fn the_runtime_probe_measures_the_test_device_consistently() { "buffer_reads_image", "host_reads_image", ] { - assert_eq!(alias[check]["mismatched"], 0, "{alias:#}"); + let mismatched = alias[check]["mismatched"].as_u64().unwrap(); + if check == "buffer_reads_image" && stale { + // Where a byte's old and new values agree it matches: most bytes differ. + let bytes = alias[check]["bytes"].as_u64().unwrap(); + assert!( + mismatched * 2 > bytes, + "the GPU of STALE_LINEAR_IMAGE_COPIES read the image's copy: {alias:#}" + ); + } else { + assert_eq!(mismatched, 0, "{check}: {alias:#}"); + } assert_ne!(alias[check]["bytes"], 0); } } if let Some(explicit) = format["drm_linear"]["explicit"].as_array() { for attempt in explicit.iter().filter(|a| a["outcome"] == "accepted") { - assert_eq!(attempt["row_pitch"], attempt["requested"], "{attempt:#}"); + let own = pitches + .iter() + .find(|pitch| pitch["width"] == attempt["width"]) + .map(|pitch| &pitch["row_pitch"]); + if !(linear_pitch && own == Some(&attempt["row_pitch"])) { + assert_eq!(attempt["row_pitch"], attempt["requested"], "{attempt:#}"); + } } } } diff --git a/crates/metal2vulkan-validation/src/metal/tests/shader_inputs.rs b/crates/metal2vulkan-validation/src/metal/tests/shader_inputs.rs index caa667786..e47128604 100644 --- a/crates/metal2vulkan-validation/src/metal/tests/shader_inputs.rs +++ b/crates/metal2vulkan-validation/src/metal/tests/shader_inputs.rs @@ -330,6 +330,9 @@ fn argument_buffer_intersection_table_is_encoded_at_reflected_field() { }; use crate::source::SourceRow; + // The fixture's interface as Metal's compiler states it (`xcrun metal -c` of + // `kernel_argument_buffer_intersection_table.metal`, metalfe-32023.921): the argument buffer's + // `table` member is an `air.intersection_function_table`, the role the executor encodes it by. let air_ll = r#" %struct.RayResources = type { ptr addrspace(1) } define void @argument_buffer_intersection_table(ptr addrspace(1) %as, ptr addrspace(2) %resources, ptr addrspace(1) %output) { @@ -340,11 +343,11 @@ entry: !0 = !{ptr @argument_buffer_intersection_table, !1, !2} !1 = !{} !2 = !{!3, !4, !7} -!3 = !{i32 0, !"air.instance_acceleration_structure", !"air.location_index", i32 5, i32 1, !"air.read", !"air.arg_type_name", !"instance_acceleration_structure"} -!4 = !{i32 1, !"air.indirect_buffer", !"air.buffer_size", i32 256, !"air.location_index", i32 6, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !5, !"air.arg_type_name", !"RayResources"} -!5 = !{i32 0, i32 8, i32 0, !"void", !"table", !"air.indirect_argument", !6} -!6 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"void"} -!7 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.write", !"air.address_space", i32 1, !"air.arg_type_name", !"uint"} +!3 = !{i32 0, !"air.instance_acceleration_structure", !"air.location_index", i32 5, i32 1, !"air.read", !"air.arg_type_name", !"acceleration_structure", !"air.arg_name", !"acceleration_structure"} +!4 = !{i32 1, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 6, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !5, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"RayResources", !"air.arg_name", !"resources"} +!5 = !{i32 0, i32 8, i32 0, !"intersection_function_table", !"table", !"air.indirect_argument", !6} +!6 = !{i32 0, !"air.intersection_function_table", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.arg_type_name", !"intersection_function_table", !"air.arg_name", !"table"} +!7 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"output"} "#; let source = SourceRow { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs index a5bd59dee..aa8a71f43 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs @@ -268,7 +268,8 @@ pub(super) const CREATED: [Degradation; 2] = [ pub(super) const PRIVATE_PROPERTIES: [Degradation; 1] = [Degradation::PrivatePropertiesUnknown]; /// The kind `gpu_times` takes on a venue whose device calibrates no timestamps against a host -/// clock the runtime reads (and expects absent where it does). +/// clock the runtime reads (and expects absent where it does), as does `first_use`'s busy work, +/// whose measurement reads GPU times (`gpu_times::read_kinds`). pub(super) const GPU_TIMES: [Degradation; 1] = [Degradation::UncalibratedGpuTimes]; /// The kind `gpu_times` takes on every venue that writes timestamps, with more command buffers in @@ -278,7 +279,9 @@ pub(super) const UNTIMED: [Degradation; 1] = [Degradation::UntimedCommandBuffer] /// The kind `color_fills` takes on every venue, with a color packed in a padded 10-bit format. pub(super) const UNPACKED_FILL: [Degradation; 1] = [Degradation::UnpackedFillColor]; -/// The kind `gpu_times` takes on every venue, on a device made with `gpu_times_from_host`. +/// The kind `gpu_times` takes on every venue, on a device made with `gpu_times_from_host`, and +/// `first_use`'s busy work where the driver answers GPU times from the host +/// (`gpu_times::read_kinds`). pub(super) const FROM_HOST: [Degradation; 1] = [Degradation::GpuTimesFromHost]; /// A non-uniform grid: 10 by 3 threads in threadgroups of 8 by 4. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs b/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs index 09a296569..25df378b9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs @@ -100,7 +100,7 @@ use crate::observation::MetalObservation; use crate::store::CorpusStore; use base64::Engine as _; use metal2vulkan::cache::VariantKey; -use metal2vulkan::device::VkProperty; +use metal2vulkan::device::{VkFeature, VkProperty}; use metal2vulkan::error::{Capability, DriverDeviation, Error as CompileError, Feature, Needs}; use metal2vulkan::library::Library; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage}; @@ -698,25 +698,38 @@ fn half_fused_multiply_adds_the_device_answers_are_metals() { // The `float` denormals, the `half` quantize, and the fused pair's NaN. /// The NaN model's denormal probe (`nan_denormals`, `nan_denormals_fast`): 256 threads of 48 -/// words over operand triples rich in denormals of both signs and the smallest normals. -const DENORMAL_PROBES: [&str; 2] = [ - "nan-model-float-denormals-per-operation", - "nan-model-float-denormals-per-operation-under-fast-math", +/// words over operand triples rich in denormals of both signs and the smallest normals; the +/// second is the first's program under fast math. +const DENORMAL_PROBES: [(&str, bool); 2] = [ + ("nan-model-float-denormals-per-operation", false), + ( + "nan-model-float-denormals-per-operation-under-fast-math", + true, + ), ]; /// The words of a [`DENORMAL_PROBES`] thread whose operations read `float` denormals as Metal -/// does on every profile: `a + b`, `a - b`, `a * b`, `a / b`, `0 - a`, `a < b`, `a == b`, `floor`, -/// `ceil`, `trunc`, `round`, `rint`, `ldexp`, `step`, `smoothstep`, `(a * b) * c`, `(a / b) * c`, -/// `a < b ? a : b`, `-(a * b)` and `fabs(a - b)`; `sqrt` and `rsqrt` ([`DENORMAL_PROBE_ROOTS`]) -/// where Metal answers a zero, an infinity or a NaN; and `pow` and `powr` -/// ([`DENORMAL_PROBE_POWERS`]) where it answers a zero, a denormal, an infinity or a NaN. Not the -/// fused multiply-adds (4, 5), `dot` and `length` (36, 37) and `mix` (38): their fused sums flush -/// at the tininess edge before rounding on Metal, which no device measured matches on every lane, -/// nor the math library's functions. +/// does on every profile: `a + b`, `a - b`, `a * b`, `0 - a`, `a < b`, `a == b`, `floor`, `ceil`, +/// `trunc`, `round`, `rint`, `ldexp`, `step`, `(a * b) * c`, `a < b ? a : b`, `-(a * b)` and +/// `fabs(a - b)`; the quotients ([`DENORMAL_PROBE_QUOTIENTS`]); `sqrt` and `rsqrt` +/// ([`DENORMAL_PROBE_ROOTS`]) where Metal answers a zero, an infinity or a NaN; and `pow` and +/// `powr` ([`DENORMAL_PROBE_POWERS`]) where it answers a zero, a denormal, an infinity or a NaN. +/// Not the fused multiply-adds (4, 5), `dot` and `length` (36, 37) and `mix` (38): their fused +/// sums flush at the tininess edge before rounding on Metal, which no device measured matches on +/// every lane, nor the math library's functions. const DENORMAL_PROBE_WORDS: &[usize] = &[ - 0, 1, 2, 3, 7, 10, 11, 12, 13, 14, 15, 16, 35, 39, 40, 43, 44, 45, 46, 47, + 0, 1, 2, 7, 10, 11, 12, 13, 14, 15, 16, 35, 39, 43, 45, 46, 47, ]; +/// The quotient words of a [`DENORMAL_PROBES`] thread: `a / b`, `smoothstep` and `(a / b) * c`. +/// Under fast math each divides by Metal's fast reciprocal, which a profile whose `float` +/// functions are not Metal's and that has no `OpFmaKHR` (`shaderFmaFloat32`) takes as the +/// device's `OpFDiv(1, y)`, within Vulkan's 2.5 ulp, not `RN(1 / y)` (the translator's +/// `divide::Reciprocal::Device`, recorded `PrecisionNote::DeviceArithmetic`): on such a profile +/// the fast probe's quotients are checked where Metal answers a zero, a denormal, an infinity or +/// a NaN, and everywhere else every word of them. +const DENORMAL_PROBE_QUOTIENTS: &[usize] = &[3, 40, 44]; + /// The `pow` and `powr` words of a [`DENORMAL_PROBES`] thread: checked where Metal answers a /// zero, a denormal, an infinity or a NaN, among them `pow(x, 1)` of a denormal `x`, which /// precise `pow` answers as `x` and `fast::pow` as the zero of its sign. Their other words are the @@ -732,6 +745,8 @@ const DENORMAL_PROBE_ROOTS: &[usize] = &[20, 21]; /// Both probes answer Metal's `float` denormals on every profile: the device's where the profile /// takes the deviation (the kernels then require `VkProperty::MetalFloatDenormals`), the /// module's own flushes elsewhere. Every word of [`DENORMAL_PROBE_WORDS`], each word of +/// [`DENORMAL_PROBE_QUOTIENTS`] (in the fast probe on a profile whose fast reciprocal is the +/// device's, where Metal answers a zero, a denormal, an infinity or a NaN), each word of /// [`DENORMAL_PROBE_ROOTS`] where Metal answers a zero, an infinity or a NaN, and each word of /// [`DENORMAL_PROBE_POWERS`] where it answers one of those or a denormal, is the Metal row's of /// the same chip; the test prints how many of the other words differ. @@ -743,8 +758,17 @@ fn float_denormals_read_as_metal_reads_them() { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); let name = device.name().to_owned(); let metals = takes(&device, DriverDeviation::MetalFloatDenormals); + // Whether Metal's fast reciprocal is the device's `OpFDiv(1, y)`: neither Metal's own + // float functions nor `OpFmaKHR`, whose refinement makes it `RN(1 / y)`. + let device_reciprocal = !takes(&device, DriverDeviation::MetalFloatFunctions) + && !device + .compile_device() + .profile() + .enabled() + .features + .contains(&VkFeature::ShaderFmaFloat32); let mut failures = Vec::new(); - for case_name in DENORMAL_PROBES { + for (case_name, fast) in DENORMAL_PROBES { let case = public_case(case_name).unwrap(); assert_eq!( requires_property(&device, &case, VkProperty::MetalFloatDenormals), @@ -765,7 +789,10 @@ fn float_denormals_read_as_metal_reads_them() { for i in 0..metal.len() / 4 { let w = i % 48; let (got, want) = (word(&run.output, i), word(&metal, i)); + let quotient = DENORMAL_PROBE_QUOTIENTS.contains(&w); if DENORMAL_PROBE_WORDS.contains(&w) + || (quotient && !(fast && device_reciprocal)) + || (quotient && edge(want)) || (DENORMAL_PROBE_ROOTS.contains(&w) && special(want)) || (DENORMAL_PROBE_POWERS.contains(&w) && edge(want)) { @@ -778,9 +805,9 @@ fn float_denormals_read_as_metal_reads_them() { } } eprintln!( - "float denormals {case_name} on {name} (the device's: {metals}): {} of \ - {checked} checked words differ from Metal; other words differing, by word: \ - {by_word:?}", + "float denormals {case_name} on {name} (the device's: {metals}; the device's \ + fast reciprocal: {device_reciprocal}): {} of {checked} checked words differ \ + from Metal; other words differing, by word: {by_word:?}", differ.len() ); if !differ.is_empty() { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/exits.rs b/crates/metal2vulkan-validation/src/runtime_lane/exits.rs index 8654ddabf..6132f7245 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/exits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/exits.rs @@ -6,7 +6,10 @@ //! a device down. The parent checks that the child exited with status 0, not by a signal, and //! within [`EXIT_LIMIT`] of its last line: below the exit hook's own bound of 2 s, so a hook that //! waited out its bound fails too. Each child reports the validation layer's messages until then, -//! which must be none. The parent prints each exit's time. +//! which must be none. The parent prints each exit's time. Each test that checks that time runs +//! alone in the suite (`.config/nextest.toml`): an exit's time holds the driver's device +//! destruction, which other processes' GPU work slows (NVIDIA's `vkDestroyDevice` took 54 ms alone +//! and up to 2 s beside other lanes on an RTX 3090). //! //! Metal's answers (EV `RT4-metal-teardown`, an M4 with macOS 27.0.1, each case without and with //! `MTL_DEBUG_LAYER=1`): every such exit was clean, in 15 to 45 ms, but one: a dropped command diff --git a/crates/metal2vulkan-validation/src/runtime_lane/first_use.rs b/crates/metal2vulkan-validation/src/runtime_lane/first_use.rs index 570b9a955..8293679d3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/first_use.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/first_use.rs @@ -51,6 +51,7 @@ use super::degrade_notices::{ assert_once_allowing, forced, made_compute_kinds, shared_in_system_memory, }; +use super::gpu_times::read_kinds; use super::host_memory::{no_copy, not_importable, recording, Mapping, Seen, GUEST_PAGE}; use super::rebind_reach::{node, walk, Outputs, Uses, A, POINTER_WALKER}; use super::rebinds::rebind; @@ -68,7 +69,7 @@ use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; use metal2vulkan::vk::DriverId; use metal2vulkan_devtools::llvm_assemble; use metal2vulkan_runtime::{ - BlitOption, Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, CommitFailure, + host_time, BlitOption, Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, CommitFailure, ComputePipelineState, CpuCacheMode, DebugMessage, Degradation, Device, Error, HazardTrackingMode, HeapDescriptor, HeapType, LoadAction, Origin, PipelineOptions, Region, RenderPassDescriptor, ResourceOptions, Size, StorageMode, StoreAction, Submission, @@ -85,9 +86,12 @@ use std::time::{Duration, Instant}; /// ([`release`]): far longer than every call a test makes while it runs. const BUSY: Duration = Duration::from_secs(2); -/// The least time the busy kernel's rate is measured over. +/// The least GPU time the busy kernel's rate is measured over, at that rate. const MEASURED: Duration = Duration::from_millis(50); +/// The most runs at one cap the busy kernel's rate is measured by. +const RUNS: usize = 3; + /// The textures' side, format and bytes per row: one guest page of texels. const SIDE: u64 = 64; const PF: PixelFormat = PixelFormat::RGBA8Unorm; @@ -111,21 +115,34 @@ const UNBOUND_CASES: [&str; 3] = [ /// test raises it ([`release`]) or its cap of loads runs out, then gives up (as /// `framebuffer_fetch::storage_forms` holds a copy), and its cap for about [`BUSY`]. Shared with /// `compressed_decode`'s lane of writes behind work in flight. +/// +/// Its cap, not the flag, ends it on an RTX 3090 (NVIDIA 615.71.09): alone, each of six busy +/// works released 0 to 50 ms into its spin ran its whole cap, 2.0 s on the GPU, and published +/// nothing. pub(super) struct Busy { state: ComputePipelineState, cap: u32, /// The kinds its pipeline state's making announced where the device had not - /// (`made_compute_kinds`). + /// (`made_compute_kinds`), and its measurement's reads of GPU times (`gpu_times::read_kinds`). pub(super) made: BTreeSet, } impl Busy { - /// The kernel, its cap grown until a run takes [`MEASURED`], then scaled to [`BUSY`]: a - /// run's wall time bounds its GPU time, so the busy work lasts at least about that long. - /// The first run is not measured: it holds the device's first use of the pipeline and of a - /// command buffer, which on a loaded host took past [`MEASURED`] by themselves, and a cap - /// scaled from it spun for microseconds (lavapipe in master's gate at 409546f2: a test of a 0.5 - /// s busy work took 0.35 s whole, and its calls saw the end mark). + /// The kernel, its cap the loads of [`BUSY`] at its rate: the fastest of every measured run, + /// in loads per second of the run's time on the GPU where the device answers it + /// ([`gpu_took`]). The cap grows sixteenfold until a run takes [`MEASURED`] at that rate, and + /// a cap whose run takes it is run again, up to [`RUNS`] times. The GPU's other work only + /// slows a run, so the fastest is the kernel's own rate unless every run was slowed; and a + /// run's wall time held that work too: on an RTX 3090 (NVIDIA 615.71.09) beside the lane's + /// other tests, which run such kernels too, a run of 4096 loads, under a millisecond on the + /// GPU, took about 200 ms from its commit, as long as another process's run, and the cap + /// scaled from that wall time, 37559 loads, spun for about 7 ms, less than a call took there + /// (7.6 ms); and three runs of 65536 loads, about 12 ms alone, each took 200 to 420 ms from + /// their GPU start to their GPU end. The first run is not measured: it holds the + /// device's first use of the pipeline and of a command buffer, which on a loaded host took + /// past [`MEASURED`] by themselves, and a cap scaled from it spun for microseconds (lavapipe in + /// master's gate at 409546f2: a test of a 0.5 s busy work took 0.35 s whole, and its calls + /// saw the end mark). pub(super) fn new(device: &Device, queue: &CommandQueue) -> Busy { let ll = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/rfs_agx_yield.ll"); @@ -143,37 +160,59 @@ impl Busy { &PipelineOptions::default(), ) .unwrap(); + let mut made = made_compute_kinds(device, function.function_descriptor()); + made.extend(read_kinds(device)); let mut busy = Busy { state, cap: 1 << 12, - made: made_compute_kinds(device, function.function_descriptor()), + made, }; - let (first, _) = busy.commit(device, queue); - first.wait_until_completed_for(WAIT).unwrap(); - assert_eq!(first.error(), None, "the busy work"); - let took = loop { - let at = Instant::now(); - let (command_buffer, mark) = busy.commit(device, queue); - command_buffer.wait_until_completed_for(WAIT).unwrap(); - let took = at.elapsed(); - assert_eq!(command_buffer.error(), None, "the busy work"); - assert_eq!(read_mark(&mark), ENDED, "the busy work's end mark"); - if took >= MEASURED || busy.cap >= 1 << 28 { - break took; + busy.run(device, queue); + // The fastest rate of every run, in loads per second, and each run's loads, time on the + // GPU and time from commit to completion, for the printed line. + let mut rate = 0.0_f64; + let mut runs = Vec::new(); + let at_rate = |cap: u32, rate: f64| f64::from(cap) / rate >= MEASURED.as_secs_f64(); + loop { + for _ in 0..RUNS { + let (took, wall) = busy.run(device, queue); + rate = rate.max(f64::from(busy.cap) / took.as_secs_f64()); + runs.push((busy.cap, took, wall)); + if !at_rate(busy.cap, rate) { + break; + } + } + if at_rate(busy.cap, rate) || busy.cap >= 1 << 28 { + break; } busy.cap <<= 4; - }; - let cap = f64::from(busy.cap) * BUSY.as_secs_f64() / took.as_secs_f64(); - let measured = busy.cap; - busy.cap = cap.clamp(1.0, f64::from(u32::MAX)) as u32; + } + busy.cap = (rate * BUSY.as_secs_f64()).clamp(1.0, f64::from(u32::MAX)) as u32; + let runs: Vec = (runs.iter()) + .map(|(cap, took, wall)| format!("{cap} in {took:.2?} ({wall:.2?})")) + .collect(); println!( - "BUSY-CAP on {}: {} loads, from {measured} in {took:?}", + "BUSY-CAP on {}: {} loads, at the fastest rate of the runs of loads in GPU time (from \ + commit to completion): {}", device.name(), - busy.cap + busy.cap, + runs.join(", ") ); busy } + /// Run the busy work once, released by nothing: the time it took on the GPU ([`gpu_took`]), + /// and from its commit to its completion. + fn run(&self, device: &Device, queue: &CommandQueue) -> (Duration, Duration) { + let at = Instant::now(); + let (command_buffer, mark) = self.commit(device, queue); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + let wall = at.elapsed(); + assert_eq!(command_buffer.error(), None, "the busy work"); + assert_eq!(read_mark(&mark), ENDED, "the busy work's end mark"); + (gpu_took(&command_buffer, wall), wall) + } + /// Commit the busy work on `queue`: the spin, then a blit that writes the end mark into the /// word after the spin's flag, ordered after the spin by the buffer both use. The command /// buffer, and the buffer of the mark. @@ -205,6 +244,19 @@ impl Busy { } } +/// The time `command_buffer`, completed in `wall` from its commit, took on the GPU: its GPU end +/// less its GPU start, where the device answers them (`CommandBuffer::gpu_start_time`) apart, +/// else `wall`, which holds it. +fn gpu_took(command_buffer: &CommandBuffer, wall: Duration) -> Duration { + match ( + command_buffer.gpu_start_time(), + command_buffer.gpu_end_time(), + ) { + (Ok(start), Ok(end)) if end > start => Duration::from_secs_f64(end - start).min(wall), + _ => wall, + } +} + /// Raise the flag the busy work's spin waits for: it ends at its next load (or, where the device /// does not show it the host's store while it runs, at its cap). pub(super) fn release(words: &Buffer) { @@ -346,6 +398,8 @@ fn zero_contents(buffer: &Buffer, len: u64) -> bool { /// (`Calls::announced_wait`) and must be a test's last timed call. struct Calls<'a> { device: &'a Device, + /// The busy work, and the buffer of its end mark. + busy: &'a CommandBuffer, mark: Buffer, took: Vec<(String, Duration)>, /// Whether the device's driver is lavapipe, whose object making waits for its queue's work. @@ -360,10 +414,11 @@ struct Calls<'a> { } impl<'a> Calls<'a> { - fn new(device: &'a Device, mark: Buffer) -> Self { + fn new(device: &'a Device, busy: &'a CommandBuffer, mark: Buffer) -> Self { let driver = device.properties().description.driver_id; Calls { device, + busy, mark, took: Vec::new(), queue_lock: driver == Some(DriverId::MESA_LLVMPIPE), @@ -402,9 +457,9 @@ impl<'a> Calls<'a> { self.notices.extend(messages.take_notices()); } let before = self.device.work_counts().internal_submissions; - let at = Instant::now(); + let (at, begun) = (Instant::now(), host_time()); let made = call(); - let took = at.elapsed(); + let (took, returned) = (at.elapsed(), host_time()); let internal = self.device.work_counts().internal_submissions - before; let announced = announcing.and_then(|(messages, kind)| { let notices = messages.take_notices(); @@ -437,17 +492,36 @@ impl<'a> Calls<'a> { self.took.push((what, took)); return made; } - assert_eq!( - read_mark(&self.mark), - 0, - "{what} returned only once the GPU's busy work ended ({took:?}, {internal} internal \ - submissions) on {}: it waited for it, where Metal's returns at once", - self.device.name() - ); + if read_mark(&self.mark) != 0 { + panic!( + "{what} returned only once the GPU's busy work ended ({took:?}, {internal} \ + internal submissions) on {}: it waited for it, where Metal's returns at once; {}", + self.device.name(), + self.span(begun, returned) + ); + } self.took.push((what, took)); made } + /// Where the busy work ran on the GPU against a call from host time `begun` to `returned`, + /// once it completed, in milliseconds from the call's start: a failure's report. + fn span(&self, begun: f64, returned: f64) -> String { + self.busy.wait_until_completed_for(WAIT).unwrap(); + let ms = |at: f64| (at - begun) * 1e3; + match (self.busy.gpu_start_time(), self.busy.gpu_end_time()) { + (Ok(start), Ok(end)) => format!( + "the busy work ran on the GPU from {:.1} ms to {:.1} ms ({:.1} ms), and the call \ + returned at {:.1} ms, from the call's start", + ms(start), + ms(end), + (end - start) * 1e3, + ms(returned) + ), + (start, _) => format!("the busy work's GPU times: {start:?}"), + } + } + /// How the calls returned against the busy work, for the test's summary line. fn waits(&self) -> String { match (&self.queue_lock_wait, &self.announced_wait) { @@ -525,7 +599,7 @@ fn new_resources_wait_for_no_gpu_work() { let (busy_work, mark) = busy.commit(device, &queue); scheduled(&busy_work); - let mut calls = Calls::new(device, mark); + let mut calls = Calls::new(device, &busy_work, mark); assert_eq!( read_mark(&calls.mark), 0, @@ -923,7 +997,7 @@ fn neutrals_and_sparse_textures_wait_for_no_gpu_work() { let (busy_work, mark) = busy.commit(device, &queue); scheduled(&busy_work); - let mut calls = Calls::new(device, mark); + let mut calls = Calls::new(device, &busy_work, mark); assert_eq!( read_mark(&calls.mark), 0, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/gpu_times.rs b/crates/metal2vulkan-validation/src/runtime_lane/gpu_times.rs index 8f23382bb..db1434d04 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/gpu_times.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/gpu_times.rs @@ -51,8 +51,10 @@ use ash::vk; use metal2vulkan::device::DriverFact; use metal2vulkan::error::Feature; use metal2vulkan_runtime::{ - host_time, CommandBuffer, CommandQueue, Device, Error, EventRef, ResourceOptions, SharedEvent, + host_time, CommandBuffer, CommandQueue, Degradation, Device, Error, EventRef, ResourceOptions, + SharedEvent, }; +use std::collections::BTreeSet; use std::ffi::{CStr, CString}; use std::sync::{Arc, Mutex, PoisonError}; use std::time::{Duration, Instant}; @@ -191,6 +193,22 @@ fn from_host_by_driver(device: &Device) -> bool { .contains(&DriverFact::TimestampsWaitForEveryQueue) } +/// The kind a read of a timed command buffer's GPU times announces on `device`, made with the +/// default options, as `command_buffers_are_timed_in_the_hosts_time_base` checks: [`FROM_HOST`]'s +/// where its driver answers them from the host, [`GPU_TIMES`]' where it writes timestamps it does +/// not calibrate, none elsewhere (a calibrating device, or one that writes no timestamps and +/// refuses the read). +pub(super) fn read_kinds(device: &Device) -> BTreeSet { + if from_host_by_driver(device) { + return BTreeSet::from(FROM_HOST); + } + let venue = Venue::of(device); + match venue.bits > 0 && !venue.calibrates() { + true => BTreeSet::from(GPU_TIMES), + false => BTreeSet::new(), + } +} + /// `cb`'s four times: GPU start and end, kernel start and end. fn times(cb: &CommandBuffer) -> [f64; 4] { [ diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs index 4763b4e18..d10a6297e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs @@ -387,18 +387,20 @@ fn heap_textures_answer_and_place_as_metal_s_do() { assert_eq!(texture.usage(), shape.usage, "{}", shape.name); } // The view's answer announces only a size's kinds, and the textures' makings - // a heap texture's route where the device's driver facts force one. + // the heap texture's route where the device's driver facts force one: an image + // the driver may compress one of `ALIASES`; a depth or stencil texture's image + // the driver lays apart from its memory a shadow of the heap's bytes + // (`shadowed-texture`, as the heap depth lane measures on MoltenVK) or, where no + // shadow serves it, `heap-depth-stencil-apart`. let facts = &device.properties().driver_facts; + let apart = is_depth_stencil(shape.pixel_format) + && facts.contains(&DriverFact::DepthStencilImagesLieApart); let routes = facts .contains(&DriverFact::CompressedImagesHideAliasedWrites) .then_some(&ALIASES[..]) .into_iter() - .flatten() - .chain( - facts - .contains(&DriverFact::DepthStencilImagesLieApart) - .then_some(&Degradation::HeapDepthStencilApart), - ); + .chain(apart.then_some(&DEPTH_STENCIL_ROUTES[..])) + .flatten(); let allowed: BTreeSet = SIZE_NOTICES.iter().chain(routes).copied().collect(); let more = announced(); @@ -886,6 +888,14 @@ fn an_adopted_device_stating_host_image_copy_aliases_its_heap_textures() { /// The kind a heap's depth or stencil texture laid apart from the heap announces. pub(super) const APART: [Degradation; 1] = [Degradation::HeapDepthStencilApart]; +/// The kinds a heap's depth or stencil texture announces where the driver lays such images apart +/// from their memory (`DriverFact::DepthStencilImagesLieApart`): its image a shadow of the heap's +/// bytes (one sample, its texels inside its bytes), else laid apart. +const DEPTH_STENCIL_ROUTES: [Degradation; 2] = [ + Degradation::ShadowedTexture, + Degradation::HeapDepthStencilApart, +]; + /// The kind a depth or stencil texture without GPU-optimized contents announces where the driver /// keeps its layout optimized. pub(super) const OPTIMIZED: [Degradation; 1] = [Degradation::OptimizedDepthStencilTexture]; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/indirect_executions.rs b/crates/metal2vulkan-validation/src/runtime_lane/indirect_executions.rs index cdc8e3f6d..49b80aaec 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/indirect_executions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/indirect_executions.rs @@ -39,13 +39,14 @@ use metal2vulkan::metal::{ use metal2vulkan::pipeline::{ComputePipelineDescriptor, LinkedFunctions, StageSource}; use metal2vulkan_devtools::{engine_dir, llvm_assemble}; use metal2vulkan_runtime::{ - Buffer, CommandBuffer, CommandBufferStatus, ComputeCommandEncoder, ComputePipelineState, - DebugMessage, Degradation, Device, DeviceOptions, Error, ExecutedPipeline, Execution, Heap, - HeapDescriptor, HeapType, HostMemory, IndirectCommand, IndirectCommandBuffer, - IndirectCommandBufferDescriptor, IndirectCommandBufferProblem, Invalid, PipelineOptions, - Problem, Region, RenderPassDescriptor, ResourceOptions, Size, VisibleFunctionTableDescriptor, + Buffer, CommandBuffer, CommandBufferError, CommandBufferStatus, ComputeCommandEncoder, + ComputePipelineState, DebugMessage, Degradation, Device, DeviceOptions, Error, + ExecutedPipeline, Execution, Heap, HeapDescriptor, HeapType, HostMemory, IndirectCommand, + IndirectCommandBuffer, IndirectCommandBufferDescriptor, IndirectCommandBufferProblem, Invalid, + PipelineCreationCause, PipelineOptions, Problem, Region, RenderPassDescriptor, ResourceOptions, + Size, VisibleFunctionTableDescriptor, VkResultCode, }; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use std::sync::Arc; /// A kernel whose threads each write their threadgroup's size and position, over a ragged grid. @@ -212,10 +213,12 @@ struct Run { executions: Vec, } -/// Why a run did not complete: the runtime's error at the dispatch or the commit, or anything -/// else. +/// Why a run did not complete: the runtime's error at the dispatch or the commit, the command +/// buffer's error once it completed (with the driver's Vulkan error for the command whose +/// pipeline it did not make, `CommandBuffer::failed_pipeline`), or anything else. enum Failed { Runtime(Error), + Command(Option, Option), Other(String), } @@ -223,6 +226,7 @@ impl std::fmt::Display for Failed { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Failed::Runtime(error) => write!(f, "{error}"), + Failed::Command(error, _) => write!(f, "the command buffer failed: {error:?}"), Failed::Other(why) => f.write_str(why), } } @@ -234,23 +238,47 @@ impl From for Failed { } } +/// The Vulkan error of a run that failed making the case's pipeline, in either of the runtime's +/// forms: the commit's `Error::Vulkan` where the commit made it (an indirect command's variants, +/// which the commit settles, `indirect_execute.rs`), or the command buffer's `PipelineCreation` +/// where its dispatch's making went on after the dispatch and failed, then failed again when the +/// recording made it once more (`pending_dispatch.rs`), naming that dispatch's pipeline with the +/// same error (`CommandBuffer::failed_pipeline`). +fn making_failed(failed: &Failed) -> Option { + match failed { + Failed::Runtime(Error::Vulkan(code)) => Some(*code), + Failed::Command( + Some(CommandBufferError::PipelineCreation(PipelineCreationCause::Vulkan(code))), + Some(made), + ) if made == code => Some(*code), + _ => None, + } +} + /// Whether the dispatch (`direct`, the device reporting `direct_reported`) and the command /// (`indirect`, `indirect_reported`) failed alike making the case's pipeline: the same Vulkan -/// error from the runtime, and the same messages from the device for each, every one a pipeline -/// compile's failure. The device's failure, which an indirect command neither causes nor hides. +/// error from the runtime ([`making_failed`]), and the same messages from the device for each, +/// every one a pipeline compile's failure. The device's failure, which an indirect command neither +/// causes nor hides. The messages compare as sets: the dispatch's making, which failed once +/// after the dispatch, is made again by its recording (`pending_dispatch.rs`), so the device +/// reports the same failure once more for it. fn compile_failed_alike( direct: &Failed, indirect: &Failed, direct_reported: &[DebugMessage], indirect_reported: &[DebugMessage], ) -> bool { - let (Failed::Runtime(Error::Vulkan(a)), Failed::Runtime(Error::Vulkan(b))) = (direct, indirect) - else { + let (Some(a), Some(b)) = (making_failed(direct), making_failed(indirect)) else { return false; }; + let within = |some: &[DebugMessage], all: &[DebugMessage]| { + some.iter().all(|message| all.contains(message)) + }; a == b && !direct_reported.is_empty() - && direct_reported == indirect_reported + && !indirect_reported.is_empty() + && within(direct_reported, indirect_reported) + && within(indirect_reported, direct_reported) && direct_reported .iter() .all(|message| message.text.contains("pipeline compile failed")) @@ -295,10 +323,15 @@ fn run( .wait_until_completed_for(WAIT) .map_err(|_| "the command buffer did not complete".to_owned())?; if command_buffer.status() != CommandBufferStatus::Completed { - return Err(Failed::Other(format!( - "the command buffer failed: {:?}", - command_buffer.error() - ))); + return Err(Failed::Command( + command_buffer.error(), + command_buffer + .failed_pipeline() + .and_then(|pipeline| match pipeline.error { + Error::Vulkan(code) => Some(code), + _ => None, + }), + )); } let report = command_buffer .execution_report() @@ -439,11 +472,13 @@ fn every_case_of_buffers_alone_runs_from_a_command_as_its_dispatch(shard: usize) &indirect_reported, ) => { - let texts: Vec<&str> = + let texts: BTreeSet<&str> = direct_reported.iter().map(|m| m.text.as_str()).collect(); + let (dispatch, command) = (direct_reported.len(), indirect_reported.len()); compile_failed.push(format!( "{name}: {direct} (from the command: {indirect}); the device reported \ - for each {texts:?}" + {dispatch} times for the dispatch and {command} for the command \ + {texts:?}" )); device_failure = true; } @@ -480,8 +515,8 @@ fn every_case_of_buffers_alone_runs_from_a_command_as_its_dispatch(shard: usize) } if !compile_failed.is_empty() { eprintln!( - "compile failed alike: the device's own pipeline compiles; docs/TODO.md 6.4 tracks \ - 3cf0a3f0's (Apple's compiler service, on MoltenVK)" + "compile failed alike: the device's own failure making the pipeline; \ + docs/FAST-PATHS.md's known gaps record 3cf0a3f0's (Apple's compiler, on MoltenVK)" ); } for why in &compile_failed { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs b/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs index e9d3fb091..e101e8f68 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs @@ -13,10 +13,16 @@ //! making is no longer the record's bytes (RADV's after its first hit from a compile's record is //! not, and settles: EVs PRDP-hl3-radv, PRDP-hl4-radv), and counts every other read unchanged //! (`driver_data_unchanged`). -//! - **Overwrite.** A record holding another pipeline's data (another state's record copied over -//! it) is loaded: the driver's miss where the other's data lacks this pipeline, and the making -//! writes the record again, holding its own pipeline now; its hit where the two states' data -//! are alike. A later device then hits it, writing it again only where the data changed. +//! - **Overwrite.** A record holding another pipeline's data (a dispatch's compute pipeline's +//! record copied over each of a render state's) is loaded: the driver's miss, and where the +//! driver's data holds its pipelines the making adds its own, so the record is written again, +//! holding this pipeline now. A later device then hits it, writing it again only where the data +//! changed. The other pipeline is a compute pipeline, which no making of a render state is on +//! any driver: another render state's would not do, since a driver may key that state's +//! libraries as this one's (NVIDIA does for `RGBA8Unorm` and `BGRA8Unorm` targets) and its +//! data for one pipeline need not be the same bytes from one making to the next (NVIDIA +//! 615.71.09's on an RTX 3090 and an RTX 5080 Laptop are not), so no comparison of two +//! makings' bytes tells whether one's data holds the other's pipeline. //! - **Makings at once.** Two processes making the same pipeline on one directory at the same //! time leave one whole record of it and no temporary file, which a later device hits. //! @@ -25,8 +31,9 @@ //! state's creation makes two, its pre-rasterization and fragment shader libraries, and the points' //! draw one, its pre-rasterization library (Metal biases depth for triangles only, so the points' //! pre-rasterization state is another, and their fragment's is the state's). Every count above is -//! of those makings there; a record written over another's holds another pipeline's data whichever -//! pairs them. The driver reports no hit or miss of a library, which [`assert_reported`] takes. +//! of those makings there; a library's record written over with the compute pipeline's data holds +//! another pipeline's data, whichever library it is. The driver reports no hit or miss of a +//! library, which [`assert_reported`] takes. //! //! **The driver's own cache is fresh for each device**: Mesa's and NVIDIA's shader disk caches are //! pointed into a new scratch directory before each device or maker process is made @@ -248,6 +255,33 @@ fn draw( unsafe { std::slice::from_raw_parts(contents.as_ptr(), (row * SIDE) as usize) }.to_vec() } +/// Dispatch the fixture's `scale_and_offset` over four values and wait: the making of its +/// compute pipeline, which no making of a render state is. +fn dispatch(device: &Device, library: &Library) { + let function = library.new_function_with_name("scale_and_offset").unwrap(); + let state = device + .new_compute_pipeline_state_with_function(&function, &PipelineOptions::default()) + .unwrap(); + let input = device + .new_buffer_with_bytes(&[0u8; 16], ResourceOptions::shared()) + .unwrap(); + let output = device.new_buffer(16, ResourceOptions::shared()).unwrap(); + let queue = device.new_command_queue().unwrap(); + let command_buffer = queue.command_buffer().unwrap(); + let mut encoder = command_buffer.compute_command_encoder().unwrap(); + encoder.set_compute_pipeline_state(&state).unwrap(); + encoder.set_buffer(Some(&input), 0, 0).unwrap(); + encoder.set_buffer(Some(&output), 0, 1).unwrap(); + encoder.set_bytes(&1.0f32.to_le_bytes(), 2).unwrap(); + encoder + .dispatch_threads(Size::new(4, 1, 1), Size::new(4, 1, 1)) + .unwrap(); + encoder.end_encoding().unwrap(); + command_buffer.commit().unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); +} + /// The driver cache counts of `statistics`, printed for `which`. fn report(which: &str, s: &ShaderCacheStatistics) { println!( @@ -685,17 +719,17 @@ fn a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records() { #[test] fn a_record_holding_another_pipeline_s_data_is_written_again() { let messages = Messages::default(); - // The record of an `RGBA8Unorm` state's making, in a directory of its own. + // The record of a dispatch's compute pipeline, in a directory of its own. let other = ScratchCache::new().unwrap(); - let (driver, foreign, makings) = { + let (driver, foreign) = { let _driver_cache = DriverCache::fresh(); let device = validated_device_with(TEST_DEVICE, &messages, other.path(), |_| {}).unwrap(); let driver = DriverData::of(&device); - let _state = state(&device, &library(&device), PixelFormat::RGBA8Unorm); + dispatch(&device, &library(&device)); let made = device.shader_cache_statistics(); - report("the other state", &made); + report("the compute pipeline", &made); assert_eq!(kept(&made), driver.whole(), "the driver's data: {driver:?}"); - (driver, records(other.path()), Makings::of(&device)) + (driver, records(other.path())) }; // Data that ends inside its header is never kept (the module docs): no record to copy. if !driver.whole() { @@ -708,22 +742,23 @@ fn a_record_holding_another_pipeline_s_data_is_written_again() { return; } let foreign: Vec> = foreign.into_values().collect(); - assert_eq!( - foreign.len() as u64, - makings.creation, - "the other state's records" - ); - // A `BGRA8Unorm` state's makings: their records, then the other's bytes put in their places, - // each record in path order taking the other's in path order: another pipeline's data. + assert_eq!(foreign.len(), 1, "the compute pipeline's record"); + let foreign = &foreign[0]; + // A `BGRA8Unorm` state's makings: their records, then the compute pipeline's bytes put in + // each one's place: another pipeline's data. let cache = ScratchCache::new().unwrap(); let format = PixelFormat::BGRA8Unorm; - let target = { + let (target, makings) = { let _driver_cache = DriverCache::fresh(); let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |_| {}).unwrap(); let state = state(&device, &library(&device), format); + let makings = Makings::of(&device); let made = device.shader_cache_statistics(); assert_reported("its own state", &made, (0, makings.creation)); - draw(&device, &state, (format, PrimitiveType::Triangle)) + ( + draw(&device, &state, (format, PrimitiveType::Triangle)), + makings, + ) }; let own: Vec<(PathBuf, Vec)> = records(cache.path()).into_iter().collect(); assert_eq!( @@ -731,38 +766,29 @@ fn a_record_holding_another_pipeline_s_data_is_written_again() { makings.creation, "its own state's records" ); - // Each record holds the driver's data; where that holds no pipeline, the other's record is - // this one's own bytes, which the making loads and finds its data, writing nothing. - let all: Vec<&[u8]> = foreign - .iter() - .chain(own.iter().map(|(_, bytes)| bytes)) - .map(|bytes| &bytes[..]) + // Each record holds the driver's data; where that holds no pipeline, the compute pipeline's + // record is each one's own bytes, which the making loads and finds its data, writing nothing. + let all: Vec<&[u8]> = std::iter::once(&foreign[..]) + .chain(own.iter().map(|(_, bytes)| &bytes[..])) .collect(); driver.assert_records(&all); - for ((path, _), foreign) in own.iter().zip(&foreign) { + for (path, _) in &own { std::fs::write(cache.path().join(path), foreign).unwrap(); } - // Loaded, then the driver's: its hit where the other's data holds this pipeline too (the two - // states' records alike: a driver that keeps one binary for both), else its miss; where it - // holds pipelines, a miss adds this one, so the record is written again. Written again - // exactly where the data changed. - let hits: Vec = own - .iter() - .zip(&foreign) - .map(|((_, own), foreign)| driver.holds() && own == foreign) - .collect(); - let hit_count = hits.iter().filter(|&&hit| hit).count() as u64; + // Loaded, then the driver's miss: the compute pipeline's data holds no making of a render + // state. Where the driver's data holds its pipelines, the miss adds this one, so each record + // is written again; where it holds none, the data stays the record's bytes. let rewritten = { let _driver_cache = DriverCache::fresh(); let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |_| {}).unwrap(); let none = device.shader_cache_statistics(); let state = state(&device, &library(&device), format); let made = device.shader_cache_statistics(); - report("the other's data in its place", &made); + report("the compute pipeline's data in its place", &made); assert_reported( - "the other's data in its place", + "the compute pipeline's data in its place", &made, - (hit_count, makings.creation - hit_count), + (0, makings.creation), ); let rewritten: Vec> = own .iter() @@ -770,23 +796,22 @@ fn a_record_holding_another_pipeline_s_data_is_written_again() { .collect(); let changed = rewritten .iter() - .zip(&foreign) - .filter(|(rewritten, foreign)| rewritten != foreign) + .filter(|rewritten| *rewritten != foreign) .count() as u64; assert_loaded( - "the other's data in its place", + "the compute pipeline's data in its place", (&none, &made), makings.creation, changed, ); - for ((rewritten, foreign), hit) in rewritten.iter().zip(&foreign).zip(&hits) { - if driver.holds() && !hit { - assert_ne!( - rewritten, foreign, - "the driver's miss added this pipeline to the record" - ); - } - } + assert_eq!( + changed, + match driver.holds() { + true => makings.creation, + false => 0, + }, + "the driver's misses added this pipeline to each record" + ); assert_eq!( draw(&device, &state, (format, PrimitiveType::Triangle)), target diff --git a/crates/metal2vulkan-validation/src/worker.rs b/crates/metal2vulkan-validation/src/worker.rs index 00d227894..b1f7a09ca 100644 --- a/crates/metal2vulkan-validation/src/worker.rs +++ b/crates/metal2vulkan-validation/src/worker.rs @@ -9,15 +9,17 @@ //! //! [`run_json`] is the one parent-side exchange: the input goes to the child's stdin from a //! scratch file (no feeder thread per row), the child writes one JSON report to stdout -//! ([`report`]: its result and its counting allocator's process peak), and every scratch file is -//! removed before the call returns. The parent samples the group's RSS every 10 ms, which can -//! miss a short peak; the allocator's peak, counted exactly in the child, is recorded beside it -//! in every result ([`Measured`]). Each member is charged only memory of its own, never its -//! parent's while it still runs in it ([`process`]), and a supervising process gives its large -//! freed buffers back to the system ([`alloc::release_large_frees`]), so its own RSS does not grow -//! from sweep to sweep. [`compile`] runs every engine pipeline compile of a device-holding tool -//! (L4 acceptance, the engine candidate, the device tests) through it, and [`audit`] every -//! attempt of the canon and bitcode-reader audit lanes. [`device`] is the other boundary: the +//! ([`report`]: its result, its counting allocator's process peak and its resident high water), +//! and every scratch file is removed before the call returns. The parent samples the group's RSS +//! every 10 ms, which can miss a short peak or a whole worker that runs between two samples: the +//! result's peak also takes the high water the worker states, and the allocator's peak, counted +//! exactly in the child, is recorded beside it in every result ([`Measured`]). Each member is +//! charged only memory of its own, never its parent's while it still runs in it ([`process`]), +//! and a supervising process gives its large freed buffers back to the system +//! ([`alloc::release_large_frees`]), so its own RSS does not grow from sweep to sweep. +//! [`compile`] runs every engine pipeline compile of a device-holding tool (L4 acceptance, the +//! engine candidate, the device tests) through it, and [`audit`] every attempt of the canon and +//! bitcode-reader audit lanes. [`device`] is the other boundary: the //! engine candidate's device work runs in a child that the parent waits for without a deadline //! or a ceiling (the child bounds its own device waits), so a driver fault ends the child, not the //! tool. A translation worker whose attempt linked a module runs `spirv-val` in a fresh image of @@ -56,8 +58,9 @@ pub struct Measured { pub elapsed: Duration, /// The peak resident size up to the result or the stop: for a worker that exited, the larger /// of the sampled process-group RSS and the kernel's peak for the worker at its reap - /// ([`ProcessExit::peak_resident_bytes`]), so known for every reaped worker on unix; for a - /// stopped one, the sampled peak alone. + /// ([`ProcessExit::peak_resident_bytes`]), and for one that reported, of its own resident + /// high water as its report states it ([`report`]), so known for every worker that reported + /// on Linux and macOS; for a stopped one, the sampled peak alone. pub peak_resident_bytes: Option, /// The worker's counting-allocator peak ([`alloc::peak_bytes`]): the most live heap bytes it /// held at once, which the RSS sampler can miss. `None` when the worker reported no result @@ -73,11 +76,12 @@ impl Measured { } } -/// What a worker writes to stdout ([`report`]): its result and its counting allocator's process -/// peak. +/// What a worker writes to stdout ([`report`]): its result, its counting allocator's process +/// peak, and its own resident high water. #[derive(Serialize)] struct Report<'a, R> { allocator_peak_bytes: Option, + resident_peak_bytes: Option, result: &'a R, } @@ -85,27 +89,53 @@ struct Report<'a, R> { #[derive(Deserialize)] struct Reported { allocator_peak_bytes: Option, + resident_peak_bytes: Option, result: R, } -/// Write `result` to stdout as this worker's one report, with its counting allocator's process -/// peak ([`alloc::peak_bytes`]), for [`run_json`] to decode. Every worker child reports through -/// this, as its last act. -pub fn report(result: &R) -> Result<(), String> { - report_with_peak(result, alloc::peak_bytes()) +/// What a worker states of its own memory in its report: its counting allocator's process peak +/// ([`alloc::peak_bytes`]) and its resident high water ([`process::own_peak_resident_bytes`]). +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +struct Peaks { + allocator_peak_bytes: Option, + resident_peak_bytes: Option, } -/// [`report`] with the allocator peak `allocator_peak_bytes`: the L3 stage's, which states the -/// larger of the translation's and its own ([`l3::serve`]). -fn report_with_peak( - result: &R, - allocator_peak_bytes: Option, -) -> Result<(), String> { +impl Peaks { + /// This process's, now. + fn now() -> Peaks { + Peaks { + allocator_peak_bytes: alloc::peak_bytes(), + resident_peak_bytes: process::own_peak_resident_bytes(), + } + } + + /// The larger of each of `self`'s and `other`'s. + fn max(self, other: Peaks) -> Peaks { + Peaks { + allocator_peak_bytes: self.allocator_peak_bytes.max(other.allocator_peak_bytes), + resident_peak_bytes: self.resident_peak_bytes.max(other.resident_peak_bytes), + } + } +} + +/// Write `result` to stdout as this worker's one report, with its counting allocator's process +/// peak ([`alloc::peak_bytes`]) and its own resident high water +/// ([`process::own_peak_resident_bytes`]), for [`run_json`] to decode. Every worker child reports +/// through this, as its last act. +pub fn report(result: &R) -> Result<(), String> { + report_with_peaks(result, Peaks::now()) +} + +/// [`report`] with the peaks `peaks`: the L3 stage's, which states the larger of the +/// translation's and its own ([`l3::serve`]). +fn report_with_peaks(result: &R, peaks: Peaks) -> Result<(), String> { let mut stdout = std::io::stdout().lock(); serde_json::to_writer( &mut stdout, &Report { - allocator_peak_bytes, + allocator_peak_bytes: peaks.allocator_peak_bytes, + resident_peak_bytes: peaks.resident_peak_bytes, result, }, ) @@ -212,8 +242,9 @@ impl WorkerFailure { pub struct WorkerRun { pub result: R, /// The larger of the peak sampled process-group RSS (the worker and every descendant, e.g. - /// `spirv-val`, summed) and the kernel's peak for the worker alone at its reap - /// ([`ProcessExit::peak_resident_bytes`]). + /// `spirv-val`, summed), the kernel's peak for the worker alone at its reap + /// ([`ProcessExit::peak_resident_bytes`]), and the worker's own resident high water as its + /// report states it ([`report`]). pub peak_resident_bytes: Option, /// The worker's counting-allocator peak, as its report states it ([`report`]). pub allocator_peak_bytes: Option, @@ -301,25 +332,31 @@ pub fn run_json_within( measured(stop.peak_resident_bytes), ) })?; - let peak = exit.peak_resident_bytes; + let exited = exit.peak_resident_bytes; if !exit.status.success() { - return Err(WorkerFailure::Exit(single_line(&stderr()), measured(peak))); + return Err(WorkerFailure::Exit( + single_line(&stderr()), + measured(exited), + )); } let output = fs::read(&stdout_path).map_err(|error| { WorkerFailure::Output( format!("read {}: {error}", stdout_path.display()), - measured(peak), + measured(exited), ) })?; let Reported { allocator_peak_bytes, + resident_peak_bytes, result, } = serde_json::from_slice(&output).map_err(|error| { WorkerFailure::Output( format!("decode translation worker result: {error}"), - measured(peak), + measured(exited), ) })?; + // `None` orders below every `Some`. + let peak = exited.max(resident_peak_bytes); drop(scratch); control.check().map_err(|error| { WorkerFailure::Process( @@ -380,12 +417,15 @@ mod tests { assert_eq!(measured.peak_resident_bytes, run.peak_resident_bytes); } - /// A worker's report states its counting allocator's process peak, which survives the - /// round trip; a peak the sampler missed still sets the ceiling measure. + /// A worker's report states its counting allocator's process peak and its resident high + /// water, which survive the round trip; a peak the sampler missed still sets the ceiling + /// measure. #[test] fn a_report_carries_the_allocator_peak_and_it_bounds_the_ceiling_measure() { + let peaks = Peaks::now(); let bytes = serde_json::to_vec(&Report { - allocator_peak_bytes: alloc::peak_bytes(), + allocator_peak_bytes: peaks.allocator_peak_bytes, + resident_peak_bytes: peaks.resident_peak_bytes, result: &7u32, }) .unwrap(); @@ -393,6 +433,10 @@ mod tests { assert_eq!(reported.result, 7); // The lib's test binary installs the counting allocator (`alloc::tests`). assert!(reported.allocator_peak_bytes.is_some_and(|peak| peak > 0)); + if cfg!(any(target_os = "macos", target_os = "linux")) { + assert!(reported.resident_peak_bytes.is_some_and(|peak| peak > 0)); + } + assert_eq!(reported.resident_peak_bytes, peaks.resident_peak_bytes); let sampled_low = Measured { elapsed: Duration::ZERO, @@ -408,6 +452,30 @@ mod tests { assert_eq!(Measured::default().peak_bytes(), None); } + /// A worker that execs and exits between two of the sampler's ticks leaves no sample, and on + /// Linux the kernel's figure at its reap may be this supervisor's own high water, which is not + /// used (`process::own_kernel_peak`): the run's peak takes the high water the worker's report + /// states. + #[cfg(unix)] + #[test] + fn a_run_s_peak_takes_the_resident_high_water_its_report_states() { + // Far above anything `sh` holds and this process's own high water, so no sample and no + // kernel figure stands in for it. + let stated = 1u64 << 40; + let run: WorkerRun = run_json( + shell(&format!( + "echo '{{\"allocator_peak_bytes\": null, \"resident_peak_bytes\": {stated}, \ + \"result\": 7}}'" + )), + "worker-test", + |_| Ok(()), + ) + .unwrap(); + assert_eq!(run.result, 7); + assert_eq!(run.peak_resident_bytes, Some(stated)); + assert_eq!(run.measured().peak_bytes(), Some(stated)); + } + #[cfg(unix)] #[test] fn worker_failures_are_typed() { diff --git a/crates/metal2vulkan-validation/src/worker/l3.rs b/crates/metal2vulkan-validation/src/worker/l3.rs index 87044c2c9..9e843fb07 100644 --- a/crates/metal2vulkan-validation/src/worker/l3.rs +++ b/crates/metal2vulkan-validation/src/worker/l3.rs @@ -14,7 +14,8 @@ //! The stage keeps the worker's pid and process group, so the parent's deadline and memory //! sampling go on uninterrupted, runs `spirv-val` on the module's file without reading it //! ([`serve`]), folds L3's result into the attempt ([`crate::engine::Attempt::settle_l3`]), and -//! writes the worker's one report, its allocator peak the larger of the translation's and its own. +//! writes the worker's one report, its allocator peak and resident high water each the larger of +//! the translation's and its own. use crate::engine::{Attempt, L3Plan, PendingL3}; use serde::de::DeserializeOwned; @@ -28,8 +29,9 @@ pub const STAGE_ARG: &str = "--l3-stage"; /// What the translation hands the L3 stage, in the pending file. #[derive(Serialize, Deserialize)] struct Pending { - /// The translation's counting-allocator process peak ([`super::alloc::peak_bytes`]). - allocator_peak_bytes: Option, + /// The translation's counting-allocator process peak and resident high water + /// ([`super::Peaks::now`]), which the exec ends. + peaks: super::Peaks, /// The worker's result, its attempt as it stands if `spirv-val` accepts the module. result: R, plan: L3Plan, @@ -58,7 +60,7 @@ pub fn report_after_l3( std::fs::write(&words_path, bytes) .map_err(|error| format!("write {}: {error}", words_path.display()))?; let text = serde_json::to_vec(&Pending { - allocator_peak_bytes: super::alloc::peak_bytes(), + peaks: super::Peaks::now(), result, plan, words: words_path, @@ -88,7 +90,8 @@ pub fn report_after_l3( /// The L3 stage of a worker whose result is an `R`: read the pending file `pending`, run /// `spirv-val` on the module, fold its result into the attempt `attempt` finds in the result, and -/// [`super::report`] it, its allocator peak the larger of the translation's and this stage's. +/// [`super::report`] it, its allocator peak and resident high water each the larger of the +/// translation's and this stage's. pub fn serve( pending: &Path, attempt: impl FnOnce(&mut R) -> &mut Attempt, @@ -98,7 +101,7 @@ pub fn serve( std::fs::read(pending).map_err(|error| format!("read {}: {error}", pending.display()))?; let _ = std::fs::remove_file(pending); let Pending { - allocator_peak_bytes, + peaks, mut result, plan, words, @@ -109,8 +112,5 @@ pub fn serve( let checked = std::panic::catch_unwind(|| plan.check_file(&words)); let _ = std::fs::remove_file(&words); attempt(&mut result).settle_l3(checked); - super::report_with_peak( - &result, - allocator_peak_bytes.max(super::alloc::peak_bytes()), - ) + super::report_with_peaks(&result, peaks.max(super::Peaks::now())) } diff --git a/crates/metal2vulkan-validation/src/worker/process.rs b/crates/metal2vulkan-validation/src/worker/process.rs index 17649eebc..033bbf5fc 100644 --- a/crates/metal2vulkan-validation/src/worker/process.rs +++ b/crates/metal2vulkan-validation/src/worker/process.rs @@ -378,6 +378,32 @@ pub fn own_resident_bytes() -> Option { } } +/// The most this process has held resident since its image was installed; `None` where it cannot +/// be read. A worker states it in its report (`worker::report`): the parent's sampler misses a +/// worker that execs and exits between two samples, and on Linux the kernel's figure at the reap +/// may be the parent's own (`own_kernel_peak`), but the worker knows its own high water. On Linux +/// it is the image's own `VmHWM`, not `getrusage`'s `ru_maxrss`, which holds the spawner's high +/// water folded in at the exec; on macOS it is `ru_maxrss`, which is the process's own +/// (`member_resident_bytes`). +pub fn own_peak_resident_bytes() -> Option { + #[cfg(target_os = "linux")] + { + own_high_water_bytes() + } + #[cfg(target_os = "macos")] + { + let mut usage = std::mem::MaybeUninit::::zeroed(); + // SAFETY: `usage` is valid for the write, which a success makes. + let read = unsafe { libc::getrusage(libc::RUSAGE_SELF, usage.as_mut_ptr()) }; + // SAFETY: `getrusage` filled `usage` when it succeeded. + (read == 0).then(|| max_rss_bytes(unsafe { usage.assume_init() }.ru_maxrss)) + } + #[cfg(not(any(target_os = "macos", target_os = "linux")))] + { + None + } +} + /// A leader [`try_reap`] found exited. struct Reaped { status: ExitStatus, @@ -907,6 +933,45 @@ mod tests { ); } + /// Run as a worker by [`a_workers_own_high_water_is_its_images_alone`]: write this + /// process's [`own_peak_resident_bytes`] to the file the variable names. + #[cfg(any(target_os = "macos", target_os = "linux"))] + #[test] + fn own_peak_fixture() { + let Some(path) = std::env::var_os("M2V_TEST_OWN_PEAK_FILE") else { + return; + }; + let peak = own_peak_resident_bytes().unwrap_or(0); + fs::write(path, peak.to_string()).unwrap(); + } + + /// A worker's own high water ([`own_peak_resident_bytes`]) is its image's alone: spawned by a + /// supervisor that held 256 MiB, which on Linux the exec folds into the worker's `ru_maxrss` + /// (`own_kernel_peak`), it states less than that, and more than nothing. + #[cfg(any(target_os = "macos", target_os = "linux"))] + #[test] + fn a_workers_own_high_water_is_its_images_alone() { + const HELD: u64 = 256 * 1024 * 1024; + let mut held = vec![0u8; HELD as usize]; + for page in held.chunks_mut(4096) { + page[0] = 1; + } + std::hint::black_box(&held); + let scratch = crate::ScratchDir::new("process-test").unwrap(); + let path = scratch.path().join("peak"); + let status = Command::new(std::env::current_exe().unwrap()) + .args(["--exact", "worker::process::tests::own_peak_fixture"]) + .env("M2V_TEST_OWN_PEAK_FILE", &path) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() + .unwrap(); + drop(held); + assert!(status.success()); + let stated: u64 = fs::read_to_string(&path).unwrap().parse().unwrap(); + assert!(stated > 0 && stated < HELD, "{stated}"); + } + /// On Linux the kernel's figure for a reaped worker counts only above this process's own /// high water: at or below it, it may be this process's memory folded in at the exec. #[cfg(target_os = "linux")] diff --git a/crates/metal2vulkan/src/bind/replay/generated.rs b/crates/metal2vulkan/src/bind/replay/generated.rs index 560f981fd..c0f8ed078 100644 --- a/crates/metal2vulkan/src/bind/replay/generated.rs +++ b/crates/metal2vulkan/src/bind/replay/generated.rs @@ -37,7 +37,14 @@ //! it (`VK_PIPELINE_CREATE_2_INDIRECT_BINDABLE_BIT_EXT`), the first as the execution set's initial //! pipeline (bound before each execution) and the others written at their indices. The //! variants' descriptor sets are bound once: they are one set ([`GeneratedRefusal::Descriptors`] -//! otherwise). +//! otherwise). A consumer may preprocess the executions apart instead: the indirect commands +//! layout made with `VK_INDIRECT_COMMANDS_LAYOUT_USAGE_EXPLICIT_PREPROCESS_BIT_EXT`, after the +//! preprocess's barrier every execution's `vkCmdPreprocessGeneratedCommandsEXT` with the state it +//! runs with, a barrier, then each execution as above, preprocessed. The runtime does so where the +//! driver's own preprocessing after an execution goes wrong +//! ([`ImplicitPreprocessAfterExecutionSet`]). +//! +//! [`ImplicitPreprocessAfterExecutionSet`]: crate::error::RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet //! //! **Its output is K14c's.** Each command's regions select the same variant with the same push //! values and group count as K14c's arguments; only the schedule between barriers differs, and a diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 452865916..2b7a9181e 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 398; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 1181; +pub const RUNTIME_VERSION: u32 = 1183; /// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex, /// of the manifest, the build script, and exactly the files the crate roots' module tree compiles diff --git a/crates/metal2vulkan/src/error/mod.rs b/crates/metal2vulkan/src/error/mod.rs index 430b5d776..fa674f167 100644 --- a/crates/metal2vulkan/src/error/mod.rs +++ b/crates/metal2vulkan/src/error/mod.rs @@ -829,6 +829,13 @@ pub enum RuntimeDriverDefect { /// under [`RuntimeDriverDefect::MultisampledDepthStencilColourCopies`] (a kernel and draws, or /// a refusal), and their depths through the colour copies. MultisampledStencilColourCopies, + /// A `vkCmdExecuteGeneratedCommandsEXT` the driver preprocesses itself, recorded after an + /// execution whose execution set bound pipelines, runs that preprocessing with the shader the + /// earlier execution bound last rather than the driver's own, which then reads and writes + /// memory by the wrong arguments: the device faults or its queue hangs. Nothing is refused: + /// the runtime preprocesses every execution of an indirect command buffer's range apart + /// (`vkCmdPreprocessGeneratedCommandsEXT`) before the first of them runs. + ImplicitPreprocessAfterExecutionSet, } /// One device capability a refusal can name. diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 7e840a1ac..b8e543a2c 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -124,3 +124,17 @@ driver's. Each is open work. (as the legacy texture read and the AIR 2.7 and 2.8 forms are), decoded to the same operation and tested with a synthetic fixture; a declaration whose operands mean something else stays refused. It is not built. +- **A loop that Apple's MSL compiler folds into 33-bit arithmetic fails to make on MoltenVK.** + Apple's MSL front end (Metal compiler 32023.921) can rewrite a loop that sums its counter + (`1 + 2 + ... + n`) into a closed form computed in 33-bit integers (`zext i32` to `i33`, + `mul i33`, `lshr i33`). Where that form lands in the kernel's constant program, the M3 Max's back + end (`applegpu_g15s`) cannot legalize the 33-bit zero extension ("unable to legalize + instruction ... (s33)", in `agc.main.constant_program`). Metal's compiler service then ends, + and MoltenVK fails the pipeline's making (`VK_ERROR_INITIALIZATION_FAILED`, + `XPC_ERROR_CONNECTION_INTERRUPTED`). The runtime returns that failure: a dispatch's command + buffer completes with `CommandBufferError::PipelineCreation`, and an indirect command's commit + returns `Error::Vulkan`. Hand-written MSL of the same loop fails the same way on Metal. The AIR + Metal compiles directly gets no such rewrite, and runs. Measured on the committed case + `authored-four-iteration-loop`: offline with `xcrun metal` and `metal-tt -arch applegpu_g15s`, + and in the runtime lane on an M3 Max with macOS 26.7. No form of the loop is known that avoids + the rewrite for every such loop, so it is not built. diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index fd89664a8..7d5835fe0 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -14,7 +14,7 @@ Columns: - `none`: no public API path: malformed or non-Metal input, Apple-private calls, or a cap no valid program of ordinary size meets; - `?`: not assessed yet. -Generated at `6cc8b0870`. +Generated at `ecb80e019`. ## Totals @@ -145,7 +145,7 @@ Generated at `6cc8b0870`. | `SparseMapping` | A sparse texture's mapping update (`updateTextureMapping:` and its array form, or a move of mappings) that covers part of one of the device's... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:466` | `rare`: sparse mappings off the device's blocks | | `TimelineSemaphores` | Command buffers and events, which the runtime completes and signals through timeline semaphores (core in Vulkan 1.2), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/device/create.rs:1014` | `none`: a device below the runtime's floor | | `Reflection` | Reflection of an argument whose answer Metal's has not been measured for (`reflection`) | every device (not implemented) | 9: `crates/metal2vulkan/src/bind/argument_buffer.rs:628`, `crates/metal2vulkan/src/reflection/derive.rs:179` (+7) | `rare`: reflection of argument kinds Metal's answer is unmeasured for | -| `HeapTextureTiling` | A texture of a heap whose memory the device's optimal images do not take (a `Shared` heap on a device whose optimal images take no host-visible... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:546` | `app`: textures in Shared heaps on a device whose optimal images take no host memory | +| `HeapTextureTiling` | A texture of a heap whose memory the device's optimal images do not take (a `Shared` heap on a device whose optimal images take no host-visible... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:548` | `app`: textures in Shared heaps on a device whose optimal images take no host memory | | `ViewportDepthRange` | A viewport depth range past `[0, 1]` (`setViewport:`), which Metal takes and the runtime draws natively (`VK_EXT_depth_range_unrestricted`) or... | drivers with a defect | 1: `crates/metal2vulkan-runtime/src/render_state.rs:1035` | `rare`: viewport depth outside [0, 1] | | `UndeclaredTextureUsage` | A shader write to a texture made without `ShaderWrite` (or `ShaderAtomic`), or a read of one made without `ShaderRead`, which plain Metal runs,... | every device (not implemented) | 2: `crates/metal2vulkan-runtime/src/binding_view.rs:141`, `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:61` | `app`: a shader write to a texture made without ShaderWrite, which plain Metal runs | | `RenderTargetSize` | A render pass whose render area or layers are past the device's framebuffer limits (`Capability::Limit` names `MaxFramebufferWidth`,... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/render_pass.rs:1166` | `rare`: a render area past a device's framebuffer limits | @@ -167,8 +167,8 @@ Generated at `6cc8b0870`. | `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458`, `crates/metal2vulkan-runtime/src/texture.rs:1476` (+1) | `rare`: sparse heaps | | `SparseTileMaps` | What the runtime's emulation of sparse textures does not build yet | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/binding.rs:428`, `crates/metal2vulkan-runtime/src/sparse/texture.rs:30` (+1) | `rare`: sparse texture emulation's unbuilt pieces | | `HeapPastMaxBufferSize` | A heap larger than the device's `maxBufferSize`, which the device can allocate | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/heap.rs:689` | `rare`: a heap past maxBufferSize | -| `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (256 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:954` | `rare`: a heap texture needing more than 256 KiB alignment | -| `HeapTextureMemory` | A heap texture whose image the heap's memory type does not take | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/texture/heap.rs:1277`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1284` (+3) | `app`: a heap texture the heap's memory type does not take | +| `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (256 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:956` | `rare`: a heap texture needing more than 256 KiB alignment | +| `HeapTextureMemory` | A heap texture whose image the heap's memory type does not take | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/texture/heap.rs:1279`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1286` (+3) | `app`: a heap texture the heap's memory type does not take | | `FunctionTablePastMaxBufferLength` | A visible-function table of more entries than one buffer of the device's `max_buffer_length` holds words for, or than its size word holds | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/function_table.rs:628` | `none`: a function table past one buffer | | `IndirectCommandBufferPastMaxBufferLength` | An indirect command buffer of more commands than one buffer of the device's `max_buffer_length` holds the records of | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:522` | `none`: an ICB past one buffer | | `IndirectRenderCommands` | What indirect command buffers lack of their render commands | every device (runtime piece not built) | 16: `crates/metal2vulkan-runtime/src/compute.rs:1026`, `crates/metal2vulkan-runtime/src/compute.rs:1076` (+14) | `rare`: indirect render commands' remaining pieces | @@ -215,12 +215,12 @@ Generated at `6cc8b0870`. | `LibrarySource` | A library compiled from Metal Shading Language source | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:107` | `app`: a library compiled from Metal source (newLibraryWithSource:); the runtime takes metallibs and AIR | | `RestartedStrip` | An indexed strip after `set_primitive_restart_enabled` with an index Vulkan does not restart at, which the runtime draws as a list an index... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/index_rewrite.rs:109`, `crates/metal2vulkan-runtime/src/render.rs:5912` | `none`: a strip after the Apple-private setPrimitiveRestartEnabled:index: whose rewrite pass cannot run as Metal draws | | `RotatedTexture` | A rotated texture (`TextureDescriptor::rotation`) where the runtime does not build what Metal does | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:1521`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:706` (+7) | `rare`: a rotated drawable's views, blits with images over overlapping rows, rows past its buffer | -| `DetachTextures` | A texture over a no-copy buffer's or heap's bytes (a heap's texture, or a texture over the buffer or over one of the heap's buffers) that no... | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/buffer.rs:1999`, `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:572` (+7) | `none`: a runtime extension's detach with a texture no stand-in presents exactly | +| `DetachTextures` | A texture over a no-copy buffer's or heap's bytes (a heap's texture, or a texture over the buffer or over one of the heap's buffers) that no... | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/buffer.rs:2012`, `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:572` (+7) | `none`: a runtime extension's detach with a texture no stand-in presents exactly | | `TextureBufferLevels` | A texture buffer of more than one level (`TextureDescriptor::mipmap_level_count`, up to its width's full chain) from the device's, a heap's or the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:531` | `rare`: a texture buffer of more than one level (public, unusual) | | `WriteSwizzle` | A texture of `TextureDescriptor::write_swizzle_enabled` whose swizzle is not the default, with `ShaderWrite` or `RenderTarget` usage, from the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:538` | `none`: Apple-private writeSwizzleEnabled with a swizzle that writes | | `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4767` | `none`: CPU texel access while a runtime extension detached the bytes | | `SurfaceDepthStencil` | A use of a texture of a depth or stencil format (`Depth16Unorm`, `Depth32Float`, `Depth32Float_Stencil8`, `Stencil8`, `X32_Stencil8`) over a plane... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:232`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:56` | `rare`: a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 | -| `HostHeapUncompressedMultisample` | A multisample texture in a heap over host pages (`Device::new_heap_with_bytes_no_copy`) that Metal keeps uncompressed | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1732` | `none`: a multisample texture Metal keeps uncompressed in a runtime extension's heap over host pages | +| `HostHeapUncompressedMultisample` | A multisample texture in a heap over host pages (`Device::new_heap_with_bytes_no_copy`) that Metal keeps uncompressed | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1734` | `none`: a multisample texture Metal keeps uncompressed in a runtime extension's heap over host pages | | `PredicationUnbalanced` | An unbalanced command-predication record (`ComputeCommandEncoder::encode_end_if` and the other ends, or `encode_start_else`, with no block open;... | every device (runtime piece not built) | 4: `crates/metal2vulkan-runtime/src/predication.rs:354`, `crates/metal2vulkan-runtime/src/predication.rs:386` (+2) | `none`: an unbalanced Apple-private command-predication record, whose dropped work Metal decides by no rule measured | | `PredicationOpenAtUnitEnd` | A command buffer one of whose units of predication ended with an If still open that no misused record killed, refused at `CommandBuffer::commit` | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/predication.rs:279` | `none`: an Apple-private predication If left open, live, where its unit ends | | `PredicationWordPastBuffer` | A predication condition word (`encode_start_if`'s offset, rounded down to a multiple of 4) past its buffer's end | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/predication.rs:139` | `none`: an Apple-private predication condition word past its buffer | @@ -331,7 +331,7 @@ Each refusal's sites, with the function that builds it. - `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs:575 (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs:2890 (patch_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:2936 (patch_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:2965 (patch_draw)`; `crates/metal2vulkan/src/bind/instantiate.rs:578 (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs:226 (select)`; `crates/metal2vulkan/src/lower/access/mod.rs:1155 (place_slots)` - `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs:582 (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs:1117 (selector_form)` - `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs:230 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs:587 (check_scalar)` -- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:455 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:469 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:526 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:1997 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:512 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:576 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:608 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:841 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:345 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:525 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1555 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1640 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:228 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:272 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:292 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:307 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:365 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:404 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:486 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:520 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:534 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:516 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:628 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:713 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:826 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:5267 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1259 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1578 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1657 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:926 (check_target)`; `crates/metal2vulkan-runtime/src/resolve.rs:387 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:295 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:352 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:359 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:1833 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3644 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1623 (new_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:79 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:275 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:378 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:115 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:359 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:372 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:379 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:389 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:399 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:271 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1705 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:192 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:953 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/unused_bits.rs:545 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:154 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1299 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1325 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:680 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:701 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:707 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:713 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:738 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:857 (plan)`; `crates/metal2vulkan/src/lower/sampler/select.rs:716 (texel_in)`; `crates/metal2vulkan/src/lower/sampler/select.rs:999 (select_extended)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1795 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:776 (zeroed_output)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2279 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2893 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3065 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3235 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3272 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3596 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1015 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1027 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1033 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:733 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:736 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:747 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:761 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:778 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:802 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:813 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:853 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:888 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:897 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1500 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1502 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1545 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2475 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2493 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2501 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2573 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:345 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:453 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:830 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:847 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:956 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:450 (rotated_blend)` +- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:455 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:469 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:526 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:1997 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:512 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:576 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:608 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:841 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:345 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:525 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1555 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1640 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:228 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:272 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:292 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:307 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:365 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:404 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:486 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:520 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:534 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:516 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:628 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:713 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:826 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:5267 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1259 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1578 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1657 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:926 (check_target)`; `crates/metal2vulkan-runtime/src/resolve.rs:387 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:295 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:352 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:359 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:1833 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3644 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1625 (new_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:79 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:275 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:378 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:115 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:359 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:372 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:379 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:389 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:399 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:271 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1705 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:192 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:953 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/unused_bits.rs:545 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:154 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1299 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1325 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:680 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:701 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:707 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:713 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:738 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:857 (plan)`; `crates/metal2vulkan/src/lower/sampler/select.rs:716 (texel_in)`; `crates/metal2vulkan/src/lower/sampler/select.rs:999 (select_extended)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1795 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:776 (zeroed_output)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2279 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2893 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3065 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3235 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3272 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3596 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1015 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1027 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1033 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:733 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:736 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:747 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:761 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:778 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:802 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:813 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:853 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:888 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:897 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1500 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1502 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1545 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2475 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2493 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2501 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2573 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:345 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:453 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:830 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:847 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:956 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:450 (rotated_blend)` - `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs:377 (select_sampling)` - `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:136 (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs:254 (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs:280 (query_min_level)` - `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs:1311 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:891 (min_lod)` @@ -408,7 +408,7 @@ Each refusal's sites, with the function that builds it. - `feature::SparseMapping`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:466 (splits_a_unit)` - `feature::TimelineSemaphores`: `crates/metal2vulkan-runtime/src/device/create.rs:1014 (timeline_difference)` - `feature::Reflection`: `crates/metal2vulkan/src/bind/argument_buffer.rs:628 (unmeasured)`; `crates/metal2vulkan/src/reflection/derive.rs:179 (specialized_reads)`; `crates/metal2vulkan/src/reflection/derive.rs:213 (read_attributes)`; `crates/metal2vulkan/src/reflection/derive.rs:240 (gap_at)`; `crates/metal2vulkan/src/reflection/function.rs:172 (unmeasured)`; `crates/metal2vulkan/src/reflection/function.rs:366 (attribute)`; `crates/metal2vulkan/src/reflection/function.rs:437 (module_constants)`; `crates/metal2vulkan/src/reflection/linked.rs:127 (function)`; `crates/metal2vulkan/src/reflection/mod.rs:249 (stage)` -- `feature::HeapTextureTiling`: `crates/metal2vulkan-runtime/src/texture/heap.rs:546 (tiling_refusal)` +- `feature::HeapTextureTiling`: `crates/metal2vulkan-runtime/src/texture/heap.rs:548 (tiling_refusal)` - `feature::ViewportDepthRange`: `crates/metal2vulkan-runtime/src/render_state.rs:1035 (depth_ranges_refused)` - `feature::UndeclaredTextureUsage`: `crates/metal2vulkan-runtime/src/binding_view.rs:141 (binding_view)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:61 (refused)` - `feature::RenderTargetSize`: `crates/metal2vulkan-runtime/src/render_pass.rs:1166 (framebuffer_fits)` @@ -425,8 +425,8 @@ Each refusal's sites, with the function that builds it. - `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1476 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4697 (make_aliasable)` - `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:428 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1501 (plan_sparse_texture)` - `gap::HeapPastMaxBufferSize`: `crates/metal2vulkan-runtime/src/heap.rs:689 (heap_size)` -- `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:954 (check_heap_base)` -- `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1277 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1284 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1727 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1940 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:473 (memory_refusal)` +- `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:956 (check_heap_base)` +- `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1279 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1286 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1729 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1942 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:475 (memory_refusal)` - `gap::FunctionTablePastMaxBufferLength`: `crates/metal2vulkan-runtime/src/function_table.rs:628 (past_limit)` - `gap::IndirectCommandBufferPastMaxBufferLength`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:522 (new_indirect_command_buffer)` - `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1026 (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/compute.rs:1076 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3495 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:517 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1413 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:5737 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6027 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6306 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6668 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1773 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2438 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:361 (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render/executions.rs:419 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/render/executions.rs:432 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/render/executions.rs:876 (back_memoryless)` @@ -465,7 +465,7 @@ Each refusal's sites, with the function that builds it. - `gap::LayeredPass`: `crates/metal2vulkan-runtime/src/color_resolve.rs:517 (plan)` - `gap::FunctionOptions`: `crates/metal2vulkan-runtime/src/library.rs:215 (new_function_with_descriptor)` - `gap::OverlappingTextureCopies`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1205 (texture_copies_of_bytes)` -- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:567 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture.rs:2696 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2712 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2732 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2746 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2817 (dma_buf_images_again)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2230 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2245 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2256 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2302 (dma_buf_heap_images_again)` +- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:567 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture.rs:2696 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2712 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2732 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2746 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2817 (dma_buf_images_again)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2232 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2247 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2258 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2304 (dma_buf_heap_images_again)` - `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5473 (host_copy)` - `gap::VertexFetchPast4GiB`: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72 (check_vertex_reach)` - `gap::StageInFetchPast4GiB`: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126 (check_stage_in_reach)` @@ -473,12 +473,12 @@ Each refusal's sites, with the function that builds it. - `gap::LibrarySource`: `crates/metal2vulkan-runtime/src/library.rs:107 (new_library_with_source)` - `gap::RestartedStrip`: `crates/metal2vulkan-runtime/src/index_rewrite.rs:109 (new)`; `crates/metal2vulkan-runtime/src/render.rs:5912 (draw_resident)` - `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1521 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:706 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:184 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:200 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:346 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:4937 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:102 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:317 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:188 (new_usage_shadow)` -- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer.rs:1999 (pages_base)`; `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:572 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:616 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:144 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2434 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:297 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:303 (stand_ins)` +- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer.rs:2012 (pages_base)`; `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:572 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:616 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:144 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2436 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:297 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:303 (stand_ins)` - `gap::TextureBufferLevels`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:531 (check_made)` - `gap::WriteSwizzle`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:538 (check_made)` - `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4767 (refuse_detached_texels)` - `gap::SurfaceDepthStencil`: `crates/metal2vulkan-runtime/src/blit_texture.rs:232 (unit)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:56 (surface_depth_twin)` -- `gap::HostHeapUncompressedMultisample`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1732 (host_heap_plan)` +- `gap::HostHeapUncompressedMultisample`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1734 (host_heap_plan)` - `gap::PredicationUnbalanced`: `crates/metal2vulkan-runtime/src/predication.rs:354 (nil)`; `crates/metal2vulkan-runtime/src/predication.rs:386 (start_else)`; `crates/metal2vulkan-runtime/src/predication.rs:438 (end_if)`; `crates/metal2vulkan-runtime/src/predication.rs:558 (end_loop)` - `gap::PredicationOpenAtUnitEnd`: `crates/metal2vulkan-runtime/src/predication.rs:279 (commit)` - `gap::PredicationWordPastBuffer`: `crates/metal2vulkan-runtime/src/predication.rs:139 (new)` diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index d83507961..17c43c1bc 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -179,7 +179,7 @@ worker under the 20-second and 500-MiB ceilings, resumable in bounded batches (` | `translation --profile P...` | Each row translated for each committed profile, recorded as a typed outcome class under the current product fingerprint (`--current-fingerprint`, `--retry-failures`, `--hash-file PATH` select rows). It fails when a row breaks a ceiling | | `budgets --profile P...` | The budget gates from recorded rows: no row above 20 s or 500 MiB, no stopped worker, and each row's ledger peak at least 0.7 of its allocator peak | | `specialization --profile P...` | Rows translated under planned function-constant value sets and the pipeline inputs their AIR states, not only with none | -| `authored-compile [--bless \| --bless-additions \| --case ID]` | Every committed authored case compiled, with the requests its executor builds, on each profile and leg of `corpus/authored-compile.tsv`; it fails on any changed cell. The table is re-blessed on `master` | +| `authored-compile [--bless \| --bless-additions \| --case ID]` | Every committed authored case compiled, with the requests its executor builds, on each profile and leg of `corpus/authored-compile.tsv`; it fails on any changed cell. The table is re-blessed on `development` | | `bitcode-reader` | The bitcode reader's decode compared with `llvm-dis`, and the intrinsic census | | focused audits (`rasterization-rate-maps`, `sample-rate`, `ulong-textures`, `fragment-varyings`, `linked-functions`) | One structural family, selected by current facts, translated in batches |