diff options
Diffstat (limited to 'gfx/wr/webrender/src/renderer')
-rw-r--r-- | gfx/wr/webrender/src/renderer/mod.rs | 49 | ||||
-rw-r--r-- | gfx/wr/webrender/src/renderer/shade.rs | 48 | ||||
-rw-r--r-- | gfx/wr/webrender/src/renderer/vertex.rs | 55 |
3 files changed, 147 insertions, 5 deletions
diff --git a/gfx/wr/webrender/src/renderer/mod.rs b/gfx/wr/webrender/src/renderer/mod.rs index a70d3eca18..ab3eb956b0 100644 --- a/gfx/wr/webrender/src/renderer/mod.rs +++ b/gfx/wr/webrender/src/renderer/mod.rs @@ -69,7 +69,7 @@ use crate::frame_builder::Frame; use glyph_rasterizer::GlyphFormat; use crate::gpu_cache::{GpuCacheUpdate, GpuCacheUpdateList}; use crate::gpu_cache::{GpuCacheDebugChunk, GpuCacheDebugCmd}; -use crate::gpu_types::{ScalingInstance, SvgFilterInstance, CopyInstance, PrimitiveInstanceData}; +use crate::gpu_types::{ScalingInstance, SvgFilterInstance, SVGFEFilterInstance, CopyInstance, PrimitiveInstanceData}; use crate::gpu_types::{BlurInstance, ClearInstance, CompositeInstance, CompositorTransform}; use crate::internal_types::{TextureSource, TextureCacheCategory, FrameId}; #[cfg(any(feature = "capture", feature = "replay"))] @@ -193,11 +193,11 @@ const GPU_TAG_CACHE_LINEAR_GRADIENT: GpuProfileTag = GpuProfileTag { label: "C_LinearGradient", color: debug_colors::BROWN, }; -const GPU_TAG_CACHE_RADIAL_GRADIENT: GpuProfileTag = GpuProfileTag { +const GPU_TAG_RADIAL_GRADIENT: GpuProfileTag = GpuProfileTag { label: "C_RadialGradient", color: debug_colors::BROWN, }; -const GPU_TAG_CACHE_CONIC_GRADIENT: GpuProfileTag = GpuProfileTag { +const GPU_TAG_CONIC_GRADIENT: GpuProfileTag = GpuProfileTag { label: "C_ConicGradient", color: debug_colors::BROWN, }; @@ -257,6 +257,10 @@ const GPU_TAG_SVG_FILTER: GpuProfileTag = GpuProfileTag { label: "SvgFilter", color: debug_colors::LEMONCHIFFON, }; +const GPU_TAG_SVG_FILTER_NODES: GpuProfileTag = GpuProfileTag { + label: "SvgFilterNodes", + color: debug_colors::LEMONCHIFFON, +}; const GPU_TAG_COMPOSITE: GpuProfileTag = GpuProfileTag { label: "Composite", color: debug_colors::TOMATO, @@ -288,6 +292,8 @@ impl BatchKind { } BatchKind::TextRun(_) => GPU_TAG_PRIM_TEXT_RUN, BatchKind::Quad(PatternKind::ColorOrTexture) => GPU_TAG_PRIMITIVE, + BatchKind::Quad(PatternKind::RadialGradient) => GPU_TAG_RADIAL_GRADIENT, + BatchKind::Quad(PatternKind::ConicGradient) => GPU_TAG_CONIC_GRADIENT, BatchKind::Quad(PatternKind::Mask) => GPU_TAG_INDIRECT_MASK, } } @@ -2527,6 +2533,35 @@ impl Renderer { ); } + fn handle_svg_nodes( + &mut self, + textures: &BatchTextures, + svg_filters: &[SVGFEFilterInstance], + projection: &default::Transform3D<f32>, + stats: &mut RendererStats, + ) { + if svg_filters.is_empty() { + return; + } + + let _timer = self.gpu_profiler.start_timer(GPU_TAG_SVG_FILTER_NODES); + + self.shaders.borrow_mut().cs_svg_filter_node.bind( + &mut self.device, + &projection, + None, + &mut self.renderer_errors, + &mut self.profile, + ); + + self.draw_instanced_batch( + &svg_filters, + VertexArrayKind::SvgFilterNode, + textures, + stats, + ); + } + fn handle_resolve( &mut self, resolve_op: &ResolveOp, @@ -3576,6 +3611,10 @@ impl Renderer { ); } + for (ref textures, ref filters) in &target.svg_nodes { + self.handle_svg_nodes(textures, filters, projection, stats); + } + for alpha_batch_container in &target.alpha_batch_containers { self.draw_alpha_batch_container( alpha_batch_container, @@ -4069,7 +4108,7 @@ impl Renderer { // Draw any radial gradients for this target. if !target.radial_gradients.is_empty() { - let _timer = self.gpu_profiler.start_timer(GPU_TAG_CACHE_RADIAL_GRADIENT); + let _timer = self.gpu_profiler.start_timer(GPU_TAG_RADIAL_GRADIENT); self.set_blend(false, FramebufferKind::Other); @@ -4095,7 +4134,7 @@ impl Renderer { // Draw any conic gradients for this target. if !target.conic_gradients.is_empty() { - let _timer = self.gpu_profiler.start_timer(GPU_TAG_CACHE_CONIC_GRADIENT); + let _timer = self.gpu_profiler.start_timer(GPU_TAG_CONIC_GRADIENT); self.set_blend(false, FramebufferKind::Other); diff --git a/gfx/wr/webrender/src/renderer/shade.rs b/gfx/wr/webrender/src/renderer/shade.rs index 96e8982aa0..5463e8eb67 100644 --- a/gfx/wr/webrender/src/renderer/shade.rs +++ b/gfx/wr/webrender/src/renderer/shade.rs @@ -263,6 +263,7 @@ impl LazilyCompiledShader { VertexArrayKind::Scale => &desc::SCALE, VertexArrayKind::Resolve => &desc::RESOLVE, VertexArrayKind::SvgFilter => &desc::SVG_FILTER, + VertexArrayKind::SvgFilterNode => &desc::SVG_FILTER_NODE, VertexArrayKind::Composite => &desc::COMPOSITE, VertexArrayKind::Clear => &desc::CLEAR, VertexArrayKind::Copy => &desc::COPY, @@ -601,6 +602,7 @@ pub struct Shaders { pub cs_radial_gradient: LazilyCompiledShader, pub cs_conic_gradient: LazilyCompiledShader, pub cs_svg_filter: LazilyCompiledShader, + pub cs_svg_filter_node: LazilyCompiledShader, // Brush shaders brush_solid: BrushShader, @@ -632,6 +634,8 @@ pub struct Shaders { ps_split_composite: LazilyCompiledShader, pub ps_quad_textured: LazilyCompiledShader, + pub ps_quad_radial_gradient: LazilyCompiledShader, + pub ps_quad_conic_gradient: LazilyCompiledShader, pub ps_mask: LazilyCompiledShader, pub ps_mask_fast: LazilyCompiledShader, pub ps_clear: LazilyCompiledShader, @@ -768,6 +772,16 @@ impl Shaders { profile, )?; + let cs_svg_filter_node = LazilyCompiledShader::new( + ShaderKind::Cache(VertexArrayKind::SvgFilterNode), + "cs_svg_filter_node", + &[], + device, + options.precache_flags, + &shader_list, + profile, + )?; + let ps_mask = LazilyCompiledShader::new( ShaderKind::Cache(VertexArrayKind::Mask), "ps_quad_mask", @@ -888,6 +902,26 @@ impl Shaders { profile, )?; + let ps_quad_radial_gradient = LazilyCompiledShader::new( + ShaderKind::Primitive, + "ps_quad_radial_gradient", + &[], + device, + options.precache_flags, + &shader_list, + profile, + )?; + + let ps_quad_conic_gradient = LazilyCompiledShader::new( + ShaderKind::Primitive, + "ps_quad_conic_gradient", + &[], + device, + options.precache_flags, + &shader_list, + profile, + )?; + let ps_split_composite = LazilyCompiledShader::new( ShaderKind::Primitive, "ps_split_composite", @@ -1107,6 +1141,7 @@ impl Shaders { cs_border_solid, cs_scale, cs_svg_filter, + cs_svg_filter_node, brush_solid, brush_image, brush_fast_image, @@ -1122,6 +1157,8 @@ impl Shaders { ps_text_run, ps_text_run_dual_source, ps_quad_textured, + ps_quad_radial_gradient, + ps_quad_conic_gradient, ps_mask, ps_mask_fast, ps_split_composite, @@ -1160,6 +1197,8 @@ impl Shaders { ) -> &mut LazilyCompiledShader { match pattern { PatternKind::ColorOrTexture => &mut self.ps_quad_textured, + PatternKind::RadialGradient => &mut self.ps_quad_radial_gradient, + PatternKind::ConicGradient => &mut self.ps_quad_conic_gradient, PatternKind::Mask => unreachable!(), } } @@ -1175,6 +1214,12 @@ impl Shaders { BatchKind::Quad(PatternKind::ColorOrTexture) => { &mut self.ps_quad_textured } + BatchKind::Quad(PatternKind::RadialGradient) => { + &mut self.ps_quad_radial_gradient + } + BatchKind::Quad(PatternKind::ConicGradient) => { + &mut self.ps_quad_conic_gradient + } BatchKind::Quad(PatternKind::Mask) => { unreachable!(); } @@ -1268,6 +1313,7 @@ impl Shaders { self.cs_blur_a8.deinit(device); self.cs_blur_rgba8.deinit(device); self.cs_svg_filter.deinit(device); + self.cs_svg_filter_node.deinit(device); self.brush_solid.deinit(device); self.brush_blend.deinit(device); self.brush_mix_blend.deinit(device); @@ -1305,6 +1351,8 @@ impl Shaders { self.cs_border_segment.deinit(device); self.ps_split_composite.deinit(device); self.ps_quad_textured.deinit(device); + self.ps_quad_radial_gradient.deinit(device); + self.ps_quad_conic_gradient.deinit(device); self.ps_mask.deinit(device); self.ps_mask_fast.deinit(device); self.ps_clear.deinit(device); diff --git a/gfx/wr/webrender/src/renderer/vertex.rs b/gfx/wr/webrender/src/renderer/vertex.rs index cd73975ddd..6ee162ae38 100644 --- a/gfx/wr/webrender/src/renderer/vertex.rs +++ b/gfx/wr/webrender/src/renderer/vertex.rs @@ -567,6 +567,56 @@ pub mod desc { ], }; + pub const SVG_FILTER_NODE: VertexDescriptor = VertexDescriptor { + vertex_attributes: &[VertexAttribute { + name: "aPosition", + count: 2, + kind: VertexAttributeKind::U8Norm, + }], + instance_attributes: &[ + VertexAttribute { + name: "aFilterTargetRect", + count: 4, + kind: VertexAttributeKind::F32, + }, + VertexAttribute { + name: "aFilterInput1ContentScaleAndOffset", + count: 4, + kind: VertexAttributeKind::F32, + }, + VertexAttribute { + name: "aFilterInput2ContentScaleAndOffset", + count: 4, + kind: VertexAttributeKind::F32, + }, + VertexAttribute { + name: "aFilterInput1TaskAddress", + count: 1, + kind: VertexAttributeKind::I32, + }, + VertexAttribute { + name: "aFilterInput2TaskAddress", + count: 1, + kind: VertexAttributeKind::I32, + }, + VertexAttribute { + name: "aFilterKind", + count: 1, + kind: VertexAttributeKind::U16, + }, + VertexAttribute { + name: "aFilterInputCount", + count: 1, + kind: VertexAttributeKind::U16, + }, + VertexAttribute { + name: "aFilterExtraDataAddress", + count: 2, + kind: VertexAttributeKind::U16, + }, + ], + }; + pub const MASK: VertexDescriptor = VertexDescriptor { vertex_attributes: &[VertexAttribute { name: "aPosition", @@ -780,6 +830,7 @@ pub enum VertexArrayKind { ConicGradient, Resolve, SvgFilter, + SvgFilterNode, Composite, Clear, Copy, @@ -1004,6 +1055,7 @@ pub struct RendererVAOs { conic_gradient_vao: VAO, resolve_vao: VAO, svg_filter_vao: VAO, + svg_filter_node_vao: VAO, composite_vao: VAO, clear_vao: VAO, copy_vao: VAO, @@ -1051,6 +1103,7 @@ impl RendererVAOs { conic_gradient_vao: device.create_vao_with_new_instances(&desc::CONIC_GRADIENT, &prim_vao), resolve_vao: device.create_vao_with_new_instances(&desc::RESOLVE, &prim_vao), svg_filter_vao: device.create_vao_with_new_instances(&desc::SVG_FILTER, &prim_vao), + svg_filter_node_vao: device.create_vao_with_new_instances(&desc::SVG_FILTER_NODE, &prim_vao), composite_vao: device.create_vao_with_new_instances(&desc::COMPOSITE, &prim_vao), clear_vao: device.create_vao_with_new_instances(&desc::CLEAR, &prim_vao), copy_vao: device.create_vao_with_new_instances(&desc::COPY, &prim_vao), @@ -1073,6 +1126,7 @@ impl RendererVAOs { device.delete_vao(self.border_vao); device.delete_vao(self.scale_vao); device.delete_vao(self.svg_filter_vao); + device.delete_vao(self.svg_filter_node_vao); device.delete_vao(self.composite_vao); device.delete_vao(self.clear_vao); device.delete_vao(self.copy_vao); @@ -1098,6 +1152,7 @@ impl ops::Index<VertexArrayKind> for RendererVAOs { VertexArrayKind::ConicGradient => &self.conic_gradient_vao, VertexArrayKind::Resolve => &self.resolve_vao, VertexArrayKind::SvgFilter => &self.svg_filter_vao, + VertexArrayKind::SvgFilterNode => &self.svg_filter_node_vao, VertexArrayKind::Composite => &self.composite_vao, VertexArrayKind::Clear => &self.clear_vao, VertexArrayKind::Copy => &self.copy_vao, |