import SwiftUI /// Memory bars share a byte scale, not a used/allocated capacity ratio. struct GPUStatisticsView: View { let inUse: UInt64? let allocated: UInt64? let average: Double? let peak: Double? @Environment(\.accessibilityReduceMotion) private var reduceMotion private var reference: Double { max(1, Double(max(inUse ?? 0, allocated ?? 0))) } var body: some View { HStack(spacing: 10) { VStack(spacing: 5) { memoryRow("gpu.driverMemory", bytes: inUse, color: Color("MetricMemory")) memoryRow("gpu.allocatedMemory", bytes: allocated, color: Color("MetricNetwork")) }.frame(maxWidth: .infinity) Divider() HStack(spacing: 6) { MetricRingGauge(title: "gpu.recentAverage", value: average, color: Color("MetricCPU")) MetricRingGauge(title: "gpu.peak", value: peak, color: Color("MetricGPU")) }.frame(maxWidth: .infinity) }.frame(height: 46) } private func memoryRow(_ title: LocalizedStringKey, bytes: UInt64?, color: Color) -> some View { VStack(spacing: 3) { HStack(spacing: 4) { Text(title).foregroundStyle(.secondary) Spacer(minLength: 0) AnimatedMetricText(value: MetricFormat.bytes(bytes)).font(PanelStyle.value) }.font(PanelStyle.label).lineLimit(1) MetricProgressBar(value: bytes.map { Double($0) / reference } ?? 0, color: color) .frame(height: 3) .animation(reduceMotion ? nil : .easeInOut(duration: 0.35), value: bytes) .animation(reduceMotion ? nil : .easeInOut(duration: 0.35), value: reference) .accessibilityHidden(true) } } }