-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0042-egl-wayland-a-linear-buffer-is-not-needed-with-DRM-f.patch
129 lines (112 loc) · 4.97 KB
/
0042-egl-wayland-a-linear-buffer-is-not-needed-with-DRM-f.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
From f1c1b4c0662caa33e42ab51c323b4d1a92366333 Mon Sep 17 00:00:00 2001
From: Brendan King <[email protected]>
Date: Wed, 28 Apr 2021 10:57:15 +0100
Subject: [PATCH] egl/wayland: a linear buffer is not needed with DRM format
modifiers
If the compositor supports DRM format modifiers, there is no
need for an additional linear buffer, as the client can allocate
buffers with attributes known to the compositor.
---
src/egl/drivers/dri2/platform_wayland.c | 36 ++++++++++++++-----------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index d651274..64c7a42 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1014,7 +1014,7 @@ create_dri_image_diff_gpu(struct dri2_egl_surface *dri2_surf,
&linear_mod, 1, NULL);
}
-static void
+static bool
create_dri_image_from_dmabuf_feedback(struct dri2_egl_surface *dri2_surf,
unsigned int dri_image_format, uint32_t use_flags)
{
@@ -1027,7 +1027,7 @@ create_dri_image_from_dmabuf_feedback(struct dri2_egl_surface *dri2_surf,
/* We don't have valid dma-buf feedback, so return */
if (dri2_surf->dmabuf_feedback.main_device == 0)
- return;
+ return false;
visual_idx = dri2_wl_visual_idx_from_fourcc(dri2_surf->format);
assert(visual_idx != -1);
@@ -1071,11 +1071,13 @@ create_dri_image_from_dmabuf_feedback(struct dri2_egl_surface *dri2_surf,
modifiers, num_modifiers, NULL);
if (dri2_surf->back->dri_image)
- return;
+ return num_modifiers != 0;
}
+
+ return false;
}
-static void
+static bool
create_dri_image(struct dri2_egl_surface *dri2_surf,
unsigned int dri_image_format, uint32_t use_flags)
{
@@ -1107,6 +1109,8 @@ create_dri_image(struct dri2_egl_surface *dri2_surf,
dri_image_format,
dri2_dpy->is_different_gpu ? 0 : use_flags,
modifiers, num_modifiers, NULL);
+
+ return num_modifiers != 0;
}
static int
@@ -1118,6 +1122,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
int visual_idx;
unsigned int dri_image_format;
unsigned int linear_dri_image_format;
+ bool have_modifiers = false;
visual_idx = dri2_wl_visual_idx_from_fourcc(dri2_surf->format);
assert(visual_idx != -1);
@@ -1177,23 +1182,24 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
use_flags |= __DRI_IMAGE_USE_PROTECTED;
}
- if (dri2_dpy->is_different_gpu && dri2_surf->back->linear_copy == NULL) {
- create_dri_image_diff_gpu(dri2_surf, linear_dri_image_format, use_flags);
- if (dri2_surf->back->linear_copy == NULL)
- return -1;
- }
-
if (dri2_surf->back->dri_image == NULL) {
if (dri2_surf->wl_dmabuf_feedback)
- create_dri_image_from_dmabuf_feedback(dri2_surf, dri_image_format, use_flags);
+ have_modifiers = create_dri_image_from_dmabuf_feedback(dri2_surf, dri_image_format, use_flags);
if (dri2_surf->back->dri_image == NULL)
- create_dri_image(dri2_surf, dri_image_format, use_flags);
+ have_modifiers = create_dri_image(dri2_surf, dri_image_format, use_flags);
dri2_surf->back->age = 0;
}
if (dri2_surf->back->dri_image == NULL)
return -1;
+ if (dri2_dpy->is_different_gpu && !have_modifiers &&
+ dri2_surf->back->linear_copy == NULL) {
+ create_dri_image_diff_gpu(dri2_surf, linear_dri_image_format, use_flags);
+ if (dri2_surf->back->linear_copy == NULL)
+ return -1;
+ }
+
dri2_surf->back->locked = true;
return 0;
@@ -1283,7 +1289,7 @@ update_buffers(struct dri2_egl_display *dri2_dpy,
dri2_surf->color_buffers[i].age > BUFFER_TRIM_AGE_HYSTERESIS) {
wl_buffer_destroy(dri2_surf->color_buffers[i].wl_buffer);
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].dri_image);
- if (dri2_dpy->is_different_gpu)
+ if (dri2_surf->color_buffers[i].linear_copy)
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].linear_copy);
dri2_surf->color_buffers[i].wl_buffer = NULL;
dri2_surf->color_buffers[i].dri_image = NULL;
@@ -1700,7 +1706,7 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp,
if (!dri2_surf->current->wl_buffer) {
__DRIimage *image;
- if (dri2_dpy->is_different_gpu)
+ if (dri2_surf->current->linear_copy)
image = dri2_surf->current->linear_copy;
else
image = dri2_surf->current->dri_image;
@@ -1734,7 +1740,7 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp,
dri2_flush_drawable_for_swapbuffers(disp, draw);
- if (dri2_dpy->is_different_gpu) {
+ if (dri2_surf->current->linear_copy) {
_EGLContext *ctx = _eglGetCurrentContext();
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
dri2_dpy->image->blitImage(dri2_ctx->dri_context,