Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

FrameBuffer

Struct FrameBuffer 

Source
pub struct FrameBuffer {
    pub width: u16,
    pub height: u16,
    pub stride: u16,
    pub drawing: u8,
}
👎Deprecated:

use psx_gpu::display::DoubleBuffer, whose methods take the Gpu

Expand description

Tracks display-start between two vertically stacked buffers.

Fields§

§width: u16
👎Deprecated:

use psx_gpu::display::DoubleBuffer, whose methods take the Gpu

Display width in pixels (set by FrameBuffer::new).

§height: u16
👎Deprecated:

use psx_gpu::display::DoubleBuffer, whose methods take the Gpu

Display height in pixels.

§stride: u16
👎Deprecated:

use psx_gpu::display::DoubleBuffer, whose methods take the Gpu

Vertical distance in VRAM rows between the two buffers.

§drawing: u8
👎Deprecated:

use psx_gpu::display::DoubleBuffer, whose methods take the Gpu

Index (0 or 1) of the buffer currently drawn TO.

Implementations§

Source§

impl FrameBuffer

Source

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.

Source

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.

Source

pub const fn buffer_y(&self, idx: u8) -> u16

Y-coordinate of buffer idx in VRAM.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn clear(&self, r: u8, g: u8, b: u8)

Clear the back-buffer (the one currently being drawn to) to (r, g, b).

Trait Implementations§

Source§

impl Debug for FrameBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for FrameBuffer

§

impl RefUnwindSafe for FrameBuffer

§

impl Send for FrameBuffer

§

impl Sync for FrameBuffer

§

impl Unpin for FrameBuffer

§

impl UnsafeUnpin for FrameBuffer

§

impl UnwindSafe for FrameBuffer

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.