tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9b8d38ca2d35f64b726b89b138eaa945bd02271f
parent 64ccd102ba7c6c84bfbb0d097fa32aa4a98c5bd0
Author: Nicolas Silva <nical@fastmail.com>
Date:   Tue,  9 Dec 2025 08:19:07 +0000

Bug 1996818 - FrameGlobalResources is not retained anymore. r=gfx-reviewers,aosmond

With the gpu cache replaced with gpu buffer, global resources only contain data that must be re-generated each frame. This commit moves the struct out of FrameBuilder to reflect it.

Differential Revision: https://phabricator.services.mozilla.com/D273097

Diffstat:
Mgfx/wr/webrender/src/frame_builder.rs | 33++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/gfx/wr/webrender/src/frame_builder.rs b/gfx/wr/webrender/src/frame_builder.rs @@ -73,9 +73,7 @@ pub struct FrameBuilderConfig { pub precise_conic_gradients: bool, } -/// A set of common / global resources that are retained between -/// new display lists, such that any GPU cache handles can be -/// persisted even when a new display list arrives. +/// A set of default / global resources that are re-built each frame. #[cfg_attr(feature = "capture", derive(Serialize))] pub struct FrameGlobalResources { /// The image shader block for the most common / default @@ -89,17 +87,7 @@ pub struct FrameGlobalResources { } impl FrameGlobalResources { - pub fn empty() -> Self { - FrameGlobalResources { - default_image_data: GpuBufferAddress::INVALID, - default_black_rect_address: GpuBufferAddress::INVALID, - } - } - - pub fn update( - &mut self, - gpu_buffers: &mut GpuBufferBuilder, - ) { + pub fn new(gpu_buffers: &mut GpuBufferBuilder) -> Self { let mut writer = gpu_buffers.f32.write_blocks(ImageBrushPrimitiveData::NUM_BLOCKS); writer.push(&ImageBrushPrimitiveData { color: PremultipliedColorF::WHITE, @@ -107,11 +95,16 @@ impl FrameGlobalResources { // -ve means use prim rect for stretch size stretch_size: LayoutSize::new(-1.0, 0.0), }); - self.default_image_data = writer.finish(); + let default_image_data = writer.finish(); let mut writer = gpu_buffers.f32.write_blocks(1); writer.push_one(PremultipliedColorF::BLACK); - self.default_black_rect_address = writer.finish(); + let default_black_rect_address = writer.finish(); + + FrameGlobalResources { + default_image_data, + default_black_rect_address, + } } } @@ -139,7 +132,6 @@ impl FrameScratchBuffer { /// Produces the frames that are sent to the renderer. #[cfg_attr(feature = "capture", derive(Serialize))] pub struct FrameBuilder { - pub globals: FrameGlobalResources, #[cfg_attr(feature = "capture", serde(skip))] prim_headers_prealloc: Preallocator, #[cfg_attr(feature = "capture", serde(skip))] @@ -264,7 +256,6 @@ pub struct PictureState { impl FrameBuilder { pub fn new() -> Self { FrameBuilder { - globals: FrameGlobalResources::empty(), prim_headers_prealloc: Preallocator::new(0), composite_state_prealloc: CompositeStatePreallocator::default(), plane_splitters: Vec::new(), @@ -669,7 +660,7 @@ impl FrameBuilder { // statically during scene building. scene.surfaces.clear(); - self.globals.update(&mut gpu_buffer_builder); + let globals = FrameGlobalResources::new(&mut gpu_buffer_builder); spatial_tree.update_tree(scene_properties); let mut transform_palette = spatial_tree.build_transform_palette(&frame_memory); @@ -759,7 +750,7 @@ impl FrameBuilder { surfaces: &scene.surfaces, scratch: &mut scratch.primitive, screen_world_rect, - globals: &self.globals, + globals: &globals, tile_caches, root_spatial_node_index: spatial_tree.root_reference_frame_index(), frame_memory: &mut frame_memory, @@ -801,7 +792,7 @@ impl FrameBuilder { surfaces: &scene.surfaces, scratch: &mut scratch.primitive, screen_world_rect, - globals: &self.globals, + globals: &globals, tile_caches, root_spatial_node_index: spatial_tree.root_reference_frame_index(), frame_memory: &mut frame_memory,