Skip to content

Build on modern macOS (Apple Silicon) + Metal depth backend#1

Merged
hbmartin merged 1 commit into
masterfrom
mac-build-fixes
Jul 5, 2026
Merged

Build on modern macOS (Apple Silicon) + Metal depth backend#1
hbmartin merged 1 commit into
masterfrom
mac-build-fixes

Conversation

@hbmartin

@hbmartin hbmartin commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Updates libfreenect2 so it configures, builds, and runs on a current Apple Silicon Mac (CMake 4.x, Xcode 26, Apple clang 21), while preserving Linux/CUDA compatibility. Every macOS-specific change is gated behind IF(APPLE) / #ifdef LIBFREENECT2_WITH_METAL_SUPPORT.

Combines the useful pieces of upstream PRs OpenKinect#1158, OpenKinect#1189, OpenKinect#1208, OpenKinect#1209, OpenKinect#1210.

Changes

Fix Source Notes
CMAKE_MINIMUM_REQUIRED 2.8.12.1 → 3.5 (3 files) OpenKinect#1209 CMake ≥ 4.0 rejects <3.5 — the hard configure blocker
Guard CL_ICDL_VERSION redefinition OpenKinect#1189 For OpenCL headers ≥ 3.0.16; used the cleaner #if !defined form
ENABLE_VIDEOTOOLBOX option OpenKinect#1208 Defaults OFF on arm64 to avoid the VTRgbPacketProcessor heap-corruption crash on Apple Silicon (falls back to TurboJPEG); stays ON for Intel Macs
Metal GPU depth backend OpenKinect#1210 New metal pipeline for Apple platforms
streamer_recorder OpenCV fix OpenKinect#1158 cv::IMWRITE_JPEG_QUALITY + C++14 (tool remains OFF by default)

Additional glue beyond the source PRs:

  • Protonect accepts metal as a pipeline argument (the factory was wired but the example parser was not).
  • The compiled default.metallib is emitted into the library output dir so the runtime loader finds it beside libfreenect2.dylib in both the build tree and after make install.

Verification (Apple M2 Pro, macOS 26.5, Xcode 26, CMake 4.3.4)

  • Clean configure + full build (library, Metal shader, Protonect) with zero errors.
  • Metal pipeline initializes on the M2 Pro and loads its shader library.
  • OpenCL, OpenGL, and CPU pipelines all initialize (OpenCL builds its program on the M2 Pro GPU).
  • make install places default.metallib beside the dylib.

Not exercised: a live frame (no Kinect connected). The Metal backend (from OpenKinect#1210) compiles and initializes correctly but its depth-decode output has not been validated against real hardware.

🤖 Generated with Claude Code


Summary by cubic

Modernized macOS build for Apple Silicon and added a Metal depth pipeline, while keeping Linux/CUDA builds intact. Installs default.metallib next to libfreenect2.dylib and defaults to TurboJPEG on arm64 for stability.

  • New Features

    • Added Metal GPU depth packet processor (MetalPacketPipeline), selectable via "metal".
    • Protonect now accepts "metal"; default.metallib is built and installed beside libfreenect2.dylib.
    • New ENABLE_METAL CMake option (ON on Apple).
  • Migration

    • Requires CMake ≥ 3.5.
    • On Apple Silicon, ENABLE_VIDEOTOOLBOX defaults OFF to avoid a crash; RGB decoding uses TurboJPEG unless explicitly enabled.
    • Tools: streamer_recorder builds as C++14 and uses cv::IMWRITE_JPEG_QUALITY.

Written for commit 5b50c2c. Summary will update on new commits.

Review in cubic

Brings libfreenect2 up to date so it configures, builds, and runs on a
current Apple Silicon Mac (CMake 4.x, Xcode 26, Apple clang 21), while
preserving Linux/CUDA compatibility. Combines fixes from upstream PRs
OpenKinect#1158, OpenKinect#1189, OpenKinect#1208, OpenKinect#1209, OpenKinect#1210.

- CMake: raise CMAKE_MINIMUM_REQUIRED 2.8.12.1 -> 3.5 (CMake >= 4.0
  removes compatibility with < 3.5). (OpenKinect#1209)
- OpenCL: guard the local CL_ICDL_VERSION against redefinition by recent
  OpenCL headers (cl_ext.h >= 3.0.16). (OpenKinect#1189)
- VideoToolbox: add ENABLE_VIDEOTOOLBOX option; default OFF on arm64 to
  avoid the VTRgbPacketProcessor heap-corruption crash on Apple Silicon,
  falling back to TurboJPEG. Stays ON for Intel Macs. (OpenKinect#1208)
- Metal: add a Metal GPU depth packet processor backend for Apple
  platforms, selectable as the "metal" pipeline. (OpenKinect#1210)
- Protonect: accept "metal" as a pipeline argument.
- Build the metallib into the library output dir so the runtime loader
  finds it next to libfreenect2.dylib in both the build tree and install.
- streamer_recorder: use cv::IMWRITE_JPEG_QUALITY and build as C++14 for
  modern OpenCV. (OpenKinect#1158)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a2ae44a1-69eb-4741-8c63-02af96e6605f

📥 Commits

Reviewing files that changed from the base of the PR and between fd64c5d and 5b50c2c.

📒 Files selected for processing (15)
  • CMakeLists.txt
  • examples/CMakeLists.txt
  • examples/Protonect.cpp
  • include/internal/libfreenect2/depth_packet_processor.h
  • include/libfreenect2/config.h.in
  • include/libfreenect2/packet_pipeline.h
  • src/libfreenect2.cpp
  • src/metal_depth_packet_processor.metal
  • src/metal_depth_packet_processor.mm
  • src/opencl_depth_packet_processor.cpp
  • src/opencl_kde_depth_packet_processor.cpp
  • src/packet_pipeline.cpp
  • tools/streamer_recorder/CMakeLists.txt
  • tools/streamer_recorder/recorder.cpp
  • tools/streamer_recorder/streamer.cpp
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mac-build-fixes

Comment @coderabbitai help to get the list of available commands.

@hbmartin hbmartin merged commit 4a70915 into master Jul 5, 2026
5 of 6 checks passed
@hbmartin hbmartin deleted the mac-build-fixes branch July 5, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant