Game Porting Toolkit 4 introduces agentic skills and a porting assistant that give AI coding agents (like Claude Code) the platform expertise needed to autonomously port games from D3D12/Windows to Metal/macOS, including new macOS 27 command-line tools gpucapture and gpudebug for fully autonomous GPU frame analysis.
โข Dramatically reduces game porting time by embedding Metal best practices, synchronization patterns, and anti-pattern detection directly into the agent's workflow โ no manual expertise hand-holding required.
โข New gpucapture and gpudebug CLI tools on macOS 27 enable coding agents to capture and analyze GPU frames autonomously, closing the last major gap in agentic porting workflows.
โข The structured discover โ plan โ execute โ validate loop with milestone-scoped expert skills means fewer regressions and systematic quality gates throughout the port.
Demonstrates the two most critical Metal 4 patterns taught by GPTK 4 agentic skills: registering resources in a residency set before GPU use, and invoking the new gpucapture CLI tool from Swift for autonomous agent-driven frame capture.
import Metal
import Foundation
// MARK: - Metal 4 Residency Set Pattern
// (Core pattern taught by GPTK 4 Resources expert skill)
func buildResidencySet(device: MTLDevice,
textures: [MTLTexture],
buffers: [MTLBuffer]) throws -> MTLResidencySet {
// Metal 4: All GPU-accessed resources must be registered in a residency set
// before any command buffer that uses them is committed.
let descriptor = MTLResidencySetDescriptor()
descriptor.label = "GameResidencySet"
descriptor.initialCapacity = textures.count + buffers.count
let residencySet = try device.makeResidencySet(descriptor: descriptor)
for texture in textures {
residencySet.addAllocation(texture)
}
for buffer in buffers {
residencySet.addAllocation(buffer)
}
residencySet.commit()
return residencySet
}
// MARK: - Encode a command buffer with residency set attached
func encodeFrame(commandQueue: MTLCommandQueue,
residencySet: MTLResidencySet,
renderPassDescriptor: MTLRenderPassDescriptor,
pipelineState: MTLRenderPipelineState,
vertexBuffer: MTLBuffer) {
guard let commandBuffer = commandQueue.makeCommandBuffer() else { return }
commandBuffer.label = "FrameCommandBuffer"
// Attach residency set so GPU can access all registered resources
commandBuffer.addResidencySet(residencySet)
guard let encoder = commandBuffer.makeRenderCommandEncoder(
descriptor: renderPassDescriptor) else { return }
encoder.setRenderPipelineState(pipelineState)
encoder.setVertexBuffer(vertexBuffer, offset: 0, index: 0)
encoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: 3)
encoder.endEncoding()
commandBuffer.commit()
}
// MARK: - gpucapture CLI invocation (macOS 27, new in GPTK 4 agentic workflow)
// Enables a coding agent to autonomously capture a GPU frame for debugging.
@discardableResult
func captureGPUFrame(outputPath: String, duration: Int = 1) -> Int32 {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/gpucapture")
process.arguments = [
"--output", outputPath,
"--frames", String(duration)
]
do {
try process.run()
process.waitUntilExit()
} catch {
print("gpucapture not available: \(error)")
return -1
}
return process.terminationStatus
}
// MARK: - gpudebug CLI invocation for autonomous analysis
func analyzeCapture(capturePath: String) -> String {
let process = Process()
let pipe = Pipe()
process.executableURL = URL(fileURLWithPath: "/usr/bin/gpudebug")
process.arguments = ["--analyze", capturePath, "--format", "json"]
process.standardOutput = pipe
do {
try process.run()
process.waitUntilExit()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
return String(data: data, encoding: .utf8) ?? ""
} catch {
return "gpudebug not available: \(error)"
}
}MetricKit has been rebuilt from the ground up in iOS 27 with a contextually rich, Swift-first API that delivers metrics and diagnostics as async streams, plus new capabilities like Metal frame rate metrics, memory exception diagnostics, and per-state metric breakdowns via the StateReporting framework.
iOS 26+ introduces a Deferred Start API for AVCaptureSession that postpones initialization of non-preview outputs (like photo and movie outputs) until after the first preview frame renders, dramatically cutting camera app launch times.
Instruments 27 introduces Run Comparisons โ a new mode that directly diffs two profiling traces side-by-side in a single document to calculate exact performance deltas โ alongside the new Top Functions analysis mode that merges scattered call-tree nodes by self-weight to instantly surface the costliest functions regardless of call hierarchy.
Agentic skills are delivered as a plugin from the GPTK GitHub marketplace โ they are not part of the Xcode SDK or Swift package ecosystem. The quality of output depends heavily on the underlying model (demo uses Claude Code). Metal 4 residency sets and explicit synchronization are mandatory and differ significantly from D3D12 patterns; skipping the skills causes silent rendering errors rather than compile-time failures.
Apple silicon required for Metal 4 tile-architecture optimizations; game porting targets macOS, not iOS devices. gpucapture and gpudebug are macOS-only CLI tools.
iOS 27 rebuilds MetricKit from the ground up with a modern, Swift-first API that delivers metric and diagnostic reports via async streams, adds Metal frame rate metrics, memory exception diagnostics, and crash termination categories, plus a new StateReporting framework to contextualize metrics by app state.