Merge pull request #83452 from RandomShaper/rd_common
Split `RenderingDevice` into API-agnostic and `RenderingDeviceDriver` parts
This commit is contained in:
@@ -1707,9 +1707,9 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) {
|
||||
window_set_transient(p_id, INVALID_WINDOW_ID);
|
||||
}
|
||||
|
||||
#ifdef VULKAN_ENABLED
|
||||
if (context_vulkan) {
|
||||
context_vulkan->window_destroy(p_id);
|
||||
#if defined(RD_ENABLED)
|
||||
if (context_rd) {
|
||||
context_rd->window_destroy(p_id);
|
||||
}
|
||||
#endif
|
||||
#ifdef GLES3_ENABLED
|
||||
@@ -2233,9 +2233,9 @@ void DisplayServerX11::window_set_size(const Size2i p_size, WindowID p_window) {
|
||||
}
|
||||
|
||||
// Keep rendering context window size in sync
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (context_vulkan) {
|
||||
context_vulkan->window_resize(p_window, xwa.width, xwa.height);
|
||||
#if defined(RD_ENABLED)
|
||||
if (context_rd) {
|
||||
context_rd->window_resize(p_window, xwa.width, xwa.height);
|
||||
}
|
||||
#endif
|
||||
#if defined(GLES3_ENABLED)
|
||||
@@ -3945,9 +3945,9 @@ void DisplayServerX11::_window_changed(XEvent *event) {
|
||||
wd.position = new_rect.position;
|
||||
wd.size = new_rect.size;
|
||||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (context_vulkan) {
|
||||
context_vulkan->window_resize(window_id, wd.size.width, wd.size.height);
|
||||
#if defined(RD_ENABLED)
|
||||
if (context_rd) {
|
||||
context_rd->window_resize(window_id, wd.size.width, wd.size.height);
|
||||
}
|
||||
#endif
|
||||
#if defined(GLES3_ENABLED)
|
||||
@@ -5244,9 +5244,9 @@ void DisplayServerX11::set_icon(const Ref<Image> &p_icon) {
|
||||
|
||||
void DisplayServerX11::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (context_vulkan) {
|
||||
context_vulkan->set_vsync_mode(p_window, p_vsync_mode);
|
||||
#if defined(RD_ENABLED)
|
||||
if (context_rd) {
|
||||
context_rd->set_vsync_mode(p_window, p_vsync_mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5262,9 +5262,9 @@ void DisplayServerX11::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mo
|
||||
|
||||
DisplayServer::VSyncMode DisplayServerX11::window_get_vsync_mode(WindowID p_window) const {
|
||||
_THREAD_SAFE_METHOD_
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (context_vulkan) {
|
||||
return context_vulkan->get_vsync_mode(p_window);
|
||||
#if defined(RD_ENABLED)
|
||||
if (context_rd) {
|
||||
return context_rd->get_vsync_mode(p_window);
|
||||
}
|
||||
#endif
|
||||
#if defined(GLES3_ENABLED)
|
||||
@@ -5606,10 +5606,21 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
|
||||
|
||||
_update_size_hints(id);
|
||||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (context_vulkan) {
|
||||
Error err = context_vulkan->window_create(id, p_vsync_mode, wd.x11_window, x11_display, win_rect.size.width, win_rect.size.height);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan window");
|
||||
#if defined(RD_ENABLED)
|
||||
if (context_rd) {
|
||||
union {
|
||||
#ifdef VULKAN_ENABLED
|
||||
VulkanContextX11::WindowPlatformData vulkan;
|
||||
#endif
|
||||
} wpd;
|
||||
#ifdef VULKAN_ENABLED
|
||||
if (rendering_driver == "vulkan") {
|
||||
wpd.vulkan.window = wd.x11_window;
|
||||
wpd.vulkan.display = x11_display;
|
||||
}
|
||||
#endif
|
||||
Error err = context_rd->window_create(id, p_vsync_mode, win_rect.size.width, win_rect.size.height, &wpd);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, vformat("Can't create a %s window", context_rd->get_api_name()));
|
||||
}
|
||||
#endif
|
||||
#ifdef GLES3_ENABLED
|
||||
@@ -6008,14 +6019,19 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
||||
rendering_driver = p_rendering_driver;
|
||||
|
||||
bool driver_found = false;
|
||||
#if defined(RD_ENABLED)
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (rendering_driver == "vulkan") {
|
||||
context_vulkan = memnew(VulkanContextX11);
|
||||
if (context_vulkan->initialize() != OK) {
|
||||
memdelete(context_vulkan);
|
||||
context_vulkan = nullptr;
|
||||
context_rd = memnew(VulkanContextX11);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (context_rd) {
|
||||
if (context_rd->initialize() != OK) {
|
||||
memdelete(context_rd);
|
||||
context_rd = nullptr;
|
||||
r_error = ERR_CANT_CREATE;
|
||||
ERR_FAIL_MSG("Could not initialize Vulkan");
|
||||
ERR_FAIL_MSG(vformat("Could not initialize %s", context_rd->get_api_name()));
|
||||
}
|
||||
driver_found = true;
|
||||
}
|
||||
@@ -6124,11 +6140,10 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
||||
}
|
||||
show_window(main_window);
|
||||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (rendering_driver == "vulkan") {
|
||||
//temporary
|
||||
rendering_device_vulkan = memnew(RenderingDeviceVulkan);
|
||||
rendering_device_vulkan->initialize(context_vulkan);
|
||||
#if defined(RD_ENABLED)
|
||||
if (context_rd) {
|
||||
rendering_device = memnew(RenderingDevice);
|
||||
rendering_device->initialize(context_rd);
|
||||
|
||||
RendererCompositorRD::make_current();
|
||||
}
|
||||
@@ -6302,9 +6317,9 @@ DisplayServerX11::~DisplayServerX11() {
|
||||
|
||||
//destroy all windows
|
||||
for (KeyValue<WindowID, WindowData> &E : windows) {
|
||||
#ifdef VULKAN_ENABLED
|
||||
if (context_vulkan) {
|
||||
context_vulkan->window_destroy(E.key);
|
||||
#if defined(RD_ENABLED)
|
||||
if (context_rd) {
|
||||
context_rd->window_destroy(E.key);
|
||||
}
|
||||
#endif
|
||||
#ifdef GLES3_ENABLED
|
||||
@@ -6346,16 +6361,16 @@ DisplayServerX11::~DisplayServerX11() {
|
||||
#endif
|
||||
|
||||
//destroy drivers
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (rendering_device_vulkan) {
|
||||
rendering_device_vulkan->finalize();
|
||||
memdelete(rendering_device_vulkan);
|
||||
rendering_device_vulkan = nullptr;
|
||||
#if defined(RD_ENABLED)
|
||||
if (rendering_device) {
|
||||
rendering_device->finalize();
|
||||
memdelete(rendering_device);
|
||||
rendering_device = nullptr;
|
||||
}
|
||||
|
||||
if (context_vulkan) {
|
||||
memdelete(context_vulkan);
|
||||
context_vulkan = nullptr;
|
||||
if (context_rd) {
|
||||
memdelete(context_rd);
|
||||
context_rd = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user