aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-graphics/xorg-xserver/xserver-xorg/0006-glamor-Plumb-the-pixmap-through-fbo-creation-instead.patch
blob: 66d2877c07c7a59e4dbbe3feda7466691bb0ff42 (plain)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
From 3c14a16e1b4277aa00a2b23d5758d99dc20ca819 Mon Sep 17 00:00:00 2001
From: Eric Anholt <eric@anholt.net>
Date: Tue, 26 Mar 2019 16:57:24 -0700
Subject: [PATCH 6/8] glamor: Plumb the pixmap through fbo creation instead of
 a "format"

For GLES, we're going to need a lot more logic for picking the
iformat/format/type of texture setup, so we'll want the pixmap's depth
and is_cbcr flag.

Upstream-Status: Backport
Signed-off-by: Eric Anholt <eric@anholt.net>
---
 glamor/glamor.c         | 20 +++++++-------------
 glamor/glamor_fbo.c     | 33 +++++++++++++++++++--------------
 glamor/glamor_picture.c |  2 +-
 glamor/glamor_priv.h    | 12 ++++++------
 4 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index c36b6ea74..f618c2128 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -106,7 +106,6 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
     glamor_pixmap_private *pixmap_priv;
     glamor_screen_private *glamor_priv;
     glamor_pixmap_fbo *fbo;
-    GLenum format;
 
     glamor_priv = glamor_get_screen_private(screen);
     pixmap_priv = glamor_get_pixmap_private(pixmap);
@@ -116,9 +115,9 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
         glamor_destroy_fbo(glamor_priv, fbo);
     }
 
-    format = gl_iformat_for_pixmap(pixmap);
-    fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
-                                     pixmap->drawable.height, format, tex, 0);
+    fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap,
+                                     pixmap->drawable.width,
+                                     pixmap->drawable.height, tex, 0);
 
     if (fbo == NULL) {
         ErrorF("XXX fail to create fbo.\n");
@@ -204,7 +203,6 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
     glamor_pixmap_fbo *fbo = NULL;
     int pitch;
-    GLenum format;
 
     if (w > 32767 || h > 32767)
         return NullPixmap;
@@ -223,8 +221,6 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 
     pixmap_priv->is_cbcr = (usage == GLAMOR_CREATE_FORMAT_CBCR);
 
-    format = gl_iformat_for_pixmap(pixmap);
-
     pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
     screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
 
@@ -238,12 +234,12 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
         glamor_check_fbo_size(glamor_priv, w, h))
     {
         glamor_init_pixmap_private_small(pixmap, pixmap_priv);
-        fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
+        fbo = glamor_create_fbo(glamor_priv, pixmap, w, h, usage);
     } else {
         int tile_size = glamor_priv->max_fbo_size;
         DEBUGF("Create LARGE pixmap %p width %d height %d, tile size %d\n",
                pixmap, w, h, tile_size);
-        fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage,
+        fbo = glamor_create_fbo_array(glamor_priv, pixmap, usage,
                                       tile_size, tile_size, pixmap_priv);
     }
 
