pub struct FrameBuffer {
pub width: u16,
pub height: u16,
pub stride: u16,
pub drawing: u8,
}use psx_gpu::display::DoubleBuffer, whose methods take the Gpu
Expand description
Tracks display-start between two vertically stacked buffers.
Fields§
§width: u16use psx_gpu::display::DoubleBuffer, whose methods take the Gpu
Display width in pixels (set by FrameBuffer::new).
height: u16use psx_gpu::display::DoubleBuffer, whose methods take the Gpu
Display height in pixels.
stride: u16use psx_gpu::display::DoubleBuffer, whose methods take the Gpu
Vertical distance in VRAM rows between the two buffers.
drawing: u8use psx_gpu::display::DoubleBuffer, whose methods take the Gpu
Index (0 or 1) of the buffer currently drawn TO.
Implementations§
Source§impl FrameBuffer
impl FrameBuffer
Sourcepub const fn new(width: u16, height: u16) -> Self
pub const fn new(width: u16, height: u16) -> Self
Create a framebuffer for the given active display size. Buffer
A lives at VRAM Y=0, buffer B at Y=height.
Sourcepub const fn new_strided(width: u16, height: u16, stride: u16) -> Self
pub const fn new_strided(width: u16, height: u16, stride: u16) -> Self
Create vertically stacked buffers with an explicit row stride.
This supports layouts which reserve rows between the visible buffers,
such as a 320x240 display at Y=0 and Y=256 with palettes in the gap.
A stride smaller than height is clamped so the buffers cannot overlap.
Sourcepub fn swap(&mut self)
pub fn swap(&mut self)
Push a display-start command for the buffer we’re NOT currently drawing to – flipping the display at the next VBlank.
Sourcepub fn begin_swap(&mut self) -> u32
pub fn begin_swap(&mut self) -> u32
Deferred-present half of FrameBuffer::swap: switch the DRAW side
now and return the GP1 display-start word for the finished buffer,
for the caller to apply exactly at a blank edge (e.g. via psx-rt’s
queued-GP1 VBlank hook). Drawing must be finished
(crate::wait_idle) before this call, because it rewrites the draw
area/offset directly.
Sourcepub fn begin_deferred_swap(&mut self) -> u32
pub fn begin_deferred_swap(&mut self) -> u32
Select the next draw buffer without writing any GP0 commands.
This is the non-blocking first half of a pipelined swap. Queue the
returned GP1 word for a VBlank edge whose handler applies it only once
the frame’s closing GP0(1Fh) has run (psx-rt’s
interrupts::queue_display_control_at_vblank; see crate::is_draw_done), wait
until that queue entry is consumed, then call
FrameBuffer::apply_draw_target before clearing or drawing into the
newly selected buffer.
Unlike FrameBuffer::begin_swap, this method is safe to call while
the previous frame is still rasterising: it only changes CPU-owned
bookkeeping and does not touch the GPU command port.
Sourcepub fn apply_draw_target(&self)
pub fn apply_draw_target(&self)
Program GP0 draw area and offset for the currently selected draw side.
Call this after a display-start queued by
FrameBuffer::begin_deferred_swap has been applied at a VBlank edge
that found the frame drawn. It deliberately remains separate from buffer selection so
a busy raster never turns these three state writes into a synchronous
CPU wait at the start of the next frame.