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.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'symbols/symbols.c') diff --git a/symbols/symbols.c b/symbols/symbols.c index cedd68f..6f355f1 100644 --- a/symbols/symbols.c +++ b/symbols/symbols.c @@ -173,13 +173,13 @@ double vega_coverage(const VegaCurve *curves, uint32_t count, double scale, doub } void vega_symbol_raster(const VegaSymbols *s, const VegaSymbol *symbol, double scale, double left, double top, int width, - int height, unsigned char *out) { + int height, unsigned char *out, size_t stride) { VegaCurve *curves = malloc((symbol->count ? symbol->count : 1) * sizeof(*curves)); uint32_t count = curves ? vega_symbol_curves(s, symbol, curves) : 0; for (int j = 0; j < height; ++j) for (int i = 0; i < width; ++i) { double coverage = vega_coverage(curves, count, scale, left + (i + 0.5) / scale, top - (j + 0.5) / scale); - out[(size_t)j * (size_t)width + (size_t)i] = (unsigned char)lround(coverage * 255); + out[(size_t)j * stride + (size_t)i] = (unsigned char)lround(coverage * 255); } free(curves); } -- cgit v1.2.3