Skip to content

Commit

Permalink
Bug 1881978 - Support more than 32k render tasks r=gfx-reviewers,lsal…
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn Watson committed Feb 27, 2024
1 parent e66ac32 commit f07d5b7
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 68 deletions.
2 changes: 1 addition & 1 deletion webrender/res/brush.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void main(void) {
Instance instance = decode_instance_attributes();
PrimitiveHeader ph = fetch_prim_header(instance.prim_header_address);
Transform transform = fetch_transform(ph.transform_id);
PictureTask task = fetch_picture_task(instance.picture_task_address);
PictureTask task = fetch_picture_task(ph.picture_task_address);
ClipArea clip_area = fetch_clip_area(instance.clip_address);

WR_VERTEX_SHADER_MAIN_FUNCTION(instance, ph, transform, task, clip_area);
Expand Down
6 changes: 3 additions & 3 deletions webrender/res/prim_shared.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ PER_INSTANCE in ivec4 aData;
struct Instance
{
int prim_header_address;
int picture_task_address;
int clip_address;
int segment_index;
int flags;
Expand All @@ -56,8 +55,7 @@ Instance decode_instance_attributes() {
Instance instance;

instance.prim_header_address = aData.x;
instance.picture_task_address = aData.y >> 16;
instance.clip_address = aData.y & 0xffff;
instance.clip_address = aData.y;
instance.segment_index = aData.z & 0xffff;
instance.flags = aData.z >> 16;
instance.resource_address = aData.w & 0xffffff;
Expand All @@ -72,6 +70,7 @@ struct PrimitiveHeader {
float z;
int specific_prim_address;
int transform_id;
int picture_task_address;
ivec4 user_data;
};

Expand All @@ -90,6 +89,7 @@ PrimitiveHeader fetch_prim_header(int index) {
ph.z = float(data0.x);
ph.specific_prim_address = data0.y;
ph.transform_id = data0.z;
ph.picture_task_address = data0.w;
ph.user_data = data1;

return ph;
Expand Down
2 changes: 1 addition & 1 deletion webrender/res/ps_text_run.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void main() {
PrimitiveHeader ph = fetch_prim_header(instance.prim_header_address);
Transform transform = fetch_transform(ph.transform_id);
ClipArea clip_area = fetch_clip_area(instance.clip_address);
PictureTask task = fetch_picture_task(instance.picture_task_address);
PictureTask task = fetch_picture_task(ph.picture_task_address);

int glyph_index = instance.segment_index;
int subpx_dir = (instance.flags >> 8) & 0xff;
Expand Down
2 changes: 1 addition & 1 deletion webrender/res/render_task.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ PictureTask fetch_picture_task(int address) {
return task;
}

#define CLIP_TASK_EMPTY 0x7FFF
#define CLIP_TASK_EMPTY 0x7FFFFFFF

struct ClipArea {
RectWithEndpoint task_rect;
Expand Down
156 changes: 111 additions & 45 deletions webrender/src/batch.rs

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions webrender/src/gpu_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub struct SvgFilterInstance {
pub kind: u16,
pub input_count: u16,
pub generic_int: u16,
pub padding: u16,
pub extra_data_address: GpuCacheAddress,
}

Expand Down Expand Up @@ -428,6 +429,7 @@ impl PrimitiveHeaders {
&mut self,
prim_header: &PrimitiveHeader,
z: ZBufferId,
render_task_address: RenderTaskAddress,
user_data: [i32; 4],
) -> PrimitiveHeaderIndex {
debug_assert_eq!(self.headers_int.len(), self.headers_float.len());
Expand All @@ -440,7 +442,7 @@ impl PrimitiveHeaders {

self.headers_int.push(PrimitiveHeaderI {
z,
unused: 0,
render_task_address,
specific_prim_address: prim_header.specific_prim_address.as_int(),
transform_id: prim_header.transform_id,
user_data,
Expand Down Expand Up @@ -480,7 +482,7 @@ pub struct PrimitiveHeaderI {
pub z: ZBufferId,
pub specific_prim_address: i32,
pub transform_id: TransformPaletteId,
pub unused: i32, // To ensure required 16 byte alignment of vertex textures
pub render_task_address: RenderTaskAddress,
pub user_data: [i32; 4],
}

Expand All @@ -501,7 +503,6 @@ impl GlyphInstance {
// header since they are constant, and some can be
// compressed to a smaller size.
pub fn build(&self,
render_task: RenderTaskAddress,
clip_task: RenderTaskAddress,
subpx_dir: SubpixelDirection,
glyph_index_in_text_run: i32,
Expand All @@ -511,8 +512,7 @@ impl GlyphInstance {
PrimitiveInstanceData {
data: [
self.prim_header_index.0 as i32,
((render_task.0 as i32) << 16)
| clip_task.0 as i32,
clip_task.0 as i32,
(subpx_dir as u32 as i32) << 24
| (color_mode as u32 as i32) << 16
| glyph_index_in_text_run,
Expand All @@ -536,7 +536,7 @@ impl From<SplitCompositeInstance> for PrimitiveInstanceData {
instance.prim_header_index.0,
instance.polygons_address,
instance.z.0,
instance.render_task_address.0 as i32,
instance.render_task_address.0,
],
}
}
Expand Down Expand Up @@ -576,7 +576,7 @@ impl From<QuadInstance> for PrimitiveInstanceData {
((instance.part_index as i32) << 8) |
((instance.segment_index as i32) << 0),

instance.render_task_address.0 as i32,
instance.render_task_address.0,
],
}
}
Expand Down Expand Up @@ -664,7 +664,6 @@ impl core::fmt::Debug for BrushFlags {
/// Convenience structure to encode into PrimitiveInstanceData.
pub struct BrushInstance {
pub prim_header_index: PrimitiveHeaderIndex,
pub render_task_address: RenderTaskAddress,
pub clip_task_address: RenderTaskAddress,
pub segment_index: i32,
pub edge_flags: EdgeAaSegmentMask,
Expand All @@ -677,8 +676,7 @@ impl From<BrushInstance> for PrimitiveInstanceData {
PrimitiveInstanceData {
data: [
instance.prim_header_index.0,
((instance.render_task_address.0 as i32) << 16)
| instance.clip_task_address.0 as i32,
instance.clip_task_address.0,
instance.segment_index
| ((instance.brush_flags.bits() as i32) << 16)
| ((instance.edge_flags.bits() as i32) << 28),
Expand Down
1 change: 1 addition & 0 deletions webrender/src/render_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ fn add_svg_filter_instances(
kind,
input_count,
generic_int,
padding: 0,
extra_data_address: extra_data_address.unwrap_or(GpuCacheAddress::INVALID),
};

Expand Down
4 changes: 2 additions & 2 deletions webrender/src/render_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fn render_task_sanity_check(size: &DeviceIntSize) {
#[repr(C)]
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct RenderTaskAddress(pub u16);
pub struct RenderTaskAddress(pub i32);

impl Into<RenderTaskAddress> for RenderTaskId {
fn into(self) -> RenderTaskAddress {
RenderTaskAddress(self.index as u16)
RenderTaskAddress(self.index as i32)
}
}

Expand Down
15 changes: 10 additions & 5 deletions webrender/src/renderer/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ pub mod desc {
VertexAttribute {
name: "aBlurRenderTaskAddress",
count: 1,
kind: VertexAttributeKind::U16,
kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aBlurSourceTaskAddress",
count: 1,
kind: VertexAttributeKind::U16,
kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aBlurDirection",
Expand Down Expand Up @@ -574,17 +574,17 @@ pub mod desc {
VertexAttribute {
name: "aFilterRenderTaskAddress",
count: 1,
kind: VertexAttributeKind::U16,
kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aFilterInput1TaskAddress",
count: 1,
kind: VertexAttributeKind::U16,
kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aFilterInput2TaskAddress",
count: 1,
kind: VertexAttributeKind::U16,
kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aFilterKind",
Expand All @@ -601,6 +601,11 @@ pub mod desc {
count: 1,
kind: VertexAttributeKind::U16,
},
VertexAttribute {
name: "aUnused",
count: 1,
kind: VertexAttributeKind::U16,
},
VertexAttribute {
name: "aFilterExtraDataAddress",
count: 2,
Expand Down

0 comments on commit f07d5b7

Please sign in to comment.