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

Check if RD is supported in the ProjectManager and disable creating RD projects if not supported.

This commit is contained in:
clayjohn
2024-04-25 10:37:38 -07:00
parent 3978628c6c
commit 04d0e7f7a4
4 changed files with 75 additions and 3 deletions

View File

@@ -34,6 +34,14 @@
#include "scene/resources/texture.h"
#include "servers/display_server_headless.h"
#if defined(VULKAN_ENABLED)
#include "drivers/vulkan/rendering_context_driver_vulkan.h"
#undef CursorShape
#endif
#if defined(D3D12_ENABLED)
#include "drivers/d3d12/rendering_context_driver_d3d12.h"
#endif
DisplayServer *DisplayServer::singleton = nullptr;
bool DisplayServer::hidpi_allowed = false;
@@ -1211,6 +1219,40 @@ void DisplayServer::_input_set_custom_mouse_cursor_func(const Ref<Resource> &p_i
singleton->cursor_set_custom_image(p_image, (CursorShape)p_shape, p_hostspot);
}
bool DisplayServer::can_create_rendering_device() {
#if defined(RD_ENABLED)
Error err;
RenderingContextDriver *rcd = nullptr;
#if defined(VULKAN_ENABLED)
rcd = memnew(RenderingContextDriverVulkan);
#endif
#ifdef D3D12_ENABLED
if (rcd == nullptr) {
rcd = memnew(RenderingContextDriverD3D12);
}
#endif
if (rcd != nullptr) {
err = rcd->initialize();
if (err == OK) {
RenderingDevice *rd = memnew(RenderingDevice);
err = rd->initialize(rcd);
memdelete(rd);
rd = nullptr;
if (err == OK) {
return true;
}
}
memdelete(rcd);
rcd = nullptr;
}
#endif // RD_ENABLED
return false;
}
DisplayServer::DisplayServer() {
singleton = this;
Input::set_mouse_mode_func = _input_set_mouse_mode;