Skip to content

Commit

Permalink
Print extended hardware information when running in verbose mode
Browse files Browse the repository at this point in the history
This is useful for troubleshooting, especially for player-submitted
reports in exported projects.
  • Loading branch information
Calinou committed Nov 19, 2024
1 parent a0cd8f1 commit 2784e7c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3166,6 +3166,44 @@ Error Main::setup2(bool p_show_boot_logo) {

register_core_singletons();

if (OS::get_singleton()->is_stdout_verbose()) {
// Print hardware information for easier troubleshooting (other than GPU, as rendering drivers already handle this).
// Only evaluate functions if needed, as some of these may be relatively slow.
print_line(vformat("Device model: %s", OS::get_singleton()->get_model_name()));
print_line(vformat("CPU model: %s (%s threads)", OS::get_singleton()->get_processor_name(), OS::get_singleton()->get_processor_count()));
print_line(vformat("Audio mix rate: %d Hz", AudioServer::get_singleton()->get_mix_rate()));
print_line("Output audio devices:");
int output_device_id = 0;
for (String output_device : AudioServer::get_singleton()->get_output_device_list()) {
print_line(vformat(" #%d: %s%s", output_device_id, output_device, AudioServer::get_singleton()->get_output_device() == output_device ? " (selected)" : ""));
output_device_id += 1;
}
print_line("Input audio devices:");
int input_device_id = 0;
for (String input_device : AudioServer::get_singleton()->get_input_device_list()) {
print_line(vformat(" #%d: %s%s", input_device_id, input_device, AudioServer::get_singleton()->get_input_device() == input_device ? " (selected)" : ""));
input_device_id += 1;
}
print_line("Displays:");
for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
const Rect2i usable_rect = DisplayServer::get_singleton()->screen_get_usable_rect();
print_line(
vformat(" #%d: (%d, %d), %dx%d, %.2f Hz, %d dpi, scale factor: %.2f, usable rect: (%d, %d), %dx%d",
i,
DisplayServer::get_singleton()->screen_get_position(i).x,
DisplayServer::get_singleton()->screen_get_position(i).y,
DisplayServer::get_singleton()->screen_get_size(i).x,
DisplayServer::get_singleton()->screen_get_size(i).y,
DisplayServer::get_singleton()->screen_get_refresh_rate(i),
DisplayServer::get_singleton()->screen_get_dpi(i),
DisplayServer::get_singleton()->screen_get_scale(i),
usable_rect.position.x,
usable_rect.position.y,
usable_rect.size.x,
usable_rect.size.y));
}
}

/* Initialize the main window and boot screen */

{
Expand Down

0 comments on commit 2784e7c

Please sign in to comment.