Commit Graph
183 Commits
Author SHA1 Message Date
Garret Rieger c5ed3c8da3 [perf] Use snprintf to format benchmark-gpu names (#6255)
Avoid potential stack buffer overflow when registering benchmarks
from user-supplied font paths by using snprintf instead of strcat.

Assisted-by: Gemini
2026-09-10 16:59:38 -06:00
Behdad Esfahbod 17a0bdc245 [benchmark-shape] Accept multiple font/text pairs
Replace the singular named font and text options with repeated
positional FONTFILE TEXTFILE pairs. Register every supplied pair and
reject incomplete input so no requested benchmark is silently omitted.

Tested with the full Meson suite and an unfiltered two-pair run.

Assisted-by: Codex <codex@openai.com>
2026-09-04 15:33:01 -06:00
Behdad Esfahbod 8a98b8b3ab [benchmark-shape] Accept multiple variations
The --variations option previously parsed its entire argument as one
hb_variation_t, so only one axis could be selected. Parse the
comma-separated argument into an array and apply all valid axes.

Tested with the full Meson suite and a two-axis benchmark-shape run.

Assisted-by: Codex <codex@openai.com>
2026-09-04 15:28:29 -06:00
Behdad Esfahbod 80540ed4b1 [perf] Add public-domain Japanese script-run corpus
Add a 100,000-character Japanese shaping corpus derived from Natsume
Soseki's copyright-expired Wagahai wa Neko de Aru.  Split the sample
into pure Han, Hiragana, and Katakana runs, with Inherited characters
allowed within a run and Common characters omitted.

Document the Aozora Bunko source, reuse terms, source checksum, and
transformations in perf/texts/COPYING.

Testing: meson test -C build (274 tests passed)

Assisted-by: OpenAI Codex
2026-09-03 19:09:08 -06:00
Behdad Esfahbod 62712e7393 Revert "Add Japanese text corpus for perf testing"
This reverts commit c159b544f9.

Reason: Incompatible license of the source.
2026-09-03 19:04:43 -06:00
Behdad Esfahbod c159b544f9 Add Japanese text corpus for perf testing 2026-09-03 17:00:18 -06:00
Garret Rieger e67dee3f3a Add tests and benchmarks for hb_set_t next_range(). 2026-08-27 15:10:38 -06:00
Behdad Esfahbod 157e5111b3 [gpu] Add tests + benchmark for hb_gpu_paint, NEWS draft
test/api/test-gpu: extends the existing draw test suite with
paint counterparts -- create/destroy, get_funcs singleton,
shader_source for all four langs, empty encode returns nullptr,
encode of a monochrome glyph (synthesized single-layer fallback),
encode of a real COLRv1 glyph (test_glyphs-glyf_colr_1.ttf,
scanning for a glyph our encoder fully supports), auto-clear on
encode, reset wipes config, recycle_blob roundtrip.

perf/benchmark-gpu: add BM_GpuPaintEncode parallel to
BM_GpuDrawEncode (renamed from BM_GpuEncode for symmetry) so the
two paths can be compared on the same fonts.

NEWS: draft entry under "leading to NEXT (REPLACEME)" listing the
new hb_gpu_paint_* API surface and the recent GPU library changes
(--draw / --paint flags, gradient inverse-transform).  Release
manager will fold this into the actual release section.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 16:00:51 -06:00
Behdad Esfahbod dfd5d5b3cb [gpu] Paint: port to HLSL/WGSL; add _hb_gpu_draw_impl; fix WGSL
This commit unblocks end-to-end paint rendering on the WebGPU
demo, adds the HLSL port, and avoids losing MSAA or stem
darkening along the way.

### Shared: _hb_gpu_draw_impl

hb_gpu_draw internally did fwidth(renderCoord) + MSAA.  That works
fine in the single-call-per-fragment case but not when called from
inside a non-uniform branch (e.g. an op-stream LAYER_SOLID
conditional in the paint fragment shader) -- WGSL rejects fwidth
from non-uniform control flow.

Factor the MSAA-aware body into _hb_gpu_draw_impl, which takes a
caller-supplied pixelsPerEm.  hb_gpu_draw is now a thin wrapper
that computes pixelsPerEm via fwidth and delegates.  The paint
fragment shader in every language now computes pixelsPerEm once
at the top of hb_gpu_paint and calls _hb_gpu_draw_impl per layer
-- MSAA preserved, no redundant fwidth calls per layer.

In WGSL, _hb_gpu_draw_impl also inlines the ppem computation from
pixelsPerEm rather than recurring into hb_gpu_ppem (which itself
calls fwidth).

### Paint shaders

- hb-gpu-paint-fragment.hlsl (new): HLSL transcription.  Assumes
  a caller-declared StructuredBuffer<float4> hb_gpu_palette at
  register(t1).
- hb-gpu-paint-fragment.wgsl: switched from hb_gpu_draw to
  _hb_gpu_draw_impl; comment updated.
- hb-gpu-paint-fragment.msl, .glsl: same switch, cached
  pixelsPerEm at entry.

hb_gpu_paint_shader_source() now returns content for all four
languages.

### Demos

- util/gpu/demo-fragment.glsl: restores stem darkening (dropped in
  the first paint wiring commit); applies to the premultiplied
  RGBA by scaling both colour and alpha.  The desktop GL demo
  regenerates demo-fragment-glsl.hh from this source.
- util/gpu/web/hb-gpu-web-webgpu.cc: WGSL fs_main concatenates the
  paint source, binds a zero-filled palette storage buffer at
  @group(0) @binding(2), and restores stem darkening.  fwidth
  hoisted outside the stem-darkening conditional so WGSL's
  derivative-uniformity rule is happy.
- util/gpu/demo-renderer-d3d11.cc: HLSL ps_main switches to
  hb_gpu_paint.  Adds a second StructuredBuffer<float4>
  hb_gpu_palette at t1, zero-filled for now, bound alongside the
  atlas SRV.

### Misc

- perf/benchmark-gpu.cc: fix stale reset/encode(draw) calls.

Measured build (local Emscripten):
  WebGL   index.wasm  : 443638  181640 gz
  WebGPU  webgpu.wasm : 461626  188400 gz

COLRv0 rendering (BungeeTint, Noto Color Emoji, etc.) now works
end-to-end on WebGL and WebGPU with the correct palette.  Metal
and D3D11 demos should likewise compile against the new shader
flow; real palette upload cross-backend remains a TODO.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:52:21 -06:00
Behdad EsfahbodandClaude Opus 4.6 066da3ed3d [gpu] Multi-script default text based on font GSUB
Check the font's GSUB table for Latin and Arabic script support.
Build default demo text from English (Lorem Ipsum) and Persian
paragraphs for supported scripts, cropped to 35 lines each.

Source paragraphs live in perf/texts/{en,fa}-paragraph.txt.
gen-default-texts.py wraps them at fixed width and generates
the .hh headers.

Web demo hardcodes both texts since the embedded font supports
both scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 12:23:43 -06:00
Behdad EsfahbodandClaude Opus 4.6 686f3caa86 [gpu] Implement blob recycling in encode
recycle_blob stores the blob; encode reuses both the blob object
and its data buffer when the buffer is >= needed and < 2x needed.
Otherwise malloc fresh and replace_buffer on the recycled blob.

hb_blob_t::replace_buffer now skips destroy_user_data when the
new data pointer is the same as the old one (same-buffer reuse).

Add explicit destructor to hb_gpu_draw_t for recycled_blob cleanup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 15:13:44 -06:00
Behdad EsfahbodandClaude Opus 4.6 971e607319 [gpu] Add API test and google-benchmark encode benchmark
test-gpu: 7 subtests covering create/destroy, empty encode,
glyph encode, reset, draw funcs singleton, shader sources,
and recycle_blob.

benchmark-gpu: benchmarks draw, encode, and draw+encode
per-glyph across several fonts using google-benchmark.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 22:27:40 -06:00
Khaled Hosny b91d4b8d75 Add meson options to disable building harfbuzz-subset 2026-03-04 18:12:45 +02:00
Behdad EsfahbodandClaude Opus 4.6 3bed6db1d9 Move hb-draw-all, hb-paint-all, hb-raster-all to util/ as uninstalled binaries
Move perf tools from perf/ and test/raster/ to util/ alongside the
other uninstalled utilities.  Remove the now-empty test/raster/ directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-21 17:29:05 -03:00
Behdad Esfahbod 32a8fd62e8 Move hb-draw-compare and hb-svg-compare to test/draw 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 07afd2ccff [hb-svg-compare] Write out error with %g, not %.5f 2026-02-06 22:29:12 -07:00
Behdad Esfahbod f0ea86526d [hb-draw-compare] Print out debug info from hb-view 2026-02-06 11:47:36 -07:00
Behdad Esfahbod a603a37294 [benchmark-shape] Fix unused-var under NDEBUG 2026-01-12 13:09:51 -07:00
Behdad Esfahbod 93fb777502 [perf/benchmark-shape] Add Duployan test
Reshuffle tests to run from fastest to slowest.
2026-01-03 17:27:50 -07:00
Khaled Hosny e9c35e7352 [perf/benchmark-shape] Add Gulzar (#5698) 2026-01-02 11:30:30 -07:00
Behdad Esfahbod f488743916 [hb-draw-compare] Fix help string 2025-12-27 12:27:49 -07:00
Behdad Esfahbod 3aa1868b23 [benchmark-font] Accept empty --variations 2025-11-20 13:37:58 -07:00
Behdad Esfahbod 5087e53be9 [perf] Use GOption (#5422)
* [perf] Don't build benchmarks if no glib

Also remove unnecessary deps.

* [benchmark-shape/font] Port to GOption
2025-07-26 04:02:41 -06:00
Behdad Esfahbod ff46559b67 [benchmark-shape] Massage message again 2025-07-24 00:34:37 -06:00
Behdad Esfahbod 5991cb3d03 [benchmark-shape] Change message 2025-07-24 00:30:06 -06:00
Behdad Esfahbod 0a7a760ae1 [benchmark-shape] Skip shaper if shaping failed 2025-07-24 00:28:51 -06:00
Behdad Esfahbod 0c3606b513 [benchmark-font] Respect HB_BENCHMARK_TEXT 2025-07-23 17:06:50 -06:00
Behdad Esfahbod fa082b258f [benchmark-shape] Warm up the font / buffer first 2025-07-23 15:18:13 -06:00
Behdad Esfahbod b3765e7c40 [benchmark-font] Call the plural glyph-v-origins API
Ouch!
2025-07-20 07:19:23 -06:00
Behdad Esfahbod cbc928fa79 [benchmark-font] malloc hygiene 2025-07-20 07:19:23 -06:00
Behdad Esfahbod dd85aeba88 [benchmark-shape] Take text direction as extra argument 2025-07-20 07:18:54 -06:00
Behdad Esfahbod 266c0f8e3e [benchmark-font] Add --max-glyphs argument
--max-glyphs 256 can be used to measure the cached behavior
of many ops, like glyph_h_advance, glyph_v_advance,
and glyph_v_origin.
2025-07-20 00:12:26 -06:00
Behdad Esfahbod 94efb343cb [benchmark-font] Benchmark v_advances and v_origin 2025-07-20 00:12:20 -06:00
Behdad Esfahbod 971036888f [perf/hb-draw-compare] Default font-funcs2 to fontations
Yay!
2025-07-11 00:55:05 -06:00
Behdad Esfahbod 8d517f7e43 [hb-draw-compare] Declutter output 2025-06-12 08:13:42 -06:00
Behdad Esfahbod d9a258bedc [perf] Add hb-draw-compare and hb-svg-compare 2025-06-08 13:43:27 +03:00
Behdad Esfahbod 88b9feb917 [benchmark-font] Allow specifying variations on cmdline 2025-05-20 20:40:40 -06:00
Behdad Esfahbod 60c4b9cb61 [benchmark-font] Minor refactor
In prep for accepting arbitrary variations on the cmdline.
2025-05-20 20:36:39 -06:00
Behdad Esfahbod 9ddf3da71e [benchmark-shape] Accept one variation on the cmd-line 2025-04-04 16:04:07 -06:00
Behdad Esfahbod 0eeb6ccb42 [perf] Bikeshedding 2025-03-21 17:36:43 -06:00
Behdad Esfahbod 6b9d9f7259 [face] Add HB_FACE_LOADER env var 2025-03-09 01:41:49 -07:00
Behdad Esfahbod 2a878b1b76 [font-funcs] Add two new API
+ hb_font_set_funcs_using()
+ hb_font_list_funcs()

Part of https://github.com/harfbuzz/harfbuzz/issues/5117
2025-03-08 11:50:53 -07:00
Behdad Esfahbod e27e7f1c7d [perf] README minor 2025-03-07 14:01:57 -07:00
Behdad Esfahbod 460a8225ba [perf] Improve README 2025-03-07 13:33:08 -07:00
Behdad Esfahbod e054db4ae2 [fontations] Hook up to benchmark-font 2025-03-06 04:23:24 +02:00
Behdad Esfahbod a2ea5d28cb [benchmark-font] Report draw times in ms, not us 2025-02-18 21:43:39 -07:00
Behdad Esfahbod 19a152b47e [perf] Don't depend on libharfbuzz-subset for most benchmarks 2025-02-09 12:37:28 +00:00
Behdad Esfahbod b44f6ff5fe [perf/texts] Add a list of just 2letter strings 2025-02-05 12:19:48 +00:00
Behdad Esfahbod 267ebeeccd [perf/text] Add a long piece of JS code for benchmarking 2025-02-04 11:10:31 +00:00
Behdad Esfahbod d8d0987feb [benchmark-shape] Remove variable-font test set
It doesn't really affect shaping much. Kill it.
2025-02-02 18:08:09 +00:00