pub struct GpuResourceRing { /* private fields */ }Expand description
Bounded cross-frame GPU staging ring, persistent scroll tile cache, and fence-deferred reclamation tracker.
Implementations§
Source§impl GpuResourceRing
Bounded staging ring acquisition, fence completion, persistent scroll tile caching, and deferred reclamation for GpuResourceRing.
impl GpuResourceRing
Bounded staging ring acquisition, fence completion, persistent scroll tile caching, and deferred reclamation for GpuResourceRing.
Sourcepub fn with_limits(
max_slots: usize,
max_total_bytes: usize,
tile_budget_bytes: usize,
) -> Self
pub fn with_limits( max_slots: usize, max_total_bytes: usize, tile_budget_bytes: usize, ) -> Self
Creates a bounded GPU resource ring with explicit staging slot count, staging byte ceiling, and tile budget.
§Arguments
usize- Maximum number of staging ring slots (>= 1).usize- Maximum aggregate staging bytes across all slots.usize- Maximum resident bytes for persistent scroll tile textures.
§Returns
Self- Configured GPU resource ring.
Sourcepub fn fence_is_completed(fence_id: u64, completed_fence_id: u64) -> bool
pub fn fence_is_completed(fence_id: u64, completed_fence_id: u64) -> bool
Returns whether fence_id has retired relative to completed_fence_id with wrap-around safety.
§Arguments
u64- Fence identifier guarding a GPU resource or staging slot.u64- Latest completed GPU fence identifier (0when no fence has completed yet).
§Returns
bool-truewhenfence_idis retired and safe for CPU reuse.
Sourcepub fn next_monotonic_fence(fence_id: u64) -> u64
pub fn next_monotonic_fence(fence_id: u64) -> u64
Sourcepub fn acquire_staging(
&mut self,
required_bytes: usize,
priority: GpuUploadPriority,
) -> GpuRingAcquireResult
pub fn acquire_staging( &mut self, required_bytes: usize, priority: GpuUploadPriority, ) -> GpuRingAcquireResult
Acquires an idle or fence-completed staging slot for required_bytes without unbounded queue growth.
§Arguments
&Self- Mutable GPU resource ring.usize- Upload payload size in bytes.GpuUploadPriority- Priority deciding whether a full ring drops prefetch or defers the frame.
§Returns
GpuRingAcquireResult- Acquired slot and fence ID, or bounded backpressure status.
Sourcepub fn complete_fence(&mut self, fence_id: u64) -> usize
pub fn complete_fence(&mut self, fence_id: u64) -> usize
Sourcepub fn in_flight_slot_count(&self) -> usize
pub fn in_flight_slot_count(&self) -> usize
Sourcepub fn staging_allocated_bytes(&self) -> usize
pub fn staging_allocated_bytes(&self) -> usize
Sourcepub fn begin_tile_frame(&mut self)
pub fn begin_tile_frame(&mut self)
Marks all cached scroll tiles as non-visible before starting a new frame’s visibility pass.
§Arguments
&Self- Mutable GPU resource ring.
Sourcepub fn acquire_scroll_tile(
&mut self,
key: GpuScrollTileKey,
width: u32,
height: u32,
fence_id: u64,
visible: bool,
) -> (RenderResourceHandle, bool)
pub fn acquire_scroll_tile( &mut self, key: GpuScrollTileKey, width: u32, height: u32, fence_id: u64, visible: bool, ) -> (RenderResourceHandle, bool)
Looks up or allocates a persistent scroll tile texture, touching LRU age and tagging fence_id.
§Arguments
&Self- Mutable GPU resource ring.GpuScrollTileKey- Content/DPI/layer key for the tile.u32- Tile physical width in pixels.u32- Tile physical height in pixels.u64- Active frame GPU fence identifier.bool- Whether this tile is visible in the current viewport.
§Returns
(RenderResourceHandle, bool)- Tile handle andtrueon cache hit (falseon fresh miss).
Sourcepub fn invalidate_scroll_tiles(
&mut self,
layer_node: Option<NodeId>,
active_dpr: Option<f32>,
) -> usize
pub fn invalidate_scroll_tiles( &mut self, layer_node: Option<NodeId>, active_dpr: Option<f32>, ) -> usize
Invalidates all cached scroll tiles belonging to a destroyed or invalidated layer node or old DPI scale.
§Arguments
&Self- Mutable GPU resource ring.Option<NodeId>- Optional specific layer node to invalidate (Noneinvalidates all non-matching DPI tiles).Option<f32>- Optional active DPI scale; tiles with a different scale are evicted cleanly.
§Returns
usize- Number of invalidated tiles moved to fence-deferred reclamation.
Sourcepub fn evict_cold_tiles_to_budget(&mut self, target_bytes: usize) -> usize
pub fn evict_cold_tiles_to_budget(&mut self, target_bytes: usize) -> usize
Sourcepub fn apply_retention_ratio(&mut self, retain_ratio: f32) -> usize
pub fn apply_retention_ratio(&mut self, retain_ratio: f32) -> usize
Sourcepub fn total_live_gpu_bytes(&self) -> usize
pub fn total_live_gpu_bytes(&self) -> usize
Sourcepub fn queue_texture_dirty_rect(&mut self, upload: GpuTextureUploadRect)
pub fn queue_texture_dirty_rect(&mut self, upload: GpuTextureUploadRect)
Queues a dirty-rectangle R8 or RGBA8 atlas/image sub-region upload for the active frame.
§Arguments
GpuTextureUploadRect- Dirty sub-region upload descriptor.
Sourcepub fn drain_texture_uploads(&mut self) -> Vec<GpuTextureUploadRect>
pub fn drain_texture_uploads(&mut self) -> Vec<GpuTextureUploadRect>
Drains all queued dirty-rectangle R8/RGBA8 texture uploads for GPU command encoding.
§Returns
Vec<GpuTextureUploadRect>- Pending dirty-rectangle sub-region uploads.