You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Improve error message when the requested V-Sync mode cannot be used
This commit is contained in:
@@ -1049,7 +1049,7 @@
|
|||||||
<return type="int" enum="DisplayServer.VSyncMode" />
|
<return type="int" enum="DisplayServer.VSyncMode" />
|
||||||
<argument index="0" name="window_id" type="int" default="0" />
|
<argument index="0" name="window_id" type="int" default="0" />
|
||||||
<description>
|
<description>
|
||||||
Returns the VSync mode of the given window.
|
Returns the V-Sync mode of the given window.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="window_move_to_foreground">
|
<method name="window_move_to_foreground">
|
||||||
@@ -1234,7 +1234,7 @@
|
|||||||
<argument index="0" name="vsync_mode" type="int" enum="DisplayServer.VSyncMode" />
|
<argument index="0" name="vsync_mode" type="int" enum="DisplayServer.VSyncMode" />
|
||||||
<argument index="1" name="window_id" type="int" default="0" />
|
<argument index="1" name="window_id" type="int" default="0" />
|
||||||
<description>
|
<description>
|
||||||
Sets the VSync mode of the given window.
|
Sets the V-Sync mode of the given window.
|
||||||
See [enum DisplayServer.VSyncMode] for possible values and how they affect the behavior of your application.
|
See [enum DisplayServer.VSyncMode] for possible values and how they affect the behavior of your application.
|
||||||
Depending on the platform and used renderer, the engine will fall back to [constant VSYNC_ENABLED], if the desired mode is not supported.
|
Depending on the platform and used renderer, the engine will fall back to [constant VSYNC_ENABLED], if the desired mode is not supported.
|
||||||
</description>
|
</description>
|
||||||
|
|||||||
@@ -588,7 +588,7 @@
|
|||||||
[b]Note:[/b] By default, or when set to 0, the initial window width is the viewport [member display/window/size/viewport_width]. This setting is ignored on iOS, Android, and HTML5.
|
[b]Note:[/b] By default, or when set to 0, the initial window width is the viewport [member display/window/size/viewport_width]. This setting is ignored on iOS, Android, and HTML5.
|
||||||
</member>
|
</member>
|
||||||
<member name="display/window/vsync/vsync_mode" type="int" setter="" getter="" default="1">
|
<member name="display/window/vsync/vsync_mode" type="int" setter="" getter="" default="1">
|
||||||
Sets the VSync mode for the main game window.
|
Sets the V-Sync mode for the main game window.
|
||||||
See [enum DisplayServer.VSyncMode] for possible values and how they affect the behavior of your application.
|
See [enum DisplayServer.VSyncMode] for possible values and how they affect the behavior of your application.
|
||||||
Depending on the platform and used renderer, the engine will fall back to [code]Enabled[/code], if the desired mode is not supported.
|
Depending on the platform and used renderer, the engine will fall back to [code]Enabled[/code], if the desired mode is not supported.
|
||||||
</member>
|
</member>
|
||||||
|
|||||||
@@ -1666,7 +1666,22 @@ Error VulkanContext::_update_swap_chain(Window *window) {
|
|||||||
if (present_mode_available) {
|
if (present_mode_available) {
|
||||||
window->presentMode = requested_present_mode;
|
window->presentMode = requested_present_mode;
|
||||||
} else {
|
} else {
|
||||||
WARN_PRINT("Requested VSync mode is not available!");
|
String present_mode_string;
|
||||||
|
switch (window->vsync_mode) {
|
||||||
|
case DisplayServer::VSYNC_MAILBOX:
|
||||||
|
present_mode_string = "Mailbox";
|
||||||
|
break;
|
||||||
|
case DisplayServer::VSYNC_ADAPTIVE:
|
||||||
|
present_mode_string = "Adaptive";
|
||||||
|
break;
|
||||||
|
case DisplayServer::VSYNC_ENABLED:
|
||||||
|
present_mode_string = "Enabled";
|
||||||
|
break;
|
||||||
|
case DisplayServer::VSYNC_DISABLED:
|
||||||
|
present_mode_string = "Disabled";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
WARN_PRINT(vformat("The requested V-Sync mode %s is not available. Falling back to V-Sync mode Enabled.", present_mode_string));
|
||||||
window->vsync_mode = DisplayServer::VSYNC_ENABLED; // Set to default.
|
window->vsync_mode = DisplayServer::VSYNC_ENABLED; // Set to default.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2471,12 +2486,12 @@ String VulkanContext::get_device_pipeline_cache_uuid() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DisplayServer::VSyncMode VulkanContext::get_vsync_mode(DisplayServer::WindowID p_window) const {
|
DisplayServer::VSyncMode VulkanContext::get_vsync_mode(DisplayServer::WindowID p_window) const {
|
||||||
ERR_FAIL_COND_V_MSG(!windows.has(p_window), DisplayServer::VSYNC_ENABLED, "Could not get VSync mode for window with WindowID " + itos(p_window) + " because it does not exist.");
|
ERR_FAIL_COND_V_MSG(!windows.has(p_window), DisplayServer::VSYNC_ENABLED, "Could not get V-Sync mode for window with WindowID " + itos(p_window) + " because it does not exist.");
|
||||||
return windows[p_window].vsync_mode;
|
return windows[p_window].vsync_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanContext::set_vsync_mode(DisplayServer::WindowID p_window, DisplayServer::VSyncMode p_mode) {
|
void VulkanContext::set_vsync_mode(DisplayServer::WindowID p_window, DisplayServer::VSyncMode p_mode) {
|
||||||
ERR_FAIL_COND_MSG(!windows.has(p_window), "Could not set VSync mode for window with WindowID " + itos(p_window) + " because it does not exist.");
|
ERR_FAIL_COND_MSG(!windows.has(p_window), "Could not set V-Sync mode for window with WindowID " + itos(p_window) + " because it does not exist.");
|
||||||
windows[p_window].vsync_mode = p_mode;
|
windows[p_window].vsync_mode = p_mode;
|
||||||
_update_swap_chain(&windows[p_window]);
|
_update_swap_chain(&windows[p_window]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -494,11 +494,11 @@ int64_t DisplayServer::window_get_native_handle(HandleType p_handle_type, Window
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DisplayServer::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
|
void DisplayServer::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
|
||||||
WARN_PRINT("Changing the VSync mode is not supported by this display server.");
|
WARN_PRINT("Changing the V-Sync mode is not supported by this display server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayServer::VSyncMode DisplayServer::window_get_vsync_mode(WindowID p_window) const {
|
DisplayServer::VSyncMode DisplayServer::window_get_vsync_mode(WindowID p_window) const {
|
||||||
WARN_PRINT("Changing the VSync mode is not supported by this display server.");
|
WARN_PRINT("Changing the V-Sync mode is not supported by this display server.");
|
||||||
return VSyncMode::VSYNC_ENABLED;
|
return VSyncMode::VSYNC_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user