@@ -860,8 +856,7 @@ _glamor_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
     switch (pixmap_priv->type) {
     case GLAMOR_TEXTURE_DRM:
     case GLAMOR_TEXTURE_ONLY:
-        if (!glamor_pixmap_ensure_fbo(pixmap, pixmap->drawable.depth == 30 ?
-                                      GL_RGB10_A2 : GL_RGBA, 0))
+        if (!glamor_pixmap_ensure_fbo(pixmap, 0))
             return 0;
 
         if (modifier) {
@@ -937,8 +932,7 @@ glamor_name_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
     switch (pixmap_priv->type) {
     case GLAMOR_TEXTURE_DRM:
     case GLAMOR_TEXTURE_ONLY:
-        if (!glamor_pixmap_ensure_fbo(pixmap, pixmap->drawable.depth == 30 ?
-                                      GL_RGB10_A2 : GL_RGBA, 0))
+        if (!glamor_pixmap_ensure_fbo(pixmap, 0))
             return -1;
         return glamor_egl_fd_name_from_pixmap(pixmap->drawable.pScreen,
                                               pixmap, stride, size);
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 58eb97bf4..75f7e2baa 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -95,8 +95,9 @@ glamor_pixmap_ensure_fb(glamor_screen_private *glamor_priv,
 
 glamor_pixmap_fbo *
 glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
-                           int w, int h, Bool is_red, GLint tex, int flag)
+                           PixmapPtr pixmap, int w, int h, GLint tex, int flag)
 {
+    GLenum format = gl_iformat_for_pixmap(pixmap);
     glamor_pixmap_fbo *fbo;
 
     fbo = calloc(1, sizeof(*fbo));
@@ -106,7 +107,7 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
     fbo->tex = tex;
     fbo->width = w;
     fbo->height = h;
-    fbo->is_red = is_red;
+    fbo->is_red = format == GL_RED;
 
     if (flag != GLAMOR_CREATE_FBO_NO_FBO) {
         if (glamor_pixmap_ensure_fb(glamor_priv, fbo) != 0) {
@@ -120,13 +121,15 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
 
 static int
 _glamor_create_tex(glamor_screen_private *glamor_priv,
-                   int w, int h, GLenum format)
+                   PixmapPtr pixmap, int w, int h)
 {
+    GLenum iformat = gl_iformat_for_pixmap(pixmap);
+    GLenum format = iformat;
     unsigned int tex;
-    GLenum iformat = format;
 
     if (format == GL_RGB10_A2)
         format = GL_RGBA;
+
     glamor_make_current(glamor_priv);
     glGenTextures(1, &tex);
     glBindTexture(GL_TEXTURE_2D, tex);
@@ -156,14 +159,14 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
 
 glamor_pixmap_fbo *
 glamor_create_fbo(glamor_screen_private *glamor_priv,
-                  int w, int h, GLenum format, int flag)
+                  PixmapPtr pixmap, int w, int h, int flag)
 {
-    GLint tex = _glamor_create_tex(glamor_priv, w, h, format);
+    GLint tex = _glamor_create_tex(glamor_priv, pixmap, w, h);
 
     if (!tex) /* Texture creation failed due to GL_OUT_OF_MEMORY */
         return NULL;
 
-    return glamor_create_fbo_from_tex(glamor_priv, w, h, format == GL_RED,
+    return glamor_create_fbo_from_tex(glamor_priv, pixmap, w, h,
                                       tex, flag);
 }
 
@@ -173,10 +176,12 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
  */
 glamor_pixmap_fbo *
 glamor_create_fbo_array(glamor_screen_private *glamor_priv,
-                         int w, int h, GLenum format, int flag,
+                        PixmapPtr pixmap, int flag,
                          int block_w, int block_h,
                          glamor_pixmap_private *priv)
 {
+    int w = pixmap->drawable.width;
+    int h = pixmap->drawable.height;
     int block_wcnt;
     int block_hcnt;
     glamor_pixmap_fbo **fbo_array;
@@ -216,8 +221,8 @@ glamor_create_fbo_array(glamor_screen_private *glamor_priv,
                 box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt +
                                                              j].x1;
             fbo_array[i * block_wcnt + j] = glamor_create_fbo(glamor_priv,
+                                                              pixmap,
                                                               fbo_w, fbo_h,
-                                                              format,
                                                               GLAMOR_CREATE_PIXMAP_FIXUP);
             if (fbo_array[i * block_wcnt + j] == NULL)
                 goto cleanup;
@@ -315,7 +320,7 @@ glamor_pixmap_destroy_fbo(PixmapPtr pixmap)
 }
 
 Bool
-glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
+glamor_pixmap_ensure_fbo(PixmapPtr pixmap, int flag)
 {
     glamor_screen_private *glamor_priv;
     glamor_pixmap_private *pixmap_priv;
@@ -325,8 +330,8 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
     pixmap_priv = glamor_get_pixmap_private(pixmap);
     if (pixmap_priv->fbo == NULL) {
 
-        fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
-                                pixmap->drawable.height, format, flag);
+        fbo = glamor_create_fbo(glamor_priv, pixmap, pixmap->drawable.width,
+                                pixmap->drawable.height, flag);
         if (fbo == NULL)
             return FALSE;
 
@@ -336,8 +341,8 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
         /* We do have a fbo, but it may lack of fb or tex. */
         if (!pixmap_priv->fbo->tex)
             pixmap_priv->fbo->tex =
-                _glamor_create_tex(glamor_priv, pixmap->drawable.width,
-                                   pixmap->drawable.height, format);
+                _glamor_create_tex(glamor_priv, pixmap, pixmap->drawable.width,
+                                   pixmap->drawable.height);
 
         if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->fbo->fb == 0)
             if (glamor_pixmap_ensure_fb(glamor_priv, pixmap_priv->fbo) != 0)
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 685d8d618..e6d387d42 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -340,7 +340,7 @@ glamor_upload_picture_to_texture(PicturePtr picture)
     else
         iformat = format;
 
-    if (!glamor_pixmap_ensure_fbo(pixmap, iformat, GLAMOR_CREATE_FBO_NO_FBO)) {
+    if (!glamor_pixmap_ensure_fbo(pixmap, GLAMOR_CREATE_FBO_NO_FBO)) {
         ret = FALSE;
         goto fail;
     }
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index e70d349da..a87caec9b 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -531,11 +531,11 @@ glamor_pixmap_fbo *glamor_pixmap_detach_fbo(glamor_pixmap_private *
                                             pixmap_priv);
 void glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo);
 glamor_pixmap_fbo *glamor_create_fbo_from_tex(glamor_screen_private *
-                                              glamor_priv, int w, int h,
-                                              Bool is_red, GLint tex,
+                                              glamor_priv, PixmapPtr pixmap,
+                                              int w, int h, GLint tex,
                                               int flag);
-glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv, int w,
-                                     int h, GLenum format, int flag);
+glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv,
+                                     PixmapPtr pixmap, int w, int h, int flag);
 void glamor_destroy_fbo(glamor_screen_private *glamor_priv,
                         glamor_pixmap_fbo *fbo);
 void glamor_pixmap_destroy_fbo(PixmapPtr pixmap);
@@ -563,7 +563,7 @@ void glamor_bind_texture(glamor_screen_private *glamor_priv,
                          Bool destination_red);
 
 glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv,
-                                           int w, int h, GLenum format,
+                                           PixmapPtr pixmap,
                                            int flag, int block_w, int block_h,
                                            glamor_pixmap_private *);
 
@@ -673,7 +673,7 @@ glamor_put_vbo_space(ScreenPtr screen);
  * the fbo has valid texture and attach to a valid fb.
  * If the fbo already has a valid glfbo then do nothing.
  */
-Bool glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag);
+Bool glamor_pixmap_ensure_fbo(PixmapPtr pixmap, int flag);
 
 glamor_pixmap_clipped_regions *
 glamor_compute_clipped_regions(PixmapPtr pixmap,
-- 
2.17.1