Merge pull request #10235 from lygstate/master

Upgrade mesa to 21.3.1 and enable EGL support on Windows.
This commit is contained in:
jeremyd2019
2021-12-18 15:59:52 -08:00
committed by GitHub
7 changed files with 3860 additions and 64 deletions

View File

@@ -1,57 +0,0 @@
--- mesa-21.2.4/meson.build.orig 2021-10-16 16:02:38.021997300 -0700
+++ mesa-21.2.4/meson.build 2021-10-16 16:03:24.287545400 -0700
@@ -1046,8 +1046,6 @@
'-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions
'-DNOMINMAX',
]
- else
- pre_args += ['-D__MSVCRT_VERSION__=0x0700']
endif
elif host_machine.system() == 'openbsd'
pre_args += '-D_ISOC11_SOURCE'
--- mesa-21.2.4/src/compiler/spirv/vtn_private.h.orig 2021-10-16 15:28:02.537761600 -0700
+++ mesa-21.2.4/src/compiler/spirv/vtn_private.h 2021-10-16 15:28:05.959391400 -0700
@@ -41,7 +41,7 @@
struct vtn_decoration;
/* setjmp/longjmp is broken on MinGW: https://sourceforge.net/p/mingw-w64/bugs/406/ */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) && !defined(_UCRT)
#define vtn_setjmp __builtin_setjmp
#define vtn_longjmp __builtin_longjmp
#else
--- mesa-21.2.4/src/compiler/nir/nir.h.orig 2021-10-14 12:59:05.367845000 -0700
+++ mesa-21.2.4/src/compiler/nir/nir.h 2021-10-16 15:55:09.881268400 -0700
@@ -54,7 +54,7 @@
#include "nir_opcodes.h"
-#if defined(_WIN32) && !defined(snprintf)
+#if defined(_WIN32) && !defined(snprintf) && !defined(_UCRT)
#define snprintf _snprintf
#endif
--- mesa-21.2.4/src/compiler/nir/nir_lower_atomics_to_ssbo.c.orig 2021-10-14 12:59:05.375845200 -0700
+++ mesa-21.2.4/src/compiler/nir/nir_lower_atomics_to_ssbo.c 2021-10-16 15:55:30.818804300 -0700
@@ -27,10 +27,6 @@
#include "nir.h"
#include "nir_builder.h"
-#if defined(_WIN32) && !defined(snprintf)
-#define snprintf _snprintf
-#endif
-
/*
* Remap atomic counters to SSBOs, starting from the shader's next SSBO slot
* (info.num_ssbos).
--- mesa-21.2.4/src/gallium/drivers/swr/swr_fence.cpp.orig 2021-10-16 16:29:10.287533700 -0700
+++ mesa-21.2.4/src/gallium/drivers/swr/swr_fence.cpp 2021-10-16 16:29:45.678206500 -0700
@@ -29,7 +29,7 @@
#include "swr_screen.h"
#include "swr_fence.h"
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__MINGW32__)
#include <sched.h>
#endif

View File

@@ -0,0 +1,101 @@
From 085038ca5ac47d914cea322e25f12649cd1fe27b Mon Sep 17 00:00:00 2001
From: Yonggang Luo <luoyonggang@gmail.com>
Date: Fri, 3 Dec 2021 00:01:34 +0800
Subject: [PATCH] win32: Fixes building with msys2/mingw/clang32,clang64,ucrt64
Move `#define snprintf _snprintf` from nir/nir_lower_atomics_to_ssbo.c to nir.h
Fixes __MSVCRT_VERSION__ properly
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
meson.build | 13 ++++++++++++-
src/compiler/nir/nir.h | 2 ++
src/compiler/nir/nir_lower_atomics_to_ssbo.c | 4 ----
src/compiler/spirv/vtn_private.h | 2 +-
src/gallium/drivers/swr/swr_fence.cpp | 2 +-
5 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/meson.build b/meson.build
index 8b8ffc95aab..ed7f93eac16 100644
--- a/meson.build
+++ b/meson.build
@@ -1089,7 +1089,18 @@ elif host_machine.system() == 'windows'
'-DNOMINMAX',
]
else
- pre_args += ['-D__MSVCRT_VERSION__=0x0700']
+ # When the target is not mingw/ucrt
+ # NOTE: clang's stddef.h are conflict with mingw/ucrt's stddef.h
+ # So do not include headers that defined in clang for detecting
+ # _UCRT
+ if cc.compiles('''
+ #include <string.h>
+ #if defined(__MINGW32__) && defined(_UCRT)
+ #error
+ #endif
+ int main(void) { return 0; }''')
+ pre_args += ['-D__MSVCRT_VERSION__=0x0700']
+ endif
endif
elif host_machine.system() == 'openbsd'
pre_args += '-D_ISOC11_SOURCE'
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 019e60f9238..3a0f0e705c2 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -55,8 +55,10 @@
#include "nir_opcodes.h"
#if defined(_WIN32) && !defined(snprintf)
+#if (defined(_MSC_VER) && _MSC_VER < 1900) || (defined(__MINGW32__) && !defined(_UCRT))
#define snprintf _snprintf
#endif
+#endif
#ifdef __cplusplus
extern "C" {
diff --git a/src/compiler/nir/nir_lower_atomics_to_ssbo.c b/src/compiler/nir/nir_lower_atomics_to_ssbo.c
index c1799d0b9d0..448f63bdc7c 100644
--- a/src/compiler/nir/nir_lower_atomics_to_ssbo.c
+++ b/src/compiler/nir/nir_lower_atomics_to_ssbo.c
@@ -27,10 +27,6 @@
#include "nir.h"
#include "nir_builder.h"
-#if defined(_WIN32) && !defined(snprintf)
-#define snprintf _snprintf
-#endif
-
/*
* Remap atomic counters to SSBOs, starting from the shader's next SSBO slot
* (info.num_ssbos).
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 93985f54f86..24958cc13d7 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -41,7 +41,7 @@ struct vtn_builder;
struct vtn_decoration;
/* setjmp/longjmp is broken on MinGW: https://sourceforge.net/p/mingw-w64/bugs/406/ */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) && !defined(_UCRT)
#define vtn_setjmp __builtin_setjmp
#define vtn_longjmp __builtin_longjmp
#else
diff --git a/src/gallium/drivers/swr/swr_fence.cpp b/src/gallium/drivers/swr/swr_fence.cpp
index 4e2b2af874c..7803c77e425 100644
--- a/src/gallium/drivers/swr/swr_fence.cpp
+++ b/src/gallium/drivers/swr/swr_fence.cpp
@@ -29,7 +29,7 @@
#include "swr_screen.h"
#include "swr_fence.h"
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__MINGW32__)
#include <sched.h>
#endif
--
2.31.1.windows.1

