Record a submission's first work and its staged copies in one command buffer
The steps this packet landed as, in order: - Choose whether batches may group by the driver's fact, not by its name - Re-bless the driver-facts goldens for the submission-merge fact - Decide whether a queue's failures are relayed by the driver's fact, not its name Content: the tree of `development` at 94416b2c77, unchanged.
This commit is contained in:
1 parent
b2d385e461
commit
4490daffbd
12 files changed
+370
-123
No files matched your search
@@ -1,12 +1,13 @@
|
||||
//! Batches that go to the driver in one kernel submission (`CompletionPolicy::Grouped`).
|
||||
//!
|
||||
//! On a driver whose queue is Mesa's common one, each `vkQueueSubmit`'s `VkSubmitInfo`s that
|
||||
//! signal nothing merge into the next one's kernel submission (Mesa 26.2.4,
|
||||
//! `vulkan/runtime/vk_queue.c`, `vk_queue_submits_merge`: "Don't merge if there are signals in
|
||||
//! between"), and ANV chains the merged command buffers into one batch buffer
|
||||
//! (`anv_queue_submit_cmd_buffers_locked`). Each kernel submission costs CPU time for every
|
||||
//! `VkDeviceMemory` of the device: ANV on i915 lists each in every execbuffer
|
||||
//! (`i915/anv_batch_chain.c`, `setup_execbuf_for_cmd_buffers`), RADV each in every CS.
|
||||
//! On a driver measured to merge each `vkQueueSubmit`'s `VkSubmitInfo`s that signal nothing into
|
||||
//! the next one's kernel submission ([`DriverFact::SubmissionsWithoutSignalsMerge`], whose
|
||||
//! documentation holds what was measured where), batches that signal nothing but their queue's
|
||||
//! timeline may wait and go in one call for the cost of one kernel submission. The question is
|
||||
//! the driver's, and the fact answers it, never the driver's name: a driver without the fact
|
||||
//! takes the ungrouped path, each batch its own `vkQueueSubmit`, which is what every batch took
|
||||
//! before grouping and is exact alike -- a group changes when a `vkQueueSubmit` is made and
|
||||
//! nothing it submits.
|
||||
//!
|
||||
//! - **What waits.** A batch the scheduler submits waits here, submitted by nothing yet, where it
|
||||
//! signals nothing but its queue's timeline and its events' semaphores: no binary semaphore,
|
||||
@@ -87,8 +88,8 @@ use crate::exit_guard::{self, Call};
|
||||
use crate::gpu_time;
|
||||
use crate::Device;
|
||||
use ash::vk;
|
||||
use metal2vulkan::device::CompletionPolicy;
|
||||
use metal2vulkan::vk::DriverId;
|
||||
use metal2vulkan::device::{CompletionPolicy, DriverFact};
|
||||
use std::collections::BTreeSet;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -104,11 +105,12 @@ const BATCH_INFOS: usize = 2;
|
||||
const MOST_INFOS: usize = GROUP_BATCHES * BATCH_INFOS + 1 + BATCH_INFOS;
|
||||
|
||||
/// Whether `device`'s batches on `VkQueue` `queue` may wait in a group: its policy groups them,
|
||||
/// its driver merges a submission that signals nothing into the next (the module docs), and the
|
||||
/// queue's failures are not relayed (each relayed batch takes a fence, `device/relay.rs`).
|
||||
/// its driver is measured to merge a submission that signals nothing into the next (the module
|
||||
/// docs), and the queue's failures are not relayed (each relayed batch takes a fence,
|
||||
/// `device/relay.rs`).
|
||||
pub(crate) fn groups(device: &Device, queue: usize) -> bool {
|
||||
device.compile_device().policy().completion == CompletionPolicy::Grouped
|
||||
&& merges_submissions(device.properties().description.driver_id)
|
||||
&& merges_submissions(&device.properties().driver_facts)
|
||||
&& device.shared().flights(queue).is_none()
|
||||
}
|
||||
|
||||
@@ -151,23 +153,12 @@ const IN_GROUP: u8 = 1;
|
||||
/// A command buffer's `group_hold` bit: a thread waits for its completion.
|
||||
const WAITED_FOR: u8 = 2;
|
||||
|
||||
/// Whether the driver's queue is Mesa's common one with kernel submissions of their own: the
|
||||
/// drivers that merge a `VkSubmitInfo` that signals nothing into the next.
|
||||
fn merges_submissions(driver: Option<DriverId>) -> bool {
|
||||
matches!(
|
||||
driver,
|
||||
Some(
|
||||
DriverId::MESA_RADV
|
||||
| DriverId::INTEL_OPEN_SOURCE_MESA
|
||||
| DriverId::MESA_LLVMPIPE
|
||||
| DriverId::MESA_TURNIP
|
||||
| DriverId::MESA_V3DV
|
||||
| DriverId::MESA_PANVK
|
||||
| DriverId::MESA_NVK
|
||||
| DriverId::MESA_HONEYKRISP
|
||||
| DriverId::IMAGINATION_OPEN_SOURCE_MESA
|
||||
)
|
||||
)
|
||||
/// Whether the driver merges a `VkSubmitInfo` that signals nothing into the next one's kernel
|
||||
/// submission ([`DriverFact::SubmissionsWithoutSignalsMerge`]): the driver's facts alone answer
|
||||
/// it, and nothing of the driver's identity, so a test can hand it the facts of each committed
|
||||
/// profile (`tests::batches::only_drivers_measured_to_merge_their_submissions_group_their_batches`).
|
||||
pub(crate) fn merges_submissions(facts: &BTreeSet<DriverFact>) -> bool {
|
||||
facts.contains(&DriverFact::SubmissionsWithoutSignalsMerge)
|
||||
}
|
||||
|
||||
/// What sent a group held (`WorkCounts::group_ends_full` and kin).
|
||||
|
||||
@@ -50,6 +50,11 @@ mod submit;
|
||||
|
||||
pub(super) use completion::Completion;
|
||||
pub(super) use first_submission::{NotedTable, ReplayTable};
|
||||
/// Whether a driver's facts merge a submission that signals nothing into the next, for the test
|
||||
/// that holds every committed profile to the fact
|
||||
/// (`tests::batches::only_drivers_measured_to_merge_their_submissions_group_their_batches`).
|
||||
#[cfg(test)]
|
||||
pub(crate) use group::merges_submissions;
|
||||
pub(super) use group::{Group, GroupEnd, GROUP_BATCHES};
|
||||
use rebound_use::{ReboundUse, Unlogged};
|
||||
pub(super) use submit::{BatchLists, Submitting};
|
||||
|
||||
@@ -115,8 +115,10 @@
|
||||
//! of the batch, whether a use names the resource or not (a command may reach a texture through its
|
||||
//! resource ID, a buffer through its address), and the batch holds what it worked on until it
|
||||
//! completes. On a device of several `VkQueue`s every batch on another one waits for it until it
|
||||
//! completed. It is a command buffer of its own, first in the batch's work's `VkSubmitInfo` (in
|
||||
//! a batch with no work, its end's), so it waits for what the work waits for: Vulkan's
|
||||
//! completed. It is recorded first in the command buffer that leads the batch's work's
|
||||
//! `VkSubmitInfo` (in a batch with no work, its end's) -- its own, or, where the batch also has
|
||||
//! host calls' staged copies, the one that holds the copies after it -- so it waits for what the
|
||||
//! work waits for: Vulkan's
|
||||
//! submission order puts it before every command of the batch ("the order in which command
|
||||
//! buffers are specified in the pCommandBuffers member of VkSubmitInfo ... determines their
|
||||
//! submission order", the Vulkan specification, Submission Order), and its last barrier,
|
||||
@@ -681,26 +683,47 @@ impl CommandBufferShared {
|
||||
work.extend(&state.recorded[start + offset].raws);
|
||||
}
|
||||
// The first work goes first in the batch's work, or in a batch with no work in its end
|
||||
// (the module docs). Host calls' staged copies go at the batch's start, after it.
|
||||
let lead = match first_work.has_first() {
|
||||
true => Some(self.record_raw(&mut state, |_, buffer| {
|
||||
// SAFETY: the command buffer is recording, outside a render pass; it is
|
||||
// submitted first in the batch, before any later one, and every batch on
|
||||
// another `VkQueue` waits for the batch (`FirstMoves::waits`).
|
||||
unsafe { first_work.record(raw, buffer, shared.queue_flags_of(queue)) };
|
||||
Ok(())
|
||||
})?),
|
||||
false => None,
|
||||
// (the module docs). Host calls' staged copies go at the batch's start, after it, in the
|
||||
// same command buffer: the two went in two command buffers of one `VkSubmitInfo`, which
|
||||
// puts them in the same submission order one command buffer's recording order does ("the
|
||||
// order in which command buffers are specified in the pCommandBuffers member of
|
||||
// VkSubmitInfo ... determines their submission order", the Vulkan specification,
|
||||
// Submission Order; inside one command buffer, the order they were recorded), and a
|
||||
// command buffer boundary is no dependency of its own, so the copies' own leading barrier
|
||||
// (`FirstMoves::record_staged`) covers the moves recorded before it either way. One
|
||||
// command buffer where the batch has both (counted:
|
||||
// `WorkCounts::command_buffers_begun_batch_work`).
|
||||
let has_first = first_work.has_first();
|
||||
let has_staged = first_work.has_staged();
|
||||
let recorded = (has_first || has_staged)
|
||||
.then(|| {
|
||||
self.record_raw(&mut state, |_, buffer| {
|
||||
if has_first {
|
||||
// SAFETY: the command buffer is recording, outside a render pass; it is
|
||||
// submitted first in the batch, before any later one, and every batch on
|
||||
// another `VkQueue` waits for the batch (`FirstMoves::waits`).
|
||||
unsafe { first_work.record(raw, buffer, shared.queue_flags_of(queue)) };
|
||||
}
|
||||
if has_staged {
|
||||
// SAFETY: the command buffer is recording, outside a render pass; every
|
||||
// image's move is in this command buffer, before it, or a submission
|
||||
// before.
|
||||
unsafe { first_work.record_staged(raw, buffer) };
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
})
|
||||
.transpose()?;
|
||||
// Where it holds staged copies it goes at the batch's start, as they did, so the batch
|
||||
// has work; the first work alone goes first in the work, or in the end where the batch
|
||||
// has none (below).
|
||||
let lead = match has_staged {
|
||||
true => {
|
||||
work.insert(0, recorded.expect("recorded where there are staged copies"));
|
||||
None
|
||||
}
|
||||
false => recorded,
|
||||
};
|
||||
if first_work.has_staged() {
|
||||
let staged = self.record_raw(&mut state, |_, buffer| {
|
||||
// SAFETY: the command buffer is recording, outside a render pass; every image's
|
||||
// move is in the first work's command buffer, before it, or a submission before.
|
||||
unsafe { first_work.record_staged(raw, buffer) };
|
||||
Ok(())
|
||||
})?;
|
||||
work.insert(0, staged);
|
||||
}
|
||||
let BatchWaits {
|
||||
semaphores: wait_semaphores,
|
||||
values: wait_values,
|
||||
|
||||
Reference in new issue
Block a user