Skip to main content

Crate ferroui_render3d

Crate ferroui_render3d 

Source
Expand description

The renderer of FerroUI’s 3D scenes (#608, docs/porting/media3d.md): what every backend shares to draw the Scene3DSnapshot of a Viewport3D.

  • cpu: the CPU reference rasterizer, deterministic and in safe Rust: the reference of the comparison tests, the renderer of the surfaces without a GPU (Skia raster, headless, the CPU mode of Vello) and, until a backend has a GPU executor, the counted last resort on its GPU surfaces (report_scene_drawn_on_cpu).
  • uniforms: the constants of a render (the camera, the lights, the matrices and colours of each draw) as #[repr(C)], std140-compatible structures, the one layout the CPU reference and the shaders of the GPU executors (step D4) share.
  • lighting: the lighting of WPF’s lights and materials per pixel, ported from ProGPU’s ComputeWpfLighting.
  • output_cache: the output of a scene kept while the scene, the size and the scale are unchanged.
  • shader: scene3d.wgsl, the one shader of the GPU executors, restricted to what WebGL2 and OpenGL ES 3.0 run.
  • wgpu_executor (feature wgpu): the executor of the GPU modes of the Vello backend, which draws a scene with wgpu into a texture of the device (step D4).

The crate depends on the base library and std only, and on wgpu with its feature wgpu; its other GPU executors come with their steps (D5: Metal, D8: GL, D9: Vulkan) as features.

Re-exports§

pub use cpu::CpuRasterizer;
pub use cpu::CpuRenderOptions;
pub use cpu::Scene3DImage;
pub use output_cache::Scene3DOutputCache;

Modules§

cpu
The CPU reference rasterizer (docs/porting/media3d.md, sections 3.9 and 4, step D3): a deterministic renderer of a Scene3DSnapshot in safe Rust, the reference the GPU executors are compared with and the renderer of the surfaces without a GPU (Skia raster, headless, the CPU mode of Vello).
lighting
The lighting and the fragment colour of a material layer (docs/porting/media3d.md, section 3.4, decision A): a port of ProGPU’s ComputeWpfLighting (Mesh3DSolid.wgsl), per pixel, over the LightUniforms of a render, and the colour each kind of layer writes. The WGSL of the GPU executors (step D4) is the same functions, in the same order of operations.
output_cache
The output of the CPU reference kept for the next frame (docs/porting/media3d.md, section 3.7, step 1): a viewport whose snapshot, size, scale and options are unchanged draws the image it drew before, without rasterizing again.
shader
The one shader of the GPU executors (docs/porting/media3d.md, sections 3.4 and 3.15): shaders/scene3d.wgsl, a port of ProGPU’s mesh shader restricted to what WebGL2 and OpenGL ES 3.0 run, with the uniform layout of crate::uniforms and the lighting of crate::lighting.
uniforms
The constants of a 3D render, in one place for every renderer (docs/porting/media3d.md, sections 3.2 and 3.4): the CPU reference reads them from these structures, and the GPU executors upload the same structures to their uniform buffers, so the CPU and the GPU light a scene with the same numbers.

Functions§

layers_with_unsampled_brushes
How many material layers were drawn with their Color alone because the renderer cannot sample their brush yet (a gradient, an image, a visual or drawing brush: step D6 of the port), since the process started.
lights_left_out
How many lights were left out of renders since the process started: a render takes the first uniforms::MAX_LIGHTS lights of a scene in tree order (docs/porting/media3d.md, section 6.1).
report_scene_drawn_on_cpu
Counts a scene drawn by the CPU reference on a GPU surface of backend (a name for the log, such as “Skia (GPU)”), and reports the first one in the log (area Visual, level warning).
scene_pixel_size
The size in device pixels of the image of a viewport drawn over bounds (in the coordinates of a drawing context) whose transform to the device maps the unit x axis to x_axis and the unit y axis to y_axis, and the scale (device pixels per unit, the larger of the two axes): the bounds at the resolution of the device, also under a rotation or a skew (docs/porting/media3d.md, section 3.6). The perspective of a 2D transform is not taken into account. Each side is at least one pixel and at most cpu::MAX_SIDE.
scenes_drawn_on_cpu
How many times a scene was drawn by the CPU reference on a GPU surface since the process started: the gap of the backends without a GPU executor (docs/porting/gpu-rendering.md), which the GPU executors of steps D4 and later close. A surface without a GPU (Skia raster, the CPU mode of Vello) draws the CPU reference by definition and is not counted.