pub struct DoubleBuffer { /* private fields */ }Expand description
Two framebuffers stacked in VRAM: the GPU shows one while the other is
drawn, and swap exchanges them.
The first buffer sits at VRAM line 0 and the second stride lines
below it, so a 320×240 pair fits beside textures in the 1024×512 VRAM.
use psx_gpu::display::{DoubleBuffer, Resolution};
let buffers = DoubleBuffer::with_stride(Resolution::R320X240, 256);
assert_eq!(buffers.draw_origin(), (0, 0));
assert_eq!(buffers.display_origin(), (0, 256));Implementations§
Source§impl DoubleBuffer
impl DoubleBuffer
Sourcepub const fn new(resolution: Resolution) -> Self
pub const fn new(resolution: Resolution) -> Self
Buffers of resolution, the second directly below the first.
Sourcepub const fn with_stride(resolution: Resolution, stride: u16) -> Self
pub const fn with_stride(resolution: Resolution, stride: u16) -> Self
Buffers stride VRAM lines apart, leaving the lines between them
free (palettes, say). A stride below the height is raised to it so
the buffers never overlap.
§Panics
If the second buffer would end past VRAM line 512 (a 480-line resolution can’t be double-buffered this way).
Sourcepub const fn draw_origin(&self) -> (u16, u16)
pub const fn draw_origin(&self) -> (u16, u16)
Top-left VRAM corner of the buffer being drawn.
Sourcepub const fn display_origin(&self) -> (u16, u16)
pub const fn display_origin(&self) -> (u16, u16)
Top-left VRAM corner of the buffer being shown.
Sourcepub fn swap(&mut self, gpu: &mut Gpu)
pub fn swap(&mut self, gpu: &mut Gpu)
Show the buffer just drawn and draw into the other one from now on.
Flips at once (GP1(05h)); the hardware latches the start at the next
frame. Drawing must be finished (crate::Gpu::wait_idle) first.
Sourcepub fn begin_swap(&mut self, gpu: &mut Gpu) -> u32
pub fn begin_swap(&mut self, gpu: &mut Gpu) -> u32
Switch the draw side now and program its draw area and offset, and
return the GP1(05h) word that shows the finished buffer, for the
caller to apply at a blank edge (psx-rt’s queued flip). Drawing must
be finished (crate::Gpu::wait_idle) first.
Sourcepub fn begin_deferred_swap(&mut self) -> u32
pub fn begin_deferred_swap(&mut self) -> u32
Select the next draw buffer without touching the GPU, and return the GP1(05h) word that shows the finished one.
The non-blocking first half of a pipelined swap: queue the word for a
VBlank edge whose handler applies it once the frame’s closing
GP0(1Fh) has run (psx_rt::interrupts::queue_display_control_at_vblank,
see crate::is_draw_done), wait until it has been applied, then
call apply_draw_target before drawing.
Safe to call while the previous frame still rasterises.
Sourcepub fn apply_draw_target(&self, _gpu: &mut Gpu)
pub fn apply_draw_target(&self, _gpu: &mut Gpu)
Program the draw area and draw offset for the buffer being drawn.
Trait Implementations§
Source§impl Clone for DoubleBuffer
impl Clone for DoubleBuffer
Source§fn clone(&self) -> DoubleBuffer
fn clone(&self) -> DoubleBuffer
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DoubleBuffer
impl Debug for DoubleBuffer
Source§impl Hash for DoubleBuffer
impl Hash for DoubleBuffer
Source§impl PartialEq for DoubleBuffer
impl PartialEq for DoubleBuffer
impl Copy for DoubleBuffer
impl Eq for DoubleBuffer
impl StructuralPartialEq for DoubleBuffer
Auto Trait Implementations§
impl Freeze for DoubleBuffer
impl RefUnwindSafe for DoubleBuffer
impl Send for DoubleBuffer
impl Sync for DoubleBuffer
impl Unpin for DoubleBuffer
impl UnsafeUnpin for DoubleBuffer
impl UnwindSafe for DoubleBuffer
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)