we (web engine): Experimental web browser project to understand the limits of Claude

Metal device, command queue, and CAMetalLayer setup #289

Open pierrelf.com
targeting main
Open opened by and assigned to pierrelf.com
targeting main

Implements issue 3mi434slnsv2g

Changes #

  • metal module in the platform crate with Metal framework FFI bindings:
    • MTLCreateSystemDefaultDevice() for obtaining the default GPU
    • Device, CommandQueue, CommandBuffer, RenderCommandEncoder wrapper types
    • MetalLayer (CAMetalLayer) with drawable size, pixel format, and device configuration
    • make_clear_pass_descriptor() helper for setting up render passes
    • drawable_texture() to extract the texture from a CAMetalDrawable
  • MetalView in appkit.rs: custom WeMetalView NSView subclass using CAMetalLayer
    • Overrides makeBackingLayer to provide CAMetalLayer
    • Overrides updateLayer to render a clear-to-color pass via Metal
    • Full event handler support (key, mouse, scroll)
  • Browser main.rs updated to try MetalView first, fall back to BitmapView
  • Double-buffered presentation via CAMetalLayer.nextDrawable
  • Drawable size updates on window resize

Tests #

6 new Metal tests covering:

  • ClearColor and MetalSize struct construction
  • Pixel format constants
  • System default device creation
  • Command queue creation
  • CAMetalLayer creation and configuration

Dependencies #

Links Metal.framework and QuartzCore.framework. No external crate dependencies. All new code is in the platform crate where unsafe is permitted.

Phase 12 — Metal GPU Compositor (1/7)

This pull request has no versions submitted yet.