Bug 1710814 - Set the image tiling threshold to 4k. r=gfx-reviewers,jnicol

Depends on D114954

Differential Revision: https://phabricator.services.mozilla.com/D114955
This commit is contained in:
Nicolas Silva 2021-05-17 09:05:52 +00:00
Родитель f7e7a32c08
Коммит 295136d90a
3 изменённых файлов: 27 добавлений и 3 удалений

Просмотреть файл

@ -959,6 +959,9 @@ impl Renderer {
max_internal_texture_size = max_internal_texture_size.min(internal_limit);
}
let image_tiling_threshold = options.image_tiling_threshold
.min(max_internal_texture_size);
device.begin_frame();
let shaders = match shaders {
@ -1230,6 +1233,7 @@ impl Renderer {
let texture_cache = TextureCache::new(
max_internal_texture_size,
image_tiling_threshold,
picture_tile_size,
color_cache_formats,
swizzle_settings,
@ -5316,6 +5320,7 @@ pub struct RendererOptions {
pub clear_color: Option<ColorF>,
pub enable_clear_scissor: bool,
pub max_internal_texture_size: Option<i32>,
pub image_tiling_threshold: i32,
pub upload_method: UploadMethod,
/// The default size in bytes for PBOs used to upload texture data.
pub upload_pbo_default_size: usize,
@ -5400,6 +5405,7 @@ impl Default for RendererOptions {
clear_color: Some(ColorF::new(1.0, 1.0, 1.0, 1.0)),
enable_clear_scissor: true,
max_internal_texture_size: None,
image_tiling_threshold: 4096,
// This is best as `Immediate` on Angle, or `Pixelbuffer(Dynamic)` on GL,
// but we are unable to make this decision here, so picking the reasonable medium.
upload_method: UploadMethod::PixelBuffer(ONE_TIME_USAGE_HINT),

Просмотреть файл

@ -556,6 +556,12 @@ impl ResourceCache {
self.texture_cache.max_texture_size()
}
/// Maximum texture size before we consider it preferrable to break the texture
/// into tiles.
pub fn tiling_threshold(&self) -> i32 {
self.texture_cache.tiling_threshold()
}
pub fn enable_multithreading(&mut self, enable: bool) {
self.glyph_rasterizer.enable_multithreading(enable);
}
@ -776,7 +782,7 @@ impl ResourceCache {
visible_rect: &DeviceIntRect,
mut tiling: Option<TileSize>,
) {
if tiling.is_none() && Self::should_tile(self.max_texture_size(), &descriptor, &data) {
if tiling.is_none() && Self::should_tile(self.tiling_threshold(), &descriptor, &data) {
// We aren't going to be able to upload a texture this big, so tile it, even
// if tiling was not requested.
tiling = Some(DEFAULT_TILE_SIZE);
@ -800,14 +806,14 @@ impl ResourceCache {
data: CachedImageData,
dirty_rect: &ImageDirtyRect,
) {
let max_texture_size = self.max_texture_size();
let tiling_threshold = self.tiling_threshold();
let image = match self.resources.image_templates.get_mut(image_key) {
Some(res) => res,
None => panic!("Attempt to update non-existent image"),
};
let mut tiling = image.tiling;
if tiling.is_none() && Self::should_tile(max_texture_size, &descriptor, &data) {
if tiling.is_none() && Self::should_tile(tiling_threshold, &descriptor, &data) {
tiling = Some(DEFAULT_TILE_SIZE);
}
@ -2013,6 +2019,7 @@ impl ResourceCache {
self.current_frame_id = FrameId::INVALID;
self.texture_cache = TextureCache::new(
self.texture_cache.max_texture_size(),
self.texture_cache.tiling_threshold(),
self.texture_cache.default_picture_tile_size(),
self.texture_cache.color_formats(),
self.texture_cache.swizzle_settings(),

Просмотреть файл

@ -761,6 +761,10 @@ pub struct TextureCache {
/// Maximum texture size supported by hardware.
max_texture_size: i32,
/// Maximum texture size before it is considered preferable to break the
/// texture into tiles.
tiling_threshold: i32,
/// Settings on using texture unit swizzling.
swizzle: Option<SwizzleSettings>,
@ -808,6 +812,7 @@ impl TextureCache {
pub fn new(
max_texture_size: i32,
tiling_threshold: i32,
default_picture_tile_size: DeviceIntSize,
color_formats: TextureFormatPair<ImageFormat>,
swizzle: Option<SwizzleSettings>,
@ -830,6 +835,7 @@ impl TextureCache {
default_picture_tile_size,
),
max_texture_size,
tiling_threshold,
swizzle,
debug_flags: DebugFlags::empty(),
next_id: next_texture_id,
@ -853,6 +859,7 @@ impl TextureCache {
image_format: ImageFormat,
) -> Self {
let mut cache = Self::new(
max_texture_size,
max_texture_size,
crate::picture::TILE_SIZE_DEFAULT,
TextureFormatPair::from(image_format),
@ -1038,6 +1045,10 @@ impl TextureCache {
self.max_texture_size
}
pub fn tiling_threshold(&self) -> i32 {
self.tiling_threshold
}
#[cfg(feature = "replay")]
pub fn color_formats(&self) -> TextureFormatPair<ImageFormat> {
self.shared_textures.color8_linear.texture_parameters().formats.clone()