pub struct Renderer {Show 63 fields
result_rx: Receiver<ResultMsg>,
api_tx: Sender<ApiMsg>,
pub device: Device,
pending_texture_updates: Vec<TextureUpdateList>,
pending_texture_cache_updates: bool,
pending_native_surface_updates: Vec<NativeSurfaceOperation>,
pending_gpu_cache_updates: Vec<GpuCacheUpdateList>,
pending_gpu_cache_clear: bool,
pending_shader_updates: Vec<PathBuf>,
active_documents: FastHashMap<DocumentId, RenderedDocument>,
shaders: Rc<RefCell<Shaders>>,
max_recorded_profiles: usize,
clear_color: ColorF,
enable_clear_scissor: bool,
enable_advanced_blend_barriers: bool,
clear_caches_with_quads: bool,
clear_alpha_targets_with_quads: bool,
debug: LazyInitializedDebugRenderer,
debug_flags: DebugFlags,
profile: TransactionProfile,
frame_counter: u64,
resource_upload_time: f64,
gpu_cache_upload_time: f64,
profiler: Profiler,
last_time: u64,
pub gpu_profiler: GpuProfiler,
vaos: RendererVAOs,
gpu_cache_texture: GpuCacheTexture,
vertex_data_textures: Vec<VertexDataTextures>,
current_vertex_data_textures: usize,
gpu_cache_debug_chunks: Vec<Vec<GpuCacheDebugChunk>>,
gpu_cache_frame_id: FrameId,
gpu_cache_overflow: bool,
pipeline_info: PipelineInfo,
texture_resolver: TextureResolver,
texture_upload_pbo_pool: UploadPBOPool,
staging_texture_pool: UploadTexturePool,
dither_matrix_texture: Option<Texture>,
external_image_handler: Option<Box<dyn ExternalImageHandler>>,
size_of_ops: Option<MallocSizeOfOps>,
pub renderer_errors: Vec<RendererError>,
pub(crate) async_frame_recorder: Option<AsyncScreenshotGrabber>,
pub(crate) async_screenshots: Option<AsyncScreenshotGrabber>,
cpu_profiles: VecDeque<CpuProfile>,
gpu_profiles: VecDeque<GpuProfile>,
notifications: Vec<NotificationRequest>,
device_size: Option<DeviceIntSize>,
zoom_debug_texture: Option<Texture>,
cursor_position: DeviceIntPoint,
shared_texture_cache_cleared: bool,
documents_seen: HashSet<DocumentId, BuildHasherDefault<FxHasher>>,
read_fbo: FBOId,
compositor_config: CompositorConfig,
current_compositor_kind: CompositorKind,
allocated_native_surfaces: HashSet<NativeSurfaceId, BuildHasherDefault<FxHasher>>,
force_redraw: bool,
debug_overlay_state: DebugOverlayState,
buffer_damage_tracker: BufferDamageTracker,
max_primitive_instance_count: usize,
enable_instancing: bool,
consecutive_oom_frames: u32,
target_frame_publish_id: Option<FramePublishId>,
pending_result_msg: Option<ResultMsg>,
}
Expand description
The renderer is responsible for submitting to the GPU the work prepared by the RenderBackend.
We have a separate Renderer
instance for each instance of WebRender (generally
one per OS window), and all instances share the same thread.
Fields§
§result_rx: Receiver<ResultMsg>
§api_tx: Sender<ApiMsg>
§device: Device
§pending_texture_updates: Vec<TextureUpdateList>
§pending_texture_cache_updates: bool
True if there are any TextureCacheUpdate pending.
pending_native_surface_updates: Vec<NativeSurfaceOperation>
§pending_gpu_cache_updates: Vec<GpuCacheUpdateList>
§pending_gpu_cache_clear: bool
§pending_shader_updates: Vec<PathBuf>
§active_documents: FastHashMap<DocumentId, RenderedDocument>
§shaders: Rc<RefCell<Shaders>>
§max_recorded_profiles: usize
§clear_color: ColorF
§enable_clear_scissor: bool
§enable_advanced_blend_barriers: bool
§clear_caches_with_quads: bool
§clear_alpha_targets_with_quads: bool
§debug: LazyInitializedDebugRenderer
§debug_flags: DebugFlags
§profile: TransactionProfile
§frame_counter: u64
§resource_upload_time: f64
§gpu_cache_upload_time: f64
§profiler: Profiler
§last_time: u64
§gpu_profiler: GpuProfiler
§vaos: RendererVAOs
§gpu_cache_texture: GpuCacheTexture
§vertex_data_textures: Vec<VertexDataTextures>
§current_vertex_data_textures: usize
§gpu_cache_debug_chunks: Vec<Vec<GpuCacheDebugChunk>>
When the GPU cache debugger is enabled, we keep track of the live blocks in the GPU cache so that we can use them for the debug display. This member stores those live blocks, indexed by row.
gpu_cache_frame_id: FrameId
§gpu_cache_overflow: bool
§pipeline_info: PipelineInfo
§texture_resolver: TextureResolver
§texture_upload_pbo_pool: UploadPBOPool
§staging_texture_pool: UploadTexturePool
§dither_matrix_texture: Option<Texture>
§external_image_handler: Option<Box<dyn ExternalImageHandler>>
Optional trait object that allows the client application to provide external buffers for image data.
size_of_ops: Option<MallocSizeOfOps>
Optional function pointers for measuring memory used by a given heap-allocated pointer.
renderer_errors: Vec<RendererError>
§async_frame_recorder: Option<AsyncScreenshotGrabber>
§async_screenshots: Option<AsyncScreenshotGrabber>
§cpu_profiles: VecDeque<CpuProfile>
List of profile results from previous frames. Can be retrieved via get_frame_profiles().
gpu_profiles: VecDeque<GpuProfile>
§notifications: Vec<NotificationRequest>
Notification requests to be fulfilled after rendering.
device_size: Option<DeviceIntSize>
§zoom_debug_texture: Option<Texture>
A lazily created texture for the zoom debugging widget.
cursor_position: DeviceIntPoint
The current mouse position. This is used for debugging functionality only, such as the debug zoom widget.
Guards to check if we might be rendering a frame with expired texture cache entries.
documents_seen: HashSet<DocumentId, BuildHasherDefault<FxHasher>>
The set of documents which we’ve seen a publish for since last render.
read_fbo: FBOId
§compositor_config: CompositorConfig
The compositing config, affecting how WR composites into the final scene.
current_compositor_kind: CompositorKind
§allocated_native_surfaces: HashSet<NativeSurfaceId, BuildHasherDefault<FxHasher>>
Maintains a set of allocated native composite surfaces. This allows any currently allocated surfaces to be cleaned up as soon as deinit() is called (the normal bookkeeping for native surfaces exists in the render backend thread).
force_redraw: bool
If true, partial present state has been reset and everything needs to be drawn on the next render.
debug_overlay_state: DebugOverlayState
State related to the debug / profiling overlays
buffer_damage_tracker: BufferDamageTracker
Tracks the dirty rectangles from previous frames. Used on platforms that require keeping the front buffer fully correct when doing partial present (e.g. unix desktop with EGL_EXT_buffer_age).
max_primitive_instance_count: usize
§enable_instancing: bool
§consecutive_oom_frames: u32
Count consecutive oom frames to detectif we are stuck unable to render in a loop.
target_frame_publish_id: Option<FramePublishId>
update() defers processing of ResultMsg, if frame_publish_id of ResultMsg::PublishDocument exceeds target_frame_publish_id.
pending_result_msg: Option<ResultMsg>
Hold a next ResultMsg that will be handled by update().
Implementations§
source§impl Renderer
impl Renderer
pub fn update_gpu_cache(&mut self)
pub fn prepare_gpu_cache( &mut self, deferred_resolves: &[DeferredResolve], ) -> Result<(), RendererError>
pub fn read_gpu_cache(&mut self) -> (DeviceIntSize, Vec<u8>)
source§impl Renderer
impl Renderer
pub fn device_size(&self) -> Option<DeviceIntSize>
sourcepub fn set_cursor_position(&mut self, position: DeviceIntPoint)
pub fn set_cursor_position(&mut self, position: DeviceIntPoint)
Update the current position of the debug cursor.
pub fn get_max_texture_size(&self) -> i32
pub fn get_graphics_api_info(&self) -> GraphicsApiInfo
pub fn preferred_color_format(&self) -> ImageFormat
pub fn required_texture_stride_alignment(&self, format: ImageFormat) -> usize
pub fn set_clear_color(&mut self, color: ColorF)
pub fn flush_pipeline_info(&mut self) -> PipelineInfo
sourcepub fn current_epoch(
&self,
document_id: DocumentId,
pipeline_id: PipelineId,
) -> Option<Epoch>
pub fn current_epoch( &self, document_id: DocumentId, pipeline_id: PipelineId, ) -> Option<Epoch>
Returns the Epoch of the current frame in a pipeline.
fn get_next_result_msg(&mut self) -> Option<ResultMsg>
sourcepub fn update(&mut self)
pub fn update(&mut self)
Processes the result queue.
Should be called before render()
, as texture cache updates are done here.
sourcepub fn set_target_frame_publish_id(&mut self, publish_id: FramePublishId)
pub fn set_target_frame_publish_id(&mut self, publish_id: FramePublishId)
update() defers processing of ResultMsg, if frame_publish_id of ResultMsg::PublishDocument exceeds target_frame_publish_id.
fn handle_debug_command(&mut self, command: DebugCommand)
sourcepub fn set_external_image_handler(
&mut self,
handler: Box<dyn ExternalImageHandler>,
)
pub fn set_external_image_handler( &mut self, handler: Box<dyn ExternalImageHandler>, )
Set a callback for handling external images.
sourcepub fn get_frame_profiles(&mut self) -> (Vec<CpuProfile>, Vec<GpuProfile>)
pub fn get_frame_profiles(&mut self) -> (Vec<CpuProfile>, Vec<GpuProfile>)
Retrieve (and clear) the current list of recorded frame profiles.
sourcepub fn force_redraw(&mut self)
pub fn force_redraw(&mut self)
Reset the current partial present state. This forces the entire framebuffer
to be refreshed next time render
is called.
sourcepub fn render(
&mut self,
device_size: DeviceIntSize,
buffer_age: usize,
) -> Result<RenderResults, Vec<RendererError>>
pub fn render( &mut self, device_size: DeviceIntSize, buffer_age: usize, ) -> Result<RenderResults, Vec<RendererError>>
Renders the current frame.
A Frame is supplied by calling [generate_frame()
][webrender_api::Transaction::generate_frame].
buffer_age is the age of the current backbuffer. It is only relevant if partial present
is active, otherwise 0 should be passed here.
sourcefn update_debug_overlay(
&mut self,
framebuffer_size: DeviceIntSize,
has_debug_items: bool,
)
fn update_debug_overlay( &mut self, framebuffer_size: DeviceIntSize, has_debug_items: bool, )
Update the state of any debug / profiler overlays. This is currently only needed when running with the native compositor enabled.
sourcefn bind_debug_overlay(
&mut self,
device_size: DeviceIntSize,
) -> Option<DrawTarget>
fn bind_debug_overlay( &mut self, device_size: DeviceIntSize, ) -> Option<DrawTarget>
Bind a draw target for the debug / profiler overlays, if required.
sourcefn unbind_debug_overlay(&mut self)
fn unbind_debug_overlay(&mut self)
Unbind the draw target for debug / profiler overlays, if required.
fn render_impl( &mut self, doc_id: DocumentId, active_doc: &mut RenderedDocument, device_size: Option<DeviceIntSize>, buffer_age: usize, ) -> Result<RenderResults, Vec<RendererError>>
fn update_gpu_profile(&mut self, device_size: DeviceIntSize)
fn update_texture_cache(&mut self)
fn check_gl_errors(&mut self)
fn bind_textures(&mut self, textures: &BatchTextures)
fn draw_instanced_batch<T: Clone>( &mut self, data: &[T], vertex_array_kind: VertexArrayKind, textures: &BatchTextures, stats: &mut RendererStats, )
fn handle_readback_composite( &mut self, draw_target: DrawTarget, uses_scissor: bool, backdrop: &RenderTask, readback: &RenderTask, )
fn handle_resolves( &mut self, resolve_ops: &[ResolveOp], render_tasks: &RenderTaskGraph, draw_target: DrawTarget, )
fn handle_prims( &mut self, draw_target: &DrawTarget, prim_instances: &[FastHashMap<TextureSource, Vec<PrimitiveInstanceData>>], prim_instances_with_scissor: &FastHashMap<(DeviceIntRect, PatternKind), FastHashMap<TextureSource, Vec<PrimitiveInstanceData>>>, projection: &Transform3D<f32>, stats: &mut RendererStats, )
fn handle_clips( &mut self, draw_target: &DrawTarget, masks: &ClipMaskInstanceList, projection: &Transform3D<f32>, stats: &mut RendererStats, )
fn handle_blits( &mut self, blits: &[BlitJob], render_tasks: &RenderTaskGraph, draw_target: DrawTarget, )
fn handle_scaling( &mut self, scalings: &FastHashMap<TextureSource, Vec<ScalingInstance>>, projection: &Transform3D<f32>, stats: &mut RendererStats, )
fn handle_svg_filters( &mut self, textures: &BatchTextures, svg_filters: &[SvgFilterInstance], projection: &Transform3D<f32>, stats: &mut RendererStats, )
fn handle_svg_nodes( &mut self, textures: &BatchTextures, svg_filters: &[SVGFEFilterInstance], projection: &Transform3D<f32>, stats: &mut RendererStats, )
fn handle_resolve( &mut self, resolve_op: &ResolveOp, render_tasks: &RenderTaskGraph, draw_target: DrawTarget, )
fn draw_picture_cache_target( &mut self, target: &PictureCacheTarget, draw_target: DrawTarget, projection: &Transform3D<f32>, render_tasks: &RenderTaskGraph, stats: &mut RendererStats, )
sourcefn draw_alpha_batch_container(
&mut self,
alpha_batch_container: &AlphaBatchContainer,
draw_target: DrawTarget,
framebuffer_kind: FramebufferKind,
projection: &Transform3D<f32>,
render_tasks: &RenderTaskGraph,
stats: &mut RendererStats,
)
fn draw_alpha_batch_container( &mut self, alpha_batch_container: &AlphaBatchContainer, draw_target: DrawTarget, framebuffer_kind: FramebufferKind, projection: &Transform3D<f32>, render_tasks: &RenderTaskGraph, stats: &mut RendererStats, )
Draw an alpha batch container into a given draw target. This is used by both color and picture cache target kinds.
sourcefn update_external_native_surfaces(
&mut self,
external_surfaces: &[ResolvedExternalSurface],
results: &mut RenderResults,
)
fn update_external_native_surfaces( &mut self, external_surfaces: &[ResolvedExternalSurface], results: &mut RenderResults, )
Rasterize any external compositor surfaces that require updating
sourcefn draw_tile_list<'a, I: Iterator<Item = &'a Item>>(
&mut self,
tiles_iter: I,
composite_state: &CompositeState,
external_surfaces: &[ResolvedExternalSurface],
projection: &Transform3D<f32>,
stats: &mut RendererStats,
)
fn draw_tile_list<'a, I: Iterator<Item = &'a Item>>( &mut self, tiles_iter: I, composite_state: &CompositeState, external_surfaces: &[ResolvedExternalSurface], projection: &Transform3D<f32>, stats: &mut RendererStats, )
Draw a list of tiles to the framebuffer
sourcefn composite_simple(
&mut self,
composite_state: &CompositeState,
draw_target: DrawTarget,
projection: &Transform3D<f32>,
results: &mut RenderResults,
partial_present_mode: Option<PartialPresentMode>,
)
fn composite_simple( &mut self, composite_state: &CompositeState, draw_target: DrawTarget, projection: &Transform3D<f32>, results: &mut RenderResults, partial_present_mode: Option<PartialPresentMode>, )
Composite picture cache tiles into the framebuffer. This is currently the only way that picture cache tiles get drawn. In future, the tiles will often be handed to the OS compositor, and this method will be rarely used.
fn draw_color_target( &mut self, draw_target: DrawTarget, target: &ColorRenderTarget, clear_depth: Option<f32>, render_tasks: &RenderTaskGraph, projection: &Transform3D<f32>, stats: &mut RendererStats, )
fn draw_blurs( &mut self, blurs: &FastHashMap<TextureSource, Vec<BlurInstance>>, stats: &mut RendererStats, )
sourcefn draw_clip_batch_list(
&mut self,
list: &ClipBatchList,
projection: &Transform3D<f32>,
stats: &mut RendererStats,
)
fn draw_clip_batch_list( &mut self, list: &ClipBatchList, projection: &Transform3D<f32>, stats: &mut RendererStats, )
Draw all the instances in a clip batcher list to the current target.
fn draw_alpha_target( &mut self, draw_target: DrawTarget, target: &AlphaRenderTarget, projection: &Transform3D<f32>, render_tasks: &RenderTaskGraph, stats: &mut RendererStats, )
fn draw_texture_cache_target( &mut self, texture: &CacheTextureId, target: &TextureCacheRenderTarget, render_tasks: &RenderTaskGraph, stats: &mut RendererStats, )
fn update_deferred_resolves( &mut self, deferred_resolves: &[DeferredResolve], ) -> Option<GpuCacheUpdateList>
fn unlock_external_images(&mut self, deferred_resolves: &[DeferredResolve])
sourcefn calculate_dirty_rects(
&mut self,
buffer_age: usize,
composite_state: &CompositeState,
draw_target_dimensions: DeviceIntSize,
results: &mut RenderResults,
) -> Option<PartialPresentMode>
fn calculate_dirty_rects( &mut self, buffer_age: usize, composite_state: &CompositeState, draw_target_dimensions: DeviceIntSize, results: &mut RenderResults, ) -> Option<PartialPresentMode>
Update the dirty rects based on current compositing mode and config
fn bind_frame_data(&mut self, frame: &mut Frame)
fn update_native_surfaces(&mut self)
fn create_gpu_buffer_texture<T: Texel>( &mut self, buffer: &GpuBuffer<T>, sampler: TextureSampler, ) -> Option<Texture>
fn draw_frame( &mut self, frame: &mut Frame, device_size: Option<DeviceIntSize>, buffer_age: usize, results: &mut RenderResults, )
fn composite_frame( &mut self, frame: &mut Frame, device_size: Option<DeviceIntSize>, results: &mut RenderResults, present_mode: Option<PartialPresentMode>, )
pub fn debug_renderer(&mut self) -> Option<&mut DebugRenderer>
pub fn get_debug_flags(&self) -> DebugFlags
pub fn set_debug_flags(&mut self, flags: DebugFlags)
pub fn set_profiler_ui(&mut self, ui_str: &str)
fn draw_frame_debug_items(&mut self, items: &[DebugItem])
fn draw_render_target_debug(&mut self, draw_target: &DrawTarget)
fn draw_zoom_debug(&mut self, device_size: DeviceIntSize)
fn draw_texture_cache_debug(&mut self, draw_target: &DrawTarget)
fn do_debug_blit( device: &mut Device, debug_renderer: &mut DebugRenderer, textures: Vec<&Texture>, draw_target: &DrawTarget, bottom: i32, select_color: &dyn Fn(&Texture) -> [f32; 4], )
fn draw_epoch_debug(&mut self)
fn draw_window_visibility_debug(&mut self)
fn draw_gpu_cache_debug(&mut self, device_size: DeviceIntSize)
sourcepub fn read_pixels_into(
&mut self,
rect: FramebufferIntRect,
format: ImageFormat,
output: &mut [u8],
)
pub fn read_pixels_into( &mut self, rect: FramebufferIntRect, format: ImageFormat, output: &mut [u8], )
Pass-through to Device::read_pixels_into
, used by Gecko’s WR bindings.
pub fn read_pixels_rgba8(&mut self, rect: FramebufferIntRect) -> Vec<u8> ⓘ
pub fn deinit(self)
fn size_of<T>(&self, ptr: *const T) -> usize
sourcepub fn report_memory(&self, swgl: *mut c_void) -> MemoryReport
pub fn report_memory(&self, swgl: *mut c_void) -> MemoryReport
Collects a memory report.
fn set_blend(&mut self, blend: bool, framebuffer_kind: FramebufferKind)
fn set_blend_mode_multiply(&mut self, framebuffer_kind: FramebufferKind)
fn set_blend_mode_premultiplied_alpha( &mut self, framebuffer_kind: FramebufferKind, )
sourcefn clear_texture(&mut self, texture: &Texture, color: [f32; 4])
fn clear_texture(&mut self, texture: &Texture, color: [f32; 4])
Clears the texture with a given color.
source§impl Renderer
impl Renderer
fn save_texture( texture: &Texture, category: Option<TextureCacheCategory>, name: &str, root: &PathBuf, device: &mut Device, ) -> PlainTexture
fn save_capture( &mut self, config: CaptureConfig, deferred_images: Vec<ExternalCaptureImage>, )
source§impl Renderer
impl Renderer
sourcepub fn record_frame(
&mut self,
image_format: ImageFormat,
) -> Option<(RecordedFrameHandle, DeviceIntSize)>
pub fn record_frame( &mut self, image_format: ImageFormat, ) -> Option<(RecordedFrameHandle, DeviceIntSize)>
Record a frame for the Composition Recorder.
The returned handle can be passed to map_recorded_frame
to copy it into
a buffer.
The returned size is the size of the frame.
sourcepub fn map_recorded_frame(
&mut self,
handle: RecordedFrameHandle,
dst_buffer: &mut [u8],
dst_stride: usize,
) -> bool
pub fn map_recorded_frame( &mut self, handle: RecordedFrameHandle, dst_buffer: &mut [u8], dst_stride: usize, ) -> bool
Map a frame captured for the composition recorder into the given buffer.
sourcepub fn release_composition_recorder_structures(&mut self)
pub fn release_composition_recorder_structures(&mut self)
Free the data structures used by the composition recorder.
sourcepub fn get_screenshot_async(
&mut self,
window_rect: DeviceIntRect,
buffer_size: DeviceIntSize,
image_format: ImageFormat,
) -> (AsyncScreenshotHandle, DeviceIntSize)
pub fn get_screenshot_async( &mut self, window_rect: DeviceIntRect, buffer_size: DeviceIntSize, image_format: ImageFormat, ) -> (AsyncScreenshotHandle, DeviceIntSize)
Take a screenshot and scale it asynchronously.
The returned handle can be used to access the mapped screenshot data via
map_and_recycle_screenshot
.
The returned size is the size of the screenshot.
sourcepub fn map_and_recycle_screenshot(
&mut self,
handle: AsyncScreenshotHandle,
dst_buffer: &mut [u8],
dst_stride: usize,
) -> bool
pub fn map_and_recycle_screenshot( &mut self, handle: AsyncScreenshotHandle, dst_buffer: &mut [u8], dst_stride: usize, ) -> bool
Map the contents of the screenshot given by the handle and copy it into the given buffer.
sourcepub fn release_profiler_structures(&mut self)
pub fn release_profiler_structures(&mut self)
Release the screenshot grabbing structures that the profiler was using.
Auto Trait Implementations§
impl !Freeze for Renderer
impl !RefUnwindSafe for Renderer
impl !Send for Renderer
impl !Sync for Renderer
impl Unpin for Renderer
impl !UnwindSafe for Renderer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more