From 2c1e29780da41bba13ac84ad01472d550e6d02e8 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sun, 27 Sep 2026 14:21:39 +0100 Subject: Draw text from an atlas the CPU fills, composed by the GPU Each size's symbols are drawn on the CPU into one 8-bit atlas, every pixel the exact area its curves cover, and text is a quad per glyph reading it. A 1080p page of 11,382 glyphs composes in 1.07 ms at 16 px (it took 525 ms computing coverage per fragment), and the composed pixels are the CPU raster's exactly (worst difference 0 for DejaVu's ASCII, 1 for Noto's 11,172 Hangul syllables). Computing coverage on the GPU lost on both counts: a compute pass filling the atlas took 5-13x longer than one Cortex-A76 core (35 against 2.7 ms at 16 px), and its faster sorting-network form computed whole rows wrongly under this Mesa V3D. Coverage now has one implementation, in C, and the shaders only compose. vega_symbol_raster takes a row stride to draw into the atlas in place. --- symbols/symbols.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'symbols/symbols.h') diff --git a/symbols/symbols.h b/symbols/symbols.h index 998ff3f..20fbd22 100644 --- a/symbols/symbols.h +++ b/symbols/symbols.h @@ -47,8 +47,9 @@ uint32_t vega_symbol_curves(const VegaSymbols *, const VegaSymbol *, VegaCurve * /* The coverage (0 to 1) of the pixel whose center is (x, y) in units, at * scale pixels per unit: the exact area the curves' outline covers. */ double vega_coverage(const VegaCurve *, uint32_t count, double scale, double x, double y); -/* width x height 8-bit coverage, rows top first; pixel (i, j) has its center - * at (left + (i + 0.5) / scale, top - (j + 0.5) / scale) in units. */ +/* width x height 8-bit coverage, rows top first, stride bytes apart; pixel + * (i, j) has its center at (left + (i + 0.5) / scale, top - (j + 0.5) / scale) + * in units. */ void vega_symbol_raster(const VegaSymbols *, const VegaSymbol *, double scale, double left, double top, int width, - int height, unsigned char *out); + int height, unsigned char *out, size_t stride); #endif -- cgit v1.2.3