SlideShare uma empresa Scribd logo
1 de 38
Webrender 1.0
Daosheng Mu
Mozilla
07/26/2016
Introduction
● The rendering engine of Servo
○ Implementations of essentially all features of CSS that Servo supports.
○ Working on enabled by default.
○ Separately from Servo
● Initial commit: September 22, 2015.
● Two main developers: Glenn Watson (lead) and Patrick Walton.
● OpenGL-based renderer
● This is just version 1.0… Still in progress.
Why Webrender?
GPU API modes
Retained mode Immediate mode Tiled-based mode
In 2000s PC GPUs In 2010s mobile GPUsIn 1990s PC GPUs
[In existing APIs] path rendering can result in many state changes per
path…In this case, the API overhead can substantially limit the overall
performance. Our experience…indicates these approaches are often more
GPU-assisted rather than GPU-accelerated…
—Mark Kilgard and Jeff Bolz, NVIDIA
SIGGRAPH Asia 2012
Today web browsers respecify paths every time a web page with path content
is re-rendered assuming re-specifying paths is cheap…When path rendering is
fully GPU-accelerated, a retained model of rendering is more appropriate and
efficient. We believe web browsers should behave more like video games in
this respect to exploit the GPU.
—Mark Kilgard and Jeff Bolz, NVIDIA
SIGGRAPH Asia 2012
Retained vs. Immediate mode
● Framework example: WPF vs. Direct2D
● Immediate mode gives the control of GPU pipeline to developers.
○ If you are good at this, your application would gain more performance. Otherwise...
● Immediate mode doesn’t help the management of scene, state, and batch.
● Retained mode have display lists for managing drawcalls & states. Ex: OpenGL 2.0
--- Advanced Game Programming 3D Mathematics.
Graphics API
“Game engines do scene graph no matter
retained mode or immediate mode API”
“Scene graph == Software retained mode”
Batching
State management
Sorting
etc...
--- Advanced Game Programming 3D Mathematics.
Graphics API
How about Web browser?
CSS DOM
simple scene graph
Batching
State management
Sorting
etc...
GPU synchronization
● Mode transition
● Command buffer
“glFinish​. It will not return, stopping the current CPU thread, until all
rendering commands that have been sent have completed.”
What is Webrender?
● A game engine (renderer) for Web browser
● Retained mode, multithreaded
● Focus on CSS
● Takes a post-layout CSS display list and draws it to the screen as quickly as
possible.
● Webrender supports OpenGL ES 2.1 and OpenGL 3.x.
○ Instance rendering / Loop in shaders
● Webrender could be used as a backend for any sort of 2D graphics that CSS can
describe
How Webrender work?
IOCompositor::
composite
Event
IOCompositor::
composite_specific_target
Servo
Renderer thread
Renderer::update
Renderer::render
publish_frame
build_scene
frame.create
render
frame.build
run
Renderer::new
Create OpenGL device
Create shader / texture
Spawn render_backend thread
webrender_traits
IOCompositor::
set_frame_tree
RenderBackend thread
ApiMsg::
SetRootPipeline
ApiMsg::
SetRootPipeline
Webrender
RendererFrame
draw RendererFrame
Main thread
Steps
1. Add items to display list
2. Scene graph: frame, layer, AABB tree, culling
3. Render
1. Add items to display list
DisplayItem
● The minimum unit of renderable item
● It describes by a visible rect and clip region
● Types:
○ RectangleDisplayItem
○ TextDisplayItem
○ ImageDisplayItem
○ WebGLDisplayItem
○ BorderDisplayItem
○ BoxShadowDisplayItem
○ GradientDisplayItem
DisplayListBuilder
pub enum SpecificDisplayListItem {
DrawList(DrawListInfo),
StackingContext(StackingContextInfo),
Iframe(IframeInfo),
}
○ Store items to a list
○ Finalize
■ Generate a displaylist as Blob
convert_to_webrender
StackingContext
● Stacking context is the three-dimensional conceptualization of HTML elements
along an imaginary z-axis relative to the user who is assumed to be facing the
viewport or the webpage
pub struct StackingContext {
pub servo_id: ServoStackingContextId,
pub scroll_layer_id: Option<ScrollLayerId>,
pub scroll_policy: ScrollPolicy,
pub bounds: Rect<f32>,
pub overflow: Rect<f32>,
pub z_index: i32,
pub display_lists: Vec<DisplayListId>,
pub transform: Matrix4,
pub perspective: Matrix4,
pub establishes_3d_context: bool,
pub mix_blend_mode: MixBlendMode,
pub filters: ItemRange,
pub has_stacking_contexts: bool,
}
StackingContext
- display_list [id]
Scene
- display_list_map(id,
display_list)StackingContext
DisplayItem
● Scene.add_stacking_context
● Scene.add_display_list
● Scene.set_root_stacking_context
Main thread
render_backend
thread
APIMsg::
SetRootStackingContext
Servo Webrender
Scene
● Pipeline_map / display_list_map / stacking_context_map
● Set_root_stacking_context()
○ Remove old display list and stacking_context
○ New a scene pipeline
○ Insert to pipeline_map and remove old one
pub struct ScenePipeline {
pub pipeline_id: PipelineId,
pub epoch: Epoch,
pub background_draw_list: Option<DrawListId>,
pub root_stacking_context_id: StackingContextId,
pub viewport_size: Size2D<f32>,
}
display_list_map
pipeline_id display_list(SpecificDisplayListItem)
pipeline_id display_list(DrawList)
Ex:
pipeline_id display_list(StackingContext)
pipeline_id display_list(Iframe)
pub enum SpecificSceneItem {
DrawList(DrawListId),
StackingContext(StackingContextId, PipelineId),
Iframe(IframeInfo),
}
pub struct SceneDisplayList {
pipeline_id
SceneItem<Vec>
epoch
}
SpecificDisplayListItem is mapped
to SpecificSceneItem
Stored to
stacking_context_map
StackingContextId SceneStackingContext
stacking_context
stacking_context
stacking_context
pub struct SceneStackingContext {
pub pipeline_id: PipelineId,
pub epoch: Epoch,
pub stacking_context: StackingContext,
pub stacking_context_id: StackingContextId,
}
StackingContextId
StackingContextId
StackingContextId
2. Scene graph
Viewport
Render target
Layer
Layer
Layer
AABB
AABB
AABB
● Build_scene -> Do scene graph
● Render -> Generate RenderFrame
Main thread
render_backend
thread
APIMsg::
SetRootPipeline
● Get root stacking_context
● Create render target
● Create layer
Create new Layer
add_items_to_target
Scrollable
stacking
context
Yes
No
Render_backend::
build_scene()
Frame::create() Frame::flatten()
● Add items to render
target
Frame::create
● Create a root layer and render target
● Flatten
○ Try to add to the existing layers as an AABB node or create a new one
■ Determine by whether the same scroll_layer_id or not
impl Layer {
pub fn new(world_origin: Point2D<f32>,
layer_size: Size2D<f32>,
viewport_rect: &Rect<f32>,
viewport_transform: &Matrix4D<f32>,
local_transform: &Matrix4D<f32>,
local_perspective: &Matrix4D<f32>,
pipeline_id: PipelineId,
stacking_context_id: ServoStackingContextId)
Layer
● Own an AABB tree to manage scene items
● Cull via view_port rect
Frame::build
● Cull layer’s AABB nodes
○ Adjust viewport to layer’s local space
○ Recursively check_node_visibility->
intersect(viewport rect, AABB node rect) and
mark is_visible to true
● Update
○ Resource
○ Texture
○ Glyph
Cull layers
via viewport rect
Update
Frame::build
● compile_visible_nodes
○ Thread_pool.scoped
○ Node_compiler uses BatchBuilder to batch draw list
(same texture, color)
(batch.rs:add_rectangle)
● update_batch_cache
○ Because some vertex buffers are modified after
batching, pending them to update
● update_layer_transforms
○ Update child layer’s world transform and viewport
to the world space
compile_visible_nodes
update_batch_cache
update_layer_transform
Frame::build
● compile_visible_nodes
○ Thread_pool.scoped
○ Node_compiler uses BatchBuilder to batch draw list
(same texture, color)
(batch.rs:add_rectangle)
● update_batch_cache
○ Because some vertex buffers are modified after
batching, pending them to update
● update_layer_transforms
○ Update child layer’s world transform and viewport
to the world space
compile_visible_nodes
update_batch_cache
update_layer_transform
thread_pool.scoped(|scope| {
for (_, layer) in layers {
let nodes = &mut layer.aabb_tree.nodes;
for node in nodes {
if node.is_visible && node.compiled_node.is_none() {
scope.execute(move || {
node.compile(resource_cache,
frame_id,
device_pixel_ratio,
stacking_context_info,
draw_list_groups,
pipeline_auxiliary_lists);
});
}
}
}
});
Frame::build
● collect_and_sort_visible_batches
○ Collect visible batches from layers and
transform them to RenderTarget space.
○ Traverse RenderTarget tree to collect
■ CompositeBatch (clear buffer,
transform, set texture commands)
■ DrawListBatch (collect draw calls)
○ Generate a DrawLayer tree
○ Return a RendererFrame
● expire_old_resources
collect_and_sort_visible_batches
expire_old_resources
3. Render
Renderer::update
● Pending shader/texture/batch updates
● Set the Rendererframe from Frame::build() to current frame
Renderer::render
● Draw frame
○ Calculate_layer_viewports
■ Layer_viewports ←- a layer owns a viewport
■ Recursive process the child layer’s viewport
○ Draw_layer recursively for children
■ Bind render target
■ Clear buffer
■ Update shaders/texture cache/batches
■ DrawCommand
● Clear frame buffer
● Batch: combine index buffer → draw_simple_triangles
● CompositeBatch ---> apply filter ---> combine index buffer → draw_simple_triangles
● End frame
○ gl::end_frame()
Render thread
RenderBackend thread
Main thread
Summary
StackingContext &
DisplayList creation
ScenePipeline
creation
AABB tree creation
Add DisplayItem
to layers
AABB nodes culling
Draw list batching
Visible batch collection
RenderFrame publication
RenderTarget
binding
Update resource
DrawCommand
execution
APIMsg::
SetRootPipeline
APIMsg::
SetRootStackingContext
RenderBackend::run()
Renderer::render()
CPU waiting GPU time
Webrender teaches us
● Scene graph
○ Using AABB tree to remove invisible display items effectively.
● Batching
○ Reduce draw calls and state changes to save redundant API calls.
● Delay execution draw commands
○ Avoiding unneeded mode-transition to occur CPU / GPU waiting time.
Thanks for your attention
Question?

Mais conteúdo relacionado

Mais procurados

Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveBin Chen
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSSMario Hernandez
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Graham Wihlidal
 
Slides - Tailwind CSS.pdf
Slides - Tailwind CSS.pdfSlides - Tailwind CSS.pdf
Slides - Tailwind CSS.pdfIgorAugusto76
 
Dx11 performancereloaded
Dx11 performancereloadedDx11 performancereloaded
Dx11 performancereloadedmistercteam
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overviewJacob Nelson
 
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lightsPrecomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lightsSeongdae Kim
 
Working Remotely (via SSH) Rocks!
Working Remotely (via SSH) Rocks!Working Remotely (via SSH) Rocks!
Working Remotely (via SSH) Rocks!Kent Chen
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android Arvind Devaraj
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architectureIblesoft
 
전형규, Vertex Post-Processing Framework, NDC2011
전형규, Vertex Post-Processing Framework, NDC2011전형규, Vertex Post-Processing Framework, NDC2011
전형규, Vertex Post-Processing Framework, NDC2011devCAT Studio, NEXON
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout Rachel Andrew
 

Mais procurados (20)

CSS Grid
CSS GridCSS Grid
CSS Grid
 
Css floats
Css floatsCss floats
Css floats
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016
 
Slides - Tailwind CSS.pdf
Slides - Tailwind CSS.pdfSlides - Tailwind CSS.pdf
Slides - Tailwind CSS.pdf
 
Dx11 performancereloaded
Dx11 performancereloadedDx11 performancereloaded
Dx11 performancereloaded
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lightsPrecomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
 
Working Remotely (via SSH) Rocks!
Working Remotely (via SSH) Rocks!Working Remotely (via SSH) Rocks!
Working Remotely (via SSH) Rocks!
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android
 
Redux toolkit
Redux toolkitRedux toolkit
Redux toolkit
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
 
React workshop
React workshopReact workshop
React workshop
 
전형규, Vertex Post-Processing Framework, NDC2011
전형규, Vertex Post-Processing Framework, NDC2011전형규, Vertex Post-Processing Framework, NDC2011
전형규, Vertex Post-Processing Framework, NDC2011
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout
 
NEXT.JS
NEXT.JSNEXT.JS
NEXT.JS
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
Bootstrap grids
Bootstrap gridsBootstrap grids
Bootstrap grids
 

Semelhante a Webrender 1.0

FrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteFrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteElectronic Arts / DICE
 
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio [Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio Owen Wu
 
CartoDB Inside Out
CartoDB Inside OutCartoDB Inside Out
CartoDB Inside OutJorge Sanz
 
Presentation on angular 5
Presentation on angular 5Presentation on angular 5
Presentation on angular 5Ramesh Adhikari
 
[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523NAVER D2
 
Advanced Node.JS Meetup
Advanced Node.JS MeetupAdvanced Node.JS Meetup
Advanced Node.JS MeetupLINAGORA
 
Computer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming IComputer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming I💻 Anton Gerdelan
 
What's new in Android Pie
What's new in Android PieWhat's new in Android Pie
What's new in Android PieHassan Abid
 
OpenCms Days 2014 - OpenCms content editor and pdf extensions
OpenCms Days 2014 - OpenCms content editor and pdf extensionsOpenCms Days 2014 - OpenCms content editor and pdf extensions
OpenCms Days 2014 - OpenCms content editor and pdf extensionsAlkacon Software GmbH & Co. KG
 
Drupal, GraphQL, Views, View Modes and Gatsby for a US Gov site CMS Philly
Drupal, GraphQL, Views, View Modes  and Gatsby for a US Gov site CMS PhillyDrupal, GraphQL, Views, View Modes  and Gatsby for a US Gov site CMS Philly
Drupal, GraphQL, Views, View Modes and Gatsby for a US Gov site CMS PhillyJesus Manuel Olivas
 
Startup Snapshot in Node.js
Startup Snapshot in Node.jsStartup Snapshot in Node.js
Startup Snapshot in Node.jsIgalia
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing moreICS
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentDavid Galeano
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewYu-Hsin Hung
 

Semelhante a Webrender 1.0 (20)

Qt Programming on TI Processors
Qt Programming on TI ProcessorsQt Programming on TI Processors
Qt Programming on TI Processors
 
FrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteFrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in Frostbite
 
Server side rendering review
Server side rendering reviewServer side rendering review
Server side rendering review
 
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio [Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
 
FrontEnd.pdf
FrontEnd.pdfFrontEnd.pdf
FrontEnd.pdf
 
CartoDB Inside Out
CartoDB Inside OutCartoDB Inside Out
CartoDB Inside Out
 
Presentation on angular 5
Presentation on angular 5Presentation on angular 5
Presentation on angular 5
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
 
CityEngine-OpenDS
CityEngine-OpenDSCityEngine-OpenDS
CityEngine-OpenDS
 
[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523
 
Advanced Node.JS Meetup
Advanced Node.JS MeetupAdvanced Node.JS Meetup
Advanced Node.JS Meetup
 
Computer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming IComputer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming I
 
What's new in Android Pie
What's new in Android PieWhat's new in Android Pie
What's new in Android Pie
 
OpenCms Days 2014 - OpenCms content editor and pdf extensions
OpenCms Days 2014 - OpenCms content editor and pdf extensionsOpenCms Days 2014 - OpenCms content editor and pdf extensions
OpenCms Days 2014 - OpenCms content editor and pdf extensions
 
Drupal, GraphQL, Views, View Modes and Gatsby for a US Gov site CMS Philly
Drupal, GraphQL, Views, View Modes  and Gatsby for a US Gov site CMS PhillyDrupal, GraphQL, Views, View Modes  and Gatsby for a US Gov site CMS Philly
Drupal, GraphQL, Views, View Modes and Gatsby for a US Gov site CMS Philly
 
Startup Snapshot in Node.js
Startup Snapshot in Node.jsStartup Snapshot in Node.js
Startup Snapshot in Node.js
 
Next.js with drupal, the good parts
Next.js with drupal, the good partsNext.js with drupal, the good parts
Next.js with drupal, the good parts
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing more
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game development
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture Overview
 

Mais de Daosheng Mu

A frame beginner lesson
A frame beginner lessonA frame beginner lesson
A frame beginner lessonDaosheng Mu
 
Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-FrameDaosheng Mu
 
Introduction to WebGL and WebVR
Introduction to WebGL and WebVRIntroduction to WebGL and WebVR
Introduction to WebGL and WebVRDaosheng Mu
 
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...Daosheng Mu
 
Introduce to 3d rendering engine
Introduce to 3d rendering engineIntroduce to 3d rendering engine
Introduce to 3d rendering engineDaosheng Mu
 
Order independent transparency
Order independent transparencyOrder independent transparency
Order independent transparencyDaosheng Mu
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engineDaosheng Mu
 

Mais de Daosheng Mu (9)

Maze VR
Maze VRMaze VR
Maze VR
 
A frame beginner lesson
A frame beginner lessonA frame beginner lesson
A frame beginner lesson
 
Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-Frame
 
Introduction to WebGL and WebVR
Introduction to WebGL and WebVRIntroduction to WebGL and WebVR
Introduction to WebGL and WebVR
 
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
 
Introduce to 3d rendering engine
Introduce to 3d rendering engineIntroduce to 3d rendering engine
Introduce to 3d rendering engine
 
Direct3D to WPF
Direct3D to WPFDirect3D to WPF
Direct3D to WPF
 
Order independent transparency
Order independent transparencyOrder independent transparency
Order independent transparency
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engine
 

Último

Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Delhi Call girls
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Standkumarajju5765
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Call Girls in Nagpur High Profile
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.CarlotaBedoya1
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 

Último (20)

Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 

Webrender 1.0

  • 2. Introduction ● The rendering engine of Servo ○ Implementations of essentially all features of CSS that Servo supports. ○ Working on enabled by default. ○ Separately from Servo ● Initial commit: September 22, 2015. ● Two main developers: Glenn Watson (lead) and Patrick Walton. ● OpenGL-based renderer ● This is just version 1.0… Still in progress.
  • 4. GPU API modes Retained mode Immediate mode Tiled-based mode In 2000s PC GPUs In 2010s mobile GPUsIn 1990s PC GPUs
  • 5. [In existing APIs] path rendering can result in many state changes per path…In this case, the API overhead can substantially limit the overall performance. Our experience…indicates these approaches are often more GPU-assisted rather than GPU-accelerated… —Mark Kilgard and Jeff Bolz, NVIDIA SIGGRAPH Asia 2012
  • 6. Today web browsers respecify paths every time a web page with path content is re-rendered assuming re-specifying paths is cheap…When path rendering is fully GPU-accelerated, a retained model of rendering is more appropriate and efficient. We believe web browsers should behave more like video games in this respect to exploit the GPU. —Mark Kilgard and Jeff Bolz, NVIDIA SIGGRAPH Asia 2012
  • 7. Retained vs. Immediate mode ● Framework example: WPF vs. Direct2D ● Immediate mode gives the control of GPU pipeline to developers. ○ If you are good at this, your application would gain more performance. Otherwise... ● Immediate mode doesn’t help the management of scene, state, and batch. ● Retained mode have display lists for managing drawcalls & states. Ex: OpenGL 2.0
  • 8. --- Advanced Game Programming 3D Mathematics. Graphics API “Game engines do scene graph no matter retained mode or immediate mode API” “Scene graph == Software retained mode” Batching State management Sorting etc...
  • 9. --- Advanced Game Programming 3D Mathematics. Graphics API How about Web browser? CSS DOM simple scene graph Batching State management Sorting etc...
  • 10. GPU synchronization ● Mode transition ● Command buffer “glFinish​. It will not return, stopping the current CPU thread, until all rendering commands that have been sent have completed.”
  • 11. What is Webrender? ● A game engine (renderer) for Web browser ● Retained mode, multithreaded ● Focus on CSS ● Takes a post-layout CSS display list and draws it to the screen as quickly as possible. ● Webrender supports OpenGL ES 2.1 and OpenGL 3.x. ○ Instance rendering / Loop in shaders ● Webrender could be used as a backend for any sort of 2D graphics that CSS can describe
  • 13. IOCompositor:: composite Event IOCompositor:: composite_specific_target Servo Renderer thread Renderer::update Renderer::render publish_frame build_scene frame.create render frame.build run Renderer::new Create OpenGL device Create shader / texture Spawn render_backend thread webrender_traits IOCompositor:: set_frame_tree RenderBackend thread ApiMsg:: SetRootPipeline ApiMsg:: SetRootPipeline Webrender RendererFrame draw RendererFrame Main thread
  • 14. Steps 1. Add items to display list 2. Scene graph: frame, layer, AABB tree, culling 3. Render
  • 15. 1. Add items to display list
  • 16. DisplayItem ● The minimum unit of renderable item ● It describes by a visible rect and clip region ● Types: ○ RectangleDisplayItem ○ TextDisplayItem ○ ImageDisplayItem ○ WebGLDisplayItem ○ BorderDisplayItem ○ BoxShadowDisplayItem ○ GradientDisplayItem DisplayListBuilder pub enum SpecificDisplayListItem { DrawList(DrawListInfo), StackingContext(StackingContextInfo), Iframe(IframeInfo), } ○ Store items to a list ○ Finalize ■ Generate a displaylist as Blob convert_to_webrender
  • 17. StackingContext ● Stacking context is the three-dimensional conceptualization of HTML elements along an imaginary z-axis relative to the user who is assumed to be facing the viewport or the webpage pub struct StackingContext { pub servo_id: ServoStackingContextId, pub scroll_layer_id: Option<ScrollLayerId>, pub scroll_policy: ScrollPolicy, pub bounds: Rect<f32>, pub overflow: Rect<f32>, pub z_index: i32, pub display_lists: Vec<DisplayListId>, pub transform: Matrix4, pub perspective: Matrix4, pub establishes_3d_context: bool, pub mix_blend_mode: MixBlendMode, pub filters: ItemRange, pub has_stacking_contexts: bool, }
  • 18. StackingContext - display_list [id] Scene - display_list_map(id, display_list)StackingContext DisplayItem
  • 19. ● Scene.add_stacking_context ● Scene.add_display_list ● Scene.set_root_stacking_context Main thread render_backend thread APIMsg:: SetRootStackingContext Servo Webrender
  • 20. Scene ● Pipeline_map / display_list_map / stacking_context_map ● Set_root_stacking_context() ○ Remove old display list and stacking_context ○ New a scene pipeline ○ Insert to pipeline_map and remove old one pub struct ScenePipeline { pub pipeline_id: PipelineId, pub epoch: Epoch, pub background_draw_list: Option<DrawListId>, pub root_stacking_context_id: StackingContextId, pub viewport_size: Size2D<f32>, }
  • 21. display_list_map pipeline_id display_list(SpecificDisplayListItem) pipeline_id display_list(DrawList) Ex: pipeline_id display_list(StackingContext) pipeline_id display_list(Iframe) pub enum SpecificSceneItem { DrawList(DrawListId), StackingContext(StackingContextId, PipelineId), Iframe(IframeInfo), } pub struct SceneDisplayList { pipeline_id SceneItem<Vec> epoch } SpecificDisplayListItem is mapped to SpecificSceneItem Stored to
  • 22. stacking_context_map StackingContextId SceneStackingContext stacking_context stacking_context stacking_context pub struct SceneStackingContext { pub pipeline_id: PipelineId, pub epoch: Epoch, pub stacking_context: StackingContext, pub stacking_context_id: StackingContextId, } StackingContextId StackingContextId StackingContextId
  • 25. ● Build_scene -> Do scene graph ● Render -> Generate RenderFrame Main thread render_backend thread APIMsg:: SetRootPipeline
  • 26. ● Get root stacking_context ● Create render target ● Create layer Create new Layer add_items_to_target Scrollable stacking context Yes No Render_backend:: build_scene() Frame::create() Frame::flatten() ● Add items to render target
  • 27. Frame::create ● Create a root layer and render target ● Flatten ○ Try to add to the existing layers as an AABB node or create a new one ■ Determine by whether the same scroll_layer_id or not impl Layer { pub fn new(world_origin: Point2D<f32>, layer_size: Size2D<f32>, viewport_rect: &Rect<f32>, viewport_transform: &Matrix4D<f32>, local_transform: &Matrix4D<f32>, local_perspective: &Matrix4D<f32>, pipeline_id: PipelineId, stacking_context_id: ServoStackingContextId) Layer ● Own an AABB tree to manage scene items ● Cull via view_port rect
  • 28. Frame::build ● Cull layer’s AABB nodes ○ Adjust viewport to layer’s local space ○ Recursively check_node_visibility-> intersect(viewport rect, AABB node rect) and mark is_visible to true ● Update ○ Resource ○ Texture ○ Glyph Cull layers via viewport rect Update
  • 29. Frame::build ● compile_visible_nodes ○ Thread_pool.scoped ○ Node_compiler uses BatchBuilder to batch draw list (same texture, color) (batch.rs:add_rectangle) ● update_batch_cache ○ Because some vertex buffers are modified after batching, pending them to update ● update_layer_transforms ○ Update child layer’s world transform and viewport to the world space compile_visible_nodes update_batch_cache update_layer_transform
  • 30. Frame::build ● compile_visible_nodes ○ Thread_pool.scoped ○ Node_compiler uses BatchBuilder to batch draw list (same texture, color) (batch.rs:add_rectangle) ● update_batch_cache ○ Because some vertex buffers are modified after batching, pending them to update ● update_layer_transforms ○ Update child layer’s world transform and viewport to the world space compile_visible_nodes update_batch_cache update_layer_transform thread_pool.scoped(|scope| { for (_, layer) in layers { let nodes = &mut layer.aabb_tree.nodes; for node in nodes { if node.is_visible && node.compiled_node.is_none() { scope.execute(move || { node.compile(resource_cache, frame_id, device_pixel_ratio, stacking_context_info, draw_list_groups, pipeline_auxiliary_lists); }); } } } });
  • 31. Frame::build ● collect_and_sort_visible_batches ○ Collect visible batches from layers and transform them to RenderTarget space. ○ Traverse RenderTarget tree to collect ■ CompositeBatch (clear buffer, transform, set texture commands) ■ DrawListBatch (collect draw calls) ○ Generate a DrawLayer tree ○ Return a RendererFrame ● expire_old_resources collect_and_sort_visible_batches expire_old_resources
  • 33. Renderer::update ● Pending shader/texture/batch updates ● Set the Rendererframe from Frame::build() to current frame
  • 34. Renderer::render ● Draw frame ○ Calculate_layer_viewports ■ Layer_viewports ←- a layer owns a viewport ■ Recursive process the child layer’s viewport ○ Draw_layer recursively for children ■ Bind render target ■ Clear buffer ■ Update shaders/texture cache/batches ■ DrawCommand ● Clear frame buffer ● Batch: combine index buffer → draw_simple_triangles ● CompositeBatch ---> apply filter ---> combine index buffer → draw_simple_triangles ● End frame ○ gl::end_frame()
  • 35. Render thread RenderBackend thread Main thread Summary StackingContext & DisplayList creation ScenePipeline creation AABB tree creation Add DisplayItem to layers AABB nodes culling Draw list batching Visible batch collection RenderFrame publication RenderTarget binding Update resource DrawCommand execution APIMsg:: SetRootPipeline APIMsg:: SetRootStackingContext
  • 37. Webrender teaches us ● Scene graph ○ Using AABB tree to remove invisible display items effectively. ● Batching ○ Reduce draw calls and state changes to save redundant API calls. ● Delay execution draw commands ○ Avoiding unneeded mode-transition to occur CPU / GPU waiting time.
  • 38. Thanks for your attention Question?