1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! emblema: a 2D vector renderer that tessellates paths on the CPU and needs
//! no compute shaders.
//!
//! 
//!
//! Draw into a [`Canvas`] with a [`Paint`], finish it into a [`Recording`],
//! and hand that to a [`Context`], which owns the device and the backend it
//! picked. The `showcase` example draws the frame above; the repository's
//! README has the rest.
//!
//! | Feature | Default | What it adds |
//! |---|---|---|
//! | `vulkan` | yes | The Vulkan 1.1 backend. |
//! | `present-wsi` | yes | Presenting into a Vulkan swapchain. Implies `vulkan`. |
//! | `gles` | | The GLES 3.0 backend. |
//! | `present-egl` | | Presenting into an EGL window surface. Implies `gles`. |
//! | `drm` | | Direct scanout to a KMS plane. Vulkan draws into it today; GLES does not yet. |
//! | `gbm` | | Scanout from buffers GBM allocates on the display's side, for a display that cannot take what the renderer allocates. Implies `drm`; needs Rust 1.94.1. |
//!
//! The whole of it, from a device to pixels in memory:
//!
//! ```no_run
//! use emblema::{BackendPreference, Canvas, Color, Context, Extent2D, Paint, PixelFormat, Rect};
//!
//! // The backend is chosen at run time, so one binary serves a board with a
//! // working Vulkan driver and one where only GLES is usable.
//! let mut ctx = Context::new(BackendPreference::Auto)?;
//!
//! let size = Extent2D::new(256, 256);
//! let mut surface = ctx.create_surface(size, PixelFormat::Rgba8Unorm)?;
//!
//! let mut canvas = Canvas::new(size);
//! canvas.clear(Color::WHITE);
//! canvas.draw_rect(
//! Rect::new(32.0, 32.0, 224.0, 224.0),
//! &Paint::fill(Color::rgba8(0, 120, 220, 255)),
//! )?;
//!
//! // Recording is separate from submitting, so a whole frame is described
//! // before any of it reaches the GPU and every shape shares one pass.
//! ctx.draw(&mut surface, &canvas.finish())?;
//! let pixels = ctx.read(&mut surface)?;
//!
//! // Destroyed explicitly, because nothing here frees a GPU object on drop. A
//! // surface still alive when its context goes is a child outliving its device,
//! // which the validation layer reports as an error rather than a leak.
//! ctx.destroy_surface(surface);
//! # Ok::<(), emblema::Error>(())
//! ```
//!
//! Which backend runs is decided when the context is created, not when the
//! binary is built, so one image can boot on a board with a working Vulkan
//! driver and on one where only GLES is usable.
//!
//! Code above the backend branches on [`Context::capabilities`] rather than on
//! which backend it got. A device that cannot export a fence is the same
//! problem whichever API it speaks, and asking which backend it is gets both
//! cases wrong.
// docs.rs builds with every feature, so without this nothing on the page
// says which feature an item needs. `doc_cfg` labels each one from its own
// `#[cfg]`, and only on docs.rs, which sets `docsrs` and builds on nightly.
pub use ;
pub use ;
// The drawing API, so an application depends on this crate alone.
pub use ;
pub use ;
pub use ;
/// What [`Context::import_image`] takes: a dma-buf's planes, its DRM format
/// and its layout.
pub use ;
/// Draw a recording into a texture this crate did not create.
///
/// [`Context::draw`] covers the case where the target came from
/// [`Context::create_surface`], and that is the ordinary one. This is the other:
/// a swapchain hands out its own images, and drawing into one means naming a
/// texture the caller got from somewhere else. Without this the presentation
/// path re-exported above reached a swapchain and then had nothing to draw into
/// its images with, which is a window a caller can open and not fill.
pub use ;
/// Direct scanout to a display, with no compositor.
pub use emblema_present_drm as drm;
/// The Vulkan backend itself.
///
/// Re-exported because [`Context`] already exposes it: `Context::Vulkan` is a
/// public variant holding a `VulkanContext`, so the type was part of this
/// crate's surface whether or not it could be named. Without this a caller
/// could match the variant and use what came out by inference, but could not
/// write its type down -- so no function of theirs could take one, and reaching
/// the swapchain meant depending on the backend crate separately and matching
/// its version by hand.
pub use emblema_hal_vulkan as vulkan;
/// The GLES backend, re-exported for the same reason.
pub use emblema_hal_gles as gles;
/// A Vulkan WSI swapchain, for drawing into a window system's surface.
///
/// This was a feature name that enabled nothing for as long as it existed:
/// `present-wsi` was in the default set and gated no dependency, and the crate
/// implementing it was not one. So the facade's default build advertised a
/// presentation path it had no route to, and a caller wanting a window had to
/// reach past this crate to `emblema-present-vk` -- which the playground does,
/// and which was the visible symptom nobody read as one.
pub use emblema_present_vk as wsi;
/// An EGL window surface, which is the GLES backend's way to the same place.
pub use emblema_present_egl as egl;
/// Presentation targets and format negotiation.
pub use emblema_present as present;