From fe38db9384208e99f3646eb33cdb7f0fc4496e05 Mon Sep 17 00:00:00 2001 From: Windsome Zeng Date: Tue, 16 Aug 2022 17:38:05 +0800 Subject: [PATCH] [mesa3d] Sync all patch files with DDK 1.17. --- package/mesa3d/0001-Add-pvr-dri-driver.patch | 6003 +---------------- ...e-the-PVR-driver-for-platform-device.patch | 8 +- ...Add-some-new-DRI-formats-and-fourccs.patch | 36 +- ...4-GL_EXT_sparse_texture-entry-points.patch | 22 +- ...-support-for-various-GLES-extensions.patch | 30 +- .../0006-Add-EGL_IMG_cl_image-extension.patch | 30 +- ...when-making-a-context-current-withou.patch | 8 +- ...MakeCurrent-for-the-case-where-nothi.patch | 8 +- ...er_pixel_local_storage2-entry-points.patch | 24 +- ..._framebuffer_downsample-entry-points.patch | 22 +- .../0011-GL_OVR_multiview-entry-points.patch | 22 +- ...iview_multisampled_render_to_texture.patch | 20 +- ...all-wayland-drm.xml-to-the-configure.patch | 6 +- ...fer-sharing-in-the-kms_swrast-driver.patch | 10 +- ...-add-support-for-RGB565-back-buffers.patch | 10 +- ...-dri3-fix-segfault-in-eglCopyBuffers.patch | 10 +- ...y-call-eglReleaseThread-on-thread-te.patch | 12 +- .../0018-egl-add-Tizen-platform-support.patch | 99 +- ...t-for-EGL_TIZEN_image_native_surface.patch | 16 +- ...nd-post-maximum-damage-when-blitting.patch | 10 +- ...d-flush-the-drawable-before-blitting.patch | 12 +- ...-an-internal-_EGLImage-for-each-tbm-.patch | 30 +- ...supported-API-in-driCreateNewContext.patch | 6 +- package/mesa3d/0024-gbm-add-gbm_bo_blit.patch | 133 +- ...assert-if-DRI-context-creation-fails.patch | 12 +- ...0026-egl-wayland-add-pbuffer-support.patch | 76 +- ...t-DRI-driver-handling-of-swap-preser.patch | 10 +- ...l-eglBindAPI-workaround-for-dEQP-bug.patch | 6 +- ...EXT_multi_draw_indirect-entry-points.patch | 22 +- ...0-dri-add-support-for-YUV-DRI-config.patch | 208 +- ...-egl-add-support-for-EXT_yuv_surface.patch | 22 +- ...__DRI_IMAGE_COMPONENTS-define-for-EG.patch | 10 +- ...yland-expose-EXT_yuv_surface-support.patch | 20 +- ...tizen-expose-EXT_yuv_surface-support.patch | 6 +- .../0035-gbm-add-some-new-GBM-formats.patch | 14 +- .../mesa3d/0036-egl-add-null-platform.patch | 82 +- .../0037-egl-add-config-debug-printout.patch | 89 +- ...-support-for-EXT_image_gl_colorspace.patch | 30 +- ...-meson-force-C-2011-for-thread_local.patch | 8 +- ...port-for-swap-intervals-other-than-1.patch | 22 +- ...d-support-for-explicit-synchronisati.patch | 14 +- ...pport-for-DRM-image-format-modifiers.patch | 401 ++ ...ry-the-supported-ES2-context-version.patch | 22 +- ...-allow-libGL-to-be-built-without-GLX.patch | 46 +- ...-process-non-resized-window-movement.patch | 14 +- ..._framebuffer_object-from-ARB-version.patch | 78 +- ...port-for-async-flip-with-front-buffe.patch | 18 +- .../mesa3d/0048-gbm-add-pbuffer-support.patch | 30 +- ...-null-expose-EXT_yuv_surface-support.patch | 305 +- ...serve-the-original-FD-for-driver-use.patch | 433 ++ ...near-buffer-is-not-needed-with-DRM-f.patch | 56 + ...ffer-is-not-needed-with-DRM-format-m.patch | 303 + ...-support-for-DRI_PRIME-GPU-selection.patch | 267 + ...-support-for-DRI_PRIME-GPU-selection.patch | 304 + ...-egl-null-introduce-NULL_DRM_DISPLAY.patch | 120 + ...-the-DRI3-and-Present-XCB-reply-poin.patch | 37 + ...-host-visible-memory-to-be-requested.patch | 143 + ...an-wsi-make-the-display-FD-available.patch | 419 ++ ...r-wsi-add-PowerVR-Vulkan-WSI-library.patch | 1343 ++++ ...i-Disable-use-of-VK_EXT_pci_bus_info.patch | 76 + ...ault-to-force_bgra8_unorm_first-true.patch | 34 + ...nable-additional-formats-for-Wayland.patch | 64 + ...nable-additional-formats-for-Display.patch | 27 + ...-add-YUV420_3PLANE-and-YVU420_3PLANE.patch | 183 + ...l-null-add-support-for-YU12-and-YV12.patch | 58 + ...lly-revert-pbuffer-attribute-removal.patch | 59 + ...ffer-config-attribs-to-0-for-non-pbu.patch | 14 +- ...GL_ARB_geometry_shader4-entry-points.patch | 146 + package/mesa3d/mesa3d.hash | 6 +- package/mesa3d/mesa3d.mk | 2 +- 70 files changed, 5794 insertions(+), 6452 deletions(-) create mode 100644 package/mesa3d/0042-egl-null-add-support-for-DRM-image-format-modifiers.patch create mode 100644 package/mesa3d/0050-dri-preserve-the-original-FD-for-driver-use.patch create mode 100644 package/mesa3d/0051-egl-wayland-a-linear-buffer-is-not-needed-with-DRM-f.patch create mode 100644 package/mesa3d/0052-dri3-a-linear-buffer-is-not-needed-with-DRM-format-m.patch create mode 100644 package/mesa3d/0053-egl-drm-add-support-for-DRI_PRIME-GPU-selection.patch create mode 100644 package/mesa3d/0054-egl-null-add-support-for-DRI_PRIME-GPU-selection.patch create mode 100644 package/mesa3d/0055-egl-null-introduce-NULL_DRM_DISPLAY.patch create mode 100644 package/mesa3d/0056-vulkan-wsi-check-the-DRI3-and-Present-XCB-reply-poin.patch create mode 100644 package/mesa3d/0057-vulkan-wsi-Allow-host-visible-memory-to-be-requested.patch create mode 100644 package/mesa3d/0058-vulkan-wsi-make-the-display-FD-available.patch create mode 100644 package/mesa3d/0059-pvr-wsi-add-PowerVR-Vulkan-WSI-library.patch create mode 100644 package/mesa3d/0060-vulkan-wsi-Disable-use-of-VK_EXT_pci_bus_info.patch create mode 100644 package/mesa3d/0061-vulkan-wsi-default-to-force_bgra8_unorm_first-true.patch create mode 100644 package/mesa3d/0062-vulkan-wsi-enable-additional-formats-for-Wayland.patch create mode 100644 package/mesa3d/0063-vulkan-wsi-enable-additional-formats-for-Display.patch create mode 100644 package/mesa3d/0064-mesa-main-dri-add-YUV420_3PLANE-and-YVU420_3PLANE.patch create mode 100644 package/mesa3d/0065-egl-null-add-support-for-YU12-and-YV12.patch create mode 100644 package/mesa3d/0066-mesa-partially-revert-pbuffer-attribute-removal.patch create mode 100644 package/mesa3d/0068-GL_ARB_geometry_shader4-entry-points.patch diff --git a/package/mesa3d/0001-Add-pvr-dri-driver.patch b/package/mesa3d/0001-Add-pvr-dri-driver.patch index 574d87a9..17f2264f 100644 --- a/package/mesa3d/0001-Add-pvr-dri-driver.patch +++ b/package/mesa3d/0001-Add-pvr-dri-driver.patch @@ -1,34 +1,28 @@ -From 2c1b96a851f2313e6832989fe13d49ca05c4545c Mon Sep 17 00:00:00 2001 +From 1546e69ae9fec54134bc06146143511b4374bf4a Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Tue, 14 Apr 2020 09:47:46 +0100 -Subject: [PATCH 01/50] Add pvr dri driver +Subject: [PATCH 01/67] Add pvr dri driver --- - meson.build | 19 +- - meson_options.txt | 2 +- - src/mesa/drivers/dri/meson.build | 5 + - src/mesa/drivers/dri/pvr/dri_support.h | 1270 ++++++++++++++++ - src/mesa/drivers/dri/pvr/img_drm_fourcc.h | 113 ++ - src/mesa/drivers/dri/pvr/imgpixfmts.h | 307 ++++ - src/mesa/drivers/dri/pvr/imgyuv.h | 58 + - src/mesa/drivers/dri/pvr/mesa_context.c | 208 +++ - src/mesa/drivers/dri/pvr/meson.build | 53 + - src/mesa/drivers/dri/pvr/pvrcb.c | 282 ++++ - src/mesa/drivers/dri/pvr/pvrcompat.c | 1552 ++++++++++++++++++++ - src/mesa/drivers/dri/pvr/pvrdrawable_mod.c | 385 +++++ - src/mesa/drivers/dri/pvr/pvrdri.c | 603 ++++++++ - src/mesa/drivers/dri/pvr/pvrdri.h | 176 +++ - src/mesa/drivers/dri/pvr/pvrdri_mod.c | 584 ++++++++ - src/mesa/drivers/dri/pvr/pvrdri_mod.h | 450 ++++++ - src/mesa/drivers/dri/pvr/pvrdri_support.h | 439 ++++++ - src/mesa/drivers/dri/pvr/pvrext.c | 698 +++++++++ - src/mesa/drivers/dri/pvr/pvrext_mod.c | 276 ++++ - src/mesa/drivers/dri/pvr/pvrimage_mod.c | 1282 ++++++++++++++++ - src/mesa/drivers/dri/pvr/pvrmesa.h | 36 + - src/mesa/drivers/dri/pvr/pvrutil.c | 239 +++ - src/mesa/drivers/dri/pvr/pvrutil_mod.c | 921 ++++++++++++ - src/meson.build | 1 + - 24 files changed, 9950 insertions(+), 9 deletions(-) + meson.build | 19 +- + meson_options.txt | 2 +- + src/mesa/drivers/dri/meson.build | 5 + + src/mesa/drivers/dri/pvr/dri_support.h | 581 +++++++++++++++ + src/mesa/drivers/dri/pvr/img_drm_fourcc.h | 113 +++ + src/mesa/drivers/dri/pvr/imgpixfmts.h | 307 ++++++++ + src/mesa/drivers/dri/pvr/imgyuv.h | 58 ++ + src/mesa/drivers/dri/pvr/mesa_context.c | 208 ++++++ + src/mesa/drivers/dri/pvr/meson.build | 48 ++ + src/mesa/drivers/dri/pvr/pvrcb.c | 328 +++++++++ + src/mesa/drivers/dri/pvr/pvrcompat.c | 838 ++++++++++++++++++++++ + src/mesa/drivers/dri/pvr/pvrdri.c | 613 ++++++++++++++++ + src/mesa/drivers/dri/pvr/pvrdri.h | 188 +++++ + src/mesa/drivers/dri/pvr/pvrdri_support.h | 206 ++++++ + src/mesa/drivers/dri/pvr/pvrext.c | 704 ++++++++++++++++++ + src/mesa/drivers/dri/pvr/pvrmesa.h | 36 + + src/mesa/drivers/dri/pvr/pvrutil.c | 239 ++++++ + src/meson.build | 1 + + 18 files changed, 4485 insertions(+), 9 deletions(-) create mode 100644 src/mesa/drivers/dri/pvr/dri_support.h create mode 100644 src/mesa/drivers/dri/pvr/img_drm_fourcc.h create mode 100644 src/mesa/drivers/dri/pvr/imgpixfmts.h @@ -37,24 +31,18 @@ Subject: [PATCH 01/50] Add pvr dri driver create mode 100644 src/mesa/drivers/dri/pvr/meson.build create mode 100644 src/mesa/drivers/dri/pvr/pvrcb.c create mode 100644 src/mesa/drivers/dri/pvr/pvrcompat.c - create mode 100644 src/mesa/drivers/dri/pvr/pvrdrawable_mod.c create mode 100644 src/mesa/drivers/dri/pvr/pvrdri.c create mode 100644 src/mesa/drivers/dri/pvr/pvrdri.h - create mode 100644 src/mesa/drivers/dri/pvr/pvrdri_mod.c - create mode 100644 src/mesa/drivers/dri/pvr/pvrdri_mod.h create mode 100644 src/mesa/drivers/dri/pvr/pvrdri_support.h create mode 100644 src/mesa/drivers/dri/pvr/pvrext.c - create mode 100644 src/mesa/drivers/dri/pvr/pvrext_mod.c - create mode 100644 src/mesa/drivers/dri/pvr/pvrimage_mod.c create mode 100644 src/mesa/drivers/dri/pvr/pvrmesa.h create mode 100644 src/mesa/drivers/dri/pvr/pvrutil.c - create mode 100644 src/mesa/drivers/dri/pvr/pvrutil_mod.c diff --git a/meson.build b/meson.build -index 932eb136681..15e08dfea1c 100644 +index 155db287796..968b4f5f499 100644 --- a/meson.build +++ b/meson.build -@@ -160,11 +160,11 @@ if dri_drivers.contains('auto') +@@ -171,11 +171,11 @@ if dri_drivers.contains('auto') if system_has_kms_drm # TODO: PPC, Sparc if ['x86', 'x86_64'].contains(host_machine.cpu_family()) @@ -63,13 +51,13 @@ index 932eb136681..15e08dfea1c 100644 elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) - dri_drivers = [] + dri_drivers = ['pvr'] - elif ['mips', 'mips64'].contains(host_machine.cpu_family()) + elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family()) - dri_drivers = ['r100', 'r200', 'nouveau'] + dri_drivers = ['r100', 'r200', 'nouveau', 'pvr'] else error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format( host_machine.cpu_family())) -@@ -183,6 +183,7 @@ with_dri_i965 = dri_drivers.contains('i965') +@@ -194,6 +194,7 @@ with_dri_i965 = dri_drivers.contains('i965') with_dri_r100 = dri_drivers.contains('r100') with_dri_r200 = dri_drivers.contains('r200') with_dri_nouveau = dri_drivers.contains('nouveau') @@ -77,7 +65,7 @@ index 932eb136681..15e08dfea1c 100644 with_dri = dri_drivers.length() != 0 -@@ -1435,14 +1436,16 @@ _drm_amdgpu_ver = '2.4.100' +@@ -1516,14 +1517,16 @@ _drm_amdgpu_ver = '2.4.107' _drm_radeon_ver = '2.4.71' _drm_nouveau_ver = '2.4.102' _drm_intel_ver = '2.4.75' @@ -86,9 +74,9 @@ index 932eb136681..15e08dfea1c 100644 _libdrm_checks = [ - ['intel', with_dri_i915 or with_gallium_i915], -- ['amdgpu', with_amd_vk or with_gallium_radeonsi], +- ['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi], + ['intel', with_dri_i915 or with_gallium_i915, true], -+ ['amdgpu', with_amd_vk or with_gallium_radeonsi, true], ++ ['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi, true], ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or - with_gallium_r300 or with_gallium_r600)], - ['nouveau', (with_gallium_nouveau or with_dri_nouveau)], @@ -98,7 +86,7 @@ index 932eb136681..15e08dfea1c 100644 ] # VC4 only needs core libdrm support of this version, not a libdrm_vc4 -@@ -1472,7 +1475,7 @@ endif +@@ -1553,7 +1556,7 @@ endif # Then get each libdrm module foreach d : _libdrm_checks @@ -108,10 +96,10 @@ index 932eb136681..15e08dfea1c 100644 'dep_libdrm_' + d[0], dependency('libdrm_' + d[0], version : '>=' + _drm_ver) diff --git a/meson_options.txt b/meson_options.txt -index fc73f6e1c24..6f001343ae6 100644 +index 29c402c4844..dac791099a1 100644 --- a/meson_options.txt +++ b/meson_options.txt -@@ -45,7 +45,7 @@ option( +@@ -55,7 +55,7 @@ option( 'dri-drivers', type : 'array', value : ['auto'], @@ -121,10 +109,10 @@ index fc73f6e1c24..6f001343ae6 100644 ) option( diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build -index 97210c8e638..2018e3fc1c4 100644 +index 239ca962c2a..88a973bb84f 100644 --- a/src/mesa/drivers/dri/meson.build +++ b/src/mesa/drivers/dri/meson.build -@@ -47,6 +47,11 @@ if with_dri_nouveau +@@ -48,6 +48,11 @@ if with_dri_nouveau _dri_drivers += libnouveau_vieux _dri_link += 'nouveau_vieux_dri.so' endif @@ -138,10 +126,10 @@ index 97210c8e638..2018e3fc1c4 100644 libmesa_dri_drivers = shared_library( diff --git a/src/mesa/drivers/dri/pvr/dri_support.h b/src/mesa/drivers/dri/pvr/dri_support.h new file mode 100644 -index 00000000000..b5da4d95a03 +index 00000000000..631410438fd --- /dev/null +++ b/src/mesa/drivers/dri/pvr/dri_support.h -@@ -0,0 +1,1270 @@ +@@ -0,0 +1,581 @@ +/* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* vi: set ts=8 sw=8 sts=8: */ +/*************************************************************************/ /*! @@ -177,18 +165,6 @@ index 00000000000..b5da4d95a03 +#include +#include + -+#include "imgpixfmts.h" -+#include "imgyuv.h" -+ -+typedef enum -+{ -+ PVRDRI_DEVICE_TYPE_INVALID = 0, -+ PVRDRI_DEVICE_TYPE_UNKNOWN, -+ PVRDRI_DEVICE_TYPE_DISPLAY, -+ PVRDRI_DEVICE_TYPE_RENDER, -+ PVRDRI_DEVICE_TYPE_CARD, -+} PVRDRIDeviceType; -+ +/* API type. */ +typedef enum +{ @@ -200,39 +176,8 @@ index 00000000000..b5da4d95a03 + PVRDRI_API_GL_CORE = 6, +} PVRDRIAPIType; + -+/* API sub type. */ +typedef enum +{ -+ PVRDRI_API_SUB_NONE, -+} PVRDRIAPISubType; -+ -+typedef enum -+{ -+ PVRDRI_DRAWABLE_NONE = 0, -+ PVRDRI_DRAWABLE_WINDOW = 1, -+ PVRDRI_DRAWABLE_PIXMAP = 2, -+ PVRDRI_DRAWABLE_PBUFFER = 3, -+} PVRDRIDrawableType; -+ -+typedef enum -+{ -+ PVRDRI_IMAGE = 1, -+ PVRDRI_IMAGE_FROM_NAMES, -+ PVRDRI_IMAGE_FROM_EGLIMAGE, -+ PVRDRI_IMAGE_FROM_DMABUFS, -+ PVRDRI_IMAGE_SUBIMAGE, -+} PVRDRIImageType; -+ -+typedef enum -+{ -+ PVRDRI_EGLIMAGE_NONE = 0, -+ PVRDRI_EGLIMAGE_IMGEGL, -+ PVRDRI_EGLIMAGE_IMGOCL, -+} PVRDRIEGLImageType; -+ -+typedef enum -+{ -+ /* Since PVRDRICallbacks version 2 */ + PVRDRI_CONFIG_ATTRIB_INVALID = 0, + PVRDRI_CONFIG_ATTRIB_RENDERABLE_TYPE = 1, + PVRDRI_CONFIG_ATTRIB_RGB_MODE = 2, @@ -254,8 +199,6 @@ index 00000000000..b5da4d95a03 + PVRDRI_CONFIG_ATTRIB_YUV_DEPTH_RANGE = 18, + PVRDRI_CONFIG_ATTRIB_YUV_CSC_STANDARD = 19, + PVRDRI_CONFIG_ATTRIB_YUV_PLANE_BPP = 20, -+ -+ /* Valid for use with with PVRDRICallbacksV2 */ + PVRDRI_CONFIG_ATTRIB_RED_MASK = 21, + PVRDRI_CONFIG_ATTRIB_GREEN_MASK = 22, + PVRDRI_CONFIG_ATTRIB_BLUE_MASK = 23, @@ -263,58 +206,6 @@ index 00000000000..b5da4d95a03 + PVRDRI_CONFIG_ATTRIB_SRGB_CAPABLE = 25 +} PVRDRIConfigAttrib; + -+typedef enum -+{ -+ /* Since PVRDRICallbacks version 2 */ -+ PVRDRI_BUFFER_ATTRIB_INVALID = 0, -+ PVRDRI_BUFFER_ATTRIB_TYPE = 1, -+ PVRDRI_BUFFER_ATTRIB_WIDTH = 2, -+ PVRDRI_BUFFER_ATTRIB_HEIGHT = 3, -+ PVRDRI_BUFFER_ATTRIB_STRIDE = 4, -+ PVRDRI_BUFFER_ATTRIB_PIXEL_FORMAT = 5, -+} PVRDRIBufferAttrib; -+ -+/* The context flags match their __DRI_CTX_FLAG and EGL_CONTEXT counterparts */ -+#define PVRDRI_CONTEXT_FLAG_DEBUG 0x00000001 -+#define PVRDRI_CONTEXT_FLAG_FORWARD_COMPATIBLE 0x00000002 -+#define PVRDRI_CONTEXT_FLAG_ROBUST_BUFFER_ACCESS 0x00000004 -+ -+/* The context error codes match their __DRI_CTX_ERROR counterparts */ -+#define PVRDRI_CONTEXT_ERROR_SUCCESS 0 -+/* Out of memory */ -+#define PVRDRI_CONTEXT_ERROR_NO_MEMORY 1 -+/* Unsupported API */ -+#define PVRDRI_CONTEXT_ERROR_BAD_API 2 -+/* Unsupported version of API */ -+#define PVRDRI_CONTEXT_ERROR_BAD_VERSION 3 -+/* Unsupported context flag or combination of flags */ -+#define PVRDRI_CONTEXT_ERROR_BAD_FLAG 4 -+/* Unrecognised context attribute */ -+#define PVRDRI_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE 5 -+/* Unrecognised context flag */ -+#define PVRDRI_CONTEXT_ERROR_UNKNOWN_FLAG 6 -+ -+/* -+ * The context priority defines match their __DRI_CTX counterparts, and -+ * the context priority values used by the DDK. -+ */ -+#define PVRDRI_CONTEXT_PRIORITY_LOW 0 -+#define PVRDRI_CONTEXT_PRIORITY_MEDIUM 1 -+#define PVRDRI_CONTEXT_PRIORITY_HIGH 2 -+ -+/* The image error flags match their __DRI_IMAGE_ERROR counterparts */ -+#define PVRDRI_IMAGE_ERROR_SUCCESS 0 -+#define PVRDRI_IMAGE_ERROR_BAD_ALLOC 1 -+#define PVRDRI_IMAGE_ERROR_BAD_MATCH 2 -+#define PVRDRI_IMAGE_ERROR_BAD_PARAMETER 3 -+#define PVRDRI_IMAGE_ERROR_BAD_ACCESS 4 -+ -+/* The buffer flags match their __DRI_IMAGE_USE counterparts */ -+#define PVDRI_BUFFER_USE_SHARE 0x0001 -+#define PVDRI_BUFFER_USE_SCANOUT 0x0002 -+#define PVDRI_BUFFER_USE_CURSOR 0x0004 -+#define PVDRI_BUFFER_USE_LINEAR 0x0008 -+ +/* EGL_RENDERABLE_TYPE mask bits */ +#define PVRDRI_API_BIT_GLES 0x0001 +#define PVRDRI_API_BIT_GLES2 0x0004 @@ -334,601 +225,11 @@ index 00000000000..b5da4d95a03 +#define PVRDRI_MESA_FORMAT_B8G8R8A8_SRGB 9 +#define PVRDRI_MESA_FORMAT_R8G8B8A8_SRGB 10 + -+/* The blit flags match their DRI counterparts */ -+#define PVRDRI_BLIT_FLAG_FLUSH 0x0001 -+#define PVRDRI_BLIT_FLAG_FINISH 0x0002 -+ -+/* The image mapping flags match their DRI counterparts */ -+#define PVRDRI_IMAGE_TRANSFER_READ 0x1 -+#define PVRDRI_IMAGE_TRANSFER_WRITE 0x2 -+#define PVRDRI_IMAGE_TRANSFER_READ_WRITE \ -+ (PVRDRI_IMAGE_TRANSFER_READ | PVRDRI_IMAGE_TRANSFER_WRITE) -+ -+/* The PVRDRI_YUV defines match their __DRI_ATTRIB_YUV counterparts */ -+#define PVRDRI_YUV_ORDER_NONE 0x0 -+#define PVRDRI_YUV_ORDER_YUV 0x1 -+#define PVRDRI_YUV_ORDER_YVU 0x2 -+#define PVRDRI_YUV_ORDER_YUYV 0x4 -+#define PVRDRI_YUV_ORDER_UYVY 0x8 -+#define PVRDRI_YUV_ORDER_YVYU 0x10 -+#define PVRDRI_YUV_ORDER_VYUY 0x20 -+#define PVRDRI_YUV_ORDER_AYUV 0x40 -+ -+#define PVRDRI_YUV_SUBSAMPLE_NONE 0x0 -+#define PVRDRI_YUV_SUBSAMPLE_4_2_0 0x1 -+#define PVRDRI_YUV_SUBSAMPLE_4_2_2 0x2 -+#define PVRDRI_YUV_SUBSAMPLE_4_4_4 0x4 -+ -+#define PVRDRI_YUV_DEPTH_RANGE_NONE 0x0 -+#define PVRDRI_YUV_DEPTH_RANGE_LIMITED 0x1 -+#define PVRDRI_YUV_DEPTH_RANGE_FULL 0x2 -+ -+#define PVRDRI_YUV_CSC_STANDARD_NONE 0x0 -+#define PVRDRI_YUV_CSC_STANDARD_601 0x1 -+#define PVRDRI_YUV_CSC_STANDARD_709 0x2 -+#define PVRDRI_YUV_CSC_STANDARD_2020 0x4 -+ -+#define PVRDRI_YUV_PLANE_BPP_NONE 0x0 -+#define PVRDRI_YUV_PLANE_BPP_0 0x1 -+#define PVRDRI_YUV_PLANE_BPP_8 0x2 -+#define PVRDRI_YUV_PLANE_BPP_10 0x4 -+ -+/* Flags for PVRDRICallbacks.DrawableGetParametersV2 */ -+/* Since PVRDRICallbacks version 2 */ -+#define PVRDRI_GETPARAMS_FLAG_ALLOW_RECREATE 0x1 -+/* Since PVRDRICallbacks version 3 */ -+#define PVRDRI_GETPARAMS_FLAG_NO_UPDATE 0x2 -+ -+/* -+ * Capabilities that might be returned by PVRDRIInterface.GetFenceCapabilities. -+ * These match their _DRI_FENCE_CAP counterparts. -+ * -+ * Since PVRDRIInterface version 2. -+ */ -+#define PVRDRI_FENCE_CAP_NATIVE_FD 0x1 -+ -+typedef struct -+{ -+ IMG_PIXFMT ePixFormat; -+ uint32_t uiWidth; -+ uint32_t uiHeight; -+ uint32_t uiStrideInBytes; -+} PVRDRIBufferAttribs; -+ -+typedef struct -+{ -+ int sampleBuffers; -+ int samples; -+ -+ int redBits; -+ int greenBits; -+ int blueBits; -+ int alphaBits; -+ -+ int rgbBits; -+ int depthBits; -+ int stencilBits; -+ -+ bool doubleBufferMode; -+ -+ int bindToTextureRgb; -+ int bindToTextureRgba; -+} PVRDRIConfigInfo; -+ -+typedef struct IMGEGLImageRec IMGEGLImage; +typedef struct __DRIimageRec __DRIimage; + -+/* PVRDRI interface opaque types */ -+typedef struct PVRDRIScreenImplRec PVRDRIScreenImpl; -+typedef struct PVRDRIContextImplRec PVRDRIContextImpl; -+typedef struct PVRDRIDrawableImplRec PVRDRIDrawableImpl; -+typedef struct PVRDRIBufferImplRec PVRDRIBufferImpl; -+ -+typedef struct PVRDRIDrawable_TAG PVRDRIDrawable; -+ -+typedef void (*PVRDRIGLAPIProc)(void); -+ -+/* Since PVRDRICallbacks version 2 */ +typedef struct PVRDRIConfigRec PVRDRIConfig; + -+/* PVRDRISupportInterface (deprecated) */ -+typedef struct { -+ /********************************************************************** -+ * Version 0 interface -+ **********************************************************************/ -+ -+ PVRDRIDeviceType (*GetDeviceTypeFromFd)(int iFd); -+ -+ bool (*IsFirstScreen)(PVRDRIScreenImpl *psScreenImpl); -+ -+ uint32_t (*PixFmtGetDepth)(IMG_PIXFMT eFmt); -+ uint32_t (*PixFmtGetBPP)(IMG_PIXFMT eFmt); -+ uint32_t (*PixFmtGetBlockSize)(IMG_PIXFMT eFmt); -+ -+ /* ScreenImpl functions */ -+ PVRDRIScreenImpl *(*CreateScreen)(int iFd); -+ void (*DestroyScreen)(PVRDRIScreenImpl *psScreenImpl); -+ -+ int (*APIVersion)(PVRDRIAPIType eAPI, -+ PVRDRIAPISubType eAPISub, -+ PVRDRIScreenImpl *psScreenImpl); -+ -+ void *(*EGLGetLibHandle)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl); -+ -+ PVRDRIGLAPIProc (*EGLGetProcAddress)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ const char *psProcName); -+ -+ bool (*EGLFlushBuffers)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl, -+ bool bFlushAllSurfaces, -+ bool bSwapBuffers, -+ bool bWaitForHW); -+ /* Obsolete (no longer supported) */ -+ bool (*EGLFreeResources)(PVRDRIScreenImpl *psPVRScreenImpl); -+ void (*EGLMarkRendersurfaceInvalid)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl); -+ /* Obsolete (no longer supported) */ -+ void (*EGLSetFrontBufferCallback)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl, -+ void (*pfnCallback)(PVRDRIDrawable *)); -+ -+ /* Obsolete (no longer supported) */ -+ unsigned (*CreateContext)(PVRDRIContextImpl **ppsContextImpl, -+ PVRDRIAPIType eAPI, -+ PVRDRIAPISubType eAPISub, -+ PVRDRIScreenImpl *psScreenImpl, -+ const PVRDRIConfigInfo *psConfigInfo, -+ unsigned uMajorVersion, -+ unsigned uMinorVersion, -+ uint32_t uFlags, -+ bool bNotifyReset, -+ unsigned uPriority, -+ PVRDRIContextImpl *psSharedContextImpl); -+ -+ void (*DestroyContext)(PVRDRIContextImpl *psContextImpl, -+ PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl); -+ -+ bool (*MakeCurrentGC)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psWriteImpl, -+ PVRDRIDrawableImpl *psReadImpl); -+ -+ void (*MakeUnCurrentGC)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl); -+ -+ unsigned (*GetImageSource)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ uint32_t uiTarget, -+ uintptr_t uiBuffer, -+ uint32_t uiLevel, -+ IMGEGLImage *psEGLImage); -+ -+ bool (*BindTexImage)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+ -+ void (*ReleaseTexImage)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+ -+ /* Obsolete (no longer supported) */ -+ PVRDRIDrawableImpl *(*CreateDrawable)(PVRDRIDrawable *psPVRDrawable); -+ -+ void (*DestroyDrawable)(PVRDRIDrawableImpl *psScreenImpl); -+ bool (*EGLDrawableCreate)(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+ bool (*EGLDrawableRecreate)(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+ bool (*EGLDrawableDestroy)(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+ void (*EGLDrawableDestroyConfig)(PVRDRIDrawableImpl *psDrawableImpl); -+ -+ /* Buffer functions */ -+ PVRDRIBufferImpl *(*BufferCreate)(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, -+ int iHeight, -+ unsigned int uiBpp, -+ unsigned int uiUseFlags, -+ unsigned int *puiStride); -+ -+ PVRDRIBufferImpl *(*BufferCreateWithModifiers)(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, -+ int iHeight, -+ int iFormat, -+ IMG_PIXFMT eIMGPixelFormat, -+ const uint64_t *puiModifiers, -+ unsigned int uiModifierCount, -+ unsigned int *puiStride); -+ -+ PVRDRIBufferImpl *(*BufferCreateFromNames)(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, -+ int iHeight, -+ unsigned uiNumPlanes, -+ const int *piName, -+ const int *piStride, -+ const int *piOffset, -+ const unsigned int *puiWidthShift, -+ const unsigned int *puiHeightShift); -+ -+ /* Obsolete (no longer supported) */ -+ PVRDRIBufferImpl *(*BufferCreateFromName)(PVRDRIScreenImpl *psScreenImpl, -+ int iName, -+ int iWidth, -+ int iHeight, -+ int iStride, -+ int iOffset); -+ -+ /* Obsolete (no longer supported) */ -+ PVRDRIBufferImpl *(*BufferCreateFromFds)(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, -+ int iHeight, -+ unsigned uiNumPlanes, -+ const int *piFd, -+ const int *piStride, -+ const int *piOffset, -+ const unsigned int *puiWidthShift, -+ const unsigned int *puiHeightShift); -+ -+ PVRDRIBufferImpl *(*BufferCreateFromFdsWithModifier)(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, -+ int iHeight, -+ uint64_t uiModifier, -+ unsigned uiNumPlanes, -+ const int *piFd, -+ const int *piStride, -+ const int *piOffset, -+ const unsigned int *puiWidthShift, -+ const unsigned int *puiHeightShift); -+ -+ PVRDRIBufferImpl *(*SubBufferCreate)(PVRDRIScreenImpl *psScreen, -+ PVRDRIBufferImpl *psParent, -+ int plane); -+ -+ void (*BufferDestroy)(PVRDRIBufferImpl *psBuffer); -+ -+ int (*BufferGetFd)(PVRDRIBufferImpl *psBuffer); -+ -+ int (*BufferGetHandle)(PVRDRIBufferImpl *psBuffer); -+ -+ uint64_t (*BufferGetModifier)(PVRDRIBufferImpl *psBuffer); -+ -+ int (*BufferGetName)(PVRDRIBufferImpl *psBuffer); -+ -+ int (*BufferGetOffset)(PVRDRIBufferImpl *psBuffer); -+ -+ /* Image functions */ -+ IMGEGLImage *(*EGLImageCreate)(void); -+ IMGEGLImage *(*EGLImageCreateFromBuffer)(int iWidth, -+ int iHeight, -+ int iStride, -+ IMG_PIXFMT ePixelFormat, -+ IMG_YUV_COLORSPACE eColourSpace, -+ IMG_YUV_CHROMA_INTERP eChromaUInterp, -+ IMG_YUV_CHROMA_INTERP eChromaVInterp, -+ PVRDRIBufferImpl *psBuffer); -+ -+ IMGEGLImage *(*EGLImageCreateFromSubBuffer)(IMG_PIXFMT ePixelFormat, -+ PVRDRIBufferImpl *psSubBuffer); -+ -+ IMGEGLImage *(*EGLImageDup)(IMGEGLImage *psIn); -+ -+ void (*EGLImageSetCallbackData)(IMGEGLImage *psEGLImage, __DRIimage *image); -+ -+ void (*EGLImageDestroyExternal)(PVRDRIScreenImpl *psScreenImpl, -+ IMGEGLImage *psEGLImage, -+ PVRDRIEGLImageType eglImageType); -+ void (*EGLImageFree)(IMGEGLImage *psEGLImage); -+ -+ void (*EGLImageGetAttribs)(IMGEGLImage *psEGLImage, -+ PVRDRIBufferAttribs *psAttribs); -+ -+ /* Sync functions */ -+ void *(*CreateFence)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl); -+ -+ void (*DestroyFence)(void *psDRIFence); -+ -+ /* -+ * When calling ClientWaitSync, the eAPI, psContextImpl and -+ * bFlushCommands parameters must be set to PVRDRI_API_NONE, -+ * NULL and false, respectively. -+ */ -+ bool (*ClientWaitSync)(PVRDRIAPIType eAPI, -+ PVRDRIContextImpl *psContextImpl, -+ void *psDRIFence, -+ bool bFlushCommands, -+ bool bTimeout, -+ uint64_t uiTimeout); -+ -+ bool (*ServerWaitSync)(PVRDRIAPIType eAPI, -+ PVRDRIContextImpl *psContextImpl, -+ void *psDRIFence); -+ -+ /* Obsolete (no longer supported) */ -+ void (*DestroyFences)(PVRDRIScreenImpl *psScreenImpl); -+ -+ /* EGL interface functions */ -+ -+ /* Obsolete (no longer supported) */ -+ bool (*EGLDrawableConfigFromGLMode)(PVRDRIDrawableImpl *psPVRDrawable, -+ PVRDRIConfigInfo *psConfigInfo, -+ int supportedAPIs, -+ IMG_PIXFMT ePixFmt); -+ -+ /* Blit functions */ -+ bool (*BlitEGLImage)(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psDstImage, -+ PVRDRIBufferImpl *psDstBuffer, -+ IMGEGLImage *psSrcImage, -+ PVRDRIBufferImpl *psSrcBuffer, -+ int iDstX, int iDstY, -+ int iDstWidth, int iDstHeight, -+ int iSrcX, int iSrcY, -+ int iSrcWidth, int iSrcHeight, -+ int iFlushFlag); -+ -+ /* Mapping functions */ -+ void *(*MapEGLImage)(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psImage, -+ PVRDRIBufferImpl *psBuffer, -+ int iX, int iY, -+ int iWidth, int iHeight, -+ unsigned iFlags, -+ int *piStride, -+ void **ppvData); -+ -+ bool (*UnmapEGLImage)(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psImage, PVRDRIBufferImpl *psBuffer, -+ void *pvData); -+ -+ /* PVR utility support functions */ -+ bool (*MesaFormatSupported)(unsigned fmt); -+ unsigned (*DepthStencilBitArraySize)(void); -+ const uint8_t *(*DepthBitsArray)(void); -+ const uint8_t *(*StencilBitsArray)(void); -+ unsigned (*MSAABitArraySize)(void); -+ const uint8_t *(*MSAABitsArray)(void); -+ uint32_t (*MaxPBufferWidth)(void); -+ uint32_t (*MaxPBufferHeight)(void); -+ -+ unsigned (*GetNumAPIFuncs)(PVRDRIAPIType eAPI); -+ const char *(*GetAPIFunc)(PVRDRIAPIType eAPI, unsigned index); -+ -+ int (*QuerySupportedFormats)(PVRDRIScreenImpl *psScreenImpl, -+ unsigned uNumFormats, -+ const int *piFormats, -+ const IMG_PIXFMT *peImgFormats, -+ bool *pbSupported); -+ -+ int (*QueryModifiers)(PVRDRIScreenImpl *psScreenImpl, -+ int iFormat, -+ IMG_PIXFMT eImgFormat, -+ uint64_t *puModifiers, -+ unsigned *puExternalOnly); -+ -+ /********************************************************************** -+ * Version 1 functions -+ **********************************************************************/ -+ -+ unsigned (*CreateContextV1)(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psSharedContextImpl, -+ PVRDRIConfig *psConfig, -+ PVRDRIAPIType eAPI, -+ PVRDRIAPISubType eAPISub, -+ unsigned uMajorVersion, -+ unsigned uMinorVersion, -+ uint32_t uFlags, -+ bool bNotifyReset, -+ unsigned uPriority, -+ PVRDRIContextImpl **ppsContextImpl); -+ -+ PVRDRIDrawableImpl *(*CreateDrawableWithConfig)(PVRDRIDrawable *psPVRDrawable, -+ PVRDRIConfig *psConfig); -+ -+ /********************************************************************** -+ * Version 2 functions -+ **********************************************************************/ -+ -+ unsigned (*GetFenceCapabilities)(PVRDRIScreenImpl *psScreenImpl); -+ -+ void *(*CreateFenceFd)(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ int iFd); -+ -+ int (*GetFenceFd)(void *psDRIFence); -+} PVRDRISupportInterface; -+ -+/* Callbacks into non-impl layer (deprecated) */ -+typedef struct -+{ -+ /********************************************************************** -+ * Version 0 callbacks -+ **********************************************************************/ -+ -+ /* Obsolete (no longer supported) */ -+ bool (*DrawableRecreate)(PVRDRIDrawable *psPVRDrawable); -+ /* Obsolete (no longer supported) */ -+ bool (*DrawableGetParameters)(PVRDRIDrawable *psPVRDrawable, -+ PVRDRIBufferImpl **ppsDstBuffer, -+ PVRDRIBufferImpl **ppsAccumBuffer, -+ PVRDRIBufferAttribs *psAttribs, -+ bool *pbDoubleBuffered); -+ -+ PVRDRIImageType (*ImageGetSharedType)(__DRIimage *image); -+ PVRDRIBufferImpl *(*ImageGetSharedBuffer)(__DRIimage *image); -+ IMGEGLImage *(*ImageGetSharedEGLImage)(__DRIimage *image); -+ IMGEGLImage *(*ImageGetEGLImage)(__DRIimage *image); -+ __DRIimage *(*ScreenGetDRIImage)(void *hEGLImage); -+ void (*RefImage)(__DRIimage *image); -+ void (*UnrefImage)(__DRIimage *image); -+ -+ /* -+ * If the DRI module calls PVRDRIRegisterCallbacks, or -+ * PVRDRIRegisterVersionedCallbacks with any version number, -+ * the DRI support library can use the callbacks above. -+ * The callbacks below can only be called if -+ * PVRDRIRegisterVersionedCallbacks is called with a suitable -+ * version number. -+ */ -+ -+ /********************************************************************** -+ * Version 1 callbacks -+ **********************************************************************/ -+ -+ /* Obsolete (no longer supported) */ -+ bool (*DrawableGetParametersV1)(PVRDRIDrawable *psPVRDrawable, -+ bool bAllowRecreate, -+ PVRDRIBufferImpl **ppsDstBuffer, -+ PVRDRIBufferImpl **ppsAccumBuffer, -+ PVRDRIBufferAttribs *psAttribs, -+ bool *pbDoubleBuffered); -+ -+ /* -+ * Register the DRI Support interface with the DRI module. -+ * The caller is not required to preserve the PVRDRICallbacks structure -+ * after the call, so the callee must make a copy. -+ */ -+ bool (*RegisterSupportInterfaceV1)(const PVRDRISupportInterface *psInterface, -+ unsigned uVersion); -+ -+ /********************************************************************** -+ * Version 2 callbacks -+ **********************************************************************/ -+ -+ bool (*ConfigQuery)(const PVRDRIConfig *psConfig, -+ PVRDRIConfigAttrib eConfigAttrib, -+ int *piValueOut); -+ /* -+ * DrawableGetParametersV2 is a replacement for DrawableGetParametersV1. -+ * Unlike earlier versions, the caller is expected to query drawable -+ * information (via DrawableQuery) instead of this information being -+ * returned by the callback. -+ */ -+ bool (*DrawableGetParametersV2)(PVRDRIDrawable *psPVRDrawable, -+ uint32_t uiFlags, -+ PVRDRIBufferImpl **ppsDstBuffer, -+ PVRDRIBufferImpl **ppsAccumBuffer); -+ bool (*DrawableQuery)(const PVRDRIDrawable *psPVRDrawable, -+ PVRDRIBufferAttrib eBufferAttrib, -+ uint32_t *uiValueOut); -+ -+ /********************************************************************** -+ * Version 3 callbacks -+ **********************************************************************/ -+} PVRDRICallbacks; -+ -+/* -+ * The caller of PVRDRIRegisterVersionedCallbacks is not required to preserve -+ * the PVRDRICallbacks structure after the call, so the callee may need to -+ * make a copy of the structure. -+ */ -+bool PVRDRIRegisterVersionedCallbacks(const PVRDRICallbacks *psCallbacks, -+ unsigned uVersion); -+ -+/* The context flags match their __DRI_CTX_RESET counterparts */ -+#define PVRDRI_CONTEXT_RESET_NO_NOTIFICATION 0 -+#define PVRDRI_CONTEXT_RESET_LOSE_CONTEXT 1 -+ -+/* The context flags match their __DRI_CTX_RELEASE counterparts */ -+#define PVRDRI_CONTEXT_RELEASE_BEHAVIOR_NONE 0 -+#define PVRDRI_CONTEXT_RELEASE_BEHAVIOR_FLUSH 1 -+ -+/* The flush flags match their __DRI2_FLUSH counterparts */ -+#define PVRDRI_FLUSH_DRAWABLE (1 << 0) -+#define PVRDRI_FLUSH_CONTEXT (1 << 1) -+#define PVRDRI_FLUSH_INVALIDATE_ANCILLARY (1 << 2) -+ -+/* The throttle reason defines match their __DRI2_THROTTLE counterparts */ -+#define PVRDRI_THROTTLE_SWAPBUFFER 0 -+#define PVRDRI_THROTTLE_COPYSUBBUFFER 1 -+#define PVRDRI_THROTTLE_FLUSHFRONT 2 -+ -+/* The render query defines match their __DRI2_RENDERER counterparts */ -+#define PVRDRI_RENDERER_VENDOR_ID 0x0000 -+#define PVRDRI_RENDERER_DEVICE_ID 0x0001 -+ -+#define PVRDRI_RENDERER_HAS_TEXTURE_3D 0x000b -+#define PVRDRI_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c -+ -+#define PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY 0x000d -+#define PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0) -+#define PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1) -+#define PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2) -+ -+#define PVRDRI_RENDERER_OPENGL_ES2_CONTEXT_CLIENT_VERSION_IMG 0x7001 -+ -+/* The fence extension defines match their __DRI2_FENCE counterparts */ -+#define PVRDRI_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffull -+#define PVRDRI_FENCE_FLAG_FLUSH_COMMANDS (1 << 0) -+ -+/* The YUV defines match their __DRI_YUV counterparts */ -+#define PVRDRI_YUV_COLOR_SPACE_UNDEFINED 0 -+#define PVRDRI_YUV_COLOR_SPACE_ITU_REC601 0x327F -+#define PVRDRI_YUV_COLOR_SPACE_ITU_REC709 0x3280 -+#define PVRDRI_YUV_COLOR_SPACE_ITU_REC2020 0x3281 -+ -+#define PVRDRI_YUV_RANGE_UNDEFINED 0 -+#define PVRDRI_YUV_FULL_RANGE 0x3282 -+#define PVRDRI_YUV_NARROW_RANGE 0x3283 -+ -+#define PVRDRI_YUV_CHROMA_SITING_UNDEFINED 0 -+#define PVRDRI_YUV_CHROMA_SITING_0 0x3284 -+#define PVRDRI_YUV_CHROMA_SITING_0_5 0x3285 -+ -+/* -+ * The image component defines match their __DRI2_IMAGE_COMPONENTS -+ * counterparts. -+ */ -+#define PVRDRI_IMAGE_COMPONENTS_RGB 0x3001 -+#define PVRDRI_IMAGE_COMPONENTS_RGBA 0x3002 -+#define PVRDRI_IMAGE_COMPONENTS_Y_U_V 0x3003 -+#define PVRDRI_IMAGE_COMPONENTS_Y_UV 0x3004 -+#define PVRDRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 -+#define PVRDRI_IMAGE_COMPONENTS_R 0x3006 -+#define PVRDRI_IMAGE_COMPONENTS_RG 0x3007 -+#define PVRDRI_IMAGE_COMPONENTS_Y_UXVX 0x3008 -+#define PVRDRI_IMAGE_COMPONENTS_AYUV 0x3009 -+#define PVRDRI_IMAGE_COMPONENTS_XYUV 0x300A -+#define PVRDRI_IMAGE_COMPONENTS_EXTERNAL 0x300B -+ -+/* -+ * The image format modifier attribute defines match their -+ * __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB counterparts. -+ */ -+#define PVRDRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT 0x0001 -+ -+/* The image attribute defines match their __DRI_IMAGE_ATTRIB counterparts */ -+#define PVRDRI_IMAGE_ATTRIB_STRIDE 0x2000 -+#define PVRDRI_IMAGE_ATTRIB_HANDLE 0x2001 -+#define PVRDRI_IMAGE_ATTRIB_NAME 0x2002 -+#define PVRDRI_IMAGE_ATTRIB_FORMAT 0x2003 -+#define PVRDRI_IMAGE_ATTRIB_WIDTH 0x2004 -+#define PVRDRI_IMAGE_ATTRIB_HEIGHT 0x2005 -+#define PVRDRI_IMAGE_ATTRIB_COMPONENTS 0x2006 -+#define PVRDRI_IMAGE_ATTRIB_FD 0x2007 -+#define PVRDRI_IMAGE_ATTRIB_FOURCC 0x2008 -+#define PVRDRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 -+#define PVRDRI_IMAGE_ATTRIB_OFFSET 0x200A -+#define PVRDRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B -+#define PVRDRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C -+ -+/* The GL defines match their EGL_GL counterparts */ ++/* The PVRDRI_GL defines match their EGL_GL counterparts */ +#define PVRDRI_GL_RENDERBUFFER 0x30B9 +#define PVRDRI_GL_TEXTURE_2D 0x30B1 +#define PVRDRI_GL_TEXTURE_3D 0x30B2 @@ -939,19 +240,10 @@ index 00000000000..b5da4d95a03 +#define PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 +#define PVRDRI_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 + -+/* The CL defines match their EGL_CL counterparts */ -+#define PVRDRI_CL_IMAGE_IMG 0x6010 -+ -+/* The swap attribute defines match their __DRI_ATTRIB_SWAP counterparts */ -+#define PVRDRI_ATTRIB_SWAP_NONE 0x0000 -+#define PVRDRI_ATTRIB_SWAP_EXCHANGE 0x8061 -+#define PVRDRI_ATTRIB_SWAP_COPY 0x8062 -+#define PVRDRI_ATTRIB_SWAP_UNDEFINED 0x8063 -+ +struct __DRIscreenRec; +struct __DRIcontextRec; +struct __DRIdrawableRec; -+struct __DRIbufferRec; ++ +struct __DRIconfigRec; + +struct DRISUPScreen; @@ -970,9 +262,6 @@ index 00000000000..b5da4d95a03 + int iReleaseBehavior; +}; + -+/* The image capability defines match their __DRI_IMAGE_CAP counterparts */ -+#define PVRDRI_IMAGE_CAP_GLOBAL_NAMES 1 -+ +/* + * PVR DRI Support interface V2. + * This structure may change over time, as older interfaces become obsolete. @@ -1323,16 +612,12 @@ index 00000000000..b5da4d95a03 + * OpenCL event based fences are available, provided the DDK is built + * with OpenCL support. + */ ++ /* The v4 interface is an extension of v3, so v3 is required as well */ ++ struct { ++ bool (*HaveGetFenceFromCLEvent)(void); ++ } v4; +}; + -+/* -+ * Buffer mask values for the GetBuffers callback. These are the same as -+ * their enum __DRIimageBufferMask counterparts. -+ */ -+#define PVRDRI_IMAGE_BUFFER_BACK (1U << 0) -+#define PVRDRI_IMAGE_BUFFER_FRONT (1U << 1) -+#define PVRDRI_IMAGE_BUFFER_PREV (1U << 31) -+ +struct PVRDRIImageList { + uint32_t uImageMask; + __DRIimage *psBack; @@ -1340,9 +625,6 @@ index 00000000000..b5da4d95a03 + __DRIimage *psPrev; +}; + -+/* The loader capabilities defines match their dri_loader_cap counterparts */ -+#define PVRDRI_LOADER_CAP_RGBA_ORDERING 0 -+ +/* + * PVR DRI Support callback interface V2. + * This structure may change over time, as older interfaces become obsolete. @@ -1409,6 +691,23 @@ index 00000000000..b5da4d95a03 + (struct __DRIdrawableRec *psDRIDrawable, + void *pvLoaderPrivate); + } v1; ++ /* The v2 interface is an extension of v1, so v1 is required as well */ ++ struct { ++ int (*GetDisplayFD) ++ (struct __DRIscreenRec *psDRIScreen, ++ void *pvLoaderPrivate); ++ } v2; ++ /* The v3 interface is an extension of v2, so v2 is required as well */ ++ struct { ++ void *(*DrawableGetReferenceHandle) ++ (struct __DRIdrawableRec *psDRIDrawable); ++ ++ void (*DrawableAddReference) ++ (void *pvReferenceHandle); ++ ++ void (*DrawableRemoveReference) ++ (void *pvReferenceHandle); ++ } v3; +}; + +#endif /* defined(__PVRDRIIFCE_H__) */ @@ -2124,10 +1423,10 @@ index 00000000000..d36bae5ac54 +} diff --git a/src/mesa/drivers/dri/pvr/meson.build b/src/mesa/drivers/dri/pvr/meson.build new file mode 100644 -index 00000000000..51b3b11948d +index 00000000000..59cccf8add4 --- /dev/null +++ b/src/mesa/drivers/dri/pvr/meson.build -@@ -0,0 +1,53 @@ +@@ -0,0 +1,48 @@ +# Copyright (c) Imagination Technologies Ltd. +# +# The contents of this file are subject to the MIT license as set out below. @@ -2154,14 +1453,9 @@ index 00000000000..51b3b11948d + 'mesa_context.c', + 'pvrcb.c', + 'pvrcompat.c', -+ 'pvrdrawable_mod.c', + 'pvrdri.c', -+ 'pvrdri_mod.c', + 'pvrext.c', -+ 'pvrext_mod.c', -+ 'pvrimage_mod.c', + 'pvrutil.c', -+ 'pvrutil_mod.c', +) + +dep_libpvr = [ @@ -2183,10 +1477,10 @@ index 00000000000..51b3b11948d +) diff --git a/src/mesa/drivers/dri/pvr/pvrcb.c b/src/mesa/drivers/dri/pvr/pvrcb.c new file mode 100644 -index 00000000000..e1232e5c400 +index 00000000000..ea8911c64d5 --- /dev/null +++ b/src/mesa/drivers/dri/pvr/pvrcb.c -@@ -0,0 +1,282 @@ +@@ -0,0 +1,328 @@ +/* + * Copyright (c) Imagination Technologies Ltd. + * @@ -2259,7 +1553,7 @@ index 00000000000..e1232e5c400 + const unsigned int *puDBModes, unsigned int uNumDBModes, + const uint8_t *puMSAASamples, unsigned int uNumMSAAModes, + bool bEnableAccum, bool bColorDepthMatch, -+ bool bMutableRenderBuffer, ++ UNUSED bool bMutableRenderBuffer, + int iYUVDepthRange, int iYUVCSCStandard, + uint32_t uMaxPbufferWidth, uint32_t uMaxPbufferHeight) +{ @@ -2289,7 +1583,6 @@ index 00000000000..e1232e5c400 + uNumDepthStencilBits, (GLenum *) puDBModes, + uNumDBModes, puMSAASamples, uNumMSAAModes, + bEnableAccum, bColorDepthMatch, -+ bMutableRenderBuffer, + iYUVDepthRange, iYUVCSCStandard); + if (!ppsConfigs) + return false; @@ -2341,74 +1634,90 @@ index 00000000000..e1232e5c400 + return 0; +} + -+bool -+PVRDRIConfigQuery(const PVRDRIConfig *psConfig, -+ PVRDRIConfigAttrib eConfigAttrib, int *piValueOut) ++int ++MODSUPGetDisplayFD(__DRIscreen *psDRIScreen, void *pvLoaderPrivate) +{ -+ if (!psConfig || !piValueOut) ++#if __DRI_IMAGE_LOADER_VERSION >= 5 ++ if (psDRIScreen->image.loader->base.version >= 5 && ++ psDRIScreen->image.loader->getDisplayFD) ++ return psDRIScreen->image.loader->getDisplayFD(pvLoaderPrivate); ++#else ++ (void) psDRIScreen; ++ (void) pvLoaderPrivate; ++#endif ++ ++ return -1; ++} ++ ++static bool ++PVRDRIConfigQueryUnsigned(const PVRDRIConfig *psConfig, ++ PVRDRIConfigAttrib eConfigAttrib, ++ unsigned int *puValueOut) ++{ ++ if (!psConfig || !puValueOut) + return false; + + switch (eConfigAttrib) { + case PVRDRI_CONFIG_ATTRIB_RENDERABLE_TYPE: -+ *piValueOut = psConfig->iSupportedAPIs; ++ *puValueOut = psConfig->iSupportedAPIs; + return true; + case PVRDRI_CONFIG_ATTRIB_RGB_MODE: -+ *piValueOut = psConfig->sGLMode.rgbMode; ++ *puValueOut = psConfig->sGLMode.rgbMode; + return true; + case PVRDRI_CONFIG_ATTRIB_DOUBLE_BUFFER_MODE: -+ *piValueOut = psConfig->sGLMode.doubleBufferMode; ++ *puValueOut = psConfig->sGLMode.doubleBufferMode; + return true; + case PVRDRI_CONFIG_ATTRIB_RED_BITS: -+ *piValueOut = psConfig->sGLMode.redBits; ++ *puValueOut = psConfig->sGLMode.redBits; + return true; + case PVRDRI_CONFIG_ATTRIB_GREEN_BITS: -+ *piValueOut = psConfig->sGLMode.greenBits; ++ *puValueOut = psConfig->sGLMode.greenBits; + return true; + case PVRDRI_CONFIG_ATTRIB_BLUE_BITS: -+ *piValueOut = psConfig->sGLMode.blueBits; ++ *puValueOut = psConfig->sGLMode.blueBits; + return true; + case PVRDRI_CONFIG_ATTRIB_ALPHA_BITS: -+ *piValueOut = psConfig->sGLMode.alphaBits; ++ *puValueOut = psConfig->sGLMode.alphaBits; + return true; + case PVRDRI_CONFIG_ATTRIB_RGB_BITS: -+ *piValueOut = psConfig->sGLMode.rgbBits; ++ *puValueOut = psConfig->sGLMode.rgbBits; + return true; + case PVRDRI_CONFIG_ATTRIB_DEPTH_BITS: -+ *piValueOut = psConfig->sGLMode.depthBits; ++ *puValueOut = psConfig->sGLMode.depthBits; + return true; + case PVRDRI_CONFIG_ATTRIB_STENCIL_BITS: -+ *piValueOut = psConfig->sGLMode.stencilBits; ++ *puValueOut = psConfig->sGLMode.stencilBits; + return true; + case PVRDRI_CONFIG_ATTRIB_SAMPLE_BUFFERS: -+ *piValueOut = psConfig->sGLMode.sampleBuffers; ++ *puValueOut = !!psConfig->sGLMode.samples; + return true; + case PVRDRI_CONFIG_ATTRIB_SAMPLES: -+ *piValueOut = psConfig->sGLMode.samples; ++ *puValueOut = psConfig->sGLMode.samples; + return true; + case PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGB: -+ *piValueOut = psConfig->sGLMode.bindToTextureRgb; ++ *puValueOut = GL_TRUE; + return true; + case PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGBA: -+ *piValueOut = psConfig->sGLMode.bindToTextureRgba; ++ *puValueOut = GL_TRUE; + return true; +#if defined(__DRI_ATTRIB_YUV_BIT) + case PVRDRI_CONFIG_ATTRIB_YUV_ORDER: -+ *piValueOut = psConfig->sGLMode.YUVOrder; ++ *puValueOut = psConfig->sGLMode.YUVOrder; + return true; + case PVRDRI_CONFIG_ATTRIB_YUV_NUM_OF_PLANES: -+ *piValueOut = psConfig->sGLMode.YUVNumberOfPlanes; ++ *puValueOut = psConfig->sGLMode.YUVNumberOfPlanes; + return true; + case PVRDRI_CONFIG_ATTRIB_YUV_SUBSAMPLE: -+ *piValueOut = psConfig->sGLMode.YUVSubsample; ++ *puValueOut = psConfig->sGLMode.YUVSubsample; + return true; + case PVRDRI_CONFIG_ATTRIB_YUV_DEPTH_RANGE: -+ *piValueOut = psConfig->sGLMode.YUVDepthRange; ++ *puValueOut = psConfig->sGLMode.YUVDepthRange; + return true; + case PVRDRI_CONFIG_ATTRIB_YUV_CSC_STANDARD: -+ *piValueOut = psConfig->sGLMode.YUVCSCStandard; ++ *puValueOut = psConfig->sGLMode.YUVCSCStandard; + return true; + case PVRDRI_CONFIG_ATTRIB_YUV_PLANE_BPP: -+ *piValueOut = psConfig->sGLMode.YUVPlaneBPP; ++ *puValueOut = psConfig->sGLMode.YUVPlaneBPP; + return true; +#endif +#if !defined(__DRI_ATTRIB_YUV_BIT) @@ -2421,19 +1730,19 @@ index 00000000000..e1232e5c400 + return false; +#endif + case PVRDRI_CONFIG_ATTRIB_RED_MASK: -+ *piValueOut = psConfig->sGLMode.redMask; ++ *puValueOut = psConfig->sGLMode.redMask; + return true; + case PVRDRI_CONFIG_ATTRIB_GREEN_MASK: -+ *piValueOut = psConfig->sGLMode.greenMask; ++ *puValueOut = psConfig->sGLMode.greenMask; + return true; + case PVRDRI_CONFIG_ATTRIB_BLUE_MASK: -+ *piValueOut = psConfig->sGLMode.blueMask; ++ *puValueOut = psConfig->sGLMode.blueMask; + return true; + case PVRDRI_CONFIG_ATTRIB_ALPHA_MASK: -+ *piValueOut = psConfig->sGLMode.alphaMask; ++ *puValueOut = psConfig->sGLMode.alphaMask; + return true; + case PVRDRI_CONFIG_ATTRIB_SRGB_CAPABLE: -+ *piValueOut = psConfig->sGLMode.sRGBCapable; ++ *puValueOut = psConfig->sGLMode.sRGBCapable; + return true; + case PVRDRI_CONFIG_ATTRIB_INVALID: + errorMessage("%s: Invalid attribute", __func__); @@ -2445,17 +1754,24 @@ index 00000000000..e1232e5c400 +} + +bool ++PVRDRIConfigQuery(const PVRDRIConfig *psConfig, ++ PVRDRIConfigAttrib eConfigAttrib, int *piValueOut) ++{ ++ bool bRes; ++ unsigned int uValue; ++ ++ bRes = PVRDRIConfigQueryUnsigned(psConfig, eConfigAttrib, &uValue); ++ if (bRes) ++ *piValueOut = (int) uValue; ++ ++ return bRes; ++} ++ ++bool +MODSUPConfigQuery(const PVRDRIConfig *psConfig, + PVRDRIConfigAttrib eConfigAttrib, unsigned int *puValueOut) +{ -+ bool bRes; -+ int iValue; -+ -+ bRes = PVRDRIConfigQuery(psConfig, eConfigAttrib, &iValue); -+ if (bRes) -+ *puValueOut = (unsigned int) iValue; -+ -+ return bRes; ++ return PVRDRIConfigQueryUnsigned(psConfig, eConfigAttrib, puValueOut); +} + +void @@ -2469,12 +1785,36 @@ index 00000000000..e1232e5c400 + psDRIScreen->image.loader->flushFrontBuffer(psDRIDrawable, + pvLoaderPrivate); +} ++ ++void * ++MODSUPDrawableGetReferenceHandle(struct __DRIdrawableRec *psDRIDrawable) ++{ ++ PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate; ++ ++ return psPVRDrawable; ++} ++ ++void ++MODSUPDrawableAddReference(void *pvReferenceHandle) ++{ ++ PVRDRIDrawable *psPVRDrawable = pvReferenceHandle; ++ ++ PVRDRIDrawableAddReference(psPVRDrawable); ++} ++ ++void ++MODSUPDrawableRemoveReference(void *pvReferenceHandle) ++{ ++ PVRDRIDrawable *psPVRDrawable = pvReferenceHandle; ++ ++ PVRDRIDrawableRemoveReference(psPVRDrawable); ++} diff --git a/src/mesa/drivers/dri/pvr/pvrcompat.c b/src/mesa/drivers/dri/pvr/pvrcompat.c new file mode 100644 -index 00000000000..70335a2c7d9 +index 00000000000..23a57dde682 --- /dev/null +++ b/src/mesa/drivers/dri/pvr/pvrcompat.c -@@ -0,0 +1,1552 @@ +@@ -0,0 +1,838 @@ +/* + * Copyright (c) Imagination Technologies Ltd. + * @@ -2509,7 +1849,6 @@ index 00000000000..70335a2c7d9 +#include + +#include "pvrdri.h" -+#include "pvrdri_mod.h" + +#ifndef DRM_FORMAT_MOD_INVALID +#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1) @@ -2523,33 +1862,16 @@ index 00000000000..70335a2c7d9 +static void *gpvSupLib; +static int giSupLibRef; + -+static PVRDRISupportInterface gsSup; +static struct PVRDRISupportInterfaceV2 gsSupV2; + +static pthread_mutex_t gsCompatLock = PTHREAD_MUTEX_INITIALIZER; + -+/* Call a function via the DRI Support interface structure */ -+#define CallFunc(field, ...) \ -+ do { \ -+ if (gsSup.field) \ -+ return gsSup.field(__VA_ARGS__); \ -+ } while(0) -+ +/* Lookup a function, and set the pointer to the function address */ +#define LookupFunc(func, ptr) \ + do { \ + ptr = dlsym(gpvSupLib, MAKESTRING(func)); \ + } while(0) + -+/* -+ * Calculate the size of a particular version of the PVRDRISupportInterface -+ * structure from the name of the last field in that version of the -+ * structure. -+ */ -+#define PVRDRIInterfaceSize(field) \ -+ (offsetof(PVRDRISupportInterface, field) + \ -+ sizeof((PVRDRISupportInterface *)0)->field) -+ +/* Call a function via the DRI Support interface structure */ +#define CallFuncV2(field, ...) \ + do { \ @@ -2655,78 +1977,13 @@ index 00000000000..70335a2c7d9 +CompatDeinit(void) +{ + UnloadSupportLib(); -+ memset(&gsSup, 0, sizeof(gsSup)); + memset(&gsSupV2, 0, sizeof(gsSupV2)); +} + -+static void -+SetupLocalDRISupportInterfaceV2(void) -+{ -+ gsSupV2.v0.CreateScreen = DRIMODCreateScreen; -+ gsSupV2.v0.DestroyScreen = DRIMODDestroyScreen; -+ gsSupV2.v0.CreateContext = DRIMODCreateContext; -+ gsSupV2.v0.DestroyContext = DRIMODDestroyContext; -+ gsSupV2.v0.CreateDrawable = DRIMODCreateDrawable; -+ gsSupV2.v0.DestroyDrawable = DRIMODDestroyDrawable; -+ gsSupV2.v0.MakeCurrent = DRIMODMakeCurrent; -+ gsSupV2.v0.UnbindContext = DRIMODUnbindContext; -+ gsSupV2.v0.AllocateBuffer = DRIMODAllocateBuffer; -+ gsSupV2.v0.ReleaseBuffer = DRIMODReleaseBuffer; -+ gsSupV2.v0.SetTexBuffer2 = DRIMODSetTexBuffer2; -+ gsSupV2.v0.ReleaseTexBuffer = DRIMODReleaseTexBuffer; -+ gsSupV2.v0.Flush = DRIMODFlush; -+ gsSupV2.v0.Invalidate = DRIMODInvalidate; -+ gsSupV2.v0.FlushWithFlags = DRIMODFlushWithFlags; -+ gsSupV2.v0.CreateImageFromName = DRIMODCreateImageFromName; -+ gsSupV2.v0.CreateImageFromRenderbuffer = -+ DRIMODCreateImageFromRenderbuffer; -+ gsSupV2.v0.DestroyImage = DRIMODDestroyImage; -+ gsSupV2.v0.CreateImage = DRIMODCreateImage; -+ gsSupV2.v0.QueryImage = DRIMODQueryImage; -+ gsSupV2.v0.DupImage = DRIMODDupImage; -+ gsSupV2.v0.ValidateImageUsage = DRIMODValidateImageUsage; -+ gsSupV2.v0.CreateImageFromNames = DRIMODCreateImageFromNames; -+ gsSupV2.v0.FromPlanar = DRIMODFromPlanar; -+ gsSupV2.v0.CreateImageFromTexture = DRIMODCreateImageFromTexture; -+ gsSupV2.v0.CreateImageFromFDs = DRIMODCreateImageFromFDs; -+ gsSupV2.v0.CreateImageFromDMABufs = DRIMODCreateImageFromDMABufs; -+ gsSupV2.v0.GetImageCapabilities = DRIMODGetImageCapabilities; -+ gsSupV2.v0.BlitImage = DRIMODBlitImage; -+ gsSupV2.v0.MapImage = DRIMODMapImage; -+ gsSupV2.v0.UnmapImage = DRIMODUnmapImage; -+ gsSupV2.v0.CreateImageWithModifiers = DRIMODCreateImageWithModifiers; -+ gsSupV2.v0.CreateImageFromDMABufs2 = DRIMODCreateImageFromDMABufs2; -+ gsSupV2.v0.QueryDMABufFormats = DRIMODQueryDMABufFormats; -+ gsSupV2.v0.QueryDMABufModifiers = DRIMODQueryDMABufModifiers; -+ gsSupV2.v0.QueryDMABufFormatModifierAttribs = -+ DRIMODQueryDMABufFormatModifierAttribs; -+ gsSupV2.v0.CreateImageFromRenderBuffer2 = -+ DRIMODCreateImageFromRenderBuffer2; -+ gsSupV2.v0.CreateImageFromBuffer = DRIMODCreateImageFromBuffer; -+ gsSupV2.v0.QueryRendererInteger = DRIMODQueryRendererInteger; -+ gsSupV2.v0.QueryRendererString = DRIMODQueryRendererString; -+ gsSupV2.v0.CreateFence = DRIMODCreateFence; -+ gsSupV2.v0.DestroyFence = DRIMODDestroyFence; -+ gsSupV2.v0.ClientWaitSync = DRIMODClientWaitSync; -+ gsSupV2.v0.ServerWaitSync = DRIMODServerWaitSync; -+ gsSupV2.v0.GetFenceCapabilities = DRIMODGetFenceCapabilities; -+ gsSupV2.v0.CreateFenceFD = DRIMODCreateFenceFD; -+ gsSupV2.v0.GetFenceFD = DRIMODGetFenceFD; -+ gsSupV2.v0.GetNumAPIProcs = DRIMODGetNumAPIProcs; -+ gsSupV2.v0.GetAPIProcName = DRIMODGetAPIProcName; -+ gsSupV2.v0.GetAPIProcAddress = DRIMODGetAPIProcAddress; -+ gsSupV2.v0.SetDamageRegion = DRIMODSetDamageRegion; -+ -+ PVRDRIAdjustExtensions(0, 0); -+} -+ +bool -+PVRDRICompatInit(const PVRDRICallbacks *psCallbacks, unsigned int uVersion, -+ const struct PVRDRICallbacksV2 *psCallbacksV2, ++PVRDRICompatInit(const struct PVRDRICallbacksV2 *psCallbacksV2, + unsigned int uVersionV2, unsigned int uMinVersionV2) +{ -+ bool (*pfRegisterVersionedCallbacks)(const PVRDRICallbacks *psCallbacks, -+ unsigned int uVersion); + bool (*pfRegisterVersionedCallbacksV2)(const void *pvCallbacks, + unsigned int uVersion, + unsigned int uMinVersion); @@ -2744,22 +2001,12 @@ index 00000000000..70335a2c7d9 + LookupFunc(PVRDRIRegisterVersionedCallbacksV2, + pfRegisterVersionedCallbacksV2); + -+ LookupFunc(PVRDRIRegisterVersionedCallbacks, -+ pfRegisterVersionedCallbacks); -+ -+ res = (pfRegisterVersionedCallbacksV2 != NULL) || -+ (pfRegisterVersionedCallbacks != NULL); ++ res = (pfRegisterVersionedCallbacksV2 != NULL); + if (!res) + goto Exit; + -+ if (pfRegisterVersionedCallbacksV2) { -+ res = pfRegisterVersionedCallbacksV2(psCallbacksV2, -+ uVersionV2, uMinVersionV2); -+ } else { -+ res = pfRegisterVersionedCallbacks(psCallbacks, uVersion); -+ if (res) -+ SetupLocalDRISupportInterfaceV2(); -+ } ++ res = pfRegisterVersionedCallbacksV2(psCallbacksV2, ++ uVersionV2, uMinVersionV2); + +Exit: + if (!res) { @@ -2781,38 +2028,12 @@ index 00000000000..70335a2c7d9 +} + +bool -+PVRDRIRegisterSupportInterfaceV1(const PVRDRISupportInterface *psInterface, -+ unsigned int uVersion) -+{ -+ size_t uSize; -+ -+ memset(&gsSup, 0, sizeof(gsSup)); -+ memset(&gsSupV2, 0, sizeof(gsSupV2)); -+ -+ /* The "default" case should be associated with the latest version */ -+ switch (uVersion) { -+ default: -+ case 2: -+ uSize = PVRDRIInterfaceSize(GetFenceFd); -+ break; -+ case 1: -+ case 0: -+ return false; -+ } -+ -+ memcpy(&gsSup, psInterface, uSize); -+ -+ return true; -+} -+ -+bool +MODSUPRegisterSupportInterfaceV2(const void *pvInterface, + unsigned int uVersion, + unsigned int uMinVersion) +{ + size_t uStart, uEnd; + -+ memset(&gsSup, 0, sizeof(gsSup)); + memset(&gsSupV2, 0, sizeof(gsSupV2)); + + if (uVersion < uMinVersion) @@ -2832,6 +2053,8 @@ index 00000000000..70335a2c7d9 + break; + case 1: + case 2: ++ case 3: ++ case 4: + /* These versions require version 0 */ + return false; + default: @@ -2841,6 +2064,13 @@ index 00000000000..70335a2c7d9 + /* The "default" case should be associated with the latest version */ + switch (uVersion) { + default: ++ case 4: ++ /* This version is an extension of versions 0 to 3 */ ++ if (uMinVersion > 0) ++ return false; ++ ++ uEnd = PVRDRIInterfaceV2End(v4); ++ break; + case 3: + /* + * This version is an extension of version 2, with no new @@ -2904,7 +2134,7 @@ index 00000000000..70335a2c7d9 + eAPI, psPVRDRIConfig, psCtxConfig, psDRIContext, + psDRISUPSharedContext, psDRISUPScreen, ppsDRISUPContext); + -+ return PVRDRI_CONTEXT_ERROR_BAD_API; ++ return __DRI_CTX_ERROR_BAD_API; +} + +void @@ -3416,1014 +2646,19 @@ index 00000000000..70335a2c7d9 + psDRISUPDrawable, uNRects, piRects); +} + -+/****************************************************************************** -+ * PVR DRI Support interface, version 1. -+ * Everything below this point is deprecated. -+ *****************************************************************************/ -+ -+PVRDRIDeviceType -+PVRDRIGetDeviceTypeFromFd(int iFd) -+{ -+ CallFunc(GetDeviceTypeFromFd, iFd); -+ -+ return PVRDRI_DEVICE_TYPE_INVALID; -+} -+ -+ +bool -+PVRDRIIsFirstScreen(PVRDRIScreenImpl *psScreenImpl) ++DRISUPHaveGetFenceFromCLEvent(void) +{ -+ CallFunc(IsFirstScreen, psScreenImpl); -+ -+ return false; -+} -+ -+ -+uint32_t -+PVRDRIPixFmtGetDepth(IMG_PIXFMT eFmt) -+{ -+ CallFunc(PixFmtGetDepth, eFmt); -+ -+ return 0; -+} -+ -+uint32_t -+PVRDRIPixFmtGetBPP(IMG_PIXFMT eFmt) -+{ -+ CallFunc(PixFmtGetBPP, eFmt); -+ -+ return 0; -+} -+ -+uint32_t -+PVRDRIPixFmtGetBlockSize(IMG_PIXFMT eFmt) -+{ -+ CallFunc(PixFmtGetBlockSize, eFmt); -+ -+ return 0; -+} -+ -+PVRDRIScreenImpl * -+PVRDRICreateScreenImpl(int iFd) -+{ -+ CallFunc(CreateScreen, iFd); -+ -+ return NULL; -+} -+ -+void -+PVRDRIDestroyScreenImpl(PVRDRIScreenImpl *psScreenImpl) -+{ -+ CallFunc(DestroyScreen, psScreenImpl); -+} -+ -+int -+PVRDRIAPIVersion(PVRDRIAPIType eAPI, PVRDRIAPISubType eAPISub, -+ PVRDRIScreenImpl *psScreenImpl) -+{ -+ CallFunc(APIVersion, eAPI, eAPISub, psScreenImpl); -+ -+ return 0; -+} -+ -+void * -+PVRDRIEGLGetLibHandle(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl) -+{ -+ CallFunc(EGLGetLibHandle, eAPI, psScreenImpl); -+ -+ return NULL; -+} -+ -+PVRDRIGLAPIProc -+PVRDRIEGLGetProcAddress(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ const char *psProcName) -+{ -+ CallFunc(EGLGetProcAddress, eAPI, psScreenImpl, psProcName); -+ -+ return (PVRDRIGLAPIProc) NULL; -+} -+ -+bool -+PVRDRIEGLFlushBuffers(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl, -+ bool bFlushAllSurfaces, bool bSwapBuffers, -+ bool bWaitForHW) -+{ -+ CallFunc(EGLFlushBuffers, eAPI, psScreenImpl, psContextImpl, -+ psDrawableImpl, bFlushAllSurfaces, bSwapBuffers, bWaitForHW); -+ -+ return false; -+} -+ -+void -+PVRDRIEGLMarkRendersurfaceInvalid(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl) -+{ -+ CallFunc(EGLMarkRendersurfaceInvalid, eAPI, psScreenImpl, psContextImpl); -+} -+ -+unsigned int -+PVRDRICreateContextV1(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psSharedContextImpl, -+ PVRDRIConfig *psConfig, -+ PVRDRIAPIType eAPI, PVRDRIAPISubType eAPISub, -+ unsigned int uMajorVersion, unsigned int uMinorVersion, -+ uint32_t uFlags, bool bNotifyReset, -+ unsigned int uPriority, -+ PVRDRIContextImpl **ppsContextImpl) -+{ -+ CallFunc(CreateContextV1, psScreenImpl, psSharedContextImpl, psConfig, -+ eAPI, eAPISub, uMajorVersion, uMinorVersion, uFlags, bNotifyReset, -+ uPriority, ppsContextImpl); -+ -+ return PVRDRI_CONTEXT_ERROR_BAD_API; -+} -+ -+void -+PVRDRIDestroyContextImpl(PVRDRIContextImpl *psContextImpl, PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl) -+{ -+ CallFunc(DestroyContext, psContextImpl, eAPI, psScreenImpl); -+} -+ -+bool -+PVRDRIMakeCurrentGC(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psWriteImpl, -+ PVRDRIDrawableImpl *psReadImpl) -+{ -+ CallFunc(MakeCurrentGC, eAPI, psScreenImpl, psContextImpl, psWriteImpl, -+ psReadImpl); -+ -+ return false; -+} -+ -+void -+PVRDRIMakeUnCurrentGC(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl) -+{ -+ CallFunc(MakeUnCurrentGC, eAPI, psScreenImpl); -+} -+ -+unsigned int -+PVRDRIGetImageSource(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, uint32_t uiTarget, -+ uintptr_t uiBuffer, uint32_t uiLevel, -+ IMGEGLImage *psEGLImage) -+{ -+ CallFunc(GetImageSource, eAPI, psScreenImpl, psContextImpl, uiTarget, -+ uiBuffer, uiLevel, psEGLImage); -+ -+ return PVRDRI_IMAGE_ERROR_BAD_MATCH; -+} -+ -+bool -+PVRDRI2BindTexImage(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl) -+{ -+ CallFunc(BindTexImage, eAPI, psScreenImpl, psContextImpl, psDrawableImpl); -+ -+ return false; -+} -+ -+void -+PVRDRI2ReleaseTexImage(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl) -+{ -+ CallFunc(ReleaseTexImage, eAPI, psScreenImpl, psContextImpl, psDrawableImpl); -+} -+ -+PVRDRIDrawableImpl * -+PVRDRICreateDrawableWithConfig(PVRDRIDrawable *psPVRDrawable, -+ PVRDRIConfig *psConfig) -+{ -+ CallFunc(CreateDrawableWithConfig, psPVRDrawable, psConfig); -+ -+ return NULL; -+} -+ -+void -+PVRDRIDestroyDrawableImpl(PVRDRIDrawableImpl *psScreenImpl) -+{ -+ CallFunc(DestroyDrawable, psScreenImpl); -+} -+ -+bool -+PVREGLDrawableCreate(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl) -+{ -+ CallFunc(EGLDrawableCreate, psScreenImpl, psDrawableImpl); -+ -+ return false; -+} -+ -+bool -+PVREGLDrawableRecreate(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl) -+{ -+ CallFunc(EGLDrawableRecreate, psScreenImpl, psDrawableImpl); -+ -+ return false; -+} -+ -+bool -+PVREGLDrawableDestroy(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl) -+{ -+ CallFunc(EGLDrawableDestroy, psScreenImpl, psDrawableImpl); -+ -+ return false; -+} -+ -+void -+PVREGLDrawableDestroyConfig(PVRDRIDrawableImpl *psDrawableImpl) -+{ -+ CallFunc(EGLDrawableDestroyConfig, psDrawableImpl); -+} -+ -+PVRDRIBufferImpl * -+PVRDRIBufferCreate(PVRDRIScreenImpl *psScreenImpl, int iWidth, int iHeight, -+ unsigned int uiBpp, unsigned int uiUseFlags, -+ unsigned int *puiStride) -+{ -+ CallFunc(BufferCreate, psScreenImpl, iWidth, iHeight, uiBpp, uiUseFlags, -+ puiStride); -+ -+ return NULL; -+} -+ -+PVRDRIBufferImpl * -+PVRDRIBufferCreateWithModifiers(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, int iHeight, -+ int format, IMG_PIXFMT eIMGPixelFormat, -+ const uint64_t *puiModifiers, -+ unsigned int uiModifierCount, -+ unsigned int *puiStride) -+{ -+ CallFunc(BufferCreateWithModifiers, psScreenImpl, iWidth, iHeight, format, -+ eIMGPixelFormat, puiModifiers, uiModifierCount, puiStride); -+ -+ return NULL; -+} -+ -+PVRDRIBufferImpl * -+PVRDRIBufferCreateFromNames(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, int iHeight, unsigned int uiNumPlanes, -+ const int *piName, const int *piStride, -+ const int *piOffset, -+ const unsigned int *puiWidthShift, -+ const unsigned int *puiHeightShift) -+{ -+ CallFunc(BufferCreateFromNames, psScreenImpl, iWidth, iHeight, uiNumPlanes, -+ piName, piStride, piOffset, puiWidthShift, puiHeightShift); -+ -+ return NULL; -+} -+ -+PVRDRIBufferImpl * -+PVRDRIBufferCreateFromFdsWithModifier(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, int iHeight, -+ uint64_t uiModifier, -+ unsigned int uiNumPlanes, -+ const int *piFd, const int *piStride, -+ const int *piOffset, -+ const unsigned int *puiWidthShift, -+ const unsigned int *puiHeightShift) -+{ -+ CallFunc(BufferCreateFromFdsWithModifier, psScreenImpl, iWidth, iHeight, -+ uiModifier, uiNumPlanes, piFd, piStride, piOffset, -+ puiWidthShift, puiHeightShift); -+ -+ return NULL; -+} -+ -+PVRDRIBufferImpl * -+PVRDRISubBufferCreate(PVRDRIScreenImpl *psScreen, -+ PVRDRIBufferImpl *psParentBuffer, int plane) -+{ -+ CallFunc(SubBufferCreate, psScreen, psParentBuffer, plane); -+ -+ return NULL; -+} -+ -+void -+PVRDRIBufferDestroy(PVRDRIBufferImpl *psBuffer) -+{ -+ CallFunc(BufferDestroy, psBuffer); -+} -+ -+int -+PVRDRIBufferGetFd(PVRDRIBufferImpl *psBuffer) -+{ -+ CallFunc(BufferGetFd, psBuffer); -+ -+ return -1; -+} -+ -+int -+PVRDRIBufferGetHandle(PVRDRIBufferImpl *psBuffer) -+{ -+ CallFunc(BufferGetHandle, psBuffer); -+ -+ return 0; -+} -+ -+uint64_t -+PVRDRIBufferGetModifier(PVRDRIBufferImpl *psBuffer) -+{ -+ CallFunc(BufferGetModifier, psBuffer); -+ -+ return DRM_FORMAT_MOD_INVALID; -+} -+ -+int -+PVRDRIBufferGetName(PVRDRIBufferImpl *psBuffer) -+{ -+ CallFunc(BufferGetName, psBuffer); -+ -+ return 0; -+} -+ -+int -+PVRDRIBufferGetOffset(PVRDRIBufferImpl *psBuffer) -+{ -+ CallFunc(BufferGetOffset, psBuffer); -+ -+ return 0; -+} -+ -+IMGEGLImage * -+PVRDRIEGLImageCreate(void) -+{ -+ CallFunc(EGLImageCreate); -+ -+ return NULL; -+} -+ -+IMGEGLImage * -+PVRDRIEGLImageCreateFromBuffer(int iWidth, int iHeight, int iStride, -+ IMG_PIXFMT ePixelFormat, -+ IMG_YUV_COLORSPACE eColourSpace, -+ IMG_YUV_CHROMA_INTERP eChromaUInterp, -+ IMG_YUV_CHROMA_INTERP eChromaVInterp, -+ PVRDRIBufferImpl *psBuffer) -+{ -+ CallFunc(EGLImageCreateFromBuffer, iWidth, iHeight, iStride, ePixelFormat, -+ eColourSpace, eChromaUInterp, eChromaVInterp, psBuffer); -+ -+ return NULL; -+} -+ -+IMGEGLImage * -+PVRDRIEGLImageCreateFromSubBuffer(IMG_PIXFMT ePixelFormat, -+ PVRDRIBufferImpl *psSubBuffer) -+{ -+ CallFunc(EGLImageCreateFromSubBuffer, ePixelFormat, psSubBuffer); -+ -+ return NULL; -+} -+ -+IMGEGLImage * -+PVRDRIEGLImageDup(IMGEGLImage *psIn) -+{ -+ CallFunc(EGLImageDup, psIn); -+ -+ return NULL; -+} -+ -+void -+PVRDRIEGLImageSetCallbackData(IMGEGLImage *psEGLImage, __DRIimage *image) -+{ -+ CallFunc(EGLImageSetCallbackData, psEGLImage, image); -+} -+ -+void -+PVRDRIEGLImageDestroyExternal(PVRDRIScreenImpl *psScreenImpl, -+ IMGEGLImage *psEGLImage, -+ PVRDRIEGLImageType eglImageType) -+{ -+ CallFunc(EGLImageDestroyExternal, psScreenImpl, psEGLImage, eglImageType); -+} -+ -+void -+PVRDRIEGLImageFree(IMGEGLImage *psEGLImage) -+{ -+ CallFunc(EGLImageFree, psEGLImage); -+} -+ -+void -+PVRDRIEGLImageGetAttribs(IMGEGLImage *psEGLImage, -+ PVRDRIBufferAttribs *psAttribs) -+{ -+ CallFunc(EGLImageGetAttribs, psEGLImage, psAttribs); -+} -+ -+void * -+PVRDRICreateFenceImpl(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl) -+{ -+ CallFunc(CreateFence, eAPI, psScreenImpl, psContextImpl); -+ -+ return NULL; -+} -+ -+void * -+PVRDRICreateFenceFd(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, int iFd) -+{ -+ CallFunc(CreateFenceFd, eAPI, psScreenImpl, psContextImpl, iFd); -+ -+ return NULL; -+} -+ -+unsigned int -+PVRDRIGetFenceCapabilities(PVRDRIScreenImpl *psScreenImpl) -+{ -+ CallFunc(GetFenceCapabilities, psScreenImpl); -+ -+ return 0; -+} -+ -+int -+PVRDRIGetFenceFd(void *pvFence) -+{ -+ CallFunc(GetFenceFd, pvFence); -+ -+ return -1; -+} -+ -+void -+PVRDRIDestroyFenceImpl(void *pvFence) -+{ -+ CallFunc(DestroyFence, pvFence); -+} -+ -+bool -+PVRDRIClientWaitSyncImpl(PVRDRIAPIType eAPI, PVRDRIContextImpl *psContextImpl, -+ void *pvFence, bool bFlushCommands, bool bTimeout, -+ uint64_t uiTimeout) -+{ -+ CallFunc(ClientWaitSync, eAPI, psContextImpl, pvFence, bFlushCommands, -+ bTimeout, uiTimeout); -+ -+ return false; -+} -+ -+bool -+PVRDRIServerWaitSyncImpl(PVRDRIAPIType eAPI, PVRDRIContextImpl *psContextImpl, -+ void *pvFence) -+{ -+ CallFunc(ServerWaitSync, eAPI, psContextImpl, pvFence); -+ -+ return false; -+} -+ -+bool -+PVRDRIBlitEGLImage(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psDstImage, PVRDRIBufferImpl *psDstBuffer, -+ IMGEGLImage *psSrcImage, PVRDRIBufferImpl *psSrcBuffer, -+ int iDstX, int iDstY, int iDstWidth, int iDstHeight, -+ int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, -+ int iFlushFlag) -+{ -+ CallFunc(BlitEGLImage, psScreenImpl, psContextImpl, -+ psDstImage, psDstBuffer, -+ psSrcImage, psSrcBuffer, -+ iDstX, iDstY, iDstWidth, iDstHeight, -+ iSrcX, iSrcY, iSrcWidth, iSrcHeight, -+ iFlushFlag); -+ -+ return false; -+} -+ -+void * -+PVRDRIMapEGLImage(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psImage, PVRDRIBufferImpl *psBuffer, -+ int iX, int iY, int iWidth, int iHeight, -+ unsigned int uiFlags, int *piStride, void **ppvData) -+{ -+ CallFunc(MapEGLImage, psScreenImpl, psContextImpl, psImage, psBuffer, -+ iX, iY, iWidth, iHeight, uiFlags, piStride, ppvData); -+ -+ return NULL; -+} -+ -+bool -+PVRDRIUnmapEGLImage(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psImage, PVRDRIBufferImpl *psBuffer, -+ void *pvData) -+{ -+ CallFunc(UnmapEGLImage, psScreenImpl, psContextImpl, psImage, psBuffer, -+ pvData); -+ -+ return false; -+} -+ -+bool -+PVRDRIMesaFormatSupported(unsigned int iFormat) -+{ -+ CallFunc(MesaFormatSupported, iFormat); -+ -+ return false; -+} -+ -+unsigned int -+PVRDRIDepthStencilBitArraySize(void) -+{ -+ CallFunc(DepthStencilBitArraySize); -+ -+ return 0; -+} -+ -+const uint8_t * -+PVRDRIDepthBitsArray(void) -+{ -+ CallFunc(DepthBitsArray); -+ -+ return NULL; -+} -+ -+const uint8_t * -+PVRDRIStencilBitsArray(void) -+{ -+ CallFunc(StencilBitsArray); -+ -+ return NULL; -+} -+ -+unsigned int -+PVRDRIMSAABitArraySize(void) -+{ -+ CallFunc(MSAABitArraySize); -+ -+ return 0; -+} -+ -+const uint8_t * -+PVRDRIMSAABitsArray(void) -+{ -+ CallFunc(MSAABitsArray); -+ -+ return NULL; -+} -+ -+uint32_t -+PVRDRIMaxPBufferWidth(void) -+{ -+ CallFunc(MaxPBufferWidth); -+ -+ return 0; -+} -+ -+uint32_t -+PVRDRIMaxPBufferHeight(void) -+{ -+ CallFunc(MaxPBufferHeight); -+ -+ return 0; -+} -+ -+ -+unsigned int -+PVRDRIGetNumAPIFuncs(PVRDRIAPIType eAPI) -+{ -+ CallFunc(GetNumAPIFuncs, eAPI); -+ -+ return 0; -+} -+ -+const char * -+PVRDRIGetAPIFunc(PVRDRIAPIType eAPI, unsigned int index) -+{ -+ CallFunc(GetAPIFunc, eAPI, index); -+ -+ return NULL; -+} -+ -+int -+PVRDRIQuerySupportedFormats(PVRDRIScreenImpl *psScreenImpl, -+ unsigned int uNumFormats, const int *piFormats, -+ const IMG_PIXFMT *peImgFormats, bool *bSupported) -+{ -+ CallFunc(QuerySupportedFormats, psScreenImpl, uNumFormats, piFormats, -+ peImgFormats, bSupported); -+ -+ return -1; -+} -+ -+int -+PVRDRIQueryModifiers(PVRDRIScreenImpl *psScreenImpl, -+ int iFormat, IMG_PIXFMT eImgFormat, -+ uint64_t *puModifiers, unsigned int *puExternalOnly) -+{ -+ CallFunc(QueryModifiers, psScreenImpl, iFormat, eImgFormat, puModifiers, -+ puExternalOnly); -+ -+ return -1; -+} -diff --git a/src/mesa/drivers/dri/pvr/pvrdrawable_mod.c b/src/mesa/drivers/dri/pvr/pvrdrawable_mod.c -new file mode 100644 -index 00000000000..505f4329cb8 ---- /dev/null -+++ b/src/mesa/drivers/dri/pvr/pvrdrawable_mod.c -@@ -0,0 +1,385 @@ -+/* -+ * Copyright (c) Imagination Technologies Ltd. -+ * -+ * The contents of this file are subject to the MIT license as set out below. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to deal -+ * in the Software without restriction, including without limitation the rights -+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -+ * copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -+ * THE SOFTWARE. -+ */ -+ -+#include -+ -+#include "util/u_atomic.h" -+#include "pvrdri_mod.h" -+ -+static inline void -+PVRDRIMarkRenderSurfaceAsInvalid(struct DRISUPDrawable *psPVRDrawable) -+{ -+ struct DRISUPContext *psPVRContext = psPVRDrawable->psPVRContext; -+ -+ if (psPVRContext) { -+ struct DRISUPScreen *psPVRScreen = psPVRContext->psPVRScreen; -+ -+ PVRDRIEGLMarkRendersurfaceInvalid(psPVRContext->eAPI, -+ psPVRScreen->psImpl, -+ psPVRContext->psImpl); -+ } -+} -+ -+/*************************************************************************//*! -+ PVR drawable local functions (image driver loader) -+ *//**************************************************************************/ -+ -+static inline void -+PVRDrawableImageDestroy(struct DRISUPDrawable *psPVRDrawable) -+{ -+ if (psPVRDrawable->psImage) { -+ PVRDRIUnrefImage(psPVRDrawable->psImage); -+ psPVRDrawable->psImage = NULL; -+ } -+} -+ -+static inline void -+PVRDrawableImageAccumDestroy(struct DRISUPDrawable *psPVRDrawable) -+{ -+ if (psPVRDrawable->psImageAccum) { -+ PVRDRIUnrefImage(psPVRDrawable->psImageAccum); -+ psPVRDrawable->psImageAccum = NULL; -+ } -+} -+ -+static void -+PVRDrawableImageUpdate(struct DRISUPDrawable *psPVRDrawable) -+{ -+ if (psPVRDrawable->psImage != psPVRDrawable->psDRI) { -+ assert(PVRDRIImageGetSharedBuffer(psPVRDrawable->psDRI) != NULL); -+ -+ PVRDrawableImageDestroy(psPVRDrawable); -+ -+ PVRDRIRefImage(psPVRDrawable->psDRI); -+ psPVRDrawable->psImage = psPVRDrawable->psDRI; -+ } -+ -+ if (psPVRDrawable->psImageAccum != psPVRDrawable->psDRIAccum) { -+ PVRDrawableImageAccumDestroy(psPVRDrawable); -+ -+ if (psPVRDrawable->psDRIAccum) { -+ PVRDRIRefImage(psPVRDrawable->psDRIAccum); -+ psPVRDrawable->psImageAccum = psPVRDrawable->psDRIAccum; -+ } -+ } -+} -+ -+/*************************************************************************//*! -+Function Name : PVRImageDrawableGetNativeInfo -+Inputs : psPVRDrawable -+Returns : Boolean -+Description : Update native drawable information. -+ *//**************************************************************************/ -+static bool -+PVRImageDrawableGetNativeInfo(struct DRISUPDrawable *psPVRDrawable) -+{ -+ struct PVRDRIImageList sImages; -+ uint32_t uBufferMask; -+ -+ if (psPVRDrawable->bDoubleBufferMode) -+ uBufferMask = PVRDRI_IMAGE_BUFFER_BACK; -+ else -+ uBufferMask = PVRDRI_IMAGE_BUFFER_FRONT; -+ -+ uBufferMask |= PVRDRI_IMAGE_BUFFER_PREV; -+ -+ if (!MODSUPGetBuffers(psPVRDrawable->psDRIDrawable, -+ psPVRDrawable->psFormat->iDRIFourCC, -+ NULL, psPVRDrawable->pvLoaderPrivate, -+ uBufferMask, &sImages)) { -+ errorMessage("%s: Image get buffers call failed", __func__); -+ return false; -+ } -+ -+ psPVRDrawable->psDRI = -+ (sImages.uImageMask & PVRDRI_IMAGE_BUFFER_BACK) ? -+ sImages.psBack : sImages.psFront; -+ -+ if (sImages.uImageMask & PVRDRI_IMAGE_BUFFER_PREV) -+ psPVRDrawable->psDRIAccum = sImages.psPrev; -+ else -+ psPVRDrawable->psDRIAccum = NULL; ++ CallFuncV2(v4.HaveGetFenceFromCLEvent); + + return true; +} -+ -+/*************************************************************************//*! -+Function Name : PVRImageDrawableCreate -+Inputs : psPVRDrawable -+Returns : Boolean -+Description : Create drawable -+ *//**************************************************************************/ -+static bool -+PVRImageDrawableCreate(struct DRISUPDrawable *psPVRDrawable) -+{ -+ uint32_t uBytesPerPixel; -+ PVRDRIBufferAttribs sBufferAttribs; -+ -+ if (!PVRImageDrawableGetNativeInfo(psPVRDrawable)) -+ return false; -+ -+ PVRDRIEGLImageGetAttribs(PVRDRIImageGetEGLImage(psPVRDrawable->psDRI), -+ &sBufferAttribs); -+ uBytesPerPixel = PVRDRIPixFmtGetBlockSize(sBufferAttribs.ePixFormat); -+ -+ psPVRDrawable->uWidth = sBufferAttribs.uiWidth; -+ psPVRDrawable->uHeight = sBufferAttribs.uiHeight; -+ psPVRDrawable->uStride = sBufferAttribs.uiStrideInBytes; -+ psPVRDrawable->uBytesPerPixel = uBytesPerPixel; -+ -+ PVRDrawableImageUpdate(psPVRDrawable); -+ -+ if (!PVREGLDrawableCreate(psPVRDrawable->psPVRScreen->psImpl, -+ psPVRDrawable->psImpl)) { -+ errorMessage("%s: Couldn't create EGL drawable", __func__); -+ return false; -+ } -+ -+ return true; -+} -+ -+/*************************************************************************//*! -+Function Name : PVRImageDrawableUpdate -+Inputs : psPVRDrawable -+Returns : Boolean -+Description : Update drawable -+ *//**************************************************************************/ -+static bool -+PVRImageDrawableUpdate(struct DRISUPDrawable *psPVRDrawable, -+ bool bAllowRecreate) -+{ -+ uint32_t uBytesPerPixel; -+ PVRDRIBufferAttribs sBufferAttribs; -+ bool bRecreate; -+ -+ PVRDRIEGLImageGetAttribs(PVRDRIImageGetEGLImage(psPVRDrawable->psDRI), -+ &sBufferAttribs); -+ uBytesPerPixel = PVRDRIPixFmtGetBlockSize(sBufferAttribs.ePixFormat); -+ -+ bRecreate = -+ (!psPVRDrawable->bDoubleBufferMode && -+ psPVRDrawable->psImage != psPVRDrawable->psDRI) || -+ (psPVRDrawable->uWidth != sBufferAttribs.uiWidth) || -+ (psPVRDrawable->uHeight != sBufferAttribs.uiHeight) || -+ (psPVRDrawable->uStride != sBufferAttribs.uiStrideInBytes) || -+ (psPVRDrawable->uBytesPerPixel != uBytesPerPixel); -+ -+ if (bRecreate) { -+ if (bAllowRecreate) { -+ PVRDRIMarkRenderSurfaceAsInvalid(psPVRDrawable); -+ -+ psPVRDrawable->uWidth = sBufferAttribs.uiWidth; -+ psPVRDrawable->uHeight = sBufferAttribs.uiHeight; -+ psPVRDrawable->uStride = sBufferAttribs.uiStrideInBytes; -+ psPVRDrawable->uBytesPerPixel = uBytesPerPixel; -+ } else { -+ return false; -+ } -+ } -+ -+ PVRDrawableImageUpdate(psPVRDrawable); -+ -+ if (bRecreate) { -+ if (!PVREGLDrawableRecreate(psPVRDrawable->psPVRScreen->psImpl, -+ psPVRDrawable->psImpl)) { -+ errorMessage("%s: Couldn't recreate EGL drawable", __func__); -+ return false; -+ } -+ } -+ -+ return true; -+} -+ -+/*************************************************************************//*! -+ PVR drawable local functions -+ *//**************************************************************************/ -+ -+/*************************************************************************//*! -+Function Name : PVRDRIDrawableUpdate -+Inputs : psPVRDrawable -+Description : Update drawable -+ *//**************************************************************************/ -+static bool -+PVRDRIDrawableUpdate(struct DRISUPDrawable *psPVRDrawable, bool bAllowRecreate) -+{ -+ bool bRes; -+ int iInfoInvalid = 0; -+ -+ /* -+ * The test for bDrawableUpdating is needed because drawable parameters are -+ * fetched (via KEGLGetDrawableParameters) when a drawable is recreated. -+ * The test for bFlushInProgress is to prevent the drawable information -+ * being updated during a flush, which could result in a call back into the -+ * Mesa platform code during the processing for a buffer swap, which could -+ * corrupt the platform state. -+ */ -+ if (psPVRDrawable->bDrawableUpdating || psPVRDrawable->bFlushInProgress) -+ return false; -+ -+ psPVRDrawable->bDrawableUpdating = true; -+ -+ if (psPVRDrawable->psPVRScreen->bUseInvalidate) { -+ iInfoInvalid = p_atomic_read(&psPVRDrawable->iInfoInvalid); -+ bRes = !iInfoInvalid; -+ if (bRes) -+ goto ExitNotUpdating; -+ } -+ -+ bRes = PVRImageDrawableGetNativeInfo(psPVRDrawable); -+ if (!bRes) -+ goto ExitNotUpdating; -+ -+ bRes = PVRImageDrawableUpdate(psPVRDrawable, bAllowRecreate); -+ if (bRes && iInfoInvalid) -+ p_atomic_add(&psPVRDrawable->iInfoInvalid, -iInfoInvalid); -+ -+ExitNotUpdating: -+ psPVRDrawable->bDrawableUpdating = false; -+ return bRes; -+} -+ -+/*************************************************************************//*! -+ PVR drawable interface -+ *//**************************************************************************/ -+bool -+PVRDRIDrawableInit(struct DRISUPDrawable *psPVRDrawable) -+{ -+ if (psPVRDrawable->bInitialised) -+ return true; -+ -+ if (!PVRImageDrawableCreate(psPVRDrawable)) -+ return false; -+ -+ psPVRDrawable->bInitialised = true; -+ -+ return true; -+} -+ -+void -+PVRDRIDrawableDeinit(struct DRISUPDrawable *psPVRDrawable) -+{ -+ (void) PVREGLDrawableDestroy(psPVRDrawable->psPVRScreen->psImpl, -+ psPVRDrawable->psImpl); -+ -+ PVRDrawableImageDestroy(psPVRDrawable); -+ PVRDrawableImageAccumDestroy(psPVRDrawable); -+ -+ psPVRDrawable->bInitialised = false; -+} -+ -+static bool -+PVRDRIDrawableGetParameters(struct DRISUPDrawable *psPVRDrawable, -+ PVRDRIBufferImpl **ppsDstBuffer, -+ PVRDRIBufferImpl **ppsAccumBuffer) -+{ -+ if (ppsDstBuffer || ppsAccumBuffer) { -+ __DRIimage *psDstImage = psPVRDrawable->psImage; -+ __DRIimage *psAccumImage = psPVRDrawable->psImageAccum; -+ PVRDRIBufferImpl *psDstBuffer, *psAccumBuffer; -+ -+ psDstBuffer = PVRDRIImageGetSharedBuffer(psDstImage); -+ if (!psDstBuffer) { -+ errorMessage("%s: Couldn't get backing buffer", __func__); -+ return false; -+ } -+ -+ if (psAccumImage) { -+ psAccumBuffer = PVRDRIImageGetSharedBuffer(psAccumImage); -+ if (!psAccumBuffer) -+ psAccumBuffer = psDstBuffer; -+ } else { -+ psAccumBuffer = psDstBuffer; -+ } -+ -+ if (ppsDstBuffer) -+ *ppsDstBuffer = psDstBuffer; -+ -+ if (ppsAccumBuffer) -+ *ppsAccumBuffer = psAccumBuffer; -+ } -+ -+ return true; -+} -+ -+bool -+PVRDRIDrawableQuery(const PVRDRIDrawable *psPVRDRIDrawable, -+ PVRDRIBufferAttrib eBufferAttrib, uint32_t *uiValueOut) -+{ -+ const struct DRISUPDrawable *psPVRDrawable; -+ -+ if (!psPVRDRIDrawable || !uiValueOut) -+ return false; -+ -+ psPVRDrawable = (const struct DRISUPDrawable *) psPVRDRIDrawable; -+ -+ switch (eBufferAttrib) { -+ case PVRDRI_BUFFER_ATTRIB_TYPE: -+ *uiValueOut = (uint32_t) psPVRDrawable->eType; -+ return true; -+ case PVRDRI_BUFFER_ATTRIB_WIDTH: -+ *uiValueOut = (uint32_t) psPVRDrawable->uWidth; -+ return true; -+ case PVRDRI_BUFFER_ATTRIB_HEIGHT: -+ *uiValueOut = (uint32_t) psPVRDrawable->uHeight; -+ return true; -+ case PVRDRI_BUFFER_ATTRIB_STRIDE: -+ *uiValueOut = (uint32_t) psPVRDrawable->uStride; -+ return true; -+ case PVRDRI_BUFFER_ATTRIB_PIXEL_FORMAT: -+ *uiValueOut = (uint32_t) psPVRDrawable->psFormat->eIMGPixelFormat; -+ static_assert(sizeof(IMG_PIXFMT) <= sizeof(*uiValueOut), -+ "Type size mismatch"); -+ return true; -+ case PVRDRI_BUFFER_ATTRIB_INVALID: -+ errorMessage("%s: Invalid attribute", __func__); -+ assert(0); -+ return false; -+ default: -+ return false; -+ } -+} -+ -+bool -+PVRDRIDrawableGetParametersV2(PVRDRIDrawable *psPVRDRIDrawable, -+ uint32_t uiFlags, -+ PVRDRIBufferImpl **ppsDstBuffer, -+ PVRDRIBufferImpl **ppsAccumBuffer) -+{ -+ const bool bNoUpdate = uiFlags & PVRDRI_GETPARAMS_FLAG_NO_UPDATE; -+ struct DRISUPDrawable *psPVRDrawable; -+ -+ psPVRDrawable = (struct DRISUPDrawable *) psPVRDRIDrawable; -+ -+ if (!bNoUpdate) { -+ const bool bAllowRecreate = -+ uiFlags & PVRDRI_GETPARAMS_FLAG_ALLOW_RECREATE; -+ -+ if (!PVRDRIDrawableUpdate(psPVRDrawable, bAllowRecreate)) -+ if (bAllowRecreate) -+ return false; -+ } -+ -+ return PVRDRIDrawableGetParameters(psPVRDrawable, -+ ppsDstBuffer, ppsAccumBuffer); -+} diff --git a/src/mesa/drivers/dri/pvr/pvrdri.c b/src/mesa/drivers/dri/pvr/pvrdri.c new file mode 100644 -index 00000000000..45950552647 +index 00000000000..ab941f71567 --- /dev/null +++ b/src/mesa/drivers/dri/pvr/pvrdri.c -@@ -0,0 +1,603 @@ +@@ -0,0 +1,613 @@ +/* + * Copyright (c) Imagination Technologies Ltd. + * @@ -4456,7 +2691,6 @@ index 00000000000..45950552647 + +#include "pvrdri.h" +#include "pvrmesa.h" -+#include "pvrdri_mod.h" + +#define PVR_IMAGE_LOADER_VER_MIN 1 + @@ -4525,6 +2759,35 @@ index 00000000000..45950552647 + free(psPVRScreen); +} + ++void ++PVRDRIDrawableAddReference(PVRDRIDrawable *psPVRDrawable) ++{ ++ int iRefCount = p_atomic_inc_return(&psPVRDrawable->iRefCount); ++ ++ (void) iRefCount; ++ assert(iRefCount > 1); ++} ++ ++void ++PVRDRIDrawableRemoveReference(PVRDRIDrawable *psPVRDrawable) ++{ ++ int iRefCount = p_atomic_dec_return(&psPVRDrawable->iRefCount); ++ ++ assert(iRefCount >= 0); ++ ++ if (iRefCount != 0) ++ return; ++ ++ DRISUPDestroyDrawable(psPVRDrawable->psDRISUPDrawable); ++ ++#if defined(DEBUG) ++ p_atomic_dec(&psPVRDrawable->psPVRScreen->iDrawableAlloc); ++#endif ++ ++ PVRDRIScreenRemoveReference(psPVRDrawable->psPVRScreen); ++ free(psPVRDrawable); ++} ++ +static void +PVRScreenPrintExtensions(__DRIscreen *psDRIScreen) +{ @@ -4573,24 +2836,6 @@ index 00000000000..45950552647 + PVRDRIScreen *psPVRScreen; + const __DRIconfig **ppsConfigs; + int iMaxGLES1Version, iMaxGLES2Version; -+ const PVRDRICallbacks sDRICallbacks = { -+ /* Version 0 callbacks */ -+ .ImageGetSharedType = PVRDRIImageGetSharedType, -+ .ImageGetSharedBuffer = PVRDRIImageGetSharedBuffer, -+ .ImageGetSharedEGLImage = PVRDRIImageGetSharedEGLImage, -+ .ImageGetEGLImage = PVRDRIImageGetEGLImage, -+ .ScreenGetDRIImage = PVRDRIScreenGetDRIImage, -+ .RefImage = PVRDRIRefImage, -+ .UnrefImage = PVRDRIUnrefImage, -+ -+ /* Version 1 callbacks */ -+ .RegisterSupportInterfaceV1 = PVRDRIRegisterSupportInterfaceV1, -+ -+ /* Version 2 callbacks */ -+ .ConfigQuery = PVRDRIConfigQuery, -+ .DrawableGetParametersV2 = PVRDRIDrawableGetParametersV2, -+ .DrawableQuery = PVRDRIDrawableQuery, -+ }; + const struct PVRDRICallbacksV2 sDRICallbacksV2 = { + /* Version 0 callbacks */ + .v0.RegisterSupportInterface = MODSUPRegisterSupportInterfaceV2, @@ -4602,12 +2847,18 @@ index 00000000000..45950552647 + .v0.GetCapability = MODSUPGetCapability, + /* Version 1 callbacks */ + .v1.FlushFrontBuffer = MODSUPFlushFrontBuffer, ++ /* Version 2 callbacks */ ++ .v2.GetDisplayFD = MODSUPGetDisplayFD, ++ /* Version 3 callbacks */ ++ .v3.DrawableGetReferenceHandle = MODSUPDrawableGetReferenceHandle, ++ .v3.DrawableAddReference = MODSUPDrawableAddReference, ++ .v3.DrawableRemoveReference = MODSUPDrawableRemoveReference, + }; + + if (!PVRLoaderIsSupported(psDRIScreen)) + return NULL; + -+ if (!PVRDRICompatInit(&sDRICallbacks, 3, &sDRICallbacksV2, 1, 0)) ++ if (!PVRDRICompatInit(&sDRICallbacksV2, 3, 0)) + return NULL; + + psPVRScreen = calloc(1, sizeof(*psPVRScreen)); @@ -4718,9 +2969,9 @@ index 00000000000..45950552647 + sCtxConfig.uMajorVersion = psCtxConfig->major_version; + sCtxConfig.uMinorVersion = psCtxConfig->minor_version; + sCtxConfig.uFlags = psCtxConfig->flags; -+ sCtxConfig.iResetStrategy = PVRDRI_CONTEXT_RESET_NO_NOTIFICATION; -+ sCtxConfig.uPriority = PVRDRI_CONTEXT_PRIORITY_MEDIUM; -+ sCtxConfig.iReleaseBehavior = PVRDRI_CONTEXT_RELEASE_BEHAVIOR_FLUSH; ++ sCtxConfig.iResetStrategy = __DRI_CTX_RESET_NO_NOTIFICATION; ++ sCtxConfig.uPriority = __DRI_CTX_PRIORITY_MEDIUM; ++ sCtxConfig.iReleaseBehavior = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH; + + psPVRContext = calloc(1, sizeof(*psPVRContext)); + if (psPVRContext == NULL) { @@ -4844,6 +3095,7 @@ index 00000000000..45950552647 + } + + psDRIDrawable->driverPrivate = (void *) psPVRDrawable; ++ psPVRDrawable->iRefCount = 1; + psPVRDrawable->psDRIDrawable = psDRIDrawable; + psPVRDrawable->psPVRScreen = psPVRScreen; + psPVRDrawable->sConfig.sGLMode = *psGLMode; @@ -4880,14 +3132,7 @@ index 00000000000..45950552647 +{ + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate; + -+ DRISUPDestroyDrawable(psPVRDrawable->psDRISUPDrawable); -+ -+#if defined(DEBUG) -+ p_atomic_dec(&psPVRDrawable->psPVRScreen->iDrawableAlloc); -+#endif -+ -+ PVRDRIScreenRemoveReference(psPVRDrawable->psPVRScreen); -+ free(psPVRDrawable); ++ PVRDRIDrawableRemoveReference(psPVRDrawable); +} + +static GLboolean @@ -5029,10 +3274,10 @@ index 00000000000..45950552647 +} diff --git a/src/mesa/drivers/dri/pvr/pvrdri.h b/src/mesa/drivers/dri/pvr/pvrdri.h new file mode 100644 -index 00000000000..8b37876411a +index 00000000000..fd465bf7f5c --- /dev/null +++ b/src/mesa/drivers/dri/pvr/pvrdri.h -@@ -0,0 +1,176 @@ +@@ -0,0 +1,188 @@ +/* + * Copyright (c) Imagination Technologies Ltd. + * @@ -5124,6 +3369,7 @@ index 00000000000..8b37876411a +typedef struct PVRDRIDrawable_TAG { + PVRDRIScreen *psPVRScreen; + __DRIdrawable *psDRIDrawable; ++ int iRefCount; + PVRDRIConfig sConfig; + struct DRISUPDrawable *psDRISUPDrawable; + unsigned int uFourCC; @@ -5131,6 +3377,12 @@ index 00000000000..8b37876411a +} PVRDRIDrawable; + +/*************************************************************************//*! ++ pvrdri.c ++ *//**************************************************************************/ ++void PVRDRIDrawableAddReference(PVRDRIDrawable *psPVRDrawable); ++void PVRDRIDrawableRemoveReference(PVRDRIDrawable *psPVRDrawable); ++ ++/*************************************************************************//*! + pvrutil.c + *//**************************************************************************/ + @@ -5154,14 +3406,10 @@ index 00000000000..8b37876411a + pvrcompat.c + *//**************************************************************************/ + -+bool PVRDRICompatInit(const PVRDRICallbacks *psCallbacks, -+ unsigned int uVersion, -+ const struct PVRDRICallbacksV2 *psCallbacksV2, ++bool PVRDRICompatInit(const struct PVRDRICallbacksV2 *psCallbacksV2, + unsigned int uVersionV2, unsigned int uMinVersionV2); +void PVRDRICompatDeinit(void); + -+bool PVRDRIRegisterSupportInterfaceV1(const PVRDRISupportInterface *psInterface, -+ unsigned int uVersion); +bool MODSUPRegisterSupportInterfaceV2(const void *pvInterface, + unsigned int uVersion, + unsigned int uMinVersion); @@ -5198,6 +3446,9 @@ index 00000000000..8b37876411a +unsigned int MODSUPGetCapability(struct __DRIscreenRec *psDRIScreen, + unsigned int uCapability); + ++int MODSUPGetDisplayFD(struct __DRIscreenRec *psDRIScreen, ++ void *pvLoaderPrivate); ++ +bool PVRDRIConfigQuery(const PVRDRIConfig *psConfig, + PVRDRIConfigAttrib eConfigAttrib, int *piValueOut); + @@ -5208,1059 +3459,19 @@ index 00000000000..8b37876411a +void MODSUPFlushFrontBuffer(struct __DRIdrawableRec *psDRIDrawable, + void *pvLoaderPrivate); + ++void *MODSUPDrawableGetReferenceHandle(struct __DRIdrawableRec *psDRIDrawable); ++ ++void MODSUPDrawableAddReference(void *pvReferenceHandle); ++ ++void MODSUPDrawableRemoveReference(void *pvReferenceHandle); ++ +#endif /* defined(__PVRDRI_H__) */ -diff --git a/src/mesa/drivers/dri/pvr/pvrdri_mod.c b/src/mesa/drivers/dri/pvr/pvrdri_mod.c -new file mode 100644 -index 00000000000..0abe8a38d3a ---- /dev/null -+++ b/src/mesa/drivers/dri/pvr/pvrdri_mod.c -@@ -0,0 +1,584 @@ -+/* -+ * Copyright (c) Imagination Technologies Ltd. -+ * -+ * The contents of this file are subject to the MIT license as set out below. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to deal -+ * in the Software without restriction, including without limitation the rights -+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -+ * copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -+ * THE SOFTWARE. -+ */ -+ -+#include -+#include -+ -+#include "pvrdri_mod.h" -+ -+#define PVR_IMAGE_LOADER_VER_MIN 1 -+ -+#define PVRDRI_FLUSH_WAIT_FOR_HW (1U << 0) -+#define PVRDRI_FLUSH_NEW_EXTERNAL_FRAME (1U << 1) -+#define PVRDRI_FLUSH_ALL_SURFACES (1U << 2) -+ -+ -+/* We need to know the current screen in order to lookup EGL images. */ -+static __thread struct DRISUPScreen *gpsPVRScreen; -+ -+/*************************************************************************//*! -+ Local functions -+ *//**************************************************************************/ -+ -+static inline bool -+PVRDRIFlushBuffers(struct DRISUPContext *psPVRContext, -+ struct DRISUPDrawable *psPVRDrawable, uint32_t uiFlags) -+{ -+ PVRDRIDrawableImpl *psDrawableImpl; -+ bool bFlushAllSurfaces = (uiFlags & PVRDRI_FLUSH_ALL_SURFACES) != 0; -+ bool bSwapBuffers = (uiFlags & PVRDRI_FLUSH_NEW_EXTERNAL_FRAME) != 0; -+ bool bWaitForHW = (uiFlags & PVRDRI_FLUSH_WAIT_FOR_HW) != 0; -+ -+ psDrawableImpl = psPVRDrawable ? psPVRDrawable->psImpl : NULL; -+ -+ assert(!(uiFlags & ~(PVRDRI_FLUSH_WAIT_FOR_HW | -+ PVRDRI_FLUSH_NEW_EXTERNAL_FRAME | -+ PVRDRI_FLUSH_ALL_SURFACES))); -+ -+ return PVRDRIEGLFlushBuffers(psPVRContext->eAPI, -+ psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, psDrawableImpl, -+ bFlushAllSurfaces, bSwapBuffers, bWaitForHW); -+} -+ -+void -+PVRDRIFlushBuffersForSwap(struct DRISUPContext *psPVRContext, -+ struct DRISUPDrawable *psPVRDrawable) -+{ -+ if (psPVRContext) { -+ /* -+ * The bFlushInProgress flag is intended to prevent new buffers being -+ * fetched whilst a flush is in progress, which may corrupt the state -+ * maintained by the Mesa platform code. -+ */ -+ psPVRDrawable->bFlushInProgress = true; -+ -+ (void) PVRDRIFlushBuffers(psPVRContext, -+ psPVRDrawable, -+ PVRDRI_FLUSH_NEW_EXTERNAL_FRAME); -+ -+ psPVRDrawable->bFlushInProgress = false; -+ } -+} -+ -+static void -+PVRDRIFlushBuffersGC(struct DRISUPContext *psPVRContext, -+ struct DRISUPDrawable *psPVRDrawable) -+{ -+ (void) PVRDRIFlushBuffers(psPVRContext, psPVRDrawable, -+ PVRDRI_FLUSH_WAIT_FOR_HW | -+ PVRDRI_FLUSH_ALL_SURFACES); -+} -+ -+static void -+PVRContextUnbind(struct DRISUPContext *psPVRContext, bool bMakeUnCurrent, -+ bool bMarkSurfaceInvalid) -+{ -+ struct DRISUPScreen *psPVRScreen = psPVRContext->psPVRScreen; -+ struct DRISUPDrawable *psPVRDrawable = psPVRContext->psPVRDrawable; -+ -+ if (bMakeUnCurrent && !psPVRContext->bMakeUncurrentNoFlush) { -+ uint32_t uiFlags = PVRDRI_FLUSH_ALL_SURFACES; -+ -+ (void) PVRDRIFlushBuffers(psPVRContext, psPVRDrawable, uiFlags); -+ } else if (psPVRDrawable) { -+ PVRDRIFlushBuffersGC(psPVRContext, psPVRDrawable); -+ } -+ -+ if (bMakeUnCurrent) -+ PVRDRIMakeUnCurrentGC(psPVRContext->eAPI, psPVRScreen->psImpl); -+ -+ if (psPVRDrawable != NULL) { -+ if (bMarkSurfaceInvalid) { -+ PVRDRIEGLMarkRendersurfaceInvalid(psPVRContext->eAPI, -+ psPVRScreen->psImpl, -+ psPVRContext->psImpl); -+ } -+ -+ psPVRContext->psPVRDrawable = NULL; -+ psPVRDrawable->psPVRContext = NULL; -+ } -+} -+ -+static inline void -+PVRDrawableUnbindContext(struct DRISUPDrawable *psPVRDrawable) -+{ -+ struct DRISUPContext *psPVRContext = psPVRDrawable->psPVRContext; -+ -+ if (psPVRContext) -+ PVRContextUnbind(psPVRContext, false, true); -+} -+ -+/*************************************************************************//*! -+ Mesa driver API functions -+ *//**************************************************************************/ -+struct DRISUPScreen * -+DRIMODCreateScreen(struct __DRIscreenRec *psDRIScreen, int iFD, -+ bool bUseInvalidate, void *pvLoaderPrivate, -+ const struct __DRIconfigRec ***pppsConfigs, -+ int *piMaxGLES1Version, int *piMaxGLES2Version) -+{ -+ struct DRISUPScreen *psPVRScreen; -+ const struct __DRIconfigRec **ppsConfigs; -+ -+ psPVRScreen = calloc(1, sizeof(*psPVRScreen)); -+ if (psPVRScreen == NULL) { -+ __driUtilMessage("%s: Couldn't allocate PVRDRIScreen", __func__); -+ return NULL; -+ } -+ -+ psPVRScreen->psDRIScreen = psDRIScreen; -+ psPVRScreen->iFD = iFD; -+ psPVRScreen->bUseInvalidate = bUseInvalidate; -+ psPVRScreen->pvLoaderPrivate = pvLoaderPrivate; -+ -+ if (!PVRDRIGetMesaFormats(psPVRScreen)) -+ goto ErrorScreenFree; -+ -+ psPVRScreen->psImpl = PVRDRICreateScreenImpl(iFD); -+ if (psPVRScreen->psImpl == NULL) -+ goto ErrorScreenFree; -+ -+ if (!PVRDRIGetSupportedFormats(psPVRScreen)) -+ goto ErrorScreenImplDeinit; -+ -+ ppsConfigs = PVRDRICreateConfigs(psPVRScreen); -+ if (ppsConfigs == NULL) { -+ __driUtilMessage("%s: No framebuffer configs", __func__); -+ goto ErrorDestroyFormatInfo; -+ } -+ -+ *piMaxGLES1Version = PVRDRIAPIVersion(PVRDRI_API_GLES1, -+ PVRDRI_API_SUB_NONE, -+ psPVRScreen->psImpl); -+ -+ *piMaxGLES2Version = PVRDRIAPIVersion(PVRDRI_API_GLES2, -+ PVRDRI_API_SUB_NONE, -+ psPVRScreen->psImpl); -+ -+ *pppsConfigs = ppsConfigs; -+ -+ return psPVRScreen; -+ -+ErrorDestroyFormatInfo: -+ PVRDRIDestroyFormatInfo(psPVRScreen); -+ -+ErrorScreenImplDeinit: -+ PVRDRIDestroyScreenImpl(psPVRScreen->psImpl); -+ -+ErrorScreenFree: -+ PVRDRIFreeMesaFormats(psPVRScreen); -+ -+ free(psPVRScreen); -+ -+ return NULL; -+} -+ -+void -+DRIMODDestroyScreen(struct DRISUPScreen *psPVRScreen) -+{ -+ PVRDRIDestroyFormatInfo(psPVRScreen); -+ PVRDRIDestroyScreenImpl(psPVRScreen->psImpl); -+ PVRDRIFreeMesaFormats(psPVRScreen); -+ free(psPVRScreen); -+} -+ -+unsigned int -+DRIMODCreateContext(PVRDRIAPIType eAPI, PVRDRIConfig *psPVRDRIConfig, -+ struct PVRDRIContextConfig *psCtxConfig, -+ struct __DRIcontextRec *psDRIContext, -+ struct DRISUPContext *psPVRSharedContext, -+ struct DRISUPScreen *psPVRScreen, -+ struct DRISUPContext **ppsPVRContext) -+{ -+ struct DRISUPContext *psPVRContext; -+ PVRDRIContextImpl *psSharedImpl; -+ bool bNotifyReset; -+ unsigned int uError; -+ -+ psSharedImpl = psPVRSharedContext ? psPVRSharedContext->psImpl : NULL, -+ psPVRContext = calloc(1, sizeof(*psPVRContext)); -+ if (psPVRContext == NULL) { -+ __driUtilMessage("%s: Couldn't allocate PVRDRIContext", __func__); -+ return PVRDRI_CONTEXT_ERROR_NO_MEMORY; -+ } -+ -+ psPVRContext->psDRIContext = psDRIContext; -+ psPVRContext->psPVRScreen = psPVRScreen; -+ -+ switch (eAPI) { -+ case PVRDRI_API_GLES1: -+ case PVRDRI_API_GLES2: -+ break; -+ default: -+ __driUtilMessage("%s: Unsupported API: %d", __func__, (int) eAPI); -+ uError = PVRDRI_CONTEXT_ERROR_BAD_API; -+ goto ErrorContextFree; -+ } -+ psPVRContext->eAPI = eAPI; -+ -+ switch (psCtxConfig->iResetStrategy) { -+ case PVRDRI_CONTEXT_RESET_NO_NOTIFICATION: -+ bNotifyReset = false; -+ break; -+ case PVRDRI_CONTEXT_RESET_LOSE_CONTEXT: -+ bNotifyReset = true; -+ break; -+ default: -+ __driUtilMessage("%s: Unsupported reset strategy: %d", -+ __func__, psCtxConfig->iResetStrategy); -+ uError = PVRDRI_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE; -+ goto ErrorContextFree; -+ } -+ -+ switch (psCtxConfig->iReleaseBehavior) { -+ case PVRDRI_CONTEXT_RELEASE_BEHAVIOR_NONE: -+ psPVRContext->bMakeUncurrentNoFlush = true; -+ break; -+ case PVRDRI_CONTEXT_RELEASE_BEHAVIOR_FLUSH: -+ psPVRContext->bMakeUncurrentNoFlush = false; -+ break; -+ default: -+ __driUtilMessage("%s: Unsupported release behaviour: %d", -+ __func__, psCtxConfig->iReleaseBehavior); -+ uError = PVRDRI_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE; -+ goto ErrorContextFree; -+ } -+ -+ uError = PVRDRICreateContextV1(psPVRScreen->psImpl, psSharedImpl, -+ psPVRDRIConfig, psPVRContext->eAPI, -+ PVRDRI_API_SUB_NONE, -+ psCtxConfig->uMajorVersion, -+ psCtxConfig->uMinorVersion, -+ psCtxConfig->uFlags, bNotifyReset, -+ psCtxConfig->uPriority, -+ &psPVRContext->psImpl); -+ if (uError != PVRDRI_CONTEXT_ERROR_SUCCESS) -+ goto ErrorContextFree; -+ -+ *ppsPVRContext = psPVRContext; -+ -+ return uError; -+ -+ErrorContextFree: -+ free(psPVRContext); -+ -+ return uError; -+} -+ -+void -+DRIMODDestroyContext(struct DRISUPContext *psPVRContext) -+{ -+ struct DRISUPScreen *psPVRScreen = psPVRContext->psPVRScreen; -+ -+ PVRContextUnbind(psPVRContext, false, false); -+ PVRDRIDestroyContextImpl(psPVRContext->psImpl, psPVRContext->eAPI, -+ psPVRScreen->psImpl); -+ free(psPVRContext); -+} -+ -+static IMG_PIXFMT -+PVRDRIGetPixelFormat(PVRDRIConfig *psPVRDRIConfig) -+{ -+ unsigned int uRGBBits; -+ unsigned int uRedMask, uGreenMask, uBlueMask, uAlphaMask; -+ unsigned int uSRGBCapable; -+ bool bRes; -+ -+ bRes = MODSUPConfigQuery(psPVRDRIConfig, -+ PVRDRI_CONFIG_ATTRIB_RGB_BITS, &uRGBBits); -+ -+ bRes &= MODSUPConfigQuery(psPVRDRIConfig, -+ PVRDRI_CONFIG_ATTRIB_RED_MASK, &uRedMask); -+ -+ bRes &= MODSUPConfigQuery(psPVRDRIConfig, -+ PVRDRI_CONFIG_ATTRIB_GREEN_MASK, -+ &uGreenMask); -+ -+ bRes &= MODSUPConfigQuery(psPVRDRIConfig, -+ PVRDRI_CONFIG_ATTRIB_BLUE_MASK, &uBlueMask); -+ -+ bRes &= MODSUPConfigQuery(psPVRDRIConfig, -+ PVRDRI_CONFIG_ATTRIB_ALPHA_MASK, -+ &uAlphaMask); -+ -+ bRes &= MODSUPConfigQuery(psPVRDRIConfig, -+ PVRDRI_CONFIG_ATTRIB_SRGB_CAPABLE, -+ &uSRGBCapable); -+ -+ if (!bRes) { -+ __driUtilMessage("%s: Config query failed", __func__); -+ return IMG_PIXFMT_UNKNOWN; -+ } -+ -+ switch (uRGBBits) { -+ case 32: -+ case 24: -+ if (uRedMask == 0x00FF0000 && -+ uGreenMask == 0x0000FF00 && uBlueMask == 0x000000FF) { -+ if (uAlphaMask == 0xFF000000) { -+ if (uSRGBCapable) -+ return IMG_PIXFMT_B8G8R8A8_UNORM_SRGB; -+ else -+ return IMG_PIXFMT_B8G8R8A8_UNORM; -+ } else if (uAlphaMask == 0) { -+ return IMG_PIXFMT_B8G8R8X8_UNORM; -+ } -+ } -+ -+ if (uRedMask == 0x000000FF && -+ uGreenMask == 0x0000FF00 && uBlueMask == 0x00FF0000) { -+ if (uAlphaMask == 0xFF000000) { -+ if (uSRGBCapable) -+ return IMG_PIXFMT_R8G8B8A8_UNORM_SRGB; -+ else -+ return IMG_PIXFMT_R8G8B8A8_UNORM; -+ } else if (uAlphaMask == 0) { -+ return IMG_PIXFMT_R8G8B8X8_UNORM; -+ } -+ } -+ -+ __driUtilMessage("%s: Unsupported format", __func__); -+ -+ return IMG_PIXFMT_UNKNOWN; -+ case 16: -+ if (uRedMask == 0xF800 && -+ uGreenMask == 0x07E0 && uBlueMask == 0x001F) { -+ return IMG_PIXFMT_B5G6R5_UNORM; -+ } -+ -+ __driUtilMessage("%s: Unsupported format", __func__); -+ -+ return IMG_PIXFMT_UNKNOWN; -+ default: -+ __driUtilMessage("%s: Unsupported format", __func__); -+ -+ return IMG_PIXFMT_UNKNOWN; -+ } -+} -+ -+struct DRISUPDrawable * -+DRIMODCreateDrawable(struct __DRIdrawableRec *psDRIDrawable, -+ struct DRISUPScreen *psPVRScreen, void *pvLoaderPrivate, -+ PVRDRIConfig *psPVRDRIConfig) -+{ -+ struct DRISUPDrawable *psPVRDrawable; -+ IMG_PIXFMT ePixelFormat; -+ unsigned int uDoubleBufferMode; -+ -+ psPVRDrawable = calloc(1, sizeof(*psPVRDrawable)); -+ if (!psPVRDrawable) { -+ __driUtilMessage("%s: Couldn't allocate PVR drawable", __func__); -+ goto ErrorDrawableFree; -+ } -+ -+ psPVRDrawable->psDRIDrawable = psDRIDrawable; -+ psPVRDrawable->psPVRScreen = psPVRScreen; -+ psPVRDrawable->pvLoaderPrivate = pvLoaderPrivate; -+ psPVRDrawable->psConfig = psPVRDRIConfig; -+ -+ ePixelFormat = PVRDRIGetPixelFormat(psPVRDRIConfig); -+ if (ePixelFormat == IMG_PIXFMT_UNKNOWN) { -+ __driUtilMessage("%s: Couldn't determine IMG pixel format", __func__); -+ goto ErrorDrawableFree; -+ } -+ -+ psPVRDrawable->psFormat = -+ PVRDRIIMGPixelFormatToImageFormat(psPVRScreen, ePixelFormat); -+ if (!psPVRDrawable->psFormat) { -+ __driUtilMessage("%s: Unsupported IMG pixel format (format = %u)", -+ __func__, ePixelFormat); -+ return false; -+ } -+ -+ if (!MODSUPConfigQuery(psPVRDRIConfig, -+ PVRDRI_CONFIG_ATTRIB_DOUBLE_BUFFER_MODE, -+ &uDoubleBufferMode)) { -+ __driUtilMessage("%s: Couldn't query double buffer mode", __func__); -+ goto ErrorDrawableFree; -+ } -+ psPVRDrawable->bDoubleBufferMode = (uDoubleBufferMode != 0); -+ -+ /* -+ * We aren't told the type of the drawable so treat double buffered -+ * drawables as windows and single buffered drawables as pixmaps (although -+ * these could actually be pbuffers). -+ */ -+ if (psPVRDrawable->bDoubleBufferMode) -+ psPVRDrawable->eType = PVRDRI_DRAWABLE_WINDOW; -+ else -+ psPVRDrawable->eType = PVRDRI_DRAWABLE_PIXMAP; -+ -+ psPVRDrawable->psImpl = -+ PVRDRICreateDrawableWithConfig((PVRDRIDrawable *) psPVRDrawable, -+ psPVRDRIConfig); -+ if (!psPVRDrawable->psImpl) { -+ __driUtilMessage("%s: Couldn't create PVR drawable", __func__); -+ goto ErrorDrawableFree; -+ } -+ -+ return psPVRDrawable; -+ -+ErrorDrawableFree: -+ PVRDRIDestroyDrawableImpl(psPVRDrawable->psImpl); -+ free(psPVRDrawable); -+ -+ return NULL; -+} -+ -+void -+DRIMODDestroyDrawable(struct DRISUPDrawable *psPVRDrawable) -+{ -+ PVRDrawableUnbindContext(psPVRDrawable); -+ PVRDRIDrawableDeinit(psPVRDrawable); -+ PVREGLDrawableDestroyConfig(psPVRDrawable->psImpl); -+ PVRDRIDestroyDrawableImpl(psPVRDrawable->psImpl); -+ free(psPVRDrawable); -+} -+ -+bool -+DRIMODMakeCurrent(struct DRISUPContext *psPVRContext, -+ struct DRISUPDrawable *psPVRWrite, -+ struct DRISUPDrawable *psPVRRead) -+{ -+ struct DRISUPDrawable *psPVRDrawableOld = psPVRContext->psPVRDrawable; -+ -+ if (psPVRWrite != NULL) { -+ if (!PVRDRIDrawableInit(psPVRWrite)) { -+ __driUtilMessage("%s: Couldn't initialise write drawable", __func__); -+ return false; -+ } -+ } -+ -+ if (psPVRRead != NULL) { -+ if (!PVRDRIDrawableInit(psPVRRead)) { -+ __driUtilMessage("%s: Couldn't initialise read drawable", __func__); -+ return false; -+ } -+ } -+ -+ if (!PVRDRIMakeCurrentGC(psPVRContext->eAPI, -+ psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, -+ psPVRWrite == NULL ? NULL : psPVRWrite->psImpl, -+ psPVRRead == NULL ? NULL : psPVRRead->psImpl)) -+ return false; -+ -+ if (psPVRDrawableOld != NULL) -+ psPVRDrawableOld->psPVRContext = NULL; -+ -+ if (psPVRWrite != NULL) -+ psPVRWrite->psPVRContext = psPVRContext; -+ -+ psPVRContext->psPVRDrawable = psPVRWrite; -+ -+ DRIMODThreadSetCurrentScreen(psPVRContext->psPVRScreen); -+ -+ return true; -+} -+ -+bool -+DRIMODUnbindContext(struct DRISUPContext *psPVRContext) -+{ -+ PVRContextUnbind(psPVRContext, true, false); -+ DRIMODThreadSetCurrentScreen(NULL); -+ -+ return true; -+} -+ -+struct DRISUPBuffer * -+DRIMODAllocateBuffer(struct DRISUPScreen *psPVRScreen, -+ unsigned int uAttachment, unsigned int uFormat, -+ int iWidth, int iHeight, unsigned int *puName, -+ unsigned int *puPitch, unsigned int *puCPP, -+ unsigned int *puFlags) -+{ -+ PVRDRIBufferImpl *psPVRBufferImpl; -+ unsigned int uBPP; -+ unsigned int uPitch; -+ -+ (void) uAttachment; -+ -+ /* GEM names are only supported on primary nodes */ -+ if (drmGetNodeTypeFromFd(psPVRScreen->iFD) != DRM_NODE_PRIMARY) { -+ __driUtilMessage("%s: Cannot allocate buffer", __func__); -+ return NULL; -+ } -+ -+ /* This is based upon PVRDRIGetPixelFormat */ -+ switch (uFormat) { -+ case 32: -+ case 16: -+ /* Format (depth) and bpp match */ -+ uBPP = uFormat; -+ break; -+ case 24: -+ uBPP = 32; -+ break; -+ default: -+ __driUtilMessage("%s: Unsupported format '%u'", __func__, uFormat); -+ return NULL; -+ } -+ -+ psPVRBufferImpl = PVRDRIBufferCreate(psPVRScreen->psImpl, iWidth, iHeight, -+ uBPP, PVDRI_BUFFER_USE_SHARE, &uPitch); -+ if (!psPVRBufferImpl) { -+ __driUtilMessage("%s: Failed to create backing buffer", __func__); -+ return NULL; -+ } -+ -+ *puName = PVRDRIBufferGetName(psPVRBufferImpl); -+ *puPitch = uPitch; -+ *puCPP = uBPP / 8; -+ *puFlags = 0; -+ -+ return (struct DRISUPBuffer *) psPVRBufferImpl; -+} -+ -+void -+DRIMODReleaseBuffer(struct DRISUPScreen *psPVRScreen, -+ struct DRISUPBuffer *psPVRBuffer) -+{ -+ PVRDRIBufferImpl *psPVRBufferImpl = (PVRDRIBufferImpl *) psPVRBuffer; -+ -+ (void) psPVRScreen; -+ -+ PVRDRIBufferDestroy(psPVRBufferImpl); -+} -+ -+/*************************************************************************//*! -+ Global functions -+ *//**************************************************************************/ -+ -+void -+DRIMODThreadSetCurrentScreen(struct DRISUPScreen *psPVRScreen) -+{ -+ gpsPVRScreen = psPVRScreen; -+} -+ -+struct DRISUPScreen * -+DRIMODThreadGetCurrentScreen(void) -+{ -+ return gpsPVRScreen; -+} -diff --git a/src/mesa/drivers/dri/pvr/pvrdri_mod.h b/src/mesa/drivers/dri/pvr/pvrdri_mod.h -new file mode 100644 -index 00000000000..e46b7b083e1 ---- /dev/null -+++ b/src/mesa/drivers/dri/pvr/pvrdri_mod.h -@@ -0,0 +1,450 @@ -+/* -+ * Copyright (c) Imagination Technologies Ltd. -+ * -+ * The contents of this file are subject to the MIT license as set out below. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to deal -+ * in the Software without restriction, including without limitation the rights -+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -+ * copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -+ * THE SOFTWARE. -+ */ -+ -+#if !defined(__PVRDRI_MOD_H__) -+#define __PVRDRI_MOD_H__ -+ -+#include -+#include -+ -+#include "pvrdri.h" -+ -+/* This should match EGL_MAX_PLANES */ -+#define DRI_PLANES_MAX 3 -+ -+#define DRI2_BUFFERS_MAX 3 -+ -+struct PVRDRIModifiers { -+ /* Number of modifiers for a given format */ -+ int iNumModifiers; -+ -+ /* Array of modifiers */ -+ uint64_t *puModifiers; -+ -+ /* -+ * Array of booleans that indicates which modifiers in the above array can -+ * only be used for EGL Image External (and so not for scanout). -+ */ -+ unsigned int *puExternalOnly; -+}; -+ -+/** Our PVR related screen data */ -+struct DRISUPScreen { -+ /* DRI screen structure pointer */ -+ struct __DRIscreenRec *psDRIScreen; -+ -+ /* Use invalidate events */ -+ bool bUseInvalidate; -+ -+ int iFD; -+ -+ void *pvLoaderPrivate; -+ -+ PVRDRIScreenImpl *psImpl; -+ -+ /* -+ * Number of supported formats: -+ * -1 -> couldn't be queried (pvr_dri_support too old) -+ * 0 -> uninitialised or initialisation failed -+ */ -+ int iNumFormats; -+ -+ /* Indicates which entries in the image format array are supported */ -+ bool *pbHasFormat; -+ -+ /* Array of modifiers for each image format array entry */ -+ struct PVRDRIModifiers *psModifiers; -+ -+ /* Supported Mesa formats */ -+ unsigned int *puMesaFormats; -+ unsigned int uNumMesaFormats; -+}; -+ -+/** Our PVR related context data */ -+struct DRISUPContext { -+ /* Pointer to DRI context */ -+ struct __DRIcontextRec *psDRIContext; -+ -+ /* Pointer to PVRDRIScreen structure */ -+ struct DRISUPScreen *psPVRScreen; -+ -+ /* Pointer to currently bound drawable */ -+ struct DRISUPDrawable *psPVRDrawable; -+ -+ /* API */ -+ PVRDRIAPIType eAPI; -+ -+ PVRDRIContextImpl *psImpl; -+ -+ /* Don't flush when the context is made uncurrent */ -+ bool bMakeUncurrentNoFlush; -+}; -+ -+typedef struct PVRDRIImageFormat_TAG { -+ /* -+ * IMG pixel format for the entire/overall image, e.g. -+ * IMG_PIXFMT_B8G8R8A8_UNORM or IMG_PIXFMT_YUV420_2PLANE. -+ */ -+ IMG_PIXFMT eIMGPixelFormat; -+ -+ /* -+ * DRI fourcc for the entire/overall image (defined by dri_interface.h), -+ * e.g. __DRI_IMAGE_FOURCC_ARGB8888 or __DRI_IMAGE_FOURCC_NV12. -+ */ -+ int iDRIFourCC; -+ -+ /* -+ * DRI components for the entire/overall image (defined by -+ * dri_interface.h), e.g. __DRI_IMAGE_COMPONENTS_RGBA or -+ * __DRI_IMAGE_COMPONENTS_Y_UV. -+ * -+ * This specifies the image components and their groupings, in terms of -+ * sub-images/planes, but not the order in which they appear. -+ * -+ * For example: -+ * - any combination of BGRA channels would correspond to -+ * __DRI_IMAGE_COMPONENTS_RGBA -+ * - any combination of BGR or BGRX would correspond to -+ * __DRI_IMAGE_COMPONENTS_RGB -+ * - any combination of YUV with 2 planes would correspond to -+ * __DRI_IMAGE_COMPONENTS_Y_UV -+ */ -+ int iDRIComponents; -+ -+ /* -+ * True if the format represents an sRGB colour space and false if it -+ * represents a linear one. -+ */ -+ bool bIsSRGB; -+ -+ /* The number of sub-images/planes that make up the overall image */ -+ unsigned int uiNumPlanes; -+ -+ /* Per-plane information */ -+ struct { -+ /* IMG pixel format for the plane */ -+ IMG_PIXFMT eIMGPixelFormat; -+ -+ /* -+ * This is the amount that the image width should be bit-shifted in -+ * order to give the plane width. This value can be determined from the -+ * YUV sub-sampling ratios and should either be 0 (full * width), 1 -+ * (half width) or 2 (quarter width). -+ */ -+ unsigned int uiWidthShift; -+ -+ /* -+ * This is the amount that the image height should be bit-shifted in -+ * order to give the plane height. This value can be determined from the -+ * YUV sub-sampling ratios and should either be 0 (full * height) or 1 -+ * (half height). -+ */ -+ unsigned int uiHeightShift; -+ } sPlanes[DRI_PLANES_MAX]; -+} PVRDRIImageFormat; -+ -+/** Our PVR related drawable data */ -+struct DRISUPDrawable { -+ /** Ptr to PVR screen, that spawned this drawable */ -+ struct DRISUPScreen *psPVRScreen; -+ -+ /** DRI drawable data */ -+ struct __DRIdrawableRec *psDRIDrawable; -+ -+ void *pvLoaderPrivate; -+ -+ bool bDoubleBufferMode; -+ PVRDRIDrawableType eType; -+ -+ PVRDRIConfig *psConfig; -+ -+ /** Are surface/buffers created? */ -+ bool bInitialised; -+ -+ /* Width and height */ -+ uint32_t uWidth; -+ uint32_t uHeight; -+ -+ /** Buffer stride */ -+ unsigned int uStride; -+ -+ /* Number of bytes per pixel */ -+ unsigned int uBytesPerPixel; -+ -+ /* Context bound to this drawable */ -+ struct DRISUPContext *psPVRContext; -+ -+ /* Format of this drawable */ -+ const PVRDRIImageFormat *psFormat; -+ -+ /* Indicates the drawable info is invalid */ -+ int iInfoInvalid; -+ -+ /* Indicates the drawable is currently being updated */ -+ bool bDrawableUpdating; -+ -+ /* Indicates a flush is in progress */ -+ bool bFlushInProgress; -+ -+ __DRIimage *psDRI; -+ __DRIimage *psImage; -+ -+ __DRIimage *psDRIAccum; -+ __DRIimage *psImageAccum; -+ -+ PVRDRIDrawableImpl *psImpl; -+}; -+ -+/*************************************************************************//*! -+ pvrdri_mod.c -+ *//**************************************************************************/ -+ -+struct DRISUPScreen *DRIMODThreadGetCurrentScreen(void); -+void DRIMODThreadSetCurrentScreen(struct DRISUPScreen *psPVRScreen); -+ -+void PVRDRIFlushBuffersForSwap(struct DRISUPContext *psPVRContext, -+ struct DRISUPDrawable *psPVRDrawable); -+ -+/*************************************************************************//*! -+ pvrutil_mod.c -+ *//**************************************************************************/ -+ -+const struct __DRIconfigRec **PVRDRICreateConfigs(const struct DRISUPScreen -+ *psPVRScreen); -+const PVRDRIImageFormat *PVRDRIFourCCToImageFormat(struct DRISUPScreen -+ *psPVRScreen, -+ int iDRIFourCC); -+const PVRDRIImageFormat *PVRDRIIMGPixelFormatToImageFormat(struct DRISUPScreen *psPVRScreen, -+ IMG_PIXFMT eIMGPixelFormat); -+IMG_YUV_COLORSPACE PVRDRIToIMGColourSpace(const PVRDRIImageFormat *psFormat, -+ unsigned int uDRIColourSpace, -+ unsigned int uDRISampleRange); -+IMG_YUV_CHROMA_INTERP PVRDRIChromaSittingToIMGInterp(const PVRDRIImageFormat *psFormat, -+ unsigned int uChromaSitting); -+bool PVRDRIGetSupportedFormats(struct DRISUPScreen *psPVRScreen); -+void PVRDRIDestroyFormatInfo(struct DRISUPScreen *psPVRScreen); -+bool PVRDRIValidateImageModifier(struct DRISUPScreen *psPVRScreen, -+ const int iFourCC, const uint64_t uiModifier); -+bool PVRDRIGetMesaFormats(struct DRISUPScreen *psPVRScreen); -+void PVRDRIFreeMesaFormats(struct DRISUPScreen *psPVRScreen); -+ -+/*************************************************************************//*! -+ pvrdrawable_mod.c -+ *//**************************************************************************/ -+ -+bool PVRDRIDrawableInit(struct DRISUPDrawable *psPVRDrawable); -+void PVRDRIDrawableDeinit(struct DRISUPDrawable *psPVRDrawable); -+bool PVRDRIDrawableQuery(const PVRDRIDrawable *psPVRDRIDrawable, -+ PVRDRIBufferAttrib eBufferAttrib, -+ uint32_t *uiValueOut); -+bool PVRDRIDrawableGetParametersV2(PVRDRIDrawable *psPVRDRIDrawable, -+ uint32_t uiFlags, -+ PVRDRIBufferImpl **ppsDstBuffer, -+ PVRDRIBufferImpl **ppsAccumBuffer); -+ -+/*************************************************************************//*! -+pvrimage_mod.c -+ *//**************************************************************************/ -+ -+__DRIimage *PVRDRIScreenGetDRIImage(void *hEGLImage); -+void PVRDRIRefImage(__DRIimage *psImage); -+void PVRDRIUnrefImage(__DRIimage *psImage); -+PVRDRIImageType PVRDRIImageGetSharedType(__DRIimage *psImage); -+PVRDRIBufferImpl *PVRDRIImageGetSharedBuffer(__DRIimage *psImage); -+IMGEGLImage *PVRDRIImageGetSharedEGLImage(__DRIimage *psImage); -+IMGEGLImage *PVRDRIImageGetEGLImage(__DRIimage *psImage); -+ -+/*************************************************************************//*! -+ Functions to implement PVRDRISupportInterfaceV2, for backwards compatibility -+ With DRI Support libraries that only provide PVRDRISupportInterface. -+ *//**************************************************************************/ -+ -+struct DRISUPScreen *DRIMODCreateScreen(struct __DRIscreenRec *psDRIScreen, -+ int iFD, bool bUseInvalidate, -+ void *pvLoaderPrivate, -+ const struct __DRIconfigRec ***pppsConfigs, -+ int *piMaxGLES1Version, -+ int *piMaxGLES2Version); -+void DRIMODDestroyScreen(struct DRISUPScreen *psDRISUPScreen); -+ -+unsigned int DRIMODCreateContext(PVRDRIAPIType eAPI, -+ PVRDRIConfig *psPVRDRIConfig, -+ struct PVRDRIContextConfig *psCtxConfig, -+ struct __DRIcontextRec *psDRIContext, -+ struct DRISUPContext *psDRISUPSharedContext, -+ struct DRISUPScreen *psDRISUPScreen, -+ struct DRISUPContext **ppsDRISUPContext); -+void DRIMODDestroyContext(struct DRISUPContext *psDRISUPContext); -+ -+struct DRISUPDrawable *DRIMODCreateDrawable(struct __DRIdrawableRec *psDRIDrawable, -+ struct DRISUPScreen *psDRISUPScreen, -+ void *pvLoaderPrivate, -+ PVRDRIConfig *psPVRDRIConfig); -+void DRIMODDestroyDrawable(struct DRISUPDrawable *psDRISUPDrawable); -+ -+bool DRIMODMakeCurrent(struct DRISUPContext *psDRISUPContext, -+ struct DRISUPDrawable *psDRISUPWrite, -+ struct DRISUPDrawable *psDRISUPRead); -+bool DRIMODUnbindContext(struct DRISUPContext *psDRISUPContext); -+ -+struct DRISUPBuffer *DRIMODAllocateBuffer(struct DRISUPScreen *psDRISUPScreen, -+ unsigned int uAttchment, -+ unsigned int uFormat, -+ int iWidth, int iHeight, -+ unsigned int *puName, -+ unsigned int *puPitch, -+ unsigned int *puCPP, -+ unsigned int *puFlags); -+void DRIMODReleaseBuffer(struct DRISUPScreen *psDRISUPScreen, -+ struct DRISUPBuffer *psDRISUPBuffer); -+void DRIMODSetTexBuffer2(struct DRISUPContext *psDRISUPContext, int iTarget, -+ int iFormat, struct DRISUPDrawable *psDRISUPDrawable); -+void DRIMODReleaseTexBuffer(struct DRISUPContext *psDRISUPContext, -+ int iTarget, -+ struct DRISUPDrawable *psDRISUPDrawable); -+ -+void DRIMODFlush(struct DRISUPDrawable *psDRISUPDrawable); -+void DRIMODInvalidate(struct DRISUPDrawable *psDRISUPDrawable); -+void DRIMODFlushWithFlags(struct DRISUPContext *psDRISUPContext, -+ struct DRISUPDrawable *psDRISUPDrawable, -+ unsigned int uFlags, unsigned int uThrottleReason); -+ -+__DRIimage *DRIMODCreateImageFromName(struct DRISUPScreen *psDRISUPScreen, -+ int iWidth, int iHeight, int iFourCC, -+ int iName, int iPitch, -+ void *pvLoaderPrivate); -+__DRIimage *DRIMODCreateImageFromRenderbuffer(struct DRISUPContext *psDRISUPContext, -+ int iRenderBuffer, -+ void *pvLoaderPrivate); -+void DRIMODDestroyImage(__DRIimage *psImage); -+__DRIimage *DRIMODCreateImage(struct DRISUPScreen *psDRISUPScreen, -+ int iWidth, int iHeight, int iFourCC, -+ unsigned int uUse, void *pvLoaderPrivate); -+bool DRIMODQueryImage(__DRIimage *psImage, int iAttrib, int *iValue); -+__DRIimage *DRIMODDupImage(__DRIimage *psImage, void *pvLoaderPrivate); -+bool DRIMODValidateImageUsage(__DRIimage *psImage, unsigned int uUse); -+__DRIimage *DRIMODCreateImageFromNames(struct DRISUPScreen *psDRISUPScreen, -+ int iWidth, int iHeight, int iFourCC, -+ int *piNames, int iNumNames, -+ int *piStrides, int *piOffsets, -+ void *pvLoaderPrivate); -+__DRIimage *DRIMODFromPlanar(__DRIimage *psImage, int iPlane, -+ void *pvLoaderPrivate); -+__DRIimage *DRIMODCreateImageFromTexture(struct DRISUPContext *psDRISUPContext, -+ int iTarget, unsigned int uTexture, -+ int iDepth, int iLevel, -+ unsigned int *puError, -+ void *pvLoaderPrivate); -+__DRIimage *DRIMODCreateImageFromFDs(struct DRISUPScreen *psDRISUPcreen, -+ int iWidth, int iHeight, int iFourCC, -+ int *piFDs, int iNumFDs, -+ int *piStrides, int *piOffsets, -+ void *pvLoaderPrivate); -+__DRIimage *DRIMODCreateImageFromDMABufs(struct DRISUPScreen *psDRISUPScreen, -+ int iWidth, int iHeight, int iFourCC, -+ int *piFDs, int iNumFDs, -+ int *piStrides, int *piOffsets, -+ unsigned int uColorSpace, -+ unsigned int uSampleRange, -+ unsigned int uHorizSiting, -+ unsigned int uVertSiting, -+ unsigned int *puError, -+ void *pvLoaderPrivate); -+int DRIMODGetImageCapabilities(struct DRISUPScreen *psDRISUPScreen); -+void DRIMODBlitImage(struct DRISUPContext *psDRISUPContext, -+ __DRIimage *psDst, __DRIimage *psSrc, -+ int iDstX0, int iDstY0, int iDstWidth, int iDstHeight, -+ int iSrcX0, int iSrcY0, int iSrcWidth, int iSrcHeight, -+ int iFlushFlag); -+void *DRIMODMapImage(struct DRISUPContext *psDRISUPContext, -+ __DRIimage *psImage, -+ int iX0, int iY0, int iWidth, int iHeight, -+ unsigned int iFlags, int *iStride, void **ppvData); -+void DRIMODUnmapImage(struct DRISUPContext *psDRISUPContext, -+ __DRIimage *psImage, void *pvData); -+__DRIimage *DRIMODCreateImageWithModifiers(struct DRISUPScreen *psDRISUPScreen, -+ int iWidth, int iHeight, -+ int iFourCC, -+ const uint64_t *puModifiers, -+ const unsigned int uModifierCount, -+ void *pvLoaderPrivate); -+__DRIimage *DRIMODCreateImageFromDMABufs2(struct DRISUPScreen *psDRISUPScreen, -+ int iWidth, int iHeight, -+ int iFourCC, uint64_t uModifier, -+ int *piFDs, int iNumFDs, -+ int *piStrides, int *piOffsets, -+ unsigned int uColorSpace, -+ unsigned int uSampleRange, -+ unsigned int uHorizSiting, -+ unsigned int uVertSiting, -+ unsigned int *puError, -+ void *pvLoaderPrivate); -+ -+bool DRIMODQueryDMABufFormats(struct DRISUPScreen *psDRISUPScreen, int iMax, -+ int *piFormats, int *piCount); -+bool DRIMODQueryDMABufModifiers(struct DRISUPScreen *psDRISUPScreen, -+ int iFourCC, int iMax, uint64_t *puModifiers, -+ unsigned int *piExternalOnly, int *piCount); -+bool DRIMODQueryDMABufFormatModifierAttribs(struct DRISUPScreen *psDRISUPScreen, -+ uint32_t uFourCC, -+ uint64_t uModifier, -+ int iAttribute, -+ uint64_t *puValue); -+ -+__DRIimage *DRIMODCreateImageFromRenderBuffer2(struct DRISUPContext *psDRISUPContext, -+ int iRenderBuffer, -+ void *pvLoaderPrivate, -+ unsigned int *puError); -+__DRIimage *DRIMODCreateImageFromBuffer(struct DRISUPContext *psDRISUPContext, -+ int iTarget, void *pvBuffer, -+ unsigned int *puError, -+ void *pvLoaderPrivate); -+ -+int DRIMODQueryRendererInteger(struct DRISUPScreen *psDRISUPScreen, -+ int iAttribute, unsigned int *puValue); -+int DRIMODQueryRendererString(struct DRISUPScreen *psDRISUPScreen, -+ int iAttribute, const char **ppszValue); -+ -+void *DRIMODCreateFence(struct DRISUPContext *psDRISUPContext); -+void DRIMODDestroyFence(struct DRISUPScreen *psDRISUPScreen, void *pvFence); -+bool DRIMODClientWaitSync(struct DRISUPContext *psDRISUPContext, -+ void *pvFence, unsigned int uFlags, -+ uint64_t uTimeout); -+void DRIMODServerWaitSync(struct DRISUPContext *psDRISUPContext, -+ void *pvFence, unsigned int uFlags); -+unsigned int DRIMODGetFenceCapabilities(struct DRISUPScreen *psDRISUPScreen); -+void *DRIMODCreateFenceFD(struct DRISUPContext *psDRISUPContext, int iFD); -+int DRIMODGetFenceFD(struct DRISUPScreen *psDRISUPScreen, void *pvFence); -+ -+unsigned int DRIMODGetNumAPIProcs(struct DRISUPScreen *psDRISUPScreen, -+ PVRDRIAPIType eAPI); -+const char *DRIMODGetAPIProcName(struct DRISUPScreen *psDRISUPScreen, -+ PVRDRIAPIType eAPI, unsigned int uIndex); -+void *DRIMODGetAPIProcAddress(struct DRISUPScreen *psDRISUPScreen, -+ PVRDRIAPIType eAPI, unsigned int uIndex); -+ -+void DRIMODSetDamageRegion(struct DRISUPDrawable *psDRISUPDrawable, -+ unsigned int uNRects, int *piRects); -+ -+#endif /* defined(__PVRDRI_MOD_H__) */ diff --git a/src/mesa/drivers/dri/pvr/pvrdri_support.h b/src/mesa/drivers/dri/pvr/pvrdri_support.h new file mode 100644 -index 00000000000..ced4f80ccc6 +index 00000000000..58ea3505a4d --- /dev/null +++ b/src/mesa/drivers/dri/pvr/pvrdri_support.h -@@ -0,0 +1,439 @@ +@@ -0,0 +1,206 @@ +/* + * Copyright (c) Imagination Technologies Ltd. + * @@ -6464,248 +3675,15 @@ index 00000000000..ced4f80ccc6 +void DRISUPSetDamageRegion(struct DRISUPDrawable *psDRISUPDrawable, + unsigned int uNRects, int *piRects); + -+/****************************************************************************** -+ * PVR DRI Support interface, version 1. -+ * Everything below this point is deprecated. -+ *****************************************************************************/ -+ -+#include "imgpixfmts.h" -+#include "imgyuv.h" -+ -+PVRDRIDeviceType PVRDRIGetDeviceTypeFromFd(int iFd); -+bool PVRDRIIsFirstScreen(PVRDRIScreenImpl *psScreenImpl); -+ -+uint32_t PVRDRIPixFmtGetDepth(IMG_PIXFMT eFmt); -+uint32_t PVRDRIPixFmtGetBPP(IMG_PIXFMT eFmt); -+uint32_t PVRDRIPixFmtGetBlockSize(IMG_PIXFMT eFmt); -+ -+/* ScreenImpl functions */ -+PVRDRIScreenImpl *PVRDRICreateScreenImpl(int iFd); -+void PVRDRIDestroyScreenImpl(PVRDRIScreenImpl *psScreenImpl); -+ -+int PVRDRIAPIVersion(PVRDRIAPIType eAPI, PVRDRIAPISubType eAPISub, -+ PVRDRIScreenImpl *psScreenImpl); -+ -+void *PVRDRIEGLGetLibHandle(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl); -+PVRDRIGLAPIProc PVRDRIEGLGetProcAddress(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ const char *psProcName); -+ -+bool PVRDRIEGLFlushBuffers(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl, -+ bool bFlushAllSurfaces, bool bSwapBuffers, -+ bool bWaitForHW); -+void PVRDRIEGLMarkRendersurfaceInvalid(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl); -+ -+unsigned int PVRDRICreateContextV1(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psSharedContextImpl, -+ PVRDRIConfig *psConfig, -+ PVRDRIAPIType eAPI, -+ PVRDRIAPISubType eAPISub, -+ unsigned int uMajorVersion, -+ unsigned int uMinorVersion, -+ uint32_t uFlags, bool bNotifyReset, -+ unsigned int uPriority, -+ PVRDRIContextImpl **ppsContextImpl); -+void PVRDRIDestroyContextImpl(PVRDRIContextImpl *psContextImpl, -+ PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl); -+ -+bool PVRDRIMakeCurrentGC(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psWriteImpl, -+ PVRDRIDrawableImpl *psReadImpl); -+void PVRDRIMakeUnCurrentGC(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl); -+ -+unsigned int PVRDRIGetImageSource(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ uint32_t uiTarget, uintptr_t uiBuffer, -+ uint32_t uiLevel, IMGEGLImage *psEGLImage); -+ -+bool PVRDRI2BindTexImage(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+void PVRDRI2ReleaseTexImage(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+ -+/* DrawableImpl functions */ -+PVRDRIDrawableImpl *PVRDRICreateDrawableWithConfig(PVRDRIDrawable *psPVRDrawable, -+ PVRDRIConfig *psConfig); -+void PVRDRIDestroyDrawableImpl(PVRDRIDrawableImpl *psScreenImpl); -+bool PVREGLDrawableCreate(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+bool PVREGLDrawableRecreate(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+bool PVREGLDrawableDestroy(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIDrawableImpl *psDrawableImpl); -+void PVREGLDrawableDestroyConfig(PVRDRIDrawableImpl *psDrawableImpl); -+ -+/* Buffer functions */ -+PVRDRIBufferImpl *PVRDRIBufferCreate(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, int iHeight, -+ unsigned int uiBpp, -+ unsigned int uiUseFlags, -+ unsigned int *puiStride); -+PVRDRIBufferImpl *PVRDRIBufferCreateWithModifiers(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, int iHeight, -+ int iFormat, -+ IMG_PIXFMT eIMGPixelFormat, -+ const uint64_t *puiModifiers, -+ unsigned int uiModifierCount, -+ unsigned int *puiStride); -+PVRDRIBufferImpl *PVRDRIBufferCreateFromNames(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, int iHeight, -+ unsigned int uiNumPlanes, -+ const int *piName, -+ const int *piStride, -+ const int *piOffset, -+ const unsigned int *puiWidthShift, -+ const unsigned int *puiHeightShift); -+PVRDRIBufferImpl *PVRDRIBufferCreateFromFds(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, int iHeight, -+ unsigned int uiNumPlanes, -+ const int *piFd, -+ const int *piStride, -+ const int *piOffset, -+ const unsigned int *puiWidthShift, -+ const unsigned int *puiHeightShift); -+PVRDRIBufferImpl *PVRDRIBufferCreateFromFdsWithModifier(PVRDRIScreenImpl *psScreenImpl, -+ int iWidth, -+ int iHeight, -+ uint64_t uiModifier, -+ unsigned int uiNumPlanes, -+ const int *piFd, -+ const int *piStride, -+ const int *piOffset, -+ const unsigned int *puiWidthShift, -+ const unsigned int *puiHeightShift); -+PVRDRIBufferImpl *PVRDRISubBufferCreate(PVRDRIScreenImpl *psScreen, -+ PVRDRIBufferImpl *psParent, -+ int plane); -+void PVRDRIBufferDestroy(PVRDRIBufferImpl *psBuffer); -+ -+int PVRDRIBufferGetFd(PVRDRIBufferImpl *psBuffer); -+int PVRDRIBufferGetHandle(PVRDRIBufferImpl *psBuffer); -+uint64_t PVRDRIBufferGetModifier(PVRDRIBufferImpl *psBuffer); -+int PVRDRIBufferGetName(PVRDRIBufferImpl *psBuffer); -+int PVRDRIBufferGetOffset(PVRDRIBufferImpl *psBuffer); -+ -+/* Image functions */ -+IMGEGLImage *PVRDRIEGLImageCreate(void); -+IMGEGLImage *PVRDRIEGLImageCreateFromBuffer(int iWidth, int iHeight, -+ int iStride, -+ IMG_PIXFMT ePixelFormat, -+ IMG_YUV_COLORSPACE eColourSpace, -+ IMG_YUV_CHROMA_INTERP eChromaUInterp, -+ IMG_YUV_CHROMA_INTERP eChromaVInterp, -+ PVRDRIBufferImpl *psBuffer); -+IMGEGLImage *PVRDRIEGLImageCreateFromSubBuffer(IMG_PIXFMT ePixelFormat, -+ PVRDRIBufferImpl *psSubBuffer); -+IMGEGLImage *PVRDRIEGLImageDup(IMGEGLImage *psIn); -+ -+void PVRDRIEGLImageSetCallbackData(IMGEGLImage *psEGLImage, -+ __DRIimage *image); -+ -+void PVRDRIEGLImageDestroyExternal(PVRDRIScreenImpl *psScreenImpl, -+ IMGEGLImage *psEGLImage, -+ PVRDRIEGLImageType eglImageType); -+void PVRDRIEGLImageFree(IMGEGLImage *psEGLImage); -+ -+void PVRDRIEGLImageGetAttribs(IMGEGLImage *psEGLImage, -+ PVRDRIBufferAttribs *psAttribs); -+ -+/* Sync functions */ -+void *PVRDRICreateFenceImpl(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl); -+void PVRDRIDestroyFenceImpl(void *pvFence); -+ -+bool PVRDRIClientWaitSyncImpl(PVRDRIAPIType eAPI, -+ PVRDRIContextImpl *psContextImpl, -+ void *pvFence, bool bFlushCommands, -+ bool bTimeout, uint64_t uiTimeout); -+bool PVRDRIServerWaitSyncImpl(PVRDRIAPIType eAPI, -+ PVRDRIContextImpl *psContextImpl, -+ void *pvFence); -+ -+/* Blit functions */ -+bool PVRDRIBlitEGLImage(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psDstImage, -+ PVRDRIBufferImpl *psDstBuffer, -+ IMGEGLImage *psSrcImage, -+ PVRDRIBufferImpl *psSrcBuffer, -+ int iDstX, int iDstY, int iDstWidth, int iDstHeight, -+ int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, -+ int iFlushFlag); -+ -+/* Mapping functions */ -+void *PVRDRIMapEGLImage(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psImage, PVRDRIBufferImpl *psBuffer, -+ int iX, int iY, int iWidth, int iHeight, -+ unsigned int uiFlags, int *piStride, void **ppvData); -+bool PVRDRIUnmapEGLImage(PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, -+ IMGEGLImage *psImage, PVRDRIBufferImpl *psBuffer, -+ void *pvData); -+ -+/* Fence functions */ -+void *PVRDRICreateFenceImpl(PVRDRIAPIType eAPI, -+ PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl); -+void *PVRDRICreateFenceFd(PVRDRIAPIType eAPI, PVRDRIScreenImpl *psScreenImpl, -+ PVRDRIContextImpl *psContextImpl, int iFd); -+unsigned int PVRDRIGetFenceCapabilities(PVRDRIScreenImpl *psScreenImpl); -+int PVRDRIGetFenceFd(void *pvFence); -+void PVRDRIDestroyFenceImpl(void *pvFence); -+ -+bool PVRDRIClientWaitSyncImpl(PVRDRIAPIType eAPI, -+ PVRDRIContextImpl *psContextImpl, void *pvFence, -+ bool bFlushCommands, -+ bool bTimeout, uint64_t uiTimeout); -+ -+bool PVRDRIServerWaitSyncImpl(PVRDRIAPIType eAPI, -+ PVRDRIContextImpl *psContextImpl, -+ void *pvFence); -+ -+/* PVR utility support functions */ -+bool PVRDRIMesaFormatSupported(unsigned int iFormat); -+unsigned int PVRDRIDepthStencilBitArraySize(void); -+const uint8_t *PVRDRIDepthBitsArray(void); -+const uint8_t *PVRDRIStencilBitsArray(void); -+unsigned int PVRDRIMSAABitArraySize(void); -+const uint8_t *PVRDRIMSAABitsArray(void); -+uint32_t PVRDRIMaxPBufferWidth(void); -+uint32_t PVRDRIMaxPBufferHeight(void); -+ -+unsigned int PVRDRIGetNumAPIFuncs(PVRDRIAPIType eAPI); -+const char *PVRDRIGetAPIFunc(PVRDRIAPIType eAPI, unsigned int index); -+ -+int PVRDRIQuerySupportedFormats(PVRDRIScreenImpl *psScreenImpl, -+ unsigned int uNumFormats, -+ const int *piFormats, -+ const IMG_PIXFMT *peImgFormats, -+ bool *pbSupported); -+int PVRDRIQueryModifiers(PVRDRIScreenImpl *psScreenImpl, -+ int iFormat, IMG_PIXFMT eImgFormat, -+ uint64_t *puModifiers, unsigned int *puExternalOnly); ++bool DRISUPHaveGetFenceFromCLEvent(void); + +#endif /* defined(__PVRDRI_SUPPORT_H__) */ diff --git a/src/mesa/drivers/dri/pvr/pvrext.c b/src/mesa/drivers/dri/pvr/pvrext.c new file mode 100644 -index 00000000000..eb94f3f50c5 +index 00000000000..478399618df --- /dev/null +++ b/src/mesa/drivers/dri/pvr/pvrext.c -@@ -0,0 +1,698 @@ +@@ -0,0 +1,704 @@ +/* + * Copyright (c) Imagination Technologies Ltd. + * @@ -6911,9 +3889,9 @@ index 00000000000..eb94f3f50c5 + int iFourCC; + + switch (iAttrib) { -+ case PVRDRI_IMAGE_ATTRIB_FORMAT: ++ case __DRI_IMAGE_ATTRIB_FORMAT: + if (DRISUPQueryImage(psImage, -+ PVRDRI_IMAGE_ATTRIB_FOURCC, &iFourCC)) { ++ __DRI_IMAGE_ATTRIB_FOURCC, &iFourCC)) { + *piValue = PVRDRIFourCCToDRIFormat(iFourCC); + return GL_TRUE; + } @@ -7394,6 +4372,12 @@ index 00000000000..eb94f3f50c5 +{ + switch (uVersion) { + default: ++ case 4: ++ /* Is the KHR_cl_event2 EGL extension supported? */ ++ if (!DRISUPHaveGetFenceFromCLEvent()) ++ pvrDRIFenceExtension.get_fence_from_cl_event = NULL; ++ ++ break; + case 3: + break; + case 2: @@ -7404,1576 +4388,6 @@ index 00000000000..eb94f3f50c5 + break; + } +} -diff --git a/src/mesa/drivers/dri/pvr/pvrext_mod.c b/src/mesa/drivers/dri/pvr/pvrext_mod.c -new file mode 100644 -index 00000000000..dfb5c79eeb4 ---- /dev/null -+++ b/src/mesa/drivers/dri/pvr/pvrext_mod.c -@@ -0,0 +1,276 @@ -+/* -+ * Copyright (c) Imagination Technologies Ltd. -+ * -+ * The contents of this file are subject to the MIT license as set out below. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to deal -+ * in the Software without restriction, including without limitation the rights -+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -+ * copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -+ * THE SOFTWARE. -+ */ -+ -+#include -+#include -+ -+#include "util/u_atomic.h" -+#include "pvrdri_mod.h" -+ -+static void -+PVRDRIFlushDrawableContext(struct DRISUPDrawable *psPVRDrawable, -+ struct DRISUPContext *psPVRContext) -+{ -+ struct DRISUPContext *psPVRDrawContext = psPVRDrawable->psPVRContext; -+ -+ if (psPVRDrawContext) { -+ PVRDRIEGLFlushBuffers(psPVRDrawContext->eAPI, -+ psPVRDrawContext->psPVRScreen->psImpl, -+ psPVRDrawContext->psImpl, -+ psPVRDrawable->psImpl, -+ false, -+ false, (psPVRDrawContext != psPVRContext)); -+ } -+} -+ -+void -+DRIMODSetTexBuffer2(struct DRISUPContext *psPVRContext, int iTarget, -+ int iFormat, struct DRISUPDrawable *psPVRDrawable) -+{ -+ (void) iTarget; -+ (void) iFormat; -+ -+ if (!psPVRDrawable->bInitialised) { -+ if (!PVRDRIDrawableInit(psPVRDrawable)) { -+ __driUtilMessage("%s: Couldn't initialise pixmap", __func__); -+ return; -+ } -+ } -+ -+ PVRDRIFlushDrawableContext(psPVRDrawable, psPVRContext); -+ PVRDRI2BindTexImage(psPVRContext->eAPI, psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, psPVRDrawable->psImpl); -+} -+ -+void -+DRIMODReleaseTexBuffer(struct DRISUPContext *psPVRContext, int iTarget, -+ struct DRISUPDrawable *psPVRDrawable) -+{ -+ (void) iTarget; -+ -+ PVRDRI2ReleaseTexImage(psPVRContext->eAPI, -+ psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, psPVRDrawable->psImpl); -+} -+ -+void -+DRIMODFlush(struct DRISUPDrawable *psPVRDrawable) -+{ -+ struct DRISUPContext *psPVRContext = psPVRDrawable->psPVRContext; -+ -+ PVRDRIFlushBuffersForSwap(psPVRContext, psPVRDrawable); -+} -+ -+void -+DRIMODInvalidate(struct DRISUPDrawable *psPVRDrawable) -+{ -+ if (psPVRDrawable->psPVRScreen->bUseInvalidate) -+ p_atomic_inc(&psPVRDrawable->iInfoInvalid); -+} -+ -+void -+DRIMODFlushWithFlags(struct DRISUPContext *psPVRContext, -+ struct DRISUPDrawable *psPVRDrawable, -+ unsigned int uFlags, unsigned int uThrottleReason) -+{ -+ (void) uThrottleReason; -+ -+ if ((uFlags & PVRDRI_FLUSH_DRAWABLE) != 0) { -+ PVRDRIFlushBuffersForSwap(psPVRContext, psPVRDrawable); -+ } else if ((uFlags & PVRDRI_FLUSH_CONTEXT) != 0) { -+ /* -+ * PVRDRI_FLUSH__CONTEXT means "glFlush". Most callers also specify -+ * PVRDRI_FLUSH_DRAWABLE. An exception is GBM, which flushes after an -+ * unmap, when there doesn't appear to be a need to flush outstanding -+ * GPU operations. -+ */ -+ } -+} -+ -+int -+DRIMODQueryRendererInteger(struct DRISUPScreen *psPVRScreen, int iAttribute, -+ unsigned int *puValue) -+{ -+ (void) psPVRScreen; -+ -+ switch (iAttribute) { -+ case PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY: -+ puValue[0] = 0; -+ puValue[0] |= PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_HIGH; -+ puValue[0] |= PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM; -+ puValue[0] |= PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_LOW; -+ return 0; -+ case PVRDRI_RENDERER_HAS_FRAMEBUFFER_SRGB: -+ puValue[0] = 1; -+ return 0; -+ default: -+ return -1; -+ } -+} -+ -+int -+DRIMODQueryRendererString(struct DRISUPScreen *psPVRScreen, int iAttribute, -+ const char **ppszValue) -+{ -+ (void) psPVRScreen; -+ (void) iAttribute; -+ (void) ppszValue; -+ -+ return -1; -+} -+ -+void * -+DRIMODCreateFence(struct DRISUPContext *psPVRContext) -+{ -+ return PVRDRICreateFenceImpl(psPVRContext->eAPI, -+ psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl); -+} -+ -+void -+DRIMODDestroyFence(struct DRISUPScreen *psPVRScreen, void *pvFence) -+{ -+ (void) psPVRScreen; -+ -+ PVRDRIDestroyFenceImpl(pvFence); -+} -+ -+bool -+DRIMODClientWaitSync(struct DRISUPContext *psPVRContext, void *pvFence, -+ unsigned int uFlags, uint64_t uTimeout) -+{ -+ bool bFlushCommands = (uFlags & PVRDRI_FENCE_FLAG_FLUSH_COMMANDS); -+ bool bTimeout = (uTimeout != PVRDRI_FENCE_TIMEOUT_INFINITE); -+ -+ if (psPVRContext && bFlushCommands) { -+ struct DRISUPDrawable *psPVRDrawable; -+ PVRDRIDrawableImpl *psDrawableImpl; -+ -+ psPVRDrawable = psPVRContext->psPVRDrawable; -+ psDrawableImpl = psPVRDrawable ? psPVRDrawable->psImpl : NULL; -+ -+ (void) PVRDRIEGLFlushBuffers(psPVRContext->eAPI, -+ psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, -+ psDrawableImpl, true, false, false); -+ } -+ -+ return PVRDRIClientWaitSyncImpl(PVRDRI_API_NONE, NULL, pvFence, false, -+ bTimeout, uTimeout); -+} -+ -+void -+DRIMODServerWaitSync(struct DRISUPContext *psPVRContext, void *pvFence, -+ unsigned int uFlags) -+{ -+ assert(uFlags == 0); -+ (void) uFlags; -+ -+ if (pvFence) { -+ if (!PVRDRIServerWaitSyncImpl(psPVRContext->eAPI, -+ psPVRContext->psImpl, pvFence)) { -+ __driUtilMessage("%s: Server wait sync failed", __func__); -+ } -+ } -+} -+ -+unsigned int -+DRIMODGetFenceCapabilities(struct DRISUPScreen *psPVRScreen) -+{ -+ return PVRDRIGetFenceCapabilities(psPVRScreen->psImpl); -+} -+ -+void * -+DRIMODCreateFenceFD(struct DRISUPContext *psPVRContext, int iFD) -+{ -+ return PVRDRICreateFenceFd(psPVRContext->eAPI, -+ psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, iFD); -+} -+ -+int -+DRIMODGetFenceFD(struct DRISUPScreen *psPVRScreen, void *pvFence) -+{ -+ (void) psPVRScreen; -+ -+ return PVRDRIGetFenceFd(pvFence); -+} -+ -+unsigned int -+DRIMODGetNumAPIProcs(struct DRISUPScreen *psPVRScreen, PVRDRIAPIType eAPI) -+{ -+ (void) psPVRScreen; -+ -+ return PVRDRIGetNumAPIFuncs(eAPI); -+} -+ -+const char * -+DRIMODGetAPIProcName(struct DRISUPScreen *psPVRScreen, PVRDRIAPIType eAPI, -+ unsigned int uIndex) -+{ -+ (void) psPVRScreen; -+ -+ return PVRDRIGetAPIFunc(eAPI, uIndex); -+} -+ -+void * -+DRIMODGetAPIProcAddress(struct DRISUPScreen *psPVRScreen, PVRDRIAPIType eAPI, -+ unsigned int uIndex) -+{ -+ const char *pszFunc; -+ void *pvHandle; -+ void *pvFunc; -+ const char *pszError; -+ -+ pszFunc = PVRDRIGetAPIFunc(eAPI, uIndex); -+ if (!pszFunc) { -+ __driUtilMessage("%s: No Proc for API %u at index %u", -+ __func__, (unsigned int) eAPI, uIndex); -+ return NULL; -+ } -+ -+ pvHandle = PVRDRIEGLGetLibHandle(eAPI, psPVRScreen->psImpl); -+ if (!pvHandle) { -+ __driUtilMessage("%s: No library handle for API %u", -+ __func__, (unsigned int) eAPI); -+ return NULL; -+ } -+ -+ (void) dlerror(); -+ pvFunc = dlsym(pvHandle, pszFunc); -+ pszError = dlerror(); -+ if (pszError) -+ pvFunc = PVRDRIEGLGetProcAddress(eAPI, psPVRScreen->psImpl, pszFunc); -+ -+ return pvFunc; -+} -+ -+void -+DRIMODSetDamageRegion(struct DRISUPDrawable *psDRISUPDrawable, -+ unsigned int uNRects, int *piRects) -+{ -+ (void) psDRISUPDrawable; -+ (void) uNRects; -+ (void) piRects; -+} -diff --git a/src/mesa/drivers/dri/pvr/pvrimage_mod.c b/src/mesa/drivers/dri/pvr/pvrimage_mod.c -new file mode 100644 -index 00000000000..df4a7f4d6fb ---- /dev/null -+++ b/src/mesa/drivers/dri/pvr/pvrimage_mod.c -@@ -0,0 +1,1282 @@ -+/* -+ * Copyright (c) Imagination Technologies Ltd. -+ * -+ * The contents of this file are subject to the MIT license as set out below. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to deal -+ * in the Software without restriction, including without limitation the rights -+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -+ * copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -+ * THE SOFTWARE. -+ */ -+ -+#include -+#include -+ -+#include "util/u_atomic.h" -+#include -+ -+#include "img_drm_fourcc.h" -+#include "pvrdri_mod.h" -+ -+struct PVRDRIImageShared { -+ int iRefCount; -+ -+ struct DRISUPScreen *psPVRScreen; -+ -+ PVRDRIImageType eType; -+ const PVRDRIImageFormat *psFormat; -+ IMG_YUV_COLORSPACE eColourSpace; -+ IMG_YUV_CHROMA_INTERP eChromaUInterp; -+ IMG_YUV_CHROMA_INTERP eChromaVInterp; -+ -+ PVRDRIBufferImpl *psBuffer; -+ IMGEGLImage *psEGLImage; -+ PVRDRIEGLImageType eglImageType; -+ struct PVRDRIImageShared *psAncestor; -+}; -+ -+struct __DRIimageRec { -+ int iRefCount; -+ -+ void *pvLoaderPrivate; -+ -+ struct PVRDRIImageShared *psShared; -+ -+ IMGEGLImage *psEGLImage; -+}; -+ -+ -+static struct PVRDRIImageShared * -+CommonImageSharedSetup(struct DRISUPScreen *psPVRScreen, -+ PVRDRIImageType eType) -+{ -+ struct PVRDRIImageShared *psShared; -+ -+ psShared = calloc(1, sizeof(*psShared)); -+ if (!psShared) -+ return NULL; -+ -+ psShared->psPVRScreen = psPVRScreen; -+ psShared->eType = eType; -+ psShared->iRefCount = 1; -+ -+ assert(psShared->eColourSpace == IMG_COLORSPACE_UNDEFINED && -+ psShared->eChromaUInterp == IMG_CHROMA_INTERP_UNDEFINED && -+ psShared->eChromaVInterp == IMG_CHROMA_INTERP_UNDEFINED); -+ -+ return psShared; -+} -+ -+static void -+DestroyImageShared(struct PVRDRIImageShared *psShared) -+{ -+ int iRefCount = p_atomic_dec_return(&psShared->iRefCount); -+ -+ assert(iRefCount >= 0); -+ -+ if (iRefCount > 0) -+ return; -+ -+ switch (psShared->eType) { -+ case PVRDRI_IMAGE_FROM_NAMES: -+ case PVRDRI_IMAGE_FROM_DMABUFS: -+ case PVRDRI_IMAGE: -+ if (psShared->psBuffer) -+ PVRDRIBufferDestroy(psShared->psBuffer); -+ -+ assert(!psShared->psAncestor); -+ break; -+ case PVRDRI_IMAGE_FROM_EGLIMAGE: { -+ PVRDRIScreenImpl *psScreenImpl; -+ -+ psScreenImpl = psShared->psPVRScreen->psImpl; -+ -+ PVRDRIEGLImageDestroyExternal(psScreenImpl, -+ psShared->psEGLImage, -+ psShared->eglImageType); -+ break; -+ } -+ case PVRDRI_IMAGE_SUBIMAGE: -+ if (psShared->psBuffer) -+ PVRDRIBufferDestroy(psShared->psBuffer); -+ -+ if (psShared->psAncestor) -+ DestroyImageShared(psShared->psAncestor); -+ break; -+ default: -+ errorMessage("%s: Unknown image type: %d", -+ __func__, (int) psShared->eType); -+ break; -+ } -+ -+ free(psShared); -+} -+ -+static struct PVRDRIImageShared * -+CreateImageSharedFromEGLImage(struct DRISUPScreen *psPVRScreen, -+ IMGEGLImage *psEGLImage, -+ PVRDRIEGLImageType eglImageType) -+{ -+ struct PVRDRIImageShared *psShared; -+ PVRDRIBufferAttribs sAttribs; -+ const PVRDRIImageFormat *psFormat; -+ -+ PVRDRIEGLImageGetAttribs(psEGLImage, &sAttribs); -+ -+ psFormat = PVRDRIIMGPixelFormatToImageFormat(psPVRScreen, -+ sAttribs.ePixFormat); -+ if (!psFormat) -+ return NULL; -+ -+ psShared = CommonImageSharedSetup(psPVRScreen, PVRDRI_IMAGE_FROM_EGLIMAGE); -+ if (!psShared) -+ return NULL; -+ -+ psShared->psEGLImage = psEGLImage; -+ psShared->psFormat = psFormat; -+ psShared->eglImageType = eglImageType; -+ -+ return psShared; -+} -+ -+static struct PVRDRIImageShared * -+CreateImageSharedFromNames(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, int iFourCC, -+ int *piNames, int iNumNames, -+ int *piStrides, int *piOffsets) -+{ -+ struct PVRDRIImageShared *psShared; -+ const PVRDRIImageFormat *psFormat; -+ int aiPlaneNames[DRI_PLANES_MAX]; -+ unsigned int auiWidthShift[DRI_PLANES_MAX]; -+ unsigned int auiHeightShift[DRI_PLANES_MAX]; -+ unsigned int i; -+ -+ psFormat = PVRDRIFourCCToImageFormat(psPVRScreen, iFourCC); -+ if (!psFormat) { -+ errorMessage("%s: Unsupported DRI FourCC (fourcc = 0x%X)", -+ __func__, iFourCC); -+ return NULL; -+ } -+ -+ if (iNumNames != 1 && iNumNames != (int) psFormat->uiNumPlanes) { -+ errorMessage("%s: Unexpected number of names (%d) for fourcc " -+ "(#%x) - expected 1 or %u", -+ __func__, iNumNames, iFourCC, psFormat->uiNumPlanes); -+ return NULL; -+ } -+ -+ for (i = 0; i < psFormat->uiNumPlanes; i++) { -+ if (piOffsets[i] < 0) { -+ errorMessage("%s: Offset %d unsupported (value = %d)", -+ __func__, i, piOffsets[i]); -+ return NULL; -+ } -+ -+ aiPlaneNames[i] = iNumNames == 1 ? piNames[0] : piNames[i]; -+ auiWidthShift[i] = psFormat->sPlanes[i].uiWidthShift; -+ auiHeightShift[i] = psFormat->sPlanes[i].uiHeightShift; -+ } -+ -+ psShared = -+ CommonImageSharedSetup(psPVRScreen, PVRDRI_IMAGE_FROM_NAMES); -+ if (!psShared) -+ return NULL; -+ -+ psShared->psBuffer = PVRDRIBufferCreateFromNames(psPVRScreen->psImpl, -+ iWidth, iHeight, -+ psFormat->uiNumPlanes, -+ aiPlaneNames, -+ piStrides, piOffsets, -+ auiWidthShift, -+ auiHeightShift); -+ if (!psShared->psBuffer) { -+ errorMessage("%s: Failed to create buffer for shared image", -+ __func__); -+ goto ErrorDestroyImage; -+ } -+ -+ psShared->psFormat = psFormat; -+ psShared->eColourSpace = -+ PVRDRIToIMGColourSpace(psFormat, -+ PVRDRI_YUV_COLOR_SPACE_UNDEFINED, -+ PVRDRI_YUV_RANGE_UNDEFINED); -+ psShared->eChromaUInterp = -+ PVRDRIChromaSittingToIMGInterp(psFormat, -+ PVRDRI_YUV_CHROMA_SITING_UNDEFINED); -+ psShared->eChromaVInterp = -+ PVRDRIChromaSittingToIMGInterp(psFormat, -+ PVRDRI_YUV_CHROMA_SITING_UNDEFINED); -+ -+ return psShared; -+ -+ErrorDestroyImage: -+ DestroyImageShared(psShared); -+ -+ return NULL; -+} -+ -+static struct PVRDRIImageShared * -+CreateImageSharedFromDMABufs(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, -+ int iFourCC, uint64_t uModifier, -+ int *piFDs, int iNumFDs, -+ int *piStrides, int *piOffsets, -+ unsigned int uColorSpace, -+ unsigned int uSampleRange, -+ unsigned int uHorizSiting, -+ unsigned int uVertSiting, -+ unsigned int *puError) -+{ -+ struct PVRDRIImageShared *psShared; -+ const PVRDRIImageFormat *psFormat; -+ int aiPlaneFDs[DRI_PLANES_MAX]; -+ unsigned int auiWidthShift[DRI_PLANES_MAX]; -+ unsigned int auiHeightShift[DRI_PLANES_MAX]; -+ unsigned int i; -+ -+ psFormat = PVRDRIFourCCToImageFormat(psPVRScreen, iFourCC); -+ if (!psFormat) { -+ errorMessage("%s: Unsupported DRI FourCC (fourcc = 0x%X)", -+ __func__, iFourCC); -+ *puError = PVRDRI_IMAGE_ERROR_BAD_MATCH; -+ return NULL; -+ } -+ -+ /* When a modifier isn't specified, skip the validation */ -+ if (uModifier != DRM_FORMAT_MOD_INVALID) { -+ /* -+ * The modifier validation has to be done in this "higher" level -+ * function instead of pvr_dri_support. The support for modifiers is -+ * done on per format basis, but there is no way to pass the format -+ * information down to the plane creation API in pvr_dri_support. -+ */ -+ if (!PVRDRIValidateImageModifier(psPVRScreen, iFourCC, uModifier)) { -+ errorMessage("%s: Unsupported mod (fmt = %#x, mod = %#llx", -+ __func__, iFourCC, -+ (long long unsigned int) uModifier); -+ *puError = PVRDRI_IMAGE_ERROR_BAD_MATCH; -+ return NULL; -+ } -+ } -+ -+ if (iNumFDs != 1 && iNumFDs != (int) psFormat->uiNumPlanes) { -+ errorMessage("%s: Unexpected number of FDs (%d) for fourcc " -+ "(#%x) - expected 1 or %u", -+ __func__, iNumFDs, iFourCC, psFormat->uiNumPlanes); -+ *puError = PVRDRI_IMAGE_ERROR_BAD_MATCH; -+ return NULL; -+ } -+ -+ for (i = 0; i < psFormat->uiNumPlanes; i++) { -+ if (piOffsets[i] < 0) { -+ errorMessage("%s: Offset %d unsupported (value = %d)", -+ __func__, i, piOffsets[i]); -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ACCESS; -+ return NULL; -+ } -+ -+ aiPlaneFDs[i] = iNumFDs == 1 ? piFDs[0] : piFDs[i]; -+ auiWidthShift[i] = psFormat->sPlanes[i].uiWidthShift; -+ auiHeightShift[i] = psFormat->sPlanes[i].uiHeightShift; -+ } -+ -+ psShared = CommonImageSharedSetup(psPVRScreen, -+ PVRDRI_IMAGE_FROM_DMABUFS); -+ if (!psShared) { -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ psShared->psBuffer = -+ PVRDRIBufferCreateFromFdsWithModifier(psPVRScreen->psImpl, -+ iWidth, iHeight, uModifier, -+ psFormat->uiNumPlanes, aiPlaneFDs, -+ piStrides, piOffsets, -+ auiWidthShift, auiHeightShift); -+ if (!psShared->psBuffer) { -+ errorMessage("%s: Failed to create buffer for shared image", -+ __func__); -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ goto ErrorDestroyImage; -+ } -+ -+ psShared->psFormat = psFormat; -+ psShared->eColourSpace = PVRDRIToIMGColourSpace(psFormat, uColorSpace, -+ uSampleRange); -+ psShared->eChromaUInterp = PVRDRIChromaSittingToIMGInterp(psFormat, -+ uHorizSiting); -+ psShared->eChromaVInterp = PVRDRIChromaSittingToIMGInterp(psFormat, -+ uVertSiting); -+ -+ *puError = PVRDRI_IMAGE_ERROR_SUCCESS; -+ -+ return psShared; -+ -+ErrorDestroyImage: -+ DestroyImageShared(psShared); -+ -+ return NULL; -+} -+ -+static struct PVRDRIImageShared * -+CreateImageShared(struct DRISUPScreen *psPVRScreen, int iWidth, int iHeight, -+ int iFourCC, unsigned int use, int *piStride) -+{ -+ struct PVRDRIImageShared *psShared; -+ const PVRDRIImageFormat *psFormat; -+ unsigned int uStride; -+ unsigned int uBPP; -+ -+ if ((use & PVDRI_BUFFER_USE_CURSOR) -+ && (use & PVDRI_BUFFER_USE_SCANOUT)) { -+ return NULL; -+ } -+ -+ psFormat = PVRDRIFourCCToImageFormat(psPVRScreen, iFourCC); -+ if (!psFormat) { -+ errorMessage("%s: Unsupported DRI image format (format = 0x%X)", -+ __func__, iFourCC); -+ return NULL; -+ } -+ -+ if (psFormat->uiNumPlanes != 1) { -+ errorMessage("%s: Only single plane formats are supported (format 0x%X has %u planes)", -+ __func__, iFourCC, psFormat->uiNumPlanes); -+ return NULL; -+ } -+ -+ uBPP = PVRDRIPixFmtGetBPP(psFormat->eIMGPixelFormat); -+ -+ psShared = CommonImageSharedSetup(psPVRScreen, PVRDRI_IMAGE); -+ if (!psShared) -+ return NULL; -+ -+ psShared->psBuffer = -+ PVRDRIBufferCreate(psPVRScreen->psImpl, iWidth, iHeight, uBPP, use, -+ &uStride); -+ if (!psShared->psBuffer) { -+ errorMessage("%s: Failed to create buffer", __func__); -+ goto ErrorDestroyImage; -+ } -+ -+ psShared->psFormat = psFormat; -+ -+ *piStride = uStride; -+ -+ return psShared; -+ -+ErrorDestroyImage: -+ DestroyImageShared(psShared); -+ -+ return NULL; -+} -+ -+static struct PVRDRIImageShared * -+CreateImageSharedWithModifiers(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, int iFourCC, -+ const uint64_t *puModifiers, -+ unsigned int uModifierCount, int *piStride) -+{ -+ struct PVRDRIImageShared *psShared; -+ const PVRDRIImageFormat *psFormat; -+ unsigned int uStride; -+ -+ psFormat = PVRDRIFourCCToImageFormat(psPVRScreen, iFourCC); -+ if (!psFormat) { -+ errorMessage("%s: Unsupported DRI image format (format = 0x%X)", -+ __func__, iFourCC); -+ return NULL; -+ } -+ -+ psShared = CommonImageSharedSetup(psPVRScreen, PVRDRI_IMAGE); -+ if (!psShared) -+ return NULL; -+ -+ psShared->psBuffer = -+ PVRDRIBufferCreateWithModifiers(psPVRScreen->psImpl, iWidth, iHeight, -+ psFormat->iDRIFourCC, -+ psFormat->eIMGPixelFormat, -+ puModifiers, uModifierCount, &uStride); -+ if (!psShared->psBuffer) { -+ errorMessage("%s: Failed to create buffer", __func__); -+ goto ErrorDestroyImage; -+ } -+ -+ psShared->psFormat = psFormat; -+ -+ *piStride = uStride; -+ -+ return psShared; -+ -+ErrorDestroyImage: -+ DestroyImageShared(psShared); -+ -+ return NULL; -+} -+ -+static struct PVRDRIImageShared * -+RefImageShared(struct PVRDRIImageShared *psShared) -+{ -+ int iRefCount = p_atomic_inc_return(&psShared->iRefCount); -+ -+ (void) iRefCount; -+ assert(iRefCount > 1); -+ -+ return psShared; -+} -+ -+static struct PVRDRIImageShared * -+CreateImageSharedForSubImage(struct PVRDRIImageShared *psParent, int iPlane) -+{ -+ struct PVRDRIImageShared *psShared; -+ struct PVRDRIImageShared *psAncestor; -+ PVRDRIBufferImpl *psBuffer = NULL; -+ IMG_PIXFMT eIMGPixelFormat; -+ -+ /* Sub-images represent a single plane in the parent image */ -+ if (!psParent->psBuffer) -+ return NULL; -+ -+ /* -+ * The ancestor image is the owner of the original buffer that will back -+ * the new image. The parent image may be a child of that image itself. The -+ * ancestor image must not be destroyed until all the child images that -+ * refer to it have been destroyed. A reference will be taken on the -+ * ancestor to ensure that is the case. We must distinguish between the -+ * parent's buffer and the ancestor's buffer. For example, plane 0 in the -+ * parent is not necessarily plane 0 in the ancestor. -+ */ -+ psAncestor = psParent; -+ if (psAncestor->psAncestor) { -+ psAncestor = psAncestor->psAncestor; -+ -+ assert(!psAncestor->psAncestor); -+ } -+ -+ psBuffer = PVRDRISubBufferCreate(psParent->psPVRScreen->psImpl, -+ psParent->psBuffer, iPlane); -+ if (!psBuffer) -+ return NULL; -+ -+ psShared = CommonImageSharedSetup(NULL, PVRDRI_IMAGE_SUBIMAGE); -+ if (!psShared) -+ goto ErrorDestroyBuffer; -+ -+ psShared->psAncestor = RefImageShared(psAncestor); -+ psShared->psBuffer = psBuffer; -+ psShared->psPVRScreen = psParent->psPVRScreen; -+ -+ eIMGPixelFormat = psParent->psFormat->sPlanes[iPlane].eIMGPixelFormat; -+ -+ psShared->psFormat = -+ PVRDRIIMGPixelFormatToImageFormat(psParent->psPVRScreen, -+ eIMGPixelFormat); -+ -+ assert(psShared->psFormat); -+ -+ return psShared; -+ -+ErrorDestroyBuffer: -+ PVRDRIBufferDestroy(psBuffer); -+ return NULL; -+} -+ -+static __DRIimage * -+CommonImageSetup(void *pvLoaderPrivate) -+{ -+ __DRIimage *psImage; -+ -+ psImage = calloc(1, sizeof(*psImage)); -+ if (!psImage) -+ return NULL; -+ -+ psImage->pvLoaderPrivate = pvLoaderPrivate; -+ psImage->iRefCount = 1; -+ -+ return psImage; -+} -+ -+void -+DRIMODDestroyImage(__DRIimage *psImage) -+{ -+ int iRefCount = p_atomic_dec_return(&psImage->iRefCount); -+ -+ assert(iRefCount >= 0); -+ -+ if (iRefCount > 0) -+ return; -+ -+ if (psImage->psShared) -+ DestroyImageShared(psImage->psShared); -+ -+ PVRDRIEGLImageFree(psImage->psEGLImage); -+ free(psImage); -+} -+ -+__DRIimage * -+DRIMODCreateImageFromName(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, int iFourCC, int iName, -+ int iPitch, void *pvLoaderPrivate) -+{ -+ const PVRDRIImageFormat *psFormat; -+ int iStride; -+ int iOffset; -+ -+ psFormat = PVRDRIFourCCToImageFormat(psPVRScreen, iFourCC); -+ if (!psFormat) { -+ errorMessage("%s: Unsupported DRI image FourCC (format = 0x%X)", -+ __func__, iFourCC); -+ return NULL; -+ } -+ -+ iStride = iPitch * PVRDRIPixFmtGetBlockSize(psFormat->eIMGPixelFormat); -+ iOffset = 0; -+ -+ return DRIMODCreateImageFromNames(psPVRScreen, iWidth, iHeight, iFourCC, -+ &iName, 1, &iStride, &iOffset, -+ pvLoaderPrivate); -+} -+ -+__DRIimage * -+DRIMODCreateImageFromRenderBuffer2(struct DRISUPContext *psPVRContext, -+ int iRenderBuffer, void *pvLoaderPrivate, -+ unsigned int *puError) -+{ -+ struct DRISUPScreen *psPVRScreen = psPVRContext->psPVRScreen; -+ unsigned int uError; -+ IMGEGLImage *psEGLImage; -+ __DRIimage *psImage; -+ -+ psImage = CommonImageSetup(pvLoaderPrivate); -+ if (!psImage) { -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ psEGLImage = PVRDRIEGLImageCreate(); -+ if (!psEGLImage) { -+ DRIMODDestroyImage(psImage); -+ -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ uError = PVRDRIGetImageSource(psPVRContext->eAPI, psPVRScreen->psImpl, -+ psPVRContext->psImpl, PVRDRI_GL_RENDERBUFFER, -+ (uintptr_t) iRenderBuffer, 0, psEGLImage); -+ if (uError != PVRDRI_IMAGE_ERROR_SUCCESS) { -+ PVRDRIEGLImageFree(psEGLImage); -+ DRIMODDestroyImage(psImage); -+ -+ *puError = uError; -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psEGLImage, psImage); -+ -+ /* -+ * We can't destroy the image after this point, as the -+ * renderbuffer now has a reference to it. -+ */ -+ psImage->psShared = -+ CreateImageSharedFromEGLImage(psPVRScreen, psEGLImage, -+ PVRDRI_EGLIMAGE_IMGEGL); -+ if (!psImage->psShared) { -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ psImage->psEGLImage = PVRDRIEGLImageDup(psImage->psShared->psEGLImage); -+ if (!psImage->psEGLImage) { -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ psImage->iRefCount++; -+ -+ *puError = PVRDRI_IMAGE_ERROR_SUCCESS; -+ return psImage; -+} -+ -+ -+__DRIimage * -+DRIMODCreateImageFromRenderbuffer(struct DRISUPContext *psPVRContext, -+ int iRenderBuffer, void *pvLoaderPrivate) -+{ -+ unsigned int uError; -+ -+ return DRIMODCreateImageFromRenderBuffer2(psPVRContext, iRenderBuffer, -+ pvLoaderPrivate, &uError); -+} -+ -+__DRIimage * -+DRIMODCreateImage(struct DRISUPScreen *psPVRScreen, int iWidth, int iHeight, -+ int iFourCC, unsigned int uUse, void *pvLoaderPrivate) -+{ -+ __DRIimage *psImage; -+ struct PVRDRIImageShared *psShared; -+ IMG_PIXFMT eIMGPixelFormat; -+ int iStride; -+ -+ psImage = CommonImageSetup(pvLoaderPrivate); -+ if (!psImage) -+ return NULL; -+ -+ psShared = CreateImageShared(psPVRScreen, iWidth, iHeight, iFourCC, uUse, -+ &iStride); -+ if (!psShared) { -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ psImage->psShared = psShared; -+ eIMGPixelFormat = psShared->psFormat->eIMGPixelFormat; -+ -+ psImage->psEGLImage = -+ PVRDRIEGLImageCreateFromBuffer(iWidth, iHeight, iStride, -+ eIMGPixelFormat, psShared->eColourSpace, -+ psShared->eChromaUInterp, -+ psShared->eChromaVInterp, -+ psShared->psBuffer); -+ if (!psImage->psEGLImage) { -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psImage->psEGLImage, psImage); -+ -+ return psImage; -+} -+ -+__DRIimage * -+DRIMODCreateImageWithModifiers(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, int iFourCC, -+ const uint64_t *puModifiers, -+ const unsigned int uModifierCount, -+ void *pvLoaderPrivate) -+{ -+ __DRIimage *psImage; -+ struct PVRDRIImageShared *psShared; -+ IMG_PIXFMT eIMGPixelFormat; -+ int iStride; -+ -+ psImage = CommonImageSetup(pvLoaderPrivate); -+ if (!psImage) -+ return NULL; -+ -+ psShared = CreateImageSharedWithModifiers(psPVRScreen, -+ iWidth, iHeight, iFourCC, -+ puModifiers, uModifierCount, -+ &iStride); -+ if (!psShared) { -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ psImage->psShared = psShared; -+ eIMGPixelFormat = psShared->psFormat->eIMGPixelFormat; -+ -+ psImage->psEGLImage = -+ PVRDRIEGLImageCreateFromBuffer(iWidth, iHeight, iStride, -+ eIMGPixelFormat, psShared->eColourSpace, -+ psShared->eChromaUInterp, -+ psShared->eChromaVInterp, -+ psShared->psBuffer); -+ if (!psImage->psEGLImage) { -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psImage->psEGLImage, psImage); -+ -+ return psImage; -+} -+ -+bool -+DRIMODQueryImage(__DRIimage *psImage, int attrib, int *value_ptr) -+{ -+ struct PVRDRIImageShared *psShared = psImage->psShared; -+ PVRDRIBufferAttribs sAttribs; -+ int value; -+ uint64_t ulValue; -+ -+ PVRDRIEGLImageGetAttribs(psImage->psEGLImage, &sAttribs); -+ -+ if (attrib == PVRDRI_IMAGE_ATTRIB_HANDLE || -+ attrib == PVRDRI_IMAGE_ATTRIB_NAME || -+ attrib == PVRDRI_IMAGE_ATTRIB_FD || -+ attrib == PVRDRI_IMAGE_ATTRIB_OFFSET) { -+ if (!psShared->psFormat) -+ return false; -+ -+ switch (psShared->psFormat->iDRIComponents) { -+ case PVRDRI_IMAGE_COMPONENTS_R: -+ case PVRDRI_IMAGE_COMPONENTS_RG: -+ case PVRDRI_IMAGE_COMPONENTS_RGB: -+ case PVRDRI_IMAGE_COMPONENTS_RGBA: -+ case PVRDRI_IMAGE_COMPONENTS_EXTERNAL: -+ break; -+ default: -+ return false; -+ } -+ } -+ -+ switch (attrib) { -+ case PVRDRI_IMAGE_ATTRIB_STRIDE: -+ *value_ptr = sAttribs.uiStrideInBytes; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_HANDLE: -+ value = PVRDRIBufferGetHandle(psShared->psBuffer); -+ if (value == -1) -+ return false; -+ -+ *value_ptr = value; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_NAME: -+ value = PVRDRIBufferGetName(psShared->psBuffer); -+ if (value == -1) -+ return false; -+ -+ *value_ptr = value; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_FORMAT: -+ /* The caller should use PVRDRI_IMAGE_ATTRIB_FOURCC, and convert. */ -+ return false; -+ case PVRDRI_IMAGE_ATTRIB_WIDTH: -+ *value_ptr = sAttribs.uiWidth; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_HEIGHT: -+ *value_ptr = sAttribs.uiHeight; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_COMPONENTS: -+ if (!psShared->psFormat || !psShared->psFormat->iDRIComponents) -+ return false; -+ -+ *value_ptr = psShared->psFormat->iDRIComponents; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_FD: -+ value = PVRDRIBufferGetFd(psShared->psBuffer); -+ if (value == -1) -+ return false; -+ -+ *value_ptr = value; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_FOURCC: -+ *value_ptr = psShared->psFormat->iDRIFourCC; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_NUM_PLANES: -+ *value_ptr = (int) psShared->psFormat->uiNumPlanes; -+ break; -+ case PVRDRI_IMAGE_ATTRIB_OFFSET: -+ *value_ptr = PVRDRIBufferGetOffset(psShared->psBuffer); -+ break; -+ case PVRDRI_IMAGE_ATTRIB_MODIFIER_LOWER: -+ ulValue = PVRDRIBufferGetModifier(psShared->psBuffer); -+ *value_ptr = (int) (ulValue & 0xffffffff); -+ break; -+ case PVRDRI_IMAGE_ATTRIB_MODIFIER_UPPER: -+ ulValue = PVRDRIBufferGetModifier(psShared->psBuffer); -+ *value_ptr = (int) ((ulValue >> 32) & 0xffffffff); -+ break; -+ default: -+ return false; -+ } -+ -+ return true; -+} -+ -+__DRIimage * -+DRIMODDupImage(__DRIimage *psSrc, void *pvLoaderPrivate) -+{ -+ __DRIimage *psDst; -+ -+ psDst = CommonImageSetup(pvLoaderPrivate); -+ if (!psDst) -+ return NULL; -+ -+ psDst->psShared = RefImageShared(psSrc->psShared); -+ -+ psDst->psEGLImage = PVRDRIEGLImageDup(psSrc->psEGLImage); -+ if (!psDst->psEGLImage) { -+ DRIMODDestroyImage(psDst); -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psDst->psEGLImage, psDst); -+ -+ return psDst; -+} -+ -+bool -+DRIMODValidateImageUsage(__DRIimage *psImage, unsigned int uUse) -+{ -+ struct PVRDRIImageShared *psShared = psImage->psShared; -+ -+ if (uUse & (PVDRI_BUFFER_USE_SCANOUT | PVDRI_BUFFER_USE_CURSOR)) { -+ uint64_t uModifier; -+ -+ /* -+ * We are extra strict in this case as an application may ask for a -+ * handle so that the memory can be wrapped as a framebuffer/used as a -+ * cursor and this can only be done on a card node. -+ */ -+ if (drmGetNodeTypeFromFd(psShared->psPVRScreen->iFD) != DRM_NODE_PRIMARY) -+ return false; -+ -+ uModifier = PVRDRIBufferGetModifier(psShared->psBuffer); -+ if (uModifier != DRM_FORMAT_MOD_INVALID && -+ uModifier != DRM_FORMAT_MOD_LINEAR) -+ return false; -+ } else if (uUse & (PVDRI_BUFFER_USE_SHARE)) { -+ /* -+ * We are less strict in this case as it's possible to share buffers -+ * using prime (but not flink) on a render node so we only need to know -+ * whether or not the FD belongs to the display. -+ */ -+ if (PVRDRIGetDeviceTypeFromFd(psShared->psPVRScreen->iFD) != -+ PVRDRI_DEVICE_TYPE_DISPLAY) -+ return false; -+ } -+ -+ return true; -+} -+ -+__DRIimage * -+DRIMODCreateImageFromNames(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, int iFourCC, -+ int *piNames, int iNumNames, -+ int *piStrides, int *piOffsets, -+ void *pvLoaderPrivate) -+{ -+ __DRIimage *psImage; -+ struct PVRDRIImageShared *psShared; -+ IMG_PIXFMT eIMGPixelFormat; -+ int iStride; -+ -+ psImage = CommonImageSetup(pvLoaderPrivate); -+ if (!psImage) -+ return NULL; -+ -+ psShared = CreateImageSharedFromNames(psPVRScreen, -+ iWidth, iHeight, iFourCC, -+ piNames, iNumNames, -+ piStrides, piOffsets); -+ if (!psShared) { -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ psImage->psShared = psShared; -+ eIMGPixelFormat = psShared->psFormat->eIMGPixelFormat; -+ -+ if (psShared->psFormat->uiNumPlanes == 1) -+ iStride = piStrides[0]; -+ else -+ iStride = iWidth * PVRDRIPixFmtGetBlockSize(eIMGPixelFormat); -+ -+ psImage->psEGLImage = -+ PVRDRIEGLImageCreateFromBuffer(iWidth, iHeight, iStride, -+ eIMGPixelFormat, psShared->eColourSpace, -+ psShared->eChromaUInterp, -+ psShared->eChromaVInterp, -+ psShared->psBuffer); -+ if (!psImage->psEGLImage) { -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psImage->psEGLImage, psImage); -+ -+ return psImage; -+} -+ -+__DRIimage * -+DRIMODFromPlanar(__DRIimage *psSrc, int iPlane, void *pvLoaderPrivate) -+{ -+ __DRIimage *psDst; -+ struct PVRDRIImageShared *psShared; -+ -+ psDst = CommonImageSetup(pvLoaderPrivate); -+ if (!psDst) -+ return NULL; -+ -+ psShared = CreateImageSharedForSubImage(psSrc->psShared, iPlane); -+ if (!psShared) { -+ if (iPlane != 0) { -+ errorMessage("%s: plane %d not supported", __func__, iPlane); -+ } else { -+ psDst->psShared = RefImageShared(psSrc->psShared); -+ psDst->psEGLImage = PVRDRIEGLImageDup(psSrc->psEGLImage); -+ } -+ } else { -+ IMG_PIXFMT eIMGPixelFormat; -+ -+ psDst->psShared = psShared; -+ eIMGPixelFormat = psShared->psFormat->eIMGPixelFormat; -+ -+ psDst->psEGLImage = -+ PVRDRIEGLImageCreateFromSubBuffer(eIMGPixelFormat, psShared->psBuffer); -+ } -+ -+ if (!psDst->psEGLImage) { -+ DRIMODDestroyImage(psDst); -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psDst->psEGLImage, psDst); -+ -+ return psDst; -+} -+ -+__DRIimage * -+DRIMODCreateImageFromTexture(struct DRISUPContext *psPVRContext, int iTarget, -+ unsigned int uTexture, int iDepth, int iLevel, -+ unsigned int *puError, void *pvLoaderPrivate) -+{ -+ IMGEGLImage *psEGLImage; -+ __DRIimage *psImage; -+ uint32_t iEGLTarget; -+ unsigned int uError; -+ -+ switch (iTarget) { -+ case PVRDRI_GL_TEXTURE_2D: -+ iEGLTarget = iTarget; -+ break; -+ case PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_X: -+ iEGLTarget = iTarget + iDepth; -+ break; -+ default: -+ errorMessage("%s: EGL GL texture %d is not supported", -+ __func__, iTarget); -+ *puError = PVRDRI_IMAGE_ERROR_BAD_PARAMETER; -+ return NULL; -+ } -+ -+ psImage = CommonImageSetup(pvLoaderPrivate); -+ if (!psImage) -+ return NULL; -+ -+ psEGLImage = PVRDRIEGLImageCreate(); -+ if (!psEGLImage) { -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ uError = PVRDRIGetImageSource(psPVRContext->eAPI, -+ psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, iEGLTarget, uTexture, -+ iLevel, psEGLImage); -+ *puError = uError; -+ -+ if (uError != PVRDRI_IMAGE_ERROR_SUCCESS) { -+ PVRDRIEGLImageFree(psEGLImage); -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psEGLImage, psImage); -+ -+ /* -+ * We can't destroy the image after this point, as the texture now has a -+ * reference to it. -+ */ -+ psImage->psShared = -+ CreateImageSharedFromEGLImage(psPVRContext->psPVRScreen, psEGLImage, -+ PVRDRI_EGLIMAGE_IMGEGL); -+ if (!psImage->psShared) -+ return NULL; -+ -+ psImage->psEGLImage = PVRDRIEGLImageDup(psImage->psShared->psEGLImage); -+ if (!psImage->psEGLImage) -+ return NULL; -+ -+ psImage->iRefCount++; -+ -+ return psImage; -+} -+ -+__DRIimage * -+DRIMODCreateImageFromFDs(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, int iFourCC, -+ int *piFDs, int iNumFDs, -+ int *piStrides, int *piOffsets, -+ void *pvLoaderPrivate) -+{ -+ unsigned int uError; -+ -+ return DRIMODCreateImageFromDMABufs(psPVRScreen, iWidth, iHeight, iFourCC, -+ piFDs, iNumFDs, piStrides, piOffsets, -+ PVRDRI_YUV_COLOR_SPACE_UNDEFINED, -+ PVRDRI_YUV_RANGE_UNDEFINED, -+ PVRDRI_YUV_CHROMA_SITING_UNDEFINED, -+ PVRDRI_YUV_CHROMA_SITING_UNDEFINED, -+ &uError, pvLoaderPrivate); -+} -+ -+__DRIimage * -+DRIMODCreateImageFromBuffer(struct DRISUPContext *psPVRContext, int iTarget, -+ void *pvBuffer, unsigned int *puError, -+ void *pvLoaderPrivate) -+{ -+ IMGEGLImage *psEGLImage; -+ __DRIimage *psImage; -+ -+ switch (iTarget) { -+ case PVRDRI_CL_IMAGE_IMG: -+ break; -+ default: -+ errorMessage("%s: Target %d is not supported", __func__, iTarget); -+ *puError = PVRDRI_IMAGE_ERROR_BAD_PARAMETER; -+ return NULL; -+ } -+ -+ psImage = CommonImageSetup(pvLoaderPrivate); -+ if (!psImage) { -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ psEGLImage = PVRDRIEGLImageCreate(); -+ if (!psEGLImage) { -+ DRIMODDestroyImage(psImage); -+ -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ *puError = PVRDRIGetImageSource(PVRDRI_API_CL, -+ psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, iTarget, -+ (uintptr_t) pvBuffer, 0, psEGLImage); -+ if (*puError != PVRDRI_IMAGE_ERROR_SUCCESS) { -+ PVRDRIEGLImageFree(psEGLImage); -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psEGLImage, psImage); -+ -+ /* -+ * We can't destroy the image after this point, as the OCL image now has a -+ * reference to it. -+ */ -+ psImage->psShared = -+ CreateImageSharedFromEGLImage(psPVRContext->psPVRScreen, psEGLImage, -+ PVRDRI_EGLIMAGE_IMGOCL); -+ if (!psImage->psShared) { -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ psImage->psEGLImage = PVRDRIEGLImageDup(psImage->psShared->psEGLImage); -+ if (!psImage->psEGLImage) { -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ psImage->iRefCount++; -+ -+ *puError = PVRDRI_IMAGE_ERROR_SUCCESS; -+ -+ return psImage; -+} -+ -+__DRIimage * -+DRIMODCreateImageFromDMABufs2(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, -+ int iFourCC, uint64_t uModifier, -+ int *piFDs, int iNumFDs, -+ int *piStrides, int *piOffsets, -+ unsigned int uColorSpace, -+ unsigned int uSampleRange, -+ unsigned int uHorizSiting, -+ unsigned int uVertSiting, -+ unsigned int *puError, -+ void *pvLoaderPrivate) -+{ -+ __DRIimage *psImage; -+ struct PVRDRIImageShared *psShared; -+ IMG_PIXFMT eIMGPixelFormat; -+ -+ psImage = CommonImageSetup(pvLoaderPrivate); -+ if (!psImage) { -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ psShared = CreateImageSharedFromDMABufs(psPVRScreen, iWidth, iHeight, -+ iFourCC, uModifier, piFDs, iNumFDs, -+ piStrides, piOffsets, -+ uColorSpace, uSampleRange, -+ uHorizSiting, uVertSiting, -+ puError); -+ if (!psShared) { -+ DRIMODDestroyImage(psImage); -+ return NULL; -+ } -+ -+ psImage->psShared = psShared; -+ eIMGPixelFormat = psShared->psFormat->eIMGPixelFormat; -+ -+ psImage->psEGLImage = -+ PVRDRIEGLImageCreateFromBuffer(iWidth, iHeight, piStrides[0], -+ eIMGPixelFormat, psShared->eColourSpace, -+ psShared->eChromaUInterp, -+ psShared->eChromaVInterp, -+ psShared->psBuffer); -+ if (!psImage->psEGLImage) { -+ DRIMODDestroyImage(psImage); -+ *puError = PVRDRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ PVRDRIEGLImageSetCallbackData(psImage->psEGLImage, psImage); -+ -+ *puError = PVRDRI_IMAGE_ERROR_SUCCESS; -+ -+ return psImage; -+} -+ -+__DRIimage * -+DRIMODCreateImageFromDMABufs(struct DRISUPScreen *psPVRScreen, -+ int iWidth, int iHeight, int iFourCC, -+ int *piFDs, int iNumFDs, -+ int *piStrides, int *piOffsets, -+ unsigned int uColorSpace, -+ unsigned int uSampleRange, -+ unsigned int uHorizSiting, -+ unsigned int uVertSiting, -+ unsigned int *puError, -+ void *pvLoaderPrivate) -+{ -+ return DRIMODCreateImageFromDMABufs2(psPVRScreen, iWidth, iHeight, -+ iFourCC, DRM_FORMAT_MOD_INVALID, -+ piFDs, iNumFDs, -+ piStrides, piOffsets, -+ uColorSpace, uSampleRange, -+ uHorizSiting, uVertSiting, -+ puError, pvLoaderPrivate); -+} -+ -+void -+PVRDRIRefImage(__DRIimage *psImage) -+{ -+ int iRefCount = p_atomic_inc_return(&psImage->iRefCount); -+ -+ (void) iRefCount; -+ assert(iRefCount > 1); -+} -+ -+void -+PVRDRIUnrefImage(__DRIimage *psImage) -+{ -+ DRIMODDestroyImage(psImage); -+} -+ -+PVRDRIImageType -+PVRDRIImageGetSharedType(__DRIimage *psImage) -+{ -+ return psImage->psShared->eType; -+} -+ -+PVRDRIBufferImpl * -+PVRDRIImageGetSharedBuffer(__DRIimage *psImage) -+{ -+ assert(psImage->psShared->eType != PVRDRI_IMAGE_FROM_EGLIMAGE); -+ -+ return psImage->psShared->psBuffer; -+} -+ -+IMGEGLImage * -+PVRDRIImageGetSharedEGLImage(__DRIimage *psImage) -+{ -+ assert(psImage->psShared->eType == PVRDRI_IMAGE_FROM_EGLIMAGE); -+ -+ return psImage->psShared->psEGLImage; -+} -+ -+IMGEGLImage * -+PVRDRIImageGetEGLImage(__DRIimage *psImage) -+{ -+ return psImage->psEGLImage; -+} -+ -+__DRIimage * -+PVRDRIScreenGetDRIImage(void *hEGLImage) -+{ -+ struct DRISUPScreen *psPVRScreen; -+ -+ psPVRScreen = DRIMODThreadGetCurrentScreen(); -+ if (!psPVRScreen) -+ return NULL; -+ -+ return MODSUPLookupEGLImage(psPVRScreen->psDRIScreen, hEGLImage, -+ psPVRScreen->pvLoaderPrivate); -+} -+ -+void -+DRIMODBlitImage(struct DRISUPContext *psPVRContext, -+ __DRIimage *psDst, __DRIimage *psSrc, -+ int iDstX0, int iDstY0, int iDstWidth, int iDstHeight, -+ int iSrcX0, int iSrcY0, int iSrcWidth, int iSrcHeight, -+ int iFlushFlag) -+{ -+ bool bRes; -+ -+ bRes = PVRDRIBlitEGLImage(psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, -+ psDst->psEGLImage, psDst->psShared->psBuffer, -+ psSrc->psEGLImage, psSrc->psShared->psBuffer, -+ iDstX0, iDstY0, iDstWidth, iDstHeight, -+ iSrcX0, iSrcY0, iSrcWidth, iSrcHeight, -+ iFlushFlag); -+ if (!bRes) -+ __driUtilMessage("%s: PVRDRIBlitEGLImage failed", __func__); -+} -+ -+int -+DRIMODGetImageCapabilities(struct DRISUPScreen *psPVRScreen) -+{ -+ (void) psPVRScreen; -+ -+ return PVRDRI_IMAGE_CAP_GLOBAL_NAMES; -+} -+ -+void * -+DRIMODMapImage(struct DRISUPContext *psPVRContext, __DRIimage *psImage, -+ int iX0, int iY0, int iWidth, int iHeight, -+ unsigned int iFlags, int *iStride, void **ppvData) -+{ -+ return PVRDRIMapEGLImage(psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, -+ psImage->psEGLImage, psImage->psShared->psBuffer, -+ iX0, iY0, iWidth, iHeight, iFlags, iStride, -+ ppvData); -+} -+ -+void -+DRIMODUnmapImage(struct DRISUPContext *psPVRContext, __DRIimage *psImage, -+ void *pvData) -+{ -+ bool bRes; -+ -+ bRes = PVRDRIUnmapEGLImage(psPVRContext->psPVRScreen->psImpl, -+ psPVRContext->psImpl, psImage->psEGLImage, -+ psImage->psShared->psBuffer, pvData); -+ if (!bRes) -+ __driUtilMessage("%s: PVRDRIUnmapEGLImage failed", __func__); -+} diff --git a/src/mesa/drivers/dri/pvr/pvrmesa.h b/src/mesa/drivers/dri/pvr/pvrmesa.h new file mode 100644 index 00000000000..5e1c9c1b2e6 @@ -9261,935 +4675,8 @@ index 00000000000..945e18cf220 + + return 0; +} -diff --git a/src/mesa/drivers/dri/pvr/pvrutil_mod.c b/src/mesa/drivers/dri/pvr/pvrutil_mod.c -new file mode 100644 -index 00000000000..5b05eb76b01 ---- /dev/null -+++ b/src/mesa/drivers/dri/pvr/pvrutil_mod.c -@@ -0,0 +1,921 @@ -+/* -+ * Copyright (c) Imagination Technologies Ltd. -+ * -+ * The contents of this file are subject to the MIT license as set out below. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to deal -+ * in the Software without restriction, including without limitation the rights -+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -+ * copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -+ * THE SOFTWARE. -+ */ -+ -+#include -+#include -+#include -+ -+#include "img_drm_fourcc.h" -+#include "pvrdri_mod.h" -+ -+/* -+ * The following sRGB formats defined may not be defined in drm_fourcc.h, but -+ * match the corresponding __DRI_IMAGE_FOURCC formats in Mesa. -+ */ -+#if !defined(DRM_FORMAT_SARGB8888) -+#define DRM_FORMAT_SARGB8888 0x83324258 -+#endif -+ -+#if !defined(DRM_FORMAT_SABGR8888) -+#define DRM_FORMAT_SABGR8888 0x84324258 -+#endif -+ -+#if !defined(DRM_FORMAT_SBGR888) -+#define DRM_FORMAT_SBGR888 0xff324742 -+#endif -+ -+static const PVRDRIImageFormat g_asFormats[] = { -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_R10G10B10A2_UNORM, -+ .iDRIFourCC = DRM_FORMAT_ABGR2101010, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGBA, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R10G10B10A2_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_B8G8R8A8_UNORM, -+ .iDRIFourCC = DRM_FORMAT_ARGB8888, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGBA, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_B8G8R8A8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_B8G8R8A8_UNORM_SRGB, -+ .iDRIFourCC = DRM_FORMAT_SARGB8888, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGBA, -+ .bIsSRGB = true, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_B8G8R8A8_UNORM_SRGB, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8A8_UNORM, -+ .iDRIFourCC = DRM_FORMAT_ABGR8888, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGBA, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8A8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8A8_UNORM_SRGB, -+ .iDRIFourCC = DRM_FORMAT_SABGR8888, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGBA, -+ .bIsSRGB = true, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8A8_UNORM_SRGB, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_B8G8R8X8_UNORM, -+ .iDRIFourCC = DRM_FORMAT_XRGB8888, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGB, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_B8G8R8X8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8X8_UNORM, -+ .iDRIFourCC = DRM_FORMAT_XBGR8888, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGB, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8X8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8_UNORM, -+ .iDRIFourCC = DRM_FORMAT_BGR888, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGB, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+#if defined(DRM_FORMAT_SBGR888) -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8_UNORM_SRGB, -+ .iDRIFourCC = DRM_FORMAT_SBGR888, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGB, -+ .bIsSRGB = true, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8B8_UNORM_SRGB, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+#endif -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_B5G6R5_UNORM, -+ .iDRIFourCC = DRM_FORMAT_RGB565, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGB, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_B5G6R5_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8_UNORM, -+ .iDRIFourCC = DRM_FORMAT_GR88, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RG, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .iDRIFourCC = DRM_FORMAT_R8, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_R, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_L8A8_UNORM, -+ .iDRIFourCC = 0, -+ .iDRIComponents = 0, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_L8A8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_L8_UNORM, -+ .iDRIFourCC = 0, -+ .iDRIComponents = 0, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_L8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_D32_FLOAT, -+ .iDRIFourCC = 0, -+ .iDRIComponents = 0, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_D32_FLOAT, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_S8_UINT, -+ .iDRIFourCC = 0, -+ .iDRIComponents = 0, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_S8_UINT, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+#if defined(DRM_FORMAT_ARGB4444) -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_B4G4R4A4_UNORM, -+ .iDRIFourCC = DRM_FORMAT_ARGB4444, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGBA, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_B4G4R4A4_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+#endif -+#if defined(DRM_FORMAT_ARGB1555) -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_B5G5R5A1_UNORM, -+ .iDRIFourCC = DRM_FORMAT_ARGB1555, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_RGBA, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_B5G5R5A1_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+#endif -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_YUYV, -+ .iDRIFourCC = DRM_FORMAT_YUYV, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_EXTERNAL, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_YUYV, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+#if defined(DRM_FORMAT_YVU444_PACK10_IMG) -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_YVU10_444_1PLANE_PACK10, -+ .iDRIFourCC = DRM_FORMAT_YVU444_PACK10_IMG, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_EXTERNAL, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_YVU10_444_1PLANE_PACK10, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0, -+ }, -+ }, -+#endif -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_YUV420_2PLANE, -+ .iDRIFourCC = DRM_FORMAT_NV12, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_Y_UV, -+ .uiNumPlanes = 2, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ .sPlanes[1] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8_UNORM, -+ .uiWidthShift = 1, -+ .uiHeightShift = 1}, -+ }, -+#if defined(DRM_FORMAT_NV21) -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_YVU420_2PLANE, -+ .iDRIFourCC = DRM_FORMAT_NV21, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_Y_UV, -+ .uiNumPlanes = 2, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ .sPlanes[1] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8G8_UNORM, -+ .uiWidthShift = 1, -+ .uiHeightShift = 1}, -+ }, -+#endif -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_YUV420_3PLANE, -+ .iDRIFourCC = DRM_FORMAT_YUV420, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_Y_U_V, -+ .uiNumPlanes = 3, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ .sPlanes[1] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 1, -+ .uiHeightShift = 1}, -+ .sPlanes[2] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 1, -+ .uiHeightShift = 1}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_YVU420_3PLANE, -+ .iDRIFourCC = DRM_FORMAT_YVU420, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_Y_U_V, -+ .uiNumPlanes = 3, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ .sPlanes[1] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 1, -+ .uiHeightShift = 1}, -+ .sPlanes[2] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 1, -+ .uiHeightShift = 1}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_YUV8_444_3PLANE_PACK8, -+ .iDRIFourCC = DRM_FORMAT_YUV444, -+ .iDRIComponents = PVRDRI_IMAGE_COMPONENTS_Y_U_V, -+ .uiNumPlanes = 3, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ .sPlanes[1] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ .sPlanes[2] = { -+ .eIMGPixelFormat = IMG_PIXFMT_R8_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_D16_UNORM, -+ .iDRIFourCC = 0, -+ .iDRIComponents = 0, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_D16_UNORM, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+ { -+ .eIMGPixelFormat = IMG_PIXFMT_D24_UNORM_X8_TYPELESS, -+ .iDRIFourCC = 0, -+ .iDRIComponents = 0, -+ .uiNumPlanes = 1, -+ .sPlanes[0] = { -+ .eIMGPixelFormat = IMG_PIXFMT_D24_UNORM_X8_TYPELESS, -+ .uiWidthShift = 0, -+ .uiHeightShift = 0}, -+ }, -+}; -+ -+/* -+ * Check if a PVR Screen has support for a particular format based upon its -+ * position in g_asFormats. If querying of this information isn't supported by -+ * pvr_dri_support then assume the format is supported. -+ */ -+static inline bool -+PVRDRIScreenHasFormatFromIdx(const struct DRISUPScreen *const psPVRScreen, -+ const unsigned int uiFormatIdx) -+{ -+ if (psPVRScreen->iNumFormats > 0) { -+ if (uiFormatIdx < ARRAY_SIZE(g_asFormats)) -+ return psPVRScreen->pbHasFormat[uiFormatIdx]; -+ return false; -+ } -+ -+ assert(psPVRScreen->iNumFormats == -1); -+ return true; -+} -+ -+const struct __DRIconfigRec ** -+PVRDRICreateConfigs(const struct DRISUPScreen *psPVRScreen) -+{ -+ static const unsigned int auBackBufferModes[] = { -+ PVRDRI_ATTRIB_SWAP_NONE, -+ PVRDRI_ATTRIB_SWAP_UNDEFINED, -+ }; -+ const uint8_t *puDepthBits = PVRDRIDepthBitsArray(); -+ const uint8_t *puStencilBits = PVRDRIStencilBitsArray(); -+ const uint8_t *puMSAASamples = PVRDRIMSAABitsArray(); -+ const unsigned int uNumBackBufferModes = ARRAY_SIZE(auBackBufferModes); -+ const unsigned int uNumDepthStencilBits = -+ PVRDRIDepthStencilBitArraySize(); -+ const unsigned int uNumMSAASamples = PVRDRIMSAABitArraySize(); -+ struct __DRIconfigRec **ppsConfigs = NULL; -+ struct __DRIconfigRec **ppsNewConfigs; -+ unsigned int i; -+ -+ for (i = 0; i < psPVRScreen->uNumMesaFormats; i++) { -+ if (!MODSUPCreateConfigs(&ppsNewConfigs, psPVRScreen->psDRIScreen, -+ psPVRScreen->puMesaFormats[i], -+ puDepthBits, puStencilBits, -+ uNumDepthStencilBits, -+ auBackBufferModes, uNumBackBufferModes, -+ puMSAASamples, uNumMSAASamples, -+ false, false, false, -+ PVRDRI_YUV_DEPTH_RANGE_NONE, -+ PVRDRI_YUV_CSC_STANDARD_NONE, -+ PVRDRIMaxPBufferWidth(), -+ PVRDRIMaxPBufferHeight())) { -+ __driUtilMessage("%s: Couldn't create DRI configs", __func__); -+ return NULL; -+ } -+ -+ ppsConfigs = MODSUPConcatConfigs(psPVRScreen->psDRIScreen, -+ ppsConfigs, ppsNewConfigs); -+ } -+ -+ return (const struct __DRIconfigRec **) ppsConfigs; -+} -+ -+const PVRDRIImageFormat * -+PVRDRIFourCCToImageFormat(struct DRISUPScreen *psPVRScreen, int iDRIFourCC) -+{ -+ unsigned int i; -+ -+ if (!iDRIFourCC) -+ return NULL; -+ -+ for (i = 0; i < ARRAY_SIZE(g_asFormats); i++) { -+ if (g_asFormats[i].iDRIFourCC != iDRIFourCC) -+ continue; -+ -+ if (!PVRDRIScreenHasFormatFromIdx(psPVRScreen, i)) -+ break; -+ -+ return &g_asFormats[i]; -+ } -+ -+ return NULL; -+} -+ -+const PVRDRIImageFormat * -+PVRDRIIMGPixelFormatToImageFormat(struct DRISUPScreen *psPVRScreen, -+ IMG_PIXFMT eIMGPixelFormat) -+{ -+ unsigned int i; -+ -+ assert(eIMGPixelFormat != IMG_PIXFMT_UNKNOWN); -+ -+ for (i = 0; i < ARRAY_SIZE(g_asFormats); i++) { -+ if (g_asFormats[i].eIMGPixelFormat != eIMGPixelFormat) -+ continue; -+ -+ /* -+ * Assume that the screen has the format, i.e. it's supported by the -+ * HW+SW, since we can only have an IMG_PIXFMT from having called one of -+ * the other PVRDRI*ToImageFormat functions or one of the -+ * pvr_dri_support functions. -+ */ -+ assert(PVRDRIScreenHasFormatFromIdx(psPVRScreen, i)); -+ return &g_asFormats[i]; -+ } -+ -+ return NULL; -+} -+ -+/* -+ * The EGL_EXT_image_dma_buf_import says that if a hint is unspecified then -+ * the implementation may guess based on the pixel format or may fallback to -+ * some default value. Furthermore, if a hint is unsupported then the -+ * implementation may use whichever settings it wants to achieve the closest -+ * match. -+ */ -+IMG_YUV_COLORSPACE -+PVRDRIToIMGColourSpace(const PVRDRIImageFormat *psFormat, -+ unsigned int uDRIColourSpace, -+ unsigned int uDRISampleRange) -+{ -+ switch (psFormat->iDRIComponents) { -+ case PVRDRI_IMAGE_COMPONENTS_R: -+ case PVRDRI_IMAGE_COMPONENTS_RG: -+ case PVRDRI_IMAGE_COMPONENTS_RGB: -+ case PVRDRI_IMAGE_COMPONENTS_RGBA: -+ return IMG_COLORSPACE_UNDEFINED; -+ case PVRDRI_IMAGE_COMPONENTS_Y_U_V: -+ case PVRDRI_IMAGE_COMPONENTS_Y_UV: -+ case PVRDRI_IMAGE_COMPONENTS_Y_XUXV: -+ case PVRDRI_IMAGE_COMPONENTS_EXTERNAL: -+ break; -+ default: -+ errorMessage("%s: Unrecognised DRI components (components = 0x%X)", -+ __func__, psFormat->iDRIComponents); -+ unreachable("unhandled DRI component"); -+ return IMG_COLORSPACE_UNDEFINED; -+ } -+ -+ switch (uDRIColourSpace) { -+ case PVRDRI_YUV_COLOR_SPACE_UNDEFINED: -+ case PVRDRI_YUV_COLOR_SPACE_ITU_REC601: -+ switch (uDRISampleRange) { -+ case PVRDRI_YUV_RANGE_UNDEFINED: -+ case PVRDRI_YUV_NARROW_RANGE: -+ return IMG_COLORSPACE_BT601_CONFORMANT_RANGE; -+ case PVRDRI_YUV_FULL_RANGE: -+ return IMG_COLORSPACE_BT601_FULL_RANGE; -+ default: -+ errorMessage ("%s: Unrecognised DRI sample range (sample range = 0x%X)", -+ __func__, uDRISampleRange); -+ unreachable("unhandled sample range"); -+ return IMG_COLORSPACE_UNDEFINED; -+ } -+ case PVRDRI_YUV_COLOR_SPACE_ITU_REC709: -+ switch (uDRISampleRange) { -+ case PVRDRI_YUV_RANGE_UNDEFINED: -+ case PVRDRI_YUV_NARROW_RANGE: -+ return IMG_COLORSPACE_BT709_CONFORMANT_RANGE; -+ case PVRDRI_YUV_FULL_RANGE: -+ return IMG_COLORSPACE_BT709_FULL_RANGE; -+ default: -+ errorMessage ("%s: Unrecognised DRI sample range (sample range = 0x%X)", -+ __func__, uDRISampleRange); -+ unreachable("unhandled sample range"); -+ return IMG_COLORSPACE_UNDEFINED; -+ } -+ case PVRDRI_YUV_COLOR_SPACE_ITU_REC2020: -+ switch (uDRISampleRange) { -+ case PVRDRI_YUV_RANGE_UNDEFINED: -+ case PVRDRI_YUV_NARROW_RANGE: -+ return IMG_COLORSPACE_BT2020_CONFORMANT_RANGE; -+ case PVRDRI_YUV_FULL_RANGE: -+ return IMG_COLORSPACE_BT2020_FULL_RANGE; -+ default: -+ errorMessage ("%s: Unrecognised DRI sample range (sample range = 0x%X)", -+ __func__, uDRISampleRange); -+ assert(0); -+ return IMG_COLORSPACE_UNDEFINED; -+ } -+ default: -+ errorMessage ("%s: Unrecognised DRI color space (color space = 0x%X)", -+ __func__, uDRIColourSpace); -+ unreachable("unhandled color space"); -+ return IMG_COLORSPACE_UNDEFINED; -+ } -+} -+ -+IMG_YUV_CHROMA_INTERP -+PVRDRIChromaSittingToIMGInterp(const PVRDRIImageFormat *psFormat, -+ unsigned int uChromaSitting) -+{ -+ switch (psFormat->iDRIComponents) { -+ case PVRDRI_IMAGE_COMPONENTS_R: -+ case PVRDRI_IMAGE_COMPONENTS_RG: -+ case PVRDRI_IMAGE_COMPONENTS_RGB: -+ case PVRDRI_IMAGE_COMPONENTS_RGBA: -+ return IMG_CHROMA_INTERP_UNDEFINED; -+ case PVRDRI_IMAGE_COMPONENTS_Y_U_V: -+ case PVRDRI_IMAGE_COMPONENTS_Y_UV: -+ case PVRDRI_IMAGE_COMPONENTS_Y_XUXV: -+ case PVRDRI_IMAGE_COMPONENTS_EXTERNAL: -+ break; -+ default: -+ errorMessage("%s: Unrecognised DRI components (components = 0x%X)", -+ __func__, psFormat->iDRIComponents); -+ unreachable("unhandled dri component"); -+ return IMG_CHROMA_INTERP_UNDEFINED; -+ } -+ -+ switch (uChromaSitting) { -+ case PVRDRI_YUV_CHROMA_SITING_UNDEFINED: -+ case PVRDRI_YUV_CHROMA_SITING_0: -+ return IMG_CHROMA_INTERP_ZERO; -+ case PVRDRI_YUV_CHROMA_SITING_0_5: -+ return IMG_CHROMA_INTERP_HALF; -+ default: -+ errorMessage ("%s: Unrecognised DRI chroma sitting (chroma sitting = 0x%X)", -+ __func__, uChromaSitting); -+ unreachable("unhandled chroma sitting"); -+ return IMG_CHROMA_INTERP_UNDEFINED; -+ } -+} -+ -+bool -+PVRDRIGetSupportedFormats(struct DRISUPScreen *psPVRScreen) -+{ -+ int *piFormats; -+ IMG_PIXFMT *peImgFormats; -+ bool bRet = false; -+ unsigned int i; -+ -+ piFormats = malloc(ARRAY_SIZE(g_asFormats) * sizeof(*piFormats)); -+ peImgFormats = malloc(ARRAY_SIZE(g_asFormats) * sizeof(*peImgFormats)); -+ -+ psPVRScreen->pbHasFormat = malloc(ARRAY_SIZE(g_asFormats) * -+ sizeof(*psPVRScreen->pbHasFormat)); -+ -+ psPVRScreen->psModifiers = calloc(ARRAY_SIZE(g_asFormats), -+ sizeof(*psPVRScreen->psModifiers)); -+ -+ if (!piFormats || !peImgFormats || -+ !psPVRScreen->pbHasFormat || !psPVRScreen->psModifiers) { -+ errorMessage("%s: Out of memory", __func__); -+ goto err_free; -+ } -+ -+ for (i = 0; i < ARRAY_SIZE(g_asFormats); i++) { -+ piFormats[i] = g_asFormats[i].iDRIFourCC; -+ peImgFormats[i] = g_asFormats[i].eIMGPixelFormat; -+ -+ psPVRScreen->psModifiers[i].iNumModifiers = -1; -+ } -+ -+ psPVRScreen->iNumFormats = -+ PVRDRIQuerySupportedFormats(psPVRScreen->psImpl, ARRAY_SIZE(g_asFormats), -+ piFormats, peImgFormats, -+ psPVRScreen->pbHasFormat); -+ if (psPVRScreen->iNumFormats == 0) { -+ __driUtilMessage("%s: Couldn't query supported pixel formats", -+ __func__); -+ goto err_free; -+ } -+ -+ bRet = true; -+ goto cleanup; -+ -+err_free: -+ free(psPVRScreen->psModifiers); -+ psPVRScreen->psModifiers = NULL; -+ -+ free(psPVRScreen->pbHasFormat); -+ psPVRScreen->pbHasFormat = NULL; -+cleanup: -+ free(peImgFormats); -+ free(piFormats); -+ return bRet; -+} -+ -+bool -+DRIMODQueryDMABufFormats(struct DRISUPScreen *psPVRScreen, int iMax, -+ int *piFormats, int *piCount) -+{ -+ int iLim; -+ unsigned int i; -+ int j; -+ -+ assert(psPVRScreen->iNumFormats != 0); -+ -+ if (psPVRScreen->iNumFormats < 0) -+ return false; -+ -+ iLim = (iMax) ? iMax : psPVRScreen->iNumFormats; -+ -+ for (i = 0, j = 0; i < ARRAY_SIZE(g_asFormats) && j < iLim; i++) { -+ /* -+ * SRGB formats don't map to DRM formats, as defined by drm_fourcc.h, so -+ * should not be returned. -+ */ -+ if (g_asFormats[i].bIsSRGB) -+ continue; -+ -+ if (psPVRScreen->pbHasFormat[i] && g_asFormats[i].iDRIFourCC) { -+ if (iMax) -+ piFormats[j] = g_asFormats[i].iDRIFourCC; -+ j++; -+ } -+ } -+ -+ *piCount = j; -+ -+ return true; -+} -+ -+static bool -+PVRDRIGetSupportedModifiers(struct DRISUPScreen *psPVRScreen, -+ struct PVRDRIModifiers *psModifiers, -+ const PVRDRIImageFormat *psFormat) -+{ -+ int iNumModifiers; -+ -+ iNumModifiers = PVRDRIQueryModifiers(psPVRScreen->psImpl, -+ psFormat->iDRIFourCC, -+ psFormat->eIMGPixelFormat, -+ NULL, NULL); -+ if (iNumModifiers < 0) { -+ errorMessage("%s: Couldn't query modifiers for format 0x%x", -+ __func__, psFormat->iDRIFourCC); -+ return false; -+ } -+ -+ psModifiers->puModifiers = malloc(iNumModifiers * -+ sizeof(*psModifiers->puModifiers)); -+ psModifiers->puExternalOnly = malloc(iNumModifiers * -+ sizeof(*psModifiers-> -+ puExternalOnly)); -+ if (!psModifiers->puModifiers || !psModifiers->puExternalOnly) { -+ free(psModifiers->puModifiers); -+ psModifiers->puModifiers = NULL; -+ -+ free(psModifiers->puExternalOnly); -+ psModifiers->puExternalOnly = NULL; -+ -+ errorMessage("%s: Out of memory", __func__); -+ -+ return false; -+ } -+ psModifiers->iNumModifiers = iNumModifiers; -+ -+ iNumModifiers = PVRDRIQueryModifiers(psPVRScreen->psImpl, -+ psFormat->iDRIFourCC, -+ psFormat->eIMGPixelFormat, -+ psModifiers->puModifiers, -+ psModifiers->puExternalOnly); -+ -+ assert(iNumModifiers == psModifiers->iNumModifiers); -+ -+ return true; -+} -+ -+static bool -+PVRDRIGetModifiersForFormat(struct DRISUPScreen *psPVRScreen, int iFourCC, -+ const PVRDRIImageFormat **ppsFormat, -+ const struct PVRDRIModifiers **ppsModifiers) -+{ -+ const PVRDRIImageFormat *psFormat; -+ struct PVRDRIModifiers *psModifiers; -+ unsigned int uIdx; -+ -+ assert(psPVRScreen->iNumFormats != 0); -+ -+ if (psPVRScreen->iNumFormats < 0) -+ return false; -+ -+ psFormat = PVRDRIFourCCToImageFormat(psPVRScreen, iFourCC); -+ if (!psFormat) -+ return false; -+ -+ uIdx = psFormat - g_asFormats; -+ psModifiers = &psPVRScreen->psModifiers[uIdx]; -+ -+ if (psModifiers->iNumModifiers < 0) -+ if (!PVRDRIGetSupportedModifiers(psPVRScreen, psModifiers, psFormat)) -+ return false; -+ -+ *ppsFormat = psFormat; -+ *ppsModifiers = psModifiers; -+ -+ return true; -+} -+ -+bool -+PVRDRIValidateImageModifier(struct DRISUPScreen *psPVRScreen, -+ const int iFourCC, const uint64_t uiModifier) -+{ -+ const PVRDRIImageFormat *psFormat; -+ const struct PVRDRIModifiers *psModifiers; -+ -+ if (!PVRDRIGetModifiersForFormat(psPVRScreen, iFourCC, &psFormat, -+ &psModifiers)) -+ return false; -+ -+ for (int i = 0; i < psModifiers->iNumModifiers; i++) -+ if (psModifiers->puModifiers[i] == uiModifier) -+ return true; -+ -+ return false; -+} -+ -+bool -+DRIMODQueryDMABufModifiers(struct DRISUPScreen *psPVRScreen, int iFourCC, -+ int iMax, uint64_t *puModifiers, -+ unsigned int *puExternalOnly, int *piCount) -+{ -+ const PVRDRIImageFormat *psFormat; -+ const struct PVRDRIModifiers *psModifiers; -+ int iNumCopy; -+ -+ if (!PVRDRIGetModifiersForFormat(psPVRScreen, iFourCC, &psFormat, -+ &psModifiers)) -+ return false; -+ -+ if (!iMax) { -+ *piCount = psModifiers->iNumModifiers; -+ return true; -+ } -+ -+ iNumCopy = (iMax < psModifiers->iNumModifiers) ? -+ iMax : psModifiers->iNumModifiers; -+ -+ if (puModifiers) -+ (void) memcpy(puModifiers, psModifiers->puModifiers, -+ sizeof(*puModifiers) * iNumCopy); -+ -+ if (puExternalOnly) -+ (void) memcpy(puExternalOnly, psModifiers->puExternalOnly, -+ sizeof(*puExternalOnly) * iNumCopy); -+ -+ *piCount = iNumCopy; -+ -+ return true; -+} -+ -+bool -+DRIMODQueryDMABufFormatModifierAttribs(struct DRISUPScreen *psPVRScreen, -+ uint32_t uFourCC, uint64_t uModifier, -+ int iAttribute, uint64_t *puValue) -+{ -+ const PVRDRIImageFormat *psFormat; -+ const struct PVRDRIModifiers *psModifiers; -+ int i; -+ -+ if (!PVRDRIGetModifiersForFormat(psPVRScreen, uFourCC, &psFormat, -+ &psModifiers)) -+ return false; -+ -+ for (i = 0; i < psModifiers->iNumModifiers; i++) -+ if (psModifiers->puModifiers[i] == uModifier) -+ break; -+ -+ if (i == psModifiers->iNumModifiers) -+ return false; -+ -+ switch (iAttribute) { -+ case PVRDRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT: -+ *puValue = psFormat->uiNumPlanes; -+ break; -+ default: -+ return false; -+ } -+ -+ return true; -+} -+ -+void -+PVRDRIDestroyFormatInfo(struct DRISUPScreen *psPVRScreen) -+{ -+ unsigned int i; -+ -+ if (psPVRScreen->psModifiers) { -+ for (i = 0; i < ARRAY_SIZE(g_asFormats); i++) { -+ free(psPVRScreen->psModifiers[i].puModifiers); -+ free(psPVRScreen->psModifiers[i].puExternalOnly); -+ } -+ free(psPVRScreen->psModifiers); -+ } -+ -+ free(psPVRScreen->pbHasFormat); -+} -+ -+bool -+PVRDRIGetMesaFormats(struct DRISUPScreen *psPVRScreen) -+{ -+ const unsigned int auMesaFormatsBase[] = { -+ PVRDRI_MESA_FORMAT_B8G8R8A8_UNORM, -+ PVRDRI_MESA_FORMAT_B8G8R8A8_SRGB, -+ PVRDRI_MESA_FORMAT_B8G8R8X8_UNORM, -+ PVRDRI_MESA_FORMAT_B5G6R5_UNORM, -+ }; -+ const unsigned int auMesaFormatsRGB[] = { -+ PVRDRI_MESA_FORMAT_R8G8B8A8_UNORM, -+ PVRDRI_MESA_FORMAT_R8G8B8A8_SRGB, -+ PVRDRI_MESA_FORMAT_R8G8B8X8_UNORM, -+ }; -+ unsigned int uSizeMesaFormats; -+ bool bCapRGB; -+ unsigned int i, j; -+ -+ bCapRGB = MODSUPGetCapability(psPVRScreen->psDRIScreen, -+ PVRDRI_LOADER_CAP_RGBA_ORDERING) != 0; -+ -+ uSizeMesaFormats = sizeof(auMesaFormatsBase); -+ if (bCapRGB) -+ uSizeMesaFormats += sizeof(auMesaFormatsRGB); -+ -+ /* -+ * We haven't checked if any of the Mesa formats are supported by the DDK -+ * at this point, so we may allocate more memory than we need. -+ */ -+ psPVRScreen->puMesaFormats = malloc(uSizeMesaFormats); -+ if (psPVRScreen->puMesaFormats == NULL) { -+ __driUtilMessage("%s: Out of memory", __func__); -+ return false; -+ } -+ -+ for (i = 0, j = 0; i < ARRAY_SIZE(auMesaFormatsBase); i++) { -+ unsigned int uMesaFormat = auMesaFormatsBase[i]; -+ -+ if (!PVRDRIMesaFormatSupported(uMesaFormat)) -+ continue; -+ -+ psPVRScreen->puMesaFormats[j++] = uMesaFormat; -+ } -+ -+ if (bCapRGB) { -+ for (i = 0; i < ARRAY_SIZE(auMesaFormatsRGB); i++) { -+ unsigned int uMesaFormat = auMesaFormatsRGB[i]; -+ -+ if (!PVRDRIMesaFormatSupported(uMesaFormat)) -+ continue; -+ -+ psPVRScreen->puMesaFormats[j++] = uMesaFormat; -+ } -+ } -+ -+ assert((j * sizeof(psPVRScreen->puMesaFormats[0])) <= -+ uSizeMesaFormats); -+ -+ psPVRScreen->uNumMesaFormats = j; -+ -+ return true; -+} -+ -+void -+PVRDRIFreeMesaFormats(struct DRISUPScreen *psPVRScreen) -+{ -+ free(psPVRScreen->puMesaFormats); -+} diff --git a/src/meson.build b/src/meson.build -index 84a990358a3..d96c754a63d 100644 +index acc7fe94abb..c3bab27718d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -25,6 +25,7 @@ inc_gallium = include_directories('gallium/include') @@ -10197,9 +4684,9 @@ index 84a990358a3..d96c754a63d 100644 inc_amd_common = include_directories('amd/common') inc_amd_common_llvm = include_directories('amd/llvm') +inc_pvr = include_directories('mesa/main', 'mapi/glapi') - - libglsl_util = static_library( - 'glsl_util', + inc_tool = include_directories('tool') + pps_datasources = [] + pps_includes = [] -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0002-Force-Mesa-to-use-the-PVR-driver-for-platform-device.patch b/package/mesa3d/0002-Force-Mesa-to-use-the-PVR-driver-for-platform-device.patch index 7139dbf4..fb7b5956 100644 --- a/package/mesa3d/0002-Force-Mesa-to-use-the-PVR-driver-for-platform-device.patch +++ b/package/mesa3d/0002-Force-Mesa-to-use-the-PVR-driver-for-platform-device.patch @@ -1,7 +1,7 @@ -From dbbfc6aadf0c6b40c47b325bf9bb35cf1d552d9c Mon Sep 17 00:00:00 2001 +From 184d3da84d449bc05511cb857cc843285dde4b63 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Wed, 17 Jun 2015 15:37:18 +0100 -Subject: [PATCH 02/50] Force Mesa to use the PVR driver for platform devices +Subject: [PATCH 02/67] Force Mesa to use the PVR driver for platform devices For platform devices, Mesa uses the DRM driver name to determine which DRI driver to load. This doesn't work in the multi-DRM driver model where there @@ -14,7 +14,7 @@ force it to use the PVR DRI driver. 1 file changed, 4 insertions(+) diff --git a/src/loader/loader.c b/src/loader/loader.c -index d64bc7c10f2..cfadecf02b4 100644 +index 08eeb61504b..c7e561ef2e4 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -436,7 +436,11 @@ loader_get_pci_driver(int fd) @@ -30,5 +30,5 @@ index d64bc7c10f2..cfadecf02b4 100644 for (i = 0; i < ARRAY_SIZE(driver_map); i++) { if (vendor_id != driver_map[i].vendor_id) -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0003-dri-Add-some-new-DRI-formats-and-fourccs.patch b/package/mesa3d/0003-dri-Add-some-new-DRI-formats-and-fourccs.patch index 01721620..c82ec948 100644 --- a/package/mesa3d/0003-dri-Add-some-new-DRI-formats-and-fourccs.patch +++ b/package/mesa3d/0003-dri-Add-some-new-DRI-formats-and-fourccs.patch @@ -1,7 +1,7 @@ -From 94cfbd20ea72aac430abf5097133b1356c0a52a1 Mon Sep 17 00:00:00 2001 +From fec4f46f7cedb6b3e90bf88c3efc3cd5da0d9131 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Thu, 5 Jun 2014 12:07:01 +0100 -Subject: [PATCH 03/50] dri: Add some new DRI formats and fourccs +Subject: [PATCH 03/67] dri: Add some new DRI formats and fourccs Add ARGB4444 DRI format and fourcc. Add YVU444_PACK10_IMG DRI format and fourcc. @@ -14,32 +14,32 @@ Add BGR888 DRI format and fourcc. 4 files changed, 11 insertions(+) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h -index 9b85e67ce49..e668798e87f 100644 +index 66dc0927cb7..510289403d2 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h -@@ -1366,6 +1366,9 @@ struct __DRIdri2ExtensionRec { - #define __DRI_IMAGE_FORMAT_XBGR16161616F 0x1014 +@@ -1367,6 +1367,9 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_FORMAT_ABGR16161616F 0x1015 #define __DRI_IMAGE_FORMAT_SXRGB8 0x1016 -+#define __DRI_IMAGE_FORMAT_ARGB4444 0x1017 -+#define __DRI_IMAGE_FORMAT_YVU444_PACK10_IMG 0x1018 -+#define __DRI_IMAGE_FORMAT_BGR888 0x1019 + #define __DRI_IMAGE_FORMAT_ABGR16161616 0x1017 ++#define __DRI_IMAGE_FORMAT_ARGB4444 0x1018 ++#define __DRI_IMAGE_FORMAT_YVU444_PACK10_IMG 0x1019 ++#define __DRI_IMAGE_FORMAT_BGR888 0x101a #define __DRI_IMAGE_USE_SHARE 0x0001 #define __DRI_IMAGE_USE_SCANOUT 0x0002 -@@ -1395,6 +1398,7 @@ struct __DRIdri2ExtensionRec { - #define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258 +@@ -1397,6 +1400,7 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_FOURCC_SABGR8888 0x84324258 #define __DRI_IMAGE_FOURCC_SXRGB8888 0x85324258 + #define __DRI_IMAGE_FOURCC_RGBA16161616 0x38344152 /* fourcc_code('R', 'A', '4', '8' ) */ +#define __DRI_IMAGE_FOURCC_SBGR888 0xff324742 /** * Queryable on images created by createImageFromNames. diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h -index 3f9c8110355..8af9b16ff88 100644 +index cd3ce8a8c60..57657592a38 100644 --- a/include/drm-uapi/drm_fourcc.h +++ b/include/drm-uapi/drm_fourcc.h -@@ -307,6 +307,7 @@ extern "C" { +@@ -344,6 +344,7 @@ extern "C" { #define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ #define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ @@ -48,13 +48,13 @@ index 3f9c8110355..8af9b16ff88 100644 /* * Format Modifiers: diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index 62fc7fb7783..4f52985c48e 100644 +index 9e5a55a287c..eee28eb4726 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -2659,6 +2659,7 @@ dri2_num_fourcc_format_planes(EGLint format) - case DRM_FORMAT_VYUY: - case DRM_FORMAT_AYUV: - case DRM_FORMAT_XYUV8888: +@@ -2652,6 +2652,7 @@ dri2_num_fourcc_format_planes(EGLint format) + case DRM_FORMAT_Y410: + case DRM_FORMAT_Y412: + case DRM_FORMAT_Y416: + case DRM_FORMAT_YVU444_PACK10_IMG: return 1; @@ -76,5 +76,5 @@ index e2a11240dea..caed5fa6a68 100644 .image_format = __DRI_IMAGE_FORMAT_XRGB8888, .mesa_format = MESA_FORMAT_B8G8R8X8_UNORM, -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0004-GL_EXT_sparse_texture-entry-points.patch b/package/mesa3d/0004-GL_EXT_sparse_texture-entry-points.patch index d810176e..2dde5cee 100644 --- a/package/mesa3d/0004-GL_EXT_sparse_texture-entry-points.patch +++ b/package/mesa3d/0004-GL_EXT_sparse_texture-entry-points.patch @@ -1,7 +1,7 @@ -From c9723120dbbe1d73c258d1aa119e05a24ab98b8a Mon Sep 17 00:00:00 2001 +From e66cd64b65e86a23807260a9a0c73f1355715314 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Wed, 12 Aug 2015 09:11:51 +0100 -Subject: [PATCH 04/50] GL_EXT_sparse_texture entry points +Subject: [PATCH 04/67] GL_EXT_sparse_texture entry points --- src/mapi/glapi/gen/EXT_sparse_texture.xml | 56 +++++++++++++++++++++++ @@ -73,7 +73,7 @@ index 00000000000..48d03e7b9c0 + + diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml -index 4386375940f..d8a80995d92 100644 +index 929b40bbd4a..962170bc58e 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -1433,6 +1433,9 @@ @@ -87,18 +87,18 @@ index 4386375940f..d8a80995d92 100644 diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py -index 5b51c222d79..a151a5d5fb4 100644 +index 6accff1b231..d063930bd81 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py -@@ -1677,6 +1677,8 @@ offsets = { - "SecondaryColor3hNV": 1641, - "SecondaryColor3hvNV": 1642, - "InternalSetError": 1643, -+ "TexPageCommitmentEXT": 1644, -+ "TexturePageCommitmentEXT" : 1645, +@@ -1689,6 +1689,8 @@ offsets = { + "VertexAttribs2hvNV": 1653, + "VertexAttribs3hvNV": 1654, + "VertexAttribs4hvNV": 1655, ++ "TexPageCommitmentEXT": 1656, ++ "TexturePageCommitmentEXT" : 1657, } functions = [ -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0005-Add-support-for-various-GLES-extensions.patch b/package/mesa3d/0005-Add-support-for-various-GLES-extensions.patch index a6a96eed..9f3f10c5 100644 --- a/package/mesa3d/0005-Add-support-for-various-GLES-extensions.patch +++ b/package/mesa3d/0005-Add-support-for-various-GLES-extensions.patch @@ -1,7 +1,7 @@ -From 329dd07729514a93a298e8ab6485822444ed4b28 Mon Sep 17 00:00:00 2001 +From 4a1be491de2ea78be95dc4cf08af4b1da5e16d91 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Mon, 10 Mar 2014 12:27:03 +0000 -Subject: [PATCH 05/50] Add support for various GLES extensions +Subject: [PATCH 05/67] Add support for various GLES extensions Add support for: EXT_occlusion_query_boolean @@ -13,7 +13,7 @@ Add support for: 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml -index d8a80995d92..42f4b2b80fb 100644 +index 962170bc58e..e586b0ec19b 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -285,28 +285,25 @@ @@ -85,22 +85,22 @@ index d8a80995d92..42f4b2b80fb 100644 diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py -index a151a5d5fb4..b23ae713f6f 100644 +index d063930bd81..79b8f19cb75 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py -@@ -1679,6 +1679,12 @@ offsets = { - "InternalSetError": 1643, - "TexPageCommitmentEXT": 1644, - "TexturePageCommitmentEXT" : 1645, -+ "CurrentPaletteMatrixOES" : 1646, -+ "LoadPaletteFromModelViewMatrixOES" : 1647, -+ "MatrixIndexPointerOES" : 1648, -+ "WeightPointerOES" : 1649, -+ "RenderbufferStorageMultisampleIMG" : 1650, -+ "FramebufferTexture2DMultisampleIMG" : 1651, +@@ -1691,6 +1691,12 @@ offsets = { + "VertexAttribs4hvNV": 1655, + "TexPageCommitmentEXT": 1656, + "TexturePageCommitmentEXT" : 1657, ++ "CurrentPaletteMatrixOES" : 1658, ++ "LoadPaletteFromModelViewMatrixOES" : 1659, ++ "MatrixIndexPointerOES" : 1660, ++ "WeightPointerOES" : 1661, ++ "RenderbufferStorageMultisampleIMG" : 1662, ++ "FramebufferTexture2DMultisampleIMG" : 1663, } functions = [ -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0006-Add-EGL_IMG_cl_image-extension.patch b/package/mesa3d/0006-Add-EGL_IMG_cl_image-extension.patch index ce4d2cfe..0d11e65d 100644 --- a/package/mesa3d/0006-Add-EGL_IMG_cl_image-extension.patch +++ b/package/mesa3d/0006-Add-EGL_IMG_cl_image-extension.patch @@ -1,7 +1,7 @@ -From e89ccf17b6a484d74fc1f0a45266ffc8f7fc3fec Mon Sep 17 00:00:00 2001 +From 7fdeb8bf25be01f122a7cb55dbe2b0e67e4a24a2 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Tue, 11 Mar 2014 11:50:53 +0000 -Subject: [PATCH 06/50] Add EGL_IMG_cl_image extension +Subject: [PATCH 06/67] Add EGL_IMG_cl_image extension Add support for the experimental EGL_IMG_cl_image extension to EGL, and the DRI2 EGL driver. @@ -30,13 +30,13 @@ index f0395a8a58c..5d11f3e488e 100644 } #endif diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h -index e668798e87f..06eab0da5aa 100644 +index 510289403d2..b197092939f 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h -@@ -1807,6 +1807,19 @@ struct __DRIimageExtensionRec { - uint32_t flags, - unsigned *error, - void *loaderPrivate); +@@ -1831,6 +1831,19 @@ struct __DRIimageExtensionRec { + const unsigned int modifier_count, + unsigned int use, + void *loaderPrivate); + + /** + * Support for experimental EGL_CL_IMAGE_IMG. @@ -54,10 +54,10 @@ index e668798e87f..06eab0da5aa 100644 diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index 4f52985c48e..fb5d5617511 100644 +index eee28eb4726..dea5899b3a8 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -1008,6 +1008,10 @@ dri2_setup_screen(_EGLDisplay *disp) +@@ -995,6 +995,10 @@ dri2_setup_screen(_EGLDisplay *disp) disp->Extensions.EXT_image_dma_buf_import_modifiers = EGL_TRUE; } #endif @@ -68,7 +68,7 @@ index 4f52985c48e..fb5d5617511 100644 } if (dri2_dpy->flush_control) -@@ -2373,17 +2377,13 @@ dri2_get_sync_values_chromium(_EGLDisplay *disp, _EGLSurface *surf, +@@ -2360,17 +2364,13 @@ dri2_get_sync_values_chromium(_EGLDisplay *disp, _EGLSurface *surf, return dri2_dpy->vtbl->get_sync_values(disp, surf, ust, msc, sbc); } @@ -88,7 +88,7 @@ index 4f52985c48e..fb5d5617511 100644 } static _EGLImage * -@@ -2462,7 +2462,49 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2449,7 +2449,49 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx, attrs.GLTextureLevel, &error, NULL); @@ -139,7 +139,7 @@ index 4f52985c48e..fb5d5617511 100644 if (!dri2_img->dri_image) { free(dri2_img); -@@ -2923,7 +2965,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2916,7 +2958,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, &error, NULL); } @@ -148,7 +148,7 @@ index 4f52985c48e..fb5d5617511 100644 if (!dri_image) return EGL_NO_IMAGE_KHR; -@@ -3159,6 +3201,8 @@ dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, +@@ -3152,6 +3194,8 @@ dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, case EGL_WAYLAND_BUFFER_WL: return dri2_create_image_wayland_wl_buffer(disp, ctx, buffer, attr_list); #endif @@ -158,7 +158,7 @@ index 4f52985c48e..fb5d5617511 100644 _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); return EGL_NO_IMAGE_KHR; diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index df0a0011dbf..e08b525c319 100644 +index 17e36af22e1..6ffcff8b2cc 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -549,6 +549,7 @@ _eglCreateExtensionsString(_EGLDisplay *disp) @@ -183,5 +183,5 @@ index 4d2afbc712e..5b05dcc1e6d 100644 struct _egl_display -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0007-egl-Be-stricter-when-making-a-context-current-withou.patch b/package/mesa3d/0007-egl-Be-stricter-when-making-a-context-current-withou.patch index de11b134..2e33ad4c 100644 --- a/package/mesa3d/0007-egl-Be-stricter-when-making-a-context-current-withou.patch +++ b/package/mesa3d/0007-egl-Be-stricter-when-making-a-context-current-withou.patch @@ -1,7 +1,7 @@ -From 9aab53e750f23aa9e2d8f1bfb2d9f6ff4ac3155a Mon Sep 17 00:00:00 2001 +From fa57726f60bc6fc6e7094f16300cdc41b44ff4f3 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Wed, 18 Jun 2014 17:10:28 +0100 -Subject: [PATCH 08/50] egl: Be stricter when making a context current without +Subject: [PATCH 07/67] egl: Be stricter when making a context current without any surfaces The EGL_KHR_surfaceless_context extension spec states for eglMakeCurrent: @@ -33,7 +33,7 @@ is 1.0. 1 file changed, 3 insertions(+) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index e08b525c319..9d90f503cc5 100644 +index 6ffcff8b2cc..3cd69b96a0f 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -888,6 +888,9 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, @@ -47,5 +47,5 @@ index e08b525c319..9d90f503cc5 100644 /* If a native window underlying either draw or read is no longer valid, -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0008-egl-optimise-eglMakeCurrent-for-the-case-where-nothi.patch b/package/mesa3d/0008-egl-optimise-eglMakeCurrent-for-the-case-where-nothi.patch index d2339659..5de24ac4 100644 --- a/package/mesa3d/0008-egl-optimise-eglMakeCurrent-for-the-case-where-nothi.patch +++ b/package/mesa3d/0008-egl-optimise-eglMakeCurrent-for-the-case-where-nothi.patch @@ -1,7 +1,7 @@ -From 0b65066319eff5c482614574d4a4192454837835 Mon Sep 17 00:00:00 2001 +From f556292d5811750d119acea6c7dc0c5ebd3e1af6 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Tue, 15 Sep 2015 14:15:31 +0100 -Subject: [PATCH 09/50] egl: optimise eglMakeCurrent for the case where nothing +Subject: [PATCH 08/67] egl: optimise eglMakeCurrent for the case where nothing has changed When an application calls eglMakeCurrent with a context, draw surface and @@ -12,7 +12,7 @@ thread don't perform a flush as this is an expensive operation. 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index 9d90f503cc5..bc7014ef8ed 100644 +index 3cd69b96a0f..234449adf64 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -853,6 +853,7 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, @@ -42,5 +42,5 @@ index 9d90f503cc5..bc7014ef8ed 100644 RETURN_EGL_EVAL(disp, ret); } -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0009-GL_EXT_shader_pixel_local_storage2-entry-points.patch b/package/mesa3d/0009-GL_EXT_shader_pixel_local_storage2-entry-points.patch index fa27b5a8..12b7e1fe 100644 --- a/package/mesa3d/0009-GL_EXT_shader_pixel_local_storage2-entry-points.patch +++ b/package/mesa3d/0009-GL_EXT_shader_pixel_local_storage2-entry-points.patch @@ -1,7 +1,7 @@ -From 921ab82e655c9a3ffab6e39847a7d2d61338221e Mon Sep 17 00:00:00 2001 +From 13e925af5ba3bd763eb4c9e5d0781f92981550f6 Mon Sep 17 00:00:00 2001 From: Rufus Hamade Date: Thu, 4 Feb 2016 14:09:26 +0000 -Subject: [PATCH 10/50] GL_EXT_shader_pixel_local_storage2 entry points +Subject: [PATCH 09/67] GL_EXT_shader_pixel_local_storage2 entry points --- .../gen/EXT_shader_pixel_local_storage2.xml | 35 +++++++++++++++++++ @@ -52,7 +52,7 @@ index 00000000000..20e186c0f0d + + diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml -index 42f4b2b80fb..c7fde29732a 100644 +index e586b0ec19b..a3bfe86a888 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -1459,6 +1459,9 @@ @@ -66,19 +66,19 @@ index 42f4b2b80fb..c7fde29732a 100644 diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py -index b23ae713f6f..1ace5e201d8 100644 +index 79b8f19cb75..99729e21b7f 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py -@@ -1685,6 +1685,9 @@ offsets = { - "WeightPointerOES" : 1649, - "RenderbufferStorageMultisampleIMG" : 1650, - "FramebufferTexture2DMultisampleIMG" : 1651, -+ "ClearPixelLocalStorageuiEXT" : 1652, -+ "FramebufferPixelLocalStorageSizeEXT" : 1653, -+ "GetFramebufferPixelLocalStorageSizeEXT" : 1654, +@@ -1697,6 +1697,9 @@ offsets = { + "WeightPointerOES" : 1661, + "RenderbufferStorageMultisampleIMG" : 1662, + "FramebufferTexture2DMultisampleIMG" : 1663, ++ "ClearPixelLocalStorageuiEXT" : 1664, ++ "FramebufferPixelLocalStorageSizeEXT" : 1665, ++ "GetFramebufferPixelLocalStorageSizeEXT" : 1666, } functions = [ -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0010-GL_IMG_framebuffer_downsample-entry-points.patch b/package/mesa3d/0010-GL_IMG_framebuffer_downsample-entry-points.patch index 6d8c842b..edc8ff1f 100644 --- a/package/mesa3d/0010-GL_IMG_framebuffer_downsample-entry-points.patch +++ b/package/mesa3d/0010-GL_IMG_framebuffer_downsample-entry-points.patch @@ -1,7 +1,7 @@ -From 67428e8b27839095214419dabccaeffab923a89b Mon Sep 17 00:00:00 2001 +From f43a3258b8f4859ff3e0e3d3d356b319dd6a5435 Mon Sep 17 00:00:00 2001 From: Rufus Hamade Date: Thu, 4 Feb 2016 14:09:26 +0000 -Subject: [PATCH 11/50] GL_IMG_framebuffer_downsample entry points +Subject: [PATCH 10/67] GL_IMG_framebuffer_downsample entry points --- .../glapi/gen/IMG_framebuffer_downsample.xml | 37 +++++++++++++++++++ @@ -54,7 +54,7 @@ index 00000000000..b5ce77dfb08 + + diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml -index c7fde29732a..6aea8c55fac 100644 +index a3bfe86a888..b3432820ba6 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -1462,6 +1462,9 @@ @@ -68,18 +68,18 @@ index c7fde29732a..6aea8c55fac 100644 diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py -index 1ace5e201d8..2838a4451a2 100644 +index 99729e21b7f..c723cb3fab8 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py -@@ -1688,6 +1688,8 @@ offsets = { - "ClearPixelLocalStorageuiEXT" : 1652, - "FramebufferPixelLocalStorageSizeEXT" : 1653, - "GetFramebufferPixelLocalStorageSizeEXT" : 1654, -+ "FramebufferTexture2DDownsampleIMG" : 1655, -+ "FramebufferTextureLayerDownsampleIMG" : 1656, +@@ -1700,6 +1700,8 @@ offsets = { + "ClearPixelLocalStorageuiEXT" : 1664, + "FramebufferPixelLocalStorageSizeEXT" : 1665, + "GetFramebufferPixelLocalStorageSizeEXT" : 1666, ++ "FramebufferTexture2DDownsampleIMG" : 1667, ++ "FramebufferTextureLayerDownsampleIMG" : 1668, } functions = [ -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0011-GL_OVR_multiview-entry-points.patch b/package/mesa3d/0011-GL_OVR_multiview-entry-points.patch index 3d0c9194..81464a56 100644 --- a/package/mesa3d/0011-GL_OVR_multiview-entry-points.patch +++ b/package/mesa3d/0011-GL_OVR_multiview-entry-points.patch @@ -1,7 +1,7 @@ -From 5aed29849109fcb20934186b9f4ffc0606b40f8e Mon Sep 17 00:00:00 2001 +From cbc7a7501ea4ceffd55ca389deb55d12ff9ceb3f Mon Sep 17 00:00:00 2001 From: Brendan King Date: Mon, 11 Jul 2016 12:45:30 +0100 -Subject: [PATCH 12/50] GL_OVR_multiview entry points +Subject: [PATCH 11/67] GL_OVR_multiview entry points --- src/mapi/glapi/gen/gl_API.xml | 17 +++++++++++++++++ @@ -9,10 +9,10 @@ Subject: [PATCH 12/50] GL_OVR_multiview entry points 2 files changed, 18 insertions(+) diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml -index dcdbe80290c..d6fae3b1988 100644 +index cf5a0f0a0c0..4e35de0f4ea 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml -@@ -13101,6 +13101,23 @@ +@@ -13125,6 +13125,23 @@ @@ -37,17 +37,17 @@ index dcdbe80290c..d6fae3b1988 100644 diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py -index 2838a4451a2..015e4efed7a 100644 +index c723cb3fab8..73625c7fe41 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py -@@ -1690,6 +1690,7 @@ offsets = { - "GetFramebufferPixelLocalStorageSizeEXT" : 1654, - "FramebufferTexture2DDownsampleIMG" : 1655, - "FramebufferTextureLayerDownsampleIMG" : 1656, -+ "FramebufferTextureMultiviewOVR" : 1657, +@@ -1702,6 +1702,7 @@ offsets = { + "GetFramebufferPixelLocalStorageSizeEXT" : 1666, + "FramebufferTexture2DDownsampleIMG" : 1667, + "FramebufferTextureLayerDownsampleIMG" : 1668, ++ "FramebufferTextureMultiviewOVR" : 1669, } functions = [ -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0012-Add-OVR_multiview_multisampled_render_to_texture.patch b/package/mesa3d/0012-Add-OVR_multiview_multisampled_render_to_texture.patch index 5b4b6a97..58cfbaaf 100644 --- a/package/mesa3d/0012-Add-OVR_multiview_multisampled_render_to_texture.patch +++ b/package/mesa3d/0012-Add-OVR_multiview_multisampled_render_to_texture.patch @@ -1,7 +1,7 @@ -From 95383627bc57aa19f0e5d40ae8c91f4d91230708 Mon Sep 17 00:00:00 2001 +From 91ea37486db99fd403654ebff2a0a8401f7cd600 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Mon, 11 Jul 2016 13:29:51 +0100 -Subject: [PATCH 13/50] Add OVR_multiview_multisampled_render_to_texture +Subject: [PATCH 12/67] Add OVR_multiview_multisampled_render_to_texture --- ...ltiview_multisampled_render_to_texture.xml | 21 +++++++++++++++++++ @@ -38,7 +38,7 @@ index 00000000000..86bebc728e9 + + diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml -index 6aea8c55fac..359cc9ca8cf 100644 +index b3432820ba6..fe8f27e1e6f 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -1459,6 +1459,9 @@ @@ -52,17 +52,17 @@ index 6aea8c55fac..359cc9ca8cf 100644 diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py -index 015e4efed7a..d13dc915d6f 100644 +index 73625c7fe41..dc6bdc9dcce 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py -@@ -1691,6 +1691,7 @@ offsets = { - "FramebufferTexture2DDownsampleIMG" : 1655, - "FramebufferTextureLayerDownsampleIMG" : 1656, - "FramebufferTextureMultiviewOVR" : 1657, -+ "FramebufferTextureMultisampleMultiviewOVR" : 1658, +@@ -1703,6 +1703,7 @@ offsets = { + "FramebufferTexture2DDownsampleIMG" : 1667, + "FramebufferTextureLayerDownsampleIMG" : 1668, + "FramebufferTextureMultiviewOVR" : 1669, ++ "FramebufferTextureMultisampleMultiviewOVR" : 1670, } functions = [ -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0013-wayland-drm-install-wayland-drm.xml-to-the-configure.patch b/package/mesa3d/0013-wayland-drm-install-wayland-drm.xml-to-the-configure.patch index ec193ed7..bb028d91 100644 --- a/package/mesa3d/0013-wayland-drm-install-wayland-drm.xml-to-the-configure.patch +++ b/package/mesa3d/0013-wayland-drm-install-wayland-drm.xml-to-the-configure.patch @@ -1,7 +1,7 @@ -From 2d7c499fe386f83e6f77ddc1e9dbd437e5dbe59a Mon Sep 17 00:00:00 2001 +From b38c4118c7a3a060ef1c8b8477200f5a73305397 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Thu, 18 Aug 2016 15:52:28 +0100 -Subject: [PATCH 14/50] wayland-drm: install wayland-drm.xml to the configured +Subject: [PATCH 13/67] wayland-drm: install wayland-drm.xml to the configured pkgdatadir Add a pkg-config file as well so that it can be located without hardcoding the @@ -53,5 +53,5 @@ index 00000000000..d08ccdaf6ce +Version: @PACKAGE_VERSION@ \ No newline at end of file -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0014-Enable-buffer-sharing-in-the-kms_swrast-driver.patch b/package/mesa3d/0014-Enable-buffer-sharing-in-the-kms_swrast-driver.patch index 4ca56a92..317ad375 100644 --- a/package/mesa3d/0014-Enable-buffer-sharing-in-the-kms_swrast-driver.patch +++ b/package/mesa3d/0014-Enable-buffer-sharing-in-the-kms_swrast-driver.patch @@ -1,7 +1,7 @@ -From 2cc857d6ae366e5599a7d39b975ab030ec915001 Mon Sep 17 00:00:00 2001 +From b80c78b05ebb661e7f088d0a369b0f0d2990afca Mon Sep 17 00:00:00 2001 From: Brendan King Date: Wed, 26 Oct 2016 16:24:28 +0100 -Subject: [PATCH 15/50] Enable buffer sharing in the kms_swrast driver +Subject: [PATCH 14/67] Enable buffer sharing in the kms_swrast driver Enable buffer sharing, so that a DRI driver can be loaded by a Wayland client when kms_swrast is being used by the compositor. @@ -10,10 +10,10 @@ Wayland client when kms_swrast is being used by the compositor. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c -index b0c0d7eafbe..d78e1638d1d 100644 +index ebc18a73c86..09f4b02e758 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c -@@ -2300,7 +2300,7 @@ dri_kms_init_screen(__DRIscreen * sPriv) +@@ -2400,7 +2400,7 @@ dri_kms_init_screen(__DRIscreen * sPriv) if (!configs) goto destroy_screen; @@ -23,5 +23,5 @@ index b0c0d7eafbe..d78e1638d1d 100644 screen->broken_invalidate = !sPriv->dri2.useInvalidate; screen->lookup_egl_image = dri2_lookup_egl_image; -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0015-egl-wayland-add-support-for-RGB565-back-buffers.patch b/package/mesa3d/0015-egl-wayland-add-support-for-RGB565-back-buffers.patch index 5e34e537..cba6084c 100644 --- a/package/mesa3d/0015-egl-wayland-add-support-for-RGB565-back-buffers.patch +++ b/package/mesa3d/0015-egl-wayland-add-support-for-RGB565-back-buffers.patch @@ -1,17 +1,17 @@ -From 39233fe0599c68e7b20e4074b0aa7c8e639f648b Mon Sep 17 00:00:00 2001 +From 55a15a019dd792477e39f6225f2b4e50a1359b66 Mon Sep 17 00:00:00 2001 From: James Glanville Date: Tue, 28 Feb 2017 16:08:47 +0000 -Subject: [PATCH 16/50] egl/wayland: add support for RGB565 back buffers +Subject: [PATCH 15/67] egl/wayland: add support for RGB565 back buffers --- src/egl/drivers/dri2/platform_wayland.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c -index f65d9e45d8f..6eb2c7cbdf6 100644 +index cfff0ade90e..c18edc0de4e 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c -@@ -647,18 +647,27 @@ back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer) +@@ -633,18 +633,27 @@ back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer) struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display); __DRIimage *image; @@ -42,5 +42,5 @@ index f65d9e45d8f..6eb2c7cbdf6 100644 static int -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0016-egl-dri3-fix-segfault-in-eglCopyBuffers.patch b/package/mesa3d/0016-egl-dri3-fix-segfault-in-eglCopyBuffers.patch index 68136982..106ea5cc 100644 --- a/package/mesa3d/0016-egl-dri3-fix-segfault-in-eglCopyBuffers.patch +++ b/package/mesa3d/0016-egl-dri3-fix-segfault-in-eglCopyBuffers.patch @@ -1,7 +1,7 @@ -From ef372bd8c5ee377bac81f22174b9e01a30cffe53 Mon Sep 17 00:00:00 2001 +From 03f4f18f9edb4090c6aeca16e6f4de602aea68bf Mon Sep 17 00:00:00 2001 From: Brendan King Date: Thu, 13 Apr 2017 10:12:40 +0100 -Subject: [PATCH 17/50] egl/dri3: fix segfault in eglCopyBuffers +Subject: [PATCH 16/67] egl/dri3: fix segfault in eglCopyBuffers The loader_dri3_copy_drawable function expected the drawable to have a fake front buffer, resulting in a segfault if there wasn't one, @@ -13,10 +13,10 @@ current back buffer. 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c -index ccf8d1795e7..0f7cf0d186c 100644 +index 6e825f9a898..ff6d1ffc660 100644 --- a/src/loader/loader_dri3_helper.c +++ b/src/loader/loader_dri3_helper.c -@@ -858,15 +858,24 @@ loader_dri3_copy_drawable(struct loader_dri3_drawable *draw, +@@ -863,15 +863,24 @@ loader_dri3_copy_drawable(struct loader_dri3_drawable *draw, xcb_drawable_t dest, xcb_drawable_t src) { @@ -45,5 +45,5 @@ index ccf8d1795e7..0f7cf0d186c 100644 void -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0017-egl-automatically-call-eglReleaseThread-on-thread-te.patch b/package/mesa3d/0017-egl-automatically-call-eglReleaseThread-on-thread-te.patch index 5c0709ba..35b2d518 100644 --- a/package/mesa3d/0017-egl-automatically-call-eglReleaseThread-on-thread-te.patch +++ b/package/mesa3d/0017-egl-automatically-call-eglReleaseThread-on-thread-te.patch @@ -1,7 +1,7 @@ -From ce5d9f5a0a95658e2c9d54726bcd8986d7e2be4a Mon Sep 17 00:00:00 2001 +From d98cd46b5841ecb785a801a977a1b341d98d08c4 Mon Sep 17 00:00:00 2001 From: Iosif Antochi Date: Wed, 14 Jun 2017 14:49:55 +0100 -Subject: [PATCH 18/50] egl: automatically call eglReleaseThread on thread +Subject: [PATCH 17/67] egl: automatically call eglReleaseThread on thread termination EGL thread cleanup conformance tests could run out of memory as the contexts @@ -22,17 +22,17 @@ dEQP-EGL.functional.robustness.create_context.query_robust_access 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c -index 29be4268025..e93793a6073 100644 +index 11277d3e4c0..c87eac0d007 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c -@@ -43,6 +43,7 @@ static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; +@@ -44,6 +44,7 @@ static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; static EGLBoolean _egl_TSDInitialized; static tss_t _egl_TSD; static void _eglDestroyThreadInfo(_EGLThreadInfo *t); +static void _eglDestroyThreadInfoCallback(_EGLThreadInfo *t); #ifdef USE_ELF_TLS - static __thread const _EGLThreadInfo *_egl_TLS + static __THREAD_INITIAL_EXEC const _EGLThreadInfo *_egl_TLS; @@ -86,7 +87,7 @@ static inline EGLBoolean _eglInitTSD() /* check again after acquiring lock */ @@ -74,5 +74,5 @@ index 29be4268025..e93793a6073 100644 * Make sure TSD is initialized and return current value. */ -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0018-egl-add-Tizen-platform-support.patch b/package/mesa3d/0018-egl-add-Tizen-platform-support.patch index a72ceee3..3fa95416 100644 --- a/package/mesa3d/0018-egl-add-Tizen-platform-support.patch +++ b/package/mesa3d/0018-egl-add-Tizen-platform-support.patch @@ -1,12 +1,12 @@ -From bbef8a8f66f7f5ac6714a2d3f77a323a2d38a493 Mon Sep 17 00:00:00 2001 +From a2fea4d0fb40d7bdfd2a3860132c37288f3d7864 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Fri, 6 Jan 2017 16:35:00 +0000 -Subject: [PATCH 19/50] egl: add Tizen platform support +Subject: [PATCH 18/67] egl: add Tizen platform support Add a new "tizen" platform to support drm/gbm and Wayland on Tizen. The platform can be enabled by passing "-Dplatforms=tizen" to Meson. --- - meson.build | 27 +- + meson.build | 25 +- meson_options.txt | 2 +- src/egl/drivers/dri2/egl_dri2.c | 182 ++++- src/egl/drivers/dri2/egl_dri2.h | 59 +- @@ -15,15 +15,15 @@ The platform can be enabled by passing "-Dplatforms=tizen" to Meson. src/egl/main/egldisplay.c | 32 +- src/egl/main/egldisplay.h | 7 + src/egl/main/egllog.c | 27 +- - src/egl/meson.build | 9 +- - 10 files changed, 1316 insertions(+), 16 deletions(-) + src/egl/meson.build | 7 +- + 10 files changed, 1313 insertions(+), 15 deletions(-) create mode 100644 src/egl/drivers/dri2/platform_tizen.c diff --git a/meson.build b/meson.build -index 15e08dfea1c..c90e44254d2 100644 +index 968b4f5f499..3d9d345dbf2 100644 --- a/meson.build +++ b/meson.build -@@ -346,6 +346,11 @@ with_platform_x11 = _platforms.contains('x11') +@@ -358,6 +358,11 @@ with_platform_x11 = _platforms.contains('x11') with_platform_wayland = _platforms.contains('wayland') with_platform_haiku = _platforms.contains('haiku') with_platform_windows = _platforms.contains('windows') @@ -33,18 +33,18 @@ index 15e08dfea1c..c90e44254d2 100644 + error('tizen cannot be enabled at the same time as other platforms') +endif - if _platforms.length() != 0 - egl_native_platform = _platforms[0] -@@ -859,7 +864,7 @@ else + with_glx = get_option('glx') + if with_glx == 'auto' +@@ -910,7 +915,7 @@ else pre_args += '-DEGL_NO_X11' gl_pkgconfig_c_flags += '-DEGL_NO_X11' endif --if with_gbm -+if with_gbm and not with_platform_tizen +-if with_gbm and not with_platform_android ++if with_gbm and not with_platform_android and not with_platform_tizen pre_args += '-DHAVE_DRM_PLATFORM' endif -@@ -889,6 +894,15 @@ endif +@@ -944,6 +949,15 @@ endif if with_platform_haiku pre_args += '-DHAVE_HAIKU_PLATFORM' endif @@ -60,7 +60,7 @@ index 15e08dfea1c..c90e44254d2 100644 prog_python = import('python').find_installation('python3') has_mako = run_command( -@@ -1487,7 +1501,8 @@ with_gallium_drisw_kms = false +@@ -1568,7 +1582,8 @@ with_gallium_drisw_kms = false dep_libdrm = dependency( 'libdrm', version : '>=' + _drm_ver, # GNU/Hurd includes egl_dri2, without drm. @@ -70,23 +70,21 @@ index 15e08dfea1c..c90e44254d2 100644 ) if dep_libdrm.found() pre_args += '-DHAVE_LIBDRM' -@@ -2028,9 +2043,11 @@ if with_egl +@@ -2187,8 +2202,10 @@ if with_egl + lines += 'EGL drivers: ' + ' '.join(egl_drivers) endif - lines += 'GBM: ' + (with_gbm ? 'yes' : 'no') if with_egl or with_any_vk - _platforms += 'surfaceless' -- if with_gbm -- _platforms += 'drm' +- if with_gbm and not with_platform_android + if not with_platform_tizen + _platforms += 'surfaceless' -+ if with_gbm -+ _platforms += 'drm' -+ endif ++ endif ++ if with_gbm and not with_platform_android and not with_platform_tizen + _platforms += 'drm' endif lines += 'EGL/Vulkan/VL platforms: ' + ' '.join(_platforms) - endif diff --git a/meson_options.txt b/meson_options.txt -index 6f001343ae6..b2ba2d8d979 100644 +index dac791099a1..8230db93c70 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -23,7 +23,7 @@ option( @@ -99,10 +97,10 @@ index 6f001343ae6..b2ba2d8d979 100644 description : 'window systems to support. If this is set to `auto`, all platforms applicable will be enabled.' ) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index a47589d929f..e9f745e4258 100644 +index dea5899b3a8..6d34395d65d 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -1208,6 +1208,11 @@ dri2_initialize(_EGLDisplay *disp) +@@ -1179,6 +1179,11 @@ dri2_initialize(_EGLDisplay *disp) case _EGL_PLATFORM_ANDROID: ret = dri2_initialize_android(disp); break; @@ -114,7 +112,7 @@ index a47589d929f..e9f745e4258 100644 default: unreachable("Callers ensure we cannot get here."); return EGL_FALSE; -@@ -1282,6 +1287,12 @@ dri2_display_destroy(_EGLDisplay *disp) +@@ -1253,6 +1258,12 @@ dri2_display_destroy(_EGLDisplay *disp) case _EGL_PLATFORM_WAYLAND: dri2_teardown_wayland(dri2_dpy); break; @@ -127,7 +125,7 @@ index a47589d929f..e9f745e4258 100644 default: /* TODO: add teardown for other platforms */ break; -@@ -2322,8 +2333,96 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2293,8 +2304,96 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, return dri2_create_image_from_dri(disp, dri_image); } @@ -225,7 +223,7 @@ index a47589d929f..e9f745e4258 100644 /* This structure describes how a wl_buffer maps to one or more * __DRIimages. A wl_drm_buffer stores the wl_drm format code and the * offsets and strides of the planes in the buffer. This table maps a -@@ -3216,6 +3315,10 @@ dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, +@@ -3193,6 +3292,10 @@ dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, #ifdef HAVE_WAYLAND_PLATFORM case EGL_WAYLAND_BUFFER_WL: return dri2_create_image_wayland_wl_buffer(disp, ctx, buffer, attr_list); @@ -236,7 +234,7 @@ index a47589d929f..e9f745e4258 100644 #endif case EGL_CL_IMAGE_IMG: return dri2_create_image_img_buffer(disp, ctx, target, buffer, attr_list); -@@ -3237,6 +3340,78 @@ dri2_destroy_image_khr(_EGLDisplay *disp, _EGLImage *image) +@@ -3214,6 +3317,78 @@ dri2_destroy_image_khr(_EGLDisplay *disp, _EGLImage *image) return EGL_TRUE; } @@ -315,7 +313,7 @@ index a47589d929f..e9f745e4258 100644 #ifdef HAVE_WAYLAND_PLATFORM static void -@@ -3767,6 +3942,11 @@ const _EGLDriver _eglDriver = { +@@ -3755,6 +3930,11 @@ const _EGLDriver _eglDriver = { .BindWaylandDisplayWL = dri2_bind_wayland_display_wl, .UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl, .QueryWaylandBufferWL = dri2_query_wayland_buffer_wl, @@ -328,10 +326,10 @@ index a47589d929f..e9f745e4258 100644 .GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium, .CreateSyncKHR = dri2_create_sync, diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index d7f9696da93..4d66936da28 100644 +index 6a7eedea112..a8bfe45b1f5 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -62,13 +62,19 @@ struct zwp_linux_dmabuf_v1; +@@ -62,9 +62,9 @@ struct zwp_linux_dmabuf_v1; #include #endif @@ -339,8 +337,11 @@ index d7f9696da93..4d66936da28 100644 #define LOG_TAG "EGL-DRI2" +#ifdef HAVE_ANDROID_PLATFORM - #include #include + + #if ANDROID_API_LEVEL >= 26 +@@ -75,6 +75,12 @@ struct zwp_linux_dmabuf_v1; + #endif /* HAVE_ANDROID_PLATFORM */ +#ifdef HAVE_TIZEN_PLATFORM @@ -352,7 +353,7 @@ index d7f9696da93..4d66936da28 100644 #include "eglconfig.h" #include "eglcontext.h" #include "egldevice.h" -@@ -251,6 +257,10 @@ struct dri2_egl_display +@@ -259,6 +265,10 @@ struct dri2_egl_display bool is_render_node; bool is_different_gpu; @@ -363,7 +364,7 @@ index d7f9696da93..4d66936da28 100644 }; struct dri2_egl_context -@@ -268,6 +278,18 @@ enum wayland_buffer_type { +@@ -276,6 +286,18 @@ enum wayland_buffer_type { }; #endif @@ -382,7 +383,7 @@ index d7f9696da93..4d66936da28 100644 struct dri2_egl_surface { _EGLSurface base; -@@ -300,15 +322,33 @@ struct dri2_egl_surface +@@ -308,15 +330,33 @@ struct dri2_egl_surface struct gbm_dri_surface *gbm_surf; #endif @@ -418,7 +419,7 @@ index d7f9696da93..4d66936da28 100644 /* for is_different_gpu case. NULL else */ __DRIimage *linear_copy; /* for swrast */ -@@ -317,6 +357,9 @@ struct dri2_egl_surface +@@ -325,6 +365,9 @@ struct dri2_egl_surface #endif #ifdef HAVE_DRM_PLATFORM struct gbm_bo *bo; @@ -428,7 +429,7 @@ index d7f9696da93..4d66936da28 100644 #endif bool locked; int age; -@@ -516,6 +559,11 @@ dri2_initialize_android(_EGLDisplay *disp) +@@ -525,6 +568,11 @@ dri2_initialize_android(_EGLDisplay *disp) EGLBoolean dri2_initialize_surfaceless(_EGLDisplay *disp); @@ -440,7 +441,7 @@ index d7f9696da93..4d66936da28 100644 EGLBoolean dri2_initialize_device(_EGLDisplay *disp); static inline void -@@ -550,6 +598,11 @@ dri2_set_WL_bind_wayland_display(_EGLDisplay *disp) +@@ -559,6 +607,11 @@ dri2_set_WL_bind_wayland_display(_EGLDisplay *disp) #endif } @@ -1439,7 +1440,7 @@ index 00000000000..a08bc8c07bf + return EGL_FALSE; +} diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index bc7014ef8ed..4c29eedb684 100644 +index 234449adf64..43c7b917909 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -416,6 +416,13 @@ _eglGetPlatformDisplayCommon(EGLenum platform, void *native_display, @@ -1606,21 +1607,19 @@ index 6a91952577f..973b7600ab1 100644 diff --git a/src/egl/meson.build b/src/egl/meson.build -index 599a66706b7..17e9c690b82 100644 +index ab8f4e1fdbe..5749ec88f89 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build -@@ -106,7 +106,9 @@ if with_dri2 +@@ -106,7 +106,7 @@ if with_dri2 + endif deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes] endif - if with_gbm -- files_egl += files('drivers/dri2/platform_drm.c') -+ if not with_platform_tizen -+ files_egl += files('drivers/dri2/platform_drm.c') -+ endif +- if with_gbm and not with_platform_android ++ if with_gbm and not with_platform_android and not with_platform_tizen + files_egl += files('drivers/dri2/platform_drm.c') link_for_egl += libgbm incs_for_egl += [inc_gbm, include_directories('../gbm/main')] - deps_for_egl += dep_libdrm -@@ -135,6 +137,11 @@ elif with_platform_haiku +@@ -141,6 +141,11 @@ elif with_platform_haiku link_for_egl += libgl deps_for_egl += cpp.find_library('be') endif @@ -1633,5 +1632,5 @@ index 599a66706b7..17e9c690b82 100644 if cc.has_function('mincore') c_args_for_egl += '-DHAVE_MINCORE' -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0019-egl-add-support-for-EGL_TIZEN_image_native_surface.patch b/package/mesa3d/0019-egl-add-support-for-EGL_TIZEN_image_native_surface.patch index d97623c9..f58ea5fd 100644 --- a/package/mesa3d/0019-egl-add-support-for-EGL_TIZEN_image_native_surface.patch +++ b/package/mesa3d/0019-egl-add-support-for-EGL_TIZEN_image_native_surface.patch @@ -1,7 +1,7 @@ -From 072528e4c6b37df46499a87478f535f6235ffde5 Mon Sep 17 00:00:00 2001 +From 230a8cb550dc23a46a96b1852720c262bb244665 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Mon, 6 Feb 2017 15:54:00 +0000 -Subject: [PATCH 20/50] egl: add support for EGL_TIZEN_image_native_surface +Subject: [PATCH 19/67] egl: add support for EGL_TIZEN_image_native_surface --- src/egl/drivers/dri2/egl_dri2.c | 127 ++++++++++++++++++++------ @@ -11,7 +11,7 @@ Subject: [PATCH 20/50] egl: add support for EGL_TIZEN_image_native_surface 4 files changed, 102 insertions(+), 30 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index e9f745e4258..04e05567acb 100644 +index 6d34395d65d..eaa0baed066 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -58,6 +58,10 @@ @@ -25,7 +25,7 @@ index e9f745e4258..04e05567acb 100644 #include "egldefines.h" #include "egl_dri2.h" #include "GL/mesa_glinterop.h" -@@ -2340,28 +2344,115 @@ dri2_fourcc_from_tbm_format(tbm_format format) +@@ -2311,28 +2315,115 @@ dri2_fourcc_from_tbm_format(tbm_format format) switch (format) { case TBM_FORMAT_ARGB8888: return DRM_FORMAT_ARGB8888; @@ -144,7 +144,7 @@ index e9f745e4258..04e05567acb 100644 tbm_surf = tpl_display_get_buffer_from_native_pixmap(dri2_dpy->tpl_dpy, (tpl_handle_t) _buffer); -@@ -2392,33 +2483,7 @@ dri2_create_image_wayland_wl_buffer_tizen(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2363,33 +2454,7 @@ dri2_create_image_wayland_wl_buffer_tizen(_EGLDisplay *disp, _EGLContext *ctx, return NULL; } @@ -179,7 +179,7 @@ index e9f745e4258..04e05567acb 100644 } #endif -@@ -3319,6 +3384,8 @@ dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, +@@ -3296,6 +3361,8 @@ dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, #ifdef HAVE_TIZEN_PLATFORM case EGL_WAYLAND_BUFFER_WL: return dri2_create_image_wayland_wl_buffer_tizen(disp, ctx, buffer, attr_list); @@ -201,7 +201,7 @@ index a08bc8c07bf..ad75c115d7e 100644 /* * Fill vtbl last to prevent accidentally calling virtual function during diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index 4c29eedb684..c4dcc015941 100644 +index 43c7b917909..e2a7797d73e 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -553,6 +553,8 @@ _eglCreateExtensionsString(_EGLDisplay *disp) @@ -227,5 +227,5 @@ index cbb098331bf..0a7366b7c07 100644 EGLBoolean WL_create_wayland_buffer_from_image; -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0020-egl-wayland-post-maximum-damage-when-blitting.patch b/package/mesa3d/0020-egl-wayland-post-maximum-damage-when-blitting.patch index 7fb85079..8d610aa6 100644 --- a/package/mesa3d/0020-egl-wayland-post-maximum-damage-when-blitting.patch +++ b/package/mesa3d/0020-egl-wayland-post-maximum-damage-when-blitting.patch @@ -1,7 +1,7 @@ -From 66118837ec11358ea86373c343c147e9659c19b8 Mon Sep 17 00:00:00 2001 +From 54d08798efca8f8929744a238e2b8b2851083317 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Wed, 8 Nov 2017 15:15:20 +0000 -Subject: [PATCH 21/50] egl/wayland: post maximum damage when blitting +Subject: [PATCH 20/67] egl/wayland: post maximum damage when blitting When blitting, as part of the "is_different_gpu" case when swapping buffers, the blit is done using the full surface dimensions, ignoring @@ -15,10 +15,10 @@ when the number of damage rectangles is 1. 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c -index 6eb2c7cbdf6..b76c63f1439 100644 +index c18edc0de4e..c2e428769fe 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c -@@ -1121,7 +1121,8 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, +@@ -1112,7 +1112,8 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, /* If the compositor doesn't support damage_buffer, we deliberately * ignore the damage region and post maximum damage, due to * https://bugs.freedesktop.org/78190 */ @@ -29,5 +29,5 @@ index 6eb2c7cbdf6..b76c63f1439 100644 0, 0, INT32_MAX, INT32_MAX); -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0021-egl-wayland-flush-the-drawable-before-blitting.patch b/package/mesa3d/0021-egl-wayland-flush-the-drawable-before-blitting.patch index c8d24560..a7801055 100644 --- a/package/mesa3d/0021-egl-wayland-flush-the-drawable-before-blitting.patch +++ b/package/mesa3d/0021-egl-wayland-flush-the-drawable-before-blitting.patch @@ -1,7 +1,7 @@ -From d9235705f0c6ff56712577670f9b174f02400f5f Mon Sep 17 00:00:00 2001 +From a6aa5c866c25f7f334afbbcc3835467d50eb8965 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Wed, 8 Nov 2017 15:26:25 +0000 -Subject: [PATCH 22/50] egl/wayland: flush the drawable before blitting +Subject: [PATCH 21/67] egl/wayland: flush the drawable before blitting Flush the drawable before blitting in the "is_different_gpu" case when swapping buffers, and pass the flush flag to the blitImage call. The @@ -17,10 +17,10 @@ invalid. 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c -index b76c63f1439..3e6456234fe 100644 +index c2e428769fe..811d28bd669 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c -@@ -1126,6 +1126,8 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, +@@ -1117,6 +1117,8 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, wl_surface_damage(dri2_surf->wl_surface_wrapper, 0, 0, INT32_MAX, INT32_MAX); @@ -29,7 +29,7 @@ index b76c63f1439..3e6456234fe 100644 if (dri2_dpy->is_different_gpu) { _EGLContext *ctx = _eglGetCurrentContext(); struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); -@@ -1135,10 +1137,9 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, +@@ -1126,10 +1128,9 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, 0, 0, dri2_surf->base.Width, dri2_surf->base.Height, 0, 0, dri2_surf->base.Width, @@ -42,5 +42,5 @@ index b76c63f1439..3e6456234fe 100644 wl_surface_commit(dri2_surf->wl_surface_wrapper); -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0022-egl-tizen-create-an-internal-_EGLImage-for-each-tbm-.patch b/package/mesa3d/0022-egl-tizen-create-an-internal-_EGLImage-for-each-tbm-.patch index 900bf338..83c95116 100644 --- a/package/mesa3d/0022-egl-tizen-create-an-internal-_EGLImage-for-each-tbm-.patch +++ b/package/mesa3d/0022-egl-tizen-create-an-internal-_EGLImage-for-each-tbm-.patch @@ -1,7 +1,7 @@ -From 201283a29b24ebff36b1616809c55c71eaf549ea Mon Sep 17 00:00:00 2001 +From 404c0e915de381c2337c79657f80b0aa95c1c995 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Wed, 25 Oct 2017 18:15:00 +0100 -Subject: [PATCH 23/50] egl/tizen: create an internal _EGLImage for each tbm +Subject: [PATCH 22/67] egl/tizen: create an internal _EGLImage for each tbm surface Create an internal _EGLImage the first time a tbm surface is seen @@ -16,10 +16,10 @@ then unmapped from the GPU. 3 files changed, 251 insertions(+), 3 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index 04e05567acb..69da031fa00 100644 +index eaa0baed066..db993f8f059 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -1293,6 +1293,10 @@ dri2_display_destroy(_EGLDisplay *disp) +@@ -1264,6 +1264,10 @@ dri2_display_destroy(_EGLDisplay *disp) break; #ifdef HAVE_TIZEN_PLATFORM case _EGL_PLATFORM_TIZEN: @@ -30,7 +30,7 @@ index 04e05567acb..69da031fa00 100644 if (dri2_dpy->tpl_dpy) tpl_object_unreference((tpl_object_t *) dri2_dpy->tpl_dpy); break; -@@ -1349,6 +1353,60 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf) +@@ -1320,6 +1324,60 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf) } } @@ -91,7 +91,7 @@ index 04e05567acb..69da031fa00 100644 /** * Called via eglTerminate(), drv->Terminate(). * -@@ -1361,6 +1419,8 @@ dri2_terminate(_EGLDisplay *disp) +@@ -1332,6 +1390,8 @@ dri2_terminate(_EGLDisplay *disp) /* Release all non-current Context/Surfaces. */ _eglReleaseDisplayResources(disp); @@ -100,7 +100,7 @@ index 04e05567acb..69da031fa00 100644 dri2_display_release(disp); return EGL_TRUE; -@@ -2338,6 +2398,9 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2309,6 +2369,9 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, } #ifdef HAVE_TIZEN_PLATFORM @@ -110,7 +110,7 @@ index 04e05567acb..69da031fa00 100644 int dri2_fourcc_from_tbm_format(tbm_format format) { -@@ -2434,14 +2497,145 @@ fail_close: +@@ -2405,14 +2468,145 @@ fail_close: return NULL; } @@ -258,7 +258,7 @@ index 04e05567acb..69da031fa00 100644 } static _EGLImage * -@@ -2453,6 +2647,9 @@ dri2_create_image_wayland_wl_buffer_tizen(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2424,6 +2618,9 @@ dri2_create_image_wayland_wl_buffer_tizen(_EGLDisplay *disp, _EGLContext *ctx, _EGLImageAttribs attrs; tbm_surface_h tbm_surf; tbm_surface_info_s info; @@ -268,7 +268,7 @@ index 04e05567acb..69da031fa00 100644 tbm_surf = tpl_display_get_buffer_from_native_pixmap(dri2_dpy->tpl_dpy, (tpl_handle_t) _buffer); -@@ -2483,7 +2680,21 @@ dri2_create_image_wayland_wl_buffer_tizen(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2454,7 +2651,21 @@ dri2_create_image_wayland_wl_buffer_tizen(_EGLDisplay *disp, _EGLContext *ctx, return NULL; } @@ -291,7 +291,7 @@ index 04e05567acb..69da031fa00 100644 } #endif -@@ -3400,10 +3611,29 @@ dri2_destroy_image_khr(_EGLDisplay *disp, _EGLImage *image) +@@ -3377,10 +3588,29 @@ dri2_destroy_image_khr(_EGLDisplay *disp, _EGLImage *image) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img = dri2_egl_image(image); @@ -322,10 +322,10 @@ index 04e05567acb..69da031fa00 100644 } diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index 4d66936da28..e516c54810d 100644 +index a8bfe45b1f5..546bc0a0dbc 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -260,6 +260,15 @@ struct dri2_egl_display +@@ -268,6 +268,15 @@ struct dri2_egl_display #ifdef HAVE_TIZEN_PLATFORM tpl_display_t *tpl_dpy; @@ -341,7 +341,7 @@ index 4d66936da28..e516c54810d 100644 #endif }; -@@ -404,6 +413,9 @@ struct dri2_egl_image +@@ -413,6 +422,9 @@ struct dri2_egl_image { _EGLImage base; __DRIimage *dri_image; @@ -376,5 +376,5 @@ index ad75c115d7e..49462152beb 100644 char *render_path; -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0023-dri-use-a-supported-API-in-driCreateNewContext.patch b/package/mesa3d/0023-dri-use-a-supported-API-in-driCreateNewContext.patch index b27fbef5..141b0176 100644 --- a/package/mesa3d/0023-dri-use-a-supported-API-in-driCreateNewContext.patch +++ b/package/mesa3d/0023-dri-use-a-supported-API-in-driCreateNewContext.patch @@ -1,7 +1,7 @@ -From b9cce4ff02e66d6db913cd10352af61d3d81d9ad Mon Sep 17 00:00:00 2001 +From 1f4a1a21384b00e28b8a9dd2c29f9c261f201c6f Mon Sep 17 00:00:00 2001 From: Brendan King Date: Thu, 23 Nov 2017 15:50:21 +0000 -Subject: [PATCH 24/50] dri: use a supported API in driCreateNewContext +Subject: [PATCH 23/67] dri: use a supported API in driCreateNewContext Don't assume the screen supports OpenGL when creating a new context, use an API that the screen supports. @@ -50,5 +50,5 @@ index caed5fa6a68..6c45eb007fc 100644 } -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0024-gbm-add-gbm_bo_blit.patch b/package/mesa3d/0024-gbm-add-gbm_bo_blit.patch index a8562ef4..82e1c442 100644 --- a/package/mesa3d/0024-gbm-add-gbm_bo_blit.patch +++ b/package/mesa3d/0024-gbm-add-gbm_bo_blit.patch @@ -1,22 +1,23 @@ -From 7b733f4e2b20614d9f367186810c4fcac4aa820c Mon Sep 17 00:00:00 2001 +From 0751612b949f1c90338a14453ff7fa4be8bfd016 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Tue, 28 Nov 2017 16:27:38 +0000 -Subject: [PATCH 25/50] gbm: add gbm_bo_blit +Subject: [PATCH 24/67] gbm: add gbm_bo_blit For the GBM DRI backend, gbm_bo_blit is a wrapper around blitImage in the DRI Image extension. --- - src/gbm/backends/dri/gbm_dri.c | 32 ++++++++++++++++++++++++++++++++ - src/gbm/main/gbm.c | 28 ++++++++++++++++++++++++++++ + src/gbm/backends/dri/gbm_dri.c | 33 +++++++++++++++++++++++++++++++++ + src/gbm/main/gbm.c | 31 +++++++++++++++++++++++++++++++ src/gbm/main/gbm.h | 21 +++++++++++++++++++++ - src/gbm/main/gbmint.h | 4 ++++ - 4 files changed, 85 insertions(+) + src/gbm/main/gbm_abi_check.c | 20 +++++++++++++++++++- + src/gbm/main/gbm_backend_abi.h | 10 +++++++++- + 5 files changed, 113 insertions(+), 2 deletions(-) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c -index b5634741554..ca865f4df9c 100644 +index 96fa9217255..bd8a80cdecf 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c -@@ -1334,6 +1334,37 @@ gbm_dri_surface_destroy(struct gbm_surface *_surf) +@@ -1355,6 +1355,37 @@ gbm_dri_surface_destroy(struct gbm_surface *_surf) free(surf); } @@ -54,23 +55,23 @@ index b5634741554..ca865f4df9c 100644 static void dri_destroy(struct gbm_device *gbm) { -@@ -1383,6 +1414,7 @@ dri_device_create(int fd) - dri->base.destroy = dri_destroy; - dri->base.surface_create = gbm_dri_surface_create; - dri->base.surface_destroy = gbm_dri_surface_destroy; -+ dri->base.bo_blit = gbm_dri_bo_blit; +@@ -1416,6 +1447,8 @@ dri_device_create(int fd, uint32_t gbm_backend_version) - dri->base.name = "drm"; + dri->base.v0.name = "drm"; + ++ dri->base.v1.bo_blit = gbm_dri_bo_blit; ++ + dri->visual_table = gbm_dri_visuals_table; + dri->num_visuals = ARRAY_SIZE(gbm_dri_visuals_table); diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c -index 954b3c35b0d..78de34286bd 100644 +index d81931a7483..e2351d34ad8 100644 --- a/src/gbm/main/gbm.c +++ b/src/gbm/main/gbm.c -@@ -741,3 +741,31 @@ gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc) - +@@ -758,6 +758,37 @@ gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc) return desc->name; } -+ + +/** + * Blit from one buffer object to another + * @@ -93,13 +94,20 @@ index 954b3c35b0d..78de34286bd 100644 + int src_x0, int src_y0, int src_width, int src_height, + enum gbm_blit_flags flags) +{ -+ return dst_bo->gbm->bo_blit(dst_bo, src_bo, -+ dst_x0, dst_y0, dst_width, dst_height, -+ src_x0, src_y0, src_width, src_height, -+ flags); ++ if (dst_bo->gbm->v0.backend_version >= 1) ++ return dst_bo->gbm->v1.bo_blit(dst_bo, src_bo, ++ dst_x0, dst_y0, dst_width, dst_height, ++ src_x0, src_y0, src_width, src_height, ++ flags); ++ else ++ return 0; +} ++ + /** + * A global table of functions and global variables defined in the core GBM + * code that need to be accessed directly by GBM backends. diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h -index 5801cd526a0..e754edd5654 100644 +index 3a0fe73faae..7c82cd661a3 100644 --- a/src/gbm/main/gbm.h +++ b/src/gbm/main/gbm.h @@ -246,6 +246,21 @@ enum gbm_bo_flags { @@ -124,7 +132,7 @@ index 5801cd526a0..e754edd5654 100644 int gbm_device_get_fd(struct gbm_device *gbm); -@@ -422,6 +437,12 @@ gbm_surface_destroy(struct gbm_surface *surface); +@@ -425,6 +440,12 @@ gbm_surface_destroy(struct gbm_surface *surface); char * gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc); @@ -137,21 +145,80 @@ index 5801cd526a0..e754edd5654 100644 #ifdef __cplusplus } #endif -diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h -index 192577431e2..fb95954ab32 100644 ---- a/src/gbm/main/gbmint.h -+++ b/src/gbm/main/gbmint.h -@@ -98,6 +98,10 @@ struct gbm_device { - struct gbm_bo *bo); - int (*surface_has_free_buffers)(struct gbm_surface *surface); - void (*surface_destroy)(struct gbm_surface *surface); +diff --git a/src/gbm/main/gbm_abi_check.c b/src/gbm/main/gbm_abi_check.c +index f1137be7baf..02ce23b129e 100644 +--- a/src/gbm/main/gbm_abi_check.c ++++ b/src/gbm/main/gbm_abi_check.c +@@ -101,6 +101,21 @@ struct gbm_device_abi0 { + struct gbm_device_v0_abi0 v0; + }; + ++#define GBM_BACKEND_ABI_VERSION_abi1 1 ++struct gbm_device_v1_abi1 { + int (*bo_blit)(struct gbm_bo *dst_bo, struct gbm_bo *src_bo, + int dst_x0, int dst_y0, int dst_width, int dst_height, + int src_x0, int src_y0, int src_width, int src_height, + enum gbm_blit_flags flags); ++}; ++ ++struct gbm_device_abi1 { ++ /* Hack to make a gbm_device detectable by its first element. */ ++ struct gbm_device *(*dummy)(int); ++ struct gbm_device_v0_abi0 v0; ++ struct gbm_device_v1_abi1 v1; ++}; ++ + /** + * GBM buffer object interface corresponding to GBM_BACKEND_ABI_VERSION = 0 + * +@@ -359,8 +374,11 @@ int main(int argc, char **argv) + CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, surface_has_free_buffers); + CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, surface_destroy); + ++ CHECK_MEMBER_CURRENT(gbm_device_v1, _abi1, bo_blit); ++ + /* Size of ABI-versioned substructures verified by above member checks */ +- CHECK_SIZE_CURRENT (gbm_device, _abi0); ++ CHECK_SIZE (gbm_device, _abi0, _abi1); ++ CHECK_SIZE_CURRENT (gbm_device, _abi1); + + + /* Check current gbm_bo ABI against gbm_bo_abi0*/ +diff --git a/src/gbm/main/gbm_backend_abi.h b/src/gbm/main/gbm_backend_abi.h +index 962ee74f003..3abf29faa92 100644 +--- a/src/gbm/main/gbm_backend_abi.h ++++ b/src/gbm/main/gbm_backend_abi.h +@@ -72,7 +72,7 @@ struct gbm_backend_desc; + * Core ABI version: 4 + * ABI version of a buffer object created by a device from the backend: 4 + */ +-#define GBM_BACKEND_ABI_VERSION 0 ++#define GBM_BACKEND_ABI_VERSION 1 + + /** + * GBM device interface corresponding to GBM_BACKEND_ABI_VERSION = 0 +@@ -149,6 +149,13 @@ struct gbm_device_v0 { + void (*surface_destroy)(struct gbm_surface *surface); + }; + ++struct gbm_device_v1 { ++ int (*bo_blit)(struct gbm_bo *dst_bo, struct gbm_bo *src_bo, ++ int dst_x0, int dst_y0, int dst_width, int dst_height, ++ int src_x0, int src_y0, int src_width, int src_height, ++ enum gbm_blit_flags flags); ++}; ++ + /** + * The device used for the memory allocation. + * +@@ -161,6 +168,7 @@ struct gbm_device { + /* Hack to make a gbm_device detectable by its first element. */ + struct gbm_device *(*dummy)(int); + struct gbm_device_v0 v0; ++ struct gbm_device_v1 v1; }; /** -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0025-gbm-don-t-assert-if-DRI-context-creation-fails.patch b/package/mesa3d/0025-gbm-don-t-assert-if-DRI-context-creation-fails.patch index 7eae75be..cac3a056 100644 --- a/package/mesa3d/0025-gbm-don-t-assert-if-DRI-context-creation-fails.patch +++ b/package/mesa3d/0025-gbm-don-t-assert-if-DRI-context-creation-fails.patch @@ -1,7 +1,7 @@ -From 5ed87bbc92b8034b14060d5170c3d82bfce54fb7 Mon Sep 17 00:00:00 2001 +From dbe611e4cb6f0dddc05ead03f0341274a6b018c8 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Fri, 1 Dec 2017 08:31:15 +0000 -Subject: [PATCH 26/50] gbm: don't assert if DRI context creation fails +Subject: [PATCH 25/67] gbm: don't assert if DRI context creation fails If the DRI backend fails to create a DRI context, return an error, rather than asserting. @@ -10,10 +10,10 @@ rather than asserting. 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c -index ca865f4df9c..f9adbc5c001 100644 +index bd8a80cdecf..2aa9c7c41ad 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c -@@ -1224,8 +1224,11 @@ gbm_dri_bo_map(struct gbm_bo *_bo, +@@ -1245,8 +1245,11 @@ gbm_dri_bo_map(struct gbm_bo *_bo, if (!dri->context) dri->context = dri->dri2->createNewContext(dri->screen, NULL, NULL, NULL); @@ -26,7 +26,7 @@ index ca865f4df9c..f9adbc5c001 100644 /* GBM flags and DRI flags are the same, so just pass them on */ return dri->image->mapImage(dri->context, bo->image, x, y, -@@ -1353,8 +1356,11 @@ gbm_dri_bo_blit(struct gbm_bo *_dst_bo, struct gbm_bo *_src_bo, +@@ -1374,8 +1377,11 @@ gbm_dri_bo_blit(struct gbm_bo *_dst_bo, struct gbm_bo *_src_bo, if (!dri->context) dri->context = dri->dri2->createNewContext(dri->screen, NULL, NULL, NULL); @@ -40,5 +40,5 @@ index ca865f4df9c..f9adbc5c001 100644 /* GBM flags and DRI flags are the same, so just pass them on */ dri->image->blitImage(dri->context, dst_bo->image, src_bo->image, -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0026-egl-wayland-add-pbuffer-support.patch b/package/mesa3d/0026-egl-wayland-add-pbuffer-support.patch index c8ee0943..1bbc6beb 100644 --- a/package/mesa3d/0026-egl-wayland-add-pbuffer-support.patch +++ b/package/mesa3d/0026-egl-wayland-add-pbuffer-support.patch @@ -1,7 +1,7 @@ -From daf743a8fdc7171dea73c390e3255b5c6e19046c Mon Sep 17 00:00:00 2001 +From f16ea577ee06375423198dced8231d04e94536af Mon Sep 17 00:00:00 2001 From: Brendan King Date: Fri, 17 Mar 2017 16:23:07 +0000 -Subject: [PATCH 27/50] egl/wayland: add pbuffer support +Subject: [PATCH 26/67] egl/wayland: add pbuffer support The pbuffer code is based on that in the Surfaceless platform code. --- @@ -10,10 +10,10 @@ The pbuffer code is based on that in the Surfaceless platform code. 2 files changed, 236 insertions(+), 38 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index e516c54810d..a33d87b23c1 100644 +index 546bc0a0dbc..f41f32cd234 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -396,6 +396,10 @@ struct dri2_egl_surface +@@ -405,6 +405,10 @@ struct dri2_egl_surface __DRIimage *front; unsigned int visual; @@ -25,10 +25,10 @@ index e516c54810d..a33d87b23c1 100644 EGLBoolean enable_out_fence; diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c -index 3e6456234fe..43ad6420174 100644 +index 811d28bd669..a096d9500c1 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c -@@ -416,6 +416,99 @@ dri2_wl_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf, +@@ -427,6 +427,99 @@ dri2_wl_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf, return NULL; } @@ -128,7 +128,7 @@ index 3e6456234fe..43ad6420174 100644 /** * Called via eglDestroySurface(), drv->DestroySurface(). */ -@@ -442,6 +535,9 @@ dri2_wl_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) +@@ -453,6 +546,9 @@ dri2_wl_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) if (dri2_dpy->dri2) dri2_egl_surface_free_local_buffers(dri2_surf); @@ -138,7 +138,7 @@ index 3e6456234fe..43ad6420174 100644 if (dri2_surf->throttle_callback) wl_callback_destroy(dri2_surf->throttle_callback); -@@ -451,11 +547,14 @@ dri2_wl_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) +@@ -462,11 +558,14 @@ dri2_wl_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) dri2_surf->wl_win->destroy_window_callback = NULL; } @@ -156,7 +156,7 @@ index 3e6456234fe..43ad6420174 100644 dri2_fini_surface(surf); free(surf); -@@ -642,20 +741,16 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) +@@ -628,20 +727,16 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) static void @@ -180,7 +180,7 @@ index 3e6456234fe..43ad6420174 100644 buffer->name = name; buffer->pitch = pitch; buffer->flags = 0; -@@ -670,12 +765,28 @@ back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer) +@@ -656,12 +751,28 @@ back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer) } } @@ -196,7 +196,7 @@ index 3e6456234fe..43ad6420174 100644 + bo_to_dri_buffer(dri2_dpy, __DRI_BUFFER_BACK_LEFT, + dri2_surf->back->dri_image, buffer); +} - ++ +static void +front_bo_to_dri_buffer(struct dri2_egl_display *dri2_dpy, + struct dri2_egl_surface *dri2_surf, @@ -205,15 +205,15 @@ index 3e6456234fe..43ad6420174 100644 + bo_to_dri_buffer(dri2_dpy, __DRI_BUFFER_FRONT_LEFT, + dri2_surf->front, buffer); +} -+ + +static int +update_buffers(struct dri2_egl_display *dri2_dpy, + struct dri2_egl_surface *dri2_surf) +{ - if (dri2_surf->base.Width != dri2_surf->wl_win->width || - dri2_surf->base.Height != dri2_surf->wl_win->height) { - -@@ -715,12 +826,13 @@ update_buffers(struct dri2_egl_surface *dri2_surf) + if (dri2_surf->wl_win && + (dri2_surf->base.Width != dri2_surf->wl_win->width || + dri2_surf->base.Height != dri2_surf->wl_win->height)) { +@@ -703,12 +814,13 @@ update_buffers(struct dri2_egl_surface *dri2_surf) } static int @@ -229,7 +229,7 @@ index 3e6456234fe..43ad6420174 100644 } static __DRIbuffer * -@@ -730,17 +842,25 @@ dri2_wl_get_buffers_with_format(__DRIdrawable * driDrawable, +@@ -718,17 +830,25 @@ dri2_wl_get_buffers_with_format(__DRIdrawable * driDrawable, int *out_count, void *loaderPrivate) { struct dri2_egl_surface *dri2_surf = loaderPrivate; @@ -259,7 +259,7 @@ index 3e6456234fe..43ad6420174 100644 break; default: local = dri2_egl_surface_alloc_local_buffer(dri2_surf, attachments[i], -@@ -810,12 +930,30 @@ image_get_buffers(__DRIdrawable *driDrawable, +@@ -798,12 +918,30 @@ image_get_buffers(__DRIdrawable *driDrawable, struct __DRIimageList *buffers) { struct dri2_egl_surface *dri2_surf = loaderPrivate; @@ -276,13 +276,13 @@ index 3e6456234fe..43ad6420174 100644 + { + if (update_buffers(dri2_dpy, dri2_surf) < 0) + return 0; -+ -+ buffers->image_mask |= __DRI_IMAGE_BUFFER_BACK; -+ buffers->back = dri2_surf->back->dri_image; -+ } - buffers->image_mask = __DRI_IMAGE_BUFFER_BACK; - buffers->back = dri2_surf->back->dri_image; ++ buffers->image_mask |= __DRI_IMAGE_BUFFER_BACK; ++ buffers->back = dri2_surf->back->dri_image; ++ } ++ + if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) + { + if (allocate_front_buffer(dri2_dpy, dri2_surf, EGL_FALSE) < 0) @@ -294,17 +294,17 @@ index 3e6456234fe..43ad6420174 100644 return 1; } -@@ -1066,6 +1204,9 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, +@@ -1054,6 +1192,9 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); + if (draw->Type != EGL_WINDOW_BIT) + return EGL_TRUE; + - while (dri2_surf->throttle_callback != NULL) - if (wl_display_dispatch_queue(dri2_dpy->wl_dpy, - dri2_surf->wl_queue) == -1) -@@ -1077,7 +1218,7 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, + if (!dri2_surf->wl_win) + return _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_swap_buffers"); + +@@ -1068,7 +1209,7 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, /* Make sure we have a back buffer in case we're swapping without ever * rendering. */ @@ -313,7 +313,7 @@ index 3e6456234fe..43ad6420174 100644 return _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers"); if (draw->SwapInterval > 0) { -@@ -1162,9 +1303,13 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, +@@ -1153,9 +1294,13 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp, static EGLint dri2_wl_query_buffer_age(_EGLDisplay *disp, _EGLSurface *surface) { @@ -328,7 +328,7 @@ index 3e6456234fe..43ad6420174 100644 _eglError(EGL_BAD_ALLOC, "dri2_query_buffer_age"); return -1; } -@@ -1385,6 +1530,7 @@ static const struct dri2_egl_display_vtbl dri2_wl_display_vtbl = { +@@ -1376,6 +1521,7 @@ static const struct dri2_egl_display_vtbl dri2_wl_display_vtbl = { .authenticate = dri2_wl_authenticate, .create_window_surface = dri2_wl_create_window_surface, .create_pixmap_surface = dri2_wl_create_pixmap_surface, @@ -336,7 +336,7 @@ index 3e6456234fe..43ad6420174 100644 .destroy_surface = dri2_wl_destroy_surface, .create_image = dri2_create_image_khr, .swap_buffers = dri2_wl_swap_buffers, -@@ -1427,7 +1573,7 @@ dri2_wl_add_configs_for_visuals(_EGLDisplay *disp) +@@ -1418,7 +1564,7 @@ dri2_wl_add_configs_for_visuals(_EGLDisplay *disp) continue; dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i], @@ -345,7 +345,7 @@ index 3e6456234fe..43ad6420174 100644 if (dri2_conf) { if (dri2_conf->base.ConfigID == count + 1) count++; -@@ -1662,6 +1808,23 @@ dri2_wl_swrast_get_stride_for_format(int format, int w) +@@ -1654,6 +1800,23 @@ dri2_wl_swrast_get_stride_for_format(int format, int w) return w * (dri2_wl_visuals[visual_idx].bpp / 8); } @@ -369,7 +369,7 @@ index 3e6456234fe..43ad6420174 100644 static EGLBoolean dri2_wl_swrast_allocate_buffer(struct dri2_egl_surface *dri2_surf, int format, int w, int h, -@@ -1782,8 +1945,24 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf) +@@ -1775,8 +1938,24 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf) return 0; } @@ -395,7 +395,7 @@ index 3e6456234fe..43ad6420174 100644 { /* if there has been a resize: */ if (!dri2_surf->current) -@@ -1853,7 +2032,9 @@ dri2_wl_swrast_get_drawable_info(__DRIdrawable * draw, +@@ -1846,7 +2025,9 @@ dri2_wl_swrast_get_drawable_info(__DRIdrawable * draw, { struct dri2_egl_surface *dri2_surf = loaderPrivate; @@ -406,7 +406,7 @@ index 3e6456234fe..43ad6420174 100644 *x = 0; *y = 0; *w = dri2_surf->base.Width; -@@ -1872,7 +2053,11 @@ dri2_wl_swrast_get_image(__DRIdrawable * read, +@@ -1865,7 +2046,11 @@ dri2_wl_swrast_get_image(__DRIdrawable * read, int dst_stride = copy_width; char *src, *dst; @@ -419,7 +419,7 @@ index 3e6456234fe..43ad6420174 100644 if (!src) { memset(data, 0, copy_width * h); return; -@@ -1910,14 +2095,20 @@ dri2_wl_swrast_put_image2(__DRIdrawable * draw, int op, +@@ -1903,14 +2088,20 @@ dri2_wl_swrast_put_image2(__DRIdrawable * draw, int op, assert(copy_width <= stride); @@ -447,7 +447,7 @@ index 3e6456234fe..43ad6420174 100644 dst += x_offset; dst += y * dst_stride; -@@ -1935,7 +2126,9 @@ dri2_wl_swrast_put_image2(__DRIdrawable * draw, int op, +@@ -1928,7 +2119,9 @@ dri2_wl_swrast_put_image2(__DRIdrawable * draw, int op, src += stride; dst += dst_stride; } @@ -458,7 +458,7 @@ index 3e6456234fe..43ad6420174 100644 } static void -@@ -2000,6 +2193,7 @@ static const struct dri2_egl_display_vtbl dri2_wl_swrast_display_vtbl = { +@@ -1996,6 +2189,7 @@ static const struct dri2_egl_display_vtbl dri2_wl_swrast_display_vtbl = { .authenticate = NULL, .create_window_surface = dri2_wl_create_window_surface, .create_pixmap_surface = dri2_wl_create_pixmap_surface, @@ -467,5 +467,5 @@ index 3e6456234fe..43ad6420174 100644 .create_image = dri2_create_image_khr, .swap_buffers = dri2_wl_swrast_swap_buffers, -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0027-egl-tizen-support-DRI-driver-handling-of-swap-preser.patch b/package/mesa3d/0027-egl-tizen-support-DRI-driver-handling-of-swap-preser.patch index 9d97e5ea..68850409 100644 --- a/package/mesa3d/0027-egl-tizen-support-DRI-driver-handling-of-swap-preser.patch +++ b/package/mesa3d/0027-egl-tizen-support-DRI-driver-handling-of-swap-preser.patch @@ -1,7 +1,7 @@ -From eeda62ee212dcd8fae6c138f4a3b27e3f2ffe8c0 Mon Sep 17 00:00:00 2001 +From 48fe256681d8d7d3892393b102bf0a3ebc697c51 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Mon, 18 Dec 2017 19:22:50 +0000 -Subject: [PATCH 28/50] egl/tizen: support DRI driver handling of swap preserve +Subject: [PATCH 27/67] egl/tizen: support DRI driver handling of swap preserve This adds a new flag (__DRI_IMAGE_BUFFER_PREV) to the __DRIimageBufferMask enum that allows a DRI driver to request the previous back buffer. This @@ -16,10 +16,10 @@ be necessary under certain conditions, e.g. an empty swap. 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h -index 06eab0da5aa..cf1cb574c41 100644 +index b197092939f..16cc095ea29 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h -@@ -2049,12 +2049,15 @@ enum __DRIimageBufferMask { +@@ -2073,12 +2073,15 @@ enum __DRIimageBufferMask { * OpenGL ES API and little change to the SurfaceFlinger API. */ __DRI_IMAGE_BUFFER_SHARED = (1 << 2), @@ -117,5 +117,5 @@ index 49462152beb..2bc9b3e7c64 100644 } -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0028-egl-eglBindAPI-workaround-for-dEQP-bug.patch b/package/mesa3d/0028-egl-eglBindAPI-workaround-for-dEQP-bug.patch index 140b027b..ebdbf207 100644 --- a/package/mesa3d/0028-egl-eglBindAPI-workaround-for-dEQP-bug.patch +++ b/package/mesa3d/0028-egl-eglBindAPI-workaround-for-dEQP-bug.patch @@ -1,7 +1,7 @@ -From c431639246d96adce4a8807fa62b3b53cca3adf2 Mon Sep 17 00:00:00 2001 +From 90c87ad050dd7a4deda3ee1609e6cc27ea7dd616 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Mon, 25 Sep 2017 15:58:49 +0100 -Subject: [PATCH 29/50] egl: eglBindAPI workaround for dEQP bug +Subject: [PATCH 28/67] egl: eglBindAPI workaround for dEQP bug dEQP relies on eglBindAPI to only return true if the API can successfully be used to create contexts, which the spec does not @@ -25,5 +25,5 @@ index d9a4a90174e..32570970947 100644 return api == EGL_OPENGL_ES_API; #else -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0029-GL_EXT_multi_draw_indirect-entry-points.patch b/package/mesa3d/0029-GL_EXT_multi_draw_indirect-entry-points.patch index dc392324..08dee620 100644 --- a/package/mesa3d/0029-GL_EXT_multi_draw_indirect-entry-points.patch +++ b/package/mesa3d/0029-GL_EXT_multi_draw_indirect-entry-points.patch @@ -1,7 +1,7 @@ -From 651ae0156f4cec4dbf70eef95e1eceebe8941a20 Mon Sep 17 00:00:00 2001 +From a763c01172ee21a26f4c9dbb6055093f78d06fb2 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Tue, 30 Jan 2018 10:25:11 +0000 -Subject: [PATCH 30/50] GL_EXT_multi_draw_indirect entry points +Subject: [PATCH 29/67] GL_EXT_multi_draw_indirect entry points --- src/mapi/glapi/gen/es_EXT.xml | 19 +++++++++++++++++++ @@ -9,7 +9,7 @@ Subject: [PATCH 30/50] GL_EXT_multi_draw_indirect entry points 2 files changed, 21 insertions(+) diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml -index 359cc9ca8cf..de2862a71a5 100644 +index fe8f27e1e6f..e0d60faa9d2 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -1140,6 +1140,25 @@ @@ -39,18 +39,18 @@ index 359cc9ca8cf..de2862a71a5 100644 diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py -index d13dc915d6f..32fb3b8f4f7 100644 +index dc6bdc9dcce..e231c176264 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py -@@ -1692,6 +1692,8 @@ offsets = { - "FramebufferTextureLayerDownsampleIMG" : 1656, - "FramebufferTextureMultiviewOVR" : 1657, - "FramebufferTextureMultisampleMultiviewOVR" : 1658, -+ "MultiDrawArraysIndirectEXT" : 1659, -+ "MultiDrawElementsIndirectEXT" : 1660, +@@ -1704,6 +1704,8 @@ offsets = { + "FramebufferTextureLayerDownsampleIMG" : 1668, + "FramebufferTextureMultiviewOVR" : 1669, + "FramebufferTextureMultisampleMultiviewOVR" : 1670, ++ "MultiDrawArraysIndirectEXT" : 1671, ++ "MultiDrawElementsIndirectEXT" : 1672, } functions = [ -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0030-dri-add-support-for-YUV-DRI-config.patch b/package/mesa3d/0030-dri-add-support-for-YUV-DRI-config.patch index 5c0f3b88..95d0ed58 100644 --- a/package/mesa3d/0030-dri-add-support-for-YUV-DRI-config.patch +++ b/package/mesa3d/0030-dri-add-support-for-YUV-DRI-config.patch @@ -1,7 +1,7 @@ -From d4632fc9ce17416cd1f3019af554a320e142dc3b Mon Sep 17 00:00:00 2001 +From 389e1a41360160bf56182a87cc52b5df9dc1265d Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Fri, 22 Dec 2017 17:17:50 +0000 -Subject: [PATCH 31/50] dri: add support for YUV DRI config +Subject: [PATCH 30/67] dri: add support for YUV DRI config This is prerequisite for adding support for EGL_EXT_yuv_surface. @@ -9,11 +9,11 @@ This also adds support for NV12 and NV21 EGL configs. --- include/GL/internal/dri_interface.h | 42 ++++++++- src/gallium/frontends/dri/dri_screen.c | 8 +- - src/gallium/include/pipe/p_format.h | 3 + - src/mesa/drivers/dri/common/utils.c | 87 +++++++++++++++++-- + src/gallium/include/pipe/p_format.h | 2 + + src/mesa/drivers/dri/common/utils.c | 88 +++++++++++++++++-- src/mesa/drivers/dri/common/utils.h | 3 +- src/mesa/drivers/dri/i915/intel_screen.c | 8 +- - src/mesa/drivers/dri/i965/intel_screen.c | 12 ++- + src/mesa/drivers/dri/i965/brw_screen.c | 12 ++- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 4 +- src/mesa/drivers/dri/radeon/radeon_screen.c | 4 +- src/mesa/main/format_info.py | 2 +- @@ -24,7 +24,7 @@ This also adds support for NV12 and NV21 EGL configs. 14 files changed, 181 insertions(+), 19 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h -index cf1cb574c41..cff3d9019dd 100644 +index 16cc095ea29..4d5a1874dc2 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -826,7 +826,13 @@ struct __DRIuseInvalidateExtensionRec { @@ -91,52 +91,51 @@ index cf1cb574c41..cff3d9019dd 100644 * This extension defines the core DRI functionality. * diff --git a/src/gallium/frontends/dri/dri_screen.c b/src/gallium/frontends/dri/dri_screen.c -index 20ee86f52b7..09f13dd9b77 100644 +index b565a1fe8ec..37a0d4add0c 100644 --- a/src/gallium/frontends/dri/dri_screen.c +++ b/src/gallium/frontends/dri/dri_screen.c -@@ -306,7 +306,9 @@ dri_fill_in_modes(struct dri_screen *screen) +@@ -324,7 +324,9 @@ dri_fill_in_modes(struct dri_screen *screen) depth_buffer_factor, back_buffer_modes, ARRAY_SIZE(back_buffer_modes), msaa_modes, 1, -- GL_TRUE, !mixed_color_depth, GL_FALSE); -+ GL_TRUE, !mixed_color_depth, GL_FALSE, +- GL_TRUE, !mixed_color_depth); ++ GL_TRUE, !mixed_color_depth, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); configs = driConcatConfigs(configs, new_configs); /* Multi-sample configs without an accumulation buffer. */ -@@ -316,7 +318,9 @@ dri_fill_in_modes(struct dri_screen *screen) +@@ -334,7 +336,9 @@ dri_fill_in_modes(struct dri_screen *screen) depth_buffer_factor, back_buffer_modes, ARRAY_SIZE(back_buffer_modes), msaa_modes+1, num_msaa_modes-1, -- GL_FALSE, !mixed_color_depth, GL_FALSE); -+ GL_FALSE, !mixed_color_depth, GL_FALSE, +- GL_FALSE, !mixed_color_depth); ++ GL_FALSE, !mixed_color_depth, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); configs = driConcatConfigs(configs, new_configs); } } diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h -index 7c62b722e5d..a3a417ea0d8 100644 +index 0c93d7df6e2..fd653379b7a 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h -@@ -493,6 +493,9 @@ enum pipe_format { - - PIPE_FORMAT_R8_G8B8_420_UNORM, - +@@ -513,6 +513,8 @@ enum pipe_format { + PIPE_FORMAT_R4G4B4X4_UNORM, + PIPE_FORMAT_B10G10R10X2_SNORM, + PIPE_FORMAT_R5G6B5_SRGB, + PIPE_FORMAT_YUV420_2PLANE, + PIPE_FORMAT_YVU420_2PLANE, -+ + PIPE_FORMAT_COUNT }; - diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c -index 0fdca2d9d84..85ffe2de64d 100644 +index a3f2bc57f46..d268dc41fbb 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c -@@ -166,6 +166,21 @@ driGetRendererString( char * buffer, const char * hardware_name, - * which translates to - * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR. +@@ -163,6 +163,21 @@ driGetRendererString( char * buffer, const char * hardware_name, + * This forces 32-bit color to have 24-bit depth, and + * 16-bit color to have 16-bit depth. * + * \param yuv_depth_range YUV pixel depth range. For non-YUV pixel formats this + * should be \c __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE. @@ -156,17 +155,17 @@ index 0fdca2d9d84..85ffe2de64d 100644 * \returns * Pointer to any array of pointers to the \c __DRIconfig structures created * for the specified formats. If there is an error, \c NULL is returned. -@@ -179,7 +194,8 @@ driCreateConfigs(mesa_format format, +@@ -175,7 +190,8 @@ driCreateConfigs(mesa_format format, + unsigned num_depth_stencil_bits, const GLenum * db_modes, unsigned num_db_modes, const uint8_t * msaa_samples, unsigned num_msaa_modes, - GLboolean enable_accum, GLboolean color_depth_match, -- GLboolean mutable_render_buffer) -+ GLboolean mutable_render_buffer, +- GLboolean enable_accum, GLboolean color_depth_match) ++ GLboolean enable_accum, GLboolean color_depth_match, + GLint yuv_depth_range, GLint yuv_csc_standard) { static const struct { uint32_t masks[4]; -@@ -218,6 +234,9 @@ driCreateConfigs(mesa_format format, +@@ -214,6 +230,9 @@ driCreateConfigs(mesa_format format, /* MESA_FORMAT_RGBA_FLOAT16 */ {{ 0, 0, 0, 0}, { 0, 16, 32, 48 }}, @@ -176,7 +175,7 @@ index 0fdca2d9d84..85ffe2de64d 100644 }; const uint32_t * masks; -@@ -231,6 +250,11 @@ driCreateConfigs(mesa_format format, +@@ -227,6 +246,11 @@ driCreateConfigs(mesa_format format, int green_bits; int blue_bits; int alpha_bits; @@ -188,7 +187,7 @@ index 0fdca2d9d84..85ffe2de64d 100644 bool is_srgb; bool is_float; -@@ -282,6 +306,33 @@ driCreateConfigs(mesa_format format, +@@ -279,6 +303,33 @@ driCreateConfigs(mesa_format format, masks = format_table[8].masks; shifts = format_table[8].shifts; break; @@ -222,7 +221,7 @@ index 0fdca2d9d84..85ffe2de64d 100644 default: fprintf(stderr, "[%s:%u] Unknown framebuffer type %s (%d).\n", __func__, __LINE__, -@@ -337,8 +388,12 @@ driCreateConfigs(mesa_format format, +@@ -334,8 +385,12 @@ driCreateConfigs(mesa_format format, modes->greenShift = shifts[1]; modes->blueShift = shifts[2]; modes->alphaShift = shifts[3]; @@ -237,18 +236,19 @@ index 0fdca2d9d84..85ffe2de64d 100644 modes->accumRedBits = 16 * j; modes->accumGreenBits = 16 * j; -@@ -355,6 +410,7 @@ driCreateConfigs(mesa_format format, - modes->transparentBlue = GLX_DONT_CARE; - modes->transparentAlpha = GLX_DONT_CARE; - modes->transparentIndex = GLX_DONT_CARE; -+ modes->rgbMode = !is_yuv; +@@ -345,6 +400,8 @@ driCreateConfigs(mesa_format format, + modes->stencilBits = stencil_bits[k]; + modes->depthBits = depth_bits[k]; ++ modes->rgbMode = !is_yuv; ++ if (db_modes[i] == __DRI_ATTRIB_SWAP_NONE) { modes->doubleBufferMode = GL_FALSE; -@@ -379,6 +435,13 @@ driCreateConfigs(mesa_format format, - modes->yInverted = GL_TRUE; + modes->swapMethod = __DRI_ATTRIB_SWAP_UNDEFINED; +@@ -357,6 +414,13 @@ driCreateConfigs(mesa_format format, + modes->samples = msaa_samples[h]; + modes->sRGBCapable = is_srgb; - modes->mutableRenderBuffer = mutable_render_buffer; + + modes->YUVOrder = yuv_order; + modes->YUVNumberOfPlanes = yuv_num_planes; @@ -259,22 +259,9 @@ index 0fdca2d9d84..85ffe2de64d 100644 } } } -@@ -468,6 +531,12 @@ static const struct { unsigned int attrib, offset; } attribMap[] = { - __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted), - __ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE, sRGBCapable), - __ATTRIB(__DRI_ATTRIB_MUTABLE_RENDER_BUFFER, mutableRenderBuffer), -+ __ATTRIB(__DRI_ATTRIB_YUV_ORDER, YUVOrder), -+ __ATTRIB(__DRI_ATTRIB_YUV_NUMBER_OF_PLANES, YUVNumberOfPlanes), -+ __ATTRIB(__DRI_ATTRIB_YUV_SUBSAMPLE, YUVSubsample), -+ __ATTRIB(__DRI_ATTRIB_YUV_DEPTH_RANGE, YUVDepthRange), -+ __ATTRIB(__DRI_ATTRIB_YUV_CSC_STANDARD, YUVCSCStandard), -+ __ATTRIB(__DRI_ATTRIB_YUV_PLANE_BPP, YUVPlaneBPP), - - /* The struct field doesn't matter here, these are handled by the - * switch in driGetConfigAttribIndex. We need them in the array -@@ -487,10 +556,14 @@ driGetConfigAttribIndex(const __DRIconfig *config, - { - switch (attribMap[index].attrib) { +@@ -436,10 +500,14 @@ driGetConfigAttribIndex(const __DRIconfig *config, + break; + __ATTRIB(__DRI_ATTRIB_SAMPLES, samples); case __DRI_ATTRIB_RENDER_TYPE: - /* no support for color index mode */ - *value = __DRI_ATTRIB_RGBA_BIT; @@ -290,116 +277,129 @@ index 0fdca2d9d84..85ffe2de64d 100644 + *value |= __DRI_ATTRIB_FLOAT_BIT; break; case __DRI_ATTRIB_CONFIG_CAVEAT: - if (config->modes.visualRating == GLX_NON_CONFORMANT_CONFIG) + if (config->modes.accumRedBits != 0) +@@ -505,6 +573,12 @@ driGetConfigAttribIndex(const __DRIconfig *config, + __ATTRIB(__DRI_ATTRIB_GREEN_SHIFT, greenShift); + __ATTRIB(__DRI_ATTRIB_BLUE_SHIFT, blueShift); + __ATTRIB(__DRI_ATTRIB_ALPHA_SHIFT, alphaShift); ++ __ATTRIB(__DRI_ATTRIB_YUV_ORDER, YUVOrder); ++ __ATTRIB(__DRI_ATTRIB_YUV_NUMBER_OF_PLANES, YUVNumberOfPlanes); ++ __ATTRIB(__DRI_ATTRIB_YUV_SUBSAMPLE, YUVSubsample); ++ __ATTRIB(__DRI_ATTRIB_YUV_DEPTH_RANGE, YUVDepthRange); ++ __ATTRIB(__DRI_ATTRIB_YUV_CSC_STANDARD, YUVCSCStandard); ++ __ATTRIB(__DRI_ATTRIB_YUV_PLANE_BPP, YUVPlaneBPP); + default: + /* XXX log an error or smth */ + return GL_FALSE; diff --git a/src/mesa/drivers/dri/common/utils.h b/src/mesa/drivers/dri/common/utils.h -index 7c9719f9f42..8159300c01d 100644 +index 7be0465c261..ebd98d9dc33 100644 --- a/src/mesa/drivers/dri/common/utils.h +++ b/src/mesa/drivers/dri/common/utils.h -@@ -46,7 +46,8 @@ driCreateConfigs(mesa_format format, +@@ -45,7 +45,8 @@ driCreateConfigs(mesa_format format, + unsigned num_depth_stencil_bits, const GLenum * db_modes, unsigned num_db_modes, const uint8_t * msaa_samples, unsigned num_msaa_modes, - GLboolean enable_accum, GLboolean color_depth_match, -- GLboolean mutable_render_buffer); -+ GLboolean mutable_render_buffer, +- GLboolean enable_accum, GLboolean color_depth_match); ++ GLboolean enable_accum, GLboolean color_depth_match, + GLint yuv_depth_range, GLint yuv_csc_standards); __DRIconfig **driConcatConfigs(__DRIconfig **a, __DRIconfig **b); diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c -index 60b35d37a6e..62973d83bd5 100644 +index 6135357c2a0..a94c6de0a06 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c -@@ -1067,7 +1067,9 @@ intel_screen_make_configs(__DRIscreen *dri_screen) +@@ -1083,7 +1083,9 @@ intel_screen_make_configs(__DRIscreen *dri_screen) num_depth_stencil_bits, back_buffer_modes, 2, singlesample_samples, 1, -- false, false, false); -+ false, false, false, +- false, false); ++ false, false, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); configs = driConcatConfigs(configs, new_configs); } -@@ -1089,7 +1091,9 @@ intel_screen_make_configs(__DRIscreen *dri_screen) +@@ -1105,7 +1107,9 @@ intel_screen_make_configs(__DRIscreen *dri_screen) depth_bits, stencil_bits, 1, back_buffer_modes, 1, singlesample_samples, 1, -- true, false, false); -+ true, false, false, +- true, false); ++ true, false, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); configs = driConcatConfigs(configs, new_configs); } -diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c -index 1e34cbbca1a..8fed9c6931a 100644 ---- a/src/mesa/drivers/dri/i965/intel_screen.c -+++ b/src/mesa/drivers/dri/i965/intel_screen.c -@@ -2336,7 +2336,9 @@ intel_screen_make_configs(__DRIscreen *dri_screen) +diff --git a/src/mesa/drivers/dri/i965/brw_screen.c b/src/mesa/drivers/dri/i965/brw_screen.c +index 56811110567..c450bae1054 100644 +--- a/src/mesa/drivers/dri/i965/brw_screen.c ++++ b/src/mesa/drivers/dri/i965/brw_screen.c +@@ -2292,7 +2292,9 @@ brw_screen_make_configs(__DRIscreen *dri_screen) + num_depth_stencil_bits, back_buffer_modes, 2, singlesample_samples, 1, - false, false, -- /*mutable_render_buffer*/ true); -+ /*mutable_render_buffer*/ true, +- false, false); ++ false, false, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); configs = driConcatConfigs(configs, new_configs); } -@@ -2369,7 +2371,9 @@ intel_screen_make_configs(__DRIscreen *dri_screen) +@@ -2325,7 +2327,9 @@ brw_screen_make_configs(__DRIscreen *dri_screen) depth_bits, stencil_bits, 1, back_buffer_modes, 1, singlesample_samples, 1, -- true, false, false); -+ true, false, false, +- true, false); ++ true, false, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); configs = driConcatConfigs(configs, new_configs); } -@@ -2434,7 +2438,9 @@ intel_screen_make_configs(__DRIscreen *dri_screen) +@@ -2390,7 +2394,9 @@ brw_screen_make_configs(__DRIscreen *dri_screen) back_buffer_modes, 1, multisample_samples, num_msaa_modes, -- false, false, false); -+ false, false, false, +- false, false); ++ false, false, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); configs = driConcatConfigs(configs, new_configs); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c -index ba85aacf741..9d4c1d9bd94 100644 +index c92efcd7b20..fc87d5eb395 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -79,7 +79,9 @@ nouveau_get_configs(uint32_t chipset) ARRAY_SIZE(back_buffer_modes), msaa_samples, ARRAY_SIZE(msaa_samples), -- GL_TRUE, chipset < 0x10, GL_FALSE); -+ GL_TRUE, chipset < 0x10, GL_FALSE, +- GL_TRUE, chipset < 0x10); ++ GL_TRUE, chipset < 0x10, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); assert(config); configs = driConcatConfigs(configs, config); diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c -index f61fe399c09..84aef8dd041 100644 +index 3764a5d6538..f7628555b8f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c -@@ -839,7 +839,9 @@ __DRIconfig **radeonInitScreen2(__DRIscreen *psp) +@@ -838,7 +838,9 @@ __DRIconfig **radeonInitScreen2(__DRIscreen *psp) ARRAY_SIZE(back_buffer_modes), msaa_samples_array, ARRAY_SIZE(msaa_samples_array), -- GL_TRUE, GL_FALSE, GL_FALSE); -+ GL_TRUE, GL_FALSE, GL_FALSE, +- GL_TRUE, GL_FALSE); ++ GL_TRUE, GL_FALSE, + __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE, + __DRI_ATTRIB_YUV_CSC_STANDARD_NONE); configs = driConcatConfigs(configs, new_configs); } diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py -index 42c236c7a6a..e07d2d98b89 100644 +index edc0324e60b..d58403ea85e 100644 --- a/src/mesa/main/format_info.py +++ b/src/mesa/main/format_info.py @@ -29,7 +29,7 @@ import sys @@ -412,10 +412,10 @@ index 42c236c7a6a..e07d2d98b89 100644 elif fmat.has_channel('r'): if fmat.has_channel('g'): diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c -index ac00a21306b..de7b9feb14b 100644 +index 9cd026f7507..f81caeceff4 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c -@@ -1450,6 +1450,15 @@ _mesa_format_matches_format_and_type(mesa_format mformat, +@@ -1452,6 +1452,15 @@ _mesa_format_matches_format_and_type(mesa_format mformat, if (error) *error = GL_NO_ERROR; @@ -432,7 +432,7 @@ index ac00a21306b..de7b9feb14b 100644 if (error) *error = GL_INVALID_ENUM; diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv -index e2b54e935bb..166c3d4830d 100644 +index 21cdea26e08..b2d476577e0 100644 --- a/src/mesa/main/formats.csv +++ b/src/mesa/main/formats.csv @@ -92,6 +92,8 @@ MESA_FORMAT_A2R10G10B10_UNORM , packed, 1, 1, 1, un2 , un10, un10, u @@ -442,13 +442,13 @@ index e2b54e935bb..166c3d4830d 100644 +MESA_FORMAT_YUV420_2PLANE , other , 1, 1, 1, x8 , , , , y___, yuv +MESA_FORMAT_YVU420_2PLANE , other , 1, 1, 1, x8 , , , , y___, yuv - # Array normalized formats - MESA_FORMAT_A_UNORM8 , array , 1, 1, 1, un8 , , , , 000x, rgb + MESA_FORMAT_RG_RB_UNORM8 , other , 2, 1, 1, x16 , , , , xyz1, rgb + MESA_FORMAT_GR_BR_UNORM8 , other , 2, 1, 1, x16 , , , , xyz1, rgb diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h -index 29c1308c383..4fcb5f73225 100644 +index 508c9c342d2..0e778d64467 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h -@@ -615,6 +615,13 @@ typedef enum pipe_format mesa_format; +@@ -617,6 +617,13 @@ typedef enum pipe_format mesa_format; #define MESA_FORMAT_ATC_RGB PIPE_FORMAT_ATC_RGB #define MESA_FORMAT_ATC_RGBA_EXPLICIT PIPE_FORMAT_ATC_RGBA_EXPLICIT #define MESA_FORMAT_ATC_RGBA_INTERPOLATED PIPE_FORMAT_ATC_RGBA_INTERPOLATED @@ -463,10 +463,10 @@ index 29c1308c383..4fcb5f73225 100644 /* Packed to array format adapters */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h -index 70e7b218197..96e55fc987d 100644 +index 32528a5f16b..8f77d4c58dd 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h -@@ -162,6 +162,7 @@ _mesa_varying_slot_in_fs(gl_varying_slot slot) +@@ -158,6 +158,7 @@ _mesa_varying_slot_in_fs(gl_varying_slot slot) */ struct gl_config { @@ -474,10 +474,10 @@ index 70e7b218197..96e55fc987d 100644 GLboolean floatMode; GLuint doubleBufferMode; GLuint stereoMode; -@@ -214,6 +215,14 @@ struct gl_config +@@ -179,6 +180,14 @@ struct gl_config - /* EGL_KHR_mutable_render_buffer */ - GLuint mutableRenderBuffer; /* bool */ + /* EXT_framebuffer_sRGB */ + GLint sRGBCapable; + + /* EXT_yuv_surface */ + GLint YUVOrder; @@ -490,5 +490,5 @@ index 70e7b218197..96e55fc987d 100644 -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0031-egl-add-support-for-EXT_yuv_surface.patch b/package/mesa3d/0031-egl-add-support-for-EXT_yuv_surface.patch index 9190a17b..96c004d6 100644 --- a/package/mesa3d/0031-egl-add-support-for-EXT_yuv_surface.patch +++ b/package/mesa3d/0031-egl-add-support-for-EXT_yuv_surface.patch @@ -1,7 +1,7 @@ -From cc2b278f33c3c9f5f74aa5b36ead67f89cb7a20d Mon Sep 17 00:00:00 2001 +From 4e65ae659b775259b4f703eb563feffc623c17b7 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Wed, 20 Dec 2017 17:41:38 +0000 -Subject: [PATCH 32/50] egl: add support for EXT_yuv_surface +Subject: [PATCH 31/67] egl: add support for EXT_yuv_surface This implements EXT_yuv_surface but doesn't expose it for any platform. --- @@ -14,7 +14,7 @@ This implements EXT_yuv_surface but doesn't expose it for any platform. 6 files changed, 348 insertions(+), 5 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h -index cff3d9019dd..89e29299840 100644 +index 4d5a1874dc2..62517e4004a 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -1154,6 +1154,7 @@ enum dri_loader_cap { @@ -26,10 +26,10 @@ index cff3d9019dd..89e29299840 100644 struct __DRIdri2LoaderExtensionRec { diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index 69da031fa00..a0b52eab983 100644 +index db993f8f059..ee3bcda4d12 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -319,6 +319,7 @@ static const EGLint dri2_to_egl_attribute_map[__DRI_ATTRIB_MAX] = { +@@ -306,6 +306,7 @@ static const EGLint dri2_to_egl_attribute_map[__DRI_ATTRIB_MAX] = { [__DRI_ATTRIB_MAX_SWAP_INTERVAL] = EGL_MAX_SWAP_INTERVAL, [__DRI_ATTRIB_MIN_SWAP_INTERVAL] = EGL_MIN_SWAP_INTERVAL, [__DRI_ATTRIB_YINVERTED] = EGL_Y_INVERTED_NOK, @@ -37,7 +37,7 @@ index 69da031fa00..a0b52eab983 100644 }; const __DRIconfig * -@@ -446,6 +447,8 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, +@@ -432,6 +433,8 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, value = EGL_RGB_BUFFER; else if (value & __DRI_ATTRIB_LUMINANCE_BIT) value = EGL_LUMINANCE_BUFFER; @@ -46,7 +46,7 @@ index 69da031fa00..a0b52eab983 100644 else return NULL; base.ColorBufferType = value; -@@ -556,6 +559,73 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, +@@ -536,6 +539,73 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, if (disp->Extensions.KHR_mutable_render_buffer) surface_type |= EGL_MUTABLE_RENDER_BUFFER_BIT_KHR; break; @@ -120,7 +120,7 @@ index 69da031fa00..a0b52eab983 100644 default: key = dri2_to_egl_attribute_map[attrib]; if (key != 0) -@@ -612,6 +682,17 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, +@@ -583,6 +653,17 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, base.RenderableType = disp->ClientAPIs; base.Conformant = disp->ClientAPIs; @@ -138,7 +138,7 @@ index 69da031fa00..a0b52eab983 100644 base.MinSwapInterval = dri2_dpy->min_swap_interval; base.MaxSwapInterval = dri2_dpy->max_swap_interval; -@@ -1043,6 +1124,8 @@ dri2_setup_screen(_EGLDisplay *disp) +@@ -1014,6 +1095,8 @@ dri2_setup_screen(_EGLDisplay *disp) disp->Extensions.EXT_protected_surface = dri2_renderer_query_integer(dri2_dpy, __DRI2_RENDERER_HAS_PROTECTED_CONTENT); @@ -148,7 +148,7 @@ index 69da031fa00..a0b52eab983 100644 void diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index c4dcc015941..8d9f4a76330 100644 +index e2a7797d73e..6d7f62c6851 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -512,6 +512,7 @@ _eglCreateExtensionsString(_EGLDisplay *disp) @@ -537,5 +537,5 @@ index 0a7366b7c07..020529c57e2 100644 unsigned int IMG_context_priority; #define __EGL_CONTEXT_PRIORITY_LOW_BIT 0 -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0032-dri-add-missing-__DRI_IMAGE_COMPONENTS-define-for-EG.patch b/package/mesa3d/0032-dri-add-missing-__DRI_IMAGE_COMPONENTS-define-for-EG.patch index 5ee0d528..7f836c6e 100644 --- a/package/mesa3d/0032-dri-add-missing-__DRI_IMAGE_COMPONENTS-define-for-EG.patch +++ b/package/mesa3d/0032-dri-add-missing-__DRI_IMAGE_COMPONENTS-define-for-EG.patch @@ -1,7 +1,7 @@ -From ab2935ddffde305a6bdf49a9e928de407e04871b Mon Sep 17 00:00:00 2001 +From 5a22280c13e98932ad45fa6a131217abdffd16b4 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Fri, 2 Feb 2018 16:59:52 +0000 -Subject: [PATCH 33/50] dri: add missing __DRI_IMAGE_COMPONENTS define for +Subject: [PATCH 32/67] dri: add missing __DRI_IMAGE_COMPONENTS define for EGL_TEXTURE_EXTERNAL_WL The __DRI_IMAGE_COMPONENTS defines have been re-ordered, to make it @@ -12,10 +12,10 @@ existing ones. 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h -index 89e29299840..8214e7a55c3 100644 +index 62517e4004a..6490f6e80e2 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h -@@ -1459,11 +1459,12 @@ struct __DRIdri2ExtensionRec { +@@ -1461,11 +1461,12 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003 #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 @@ -31,5 +31,5 @@ index 89e29299840..8214e7a55c3 100644 /** -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0033-egl-wayland-expose-EXT_yuv_surface-support.patch b/package/mesa3d/0033-egl-wayland-expose-EXT_yuv_surface-support.patch index 397f39d8..e7f0fba5 100644 --- a/package/mesa3d/0033-egl-wayland-expose-EXT_yuv_surface-support.patch +++ b/package/mesa3d/0033-egl-wayland-expose-EXT_yuv_surface-support.patch @@ -1,7 +1,7 @@ -From 2b9a147b073ed8ff1d52246be5c885959d859c45 Mon Sep 17 00:00:00 2001 +From 3d47285da42c76fe36ae67c62e8d0a0d76d18da0 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Thu, 11 Jan 2018 09:38:47 +0000 -Subject: [PATCH 34/50] egl/wayland: expose EXT_yuv_surface support +Subject: [PATCH 33/67] egl/wayland: expose EXT_yuv_surface support This adds support for YUYV configs. --- @@ -10,10 +10,10 @@ This adds support for YUYV configs. 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index a0b52eab983..d359934a818 100644 +index ee3bcda4d12..d511d73f2ed 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -2798,6 +2798,7 @@ static const struct wl_drm_components_descriptor { +@@ -2769,6 +2769,7 @@ static const struct wl_drm_components_descriptor { { __DRI_IMAGE_COMPONENTS_Y_U_V, EGL_TEXTURE_Y_U_V_WL, 3 }, { __DRI_IMAGE_COMPONENTS_Y_UV, EGL_TEXTURE_Y_UV_WL, 2 }, { __DRI_IMAGE_COMPONENTS_Y_XUXV, EGL_TEXTURE_Y_XUXV_WL, 2 }, @@ -22,10 +22,10 @@ index a0b52eab983..d359934a818 100644 static _EGLImage * diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c -index 43ad6420174..de12ec21f53 100644 +index a096d9500c1..72456d5d748 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c -@@ -134,6 +134,13 @@ static const struct dri2_wl_visual { +@@ -135,6 +135,13 @@ static const struct dri2_wl_visual { { 11, 5, 0, -1 }, { 5, 6, 5, 0 }, }, @@ -39,7 +39,7 @@ index 43ad6420174..de12ec21f53 100644 }; static_assert(ARRAY_SIZE(dri2_wl_visuals) <= EGL_DRI2_MAX_FORMATS, -@@ -970,6 +977,7 @@ dri2_wl_get_capability(void *loaderPrivate, enum dri_loader_cap cap) +@@ -958,6 +965,7 @@ dri2_wl_get_capability(void *loaderPrivate, enum dri_loader_cap cap) { switch (cap) { case DRI_LOADER_CAP_FP16: @@ -47,7 +47,7 @@ index 43ad6420174..de12ec21f53 100644 return 1; default: return 0; -@@ -1561,6 +1569,7 @@ dri2_wl_add_configs_for_visuals(_EGLDisplay *disp) +@@ -1552,6 +1560,7 @@ dri2_wl_add_configs_for_visuals(_EGLDisplay *disp) struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); unsigned int format_count[ARRAY_SIZE(dri2_wl_visuals)] = { 0 }; unsigned int count = 0; @@ -55,7 +55,7 @@ index 43ad6420174..de12ec21f53 100644 bool assigned; for (unsigned i = 0; dri2_dpy->driver_configs[i]; i++) { -@@ -1572,8 +1581,12 @@ dri2_wl_add_configs_for_visuals(_EGLDisplay *disp) +@@ -1563,8 +1572,12 @@ dri2_wl_add_configs_for_visuals(_EGLDisplay *disp) if (!BITSET_TEST(dri2_dpy->formats, j)) continue; @@ -70,5 +70,5 @@ index 43ad6420174..de12ec21f53 100644 if (dri2_conf->base.ConfigID == count + 1) count++; -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0034-egl-tizen-expose-EXT_yuv_surface-support.patch b/package/mesa3d/0034-egl-tizen-expose-EXT_yuv_surface-support.patch index d9ee5390..f15e4996 100644 --- a/package/mesa3d/0034-egl-tizen-expose-EXT_yuv_surface-support.patch +++ b/package/mesa3d/0034-egl-tizen-expose-EXT_yuv_surface-support.patch @@ -1,7 +1,7 @@ -From daf8ff0be3c3fbfe5bfba656eca511a45720bdea Mon Sep 17 00:00:00 2001 +From 40c0d03cfb2751279b24890d0f752fade968862e Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Tue, 13 Feb 2018 14:47:48 +0000 -Subject: [PATCH 35/50] egl/tizen: expose EXT_yuv_surface support +Subject: [PATCH 34/67] egl/tizen: expose EXT_yuv_surface support This adds support for NV12 and NV21 configs. --- @@ -353,5 +353,5 @@ index 2bc9b3e7c64..b6478a1875b 100644 if (caveat & __DRI_ATTRIB_NON_CONFORMANT_CONFIG) attr_list[3] = EGL_NON_CONFORMANT_CONFIG; -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0035-gbm-add-some-new-GBM-formats.patch b/package/mesa3d/0035-gbm-add-some-new-GBM-formats.patch index c4528930..9e41da2b 100644 --- a/package/mesa3d/0035-gbm-add-some-new-GBM-formats.patch +++ b/package/mesa3d/0035-gbm-add-some-new-GBM-formats.patch @@ -1,7 +1,7 @@ -From 812b414afa598605ddc163d0a07f4374d1a625c9 Mon Sep 17 00:00:00 2001 +From 5bd42e648dc9068392641436b70fc28a00689c8e Mon Sep 17 00:00:00 2001 From: Silvestrs Timofejevs Date: Thu, 30 Aug 2018 13:48:53 +0100 -Subject: [PATCH 36/50] gbm: add some new GBM formats +Subject: [PATCH 35/67] gbm: add some new GBM formats GBM_FORMAT_ARGB4444 GBM_FORMAT_BGR888 @@ -13,10 +13,10 @@ GBM_FORMAT_YVU444_PACK10_IMG 2 files changed, 18 insertions(+) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c -index f9adbc5c001..1144e9a62d1 100644 +index 2aa9c7c41ad..5acb15b516f 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c -@@ -508,11 +508,21 @@ static const struct gbm_dri_visual gbm_dri_visuals_table[] = { +@@ -514,11 +514,21 @@ static const struct gbm_dri_visual gbm_dri_visuals_table[] = { { 10, 5, 0, 11 }, { 5, 5, 5, 1 }, }, @@ -38,7 +38,7 @@ index f9adbc5c001..1144e9a62d1 100644 { GBM_FORMAT_XRGB8888, __DRI_IMAGE_FORMAT_XRGB8888, { 16, 8, 0, -1 }, -@@ -565,6 +575,12 @@ static const struct gbm_dri_visual gbm_dri_visuals_table[] = { +@@ -571,6 +581,12 @@ static const struct gbm_dri_visual gbm_dri_visuals_table[] = { { 16, 16, 16, 16 }, true, }, @@ -52,7 +52,7 @@ index f9adbc5c001..1144e9a62d1 100644 static int diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h -index e754edd5654..19b601dc1f3 100644 +index 7c82cd661a3..81308ab9745 100644 --- a/src/gbm/main/gbm.h +++ b/src/gbm/main/gbm.h @@ -167,6 +167,8 @@ enum gbm_bo_format { @@ -65,5 +65,5 @@ index e754edd5654..19b601dc1f3 100644 * 2 plane YCbCr * index 0 = Y plane, [7:0] Y -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0036-egl-add-null-platform.patch b/package/mesa3d/0036-egl-add-null-platform.patch index c0f08199..f43dd4c4 100644 --- a/package/mesa3d/0036-egl-add-null-platform.patch +++ b/package/mesa3d/0036-egl-add-null-platform.patch @@ -1,26 +1,26 @@ -From 41dc5e009c2ad9e9db26256fbff335d04f03ccbd Mon Sep 17 00:00:00 2001 +From def26b8534e4f8e150e5775dd1f7d2d955580c05 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Sun, 5 Jun 2016 12:04:40 +0100 -Subject: [PATCH 37/50] egl: add "null" platform +Subject: [PATCH 36/67] egl: add "null" platform --- meson.build | 25 +- meson_options.txt | 2 +- - src/egl/drivers/dri2/egl_dri2.c | 6 + + src/egl/drivers/dri2/egl_dri2.c | 11 +- src/egl/drivers/dri2/egl_dri2.h | 57 +- - src/egl/drivers/dri2/platform_null.c | 1176 ++++++++++++++++++++++++++ + src/egl/drivers/dri2/platform_null.c | 1179 ++++++++++++++++++++++++++ src/egl/main/eglapi.c | 5 +- src/egl/main/egldisplay.c | 1 + src/egl/main/egldisplay.h | 1 + src/egl/meson.build | 5 + - 9 files changed, 1271 insertions(+), 7 deletions(-) + 9 files changed, 1277 insertions(+), 9 deletions(-) create mode 100644 src/egl/drivers/dri2/platform_null.c diff --git a/meson.build b/meson.build -index c90e44254d2..56340b8ef3b 100644 +index 3d9d345dbf2..2018562a1ec 100644 --- a/meson.build +++ b/meson.build -@@ -328,7 +328,7 @@ endif +@@ -340,7 +340,7 @@ endif _platforms = get_option('platforms') if _platforms.contains('auto') if system_has_kms_drm @@ -29,7 +29,7 @@ index c90e44254d2..56340b8ef3b 100644 elif ['darwin', 'cygwin'].contains(host_machine.system()) _platforms = ['x11'] elif ['haiku'].contains(host_machine.system()) -@@ -347,6 +347,7 @@ with_platform_wayland = _platforms.contains('wayland') +@@ -359,6 +359,7 @@ with_platform_wayland = _platforms.contains('wayland') with_platform_haiku = _platforms.contains('haiku') with_platform_windows = _platforms.contains('windows') with_platform_tizen = _platforms.contains('tizen') @@ -37,7 +37,7 @@ index c90e44254d2..56340b8ef3b 100644 if with_platform_tizen and _platforms.length() != 1 error('tizen cannot be enabled at the same time as other platforms') -@@ -903,6 +904,26 @@ if with_platform_tizen +@@ -958,6 +959,26 @@ if with_platform_tizen ] pre_args += '-DHAVE_TIZEN_PLATFORM' endif @@ -64,7 +64,7 @@ index c90e44254d2..56340b8ef3b 100644 prog_python = import('python').find_installation('python3') has_mako = run_command( -@@ -1502,7 +1523,7 @@ dep_libdrm = dependency( +@@ -1583,7 +1604,7 @@ dep_libdrm = dependency( 'libdrm', version : '>=' + _drm_ver, # GNU/Hurd includes egl_dri2, without drm. required : (with_dri2 and host_machine.system() != 'gnu') or with_dri3 or @@ -74,7 +74,7 @@ index c90e44254d2..56340b8ef3b 100644 if dep_libdrm.found() pre_args += '-DHAVE_LIBDRM' diff --git a/meson_options.txt b/meson_options.txt -index b2ba2d8d979..9073223e8f5 100644 +index 8230db93c70..d90a25f97ff 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -23,7 +23,7 @@ option( @@ -87,10 +87,10 @@ index b2ba2d8d979..9073223e8f5 100644 description : 'window systems to support. If this is set to `auto`, all platforms applicable will be enabled.' ) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index d359934a818..ee19d125675 100644 +index d511d73f2ed..2f8414e0c60 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -1282,6 +1282,9 @@ dri2_initialize(_EGLDisplay *disp) +@@ -1253,6 +1253,9 @@ dri2_initialize(_EGLDisplay *disp) case _EGL_PLATFORM_DEVICE: ret = dri2_initialize_device(disp); break; @@ -100,7 +100,16 @@ index d359934a818..ee19d125675 100644 case _EGL_PLATFORM_X11: case _EGL_PLATFORM_XCB: ret = dri2_initialize_x11(disp); -@@ -1384,6 +1387,9 @@ dri2_display_destroy(_EGLDisplay *disp) +@@ -1318,8 +1321,6 @@ dri2_display_destroy(_EGLDisplay *disp) + dri2_dpy->vtbl->close_screen_notify(disp); + dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); + } +- if (dri2_dpy->fd >= 0) +- close(dri2_dpy->fd); + + /* Don't dlclose the driver when building with the address sanitizer, so you + * get good symbols from the leak reports. +@@ -1355,11 +1356,17 @@ dri2_display_destroy(_EGLDisplay *disp) tpl_object_unreference((tpl_object_t *) dri2_dpy->tpl_dpy); break; #endif @@ -110,11 +119,19 @@ index d359934a818..ee19d125675 100644 default: /* TODO: add teardown for other platforms */ break; + } + ++ if (dri2_dpy->fd >= 0) ++ close(dri2_dpy->fd); ++ + /* The drm platform does not create the screen/driver_configs but reuses + * the ones from the gbm device. As such the gbm itself is responsible + * for the cleanup. diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index a33d87b23c1..95435b9ee12 100644 +index f41f32cd234..eb2127e3fe6 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -75,6 +75,10 @@ struct zwp_linux_dmabuf_v1; +@@ -81,6 +81,10 @@ struct zwp_linux_dmabuf_v1; #include #endif @@ -125,7 +142,7 @@ index a33d87b23c1..95435b9ee12 100644 #include "eglconfig.h" #include "eglcontext.h" #include "egldevice.h" -@@ -93,6 +97,22 @@ struct zwp_linux_dmabuf_v1; +@@ -99,6 +103,22 @@ struct zwp_linux_dmabuf_v1; struct wl_buffer; @@ -148,7 +165,7 @@ index a33d87b23c1..95435b9ee12 100644 struct dri2_egl_display_vtbl { /* mandatory on Wayland, unused otherwise */ int (*authenticate)(_EGLDisplay *disp, uint32_t id); -@@ -251,6 +271,11 @@ struct dri2_egl_display +@@ -257,6 +277,11 @@ struct dri2_egl_display char *device_name; #endif @@ -159,8 +176,8 @@ index a33d87b23c1..95435b9ee12 100644 + #ifdef HAVE_ANDROID_PLATFORM const gralloc_module_t *gralloc; - #endif -@@ -324,7 +349,10 @@ struct dri2_egl_surface + /* gralloc vendor usage bit for front rendering */ +@@ -332,7 +357,10 @@ struct dri2_egl_surface struct wl_display *wl_dpy_wrapper; struct wl_drm *wl_drm_wrapper; struct wl_callback *throttle_callback; @@ -172,7 +189,7 @@ index a33d87b23c1..95435b9ee12 100644 #endif #ifdef HAVE_DRM_PLATFORM -@@ -350,9 +378,10 @@ struct dri2_egl_surface +@@ -358,9 +386,10 @@ struct dri2_egl_surface __DRIbuffer *local_buffers[__DRI_BUFFER_COUNT]; #if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM) || \ @@ -185,7 +202,7 @@ index a33d87b23c1..95435b9ee12 100644 __DRIimage *dri_image; #endif #ifdef HAVE_WAYLAND_PLATFORM -@@ -369,6 +398,9 @@ struct dri2_egl_surface +@@ -377,6 +406,9 @@ struct dri2_egl_surface #endif #ifdef HAVE_TIZEN_PLATFORM tbm_surface_h tbm_surf; @@ -195,7 +212,7 @@ index a33d87b23c1..95435b9ee12 100644 #endif bool locked; int age; -@@ -400,6 +432,10 @@ struct dri2_egl_surface +@@ -409,6 +441,10 @@ struct dri2_egl_surface void *swrast_front; #endif @@ -206,7 +223,7 @@ index a33d87b23c1..95435b9ee12 100644 int out_fence_fd; EGLBoolean enable_out_fence; -@@ -580,6 +616,21 @@ EGLBoolean +@@ -589,6 +625,21 @@ EGLBoolean dri2_initialize_tizen(_EGLDisplay *disp); #endif @@ -230,10 +247,10 @@ index a33d87b23c1..95435b9ee12 100644 static inline void diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c new file mode 100644 -index 00000000000..2b3b08cc259 +index 00000000000..fb03ecc36fd --- /dev/null +++ b/src/egl/drivers/dri2/platform_null.c -@@ -0,0 +1,1176 @@ +@@ -0,0 +1,1179 @@ +/* + * Copyright (c) Imagination Technologies Ltd. + * @@ -1282,8 +1299,11 @@ index 00000000000..2b3b08cc259 + if (format_idx == -1) + continue; + -+ if (!(dri2_dpy->output.formats & (1 << format_idx))) ++ if (!(dri2_dpy->output.formats & (1 << format_idx))) { ++ _eglLog(_EGL_DEBUG, "unsupported drm format 0x%04x", ++ dri2_null_formats[format_idx].drm_format); + continue; ++ } + + dri2_conf = dri2_add_config(disp, + dri2_dpy->driver_configs[i], count + 1, @@ -1411,7 +1431,7 @@ index 00000000000..2b3b08cc259 + } +} diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index 8d9f4a76330..893541f55b1 100644 +index 6d7f62c6851..e4f2c43b4ef 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -989,7 +989,10 @@ _eglCreateWindowSurfaceCommon(_EGLDisplay *disp, EGLConfig config, @@ -1451,10 +1471,10 @@ index 020529c57e2..8489af9dde2 100644 _EGL_NUM_PLATFORMS, _EGL_INVALID_PLATFORM = -1 diff --git a/src/egl/meson.build b/src/egl/meson.build -index 17e9c690b82..d23d62562da 100644 +index 5749ec88f89..daa6a3a04f0 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build -@@ -142,6 +142,11 @@ if with_platform_tizen +@@ -146,6 +146,11 @@ if with_platform_tizen incs_for_egl += [inc_loader] deps_for_egl += [dep_tizen, dep_libdrm] endif @@ -1467,5 +1487,5 @@ index 17e9c690b82..d23d62562da 100644 if cc.has_function('mincore') c_args_for_egl += '-DHAVE_MINCORE' -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0037-egl-add-config-debug-printout.patch b/package/mesa3d/0037-egl-add-config-debug-printout.patch index 93c0d720..9523d41c 100644 --- a/package/mesa3d/0037-egl-add-config-debug-printout.patch +++ b/package/mesa3d/0037-egl-add-config-debug-printout.patch @@ -1,7 +1,7 @@ -From 7065e8e6bc0c3674ae310468b95cef1d538f5f03 Mon Sep 17 00:00:00 2001 +From 02065d490a68d542be56c2ea23346b3fa19928cb Mon Sep 17 00:00:00 2001 From: Silvestrs Timofejevs Date: Mon, 24 Sep 2018 14:14:25 +0100 -Subject: [PATCH 38/50] egl: add config debug printout +Subject: [PATCH 37/67] egl: add config debug printout Feature to print out EGL returned configs for debug purposes. @@ -10,32 +10,16 @@ enabled when the log level equals '_EGL_DEBUG'. The configs are printed, and if any of them are "chosen" they are marked with their index in the chosen configs array. --- - src/egl/Makefile.sources | 4 +- src/egl/main/eglconfig.c | 20 ++- - src/egl/main/eglconfigdebug.c | 276 ++++++++++++++++++++++++++++++++++ - src/egl/main/eglconfigdebug.h | 55 +++++++ - src/egl/main/egllog.c | 9 ++ + src/egl/main/eglconfigdebug.c | 321 ++++++++++++++++++++++++++++++++++ + src/egl/main/eglconfigdebug.h | 55 ++++++ + src/egl/main/egllog.c | 9 + src/egl/main/egllog.h | 4 + src/egl/meson.build | 2 + - 7 files changed, 365 insertions(+), 5 deletions(-) + 6 files changed, 407 insertions(+), 4 deletions(-) create mode 100644 src/egl/main/eglconfigdebug.c create mode 100644 src/egl/main/eglconfigdebug.h -diff --git a/src/egl/Makefile.sources b/src/egl/Makefile.sources -index 5f5b6d27e64..d757ba9bed4 100644 ---- a/src/egl/Makefile.sources -+++ b/src/egl/Makefile.sources -@@ -25,7 +25,9 @@ LIBEGL_C_FILES := \ - main/eglsync.c \ - main/eglsync.h \ - main/eglentrypoint.h \ -- main/egltypedefs.h -+ main/egltypedefs.h \ -+ main/eglconfigdebug.h \ -+ main/eglconfigdebug.c - - dri2_backend_core_FILES := \ - drivers/dri2/egl_dri2.c \ diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 5e56948ab72..ea4b3c15f3f 100644 --- a/src/egl/main/eglconfig.c @@ -86,10 +70,10 @@ index 5e56948ab72..ea4b3c15f3f 100644 } diff --git a/src/egl/main/eglconfigdebug.c b/src/egl/main/eglconfigdebug.c new file mode 100644 -index 00000000000..13e0a8bc350 +index 00000000000..92ac41a5614 --- /dev/null +++ b/src/egl/main/eglconfigdebug.c -@@ -0,0 +1,276 @@ +@@ -0,0 +1,321 @@ +/* + * Copyright 2017 Imagination Technologies. + * All Rights Reserved. @@ -144,6 +128,8 @@ index 00000000000..13e0a8bc350 + EGLint vid, vtype, caveat, bindRgb, bindRgba; + EGLint samples, sampleBuffers; + char surfString[100]; ++ EGLint colorBufferType; ++ EGLint numPlanes, subsample, order; +}; + +static void @@ -158,7 +144,7 @@ index 00000000000..13e0a8bc350 + * bfsz ----------------- EGL_BUFFER_SIZE + * lvl ------------------ EGL_LEVEL + * -+ * colourbuffer ++ * color size + * r -------------------- EGL_RED_SIZE + * g -------------------- EGL_GREEN_SIZE + * b -------------------- EGL_BLUE_SIZE @@ -178,11 +164,19 @@ index 00000000000..13e0a8bc350 + * + * supported + * surfaces ------------- EGL_SURFACE_TYPE ++ * colbuf --------------- EGL_COLOR_BUFFER_TYPE ++ * ++ * yuv ++ * p -------------------- EGL_YUV_NUMBER_OF_PLANES_EXT ++ * sub ------------------ EGL_YUV_SUBSAMPLE_EXT ++ * ord ------------------ EGL_YUV_ORDER_EXT + */ + _eglLog(_EGL_DEBUG, "---------------"); + _eglLog(_EGL_DEBUG, "Configurations:"); -+ _eglLog(_EGL_DEBUG, "cho bf lv colourbuffer dp st ms vis cav bi renderable supported"); -+ _eglLog(_EGL_DEBUG, "sen id sz l r g b a th cl ns b id eat nd gl es es2 es3 vg surfaces"); ++ _eglLog(_EGL_DEBUG, "cho bf lv color size dp st ms vis cav bi renderable supported" ++ " col yuv "); ++ _eglLog(_EGL_DEBUG, "sen id sz l r g b a th cl ns b id eat nd gl es es2 es3 vg surfaces" ++ " buf p sub ord"); + _eglLog(_EGL_DEBUG, "---------------"); +} + @@ -199,6 +193,26 @@ index 00000000000..13e0a8bc350 + va_end(args); +} + ++static inline const char *_enumToString(EGLint constant) ++{ ++ switch (constant) { ++ case EGL_YUV_SUBSAMPLE_4_2_0_EXT: return "420"; ++ case EGL_YUV_SUBSAMPLE_4_2_2_EXT: return "422"; ++ case EGL_YUV_SUBSAMPLE_4_4_4_EXT: return "444"; ++ case EGL_YUV_ORDER_AYUV_EXT: return "AYUV"; ++ case EGL_YUV_ORDER_UYVY_EXT: return "UYVY"; ++ case EGL_YUV_ORDER_VYUY_EXT: return "VYUY"; ++ case EGL_YUV_ORDER_YUYV_EXT: return "YUYV"; ++ case EGL_YUV_ORDER_YVYU_EXT: return "YVYU"; ++ case EGL_YUV_ORDER_YUV_EXT: return "YUV"; ++ case EGL_YUV_ORDER_YVU_EXT: return "YVU"; ++ case EGL_LUMINANCE_BUFFER: return "lum"; ++ case EGL_YUV_BUFFER_EXT: return "yuv"; ++ case EGL_RGB_BUFFER: return "rgb"; ++ default: return "?"; ++ } ++} ++ +static void +_eglGetConfigAttrs(_EGLDisplay *const dpy, _EGLConfig *const conf, + struct _printAttributes *const attr) @@ -226,6 +240,14 @@ index 00000000000..13e0a8bc350 + + success &= _eglGetConfigAttrib(dpy, conf, EGL_SAMPLES, &attr->samples); + success &= _eglGetConfigAttrib(dpy, conf, EGL_SAMPLE_BUFFERS, &attr->sampleBuffers); ++ success &= _eglGetConfigAttrib(dpy, conf, EGL_COLOR_BUFFER_TYPE, &attr->colorBufferType); ++ ++ if (conf->Display->Extensions.EXT_yuv_surface) { ++ success &= _eglGetConfigAttrib(dpy, conf, EGL_YUV_NUMBER_OF_PLANES_EXT, ++ &attr->numPlanes); ++ success &= _eglGetConfigAttrib(dpy, conf, EGL_YUV_SUBSAMPLE_EXT, &attr->subsample); ++ success &= _eglGetConfigAttrib(dpy, conf, EGL_YUV_ORDER_EXT, &attr->order); ++ } + + if (!success) + _eglLog(_EGL_DEBUG, "%s: config tainted, could not obtain all attributes", @@ -272,6 +294,13 @@ index 00000000000..13e0a8bc350 + (attr.renderable & EGL_OPENVG_BIT) ? 'y' : ' ', + attr.surfString); + ++ _snprintfStrcat(printMsg, maxMsgSize, " %3.3s", ++ _enumToString(attr.colorBufferType)); ++ ++ if (attr.colorBufferType == EGL_YUV_BUFFER_EXT) ++ _snprintfStrcat(printMsg, maxMsgSize, " %1.1d %3.3s %4.4s", attr.numPlanes, ++ _enumToString(attr.subsample), _enumToString(attr.order)); ++ + _eglLog(_EGL_DEBUG, printMsg); +} + @@ -463,10 +492,10 @@ index 2a06a34684a..a1cf9770ed8 100644 _eglLog(EGLint level, const char *fmtStr, ...); diff --git a/src/egl/meson.build b/src/egl/meson.build -index d23d62562da..e0628c41c43 100644 +index daa6a3a04f0..384bb98ebb3 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build -@@ -30,6 +30,8 @@ files_egl = files( +@@ -31,6 +31,8 @@ files_egl = files( 'main/eglapi.c', 'main/eglarray.c', 'main/eglarray.h', @@ -476,5 +505,5 @@ index d23d62562da..e0628c41c43 100644 'main/eglconfig.h', 'main/eglcontext.c', -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0038-egl-add-support-for-EXT_image_gl_colorspace.patch b/package/mesa3d/0038-egl-add-support-for-EXT_image_gl_colorspace.patch index 4d04dfe4..750fd0c4 100644 --- a/package/mesa3d/0038-egl-add-support-for-EXT_image_gl_colorspace.patch +++ b/package/mesa3d/0038-egl-add-support-for-EXT_image_gl_colorspace.patch @@ -1,7 +1,7 @@ -From 1b9ddfc2a489056311c6eff3760ad6f450d13c94 Mon Sep 17 00:00:00 2001 +From d1d64a3c11fbab083d6225857554ac1c9ad645b6 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Tue, 29 Jan 2019 14:36:25 +0000 -Subject: [PATCH 39/50] egl: add support for EXT_image_gl_colorspace +Subject: [PATCH 38/67] egl: add support for EXT_image_gl_colorspace --- src/egl/drivers/dri2/egl_dri2.c | 57 +++++++++++++++++++++++++++++++-- @@ -12,10 +12,10 @@ Subject: [PATCH 39/50] egl: add support for EXT_image_gl_colorspace 5 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index ee19d125675..f001ee7b98f 100644 +index 2f8414e0c60..6b26ff979ae 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -1113,6 +1113,9 @@ dri2_setup_screen(_EGLDisplay *disp) +@@ -1084,6 +1084,9 @@ dri2_setup_screen(_EGLDisplay *disp) dri2_dpy->image->createImageFromBuffer) { disp->Extensions.IMG_cl_image = EGL_TRUE; } @@ -25,7 +25,7 @@ index ee19d125675..f001ee7b98f 100644 } if (dri2_dpy->flush_control) -@@ -2752,6 +2755,11 @@ dri2_create_image_wayland_wl_buffer_tizen(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2724,6 +2727,11 @@ dri2_create_image_wayland_wl_buffer_tizen(_EGLDisplay *disp, _EGLContext *ctx, return NULL; } @@ -37,7 +37,7 @@ index ee19d125675..f001ee7b98f 100644 if (tbm_surface_get_info(tbm_surf, &info)) { _eglError(EGL_BAD_PARAMETER, "tbm_surface_get_info"); return NULL; -@@ -2827,6 +2835,11 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2799,6 +2807,11 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx, if (!_eglParseImageAttribList(&attrs, disp, attr_list)) return NULL; @@ -49,7 +49,7 @@ index ee19d125675..f001ee7b98f 100644 plane = attrs.PlaneWL; f = buffer->driver_format; if (plane < 0 || plane >= f->nplanes) { -@@ -2890,6 +2903,11 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx, +@@ -2862,6 +2875,11 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx, if (!_eglParseImageAttribList(&attrs, disp, attr_list)) return EGL_NO_IMAGE_KHR; @@ -61,7 +61,7 @@ index ee19d125675..f001ee7b98f 100644 switch (target) { case EGL_GL_TEXTURE_2D_KHR: if (!disp->Extensions.KHR_gl_texture_2D_image) { -@@ -3035,6 +3053,11 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx, +@@ -3007,6 +3025,11 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx, return NULL; } @@ -73,7 +73,7 @@ index ee19d125675..f001ee7b98f 100644 switch (attrs.DRMBufferFormatMESA) { case EGL_DRM_BUFFER_FORMAT_ARGB32_MESA: format = __DRI_IMAGE_FORMAT_ARGB8888; -@@ -3211,6 +3234,23 @@ dri2_num_fourcc_format_planes(EGLint format) +@@ -3189,6 +3212,23 @@ dri2_num_fourcc_format_planes(EGLint format) } } @@ -97,7 +97,7 @@ index ee19d125675..f001ee7b98f 100644 /* Returns the total number of file descriptors. Zero indicates an error. */ static unsigned dri2_check_dma_buf_format(const _EGLImageAttribs *attrs) -@@ -3356,6 +3396,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, +@@ -3334,6 +3374,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, int fds[DMA_BUF_MAX_PLANES]; int pitches[DMA_BUF_MAX_PLANES]; int offsets[DMA_BUF_MAX_PLANES]; @@ -105,7 +105,7 @@ index ee19d125675..f001ee7b98f 100644 uint64_t modifier; bool has_modifier = false; unsigned error; -@@ -3381,6 +3422,18 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, +@@ -3359,6 +3400,18 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, if (!num_fds) return NULL; @@ -124,7 +124,7 @@ index ee19d125675..f001ee7b98f 100644 for (unsigned i = 0; i < num_fds; ++i) { fds[i] = attrs.DMABufPlaneFds[i].Value; pitches[i] = attrs.DMABufPlanePitches[i].Value; -@@ -3425,7 +3478,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, +@@ -3403,7 +3456,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, } dri_image = dri2_dpy->image->createImageFromDmaBufs2(dri2_dpy->dri_screen, @@ -133,7 +133,7 @@ index ee19d125675..f001ee7b98f 100644 modifier, fds, num_fds, pitches, offsets, attrs.DMABufYuvColorSpaceHint.Value, attrs.DMABufSampleRangeHint.Value, -@@ -3437,7 +3490,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, +@@ -3415,7 +3468,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, else { dri_image = dri2_dpy->image->createImageFromDmaBufs(dri2_dpy->dri_screen, @@ -143,7 +143,7 @@ index ee19d125675..f001ee7b98f 100644 attrs.DMABufYuvColorSpaceHint.Value, attrs.DMABufSampleRangeHint.Value, diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index 893541f55b1..431dd70d1d8 100644 +index e4f2c43b4ef..2d3931dfd26 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -508,6 +508,7 @@ _eglCreateExtensionsString(_EGLDisplay *disp) @@ -213,5 +213,5 @@ index 9837f05dad1..fc02d7a265c 100644 EGLBoolean ProtectedContent; }; -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0039-meson-force-C-2011-for-thread_local.patch b/package/mesa3d/0039-meson-force-C-2011-for-thread_local.patch index 92e7d239..07639ee1 100644 --- a/package/mesa3d/0039-meson-force-C-2011-for-thread_local.patch +++ b/package/mesa3d/0039-meson-force-C-2011-for-thread_local.patch @@ -1,7 +1,7 @@ -From 04993e64906c7481f877dd6775a935259ea2d5b9 Mon Sep 17 00:00:00 2001 +From c8a6405eaf4c9693f32381fa7aa6d292e7f95716 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Mon, 24 Jun 2019 09:35:39 +0100 -Subject: [PATCH 40/50] meson: force C++ 2011 for "thread_local" +Subject: [PATCH 39/67] meson: force C++ 2011 for "thread_local" For some combinations of Meson and the GNU C++ compiler, Meson does not add '-std=c++11' to the command line arguments, resulting in @@ -14,7 +14,7 @@ command line arguments. 1 file changed, 6 insertions(+) diff --git a/meson.build b/meson.build -index 56340b8ef3b..3c55447b6eb 100644 +index 2018562a1ec..21d93d372c2 100644 --- a/meson.build +++ b/meson.build @@ -32,6 +32,12 @@ project( @@ -31,5 +31,5 @@ index 56340b8ef3b..3c55447b6eb 100644 if get_option('layout') != 'mirror' -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0040-dri2-add-support-for-swap-intervals-other-than-1.patch b/package/mesa3d/0040-dri2-add-support-for-swap-intervals-other-than-1.patch index 44c129be..8bb37349 100644 --- a/package/mesa3d/0040-dri2-add-support-for-swap-intervals-other-than-1.patch +++ b/package/mesa3d/0040-dri2-add-support-for-swap-intervals-other-than-1.patch @@ -1,7 +1,7 @@ -From dc031ad65131ed5de6e8dd8db21d49c0185d6e0b Mon Sep 17 00:00:00 2001 +From dbb0d023abb9e4bfed70144514595f0477840f3e Mon Sep 17 00:00:00 2001 From: Luigi Santivetti Date: Wed, 19 Jun 2019 16:36:06 +0100 -Subject: [PATCH 41/50] dri2: add support for swap intervals other than 1 +Subject: [PATCH 40/67] dri2: add support for swap intervals other than 1 Before this change, the swap interval was fixed at 1, with page flips scheduled on the next vblank. This change allows any swap interval @@ -22,10 +22,10 @@ Signed-off-by: Luigi Santivetti 2 files changed, 497 insertions(+), 78 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index 95435b9ee12..2fdba4bd62e 100644 +index eb2127e3fe6..64d60ed66e4 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -324,6 +324,23 @@ struct tpl_swap_queue_elem +@@ -332,6 +332,23 @@ struct tpl_swap_queue_elem }; #endif @@ -49,7 +49,7 @@ index 95435b9ee12..2fdba4bd62e 100644 struct dri2_egl_surface { _EGLSurface base; -@@ -362,13 +379,18 @@ struct dri2_egl_surface +@@ -370,13 +387,18 @@ struct dri2_egl_surface #ifdef HAVE_TIZEN_PLATFORM tpl_surface_t *tpl_surf; bool reset; @@ -69,7 +69,7 @@ index 95435b9ee12..2fdba4bd62e 100644 int swap_queue_idx_head; int swap_queue_idx_tail; pthread_t swap_queue_processor; -@@ -404,7 +426,7 @@ struct dri2_egl_surface +@@ -412,7 +434,7 @@ struct dri2_egl_surface #endif bool locked; int age; @@ -78,7 +78,7 @@ index 95435b9ee12..2fdba4bd62e 100644 #endif #ifdef HAVE_ANDROID_PLATFORM -@@ -433,7 +455,13 @@ struct dri2_egl_surface +@@ -442,7 +464,13 @@ struct dri2_egl_surface #endif #ifdef HAVE_NULL_PLATFORM @@ -94,7 +94,7 @@ index 95435b9ee12..2fdba4bd62e 100644 int out_fence_fd; diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c -index 2b3b08cc259..0b20aef9e4d 100644 +index fb03ecc36fd..5b7c1ec426c 100644 --- a/src/egl/drivers/dri2/platform_null.c +++ b/src/egl/drivers/dri2/platform_null.c @@ -31,6 +31,7 @@ @@ -730,7 +730,7 @@ index 2b3b08cc259..0b20aef9e4d 100644 .swap_buffers = dri2_null_swap_buffers, .query_buffer_age = dri2_null_query_buffer_age, .get_dri_drawable = dri2_surface_get_dri_drawable, -@@ -1059,12 +1431,35 @@ dri2_null_add_configs_for_formats(_EGLDisplay *disp) +@@ -1062,12 +1434,35 @@ dri2_null_add_configs_for_formats(_EGLDisplay *disp) return count != 0; } @@ -767,7 +767,7 @@ index 2b3b08cc259..0b20aef9e4d 100644 int err; dri2_dpy = calloc(1, sizeof(*dri2_dpy)); -@@ -1111,11 +1506,7 @@ dri2_initialize_null(_EGLDisplay *disp) +@@ -1114,11 +1509,7 @@ dri2_initialize_null(_EGLDisplay *disp) } dri2_setup_screen(disp); @@ -781,5 +781,5 @@ index 2b3b08cc259..0b20aef9e4d 100644 if (dri2_dpy->image->base.version < NULL_IMAGE_EXTENSION_VERSION_MIN) { _eglError(EGL_NOT_INITIALIZED, "image extension version too old"); -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0041-null_platform-add-support-for-explicit-synchronisati.patch b/package/mesa3d/0041-null_platform-add-support-for-explicit-synchronisati.patch index ab394328..6a3b6491 100644 --- a/package/mesa3d/0041-null_platform-add-support-for-explicit-synchronisati.patch +++ b/package/mesa3d/0041-null_platform-add-support-for-explicit-synchronisati.patch @@ -1,7 +1,7 @@ -From 58d5fa48cf14a930322b5645dd5e26c8b546f394 Mon Sep 17 00:00:00 2001 +From d286d05d0d84c913c8bfcbe8f693083caf3bcc77 Mon Sep 17 00:00:00 2001 From: Silvestrs Timofejevs Date: Mon, 2 Sep 2019 09:32:01 +0100 -Subject: [PATCH 42/50] null_platform: add support for explicit synchronisation +Subject: [PATCH 41/67] null_platform: add support for explicit synchronisation This change adds support for the 'in' fence, the 'out' fence will potentially be added in subsequent optimisation changes. @@ -42,10 +42,10 @@ Change-Id: Ib9c4a0bc3ea1b21192ee37909d7580d6b7b366ec 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index 2fdba4bd62e..3d5c9adb4f3 100644 +index 64d60ed66e4..eb6e4551087 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -100,6 +100,7 @@ struct wl_buffer; +@@ -106,6 +106,7 @@ struct wl_buffer; #ifdef HAVE_NULL_PLATFORM struct display_output { bool in_use; @@ -53,7 +53,7 @@ index 2fdba4bd62e..3d5c9adb4f3 100644 uint32_t connector_id; drmModePropertyRes **connector_prop_res; uint32_t crtc_id; -@@ -330,6 +331,7 @@ struct swap_queue_elem +@@ -338,6 +339,7 @@ struct swap_queue_elem uint32_t swap_interval; uint32_t back_id; uint32_t fb_id; @@ -62,7 +62,7 @@ index 2fdba4bd62e..3d5c9adb4f3 100644 enum { diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c -index 0b20aef9e4d..c25ae0b2a04 100644 +index 5b7c1ec426c..d36dc0ced2a 100644 --- a/src/egl/drivers/dri2/platform_null.c +++ b/src/egl/drivers/dri2/platform_null.c @@ -401,6 +401,9 @@ display_output_atomic_init(int fd, struct display_output *output) @@ -210,5 +210,5 @@ index 0b20aef9e4d..c25ae0b2a04 100644 err_free_surface: -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0042-egl-null-add-support-for-DRM-image-format-modifiers.patch b/package/mesa3d/0042-egl-null-add-support-for-DRM-image-format-modifiers.patch new file mode 100644 index 00000000..fbd970ca --- /dev/null +++ b/package/mesa3d/0042-egl-null-add-support-for-DRM-image-format-modifiers.patch @@ -0,0 +1,401 @@ +From 4f9ca104c16a6eb1af770e2447adb4413fb41cb7 Mon Sep 17 00:00:00 2001 +From: Luigi Santivetti +Date: Thu, 26 Sep 2019 13:32:15 +0100 +Subject: [PATCH 42/68] egl/null: add support for DRM image format modifiers + +This change introduces support for image modifiers to platform_null. In +order for it to create an image with modifiers, it relies on libdrm to +iterate all formats with associated modifiers supported by the display +for the primary drm plane in use. + +drmModeFormatModifierBlobIterNext() is added to the DRM api in a different +change and it is not upstream at present. + +Internal notes: + [1] IN_FORMATS blobs are available since kernel 4.14: + - db1689aa61bd1efb5ce9b896e7aa860a85b7f1b6 + - https://patchwork.freedesktop.org/patch/168543 + + [2] the dri image->base.version threshold is 14. + - Unlike for platform_wayland, where no details were found regarding + why it's using 15 + - dri_interface.h makes createImageWithModifiers available since + version 14 + - dri/gbm_dri.c as an example checks for minimum version 14. + +Change-Id: I0f7b030f6e1943690692674bf18daabfc153208a +Signed-off-by: Luigi Santivetti +--- + meson.build | 5 + + src/egl/drivers/dri2/egl_dri2.h | 3 + + src/egl/drivers/dri2/platform_null.c | 221 +++++++++++++++++++++++---- + 3 files changed, 203 insertions(+), 26 deletions(-) + +diff --git a/meson.build b/meson.build +index 21d93d372c2..ca89b8ac20d 100644 +--- a/meson.build ++++ b/meson.build +@@ -1581,6 +1581,11 @@ if with_gallium_etnaviv + _drm_ver = '2.4.89' + endif + ++# platform_null relies on DRM format-modifier iterators available since 2.4.108 ++if with_platform_null ++ _drm_ver = '2.4.108' ++endif ++ + # Loop over the enables versions and get the highest libdrm requirement for all + # active drivers. + _drm_blame = '' +diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h +index eb6e4551087..32ad720b343 100644 +--- a/src/egl/drivers/dri2/egl_dri2.h ++++ b/src/egl/drivers/dri2/egl_dri2.h +@@ -117,6 +117,8 @@ struct display_output { + uint32_t mode_blob_id; + unsigned formats; + drmModeAtomicReq *atomic_state; ++ uint32_t in_formats_id; ++ struct u_vector modifiers; + }; + #endif + +@@ -280,6 +282,7 @@ struct dri2_egl_display + + #ifdef HAVE_NULL_PLATFORM + bool atomic_enabled; ++ bool in_formats_enabled; + struct display_output output; + #endif + +diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c +index d36dc0ced2a..2c79199da26 100644 +--- a/src/egl/drivers/dri2/platform_null.c ++++ b/src/egl/drivers/dri2/platform_null.c +@@ -40,6 +40,7 @@ + #include + #include + #include ++#include + #include + + #include "egl_dri2.h" +@@ -156,6 +157,18 @@ format_idx_get_from_drm_format(uint32_t drm_format) + return -1; + } + ++static inline uint32_t ++blob_id_from_property_value(uint64_t prop_value) ++{ ++ /* The KMS properties documetation, 01.org/linuxgraphics, says: ++ * ++ * For all property types except blob properties the value is a 64-bit ++ * unsigned integer. ++ */ ++ assert(!(prop_value >> 32)); ++ return (uint32_t) prop_value; ++} ++ + static int + atomic_state_add_object_properties(drmModeAtomicReq *atomic_state, + const struct object_property *props, +@@ -645,7 +658,66 @@ drm_event_process(int fd) + } + + static bool +-display_output_init(int fd, struct display_output *output, bool use_atomic) ++plane_init_in_formats(int fd, drmModePlane *plane, struct u_vector *modifiers, ++ uint32_t *in_formats_id_out, unsigned *formats_out) ++{ ++ uint32_t blob_id, prev_fmt = DRM_FORMAT_INVALID, count_formats = 0; ++ drmModeFormatModifierIterator drm_iter = {0}; ++ drmModePropertyBlobRes *blob; ++ uint64_t prop_value; ++ int idx, err; ++ ++ assert(plane && in_formats_id_out && formats_out); ++ ++ err = !object_property_value_for_name(fd, plane->plane_id, ++ DRM_MODE_OBJECT_PLANE, ++ "IN_FORMATS", &prop_value); ++ if (err) ++ return false; ++ ++ blob_id = blob_id_from_property_value(prop_value); ++ blob = drmModeGetPropertyBlob(fd, blob_id); ++ ++ while (drmModeFormatModifierBlobIterNext(blob, &drm_iter)) { ++ if (drm_iter.fmt != prev_fmt) { ++ prev_fmt = drm_iter.fmt; ++ count_formats++; ++ ++ idx = format_idx_get_from_drm_format(drm_iter.fmt); ++ if (idx < 0) ++ continue; ++ ++ *formats_out |= (1 << idx); ++ } ++ } ++ ++ drmModeFreePropertyBlob(blob); ++ ++ if (!count_formats) { ++ /* None of the formats in the IN_FORMATS blob has associated modifiers */ ++ _eglLog(_EGL_WARNING, "no format-modifiers found in IN_FORMATS"); ++ return false; ++ } ++ ++ if (plane->count_formats != count_formats) ++ /* Only some of the formats in the IN_FORMATS blob have associated modifiers, ++ * try to use this subset. ++ */ ++ _eglLog(_EGL_WARNING, "discarding formats without modifiers"); ++ ++ /* Allocate space for modifiers, if ENOMEM fallback to plane formats */ ++ if (!u_vector_init(modifiers, sizeof(uint64_t), 64)) { ++ _eglLog(_EGL_WARNING, "failed to allocate modifiers"); ++ return false; ++ } ++ ++ *in_formats_id_out = blob_id; ++ return true; ++} ++ ++static bool ++display_output_init(int fd, struct display_output *output, bool use_atomic, ++ bool prefer_in_formats, bool *in_formats_enabled_out) + { + drmModeRes *resources; + drmModeConnector *connector; +@@ -674,16 +746,34 @@ display_output_init(int fd, struct display_output *output, bool use_atomic) + goto err_free_plane; + output->mode = connector->modes[mode_idx]; + +- /* Record the display supported formats */ +- for (unsigned i = 0; i < plane->count_formats; i++) { +- int format_idx; ++ assert(in_formats_enabled_out && !(*in_formats_enabled_out)); + +- format_idx = format_idx_get_from_drm_format(plane->formats[i]); +- if (format_idx == -1) +- continue; ++ /* Track display supported formats. Look them up from IN_FORMATS blobs ++ * if they are available, otherwise use plane formats. ++ */ ++ if (prefer_in_formats) ++ *in_formats_enabled_out = plane_init_in_formats(fd, plane, ++ &output->modifiers, ++ &output->in_formats_id, ++ &output->formats); + +- output->formats |= (1 << format_idx); ++ if (!*in_formats_enabled_out) { ++ _eglLog(_EGL_WARNING, "fallback to plane formats"); ++ ++ for (unsigned i = 0; i < plane->count_formats; i++) { ++ int format_idx; ++ ++ format_idx = format_idx_get_from_drm_format(plane->formats[i]); ++ if (format_idx == -1) ++ continue; ++ ++ output->formats |= (1 << format_idx); ++ } + } ++ ++ /* At this point we can only shut down if the look up failed and ++ * it is safe to pass NULL to drmModeFreeFormats(). ++ */ + if (!output->formats) + goto err_free_plane; + +@@ -983,10 +1073,12 @@ static bool + add_fb_for_dri_image(struct dri2_egl_display *dri2_dpy, __DRIimage *image, + uint32_t *fb_id_out) + { ++ uint64_t modifiers[4] = {0}; + uint32_t handles[4] = {0}; + uint32_t pitches[4] = {0}; + uint32_t offsets[4] = {0}; +- int handle, stride, width, height, format; ++ uint32_t flags = 0; ++ int handle, stride, width, height, format, l_mod, h_mod; + int format_idx; + + dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_HANDLE, &handle); +@@ -1001,9 +1093,47 @@ add_fb_for_dri_image(struct dri2_egl_display *dri2_dpy, __DRIimage *image, + format_idx = format_idx_get_from_dri_image_format(format); + assert(format_idx != -1); + +- return !drmModeAddFB2(dri2_dpy->fd, width, height, +- dri2_null_formats[format_idx].drm_format, +- handles, pitches, offsets, fb_id_out, 0); ++ if (dri2_dpy->in_formats_enabled) { ++ dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_MODIFIER_UPPER, &h_mod); ++ dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_MODIFIER_LOWER, &l_mod); ++ ++ modifiers[0] = combine_u32_into_u64((uint32_t) h_mod, (uint32_t) l_mod); ++ flags |= DRM_MODE_FB_MODIFIERS; ++ } ++ ++ return !drmModeAddFB2WithModifiers(dri2_dpy->fd, width, height, ++ dri2_null_formats[format_idx].drm_format, ++ handles, pitches, offsets, modifiers, ++ fb_id_out, flags); ++} ++ ++static __DRIimage * ++create_image(struct dri2_egl_surface *dri2_surf, uint32_t flags) ++{ ++ struct dri2_egl_display *dri2_dpy = ++ dri2_egl_display(dri2_surf->base.Resource.Display); ++ uint32_t count_modifiers; ++ uint64_t *modifiers; ++ ++ if (dri2_dpy->in_formats_enabled) { ++ count_modifiers = u_vector_length(&dri2_dpy->output.modifiers); ++ modifiers = u_vector_tail(&dri2_dpy->output.modifiers); ++ ++ return dri2_dpy->image->createImageWithModifiers(dri2_dpy->dri_screen, ++ dri2_surf->base.Width, ++ dri2_surf->base.Height, ++ dri2_surf->format, ++ modifiers, ++ count_modifiers, ++ NULL); ++ } ++ ++ return dri2_dpy->image->createImage(dri2_dpy->dri_screen, ++ dri2_surf->base.Width, ++ dri2_surf->base.Height, ++ dri2_surf->format, ++ flags, ++ NULL); + } + + static bool +@@ -1016,12 +1146,7 @@ get_front_bo(struct dri2_egl_surface *dri2_surf) + if (dri2_surf->base.Type == EGL_WINDOW_BIT) + use |= __DRI_IMAGE_USE_SCANOUT; + +- dri2_surf->front = dri2_dpy->image->createImage(dri2_dpy->dri_screen, +- dri2_surf->base.Width, +- dri2_surf->base.Height, +- dri2_surf->format, +- use, +- NULL); ++ dri2_surf->front = create_image(dri2_surf, use); + if (!dri2_surf->front) + return false; + +@@ -1058,13 +1183,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) + } + + if (!dri2_surf->back->dri_image) { +- dri2_surf->back->dri_image = +- dri2_dpy->image->createImage(dri2_dpy->dri_screen, +- dri2_surf->base.Width, +- dri2_surf->base.Height, +- dri2_surf->format, +- __DRI_IMAGE_USE_SCANOUT, +- NULL); ++ dri2_surf->back->dri_image = create_image(dri2_surf, ++ __DRI_IMAGE_USE_SCANOUT); + if (!dri2_surf->back->dri_image) + goto err_unlock; + } +@@ -1094,6 +1214,30 @@ static void surface_swap_queue_init(struct dri2_egl_surface *dri2_surf) + swap_queue[i].kms_in_fence_fd = -1; + } + ++static bool ++in_formats_get_modifiers(const int fd, const uint32_t in_formats_id, ++ const int drm_format, struct u_vector *modifiers) ++{ ++ drmModeFormatModifierIterator drm_iter = {0}; ++ drmModePropertyBlobRes *blob; ++ uint64_t *mod = NULL; ++ ++ blob = drmModeGetPropertyBlob(fd, in_formats_id); ++ ++ while (drmModeFormatModifierBlobIterNext(blob, &drm_iter)) { ++ if (drm_iter.fmt == drm_format) { ++ assert(drm_iter.mod != DRM_FORMAT_MOD_INVALID); ++ ++ mod = u_vector_add(modifiers); ++ *mod = drm_iter.mod; ++ } ++ } ++ ++ drmModeFreePropertyBlob(blob); ++ ++ return mod != NULL; ++} ++ + static _EGLSurface * + create_surface(_EGLDisplay *disp, _EGLConfig *config, EGLint type, + const EGLint *attrib_list) +@@ -1105,6 +1249,7 @@ create_surface(_EGLDisplay *disp, _EGLConfig *config, EGLint type, + const __DRIconfig *dri_config; + _EGLSurface *surf; + int format_idx; ++ bool ret; + + dri2_surf = calloc(1, sizeof(*dri2_surf)); + if (!dri2_surf) { +@@ -1137,6 +1282,15 @@ create_surface(_EGLDisplay *disp, _EGLConfig *config, EGLint type, + + dri2_surf->format = dri2_null_formats[format_idx].dri_image_format; + ++ if (dri2_dpy->in_formats_enabled) { ++ ret = in_formats_get_modifiers(dri2_dpy->fd, ++ dri2_dpy->output.in_formats_id, ++ dri2_null_formats[format_idx].drm_format, ++ &dri2_dpy->output.modifiers); ++ if (!ret) ++ goto err_free_surface; ++ } ++ + surface_swap_queue_init(dri2_surf); + + return surf; +@@ -1536,6 +1690,8 @@ EGLBoolean + dri2_initialize_null(_EGLDisplay *disp) + { + struct dri2_egl_display *dri2_dpy; ++ bool prefer_in_formats = false; ++ uint64_t value; + int err; + + dri2_dpy = calloc(1, sizeof(*dri2_dpy)); +@@ -1589,8 +1745,19 @@ dri2_initialize_null(_EGLDisplay *disp) + goto cleanup; + } + ++ err = drmGetCap(dri2_dpy->fd_dpy, DRM_CAP_ADDFB2_MODIFIERS, &value); ++ if (!err && value) { ++ /* in_formats could be supported by the platform, however not being ++ * actually enabled, i.e. in_formats init can still fail. ++ */ ++ prefer_in_formats = dri2_dpy->image->base.version >= 14 && ++ dri2_dpy->image->createImageWithModifiers; ++ } ++ + if (!display_output_init(dri2_dpy->fd, &dri2_dpy->output, +- dri2_dpy->atomic_enabled)) { ++ dri2_dpy->atomic_enabled, ++ prefer_in_formats, ++ &dri2_dpy->in_formats_enabled)) { + _eglError(EGL_NOT_INITIALIZED, "failed to create output"); + goto cleanup; + } +@@ -1640,4 +1807,6 @@ dri2_teardown_null(struct dri2_egl_display *dri2_dpy) + drmModeFreeProperty(dri2_dpy->output.connector_prop_res[i]); + free(dri2_dpy->output.connector_prop_res); + } ++ ++ u_vector_finish(&dri2_dpy->output.modifiers); + } +-- +2.25.1 + diff --git a/package/mesa3d/0043-egl-query-the-supported-ES2-context-version.patch b/package/mesa3d/0043-egl-query-the-supported-ES2-context-version.patch index 342692d6..6f2d9b46 100644 --- a/package/mesa3d/0043-egl-query-the-supported-ES2-context-version.patch +++ b/package/mesa3d/0043-egl-query-the-supported-ES2-context-version.patch @@ -1,7 +1,7 @@ -From 7c21f010de28888376dcafd99d3fa43d15279dc6 Mon Sep 17 00:00:00 2001 +From 1e6466e541e1fc67198be3eeb090e3af22bd6d19 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Mon, 10 Feb 2020 09:23:03 +0000 -Subject: [PATCH 44/50] egl: query the supported ES2 context version +Subject: [PATCH 43/67] egl: query the supported ES2 context version For OpenGL ES contexts, the EGL specification states that querying EGL_CONTEXT_CLIENT_VERSION with eglQueryContext may return a version @@ -39,10 +39,10 @@ large value it currently has. 7 files changed, 50 insertions(+), 4 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h -index 8214e7a55c3..302e4e08de0 100644 +index 6490f6e80e2..9c7bcac4cae 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h -@@ -2028,6 +2028,8 @@ typedef struct __DRIDriverVtableExtensionRec { +@@ -2052,6 +2052,8 @@ typedef struct __DRIDriverVtableExtensionRec { #define __DRI2_RENDERER_HAS_PROTECTED_CONTENT 0x000e @@ -52,10 +52,10 @@ index 8214e7a55c3..302e4e08de0 100644 struct __DRI2rendererQueryExtensionRec { __DRIextension base; diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index f001ee7b98f..cda414f4adc 100644 +index 6b26ff979ae..c4a49cae592 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -2083,6 +2083,26 @@ dri2_make_current(_EGLDisplay *disp, _EGLSurface *dsurf, +@@ -2055,6 +2055,26 @@ dri2_make_current(_EGLDisplay *disp, _EGLSurface *dsurf, return EGL_TRUE; } @@ -82,7 +82,7 @@ index f001ee7b98f..cda414f4adc 100644 __DRIdrawable * dri2_surface_get_dri_drawable(_EGLSurface *surf) { -@@ -4347,6 +4367,7 @@ const _EGLDriver _eglDriver = { +@@ -4336,6 +4356,7 @@ const _EGLDriver _eglDriver = { .CreateContext = dri2_create_context, .DestroyContext = dri2_destroy_context, .MakeCurrent = dri2_make_current, @@ -91,7 +91,7 @@ index f001ee7b98f..cda414f4adc 100644 .CreatePixmapSurface = dri2_create_pixmap_surface, .CreatePbufferSurface = dri2_create_pbuffer_surface, diff --git a/src/egl/drivers/haiku/egl_haiku.cpp b/src/egl/drivers/haiku/egl_haiku.cpp -index 8eda31c2936..6fc58371063 100644 +index 18c73c9cd8b..2690a82eb75 100644 --- a/src/egl/drivers/haiku/egl_haiku.cpp +++ b/src/egl/drivers/haiku/egl_haiku.cpp @@ -297,6 +297,14 @@ haiku_make_current(_EGLDisplay *disp, _EGLSurface *dsurf, @@ -118,7 +118,7 @@ index 8eda31c2936..6fc58371063 100644 .CreatePixmapSurface = haiku_create_pixmap_surface, .CreatePbufferSurface = haiku_create_pbuffer_surface, diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c -index 431dd70d1d8..900ef7ab4cc 100644 +index 2d3931dfd26..1cbff9656e4 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -948,7 +948,7 @@ eglQueryContext(EGLDisplay dpy, EGLContext ctx, @@ -131,7 +131,7 @@ index 431dd70d1d8..900ef7ab4cc 100644 RETURN_EGL_EVAL(disp, ret); } diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c -index 65dc886abbb..09e7d3ee589 100644 +index 15de7c99496..7274d246194 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -35,6 +35,7 @@ @@ -199,5 +199,5 @@ index 12f9a0aab86..92af8bd16d5 100644 /* surface funcs */ _EGLSurface *(*CreateWindowSurface)(_EGLDisplay *disp, _EGLConfig *config, -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0044-meson-allow-libGL-to-be-built-without-GLX.patch b/package/mesa3d/0044-meson-allow-libGL-to-be-built-without-GLX.patch index 0f347bf4..fc079b66 100644 --- a/package/mesa3d/0044-meson-allow-libGL-to-be-built-without-GLX.patch +++ b/package/mesa3d/0044-meson-allow-libGL-to-be-built-without-GLX.patch @@ -1,7 +1,7 @@ -From 43662126e9973c6cff496ba32fae3cf372e0646b Mon Sep 17 00:00:00 2001 +From 64e6997ded5825f10125313ea15e3164bdad769b Mon Sep 17 00:00:00 2001 From: Brendan King Date: Thu, 11 Jun 2020 12:29:51 +0100 -Subject: [PATCH 45/50] meson: allow libGL to be built without GLX +Subject: [PATCH 44/67] meson: allow libGL to be built without GLX If Meson is run with option "glx" set to "null", build the OpenGL library without GLX. @@ -15,16 +15,16 @@ with OpenGL on platforms other than X11. meson.build | 8 ++++++-- meson_options.txt | 2 +- src/egl/main/eglcurrent.h | 7 +++---- - src/glx/meson.build | 16 ++++++++++++---- + src/glx/meson.build | 20 ++++++++++++++++---- src/meson.build | 2 +- - 5 files changed, 23 insertions(+), 12 deletions(-) + 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build -index 3c55447b6eb..af020203752 100644 +index 21d93d372c2..8db1699729a 100644 --- a/meson.build +++ b/meson.build -@@ -459,6 +459,10 @@ else - with_egl = false +@@ -485,6 +485,10 @@ if with_egl and not _platforms.contains(egl_native_platform) + error('-Degl-native-platform does not specify an enabled platform') endif +if with_egl and with_opengl and with_glx != 'disabled' @@ -33,9 +33,9 @@ index 3c55447b6eb..af020203752 100644 + # Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS. use_elf_tls = false - if not ['windows', 'freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and (not with_platform_android or get_option('platform-sdk-version') >= 29) -@@ -466,7 +470,7 @@ if not ['windows', 'freebsd', 'openbsd', 'haiku'].contains(host_machine.system() - use_elf_tls = true + if (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and +@@ -502,7 +506,7 @@ if (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and + endif endif -if with_glx != 'disabled' @@ -43,7 +43,7 @@ index 3c55447b6eb..af020203752 100644 if not (with_platform_x11 and with_any_opengl) error('Cannot build GLX support without X11 platform support and at least one OpenGL API') elif with_glx == 'gallium-xlib' -@@ -528,7 +532,7 @@ if with_any_vk and (with_platform_x11 and not with_dri3) +@@ -564,7 +568,7 @@ if with_any_vk and (with_platform_x11 and not with_dri3) error('Vulkan drivers require dri3 for X11 support') endif if with_dri @@ -53,10 +53,10 @@ index 3c55447b6eb..af020203752 100644 endif endif diff --git a/meson_options.txt b/meson_options.txt -index 9073223e8f5..4038629544e 100644 +index d90a25f97ff..d36e714ea4c 100644 --- a/meson_options.txt +++ b/meson_options.txt -@@ -267,7 +267,7 @@ option( +@@ -290,7 +290,7 @@ option( 'glx', type : 'combo', value : 'auto', @@ -85,14 +85,18 @@ index 32570970947..dcc418afd6f 100644 } diff --git a/src/glx/meson.build b/src/glx/meson.build -index 58f9e1aa896..41ca936b8f4 100644 +index 8f642d5e14b..605a9717e37 100644 --- a/src/glx/meson.build +++ b/src/glx/meson.build -@@ -126,7 +126,11 @@ gl_lib_cargs = [ - '-D_REENTRANT', - ] +@@ -122,7 +122,15 @@ else + ) + endif -libglx = static_library( ++gl_lib_cargs = [ ++ '-D_REENTRANT', ++] ++ +if with_glx == 'null' + libglx_link = [libglapi] + libglx_link_whole = [libglapi_static] @@ -101,7 +105,7 @@ index 58f9e1aa896..41ca936b8f4 100644 'glx', [files_libglx, glx_generated], include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_glapi, inc_loader], -@@ -143,13 +147,17 @@ libglx = static_library( +@@ -138,13 +146,17 @@ libglx = static_library( idep_mesautil, idep_xmlconfig, dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_glvnd, ], @@ -123,10 +127,10 @@ index 58f9e1aa896..41ca936b8f4 100644 dependencies : [ dep_libdrm, dep_dl, dep_m, dep_thread, dep_x11, dep_xcb_glx, dep_xcb, diff --git a/src/meson.build b/src/meson.build -index d96c754a63d..a92580b2dd5 100644 +index c3bab27718d..f6eede56648 100644 --- a/src/meson.build +++ b/src/meson.build -@@ -104,7 +104,7 @@ subdir('loader') +@@ -110,7 +110,7 @@ subdir('loader') if with_platform_haiku subdir('hgl') endif @@ -136,5 +140,5 @@ index d96c754a63d..a92580b2dd5 100644 endif if with_gbm -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0045-egl-wayland-process-non-resized-window-movement.patch b/package/mesa3d/0045-egl-wayland-process-non-resized-window-movement.patch index 9fcfb3c2..a20ca770 100644 --- a/package/mesa3d/0045-egl-wayland-process-non-resized-window-movement.patch +++ b/package/mesa3d/0045-egl-wayland-process-non-resized-window-movement.patch @@ -1,7 +1,7 @@ -From bc8f13db460c79ef9036e7f0983bb039ac1af777 Mon Sep 17 00:00:00 2001 +From 394d340dda351452571ec8861d6768c52d338251 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Tue, 25 Aug 2020 14:12:32 +0100 -Subject: [PATCH 46/50] egl/wayland: process non-resized window movement +Subject: [PATCH 45/67] egl/wayland: process non-resized window movement The dx and dy parameters to the wl_egl_window_resize function were not being processed unless the window width or height were being @@ -11,10 +11,10 @@ changed. 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c -index de12ec21f53..f4b43aa26a2 100644 +index 72456d5d748..06272d4081e 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c -@@ -265,6 +265,9 @@ resize_callback(struct wl_egl_window *wl_win, void *data) +@@ -266,6 +266,9 @@ resize_callback(struct wl_egl_window *wl_win, void *data) struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display); @@ -24,7 +24,7 @@ index de12ec21f53..f4b43aa26a2 100644 if (dri2_surf->base.Width == wl_win->width && dri2_surf->base.Height == wl_win->height) return; -@@ -799,8 +802,6 @@ update_buffers(struct dri2_egl_display *dri2_dpy, +@@ -786,8 +789,6 @@ update_buffers(struct dri2_egl_display *dri2_dpy, dri2_surf->base.Width = dri2_surf->wl_win->width; dri2_surf->base.Height = dri2_surf->wl_win->height; @@ -32,7 +32,7 @@ index de12ec21f53..f4b43aa26a2 100644 - dri2_surf->dy = dri2_surf->wl_win->dy; } - if (dri2_surf->base.Width != dri2_surf->wl_win->attached_width || + if (dri2_surf->wl_win && -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0046-Separate-EXT_framebuffer_object-from-ARB-version.patch b/package/mesa3d/0046-Separate-EXT_framebuffer_object-from-ARB-version.patch index 0f1f2416..f0cfb1ef 100644 --- a/package/mesa3d/0046-Separate-EXT_framebuffer_object-from-ARB-version.patch +++ b/package/mesa3d/0046-Separate-EXT_framebuffer_object-from-ARB-version.patch @@ -1,7 +1,7 @@ -From 22afb695d4598a52198f9bbe98b359f9fcf77cfa Mon Sep 17 00:00:00 2001 +From ed4671544a6add01e87e94c04df59a600403dd21 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Mon, 10 Mar 2014 13:43:45 +0000 -Subject: [PATCH 47/50] Separate EXT_framebuffer_object from ARB version +Subject: [PATCH 46/67] Separate EXT_framebuffer_object from ARB version This patch separates the EXT_framebuffer_object entry points from the ARB equivalents. @@ -145,36 +145,36 @@ index 6c0e54af1c9..957b6a3a632 100644 diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py -index 32fb3b8f4f7..ecd650ab814 100644 +index e231c176264..974f366d7b4 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py -@@ -1694,6 +1694,21 @@ offsets = { - "FramebufferTextureMultisampleMultiviewOVR" : 1658, - "MultiDrawArraysIndirectEXT" : 1659, - "MultiDrawElementsIndirectEXT" : 1660, -+ "IsRenderbufferEXT" : 1661, -+ "DeleteRenderbuffersEXT" : 1662, -+ "GenRenderbuffersEXT" : 1663, -+ "RenderbufferStorageEXT" : 1664, -+ "GetRenderbufferParameterivEXT" : 1665, -+ "IsFramebufferEXT" : 1666, -+ "DeleteFramebuffersEXT" : 1667, -+ "GenFramebuffersEXT" : 1668, -+ "CheckFramebufferStatusEXT" : 1669, -+ "FramebufferTexture1DEXT" : 1670, -+ "FramebufferTexture2DEXT" : 1671, -+ "FramebufferTexture3DEXT" : 1672, -+ "FramebufferRenderbufferEXT" : 1673, -+ "GetFramebufferAttachmentParameterivEXT" : 1674, -+ "GenerateMipmapEXT" : 1675, +@@ -1706,6 +1706,21 @@ offsets = { + "FramebufferTextureMultisampleMultiviewOVR" : 1670, + "MultiDrawArraysIndirectEXT" : 1671, + "MultiDrawElementsIndirectEXT" : 1672, ++ "IsRenderbufferEXT" : 1673, ++ "DeleteRenderbuffersEXT" : 1674, ++ "GenRenderbuffersEXT" : 1675, ++ "RenderbufferStorageEXT" : 1676, ++ "GetRenderbufferParameterivEXT" : 1677, ++ "IsFramebufferEXT" : 1678, ++ "DeleteFramebuffersEXT" : 1679, ++ "GenFramebuffersEXT" : 1680, ++ "CheckFramebufferStatusEXT" : 1681, ++ "FramebufferTexture1DEXT" : 1682, ++ "FramebufferTexture2DEXT" : 1683, ++ "FramebufferTexture3DEXT" : 1684, ++ "FramebufferRenderbufferEXT" : 1685, ++ "GetFramebufferAttachmentParameterivEXT" : 1686, ++ "GenerateMipmapEXT" : 1687, } functions = [ diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c -index 798f59d2499..21507ff7c19 100644 +index 49893165250..885aa442911 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c -@@ -1973,6 +1973,11 @@ _mesa_detach_renderbuffer(struct gl_context *ctx, +@@ -1995,6 +1995,11 @@ _mesa_detach_renderbuffer(struct gl_context *ctx, return progress; } @@ -186,7 +186,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) -@@ -2682,6 +2687,12 @@ renderbuffer_storage_target(GLenum target, GLenum internalFormat, +@@ -2722,6 +2727,12 @@ renderbuffer_storage_target(GLenum target, GLenum internalFormat, } @@ -199,7 +199,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) { -@@ -2712,6 +2723,11 @@ _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +@@ -2752,6 +2763,11 @@ _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image); } @@ -211,7 +211,7 @@ index 798f59d2499..21507ff7c19 100644 /** * Helper function for _mesa_GetRenderbufferParameteriv() and -@@ -2744,6 +2760,12 @@ _mesa_RenderbufferStorage(GLenum target, GLenum internalFormat, +@@ -2784,6 +2800,12 @@ _mesa_RenderbufferStorage(GLenum target, GLenum internalFormat, NO_SAMPLES, 0, "glRenderbufferStorage"); } @@ -224,7 +224,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, -@@ -2945,6 +2967,11 @@ _mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname, +@@ -2985,6 +3007,11 @@ _mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname, "glGetNamedRenderbufferParameteriv"); } @@ -236,7 +236,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_GetNamedRenderbufferParameterivEXT(GLuint renderbuffer, GLenum pname, -@@ -2978,6 +3005,11 @@ _mesa_IsFramebuffer(GLuint framebuffer) +@@ -3018,6 +3045,11 @@ _mesa_IsFramebuffer(GLuint framebuffer) return GL_FALSE; } @@ -248,7 +248,7 @@ index 798f59d2499..21507ff7c19 100644 /** * Check if any of the attachments of the given framebuffer are textures -@@ -3212,6 +3244,11 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers) +@@ -3253,6 +3285,11 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers) } } @@ -260,7 +260,7 @@ index 798f59d2499..21507ff7c19 100644 /** * This is the implementation for glGenFramebuffers and glCreateFramebuffers. -@@ -3258,6 +3295,11 @@ create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa) +@@ -3299,6 +3336,11 @@ create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa) _mesa_HashUnlockMutex(ctx->Shared->FrameBuffers); } @@ -272,7 +272,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers) -@@ -3297,6 +3339,11 @@ _mesa_check_framebuffer_status(struct gl_context *ctx, +@@ -3338,6 +3380,11 @@ _mesa_check_framebuffer_status(struct gl_context *ctx, return buffer->_Status; } @@ -284,7 +284,7 @@ index 798f59d2499..21507ff7c19 100644 GLenum GLAPIENTRY _mesa_CheckFramebufferStatus_no_error(GLenum target) -@@ -3909,6 +3956,12 @@ _mesa_FramebufferTexture1D_no_error(GLenum target, GLenum attachment, +@@ -3950,6 +3997,12 @@ _mesa_FramebufferTexture1D_no_error(GLenum target, GLenum attachment, texture, level, 0); } @@ -297,7 +297,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_FramebufferTexture1D(GLenum target, GLenum attachment, -@@ -3949,6 +4002,12 @@ _mesa_FramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, +@@ -3990,6 +4043,12 @@ _mesa_FramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, false); } @@ -310,7 +310,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_FramebufferTexture3D_no_error(GLenum target, GLenum attachment, -@@ -4059,6 +4118,15 @@ frame_buffer_texture(GLuint framebuffer, GLenum target, +@@ -4100,6 +4159,15 @@ frame_buffer_texture(GLuint framebuffer, GLenum target, level, 0, layer, layered); } @@ -326,7 +326,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_FramebufferTextureLayer_no_error(GLenum target, GLenum attachment, GLuint texture, GLint level, -@@ -4312,6 +4380,15 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, +@@ -4353,6 +4421,15 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, renderbuffer, "glFramebufferRenderbuffer"); } @@ -342,7 +342,7 @@ index 798f59d2499..21507ff7c19 100644 void GLAPIENTRY _mesa_NamedFramebufferRenderbuffer_no_error(GLuint framebuffer, GLenum attachment, -@@ -4713,6 +4790,12 @@ invalid_pname_enum: +@@ -4754,6 +4831,12 @@ invalid_pname_enum: return; } @@ -507,7 +507,7 @@ index 2a32c158e68..98271d76f50 100644 _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, diff --git a/src/mesa/main/genmipmap.c b/src/mesa/main/genmipmap.c -index 16e2b037635..4d7b7db36a5 100644 +index 36727bb7060..8d262e53852 100644 --- a/src/mesa/main/genmipmap.c +++ b/src/mesa/main/genmipmap.c @@ -267,3 +267,9 @@ _mesa_GenerateMultiTexMipmapEXT(GLenum texunit, GLenum target) @@ -535,5 +535,5 @@ index c661f2184c7..ff3b45a4417 100644 _mesa_GenerateTextureMipmap(GLuint texture); -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0047-egl-null-add-support-for-async-flip-with-front-buffe.patch b/package/mesa3d/0047-egl-null-add-support-for-async-flip-with-front-buffe.patch index d1a5ecf0..58832edd 100644 --- a/package/mesa3d/0047-egl-null-add-support-for-async-flip-with-front-buffe.patch +++ b/package/mesa3d/0047-egl-null-add-support-for-async-flip-with-front-buffe.patch @@ -1,7 +1,7 @@ -From b2bee752e8c3d4188037b0d538b86836a0ba19d3 Mon Sep 17 00:00:00 2001 +From f775167cbe3f324468f8f355be13bd6efa7d4567 Mon Sep 17 00:00:00 2001 From: Luigi Santivetti Date: Mon, 21 Oct 2019 09:21:52 +0100 -Subject: [PATCH 48/50] egl/null: add support for async flip with front buffer +Subject: [PATCH 47/67] egl/null: add support for async flip with front buffer rendering This change enables the application to render into the buffer being @@ -45,10 +45,10 @@ Signed-off-by: Luigi Santivetti 2 files changed, 129 insertions(+), 32 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index 6ec9ee01885..9d60d21e8fd 100644 +index 0f683d76e18..13b808bff80 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -276,6 +276,7 @@ struct dri2_egl_display +@@ -282,6 +282,7 @@ struct dri2_egl_display #ifdef HAVE_NULL_PLATFORM bool atomic_enabled; bool in_formats_enabled; @@ -56,7 +56,7 @@ index 6ec9ee01885..9d60d21e8fd 100644 struct display_output output; #endif -@@ -434,8 +435,12 @@ struct dri2_egl_surface +@@ -442,8 +443,12 @@ struct dri2_egl_surface #endif bool locked; int age; @@ -69,7 +69,7 @@ index 6ec9ee01885..9d60d21e8fd 100644 #ifdef HAVE_ANDROID_PLATFORM struct ANativeWindow *window; -@@ -463,12 +468,13 @@ struct dri2_egl_surface +@@ -472,12 +477,13 @@ struct dri2_egl_surface #endif #ifdef HAVE_NULL_PLATFORM @@ -85,7 +85,7 @@ index 6ec9ee01885..9d60d21e8fd 100644 #endif diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c -index 701460dde4e..4969121bf37 100644 +index 48a586b6f38..33cf576f147 100644 --- a/src/egl/drivers/dri2/platform_null.c +++ b/src/egl/drivers/dri2/platform_null.c @@ -601,6 +601,15 @@ swap_dequeue_data_finish(struct dri2_egl_surface *dri2_surf) @@ -277,7 +277,7 @@ index 701460dde4e..4969121bf37 100644 } if (buffer_mask & __DRI_IMAGE_BUFFER_BACK) { -@@ -1637,18 +1719,27 @@ dri2_null_setup_swap_interval(_EGLDisplay *disp) +@@ -1640,18 +1722,27 @@ dri2_null_setup_swap_interval(_EGLDisplay *disp) dri2_setup_swap_interval(disp, swap_max_interval); err = drmGetCap(dri2_dpy->fd, DRM_CAP_ASYNC_PAGE_FLIP, &value); @@ -317,5 +317,5 @@ index 701460dde4e..4969121bf37 100644 EGLBoolean -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0048-gbm-add-pbuffer-support.patch b/package/mesa3d/0048-gbm-add-pbuffer-support.patch index 59c6b14a..5dd9e69c 100644 --- a/package/mesa3d/0048-gbm-add-pbuffer-support.patch +++ b/package/mesa3d/0048-gbm-add-pbuffer-support.patch @@ -1,7 +1,7 @@ -From 8ea569933388752a39e859989b69ab2f09f68309 Mon Sep 17 00:00:00 2001 +From 4d19dc5cc9be4f3f25ed8befbfcda70c047065d3 Mon Sep 17 00:00:00 2001 From: Brendan King Date: Fri, 21 Aug 2020 12:13:28 +0100 -Subject: [PATCH 49/50] gbm: add pbuffer support +Subject: [PATCH 48/67] gbm: add pbuffer support The EGL backend GLX provider for XWayland may get the EGL configs it uses to generate the GLX ones from GBM. That platform doesn't support @@ -18,10 +18,10 @@ isn't supported. 2 files changed, 103 insertions(+), 10 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index 9d60d21e8fd..2292f29772d 100644 +index 13b808bff80..141df1b1732 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -462,6 +462,9 @@ struct dri2_egl_surface +@@ -471,6 +471,9 @@ struct dri2_egl_surface /* surfaceless and device */ __DRIimage *front; unsigned int visual; @@ -32,7 +32,7 @@ index 9d60d21e8fd..2292f29772d 100644 #ifdef HAVE_WAYLAND_PLATFORM void *swrast_front; diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c -index 2944a5d7ad4..7fb8d2376d8 100644 +index 2b329437f88..258e8b6593e 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -41,6 +41,38 @@ @@ -46,13 +46,13 @@ index 2944a5d7ad4..7fb8d2376d8 100644 + struct dri2_egl_display *dri2_dpy = + dri2_egl_display(dri2_surf->base.Resource.Display); + -+ struct gbm_surface *surf = &dri2_surf->gbm_surf->base; ++ struct gbm_dri_surface *surf = dri2_surf->gbm_surf; + + dri2_surf->front_bo = gbm_bo_create(&dri2_dpy->gbm_dri->base, -+ surf->width, -+ surf->height, -+ surf->format, -+ surf->flags); ++ surf->base.v0.width, ++ surf->base.v0.height, ++ surf->base.v0.format, ++ surf->base.v0.flags); + if (!dri2_surf->front_bo) { + _eglError(EGL_BAD_ALLOC, "failed to allocate front buffer"); + return false; @@ -163,7 +163,7 @@ index 2944a5d7ad4..7fb8d2376d8 100644 dri2_fini_surface(surf); free(surf); -@@ -400,12 +470,27 @@ dri2_drm_image_get_buffers(__DRIdrawable *driDrawable, +@@ -402,12 +472,27 @@ dri2_drm_image_get_buffers(__DRIdrawable *driDrawable, struct dri2_egl_surface *dri2_surf = loaderPrivate; struct gbm_dri_bo *bo; @@ -196,7 +196,7 @@ index 2944a5d7ad4..7fb8d2376d8 100644 return 1; } -@@ -423,6 +508,9 @@ dri2_drm_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw) +@@ -425,6 +510,9 @@ dri2_drm_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw) struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); @@ -206,7 +206,7 @@ index 2944a5d7ad4..7fb8d2376d8 100644 if (!dri2_dpy->flush) { dri2_dpy->core->swapBuffers(dri2_surf->dri_drawable); return EGL_TRUE; -@@ -646,7 +734,8 @@ drm_add_configs_for_visuals(_EGLDisplay *disp) +@@ -648,7 +736,8 @@ drm_add_configs_for_visuals(_EGLDisplay *disp) }; dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i], @@ -216,7 +216,7 @@ index 2944a5d7ad4..7fb8d2376d8 100644 if (dri2_conf) { if (dri2_conf->base.ConfigID == config_count + 1) config_count++; -@@ -670,6 +759,7 @@ static const struct dri2_egl_display_vtbl dri2_drm_display_vtbl = { +@@ -672,6 +761,7 @@ static const struct dri2_egl_display_vtbl dri2_drm_display_vtbl = { .authenticate = dri2_drm_authenticate, .create_window_surface = dri2_drm_create_window_surface, .create_pixmap_surface = dri2_drm_create_pixmap_surface, @@ -225,5 +225,5 @@ index 2944a5d7ad4..7fb8d2376d8 100644 .create_image = dri2_drm_create_image_khr, .swap_buffers = dri2_drm_swap_buffers, -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0049-egl-null-expose-EXT_yuv_surface-support.patch b/package/mesa3d/0049-egl-null-expose-EXT_yuv_surface-support.patch index eafc25e9..b8978cdc 100644 --- a/package/mesa3d/0049-egl-null-expose-EXT_yuv_surface-support.patch +++ b/package/mesa3d/0049-egl-null-expose-EXT_yuv_surface-support.patch @@ -1,30 +1,254 @@ -From b8488580d9d7e034aa39426f6ef161035e56915d Mon Sep 17 00:00:00 2001 -From: Luigi Santivetti -Date: Mon, 25 Jan 2021 11:05:49 +0000 -Subject: [PATCH 50/50] egl/null: expose EXT_yuv_surface support +From b0ea3289c16d31d840af71876187cf30b2b32e9a Mon Sep 17 00:00:00 2001 +From: Luigi Santivetti +Date: Thu, 2 Sep 2021 22:47:54 +0100 +Subject: [PATCH 49/68] egl/null: expose EXT_yuv_surface support --- - src/egl/drivers/dri2/platform_null.c | 28 +++++++++++++++++++++++++--- - 1 file changed, 25 insertions(+), 3 deletions(-) + include/GL/internal/dri_interface.h | 2 + + src/egl/drivers/dri2/platform_null.c | 177 ++++++++++++++++++++++++--- + src/mesa/drivers/dri/pvr/pvrutil.c | 8 ++ + 3 files changed, 173 insertions(+), 14 deletions(-) +diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h +index 9c7bcac4cae..888a117d56e 100644 +--- a/include/GL/internal/dri_interface.h ++++ b/include/GL/internal/dri_interface.h +@@ -1411,6 +1411,8 @@ struct __DRIdri2ExtensionRec { + #define __DRI_IMAGE_FORMAT_ARGB4444 0x1018 + #define __DRI_IMAGE_FORMAT_YVU444_PACK10_IMG 0x1019 + #define __DRI_IMAGE_FORMAT_BGR888 0x101a ++#define __DRI_IMAGE_FORMAT_NV12 0x101b ++#define __DRI_IMAGE_FORMAT_NV21 0x101c + + #define __DRI_IMAGE_USE_SHARE 0x0001 + #define __DRI_IMAGE_USE_SCANOUT 0x0002 diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c -index 4969121bf37..9830b73d704 100644 +index f2c481c256b..d1e576af5ce 100644 --- a/src/egl/drivers/dri2/platform_null.c +++ b/src/egl/drivers/dri2/platform_null.c -@@ -106,6 +106,12 @@ static const struct dri2_null_format { +@@ -79,6 +79,35 @@ uint32_t get_back_buffer_id(struct dri2_egl_surface *dri2_surf) + .prop_value = value, \ + } + ++static const struct dri2_null_yuv_attrib { ++ uint32_t order; ++ uint32_t subsample; ++ uint32_t num_planes; ++ uint32_t plane_bpp; ++} dri2_null_yuv_attribs[] = { ++ { ++ /* __DRI_IMAGE_FORMAT_YUYV */ ++ .order = __DRI_ATTRIB_YUV_ORDER_YUYV_BIT, ++ .subsample = __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_2_BIT, ++ .num_planes = 1, ++ .plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT, ++ }, ++ { ++ /* __DRI_IMAGE_FORMAT_NV12 */ ++ .order = __DRI_ATTRIB_YUV_ORDER_YUV_BIT, ++ .subsample = __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_0_BIT, ++ .num_planes = 2, ++ .plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT, ++ }, ++ { ++ /* __DRI_IMAGE_FORMAT_NV21 */ ++ .order = __DRI_ATTRIB_YUV_ORDER_YVU_BIT, ++ .subsample = __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_0_BIT, ++ .num_planes = 2, ++ .plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT, ++ }, ++}; ++ + /* + * The index of entries in this table is used as a bitmask in + * dri2_dpy->formats, which tracks the formats supported by the display. +@@ -88,24 +117,49 @@ static const struct dri2_null_format { + int dri_image_format; + int rgba_shifts[4]; + unsigned int rgba_sizes[4]; ++ const struct dri2_null_yuv_attrib *yuv; + } dri2_null_formats[] = { + { + .drm_format = DRM_FORMAT_XRGB8888, + .dri_image_format = __DRI_IMAGE_FORMAT_XRGB8888, + .rgba_shifts = { 16, 8, 0, -1 }, + .rgba_sizes = { 8, 8, 8, 0 }, ++ .yuv = NULL, + }, + { + .drm_format = DRM_FORMAT_ARGB8888, + .dri_image_format = __DRI_IMAGE_FORMAT_ARGB8888, + .rgba_shifts = { 16, 8, 0, 24 }, + .rgba_sizes = { 8, 8, 8, 8 }, ++ .yuv = NULL, + }, + { + .drm_format = DRM_FORMAT_RGB565, + .dri_image_format = __DRI_IMAGE_FORMAT_RGB565, .rgba_shifts = { 11, 5, 0, -1 }, .rgba_sizes = { 5, 6, 5, 0 }, - }, ++ .yuv = NULL, ++ }, + { + .drm_format = DRM_FORMAT_YUYV, + .dri_image_format = __DRI_IMAGE_FORMAT_YUYV, + .rgba_shifts = { -1, -1, -1, -1 }, + .rgba_sizes = { 0, 0, 0, 0 }, ++ .yuv = &dri2_null_yuv_attribs[0], + }, ++ { ++ .drm_format = DRM_FORMAT_NV12, ++ .dri_image_format = __DRI_IMAGE_FORMAT_NV12, ++ .rgba_shifts = { -1, -1, -1, -1 }, ++ .rgba_sizes = { 0, 0, 0, 0 }, ++ .yuv = &dri2_null_yuv_attribs[1], ++ }, ++ { ++ .drm_format = DRM_FORMAT_NV21, ++ .dri_image_format = __DRI_IMAGE_FORMAT_NV21, ++ .rgba_shifts = { -1, -1, -1, -1 }, ++ .rgba_sizes = { 0, 0, 0, 0 }, ++ .yuv = &dri2_null_yuv_attribs[2], + }, }; +@@ -137,6 +191,36 @@ format_idx_get_from_config(struct dri2_egl_display *dri2_dpy, + return -1; + } -@@ -1595,6 +1601,17 @@ dri2_null_image_get_buffers(__DRIdrawable *driDrawable, unsigned int format, ++static int ++yuv_format_idx_get_from_config(struct dri2_egl_display *dri2_dpy, ++ const __DRIconfig *dri_config) ++{ ++ for (unsigned int i = 0; i < ARRAY_SIZE(dri2_null_formats); i++) { ++ const struct dri2_null_yuv_attrib *yuv = dri2_null_formats[i].yuv; ++ unsigned order, subsample, num_planes, plane_bpp; ++ ++ if (!yuv) ++ continue; ++ ++ dri2_dpy->core->getConfigAttrib(dri_config, __DRI_ATTRIB_YUV_ORDER, ++ &order); ++ dri2_dpy->core->getConfigAttrib(dri_config, __DRI_ATTRIB_YUV_SUBSAMPLE, ++ &subsample); ++ dri2_dpy->core->getConfigAttrib(dri_config, __DRI_ATTRIB_YUV_NUMBER_OF_PLANES, ++ &num_planes); ++ dri2_dpy->core->getConfigAttrib(dri_config, __DRI_ATTRIB_YUV_PLANE_BPP, ++ &plane_bpp); ++ ++ if (order != yuv->order || subsample != yuv->subsample || ++ num_planes != yuv->num_planes || plane_bpp != yuv->plane_bpp) ++ continue; ++ ++ return i; ++ } ++ ++ return -1; ++} ++ + static int + format_idx_get_from_dri_image_format(uint32_t dri_image_format) + { +@@ -1082,23 +1166,21 @@ static bool + add_fb_for_dri_image(struct dri2_egl_display *dri2_dpy, __DRIimage *image, + uint32_t *fb_id_out) + { +- uint64_t modifiers[4] = {0}; ++ int handle, stride, width, height, format, l_mod, h_mod, offset; ++ uint64_t modifier = DRM_FORMAT_MOD_INVALID; ++ uint64_t *modifiers = NULL, mods[4] = {0}; + uint32_t handles[4] = {0}; + uint32_t pitches[4] = {0}; + uint32_t offsets[4] = {0}; ++ __DRIimage *p_image; + uint32_t flags = 0; +- int handle, stride, width, height, format, l_mod, h_mod; + int format_idx; ++ int num_planes; + +- dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_HANDLE, &handle); +- dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride); + dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_WIDTH, &width); + dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_HEIGHT, &height); + dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &format); + +- handles[0] = (uint32_t) handle; +- pitches[0] = (uint32_t) stride; +- + format_idx = format_idx_get_from_dri_image_format(format); + assert(format_idx != -1); + +@@ -1106,10 +1188,44 @@ add_fb_for_dri_image(struct dri2_egl_display *dri2_dpy, __DRIimage *image, + dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_MODIFIER_UPPER, &h_mod); + dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_MODIFIER_LOWER, &l_mod); + +- modifiers[0] = combine_u32_into_u64((uint32_t) h_mod, (uint32_t) l_mod); ++ modifier = combine_u32_into_u64((uint32_t) h_mod, (uint32_t) l_mod); ++ modifiers = mods; ++ + flags |= DRM_MODE_FB_MODIFIERS; + } + ++ dri2_dpy->image->queryImage(image, ++ __DRI_IMAGE_ATTRIB_NUM_PLANES, &num_planes); ++ if (num_planes <= 0) ++ num_planes = 1; ++ ++ for (int i = 0; i < num_planes; i++) { ++ if (dri2_dpy->in_formats_enabled) { ++ assert(modifiers && modifier != DRM_FORMAT_MOD_INVALID); ++ modifiers[i] = modifier; ++ } ++ ++ p_image = dri2_dpy->image->fromPlanar(image, i, NULL); ++ if (!p_image) { ++ assert(i == 0); ++ p_image = image; ++ } ++ ++ dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_STRIDE, ++ &stride); ++ dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_OFFSET, ++ &offset); ++ dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_HANDLE, ++ &handle); ++ ++ if (p_image != image) ++ dri2_dpy->image->destroyImage(p_image); ++ ++ pitches[i] = (uint32_t) stride; ++ offsets[i] = (uint32_t) offset; ++ handles[i] = (uint32_t) handle; ++ } ++ + return !drmModeAddFB2WithModifiers(dri2_dpy->fd, width, height, + dri2_null_formats[format_idx].drm_format, + handles, pitches, offsets, modifiers, +@@ -1256,6 +1372,7 @@ create_surface(_EGLDisplay *disp, _EGLConfig *config, EGLint type, + struct dri2_egl_config *dri2_config = dri2_egl_config(config); + struct dri2_egl_surface *dri2_surf; + const __DRIconfig *dri_config; ++ unsigned int render_type; + _EGLSurface *surf; + int format_idx; + bool ret; +@@ -1286,7 +1403,14 @@ create_surface(_EGLDisplay *disp, _EGLConfig *config, EGLint type, + goto err_free_surface; + } + +- format_idx = format_idx_get_from_config(dri2_dpy, dri_config); ++ if (!dri2_dpy->core->getConfigAttrib(dri_config, __DRI_ATTRIB_RENDER_TYPE, ++ &render_type)) ++ goto err_free_surface; ++ ++ if (render_type & __DRI_ATTRIB_YUV_BIT) ++ format_idx = yuv_format_idx_get_from_config(dri2_dpy, dri_config); ++ else ++ format_idx = format_idx_get_from_config(dri2_dpy, dri_config); + assert(format_idx != -1); + + dri2_surf->format = dri2_null_formats[format_idx].dri_image_format; +@@ -1627,6 +1751,17 @@ dri2_null_image_get_buffers(__DRIdrawable *driDrawable, unsigned int format, return 1; } @@ -42,7 +266,7 @@ index 4969121bf37..9830b73d704 100644 static void dri2_null_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) { -@@ -1603,10 +1620,11 @@ dri2_null_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) +@@ -1635,10 +1770,11 @@ dri2_null_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) } static const __DRIimageLoaderExtension image_loader_extension = { @@ -55,22 +279,35 @@ index 4969121bf37..9830b73d704 100644 }; static const __DRIextension *image_loader_extensions[] = { -@@ -1688,6 +1706,7 @@ dri2_null_add_configs_for_formats(_EGLDisplay *disp) +@@ -1720,10 +1856,24 @@ dri2_null_add_configs_for_formats(_EGLDisplay *disp) for (unsigned i = 0; dri2_dpy->driver_configs[i]; i++) { struct dri2_egl_config *dri2_conf; -+ EGLint surface_type; ++ EGLint surface_type = EGL_WINDOW_BIT; ++ unsigned int render_type; int format_idx; - format_idx = format_idx_get_from_config(dri2_dpy, -@@ -1698,10 +1717,13 @@ dri2_null_add_configs_for_formats(_EGLDisplay *disp) - if (!(dri2_dpy->output.formats & (1 << format_idx))) +- format_idx = format_idx_get_from_config(dri2_dpy, +- dri2_dpy->driver_configs[i]); ++ if (!dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i], ++ __DRI_ATTRIB_RENDER_TYPE, ++ &render_type)) ++ continue; ++ ++ if (render_type & __DRI_ATTRIB_YUV_BIT) { ++ format_idx = yuv_format_idx_get_from_config(dri2_dpy, ++ dri2_dpy->driver_configs[i]); ++ } else { ++ format_idx = format_idx_get_from_config(dri2_dpy, ++ dri2_dpy->driver_configs[i]); ++ surface_type |= EGL_PBUFFER_BIT; ++ } ++ + if (format_idx == -1) continue; -+ surface_type = EGL_WINDOW_BIT; -+ if (dri2_null_formats[format_idx].drm_format != DRM_FORMAT_YUYV) -+ surface_type |= EGL_PBUFFER_BIT; -+ +@@ -1735,8 +1885,7 @@ dri2_null_add_configs_for_formats(_EGLDisplay *disp) + dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i], count + 1, - EGL_WINDOW_BIT | EGL_PBUFFER_BIT, @@ -79,6 +316,32 @@ index 4969121bf37..9830b73d704 100644 if (dri2_conf) count++; } +diff --git a/src/mesa/drivers/dri/pvr/pvrutil.c b/src/mesa/drivers/dri/pvr/pvrutil.c +index 945e18cf220..d107a5dafad 100644 +--- a/src/mesa/drivers/dri/pvr/pvrutil.c ++++ b/src/mesa/drivers/dri/pvr/pvrutil.c +@@ -174,6 +174,10 @@ PVRDRIFormatToFourCC(int dri_format) + return DRM_FORMAT_YVU444_PACK10_IMG; + case __DRI_IMAGE_FORMAT_BGR888: + return DRM_FORMAT_BGR888; ++ case __DRI_IMAGE_FORMAT_NV12: ++ return DRM_FORMAT_NV12; ++ case __DRI_IMAGE_FORMAT_NV21: ++ return DRM_FORMAT_NV21; + default: + __driUtilMessage("%s: Unknown format: %d", __func__, dri_format); + break; +@@ -230,6 +234,10 @@ PVRDRIFourCCToDRIFormat(int iFourCC) + return __DRI_IMAGE_FORMAT_YVU444_PACK10_IMG; + case DRM_FORMAT_BGR888: + return __DRI_IMAGE_FORMAT_BGR888; ++ case DRM_FORMAT_NV12: ++ return __DRI_IMAGE_FORMAT_NV12; ++ case DRM_FORMAT_NV21: ++ return __DRI_IMAGE_FORMAT_NV21; + default: + __driUtilMessage("%s: Unknown format: %d", __func__, iFourCC); + break; -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0050-dri-preserve-the-original-FD-for-driver-use.patch b/package/mesa3d/0050-dri-preserve-the-original-FD-for-driver-use.patch new file mode 100644 index 00000000..cbe368f9 --- /dev/null +++ b/package/mesa3d/0050-dri-preserve-the-original-FD-for-driver-use.patch @@ -0,0 +1,433 @@ +From db015d5fd0ded075e759677c047c581151bb1b52 Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Tue, 9 Mar 2021 17:15:30 +0000 +Subject: [PATCH 50/67] dri: preserve the original FD for driver use. + +If an application uses a different GPU from the default, allow the +file descriptor (FD) for that original GPU/display to be preserved +for use by drivers. Drivers may wish to use the original FD to +allocate shared surfaces, to ensure the surface properties are +compatible with the original GPU/display (e.g. for X11 or Wayland). + +This feature is only available on platforms that choose to support +it, by implementing the new getDisplayFD function in the DRI image, +and DRI2 loader extensions. + +If the feature is available, drivers can obtain the original FD +by calling the getDisplayFD function in the relevant loader extension. +Drivers should check the FD is valid before use (i.e. not -1). If +the FD is valid, it may be equal to the current GPU FD if a different +GPU is not being used. The FD is owned by the platform, not the +driver, and the platform is responsible for closing it. + +The feature is currently supported by the Wayland, and DRI3 based +X11 EGL and GLX platforms. +--- + include/GL/internal/dri_interface.h | 26 +++++++++++++++++-- + src/egl/drivers/dri2/egl_dri2.c | 10 +++++++ + src/egl/drivers/dri2/egl_dri2.h | 1 + + src/egl/drivers/dri2/platform_wayland.c | 31 ++++++++++++++++++++-- + src/egl/drivers/dri2/platform_x11.c | 3 +++ + src/egl/drivers/dri2/platform_x11_dri3.c | 27 ++++++++++++++++++- + src/glx/dri3_glx.c | 33 ++++++++++++++++++++++-- + src/glx/dri3_priv.h | 1 + + 8 files changed, 125 insertions(+), 7 deletions(-) + +diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h +index 888a117d56e..2fb440feb50 100644 +--- a/include/GL/internal/dri_interface.h ++++ b/include/GL/internal/dri_interface.h +@@ -1146,7 +1146,7 @@ struct __DRIbufferRec { + }; + + #define __DRI_DRI2_LOADER "DRI_DRI2Loader" +-#define __DRI_DRI2_LOADER_VERSION 5 ++#define __DRI_DRI2_LOADER_VERSION 6 + + enum dri_loader_cap { + /* Whether the loader handles RGBA channel ordering correctly. If not, +@@ -1227,6 +1227,17 @@ struct __DRIdri2LoaderExtensionRec { + * \since 5 + */ + void (*destroyLoaderImageState)(void *loaderPrivate); ++ ++ /** ++ * Get the display FD ++ * ++ * Get the FD of the display device. ++ * ++ * \param loaderPrivate The last parameter of createNewScreen or ++ * createNewScreen2. ++ * \since 6 ++ */ ++ int (*getDisplayFD)(void *loaderPrivate); + }; + + /** +@@ -2131,7 +2142,7 @@ struct __DRIimageList { + }; + + #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER" +-#define __DRI_IMAGE_LOADER_VERSION 4 ++#define __DRI_IMAGE_LOADER_VERSION 5 + + struct __DRIimageLoaderExtensionRec { + __DRIextension base; +@@ -2199,6 +2210,17 @@ struct __DRIimageLoaderExtensionRec { + * \since 4 + */ + void (*destroyLoaderImageState)(void *loaderPrivate); ++ ++ /** ++ * Get the display FD ++ * ++ * Get the FD of the display device. ++ * ++ * \param loaderPrivate The last parameter of createNewScreen or ++ * createNewScreen2. ++ * \since 5 ++ */ ++ int (*getDisplayFD)(void *loaderPrivate); + }; + + /** +diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c +index c4a49cae592..1df53ef011c 100644 +--- a/src/egl/drivers/dri2/egl_dri2.c ++++ b/src/egl/drivers/dri2/egl_dri2.c +@@ -1367,6 +1367,16 @@ dri2_display_destroy(_EGLDisplay *disp) + break; + } + ++ switch (disp->Platform) { ++ case _EGL_PLATFORM_WAYLAND: ++ case _EGL_PLATFORM_X11: ++ if (dri2_dpy->fd_dpy >= 0 && dri2_dpy->fd_dpy != dri2_dpy->fd) ++ close(dri2_dpy->fd_dpy); ++ break; ++ default: ++ break; ++ } ++ + if (dri2_dpy->fd >= 0) + close(dri2_dpy->fd); + +diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h +index 141df1b1732..af03caee623 100644 +--- a/src/egl/drivers/dri2/egl_dri2.h ++++ b/src/egl/drivers/dri2/egl_dri2.h +@@ -230,6 +230,7 @@ struct dri2_egl_display + const __DRIconfigOptionsExtension *configOptions; + const __DRImutableRenderBufferDriverExtension *mutable_render_buffer; + int fd; ++ int fd_dpy; + + /* dri2_initialize/dri2_terminate increment/decrement this count, so does + * dri2_make_current (tracks if there are active contexts/surfaces). */ +diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c +index 06272d4081e..b393e058770 100644 +--- a/src/egl/drivers/dri2/platform_wayland.c ++++ b/src/egl/drivers/dri2/platform_wayland.c +@@ -44,6 +44,7 @@ + #include "loader.h" + #include "util/u_vector.h" + #include "util/anon_file.h" ++#include "util/os_file.h" + #include "eglglobals.h" + + #include +@@ -973,21 +974,32 @@ dri2_wl_get_capability(void *loaderPrivate, enum dri_loader_cap cap) + } + } + ++static int ++dri2_wl_get_display_fd(void *loaderPrivate) ++{ ++ _EGLDisplay *disp = loaderPrivate; ++ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); ++ ++ return dri2_dpy->fd_dpy; ++} ++ + static const __DRIdri2LoaderExtension dri2_loader_extension = { +- .base = { __DRI_DRI2_LOADER, 4 }, ++ .base = { __DRI_DRI2_LOADER, 6 }, + + .getBuffers = dri2_wl_get_buffers, + .flushFrontBuffer = dri2_wl_flush_front_buffer, + .getBuffersWithFormat = dri2_wl_get_buffers_with_format, + .getCapability = dri2_wl_get_capability, ++ .getDisplayFD = dri2_wl_get_display_fd, + }; + + static const __DRIimageLoaderExtension image_loader_extension = { +- .base = { __DRI_IMAGE_LOADER, 2 }, ++ .base = { __DRI_IMAGE_LOADER, 5 }, + + .getBuffers = image_get_buffers, + .flushFrontBuffer = dri2_wl_flush_front_buffer, + .getCapability = dri2_wl_get_capability, ++ .getDisplayFD = dri2_wl_get_display_fd, + }; + + static void +@@ -1640,12 +1652,14 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp) + { + _EGLDevice *dev; + struct dri2_egl_display *dri2_dpy; ++ int fd_old; + + dri2_dpy = calloc(1, sizeof *dri2_dpy); + if (!dri2_dpy) + return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + + dri2_dpy->fd = -1; ++ dri2_dpy->fd_dpy = -1; + disp->DriverData = (void *) dri2_dpy; + if (disp->PlatformDisplay == NULL) { + dri2_dpy->wl_dpy = wl_display_connect(NULL); +@@ -1690,8 +1704,20 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp) + (roundtrip(dri2_dpy) < 0 || !dri2_dpy->authenticated)) + goto cleanup; + ++ fd_old = dri2_dpy->fd; ++ dri2_dpy->fd_dpy = os_dupfd_cloexec(dri2_dpy->fd); + dri2_dpy->fd = loader_get_user_preferred_fd(dri2_dpy->fd, + &dri2_dpy->is_different_gpu); ++ if (dri2_dpy->fd == fd_old) { ++ if (dri2_dpy->fd_dpy != -1) ++ close(dri2_dpy->fd_dpy); ++ ++ dri2_dpy->fd_dpy = dri2_dpy->fd; ++ } else if (dri2_dpy->fd_dpy == -1) { ++ _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to dup display FD"); ++ goto cleanup; ++ } ++ + dev = _eglAddDevice(dri2_dpy->fd, false); + if (!dev) { + _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice"); +@@ -2236,6 +2262,7 @@ dri2_initialize_wayland_swrast(_EGLDisplay *disp) + return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + + dri2_dpy->fd = -1; ++ dri2_dpy->fd_dpy = -1; + disp->DriverData = (void *) dri2_dpy; + if (disp->PlatformDisplay == NULL) { + dri2_dpy->wl_dpy = wl_display_connect(NULL); +diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c +index 5ffdf132184..5cf3ce2a369 100644 +--- a/src/egl/drivers/dri2/platform_x11.c ++++ b/src/egl/drivers/dri2/platform_x11.c +@@ -1277,6 +1277,7 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp) + return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + + dri2_dpy->fd = -1; ++ dri2_dpy->fd_dpy = -1; + if (!dri2_get_xcb_connection(disp, dri2_dpy)) + goto cleanup; + +@@ -1364,6 +1365,7 @@ dri2_initialize_x11_dri3(_EGLDisplay *disp) + return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + + dri2_dpy->fd = -1; ++ dri2_dpy->fd_dpy = -1; + if (!dri2_get_xcb_connection(disp, dri2_dpy)) + goto cleanup; + +@@ -1472,6 +1474,7 @@ dri2_initialize_x11_dri2(_EGLDisplay *disp) + return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + + dri2_dpy->fd = -1; ++ dri2_dpy->fd_dpy = -1; + if (!dri2_get_xcb_connection(disp, dri2_dpy)) + goto cleanup; + +diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c +index e117105fcb6..0babf9f867e 100644 +--- a/src/egl/drivers/dri2/platform_x11_dri3.c ++++ b/src/egl/drivers/dri2/platform_x11_dri3.c +@@ -32,6 +32,7 @@ + + #include + #include "util/macros.h" ++#include "util/os_file.h" + + #include "egl_dri2.h" + #include "platform_x11_dri3.h" +@@ -414,11 +415,21 @@ dri3_flush_front_buffer(__DRIdrawable *driDrawable, void *loaderPrivate) + _eglLog(_EGL_WARNING, "FIXME: egl/x11 doesn't support front buffer rendering."); + } + ++static int ++dri3_get_display_fd(void *loaderPrivate) ++{ ++ _EGLDisplay *disp = loaderPrivate; ++ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); ++ ++ return dri2_dpy->fd_dpy; ++} ++ + const __DRIimageLoaderExtension dri3_image_loader_extension = { +- .base = { __DRI_IMAGE_LOADER, 1 }, ++ .base = { __DRI_IMAGE_LOADER, 5 }, + + .getBuffers = loader_dri3_get_buffers, + .flushFrontBuffer = dri3_flush_front_buffer, ++ .getDisplayFD = dri3_get_display_fd, + }; + + static EGLBoolean +@@ -537,6 +548,7 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy) + xcb_xfixes_query_version_cookie_t xfixes_query_cookie; + xcb_generic_error_t *error; + const xcb_query_extension_reply_t *extension; ++ int fd_old; + + xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_dri3_id); + xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_present_id); +@@ -616,12 +628,25 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy) + return EGL_FALSE; + } + ++ fd_old = dri2_dpy->fd; ++ dri2_dpy->fd_dpy = os_dupfd_cloexec(dri2_dpy->fd); + dri2_dpy->fd = loader_get_user_preferred_fd(dri2_dpy->fd, &dri2_dpy->is_different_gpu); ++ if (dri2_dpy->fd == fd_old) { ++ if (dri2_dpy->fd_dpy != -1) ++ close(dri2_dpy->fd_dpy); ++ ++ dri2_dpy->fd_dpy = dri2_dpy->fd; ++ } else if (dri2_dpy->fd_dpy == -1) { ++ _eglLog(_EGL_WARNING, "DRI3: failed to dup display FD"); ++ close(dri2_dpy->fd); ++ return EGL_FALSE; ++ } + + dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd); + if (!dri2_dpy->driver_name) { + _eglLog(_EGL_WARNING, "DRI3: No driver found"); + close(dri2_dpy->fd); ++ close(dri2_dpy->fd_dpy); + return EGL_FALSE; + } + +diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c +index db1b079663f..1ed6b60ffe8 100644 +--- a/src/glx/dri3_glx.c ++++ b/src/glx/dri3_glx.c +@@ -77,6 +77,7 @@ + #include "dri3_priv.h" + #include "loader.h" + #include "dri2.h" ++#include "util/os_file.h" + + static struct dri3_drawable * + loader_drawable_to_dri3_drawable(struct loader_dri3_drawable *draw) { +@@ -529,6 +530,14 @@ dri3_flush_swap_buffers(__DRIdrawable *driDrawable, void *loaderPrivate) + loader_dri3_swapbuffer_barrier(draw); + } + ++static int ++dri3_get_display_fd(void *loaderPrivate) ++{ ++ struct dri3_screen *psc = (struct dri3_screen *)loaderPrivate; ++ ++ return psc->fd_dpy; ++} ++ + static void + dri_set_background_context(void *loaderPrivate) + { +@@ -548,11 +557,12 @@ dri_is_thread_safe(void *loaderPrivate) + /* The image loader extension record for DRI3 + */ + static const __DRIimageLoaderExtension imageLoaderExtension = { +- .base = { __DRI_IMAGE_LOADER, 3 }, ++ .base = { __DRI_IMAGE_LOADER, 5 }, + + .getBuffers = loader_dri3_get_buffers, + .flushFrontBuffer = dri3_flush_front_buffer, + .flushSwapBuffers = dri3_flush_swap_buffers, ++ .getDisplayFD = dri3_get_display_fd, + }; + + const __DRIuseInvalidateExtension dri3UseInvalidate = { +@@ -618,6 +628,10 @@ dri3_destroy_screen(struct glx_screen *base) + loader_dri3_close_screen(psc->driScreen); + (*psc->core->destroyScreen) (psc->driScreen); + driDestroyConfigs(psc->driver_configs); ++ ++ if (psc->fd_dpy != psc->fd) ++ close(psc->fd_dpy); ++ + close(psc->fd); + free(psc); + } +@@ -842,8 +856,9 @@ dri3_create_screen(int screen, struct glx_display * priv) + struct dri3_screen *psc; + __GLXDRIscreen *psp; + struct glx_config *configs = NULL, *visuals = NULL; +- char *driverName, *driverNameDisplayGPU, *tmp; ++ char *driverName = NULL, *driverNameDisplayGPU, *tmp; + int i; ++ int fd_old; + + psc = calloc(1, sizeof *psc); + if (psc == NULL) +@@ -851,6 +866,7 @@ dri3_create_screen(int screen, struct glx_display * priv) + + psc->fd = -1; + psc->fd_display_gpu = -1; ++ psc->fd_dpy = -1; + + if (!glx_screen_init(&psc->base, screen, priv)) { + free(psc); +@@ -871,12 +887,23 @@ dri3_create_screen(int screen, struct glx_display * priv) + return NULL; + } + ++ fd_old = psc->fd; ++ psc->fd_dpy = os_dupfd_cloexec(psc->fd); + psc->fd_display_gpu = fcntl(psc->fd, F_DUPFD_CLOEXEC, 3); + psc->fd = loader_get_user_preferred_fd(psc->fd, &psc->is_different_gpu); + if (!psc->is_different_gpu) { + close(psc->fd_display_gpu); + psc->fd_display_gpu = -1; + } ++ if (psc->fd == fd_old) { ++ if (psc->fd_dpy != -1) ++ close(psc->fd_dpy); ++ ++ psc->fd_dpy = psc->fd; ++ } else if (psc->fd_dpy == -1) { ++ ErrorMessageF("Unable to dup the display FD"); ++ goto handle_error; ++ } + + driverName = loader_get_driver_for_fd(psc->fd); + if (!driverName) { +@@ -1049,6 +1076,8 @@ handle_error: + if (psc->driScreenDisplayGPU) + psc->core->destroyScreen(psc->driScreenDisplayGPU); + psc->driScreenDisplayGPU = NULL; ++ if (psc->fd_dpy >= 0 && psc->fd_dpy != psc->fd) ++ close(psc->fd_dpy); + if (psc->fd >= 0) + close(psc->fd); + if (psc->fd_display_gpu >= 0) +diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h +index c0e833c16ef..b3dccf28c06 100644 +--- a/src/glx/dri3_priv.h ++++ b/src/glx/dri3_priv.h +@@ -107,6 +107,7 @@ struct dri3_screen { + + void *driver; + int fd; ++ int fd_dpy; + bool is_different_gpu; + + /* fd for display GPU in case of prime */ +-- +2.25.1 + diff --git a/package/mesa3d/0051-egl-wayland-a-linear-buffer-is-not-needed-with-DRM-f.patch b/package/mesa3d/0051-egl-wayland-a-linear-buffer-is-not-needed-with-DRM-f.patch new file mode 100644 index 00000000..7f1d8d00 --- /dev/null +++ b/package/mesa3d/0051-egl-wayland-a-linear-buffer-is-not-needed-with-DRM-f.patch @@ -0,0 +1,56 @@ +From 627ec429d684c57bdee45a21354009810fc03186 Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Wed, 28 Apr 2021 10:57:15 +0100 +Subject: [PATCH 51/67] 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 | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c +index b393e058770..60683fa6c1a 100644 +--- a/src/egl/drivers/dri2/platform_wayland.c ++++ b/src/egl/drivers/dri2/platform_wayland.c +@@ -695,7 +695,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) + use_flags |= __DRI_IMAGE_USE_PROTECTED; + } + +- if (dri2_dpy->is_different_gpu && ++ if (dri2_dpy->is_different_gpu && !num_modifiers && + dri2_surf->back->linear_copy == NULL) { + /* The LINEAR modifier should be a perfect alias of the LINEAR use + * flag; try the new interface first before the old, then fall back. */ +@@ -811,7 +811,7 @@ update_buffers(struct dri2_egl_display *dri2_dpy, + dri2_surf->color_buffers[i].wl_buffer) { + 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; +@@ -1247,7 +1247,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; +@@ -1281,7 +1281,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, +-- +2.25.1 + diff --git a/package/mesa3d/0052-dri3-a-linear-buffer-is-not-needed-with-DRM-format-m.patch b/package/mesa3d/0052-dri3-a-linear-buffer-is-not-needed-with-DRM-format-m.patch new file mode 100644 index 00000000..5585d620 --- /dev/null +++ b/package/mesa3d/0052-dri3-a-linear-buffer-is-not-needed-with-DRM-format-m.patch @@ -0,0 +1,303 @@ +From e57b9a1b34a733f88af51b1395eebe647006939d Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Wed, 28 Apr 2021 16:33:42 +0100 +Subject: [PATCH 52/67] dri3: a linear buffer is not needed with DRM format + modifiers + +If the X Server supports DRM format modifiers, there is no need +for an additional linear buffer, as the client can allocate buffers +with attributes known to the Server. +--- + src/egl/drivers/dri2/platform_x11_dri3.c | 7 +- + src/glx/dri3_glx.c | 137 +++++++++++++++-------- + src/loader/loader_dri3_helper.c | 15 +++ + src/loader/loader_dri3_helper.h | 4 + + 4 files changed, 113 insertions(+), 50 deletions(-) + +diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c +index 0babf9f867e..94205a495a6 100644 +--- a/src/egl/drivers/dri2/platform_x11_dri3.c ++++ b/src/egl/drivers/dri2/platform_x11_dri3.c +@@ -143,6 +143,7 @@ dri3_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf, + struct dri3_egl_surface *dri3_surf; + const __DRIconfig *dri_config; + xcb_drawable_t drawable; ++ bool is_incompat_gpu; + + dri3_surf = calloc(1, sizeof *dri3_surf); + if (!dri3_surf) { +@@ -150,6 +151,10 @@ dri3_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf, + return NULL; + } + ++ is_incompat_gpu = dri2_dpy->is_different_gpu && ++ !loader_dri3_has_modifiers(dri2_dpy->multibuffers_available, ++ dri2_dpy->image); ++ + if (!dri2_init_surface(&dri3_surf->surf.base, disp, type, conf, + attrib_list, false, native_surface)) + goto cleanup_surf; +@@ -174,7 +179,7 @@ dri3_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf, + + if (loader_dri3_drawable_init(dri2_dpy->conn, drawable, + dri2_dpy->dri_screen, +- dri2_dpy->is_different_gpu, ++ is_incompat_gpu, + dri2_dpy->multibuffers_available, + dri_config, + &dri2_dpy->loader_dri3_ext, +diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c +index 1ed6b60ffe8..025ad0128ec 100644 +--- a/src/glx/dri3_glx.c ++++ b/src/glx/dri3_glx.c +@@ -354,6 +354,21 @@ dri3_destroy_drawable(__GLXDRIdrawable *base) + free(pdraw); + } + ++static bool ++dri3_has_multibuffer(const __DRIimageExtension *image, ++ const struct dri3_display *pdp) ++{ ++#ifdef HAVE_DRI3_MODIFIERS ++ return (image && image->base.version >= 15) && ++ (pdp->dri3Major > 1 || ++ (pdp->dri3Major == 1 && pdp->dri3Minor >= 2)) && ++ (pdp->presentMajor > 1 || ++ (pdp->presentMajor == 1 && pdp->presentMinor >= 2)); ++#else ++ return false; ++#endif ++} ++ + static __GLXDRIdrawable * + dri3_create_drawable(struct glx_screen *base, XID xDrawable, + GLXDrawable drawable, struct glx_config *config_base) +@@ -361,11 +376,9 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable, + struct dri3_drawable *pdraw; + struct dri3_screen *psc = (struct dri3_screen *) base; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; +- bool has_multibuffer = false; +-#ifdef HAVE_DRI3_MODIFIERS + const struct dri3_display *const pdp = (struct dri3_display *) + base->display->dri3Display; +-#endif ++ bool has_multibuffer = dri3_has_multibuffer(psc->image, pdp); + + pdraw = calloc(1, sizeof(*pdraw)); + if (!pdraw) +@@ -376,14 +389,6 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable, + pdraw->base.drawable = drawable; + pdraw->base.psc = &psc->base; + +-#ifdef HAVE_DRI3_MODIFIERS +- if ((psc->image && psc->image->base.version >= 15) && +- (pdp->dri3Major > 1 || (pdp->dri3Major == 1 && pdp->dri3Minor >= 2)) && +- (pdp->presentMajor > 1 || +- (pdp->presentMajor == 1 && pdp->presentMinor >= 2))) +- has_multibuffer = true; +-#endif +- + (void) __glXInitialize(psc->base.dpy); + + if (loader_dri3_drawable_init(XGetXCBConnection(base->dpy), +@@ -737,13 +742,14 @@ static const struct glx_context_vtable dri3_context_vtable = { + .interop_export_object = dri3_interop_export_object + }; + +-/** dri3_bind_extensions ++/** dri3_bind_extensions_part1 + * +- * Enable all of the extensions supported on DRI3 ++ * Enable the extensions supported on DRI3 that don't depend on ++ * whether we are using a different GPU. + */ + static void +-dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv, +- const char *driverName) ++dri3_bind_extensions_part1(struct dri3_screen *psc, struct glx_display * priv, ++ const char *driverName) + { + const __DRIextension **extensions; + unsigned mask; +@@ -774,16 +780,6 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv, + } + + for (i = 0; extensions[i]; i++) { +- /* when on a different gpu than the server, the server pixmaps +- * can have a tiling mode we can't read. Thus we can't create +- * a texture from them. +- */ +- if (!psc->is_different_gpu && +- (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) { +- psc->texBuffer = (__DRItexBufferExtension *) extensions[i]; +- __glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap"); +- } +- + if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) { + psc->f = (__DRI2flushExtension *) extensions[i]; + /* internal driver extension, no GL extension exposed */ +@@ -817,6 +813,33 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv, + } + } + ++/** dri3_bind_extensions_part2 ++ * ++ * Enable the extensions supported on DRI3 that depend on whether we ++ * are using a different GPU. ++ */ ++static void ++dri3_bind_extensions_part2(struct dri3_screen *psc, struct glx_display * priv, ++ const char *driverName) ++{ ++ const __DRIextension **extensions; ++ int i; ++ ++ extensions = psc->core->getExtensions(psc->driScreen); ++ ++ for (i = 0; extensions[i]; i++) { ++ /* when on a different gpu than the server, the server pixmaps ++ * can have a tiling mode we can't read. Thus we can't create ++ * a texture from them. ++ */ ++ if (!psc->is_different_gpu && ++ (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) { ++ psc->texBuffer = (__DRItexBufferExtension *) extensions[i]; ++ __glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap"); ++ } ++ } ++} ++ + static char * + dri3_get_driver_name(struct glx_screen *glx_screen) + { +@@ -859,6 +882,8 @@ dri3_create_screen(int screen, struct glx_display * priv) + char *driverName = NULL, *driverNameDisplayGPU, *tmp; + int i; + int fd_old; ++ bool is_different_gpu; ++ bool have_modifiers; + + psc = calloc(1, sizeof *psc); + if (psc == NULL) +@@ -890,8 +915,8 @@ dri3_create_screen(int screen, struct glx_display * priv) + fd_old = psc->fd; + psc->fd_dpy = os_dupfd_cloexec(psc->fd); + psc->fd_display_gpu = fcntl(psc->fd, F_DUPFD_CLOEXEC, 3); +- psc->fd = loader_get_user_preferred_fd(psc->fd, &psc->is_different_gpu); +- if (!psc->is_different_gpu) { ++ psc->fd = loader_get_user_preferred_fd(psc->fd, &is_different_gpu); ++ if (!is_different_gpu) { + close(psc->fd_display_gpu); + psc->fd_display_gpu = -1; + } +@@ -933,27 +958,6 @@ dri3_create_screen(int screen, struct glx_display * priv) + goto handle_error; + } + +- if (psc->is_different_gpu) { +- driverNameDisplayGPU = loader_get_driver_for_fd(psc->fd_display_gpu); +- if (driverNameDisplayGPU) { +- +- /* check if driver name is matching so that non mesa drivers +- * will not crash. Also need this check since image extension +- * pointer from render gpu is shared with display gpu. Image +- * extension pointer is shared because it keeps things simple. +- */ +- if (strcmp(driverName, driverNameDisplayGPU) == 0) { +- psc->driScreenDisplayGPU = +- psc->image_driver->createNewScreen2(screen, psc->fd_display_gpu, +- pdp->loader_extensions, +- extensions, +- &driver_configs, psc); +- } +- +- free(driverNameDisplayGPU); +- } +- } +- + psc->driScreen = + psc->image_driver->createNewScreen2(screen, psc->fd, + pdp->loader_extensions, +@@ -965,7 +969,42 @@ dri3_create_screen(int screen, struct glx_display * priv) + goto handle_error; + } + +- dri3_bind_extensions(psc, priv, driverName); ++ dri3_bind_extensions_part1(psc, priv, driverName); ++ ++ have_modifiers = loader_dri3_has_modifiers(dri3_has_multibuffer(psc->image, ++ pdp), ++ psc->image); ++ ++ if (is_different_gpu) { ++ if (have_modifiers) { ++ close(psc->fd_display_gpu); ++ psc->fd_display_gpu = -1; ++ } else { ++ driverNameDisplayGPU = loader_get_driver_for_fd(psc->fd_display_gpu); ++ if (driverNameDisplayGPU) { ++ ++ /* check if driver name is matching so that non mesa drivers ++ * will not crash. Also need this check since image extension ++ * pointer from render gpu is shared with display gpu. Image ++ * extension pointer is shared because it keeps things simple. ++ */ ++ if (strcmp(driverName, driverNameDisplayGPU) == 0) { ++ psc->driScreenDisplayGPU = ++ psc->image_driver->createNewScreen2(screen, ++ psc->fd_display_gpu, ++ pdp->loader_extensions, ++ extensions, ++ &driver_configs, psc); ++ } ++ ++ free(driverNameDisplayGPU); ++ } ++ } ++ } ++ ++ psc->is_different_gpu = is_different_gpu && !have_modifiers; ++ ++ dri3_bind_extensions_part2(psc, priv, driverName); + + if (!psc->image || psc->image->base.version < 7 || !psc->image->createImageFromFds) { + ErrorMessageF("Version 7 or imageFromFds image extension not found\n"); +diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c +index ff6d1ffc660..5c0379ab5de 100644 +--- a/src/loader/loader_dri3_helper.c ++++ b/src/loader/loader_dri3_helper.c +@@ -2288,3 +2288,18 @@ dri3_find_back_alloc(struct loader_dri3_drawable *draw) + + return back; + } ++ ++bool ++loader_dri3_has_modifiers(bool multiplanes_available, ++ const __DRIimageExtension *image) ++{ ++#ifdef HAVE_DRI3_MODIFIERS ++ return multiplanes_available && image && ++ image->base.version >= 15 && ++ image->queryDmaBufModifiers && ++ image->createImageWithModifiers && ++ image->createImageFromDmaBufs2; ++#else ++ return false; ++#endif ++} +diff --git a/src/loader/loader_dri3_helper.h b/src/loader/loader_dri3_helper.h +index 028e25dc070..5790f5444f5 100644 +--- a/src/loader/loader_dri3_helper.h ++++ b/src/loader/loader_dri3_helper.h +@@ -287,4 +287,8 @@ loader_dri3_swapbuffer_barrier(struct loader_dri3_drawable *draw); + + void + loader_dri3_close_screen(__DRIscreen *dri_screen); ++ ++bool ++loader_dri3_has_modifiers(bool multiplanes_available, ++ const __DRIimageExtension *image); + #endif +-- +2.25.1 + diff --git a/package/mesa3d/0053-egl-drm-add-support-for-DRI_PRIME-GPU-selection.patch b/package/mesa3d/0053-egl-drm-add-support-for-DRI_PRIME-GPU-selection.patch new file mode 100644 index 00000000..f097cd46 --- /dev/null +++ b/package/mesa3d/0053-egl-drm-add-support-for-DRI_PRIME-GPU-selection.patch @@ -0,0 +1,267 @@ +From 8de0535741ce8d126da4d9b0b0eb8c46dd4810b5 Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Thu, 20 May 2021 14:43:29 +0100 +Subject: [PATCH 53/67] egl/drm: add support for DRI_PRIME GPU selection + +Add support for selecting the GPU to be used for rendering using +the DRI_PRIME environment variable. If a different GPU is selected, +a duplicate of the file descriptor for the original GPU/display is +preserved, which can be obtained by calling the getDisplayFD +function in the image loader extension. + +For server side Wayland, the ability to support PRIME is +determined by checking for the PRIME import and export +capabilities on the driver file descriptor, which may no +longer support them if a different GPU from the default has +been selected. It may be that the driver can still support +PRIME; for example, by making use of the original (default) +file descriptor. The driver can indicate it supports PRIME +via the getCapabilities function in the DRI Image extension. +--- + include/GL/internal/dri_interface.h | 2 ++ + src/egl/drivers/dri2/egl_dri2.c | 10 ++++++++ + src/egl/drivers/dri2/platform_drm.c | 19 ++++++++++----- + src/gbm/backends/dri/gbm_dri.c | 38 +++++++++++++++++++++++++---- + src/gbm/backends/dri/gbm_driint.h | 8 ++++++ + 5 files changed, 66 insertions(+), 11 deletions(-) + +diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h +index 2fb440feb50..080d191b0a3 100644 +--- a/include/GL/internal/dri_interface.h ++++ b/include/GL/internal/dri_interface.h +@@ -1548,6 +1548,8 @@ enum __DRIChromaSiting { + */ + /*@{*/ + #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1 ++#define __DRI_IMAGE_CAP_PRIME_IMPORT 0x2000 ++#define __DRI_IMAGE_CAP_PRIME_EXPORT 0x4000 + /*@}*/ + + /** +diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c +index 1df53ef011c..ec4ac602a84 100644 +--- a/src/egl/drivers/dri2/egl_dri2.c ++++ b/src/egl/drivers/dri2/egl_dri2.c +@@ -1368,6 +1368,7 @@ dri2_display_destroy(_EGLDisplay *disp) + } + + switch (disp->Platform) { ++ case _EGL_PLATFORM_DRM: + case _EGL_PLATFORM_WAYLAND: + case _EGL_PLATFORM_X11: + if (dri2_dpy->fd_dpy >= 0 && dri2_dpy->fd_dpy != dri2_dpy->fd) +@@ -3943,6 +3944,15 @@ dri2_bind_wayland_display_wl(_EGLDisplay *disp, struct wl_display *wl_dpy) + dri2_dpy->image->base.version >= 7 && + dri2_dpy->image->createImageFromFds != NULL) + flags |= WAYLAND_DRM_PRIME; ++ else if (dri2_dpy->image->base.version >= 10 && ++ dri2_dpy->image->getCapabilities != NULL) { ++ int capabilities; ++ ++ capabilities = dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen); ++ if ((capabilities & __DRI_IMAGE_CAP_PRIME_IMPORT) != 0 && ++ (capabilities & __DRI_IMAGE_CAP_PRIME_EXPORT) != 0) ++ flags |= WAYLAND_DRM_PRIME; ++ } + + dri2_dpy->wl_server_drm = + wayland_drm_init(wl_dpy, device_name, +diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c +index 258e8b6593e..f160ad1175e 100644 +--- a/src/egl/drivers/dri2/platform_drm.c ++++ b/src/egl/drivers/dri2/platform_drm.c +@@ -595,7 +595,7 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id) + { + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + +- return drmAuthMagic(dri2_dpy->fd, id); ++ return drmAuthMagic(dri2_dpy->fd_dpy, id); + } + + static void +@@ -782,6 +782,7 @@ dri2_initialize_drm(_EGLDisplay *disp) + return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + + dri2_dpy->fd = -1; ++ dri2_dpy->fd_dpy = -1; + disp->DriverData = (void *) dri2_dpy; + + gbm = disp->PlatformDisplay; +@@ -789,16 +790,16 @@ dri2_initialize_drm(_EGLDisplay *disp) + char buf[64]; + int n = snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, 0); + if (n != -1 && n < sizeof(buf)) +- dri2_dpy->fd = loader_open_device(buf); +- gbm = gbm_create_device(dri2_dpy->fd); ++ dri2_dpy->fd_dpy = loader_open_device(buf); ++ gbm = gbm_create_device(dri2_dpy->fd_dpy); + if (gbm == NULL) { + err = "DRI2: failed to create gbm device"; + goto cleanup; + } + dri2_dpy->own_device = true; + } else { +- dri2_dpy->fd = os_dupfd_cloexec(gbm_device_get_fd(gbm)); +- if (dri2_dpy->fd < 0) { ++ dri2_dpy->fd_dpy = os_dupfd_cloexec(gbm_device_get_fd(gbm)); ++ if (dri2_dpy->fd_dpy < 0) { + err = "DRI2: failed to fcntl() existing gbm device"; + goto cleanup; + } +@@ -810,6 +811,12 @@ dri2_initialize_drm(_EGLDisplay *disp) + goto cleanup; + } + ++ if (gbm_dri_device_get_fd(dri2_dpy->gbm_dri) == ++ gbm_device_get_fd(gbm)) ++ dri2_dpy->fd = dri2_dpy->fd_dpy; ++ else ++ dri2_dpy->fd = os_dupfd_cloexec(gbm_dri_device_get_fd(dri2_dpy->gbm_dri)); ++ + dev = _eglAddDevice(dri2_dpy->fd, dri2_dpy->gbm_dri->software); + if (!dev) { + err = "DRI2: failed to find EGLDevice"; +@@ -872,7 +879,7 @@ dri2_initialize_drm(_EGLDisplay *disp) + disp->Extensions.EXT_buffer_age = EGL_TRUE; + + #ifdef HAVE_WAYLAND_PLATFORM +- dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd); ++ dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd_dpy); + #endif + dri2_set_WL_bind_wayland_display(disp); + +diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c +index 5acb15b516f..c1586f42e46 100644 +--- a/src/gbm/backends/dri/gbm_dri.c ++++ b/src/gbm/backends/dri/gbm_dri.c +@@ -51,6 +51,7 @@ + #include "loader.h" + #include "util/debug.h" + #include "util/macros.h" ++#include "util/os_file.h" + + /* For importing wl_buffer */ + #if HAVE_WAYLAND_PLATFORM +@@ -141,6 +142,14 @@ image_get_buffers(__DRIdrawable *driDrawable, + surf->dri_private, buffer_mask, buffers); + } + ++static int ++dri_get_display_fd(void *loaderPrivate) ++{ ++ struct gbm_dri_device *dri = loaderPrivate; ++ ++ return dri->base.v0.fd; ++} ++ + static void + swrast_get_drawable_info(__DRIdrawable *driDrawable, + int *x, +@@ -220,20 +229,22 @@ static const __DRIimageLookupExtension image_lookup_extension = { + }; + + static const __DRIdri2LoaderExtension dri2_loader_extension = { +- .base = { __DRI_DRI2_LOADER, 4 }, ++ .base = { __DRI_DRI2_LOADER, 6 }, + + .getBuffers = dri_get_buffers, + .flushFrontBuffer = dri_flush_front_buffer, + .getBuffersWithFormat = dri_get_buffers_with_format, + .getCapability = dri_get_capability, ++ .getDisplayFD = dri_get_display_fd, + }; + + static const __DRIimageLoaderExtension image_loader_extension = { +- .base = { __DRI_IMAGE_LOADER, 2 }, ++ .base = { __DRI_IMAGE_LOADER, 5 }, + + .getBuffers = image_get_buffers, + .flushFrontBuffer = dri_flush_front_buffer, + .getCapability = dri_get_capability, ++ .getDisplayFD = dri_get_display_fd, + }; + + static const __DRIswrastLoaderExtension swrast_loader_extension = { +@@ -398,12 +409,12 @@ dri_screen_create_dri2(struct gbm_dri_device *dri, char *driver_name) + return -1; + + if (dri->dri2->base.version >= 4) { +- dri->screen = dri->dri2->createNewScreen2(0, dri->base.v0.fd, ++ dri->screen = dri->dri2->createNewScreen2(0, dri->fd, + dri->loader_extensions, + dri->driver_extensions, + &dri->driver_configs, dri); + } else { +- dri->screen = dri->dri2->createNewScreen(0, dri->base.v0.fd, ++ dri->screen = dri->dri2->createNewScreen(0, dri->fd, + dri->loader_extensions, + &dri->driver_configs, dri); + } +@@ -470,8 +481,20 @@ static int + dri_screen_create(struct gbm_dri_device *dri) + { + char *driver_name; ++ int dup_fd, new_fd; ++ bool is_different_gpu; + +- driver_name = loader_get_driver_for_fd(dri->base.v0.fd); ++ dup_fd = os_dupfd_cloexec(dri->fd); ++ if (dup_fd < 0) ++ return -1; ++ ++ new_fd = loader_get_user_preferred_fd(dup_fd, &is_different_gpu); ++ if (new_fd == dup_fd) ++ close(new_fd); ++ else ++ dri->fd = new_fd; ++ ++ driver_name = loader_get_driver_for_fd(dri->fd); + if (!driver_name) + return -1; + +@@ -1424,6 +1447,9 @@ dri_destroy(struct gbm_device *gbm) + dlclose(dri->driver); + free(dri->driver_name); + ++ if (dri->fd >= 0 && dri->fd != dri->base.v0.fd) ++ close (dri->fd); ++ + free(dri); + } + +@@ -1445,6 +1471,8 @@ dri_device_create(int fd, uint32_t gbm_backend_version) + if (!dri) + return NULL; + ++ dri->fd = fd; ++ + dri->base.v0.fd = fd; + dri->base.v0.backend_version = gbm_backend_version; + dri->base.v0.bo_create = gbm_dri_bo_create; +diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h +index 9e77ba5887c..e33a96edb0b 100644 +--- a/src/gbm/backends/dri/gbm_driint.h ++++ b/src/gbm/backends/dri/gbm_driint.h +@@ -61,6 +61,8 @@ struct gbm_dri_visual { + struct gbm_dri_device { + struct gbm_device base; + ++ int fd; ++ + void *driver; + char *driver_name; /* Name of the DRI module, without the _dri suffix */ + bool software; /* A software driver was loaded */ +@@ -191,4 +193,10 @@ gbm_dri_bo_unmap_dumb(struct gbm_dri_bo *bo) + bo->map = NULL; + } + ++static inline int ++gbm_dri_device_get_fd(struct gbm_dri_device *dri) ++{ ++ return dri->fd; ++} ++ + #endif +-- +2.25.1 + diff --git a/package/mesa3d/0054-egl-null-add-support-for-DRI_PRIME-GPU-selection.patch b/package/mesa3d/0054-egl-null-add-support-for-DRI_PRIME-GPU-selection.patch new file mode 100644 index 00000000..2c0d670c --- /dev/null +++ b/package/mesa3d/0054-egl-null-add-support-for-DRI_PRIME-GPU-selection.patch @@ -0,0 +1,304 @@ +From f1f625dbcb4e0cc062369729b1da3d7fc65969e8 Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Thu, 20 May 2021 20:16:18 +0100 +Subject: [PATCH 54/67] egl/null: add support for DRI_PRIME GPU selection + +Add support for selecting the GPU to be used for rendering using +the DRI_PRIME environment variable. If a different GPU is selected, +a duplicate of the file descriptor for the original GPU/display is +preserved, which can be obtained by calling the getDisplayFD +function in the image loader extension. + +This change includes code, in function dri2_null_try_device, to +skip display devices that are not supported by the PVR driver. +This is to prevent failure on PC based test systems, that often +include display hardware that is incompatible with the driver. +This code would not be needed for systems that don't use the PVR +driver, or on production systems that use the PVR driver. +--- + src/egl/drivers/dri2/egl_dri2.c | 1 + + src/egl/drivers/dri2/platform_null.c | 133 +++++++++++++++++++-------- + 2 files changed, 98 insertions(+), 36 deletions(-) + +diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c +index ec4ac602a84..56b5175db6e 100644 +--- a/src/egl/drivers/dri2/egl_dri2.c ++++ b/src/egl/drivers/dri2/egl_dri2.c +@@ -1369,6 +1369,7 @@ dri2_display_destroy(_EGLDisplay *disp) + + switch (disp->Platform) { + case _EGL_PLATFORM_DRM: ++ case _EGL_PLATFORM_NULL: + case _EGL_PLATFORM_WAYLAND: + case _EGL_PLATFORM_X11: + if (dri2_dpy->fd_dpy >= 0 && dri2_dpy->fd_dpy != dri2_dpy->fd) +diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c +index db6f1147670..af77ea4dd89 100644 +--- a/src/egl/drivers/dri2/platform_null.c ++++ b/src/egl/drivers/dri2/platform_null.c +@@ -44,6 +44,7 @@ + + #include "egl_dri2.h" + #include "loader.h" ++#include "util/os_file.h" + + #define NULL_CARD_MINOR_MAX 63U + +@@ -953,7 +954,7 @@ swap_idle_get_target_frame(struct dri2_egl_surface *dri2_surf, + * current vblank by the number of intervals set at the time swapBuffer + * is called. For intervals of 1 or 0, we don't need a target frame. + */ +- err = display_get_vblank_sequence(dri2_dpy->fd, current_vblank_out); ++ err = display_get_vblank_sequence(dri2_dpy->fd_dpy, current_vblank_out); + if (err) + return err; + +@@ -1003,7 +1004,7 @@ swap_vblank_state_transition(struct dri2_egl_surface *dri2_surf, + uint32_t flags = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT; + int err; + +- err = display_request_vblank(dri2_dpy->fd, target_frame, ++ err = display_request_vblank(dri2_dpy->fd_dpy, target_frame, + flags, dri2_surf); + if (err) { + dri2_surf->swap_state = SWAP_ERROR; +@@ -1029,7 +1030,7 @@ swap_flip_state_transition(struct dri2_egl_surface *dri2_surf) + flags |= DRM_MODE_PAGE_FLIP_ASYNC; + } + +- err = display_output_flip(dri2_dpy->fd, &dri2_dpy->output, ++ err = display_output_flip(dri2_dpy->fd_dpy, &dri2_dpy->output, + dri2_surf->swap_data->fb_id, flags, dri2_surf); + if (err) { + dri2_surf->swap_state = SWAP_ERROR; +@@ -1049,7 +1050,7 @@ swap_poll_state_transition(struct dri2_egl_surface *dri2_surf) + int err; + + /* dri2_surf->swap_state is being set inside the handler */ +- err = drm_event_process(dri2_dpy->fd); ++ err = drm_event_process(dri2_dpy->fd_dpy); + if (err) { + dri2_surf->swap_state = SWAP_ERROR; + return err; +@@ -1201,7 +1202,7 @@ add_fb_for_dri_image(struct dri2_egl_display *dri2_dpy, __DRIimage *image, + handles[i] = (uint32_t) handle; + } + +- return !drmModeAddFB2WithModifiers(dri2_dpy->fd, width, height, ++ return !drmModeAddFB2WithModifiers(dri2_dpy->fd_dpy, width, height, + dri2_null_formats[format_idx].drm_format, + handles, pitches, offsets, modifiers, + fb_id_out, flags); +@@ -1459,7 +1460,7 @@ dri2_null_create_window_surface(_EGLDisplay *disp, _EGLConfig *config, + goto err_destroy_surface; + } + +- err = display_output_modeset(dri2_dpy->fd, &dri2_dpy->output, ++ err = display_output_modeset(dri2_dpy->fd_dpy, &dri2_dpy->output, + dri2_surf->front_buffer.fb_id); + if (err) { + _eglError(EGL_BAD_NATIVE_WINDOW, "window set mode"); +@@ -1573,11 +1574,11 @@ dri2_null_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) + dri2_dpy->image->destroyImage(dri2_surf->front_buffer.dri_image); + + if (dri2_surf->front_buffer.fb_id) +- drmModeRmFB(dri2_dpy->fd, dri2_surf->front_buffer.fb_id); ++ drmModeRmFB(dri2_dpy->fd_dpy, dri2_surf->front_buffer.fb_id); + + for (unsigned i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) { + if (dri2_surf->color_buffers[i].fb_id) +- drmModeRmFB(dri2_dpy->fd, dri2_surf->color_buffers[i].fb_id); ++ drmModeRmFB(dri2_dpy->fd_dpy, dri2_surf->color_buffers[i].fb_id); + if (dri2_surf->color_buffers[i].dri_image) + dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].dri_image); + } +@@ -1734,12 +1735,22 @@ dri2_null_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) + (void) loaderPrivate; + } + ++static int ++dri2_null_get_display_fd(void *loaderPrivate) ++{ ++ _EGLDisplay *disp = loaderPrivate; ++ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); ++ ++ return dri2_dpy->fd_dpy; ++} ++ + static const __DRIimageLoaderExtension image_loader_extension = { +- .base = { __DRI_IMAGE_LOADER, 2 }, ++ .base = { __DRI_IMAGE_LOADER, 5 }, + + .getBuffers = dri2_null_image_get_buffers, + .flushFrontBuffer = dri2_null_flush_front_buffer, + .getCapability = dri2_null_get_capability, ++ .getDisplayFD = dri2_null_get_display_fd, + }; + + static const __DRIextension *image_loader_extensions[] = { +@@ -1768,12 +1779,74 @@ dri2_null_device_is_kms(int fd) + return is_kms; + } + ++static bool ++dri2_null_try_device(_EGLDisplay *disp) ++{ ++ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); ++ ++ if (!dri2_null_device_is_kms(dri2_dpy->fd_dpy)) ++ return false; ++ ++#if 1 ++ /* Skip devices not supported by the pvr driver */ ++ { ++ char *driver_name = loader_get_driver_for_fd(dri2_dpy->fd_dpy); ++ bool skip = !driver_name || !!strcmp(driver_name, "pvr"); ++ ++ free(driver_name); ++ ++ if (skip) ++ return false; ++ } ++#endif ++ ++ dri2_dpy->fd = os_dupfd_cloexec(dri2_dpy->fd_dpy); ++ if (dri2_dpy->fd < 0) { ++ _eglLog(_EGL_WARNING, "DRI2: failed to dup display FD"); ++ dri2_dpy->fd = dri2_dpy->fd_dpy; ++ } else { ++ int fd_old; ++ bool is_different_gpu; ++ ++ fd_old = dri2_dpy->fd; ++ dri2_dpy->fd = loader_get_user_preferred_fd(dri2_dpy->fd, ++ &is_different_gpu); ++ if (dri2_dpy->fd == fd_old) { ++ close (dri2_dpy->fd); ++ dri2_dpy->fd = dri2_dpy->fd_dpy; ++ } ++ } ++ ++ dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd); ++ if (!dri2_dpy->driver_name) ++ return false; ++ ++ if (dri2_load_driver_dri3(disp)) { ++ _EGLDevice *dev = _eglAddDevice(dri2_dpy->fd, false); ++ if (!dev) { ++ dlclose(dri2_dpy->driver); ++ _eglLog(_EGL_WARNING, "DRI2: failed to find EGLDevice"); ++ } else { ++ dri2_dpy->loader_extensions = image_loader_extensions; ++ dri2_dpy->own_device = 1; ++ disp->Device = dev; ++ return true; ++ } ++ } ++ ++ free(dri2_dpy->driver_name); ++ dri2_dpy->driver_name = NULL; ++ ++ return false; ++} ++ + static bool + dri2_null_probe_device(_EGLDisplay *disp) + { + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + + dri2_dpy->fd = -1; ++ dri2_dpy->fd_dpy = -1; + + for (unsigned i = 0; i <= NULL_CARD_MINOR_MAX; i++) { + char *card_path; +@@ -1781,32 +1854,20 @@ dri2_null_probe_device(_EGLDisplay *disp) + if (asprintf(&card_path, DRM_DEV_NAME, DRM_DIR_NAME, i) < 0) + continue; + +- dri2_dpy->fd = loader_open_device(card_path); ++ dri2_dpy->fd_dpy = loader_open_device(card_path); + free(card_path); +- if (dri2_dpy->fd < 0) ++ if (dri2_dpy->fd_dpy < 0) + continue; + +- if (dri2_null_device_is_kms(dri2_dpy->fd)) { +- dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd); +- if (dri2_dpy->driver_name) { +- if (dri2_load_driver_dri3(disp)) { +- _EGLDevice *dev = _eglAddDevice(dri2_dpy->fd, false); +- if (!dev) { +- dlclose(dri2_dpy->driver); +- _eglLog(_EGL_WARNING, "DRI2: failed to find EGLDevice"); +- } else { +- dri2_dpy->loader_extensions = image_loader_extensions; +- dri2_dpy->own_device = 1; +- disp->Device = dev; +- return true; +- } +- } +- free(dri2_dpy->driver_name); +- dri2_dpy->driver_name = NULL; +- } +- } ++ if (dri2_null_try_device(disp)) ++ return true; ++ ++ close(dri2_dpy->fd_dpy); ++ ++ if (dri2_dpy->fd >= 0 && dri2_dpy->fd != dri2_dpy->fd_dpy) ++ close(dri2_dpy->fd); + +- close(dri2_dpy->fd); ++ dri2_dpy->fd_dpy = -1; + dri2_dpy->fd = -1; + } + +@@ -1867,7 +1928,7 @@ dri2_null_setup_swap_interval(_EGLDisplay *disp) + + dri2_setup_swap_interval(disp, swap_max_interval); + +- err = drmGetCap(dri2_dpy->fd, DRM_CAP_ASYNC_PAGE_FLIP, &value); ++ err = drmGetCap(dri2_dpy->fd_dpy, DRM_CAP_ASYNC_PAGE_FLIP, &value); + if (err || value == 0) { + + /* DRM/KMS does not support async page flip. In order to support +@@ -1914,7 +1975,7 @@ dri2_initialize_null(_EGLDisplay *disp) + * modesetting if not. If this succeeds then universal planes will also have + * been enabled. + */ +- err = drmSetClientCap(dri2_dpy->fd, DRM_CLIENT_CAP_ATOMIC, 1); ++ err = drmSetClientCap(dri2_dpy->fd_dpy, DRM_CLIENT_CAP_ATOMIC, 1); + dri2_dpy->atomic_enabled = !err; + + if (!dri2_dpy->atomic_enabled) { +@@ -1922,7 +1983,7 @@ dri2_initialize_null(_EGLDisplay *disp) + * Enable universal planes so that we can get the pixel formats for the + * primary plane + */ +- err = drmSetClientCap(dri2_dpy->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); ++ err = drmSetClientCap(dri2_dpy->fd_dpy, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); + if (err) { + _eglError(EGL_NOT_INITIALIZED, "failed to enable universal planes"); + goto cleanup; +@@ -1955,7 +2016,7 @@ dri2_initialize_null(_EGLDisplay *disp) + prefer_in_formats = dri2_dpy->image->base.version >= 14 && + dri2_dpy->image->createImageWithModifiers; + +- if (!display_output_init(dri2_dpy->fd, &dri2_dpy->output, ++ if (!display_output_init(dri2_dpy->fd_dpy, &dri2_dpy->output, + dri2_dpy->atomic_enabled, + prefer_in_formats, + &dri2_dpy->in_formats_enabled)) { +@@ -1990,7 +2051,7 @@ dri2_teardown_null(struct dri2_egl_display *dri2_dpy) + drmModeFreeFormats(dri2_dpy->output.in_formats); + + if (dri2_dpy->output.mode_blob_id) +- drmModeDestroyPropertyBlob(dri2_dpy->fd, dri2_dpy->output.mode_blob_id); ++ drmModeDestroyPropertyBlob(dri2_dpy->fd_dpy, dri2_dpy->output.mode_blob_id); + + if (dri2_dpy->output.plane_prop_res) { + for (unsigned i = 0; dri2_dpy->output.plane_prop_res[i]; i++) +-- +2.25.1 + diff --git a/package/mesa3d/0055-egl-null-introduce-NULL_DRM_DISPLAY.patch b/package/mesa3d/0055-egl-null-introduce-NULL_DRM_DISPLAY.patch new file mode 100644 index 00000000..a9fc930b --- /dev/null +++ b/package/mesa3d/0055-egl-null-introduce-NULL_DRM_DISPLAY.patch @@ -0,0 +1,120 @@ +From 693fff6d87abfcae887afde7f80f402b7ff5c0ab Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Mon, 28 Jun 2021 16:36:15 +0100 +Subject: [PATCH 55/67] egl/null: introduce NULL_DRM_DISPLAY + +Introduce the NULL_DRM_DISPLAY environment variable, which allows +a particular DRM display to be selected, rather than the first +suitable DRM device found. + +To select a particular display, NULL_DRM_DISPLAY should be set to +the card number (i.e. minor number) of the DRM device representing +the display. For example, NULL_DRM_DISPLAY=2 will select +/dev/dri/card2. +--- + src/egl/drivers/dri2/platform_null.c | 65 ++++++++++++++++++++-------- + 1 file changed, 46 insertions(+), 19 deletions(-) + +diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c +index af77ea4dd89..529cc7a2a2f 100644 +--- a/src/egl/drivers/dri2/platform_null.c ++++ b/src/egl/drivers/dri2/platform_null.c +@@ -1784,6 +1784,8 @@ dri2_null_try_device(_EGLDisplay *disp) + { + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + ++ dri2_dpy->fd = -1; ++ + if (!dri2_null_device_is_kms(dri2_dpy->fd_dpy)) + return false; + +@@ -1841,34 +1843,56 @@ dri2_null_try_device(_EGLDisplay *disp) + } + + static bool +-dri2_null_probe_device(_EGLDisplay *disp) ++dri2_null_probe_device(_EGLDisplay *disp, unsigned minor) + { + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); ++ char *card_path; + +- dri2_dpy->fd = -1; +- dri2_dpy->fd_dpy = -1; ++ if (asprintf(&card_path, DRM_DEV_NAME, DRM_DIR_NAME, minor) < 0) ++ goto cleanup; + +- for (unsigned i = 0; i <= NULL_CARD_MINOR_MAX; i++) { +- char *card_path; ++ dri2_dpy->fd_dpy = loader_open_device(card_path); ++ free(card_path); ++ if (dri2_dpy->fd_dpy < 0) ++ goto cleanup; + +- if (asprintf(&card_path, DRM_DEV_NAME, DRM_DIR_NAME, i) < 0) +- continue; ++ if (dri2_null_try_device(disp)) ++ return true; + +- dri2_dpy->fd_dpy = loader_open_device(card_path); +- free(card_path); +- if (dri2_dpy->fd_dpy < 0) +- continue; ++ close(dri2_dpy->fd_dpy); + +- if (dri2_null_try_device(disp)) +- return true; ++ if (dri2_dpy->fd >= 0 && dri2_dpy->fd != dri2_dpy->fd_dpy) ++ close(dri2_dpy->fd); + +- close(dri2_dpy->fd_dpy); ++cleanup: ++ dri2_dpy->fd_dpy = -1; ++ dri2_dpy->fd = -1; + +- if (dri2_dpy->fd >= 0 && dri2_dpy->fd != dri2_dpy->fd_dpy) +- close(dri2_dpy->fd); ++ return false; ++} ++ ++static bool ++dri2_null_probe_devices(_EGLDisplay *disp) ++{ ++ const char *null_drm_display = getenv("NULL_DRM_DISPLAY"); ++ ++ if (null_drm_display) { ++ char *endptr; ++ long val = strtol(null_drm_display, &endptr, 10); + +- dri2_dpy->fd_dpy = -1; +- dri2_dpy->fd = -1; ++ if (endptr != null_drm_display && !*endptr && ++ val >= 0 && val <= NULL_CARD_MINOR_MAX) { ++ if (dri2_null_probe_device(disp, (unsigned)val)) ++ return true; ++ } else { ++ _eglLog(_EGL_FATAL, "NULL_DRM_DISPLAY is invalid: %s", ++ null_drm_display); ++ } ++ } else { ++ for (unsigned i = 0; i <= NULL_CARD_MINOR_MAX; i++) { ++ if (dri2_null_probe_device(disp, i)) ++ return true; ++ } + } + + return false; +@@ -1965,7 +1989,10 @@ dri2_initialize_null(_EGLDisplay *disp) + + disp->DriverData = (void *) dri2_dpy; + +- if (!dri2_null_probe_device(disp)) { ++ dri2_dpy->fd_dpy = -1; ++ dri2_dpy->fd = -1; ++ ++ if (!dri2_null_probe_devices(disp)) { + _eglError(EGL_NOT_INITIALIZED, "failed to load driver"); + goto cleanup; + } +-- +2.25.1 + diff --git a/package/mesa3d/0056-vulkan-wsi-check-the-DRI3-and-Present-XCB-reply-poin.patch b/package/mesa3d/0056-vulkan-wsi-check-the-DRI3-and-Present-XCB-reply-poin.patch new file mode 100644 index 00000000..2481e925 --- /dev/null +++ b/package/mesa3d/0056-vulkan-wsi-check-the-DRI3-and-Present-XCB-reply-poin.patch @@ -0,0 +1,37 @@ +From a422756b7d73b48d3d10d15066a61e9332370719 Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Mon, 21 Jun 2021 17:05:17 +0100 +Subject: [PATCH 56/67] vulkan/wsi: check the DRI3 and Present XCB reply + pointers + +Check that the DRI3 and Present version replies are not NULL +before accessing the version fields. +--- + src/vulkan/wsi/wsi_common_x11.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c +index 9dce78eddeb..9eb624df640 100644 +--- a/src/vulkan/wsi/wsi_common_x11.c ++++ b/src/vulkan/wsi/wsi_common_x11.c +@@ -216,7 +216,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, + + ver_cookie = xcb_dri3_query_version(conn, 1, 2); + ver_reply = xcb_dri3_query_version_reply(conn, ver_cookie, NULL); +- has_dri3_v1_2 = ++ has_dri3_v1_2 = ver_reply != NULL && + (ver_reply->major_version > 1 || ver_reply->minor_version >= 2); + free(ver_reply); + } +@@ -230,7 +230,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, + + ver_cookie = xcb_present_query_version(conn, 1, 2); + ver_reply = xcb_present_query_version_reply(conn, ver_cookie, NULL); +- has_present_v1_2 = ++ has_present_v1_2 = ver_reply != NULL && + (ver_reply->major_version > 1 || ver_reply->minor_version >= 2); + free(ver_reply); + } +-- +2.25.1 + diff --git a/package/mesa3d/0057-vulkan-wsi-Allow-host-visible-memory-to-be-requested.patch b/package/mesa3d/0057-vulkan-wsi-Allow-host-visible-memory-to-be-requested.patch new file mode 100644 index 00000000..a65524a2 --- /dev/null +++ b/package/mesa3d/0057-vulkan-wsi-Allow-host-visible-memory-to-be-requested.patch @@ -0,0 +1,143 @@ +From b900d4998b95a8bdfb01600f81635ff76810cfe6 Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Tue, 16 Feb 2021 20:17:32 +0000 +Subject: [PATCH 57/67] vulkan/wsi: Allow host visible memory to be requested + +Allow host visible memory to be explicitly requested when allocating +native images. + +For a software driver on X11, we need to be able to map the memory on +the host, in order to present the contents to the X Server. +--- + src/vulkan/wsi/wsi_common_display.c | 2 +- + src/vulkan/wsi/wsi_common_drm.c | 17 +++++++++++++---- + src/vulkan/wsi/wsi_common_private.h | 1 + + src/vulkan/wsi/wsi_common_wayland.c | 3 ++- + src/vulkan/wsi/wsi_common_x11.c | 1 + + 5 files changed, 18 insertions(+), 6 deletions(-) + +diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c +index aa07cada107..71a84e54079 100644 +--- a/src/vulkan/wsi/wsi_common_display.c ++++ b/src/vulkan/wsi/wsi_common_display.c +@@ -1031,7 +1031,7 @@ wsi_display_image_init(VkDevice device_h, + return VK_ERROR_DEVICE_LOST; + + VkResult result = wsi_create_native_image(&chain->base, create_info, +- 0, NULL, NULL, ++ 0, NULL, NULL, false, + &image->base); + if (result != VK_SUCCESS) + return result; +diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c +index 70d934aef13..aabb761908c 100644 +--- a/src/vulkan/wsi/wsi_common_drm.c ++++ b/src/vulkan/wsi/wsi_common_drm.c +@@ -66,6 +66,7 @@ wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd) + static uint32_t + select_memory_type(const struct wsi_device *wsi, + bool want_device_local, ++ bool want_host_visible, + uint32_t type_bits) + { + assert(type_bits); +@@ -74,8 +75,10 @@ select_memory_type(const struct wsi_device *wsi, + for (uint32_t i = 0; i < wsi->memory_props.memoryTypeCount; i++) { + const VkMemoryType type = wsi->memory_props.memoryTypes[i]; + bool local = type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; ++ bool host = type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + +- if ((type_bits & (1 << i)) && local == want_device_local) ++ if ((type_bits & (1 << i)) && local == want_device_local && ++ (!want_host_visible || host)) + return i; + all_local &= local; + } +@@ -83,6 +86,8 @@ select_memory_type(const struct wsi_device *wsi, + /* ignore want_device_local when all memory types are device-local */ + if (all_local) { + assert(!want_device_local); ++ /* currently, host visibility is only needed with device local */ ++ assert(!want_host_visible); + return ffs(type_bits) - 1; + } + +@@ -107,6 +112,7 @@ wsi_create_native_image(const struct wsi_swapchain *chain, + uint32_t num_modifier_lists, + const uint32_t *num_modifiers, + const uint64_t *const *modifiers, ++ bool host_visible, + struct wsi_image *image) + { + const struct wsi_device *wsi = chain->wsi; +@@ -317,7 +323,8 @@ wsi_create_native_image(const struct wsi_swapchain *chain, + .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, + .pNext = &memory_dedicated_info, + .allocationSize = reqs.size, +- .memoryTypeIndex = select_memory_type(wsi, true, reqs.memoryTypeBits), ++ .memoryTypeIndex = select_memory_type(wsi, true, host_visible, ++ reqs.memoryTypeBits), + }; + result = wsi->AllocateMemory(chain->device, &memory_info, + &chain->alloc, &image->memory); +@@ -488,7 +495,8 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, + .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, + .pNext = &prime_memory_dedicated_info, + .allocationSize = linear_size, +- .memoryTypeIndex = select_memory_type(wsi, false, reqs.memoryTypeBits), ++ .memoryTypeIndex = select_memory_type(wsi, false, false, ++ reqs.memoryTypeBits), + }; + result = wsi->AllocateMemory(chain->device, &prime_memory_info, + &chain->alloc, &image->prime.memory); +@@ -542,7 +550,8 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, + .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, + .pNext = &memory_dedicated_info, + .allocationSize = reqs.size, +- .memoryTypeIndex = select_memory_type(wsi, true, reqs.memoryTypeBits), ++ .memoryTypeIndex = select_memory_type(wsi, true, false, ++ reqs.memoryTypeBits), + }; + result = wsi->AllocateMemory(chain->device, &memory_info, + &chain->alloc, &image->memory); +diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h +index 1fe8211f9cb..5ad087b32e0 100644 +--- a/src/vulkan/wsi/wsi_common_private.h ++++ b/src/vulkan/wsi/wsi_common_private.h +@@ -94,6 +94,7 @@ wsi_create_native_image(const struct wsi_swapchain *chain, + uint32_t num_modifier_lists, + const uint32_t *num_modifiers, + const uint64_t *const *modifiers, ++ bool host_visible, + struct wsi_image *image); + + VkResult +diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c +index 40f5338314f..983833e880b 100644 +--- a/src/vulkan/wsi/wsi_common_wayland.c ++++ b/src/vulkan/wsi/wsi_common_wayland.c +@@ -1074,7 +1074,8 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, + result = wsi_create_native_image(&chain->base, pCreateInfo, + chain->num_drm_modifiers > 0 ? 1 : 0, + &chain->num_drm_modifiers, +- &chain->drm_modifiers, &image->base); ++ &chain->drm_modifiers, false, ++ &image->base); + + if (result != VK_SUCCESS) + return result; +diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c +index 9eb624df640..eb639d6c265 100644 +--- a/src/vulkan/wsi/wsi_common_x11.c ++++ b/src/vulkan/wsi/wsi_common_x11.c +@@ -1315,6 +1315,7 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain, + } else { + result = wsi_create_native_image(&chain->base, pCreateInfo, + num_tranches, num_modifiers, modifiers, ++ chain->base.wsi->sw, + &image->base); + } + if (result < 0) +-- +2.25.1 + diff --git a/package/mesa3d/0058-vulkan-wsi-make-the-display-FD-available.patch b/package/mesa3d/0058-vulkan-wsi-make-the-display-FD-available.patch new file mode 100644 index 00000000..484e14b7 --- /dev/null +++ b/package/mesa3d/0058-vulkan-wsi-make-the-display-FD-available.patch @@ -0,0 +1,419 @@ +From afcfb076e89365ff1f33c658a6a615d2108d97f5 Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Thu, 17 Jun 2021 17:17:07 +0100 +Subject: [PATCH 58/67] vulkan/wsi: make the display FD available + +Pass the display FD to the Vulkan image create and memory +allocation functions when allocating swapchain images. +--- + src/vulkan/wsi/wsi_common.h | 14 +++ + src/vulkan/wsi/wsi_common_display.c | 2 +- + src/vulkan/wsi/wsi_common_drm.c | 22 ++++- + src/vulkan/wsi/wsi_common_private.h | 2 + + src/vulkan/wsi/wsi_common_wayland.c | 127 ++++++++++++++++++++++------ + src/vulkan/wsi/wsi_common_x11.c | 42 ++++++--- + 6 files changed, 169 insertions(+), 40 deletions(-) + +diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h +index d5367db3a94..c2563c677e6 100644 +--- a/src/vulkan/wsi/wsi_common.h ++++ b/src/vulkan/wsi/wsi_common.h +@@ -37,6 +37,8 @@ + #define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA (VkStructureType)1000001003 + #define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA (VkStructureType)1000001005 + #define VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA (VkStructureType)1000001006 ++#define VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO2_MESA (VkStructureType)1000001007 ++#define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO2_MESA (VkStructureType)1000001008 + + /* This is always chained to VkImageCreateInfo when a wsi image is created. + * It indicates that the image can be transitioned to/from +@@ -75,6 +77,18 @@ struct wsi_memory_signal_submit_info { + VkDeviceMemory memory; + }; + ++struct wsi_image_create_info2 { ++ VkStructureType sType; ++ const void *pNext; ++ int display_fd; ++}; ++ ++struct wsi_memory_allocate_info2 { ++ VkStructureType sType; ++ const void *pNext; ++ int display_fd; ++}; ++ + struct wsi_fence { + VkDevice device; + const struct wsi_device *wsi_device; +diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c +index 71a84e54079..f135b4e38de 100644 +--- a/src/vulkan/wsi/wsi_common_display.c ++++ b/src/vulkan/wsi/wsi_common_display.c +@@ -1032,7 +1032,7 @@ wsi_display_image_init(VkDevice device_h, + + VkResult result = wsi_create_native_image(&chain->base, create_info, + 0, NULL, NULL, false, +- &image->base); ++ wsi->fd, &image->base); + if (result != VK_SUCCESS) + return result; + +diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c +index aabb761908c..6201891ca80 100644 +--- a/src/vulkan/wsi/wsi_common_drm.c ++++ b/src/vulkan/wsi/wsi_common_drm.c +@@ -113,6 +113,7 @@ wsi_create_native_image(const struct wsi_swapchain *chain, + const uint32_t *num_modifiers, + const uint64_t *const *modifiers, + bool host_visible, ++ int display_fd, + struct wsi_image *image) + { + const struct wsi_device *wsi = chain->wsi; +@@ -170,6 +171,12 @@ wsi_create_native_image(const struct wsi_swapchain *chain, + __vk_append_struct(&image_info, &image_format_list); + } + ++ struct wsi_image_create_info2 image_wsi_info2 = { ++ .sType = VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO2_MESA, ++ .display_fd = display_fd, ++ }; ++ __vk_append_struct(&image_info, &image_wsi_info2); ++ + VkImageDrmFormatModifierListCreateInfoEXT image_modifier_list; + + uint32_t image_modifier_count = 0, modifier_prop_count = 0; +@@ -308,9 +315,14 @@ wsi_create_native_image(const struct wsi_swapchain *chain, + .pNext = NULL, + .implicit_sync = true, + }; ++ const struct wsi_memory_allocate_info2 memory_wsi_info2 = { ++ .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO2_MESA, ++ .pNext = &memory_wsi_info, ++ .display_fd = display_fd, ++ }; + const VkExportMemoryAllocateInfo memory_export_info = { + .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO, +- .pNext = &memory_wsi_info, ++ .pNext = &memory_wsi_info2, + .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, + }; + const VkMemoryDedicatedAllocateInfo memory_dedicated_info = { +@@ -440,6 +452,7 @@ VkResult + wsi_create_prime_image(const struct wsi_swapchain *chain, + const VkSwapchainCreateInfoKHR *pCreateInfo, + bool use_modifier, ++ int display_fd, + struct wsi_image *image) + { + const struct wsi_device *wsi = chain->wsi; +@@ -480,9 +493,14 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, + .pNext = NULL, + .implicit_sync = true, + }; ++ const struct wsi_memory_allocate_info2 memory_wsi_info2 = { ++ .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO2_MESA, ++ .pNext = &memory_wsi_info, ++ .display_fd = display_fd, ++ }; + const VkExportMemoryAllocateInfo prime_memory_export_info = { + .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO, +- .pNext = &memory_wsi_info, ++ .pNext = &memory_wsi_info2, + .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, + }; + const VkMemoryDedicatedAllocateInfo prime_memory_dedicated_info = { +diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h +index 5ad087b32e0..e46328156dc 100644 +--- a/src/vulkan/wsi/wsi_common_private.h ++++ b/src/vulkan/wsi/wsi_common_private.h +@@ -95,12 +95,14 @@ wsi_create_native_image(const struct wsi_swapchain *chain, + const uint32_t *num_modifiers, + const uint64_t *const *modifiers, + bool host_visible, ++ int display_fd, + struct wsi_image *image); + + VkResult + wsi_create_prime_image(const struct wsi_swapchain *chain, + const VkSwapchainCreateInfoKHR *pCreateInfo, + bool use_modifier, ++ int display_fd, + struct wsi_image *image); + + void +diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c +index 983833e880b..1109d3f07b6 100644 +--- a/src/vulkan/wsi/wsi_common_wayland.c ++++ b/src/vulkan/wsi/wsi_common_wayland.c +@@ -32,6 +32,8 @@ + #include + #include + #include ++#include ++#include + + #include "drm-uapi/drm_fourcc.h" + +@@ -82,6 +84,9 @@ struct wsi_wl_display { + + struct wsi_wayland *wsi_wl; + ++ int fd; ++ bool authenticated; ++ + /* Points to formats in wsi_wl_display_drm or wsi_wl_display_dmabuf */ + struct u_vector * formats; + +@@ -261,10 +266,52 @@ wsi_wl_display_add_wl_shm_format(struct wsi_wl_display *display, + } + } + ++static int ++open_display_device(const char *name) ++{ ++ int fd; ++ ++#ifdef O_CLOEXEC ++ fd = open(name, O_RDWR | O_CLOEXEC); ++ if (fd != -1 || errno != EINVAL) { ++ return fd; ++ } ++#endif ++ ++ fd = open(name, O_RDWR); ++ if (fd != -1) { ++ long flags = fcntl(fd, F_GETFD); ++ ++ if (flags != -1) { ++ if (!fcntl(fd, F_SETFD, flags | FD_CLOEXEC)) ++ return fd; ++ } ++ close (fd); ++ } ++ ++ return -1; ++} + + static void + drm_handle_device(void *data, struct wl_drm *drm, const char *name) + { ++ struct wsi_wl_display *display = data; ++ const int fd = open_display_device(name); ++ ++ if (fd != -1) { ++ if (drmGetNodeTypeFromFd(fd) != DRM_NODE_RENDER) { ++ drm_magic_t magic; ++ ++ if (drmGetMagic(fd, &magic)) { ++ close(fd); ++ return; ++ } ++ wl_drm_authenticate(drm, magic); ++ } else { ++ display->authenticated = true; ++ } ++ display->fd = fd; ++ } + } + + static uint32_t +@@ -346,6 +393,9 @@ drm_handle_format(void *data, struct wl_drm *drm, uint32_t wl_format) + static void + drm_handle_authenticated(void *data, struct wl_drm *drm) + { ++ struct wsi_wl_display *display = data; ++ ++ display->authenticated = true; + } + + static void +@@ -487,6 +537,9 @@ wsi_wl_display_finish(struct wsi_wl_display *display) + wl_proxy_wrapper_destroy(display->wl_display_wrapper); + if (display->queue) + wl_event_queue_destroy(display->queue); ++ ++ if (display->fd != -1) ++ close(display->fd); + } + + static VkResult +@@ -501,6 +554,7 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl, + display->wsi_wl = wsi_wl; + display->wl_display = wl_display; + display->sw = sw; ++ display->fd = -1; + + if (get_format_list) { + if (!u_vector_init(&display->swrast.formats, sizeof(VkFormat), 8) || +@@ -542,41 +596,60 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl, + /* Round-trip to get wl_drms and zwp_linux_dmabuf_v1 globals */ + wl_display_roundtrip_queue(display->wl_display, display->queue); + ++ if (!display->drm.wl_drm && !display->dmabuf.wl_dmabuf && !display->swrast.wl_shm) { ++ result = VK_ERROR_SURFACE_LOST_KHR; ++ goto fail_registry; ++ } ++ + /* Round-trip again to get formats, modifiers and capabilities */ +- if (display->drm.wl_drm || display->dmabuf.wl_dmabuf || display->swrast.wl_shm) +- wl_display_roundtrip_queue(display->wl_display, display->queue); ++ wl_display_roundtrip_queue(display->wl_display, display->queue); + +- if (wsi_wl->wsi->force_bgra8_unorm_first) { +- /* Find BGRA8_UNORM in the list and swap it to the first position if we +- * can find it. Some apps get confused if SRGB is first in the list. +- */ +- VkFormat *first_fmt = u_vector_head(display->formats); +- VkFormat *iter_fmt; +- u_vector_foreach(iter_fmt, display->formats) { +- if (*iter_fmt == VK_FORMAT_B8G8R8A8_UNORM) { +- *iter_fmt = *first_fmt; +- *first_fmt = VK_FORMAT_B8G8R8A8_UNORM; +- break; +- } +- } ++ if (display->fd == -1) { ++ result = VK_ERROR_SURFACE_LOST_KHR; ++ goto fail_registry; + } + +- /* Prefer the linux-dmabuf protocol if available */ +- if (display->sw) +- display->formats = &display->swrast.formats; +- else if (display->dmabuf.wl_dmabuf) { +- display->formats = &display->dmabuf.formats; +- } else if (display->drm.wl_drm && +- (display->drm.capabilities & WL_DRM_CAPABILITY_PRIME)) { +- /* We need prime support for wl_drm */ +- display->formats = &display->drm.formats; +- } ++ wl_display_roundtrip_queue(display->wl_display, display->queue); + +- if (!display->formats) { ++ if (!display->authenticated) { + result = VK_ERROR_SURFACE_LOST_KHR; + goto fail_registry; + } + ++ if (get_format_list) { ++ /* Prefer the linux-dmabuf protocol if available */ ++ if (display->sw) ++ display->formats = &display->swrast.formats; ++ else if(display->dmabuf.wl_dmabuf && ++ u_vector_length(&display->dmabuf.formats)) { ++ display->formats = &display->dmabuf.formats; ++ } else if (display->drm.wl_drm && ++ display->drm.capabilities & WL_DRM_CAPABILITY_PRIME) { ++ display->formats = &display->drm.formats; ++ } ++ ++ if (!display->formats) { ++ result = VK_ERROR_SURFACE_LOST_KHR; ++ goto fail_registry; ++ } ++ ++ if (wsi_wl->wsi->force_bgra8_unorm_first) { ++ /* Find BGRA8_UNORM in the list and swap it to the first position if ++ * we can find it. Some apps get confused if SRGB is first in the ++ * list. ++ */ ++ VkFormat *first_fmt = u_vector_tail(display->formats); ++ VkFormat *iter_fmt; ++ u_vector_foreach(iter_fmt, display->formats) { ++ if (*iter_fmt == VK_FORMAT_B8G8R8A8_UNORM) { ++ *iter_fmt = *first_fmt; ++ *first_fmt = VK_FORMAT_B8G8R8A8_UNORM; ++ break; ++ } ++ } ++ } ++ } ++ + /* We don't need this anymore */ + wl_registry_destroy(registry); + +@@ -1075,7 +1148,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, + chain->num_drm_modifiers > 0 ? 1 : 0, + &chain->num_drm_modifiers, + &chain->drm_modifiers, false, +- &image->base); ++ display->fd, &image->base); + + if (result != VK_SUCCESS) + return result; +diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c +index eb639d6c265..ba64e260932 100644 +--- a/src/vulkan/wsi/wsi_common_x11.c ++++ b/src/vulkan/wsi/wsi_common_x11.c +@@ -1303,7 +1303,8 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain, + const VkAllocationCallbacks* pAllocator, + const uint64_t *const *modifiers, + const uint32_t *num_modifiers, +- int num_tranches, struct x11_image *image) ++ int num_tranches, int display_fd, ++ struct x11_image *image) + { + xcb_void_cookie_t cookie; + VkResult result; +@@ -1311,11 +1312,12 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain, + + if (chain->base.use_prime_blit) { + bool use_modifier = num_tranches > 0; +- result = wsi_create_prime_image(&chain->base, pCreateInfo, use_modifier, &image->base); ++ result = wsi_create_prime_image(&chain->base, pCreateInfo, use_modifier, ++ display_fd, &image->base); + } else { + result = wsi_create_native_image(&chain->base, pCreateInfo, + num_tranches, num_modifiers, modifiers, +- chain->base.wsi->sw, ++ chain->base.wsi->sw, display_fd, + &image->base); + } + if (result < 0) +@@ -1687,14 +1689,34 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, + modifiers, num_modifiers, &num_tranches, + pAllocator); + ++ + uint32_t image = 0; +- for (; image < chain->base.image_count; image++) { +- result = x11_image_init(device, chain, pCreateInfo, pAllocator, +- (const uint64_t *const *)modifiers, +- num_modifiers, num_tranches, +- &chain->images[image]); +- if (result != VK_SUCCESS) +- goto fail_init_images; ++ { ++ int display_fd = -1; ++ ++ if (!wsi_device->sw) { ++ xcb_screen_iterator_t screen_iter = ++ xcb_setup_roots_iterator(xcb_get_setup(conn)); ++ xcb_screen_t *screen = screen_iter.data; ++ ++ display_fd = wsi_dri3_open(conn, screen->root, None); ++ } ++ ++ for (; image < chain->base.image_count; image++) { ++ result = x11_image_init(device, chain, pCreateInfo, pAllocator, ++ (const uint64_t *const *)modifiers, ++ num_modifiers, num_tranches, ++ display_fd, &chain->images[image]); ++ if (result != VK_SUCCESS) { ++ if (display_fd >= 0) ++ close(display_fd); ++ ++ goto fail_init_images; ++ } ++ } ++ ++ if (display_fd >= 0) ++ close(display_fd); + } + + if ((chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR || +-- +2.25.1 + diff --git a/package/mesa3d/0059-pvr-wsi-add-PowerVR-Vulkan-WSI-library.patch b/package/mesa3d/0059-pvr-wsi-add-PowerVR-Vulkan-WSI-library.patch new file mode 100644 index 00000000..79085fa4 --- /dev/null +++ b/package/mesa3d/0059-pvr-wsi-add-PowerVR-Vulkan-WSI-library.patch @@ -0,0 +1,1343 @@ +From 650cbfe1007a3f9dd4ef8a3bbe829bbfed4ab1cc Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Thu, 18 Mar 2021 13:44:57 +0000 +Subject: [PATCH 59/67] pvr/wsi: add PowerVR Vulkan WSI library + +PowerVR Vulkan will load the WSI library, libpvr_mesa_wsi.so, +and lookup the symbol pvr_mesa_wsi_sym_addr, which is a used to +lookup all other symbols required by Vulkan from the library. +The function is used by Vulkan to lookup the library initialisation +function, pvr_mesa_wsi_init. That function is passed the address +of another lookup function, pvr_vk_mesa_wsi_sym_addr, which is used +by the WSI library to lookup symbols in Vulkan. + +The interface between PVR Vulkan and the WSI library is defined in +pvr_mesa_wsi_interface.h. Most of the functions defined on the WSI +side are wrappers around Mesa WSI functions. +--- + meson.build | 1 + + meson_options.txt | 2 +- + src/meson.build | 3 + + src/pvr/meson.build | 23 ++ + src/pvr/wsi/meson.build | 75 ++++++ + src/pvr/wsi/pvr_mesa_wsi_interface.h | 306 ++++++++++++++++++++++++ + src/pvr/wsi/pvr_wsi.c | 333 +++++++++++++++++++++++++++ + src/pvr/wsi/pvr_wsi.h | 78 +++++++ + src/pvr/wsi/pvr_wsi_display.c | 293 +++++++++++++++++++++++ + src/pvr/wsi/pvr_wsi_wayland.c | 45 ++++ + src/pvr/wsi/pvr_wsi_x11.c | 62 +++++ + 11 files changed, 1220 insertions(+), 1 deletion(-) + create mode 100644 src/pvr/meson.build + create mode 100644 src/pvr/wsi/meson.build + create mode 100644 src/pvr/wsi/pvr_mesa_wsi_interface.h + create mode 100644 src/pvr/wsi/pvr_wsi.c + create mode 100644 src/pvr/wsi/pvr_wsi.h + create mode 100644 src/pvr/wsi/pvr_wsi_display.c + create mode 100644 src/pvr/wsi/pvr_wsi_wayland.c + create mode 100644 src/pvr/wsi/pvr_wsi_x11.c + +diff --git a/meson.build b/meson.build +index 8db1699729a..9341e5500fc 100644 +--- a/meson.build ++++ b/meson.build +@@ -296,6 +296,7 @@ with_swrast_vk = _vulkan_drivers.contains('swrast') + with_virtio_vk = _vulkan_drivers.contains('virtio-experimental') + with_freedreno_kgsl = get_option('freedreno-kgsl') + with_broadcom_vk = _vulkan_drivers.contains('broadcom') ++with_pvr_vk = _vulkan_drivers.contains('pvr') + with_any_vk = _vulkan_drivers.length() != 0 + + with_any_broadcom = with_gallium_vc4 or with_gallium_v3d or with_broadcom_vk +diff --git a/meson_options.txt b/meson_options.txt +index d36e714ea4c..e0c25a5b15b 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -194,7 +194,7 @@ option( + 'vulkan-drivers', + type : 'array', + value : ['auto'], +- choices : ['auto', 'amd', 'broadcom', 'freedreno', 'intel', 'panfrost', 'swrast', 'virtio-experimental'], ++ choices : ['auto', 'amd', 'broadcom', 'freedreno', 'intel', 'panfrost', 'swrast', 'virtio-experimental', 'pvr'], + description : 'List of vulkan drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built' + ) + option( +diff --git a/src/meson.build b/src/meson.build +index f6eede56648..36fec262020 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -90,6 +90,9 @@ endif + if with_gallium_panfrost or with_gallium_lima or with_panfrost_vk + subdir('panfrost') + endif ++if with_pvr_vk ++ subdir('pvr') ++endif + if with_gallium_virgl or with_virtio_vk + subdir('virtio') + endif +diff --git a/src/pvr/meson.build b/src/pvr/meson.build +new file mode 100644 +index 00000000000..09a6986a4c9 +--- /dev/null ++++ b/src/pvr/meson.build +@@ -0,0 +1,23 @@ ++# Copyright (c) Imagination Technologies Ltd. ++ ++# Permission is hereby granted, free of charge, to any person obtaining a copy ++# of this software and associated documentation files (the "Software"), to deal ++# in the Software without restriction, including without limitation the rights ++# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++# copies of the Software, and to permit persons to whom the Software is ++# furnished to do so, subject to the following conditions: ++ ++# The above copyright notice and this permission notice shall be included in ++# all copies or substantial portions of the Software. ++ ++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++# SOFTWARE. ++ ++if with_pvr_vk ++ subdir('wsi') ++endif +diff --git a/src/pvr/wsi/meson.build b/src/pvr/wsi/meson.build +new file mode 100644 +index 00000000000..57c7623c4bb +--- /dev/null ++++ b/src/pvr/wsi/meson.build +@@ -0,0 +1,75 @@ ++# Copyright (c) Imagination Technologies Ltd. ++ ++# Permission is hereby granted, free of charge, to any person obtaining a copy ++# of this software and associated documentation files (the "Software"), to deal ++# in the Software without restriction, including without limitation the rights ++# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++# copies of the Software, and to permit persons to whom the Software is ++# furnished to do so, subject to the following conditions: ++ ++# The above copyright notice and this permission notice shall be included in ++# all copies or substantial portions of the Software. ++ ++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++# SOFTWARE. ++ ++pvr_wsi_args = vulkan_wsi_args ++ ++pvr_wsi_depends = [ dep_libdrm, idep_vulkan_util, idep_xmlconfig ] ++ ++pvr_wsi_includes = [ ++ inc_include, ++ inc_src, ++ inc_vulkan_util, ++ inc_vulkan_wsi ++] ++ ++pvr_wsi_src = [ 'pvr_wsi.c' ] ++ ++if with_platform_wayland ++ pvr_wsi_args += '-DVK_USE_PLATFORM_WAYLAND_KHR' ++ ++ pvr_wsi_depends += dep_wayland_client ++ ++ pvr_wsi_src += 'pvr_wsi_wayland.c' ++endif ++ ++if with_platform_x11 ++ pvr_wsi_args += [ ++ '-DVK_USE_PLATFORM_XCB_KHR', ++ '-DVK_USE_PLATFORM_XLIB_KHR', ++ ] ++ ++ pvr_wsi_depends += dep_xcb_dri2 ++ ++ pvr_wsi_src += 'pvr_wsi_x11.c' ++endif ++ ++if system_has_kms_drm and not with_platform_android ++ pvr_wsi_args += '-DVK_USE_PLATFORM_DISPLAY_KHR' ++ ++ pvr_wsi_src += 'pvr_wsi_display.c' ++endif ++ ++if with_xlib_lease ++ pvr_wsi_args += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT' ++ ++ pvr_wsi_depends += dep_xlib_xrandr ++endif ++ ++libvulkan_wsi = shared_library( ++ 'pvr_mesa_wsi', ++ pvr_wsi_src, ++ include_directories : pvr_wsi_includes, ++ dependencies : pvr_wsi_depends, ++ c_args : pvr_wsi_args, ++ link_with: libvulkan_wsi, ++ gnu_symbol_visibility : 'hidden', ++ build_by_default : true, ++ install : true ++) +diff --git a/src/pvr/wsi/pvr_mesa_wsi_interface.h b/src/pvr/wsi/pvr_mesa_wsi_interface.h +new file mode 100644 +index 00000000000..b4b1bcb0c9d +--- /dev/null ++++ b/src/pvr/wsi/pvr_mesa_wsi_interface.h +@@ -0,0 +1,306 @@ ++/*************************************************************************/ /*! ++@File ++@Title PVR interface to the Vulkan WSI layer in Mesa ++@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved ++@License MIT ++ ++The contents of this file are subject to the MIT license as set out below. ++ ++Permission is hereby granted, free of charge, to any person obtaining a copy ++of this software and associated documentation files (the "Software"), to deal ++in the Software without restriction, including without limitation the rights ++to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++copies of the Software, and to permit persons to whom the Software is ++furnished to do so, subject to the following conditions: ++ ++The above copyright notice and this permission notice shall be included in ++all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ++THE SOFTWARE. ++*/ /**************************************************************************/ ++ ++#ifndef PVR_MESA_WSI_INTERFACE_H ++#define PVR_MESA_WSI_INTERFACE_H ++ ++#include ++#include ++ ++#include ++ ++/* ++ * The pvr_mesa_wsi structure holds the Mesa WSI state, and is opaque to ++ * the PowerVK DDK. ++ */ ++struct pvr_mesa_wsi; ++ ++/* ++ * Functions defined in Mesa for use by the PowerVR DDK. ++ * All functions have a "pvr_mesa_wsi" prefix. ++ */ ++ ++void * ++pvr_mesa_wsi_sym_addr(struct pvr_mesa_wsi *mwsi, ++ const char *name); ++ ++VkResult ++pvr_mesa_wsi_init(struct pvr_mesa_wsi **mwsi, ++ VkPhysicalDevice physicalDevice, ++ PFN_vkVoidFunction (VKAPI_PTR *pvr_vk_mesa_wsi_sym_addr) ++ (VkPhysicalDevice physicalDevice, const char *), ++ const VkAllocationCallbacks *alloc, ++ int fd, ++ bool sw); ++ ++void ++pvr_mesa_wsi_finish(struct pvr_mesa_wsi *mwsi, ++ const VkAllocationCallbacks *alloc); ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_support(struct pvr_mesa_wsi *mwsi, ++ uint32_t queueFamilyIndex, ++ VkSurfaceKHR surface, ++ VkBool32 *pSupported); ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_capabilities(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ VkSurfaceCapabilitiesKHR *pSurfaceCapabilities); ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_capabilities2(struct pvr_mesa_wsi *mwsi, ++ const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, ++ VkSurfaceCapabilities2KHR *pSurfaceCapabilities); ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_capabilities2ext(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ VkSurfaceCapabilities2EXT *pSurfaceCapabilities); ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_formats(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ uint32_t *pSurfaceFormatCount, ++ VkSurfaceFormatKHR *pSurfaceFormats); ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_formats2(struct pvr_mesa_wsi *mwsi, ++ const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, ++ uint32_t *pSurfaceFormatCount, ++ VkSurfaceFormat2KHR *pSurfaceFormats); ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_present_modes(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ uint32_t *pPresentModeCount, ++ VkPresentModeKHR *pPresentModes); ++ ++VkResult ++pvr_mesa_wsi_common_create_swapchain(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ const VkSwapchainCreateInfoKHR *pCreateInfo, ++ const VkAllocationCallbacks *pAllocator, ++ VkSwapchainKHR *pSwapchain); ++void ++pvr_mesa_wsi_common_destroy_swapchain(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkSwapchainKHR swapchain, ++ const VkAllocationCallbacks *pAllocator); ++ ++VkResult ++pvr_mesa_wsi_common_get_images(struct pvr_mesa_wsi *mwsi, ++ VkSwapchainKHR swapchain, ++ uint32_t *pSwapchainImageCount, ++ VkImage *pSwapchainImages); ++ ++VkResult ++pvr_mesa_wsi_common_acquire_next_image2(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ const VkAcquireNextImageInfoKHR *pAcquireInfo, ++ uint32_t *pImageIndex); ++ ++VkResult ++pvr_mesa_wsi_common_queue_present(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkQueue queue, ++ int queue_family_index, ++ const VkPresentInfoKHR *pPresentInfo); ++ ++VkResult ++pvr_mesa_wsi_common_get_present_rectangles(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ uint32_t* pRectCount, ++ VkRect2D* pRects); ++ ++#if defined(VK_USE_PLATFORM_WAYLAND_KHR) ++VkBool32 ++pvr_mesa_wsi_get_physical_device_wayland_presentation_support(struct pvr_mesa_wsi *mwsi, ++ uint32_t queueFamilyIndex, ++ void *display); ++ ++VkResult ++pvr_mesa_wsi_create_wayland_surface(struct pvr_mesa_wsi *mwsi, ++ const VkAllocationCallbacks *pAllocator, ++ const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, ++ VkSurfaceKHR *pSurface); ++#endif ++ ++#if defined(VK_USE_PLATFORM_XCB_KHR) ++VkBool32 ++pvr_mesa_wsi_get_physical_device_xcb_presentation_support(struct pvr_mesa_wsi *mwsi, ++ uint32_t queueFamilyIndex, ++ void *connection, ++ uint32_t visualId); ++VkResult ++pvr_mesa_wsi_create_xcb_surface(struct pvr_mesa_wsi *mwsi, ++ const VkAllocationCallbacks *pAllocator, ++ const VkXcbSurfaceCreateInfoKHR *pCreateInfo, ++ VkSurfaceKHR *pSurface); ++#endif ++ ++#if defined(VK_USE_PLATFORM_XLIB_KHR) ++VkResult ++pvr_mesa_wsi_create_xlib_surface(struct pvr_mesa_wsi *mwsi, ++ const VkAllocationCallbacks *pAllocator, ++ const VkXlibSurfaceCreateInfoKHR *pCreateInfo, ++ VkSurfaceKHR *pSurface); ++#endif ++ ++VkResult ++pvr_mesa_wsi_display_get_physical_device_display_properties(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t *pPropertyCount, ++ VkDisplayPropertiesKHR *pProperties); ++ ++VkResult ++pvr_mesa_wsi_display_get_physical_device_display_properties2(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t *pPropertyCount, ++ VkDisplayProperties2KHR *pProperties); ++ ++VkResult ++pvr_mesa_wsi_display_get_physical_device_display_plane_properties(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t *pPropertyCount, ++ VkDisplayPlanePropertiesKHR *pProperties); ++ ++VkResult ++pvr_mesa_wsi_display_get_physical_device_display_plane_properties2(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t *pPropertyCount, ++ VkDisplayPlaneProperties2KHR *pProperties); ++ ++VkResult ++pvr_mesa_wsi_display_get_display_plane_supported_displays(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t planeIndex, ++ uint32_t *pDisplayCount, ++ VkDisplayKHR *pDisplays); ++ ++VkResult ++pvr_mesa_wsi_display_get_display_mode_properties(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayKHR display, ++ uint32_t *pPropertyCount, ++ VkDisplayModePropertiesKHR *pProperties); ++ ++VkResult ++pvr_mesa_wsi_display_get_display_mode_properties2(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayKHR display, ++ uint32_t *pPropertyCount, ++ VkDisplayModeProperties2KHR *pProperties); ++ ++VkResult ++pvr_mesa_wsi_display_create_display_mode(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayKHR display, ++ const VkDisplayModeCreateInfoKHR *pCreateInfo, ++ const VkAllocationCallbacks *pAllocator, ++ VkDisplayModeKHR *pMode); ++ ++VkResult ++pvr_mesa_wsi_get_display_plane_capabilities(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayModeKHR modeKhr, ++ uint32_t planeIndex, ++ VkDisplayPlaneCapabilitiesKHR *pCapabilities); ++ ++VkResult ++pvr_mesa_wsi_get_display_plane_capabilities2(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo, ++ VkDisplayPlaneCapabilities2KHR *pCapabilities); ++ ++VkResult ++pvr_mesa_wsi_create_display_surface(struct pvr_mesa_wsi *mwsi, ++ VkInstance instance, ++ const VkAllocationCallbacks *pAllocator, ++ const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, ++ VkSurfaceKHR *pSurface); ++ ++VkResult ++pvr_mesa_wsi_release_display(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayKHR display); ++ ++#if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT) ++VkResult ++pvr_mesa_wsi_acquire_xlib_display(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ void *dpy, ++ VkDisplayKHR display); ++ ++VkResult ++pvr_mesa_wsi_get_randr_output_display(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ void *dpy, ++ uint32_t output, ++ VkDisplayKHR *pDisplay); ++ ++#endif ++ ++VkResult ++pvr_mesa_wsi_display_power_control(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkDisplayKHR display, ++ const VkDisplayPowerInfoEXT *pDisplayPowerInfo); ++ ++VkResult ++pvr_mesa_wsi_register_device_event(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ const VkDeviceEventInfoEXT *pDeviceEventInfo, ++ const VkAllocationCallbacks *pAllocator, ++ void **pFence, ++ int syncFd); ++ ++VkResult ++pvr_mesa_wsi_register_display_event(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkDisplayKHR display, ++ const VkDisplayEventInfoEXT *pDisplayEventInfo, ++ const VkAllocationCallbacks *pAllocator, ++ void **pFence, ++ int syncFd); ++ ++VkResult ++pvr_mesa_wsi_get_swapchain_counter(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkSwapchainKHR swapchain, ++ VkSurfaceCounterFlagBitsEXT flagBits, ++ uint64_t *pValue); ++ ++/* ++ * Functions defined in the PowerVR DDK for use by Mesa. ++ * All functions have a "pvr_vk_mesa_wsi" prefix. ++ */ ++VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL ++pvr_vk_mesa_wsi_sym_addr(VkPhysicalDevice physicalDevice, ++ const char *name); ++ ++#endif /* PVR_MESA_WSI_INTERFACE_H */ +diff --git a/src/pvr/wsi/pvr_wsi.c b/src/pvr/wsi/pvr_wsi.c +new file mode 100644 +index 00000000000..a1fcdfd6164 +--- /dev/null ++++ b/src/pvr/wsi/pvr_wsi.c +@@ -0,0 +1,333 @@ ++/* ++ * Copyright © Imagination Technologies Ltd. ++ * ++ * The contents of this file are subject to the MIT license as set out below. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to deal ++ * in the Software without restriction, including without limitation the rights ++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++ * copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ++ * THE SOFTWARE. ++ */ ++ ++#include ++ ++#include "pvr_wsi.h" ++#include "pvr_mesa_wsi_interface.h" ++ ++VkResult ++pvr_mesa_wsi_init(struct pvr_mesa_wsi **pmwsi, ++ VkPhysicalDevice physicalDevice, ++ PFN_vkVoidFunction (VKAPI_PTR *pvr_vk_mesa_wsi_sym_addr) ++ (VkPhysicalDevice physicalDevice, const char *), ++ const VkAllocationCallbacks *alloc, ++ int fd, ++ bool sw) ++{ ++ struct pvr_mesa_wsi *mwsi; ++ VkResult result; ++ ++ mwsi = vk_zalloc(alloc, sizeof(*mwsi), 8, ++ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); ++ if (!mwsi) ++ return VK_ERROR_OUT_OF_HOST_MEMORY; ++ ++ mwsi->symtab.pvr_vk_mesa_wsi_sym_addr = pvr_vk_mesa_wsi_sym_addr; ++ mwsi->physicalDevice = physicalDevice; ++ ++ result = wsi_device_init(&mwsi->wsi, ++ physicalDevice, ++ pvr_vk_mesa_wsi_sym_addr, ++ alloc, ++ fd, NULL, sw); ++ if (result != VK_SUCCESS) { ++ vk_free(alloc, mwsi); ++ return result; ++ } ++ ++ if (!sw) ++ mwsi->wsi.supports_modifiers = true; ++ ++ *pmwsi = mwsi; ++ ++ return VK_SUCCESS; ++} ++ ++void ++pvr_mesa_wsi_finish(struct pvr_mesa_wsi *mwsi, ++ const VkAllocationCallbacks *alloc) ++{ ++ wsi_device_finish(&mwsi->wsi, alloc); ++ ++ vk_free(alloc, mwsi); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_support(struct pvr_mesa_wsi *mwsi, ++ uint32_t queueFamilyIndex, ++ VkSurfaceKHR surface, ++ VkBool32 *pSupported) ++{ ++ return wsi_common_get_surface_support(&mwsi->wsi, ++ queueFamilyIndex, ++ surface, ++ pSupported); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_capabilities(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) ++{ ++ return wsi_common_get_surface_capabilities(&mwsi->wsi, ++ surface, ++ pSurfaceCapabilities); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_capabilities2(struct pvr_mesa_wsi *mwsi, ++ const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, ++ VkSurfaceCapabilities2KHR *pSurfaceCapabilities) ++{ ++ return wsi_common_get_surface_capabilities2(&mwsi->wsi, ++ pSurfaceInfo, ++ pSurfaceCapabilities); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_capabilities2ext(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ VkSurfaceCapabilities2EXT *pSurfaceCapabilities) ++{ ++ return wsi_common_get_surface_capabilities2ext(&mwsi->wsi, ++ surface, ++ pSurfaceCapabilities); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_formats(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ uint32_t *pSurfaceFormatCount, ++ VkSurfaceFormatKHR *pSurfaceFormats) ++{ ++ return wsi_common_get_surface_formats(&mwsi->wsi, ++ surface, ++ pSurfaceFormatCount, ++ pSurfaceFormats); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_formats2(struct pvr_mesa_wsi *mwsi, ++ const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, ++ uint32_t *pSurfaceFormatCount, ++ VkSurfaceFormat2KHR *pSurfaceFormats) ++{ ++ return wsi_common_get_surface_formats2(&mwsi->wsi, ++ pSurfaceInfo, ++ pSurfaceFormatCount, ++ pSurfaceFormats); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_surface_present_modes(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ uint32_t *pPresentModeCount, ++ VkPresentModeKHR *pPresentModes) ++{ ++ return wsi_common_get_surface_present_modes(&mwsi->wsi, ++ surface, ++ pPresentModeCount, ++ pPresentModes); ++} ++ ++VkResult ++pvr_mesa_wsi_common_create_swapchain(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ const VkSwapchainCreateInfoKHR *pCreateInfo, ++ const VkAllocationCallbacks *pAllocator, ++ VkSwapchainKHR *pSwapchain) ++{ ++ return wsi_common_create_swapchain(&mwsi->wsi, ++ device, ++ pCreateInfo, ++ pAllocator, ++ pSwapchain); ++} ++ ++void ++pvr_mesa_wsi_common_destroy_swapchain(UNUSED struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkSwapchainKHR swapchain, ++ const VkAllocationCallbacks *pAllocator) ++{ ++ return wsi_common_destroy_swapchain(device, ++ swapchain, ++ pAllocator); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_images(UNUSED struct pvr_mesa_wsi *mwsi, ++ VkSwapchainKHR swapchain, ++ uint32_t *pSwapchainImageCount, ++ VkImage *pSwapchainImages) ++{ ++ return wsi_common_get_images(swapchain, ++ pSwapchainImageCount, ++ pSwapchainImages); ++} ++ ++VkResult ++pvr_mesa_wsi_common_acquire_next_image2(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ const VkAcquireNextImageInfoKHR *pAcquireInfo, ++ uint32_t *pImageIndex) ++{ ++ return wsi_common_acquire_next_image2(&mwsi->wsi, ++ device, ++ pAcquireInfo, ++ pImageIndex); ++} ++ ++VkResult ++pvr_mesa_wsi_common_queue_present(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkQueue queue, ++ int queue_family_index, ++ const VkPresentInfoKHR *pPresentInfo) ++{ ++ return wsi_common_queue_present(&mwsi->wsi, ++ device, ++ queue, ++ queue_family_index, ++ pPresentInfo); ++} ++ ++VkResult ++pvr_mesa_wsi_common_get_present_rectangles(struct pvr_mesa_wsi *mwsi, ++ VkSurfaceKHR surface, ++ uint32_t* pRectCount, ++ VkRect2D* pRects) ++{ ++ return wsi_common_get_present_rectangles(&mwsi->wsi, ++ surface, ++ pRectCount, ++ pRects); ++} ++ ++/* ++ * The mwsi parameter is currently unused. Note that it is invalid for ++ * pvr_mesa_wsi_init, which is responsible for allocating it. ++*/ ++PUBLIC void * ++pvr_mesa_wsi_sym_addr(UNUSED struct pvr_mesa_wsi *mwsi, const char *name) ++{ ++ static const struct { ++ char *name; ++ void *addr; ++ } lookup[] = { ++ { "pvr_mesa_wsi_init", ++ pvr_mesa_wsi_init }, ++ { "pvr_mesa_wsi_finish", ++ pvr_mesa_wsi_finish }, ++ { "pvr_mesa_wsi_common_get_surface_support", ++ pvr_mesa_wsi_common_get_surface_support }, ++ { "pvr_mesa_wsi_common_get_surface_capabilities", ++ pvr_mesa_wsi_common_get_surface_capabilities }, ++ { "pvr_mesa_wsi_common_get_surface_capabilities2", ++ pvr_mesa_wsi_common_get_surface_capabilities2 }, ++ { "pvr_mesa_wsi_common_get_surface_capabilities2ext", ++ pvr_mesa_wsi_common_get_surface_capabilities2ext }, ++ { "pvr_mesa_wsi_common_get_surface_formats", ++ pvr_mesa_wsi_common_get_surface_formats }, ++ { "pvr_mesa_wsi_common_get_surface_formats2", ++ pvr_mesa_wsi_common_get_surface_formats2 }, ++ { "pvr_mesa_wsi_common_get_surface_present_modes", ++ pvr_mesa_wsi_common_get_surface_present_modes }, ++ { "pvr_mesa_wsi_common_create_swapchain", ++ pvr_mesa_wsi_common_create_swapchain }, ++ { "pvr_mesa_wsi_common_destroy_swapchain", ++ pvr_mesa_wsi_common_destroy_swapchain }, ++ { "pvr_mesa_wsi_common_get_images", ++ pvr_mesa_wsi_common_get_images }, ++ { "pvr_mesa_wsi_common_acquire_next_image2", ++ pvr_mesa_wsi_common_acquire_next_image2 }, ++ { "pvr_mesa_wsi_common_queue_present", ++ pvr_mesa_wsi_common_queue_present }, ++ { "pvr_mesa_wsi_common_get_present_rectangles", ++ pvr_mesa_wsi_common_get_present_rectangles }, ++#if defined(VK_USE_PLATFORM_WAYLAND_KHR) ++ { "pvr_mesa_wsi_get_physical_device_wayland_presentation_support", ++ pvr_mesa_wsi_get_physical_device_wayland_presentation_support }, ++ { "pvr_mesa_wsi_create_wayland_surface", ++ pvr_mesa_wsi_create_wayland_surface }, ++#endif ++#if defined(VK_USE_PLATFORM_XCB_KHR) ++ { "pvr_mesa_wsi_get_physical_device_xcb_presentation_support", ++ pvr_mesa_wsi_get_physical_device_xcb_presentation_support }, ++ { "pvr_mesa_wsi_create_xcb_surface", ++ pvr_mesa_wsi_create_xcb_surface }, ++#endif ++#if defined(VK_USE_PLATFORM_XLIB_KHR) ++ { "pvr_mesa_wsi_create_xlib_surface", ++ pvr_mesa_wsi_create_xlib_surface }, ++#endif ++ { "pvr_mesa_wsi_display_get_physical_device_display_properties", ++ pvr_mesa_wsi_display_get_physical_device_display_properties }, ++ { "pvr_mesa_wsi_display_get_physical_device_display_properties2", ++ pvr_mesa_wsi_display_get_physical_device_display_properties2 }, ++ { "pvr_mesa_wsi_display_get_physical_device_display_plane_properties", ++ pvr_mesa_wsi_display_get_physical_device_display_plane_properties }, ++ { "pvr_mesa_wsi_display_get_physical_device_display_plane_properties2", ++ pvr_mesa_wsi_display_get_physical_device_display_plane_properties2 }, ++ { "pvr_mesa_wsi_display_get_display_plane_supported_displays", ++ pvr_mesa_wsi_display_get_display_plane_supported_displays }, ++ { "pvr_mesa_wsi_display_get_display_mode_properties", ++ pvr_mesa_wsi_display_get_display_mode_properties }, ++ { "pvr_mesa_wsi_display_get_display_mode_properties2", ++ pvr_mesa_wsi_display_get_display_mode_properties2 }, ++ { "pvr_mesa_wsi_display_create_display_mode", ++ pvr_mesa_wsi_display_create_display_mode }, ++ { "pvr_mesa_wsi_get_display_plane_capabilities", ++ pvr_mesa_wsi_get_display_plane_capabilities }, ++ { "pvr_mesa_wsi_get_display_plane_capabilities2", ++ pvr_mesa_wsi_get_display_plane_capabilities2 }, ++ { "pvr_mesa_wsi_create_display_surface", ++ pvr_mesa_wsi_create_display_surface }, ++ { "pvr_mesa_wsi_release_display", ++ pvr_mesa_wsi_release_display }, ++#if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT) ++ { "pvr_mesa_wsi_acquire_xlib_display", ++ pvr_mesa_wsi_acquire_xlib_display }, ++ { "pvr_mesa_wsi_get_randr_output_display", ++ pvr_mesa_wsi_get_randr_output_display }, ++#endif ++ { "pvr_mesa_wsi_display_power_control", ++ pvr_mesa_wsi_display_power_control }, ++ { "pvr_mesa_wsi_register_device_event", ++ pvr_mesa_wsi_register_device_event }, ++ { "pvr_mesa_wsi_register_display_event", ++ pvr_mesa_wsi_register_display_event }, ++ { "pvr_mesa_wsi_get_swapchain_counter", ++ pvr_mesa_wsi_get_swapchain_counter }, ++ }; ++ unsigned i; ++ ++ for (i = 0; i < ARRAY_SIZE(lookup); i++) { ++ if (!strcmp(name, lookup[i].name)) ++ return lookup[i].addr; ++ } ++ ++ return NULL; ++} +diff --git a/src/pvr/wsi/pvr_wsi.h b/src/pvr/wsi/pvr_wsi.h +new file mode 100644 +index 00000000000..142358db3de +--- /dev/null ++++ b/src/pvr/wsi/pvr_wsi.h +@@ -0,0 +1,78 @@ ++/* ++ * Copyright © Imagination Technologies Ltd. ++ * ++ * The contents of this file are subject to the MIT license as set out below. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to deal ++ * in the Software without restriction, including without limitation the rights ++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++ * copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ++ * THE SOFTWARE. ++ */ ++ ++#if !defined PVR_WSI_H ++#define PVR_WSI_H ++ ++#include "util/macros.h" ++#include "util/u_memory.h" ++#include "util/u_atomic.h" ++ ++#include "wsi_common.h" ++ ++#define Container(p, s, m) ((s *) ((uintptr_t)(p) - Offset(s, m))) ++ ++#define _MAKE_STRING(x) # x ++#define MAKE_STRING(x) _MAKE_STRING(x) ++ ++#define LOOKUP_DDK(mwsi, sym) \ ++ mwsi->symtab.pvr_vk_mesa_wsi_sym_addr(MAKE_STRING(sym)) ++ ++#define JUMP_DDK(mwsi, sym, ...) \ ++ do { \ ++ void *_entry = p_atomic_read(&mwsi->symtab.sym); \ ++ \ ++ if (!_entry) { \ ++ _entry = LOOKUP_DDK(mwsi, sym); \ ++ \ ++ if (_entry) \ ++ p_atomic_set(&mwsi->symtab.sym, _entry); \ ++ } \ ++ \ ++ if (_entry) { \ ++ __typeof__(mwsi->symtab.sym) _func = _entry; \ ++ \ ++ return _func(__VA_ARGS__); \ ++ } \ ++ } while(0) ++ ++struct pvr_vk_mesa_wsi_sym_tab ++{ ++ PFN_vkVoidFunction (VKAPI_PTR *pvr_vk_mesa_wsi_sym_addr) ++ (VkPhysicalDevice physicalDevice, const char *); ++}; ++ ++struct pvr_mesa_wsi ++{ ++ struct wsi_device wsi; ++ struct pvr_vk_mesa_wsi_sym_tab symtab; ++ VkPhysicalDevice physicalDevice; ++}; ++ ++static inline struct pvr_mesa_wsi *pvr_mesa_wsi(struct wsi_device *wsi_ptr) ++{ ++ return Container(wsi_ptr, struct pvr_mesa_wsi, wsi); ++} ++ ++#endif +diff --git a/src/pvr/wsi/pvr_wsi_display.c b/src/pvr/wsi/pvr_wsi_display.c +new file mode 100644 +index 00000000000..65a1c99507c +--- /dev/null ++++ b/src/pvr/wsi/pvr_wsi_display.c +@@ -0,0 +1,293 @@ ++/* ++ * Copyright © Imagination Technologies Ltd. ++ * ++ * The contents of this file are subject to the MIT license as set out below. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to deal ++ * in the Software without restriction, including without limitation the rights ++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++ * copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ++ * THE SOFTWARE. ++ */ ++ ++#include "wsi_common_display.h" ++ ++#if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT) ++#include "wsi_common_x11.h" ++#endif ++ ++#include "pvr_wsi.h" ++#include "pvr_mesa_wsi_interface.h" ++ ++VkResult ++pvr_mesa_wsi_display_get_physical_device_display_properties(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t *pPropertyCount, ++ VkDisplayPropertiesKHR *pProperties) ++{ ++ return wsi_display_get_physical_device_display_properties(physicalDevice, ++ &mwsi->wsi, ++ pPropertyCount, ++ pProperties); ++} ++ ++VkResult ++pvr_mesa_wsi_display_get_physical_device_display_properties2(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t *pPropertyCount, ++ VkDisplayProperties2KHR *pProperties) ++{ ++ return wsi_display_get_physical_device_display_properties2(physicalDevice, ++ &mwsi->wsi, ++ pPropertyCount, ++ pProperties); ++} ++ ++VkResult ++pvr_mesa_wsi_display_get_physical_device_display_plane_properties(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t *pPropertyCount, ++ VkDisplayPlanePropertiesKHR *pProperties) ++{ ++ return wsi_display_get_physical_device_display_plane_properties(physicalDevice, ++ &mwsi->wsi, ++ pPropertyCount, ++ pProperties); ++} ++ ++VkResult ++pvr_mesa_wsi_display_get_physical_device_display_plane_properties2(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t *pPropertyCount, ++ VkDisplayPlaneProperties2KHR *pProperties) ++{ ++ return wsi_display_get_physical_device_display_plane_properties2(physicalDevice, ++ &mwsi->wsi, ++ pPropertyCount, ++ pProperties); ++} ++ ++VkResult ++pvr_mesa_wsi_display_get_display_plane_supported_displays(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ uint32_t planeIndex, ++ uint32_t *pDisplayCount, ++ VkDisplayKHR *pDisplays) ++{ ++ return wsi_display_get_display_plane_supported_displays(physicalDevice, ++ &mwsi->wsi, ++ planeIndex, ++ pDisplayCount, ++ pDisplays); ++ ++} ++ ++VkResult ++pvr_mesa_wsi_display_get_display_mode_properties(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayKHR display, ++ uint32_t *pPropertyCount, ++ VkDisplayModePropertiesKHR *pProperties) ++{ ++ return wsi_display_get_display_mode_properties(physicalDevice, ++ &mwsi->wsi, ++ display, ++ pPropertyCount, ++ pProperties); ++} ++ ++VkResult ++pvr_mesa_wsi_display_get_display_mode_properties2(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayKHR display, ++ uint32_t *pPropertyCount, ++ VkDisplayModeProperties2KHR *pProperties) ++{ ++ return wsi_display_get_display_mode_properties2(physicalDevice, ++ &mwsi->wsi, ++ display, ++ pPropertyCount, ++ pProperties); ++} ++ ++VkResult ++pvr_mesa_wsi_display_create_display_mode(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayKHR display, ++ const VkDisplayModeCreateInfoKHR *pCreateInfo, ++ const VkAllocationCallbacks *pAllocator, ++ VkDisplayModeKHR *pMode) ++{ ++ return wsi_display_create_display_mode(physicalDevice, ++ &mwsi->wsi, ++ display, ++ pCreateInfo, ++ pAllocator, ++ pMode); ++} ++ ++VkResult ++pvr_mesa_wsi_get_display_plane_capabilities(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayModeKHR modeKhr, ++ uint32_t planeIndex, ++ VkDisplayPlaneCapabilitiesKHR *pCapabilities) ++{ ++ return wsi_get_display_plane_capabilities(physicalDevice, ++ &mwsi->wsi, ++ modeKhr, ++ planeIndex, ++ pCapabilities); ++} ++ ++VkResult ++pvr_mesa_wsi_get_display_plane_capabilities2(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo, ++ VkDisplayPlaneCapabilities2KHR *pCapabilities) ++{ ++ return wsi_get_display_plane_capabilities2(physicalDevice, ++ &mwsi->wsi, ++ pDisplayPlaneInfo, ++ pCapabilities); ++} ++ ++VkResult ++pvr_mesa_wsi_create_display_surface(UNUSED struct pvr_mesa_wsi *mwsi, ++ VkInstance instance, ++ const VkAllocationCallbacks *pAllocator, ++ const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, ++ VkSurfaceKHR *pSurface) ++{ ++ return wsi_create_display_surface(instance, ++ pAllocator, ++ pCreateInfo, ++ pSurface); ++} ++ ++VkResult ++pvr_mesa_wsi_release_display(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ VkDisplayKHR display) ++{ ++ return wsi_release_display(physicalDevice, ++ &mwsi->wsi, ++ display); ++} ++ ++#if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT) ++VkResult ++pvr_mesa_wsi_acquire_xlib_display(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ void *dpy, ++ VkDisplayKHR display) ++{ ++ return wsi_acquire_xlib_display(physicalDevice, ++ &mwsi->wsi, ++ dpy, ++ display); ++} ++ ++VkResult ++pvr_mesa_wsi_get_randr_output_display(struct pvr_mesa_wsi *mwsi, ++ VkPhysicalDevice physicalDevice, ++ void *dpy, ++ uint32_t output, ++ VkDisplayKHR *pDisplay) ++{ ++ return wsi_get_randr_output_display(physicalDevice, ++ &mwsi->wsi, ++ dpy, ++ output, ++ pDisplay); ++} ++#endif ++ ++VkResult ++pvr_mesa_wsi_display_power_control(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkDisplayKHR display, ++ const VkDisplayPowerInfoEXT *pDisplayPowerInfo) ++{ ++ return wsi_display_power_control(device, ++ &mwsi->wsi, ++ display, ++ pDisplayPowerInfo); ++} ++ ++VkResult ++pvr_mesa_wsi_register_device_event(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ const VkDeviceEventInfoEXT *pDeviceEventInfo, ++ const VkAllocationCallbacks *pAllocator, ++ void **pFence, ++ int syncFd) ++{ ++ struct wsi_fence *fence; ++ VkResult ret; ++ ++ ret = wsi_register_device_event(device, ++ &mwsi->wsi, ++ pDeviceEventInfo, ++ pAllocator, ++ pFence ? &fence : NULL, ++ syncFd); ++ ++ if (ret == VK_SUCCESS && pFence != NULL) ++ *pFence = fence; ++ ++ return ret; ++} ++ ++VkResult ++pvr_mesa_wsi_register_display_event(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkDisplayKHR display, ++ const VkDisplayEventInfoEXT *pDisplayEventInfo, ++ const VkAllocationCallbacks *pAllocator, ++ void **pFence, ++ int syncFd) ++{ ++ struct wsi_fence *fence; ++ VkResult ret; ++ ++ ret = wsi_register_display_event(device, ++ &mwsi->wsi, ++ display, ++ pDisplayEventInfo, ++ pAllocator, ++ pFence ? &fence : NULL, ++ syncFd); ++ ++ if (ret == VK_SUCCESS && pFence != NULL) ++ *pFence = fence; ++ ++ return ret; ++} ++ ++VkResult ++pvr_mesa_wsi_get_swapchain_counter(struct pvr_mesa_wsi *mwsi, ++ VkDevice device, ++ VkSwapchainKHR swapchain, ++ VkSurfaceCounterFlagBitsEXT flagBits, ++ uint64_t *pValue) ++{ ++ return wsi_get_swapchain_counter(device, ++ &mwsi->wsi, ++ swapchain, ++ flagBits, ++ pValue); ++} ++ +diff --git a/src/pvr/wsi/pvr_wsi_wayland.c b/src/pvr/wsi/pvr_wsi_wayland.c +new file mode 100644 +index 00000000000..5b052667ac9 +--- /dev/null ++++ b/src/pvr/wsi/pvr_wsi_wayland.c +@@ -0,0 +1,45 @@ ++/* ++ * Copyright © Imagination Technologies Ltd. ++ * ++ * The contents of this file are subject to the MIT license as set out below. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to deal ++ * in the Software without restriction, including without limitation the rights ++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++ * copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ++ * THE SOFTWARE. ++ */ ++ ++#include "wsi_common_wayland.h" ++ ++#include "pvr_wsi.h" ++#include "pvr_mesa_wsi_interface.h" ++ ++VkBool32 ++pvr_mesa_wsi_get_physical_device_wayland_presentation_support(struct pvr_mesa_wsi *mwsi, ++ uint32_t queueFamilyIndex, ++ void *display) ++{ ++ return wsi_wl_get_presentation_support(&mwsi->wsi, display); ++} ++ ++VkResult ++pvr_mesa_wsi_create_wayland_surface(UNUSED struct pvr_mesa_wsi *mwsi, ++ const VkAllocationCallbacks *pAllocator, ++ const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, ++ VkSurfaceKHR *pSurface) ++{ ++ return wsi_create_wl_surface(pAllocator, pCreateInfo, pSurface); ++} +diff --git a/src/pvr/wsi/pvr_wsi_x11.c b/src/pvr/wsi/pvr_wsi_x11.c +new file mode 100644 +index 00000000000..0a69e92ac9e +--- /dev/null ++++ b/src/pvr/wsi/pvr_wsi_x11.c +@@ -0,0 +1,62 @@ ++/* ++ * Copyright © Imagination Technologies Ltd. ++ * ++ * The contents of this file are subject to the MIT license as set out below. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to deal ++ * in the Software without restriction, including without limitation the rights ++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++ * copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ++ * THE SOFTWARE. ++ */ ++ ++#include "wsi_common_x11.h" ++ ++#include "pvr_wsi.h" ++#include "pvr_mesa_wsi_interface.h" ++ ++VkBool32 ++pvr_mesa_wsi_get_physical_device_xcb_presentation_support(struct pvr_mesa_wsi *mwsi, ++ uint32_t queueFamilyIndex, ++ void *connection, ++ uint32_t visual_id) ++{ ++ return wsi_get_physical_device_xcb_presentation_support(&mwsi->wsi, ++ queueFamilyIndex, ++ connection, ++ visual_id); ++} ++ ++VkResult ++pvr_mesa_wsi_create_xcb_surface(UNUSED struct pvr_mesa_wsi *mwsi, ++ const VkAllocationCallbacks *pAllocator, ++ const VkXcbSurfaceCreateInfoKHR *pCreateInfo, ++ VkSurfaceKHR *pSurface) ++{ ++ return wsi_create_xcb_surface(pAllocator, ++ pCreateInfo, ++ pSurface); ++} ++ ++VkResult ++pvr_mesa_wsi_create_xlib_surface(UNUSED struct pvr_mesa_wsi *mwsi, ++ const VkAllocationCallbacks *pAllocator, ++ const VkXlibSurfaceCreateInfoKHR *pCreateInfo, ++ VkSurfaceKHR *pSurface) ++{ ++ return wsi_create_xlib_surface(pAllocator, ++ pCreateInfo, ++ pSurface); ++} +-- +2.25.1 + diff --git a/package/mesa3d/0060-vulkan-wsi-Disable-use-of-VK_EXT_pci_bus_info.patch b/package/mesa3d/0060-vulkan-wsi-Disable-use-of-VK_EXT_pci_bus_info.patch new file mode 100644 index 00000000..9e5b3d62 --- /dev/null +++ b/package/mesa3d/0060-vulkan-wsi-Disable-use-of-VK_EXT_pci_bus_info.patch @@ -0,0 +1,76 @@ +From 83953c9325e4cc9adb23ad7654a02ddabdd3fd99 Mon Sep 17 00:00:00 2001 +From: brendan King +Date: Fri, 30 Jul 2021 15:34:13 +0100 +Subject: [PATCH 60/67] vulkan/wsi: Disable use of VK_EXT_pci_bus_info + +The VK_EXT_pci_bus_info related code has been wrapped in +VULKAN_WSI_USE_PCI_BUS_INFO, effectively disabling it. + +Not all platforms support the VK_EXT_pci_bus_info extension. +A better fix might be to pass another parameter to wsi_device_init, +to indicate that the device is a PCI one. +--- + src/vulkan/wsi/wsi_common.c | 4 ++++ + src/vulkan/wsi/wsi_common.h | 2 ++ + src/vulkan/wsi/wsi_common_drm.c | 4 ++++ + 3 files changed, 10 insertions(+) + +diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c +index b1360edb911..66d6683a7c1 100644 +--- a/src/vulkan/wsi/wsi_common.c ++++ b/src/vulkan/wsi/wsi_common.c +@@ -56,11 +56,15 @@ wsi_device_init(struct wsi_device *wsi, + WSI_GET_CB(GetPhysicalDeviceQueueFamilyProperties); + #undef WSI_GET_CB + ++#if defined(VULKAN_WSI_USE_PCI_BUS_INFO) + wsi->pci_bus_info.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT; ++#endif + VkPhysicalDeviceProperties2 pdp2 = { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, ++#if defined(VULKAN_WSI_USE_PCI_BUS_INFO) + .pNext = &wsi->pci_bus_info, ++#endif + }; + GetPhysicalDeviceProperties2(pdevice, &pdp2); + +diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h +index c2563c677e6..4a733665d2c 100644 +--- a/src/vulkan/wsi/wsi_common.h ++++ b/src/vulkan/wsi/wsi_common.h +@@ -112,7 +112,9 @@ struct wsi_device { + VkPhysicalDeviceMemoryProperties memory_props; + uint32_t queue_family_count; + ++#if defined(VULKAN_WSI_USE_PCI_BUS_INFO) + VkPhysicalDevicePCIBusInfoPropertiesEXT pci_bus_info; ++#endif + + bool supports_modifiers; + uint32_t maxImageDimension2D; +diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c +index 6201891ca80..49a78cf4c62 100644 +--- a/src/vulkan/wsi/wsi_common_drm.c ++++ b/src/vulkan/wsi/wsi_common_drm.c +@@ -45,6 +45,7 @@ wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd) + if (ret) + return false; + ++#if defined(VULKAN_WSI_USE_PCI_BUS_INFO) + bool match = false; + switch (fd_device->bustype) { + case DRM_BUS_PCI: +@@ -57,6 +58,9 @@ wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd) + default: + break; + } ++#else ++ const bool match = true; ++#endif + + drmFreeDevice(&fd_device); + +-- +2.25.1 + diff --git a/package/mesa3d/0061-vulkan-wsi-default-to-force_bgra8_unorm_first-true.patch b/package/mesa3d/0061-vulkan-wsi-default-to-force_bgra8_unorm_first-true.patch new file mode 100644 index 00000000..881d6fb2 --- /dev/null +++ b/package/mesa3d/0061-vulkan-wsi-default-to-force_bgra8_unorm_first-true.patch @@ -0,0 +1,34 @@ +From 10a0d4ec4f9d468c792f5e675d924fa7a8f97373 Mon Sep 17 00:00:00 2001 +From: brendan King +Date: Mon, 2 Aug 2021 16:29:36 +0100 +Subject: [PATCH 61/67] vulkan/wsi: default to force_bgra8_unorm_first true + +If VULKAN_WSI_BGRA8_SNORM_FIRST is not defined, default to +force_bgra8_unorm_first true. + +This brings Mesa WSI into line with IMG WSI with regards to the +VK_FORMAT_B8G8R8A8_UNORM and VK_FORMAT_B8G8R8A8_SRGB formats. +With this change, the IMG Vulkan unit test, vkbonjour, will default +to VK_FORMAT_B8G8R8A8_UNORM rather than VK_FORMAT_B8G8R8A8_SRGB. +--- + src/vulkan/wsi/wsi_common.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c +index 66d6683a7c1..1ffca6fecfb 100644 +--- a/src/vulkan/wsi/wsi_common.c ++++ b/src/vulkan/wsi/wsi_common.c +@@ -158,6 +158,10 @@ wsi_device_init(struct wsi_device *wsi, + driQueryOptionb(dri_options, "vk_wsi_force_bgra8_unorm_first"); + } + } ++#if !defined(VULKAN_WSI_BGRA8_SNORM_FIRST) ++ else ++ wsi->force_bgra8_unorm_first = true; ++#endif + + return VK_SUCCESS; + #if defined(VK_USE_PLATFORM_XCB_KHR) || \ +-- +2.25.1 + diff --git a/package/mesa3d/0062-vulkan-wsi-enable-additional-formats-for-Wayland.patch b/package/mesa3d/0062-vulkan-wsi-enable-additional-formats-for-Wayland.patch new file mode 100644 index 00000000..4290a33f --- /dev/null +++ b/package/mesa3d/0062-vulkan-wsi-enable-additional-formats-for-Wayland.patch @@ -0,0 +1,64 @@ +From 7e8bb12d48651796da6d8f3df1b388551d3b5510 Mon Sep 17 00:00:00 2001 +From: brendan King +Date: Mon, 2 Aug 2021 11:21:16 +0100 +Subject: [PATCH 62/67] vulkan/wsi: enable additional formats for Wayland + +Add VK_FORMAT_R5G6B5_UNORM_PACK16. + +This is for compatibility with IMG WSI. +--- + src/vulkan/wsi/wsi_common_wayland.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c +index 1109d3f07b6..e520aa9af00 100644 +--- a/src/vulkan/wsi/wsi_common_wayland.c ++++ b/src/vulkan/wsi/wsi_common_wayland.c +@@ -68,6 +68,7 @@ struct wsi_wl_display_dmabuf { + struct { + struct u_vector argb8888; + struct u_vector xrgb8888; ++ struct u_vector rgb565; + } modifiers; + }; + +@@ -441,6 +442,9 @@ dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf, + case WL_DRM_FORMAT_XRGB8888: + modifiers = &display->dmabuf.modifiers.xrgb8888; + break; ++ case WL_DRM_FORMAT_RGB565: ++ modifiers = &display->dmabuf.modifiers.rgb565; ++ break; + default: + return; /* Unsupported format */ + } +@@ -527,6 +531,7 @@ wsi_wl_display_finish(struct wsi_wl_display *display) + u_vector_finish(&display->dmabuf.formats); + u_vector_finish(&display->dmabuf.modifiers.argb8888); + u_vector_finish(&display->dmabuf.modifiers.xrgb8888); ++ u_vector_finish(&display->dmabuf.modifiers.rgb565); + if (display->swrast.wl_shm) + wl_shm_destroy(display->swrast.wl_shm); + if (display->drm.wl_drm) +@@ -563,6 +568,8 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl, + !u_vector_init(&display->dmabuf.modifiers.argb8888, + sizeof(uint64_t), 32) || + !u_vector_init(&display->dmabuf.modifiers.xrgb8888, ++ sizeof(uint64_t), 32) || ++ !u_vector_init(&display->dmabuf.modifiers.rgb565, + sizeof(uint64_t), 32)) { + result = VK_ERROR_OUT_OF_HOST_MEMORY; + goto fail; +@@ -1356,6 +1363,9 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, + case WL_DRM_FORMAT_XRGB8888: + modifiers = &chain->display->dmabuf.modifiers.xrgb8888; + break; ++ case WL_DRM_FORMAT_RGB565: ++ modifiers = &chain->display->dmabuf.modifiers.rgb565; ++ break; + default: + modifiers = NULL; + break; +-- +2.25.1 + diff --git a/package/mesa3d/0063-vulkan-wsi-enable-additional-formats-for-Display.patch b/package/mesa3d/0063-vulkan-wsi-enable-additional-formats-for-Display.patch new file mode 100644 index 00000000..f8803592 --- /dev/null +++ b/package/mesa3d/0063-vulkan-wsi-enable-additional-formats-for-Display.patch @@ -0,0 +1,27 @@ +From c2b91fcb7c88bfec23077ae31c0035684249ea1b Mon Sep 17 00:00:00 2001 +From: brendan King +Date: Tue, 3 Aug 2021 15:44:57 +0100 +Subject: [PATCH 63/67] vulkan/wsi: enable additional formats for Display + +Add VK_FORMAT_R5G6B5_UNORM_PACK16. + +This is for compatibility with IMG WSI. +--- + src/vulkan/wsi/wsi_common_display.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c +index f135b4e38de..298c78809c3 100644 +--- a/src/vulkan/wsi/wsi_common_display.c ++++ b/src/vulkan/wsi/wsi_common_display.c +@@ -900,6 +900,7 @@ static const struct { + } available_surface_formats[] = { + { .format = VK_FORMAT_B8G8R8A8_SRGB, .drm_format = DRM_FORMAT_XRGB8888 }, + { .format = VK_FORMAT_B8G8R8A8_UNORM, .drm_format = DRM_FORMAT_XRGB8888 }, ++ { .format = VK_FORMAT_R5G6B5_UNORM_PACK16, .drm_format = DRM_FORMAT_RGB565 }, + }; + + static void +-- +2.25.1 + diff --git a/package/mesa3d/0064-mesa-main-dri-add-YUV420_3PLANE-and-YVU420_3PLANE.patch b/package/mesa3d/0064-mesa-main-dri-add-YUV420_3PLANE-and-YVU420_3PLANE.patch new file mode 100644 index 00000000..39e08c00 --- /dev/null +++ b/package/mesa3d/0064-mesa-main-dri-add-YUV420_3PLANE-and-YVU420_3PLANE.patch @@ -0,0 +1,183 @@ +From 85762f3538a21a99bf1b71d87345ebe51f9de453 Mon Sep 17 00:00:00 2001 +From: Luigi Santivetti +Date: Thu, 12 Aug 2021 00:55:46 +0100 +Subject: [PATCH 64/67] mesa/main: dri: add YUV420_3PLANE and YVU420_3PLANE + +--- + include/GL/internal/dri_interface.h | 2 ++ + src/gallium/include/pipe/p_format.h | 3 +++ + src/mesa/drivers/dri/common/utils.c | 18 ++++++++++++++++++ + src/mesa/drivers/dri/pvr/dri_support.h | 2 ++ + src/mesa/drivers/dri/pvr/pvrutil.c | 13 +++++++++++++ + src/mesa/main/format_info.py | 2 +- + src/mesa/main/formats.c | 2 ++ + src/mesa/main/formats.csv | 2 ++ + src/mesa/main/formats.h | 6 ++++++ + 9 files changed, 49 insertions(+), 1 deletion(-) + +diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h +index 080d191b0a3..7d9a1bd9ba6 100644 +--- a/include/GL/internal/dri_interface.h ++++ b/include/GL/internal/dri_interface.h +@@ -1424,6 +1424,8 @@ struct __DRIdri2ExtensionRec { + #define __DRI_IMAGE_FORMAT_BGR888 0x101a + #define __DRI_IMAGE_FORMAT_NV12 0x101b + #define __DRI_IMAGE_FORMAT_NV21 0x101c ++#define __DRI_IMAGE_FORMAT_YU12 0x101d ++#define __DRI_IMAGE_FORMAT_YV12 0x101e + + #define __DRI_IMAGE_USE_SHARE 0x0001 + #define __DRI_IMAGE_USE_SCANOUT 0x0002 +diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h +index fd653379b7a..970f07598d5 100644 +--- a/src/gallium/include/pipe/p_format.h ++++ b/src/gallium/include/pipe/p_format.h +@@ -516,6 +516,9 @@ enum pipe_format { + PIPE_FORMAT_YUV420_2PLANE, + PIPE_FORMAT_YVU420_2PLANE, + ++ PIPE_FORMAT_YUV420_3PLANE, ++ PIPE_FORMAT_YVU420_3PLANE, ++ + PIPE_FORMAT_COUNT + }; + +diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c +index d268dc41fbb..df5f8cbfdc0 100644 +--- a/src/mesa/drivers/dri/common/utils.c ++++ b/src/mesa/drivers/dri/common/utils.c +@@ -330,6 +330,24 @@ driCreateConfigs(mesa_format format, + yuv_subsample = __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_0_BIT; + yuv_plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT; + break; ++ case MESA_FORMAT_YUV420_3PLANE: ++ masks = format_table[11].masks; ++ shifts = format_table[11].shifts; ++ is_yuv = true; /* FIXME: This should come from formats_info.py */ ++ yuv_order = __DRI_ATTRIB_YUV_ORDER_YUV_BIT; ++ yuv_num_planes = 3; ++ yuv_subsample = __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_0_BIT; ++ yuv_plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT; ++ break; ++ case MESA_FORMAT_YVU420_3PLANE: ++ masks = format_table[11].masks; ++ shifts = format_table[11].shifts; ++ is_yuv = true; /* FIXME: This should come from formats_info.py */ ++ yuv_order = __DRI_ATTRIB_YUV_ORDER_YVU_BIT; ++ yuv_num_planes = 3; ++ yuv_subsample = __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_0_BIT; ++ yuv_plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT; ++ break; + default: + fprintf(stderr, "[%s:%u] Unknown framebuffer type %s (%d).\n", + __func__, __LINE__, +diff --git a/src/mesa/drivers/dri/pvr/dri_support.h b/src/mesa/drivers/dri/pvr/dri_support.h +index ab0b9dd9a23..a4999dc36bf 100644 +--- a/src/mesa/drivers/dri/pvr/dri_support.h ++++ b/src/mesa/drivers/dri/pvr/dri_support.h +@@ -189,6 +189,8 @@ typedef enum + #define PVRDRI_MESA_FORMAT_YVU420_2PLANE 8 + #define PVRDRI_MESA_FORMAT_B8G8R8A8_SRGB 9 + #define PVRDRI_MESA_FORMAT_R8G8B8A8_SRGB 10 ++#define PVRDRI_MESA_FORMAT_YUV420_3PLANE 11 ++#define PVRDRI_MESA_FORMAT_YVU420_3PLANE 12 + + /* The blit flags match their DRI counterparts */ + #define PVRDRI_BLIT_FLAG_FLUSH 0x0001 +diff --git a/src/mesa/drivers/dri/pvr/pvrutil.c b/src/mesa/drivers/dri/pvr/pvrutil.c +index d107a5dafad..ee11ac55914 100644 +--- a/src/mesa/drivers/dri/pvr/pvrutil.c ++++ b/src/mesa/drivers/dri/pvr/pvrutil.c +@@ -118,6 +118,10 @@ PVRDRIMesaFormatToMesaFormat(int pvrdri_mesa_format) + return MESA_FORMAT_B8G8R8A8_SRGB; + case PVRDRI_MESA_FORMAT_R8G8B8A8_SRGB: + return MESA_FORMAT_R8G8B8A8_SRGB; ++ case PVRDRI_MESA_FORMAT_YUV420_3PLANE: ++ return MESA_FORMAT_YUV420_3PLANE; ++ case PVRDRI_MESA_FORMAT_YVU420_3PLANE: ++ return MESA_FORMAT_YVU420_3PLANE; + default: + __driUtilMessage("%s: Unknown format: %d", __func__, pvrdri_mesa_format); + break; +@@ -178,6 +182,11 @@ PVRDRIFormatToFourCC(int dri_format) + return DRM_FORMAT_NV12; + case __DRI_IMAGE_FORMAT_NV21: + return DRM_FORMAT_NV21; ++ case __DRI_IMAGE_FORMAT_YU12: ++ return DRM_FORMAT_YUV420; ++ case __DRI_IMAGE_FORMAT_YV12: ++ return DRM_FORMAT_YVU420; ++ + default: + __driUtilMessage("%s: Unknown format: %d", __func__, dri_format); + break; +@@ -238,6 +247,10 @@ PVRDRIFourCCToDRIFormat(int iFourCC) + return __DRI_IMAGE_FORMAT_NV12; + case DRM_FORMAT_NV21: + return __DRI_IMAGE_FORMAT_NV21; ++ case DRM_FORMAT_YUV420: ++ return __DRI_IMAGE_FORMAT_YU12; ++ case DRM_FORMAT_YVU420: ++ return __DRI_IMAGE_FORMAT_YV12; + default: + __driUtilMessage("%s: Unknown format: %d", __func__, iFourCC); + break; +diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py +index d58403ea85e..bc18db74f17 100644 +--- a/src/mesa/main/format_info.py ++++ b/src/mesa/main/format_info.py +@@ -29,7 +29,7 @@ import sys + def get_gl_base_format(fmat): + if fmat.name == 'MESA_FORMAT_NONE': + return 'GL_NONE' +- elif fmat.name in ['MESA_FORMAT_YCBCR', 'MESA_FORMAT_YCBCR_REV', 'MESA_FORMAT_YUV420_2PLANE', 'MESA_FORMAT_YVU420_2PLANE']: ++ elif fmat.name in ['MESA_FORMAT_YCBCR', 'MESA_FORMAT_YCBCR_REV', 'MESA_FORMAT_YUV420_2PLANE', 'MESA_FORMAT_YVU420_2PLANE', 'MESA_FORMAT_YUV420_3PLANE', 'MESA_FORMAT_YVU420_3PLANE']: + return 'GL_YCBCR_MESA' + elif fmat.has_channel('r'): + if fmat.has_channel('g'): +diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c +index f81caeceff4..d7b0d0a07c9 100644 +--- a/src/mesa/main/formats.c ++++ b/src/mesa/main/formats.c +@@ -1455,6 +1455,8 @@ _mesa_format_matches_format_and_type(mesa_format mformat, + switch (mformat) { + case MESA_FORMAT_YUV420_2PLANE: + case MESA_FORMAT_YVU420_2PLANE: ++ case MESA_FORMAT_YUV420_3PLANE: ++ case MESA_FORMAT_YVU420_3PLANE: + return false; + + default: +diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv +index b2d476577e0..825443b10ce 100644 +--- a/src/mesa/main/formats.csv ++++ b/src/mesa/main/formats.csv +@@ -94,6 +94,8 @@ MESA_FORMAT_YCBCR , other , 1, 1, 1, x16 , , , + MESA_FORMAT_YCBCR_REV , other , 1, 1, 1, x16 , , , , xyzw, yuv + MESA_FORMAT_YUV420_2PLANE , other , 1, 1, 1, x8 , , , , y___, yuv + MESA_FORMAT_YVU420_2PLANE , other , 1, 1, 1, x8 , , , , y___, yuv ++MESA_FORMAT_YUV420_3PLANE , other , 1, 1, 1, x8 , , , , y___, yuv ++MESA_FORMAT_YVU420_3PLANE , other , 1, 1, 1, x8 , , , , y___, yuv + + MESA_FORMAT_RG_RB_UNORM8 , other , 2, 1, 1, x16 , , , , xyz1, rgb + MESA_FORMAT_GR_BR_UNORM8 , other , 2, 1, 1, x16 , , , , xyz1, rgb +diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h +index 0e778d64467..1ab03d2be7e 100644 +--- a/src/mesa/main/formats.h ++++ b/src/mesa/main/formats.h +@@ -624,6 +624,12 @@ typedef enum pipe_format mesa_format; + #define HAVE_MESA_FORMAT_YVU420_2PLANE + #define MESA_FORMAT_YVU420_2PLANE PIPE_FORMAT_YVU420_2PLANE + ++#define HAVE_MESA_FORMAT_YUV420_3PLANE ++#define MESA_FORMAT_YUV420_3PLANE PIPE_FORMAT_YUV420_3PLANE ++ ++#define HAVE_MESA_FORMAT_YVU420_3PLANE ++#define MESA_FORMAT_YVU420_3PLANE PIPE_FORMAT_YVU420_3PLANE ++ + #define MESA_FORMAT_COUNT PIPE_FORMAT_COUNT + + /* Packed to array format adapters */ +-- +2.25.1 + diff --git a/package/mesa3d/0065-egl-null-add-support-for-YU12-and-YV12.patch b/package/mesa3d/0065-egl-null-add-support-for-YU12-and-YV12.patch new file mode 100644 index 00000000..63c6e2b6 --- /dev/null +++ b/package/mesa3d/0065-egl-null-add-support-for-YU12-and-YV12.patch @@ -0,0 +1,58 @@ +From 89f34a04c15c8657cb77bbbc94fb9b9d0ac76980 Mon Sep 17 00:00:00 2001 +From: Luigi Santivetti +Date: Mon, 23 Aug 2021 09:18:37 +0100 +Subject: [PATCH 65/67] egl/null: add support for YU12 and YV12 + +--- + src/egl/drivers/dri2/platform_null.c | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c +index 529cc7a2a2f..2e86d6533de 100644 +--- a/src/egl/drivers/dri2/platform_null.c ++++ b/src/egl/drivers/dri2/platform_null.c +@@ -106,6 +106,20 @@ static const struct dri2_null_yuv_attrib { + .num_planes = 2, + .plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT, + }, ++ { ++ /* __DRI_IMAGE_FORMAT_YU12 */ ++ .order = __DRI_ATTRIB_YUV_ORDER_YUV_BIT, ++ .subsample = __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_0_BIT, ++ .num_planes = 3, ++ .plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT, ++ }, ++ { ++ /* __DRI_IMAGE_FORMAT_YV12 */ ++ .order = __DRI_ATTRIB_YUV_ORDER_YVU_BIT, ++ .subsample = __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_0_BIT, ++ .num_planes = 3, ++ .plane_bpp = __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT, ++ }, + }; + + /* +@@ -161,6 +175,20 @@ static const struct dri2_null_format { + .rgba_sizes = { 0, 0, 0, 0 }, + .yuv = &dri2_null_yuv_attribs[2], + }, ++ { ++ .drm_format = DRM_FORMAT_YUV420, ++ .dri_image_format = __DRI_IMAGE_FORMAT_YU12, ++ .rgba_shifts = { -1, -1, -1, -1 }, ++ .rgba_sizes = { 0, 0, 0, 0 }, ++ .yuv = &dri2_null_yuv_attribs[3], ++ }, ++ { ++ .drm_format = DRM_FORMAT_YVU420, ++ .dri_image_format = __DRI_IMAGE_FORMAT_YV12, ++ .rgba_shifts = { -1, -1, -1, -1 }, ++ .rgba_sizes = { 0, 0, 0, 0 }, ++ .yuv = &dri2_null_yuv_attribs[4], ++ }, + }; + + +-- +2.25.1 + diff --git a/package/mesa3d/0066-mesa-partially-revert-pbuffer-attribute-removal.patch b/package/mesa3d/0066-mesa-partially-revert-pbuffer-attribute-removal.patch new file mode 100644 index 00000000..049e2f40 --- /dev/null +++ b/package/mesa3d/0066-mesa-partially-revert-pbuffer-attribute-removal.patch @@ -0,0 +1,59 @@ +From 28e4349702566ba34dad4c214c64bfd702177c8a Mon Sep 17 00:00:00 2001 +From: brendan King +Date: Thu, 16 Sep 2021 17:46:28 +0100 +Subject: [PATCH 66/67] mesa: partially revert pbuffer attribute removal + +This partially reverts commit 5ffd1ebe6b3c8c7dd316dd47fac088044222e6ef +("mesa: Remove misc pbuffer attributes from struct gl_config"). + +The IMG PowerVR driver sets meaningful values for the maximum +pbuffer width, height and pixels. +--- + src/mesa/drivers/dri/common/utils.c | 7 ++++--- + src/mesa/main/mtypes.h | 5 +++++ + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c +index df5f8cbfdc0..28debe4e013 100644 +--- a/src/mesa/drivers/dri/common/utils.c ++++ b/src/mesa/drivers/dri/common/utils.c +@@ -480,6 +480,7 @@ __DRIconfig **driConcatConfigs(__DRIconfig **a, + return all; + } + ++/* careful, lack of trailing semicolon */ + #define __ATTRIB(attrib, field) case attrib: *value = config->modes.field; break + + /** +@@ -555,9 +556,9 @@ driGetConfigAttribIndex(const __DRIconfig *config, + __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask); + __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask); + __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask); +- case __DRI_ATTRIB_MAX_PBUFFER_WIDTH: +- case __DRI_ATTRIB_MAX_PBUFFER_HEIGHT: +- case __DRI_ATTRIB_MAX_PBUFFER_PIXELS: ++ __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth); ++ __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight); ++ __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels); + case __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH: + case __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT: + case __DRI_ATTRIB_VISUAL_SELECT_GROUP: +diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h +index 8f77d4c58dd..e37c61d23d0 100644 +--- a/src/mesa/main/mtypes.h ++++ b/src/mesa/main/mtypes.h +@@ -175,6 +175,11 @@ struct gl_config + /* ARB_multisample / SGIS_multisample */ + GLuint samples; + ++ /* GLX 1.3 */ ++ GLint maxPbufferWidth; ++ GLint maxPbufferHeight; ++ GLint maxPbufferPixels; ++ + /* OML_swap_method */ + GLint swapMethod; + +-- +2.25.1 + diff --git a/package/mesa3d/0067-egl_dri2-set-pbuffer-config-attribs-to-0-for-non-pbu.patch b/package/mesa3d/0067-egl_dri2-set-pbuffer-config-attribs-to-0-for-non-pbu.patch index 5b10912b..1fdc1794 100644 --- a/package/mesa3d/0067-egl_dri2-set-pbuffer-config-attribs-to-0-for-non-pbu.patch +++ b/package/mesa3d/0067-egl_dri2-set-pbuffer-config-attribs-to-0-for-non-pbu.patch @@ -1,7 +1,7 @@ -From 090a4c570fb58b5cd55a7628e6805cf16b36b030 Mon Sep 17 00:00:00 2001 +From 9bb8868ebab2d041c24c76487b6419a8039a5ce7 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Wed, 4 Jun 2014 13:43:03 +0100 -Subject: [PATCH 07/50] egl_dri2: set pbuffer config attribs to 0 for +Subject: [PATCH 67/67] egl_dri2: set pbuffer config attribs to 0 for non-pbuffer configs If the EGL_PBUFFER_BIT isn't set in the surface type, don't set the @@ -14,10 +14,10 @@ values from the DRI config. 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index fb5d5617511..a47589d929f 100644 +index 56b5175db6e..1b10c2e7362 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -415,6 +415,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, +@@ -407,6 +407,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); _EGLConfig base; unsigned int attrib, value, double_buffer; @@ -25,7 +25,7 @@ index fb5d5617511..a47589d929f 100644 bool srgb = false; EGLint key, bind_to_texture_rgb, bind_to_texture_rgba; int dri_shifts[4] = { -1, -1, -1, -1 }; -@@ -536,11 +537,17 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, +@@ -530,11 +531,17 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, break; case __DRI_ATTRIB_MAX_PBUFFER_WIDTH: @@ -45,7 +45,7 @@ index fb5d5617511..a47589d929f 100644 case __DRI_ATTRIB_MUTABLE_RENDER_BUFFER: if (disp->Extensions.KHR_mutable_render_buffer) surface_type |= EGL_MUTABLE_RENDER_BUFFER_BIT_KHR; -@@ -553,6 +560,15 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, +@@ -614,6 +621,15 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, } } @@ -62,5 +62,5 @@ index fb5d5617511..a47589d929f 100644 for (int i = 0; attr_list[i] != EGL_NONE; i += 2) _eglSetConfigKey(&base, attr_list[i], attr_list[i+1]); -- -2.17.1 +2.25.1 diff --git a/package/mesa3d/0068-GL_ARB_geometry_shader4-entry-points.patch b/package/mesa3d/0068-GL_ARB_geometry_shader4-entry-points.patch new file mode 100644 index 00000000..e14a2442 --- /dev/null +++ b/package/mesa3d/0068-GL_ARB_geometry_shader4-entry-points.patch @@ -0,0 +1,146 @@ +From f9c028d508bac22d7c78b0232c625e27d13340a7 Mon Sep 17 00:00:00 2001 +From: Brendan King +Date: Thu, 11 Nov 2021 12:09:38 +0000 +Subject: [PATCH 68/68] GL_ARB_geometry_shader4 entry points. + +--- + src/mapi/glapi/gen/ARB_geometry_shader4.xml | 97 +++++++++++++++++++++ + src/mapi/glapi/gen/gl_API.xml | 2 +- + src/mapi/glapi/gen/static_data.py | 4 + + 3 files changed, 102 insertions(+), 1 deletion(-) + create mode 100644 src/mapi/glapi/gen/ARB_geometry_shader4.xml + +diff --git a/src/mapi/glapi/gen/ARB_geometry_shader4.xml b/src/mapi/glapi/gen/ARB_geometry_shader4.xml +new file mode 100644 +index 00000000000..d92dc577b17 +--- /dev/null ++++ b/src/mapi/glapi/gen/ARB_geometry_shader4.xml +@@ -0,0 +1,97 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml +index 4e35de0f4ea..d5a5e7f5386 100644 +--- a/src/mapi/glapi/gen/gl_API.xml ++++ b/src/mapi/glapi/gen/gl_API.xml +@@ -8064,7 +8064,7 @@ + + + +- ++ + + + +diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py +index 974f366d7b4..833ad73dd6a 100644 +--- a/src/mapi/glapi/gen/static_data.py ++++ b/src/mapi/glapi/gen/static_data.py +@@ -1721,6 +1721,10 @@ offsets = { + "FramebufferRenderbufferEXT" : 1685, + "GetFramebufferAttachmentParameterivEXT" : 1686, + "GenerateMipmapEXT" : 1687, ++ "ProgramParameteriARB" : 1688, ++ "FramebufferTextureARB" : 1689, ++ "FramebufferTextureLayerARB" : 1690, ++ "FramebufferTextureFaceARB" : 1691, + } + + functions = [ +-- +2.25.1 + diff --git a/package/mesa3d/mesa3d.hash b/package/mesa3d/mesa3d.hash index eb56b8c8..fb15cc9d 100644 --- a/package/mesa3d/mesa3d.hash +++ b/package/mesa3d/mesa3d.hash @@ -1,6 +1,6 @@ -# From https://lists.freedesktop.org/archives/mesa-announce/2021-March/000624.html -sha256 379fc984459394f2ab2d84049efdc3a659869dc1328ce72ef0598506611712bb mesa-21.0.1.tar.xz -sha512 b31b78778b6092dfaf0712f90de3074217574389c4236f8379c127739874f6bd1b47883140a26445d25e58df87e6207278efd048453096ee710d334b1dcfe419 mesa-21.0.1.tar.xz +# From https://lists.freedesktop.org/archives/mesa-announce/2021-August/000643.html +sha256 2c65e6710b419b67456a48beefd0be827b32db416772e0e363d5f7d54dc01787 mesa-21.2.1.tar.xz +sha512 d4056287ec86f7a95ce534a251a1ccbc3a3b08a2f7112152def2f054fc8a9424501d5883c463554ee95fe2dafb832613efd7145e989ee8281948233942730c2c mesa-21.2.1.tar.xz # License sha256 998437f3f75f0c542046f83c1cb349408122268168fb13eb4ae6967aa18b7d98 docs/license.rst diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk index 550b0b20..8a547912 100644 --- a/package/mesa3d/mesa3d.mk +++ b/package/mesa3d/mesa3d.mk @@ -5,7 +5,7 @@ ################################################################################ # When updating the version, please also update mesa3d-headers -MESA3D_VERSION = 21.0.1 +MESA3D_VERSION = 21.2.1 MESA3D_SOURCE = mesa-$(MESA3D_VERSION).tar.xz MESA3D_SITE = https://archive.mesa3d.org MESA3D_LICENSE = MIT, SGI, Khronos