Skip to main content

mln_gfx/
lib.rs

1//! The backend-independent graphics layer: the [`gpu::Gpu`] interface a
2//! backend implements, and the renderer data drawn through it. `mln_webgpu`
3//! implements it on `wgpu`, `mln_mtl` on Metal, `mln_vulkan` on Vulkan and
4//! `mln_gl` on OpenGL ES 3.0.
5//!
6//! A backend's `RendererBackend` owns its `Gpu` and lends it, to the
7//! renderer and to the `FrameTarget` that the renderer draws into; the `Gpu`
8//! owns the renderer's buffers, textures and the groups of buffers its
9//! draws bind, which the renderer keeps in `mln_engine`. The targets that
10//! draw into rings of the host's textures, or of images they export, are
11//! generic over each backend's part, in [`ring`]. What each program reads, and
12//! the text it compiles from, is in `shaders::program`; the renderer
13//! declares the programs.
14//!
15//! gfx and the backends log through `tracing`, as the rest of the library
16//! does, under targets that name the event: `<crate>::render` for
17//! devices, frames and presenting, and `<crate>::graphics_backend` for the
18//! calls of a graphics API's platform layer, such as EGL's or WGL's.
19
20#![warn(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
21#![cfg_attr(not(test), warn(clippy::unreachable, clippy::print_stdout, clippy::print_stderr))]
22
23pub mod backend;
24pub mod color_mode;
25pub mod cull_face_mode;
26pub mod depth_mode;
27pub mod draw_mode;
28pub mod error;
29pub mod export;
30pub mod frame;
31pub mod gfx_types;
32pub mod gpu;
33pub mod offscreen_target;
34pub mod projection_variant;
35pub mod renderer_backend;
36pub mod rendering_stats;
37pub mod ring;
38pub mod shaders;
39mod size;
40pub mod stencil_mode;
41pub mod texture2d;
42pub mod types;
43pub mod util_hash;
44pub mod window;
45
46pub use color_mode::{ColorMode, Rgba};
47/// The `tracing` targets of this crate's events (see the crate docs).
48mod log_target {
49    pub(crate) const RENDER: &str = "mln_gfx::render";
50}
51
52pub use cull_face_mode::CullFaceMode;
53pub use depth_mode::DepthMode;
54pub use draw_mode::DrawMode;
55pub use error::{Error, ErrorKind};
56pub use export::{
57    DepthStencilFormat, DepthStencilFormats, DmaBufFormat, DmaBufPlane, ExportKind, ExportKinds, ExportedFrame,
58    ExportedImage, ExportedRing, FrameDepth, NativeTexture,
59};
60pub use frame::{ConsumerSync, FrameImage, FramePixels, FrameTarget, GpuSync, Handoff, SyncKind, SyncKinds};
61pub use gfx_types::{AttributeDataType, DrawModeType, PrimitiveType};
62pub use renderer_backend::RendererBackend;
63pub use size::Size;
64pub use stencil_mode::StencilMode;
65pub use types::DepthMaskType;
66pub use window::Window;