1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

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.
This commit is contained in:
Hugo Locurcio
2025-08-05 23:43:33 +02:00
parent c81fd6c512
commit 22285c8fd9

View File

@@ -611,6 +611,25 @@
The first element holds the driver name, such as [code]nvidia[/code], [code]amdgpu[/code], etc.
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].
[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.
[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.
[codeblocks]
[gdscript]
var thread = Thread.new()
func _ready():
thread.start(
func():
var driver_info = OS.get_video_adapter_driver_info()
if not driver_info.is_empty():
print("Driver: %s %s" % [driver_info[0], driver_info[1]])
else:
print("Driver: (unknown)")
)
func _exit_tree():
thread.wait_to_finish()
[/gdscript]
[/codeblocks]
</description>
</method>
<method name="has_environment" qualifiers="const">