diff options
Diffstat (limited to 'recipes-graphics/xorg-xserver/xserver-xorg/0008-glamor-Introduce-a-central-place-for-our-pixmap-form.patch')
-rw-r--r-- | recipes-graphics/xorg-xserver/xserver-xorg/0008-glamor-Introduce-a-central-place-for-our-pixmap-form.patch | 669 |
1 files changed, 669 insertions, 0 deletions
diff --git a/recipes-graphics/xorg-xserver/xserver-xorg/0008-glamor-Introduce-a-central-place-for-our-pixmap-form.patch b/recipes-graphics/xorg-xserver/xserver-xorg/0008-glamor-Introduce-a-central-place-for-our-pixmap-form.patch new file mode 100644 index 00000000..dd82340a --- /dev/null +++ b/recipes-graphics/xorg-xserver/xserver-xorg/0008-glamor-Introduce-a-central-place-for-our-pixmap-form.patch | |||
@@ -0,0 +1,669 @@ | |||
1 | From b75296bee6ab3578f3a13cfb6de5d77ec02b9047 Mon Sep 17 00:00:00 2001 | ||
2 | From: Eric Anholt <eric@anholt.net> | ||
3 | Date: Tue, 26 Mar 2019 15:10:49 -0700 | ||
4 | Subject: [PATCH 8/8] glamor: Introduce a central place for our pixmap | ||
5 | format/type handling. | ||
6 | |||
7 | We had various helper functions trying to come up with the | ||
8 | internalformat/format/type/render formats for pixmaps, and it's much | ||
9 | nicer to just detect what those should be once at startup. This gives | ||
10 | us a chance to do the right thing for GLES. | ||
11 | |||
12 | It also, notably, fixes our format/type for depth 15 and 16 setup for | ||
13 | desktop GL, so that we actually allocate 16bpp (GL_RGB/565) on most | ||
14 | drivers instead of 32bpp (GL_RGB/UBYTE). | ||
15 | |||
16 | GLES still has regressions over desktop (2 regressions in llvmpipe | ||
17 | XTS, many in rendercheck), but I think this is a good baseline. | ||
18 | |||
19 | Upstream-Status: Backport | ||
20 | Signed-off-by: Eric Anholt <eric@anholt.net> | ||
21 | --- | ||
22 | glamor/glamor.c | 167 ++++++++++++++++++++++++++++++++++++-- | ||
23 | glamor/glamor_fbo.c | 16 ++-- | ||
24 | glamor/glamor_picture.c | 7 +- | ||
25 | glamor/glamor_priv.h | 22 ++++- | ||
26 | glamor/glamor_render.c | 7 +- | ||
27 | glamor/glamor_spans.c | 14 ++-- | ||
28 | glamor/glamor_transfer.c | 56 ++----------- | ||
29 | glamor/glamor_transfer.h | 3 - | ||
30 | glamor/glamor_transform.c | 5 +- | ||
31 | glamor/glamor_utils.h | 57 ------------- | ||
32 | 10 files changed, 209 insertions(+), 145 deletions(-) | ||
33 | |||
34 | diff --git a/glamor/glamor.c b/glamor/glamor.c | ||
35 | index 019edbbb1..3450113e0 100644 | ||
36 | --- a/glamor/glamor.c | ||
37 | +++ b/glamor/glamor.c | ||
38 | @@ -212,7 +212,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, | ||
39 | w <= glamor_priv->glyph_max_dim && | ||
40 | h <= glamor_priv->glyph_max_dim) | ||
41 | || (w == 0 && h == 0) | ||
42 | - || !glamor_check_pixmap_fbo_depth(depth))) | ||
43 | + || !glamor_priv->formats[depth].format)) | ||
44 | return fbCreatePixmap(screen, w, h, depth, usage); | ||
45 | else | ||
46 | pixmap = fbCreatePixmap(screen, 0, 0, depth, usage); | ||
47 | @@ -440,6 +440,165 @@ glamor_setup_debug_output(ScreenPtr screen) | ||
48 | glEnable(GL_DEBUG_OUTPUT); | ||
49 | } | ||
50 | |||
51 | +const struct glamor_format * | ||
52 | +glamor_format_for_pixmap(PixmapPtr pixmap) | ||
53 | +{ | ||
54 | + ScreenPtr pScreen = pixmap->drawable.pScreen; | ||
55 | + glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen); | ||
56 | + glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); | ||
57 | + | ||
58 | + if (pixmap_priv->is_cbcr) | ||
59 | + return &glamor_priv->cbcr_format; | ||
60 | + else | ||
61 | + return &glamor_priv->formats[pixmap->drawable.depth]; | ||
62 | +} | ||
63 | + | ||
64 | +static void | ||
65 | +glamor_add_format(ScreenPtr screen, int depth, CARD32 render_format, | ||
66 | + GLenum internalformat, GLenum format, GLenum type) | ||
67 | +{ | ||
68 | + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); | ||
69 | + struct glamor_format *f = &glamor_priv->formats[depth]; | ||
70 | + | ||
71 | + /* If we're trying to run on GLES, make sure that we get the read | ||
72 | + * formats that we're expecting, since glamor_transfer relies on | ||
73 | + * them matching to get data back out. To avoid this limitation, we | ||
74 | + * would need to have a more general glReadPixels() path in | ||
75 | + * glamor_transfer that re-encoded the bits to the pixel format that | ||
76 | + * we intended after. | ||
77 | + * | ||
78 | + * Note that we can't just create a pixmap because we're in | ||
79 | + * screeninit. | ||
80 | + */ | ||
81 | + if (glamor_priv->is_gles) { | ||
82 | + unsigned fbo, tex; | ||
83 | + int read_format, read_type; | ||
84 | + GLenum status; | ||
85 | + | ||
86 | + glGenTextures(1, &tex); | ||
87 | + glBindTexture(GL_TEXTURE_2D, tex); | ||
88 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||
89 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||
90 | + glTexImage2D(GL_TEXTURE_2D, 0, internalformat, 1, 1, 0, | ||
91 | + format, type, NULL); | ||
92 | + | ||
93 | + glGenFramebuffers(1, &fbo); | ||
94 | + glBindFramebuffer(GL_FRAMEBUFFER, fbo); | ||
95 | + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | ||
96 | + GL_TEXTURE_2D, tex, 0); | ||
97 | + status = glCheckFramebufferStatus(GL_FRAMEBUFFER); | ||
98 | + if (status != GL_FRAMEBUFFER_COMPLETE) { | ||
99 | + ErrorF("glamor: Test fbo for depth %d incomplete. " | ||
100 | + "Falling back to software.\n", depth); | ||
101 | + glDeleteTextures(1, &tex); | ||
102 | + glDeleteFramebuffers(1, &fbo); | ||
103 | + return; | ||
104 | + } | ||
105 | + | ||
106 | + glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &read_format); | ||
107 | + glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &read_type); | ||
108 | + | ||
109 | + glDeleteTextures(1, &tex); | ||
110 | + glDeleteFramebuffers(1, &fbo); | ||
111 | + | ||
112 | + if (format != read_format || type != read_type) { | ||
113 | + ErrorF("glamor: Implementation returned 0x%x/0x%x read format/type " | ||
114 | + "for depth %d, expected 0x%x/0x%x. " | ||
115 | + "Falling back to software.\n", | ||
116 | + read_format, read_type, depth, format, type); | ||
117 | + return; | ||
118 | + } | ||
119 | + } | ||
120 | + | ||
121 | + f->depth = depth; | ||
122 | + f->render_format = render_format; | ||
123 | + f->internalformat = internalformat; | ||
124 | + f->format = format; | ||
125 | + f->type = type; | ||
126 | +} | ||
127 | + | ||
128 | +/* Set up the GL format/types that glamor will use for the various depths | ||
129 | + * | ||
130 | + * X11's pixel data doesn't have channels, but to store our data in GL | ||
131 | + * we have to pick some sort of format to move X11 pixel data in and | ||
132 | + * out with in glamor_transfer.c. For X11 core operations, other than | ||
133 | + * GL logic ops (non-GXcopy GC ops) what the driver chooses internally | ||
134 | + * doesn't matter as long as it doesn't drop any bits (we expect them | ||
135 | + * to generally expand, if anything). For Render, we can expect | ||
136 | + * clients to tend to render with PictFormats matching our channel | ||
137 | + * layouts here since ultimately X11 pixels tend to end up on the | ||
138 | + * screen. The render implementation will fall back to fb if the | ||
139 | + * channels don't match. | ||
140 | + * | ||
141 | + * Note that these formats don't affect what glamor_egl.c or | ||
142 | + * Xwayland's EGL layer choose for surfaces exposed through DRI or | ||
143 | + * scanout. For now, those layers need to match what we're choosing | ||
144 | + * here, or channels will end up swizzled around. Similarly, the | ||
145 | + * driver's visual masks also need to match what we're doing here. | ||
146 | + */ | ||
147 | +static void | ||
148 | +glamor_setup_formats(ScreenPtr screen) | ||
149 | +{ | ||
150 | + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); | ||
151 | + | ||
152 | + /* Prefer r8 textures since they're required by GLES3 and core, | ||
153 | + * only falling back to a8 if we can't do them. | ||
154 | + */ | ||
155 | + if (glamor_priv->is_gles || epoxy_has_gl_extension("GL_ARB_texture_rg")) { | ||
156 | + glamor_add_format(screen, 8, PICT_a8, | ||
157 | + GL_R8, GL_RED, GL_UNSIGNED_BYTE); | ||
158 | + } else { | ||
159 | + glamor_add_format(screen, 8, PICT_a8, | ||
160 | + GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE); | ||
161 | + } | ||
162 | + | ||
163 | + if (glamor_priv->is_gles) { | ||
164 | + /* For 15bpp, GLES supports format/type RGBA/5551, rather than | ||
165 | + * bgra/1555_rev. GL_EXT_bgra lets the impl say the color | ||
166 | + * read format/type is bgra/1555 even if we had to create it | ||
167 | + * with rgba/5551, with Mesa does. That means we can't use | ||
168 | + * the same format/type for TexSubImage and readpixels. | ||
169 | + * | ||
170 | + * Instead, just store 16 bits using the trusted 565 path, and | ||
171 | + * disable render accel for now. | ||
172 | + */ | ||
173 | + glamor_add_format(screen, 15, PICT_x1r5g5b5, | ||
174 | + GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1); | ||
175 | + } else { | ||
176 | + glamor_add_format(screen, 15, PICT_x1r5g5b5, | ||
177 | + GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV); | ||
178 | + } | ||
179 | + | ||
180 | + glamor_add_format(screen, 16, PICT_r5g6b5, | ||
181 | + GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5); | ||
182 | + | ||
183 | + if (glamor_priv->is_gles) { | ||
184 | + assert(X_BYTE_ORDER == X_LITTLE_ENDIAN); | ||
185 | + glamor_add_format(screen, 24, PICT_x8b8g8r8, | ||
186 | + GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE); | ||
187 | + glamor_add_format(screen, 32, PICT_a8b8g8r8, | ||
188 | + GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE); | ||
189 | + } else { | ||
190 | + glamor_add_format(screen, 24, PICT_x8r8g8b8, | ||
191 | + GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV); | ||
192 | + glamor_add_format(screen, 32, PICT_a8r8g8b8, | ||
193 | + GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV); | ||
194 | + } | ||
195 | + | ||
196 | + if (glamor_priv->is_gles) { | ||
197 | + glamor_add_format(screen, 30, PICT_x2b10g10r10, | ||
198 | + GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV); | ||
199 | + } else { | ||
200 | + glamor_add_format(screen, 30, PICT_x2r10g10b10, | ||
201 | + GL_RGB10_A2, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV); | ||
202 | + } | ||
203 | + | ||
204 | + glamor_priv->cbcr_format.depth = 16; | ||
205 | + glamor_priv->cbcr_format.internalformat = GL_RG8; | ||
206 | + glamor_priv->cbcr_format.format = GL_RG; | ||
207 | + glamor_priv->cbcr_format.type = GL_UNSIGNED_BYTE; | ||
208 | +} | ||
209 | + | ||
210 | /** Set up glamor for an already-configured GL context. */ | ||
211 | Bool | ||
212 | glamor_init(ScreenPtr screen, unsigned int flags) | ||
213 | @@ -665,11 +824,7 @@ glamor_init(ScreenPtr screen, unsigned int flags) | ||
214 | (epoxy_has_gl_extension("GL_ARB_texture_swizzle") || | ||
215 | (glamor_priv->is_gles && gl_version >= 30)); | ||
216 | |||
217 | - glamor_priv->one_channel_format = GL_ALPHA; | ||
218 | - if (epoxy_has_gl_extension("GL_ARB_texture_rg") && | ||
219 | - glamor_priv->has_texture_swizzle) { | ||
220 | - glamor_priv->one_channel_format = GL_RED; | ||
221 | - } | ||
222 | + glamor_setup_formats(screen); | ||
223 | |||
224 | glamor_set_debug_level(&glamor_debug_level); | ||
225 | |||
226 | diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c | ||
227 | index 75f7e2baa..dfb3f754d 100644 | ||
228 | --- a/glamor/glamor_fbo.c | ||
229 | +++ b/glamor/glamor_fbo.c | ||
230 | @@ -97,7 +97,7 @@ glamor_pixmap_fbo * | ||
231 | glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv, | ||
232 | PixmapPtr pixmap, int w, int h, GLint tex, int flag) | ||
233 | { | ||
234 | - GLenum format = gl_iformat_for_pixmap(pixmap); | ||
235 | + const struct glamor_format *f = glamor_format_for_pixmap(pixmap); | ||
236 | glamor_pixmap_fbo *fbo; | ||
237 | |||
238 | fbo = calloc(1, sizeof(*fbo)); | ||
239 | @@ -107,7 +107,7 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv, | ||
240 | fbo->tex = tex; | ||
241 | fbo->width = w; | ||
242 | fbo->height = h; | ||
243 | - fbo->is_red = format == GL_RED; | ||
244 | + fbo->is_red = f->format == GL_RED; | ||
245 | |||
246 | if (flag != GLAMOR_CREATE_FBO_NO_FBO) { | ||
247 | if (glamor_pixmap_ensure_fb(glamor_priv, fbo) != 0) { | ||
248 | @@ -123,23 +123,19 @@ static int | ||
249 | _glamor_create_tex(glamor_screen_private *glamor_priv, | ||
250 | PixmapPtr pixmap, int w, int h) | ||
251 | { | ||
252 | - GLenum iformat = gl_iformat_for_pixmap(pixmap); | ||
253 | - GLenum format = iformat; | ||
254 | + const struct glamor_format *f = glamor_format_for_pixmap(pixmap); | ||
255 | unsigned int tex; | ||
256 | |||
257 | - if (format == GL_RGB10_A2) | ||
258 | - format = GL_RGBA; | ||
259 | - | ||
260 | glamor_make_current(glamor_priv); | ||
261 | glGenTextures(1, &tex); | ||
262 | glBindTexture(GL_TEXTURE_2D, tex); | ||
263 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||
264 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||
265 | - if (format == glamor_priv->one_channel_format && format == GL_RED) | ||
266 | + if (f->format == GL_RED) | ||
267 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED); | ||
268 | glamor_priv->suppress_gl_out_of_memory_logging = true; | ||
269 | - glTexImage2D(GL_TEXTURE_2D, 0, iformat, w, h, 0, | ||
270 | - format, GL_UNSIGNED_BYTE, NULL); | ||
271 | + glTexImage2D(GL_TEXTURE_2D, 0, f->internalformat, w, h, 0, | ||
272 | + f->format, f->type, NULL); | ||
273 | glamor_priv->suppress_gl_out_of_memory_logging = false; | ||
274 | |||
275 | if (glGetError() == GL_OUT_OF_MEMORY) { | ||
276 | diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c | ||
277 | index ed2decc83..33b3bebd9 100644 | ||
278 | --- a/glamor/glamor_picture.c | ||
279 | +++ b/glamor/glamor_picture.c | ||
280 | @@ -83,7 +83,7 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr pScreen, | ||
281 | |||
282 | switch (format) { | ||
283 | case PICT_a1: | ||
284 | - *tex_format = glamor_priv->one_channel_format; | ||
285 | + *tex_format = glamor_priv->formats[1].format; | ||
286 | *tex_type = GL_UNSIGNED_BYTE; | ||
287 | *temp_format = PICT_a8; | ||
288 | break; | ||
289 | @@ -195,7 +195,7 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr pScreen, | ||
290 | break; | ||
291 | |||
292 | case PICT_a8: | ||
293 | - *tex_format = glamor_priv->one_channel_format; | ||
294 | + *tex_format = glamor_priv->formats[8].format; | ||
295 | *tex_type = GL_UNSIGNED_BYTE; | ||
296 | break; | ||
297 | |||
298 | @@ -286,6 +286,7 @@ glamor_upload_picture_to_texture(PicturePtr picture) | ||
299 | Bool ret = TRUE; | ||
300 | Bool needs_swizzle; | ||
301 | pixman_image_t *converted_image = NULL; | ||
302 | + const struct glamor_format *f = glamor_format_for_pixmap(pixmap); | ||
303 | |||
304 | assert(glamor_pixmap_is_memory(pixmap)); | ||
305 | assert(!pixmap_priv->fbo); | ||
306 | @@ -336,7 +337,7 @@ glamor_upload_picture_to_texture(PicturePtr picture) | ||
307 | } | ||
308 | |||
309 | if (!glamor_priv->is_gles) | ||
310 | - iformat = gl_iformat_for_pixmap(pixmap); | ||
311 | + iformat = f->internalformat; | ||
312 | else | ||
313 | iformat = format; | ||
314 | |||
315 | diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h | ||
316 | index 8e8433ff3..b8e2b932e 100644 | ||
317 | --- a/glamor/glamor_priv.h | ||
318 | +++ b/glamor/glamor_priv.h | ||
319 | @@ -157,6 +157,21 @@ struct glamor_pixmap_private; | ||
320 | |||
321 | #define GLAMOR_COMPOSITE_VBO_VERT_CNT (64*1024) | ||
322 | |||
323 | +struct glamor_format { | ||
324 | + /** X Server's "depth" value */ | ||
325 | + int depth; | ||
326 | + /** GL internalformat for creating textures of this type */ | ||
327 | + GLenum internalformat; | ||
328 | + /** GL format transferring pixels in/out of textures of this type. */ | ||
329 | + GLenum format; | ||
330 | + /** GL type transferring pixels in/out of textures of this type. */ | ||
331 | + GLenum type; | ||
332 | + /* Render PICT_* matching GL's channel layout for pixels | ||
333 | + * transferred using format/type. | ||
334 | + */ | ||
335 | + CARD32 render_format; | ||
336 | +}; | ||
337 | + | ||
338 | struct glamor_saved_procs { | ||
339 | CloseScreenProcPtr close_screen; | ||
340 | CreateGCProcPtr create_gc; | ||
341 | @@ -199,7 +214,8 @@ typedef struct glamor_screen_private { | ||
342 | Bool can_copyplane; | ||
343 | int max_fbo_size; | ||
344 | |||
345 | - GLuint one_channel_format; | ||
346 | + struct glamor_format formats[33]; | ||
347 | + struct glamor_format cbcr_format; | ||
348 | |||
349 | /* glamor point shader */ | ||
350 | glamor_program point_prog; | ||
351 | @@ -537,6 +553,8 @@ void glamor_pixmap_destroy_fbo(PixmapPtr pixmap); | ||
352 | Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap); | ||
353 | void glamor_pixmap_clear_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *fbo); | ||
354 | |||
355 | +const struct glamor_format *glamor_format_for_pixmap(PixmapPtr pixmap); | ||
356 | + | ||
357 | /* Return whether 'picture' is alpha-only */ | ||
358 | static inline Bool glamor_picture_is_alpha(PicturePtr picture) | ||
359 | { | ||
360 | @@ -549,7 +567,7 @@ glamor_picture_red_is_alpha(PicturePtr picture) | ||
361 | { | ||
362 | /* True when the picture is alpha only and the screen is using GL_RED for alpha pictures */ | ||
363 | return glamor_picture_is_alpha(picture) && | ||
364 | - glamor_get_screen_private(picture->pDrawable->pScreen)->one_channel_format == GL_RED; | ||
365 | + glamor_get_screen_private(picture->pDrawable->pScreen)->formats[8].format == GL_RED; | ||
366 | } | ||
367 | |||
368 | void glamor_bind_texture(glamor_screen_private *glamor_priv, | ||
369 | diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c | ||
370 | index d3859e4d1..a8dc3924b 100644 | ||
371 | --- a/glamor/glamor_render.c | ||
372 | +++ b/glamor/glamor_render.c | ||
373 | @@ -772,12 +772,15 @@ static Bool | ||
374 | glamor_render_format_is_supported(PicturePtr picture) | ||
375 | { | ||
376 | PictFormatShort storage_format; | ||
377 | + glamor_screen_private *glamor_priv; | ||
378 | |||
379 | /* Source-only pictures should always work */ | ||
380 | if (!picture->pDrawable) | ||
381 | return TRUE; | ||
382 | |||
383 | - storage_format = format_for_depth(picture->pDrawable->depth); | ||
384 | + glamor_priv = glamor_get_screen_private(picture->pDrawable->pScreen); | ||
385 | + storage_format = | ||
386 | + glamor_priv->formats[picture->pDrawable->depth].render_format; | ||
387 | |||
388 | switch (picture->format) { | ||
389 | case PICT_x2r10g10b10: | ||
390 | @@ -898,7 +901,7 @@ glamor_composite_choose_shader(CARD8 op, | ||
391 | } | ||
392 | |||
393 | if (dest_pixmap->drawable.bitsPerPixel <= 8 && | ||
394 | - glamor_priv->one_channel_format == GL_RED) { | ||
395 | + glamor_priv->formats[8].format == GL_RED) { | ||
396 | key.dest_swizzle = SHADER_DEST_SWIZZLE_ALPHA_TO_RED; | ||
397 | } else { | ||
398 | key.dest_swizzle = SHADER_DEST_SWIZZLE_DEFAULT; | ||
399 | diff --git a/glamor/glamor_spans.c b/glamor/glamor_spans.c | ||
400 | index b3c028d67..b5f297d2f 100644 | ||
401 | --- a/glamor/glamor_spans.c | ||
402 | +++ b/glamor/glamor_spans.c | ||
403 | @@ -187,9 +187,8 @@ glamor_get_spans_gl(DrawablePtr drawable, int wmax, | ||
404 | int box_index; | ||
405 | int n; | ||
406 | char *d; | ||
407 | - GLenum type; | ||
408 | - GLenum format; | ||
409 | int off_x, off_y; | ||
410 | + const struct glamor_format *f = glamor_format_for_pixmap(pixmap); | ||
411 | |||
412 | pixmap_priv = glamor_get_pixmap_private(pixmap); | ||
413 | if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) | ||
414 | @@ -197,8 +196,6 @@ glamor_get_spans_gl(DrawablePtr drawable, int wmax, | ||
415 | |||
416 | glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y); | ||
417 | |||
418 | - glamor_format_for_pixmap(pixmap, &format, &type); | ||
419 | - | ||
420 | glamor_make_current(glamor_priv); | ||
421 | |||
422 | glamor_pixmap_loop(pixmap_priv, box_index) { | ||
423 | @@ -234,7 +231,8 @@ glamor_get_spans_gl(DrawablePtr drawable, int wmax, | ||
424 | if (y >= box->y2) | ||
425 | continue; | ||
426 | |||
427 | - glReadPixels(x1 - box->x1, y - box->y1, x2 - x1, 1, format, type, l); | ||
428 | + glReadPixels(x1 - box->x1, y - box->y1, x2 - x1, 1, | ||
429 | + f->format, f->type, l); | ||
430 | } | ||
431 | } | ||
432 | |||
433 | @@ -269,11 +267,10 @@ glamor_set_spans_gl(DrawablePtr drawable, GCPtr gc, char *src, | ||
434 | glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); | ||
435 | PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); | ||
436 | glamor_pixmap_private *pixmap_priv; | ||
437 | + const struct glamor_format *f = glamor_format_for_pixmap(pixmap); | ||
438 | int box_index; | ||
439 | int n; | ||
440 | char *s; | ||
441 | - GLenum type; | ||
442 | - GLenum format; | ||
443 | int off_x, off_y; | ||
444 | |||
445 | pixmap_priv = glamor_get_pixmap_private(pixmap); | ||
446 | @@ -287,7 +284,6 @@ glamor_set_spans_gl(DrawablePtr drawable, GCPtr gc, char *src, | ||
447 | goto bail; | ||
448 | |||
449 | glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y); | ||
450 | - glamor_format_for_pixmap(pixmap, &format, &type); | ||
451 | |||
452 | glamor_make_current(glamor_priv); | ||
453 | |||
454 | @@ -348,7 +344,7 @@ glamor_set_spans_gl(DrawablePtr drawable, GCPtr gc, char *src, | ||
455 | |||
456 | glTexSubImage2D(GL_TEXTURE_2D, 0, | ||
457 | x1 - box->x1, y1 - box->y1, x2 - x1, 1, | ||
458 | - format, type, | ||
459 | + f->format, f->type, | ||
460 | l); | ||
461 | } | ||
462 | s += PixmapBytePad(w, drawable->depth); | ||
463 | diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c | ||
464 | index 215752d7b..e706e0fb4 100644 | ||
465 | --- a/glamor/glamor_transfer.c | ||
466 | +++ b/glamor/glamor_transfer.c | ||
467 | @@ -23,44 +23,6 @@ | ||
468 | #include "glamor_priv.h" | ||
469 | #include "glamor_transfer.h" | ||
470 | |||
471 | -/* XXX a kludge for now */ | ||
472 | -void | ||
473 | -glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type) | ||
474 | -{ | ||
475 | - glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); | ||
476 | - switch (pixmap->drawable.depth) { | ||
477 | - case 24: | ||
478 | - case 32: | ||
479 | - *format = GL_BGRA; | ||
480 | - *type = GL_UNSIGNED_INT_8_8_8_8_REV; | ||
481 | - break; | ||
482 | - case 30: | ||
483 | - *format = GL_BGRA; | ||
484 | - *type = GL_UNSIGNED_INT_2_10_10_10_REV; | ||
485 | - break; | ||
486 | - case 16: | ||
487 | - if (priv->is_cbcr) { | ||
488 | - *format = GL_RG; | ||
489 | - *type = GL_UNSIGNED_BYTE; | ||
490 | - } else { | ||
491 | - *format = GL_RGB; | ||
492 | - *type = GL_UNSIGNED_SHORT_5_6_5; | ||
493 | - } | ||
494 | - break; | ||
495 | - case 15: | ||
496 | - *format = GL_BGRA; | ||
497 | - *type = GL_UNSIGNED_SHORT_1_5_5_5_REV; | ||
498 | - break; | ||
499 | - case 8: | ||
500 | - *format = glamor_get_screen_private(pixmap->drawable.pScreen)->one_channel_format; | ||
501 | - *type = GL_UNSIGNED_BYTE; | ||
502 | - break; | ||
503 | - default: | ||
504 | - FatalError("Invalid pixmap depth %d\n", pixmap->drawable.depth); | ||
505 | - break; | ||
506 | - } | ||
507 | -} | ||
508 | - | ||
509 | /* | ||
510 | * Write a region of bits into a pixmap | ||
511 | */ | ||
512 | @@ -75,10 +37,7 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox, | ||
513 | glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); | ||
514 | int box_index; | ||
515 | int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3; | ||
516 | - GLenum type; | ||
517 | - GLenum format; | ||
518 | - | ||
519 | - glamor_format_for_pixmap(pixmap, &format, &type); | ||
520 | + const struct glamor_format *f = glamor_format_for_pixmap(pixmap); | ||
521 | |||
522 | glamor_make_current(glamor_priv); | ||
523 | |||
524 | @@ -116,14 +75,14 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox, | ||
525 | glTexSubImage2D(GL_TEXTURE_2D, 0, | ||
526 | x1 - box->x1, y1 - box->y1, | ||
527 | x2 - x1, y2 - y1, | ||
528 | - format, type, | ||
529 | + f->format, f->type, | ||
530 | bits + ofs); | ||
531 | } else { | ||
532 | for (; y1 < y2; y1++, ofs += byte_stride) | ||
533 | glTexSubImage2D(GL_TEXTURE_2D, 0, | ||
534 | x1 - box->x1, y1 - box->y1, | ||
535 | x2 - x1, 1, | ||
536 | - format, type, | ||
537 | + f->format, f->type, | ||
538 | bits + ofs); | ||
539 | } | ||
540 | } | ||
541 | @@ -178,10 +137,7 @@ glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox, | ||
542 | glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); | ||
543 | int box_index; | ||
544 | int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3; | ||
545 | - GLenum type; | ||
546 | - GLenum format; | ||
547 | - | ||
548 | - glamor_format_for_pixmap(pixmap, &format, &type); | ||
549 | + const struct glamor_format *f = glamor_format_for_pixmap(pixmap); | ||
550 | |||
551 | glamor_make_current(glamor_priv); | ||
552 | |||
553 | @@ -216,10 +172,10 @@ glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox, | ||
554 | |||
555 | if (glamor_priv->has_pack_subimage || | ||
556 | x2 - x1 == byte_stride / bytes_per_pixel) { | ||
557 | - glReadPixels(x1 - box->x1, y1 - box->y1, x2 - x1, y2 - y1, format, type, bits + ofs); | ||
558 | + glReadPixels(x1 - box->x1, y1 - box->y1, x2 - x1, y2 - y1, f->format, f->type, bits + ofs); | ||
559 | } else { | ||
560 | for (; y1 < y2; y1++, ofs += byte_stride) | ||
561 | - glReadPixels(x1 - box->x1, y1 - box->y1, x2 - x1, 1, format, type, bits + ofs); | ||
562 | + glReadPixels(x1 - box->x1, y1 - box->y1, x2 - x1, 1, f->format, f->type, bits + ofs); | ||
563 | } | ||
564 | } | ||
565 | } | ||
566 | diff --git a/glamor/glamor_transfer.h b/glamor/glamor_transfer.h | ||
567 | index de8186a70..a6137b3ff 100644 | ||
568 | --- a/glamor/glamor_transfer.h | ||
569 | +++ b/glamor/glamor_transfer.h | ||
570 | @@ -23,9 +23,6 @@ | ||
571 | #ifndef _GLAMOR_TRANSFER_H_ | ||
572 | #define _GLAMOR_TRANSFER_H_ | ||
573 | |||
574 | -void | ||
575 | -glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type); | ||
576 | - | ||
577 | void | ||
578 | glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox, | ||
579 | int dx_src, int dy_src, | ||
580 | diff --git a/glamor/glamor_transform.c b/glamor/glamor_transform.c | ||
581 | index 2d5a634a8..348d00be1 100644 | ||
582 | --- a/glamor/glamor_transform.c | ||
583 | +++ b/glamor/glamor_transform.c | ||
584 | @@ -121,10 +121,9 @@ glamor_set_color_depth(ScreenPtr pScreen, | ||
585 | |||
586 | glamor_get_rgba_from_pixel(pixel, | ||
587 | &color[0], &color[1], &color[2], &color[3], | ||
588 | - format_for_depth(depth)); | ||
589 | + glamor_priv->formats[depth].render_format); | ||
590 | |||
591 | - if ((depth == 1 || depth == 8) && | ||
592 | - glamor_priv->one_channel_format == GL_RED) | ||
593 | + if ((depth <= 8) && glamor_priv->formats[8].format == GL_RED) | ||
594 | color[0] = color[3]; | ||
595 | |||
596 | glUniform4fv(uniform, 1, color); | ||
597 | diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h | ||
598 | index cbb808294..651faf2fe 100644 | ||
599 | --- a/glamor/glamor_utils.h | ||
600 | +++ b/glamor/glamor_utils.h | ||
601 | @@ -570,65 +570,8 @@ | ||
602 | && (_w_) <= _glamor_->max_fbo_size \ | ||
603 | && (_h_) <= _glamor_->max_fbo_size) | ||
604 | |||
605 | -/* For 1bpp pixmap, we don't store it as texture. */ | ||
606 | -#define glamor_check_pixmap_fbo_depth(_depth_) ( \ | ||
607 | - _depth_ == 8 \ | ||
608 | - || _depth_ == 15 \ | ||
609 | - || _depth_ == 16 \ | ||
610 | - || _depth_ == 24 \ | ||
611 | - || _depth_ == 30 \ | ||
612 | - || _depth_ == 32) | ||
613 | - | ||
614 | #define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) (pixmap_priv->gl_fbo == GLAMOR_FBO_NORMAL) | ||
615 | |||
616 | -/** | ||
617 | - * Borrow from uxa. | ||
618 | - */ | ||
619 | -static inline CARD32 | ||
620 | -format_for_depth(int depth) | ||
621 | -{ | ||
622 | - switch (depth) { | ||
623 | - case 1: | ||
624 | - return PICT_a1; | ||
625 | - case 4: | ||
626 | - return PICT_a4; | ||
627 | - case 8: | ||
628 | - return PICT_a8; | ||
629 | - case 15: | ||
630 | - return PICT_x1r5g5b5; | ||
631 | - case 16: | ||
632 | - return PICT_r5g6b5; | ||
633 | - default: | ||
634 | - case 24: | ||
635 | - return PICT_x8r8g8b8; | ||
636 | - case 30: | ||
637 | - return PICT_x2r10g10b10; | ||
638 | - case 32: | ||
639 | - return PICT_a8r8g8b8; | ||
640 | - } | ||
641 | -} | ||
642 | - | ||
643 | -static inline GLenum | ||
644 | -gl_iformat_for_pixmap(PixmapPtr pixmap) | ||
645 | -{ | ||
646 | - glamor_screen_private *glamor_priv = | ||
647 | - glamor_get_screen_private((pixmap)->drawable.pScreen); | ||
648 | - glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); | ||
649 | - | ||
650 | - if (!glamor_priv->is_gles && | ||
651 | - ((pixmap)->drawable.depth == 1 || (pixmap)->drawable.depth == 8)) { | ||
652 | - return glamor_priv->one_channel_format; | ||
653 | - } else if (!glamor_priv->is_gles && | ||
654 | - (pixmap)->drawable.depth == 16 && pixmap_priv->is_cbcr) { | ||
655 | - return GL_RG; | ||
656 | - } else if (!glamor_priv->is_gles && | ||
657 | - (pixmap)->drawable.depth == 30) { | ||
658 | - return GL_RGB10_A2; | ||
659 | - } else { | ||
660 | - return GL_RGBA; | ||
661 | - } | ||
662 | -} | ||
663 | - | ||
664 | #define REVERT_NONE 0 | ||
665 | #define REVERT_NORMAL 1 | ||
666 | #define REVERT_UPLOADING_A1 3 | ||
667 | -- | ||
668 | 2.17.1 | ||
669 | |||