mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added Apple Graphics to the GPU module (#260)
This commit is contained in:
@@ -26,7 +26,7 @@ public struct GPU_Info {
|
||||
public let model: String
|
||||
public let IOClass: String
|
||||
public let type: GPU_type
|
||||
public var state: Bool = false
|
||||
public var state: Bool = true
|
||||
|
||||
public var utilization: Double = 0
|
||||
public var temperature: Int = 0
|
||||
|
||||
@@ -81,15 +81,33 @@ internal class InfoReader: Reader<GPUs> {
|
||||
var predictModel = ""
|
||||
var type: GPU_types = .unknown
|
||||
|
||||
if ioClass == "nvAccelerator" || ioClass.contains("nvidia") {
|
||||
let utilization = stats["Device Utilization %"] as? Int ?? stats["GPU Activity(%)"] as? Int ?? 0
|
||||
var temperature = stats["Temperature(C)"] as? Int ?? 0
|
||||
|
||||
if ioClass == "nvAccelerator" || ioClass.contains("nvidia") { // nvidia
|
||||
predictModel = "Nvidia Graphics"
|
||||
type = .discrete
|
||||
} else if ioClass.contains("amd") {
|
||||
} else if ioClass.contains("amd") { // amd
|
||||
predictModel = "AMD Graphics"
|
||||
type = .discrete
|
||||
} else if ioClass.contains("intel") {
|
||||
|
||||
if temperature == 0 {
|
||||
if let tmp = self.smc?.pointee.getValue("TGDD") {
|
||||
temperature = Int(tmp)
|
||||
}
|
||||
}
|
||||
} else if ioClass.contains("intel") { // intel
|
||||
predictModel = "Intel Graphics"
|
||||
type = .integrated
|
||||
|
||||
if temperature == 0 {
|
||||
if let tmp = self.smc?.pointee.getValue("TCGC") {
|
||||
temperature = Int(tmp)
|
||||
}
|
||||
}
|
||||
} else if ioClass.contains("AGX") { // apple
|
||||
predictModel = stats["model"] as? String ?? "Apple Graphics"
|
||||
type = .integrated
|
||||
} else {
|
||||
predictModel = "Unknown"
|
||||
type = .unknown
|
||||
@@ -106,21 +124,6 @@ internal class InfoReader: Reader<GPUs> {
|
||||
return
|
||||
}
|
||||
|
||||
let utilization = stats["Device Utilization %"] as? Int ?? stats["GPU Activity(%)"] as? Int ?? 0
|
||||
var temperature = stats["Temperature(C)"] as? Int ?? 0
|
||||
|
||||
if temperature == 0 {
|
||||
if IOClass == "IntelAccelerator" {
|
||||
if let tmp = self.smc?.pointee.getValue("TCGC") {
|
||||
temperature = Int(tmp)
|
||||
}
|
||||
} else if IOClass.starts(with: "AMDRadeon") {
|
||||
if let tmp = self.smc?.pointee.getValue("TGDD") {
|
||||
temperature = Int(tmp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let agcInfo = accelerator["AGCInfo"] as? [String:Int] {
|
||||
self.gpus.list[idx].state = agcInfo["poweredOffByAGC"] == 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user