Skip to content

M3b: implement the Metal zero-copy shim stubs + Bevy bridge tier #7

Description

@Bantarus

Context

After the Metal spike and ObjC++ build wiring land, implement the declared+stubbed Metal C-ABI (today returns NULL/nonzero): rive_render_context_create_metal_external(mtlDevice, mtlCommandQueue), rive_render_target_wrap_metal_texture(ctx, mtlTexture, w, h, mtlPixelFormat), rive_frame_submit_external_metal(ctx, target, mtlCommandBuffer) (shim/rive_shim.h:452-459, .cpp:1762-1779, src/lib.rs:549-565). Metal's id<MTLCommandBuffer> self-submits via commit. Note Metal requires 256-byte-aligned vertex buffers.

Scope

  • Implement create via RenderContextMetalImpl::MakeContext(id<MTLDevice>, ContextOptions); wrap via RenderTargetMetal setTargetTexture-equivalent (bring-your-own MTLTexture); submit recording into a caller-owned id<MTLCommandBuffer> and committing per the spike's chosen ordering on the shared MTLCommandQueue.
  • Add a Metal zero-copy render-graph node in crates/bevy-rive, extracting MTLTexture/MTLDevice/MTLCommandQueue via the wgpu-hal paths the spike validated; reuse the watermark approach the spike chose (e.g. MTLSharedEvent).
  • Gate behind a Metal feature; do not touch Vulkan/D3D12/floor.

Acceptance criteria

  • A .riv renders zero-copy into a wgpu-allocated MTLTexture on macOS, pixels correct vs the Vulkan reference, non-blocking recycle.
  • Validated on macOS CI (see CI runner issue).

Depends on

  • Metal feasibility spike issue.
  • ObjC++ build wiring issue.
  • macOS CI runner issue.

Refs

  • crates/rive-renderer-sys/shim/rive_shim.h:452-459, .cpp:1762-1779, src/lib.rs:549-565
  • vendor/rive-runtime/renderer/include/rive/renderer/metal/render_context_metal_impl.h:111-116
  • wgpu-hal-27.0.4/src/metal/mod.rs:373,544,929

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions