Files
harfbuzz/src
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
..
2025-05-08 16:03:02 +03:00
2023-07-08 13:51:07 -04:00
2026-03-10 09:56:47 -03:00
2026-03-09 22:37:07 -06:00
2026-03-09 22:37:07 -06:00
2024-03-30 02:20:21 +02:00
2025-08-15 00:54:52 -06:00
2025-03-13 01:07:35 -06:00
2023-01-12 10:44:08 -07:00
…
2025-10-17 15:23:05 -06:00
2026-02-24 16:57:44 -03:00
2025-03-12 23:56:52 -06:00
2023-02-21 18:07:53 +02:00
2025-04-08 02:13:39 -06:00
2025-03-12 18:27:27 -06:00
2025-07-20 21:40:37 +03:00
2025-03-24 00:33:53 +02:00
2025-09-15 23:56:25 -06:00
…
…
2024-10-27 16:14:53 -07:00
…
2025-08-29 00:08:28 -06:00
2023-08-25 07:51:05 -06:00
2023-06-03 14:56:47 -06:00
2025-04-08 01:58:10 -06:00
2025-08-07 22:38:58 -06:00
2025-06-08 13:43:27 +03:00
2023-02-11 23:52:58 +02:00
2025-08-07 22:38:58 -06:00
2025-08-27 15:36:48 -06:00
2026-03-19 00:45:24 +02:00
2026-03-19 00:45:24 +02:00
2025-02-06 14:26:37 +00:00
2025-11-11 12:29:06 -07:00
2025-06-08 13:43:27 +03:00
2024-04-16 17:10:09 -06:00
2025-06-08 13:43:27 +03:00
…
2025-06-08 13:43:27 +03:00
2025-06-08 13:43:27 +03:00
2026-03-09 22:37:07 -06:00
2025-11-10 02:55:44 -07:00
2025-10-01 08:24:34 +03:00
2025-09-15 23:56:25 -06:00
2025-09-23 11:23:03 -04:00
2023-08-25 07:51:05 -06:00
2023-06-03 14:56:47 -06:00
2025-07-23 21:39:23 +03:00
2025-08-07 22:38:58 -06:00
2024-08-23 08:58:50 -06:00
2025-01-11 18:13:18 +02:00
2025-01-11 18:13:18 +02:00
2025-07-25 00:05:46 -06:00
2025-07-24 22:47:08 -06:00
…
2023-04-27 00:48:00 +02:00
2025-05-12 14:05:39 -06:00
2025-08-28 15:58:39 -06:00
2026-04-04 20:31:18 +02:00
2024-04-01 01:55:38 -06:00
2023-03-31 17:33:45 -06:00
2022-12-23 13:37:59 -07:00
2025-03-07 18:19:29 -07:00
…
2023-01-12 17:04:24 -07:00