### Godot version

4.0 RC3 (update: tested on 4.0.2 stable, still persists)

### System information

EndeavourOS Linux, AMD Radeon 5700XT, Vulkan

### Issue description

This may be considered a duplicate of  #70837 or #65391 since they occur under similar circumstances, so feel free to close this if it's deemed too similar, but at any rate here is my experience:
Mailbox vsync appears to work just fine if set with the project settings and left alone.
However if you have vsync options available in-game, I find that all of them are able to be changed at runtime without a hitch, except if your project settings change from something else to mailbox, or if your project settings are set to mailbox and you change to something else. 

The issue does not seem to occur when using the OpenGL (compatibility) renderer.

### Steps to reproduce

-New scene (any type seems to work)
-Attach script to root node, GDscript or C# works (I am using GDscript for this example, C# script is available in the minimal reproduction project)

if you put the line `DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)`
in the _ready function, the game freezes at the splash screen.

If you do something like the following to get it to happen during _process...
```
var changed = false;

func _process(delta):
	if (!changed):
		DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
		changed = true
	pass
```


Then you have a rapidly flickering and garbled screen like the following screenshot, and the following error message
![Screenshot_20230225_050232](https://user-images.githubusercontent.com/36201999/221358384-00e8b350-061a-4e03-ac9a-d1d5481b9a64.png)


```
E 0:00:00:0332   main.gd:7 @ _process(): Condition "swapchainImageCount != sp_image_count" is true. Returning: ERR_BUG
  <C++ Source>   drivers/vulkan/vulkan_context.cpp:1975 @ _update_swap_chain()
  <Stack Trace>  main.gd:7 @ _process()
```



### Minimal reproduction project

[BugTester.zip](https://github.com/godotengine/godot/files/10831213/BugTester.zip)

for (uint32_t i = 0; i < check_count; i++) {
		VkBool32 found = 0;
		for (uint32_t j = 0; j < layer_count; j++) {
			if (!strcmp(check_names[i], layers[j].layerName)) {
				found = 1;
				break;
			}
		}
		if (!found) {
			WARN_PRINT("Can't find layer: " + String(check_names[i]));
			return 0;
		}
	}
	return 1;
}
Error VulkanContext::_get_preferred_validation_layers(uint32_t *count, const char *const **names) {
	static const LocalVector<LocalVector<const char *>> instance_validation_layers_alt{
		
		{ "VK_LAYER_KHRONOS_validation" },
		
		{ "VK_LAYER_LUNARG_standard_validation" },
		
		{ "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker", "VK_LAYER_LUNARG_core_validation", "VK_LAYER_GOOGLE_unique_objects" }
	};
	
	*count = 0;
	if (names != nullptr) {
		*names = nullptr;