pub struct FramePair<const N: usize, S: 'static> { /* private fields */ }Expand description
Two FrameStorages in the usual ping-pong: build frame N+1 into one
while the GPU walks frame N from the other.
ⓘ
loop {
pair.build(|frame, packets| { /* add packets */ });
pair.wait(); // frame N's walk is done
psx_gpu::arm_draw_done(); // anything that must precede the kick
pair.kick(); // frame N+1 goes out; storages swap
}Implementations§
Source§impl<const N: usize, S> FramePair<N, S>
impl<const N: usize, S> FramePair<N, S>
Sourcepub fn new(
a: &'static mut FrameStorage<N, S>,
b: &'static mut FrameStorage<N, S>,
dma: GpuDma,
) -> Self
pub fn new( a: &'static mut FrameStorage<N, S>, b: &'static mut FrameStorage<N, S>, dma: GpuDma, ) -> Self
Ping-pong between a and b, owning the GPU DMA token.
Sourcepub fn build<R>(
&mut self,
build: impl for<'f> FnOnce(&mut OtFrame<'f, N>, &'f mut S) -> R,
) -> R
pub fn build<R>( &mut self, build: impl for<'f> FnOnce(&mut OtFrame<'f, N>, &'f mut S) -> R, ) -> R
Build the next frame into the storage the GPU is not walking.
Building again before kick starts that frame over.
Sourcepub fn wait(&mut self) -> &mut GpuDma
pub fn wait(&mut self) -> &mut GpuDma
Wait until the frame kicked last has been walked, and lend the token for work that must not overlap it (VRAM uploads, immediate GP0).
Sourcepub fn kick(&mut self)
pub fn kick(&mut self)
Wait for the previous walk, kick the frame built last, and switch
build to the other storage.
Sourcepub fn release(self) -> ([&'static mut FrameStorage<N, S>; 2], GpuDma)
pub fn release(self) -> ([&'static mut FrameStorage<N, S>; 2], GpuDma)
Wait for the last walk, then hand back both storages and the token.