aboutsummaryrefslogtreecommitdiffstats
path: root/src/symbols-gl.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-27 13:02:41 +0100
committereunhhu <[email protected]>2026-09-27 13:02:41 +0100
commitba76d3810713bb67569114e9458416df0f78687a (patch)
tree357c5285b72626ff7f77d0339ccc0e6d2cc66b7d /src/symbols-gl.h
parent2acf27f665f8a926d244efa58f6ef2c92d65e8c4 (diff)
downloadvega-ba76d3810713bb67569114e9458416df0f78687a.tar.gz
vega-ba76d3810713bb67569114e9458416df0f78687a.zip
Draw symbols on the GPU from the point table as it is
OpenGL ES 3.1: the file's points go up as one storage buffer, each symbol gets 16 row bands listing the curves they reach (cut by integer division of doubled coordinates, so CPU and shader agree), and every pixel of a symbol's box sums the exact area of its bands' curves, as vega_coverage does. vega-symbols gpu draws every symbol against the CPU reference and times 1080p pages. On the Pi 5's V3D it matches the reference (mean 0.001-0.1 levels, worst 4) but takes 142-757 ms a page, 83% of it in the area function. A sorting network in registers made it 2.3x faster yet computes wrong rows in the fragment stage with this driver, while the same code is exact in a compute shader; so drawing each glyph size once into an atlas by compute comes next.
Diffstat (limited to 'src/symbols-gl.h')
-rw-r--r--src/symbols-gl.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/symbols-gl.h b/src/symbols-gl.h
new file mode 100644
index 0000000..4c6db67
--- /dev/null
+++ b/src/symbols-gl.h
@@ -0,0 +1,24 @@
+#ifndef VEGA_SYMBOLS_GL_H
+#define VEGA_SYMBOLS_GL_H
+#include "symbols.h"
+#include <GLES3/gl31.h>
+
+/* Symbols drawn by the GPU (OpenGL ES 3.1): the file's point table goes up
+ * as it is, one storage buffer, and each pixel of a symbol's box sums the
+ * exact area of the curves crossing its row, as vega_coverage does. Rows
+ * are cut into bands at upload, each listing its curves, so a pixel reads
+ * only those. Needs a current context. */
+typedef struct {
+ GLuint program, points, bands, instances, array;
+ GLint viewport;
+} VegaGl;
+
+/* A symbol placed: its origin in pixels from the target's top left, and
+ * pixels per unit. */
+typedef struct { float x, y, scale; uint32_t symbol; } VegaGlyph;
+
+bool vega_gl_open(VegaGl *, const VegaSymbols *, char *error, size_t error_size);
+/* Coverage added into the red channel of the bound framebuffer. */
+void vega_gl_draw(VegaGl *, const VegaSymbols *, const VegaGlyph *, uint32_t count, int width, int height);
+void vega_gl_close(VegaGl *);
+#endif