зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1679751 - Rename ArrayAllocationTracker into GuillotineAllocator. r=gw
I'm about to add a couple of new atlas allocation algorithms. This patch renames one of the existing one into something less generic before it gets confusing. Also fix outdated comments about merging and dynamic allocation which was removed a while ago. Differential Revision: https://phabricator.services.mozilla.com/D98201
This commit is contained in:
Родитель
453481a6fe
Коммит
f7e4be63d5
|
@ -46,26 +46,26 @@ pub struct FreeRect {
|
|||
rect: DeviceIntRect,
|
||||
}
|
||||
|
||||
/// A texture allocator using the guillotine algorithm with the rectangle merge improvement. See
|
||||
/// sections 2.2 and 2.2.5 in "A Thousand Ways to Pack the Bin - A Practical Approach to Two-
|
||||
/// A texture allocator using the guillotine algorithm.
|
||||
///
|
||||
/// See sections 2.2 and 2.2.5 in "A Thousand Ways to Pack the Bin - A Practical Approach to Two-
|
||||
/// Dimensional Rectangle Bin Packing":
|
||||
///
|
||||
/// http://clb.demon.fi/files/RectangleBinPack.pdf
|
||||
///
|
||||
/// This approach was chosen because of its simplicity, good performance, and easy support for
|
||||
/// dynamic texture deallocation.
|
||||
/// This approach was chosen because of its simplicity and good performance.
|
||||
///
|
||||
/// Note: the allocations are spread across multiple textures, and also are binned
|
||||
/// orthogonally in order to speed up the search.
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub struct ArrayAllocationTracker {
|
||||
pub struct GuillotineAllocator {
|
||||
bins: [Vec<FreeRect>; NUM_BINS],
|
||||
}
|
||||
|
||||
impl ArrayAllocationTracker {
|
||||
impl GuillotineAllocator {
|
||||
pub fn new(initial_size: Option<DeviceIntSize>) -> Self {
|
||||
let mut allocator = ArrayAllocationTracker {
|
||||
let mut allocator = GuillotineAllocator {
|
||||
bins: [
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
|
@ -222,7 +222,7 @@ fn random_fill(count: usize, texture_size: i32) -> f32 {
|
|||
DeviceIntSize::new(texture_size, texture_size),
|
||||
);
|
||||
let mut rng = thread_rng();
|
||||
let mut allocator = ArrayAllocationTracker::new(None);
|
||||
let mut allocator = GuillotineAllocator::new(None);
|
||||
|
||||
// check for empty allocation
|
||||
assert_eq!(
|
|
@ -126,7 +126,7 @@ mod segment;
|
|||
mod shade;
|
||||
mod spatial_node;
|
||||
mod storage;
|
||||
mod texture_allocator;
|
||||
mod guillotine_allocator;
|
||||
mod texture_cache;
|
||||
mod tile_cache;
|
||||
mod util;
|
||||
|
|
|
@ -24,7 +24,7 @@ use crate::render_task::{RenderTaskKind, RenderTaskAddress, BlitSource};
|
|||
use crate::render_task::{RenderTask, ScalingTask, SvgFilterInfo};
|
||||
use crate::render_task_graph::{RenderTaskGraph, RenderTaskId};
|
||||
use crate::resource_cache::ResourceCache;
|
||||
use crate::texture_allocator::{ArrayAllocationTracker, FreeRectSlice};
|
||||
use crate::guillotine_allocator::{GuillotineAllocator, FreeRectSlice};
|
||||
use crate::visibility::PrimitiveVisibilityMask;
|
||||
use std::{cmp, mem};
|
||||
|
||||
|
@ -174,7 +174,7 @@ pub struct RenderTargetList<T> {
|
|||
pub max_dynamic_size: DeviceIntSize,
|
||||
pub targets: Vec<T>,
|
||||
pub saved_index: Option<SavedTargetIndex>,
|
||||
pub alloc_tracker: ArrayAllocationTracker,
|
||||
pub alloc_tracker: GuillotineAllocator,
|
||||
gpu_supports_fast_clears: bool,
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ impl<T: RenderTarget> RenderTargetList<T> {
|
|||
max_dynamic_size: DeviceIntSize::new(0, 0),
|
||||
targets: Vec::new(),
|
||||
saved_index: None,
|
||||
alloc_tracker: ArrayAllocationTracker::new(None),
|
||||
alloc_tracker: GuillotineAllocator::new(None),
|
||||
gpu_supports_fast_clears,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ use crate::scene_builder_thread::{SceneBuilderThread, SceneBuilderThreadChannels
|
|||
use crate::screen_capture::AsyncScreenshotGrabber;
|
||||
use crate::shade::{Shaders, WrShaders};
|
||||
use smallvec::SmallVec;
|
||||
use crate::texture_allocator::{ArrayAllocationTracker, FreeRectSlice};
|
||||
use crate::guillotine_allocator::{GuillotineAllocator, FreeRectSlice};
|
||||
use crate::texture_cache::TextureCache;
|
||||
use crate::render_target::{AlphaRenderTarget, ColorRenderTarget, PictureCacheTarget};
|
||||
use crate::render_target::{RenderTarget, TextureCacheRenderTarget, RenderTargetList};
|
||||
|
@ -4118,7 +4118,7 @@ impl Renderer {
|
|||
|
||||
if use_batch_upload {
|
||||
let (allocator, buffers) = batch_upload_buffers.entry(texture.get_format())
|
||||
.or_insert_with(|| (ArrayAllocationTracker::new(None), Vec::new()));
|
||||
.or_insert_with(|| (GuillotineAllocator::new(None), Vec::new()));
|
||||
|
||||
// Allocate a region within the staging buffer for this update. If there is
|
||||
// no room in an existing buffer then allocate another texture and buffer.
|
||||
|
|
Загрузка…
Ссылка в новой задаче