View File

@@ -0,0 +1,53 @@
From f35c365839ae6c92d93b11238caa6101837e2c22 Mon Sep 17 00:00:00 2001
From: Yonggang Luo <luoyonggang@gmail.com>
Date: Thu, 2 Dec 2021 23:39:20 +0800
Subject: [PATCH 2/3] win32: Generate the source with encoding utf-8 to fixes
the python error
"C:\CI-Tools\msys64\mingw64\bin/python3.EXE" "../../src/vulkan/util/gen_enum_to_str.py" "--xml" "../../src/vulkan/registry/vk.xml" "--outdir" "C:/work/xemu/xemu-opengl/mesa/build/windows-mingw64/src/vulkan/util"
Traceback (most recent call last):
File "C:\work\xemu\xemu-opengl\mesa\src\vulkan\util\gen_enum_to_str.py", line 473, in <module>
main()
File "C:\work\xemu\xemu-opengl\mesa\src\vulkan\util\gen_enum_to_str.py", line 462, in main
f.write(template.render(
UnicodeEncodeError: 'gbk' codec can't encode character '\xa9' in position 107: illegal multibyte sequence
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
src/vulkan/util/gen_enum_to_str.py | 2 +-
src/vulkan/util/vk_entrypoints_gen.py | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index 7357b537fdd..27fd76731c7 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -458,7 +458,7 @@ def main():
for template, file_ in [(C_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.c')),
(H_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.h')),
(H_DEFINE_TEMPLATE, os.path.join(args.outdir, 'vk_enum_defines.h'))]:
- with open(file_, 'w') as f:
+ with open(file_, 'w', encoding='utf-8') as f:
f.write(template.render(
file=os.path.basename(__file__),
enums=enums,
diff --git a/src/vulkan/util/vk_entrypoints_gen.py b/src/vulkan/util/vk_entrypoints_gen.py
index 078b6daec0b..5d2c1ca0cd5 100644
--- a/src/vulkan/util/vk_entrypoints_gen.py
+++ b/src/vulkan/util/vk_entrypoints_gen.py
@@ -237,10 +237,10 @@ def main():
# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
# per entry point.
try:
- with open(args.out_h, 'w') as f:
+ with open(args.out_h, 'w', encoding='utf-8') as f:
guard = os.path.basename(args.out_h).replace('.', '_').upper()
f.write(TEMPLATE_H.render(guard=guard, **environment))
- with open(args.out_c, 'w') as f:
+ with open(args.out_c, 'w', encoding='utf-8') as f:
f.write(TEMPLATE_C.render(**environment))
except Exception:
--
2.31.1.windows.1

View File

@@ -0,0 +1,48 @@
From 7027ea1b867ea342ae209bef6405d71c6ffd4283 Mon Sep 17 00:00:00 2001
From: Yonggang Luo <luoyonggang@gmail.com>
Date: Fri, 3 Dec 2021 03:14:45 +0800
Subject: [PATCH 6/6] win32: The opengl headers should install to mesa/GL
subdir
The subdir `mesa/GL` used to avoid conflict between Windows GL headers and mesa GL headers.
The GL headers resident in Windows SDK are:
```
gl.h
glaux.h
glcorearb.h
glext.h
glu.h
glxext.h
wgl.h
wglext.h
```
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
include/meson.build | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/meson.build b/include/meson.build
index d1d5787cf1d..f4686cd3eb0 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -62,11 +62,15 @@ if not with_glvnd
endif
if with_opengl
+ opengl_subdir = 'GL'
+ if host_machine.system() == 'windows'
+ opengl_subdir = 'mesa/GL'
+ endif
install_headers(
'GL/gl.h',
'GL/glcorearb.h',
'GL/glext.h',
- subdir : 'GL',
+ subdir : opengl_subdir,
)
endif
--
2.31.1.windows.1

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,82 @@
From 09bc2c229fc4b70488933530bcdc705a1dd670b9 Mon Sep 17 00:00:00 2001
From: Yonggang Luo <luoyonggang@gmail.com>
Date: Sat, 4 Dec 2021 15:44:51 +0800
Subject: [PATCH] win32: Do not use BUILD_GL32, we use def file to export win32
dll symbols.
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
src/gallium/frontends/osmesa/meson.build | 2 +-
src/mapi/es1api/meson.build | 2 +-
src/mapi/es2api/meson.build | 2 +-
src/mapi/glapi/meson.build | 2 +-
src/mesa/meson.build | 1 -
5 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/gallium/frontends/osmesa/meson.build b/src/gallium/frontends/osmesa/meson.build
index e5848fd9934..fe78a4daa31 100644
--- a/src/gallium/frontends/osmesa/meson.build
+++ b/src/gallium/frontends/osmesa/meson.build
@@ -20,7 +20,7 @@
osmesa_st_c_args = []
if with_platform_windows
- osmesa_st_c_args += ['-DBUILD_GL32', '-DWIN32_LEAN_AND_MEAN']
+ osmesa_st_c_args += ['-DWIN32_LEAN_AND_MEAN']
if not with_shared_glapi
osmesa_st_c_args += ['-D_GLAPI_NO_EXPORTS']
endif
diff --git a/src/mapi/es1api/meson.build b/src/mapi/es1api/meson.build
index 8b749b1a332..7e52633a245 100644
--- a/src/mapi/es1api/meson.build
+++ b/src/mapi/es1api/meson.build
@@ -29,7 +29,7 @@ es1_glapi_mapi_tmp_h = custom_target(
_es1_c_args = []
if with_platform_windows
- _es1_c_args += ['-D_GDI32_', '-DBUILD_GL32']
+ _es1_c_args += ['-D_GDI32_']
endif
libglesv1_cm = shared_library(
diff --git a/src/mapi/es2api/meson.build b/src/mapi/es2api/meson.build
index 356c5760c49..0290674564f 100644
--- a/src/mapi/es2api/meson.build
+++ b/src/mapi/es2api/meson.build
@@ -29,7 +29,7 @@ es2_glapi_mapi_tmp_h = custom_target(
_es2_c_args = []
if with_platform_windows
- _es2_c_args += ['-D_GDI32_', '-DBUILD_GL32']
+ _es2_c_args += ['-D_GDI32_']
endif
libgles2 = shared_library(
diff --git a/src/mapi/glapi/meson.build b/src/mapi/glapi/meson.build
index 3eb4318dedb..941185e4b0d 100644
--- a/src/mapi/glapi/meson.build
+++ b/src/mapi/glapi/meson.build
@@ -52,7 +52,7 @@ if with_shared_glapi
else
static_glapi_args += '-DMAPI_MODE_UTIL'
if with_platform_windows
- static_glapi_args += ['-D_GDI32_', '-DBUILD_GL32', '-DKHRONOS_DLL_EXPORTS', '-D_GLAPI_NO_EXPORTS']
+ static_glapi_args += ['-D_GDI32_', '-DKHRONOS_DLL_EXPORTS', '-D_GLAPI_NO_EXPORTS']
endif
static_glapi_files += files(
'glapi_dispatch.c',
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index 2f29012c901..396d30848db 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -713,7 +713,6 @@ _mesa_windows_args = []
if with_platform_windows
_mesa_windows_args += [
'-D_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
- '-DBUILD_GL32' # declare gl* as __declspec(dllexport) in Mesa headers
]
if not with_shared_glapi
# prevent _glapi_* from being declared __declspec(dllimport)
--
2.31.1.windows.1

View File

@@ -3,8 +3,8 @@
_realname=mesa
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=21.2.6
pkgrel=2
pkgver=21.3.2
pkgrel=1
pkgdesc="Open-source implementation of the OpenGL specification (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
@@ -29,13 +29,21 @@ source=(https://mesa.freedesktop.org/archive/${_realname}-${pkgver}.tar.xz{,.sig
llvmwrapgen.sh
0001-swr-llvm-fix-swr-build-with-LLVM-13.patch
0002-swr-Fix-build-with-llvm-13.patch
0003-ucrt-fixes.patch)
sha256sums=('1e7e22d93c6e8859fa044b1121119d26b2e67e4184b92ebb81c66497dc80c954'
0003-win32-Fixes-building-with-msys2-mingw-clang32-clang6.patch
0004-win32-Generate-the-source-with-encoding-utf-8-to-fix.patch
0005-win32-The-opengl-headers-should-install-to-mesa-GL-s.patch
0006-win32-Fixes-32-bits-visual-studio-module-definition-.patch
0007-win32-Do-not-use-BUILD_GL32-we-use-def-file-to-expor.patch)
sha256sums=('e2e7bafb8307e7abc3bf982f39382fae3619c84b45504920a21504be52f126bd'
'SKIP'
'69f21522f20c10f5699dfe3e128aa88d4fedde816f6e8df1506d7470c44bf3da'
'e5aa27b6aba3e75335bbd6d989c52dd42a8435ef87a1453267164e9612daee1a'
'37d1c37fd3a8563b9dd78ecd361e5a39440310facd1ed656ca1e12f667b54d6b'
'6baff82b5e80f6f47f7cb54af67efb02c5c4f10e99e3c0fa1dc180e9100f9872')
'4f2f293203ea202de43655fdcdc943c4f82a0d8ef4ec1466713c4fb7fcfe4002'
'eba09356b17b22a7e9c2151d254b0f7c20029af3f6c0a0ca4a0e4ff15de8da97'
'747e3894d50511f611b4a4cbcc1aad13f70c251202ef33f151d1e18ce541e8eb'
'6fa9d642782d8ac733f50cc356e0802e0f3d540c6045270924707747933b79eb'
'5319ea618826cdafa1ddf1d9be8cb486eac73eddafec9b09b6652a0f08994efb')
validpgpkeys=('8703B6700E7EE06D7A39B8D6EDAE37B02CEB490D') # Emil Velikov <emil.l.velikov@gmail.com>
validpgpkeys+=('946D09B5E4C9845E63075FF1D961C596A7203456') # Andres Gomez <tanty@igalia.com>
validpgpkeys+=('E3E8F480C52ADD73B278EE78E1ECBE07D7D70895') # Juan Antonio Suárez Romero (Igalia, S.L.) <jasuarez@igalia.com>"
@@ -95,7 +103,11 @@ prepare() {
0002-swr-Fix-build-with-llvm-13.patch
apply_patch_with_msg \
0003-ucrt-fixes.patch
0003-win32-Fixes-building-with-msys2-mingw-clang32-clang6.patch \
0004-win32-Generate-the-source-with-encoding-utf-8-to-fix.patch \
0005-win32-The-opengl-headers-should-install-to-mesa-GL-s.patch \
0006-win32-Fixes-32-bits-visual-studio-module-definition-.patch \
0007-win32-Do-not-use-BUILD_GL32-we-use-def-file-to-expor.patch
# Generate binary wrap for LLVM if llvm-config tool is busted
if ! [ "$(${MINGW_PREFIX}/bin/llvm-config --has-rtti 2>&1)" = YES ] && ! [ "$(${MINGW_PREFIX}/bin/llvm-config --has-rtti 2>&1)" = NO ]; then
@@ -107,10 +119,10 @@ build() {
cd ${srcdir}/${_realname}-${pkgver}
buildconf="${MINGW_PREFIX}/bin/meson ./build/windows-${_mach}
--prefix=${MINGW_PREFIX}
--includedir=include/mesa
--buildtype=release
--backend=ninja
-Dshared-glapi=enabled
-Degl=enabled
-Dgles1=enabled
-Dgles2=enabled
-Dllvm=enabled