meson, egl: Support building for the Windows platform
Add a stub EGL driver for Windows Fix compiler issues in egl/main Ensure Windows build produces libEGL.dll Default EGL to enabled for Windows when building a Gallium driver Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed By: Bill Kristiansen <billkris@microsoft.com> Acked-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12727>
This commit is contained in:
19
meson.build
19
meson.build
@@ -435,18 +435,19 @@ elif _egl == 'false'
|
||||
endif
|
||||
if _egl == 'auto'
|
||||
with_egl = (
|
||||
not ['darwin', 'windows'].contains(host_machine.system()) and
|
||||
with_dri and with_shared_glapi
|
||||
host_machine.system() != 'darwin' and
|
||||
(with_platform_windows or with_dri) and
|
||||
with_shared_glapi
|
||||
)
|
||||
elif _egl == 'enabled'
|
||||
if not with_dri and not with_platform_haiku
|
||||
error('EGL requires dri')
|
||||
if not with_dri and not with_platform_haiku and not with_platform_windows
|
||||
error('EGL requires dri, haiku, or windows')
|
||||
elif not with_shared_glapi
|
||||
error('EGL requires shared-glapi')
|
||||
elif not ['disabled', 'dri'].contains(with_glx)
|
||||
error('EGL requires dri, but a GLX is being built without dri')
|
||||
elif ['darwin', 'windows'].contains(host_machine.system())
|
||||
error('EGL is not available on Windows or MacOS')
|
||||
elif host_machine.system() == 'darwin'
|
||||
error('EGL is not available on MacOS')
|
||||
endif
|
||||
with_egl = true
|
||||
else
|
||||
@@ -913,6 +914,9 @@ endif
|
||||
if with_gbm and not with_platform_android
|
||||
pre_args += '-DHAVE_DRM_PLATFORM'
|
||||
endif
|
||||
if with_platform_windows
|
||||
pre_args += '-DHAVE_WINDOWS_PLATFORM'
|
||||
endif
|
||||
|
||||
with_android_stub = get_option('android-stub')
|
||||
if with_android_stub and not with_platform_android
|
||||
@@ -2188,6 +2192,9 @@ if with_egl
|
||||
if with_dri3
|
||||
egl_drivers += 'builtin:egl_dri3'
|
||||
endif
|
||||
if with_platform_windows
|
||||
egl_drivers += 'builtin:wgl'
|
||||
endif
|
||||
lines += 'EGL drivers: ' + ' '.join(egl_drivers)
|
||||
endif
|
||||
if with_egl or with_any_vk
|
||||
|
27
src/egl/drivers/wgl/egl_wgl.c
Normal file
27
src/egl/drivers/wgl/egl_wgl.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright © Microsoft Corporation
|
||||
*
|
||||
* 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 (including the next
|
||||
* paragraph) 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 <egldriver.h>
|
||||
|
||||
struct _egl_driver _eglDriver;
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "c99_compat.h"
|
||||
#include "c11/threads.h"
|
||||
#include "util/u_thread.h"
|
||||
#include "util/u_string.h"
|
||||
|
||||
#include "egllog.h"
|
||||
#include "eglcurrent.h"
|
||||
|
@@ -35,7 +35,11 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include "c11/threads.h"
|
||||
#include "util/macros.h"
|
||||
@@ -77,6 +81,7 @@ static const struct {
|
||||
{ _EGL_PLATFORM_HAIKU, "haiku" },
|
||||
{ _EGL_PLATFORM_SURFACELESS, "surfaceless" },
|
||||
{ _EGL_PLATFORM_DEVICE, "device" },
|
||||
{ _EGL_PLATFORM_WINDOWS, "windows" },
|
||||
};
|
||||
|
||||
|
||||
|
@@ -52,6 +52,7 @@ enum _egl_platform_type {
|
||||
_EGL_PLATFORM_HAIKU,
|
||||
_EGL_PLATFORM_SURFACELESS,
|
||||
_EGL_PLATFORM_DEVICE,
|
||||
_EGL_PLATFORM_WINDOWS,
|
||||
|
||||
_EGL_NUM_PLATFORMS,
|
||||
_EGL_INVALID_PLATFORM = -1
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "egldisplay.h"
|
||||
|
||||
#include "util/macros.h"
|
||||
#include "util/os_misc.h"
|
||||
|
||||
#ifdef HAVE_MINCORE
|
||||
#include <unistd.h>
|
||||
@@ -137,7 +138,8 @@ EGLBoolean
|
||||
_eglPointerIsDereferencable(void *p)
|
||||
{
|
||||
uintptr_t addr = (uintptr_t) p;
|
||||
const long page_size = getpagesize();
|
||||
uint64_t page_size = 0;
|
||||
os_get_page_size(&page_size);
|
||||
#ifdef HAVE_MINCORE
|
||||
unsigned char valid = 0;
|
||||
|
||||
|
@@ -39,7 +39,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include "c11/threads.h"
|
||||
#include "util/macros.h"
|
||||
#include "util/u_string.h"
|
||||
|
@@ -140,6 +140,11 @@ elif with_platform_haiku
|
||||
files_egl += files('drivers/haiku/egl_haiku.cpp')
|
||||
link_for_egl += libgl
|
||||
deps_for_egl += cpp.find_library('be')
|
||||
elif with_platform_windows
|
||||
c_args_for_egl += [
|
||||
'-DEGLAPI=', '-DPUBLIC='
|
||||
]
|
||||
files_egl += files('drivers/wgl/egl_wgl.c')
|
||||
endif
|
||||
|
||||
if cc.has_function('mincore')
|
||||
@@ -149,9 +154,11 @@ endif
|
||||
if not with_glvnd
|
||||
egl_lib_name = 'EGL' + get_option('egl-lib-suffix')
|
||||
egl_lib_version = '1.0.0'
|
||||
egl_lib_soversion = host_machine.system() == 'windows' ? '' : '1'
|
||||
else
|
||||
egl_lib_name = 'EGL_@0@'.format(glvnd_vendor_name)
|
||||
egl_lib_version = '0.0.0'
|
||||
egl_lib_soversion = '0'
|
||||
deps_for_egl += dep_glvnd
|
||||
files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
|
||||
files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
|
||||
@@ -181,6 +188,8 @@ libegl = shared_library(
|
||||
dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread, idep_mesautil],
|
||||
install : true,
|
||||
version : egl_lib_version,
|
||||
soversion : egl_lib_soversion,
|
||||
name_prefix : 'lib', # even on windows
|
||||
)
|
||||
|
||||
if not with_glvnd
|
||||
|
Reference in New Issue
Block a user