Skip to content

Latest commit

 

History

History
97 lines (86 loc) · 10 KB

MetalKit.md

File metadata and controls

97 lines (86 loc) · 10 KB

MetalKit

Symbols: 58.9% of Apple's iOS API (66 of 112, exact) · Rows: 4: 2 ✅ 1 🟡 1 ❌ · iOS: 9.0+

Area: GPU · Apple: MetalKit · Issues: area:gpu

How isim implements it

  • Adapted: isim's Swift implementation (isim/swift/overlays/MetalKit), over isim's Metal, which renders on the CPU (see Metal, #329). import MetalKit re-exports Metal and QuartzCore, as on iOS.
  • MTKView:
    • It is a UIView whose layer is a CAMetalLayer (see QuartzCore).
    • A CADisplayLink calls draw() at preferredFramesPerSecond, or after setNeedsDisplay() when enableSetNeedsDisplay is set. draw() calls the delegate's draw(in:), or a subclass's draw(_:). isim's view rendering does not call that draw(_:) itself (UIView _isim_skipsDrawRect).
    • currentRenderPassDescriptor clears the current drawable and the view's depth / stencil and multisample textures, which are made at the drawable's size.
  • MTKTextureLoader: decodes images with UIKit (UIImage: PNG, JPEG and the formats isim reads, and asset catalog images by name) into RGBA8 textures:
    • _srgb unless SRGB is false;
    • straight alpha;
    • optionally flipped by origin;
    • mipmaps generated by a blit.
  • Objective-C: headers in isim/sdk-src/Frameworks/MetalKit over the Swift classes. MetalKit.framework re-exports the overlay, and isim/frameworks/MetalKit/MetalKit.m holds the MTKTextureLoader option constants.
  • Versus Apple's Simulator: the frames are drawn by the CPU, so a large view at full resolution draws fewer frames per second. Multisampling holds one sample per pixel (not antialiased). KTX / PVR files, MDLTexture, MTKMesh and the Model I/O bridges are not provided.

API

API / feature Status iOS Notes
MTKView (init(frame:device:), delegate, device, colorPixelFormat, depthStencilPixelFormat, sampleCount, clearColor / clearDepth / clearStencil, currentDrawable, currentRenderPassDescriptor, depthStencilTexture, multisampleColorTexture, preferredFramesPerSecond, enableSetNeedsDisplay, isPaused, autoResizeDrawable, drawableSize, preferredDrawableSize, framebufferOnly, draw(), releaseDrawables()) ✅ ≤17 adapted: frames rendered by isim's Metal on the CPU; multisample textures hold one sample per pixel. Tested (HelloMetalKit, test_metalkit)
MTKViewDelegate (mtkView(_:drawableSizeWillChange:), draw(in:)) ✅ ≤17 Tested (HelloMetalKit, test_metalkit)
MTKTextureLoader (newTexture(URL:options:), newTexture(data:options:), newTexture(cgImage:options:), newTexture(name:scaleFactor:bundle:options:), the completion-handler and async forms, newTextures(URLs:options:)), MTKTextureLoader.Option (SRGB, generateMipmaps, allocateMipmaps, textureUsage, textureStorageMode, origin) 🟡 ≤17 adapted: images decoded by UIKit into RGBA8 textures; KTX, PVR and MDLTexture are not supported (an error); cubeLayout and loadAsArray are ignored. Tested (HelloMetalKit: a generated image with mipmaps)
MTKMesh, MTKSubmesh, MTKMeshBufferAllocator, MTKModelIOVertexDescriptorFromMetal ❌ ≤17 need Model I/O, which isim does not have

Not yet in isim

46 symbols Apple documents for iOS that isim does not have (exact; Apple snapshot 2026-10-14). Each links to Apple's documentation.

List