Skip to content

Commit 22285c8

Browse files
committed
Document OS.get_video_adapter_driver_info() being slow to call the first time
- Add a code sample that shows how to call it from a thread to avoid blocking the engine.
1 parent c81fd6c commit 22285c8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/classes/OS.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,25 @@
611611
The first element holds the driver name, such as [code]nvidia[/code], [code]amdgpu[/code], etc.
612612
The second element holds the driver version. For example, on the [code]nvidia[/code] driver on a Linux/BSD platform, the version is in the format [code]510.85.02[/code]. For Windows, the driver's format is [code]31.0.15.1659[/code].
613613
[b]Note:[/b] This method is only supported on Linux/BSD and Windows when not running in headless mode. On other platforms, it returns an empty array.
614+
[b]Note:[/b] This method will run slowly the first time it is called in a session; it can take several seconds depending on the operating system and hardware. It is blocking if called on the main thread, so it's recommended to call it on a separate thread using [Thread]. This allows the engine to keep running while the information is being retrieved. However, [method get_video_adapter_driver_info] is [i]not[/i] thread-safe, so it should not be called from multiple threads at the same time.
615+
[codeblocks]
616+
[gdscript]
617+
var thread = Thread.new()
618+
619+
func _ready():
620+
thread.start(
621+
func():
622+
var driver_info = OS.get_video_adapter_driver_info()
623+
if not driver_info.is_empty():
624+
print("Driver: %s %s" % [driver_info[0], driver_info[1]])
625+
else:
626+
print("Driver: (unknown)")
627+
)
628+
629+
func _exit_tree():
630+
thread.wait_to_finish()
631+
[/gdscript]
632+
[/codeblocks]
614633
</description>
615634
</method>
616635
<method name="has_environment" qualifiers="const">

0 commit comments

Comments
 (0)