Avoid potential stack buffer overflow when registering benchmarks
from user-supplied font paths by using snprintf instead of strcat.
Assisted-by: Gemini
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>
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>
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
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>
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>
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>
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>
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>