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’sComputeWpfLighting.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(featurewgpu): 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 aScene3DSnapshotin 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’sComputeWpfLighting(Mesh3DSolid.wgsl), per pixel, over theLightUniformsof 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 ofcrate::uniformsand the lighting ofcrate::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
Coloralone 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_LIGHTSlights 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 (areaVisual, 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 tox_axisand the unit y axis toy_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 mostcpu::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.