This commit is contained in:
Hariharan Mudaliar 2025-10-19 16:07:44 +05:30
commit 38739f9831
3 changed files with 87 additions and 71 deletions

View file

@ -85,10 +85,13 @@ private struct GPUUsageDashboard: View {
}
private var leftColumn: some View {
VStack(alignment: .center, spacing: 16) {
usageRing
GPUEngineGauges(render: renderEngineUtilization, tiler: tilerUtilization, accentColor: accentColor)
}
GPUEngineGauges(
usage: usage,
render: renderEngineUtilization,
tiler: tilerUtilization,
accentColor: accentColor
)
.frame(maxWidth: .infinity, alignment: .leading)
}
private var breakdownAndMeta: some View {
@ -105,25 +108,6 @@ private struct GPUUsageDashboard: View {
}
}
private var usageRing: some View {
ZStack {
Circle()
.stroke(accentColor.opacity(0.25), lineWidth: 12)
.frame(width: 108, height: 108)
RingArc(start: 0, end: CGFloat(min(max(usage / 100, 0), 1)), color: accentColor, lineWidth: 12)
.frame(width: 108, height: 108)
VStack(spacing: 4) {
Text(StatsFormatting.percentage(usage))
.font(.system(size: 28, weight: .bold, design: .rounded))
Text("Active")
.font(.footnote)
.foregroundColor(.secondary)
}
}
}
private var breakdownSection: some View {
VStack(alignment: .leading, spacing: 12) {
DetailRow(color: accentColor.opacity(0.9), label: "Render", value: StatsFormatting.percentage(breakdown.render))
@ -164,20 +148,48 @@ private struct GPUUsageDashboard: View {
}
private struct GPUEngineGauges: View {
let usage: Double
let render: Double?
let tiler: Double?
let accentColor: Color
private let ringDiameter: CGFloat = 112
private let ringLineWidth: CGFloat = 12
var body: some View {
VStack(alignment: .leading, spacing: 10) {
Text("Engines")
Text("Engine Utilization")
.font(.caption)
.foregroundColor(.secondary)
HStack(alignment: .center, spacing: 16) {
EngineGaugeView(title: "Render", value: render, tint: accentColor)
EngineGaugeView(title: "Tiler", value: tiler, tint: accentColor.opacity(0.75))
HStack(alignment: .center, spacing: 18) {
EngineGaugeView(title: "Render", value: render, tint: accentColor, size: 72)
GPUUsageRing(usage: usage, accentColor: accentColor, diameter: ringDiameter, lineWidth: ringLineWidth)
EngineGaugeView(title: "Tiler", value: tiler, tint: accentColor.opacity(0.75), size: 72)
}
.frame(maxWidth: .infinity, alignment: .center)
}
}
}
private struct GPUUsageRing: View {
let usage: Double
let accentColor: Color
var diameter: CGFloat = 108
var lineWidth: CGFloat = 12
var body: some View {
ZStack {
Circle()
.stroke(accentColor.opacity(0.25), lineWidth: lineWidth)
RingArc(start: 0, end: CGFloat(min(max(usage / 100, 0), 1)), color: accentColor, lineWidth: lineWidth)
VStack(spacing: 4) {
Text(StatsFormatting.percentage(usage))
.font(.system(size: 26, weight: .bold, design: .rounded))
Text("Active")
.font(.footnote)
.foregroundColor(.secondary)
}
}
.frame(width: diameter, height: diameter)
}
}
@ -185,7 +197,7 @@ private struct EngineGaugeView: View {
let title: String
let value: Double?
let tint: Color
private let size: CGFloat = 68
var size: CGFloat = 68
var body: some View {
if let value {