mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 07:21:06 +01:00
[gpu] First working COLRv0 GPU render
Two paint-encoder bugs and two demo-plumbing bugs together prevented end-to-end rendering. With all four fixed, BungeeTint and similar COLRv0 fonts now render through the GL demo in their proper palette colors. ### Paint encoder 1. hb-gpu-paint-fragment.glsl: the LAYER_SOLID op's payload is a blob-relative texel offset, but the shader was passing it to hb_gpu_draw() as-is -- which treats its argument as an absolute atlas offset. Add the glyph's `base` to the payload before the draw-coverage call so the sub-blob reference resolves inside the paint blob instead of elsewhere in the atlas. 2. hb-gpu-paint.cc push_clip_glyph callback: was resetting pending_palette_index to 0. But harfbuzz's COLRv0 paint emitter calls custom_palette_color BEFORE push_clip_glyph for each layer, so the index set by custom_palette_color was being clobbered before the color callback consumed it -- every layer ended up tagged palette_index=0. Leave pending_palette_index alone in push_clip_glyph. ### Demo plumbing 3. util/gpu/demo-glstate.cc: demo_glstate_create now glUseProgram's its program immediately. The palette uniform upload reads GL_CURRENT_PROGRAM, and glyph upload happens from demo_buffer_current_line() -- which runs before demo_view_setup() would have bound the program. Without this, glGetIntegerv returned 0 and the palette was never uploaded. 4. util/gpu/demo-font.cc: adds lazy demo_font_upload_palette() on first glyph request. Also tries both "hb_gpu_palette" and "hb_gpu_palette[0]" for the uniform lookup since drivers disagree. ### Bonus util/hb-gpu-encode-all.cc: reports paint-encoded and draw-fallback counts / sizes / timings separately so you can tell where time goes in mixed-content fonts. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7c97464406
commit
f3fcd46ba9
6 files changed
+98
-43
No files matched your search
@@ -76,7 +76,9 @@ static const char *hb_gpu_paint_fragment_glsl =
|
||||
" : hb_gpu_palette[palette_index];\n"
|
||||
" col.a *= alpha;\n"
|
||||
"\n"
|
||||
" float cov = hb_gpu_draw (renderCoord, uint (payload));\n"
|
||||
" /* payload is a blob-relative texel offset; sub-blobs live\n"
|
||||
" * inside the paint blob at atlas offset `base`. */\n"
|
||||
" float cov = hb_gpu_draw (renderCoord, uint (base + payload));\n"
|
||||
" vec4 src = col * cov;\n"
|
||||
" /* SRC_OVER with premultiplied source. */\n"
|
||||
" acc = src + acc * (1.0 - src.a);\n"
|
||||
|
||||
@@ -75,7 +75,9 @@ vec4 hb_gpu_paint (vec2 renderCoord, uint glyphLoc, vec4 foreground)
|
||||
: hb_gpu_palette[palette_index];
|
||||
col.a *= alpha;
|
||||
|
||||
float cov = hb_gpu_draw (renderCoord, uint (payload));
|
||||
/* payload is a blob-relative texel offset; sub-blobs live
|
||||
* inside the paint blob at atlas offset `base`. */
|
||||
float cov = hb_gpu_draw (renderCoord, uint (base + payload));
|
||||
vec4 src = col * cov;
|
||||
/* SRC_OVER with premultiplied source. */
|
||||
acc = src + acc * (1.0 - src.a);
|
||||
|
||||
+4
-1
@@ -71,7 +71,10 @@ hb_gpu_paint_push_clip_glyph (hb_paint_funcs_t *funcs HB_UNUSED,
|
||||
c->pending_clip = true;
|
||||
c->pending_clip_glyph = glyph;
|
||||
c->pending_clip_font = font;
|
||||
c->pending_palette_index = 0;
|
||||
/* Don't reset pending_palette_index here: COLR's paint emitter
|
||||
* calls custom_palette_color BEFORE push_clip_glyph, so the
|
||||
* index set by the custom-palette-color callback must survive
|
||||
* this call and be consumed by the next color callback. */
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in new issue
Block a user