Skip to content

Commit 25e2e9d

Browse files
pastaqShadowApex
authored andcommitted
fix(Hardware Manager): Gracefully detect all GPU's instead of failing.
1 parent 150026f commit 25e2e9d

File tree

2 files changed

+10
-34
lines changed

2 files changed

+10
-34
lines changed

core/systems/hardware/drm_card_port.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ func _to_string() -> String:
129129
+ " Name: (" + str(name) \
130130
+ ") Status: (" + str(status) \
131131
+ ") Enabled: (" + str(enabled) \
132+
+ ") Instance ID: (" + str(self.get_instance_id()) \
132133
+ ")>"

core/systems/hardware/hardware_manager.gd

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,13 @@ func get_gpu_info() -> GPUInfo:
7272
# for the currently active GPU. Vulkaninfo can provide data
7373
# on all detected GPU devices.
7474
gpu_info.vendor = RenderingServer.get_video_adapter_vendor()
75-
match gpu_info.vendor:
76-
"AMD", "AuthenticAMD", 'AuthenticAMD Advanced Micro Devices, Inc.', "Advanced Micro Devices, Inc. [AMD/ATI]":
77-
gpu_info.vendor = "AMD"
78-
"Intel", "GenuineIntel", "Intel Corporation":
79-
gpu_info.vendor = "Intel"
80-
"Nvidia":
81-
gpu_info.vendor = "Trash" # :D
82-
logger.info("Nvidia devices are not suppored.")
83-
return null
84-
_:
85-
logger.warn("Device vendor string not recognized:", RenderingServer.get_video_adapter_vendor())
86-
return null
87-
8875
gpu_info.model = RenderingServer.get_video_adapter_name()
8976
gpu_info.driver = RenderingServer.get_video_adapter_api_version()
9077

9178
# Identify all installed GPU's
9279
if cards.size() <= 0:
93-
logger.error("GPU Data could not be derived.")
94-
return null
80+
logger.error("GPU Card subdata could not be derived.")
81+
return gpu_info
9582

9683
var active_gpu_data := get_active_gpu_device()
9784
if active_gpu_data.size() == 0:
@@ -192,11 +179,13 @@ func get_gpu_card(card_dir: String) -> DRMCardInfo:
192179

193180
if line.begins_with("\t") and not vendor_found:
194181
continue
182+
195183
if line.begins_with(vendor_id):
196184
vendor = line.lstrip(vendor_id).strip_edges()
197185
logger.debug("Found vendor name:", vendor)
198186
vendor_found = true
199187
continue
188+
200189
if vendor_found and not line.begins_with("\t"):
201190
if line.begins_with("#"):
202191
continue
@@ -221,31 +210,17 @@ func get_gpu_card(card_dir: String) -> DRMCardInfo:
221210
logger.debug("Found subdevice name:", subdevice)
222211
break
223212

224-
# Sanitize the vendor strings so they are standard.
225-
match vendor:
226-
"AMD", "AuthenticAMD", 'AuthenticAMD Advanced Micro Devices, Inc.', "Advanced Micro Devices, Inc. [AMD/ATI]":
227-
vendor = "AMD"
228-
"Intel", "GenuineIntel", "Intel Corporation":
229-
vendor = "Intel"
230-
"Nvidia":
231-
vendor = "Trash"
232-
logger.warn("Nvidia devices are not suppored.")
233-
# TODO: Handle this case
234-
return null
235-
_:
236-
logger.warn("Device vendor string not recognized:", vendor)
237-
# TODO: Handle this case
238-
return null
239-
240213
# Create a new card instance and take over the caching path
241214
var card_info: DRMCardInfo
242215
match vendor:
243-
"AMD":
216+
"AMD", "AuthenticAMD", 'AuthenticAMD Advanced Micro Devices, Inc.', "Advanced Micro Devices, Inc. [AMD/ATI]":
244217
card_info = DRMCardInfoAMD.new(card_dir)
245-
"Intel":
218+
"Intel", "GenuineIntel", "Intel Corporation":
246219
card_info = DRMCardInfoIntel.new(card_dir)
247220
_:
248-
return null
221+
logger.info("Device vendor string is not fully supported:", vendor, ". Using generic implementation.")
222+
card_info = DRMCardInfo.new(card_dir)
223+
249224
card_info.take_over_path(res_path)
250225
card_info.vendor = vendor
251226
card_info.vendor_id = vendor_id

0 commit comments

Comments
 (0)