summaryrefslogtreecommitdiffstats
path: root/platform/linuxbsd/wayland
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linuxbsd/wayland')
-rw-r--r--platform/linuxbsd/wayland/SCsub14
-rw-r--r--platform/linuxbsd/wayland/display_server_wayland.cpp61
-rw-r--r--platform/linuxbsd/wayland/display_server_wayland.h4
-rw-r--r--platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.cpp (renamed from platform/linuxbsd/wayland/vulkan_context_wayland.cpp)39
-rw-r--r--platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.h (renamed from platform/linuxbsd/wayland/vulkan_context_wayland.h)21
-rw-r--r--platform/linuxbsd/wayland/wayland_thread.cpp16
-rw-r--r--platform/linuxbsd/wayland/wayland_thread.h6
7 files changed, 103 insertions, 58 deletions
diff --git a/platform/linuxbsd/wayland/SCsub b/platform/linuxbsd/wayland/SCsub
index d2b000ff66..cab45b7672 100644
--- a/platform/linuxbsd/wayland/SCsub
+++ b/platform/linuxbsd/wayland/SCsub
@@ -11,15 +11,15 @@ if env["use_sowrap"]:
WAYLAND_BUILDERS_SOWRAP = {
"WAYLAND_API_HEADER": Builder(
action=Action(
- "wayland-scanner -c client-header < ${SOURCE} | sed 's:wayland-client-core\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
+ r"wayland-scanner -c client-header < ${SOURCE} | sed 's:wayland-client-core\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
'Generating Wayland client header: "${TARGET}"',
),
single_source=True,
),
"WAYLAND_API_CODE": Builder(
action=Action(
- "wayland-scanner -c private-code < ${SOURCE} | sed 's:wayland-util\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
- 'Generating Wayland protocol marshalling code: "${TARGET}"',
+ r"wayland-scanner -c private-code < ${SOURCE} | sed 's:wayland-util\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
+ 'Generating Wayland protocol marshaling code: "${TARGET}"',
),
single_source=True,
),
@@ -29,15 +29,15 @@ else:
WAYLAND_BUILDERS = {
"WAYLAND_API_HEADER": Builder(
action=Action(
- "wayland-scanner -c client-header < ${SOURCE} > ${TARGET}",
+ r"wayland-scanner -c client-header < ${SOURCE} > ${TARGET}",
'Generating Wayland client header: "${TARGET}"',
),
single_source=True,
),
"WAYLAND_API_CODE": Builder(
action=Action(
- "wayland-scanner -c private-code < ${SOURCE} > ${TARGET}",
- 'Generating Wayland protocol marshalling code: "${TARGET}"',
+ r"wayland-scanner -c private-code < ${SOURCE} > ${TARGET}",
+ 'Generating Wayland protocol marshaling code: "${TARGET}"',
),
single_source=True,
),
@@ -195,7 +195,7 @@ if env["use_sowrap"]:
if env["vulkan"]:
- source_files.append("vulkan_context_wayland.cpp")
+ source_files.append("rendering_context_driver_vulkan_wayland.cpp")
if env["opengl3"]:
source_files.append("egl_manager_wayland.cpp")
diff --git a/platform/linuxbsd/wayland/display_server_wayland.cpp b/platform/linuxbsd/wayland/display_server_wayland.cpp
index 02b715056a..b8a10ea6b9 100644
--- a/platform/linuxbsd/wayland/display_server_wayland.cpp
+++ b/platform/linuxbsd/wayland/display_server_wayland.cpp
@@ -100,8 +100,8 @@ void DisplayServerWayland::_resize_window(const Size2i &p_size) {
wd.rect.size = p_size;
#ifdef RD_ENABLED
- if (wd.visible && context_rd) {
- context_rd->window_resize(MAIN_WINDOW_ID, wd.rect.size.width, wd.rect.size.height);
+ if (wd.visible && rendering_context) {
+ rendering_context->window_set_size(MAIN_WINDOW_ID, wd.rect.size.width, wd.rect.size.height);
}
#endif
@@ -140,10 +140,10 @@ void DisplayServerWayland::_show_window() {
// the only acceptable way of implementing window showing is to move the
// graphics context window creation logic here.
#ifdef RD_ENABLED
- if (context_rd) {
+ if (rendering_context) {
union {
#ifdef VULKAN_ENABLED
- VulkanContextWayland::WindowPlatformData vulkan;
+ RenderingContextDriverVulkanWayland::WindowPlatformData vulkan;
#endif
} wpd;
#ifdef VULKAN_ENABLED
@@ -152,14 +152,17 @@ void DisplayServerWayland::_show_window() {
wpd.vulkan.display = wayland_thread.get_wl_display();
}
#endif
- Error err = context_rd->window_create(wd.id, wd.vsync_mode, wd.rect.size.width, wd.rect.size.height, &wpd);
- ERR_FAIL_COND_MSG(err != OK, vformat("Can't create a %s window", context_rd->get_api_name()));
+ Error err = rendering_context->window_create(wd.id, &wpd);
+ ERR_FAIL_COND_MSG(err != OK, vformat("Can't create a %s window", rendering_driver));
- emulate_vsync = (context_rd->get_vsync_mode(wd.id) == DisplayServer::VSYNC_ENABLED);
+ rendering_context->window_set_size(wd.id, wd.rect.size.width, wd.rect.size.height);
+ rendering_context->window_set_vsync_mode(wd.id, wd.vsync_mode);
+
+ emulate_vsync = (rendering_context->window_get_vsync_mode(wd.id) == DisplayServer::VSYNC_ENABLED);
if (emulate_vsync) {
print_verbose("VSYNC: manually throttling frames using MAILBOX.");
- context_rd->set_vsync_mode(wd.id, DisplayServer::VSYNC_MAILBOX);
+ rendering_context->window_set_vsync_mode(wd.id, DisplayServer::VSYNC_MAILBOX);
}
}
#endif
@@ -885,14 +888,14 @@ void DisplayServerWayland::window_set_vsync_mode(DisplayServer::VSyncMode p_vsyn
MutexLock mutex_lock(wayland_thread.mutex);
#ifdef RD_ENABLED
- if (context_rd) {
- context_rd->set_vsync_mode(p_window_id, p_vsync_mode);
+ if (rendering_context) {
+ rendering_context->window_set_vsync_mode(p_window_id, p_vsync_mode);
- emulate_vsync = (context_rd->get_vsync_mode(p_window_id) == DisplayServer::VSYNC_ENABLED);
+ emulate_vsync = (rendering_context->window_get_vsync_mode(p_window_id) == DisplayServer::VSYNC_ENABLED);
if (emulate_vsync) {
print_verbose("VSYNC: manually throttling frames using MAILBOX.");
- context_rd->set_vsync_mode(p_window_id, DisplayServer::VSYNC_MAILBOX);
+ rendering_context->window_set_vsync_mode(p_window_id, DisplayServer::VSYNC_MAILBOX);
}
}
#endif // VULKAN_ENABLED
@@ -917,8 +920,8 @@ DisplayServer::VSyncMode DisplayServerWayland::window_get_vsync_mode(DisplayServ
}
#ifdef VULKAN_ENABLED
- if (context_rd) {
- return context_rd->get_vsync_mode(p_window_id);
+ if (rendering_context) {
+ return rendering_context->window_get_vsync_mode(p_window_id);
}
#endif // VULKAN_ENABLED
@@ -1236,15 +1239,15 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
#ifdef RD_ENABLED
#ifdef VULKAN_ENABLED
if (p_rendering_driver == "vulkan") {
- context_rd = memnew(VulkanContextWayland);
+ rendering_context = memnew(RenderingContextDriverVulkanWayland);
}
#endif
- if (context_rd) {
- if (context_rd->initialize() != OK) {
- ERR_PRINT(vformat("Could not initialize %s", context_rd->get_api_name()));
- memdelete(context_rd);
- context_rd = nullptr;
+ if (rendering_context) {
+ if (rendering_context->initialize() != OK) {
+ ERR_PRINT(vformat("Could not initialize %s", p_rendering_driver));
+ memdelete(rendering_context);
+ rendering_context = nullptr;
r_error = ERR_CANT_CREATE;
return;
}
@@ -1329,9 +1332,10 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
_show_window();
#ifdef RD_ENABLED
- if (context_rd) {
+ if (rendering_context) {
rendering_device = memnew(RenderingDevice);
- rendering_device->initialize(context_rd);
+ rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
+ rendering_device->screen_create(MAIN_WINDOW_ID);
RendererCompositorRD::make_current();
}
@@ -1351,8 +1355,12 @@ DisplayServerWayland::~DisplayServerWayland() {
// TODO: Multiwindow support.
if (main_window.visible) {
#ifdef VULKAN_ENABLED
- if (context_rd) {
- context_rd->window_destroy(MAIN_WINDOW_ID);
+ if (rendering_device) {
+ rendering_device->screen_free(MAIN_WINDOW_ID);
+ }
+
+ if (rendering_context) {
+ rendering_context->window_destroy(MAIN_WINDOW_ID);
}
#endif
@@ -1374,12 +1382,11 @@ DisplayServerWayland::~DisplayServerWayland() {
// Destroy all drivers.
#ifdef RD_ENABLED
if (rendering_device) {
- rendering_device->finalize();
memdelete(rendering_device);
}
- if (context_rd) {
- memdelete(context_rd);
+ if (rendering_context) {
+ memdelete(rendering_context);
}
#endif
diff --git a/platform/linuxbsd/wayland/display_server_wayland.h b/platform/linuxbsd/wayland/display_server_wayland.h
index 3e7f3c4cb4..58c5dab586 100644
--- a/platform/linuxbsd/wayland/display_server_wayland.h
+++ b/platform/linuxbsd/wayland/display_server_wayland.h
@@ -39,7 +39,7 @@
#include "servers/rendering/rendering_device.h"
#ifdef VULKAN_ENABLED
-#include "wayland/vulkan_context_wayland.h"
+#include "wayland/rendering_context_driver_vulkan_wayland.h"
#endif
#endif //RD_ENABLED
@@ -123,7 +123,7 @@ class DisplayServerWayland : public DisplayServer {
String rendering_driver;
#ifdef RD_ENABLED
- ApiContextRD *context_rd = nullptr;
+ RenderingContextDriver *rendering_context = nullptr;
RenderingDevice *rendering_device = nullptr;
#endif
diff --git a/platform/linuxbsd/wayland/vulkan_context_wayland.cpp b/platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.cpp
index b3f28a1678..c874c45a8a 100644
--- a/platform/linuxbsd/wayland/vulkan_context_wayland.cpp
+++ b/platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.cpp
@@ -1,5 +1,5 @@
/**************************************************************************/
-/* vulkan_context_wayland.cpp */
+/* rendering_context_driver_vulkan_wayland.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,32 +28,43 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
-#include "vulkan_context_wayland.h"
-
#ifdef VULKAN_ENABLED
+#include "rendering_context_driver_vulkan_wayland.h"
+
#ifdef USE_VOLK
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
-const char *VulkanContextWayland::_get_platform_surface_extension() const {
+const char *RenderingContextDriverVulkanWayland::_get_platform_surface_extension() const {
return VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
}
-Error VulkanContextWayland::window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, int p_width, int p_height, const void *p_platform_data) {
- const WindowPlatformData *wpd = (const WindowPlatformData *)p_platform_data;
+RenderingContextDriver::SurfaceID RenderingContextDriverVulkanWayland::surface_create(const void *p_platform_data) {
+ const WindowPlatformData *wpd = (const WindowPlatformData *)(p_platform_data);
+
+ VkWaylandSurfaceCreateInfoKHR create_info = {};
+ create_info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
+ create_info.display = wpd->display;
+ create_info.surface = wpd->surface;
+
+ VkSurfaceKHR vk_surface = VK_NULL_HANDLE;
+ VkResult err = vkCreateWaylandSurfaceKHR(instance_get(), &create_info, nullptr, &vk_surface);
+ ERR_FAIL_COND_V(err != VK_SUCCESS, SurfaceID());
- VkWaylandSurfaceCreateInfoKHR createInfo = {};
- createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
- createInfo.display = wpd->display;
- createInfo.surface = wpd->surface;
+ Surface *surface = memnew(Surface);
+ surface->vk_surface = vk_surface;
+ return SurfaceID(surface);
+}
+
+RenderingContextDriverVulkanWayland::RenderingContextDriverVulkanWayland() {
+ // Does nothing.
+}
- VkSurfaceKHR surface = VK_NULL_HANDLE;
- VkResult err = vkCreateWaylandSurfaceKHR(get_instance(), &createInfo, nullptr, &surface);
- ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
- return _window_create(p_window_id, p_vsync_mode, surface, p_width, p_height);
+RenderingContextDriverVulkanWayland::~RenderingContextDriverVulkanWayland() {
+ // Does nothing.
}
#endif // VULKAN_ENABLED
diff --git a/platform/linuxbsd/wayland/vulkan_context_wayland.h b/platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.h
index b0a7d1ff87..dfebca1890 100644
--- a/platform/linuxbsd/wayland/vulkan_context_wayland.h
+++ b/platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.h
@@ -1,5 +1,5 @@
/**************************************************************************/
-/* vulkan_context_wayland.h */
+/* rendering_context_driver_vulkan_wayland.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
-#ifndef VULKAN_CONTEXT_WAYLAND_H
-#define VULKAN_CONTEXT_WAYLAND_H
+#ifndef RENDERING_CONTEXT_DRIVER_VULKAN_WAYLAND_H
+#define RENDERING_CONTEXT_DRIVER_VULKAN_WAYLAND_H
#ifdef VULKAN_ENABLED
-#include "drivers/vulkan/vulkan_context.h"
+#include "drivers/vulkan/rendering_context_driver_vulkan.h"
-class VulkanContextWayland : public VulkanContext {
- const char *_get_platform_surface_extension() const override final;
+class RenderingContextDriverVulkanWayland : public RenderingContextDriverVulkan {
+private:
+ virtual const char *_get_platform_surface_extension() const override final;
+
+protected:
+ SurfaceID surface_create(const void *p_platform_data) override final;
public:
struct WindowPlatformData {
@@ -44,9 +48,10 @@ public:
struct wl_surface *surface;
};
- Error window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, int p_width, int p_height, const void *p_platform_data) override final;
+ RenderingContextDriverVulkanWayland();
+ ~RenderingContextDriverVulkanWayland();
};
#endif // VULKAN_ENABLED
-#endif // VULKAN_CONTEXT_WAYLAND_H
+#endif // RENDERING_CONTEXT_DRIVER_VULKAN_WAYLAND_H
diff --git a/platform/linuxbsd/wayland/wayland_thread.cpp b/platform/linuxbsd/wayland/wayland_thread.cpp
index 7e96f2dd75..ae1d96a3b1 100644
--- a/platform/linuxbsd/wayland/wayland_thread.cpp
+++ b/platform/linuxbsd/wayland/wayland_thread.cpp
@@ -986,6 +986,14 @@ void WaylandThread::_wl_surface_on_leave(void *data, struct wl_surface *wl_surfa
DEBUG_LOG_WAYLAND_THREAD(vformat("Window left output %x.\n", (size_t)wl_output));
}
+// TODO: Add support to this event.
+void WaylandThread::_wl_surface_on_preferred_buffer_scale(void *data, struct wl_surface *wl_surface, int32_t factor) {
+}
+
+// TODO: Add support to this event.
+void WaylandThread::_wl_surface_on_preferred_buffer_transform(void *data, struct wl_surface *wl_surface, uint32_t transform) {
+}
+
void WaylandThread::_wl_output_on_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char *make, const char *model, int32_t transform) {
ScreenState *ss = (ScreenState *)data;
ERR_FAIL_NULL(ss);
@@ -1506,6 +1514,8 @@ void WaylandThread::_wl_pointer_on_frame(void *data, struct wl_pointer *wl_point
mm->set_relative(pd.position - old_pd.position);
mm->set_velocity((Vector2)pos_delta / time_delta);
}
+ mm->set_relative_screen_position(mm->get_relative());
+ mm->set_screen_velocity(mm->get_velocity());
Ref<InputEventMessage> msg;
msg.instantiate();
@@ -1699,6 +1709,10 @@ void WaylandThread::_wl_pointer_on_axis_discrete(void *data, struct wl_pointer *
void WaylandThread::_wl_pointer_on_axis_value120(void *data, struct wl_pointer *wl_pointer, uint32_t axis, int32_t value120) {
}
+// TODO: Add support to this event.
+void WaylandThread::_wl_pointer_on_axis_relative_direction(void *data, struct wl_pointer *wl_pointer, uint32_t axis, uint32_t direction) {
+}
+
void WaylandThread::_wl_keyboard_on_keymap(void *data, struct wl_keyboard *wl_keyboard, uint32_t format, int32_t fd, uint32_t size) {
ERR_FAIL_COND_MSG(format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, "Unsupported keymap format announced from the Wayland compositor.");
@@ -2399,11 +2413,13 @@ void WaylandThread::_wp_tablet_tool_on_frame(void *data, struct zwp_tablet_tool_
mm->set_pen_inverted(td.is_eraser);
mm->set_relative(td.position - old_td.position);
+ mm->set_relative_screen_position(mm->get_relative());
// FIXME: Stop doing this to calculate speed.
// FIXME2: It has been done, port this from the pointer logic once this works again.
Input::get_singleton()->set_mouse_position(td.position);
mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity());
+ mm->set_screen_velocity(mm->get_velocity());
Ref<InputEventMessage> inputev_msg;
inputev_msg.instantiate();
diff --git a/platform/linuxbsd/wayland/wayland_thread.h b/platform/linuxbsd/wayland/wayland_thread.h
index 43c562aade..86033c1a09 100644
--- a/platform/linuxbsd/wayland/wayland_thread.h
+++ b/platform/linuxbsd/wayland/wayland_thread.h
@@ -502,6 +502,8 @@ private:
static void _wl_surface_on_enter(void *data, struct wl_surface *wl_surface, struct wl_output *wl_output);
static void _wl_surface_on_leave(void *data, struct wl_surface *wl_surface, struct wl_output *wl_output);
+ static void _wl_surface_on_preferred_buffer_scale(void *data, struct wl_surface *wl_surface, int32_t factor);
+ static void _wl_surface_on_preferred_buffer_transform(void *data, struct wl_surface *wl_surface, uint32_t transform);
static void _frame_wl_callback_on_done(void *data, struct wl_callback *wl_callback, uint32_t callback_data);
@@ -527,6 +529,7 @@ private:
static void _wl_pointer_on_axis_stop(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis);
static void _wl_pointer_on_axis_discrete(void *data, struct wl_pointer *wl_pointer, uint32_t axis, int32_t discrete);
static void _wl_pointer_on_axis_value120(void *data, struct wl_pointer *wl_pointer, uint32_t axis, int32_t value120);
+ static void _wl_pointer_on_axis_relative_direction(void *data, struct wl_pointer *wl_pointer, uint32_t axis, uint32_t direction);
static void _wl_keyboard_on_keymap(void *data, struct wl_keyboard *wl_keyboard, uint32_t format, int32_t fd, uint32_t size);
static void _wl_keyboard_on_enter(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys);
@@ -619,6 +622,8 @@ private:
static constexpr struct wl_surface_listener wl_surface_listener = {
.enter = _wl_surface_on_enter,
.leave = _wl_surface_on_leave,
+ .preferred_buffer_scale = _wl_surface_on_preferred_buffer_scale,
+ .preferred_buffer_transform = _wl_surface_on_preferred_buffer_transform,
};
static constexpr struct wl_callback_listener frame_wl_callback_listener {
@@ -654,6 +659,7 @@ private:
.axis_stop = _wl_pointer_on_axis_stop,
.axis_discrete = _wl_pointer_on_axis_discrete,
.axis_value120 = _wl_pointer_on_axis_value120,
+ .axis_relative_direction = _wl_pointer_on_axis_relative_direction,
};
static constexpr struct wl_keyboard_listener wl_keyboard_listener = {