pub struct OtFrame<'f, const N: usize> { /* private fields */ }Expand description
One frame’s view of an OrderingTable: insert packets, then submit.
Made by OrderingTable::frame. Every packet added must live for 'f,
the frame’s borrow of the table, and is exclusively borrowed for that
long; submitting consumes the frame and waits for the walk.
Implementations§
Source§impl<'f, const N: usize> OtFrame<'f, N>
impl<'f, const N: usize> OtFrame<'f, N>
Sourcepub fn add<P: GpuPacket>(&mut self, z: usize, packet: &'f mut P)
pub fn add<P: GpuPacket>(&mut self, z: usize, packet: &'f mut P)
Prepend packet to depth slot z (clamped to N - 1). Slot N - 1
is walked first, slot 0 last, so lower slots draw on top.
Sourcepub unsafe fn add_raw(&mut self, z: usize, packet: *mut u32, words: u8)
pub unsafe fn add_raw(&mut self, z: usize, packet: *mut u32, words: u8)
Prepend a raw packet to depth slot z (clamped to N - 1).
§Safety
packet must point at a 4-byte-aligned tag word followed by words
payload words, all in RAM that stays live and unmodified, except for
the tag this call writes, until this frame’s walk has finished (or
for good, if the frame is never submitted).
§Panics
If words exceeds crate::chain::MAX_NODE_WORDS.
Sourcepub unsafe fn add_raw_unchecked(
&mut self,
z: usize,
packet: *mut u32,
words: u8,
)
pub unsafe fn add_raw_unchecked( &mut self, z: usize, packet: *mut u32, words: u8, )
add_raw without the depth clamp or the node-length
check.
§Safety
The contract of add_raw, and also: z is less
than N, and words is at most crate::chain::MAX_NODE_WORDS.
Sourcepub unsafe fn add_raw_tag_high_unchecked(
&mut self,
z: usize,
packet: *mut u32,
tag_high: u32,
)
pub unsafe fn add_raw_tag_high_unchecked( &mut self, z: usize, packet: *mut u32, tag_high: u32, )
add_raw_unchecked with the word count
already in tag form, in bits 24..31 of tag_high.
§Safety
The contract of add_raw_unchecked, with
tag_high >> 24 as the word count, and also: the low 24 bits of
tag_high are zero.
Sourcepub unsafe fn add_packed_commands_unchecked(
&mut self,
commands: *const usize,
command_count: usize,
)
pub unsafe fn add_packed_commands_unchecked( &mut self, commands: *const usize, command_count: usize, )
Add packed two-word commands, first to last, the way repeated classic
addPrim calls do: packets that share a slot come out in reverse.
Each command is two machine words: the packet’s address (ptr as usize, which exposes it), then a word with the slot in bits 0..=15
and the packet’s payload word count in bits 24..=31. On the console
this is one hand-scheduled loop; host builds run a scalar twin.
§Safety
commands points at command_count * 2 readable words in that
layout; every slot is less than N and every word count at most
crate::chain::MAX_NODE_WORDS; and every packet meets the contract of
add_raw.
Sourcepub unsafe fn add_packed_commands_reverse_unchecked(
&mut self,
commands: *const usize,
command_count: usize,
)
pub unsafe fn add_packed_commands_reverse_unchecked( &mut self, commands: *const usize, command_count: usize, )
add_packed_commands_unchecked
last to first, so packets that share a slot keep their array order.
§Safety
Sourcepub unsafe fn add_tagged_packet_stream_unchecked(
&mut self,
first: *mut u32,
end: *mut u32,
)
pub unsafe fn add_tagged_packet_stream_unchecked( &mut self, first: *mut u32, end: *mut u32, )
Add a contiguous stream of packets whose tags carry their own slot.
Before this call each tag holds the packet’s payload word count in
bits 24..=31 and its slot in bits 0..=15. Packets are prepended from
first to end, as repeated addPrim calls would; slot 0xFFFF
skips a packet, so separately ordered HUD packets can share the
arena. Renderers stage depth keys in the tags as they build packets
and leave the link pass to this one loop.
§Safety
first..end is a writable, contiguous sequence of complete packets
in that layout; every word count describes the next packet exactly
and is at most crate::chain::MAX_NODE_WORDS; every slot other than
0xFFFF is less than N; and the whole range meets the contract of
add_raw.
Sourcepub unsafe fn add_tagged_packet_stream_shifted_unchecked<const SLOT_SHIFT: u32>(
&mut self,
first: *mut u32,
end: *mut u32,
)
pub unsafe fn add_tagged_packet_stream_shifted_unchecked<const SLOT_SHIFT: u32>( &mut self, first: *mut u32, end: *mut u32, )
add_tagged_packet_stream_unchecked
with every staged slot other than 0xFFFF shifted right by
SLOT_SHIFT, so a smaller table can back a fine depth range
(SLOT_SHIFT = 3 maps depths 0..2047 onto 256 slots).
§Safety
As add_tagged_packet_stream_unchecked,
with every shifted slot less than N, and SLOT_SHIFT less than 16.
Sourcepub fn end_with_draw_done(&mut self)
pub fn end_with_draw_done(&mut self)
End the walk with GP0(1Fh) so crate::is_draw_done rises once the
frame is drawn; see OrderingTable::end_with_draw_done.
§Panics
If anything was already added at slot 0, or the frame already ends in a link.
Sourcepub fn submit_head(&self) -> *const u32
pub fn submit_head(&self) -> *const u32
The node the frame’s walk starts at, for a chain that continues into
this frame (a recorded preamble handed to psx_rt::present). Only an
address: kicking a walk from it is up to an unsafe call that takes on
the frame’s lifetime itself.
Sourcepub unsafe fn end_with_chain(&mut self, head: *const u32)
pub unsafe fn end_with_chain(&mut self, head: *const u32)
Continue this frame’s walk into head, a chain that ends the list
itself; see OrderingTable::end_with_chain.
§Safety
Every node reachable from head must stay live and unmodified for
'f, and for any walk of this frame that outlives it, under
crate::chain::submit_async_raw’s node rules.
§Panics
If anything was already added at slot 0, or the frame already ends in a link.
Sourcepub fn link_after<const M: usize>(&mut self, next: OtFrame<'f, M>)
pub fn link_after<const M: usize>(&mut self, next: OtFrame<'f, M>)
Continue this frame’s walk into next once its own slot 0 is done,
so both tables go out in one kick.
next is consumed: its table stays borrowed for 'f and is walked as
part of this frame. Its own packets keep their order; anything added
to this frame’s slot 0 afterwards still draws before next.
Host builds link for real, but OrderingTable::packets only
follows links within one table’s address window.
§Panics
If anything was already added at slot 0, or the frame already ends
in a link or GP0(1Fh): call it before slot 0 is used, and close only
the last frame of a chain with end_with_draw_done.
Sourcepub fn submit_with<R>(self, _dma: &mut GpuDma, overlap: impl FnOnce() -> R) -> R
pub fn submit_with<R>(self, _dma: &mut GpuDma, overlap: impl FnOnce() -> R) -> R
Kick the walk, run overlap while the GPU walks, then wait.
overlap cannot reach the table or the packets: they are still
borrowed by this frame.