Skip to content

Add Metal GPU depth packet processor backend#1210

Open
mcakyurek wants to merge 1 commit intoOpenKinect:masterfrom
mcakyurek:feature/metal-backend
Open

Add Metal GPU depth packet processor backend#1210
mcakyurek wants to merge 1 commit intoOpenKinect:masterfrom
mcakyurek:feature/metal-backend

Conversation

@mcakyurek
Copy link
Copy Markdown

Adds a new packet pipeline using Apple's Metal GPU compute framework for depth decoding on macOS, following the same structure as the existing OpenCL and CUDA backends.

New files:

  • src/metal_depth_packet_processor.mm -- Host-side Objective-C++ implementation: device init, pipeline compilation, buffer management, and the four-stage dispatch loop (processPixelStage1, filterPixelStage1, processPixelStage2, filterPixelStage2). Loads default.metallib from alongside the dylib, falling back to the main bundle and device default library.
  • src/metal_depth_packet_processor.metal -- Metal Shading Language compute kernels ported from the OpenCL implementation. Uses non-uniform dispatchThreads for clean IMAGE_SIZE dispatch.

Modified files:

  • CMakeLists.txt: ENABLE_METAL option (ON by default on Apple), xcrun metal/metallib custom commands to compile the Metal library, MetalShaders target, framework link flags, and install rule for default.metallib.
  • include/libfreenect2/config.h.in: LIBFREENECT2_WITH_METAL_SUPPORT cmake define.
  • include/libfreenect2/packet_pipeline.h: MetalPacketPipeline class declaration under LIBFREENECT2_WITH_METAL_SUPPORT guard.
  • include/internal/libfreenect2/depth_packet_processor.h: MetalDepthPacketProcessor class declaration.
  • src/packet_pipeline.cpp: MetalPacketPipeline constructor/destructor.
  • src/libfreenect2.cpp: "metal" pipeline name in createPacketPipelineByName(); Metal chosen as default on Apple when available.

Adds a new packet pipeline using Apple's Metal GPU compute framework
for depth decoding on macOS, following the same structure as the
existing OpenCL and CUDA backends.

New files:
- src/metal_depth_packet_processor.mm  -- Host-side Objective-C++
  implementation: device init, pipeline compilation, buffer management,
  and the four-stage dispatch loop (processPixelStage1, filterPixelStage1,
  processPixelStage2, filterPixelStage2). Loads default.metallib from
  alongside the dylib, falling back to the main bundle and device
  default library.
- src/metal_depth_packet_processor.metal -- Metal Shading Language
  compute kernels ported from the OpenCL implementation. Uses
  non-uniform dispatchThreads for clean IMAGE_SIZE dispatch.

Modified files:
- CMakeLists.txt: ENABLE_METAL option (ON by default on Apple),
  xcrun metal/metallib custom commands to compile the Metal library,
  MetalShaders target, framework link flags, and install rule for
  default.metallib.
- include/libfreenect2/config.h.in: LIBFREENECT2_WITH_METAL_SUPPORT
  cmake define.
- include/libfreenect2/packet_pipeline.h: MetalPacketPipeline class
  declaration under LIBFREENECT2_WITH_METAL_SUPPORT guard.
- include/internal/libfreenect2/depth_packet_processor.h:
  MetalDepthPacketProcessor class declaration.
- src/packet_pipeline.cpp: MetalPacketPipeline constructor/destructor.
- src/libfreenect2.cpp: "metal" pipeline name in
  createPacketPipelineByName(); Metal chosen as default on Apple when
  available.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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