rt: an execution over a range the GPU writes counts its parts with a kernel; parts bounded at 2 MiB of preprocess bytes
What: an execution of an indirect command buffer runs in parts of the most commands whose preprocess bytes, as vkGetGeneratedCommandsMemoryRequirementsEXT answers with the inherited pipeline, stay at or under 2 MiB (indirect::PART_BYTES), one rule on every device, in place of parts of 64 commands. The device is asked from one command up, doubling while the answer stays at or under the bound, then again at fewer in proportion to the last answer until it is, so no answer at far more commands than a part takes is trusted (lavapipe's grows with the square of the count and wraps at 32 bits). An execution over a range a buffer holds (executeCommandsInBuffer: indirectBuffer:indirectBufferOffset:), location 0 included, ends the rendering, runs the translator's new count kernel (pipeline::own_kernel(OwnKernel::ExecutionCounts), one workgroup a part, its parameter block pipeline::ExecutionCounts in the ring), one global barrier, and begins the rendering again; each part's vkCmdExecuteGeneratedCommandsEXT reads its count at sequenceCountAddress: its commands through the range's last, none past it or wholly before its location. A CPU-given range runs no kernel. While a visibility result's query counts the draws, the execution is refused (Gap::Draw VisibilityResultInterrupt, counted), as the rendering cannot end inside the query. The runtime makes its own kernels once a device, at first use, through the pipeline cache and layout (runtime src/own.rs), and destroys them with the device. The idle preprocess pool's bound goes from 128 to 64 MiB: one frame of the sample now takes about 27 MB of commands' bytes plus at most one part an execution. Why: an execution over a GPU range ran the buffer's whole capacity, every command past the range costing its vertex work. Parts of 64 commands cost 61 times one execution's GPU time on the 2080. RADV fails past about 4 MiB of generated commands in one execution (draws nothing on a 7900 XTX, loses the device on a 780M): it chains by sequence count, not bytes. The 2 MiB bound is half that. Verified: on the probe branch (d59701c670), jobs 63460 and 63481 measured the frame of Apple's rendering sample: at the 2 MiB bound 931.8 us of GPU time on the 2080 (920.0 at whole capacity) and 588.5 on the XTX. This commit: compile job and the lavapipe rt suite, reported with the sha. Tests: the count kernel against a brute-force count on the interpreter and valid on every committed profile; held ranges at 0, past a part, past the commands, and a CPU range across parts; a held range in a Boolean visibility mode before and after its first draw; the widest layout's part at or under the bound on every device.
This commit is contained in:
1 parent
01ed696846
commit
d245bab9d1
14 files changed
+879
-134
No files matched your search
@@ -3699,18 +3699,30 @@ vertex and fragment buffers (`inheritBuffers` false), at most 31 of each stage.
|
||||
least recently used forgotten first), in the upload of the next commit.
|
||||
`BlitCommandEncoder::reset_commands_in_buffer` copies the same commands over its range, and
|
||||
`optimize_indirect_command_buffer` records nothing.
|
||||
- `RenderCommandEncoder::execute_commands_in_buffer` runs the range in parts of 64 commands, in
|
||||
order, the last part the rest: one `vkCmdExecuteGeneratedCommandsEXT` a part, a sequence a
|
||||
command, with the encoder's pipeline state and render state: a push constant token for each
|
||||
slot word the state's functions read, the index buffer token, a sequence index token and the
|
||||
indexed draw token. Before each part the execution pushes the part's
|
||||
- `RenderCommandEncoder::execute_commands_in_buffer` runs the range in parts, in order, the last
|
||||
part the rest: one `vkCmdExecuteGeneratedCommandsEXT` a part, a sequence a command, with the
|
||||
encoder's pipeline state and render state: a push constant token for each slot word the state's
|
||||
functions read, the index buffer token, a sequence index token and the indexed draw token. A
|
||||
part is the most commands whose preprocess bytes, as
|
||||
`vkGetGeneratedCommandsMemoryRequirementsEXT` answers for them with the inherited pipeline, stay
|
||||
at or under 2 MiB, one rule on every device (known gaps, below): the device is asked from one
|
||||
command up, doubling while the answer stays at or under the bound, then again at fewer, in
|
||||
proportion to the last answer, until it is. Before each part the execution pushes the part's
|
||||
first command, which the vertex function adds to the sequence index. The device keeps 64 command
|
||||
layouts, one per shape of tokens, and 256 execution shapes of a part's 64 commands, one per
|
||||
state, raster state (the depth clip and triangle fill modes, which choose the state's pipeline)
|
||||
and layout. `execute_commands_in_buffer_with_range` reads the range
|
||||
(`MTLIndirectCommandBufferExecutionRange`) where a buffer holds it when the command runs: the
|
||||
execution runs every command of the buffer, and the vertex function returns before its body for
|
||||
a command outside the range.
|
||||
layouts, one per shape of tokens, and 256 execution shapes, each with its part, one per state,
|
||||
raster state (the depth clip and triangle fill modes, which choose the state's pipeline), layout
|
||||
and capacity.
|
||||
- `execute_commands_in_buffer_with_range` reads the range (`MTLIndirectCommandBufferExecutionRange`)
|
||||
where a buffer holds it when the command runs, the one form for every range the GPU reads,
|
||||
location 0 included: the rendering ends, the device's count kernel (the translator's
|
||||
`OwnKernel::ExecutionCounts`, made at its first use and counted in `pipelines_created`) runs one
|
||||
workgroup a part, reads the range and writes each part's count into the command buffer's ring,
|
||||
one global barrier follows, and the rendering begins again, loading what it stored. The parts
|
||||
run from command 0, each through the range's last command (its `sequenceCountAddress`), none
|
||||
past it and none wholly before its location; in the part that holds the location, the vertex
|
||||
function returns before its body for each command before it. A range past the buffer's
|
||||
commands is clamped to them. A range the CPU gives (`execute_commands_in_buffer`) runs no
|
||||
kernel.
|
||||
- A state made with `supportIndirectCommandBuffers` pulls every vertex attribute its vertex function
|
||||
reads, at its layout's stride from the descriptor, so a command binds no vertex buffer of its
|
||||
own, and its vertex function tests its command against the execution's range; a direct draw of
|
||||
@@ -3723,10 +3735,11 @@ vertex and fragment buffers (`inheritBuffers` false), at most 31 of each stage.
|
||||
the next draw pushes and binds its own; the pipeline and the vertex buffers stay bound.
|
||||
- Each execution takes a preprocess region when it is recorded, an idle one of the device's pool
|
||||
or one made then, its parts' preprocess one after another, each sized by
|
||||
`vkGetGeneratedCommandsMemoryRequirementsEXT` with the inherited pipeline at 64 commands, and
|
||||
`vkGetGeneratedCommandsMemoryRequirementsEXT` with the inherited pipeline at its part, and
|
||||
gives it back when its command buffer completes. Its sizes are those of a token per slot word
|
||||
(known gaps, below): on the 2080 a part of 64 commands of four slot words takes 69,888 bytes,
|
||||
1,092 a command, and one of 17 tokens 151,808. The pool keeps at most 128 MiB of idle regions,
|
||||
1,092 a command, and 17 tokens take about 592 bytes a command at 1,024 commands or more. The
|
||||
pool keeps at most 64 MiB of idle regions,
|
||||
the oldest freed past that, and the block-maker thread frees each region idle for 250 ms, the
|
||||
idle age, as it frees idle allocations: at rest the pool holds nothing.
|
||||
`Metrics::preprocess_regions_remade` counts the regions made within a second after one was freed
|
||||
@@ -3738,8 +3751,18 @@ vertex and fragment buffers (`inheritBuffers` false), at most 31 of each stage.
|
||||
|
||||
### Known gaps of indirect command buffers
|
||||
|
||||
- An execution over a range a buffer holds processes the buffer's whole capacity: each command
|
||||
outside the range, reset or not, costs its vertex work and draws nothing.
|
||||
- An execution over a range a buffer holds runs its parts from command 0: each part wholly before
|
||||
the range's location runs no command but costs its execution (below), and the part that holds
|
||||
the location runs its commands before it, at most a part's less one, each costing its vertex
|
||||
work and drawing nothing.
|
||||
- An execution over a range a buffer holds ends the rendering for its count kernel and begins it
|
||||
again: one more dispatch, one barrier, and the attachments stored and loaded. With the probe's
|
||||
form of the split, Apple's rendering sample's frame (11 such executions) took 1,003.4 us of GPU
|
||||
time against 931.8 without it on an RTX 2080, and 617.0 against 588.5 on a Radeon RX 7900 XTX
|
||||
(job 63481, medians of 9). While a visibility result's query counts the draws (after a draw
|
||||
under a `Boolean` or `Counting` mode) the rendering cannot end, so such an execution is refused,
|
||||
`Gap::Draw` of `DrawKind::VisibilityResultInterrupt`, counted in
|
||||
`Metrics::visibility_interrupts_refused`; one before the mode's first draw runs.
|
||||
- A state made with `supportIndirectCommandBuffers` pays one 8-byte load a vertex on its direct
|
||||
draws too: its vertex function reads the execution range.
|
||||
- A state made with `supportIndirectCommandBuffers` whose vertex descriptor has a layout of
|
||||
@@ -3748,20 +3771,24 @@ vertex and fragment buffers (`inheritBuffers` false), at most 31 of each stage.
|
||||
stride each bind sets (`setVertexBuffer:offset:attributeStride:atIndex:`, a command's included)
|
||||
from a push field the encoder does not fill.
|
||||
- An execution over a range a buffer holds takes a preprocess region for the buffer's whole
|
||||
capacity, whatever the range, held until the command buffer completes. A part of 64 commands of
|
||||
17 tokens takes 151,808 bytes on NVIDIA's driver (an RTX 2080; 2,372 a command) and 39,680 on
|
||||
RADV (a Radeon RX 7900 XTX; 620 a command).
|
||||
- Every execution runs in parts of 64 commands, on every device. One execution of more did not
|
||||
draw every command in order where it was measured: on RADV (Mesa 26.2.6, a Radeon RX 7900 XTX)
|
||||
an execution of N commands whose generated commands pass about 4 MiB (296 bytes a command,
|
||||
14,170 commands) drew only its first N - 14,170 commands, or none, a driver bug; on NVIDIA's
|
||||
driver (620.70.06, an RTX 2080) one of 96 commands or more (65 drew right) ended with its own
|
||||
29th to 32nd commands on top of every later one, under the token bug below. The parts cost, at
|
||||
14,000 commands against one execution: 62% more GPU time on the XTX and 61 times as much on the
|
||||
2080, and 25 to 34 times the recording time. Their memory, for a frame of Apple's rendering
|
||||
sample at its worst (45,024 commands of 17 tokens in 11 executions, 710 parts): about 108 MB of
|
||||
preprocess regions on the 2080 and 28 MB on the XTX, where single executions would take about 27
|
||||
MB on each (592 and 608 bytes a command).
|
||||
capacity, whatever the range, held until the command buffer completes: 17 tokens take about 592
|
||||
bytes a command on NVIDIA's driver (an RTX 2080) and 776 on RADV (a Radeon 780M), at 1,024
|
||||
commands or more.
|
||||
- Every execution runs in parts of at most 2 MiB of preprocess bytes, on every device: half of
|
||||
about 4 MiB, past which one execution did not draw where it was measured on RADV, a driver bug,
|
||||
and since a wrong guess loses the guest's device, the bound keeps that margin. On a Radeon RX
|
||||
7900 XTX (Mesa 26.2.6) an execution of N commands whose generated commands pass about 4 MiB (296
|
||||
bytes a command, 14,170 commands) drew only its first N - 14,170 commands, or none; on a Radeon
|
||||
780M (Mesa 26.2.6) one execution of 8,162 commands of 17 tokens (about 6.3 MB) lost the device.
|
||||
Mesa 26.3.1's source chains the generated commands into further command buffers by the count of
|
||||
sequences alone (65,536), not by their bytes. NVIDIA's driver draws one execution of a buffer's
|
||||
whole capacity right, so there each part past the first is paid for the other driver's limit,
|
||||
about 10.5 us of GPU time a part: Apple's rendering sample's frame (45,024 commands of 17 tokens
|
||||
in 11 executions, each run through its range's last command) took 2,598.9 us in 182 parts,
|
||||
1,648.8 in 91, 1,175.6 in 46, 907.2 in 16 and 870.5 in 11 (one part an execution), against
|
||||
391.4 drawn directly (job 63460, an RTX 2080 on NVIDIA's 620.70.06, medians of 9). On the XTX a
|
||||
part costs about 2.4 us. The frame's parts at the bound took 931.8 us on the 2080 and 588.5 on
|
||||
the XTX (job 63481).
|
||||
- A command's buffer slots reach its functions through the push bytes alone, so each slot a
|
||||
command binds needs its word in the state's 256 push bytes, which the vertex and fragment
|
||||
functions and all their other fields share. The translator places the vertex function's fields
|
||||
@@ -3809,9 +3836,9 @@ vertex and fragment buffers (`inheritBuffers` false), at most 31 of each stage.
|
||||
- On Mesa's CPU device (lavapipe, Mesa 26.2.6) the size
|
||||
`vkGetGeneratedCommandsMemoryRequirementsEXT` reports for a draw layout is quadratic in the
|
||||
command count and wraps at 2^32 (8,519,680 bytes at 16,384 commands of four buffers), a driver
|
||||
bug. Each part is sized at its 64 commands, which the wrap does not reach, but that size is
|
||||
large: 557,568 bytes for commands of four buffers (8,712 a command; 134,750,208 bytes at 1,024
|
||||
commands).
|
||||
bug. The part search asks from one command up, doubling, so it asks at no count the wrap
|
||||
reaches, and the parts are small: 64 commands of four buffers take 557,568 bytes (8,712 a
|
||||
command; 134,750,208 bytes at 1,024 commands).
|
||||
- On the Iris Xe (ANV, Mesa 26.2.6), which does not list `VK_EXT_device_generated_commands`, an
|
||||
indirect command buffer is refused (`Gap::IndirectCommandBuffers`,
|
||||
`IndirectCommandsKind::Extension`).
|
||||
|
||||
@@ -373,6 +373,8 @@ pub(crate) struct Core {
|
||||
pub(crate) caches: Caches,
|
||||
/// The compiled kernels by content, which every compute pipeline state of a content shares.
|
||||
pub(crate) kernels: KernelMap,
|
||||
/// The runtime's own kernels made so far (`crate::own`).
|
||||
pub(crate) own: crate::own::OwnKernels,
|
||||
/// The translator's decodes and specialized entries of the functions the device's pipeline
|
||||
/// states lowered, which every creation reads, so a module is decoded and a stage
|
||||
/// specialized once for the device rather than once a state. Bounded by the translator: the
|
||||
@@ -810,6 +812,7 @@ impl Device {
|
||||
translator,
|
||||
caches,
|
||||
kernels: KernelMap::new(),
|
||||
own: crate::own::OwnKernels::default(),
|
||||
entries: metal2vulkan::pipeline::StageEntries::new(),
|
||||
closed: AtomicBool::new(false),
|
||||
halt: AtomicU8::new(RUNNING),
|
||||
@@ -1684,6 +1687,8 @@ impl Drop for Core {
|
||||
self.imports.destroy(&self.device);
|
||||
self.stamps.destroy(&self.device, &self.counters);
|
||||
self.occlusion.destroy(&self.device, &self.counters);
|
||||
// SAFETY: the device is idle, and nothing records any more.
|
||||
unsafe { self.own.destroy(self) };
|
||||
// SAFETY: the device is idle; nothing reads the ring.
|
||||
let ring_blocks = unsafe { self.ring.destroy(&self.device) };
|
||||
let filler = self.filler.take();
|
||||
|
||||
@@ -216,7 +216,7 @@ impl MemoryInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/// `VkGeneratedCommandsInfoEXT`, with no execution set and no count address.
|
||||
/// `VkGeneratedCommandsInfoEXT`, with no execution set.
|
||||
#[repr(C)]
|
||||
pub(crate) struct CommandsInfo {
|
||||
s_type: vk::StructureType,
|
||||
@@ -234,14 +234,15 @@ pub(crate) struct CommandsInfo {
|
||||
}
|
||||
|
||||
impl CommandsInfo {
|
||||
/// `sequences` sequences of `layout` at `indirect` (`size` bytes), preprocessed into
|
||||
/// `preprocess` (`preprocess_size` bytes), with the inherited `pipeline`.
|
||||
/// At most `sequences` sequences of `layout` at `indirect` (`size` bytes), preprocessed into
|
||||
/// `preprocess` (`preprocess_size` bytes), with the inherited `pipeline`: all of them where
|
||||
/// `count` is 0, else as many as the `u32` at device address `count` says, up to `sequences`.
|
||||
pub(crate) fn new(
|
||||
pipeline: &PipelineInfo,
|
||||
layout: u64,
|
||||
(indirect, size): (u64, u64),
|
||||
(preprocess, preprocess_size): (u64, u64),
|
||||
sequences: u32,
|
||||
(sequences, count): (u32, u64),
|
||||
) -> CommandsInfo {
|
||||
CommandsInfo {
|
||||
s_type: structure(4),
|
||||
@@ -254,7 +255,7 @@ impl CommandsInfo {
|
||||
preprocess_address: preprocess,
|
||||
preprocess_size,
|
||||
max_sequence_count: sequences,
|
||||
sequence_count_address: 0,
|
||||
sequence_count_address: count,
|
||||
max_draw_count: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,21 +46,25 @@ pub(crate) const LAYOUTS: usize = 64;
|
||||
/// The most execution shapes (a content, a raster state, a record layout and a command count)
|
||||
/// whose layout and preprocess requirements a device keeps ([`Shape`]).
|
||||
pub(crate) const SHAPES: usize = 256;
|
||||
/// The most commands one `vkCmdExecuteGeneratedCommandsEXT` runs: an execution of more is one of
|
||||
/// each part of `PART` commands in order, the last the rest, each its own preprocess in the
|
||||
/// execution's region, its sequences counted from the part's first command
|
||||
/// (`PushField::IndirectBase`). One form on every device; its cost is a known gap (README).
|
||||
pub(crate) const PART: u32 = 64;
|
||||
/// The most preprocess bytes one `vkCmdExecuteGeneratedCommandsEXT` takes, as
|
||||
/// `vkGetGeneratedCommandsMemoryRequirementsEXT` answers for its commands: an execution of more is
|
||||
/// one of each part of the most commands that stay at or under it ([`Shape::part`]), in order, the
|
||||
/// last the rest, each its own preprocess in the execution's region, its sequences counted from the
|
||||
/// part's first command (`PushField::IndirectBase`). Half of about 4 MiB, past which a driver was
|
||||
/// measured to draw nothing of an execution or to lose the device (README). One rule on every
|
||||
/// device; the bytes a command are the device's own answer.
|
||||
pub(crate) const PART_BYTES: u64 = 2 << 20;
|
||||
/// The most bytes of preprocess regions no execution holds that a device keeps for the next ones:
|
||||
/// the regions of one frame of Apple's published rendering sample's 45,024 commands, which a
|
||||
/// completed frame gives back for a later one to take (in a steady run only one frame's regions
|
||||
/// are idle; those of the frames in flight are in use): its 11 executions' 710 parts at the most a
|
||||
/// part takes (151,808 bytes, NVIDIA's for 17 tokens), about 108 MB, with room for the regions'
|
||||
/// rounding. A region made within a second of one freed past it is counted
|
||||
/// are idle; those of the frames in flight are in use): its 11 executions' parts hold the commands'
|
||||
/// own preprocess bytes (about 27 MB at the 592 bytes a command of 17 tokens measured on one
|
||||
/// device) and at most one part of [`PART_BYTES`] more an execution (22 MB), with room for the
|
||||
/// regions' rounding. A region made within a second of one freed past it is counted
|
||||
/// ([`Metrics::preprocess_regions_remade`](crate::Metrics::preprocess_regions_remade)), and every
|
||||
/// idle region goes once it has been idle for the runtime's idle age
|
||||
/// ([`memory::IDLE_AGE_NANOS`]): at rest the pool holds nothing.
|
||||
pub(crate) const IDLE_BYTES: u64 = 128 << 20;
|
||||
pub(crate) const IDLE_BYTES: u64 = 64 << 20;
|
||||
/// The granule a preprocess region's bytes are rounded up to.
|
||||
const REGION_GRANULE: u64 = 64 << 10;
|
||||
/// The bounds of a buffer slot a command holds, which an execution pushes for it: its offset
|
||||
@@ -263,17 +267,20 @@ impl Drop for CommandsLayout {
|
||||
}
|
||||
}
|
||||
|
||||
/// An execution shape's layout and preprocess requirements, with the inherited pipeline.
|
||||
/// An execution shape's layout, its part and a part's preprocess requirements, with the inherited
|
||||
/// pipeline.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct Shape {
|
||||
pub(crate) layout: Arc<CommandsLayout>,
|
||||
/// The push offset of the part's first command ([`Tokens::base`]).
|
||||
pub(crate) base: u32,
|
||||
/// The commands of a part: the most whose preprocess bytes stay at or under [`PART_BYTES`].
|
||||
pub(crate) part: u32,
|
||||
preprocess: vk::MemoryRequirements,
|
||||
}
|
||||
|
||||
impl Shape {
|
||||
/// The preprocess bytes an execution of the shape takes.
|
||||
/// The preprocess bytes a part of the shape takes.
|
||||
pub(crate) fn preprocess_size(&self) -> u64 {
|
||||
self.preprocess.size
|
||||
}
|
||||
@@ -366,10 +373,11 @@ impl Indirect {
|
||||
}
|
||||
}
|
||||
|
||||
/// The shape of an execution of `capacity` commands of `layout` with `compiled`'s
|
||||
/// The shape of an execution of at most `capacity` commands of `layout` with `compiled`'s
|
||||
/// `pipeline`, made under `raster`: the device's, or one made now, its layout the device's for
|
||||
/// its tokens ([`tokens`]) or one made now, and its preprocess requirements queried with the
|
||||
/// pipeline, which an execution with another of the content's pipelines does not reuse.
|
||||
/// its tokens ([`tokens`]) or one made now, and its part and a part's preprocess requirements
|
||||
/// queried with the pipeline ([`part`](Self::part)), which an execution with another of the
|
||||
/// content's pipelines does not reuse.
|
||||
///
|
||||
/// Err: [`Gap::IndirectCommandBuffers`] where [`tokens`] answers a kind, and of
|
||||
/// [`IndirectCommandsKind::Tokens`] for more tokens than the device takes; [`Error::Vulkan`]
|
||||
@@ -391,26 +399,80 @@ impl Indirect {
|
||||
return Err(refuse(IndirectCommandsKind::Tokens));
|
||||
}
|
||||
let commands = self.layout(core, &tokens)?;
|
||||
let info = dgc::PipelineInfo::new(pipeline);
|
||||
let asked = dgc::MemoryInfo::new(&info, commands.handle, capacity);
|
||||
let mut requirements: vk::MemoryRequirements2<'static> = vk::MemoryRequirements2::default();
|
||||
// SAFETY: the layout and the pipeline are the device's, and the structures are valid for
|
||||
// the call.
|
||||
unsafe { (self.dgc.memory_requirements)(core.device.handle(), &asked, &mut requirements) };
|
||||
let (part, preprocess) = self.part(core, &commands, pipeline, capacity);
|
||||
let shape = Shape {
|
||||
layout: commands,
|
||||
base: tokens.base,
|
||||
preprocess: requirements.memory_requirements,
|
||||
part,
|
||||
preprocess,
|
||||
};
|
||||
let (kept, gone) = lock(&self.shapes).keep(key, shape);
|
||||
drop(gone);
|
||||
Ok(kept)
|
||||
}
|
||||
|
||||
/// The commands of a part of an execution of at most `capacity` commands of `commands` with
|
||||
/// `pipeline`, and a part's preprocess requirements: every command where the device's
|
||||
/// preprocess bytes for them (`vkGetGeneratedCommandsMemoryRequirementsEXT`) stay at or under
|
||||
/// [`PART_BYTES`], else about the most that do. The device is asked from one command up,
|
||||
/// doubling while the answer stays at or under the bound, so no answer for far more commands
|
||||
/// than a part takes is trusted (one driver's answer grows with the square of the count and
|
||||
/// wraps at 32 bits); past the last count that stayed under it, the device is asked again at
|
||||
/// fewer, in proportion to the last answer's bytes, until the answer is at or under it.
|
||||
pub(crate) fn part(
|
||||
&self,
|
||||
core: &Core,
|
||||
commands: &CommandsLayout,
|
||||
pipeline: vk::Pipeline,
|
||||
capacity: u32,
|
||||
) -> (u32, vk::MemoryRequirements) {
|
||||
let info = dgc::PipelineInfo::new(pipeline);
|
||||
let ask = |sequences: u32| {
|
||||
let asked = dgc::MemoryInfo::new(&info, commands.handle, sequences);
|
||||
let mut requirements: vk::MemoryRequirements2<'static> =
|
||||
vk::MemoryRequirements2::default();
|
||||
// SAFETY: the layout and the pipeline are the device's, and the structures are valid
|
||||
// for the call.
|
||||
unsafe {
|
||||
(self.dgc.memory_requirements)(core.device.handle(), &asked, &mut requirements)
|
||||
};
|
||||
requirements.memory_requirements
|
||||
};
|
||||
let (mut part, mut need) = (1, ask(1));
|
||||
while part < capacity {
|
||||
let next = part.saturating_mul(2).min(capacity);
|
||||
let more = ask(next);
|
||||
if more.size <= PART_BYTES {
|
||||
(part, need) = (next, more);
|
||||
continue;
|
||||
}
|
||||
let (mut over, mut bytes) = (next, more.size);
|
||||
loop {
|
||||
let fewer = u128::from(PART_BYTES) * u128::from(over) / u128::from(bytes);
|
||||
let count = u32::try_from(fewer).map_or(over - 1, |fewer| fewer.min(over - 1));
|
||||
if count <= part {
|
||||
break;
|
||||
}
|
||||
let asked = ask(count);
|
||||
if asked.size <= PART_BYTES {
|
||||
(part, need) = (count, asked);
|
||||
break;
|
||||
}
|
||||
(over, bytes) = (count, asked.size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
(part, need)
|
||||
}
|
||||
|
||||
/// The command layout of `tokens`: the device's, or one made now, through the device's
|
||||
/// pipeline layout, for vertex and fragment stages, its push tokens' ranges of
|
||||
/// [`PUSH_STAGES`], the layout's one push range's stages.
|
||||
fn layout(&self, core: &Core, tokens: &Tokens) -> Result<Arc<CommandsLayout>, Error> {
|
||||
pub(crate) fn layout(
|
||||
&self,
|
||||
core: &Core,
|
||||
tokens: &Tokens,
|
||||
) -> Result<Arc<CommandsLayout>, Error> {
|
||||
if let Some(layout) = lock(&self.layouts).get(tokens) {
|
||||
return Ok(layout);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ mod kept;
|
||||
mod kernel_map;
|
||||
mod memory;
|
||||
mod over;
|
||||
mod own;
|
||||
mod pass;
|
||||
mod pipeline;
|
||||
mod pixel_format_info;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
//! The runtime's own kernels (`metal2vulkan::pipeline::OwnKernel`): each made once a device, at its
|
||||
//! first use, from the translator's module for the device's profile, through the device's one
|
||||
//! pipeline cache and its pipeline layout (counted as a pipeline made, in
|
||||
//! `Metrics::pipelines_created` and the `pipelines` gauge), and destroyed with the device.
|
||||
|
||||
use crate::counters::Gauge;
|
||||
use crate::device::{lock, Core};
|
||||
use crate::error::Error;
|
||||
use crate::pipeline::made_through_cache;
|
||||
use ash::vk;
|
||||
use metal2vulkan::pipeline::{own_kernel, OwnKernel};
|
||||
use std::sync::Mutex;
|
||||
|
||||
/// A device's own kernels made so far: each with its module and its pipeline.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct OwnKernels {
|
||||
made: Mutex<Vec<(OwnKernel, vk::ShaderModule, vk::Pipeline)>>,
|
||||
}
|
||||
|
||||
impl OwnKernels {
|
||||
/// `kernel`'s pipeline on `core`'s device, made now where it is not yet: the calling thread
|
||||
/// waits for it, a first-use wait, as another that asks meanwhile does.
|
||||
///
|
||||
/// Err: [`Error::Translation`] where the translator makes no module of it for the device's
|
||||
/// profile; [`Error::Vulkan`] where the module or the pipeline cannot be made.
|
||||
pub(crate) fn pipeline(&self, core: &Core, kernel: OwnKernel) -> Result<vk::Pipeline, Error> {
|
||||
let mut made = lock(&self.made);
|
||||
if let Some(&(_, _, pipeline)) = made.iter().find(|(held, ..)| *held == kernel) {
|
||||
return Ok(pipeline);
|
||||
}
|
||||
let words = own_kernel(kernel, core.translator.profile()).map_err(Error::translation)?;
|
||||
let info = vk::ShaderModuleCreateInfo::default().code(&words);
|
||||
// SAFETY: the words are the translator's SPIR-V for the device's profile.
|
||||
let module =
|
||||
unsafe { core.device.create_shader_module(&info, None) }.map_err(|result| {
|
||||
Error::Vulkan {
|
||||
call: "vkCreateShaderModule",
|
||||
result,
|
||||
}
|
||||
})?;
|
||||
let stage = vk::PipelineShaderStageCreateInfo::default()
|
||||
.stage(vk::ShaderStageFlags::COMPUTE)
|
||||
.module(module)
|
||||
.name(c"main");
|
||||
let info = vk::ComputePipelineCreateInfo::default()
|
||||
.stage(stage)
|
||||
.layout(core.layout);
|
||||
let pipeline = made_through_cache(core, "vkCreateComputePipelines", |cache| {
|
||||
// SAFETY: the module, the layout and the cache are the device's.
|
||||
unsafe { core.device.create_compute_pipelines(cache, &[info], None) }
|
||||
});
|
||||
match pipeline {
|
||||
Ok(pipeline) => {
|
||||
made.push((kernel, module, pipeline));
|
||||
Ok(pipeline)
|
||||
}
|
||||
Err(error) => {
|
||||
// SAFETY: no pipeline was made of the module.
|
||||
unsafe { core.device.destroy_shader_module(module, None) };
|
||||
Err(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Destroys every kernel made.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// No command buffer that used one is pending, and none is used again.
|
||||
pub(crate) unsafe fn destroy(&self, core: &Core) {
|
||||
for (_, module, pipeline) in lock(&self.made).drain(..) {
|
||||
// SAFETY: the caller's contract.
|
||||
unsafe {
|
||||
core.device.destroy_pipeline(pipeline, None);
|
||||
core.device.destroy_shader_module(module, None);
|
||||
}
|
||||
core.counters.fall(Gauge::Pipelines);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ use crate::encoder::{
|
||||
use crate::error::{DrawKind, Error, Gap, IndirectCommandsKind, Limit, Refusal, RenderPassKind};
|
||||
use crate::fence::Fence;
|
||||
use crate::hazard::Access;
|
||||
use crate::indirect::{IndirectCommandBuffer, PART, UNCHECKED_BOUNDS};
|
||||
use crate::indirect::{IndirectCommandBuffer, UNCHECKED_BOUNDS};
|
||||
use crate::kept::{Handle, Lent, Uncounted};
|
||||
use crate::memory::BlockId;
|
||||
use crate::over::{self, Reached};
|
||||
@@ -539,12 +539,14 @@ enum Call<'a> {
|
||||
/// An execution of `sequences` commands of an indirect command buffer from command `first`
|
||||
/// (`crate::indirect`), each a sequence of triangles: over the range the CPU gave, or, where
|
||||
/// `range` holds a buffer and an offset, over the range that buffer holds there, from command
|
||||
/// 0 through every command.
|
||||
/// 0 through every command, each part running as many as its count at `counts` (part `p`'s
|
||||
/// at `counts + 4 * p`, which the count kernel wrote; 0 for a range the CPU gave).
|
||||
Commands {
|
||||
buffer: &'a IndirectCommandBuffer,
|
||||
first: u32,
|
||||
sequences: u32,
|
||||
range: Option<(&'a Buffer, u64)>,
|
||||
counts: u64,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2392,9 +2394,9 @@ impl RenderCommandEncoder {
|
||||
&self.core,
|
||||
(compiled, self.raster, pipeline),
|
||||
buffer.layout(),
|
||||
PART,
|
||||
buffer.size(),
|
||||
)?;
|
||||
let parts = sequences.div_ceil(PART);
|
||||
let parts = sequences.div_ceil(shape.part);
|
||||
let (executed, preprocess) =
|
||||
indirect.executed(building.device.core(), &shape, parts)?;
|
||||
Some((shape, executed, preprocess))
|
||||
@@ -2616,6 +2618,7 @@ impl RenderCommandEncoder {
|
||||
buffer,
|
||||
first,
|
||||
sequences,
|
||||
counts,
|
||||
..
|
||||
},
|
||||
_,
|
||||
@@ -2624,12 +2627,18 @@ impl RenderCommandEncoder {
|
||||
(&core.indirect, &execution)
|
||||
{
|
||||
// One execution of each part, in order, each part's first command pushed
|
||||
// at the base field; the first part's push is the draw's own.
|
||||
// at the base field; the first part's push is the draw's own. Over a
|
||||
// range a buffer holds, each part runs as many as its count says.
|
||||
let layout = buffer.layout();
|
||||
let info = crate::dgc::PipelineInfo::new(pipeline);
|
||||
let base = shape.base as usize;
|
||||
for (part, from) in (0..sequences).step_by(PART as usize).enumerate() {
|
||||
let count = (sequences - from).min(PART);
|
||||
for (part, from) in (0..sequences).step_by(shape.part as usize).enumerate()
|
||||
{
|
||||
let count = (sequences - from).min(shape.part);
|
||||
let counted = match counts {
|
||||
0 => 0,
|
||||
counts => counts + 4 * part as u64,
|
||||
};
|
||||
if part > 0 {
|
||||
let command_index = first + from;
|
||||
self.push[base..base + 4]
|
||||
@@ -2651,7 +2660,7 @@ impl RenderCommandEncoder {
|
||||
shape.layout.handle(),
|
||||
(stream, size),
|
||||
(at, shape.preprocess_size()),
|
||||
count,
|
||||
(count, counted),
|
||||
);
|
||||
(indirect.dgc.execute)(command, vk::FALSE, &generated);
|
||||
}
|
||||
@@ -2674,11 +2683,12 @@ impl RenderCommandEncoder {
|
||||
/// `executeCommandsInBuffer:withRange:`: commands `range` of `buffer`, drawn as triangles with
|
||||
/// the encoder's pipeline state and every render state it set, each command with the buffers
|
||||
/// its encoding bound (the command buffer keeps `buffer`'s records until it retires): one
|
||||
/// `vkCmdExecuteGeneratedCommandsEXT` for each part of 64 commands from the range's first, in
|
||||
/// order, each command a sequence of the content's command layout ([`IndirectCommandBuffer`]),
|
||||
/// each part its own preprocess in the execution's region and its first command pushed before
|
||||
/// it. Metal runs one execution; the parts cost GPU and recording time (the README's known
|
||||
/// gaps). A command's buffers are read through its vertex and fragment
|
||||
/// `vkCmdExecuteGeneratedCommandsEXT` for each part from the range's first, in order, a part
|
||||
/// the most commands whose preprocess bytes (`vkGetGeneratedCommandsMemoryRequirementsEXT`)
|
||||
/// stay at or under 2 MiB, each command a sequence of the content's command layout
|
||||
/// ([`IndirectCommandBuffer`]), each part its own preprocess in the execution's region and its
|
||||
/// first command pushed before it. Metal runs one execution; each part past the first costs
|
||||
/// GPU and recording time (the README's known gaps). A command's buffers are read through its vertex and fragment
|
||||
/// slots unchecked: an access of one reads and writes at the address the kernel's encoding
|
||||
/// wrote plus its offset, as an access through a pointer loaded from memory does
|
||||
/// (`docs/API.md`, section 5). An execution leaves the encoder's state as it was: the next
|
||||
@@ -2708,6 +2718,7 @@ impl RenderCommandEncoder {
|
||||
first: range.start,
|
||||
sequences: range.end - range.start,
|
||||
range: None,
|
||||
counts: 0,
|
||||
};
|
||||
self.draw(primitives(PrimitiveType::Triangle), call, Some([1, 0]))
|
||||
}
|
||||
@@ -2715,14 +2726,23 @@ impl RenderCommandEncoder {
|
||||
/// `executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:`: the commands of `buffer` in
|
||||
/// the range (`MTLIndirectCommandBufferExecutionRange`: a `u32` location, then a `u32`
|
||||
/// length) `range_buffer` holds at `offset` when the command runs, as
|
||||
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) draws them. The execution
|
||||
/// runs every command of the buffer, and the vertex function of each command outside the
|
||||
/// range returns before its body, drawing nothing; a command past the buffer's is none. The
|
||||
/// range buffer counts as a read, and the command buffer keeps it until it retires.
|
||||
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) draws them. The rendering
|
||||
/// ends, the device's count kernel (`metal2vulkan::pipeline::OwnKernel::ExecutionCounts`)
|
||||
/// reads the range and writes each part's count, one global barrier follows, and the
|
||||
/// rendering begins again, loading what it stored. The execution's parts from command 0 then
|
||||
/// each run their commands through the range's last, and none past it or wholly before its
|
||||
/// location; in the part that holds the location, the vertex function of each command before
|
||||
/// it returns before its body, drawing nothing. A range past the buffer's commands is clamped
|
||||
/// to them. The range buffer counts as a read, and the command buffer keeps it until it
|
||||
/// retires.
|
||||
///
|
||||
/// Err: as [`execute_commands_in_buffer`](Self::execute_commands_in_buffer);
|
||||
/// [`Refusal::OtherDevice`] for another device's range buffer; [`Refusal::CommandRange`]
|
||||
/// for an offset that is not a multiple of 4 or a range whose 8 bytes leave the buffer.
|
||||
/// for an offset that is not a multiple of 4 or a range whose 8 bytes leave the buffer;
|
||||
/// [`Gap::Draw`] of [`DrawKind::VisibilityResultInterrupt`], counted, while a visibility
|
||||
/// result's query counts the draws (after a draw of a `Boolean` or `Counting` mode: the
|
||||
/// count kernel would end the rendering inside the query); [`Error::Translation`] or
|
||||
/// [`Error::Vulkan`] where the count kernel cannot be made.
|
||||
pub fn execute_commands_in_buffer_with_range(
|
||||
&mut self,
|
||||
buffer: &IndirectCommandBuffer,
|
||||
@@ -2740,15 +2760,94 @@ impl RenderCommandEncoder {
|
||||
{
|
||||
return Err(Error::Refused(Refusal::CommandRange));
|
||||
}
|
||||
// The count kernel runs outside the rendering, which nothing may end while a visibility
|
||||
// result's query counts the draws.
|
||||
if self.results.counting() {
|
||||
return Err(self.interrupt_refused());
|
||||
}
|
||||
let part = self.execution_part(buffer)?;
|
||||
let range = range_buffer.gpu_address().wrapping_add(offset);
|
||||
let counts = self.execution_counts(range, buffer.size(), part)?;
|
||||
let call = Call::Commands {
|
||||
buffer,
|
||||
first: 0,
|
||||
sequences: buffer.size(),
|
||||
range: Some((range_buffer, offset)),
|
||||
counts,
|
||||
};
|
||||
self.draw(primitives(PrimitiveType::Triangle), call, Some([1, 0]))
|
||||
}
|
||||
|
||||
/// The part of an execution of `buffer`'s commands with the encoder's pipeline state
|
||||
/// ([`Shape::part`](crate::indirect::Shape)), as [`draw`](Self::draw) takes it.
|
||||
///
|
||||
/// Err: as [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) for the state.
|
||||
pub(crate) fn execution_part(&self, buffer: &IndirectCommandBuffer) -> Result<u32, Error> {
|
||||
let Some(state) = &self.pipeline else {
|
||||
return Err(Error::Refused(Refusal::NoPipeline));
|
||||
};
|
||||
let compiled = &state.inner.compiled;
|
||||
if compiled.draws.patches {
|
||||
return Err(Error::Refused(Refusal::PatchDraw));
|
||||
}
|
||||
let Some(indirect) = &self.core.indirect else {
|
||||
return Err(Error::Unsupported(Gap::IndirectCommandBuffers {
|
||||
kind: IndirectCommandsKind::Extension,
|
||||
}));
|
||||
};
|
||||
let (topology, _) = primitives(PrimitiveType::Triangle);
|
||||
let pipeline = compiled.pipeline(topology, self.raster)?;
|
||||
let made = (compiled, self.raster, pipeline);
|
||||
let shape = indirect.shape(&self.core, made, buffer.layout(), buffer.size())?;
|
||||
Ok(shape.part)
|
||||
}
|
||||
|
||||
/// Ends the rendering, runs the device's count kernel over the range at device address
|
||||
/// `range` for an execution of `capacity` commands in parts of `part`, records one global
|
||||
/// barrier and begins the rendering again, loading what it stored: where the parts' counts
|
||||
/// lie, part `p`'s at the address returned plus `4 * p`, in the command buffer's ring.
|
||||
///
|
||||
/// Err: [`Error::Translation`] or [`Error::Vulkan`] where the kernel cannot be made;
|
||||
/// [`Error::Vulkan`] where the command buffer cannot record.
|
||||
fn execution_counts(&mut self, range: u64, capacity: u32, part: u32) -> Result<u64, Error> {
|
||||
use metal2vulkan::pipeline::{ExecutionCounts, OwnKernel};
|
||||
let pipeline = (self.core.own).pipeline(&self.core, OwnKernel::ExecutionCounts)?;
|
||||
let parts = capacity.div_ceil(part);
|
||||
let mut block = vec![0; ExecutionCounts::COUNTS_AT as usize + 4 * parts as usize];
|
||||
let at = |field: u32| field as usize;
|
||||
block[at(ExecutionCounts::RANGE_AT)..][..8].copy_from_slice(&range.to_le_bytes());
|
||||
block[at(ExecutionCounts::CAPACITY_AT)..][..4].copy_from_slice(&capacity.to_le_bytes());
|
||||
block[at(ExecutionCounts::PART_AT)..][..4].copy_from_slice(&part.to_le_bytes());
|
||||
(self.drew, self.owed) = (false, false);
|
||||
let mut counts = 0;
|
||||
self.interrupt(|building, core| {
|
||||
let placed = building.write_ring_placed(&block)?;
|
||||
counts = placed.address + u64::from(ExecutionCounts::COUNTS_AT);
|
||||
let command = building.ordered_command()?;
|
||||
let push = placed.address.to_le_bytes();
|
||||
// SAFETY: the command buffer records outside any rendering; the pipeline and the
|
||||
// layout are the device's, the kernel's push field lies in the layout's one push
|
||||
// range, of `PUSH_STAGES`, and its block in the ring, which the command buffer keeps
|
||||
// until it retires.
|
||||
unsafe {
|
||||
if building.bind(pipeline) {
|
||||
(core.device).cmd_bind_pipeline(
|
||||
command,
|
||||
vk::PipelineBindPoint::COMPUTE,
|
||||
pipeline,
|
||||
);
|
||||
}
|
||||
if building.push_needed(&push) {
|
||||
(core.device).cmd_push_constants(command, core.layout, PUSH_STAGES, 0, &push);
|
||||
}
|
||||
core.device.cmd_dispatch(command, parts, 1, 1);
|
||||
}
|
||||
building.barrier(command, Reach::Commands);
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(counts)
|
||||
}
|
||||
|
||||
/// What a draw of `draws` reads of its pass's attachments through textures. A texture whose
|
||||
/// image the pass renders and that reaches the attachment's level and layer reads the
|
||||
/// attachment: from the fragment function, never written, of an image a draw may read so that
|
||||
|
||||
@@ -17,6 +17,15 @@
|
||||
//! commands 0 and 1, then a direct draw of command 2, then command 3, the direct draw drawing
|
||||
//! after an execution as it does alone. A range past the commands and a range buffer's offset
|
||||
//! off a multiple of 4 are refused.
|
||||
//! - an execution of three parts and eight commands (a part the most commands whose preprocess
|
||||
//! bytes the device puts at or under 2 MiB) draws as its draws direct: all of it, a CPU range
|
||||
//! across three parts, and ranges a buffer holds, which the count kernel reads: at location 0
|
||||
//! across two parts, from inside the second part, and past the commands, clamped to them.
|
||||
//! - at the widest layout the device can take, the part of an execution of the most commands it
|
||||
//! takes has queried preprocess bytes at or under 2 MiB.
|
||||
//! - an execution over a range a buffer holds runs as a `Boolean` visibility mode's first draw,
|
||||
//! its samples counted, and after a draw of a mode it is
|
||||
//! `DrawKind::VisibilityResultInterrupt`, counted.
|
||||
//! - a kernel's reset of command 1 and a blit's reset of command 3 leave commands 0 and 2 to
|
||||
//! draw; an optimize records nothing; a blit reset past the commands is refused.
|
||||
//! - a command's slots go unchecked on both sides: a vertex function that reads four elements
|
||||
@@ -27,8 +36,8 @@
|
||||
//! device that takes fewer (lavapipe's 16), and executes on one that takes as many.
|
||||
//! - the device's caches hold at most their capacities past them: 16 templates, 256 execution
|
||||
//! shapes and 64 command layouts.
|
||||
//! - the preprocess pool: regions held past 128 MiB in use all go back, the idle bytes at most
|
||||
//! 128 MiB after them; as many taken again at once count the regions made again past the
|
||||
//! - the preprocess pool: regions held past 64 MiB in use all go back, the idle bytes at most
|
||||
//! 64 MiB after them; as many taken again at once count the regions made again past the
|
||||
//! bound; past the idle age the idle bytes reach 0, the pool at rest; 200 executions keep the
|
||||
//! regions' bytes flat between the 100th and the 200th; every indirect gauge is zero once the
|
||||
//! device is dropped.
|
||||
@@ -137,17 +146,17 @@ fn an_executions_tokens_are_a_token_per_slot_word() {
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::indirect::{IDLE_BYTES, LAYOUTS, PART, SHAPES, TEMPLATES};
|
||||
use crate::indirect::{Tokens, IDLE_BYTES, LAYOUTS, PART_BYTES, SHAPES, TEMPLATES};
|
||||
use crate::render::Raster;
|
||||
use crate::tests::command::on_device::each_device;
|
||||
use crate::tests::draw::on_device::{library, pass, read, run, state, target, Buffers};
|
||||
use crate::{
|
||||
Buffer, ColorAttachmentDescriptor, ComputePipelineDescriptor, ComputePipelineState,
|
||||
CullMode, Device, DispatchType, Error, FunctionDescriptor, Gap, IndexBuffer, IndexType,
|
||||
IndirectCommandBuffer, IndirectCommandBufferDescriptor, IndirectCommandType,
|
||||
CullMode, Device, DispatchType, DrawKind, Error, FunctionDescriptor, Gap, IndexBuffer,
|
||||
IndexType, IndirectCommandBuffer, IndirectCommandBufferDescriptor, IndirectCommandType,
|
||||
IndirectCommandsKind, Library, MemoryClass, PixelFormat, PrimitiveType, Refusal,
|
||||
RenderCommandEncoder, RenderPipelineDescriptor, RenderPipelineKind, RenderPipelineState,
|
||||
Resource, ResourceUsage, StageSource, TextureUsage,
|
||||
Resource, ResourceUsage, StageSource, TextureUsage, VisibilityResultMode,
|
||||
};
|
||||
use ash::vk;
|
||||
use metal2vulkan::metal::VertexFormat;
|
||||
@@ -336,7 +345,10 @@ mod on_device {
|
||||
ResourceUsage::WRITE,
|
||||
),
|
||||
);
|
||||
ok(name, e.dispatch_threadgroups([1, 1, 1], [threads, 1, 1]));
|
||||
ok(
|
||||
name,
|
||||
e.dispatch_threads([threads, 1, 1], [threads.min(64), 1, 1]),
|
||||
);
|
||||
e.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
}
|
||||
@@ -495,29 +507,40 @@ mod on_device {
|
||||
}
|
||||
|
||||
/// An execution of more commands than one part holds runs its parts in order, each command
|
||||
/// tested against the range as its own: whole, over a CPU range and over a range a buffer
|
||||
/// holds, each across parts, against the same draws direct.
|
||||
/// tested against the range as its own, against the same draws direct: whole, over a CPU range
|
||||
/// across three parts, and over ranges a buffer holds, which the count kernel reads: one at
|
||||
/// location 0 across two parts, one from a location inside a part (the part's commands before
|
||||
/// it run and draw nothing), and one past the commands, clamped to them.
|
||||
#[test]
|
||||
fn every_device_draws_an_execution_of_several_parts_as_its_draws_direct() {
|
||||
const MANY: u32 = 3 * PART + 8;
|
||||
let Some(indexed) = library(&engine_dir().join("icb_merged_indexed.ll")) else {
|
||||
return;
|
||||
};
|
||||
each_device("icb_parts", |name, _, device| {
|
||||
let Some(commands) = commands(name, &device, &descriptor(3, 1), MANY) else {
|
||||
return;
|
||||
};
|
||||
let state = flagged(
|
||||
name,
|
||||
&device,
|
||||
&indexed,
|
||||
("icb_indexed_vertex", "icb_indexed_fragment"),
|
||||
);
|
||||
// The device's part for this state, from a buffer of as many commands as it takes up
|
||||
// to 2^16.
|
||||
let most = (device.core().indirect.as_ref()).map_or(1, |i| i.limits.sequences);
|
||||
let Some(sized) = commands(name, &device, &descriptor(3, 1), most.min(1 << 16)) else {
|
||||
return;
|
||||
};
|
||||
let mut part = 0;
|
||||
drawn(name, &device, &state, |e| {
|
||||
part = ok(name, e.execution_part(&sized));
|
||||
});
|
||||
drop(sized);
|
||||
let many = (3 * part + 8).min(most.min(1 << 16));
|
||||
let commands = commands(name, &device, &descriptor(3, 1), many).expect("a buffer");
|
||||
let kernel = kernel(name, &device, &indexed, "icb_indexed_16");
|
||||
let mut buffers = Buffers::new(&device);
|
||||
let s = Scene::of(&device, &mut buffers, &commands, MANY);
|
||||
let s = Scene::of(&device, &mut buffers, &commands, many);
|
||||
let at = (&s, &s.xy, 0);
|
||||
encode(name, &device, &kernel, &commands, at, MANY);
|
||||
encode(name, &device, &kernel, &commands, at, many);
|
||||
let direct_of = |range: std::ops::Range<u32>| {
|
||||
drawn(name, &device, &state, |e| {
|
||||
for i in range {
|
||||
@@ -538,36 +561,130 @@ mod on_device {
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
let check = |what: &str, texels: Vec<u8>, range: std::ops::Range<u32>| {
|
||||
assert_eq!(texels, direct_of(range.clone()), "{name}: {what}");
|
||||
assert_eq!(marks(name, &texels), last(range), "{name}: {what}");
|
||||
};
|
||||
let all = drawn(name, &device, &state, |e| {
|
||||
ok(name, e.execute_commands_in_buffer(&commands, 0..MANY))
|
||||
ok(name, e.execute_commands_in_buffer(&commands, 0..many))
|
||||
});
|
||||
assert_eq!(all, direct_of(0..MANY), "{name}: all {MANY}");
|
||||
assert_eq!(marks(name, &all), last(0..MANY), "{name}: all {MANY}");
|
||||
let part = drawn(name, &device, &state, |e| {
|
||||
ok(name, e.execute_commands_in_buffer(&commands, 60..140))
|
||||
});
|
||||
assert_eq!(part, direct_of(60..140), "{name}: commands 60 to 139");
|
||||
assert_eq!(
|
||||
marks(name, &part),
|
||||
last(60..140),
|
||||
"{name}: commands 60 to 139"
|
||||
);
|
||||
let range = buffers.of(&device, &words(&[70, 100]));
|
||||
let held = drawn(name, &device, &state, |e| {
|
||||
check("all", all, 0..many);
|
||||
let across = part / 2..(2 * part + part / 2).min(many);
|
||||
let cpu = drawn(name, &device, &state, |e| {
|
||||
ok(
|
||||
name,
|
||||
e.execute_commands_in_buffer_with_range(&commands, &range, 0),
|
||||
e.execute_commands_in_buffer(&commands, across.clone()),
|
||||
)
|
||||
});
|
||||
assert_eq!(held, direct_of(70..170), "{name}: the range 70 to 169");
|
||||
assert_eq!(
|
||||
marks(name, &held),
|
||||
last(70..170),
|
||||
"{name}: the range 70 to 169"
|
||||
check("a CPU range across three parts", cpu, across);
|
||||
let mut held = |location: u32, length: u32| {
|
||||
let range = buffers.of(&device, &words(&[location, length]));
|
||||
drawn(name, &device, &state, |e| {
|
||||
ok(
|
||||
name,
|
||||
e.execute_commands_in_buffer_with_range(&commands, &range, 0),
|
||||
)
|
||||
})
|
||||
};
|
||||
check(
|
||||
"a held range at location 0 across two parts",
|
||||
held(0, part + 5),
|
||||
0..part + 5,
|
||||
);
|
||||
let inside = part + part / 2;
|
||||
check(
|
||||
"a held range from inside the second part",
|
||||
held(inside, part),
|
||||
inside..(inside + part).min(many),
|
||||
);
|
||||
check(
|
||||
"a held range past the commands",
|
||||
held(many - 6, 100),
|
||||
many - 6..many,
|
||||
);
|
||||
println!(
|
||||
"{name}: {MANY} encoded commands, commands 60 to 139 and the range 70 to 169 a \
|
||||
buffer holds, in parts of {PART}, each draw as their draws direct"
|
||||
"{name}: {many} encoded commands in parts of {part}: all, a CPU range across three \
|
||||
parts and ranges a buffer holds (at 0, inside the second part, past the \
|
||||
commands) each draw as their draws direct"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// An execution over a range a buffer holds, as a `Boolean` mode's first draw, runs and its
|
||||
/// samples count: its count kernel ends the rendering before the mode's query begins. After a
|
||||
/// draw of a mode, whose query then counts, it is `DrawKind::VisibilityResultInterrupt`,
|
||||
/// counted, and the encoder draws on.
|
||||
#[test]
|
||||
fn every_device_runs_a_held_range_first_in_a_visibility_mode_and_refuses_it_after_a_draw() {
|
||||
let Some(indexed) = library(&engine_dir().join("icb_merged_indexed.ll")) else {
|
||||
return;
|
||||
};
|
||||
each_device("icb_visibility", |name, _, device| {
|
||||
let Some(commands) = commands(name, &device, &descriptor(3, 1), N) else {
|
||||
return;
|
||||
};
|
||||
let state = flagged(
|
||||
name,
|
||||
&device,
|
||||
&indexed,
|
||||
("icb_indexed_vertex", "icb_indexed_fragment"),
|
||||
);
|
||||
let kernel = kernel(name, &device, &indexed, "icb_indexed_16");
|
||||
let mut buffers = Buffers::new(&device);
|
||||
let s = Scene::new(&device, &mut buffers, &commands);
|
||||
let at = (&s, &s.xy, 0);
|
||||
encode(name, &device, &kernel, &commands, at, N);
|
||||
let range = buffers.of(&device, &words(&[0, N]));
|
||||
let visibility = buffers.of(&device, &[0xaa; 16]);
|
||||
let counters = device.counters();
|
||||
let before = counters.metrics().visibility_interrupts_refused;
|
||||
let color = target(
|
||||
&device,
|
||||
PixelFormat::RGBA32Uint,
|
||||
TextureUsage::RENDER_TARGET,
|
||||
);
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut d = pass(&color, None);
|
||||
d.visibility_result_buffer = Some(visibility.clone());
|
||||
let mut e = ok(name, command_buffer.render_command_encoder(&d));
|
||||
ok(name, e.set_render_pipeline_state(&state));
|
||||
e.set_cull_mode(CullMode::None);
|
||||
let boolean = VisibilityResultMode::Boolean;
|
||||
ok(name, e.set_visibility_result_mode(boolean, 0));
|
||||
ok(
|
||||
name,
|
||||
e.execute_commands_in_buffer_with_range(&commands, &range, 0),
|
||||
);
|
||||
ok(name, e.set_visibility_result_mode(boolean, 8));
|
||||
direct(name, &mut e, at, 0, 0);
|
||||
let refused = e.execute_commands_in_buffer_with_range(&commands, &range, 0);
|
||||
assert!(
|
||||
matches!(
|
||||
refused,
|
||||
Err(Error::Unsupported(Gap::Draw {
|
||||
kind: DrawKind::VisibilityResultInterrupt
|
||||
}))
|
||||
),
|
||||
"{name}: an execution while the query counts: {refused:?}"
|
||||
);
|
||||
direct(name, &mut e, at, 1, 4);
|
||||
e.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
let refusals = counters.metrics().visibility_interrupts_refused - before;
|
||||
assert_eq!(refusals, 1, "{name}: the refusal counted");
|
||||
let contents = visibility.contents().expect("a Shared buffer");
|
||||
// SAFETY: the buffer holds 16 bytes, which the finished command buffer wrote and whose
|
||||
// writes reach the host.
|
||||
let bytes = unsafe { std::slice::from_raw_parts(contents.as_ptr(), 16) };
|
||||
let counts: Vec<u64> = (bytes.chunks(8))
|
||||
.map(|word| u64::from_le_bytes(word.try_into().expect("a word")))
|
||||
.collect();
|
||||
// Each command draws a band of 16 pixels: the execution's four, the two direct draws'.
|
||||
assert_eq!(counts, [64, 32], "{name}: each mode's samples");
|
||||
println!(
|
||||
"{name}: an execution over a held range as a Boolean mode's first draw counted 64 \
|
||||
samples; after a draw of the next mode it was refused and counted"
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -1060,6 +1177,65 @@ mod on_device {
|
||||
});
|
||||
}
|
||||
|
||||
/// The part's bound, checked on the device: at the widest layout the device can take (as many
|
||||
/// 8-byte slot words as its tokens allow, at most the push bytes less the word of the sequence
|
||||
/// index and the part's first command), the part of an execution of the most commands the
|
||||
/// device takes has queried preprocess bytes at or under `PART_BYTES`.
|
||||
#[test]
|
||||
fn every_device_keeps_the_part_of_its_widest_layout_under_the_bound() {
|
||||
let Some(indexed) = library(&engine_dir().join("icb_merged_indexed.ll")) else {
|
||||
return;
|
||||
};
|
||||
each_device("icb_part_bytes", |name, _, device| {
|
||||
let Some(_commands) = commands(name, &device, &descriptor(3, 1), 1) else {
|
||||
return;
|
||||
};
|
||||
let state = flagged(
|
||||
name,
|
||||
&device,
|
||||
&indexed,
|
||||
("icb_indexed_vertex", "icb_indexed_fragment"),
|
||||
);
|
||||
let core = device.core();
|
||||
let indirect = (core.indirect.as_ref()).expect("the extension");
|
||||
let pipeline = ok(
|
||||
name,
|
||||
(state.inner.compiled)
|
||||
.pipeline(vk::PrimitiveTopology::TRIANGLE_LIST, Raster::default()),
|
||||
);
|
||||
let layout = IndirectDrawLayout::new(31, 31).expect("a layout");
|
||||
let room = crate::pipeline::PUSH_BYTES / 8 - 1;
|
||||
let words = room.min(indirect.limits.tokens.saturating_sub(3));
|
||||
let slots = (0..31)
|
||||
.map(|slot| layout.vertex_slot(slot))
|
||||
.chain((0..31).map(|slot| layout.fragment_slot(slot)));
|
||||
let tokens = Tokens {
|
||||
layout,
|
||||
pushes: slots
|
||||
.take(words as usize)
|
||||
.zip((0..).map(|w| 8 * w))
|
||||
.collect(),
|
||||
sequence: 8 * room,
|
||||
base: 8 * room + 4,
|
||||
};
|
||||
let commands = ok(name, indirect.layout(core, &tokens));
|
||||
let most = indirect.limits.sequences;
|
||||
let (part, need) = indirect.part(core, &commands, pipeline, most);
|
||||
assert!(
|
||||
part >= 1 && need.size <= PART_BYTES,
|
||||
"{name}: {} tokens: a part of {part} commands takes {} preprocess bytes",
|
||||
tokens.count(),
|
||||
need.size
|
||||
);
|
||||
println!(
|
||||
"{name}: {} tokens: a part of {part} of the most {most} commands takes {} \
|
||||
preprocess bytes, at most {PART_BYTES}",
|
||||
tokens.count(),
|
||||
need.size
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_device_bounds_its_preprocess_pool_and_drops_it() {
|
||||
let Some(indexed) = library(&engine_dir().join("icb_merged_indexed.ll")) else {
|
||||
@@ -1096,20 +1272,13 @@ mod on_device {
|
||||
),
|
||||
)
|
||||
};
|
||||
// A capacity whose region is between 4 and 16 MiB, so a few dozen pass the bound.
|
||||
let mut capacity = 1024;
|
||||
while shape(capacity).preprocess_size() > 16 << 20 && capacity > 1 {
|
||||
capacity /= 2;
|
||||
}
|
||||
while shape(capacity).preprocess_size() < 4 << 20
|
||||
&& 2 * capacity <= indirect.limits.sequences
|
||||
{
|
||||
capacity *= 2;
|
||||
}
|
||||
let shape = shape(capacity);
|
||||
// Regions of about 8 MiB, so a few dozen pass the bound: parts of a shape of 1024
|
||||
// commands, each at most `PART_BYTES`.
|
||||
let shape = shape(1024);
|
||||
let parts = ((8 << 20) / shape.part_stride().max(1)).max(1) as u32;
|
||||
let mut held = Vec::new();
|
||||
while counters.gauges().preprocess_used_bytes <= IDLE_BYTES {
|
||||
held.push(ok(name, indirect.executed(core, &shape, 1)).0);
|
||||
held.push(ok(name, indirect.executed(core, &shape, parts)).0);
|
||||
}
|
||||
let regions = held.len();
|
||||
drop(held);
|
||||
@@ -1138,7 +1307,7 @@ mod on_device {
|
||||
);
|
||||
let before = counters.metrics().preprocess_regions_remade;
|
||||
let again: Vec<_> = (0..regions)
|
||||
.map(|_| ok(name, indirect.executed(core, &shape, 1)).0)
|
||||
.map(|_| ok(name, indirect.executed(core, &shape, parts)).0)
|
||||
.collect();
|
||||
let remade = counters.metrics().preprocess_regions_remade - before;
|
||||
assert!(remade > 0, "{name}: regions made again past the bound");
|
||||
@@ -1147,7 +1316,7 @@ mod on_device {
|
||||
let rest = settled(&|idle| idle == 0);
|
||||
assert_eq!(rest, 0, "{name}: the pool at rest");
|
||||
println!(
|
||||
"{name}: {regions} regions of {capacity} commands held past {IDLE_BYTES} bytes \
|
||||
"{name}: {regions} regions of {parts} parts held past {IDLE_BYTES} bytes \
|
||||
went back, {kept} bytes kept idle; {remade} made again past the bound; idle \
|
||||
bytes 0 {} ms after the last went back",
|
||||
since.elapsed().as_millis()
|
||||
|
||||
@@ -90,6 +90,7 @@ pub(crate) mod interface;
|
||||
pub(crate) mod layout;
|
||||
pub(crate) mod link;
|
||||
pub(crate) mod lower_inputs;
|
||||
mod own;
|
||||
pub(crate) mod private_state;
|
||||
pub(crate) mod relocate;
|
||||
pub(crate) mod rotated_blend;
|
||||
@@ -136,6 +137,7 @@ pub use lower_inputs::{
|
||||
FetchedAttachment, FramebufferFetchInputs, KernelVariant, LoweringInputs, StorageImageChoice,
|
||||
StorageImageClass, VertexFetch, VertexFetchProjection,
|
||||
};
|
||||
pub use own::{own_kernel, ExecutionCounts, OwnKernel};
|
||||
pub use table::FunctionHandle;
|
||||
// The vocabulary the pipeline surface reaches: render-pipeline keys, runtime facts and their
|
||||
// mechanisms, and the link symbols artifacts, layouts, and plans name.
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
//! The kernels a consumer runs for its own work beside a program's ([`OwnKernel`]), built from no
|
||||
//! Metal function. Each has the interface every function the translator compiles has: the
|
||||
//! pipeline layout's one push range, which holds the kernel's one field at offset 0, the device
|
||||
//! address (`u64`) of its parameter block in memory the consumer writes for the dispatch
|
||||
//! ([`PushField::ArgumentTableAddress`]), and no descriptor. Each is a compute stage of one
|
||||
//! invocation a workgroup, entry point `main`, dispatched with as many workgroups along x as the
|
||||
//! kernel names.
|
||||
|
||||
use crate::budget::{Budget, Meter};
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::error::Error;
|
||||
use crate::pipeline::sym::PushField;
|
||||
use crate::spirv::builder::{FunctionBuilder, ModuleBuilder};
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{TypeId, Value};
|
||||
use crate::spirv::ir::{BinOp, ConvOp, ExecMode, ExecModel, IoDir, MemAccess, Type, TypedModule};
|
||||
|
||||
/// A kernel of a consumer's own work.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum OwnKernel {
|
||||
/// The sequence counts of an execution of an indirect command buffer's commands over the range
|
||||
/// a buffer holds (Metal's `executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:`)
|
||||
/// that runs the buffer's commands as parts from command 0, each part a
|
||||
/// `vkCmdExecuteGeneratedCommandsEXT` whose `sequenceCountAddress` is its count. Workgroup `p`
|
||||
/// writes part `p`'s count: how many of its commands, from its first, it runs. That is through
|
||||
/// the range's last command, and none for a part wholly before the range's location or wholly
|
||||
/// past its end; a part that holds the location runs its commands before it too, which the
|
||||
/// vertex function's range test skips. The range is clamped to the buffer's commands. Its
|
||||
/// parameter block is [`ExecutionCounts`]'s, and it is dispatched with a workgroup a part.
|
||||
ExecutionCounts,
|
||||
}
|
||||
|
||||
/// The parameter block of [`OwnKernel::ExecutionCounts`]: 8-byte aligned, of
|
||||
/// [`COUNTS_AT`](Self::COUNTS_AT) bytes and 4 a part.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct ExecutionCounts;
|
||||
|
||||
impl ExecutionCounts {
|
||||
/// The device address (`u64`) of the range: Metal's `MTLIndirectCommandBufferExecutionRange`
|
||||
/// there, a `u32` location, then a `u32` length; a multiple of 4.
|
||||
pub const RANGE_AT: u32 = 0;
|
||||
/// The commands of the buffer (`u32`).
|
||||
pub const CAPACITY_AT: u32 = 8;
|
||||
/// The commands of each part (`u32`, not 0); the last part holds the rest.
|
||||
pub const PART_AT: u32 = 12;
|
||||
/// Part 0's count (`u32`), part `p`'s at `COUNTS_AT + 4 * p`: what the kernel writes.
|
||||
pub const COUNTS_AT: u32 = 16;
|
||||
}
|
||||
|
||||
/// `kernel`'s SPIR-V for a device of `profile` (entry point `main`), verified as a compiled
|
||||
/// function's module is.
|
||||
///
|
||||
/// Err: what the verifier finds the profile lacks.
|
||||
pub fn own_kernel(kernel: OwnKernel, profile: &DeviceProfile) -> Result<Vec<u32>, Error> {
|
||||
let module = match kernel {
|
||||
OwnKernel::ExecutionCounts => execution_counts()?,
|
||||
};
|
||||
let mut meter = Meter::new(&Budget::default());
|
||||
crate::spirv::verify::verify(&module, profile, &mut meter)?;
|
||||
// The module names no resource: it has no relocation.
|
||||
Ok(crate::spirv::serialize::serialize(module)?.words)
|
||||
}
|
||||
|
||||
/// A `u32` constant.
|
||||
fn k32(fb: &mut FunctionBuilder<'_>, v: u32) -> BResult<Value> {
|
||||
let c = fb.u32_const(v)?;
|
||||
fb.module().const_value(c)
|
||||
}
|
||||
|
||||
/// The `u32` at `offset` bytes past device address `address`, which nothing writes while the
|
||||
/// kernel runs.
|
||||
fn word(fb: &mut FunctionBuilder<'_>, u32_: TypeId, address: Value, offset: u32) -> BResult<Value> {
|
||||
let at = match offset {
|
||||
0 => address,
|
||||
offset => {
|
||||
let offset = crate::memory::roots::k64(fb, u64::from(offset))?;
|
||||
fb.binary(BinOp::IAdd, address, offset)?
|
||||
}
|
||||
};
|
||||
let place = fb.device_place_read_only(at, u32_)?;
|
||||
let access = MemAccess {
|
||||
aligned: Some(4),
|
||||
..MemAccess::default()
|
||||
};
|
||||
fb.load(place, access)
|
||||
}
|
||||
|
||||
/// The lesser of `a` and `b`, unsigned.
|
||||
fn umin(fb: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult<Value> {
|
||||
let less = fb.binary(BinOp::ULessThan, a, b)?;
|
||||
fb.select(less, a, b)
|
||||
}
|
||||
|
||||
/// [`OwnKernel::ExecutionCounts`].
|
||||
fn execution_counts() -> BResult<TypedModule> {
|
||||
let mut mb = ModuleBuilder::new();
|
||||
let u32_ = mb.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: false,
|
||||
})?;
|
||||
let u64_ = mb.ty(Type::Int {
|
||||
width: 64,
|
||||
signed: false,
|
||||
})?;
|
||||
let uvec3 = mb.ty(Type::Vector { elem: u32_, len: 3 })?;
|
||||
let void = mb.ty(Type::Void)?;
|
||||
let field = mb.push_member(PushField::ArgumentTableAddress, u64_, 0)?;
|
||||
let push = mb.push_global()?;
|
||||
let group = mb.builtin(crate::spv::BuiltIn::WorkgroupId, IoDir::Input, uvec3)?;
|
||||
let mut fb = mb.function(void)?;
|
||||
let base = fb.module().global_value(push)?;
|
||||
let member = k32(&mut fb, field.index)?;
|
||||
let at = fb.access_chain(base, &[member])?;
|
||||
let block = fb.load(at, MemAccess::default())?;
|
||||
let range_at = fb.device_place_read_only(block, u64_)?;
|
||||
let eight = MemAccess {
|
||||
aligned: Some(8),
|
||||
..MemAccess::default()
|
||||
};
|
||||
let range = fb.load(range_at, eight)?;
|
||||
let capacity = word(&mut fb, u32_, block, ExecutionCounts::CAPACITY_AT)?;
|
||||
let part = word(&mut fb, u32_, block, ExecutionCounts::PART_AT)?;
|
||||
let location = word(&mut fb, u32_, range, 0)?;
|
||||
let length = word(&mut fb, u32_, range, 4)?;
|
||||
let group = fb.module().global_value(group)?;
|
||||
let group = fb.load(group, MemAccess::default())?;
|
||||
let p = fb.composite_extract(group, &[0])?;
|
||||
// The range, clamped to the buffer's commands: `[first, end)`.
|
||||
let first = umin(&mut fb, location, capacity)?;
|
||||
let room = fb.binary(BinOp::ISub, capacity, first)?;
|
||||
let taken = umin(&mut fb, length, room)?;
|
||||
let end = fb.binary(BinOp::IAdd, first, taken)?;
|
||||
// Part `p`: `[start, stop)`.
|
||||
let start = fb.binary(BinOp::IMul, p, part)?;
|
||||
let past = fb.binary(BinOp::IAdd, start, part)?;
|
||||
let stop = umin(&mut fb, past, capacity)?;
|
||||
let before_stop = fb.binary(BinOp::ULessThan, first, stop)?;
|
||||
let after_start = fb.binary(BinOp::UGreaterThan, end, start)?;
|
||||
let holds = fb.binary(BinOp::LogicalAnd, before_stop, after_start)?;
|
||||
let through = umin(&mut fb, end, stop)?;
|
||||
let runs = fb.binary(BinOp::ISub, through, start)?;
|
||||
let none = k32(&mut fb, 0)?;
|
||||
let count = fb.select(holds, runs, none)?;
|
||||
let four = k32(&mut fb, 4)?;
|
||||
let offset = fb.binary(BinOp::IMul, p, four)?;
|
||||
let counts = k32(&mut fb, ExecutionCounts::COUNTS_AT)?;
|
||||
let offset = fb.binary(BinOp::IAdd, offset, counts)?;
|
||||
let offset = fb.convert(ConvOp::UConvert, offset, u64_)?;
|
||||
let to = fb.binary(BinOp::IAdd, block, offset)?;
|
||||
let to = fb.device_place(to, u32_)?;
|
||||
let access = MemAccess {
|
||||
aligned: Some(4),
|
||||
..MemAccess::default()
|
||||
};
|
||||
fb.store(to, count, access)?;
|
||||
fb.ret(None)?;
|
||||
let f = fb.finish()?;
|
||||
mb.entry(
|
||||
ExecModel::GLCompute,
|
||||
f,
|
||||
vec![ExecMode::LocalSize { x: 1, y: 1, z: 1 }],
|
||||
)?;
|
||||
mb.finalize()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{execution_counts, own_kernel, ExecutionCounts, OwnKernel};
|
||||
use crate::spirv::interp::{run, Buffer, Config, Resources};
|
||||
|
||||
/// Where the interpreter puts the parameter block and the range.
|
||||
const BLOCK: u64 = 0x1000_0000;
|
||||
const RANGE: u64 = 0x2000_0000;
|
||||
|
||||
/// Part `p`'s count by brute force: one past the part's last command in the range, less the
|
||||
/// part's first; 0 where none of its commands is in the range.
|
||||
fn want(capacity: u32, part: u32, location: u32, length: u32) -> Vec<u32> {
|
||||
let end = u64::from(location) + u64::from(length);
|
||||
let held = |c: u32| c >= location && u64::from(c) < end;
|
||||
(0..capacity.div_ceil(part))
|
||||
.map(|p| {
|
||||
let start = p * part;
|
||||
let stop = (start + part).min(capacity);
|
||||
(start..stop)
|
||||
.rev()
|
||||
.find(|&c| held(c))
|
||||
.map_or(0, |c| c + 1 - start)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The counts the kernel writes on the interpreter, every count's word filled with a mark
|
||||
/// first.
|
||||
fn counts(capacity: u32, part: u32, location: u32, length: u32) -> Vec<u32> {
|
||||
let module = execution_counts().expect("the module");
|
||||
let parts = capacity.div_ceil(part);
|
||||
let mut block = RANGE.to_le_bytes().to_vec();
|
||||
block.extend(capacity.to_le_bytes());
|
||||
block.extend(part.to_le_bytes());
|
||||
assert_eq!(block.len(), ExecutionCounts::COUNTS_AT as usize);
|
||||
block.resize(block.len() + 4 * parts as usize, 0xAB);
|
||||
let range: Vec<u8> = [location, length]
|
||||
.iter()
|
||||
.flat_map(|w| w.to_le_bytes())
|
||||
.collect();
|
||||
let resources = Resources {
|
||||
buffers: vec![
|
||||
Buffer {
|
||||
slot: None,
|
||||
address: Some(BLOCK),
|
||||
bytes: block,
|
||||
},
|
||||
Buffer {
|
||||
slot: None,
|
||||
address: Some(RANGE),
|
||||
bytes: range,
|
||||
},
|
||||
],
|
||||
push: BLOCK.to_le_bytes().to_vec(),
|
||||
spec: Default::default(),
|
||||
};
|
||||
let config = Config {
|
||||
workgroups: [parts, 1, 1],
|
||||
..Config::default()
|
||||
};
|
||||
let out = run(&module, &config, resources).expect("the run");
|
||||
(out.buffers[0][ExecutionCounts::COUNTS_AT as usize..].chunks(4))
|
||||
.map(|w| u32::from_le_bytes(w.try_into().expect("a word")))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Each part's count runs through the range's last command and no further, none for a part
|
||||
/// wholly before the location or past the end, over ranges at location 0, inside a part,
|
||||
/// across parts, empty, past the commands and of the widest `u32`s.
|
||||
#[test]
|
||||
fn each_parts_count_runs_through_the_ranges_last_command() {
|
||||
for (capacity, part) in [(10, 4), (785, 785), (1, 1), (64, 7), (8162, 2701)] {
|
||||
let ranges = [
|
||||
(0, capacity),
|
||||
(0, 0),
|
||||
(0, 3),
|
||||
(3, 2),
|
||||
(5, 3),
|
||||
(part, part),
|
||||
(part + part / 2, part),
|
||||
(capacity - 1, 100),
|
||||
(capacity + 2, 5),
|
||||
(0, u32::MAX),
|
||||
(u32::MAX, u32::MAX),
|
||||
];
|
||||
for (location, length) in ranges {
|
||||
assert_eq!(
|
||||
counts(capacity, part, location, length),
|
||||
want(capacity, part, location, length),
|
||||
"{capacity} commands in parts of {part}, the range {location} for {length}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The kernel is valid SPIR-V (the owned verifier and `spirv-val`) on every committed profile,
|
||||
/// and the public function makes it there.
|
||||
#[test]
|
||||
fn the_count_kernel_is_valid_on_every_committed_profile() {
|
||||
let profiles = crate::spirv::testing::committed_profiles().expect("the profiles");
|
||||
for (stem, profile) in &profiles {
|
||||
let module = execution_counts().expect("the module");
|
||||
if let Err(e) = crate::spirv::testing::check_valid(module, profile) {
|
||||
panic!("{stem}: {e}");
|
||||
}
|
||||
if let Err(e) = own_kernel(OwnKernel::ExecutionCounts, profile) {
|
||||
panic!("{stem}: {e}");
|
||||
}
|
||||
}
|
||||
assert!(!profiles.is_empty(), "no committed profile");
|
||||
}
|
||||
}
|
||||
@@ -211,6 +211,10 @@ assoc-const metal2vulkan::pipeline::CommandWrites::RENDER_STATE pub const RENDER
|
||||
assoc-const metal2vulkan::pipeline::CommandWrites::RESET pub const RESET: u32
|
||||
assoc-const metal2vulkan::pipeline::CommandWrites::STAGE_IN_REGION pub const STAGE_IN_REGION: u32
|
||||
assoc-const metal2vulkan::pipeline::CommandWrites::THREADGROUP_MEMORY pub const THREADGROUP_MEMORY: u32
|
||||
assoc-const metal2vulkan::pipeline::ExecutionCounts::CAPACITY_AT pub const CAPACITY_AT: u32
|
||||
assoc-const metal2vulkan::pipeline::ExecutionCounts::COUNTS_AT pub const COUNTS_AT: u32
|
||||
assoc-const metal2vulkan::pipeline::ExecutionCounts::PART_AT pub const PART_AT: u32
|
||||
assoc-const metal2vulkan::pipeline::ExecutionCounts::RANGE_AT pub const RANGE_AT: u32
|
||||
assoc-const metal2vulkan::pipeline::FunctionHandle::NULL_WORD pub const NULL_WORD: u32
|
||||
assoc-const metal2vulkan::pipeline::FunctionHandle::RESERVED_WORD pub const RESERVED_WORD: u32
|
||||
assoc-const metal2vulkan::pipeline::IndirectDrawLayout::CAPACITY_AT pub const CAPACITY_AT: u32
|
||||
@@ -433,6 +437,10 @@ assoc-const-value metal2vulkan::pipeline::CommandWrites::RENDER_STATE 1 <<9
|
||||
assoc-const-value metal2vulkan::pipeline::CommandWrites::RESET 1 <<13
|
||||
assoc-const-value metal2vulkan::pipeline::CommandWrites::STAGE_IN_REGION 1 <<11
|
||||
assoc-const-value metal2vulkan::pipeline::CommandWrites::THREADGROUP_MEMORY 1 <<10
|
||||
assoc-const-value metal2vulkan::pipeline::ExecutionCounts::CAPACITY_AT 8
|
||||
assoc-const-value metal2vulkan::pipeline::ExecutionCounts::COUNTS_AT 16
|
||||
assoc-const-value metal2vulkan::pipeline::ExecutionCounts::PART_AT 12
|
||||
assoc-const-value metal2vulkan::pipeline::ExecutionCounts::RANGE_AT 0
|
||||
assoc-const-value metal2vulkan::pipeline::FunctionHandle::NULL_WORD 0
|
||||
assoc-const-value metal2vulkan::pipeline::FunctionHandle::RESERVED_WORD 1
|
||||
assoc-const-value metal2vulkan::pipeline::IndirectDrawLayout::CAPACITY_AT 0
|
||||
@@ -932,6 +940,7 @@ enum metal2vulkan::pipeline::KernelVariant #[cfg_attr(feature = "serde", derive(
|
||||
enum metal2vulkan::pipeline::LinkedList #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum LinkedList<'a>
|
||||
enum metal2vulkan::pipeline::Mechanism #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Mechanism
|
||||
enum metal2vulkan::pipeline::NumberedSampler #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum NumberedSampler
|
||||
enum metal2vulkan::pipeline::OwnKernel #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum OwnKernel
|
||||
enum metal2vulkan::pipeline::PatchDomain #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum PatchDomain
|
||||
enum metal2vulkan::pipeline::PrecisionNote #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum PrecisionNote
|
||||
enum metal2vulkan::pipeline::PushField #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum PushField
|
||||
@@ -3470,6 +3479,7 @@ fn metal2vulkan::pipeline::grid_tile pub fn grid_tile(threads: [u32; 3]) -> [u32
|
||||
fn metal2vulkan::pipeline::heap_sampler_capacity pub fn heap_sampler_capacity(p: &DeviceProfile) -> u32
|
||||
fn metal2vulkan::pipeline::heap_unused_while_pending pub fn heap_unused_while_pending(p: &DeviceProfile) -> bool
|
||||
fn metal2vulkan::pipeline::nonuniform_region_bytes pub fn nonuniform_region_bytes(base: [u32; 3], threads: [u32; 3], l: [u32; 3]) -> Option<[u8; 32]>
|
||||
fn metal2vulkan::pipeline::own_kernel pub fn own_kernel(kernel: OwnKernel, profile: &DeviceProfile) -> Result<Vec<u32>, Error>
|
||||
fn metal2vulkan::pipeline::region_bytes pub fn region_bytes(base: [u32; 3], threads: [u32; 3], l: [u32; 3]) -> Option<[u8; 32]>
|
||||
macro-decl metal2vulkan-air::ir::ArgIdx ir_id! ArgIdx
|
||||
macro-decl metal2vulkan-air::ir::BlockId id_type! BlockId
|
||||
@@ -7861,6 +7871,7 @@ struct metal2vulkan::pipeline::DescriptorSetLayout #[cfg_attr(feature = "serde",
|
||||
struct metal2vulkan::pipeline::DynamicLibraries #[derive(Clone, Debug, Default, PartialEq, Eq)] #[non_exhaustive] pub struct DynamicLibraries
|
||||
struct metal2vulkan::pipeline::EntryDescriptor #[derive(Clone, Debug)] #[non_exhaustive] pub struct EntryDescriptor<'a>
|
||||
struct metal2vulkan::pipeline::EntryPlan #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct EntryPlan
|
||||
struct metal2vulkan::pipeline::ExecutionCounts #[derive(Clone, Copy, Debug)] pub struct ExecutionCounts
|
||||
struct metal2vulkan::pipeline::ExtendedRangeColor #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct ExtendedRangeColor
|
||||
struct metal2vulkan::pipeline::FetchedAttachment #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct FetchedAttachment
|
||||
struct metal2vulkan::pipeline::FramebufferFetchInputs #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct FramebufferFetchInputs
|
||||
@@ -10883,6 +10894,7 @@ variant metal2vulkan::pipeline::Mechanism::Variant Variant
|
||||
variant metal2vulkan::pipeline::NumberedSampler::Constexpr Constexpr([u64; 2])
|
||||
variant metal2vulkan::pipeline::NumberedSampler::Read Read
|
||||
variant metal2vulkan::pipeline::NumberedSampler::Write Write
|
||||
variant metal2vulkan::pipeline::OwnKernel::ExecutionCounts ExecutionCounts
|
||||
variant metal2vulkan::pipeline::PatchDomain::Quad Quad
|
||||
variant metal2vulkan::pipeline::PatchDomain::Triangle Triangle
|
||||
variant metal2vulkan::pipeline::PrecisionNote::AnisotropicFilter AnisotropicFilter
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -312,6 +312,9 @@ surface! {
|
||||
const GRID_TILE_THREADS;
|
||||
const DEEP_THREADGROUP;
|
||||
const COMPILED_STAGE_WEIGHT;
|
||||
fn own_kernel;
|
||||
struct ExecutionCounts E;
|
||||
enum OwnKernel N;
|
||||
struct ComputePipeline N;
|
||||
struct ComputePipelineMetalInfo N;
|
||||
struct CompileReport N;
|
||||
|
||||
@@ -263,6 +263,12 @@ and so do the command line, the compile worker and every validation tool. It hol
|
||||
and its command, `PushField::IndirectSequence` (a part's sequence index) plus
|
||||
`PushField::IndirectBase` (the part's first command), a command outside the range draws nothing,
|
||||
and the function pulls every vertex attribute it reads.
|
||||
Where the GPU writes the range, the parts' counts come from a kernel built from no Metal
|
||||
function, `pipeline::own_kernel(OwnKernel::ExecutionCounts, profile)`: one workgroup a part
|
||||
reads the range and writes the part's count, the commands it runs through the range's last,
|
||||
into the parameter block `pipeline::ExecutionCounts` lays out, where each part's
|
||||
`sequenceCountAddress` reads it. Its interface is a compiled function's: the one push range,
|
||||
holding the block's device address at offset 0, and no descriptor.
|
||||
- **The resident-table domains** (`DevicePolicy::RESIDENT_TABLES`: `PointerDomain::ResidentTable`
|
||||
with `HandleDomain::Table`) exist for the validation executor alone, which builds the resident
|
||||
root and the handle table itself. Besides it, only the translator's own tests of that lowering
|
||||
|
||||
+6
-6
@@ -273,9 +273,9 @@ Columns:
|
||||
| `OtherDevice` | An event, a buffer, a texture or a pipeline state of another device in an encode call (`CommandBuffer::encode_wait_for_event`,... | every device (a public call's own check of its arguments) | `ours`: an event's semaphore, a buffer's block, a texture's image, a pipeline and a block belong to the `VkDevice` that made them | 39: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`, `crates/metal2vulkan-runtime/src/blit.rs (copy_from_buffer_to_buffer)` (+32) | `-` |
|
||||
| `NoCommandBuffers` | A queue that may hold no command buffer (`Device::new_command_queue` with a count of 0) | every device (a public call's own check of its arguments) | `ours`: its first `commandBuffer` call would wait forever | 1: `crates/metal2vulkan-runtime/src/queue.rs (new_command_queue)` | `-` |
|
||||
| `EncoderOpen` | A second encoder, an encode call, or a commit or enqueue, while an encoder of the command buffer is open | every device (a public call's own check of its arguments) | `metal-documented`: a command buffer has one active encoder at a time, ended by `endEncoding` before another is made or the command buffer is committed | 1: `crates/metal2vulkan-runtime/src/command.rs (open)` | `-` |
|
||||
| `NoPipeline` | A dispatch or a draw with no pipeline state set | every device (a public call's own check of its arguments) | `metal-documented`: a compute dispatch needs a compute pipeline state set first, and a draw a render pipeline state | 3: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)` (+1) | `-` |
|
||||
| `NoPipeline` | A dispatch or a draw with no pipeline state set | every device (a public call's own check of its arguments) | `metal-documented`: a compute dispatch needs a compute pipeline state set first, and a draw a render pipeline state | 4: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)` (+2) | `-` |
|
||||
| `CommandRange` | A range of an indirect command buffer's commands past them, in an execution (`RenderCommandEncoder::execute_commands_in_buffer`), a reset or an... | every device (a public call's own check of its arguments) | `metal-documented`: each call names commands of the buffer, and the offset of a range a buffer holds must be a multiple of 4 bytes | 4: `crates/metal2vulkan-runtime/src/blit.rs (optimize_indirect_command_buffer)`, `crates/metal2vulkan-runtime/src/blit.rs (reset_commands_in_buffer)` (+2) | `-` |
|
||||
| `PatchDraw` | A draw of patches with a render pipeline state whose vertex function is not a post-tessellation one, or a draw of primitives with one whose vertex... | every device (a public call's own check of its arguments) | `metal-measured`: an M4: plain Metal stops its process over a patch draw with a pipeline that is not a tessellation one, its validation off; Metal's validation stops a draw of primitives with a tessellation pipeline | 1: `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)` | `-` |
|
||||
| `PatchDraw` | A draw of patches with a render pipeline state whose vertex function is not a post-tessellation one, or a draw of primitives with one whose vertex... | every device (a public call's own check of its arguments) | `metal-measured`: an M4: plain Metal stops its process over a patch draw with a pipeline that is not a tessellation one, its validation off; Metal's validation stops a draw of primitives with a tessellation pipeline | 2: `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (execution_part)` | `-` |
|
||||
| `NoTessellationFactorBuffer` | A draw of patches while the encoder has no tessellation factor buffer (`setTessellationFactorBuffer:offset:instanceStride:`) | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal ends the process, SIGSEGV, at a quad patch draw with no tessellation factor buffer, where the same draw with one set runs and paints the target, the API validation layer off | 1: `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)` | `-` |
|
||||
| `PointSizeTopology` | `Device::new_render_pipeline_state` of a vertex function that writes `[[point_size]]` under the line or the triangle input primitive topology... | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, every class crossed with both shapes of vertex function: Metal's pipeline creation fails with `Vertex shader writes point size but inputPrimitiveTopology is MTLPrimitiveTopologyClassLine`, and its `Triangle` counterpart; the conformance crate's `topology-class-point-size-function` compares it | 1: `crates/metal2vulkan-runtime/src/render.rs (of)` | `-` |
|
||||
| `BufferIndex` | A buffer argument index past Metal's 31 entries (`setBuffer`, `setBytes`, `setBufferOffset`, `setThreadgroupMemoryLength`) | every device (a public call's own check of its arguments) | `metal-documented`: the buffer argument table has 31 entries per stage | 2: `crates/metal2vulkan-runtime/src/encoder.rs (slot)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (slot)` | `-` |
|
||||
@@ -361,7 +361,7 @@ Columns:
|
||||
|
||||
| Variant | What it blocks | Where | Basis | Sites | Reach |
|
||||
|---|---|---|---|---|---|
|
||||
| `IndirectCommandBuffers` | An indirect command buffer, its execution, or a compute pipeline state for one, of what the runtime does not build, `kind` naming it | every device (a public call's own check of its arguments) | `ours`: the first cut of indirect command buffers builds that alone | 4: `crates/metal2vulkan-runtime/src/indirect.rs (new_indirect_command_buffer)`, `crates/metal2vulkan-runtime/src/indirect.rs (shape)` (+2) | `-` |
|
||||
| `IndirectCommandBuffers` | An indirect command buffer, its execution, or a compute pipeline state for one, of what the runtime does not build, `kind` naming it | every device (a public call's own check of its arguments) | `ours`: the first cut of indirect command buffers builds that alone | 5: `crates/metal2vulkan-runtime/src/indirect.rs (new_indirect_command_buffer)`, `crates/metal2vulkan-runtime/src/indirect.rs (shape)` (+3) | `-` |
|
||||
| `KernelInput` | A kernel that reads something the compute encoder does not supply yet, `kind` naming what | every device (a public call's own check of its arguments) | `ours`: the encoder supplies only those | 1: `crates/metal2vulkan-runtime/src/pipeline.rs (gap)` | `-` |
|
||||
| `ImageblockLength` | An imageblock length Metal answers that no case measures | every device (a public call's own check of its arguments) | `ours`: the length is not measured against Metal's | 2: `crates/metal2vulkan-runtime/src/pipeline.rs (imageblock_memory_length_for_dimensions)`, `crates/metal2vulkan-runtime/src/render.rs (imageblock_sample_length)` | `-` |
|
||||
| `PartialSimdgroups` | A dispatch whose threadgroup is not whole SIMD groups of a kernel whose tier runs each SIMD group as one subgroup of `width` threads (a pinned... | every device (a public call's own check of its arguments) | `ours`: no emulated-SIMD-group module | 1: `crates/metal2vulkan-runtime/src/encoder.rs (decide)` | `-` |
|
||||
@@ -572,9 +572,9 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Refusal::OtherDevice`: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-runtime/src/blit.rs (copy_from_buffer_to_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (copy_from_texture)`; `crates/metal2vulkan-runtime/src/blit.rs (fill_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)`; `crates/metal2vulkan-runtime/src/blit.rs (optimize_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (release_surface_to_external)`; `crates/metal2vulkan-runtime/src/blit.rs (release_to_external)`; `crates/metal2vulkan-runtime/src/blit.rs (reset_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (synchronize_resource)`; `crates/metal2vulkan-runtime/src/command.rs (check)`; `crates/metal2vulkan-runtime/src/command.rs (present_drawable)`; `crates/metal2vulkan-runtime/src/device.rs (release_block)`; `crates/metal2vulkan-runtime/src/encoder.rs (dispatch_threadgroups_with_indirect_buffer)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_buffer)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_sampler_state)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_texture)`; `crates/metal2vulkan-runtime/src/encoder.rs (use_resource, 3 sites)`; `crates/metal2vulkan-runtime/src/fence.rs (check)`; `crates/metal2vulkan-runtime/src/pass.rs (check, 2 sites)`; `crates/metal2vulkan-runtime/src/pass.rs (resolve)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execute_commands_in_buffer_with_range)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (indirect)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_depth_stencil_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_render_pipeline_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_sampler_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_tessellation_factor_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_texture)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (use_resource, 3 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (new_managed_texture)`
|
||||
- `rt:Refusal::NoCommandBuffers`: `crates/metal2vulkan-runtime/src/queue.rs (new_command_queue)`
|
||||
- `rt:Refusal::EncoderOpen`: `crates/metal2vulkan-runtime/src/command.rs (open)`
|
||||
- `rt:Refusal::NoPipeline`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_reaches)`
|
||||
- `rt:Refusal::NoPipeline`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_reaches)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execution_part)`
|
||||
- `rt:Refusal::CommandRange`: `crates/metal2vulkan-runtime/src/blit.rs (optimize_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (reset_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execute_commands_in_buffer_with_range)`
|
||||
- `rt:Refusal::PatchDraw`: `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`
|
||||
- `rt:Refusal::PatchDraw`: `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execution_part)`
|
||||
- `rt:Refusal::NoTessellationFactorBuffer`: `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`
|
||||
- `rt:Refusal::PointSizeTopology`: `crates/metal2vulkan-runtime/src/render.rs (of)`
|
||||
- `rt:Refusal::BufferIndex`: `crates/metal2vulkan-runtime/src/encoder.rs (slot)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (slot)`
|
||||
@@ -650,7 +650,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Limit::NoExport`: `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)`; `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
|
||||
- `rt:Limit::ExportType`: `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`; `crates/metal2vulkan-runtime/src/import.rs (surface_import)`; `crates/metal2vulkan-runtime/src/memory.rs (export)`; `crates/metal2vulkan-runtime/src/memory.rs (surface_view)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
|
||||
- `rt:Limit::TextureSamples`: `crates/metal2vulkan-runtime/src/texture.rs (plan)`
|
||||
- `rt:Gap::IndirectCommandBuffers`: `crates/metal2vulkan-runtime/src/indirect.rs (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/indirect.rs (shape)`; `crates/metal2vulkan-runtime/src/pipeline.rs (compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`
|
||||
- `rt:Gap::IndirectCommandBuffers`: `crates/metal2vulkan-runtime/src/indirect.rs (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/indirect.rs (shape)`; `crates/metal2vulkan-runtime/src/pipeline.rs (compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execution_part)`
|
||||
- `rt:Gap::KernelInput`: `crates/metal2vulkan-runtime/src/pipeline.rs (gap)`
|
||||
- `rt:Gap::ImageblockLength`: `crates/metal2vulkan-runtime/src/pipeline.rs (imageblock_memory_length_for_dimensions)`; `crates/metal2vulkan-runtime/src/render.rs (imageblock_sample_length)`
|
||||
- `rt:Gap::PartialSimdgroups`: `crates/metal2vulkan-runtime/src/encoder.rs (decide)`
|
||||
|
||||
Reference in new issue
Block a user