pub struct StreamingTexture { /* private fields */ }Expand description
An app-owned texture updated from CPU pixel data every frame or so —
video frames, animated images, camera feeds, software-rendered
panels. Owns the texture lifecycle that every media consumer
otherwise hand-rolls around app_texture:
- creates (and on size/format change, recreates) the
TEXTURE_BINDING | COPY_DSTtexture; - uploads frames with
Self::write_frame, orSelf::write_frame_if_changedfor sources that repeat frames (paused video, looping animations) where a cheap content hash saves the redundant upload; - hands out a stable
AppTexturehandle viaSelf::app_texturefor thesurface()tree builder. The handle’s identity is stable acrosswrite_framecalls — which is what keeps the per-texture bind-group cache warm — and changes only when a size/format change forces a new GPU texture (one cold bind-group rebuild, then warm again).
data is tightly-packed rows of width * height pixels in the
texture’s format (RGBA8 variants: 4 bytes/pixel; Rgba16Float:
8 bytes/pixel). Formats follow app_texture’s supported set.
Implementations§
Source§impl StreamingTexture
impl StreamingTexture
Sourcepub fn new(
device: &Device,
format: TextureFormat,
width: u32,
height: u32,
) -> Self
pub fn new( device: &Device, format: TextureFormat, width: u32, height: u32, ) -> Self
Create with an initial size. The texture contents are undefined
until the first Self::write_frame; draw order guarantees
nothing samples it before the first queue submission that
follows a write.
Sourcepub fn write_frame(
&mut self,
device: &Device,
queue: &Queue,
width: u32,
height: u32,
data: &[u8],
)
pub fn write_frame( &mut self, device: &Device, queue: &Queue, width: u32, height: u32, data: &[u8], )
Upload one frame of tightly-packed pixel rows, recreating the
texture first if width/height differ from the current size.
Panics if data is not exactly width * height * bytes_per_pixel long.
Sourcepub fn write_frame_if_changed(
&mut self,
device: &Device,
queue: &Queue,
width: u32,
height: u32,
data: &[u8],
) -> bool
pub fn write_frame_if_changed( &mut self, device: &Device, queue: &Queue, width: u32, height: u32, data: &[u8], ) -> bool
Self::write_frame, skipped when data hashes identically
to the previous accepted frame. Worth it for sources that
repeat frames (paused video, looping GIFs at rest); for live
video where every frame differs, prefer Self::write_frame
and skip the hash. Returns true when an upload happened.
Sourcepub fn app_texture(&self) -> AppTexture
pub fn app_texture(&self) -> AppTexture
The handle to embed in the tree via
[damascene_core::surface]. Cheap clone; identity stays stable
across Self::write_frame calls so backend bind-group caches
stay warm.
Auto Trait Implementations§
impl !RefUnwindSafe for StreamingTexture
impl !UnwindSafe for StreamingTexture
impl Freeze for StreamingTexture
impl Send for StreamingTexture
impl Sync for StreamingTexture
impl Unpin for StreamingTexture
impl UnsafeUnpin for StreamingTexture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.