Commit Graph
23 Commits
Author SHA1 Message Date
fanc999-1 f54cb4a3ae build: Fix building hb-gpu on Windows (#5986)
Correct the d3dcompiler dependency-it should be looking for
D3DCompiler.lib (or so), not D3DCompiler_47.lib, to link to
D3DCompiler_47.dll.
2026-05-22 04:18:45 -06:00
Behdad Esfahbod 1f813cfb86 [util/gpu] Extract MSL/HLSL/WGSL demo shaders into own files
Matches the GLSL convention: demo-shader.{msl,hlsl,wgsl} live
alongside demo-fragment.glsl and get stringified by the same
gen-gpu-shader-artifacts.py helper into demo-shader-{msl,hlsl,
wgsl}.hh.  No more giant inline R"msl(...)" / R"hlsl(...)" /
R"wgsl(...)" blobs in the .mm / .cc files.

Each language combines vertex and fragment entry points in one
source, as is idiomatic for MSL / HLSL / WGSL compilers; GLSL's
split (demo-vertex.glsl + demo-fragment.glsl) is preserved
because glCompileShader takes separate stages.

No functional change.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 15:33:44 -06:00
Behdad Esfahbod 34a9f22f25 [util/gpu] Extract demo shaders into .glsl files
demo_vertex_glsl and demo_fragment_glsl were inline R"glsl(...)"
string literals in util/gpu/demo-shader.cc.  Pull them into
dedicated util/gpu/demo-{vertex,fragment}.glsl source files with
their own copyright headers, and wire the existing
gen-gpu-shader-artifacts.py generator to stringize them into
demo-*-glsl.hh at build time.

Also simplifies gen-gpu-shader-artifacts.py: the decl_map had
grown to cover every shader and its entries were all trivial
filename-to-symbol derivations.  Replace the map with direct
derivation (hyphens -> underscores, strip .hh), so adding more
shaders anywhere -- library or demo -- needs no generator edit.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:10:09 -06:00
Behdad EsfahbodandKhaled Hosny 7af550edd4 Update util/gpu/meson.build
Co-authored-by: Khaled Hosny <khaled@aliftype.com>
2026-03-30 16:40:29 -06:00
Behdad EsfahbodandClaude Opus 4.6 a6396882b0 [gpu] Add gpu_demo option, disable on MSVC only
GPU library always builds (no deps). GPU demo controlled by
gpu_demo option (auto default). Only MSVC CI disables it
(GLEW wrap broken with -nodefaultlib). All other CIs install
GLEW/GLFW system packages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 16:09:37 -06:00
Behdad EsfahbodandClaude Opus 4.6 f138460772 [gpu] Simplify GPU demo dep handling across CIs
Drop gpu_demo option. GLEW/GLFW use required:false — demo builds
when deps are found, skipped when not. Install GLEW/GLFW on all
CIs (Linux already had them, add to macOS and Rust). MinGW CI
uses wraps via --wrap-mode=default.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 16:02:04 -06:00
Behdad EsfahbodandClaude Opus 4.6 d30dc93503 [gpu] Add gpu_demo option, gate deps behind it
GPU library is always built (no deps). GPU demo (hb-gpu) requires
GLEW/GLFW/GL and is controlled by gpu_demo option (auto by default).
When disabled, deps aren't even looked up — fixes MSVC pulling in
broken GLEW wrap. MinGW CI explicitly enables with -Dgpu_demo=enabled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 15:55:06 -06:00
Behdad EsfahbodandClaude Opus 4.6 9b3a62ca84 [gpu] Integrate D3D11 renderer into main hb-gpu tool
Wire demo_renderer_create_d3d11 into gpu-output.hh with --direct3d
flag. Add to meson build conditionally on Windows with d3d11 and
d3dcompiler libraries. Remove standalone D3D11 demo (superseded).

hb-gpu.exe --demo --direct3d now works under Wine.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 15:19:28 -06:00
Behdad EsfahbodandClaude Opus 4.6 f3be5f329b [gpu] Inline demo shaders as raw string literals
Replace separate .glsl files and generated .hh headers with C++11
raw string literals (R"glsl(...)glsl") directly in demo-shader.cc.
Matches the pattern already used by demo-metal.mm and the WebGPU
demo. Removes demo shader generation from meson and the generator
script.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 18:02:00 -06:00
Behdad EsfahbodandClaude Opus 4.6 ddd6a86470 [gpu] Add debug heatmap mode (d key)
Refactor library fragment shaders (GLSL, MSL, WGSL) to extract
_hb_gpu_decode_glyph and _hb_gpu_curve_counts helpers, used by
both hb_gpu_render and the debug visualization.

Debug mode (d key) shows per-pixel curve counts as a heatmap:
R = horizontal band curves, G = vertical band curves, B = text
coverage. Scale 0-8 curves maps to 0-1 intensity.

Also auto-generates demo shader headers via meson, and adds
set_debug to the renderer interface.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 17:40:38 -06:00
Behdad EsfahbodandClaude Opus 4.6 216fb4fb43 [gpu] Refactor demo to virtual renderer interface
Replace backend-specific branches with a demo_renderer_t base class
that both GL and Metal implement. This eliminates all if(metal) checks
in the view code and makes adding future backends (WebGPU) clean.

- Add demo-renderer.h with virtual interface
- Add demo-renderer-gl.cc wrapping existing GL code
- Rewrite demo-metal.mm to implement renderer interface
- Move VBO/VAO management from demo_buffer into GL renderer
- Fix Metal vsync (CAMetalLayer.displaySyncEnabled)
- Fix dark mode crash on Metal (was calling GL directly)
- Add set_background to renderer for clear color control

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 13:42:57 -06:00
Behdad EsfahbodandClaude Opus 4.6 6910b9a3ed [gpu] Add Metal backend for macOS demo
Add MSL shader translations of the Slug GPU text rasterizer, and a
Metal rendering backend for hb-gpu-demo selectable via --metal flag.

Library changes:
- Add HB_GPU_SHADER_LANG_MSL enum value
- Add hb-gpu-vertex.msl and hb-gpu-fragment.msl
- Extend gen-gpu-shader-artifacts.py for MSL

Demo changes:
- Add demo-metal.h/mm with CAMetalLayer rendering
- Add external atlas backend for non-GL paths
- Add demo_buffer_get_vertices for Metal draw path
- Skip GL init when using Metal (GLFW_NO_API)
- Add --metal command-line flag

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 13:36:28 -06:00
Behdad EsfahbodandClaude Opus 4.6 457de66b8e [gpu] Use Apple OpenGL framework on macOS
dependency('gl') resolves to Mesa's libGL via Homebrew, which
can't render to native macOS windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 13:50:36 -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 30e1a703f0 [gpu] Convert matrix4x4 and trackball to C++ headers
Merge the .c and .h files into single .hh headers with
static inline functions.  Eliminates the C/C++ linkage issue
and simplifies the web demo build to a single em++ call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 03:53:20 -06:00
Behdad EsfahbodandClaude Opus 4.6 0172453697 [gpu] Remove unused gpu_demo_generated from meson
The demo headers are pre-generated and committed; the
custom_target generation was already removed but the empty
variable and its reference remained.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 01:46:29 -06:00
Behdad EsfahbodandClaude Opus 4.6 d07b1fbbb2 [gpu] Commit demo generated headers; remove stringize/hexify dependency
Pre-generate demo shader headers, default text, and default font
so the demo builds without stringize or hexify at compile time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 23:48:28 -06:00
Behdad EsfahbodandClaude Opus 4.6 b1ad797e50 [gpu] Commit stringized shader headers; auto-regenerate like ragel
Pre-generate hb-gpu-{fragment,vertex}-glsl.hh from the .glsl
sources so the library builds without Python/stringize at
compile time.

When stringize is found, a build rule regenerates them from
the .glsl sources and copies back to the source tree, matching
the ragel artifact pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 23:37:52 -06:00
Behdad EsfahbodandClaude Opus 4.6 25e69d9b96 [gpu] Port hb-gpu-demo to options.hh infrastructure
Replace the manual getopt-based demo main with the standard
main_font_text_t / shape_consumer_t composition, getting all
harfbuzz options for free: --variations, --features, --script,
--direction, --face-index, --font-funcs, etc.

New gpu_output_t (in util/gpu-output.hh) implements the output
interface, feeding shaped glyphs to the demo's GL renderer.

Add demo_buffer_add_glyph() and demo_buffer_current_line() to
demo-buffer for glyph-at-a-time insertion (vs the old batch
add_text which did its own shaping).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 16:34:04 -06:00
Behdad EsfahbodandClaude Opus 4.6 e8d2bddfab [gpu] Make GL deps optional; add them to Linux CI
The demo requires GLEW, GLFW3, and GL. Make these optional so the
library still builds on headless systems. The demo is skipped when
they're missing.

Install the GL packages in the Linux CI workflow so the demo
builds there.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:14:10 -06:00
Behdad EsfahbodandClaude Opus 4.6 9732ad4bcf [gpu] Build hb-gpu binary in util/ instead of util/gpu/
Move the executable definition to util/meson.build so the binary
lands at util/hb-gpu, consistent with other utilities.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:50:41 -06:00
Behdad EsfahbodandClaude Opus 4.6 294b625f7c [gpu] Wire up default font/text in demo
Fall back to an embedded font when no font file is given,
matching the glyphy-demo behaviour.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:32:21 -06:00
Behdad EsfahbodandClaude Opus 4.6 03c2688436 [gpu] Add GPU demo app in util/gpu
Port the glyphy-demo to use the hb-gpu API.  Builds as util/hb-gpu
and requires GLEW, GLFW3, and OpenGL 3.3.  Includes default text
and embedded font for quick testing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:30:13 -06:00