Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libglvnd for openSUSE:Factory checked in at 2023-10-12 23:39:01 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libglvnd (Old) and /work/SRC/openSUSE:Factory/.libglvnd.new.1807 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libglvnd" Thu Oct 12 23:39:01 2023 rev:29 rq:1117454 version:1.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/libglvnd/libglvnd.changes 2022-12-08 16:50:28.307263900 +0100 +++ /work/SRC/openSUSE:Factory/.libglvnd.new.1807/libglvnd.changes 2023-10-12 23:39:05.486343448 +0200 @@ -1,0 +2,11 @@ +Wed Oct 11 15:12:15 UTC 2023 - Bjørn Lie <[email protected]> + +- Update to 1.7.0: + * meson.build: error out on unsupported OSes + * Update bin/symbols-check.py from mesa/mesa@9d42e31b + * EGL/libeglcurrent: fix crash on library unload + * HGL: add Haiku libGL.so implementation based on EGL + * symbols-check: Add Haiku platform symbols + * tests/egl: Fix LIBRARY_PATH on Haiku + +------------------------------------------------------------------- Old: ---- libglvnd-1.6.0.tar.gz New: ---- libglvnd-1.7.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libglvnd.spec ++++++ --- /var/tmp/diff_new_pack.keGqOp/_old 2023-10-12 23:39:06.262371539 +0200 +++ /var/tmp/diff_new_pack.keGqOp/_new 2023-10-12 23:39:06.262371539 +0200 @@ -1,7 +1,7 @@ # # spec file for package libglvnd # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,13 +19,13 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: libglvnd -Version: 1.6.0 +Version: 1.7.0 Release: 0 Summary: The GL Vendor-Neutral Dispatch library License: MIT Group: Development/Libraries/C and C++ URL: https://github.com/NVIDIA/libglvnd -Source: https://github.com/NVIDIA/libglvnd/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source: %{url}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz Source1: baselibs.conf Source2: libglvnd.rpmlintrc Patch1: disable-glx-tests.patch ++++++ libglvnd-1.6.0.tar.gz -> libglvnd-1.7.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/bin/symbols-check.py new/libglvnd-1.7.0/bin/symbols-check.py --- old/libglvnd-1.6.0/bin/symbols-check.py 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/bin/symbols-check.py 2023-09-12 16:02:00.000000000 +0200 @@ -13,6 +13,34 @@ '__cxa_guard_abort', '__cxa_guard_acquire', '__cxa_guard_release', + '__cxa_allocate_dependent_exception', + '__cxa_allocate_exception', + '__cxa_begin_catch', + '__cxa_call_unexpected', + '__cxa_current_exception_type', + '__cxa_current_primary_exception', + '__cxa_decrement_exception_refcount', + '__cxa_deleted_virtual', + '__cxa_demangle', + '__cxa_end_catch', + '__cxa_free_dependent_exception', + '__cxa_free_exception', + '__cxa_get_exception_ptr', + '__cxa_get_globals', + '__cxa_get_globals_fast', + '__cxa_increment_exception_refcount', + '__cxa_new_handler', + '__cxa_pure_virtual', + '__cxa_rethrow', + '__cxa_rethrow_primary_exception', + '__cxa_terminate_handler', + '__cxa_throw', + '__cxa_uncaught_exception', + '__cxa_uncaught_exceptions', + '__cxa_unexpected_handler', + '__dynamic_cast', + '__emutls_get_address', + '__gxx_personality_v0', '__end__', '__odr_asan._glapi_Context', '__odr_asan._glapi_Dispatch', @@ -24,8 +52,11 @@ '_fbss', '_fdata', '_ftext', + '_gSharedObjectHaikuABI', + '_gSharedObjectHaikuVersion', ] + def get_symbols_nm(nm, lib): ''' List all the (non platform-specific) symbols exported by the library @@ -40,7 +71,7 @@ if len(fields) == 2 or fields[1] == 'U': continue symbol_name = fields[0] - if platform_name == 'Linux': + if platform_name in ['Linux', 'GNU', 'Haiku'] or platform_name.startswith('GNU/'): if symbol_name in PLATFORM_SYMBOLS: continue elif platform_name == 'Darwin': @@ -73,7 +104,7 @@ continue symbol_name = fields[3] # De-mangle symbols - if symbol_name[0] == '_': + if symbol_name[0] == '_' and '@' in symbol_name: symbol_name = symbol_name[1:].split('@')[0] symbols.append(symbol_name) return symbols diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/configure.ac new/libglvnd-1.7.0/configure.ac --- old/libglvnd-1.6.0/configure.ac 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/configure.ac 2023-09-12 16:02:00.000000000 +0200 @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.63]) -AC_INIT([libglvnd], [1.6.0], [[email protected]]) +AC_INIT([libglvnd], [1.7.0], [[email protected]]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/include/HGL/OpenGLKit.h new/libglvnd-1.7.0/include/HGL/OpenGLKit.h --- old/libglvnd-1.6.0/include/HGL/OpenGLKit.h 1970-01-01 01:00:00.000000000 +0100 +++ new/libglvnd-1.7.0/include/HGL/OpenGLKit.h 2023-09-12 16:02:00.000000000 +0200 @@ -0,0 +1,10 @@ +/* + * Master include file for the Haiku OpenGL Kit. + */ + +#include <GL/gl.h> +#include <GLView.h> + +// Projects needing GL/glu.h and GL/glut.h should now +// include these headers independently as glu and glut +// are no longer core parts of mesa diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/include/HGL/README new/libglvnd-1.7.0/include/HGL/README --- old/libglvnd-1.6.0/include/HGL/README 1970-01-01 01:00:00.000000000 +0100 +++ new/libglvnd-1.7.0/include/HGL/README 2023-09-12 16:02:00.000000000 +0200 @@ -0,0 +1,21 @@ +These headers make up the Haiku OpenGL kit. + +Headers in this directory preserve some BeOS⢠compatibility +compatibility, so changes should be mentioned to the Haiku +project mailing list. + +Haiku Website: http://haiku-os.org +BeOS OpenGL API Docs: https://www.haiku-os.org/legacy-docs/bebook/TheOpenGLKit_Overview.html + +Normal Haiku OpenGL layout: + + * headers/os/OpenGLKit.h + * headers/os/opengl/GLView.h + * headers/os/opengl/GL/gl.h + * headers/os/opengl/GL/glext.h + * headers/os/opengl/GL/osmesa.h (needed?) + +Extras: + + * headers/os/opengl/GL/glu.h + * headers/os/opengl/GL/glut.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/include/HGL/opengl/GLView.h new/libglvnd-1.7.0/include/HGL/opengl/GLView.h --- old/libglvnd-1.6.0/include/HGL/opengl/GLView.h 1970-01-01 01:00:00.000000000 +0100 +++ new/libglvnd-1.7.0/include/HGL/opengl/GLView.h 2023-09-12 16:02:00.000000000 +0200 @@ -0,0 +1,196 @@ +/* + * Copyright 2008-2023, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * This header defines BGLView, the base class making up + * the Haiku OpenGL Kit. + * + */ +#ifndef BGLVIEW_H +#define BGLVIEW_H + + +#include <GL/gl.h> + +#define BGL_RGB 0 +#define BGL_INDEX 1 +#define BGL_SINGLE 0 +#define BGL_DOUBLE 2 +#define BGL_DIRECT 0 +#define BGL_INDIRECT 4 +#define BGL_ACCUM 8 +#define BGL_ALPHA 16 +#define BGL_DEPTH 32 +#define BGL_OVERLAY 64 +#define BGL_UNDERLAY 128 +#define BGL_STENCIL 512 +#define BGL_SHARE_CONTEXT 1024 + + +#ifdef __cplusplus + +#include <AppKit.h> +#include <Bitmap.h> +#include <DirectWindow.h> +#include <View.h> +#include <Window.h> +#include <WindowScreen.h> + + +struct glview_direct_info; + +class _EXPORT BGLView : public BView { +public: + BGLView(BRect rect, const char* name, + ulong resizingMode, ulong mode, + ulong options); + virtual ~BGLView(); + + void LockGL(); + void UnlockGL(); + void SwapBuffers(); + void SwapBuffers(bool vSync); + + BView* EmbeddedView(); + void* GetGLProcAddress(const char* procName); + + status_t CopyPixelsOut(BPoint source, BBitmap *dest); + status_t CopyPixelsIn(BBitmap *source, BPoint dest); + + // Mesa's GLenum is uint where Be's ones was ulong! + virtual void ErrorCallback(unsigned long errorCode); + + virtual void Draw(BRect updateRect); + virtual void AttachedToWindow(); + virtual void AllAttached(); + virtual void DetachedFromWindow(); + virtual void AllDetached(); + + virtual void FrameResized(float newWidth, float newHeight); + virtual status_t Perform(perform_code d, void *arg); + + virtual status_t Archive(BMessage *data, bool deep = true) const; + + virtual void MessageReceived(BMessage *message); + virtual void SetResizingMode(uint32 mode); + + virtual void Show(); + virtual void Hide(); + + virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index, + BMessage *specifier, int32 form, + const char *property); + virtual status_t GetSupportedSuites(BMessage *data); + + void DirectConnected(direct_buffer_info *info); + void EnableDirectMode(bool enabled); + + void* getGC() { return fGc; } + + virtual void GetPreferredSize(float* width, float* height); + +private: + class Display; + struct Renderer; + + virtual void _ReservedGLView1(); + virtual void _ReservedGLView2(); + virtual void _ReservedGLView3(); + virtual void _ReservedGLView4(); + virtual void _ReservedGLView5(); + virtual void _ReservedGLView6(); + virtual void _ReservedGLView7(); + virtual void _ReservedGLView8(); + + BGLView(const BGLView &); + BGLView &operator=(const BGLView &); + + static Display sDisplay; + + void _DitherFront(); + bool _ConfirmDither(); + void _Draw(BRect rect); + void _CallDirectConnected(); + + void* fGc; + uint32 fOptions; + uint32 fUnused1; + BLocker fDrawLock; + BLocker fDisplayLock; + glview_direct_info* fClipInfo; + + Renderer* fRenderer; + void* fUnused2; + void* fUnused3; + BRect fUnused4; + void* fUnused5[2]; + uint64 _reserved[8]; + + void _LockDraw(); + void _UnlockDraw(); + +// BeOS compatibility +private: + BGLView(BRect rect, char* name, + ulong resizingMode, ulong mode, + ulong options); +}; + + +class BGLScreen : public BWindowScreen { +public: + BGLScreen(char* name, + ulong screenMode, ulong options, + status_t *error, bool debug=false); + ~BGLScreen(); + + void LockGL(); + void UnlockGL(); + void SwapBuffers(); + // Mesa's GLenum is uint where Be's ones was ulong! + virtual void ErrorCallback(unsigned long errorCode); + + virtual void ScreenConnected(bool connected); + virtual void FrameResized(float width, float height); + virtual status_t Perform(perform_code code, void *arg); + + virtual status_t Archive(BMessage *data, bool deep = true) const; + virtual void MessageReceived(BMessage *message); + + virtual void Show(); + virtual void Hide(); + + virtual BHandler* ResolveSpecifier(BMessage *message, + int32 index, + BMessage *specifier, + int32 form, + const char *property); + virtual status_t GetSupportedSuites(BMessage *data); + +private: + + virtual void _ReservedGLScreen1(); + virtual void _ReservedGLScreen2(); + virtual void _ReservedGLScreen3(); + virtual void _ReservedGLScreen4(); + virtual void _ReservedGLScreen5(); + virtual void _ReservedGLScreen6(); + virtual void _ReservedGLScreen7(); + virtual void _ReservedGLScreen8(); + + BGLScreen(const BGLScreen &); + BGLScreen &operator=(const BGLScreen &); + + void* fGc; + long fOptions; + BLocker fDrawLock; + + int32 fColorSpace; + uint32 fScreenMode; + + uint64 _reserved[7]; +}; + +#endif // __cplusplus + +#endif // BGLVIEW_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/include/Makefile.am new/libglvnd-1.7.0/include/Makefile.am --- old/libglvnd-1.6.0/include/Makefile.am 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/include/Makefile.am 2023-09-12 16:02:00.000000000 +0200 @@ -44,6 +44,10 @@ EGL/eglext.h \ EGL/eglplatform.h +HGL_HEADER_FILES = \ + HGL/OpenGLKit.h \ + HGL/opengl/GLView.h + if ENABLE_GL_HEADERS nobase_include_HEADERS += $(GL_HEADER_FILES) else @@ -76,4 +80,4 @@ noinst_HEADERS += $(EGL_HEADER_FILES) endif -EXTRA_DIST = meson.build \ No newline at end of file +EXTRA_DIST = meson.build $(HGL_HEADER_FILES) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/include/meson.build new/libglvnd-1.7.0/include/meson.build --- old/libglvnd-1.6.0/include/meson.build 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/include/meson.build 2023-09-12 16:02:00.000000000 +0200 @@ -22,6 +22,7 @@ # MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. inc_include = include_directories('.') +inc_include_hgl = include_directories('HGL/opengl') install_headers( 'glvnd/GLdispatchABI.h', @@ -54,6 +55,17 @@ ) endif +if with_hgl and _headers + install_headers( + 'HGL/opengl/GLView.h', + subdir : 'opengl', + ) + install_headers( + 'HGL/OpenGLKit.h', + subdir : '', + ) +endif + if get_option('gles1') and _headers install_headers( 'GLES/egl.h', @@ -89,4 +101,3 @@ subdir : 'EGL', ) endif - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/meson.build new/libglvnd-1.7.0/meson.build --- old/libglvnd-1.6.0/meson.build 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/meson.build 2023-09-12 16:02:00.000000000 +0200 @@ -24,11 +24,15 @@ project( 'glvnd', 'c', - version : '1.6.0', + version : '1.7.0', meson_version : '>= 0.48', default_options : ['c_std=gnu99'] ) +if host_machine.system() in ['darwin', 'windows'] + error('Host OS: @0@ is unsupported.'.format(host_machine.system())) +endif + dep_null = dependency('', required : false) cc = meson.get_compiler('c') prog_py = import('python').find_installation() @@ -106,6 +110,12 @@ with_glx = true endif +with_hgl = false +if get_option('hgl') and host_machine.system() in ['haiku'] + add_languages('cpp') + with_hgl = true +endif + if cc.compiles('typeof(int *);', name : 'typeof') add_project_arguments('-DHAVE_TYPEOF', language : ['c']) endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/meson_options.txt new/libglvnd-1.7.0/meson_options.txt --- old/libglvnd-1.6.0/meson_options.txt 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/meson_options.txt 2023-09-12 16:02:00.000000000 +0200 @@ -43,6 +43,12 @@ description : 'Support the GLX platform.' ) option( + 'hgl', + type : 'boolean', + value : true, + description : 'Support the Haiku GL platform.' +) +option( 'gles1', type : 'boolean', value : true, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/src/EGL/libeglcurrent.c new/libglvnd-1.7.0/src/EGL/libeglcurrent.c --- old/libglvnd-1.6.0/src/EGL/libeglcurrent.c 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/src/EGL/libeglcurrent.c 2023-09-12 16:02:00.000000000 +0200 @@ -100,6 +100,8 @@ if (doReset) { __glvndPthreadFuncs.mutex_init(¤tStateListMutex, NULL); + } else { + __glvndPthreadFuncs.key_delete(threadStateKey); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/src/EGL/meson.build new/libglvnd-1.7.0/src/EGL/meson.build --- old/libglvnd-1.6.0/src/EGL/meson.build 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/src/EGL/meson.build 2023-09-12 16:02:00.000000000 +0200 @@ -29,6 +29,21 @@ gnu_symbol_visibility : 'hidden', ) +if host_machine.system() in ['haiku'] + # A booted Haiku system has a rigid directory structure. + # non-packaged prefixes are like local where the user can modify the contents. + # Anything missing "non-packaged" is read-only and populated by our software packages. + # Anything in system is system installed software, anything in home is user installed + egl_vendor_config_dirs = '/boot/home/config/non-packaged/add-ons/opengl/egl_vendor.d' + egl_vendor_config_dirs += ':/boot/home/config/add-ons/opengl/egl_vendor.d' + egl_vendor_config_dirs += ':/boot/system/non-packaged/add-ons/opengl/egl_vendor.d' + egl_vendor_config_dirs += ':/boot/system/add-ons/opengl/egl_vendor.d' +else + egl_vendor_config_dirs = '@0@/glvnd/egl_vendor.d:@1@/glvnd/egl_vendor.d'.format( + join_paths(get_option('prefix'),get_option('sysconfdir')), + join_paths(get_option('prefix'),get_option('datadir'))) +endif + libEGL = shared_library( 'EGL', [ @@ -39,9 +54,7 @@ 'libeglerror.c', ], c_args : [ - '-DDEFAULT_EGL_VENDOR_CONFIG_DIRS="@0@/glvnd/egl_vendor.d:@1@/glvnd/egl_vendor.d"'.format( - join_paths(get_option('prefix'), get_option('sysconfdir')), - join_paths(get_option('prefix'), get_option('datadir'))), + '-DDEFAULT_EGL_VENDOR_CONFIG_DIRS="@0@"'.format(egl_vendor_config_dirs) ], include_directories : inc_include, link_args : '-Wl,-Bsymbolic', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/src/HGL/.gitignore new/libglvnd-1.7.0/src/HGL/.gitignore --- old/libglvnd-1.6.0/src/HGL/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/libglvnd-1.7.0/src/HGL/.gitignore 2023-09-12 16:02:00.000000000 +0200 @@ -0,0 +1,2 @@ +g_glapi_mapi_gl_tmp.h +g_libglglxwrapper.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/src/HGL/BitmapHook.h new/libglvnd-1.7.0/src/HGL/BitmapHook.h --- old/libglvnd-1.6.0/src/HGL/BitmapHook.h 1970-01-01 01:00:00.000000000 +0100 +++ new/libglvnd-1.7.0/src/HGL/BitmapHook.h 2023-09-12 16:02:00.000000000 +0200 @@ -0,0 +1,17 @@ +/* + * Copyright 2022-2023, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#pragma once + +#include <stdint.h> + +class BBitmap; + +class BitmapHook { +public: + virtual ~BitmapHook() {}; + virtual void GetSize(uint32_t &width, uint32_t &height) = 0; + virtual BBitmap *SetBitmap(BBitmap *bmp) = 0; +}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/src/HGL/GLView.cpp new/libglvnd-1.7.0/src/HGL/GLView.cpp --- old/libglvnd-1.6.0/src/HGL/GLView.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/libglvnd-1.7.0/src/HGL/GLView.cpp 2023-09-12 16:02:00.000000000 +0200 @@ -0,0 +1,580 @@ +/* + * Copyright 2006-2023, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jérôme Duval, [email protected] + * Philippe Houdoin, [email protected] + * Stefano Ceccherini, [email protected] + * X512, [email protected] + * Alexander von Gluck IV, [email protected] + */ + +#include <kernel/image.h> + +#define EGL_EGL_PROTOTYPES 0 +#include <GLView.h> +#include <EGL/egl.h> + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <dlfcn.h> +#include <algorithm> + +#include <DirectWindow.h> +#include <Referenceable.h> + +#include <private/interface/DirectWindowPrivate.h> +#include <private/shared/AutoDeleter.h> +#include <private/shared/AutoLocker.h> +#include <private/shared/PthreadMutexLocker.h> + +#include "BitmapHook.h" + + +struct glview_direct_info { + direct_buffer_info* direct_info; + bool direct_connected; + bool enable_direct_mode; + + glview_direct_info(); + ~glview_direct_info(); +}; + +#define LIBEGL_HOOK_LIST(REQUIRED) \ + REQUIRED(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress) \ + REQUIRED(PFNEGLGETDISPLAYPROC, eglGetDisplay) \ + REQUIRED(PFNEGLINITIALIZEPROC, eglInitialize) \ + REQUIRED(PFNEGLCHOOSECONFIGPROC, eglChooseConfig) \ + REQUIRED(PFNEGLBINDAPIPROC, eglBindAPI) \ + REQUIRED(PFNEGLCREATECONTEXTPROC, eglCreateContext) \ + REQUIRED(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext) \ + REQUIRED(PFNEGLMAKECURRENTPROC, eglMakeCurrent) \ + REQUIRED(PFNEGLTERMINATEPROC, eglTerminate) \ + REQUIRED(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers) \ + REQUIRED(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface) \ + REQUIRED(PFNEGLCREATEPBUFFERSURFACEPROC, eglCreatePbufferSurface) \ + REQUIRED(PFNEGLDESTROYSURFACEPROC, eglDestroySurface) \ + REQUIRED(PFNEGLGETCURRENTCONTEXTPROC, eglGetCurrentContext) \ + REQUIRED(PFNEGLGETCURRENTDISPLAYPROC, eglGetCurrentDisplay) + + +class BGLView::Display : public BReferenceable { +public: +#define DISPATCH_TABLE_ENTRY(x, y) x y {}; + LIBEGL_HOOK_LIST(DISPATCH_TABLE_ENTRY) +#undef DISPATCH_TABLE_ENTRY + + EGLDisplay eglDpy {}; + EGLConfig eglCfg {}; + +private: + status_t Init(); + + pthread_mutex_t fLock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; + status_t fStatus = B_NO_INIT; + void *libEgl {}; + +protected: + virtual void FirstReferenceAcquired(); + virtual void LastReferenceReleased(); + +public: + Display(); + virtual ~Display() = default; + + status_t InitCheck(); +}; + + +struct BGLView::Renderer { + BGLView *view; + + BReference<Display> display; + + EGLContext eglCtx = EGL_NO_CONTEXT; + EGLSurface eglSurf = EGL_NO_SURFACE; + uint32_t width = 0; + uint32_t height = 0; + + class BitmapHook: public ::BitmapHook { + private: + inline Renderer *Base() {return (Renderer*)((char*)this - offsetof(Renderer, fBmpHook));} + + public: + virtual ~BitmapHook() {}; + void GetSize(uint32_t &width, uint32_t &height) override; + BBitmap *SetBitmap(BBitmap *bmp) override; + } fBmpHook; + pthread_mutex_t fLock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; + ObjectDeleter<BBitmap> fBitmap; + + ~Renderer(); + status_t Init(); + void SwapBuffers(); +}; + + +BGLView::Display BGLView::sDisplay; + + +BGLView::Display::Display() +{ + fReferenceCount = 0; +} + +status_t BGLView::Display::InitCheck() +{ + PthreadMutexLocker lock(&fLock); + return fStatus; +} + +void BGLView::Display::FirstReferenceAcquired() +{ + PthreadMutexLocker lock(&fLock); + fStatus = Init(); +} + +void BGLView::Display::LastReferenceReleased() +{ + PthreadMutexLocker lock(&fLock); + + if (fStatus < B_OK) + return; + + fStatus = B_NO_INIT; + + if (eglDpy == eglGetCurrentDisplay()) + eglMakeCurrent(eglDpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + eglTerminate(eglDpy); eglDpy = NULL; + dlclose(libEgl); libEgl = NULL; +} + +status_t BGLView::Display::Init() +{ + libEgl = dlopen("libEGL.so.1", RTLD_LOCAL); + if (libEgl == NULL) { + fprintf(stderr, "[!] libEGL.so.1 not found\n"); + return B_ERROR; + } + +#define DISPATCH_TABLE_ENTRY(x, y) \ + *(void**)&y = dlsym(libEgl, #y); \ + if (y == NULL) { \ + fprintf(stderr, "[!] libEGL symbol " #y " not found\n"); \ + return B_ERROR; \ + } + LIBEGL_HOOK_LIST(DISPATCH_TABLE_ENTRY) +#undef DISPATCH_TABLE_ENTRY + + eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (eglDpy == EGL_NO_DISPLAY) { + fprintf(stderr, "[!] eglGetDisplay failed to obtain EGL_DEFAULT_DISPLAY\n"); + return B_ERROR; + } + + EGLint major, minor; + EGLBoolean result = eglInitialize(eglDpy, &major, &minor); + if (result != EGL_TRUE) { + fprintf(stderr, "[!] eglInitialize failed for EGL_DEFAULT_DISPLAY\n"); + return B_ERROR; + } + + EGLint numConfigs; + static const EGLint configAttribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_BLUE_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_RED_SIZE, 8, + EGL_DEPTH_SIZE, 8, + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, + EGL_NONE + }; + result = eglChooseConfig(eglDpy, configAttribs, &eglCfg, 1, &numConfigs); + if (result != EGL_TRUE || numConfigs <= 0) { + fprintf(stderr, "[!] eglChooseDisplay failed\n"); + return B_ERROR; + } + + return B_OK; +} + +void BGLView::Renderer::BitmapHook::GetSize(uint32_t &width, uint32_t &height) +{ + PthreadMutexLocker lock(&Base()->fLock); + width = Base()->width; + height = Base()->height; +} + +BBitmap *BGLView::Renderer::BitmapHook::SetBitmap(BBitmap *bmp) +{ + PthreadMutexLocker lock(&Base()->fLock); + BBitmap* oldBmp = Base()->fBitmap.Detach(); + Base()->fBitmap.SetTo(bmp); + BMessenger(Base()->view).SendMessage(B_INVALIDATE); + return oldBmp; +} + +status_t BGLView::Renderer::Init() +{ + display = &BGLView::sDisplay; + if (display->InitCheck() < B_OK) + return display->InitCheck(); + + EGLContext shareCtx = EGL_NO_CONTEXT; + if ((view->fOptions & BGL_SHARE_CONTEXT) != 0) { + shareCtx = display->eglGetCurrentContext(); + } + + EGLBoolean result = display->eglBindAPI(EGL_OPENGL_API); + if (result != EGL_TRUE) { + fprintf(stderr, "[!] eglBindAPI failed\n"); + return B_ERROR; + } + + eglCtx = display->eglCreateContext(display->eglDpy, display->eglCfg, shareCtx, NULL); + if (eglCtx == NULL) { + fprintf(stderr, "[!] eglCreateContext failed\n"); + return B_ERROR; + } + + BRect viewFrame = view->Frame(); + width = (uint32_t)viewFrame.Width() + 1; + height = (uint32_t)viewFrame.Height() + 1; + + eglSurf = display->eglCreateWindowSurface(display->eglDpy, display->eglCfg, + (EGLNativeWindowType)&fBmpHook, NULL); + if (eglSurf == NULL) { + fprintf(stderr, "[!] eglCreateWindowSurface failed\n"); + return B_ERROR; + } + + return B_OK; +} + +BGLView::Renderer::~Renderer() +{ + if (display->InitCheck() < B_OK) + return; + + if (display->eglDpy == display->eglGetCurrentDisplay() + && eglCtx == display->eglGetCurrentContext()) + display->eglMakeCurrent(display->eglDpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (eglSurf != EGL_NO_SURFACE) { + display->eglDestroySurface(display->eglDpy, eglSurf); + eglSurf = EGL_NO_SURFACE; + } + + if (eglCtx != EGL_NO_CONTEXT) { + display->eglDestroyContext(display->eglDpy, eglCtx); + eglCtx = EGL_NO_CONTEXT; + } +} + +void BGLView::Renderer::SwapBuffers() +{ + display->eglSwapBuffers(display->eglDpy, eglSurf); +} + +// #pragma mark - + +BGLView::BGLView(BRect rect, const char* name, ulong resizingMode, ulong mode, + ulong options) + : + BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS), + fGc(NULL), + fOptions(options), + fDrawLock("BGLView draw lock"), + fDisplayLock("BGLView display lock"), + fClipInfo(NULL), + fRenderer(new Renderer{.view = this}) +{ + if (fRenderer->Init() < B_OK) { + delete fRenderer; + fRenderer = NULL; + } +} + +// BeOS compatibility: contrary to others BView's contructors, +// BGLView one wants a non-const name argument. +BGLView::BGLView(BRect rect, char* name, ulong resizingMode, ulong mode, + ulong options) + : + BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS), + fGc(NULL), + fOptions(options), + fDrawLock("BGLView draw lock"), + fDisplayLock("BGLView display lock"), + fClipInfo(NULL), + fRenderer(new Renderer{.view = this}) +{ + if (fRenderer->Init() < B_OK) { + delete fRenderer; + fRenderer = NULL; + } +} + +BGLView::~BGLView() +{ + delete fRenderer; + delete fClipInfo; +} + +void +BGLView::LockGL() +{ + fDisplayLock.Lock(); + if (fDisplayLock.CountLocks() == 1) { + fRenderer->display->eglMakeCurrent(fRenderer->display->eglDpy, fRenderer->eglSurf, + fRenderer->eglSurf, fRenderer->eglCtx); + } +} + +void +BGLView::UnlockGL() +{ + thread_id lockerThread = fDisplayLock.LockingThread(); + thread_id callerThread = find_thread(NULL); + + if (lockerThread != B_ERROR && lockerThread != callerThread) { + printf("UnlockGL is called from wrong thread, lockerThread: %d, callerThread: %d\n", + (int)lockerThread, (int)callerThread); + } + + if (fDisplayLock.CountLocks() == 1) { + fRenderer->display->eglMakeCurrent(fRenderer->display->eglDpy, EGL_NO_SURFACE, + EGL_NO_SURFACE, EGL_NO_CONTEXT); + } + fDisplayLock.Unlock(); +} + +void +BGLView::SwapBuffers() +{ + SwapBuffers(false); +} + +void +BGLView::SwapBuffers(bool vSync) +{ + _LockDraw(); + fRenderer->SwapBuffers(); + _UnlockDraw(); +} + + +BView* +BGLView::EmbeddedView() +{ + return NULL; +} + +void* +BGLView::GetGLProcAddress(const char* procName) +{ + return (void*)fRenderer->display->eglGetProcAddress(procName); +} + +status_t +BGLView::CopyPixelsOut(BPoint source, BBitmap* dest) +{ + if (!dest || !dest->Bounds().IsValid()) + return B_BAD_VALUE; + + return ENOSYS; +} + +status_t +BGLView::CopyPixelsIn(BBitmap* source, BPoint dest) +{ + if (!source || !source->Bounds().IsValid()) + return B_BAD_VALUE; + + return ENOSYS; +} + +/*! Mesa's GLenum is not ulong but uint, so we can't use GLenum + without breaking this method signature. + Instead, we have to use the effective BeOS's SGI OpenGL GLenum type: + unsigned long. + */ +void +BGLView::ErrorCallback(unsigned long errorCode) +{ + char msg[32]; + sprintf(msg, "GL: Error code $%04lx.", errorCode); + // TODO: under BeOS R5, it call debugger(msg); + fprintf(stderr, "%s\n", msg); +} + +void +BGLView::Draw(BRect updateRect) +{ + BRegion region(updateRect); + PthreadMutexLocker lock(&fRenderer->fLock); + if (fRenderer->fBitmap.IsSet()) { + DrawBitmap(fRenderer->fBitmap.Get(), B_ORIGIN); + region.Exclude(fRenderer->fBitmap->Bounds()); + } + FillRegion(®ion, B_SOLID_LOW); +} + +void +BGLView::AttachedToWindow() +{ + BView::AttachedToWindow(); + + { + PthreadMutexLocker lock(&fRenderer->fLock); + fRenderer->width = Bounds().IntegerWidth() + 1; + fRenderer->height = Bounds().IntegerHeight() + 1; + } + + // Set default OpenGL viewport: + LockGL(); + glViewport(0, 0, Bounds().IntegerWidth() + 1, Bounds().IntegerHeight() + 1); + UnlockGL(); +} + +void BGLView::GetPreferredSize(float* _width, float* _height) +{ + if (_width) + *_width = 0; + if (_height) + *_height = 0; +} + +void +BGLView::DirectConnected(direct_buffer_info* info) +{ +} + + +void +BGLView::EnableDirectMode(bool enabled) +{ +} + +void BGLView::FrameResized(float width, float height) +{ + BView::FrameResized(width, height); + PthreadMutexLocker lock(&fRenderer->fLock); + fRenderer->width = (uint32_t)width + 1; + fRenderer->height = (uint32_t)height + 1; +} + + +// forward to base class +void BGLView::AllAttached() { + BView::AllAttached(); +} + +void BGLView::DetachedFromWindow() { + BView::DetachedFromWindow(); +} + +void BGLView::AllDetached() { + BView::AllDetached(); +} + +status_t BGLView::Perform(perform_code d, void* arg) { + return BView::Perform(d, arg); +} + +status_t BGLView::Archive(BMessage* data, bool deep) const { + return BView::Archive(data, deep); +} + +void BGLView::MessageReceived(BMessage* msg) { + BView::MessageReceived(msg); +} + +void BGLView::SetResizingMode(uint32 mode) { + BView::SetResizingMode(mode); +} + +void BGLView::Show() { + BView::Show(); +} + +void BGLView::Hide() { + BView::Hide(); +} + +BHandler* BGLView::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, + int32 form, const char* property) { + return BView::ResolveSpecifier(msg, index, specifier, form, property); +} + +status_t BGLView::GetSupportedSuites(BMessage* data) { + return BView::GetSupportedSuites(data); +} + +void BGLView::_LockDraw() +{ + if (!fClipInfo || !fClipInfo->enable_direct_mode) + return; + + fDrawLock.Lock(); +} + +void BGLView::_UnlockDraw() +{ + if (!fClipInfo || !fClipInfo->enable_direct_mode) + return; + + fDrawLock.Unlock(); +} + +//---- virtual reserved methods ---------- + +void BGLView::_ReservedGLView1() {} +void BGLView::_ReservedGLView2() {} +void BGLView::_ReservedGLView3() {} +void BGLView::_ReservedGLView4() {} +void BGLView::_ReservedGLView5() {} +void BGLView::_ReservedGLView6() {} +void BGLView::_ReservedGLView7() {} +void BGLView::_ReservedGLView8() {} + +// #pragma mark - + +const char* color_space_name(color_space space) +{ +#define C2N(a) case a: return #a + + switch (space) { + C2N(B_RGB24); + C2N(B_RGB32); + C2N(B_RGBA32); + C2N(B_RGB32_BIG); + C2N(B_RGBA32_BIG); + C2N(B_GRAY8); + C2N(B_GRAY1); + C2N(B_RGB16); + C2N(B_RGB15); + C2N(B_RGBA15); + C2N(B_CMAP8); + default: + return "Unknown!"; + }; + +#undef C2N +}; + +glview_direct_info::glview_direct_info() +{ + // TODO: See direct_window_data() in app_server's ServerWindow.cpp + direct_info = (direct_buffer_info*)calloc(1, DIRECT_BUFFER_INFO_AREA_SIZE); + direct_connected = false; + enable_direct_mode = false; +} + +glview_direct_info::~glview_direct_info() +{ + free(direct_info); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/src/HGL/libgl.c new/libglvnd-1.7.0/src/HGL/libgl.c --- old/libglvnd-1.6.0/src/HGL/libgl.c 1970-01-01 01:00:00.000000000 +0100 +++ new/libglvnd-1.7.0/src/HGL/libgl.c 2023-09-12 16:02:00.000000000 +0200 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013, NVIDIA CORPORATION. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * unaltered in all copies or substantial portions of the Materials. + * Any additions, deletions, or changes to the original source files + * must be clearly indicated in accompanying documentation. + * + * THE MATERIALS ARE 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 + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + */ + +#include <dlfcn.h> +#include <GL/gl.h> +#include "compiler.h" +#include "entry.h" +#include "stub.h" +#include "GLdispatch.h" + +static int patchStubId = -1; + +// Initialize GLX imports +#if defined(USE_ATTRIBUTE_CONSTRUCTOR) +void __attribute__((constructor)) __libGLInit(void) +#else +void _init(void) +#endif +{ + __glDispatchInit(); + + // Register these entrypoints with GLdispatch so they can be overwritten at + // runtime + patchStubId = __glDispatchRegisterStubCallbacks(stub_get_patch_callbacks()); +} + +#if defined(USE_ATTRIBUTE_CONSTRUCTOR) +void __attribute__((destructor)) __libGLFini(void) +#else +void _fini(void) +#endif +{ + // Unregister the GLdispatch entrypoints + stub_cleanup(); + __glDispatchUnregisterStubCallbacks(patchStubId); + __glDispatchFini(); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/src/HGL/meson.build new/libglvnd-1.7.0/src/HGL/meson.build --- old/libglvnd-1.6.0/src/HGL/meson.build 1970-01-01 01:00:00.000000000 +0100 +++ new/libglvnd-1.7.0/src/HGL/meson.build 2023-09-12 16:02:00.000000000 +0200 @@ -0,0 +1,53 @@ + +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# THE MATERIALS ARE 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 +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +dep_be = cc.find_library('be') + +libGL = shared_library( + 'GL', + [ + 'libgl.c', + 'GLView.cpp', + ], + include_directories : [ + inc_include, + inc_include_hgl, + '/boot/system/develop/headers/private/shared' + ], + link_args : '-Wl,-Bsymbolic', + dependencies : [ + dep_dl, idep_gldispatch, idep_glapi_gl, idep_utils_misc, + dep_be + ], + version : '1.0.0', + gnu_symbol_visibility : 'hidden', + install : true, +) + +pkg.generate( + libGL, + filebase : 'gl', + description : 'Legacy OpenGL and HGL library and headers.', + version : '1.2', +) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/src/meson.build new/libglvnd-1.7.0/src/meson.build --- old/libglvnd-1.6.0/src/meson.build 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/src/meson.build 2023-09-12 16:02:00.000000000 +0200 @@ -35,6 +35,10 @@ subdir('GL') endif +if with_hgl + subdir('HGL') +endif + if get_option('gles1') subdir('GLESv1') endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/tests/eglenv.sh new/libglvnd-1.7.0/tests/eglenv.sh --- old/libglvnd-1.6.0/tests/eglenv.sh 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/tests/eglenv.sh 2023-09-12 16:02:00.000000000 +0200 @@ -3,5 +3,11 @@ __EGL_VENDOR_LIBRARY_DIRS=$TOP_SRCDIR/tests/json export __EGL_VENDOR_LIBRARY_DIRS -LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TOP_BUILDDIR/tests/dummy/.libs -export LD_LIBRARY_PATH +PLATFORM=$(uname -s) +if test $PLATFORM -eq "Haiku"; then + LIBRARY_PATH=$LIBRARY_PATH:$TOP_BUILDDIR/tests/dummy/.libs + export LIBRARY_PATH +else + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TOP_BUILDDIR/tests/dummy/.libs + export LD_LIBRARY_PATH +fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libglvnd-1.6.0/tests/meson.build new/libglvnd-1.7.0/tests/meson.build --- old/libglvnd-1.6.0/tests/meson.build 2022-11-21 22:05:30.000000000 +0100 +++ new/libglvnd-1.7.0/tests/meson.build 2023-09-12 16:02:00.000000000 +0200 @@ -60,7 +60,11 @@ suite : ['gldispatch'], ) -_env_ld = 'LD_LIBRARY_PATH=@0@/'.format(dummy_build_dir) +if host_machine.system() in ['haiku'] + _env_ld = 'LIBRARY_PATH=@0@:/boot/system/lib'.format(dummy_build_dir) +else + _env_ld = 'LD_LIBRARY_PATH=@0@'.format(dummy_build_dir) +endif if with_glx env_glx = [
