Expand description
Format-modifier and hardware-compression support for drmkit’s plane allocator.
Port of src/fmt/ from drm-cxx @ dc2915b.
§Design contract
Carried verbatim from the C++, because the allocator depends on all three:
IN_FORMATSprunes the bipartite graph — necessary, not sufficient.- The atomic
TEST_ONLYcommit is ground truth for what a plane can scan out. BandwidthClassis a cost input to placement scoring, never a correctness gate.
This keeps every vendor on one code path — AFBC (Arm/Rockchip/MediaTek),
AMD DCC, Qualcomm UBWC, NVIDIA block-linear, Broadcom tiling: a
(fourcc, modifier) pair flows from the producer’s allocation, through
IN_FORMATS eligibility, to a probed-and-memoized test commit.
§Scope
This crate is no_std + alloc and device-free. Two pieces of the C++
fmt/ header live elsewhere in the port:
FormatTable::from_plane(fd, plane_id)— blob fetching belongs todrmkit-core’s property layer, which hands the bytes toFormatTable::from_blob. The C++ had already split the parser out for testability; this makes the split structural.ScanoutBuffer— not ported as one type: GBM allocation isdrmkit-gbm’sGbmBuffer, and the framebuffer modifier rule isdrmkit-core’sframebuffer_modifier.
§Example
use drmkit_fmt::{
BandwidthClass, FormatTable, Modifier, classify, fourcc, layer_fits_plane,
};
let plane = FormatTable::from_pairs([
(fourcc::XRGB8888, Modifier::LINEAR),
(fourcc::NV12, Modifier::LINEAR),
]);
assert!(layer_fits_plane(&plane, fourcc::XRGB8888, Modifier::LINEAR));
assert!(!layer_fits_plane(&plane, fourcc::ARGB8888, Modifier::LINEAR));
// The INVALID sentinel is interchangeable with LINEAR.
assert!(layer_fits_plane(&plane, fourcc::NV12, Modifier::INVALID));
assert_eq!(classify(Modifier::LINEAR), BandwidthClass::Linear);Re-exports§
pub use fourcc::format_bpp;pub use fourcc::format_name;
Modules§
- afbc_
block - AFBC superblock-size codes (low 4 bits of the modifier body).
- afbc_
flag - AFBC feature flags.
- arm_
type - Arm modifier type field (bits 55:52).
- broadcom
- Broadcom layout codes (low byte of the modifier body).
- fourcc
- DRM
FourCCpixel-format codes and their bit depths. - vendor
- DRM modifier vendor identifiers (
DRM_FORMAT_MOD_VENDOR_*, the top 8 bits).
Structs§
- Format
Mod - A
(fourcc, modifier)pair a plane accepts. - Format
Table - A plane’s accepted
(fourcc, modifier)pairs, sorted and de-duplicated. - Modifier
- A DRM format modifier.
- Modifier
Probe Cache - Memoizes atomic
TEST_ONLYverdicts.
Enums§
- Bandwidth
Class - What a modifier does to bus traffic.
- Modifier
Family - The family a modifier belongs to, for eligibility matching.
- Rotation
- Display-plane rotation. 90/270 transpose the scanout fetch order; 0/180 do not.
- Verdict
- The cached outcome of probing a
(crtc, plane, fourcc, modifier)tuple with an atomicTEST_ONLYcommit.
Constants§
- ARM_
16X16_ BLOCK_ U_ INTERLEAVED - Legacy
DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED. - DEFAULT_
COMPRESSED_ RATIO - The default worst-case compression ratio used when a modifier’s
BandwidthClassisCompression.
Functions§
- classify
- Classify a modifier’s effect on scanout bandwidth.
- describe
- A human-readable rendering, e.g.
ARM_AFBC(16x16|YTR|SPARSE)orQCOM_COMPRESSED(UBWC). - layer_
fits_ plane - Edge eligibility for the allocator’s bipartite pre-solve: an
IN_FORMATScheck with family awareness. - mod_
code - Build a modifier value from a vendor and a 56-bit body, matching the
fourcc_mod_codemacro. - rotation_
compatible - Can a buffer with modifier
mbe scanned out under rotationr? - sand128_
col_ height - Build a Broadcom
SAND128modifier with an explicit column height. - sand_
col_ height - The column height baked into a
SAND64,SAND128orSAND256modifier, orNonefor anything else,SAND32included. - scanout_
cost_ bytes - Approximate per-frame scanout read in bytes, for the allocator’s content-priority and spatial-split cost model.