feat(menubar): 完善首排监控卡片与温度风扇采样

补充 GPU 渲染分块、内存与利用率统计,增加只读 SMC 温度及风扇信息和旋转动效。完善电池功率与耗电进程列表,统一首排布局并固定异步加载区域高度。同步验证用例、架构说明和 GPU 能力调研工具。
This commit is contained in:
2026-11-03 16:42:09 +08:00
parent 45a6e16bb8
commit cc38066de2
43 changed files with 2658 additions and 536 deletions
+37
View File
@@ -0,0 +1,37 @@
// Bounded, self-contained workload for Instruments validation (not app code).
// swiftc tools/gpu_compute_probe.swift -o /tmp/kymo-gpu-compute-probe
import Foundation
import Metal
guard let device = MTLCreateSystemDefaultDevice(), let queue = device.makeCommandQueue() else {
fatalError("Metal device/queue unavailable")
}
let source = """
#include <metal_stdlib>
using namespace metal;
kernel void probe(device float *values [[buffer(0)]], uint index [[thread_position_in_grid]]) {
float value = float(index) * 0.0001f;
for (uint i = 0; i < 512; ++i) value = sin(value) * 0.99f + 0.01f;
values[index] = value;
}
"""
let library = try device.makeLibrary(source: source, options: nil)
let pipeline = try device.makeComputePipelineState(function: library.makeFunction(name: "probe")!)
let count = 65_536
let buffer = device.makeBuffer(length: count * MemoryLayout<Float>.stride, options: .storageModeShared)!
let start = ProcessInfo.processInfo.systemUptime
var completed = 0
while ProcessInfo.processInfo.systemUptime - start < 3 {
let command = queue.makeCommandBuffer()!
let encoder = command.makeComputeCommandEncoder()!
encoder.setComputePipelineState(pipeline)
encoder.setBuffer(buffer, offset: 0, index: 0)
encoder.dispatchThreads(MTLSize(width: count, height: 1, depth: 1),
threadsPerThreadgroup: MTLSize(width: min(256, pipeline.maxTotalThreadsPerThreadgroup), height: 1, depth: 1))
encoder.endEncoding()
command.commit()
command.waitUntilCompleted()
guard command.status == .completed else { fatalError("GPU command failed: \(String(describing: command.error))") }
completed += 1
}
print("GPU probe completed \(completed) commands")