Twice on an RTX 3090 a command buffer failed with VkResult -13 and nothing said what its submission held. Every vkQueueSubmit of the runtime's that fails now logs one warning (id name metal2vulkan-submit-failed) through the device's sink, else on stderr: the VkResult, the VkQueue and what submitted; each VkSubmitInfo's waits, VkCommandBuffers and signals, each semaphore by its role with its value and the timeline's value read after the failure (flagged where a signal is not above it, VUID-VkSubmitInfo-pSignalSemaphores-03242, or a value lies past the least maxTimelineSemaphoreValueDifference, -03243/-03244); each VkCommandBuffer by its role (an encoder's, barriers, kept barriers submitted again, first work, end); the Metal command buffers by id and label; and the resources their encoders name, as what owns their memory, with size, storage mode, memory type and flags, no-copy import kind and whether it is released now, detached or gone, and age in the device's submissions since it was made. Bounded: 8 infos, 8 waits and 8 signals each, 32 VkCommandBuffers, 8 command buffers, 32 resources, each list counting the rest. Nothing is read on the success path: the line is built only in each call's error branch, and it reads under its submitter's locks without waiting for any lock another thread may hold (try_lock), but the two resource registries a batch's submission already locks. A recording that fails also fails its command buffer with a raw VkResult (VK_ERROR_UNKNOWN for the runtime's own error, which the command buffer's error drops): recording_error now logs that error (id name metal2vulkan-recording-failed), so a raw -13 says which of the two it was. Tests: tests/submit_failure.rs (an info's lists read back from its chain; the line's words, flags and bounds), tests/submit_failure_device.rs (a blit's batch failed by the test hook as VK_ERROR_UNKNOWN: one warning naming the result, the label, the encoder, the queue's timeline and the buffer with its age).
72 lines
2.9 KiB
Rust
72 lines
2.9 KiB
Rust
//! What a command buffer's batches carried into a `vkQueueSubmit` that failed, for the line it
|
|
//! logs (`submit_failure.rs`): the command buffer as the runtime's notices name it, and the
|
|
//! resources its encoders' uses name and what they made resident, each as what owns its memory
|
|
//! (`used_resources.rs`). Read only once the call failed, under the locks its submitter holds.
|
|
|
|
use super::{CommandBufferShared, State};
|
|
use crate::submit_failure::{Carried, TypeFlags};
|
|
use crate::used_resources::{failure_facts, resident_keys};
|
|
use std::collections::BTreeSet;
|
|
use std::fmt::Write;
|
|
use std::ops::Range;
|
|
|
|
impl CommandBufferShared {
|
|
/// Add the command buffer, `state` its state, to `carried`: named by its identity and as the
|
|
/// runtime's notices name it, with its batch `index` where given; the role of each
|
|
/// `VkCommandBuffer` of the encoders it recorded at `encoders` (every one it recorded where
|
|
/// that is `None`); and the resources those encoders name, or, where it is `None`, every ended
|
|
/// encoder of it, stated with `types`' flags for their memory types.
|
|
pub(crate) fn carry(
|
|
&self,
|
|
state: &State,
|
|
(index, encoders): (Option<usize>, Option<Range<usize>>),
|
|
carried: &mut Carried,
|
|
types: &TypeFlags,
|
|
) {
|
|
let queue = self.queue.label();
|
|
let mut named = format!("#{} {}", self.id.get(), state.named(queue.as_deref()));
|
|
if let Some(index) = index {
|
|
let batches = state.batches.all().len();
|
|
let _ = write!(named, ", its batch {index} of {batches}");
|
|
}
|
|
carried.buffers.push(named);
|
|
let recorded = match &encoders {
|
|
Some(encoders) => &state.recorded[encoders.clone()],
|
|
None => &state.recorded[..],
|
|
};
|
|
let mut keys = BTreeSet::new();
|
|
for part in recorded {
|
|
let kind = match state.ended.get(part.encoder) {
|
|
Some(record) => format!("{:?}", record.kind),
|
|
None => "open".to_owned(),
|
|
};
|
|
let role = format!("encoder {} {kind} of #{}", part.encoder, self.id.get());
|
|
carried
|
|
.roles
|
|
.extend(part.raws.iter().map(|&raw| (raw, role.clone())));
|
|
if encoders.is_some() {
|
|
keys.extend(part.summary.keys());
|
|
}
|
|
}
|
|
let ended = match encoders {
|
|
Some(_) => (recorded.iter())
|
|
.filter_map(|part| state.ended.get(part.encoder))
|
|
.collect(),
|
|
None => state.ended.iter().collect::<Vec<_>>(),
|
|
};
|
|
for record in ended {
|
|
keys.extend(&record.keys);
|
|
if let Some(residency) = &record.residency {
|
|
resident_keys(residency, &mut keys);
|
|
}
|
|
}
|
|
let shared = self.device.shared();
|
|
failure_facts(
|
|
shared,
|
|
&keys,
|
|
types,
|
|
(&mut carried.resources, &mut carried.stated),
|
|
);
|
|
}
|
|
}
|