diff -u mesa-20.2.6/debian/changelog mesa-20.2.6/debian/changelog --- mesa-20.2.6/debian/changelog +++ mesa-20.2.6/debian/changelog @@ -1,3 +1,9 @@ +mesa (20.2.6-0ubuntu0.20.04.2) focal; urgency=medium + + * Cherrypick upstream commits to fix the distored display issues. (LP: #1937988) + + -- Shengyao Xue Tue, 03 Aug 2021 14:07:14 +0800 + mesa (20.2.6-0ubuntu0.20.04.1) focal; urgency=medium * New upstream bugfix release. (LP: #1908699) diff -u mesa-20.2.6/debian/patches/series mesa-20.2.6/debian/patches/series --- mesa-20.2.6/debian/patches/series +++ mesa-20.2.6/debian/patches/series @@ -5,0 +6 @@ +0001-Cherrypick-upstream-commits-to-fix-the-distored-displ.patch only in patch2: unchanged: --- mesa-20.2.6.orig/debian/patches/0001-Cherrypick-upstream-commits-to-fix-the-distored-displ.patch +++ mesa-20.2.6/debian/patches/0001-Cherrypick-upstream-commits-to-fix-the-distored-displ.patch @@ -0,0 +1,319 @@ +From f3d04746c51d07ffdb64ceed77ade91b45ea25af Mon Sep 17 00:00:00 2001 +From: Shengyao Xue +Date: Tue, 3 Aug 2021 13:58:00 +0800 +Subject: [PATCH] Cherrypick upstream commits to fix the distored display issue + on I+A platforms, see issues below for more detals: + https://bugs.launchpad.net/oem-priority/+bug/1937988 + +The related upstream commits are: + +a3a4517f4147a0a7c1b34a4bcd42de45d552df5f +55d1b8f929bbba58734bc7b1f79a6f53ab5aa0e8 +0e856b95c59d4b9d1909bd96eca0296dd14b41ff +f1a66e7c90ceb4796085989d0d8374689753121e +--- + include/GL/internal/dri_interface.h | 1 + + src/intel/isl/isl.c | 5 +- + src/loader/loader_dri3_helper.c | 68 ++++++++++++++++++-------- + src/loader/loader_dri3_helper.h | 5 ++ + src/loader/loader_dri_helper.c | 75 +++++++++++++++++++++++++++++ + src/loader/loader_dri_helper.h | 33 +++++++++++++ + src/loader/meson.build | 2 +- + 7 files changed, 166 insertions(+), 23 deletions(-) + create mode 100644 src/loader/loader_dri_helper.c + create mode 100644 src/loader/loader_dri_helper.h + +diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h +index e40106575..d2b42e076 100644 +--- a/include/GL/internal/dri_interface.h ++++ b/include/GL/internal/dri_interface.h +@@ -1367,6 +1367,7 @@ struct __DRIdri2ExtensionRec { + * could be read after a flush." + */ + #define __DRI_IMAGE_USE_BACKBUFFER 0x0010 ++#define __DRI_IMAGE_USE_PROTECTED 0x0020 + + + #define __DRI_IMAGE_TRANSFER_READ 0x1 +diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c +index a037956f0..656765ce0 100644 +--- a/src/intel/isl/isl.c ++++ b/src/intel/isl/isl.c +@@ -1432,9 +1432,12 @@ isl_calc_row_pitch_alignment(const struct isl_device *dev, + * PRI_STRIDE Stride (p1254): + * + * "When using linear memory, this must be at least 64 byte aligned." ++ * ++ * However, when displaying on NVIDIA and recent AMD GPUs via PRIME, ++ * we need a larger pitch of 256 bytes. We do that just in case. + */ + if (surf_info->usage & ISL_SURF_USAGE_DISPLAY_BIT) +- alignment = isl_align(alignment, 64); ++ alignment = isl_align(alignment, 256); + + return alignment; + } +diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c +index 78cf14b9f..79db38669 100644 +--- a/src/loader/loader_dri3_helper.c ++++ b/src/loader/loader_dri3_helper.c +@@ -34,6 +34,7 @@ + + #include + ++#include "loader_dri_helper.h" + #include "loader_dri3_helper.h" + #include "util/macros.h" + #include "drm-uapi/drm_fourcc.h" +@@ -1300,12 +1301,14 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, + int width, int height, int depth) + { + struct loader_dri3_buffer *buffer; +- __DRIimage *pixmap_buffer; ++ __DRIimage *pixmap_buffer = NULL, *linear_buffer_display_gpu = NULL; + xcb_pixmap_t pixmap; + xcb_sync_fence_t sync_fence; + struct xshmfence *shm_fence; + int buffer_fds[4], fence_fd; + int num_planes = 0; ++ uint64_t *modifiers = NULL; ++ uint32_t count = 0; + int i, mod; + int ret; + +@@ -1405,14 +1408,15 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, + free(modifiers); + } + #endif +- if (!buffer->image) +- buffer->image = draw->ext->image->createImage(draw->dri_screen, +- width, height, +- format, +- __DRI_IMAGE_USE_SHARE | +- __DRI_IMAGE_USE_SCANOUT | +- __DRI_IMAGE_USE_BACKBUFFER, +- buffer); ++ buffer->image = loader_dri_create_image(draw->dri_screen, draw->ext->image, ++ width, height, format, ++ __DRI_IMAGE_USE_SHARE | ++ __DRI_IMAGE_USE_SCANOUT | ++ __DRI_IMAGE_USE_BACKBUFFER | ++ (draw->is_protected_content ? ++ __DRI_IMAGE_USE_PROTECTED : 0), ++ modifiers, count, buffer); ++ free(modifiers); + + pixmap_buffer = buffer->image; + +@@ -1428,18 +1432,40 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, + if (!buffer->image) + goto no_image; + +- buffer->linear_buffer = +- draw->ext->image->createImage(draw->dri_screen, +- width, height, +- dri3_linear_format_for_format(draw, format), +- __DRI_IMAGE_USE_SHARE | +- __DRI_IMAGE_USE_LINEAR | +- __DRI_IMAGE_USE_BACKBUFFER, +- buffer); +- pixmap_buffer = buffer->linear_buffer; +- +- if (!buffer->linear_buffer) +- goto no_linear_buffer; ++ /* if driver name is same only then dri_screen_display_gpu is set. ++ * This check is needed because for simplicity render gpu image extension ++ * is also used for display gpu. ++ */ ++ if (draw->dri_screen_display_gpu) { ++ linear_buffer_display_gpu = ++ draw->ext->image->createImage(draw->dri_screen_display_gpu, ++ width, height, ++ dri3_linear_format_for_format(draw, format), ++ __DRI_IMAGE_USE_SHARE | ++ __DRI_IMAGE_USE_LINEAR | ++ __DRI_IMAGE_USE_BACKBUFFER | ++ __DRI_IMAGE_USE_SCANOUT, ++ buffer); ++ pixmap_buffer = linear_buffer_display_gpu; ++ } ++ ++ if (!pixmap_buffer) { ++ buffer->linear_buffer = ++ draw->ext->image->createImage(draw->dri_screen, ++ width, height, ++ dri3_linear_format_for_format(draw, format), ++ __DRI_IMAGE_USE_SHARE | ++ __DRI_IMAGE_USE_LINEAR | ++ __DRI_IMAGE_USE_BACKBUFFER | ++ __DRI_IMAGE_USE_SCANOUT, ++ buffer); ++ ++ pixmap_buffer = buffer->linear_buffer; ++ if (!buffer->linear_buffer) { ++ goto no_linear_buffer; ++ } ++ } ++ + } + + /* X want some information about the planes, so ask the image for it +diff --git a/src/loader/loader_dri3_helper.h b/src/loader/loader_dri3_helper.h +index 3d50852ba..a256c377e 100644 +--- a/src/loader/loader_dri3_helper.h ++++ b/src/loader/loader_dri3_helper.h +@@ -128,6 +128,9 @@ struct loader_dri3_drawable { + bool is_different_gpu; + bool multiplanes_available; + ++ /* DRI screen created for display GPU in case of prime */ ++ __DRIscreen *dri_screen_display_gpu; ++ + /* Present extension capabilities + */ + uint32_t present_capabilities; +@@ -168,6 +171,8 @@ struct loader_dri3_drawable { + unsigned int back_format; + xcb_present_complete_mode_t last_present_mode; + ++ bool is_protected_content; ++ + /* Currently protects the following fields: + * event_cnd, has_event_waiter, + * recv_sbc, ust, msc, recv_msc_serial, +diff --git a/src/loader/loader_dri_helper.c b/src/loader/loader_dri_helper.c +new file mode 100644 +index 000000000..13fcfbe73 +--- /dev/null ++++ b/src/loader/loader_dri_helper.c +@@ -0,0 +1,75 @@ ++/* ++ * Permission to use, copy, modify, distribute, and sell this software and its ++ * documentation for any purpose is hereby granted without fee, provided that ++ * the above copyright notice appear in all copies and that both that copyright ++ * notice and this permission notice appear in supporting documentation, and ++ * that the name of the copyright holders not be used in advertising or ++ * publicity pertaining to distribution of the software without specific, ++ * written prior permission. The copyright holders make no representations ++ * about the suitability of this software for any purpose. It is provided "as ++ * is" without express or implied warranty. ++ * ++ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, ++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO ++ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR ++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, ++ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ++ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE ++ * OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#include /* dri_interface needs GL types */ ++#include ++ ++#include "drm-uapi/drm_fourcc.h" ++#include "loader_dri_helper.h" ++ ++__DRIimage *loader_dri_create_image(__DRIscreen *screen, ++ const __DRIimageExtension *image, ++ uint32_t width, uint32_t height, ++ uint32_t dri_format, uint32_t dri_usage, ++ const uint64_t *modifiers, ++ unsigned int modifiers_count, ++ void *loaderPrivate) ++{ ++ if (modifiers && modifiers_count > 0 && ++ image->base.version > 14 && image->createImageWithModifiers) { ++ bool has_valid_modifier = false; ++ int i; ++ ++ /* It's acceptable to create an image with INVALID modifier in the list, ++ * but it cannot be on the only modifier (since it will certainly fail ++ * later). While we could easily catch this after modifier creation, doing ++ * the check here is a convenient debug check likely pointing at whatever ++ * interface the client is using to build its modifier list. ++ */ ++ for (i = 0; i < modifiers_count; i++) { ++ if (modifiers[i] != DRM_FORMAT_MOD_INVALID) { ++ has_valid_modifier = true; ++ break; ++ } ++ } ++ if (!has_valid_modifier) ++ return NULL; ++ ++ /* ++ if (image->base.version >= 19 && image->createImageWithModifiers2) ++ return image->createImageWithModifiers2(screen, width, height, ++ dri_format, modifiers, ++ modifiers_count, dri_usage, ++ loaderPrivate); ++ else */ ++ return image->createImageWithModifiers(screen, width, height, ++ dri_format, modifiers, ++ modifiers_count, loaderPrivate); ++ } ++ ++ /* No modifier given or fallback to the legacy createImage allowed */ ++ return image->createImage(screen, width, height, dri_format, dri_usage, ++ loaderPrivate); ++} +diff --git a/src/loader/loader_dri_helper.h b/src/loader/loader_dri_helper.h +new file mode 100644 +index 000000000..e0aae6947 +--- /dev/null ++++ b/src/loader/loader_dri_helper.h +@@ -0,0 +1,33 @@ ++/* ++ * Permission to use, copy, modify, distribute, and sell this software and its ++ * documentation for any purpose is hereby granted without fee, provided that ++ * the above copyright notice appear in all copies and that both that copyright ++ * notice and this permission notice appear in supporting documentation, and ++ * that the name of the copyright holders not be used in advertising or ++ * publicity pertaining to distribution of the software without specific, ++ * written prior permission. The copyright holders make no representations ++ * about the suitability of this software for any purpose. It is provided "as ++ * is" without express or implied warranty. ++ * ++ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, ++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO ++ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR ++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, ++ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ++ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE ++ * OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++ ++#include /* dri_interface needs GL types */ ++#include ++ ++__DRIimage *loader_dri_create_image(__DRIscreen *screen, ++ const __DRIimageExtension *image, ++ uint32_t width, uint32_t height, ++ uint32_t dri_format, uint32_t dri_usage, ++ const uint64_t *modifiers, ++ unsigned int modifiers_count, ++ void *loaderPrivate); +diff --git a/src/loader/meson.build b/src/loader/meson.build +index 34a43e33f..57a93c3aa 100644 +--- a/src/loader/meson.build ++++ b/src/loader/meson.build +@@ -47,7 +47,7 @@ endif + + libloader = static_library( + 'loader', +- ['loader.c', 'pci_id_driver_map.c'], ++ ['loader_dri_helper.c', 'loader.c', 'pci_id_driver_map.c'], + c_args : loader_c_args, + gnu_symbol_visibility : 'hidden', + include_directories : [inc_include, inc_src, inc_util], +-- +2.25.1 +