diff --git a/sys-libs/mesa/mesa-17.1.10.recipe b/sys-libs/mesa/mesa-17.1.10.recipe deleted file mode 100644 index 58d6c6eb8..000000000 --- a/sys-libs/mesa/mesa-17.1.10.recipe +++ /dev/null @@ -1,167 +0,0 @@ -SUMMARY="Multi-platform GL implementation" -DESCRIPTION="Mesa is an open-source implementation of the OpenGL \ -specification. The OpenGL specification documents a system for rendering \ -interactive 3D graphics. Mesa fills the role of the Haiku OpenGL kit \ -providing 3D rendering to Haiku applications." -HOMEPAGE="https://www.mesa3d.org/" -COPYRIGHT="1999-2018 Brian Paul" -LICENSE="MIT" -REVISION="6" -SOURCE_URI="https://mesa.freedesktop.org/archive/mesa-${portVersion}.tar.xz" -CHECKSUM_SHA256="cbc0d681cc4df47d8deb5a36f45b420978128522fd665b2cd4c7096316f11bdb" -PATCHES="mesa-$portVersion.patchset" - -ARCHITECTURES="all !x86_gcc2 ?arm ?ppc" -SECONDARY_ARCHITECTURES="x86" - -libVersion=1.0.0 -libOSMesaVersion=8.0.0 -libVersionCompat="$libVersion compat >= ${libVersion%%.*}" -libOSMesaVersionCompat="$libOSMesaVersion compat >= ${libOSMesaVersion%%.*}" - -PROVIDES=" - mesa$secondaryArchSuffix = $portVersion - lib:libEGL$secondaryArchSuffix = $libVersionCompat - lib:libGL$secondaryArchSuffix = $libVersionCompat - lib:libOSMesa$secondaryArchSuffix = $libOSMesaVersionCompat - " -REQUIRES=" - haiku$secondaryArchSuffix - lib:libz$secondaryArchSuffix - " - -PROVIDES_devel=" - mesa${secondaryArchSuffix}_devel = $portVersion - devel:libEGL$secondaryArchSuffix = $libVersionCompat - devel:libGL$secondaryArchSuffix = $libVersionCompat - devel:libOSMesa$secondaryArchSuffix = $libOSMesaVersionCompat - " -REQUIRES_devel=" - mesa$secondaryArchSuffix == $portVersion base - " - -SUMMARY_swpipe="The Mesa LLVM enhanced Gallium software pipe renderer" -DESCRIPTION_swpipe="This 3D BGLRenderer add-on provides Gallium LLVM \ -enhanced software rendering. Software pipe rendering performs all \ -3D rendering on the systems CPU and doesn't require any specialized \ -hardware. The usage of LLVM over traditional rasterization gives this \ -renderer a boost in performance. - -Gallium software pipe rendering is in an extremely early state as of \ -this version of Mesa, and may not function as expected." - -PROVIDES_swpipe=" - mesa${secondaryArchSuffix}_swpipe = $portVersion - " -REQUIRES_swpipe=" - mesa$secondaryArchSuffix == $portVersion base - lib:libLLVM_7$secondaryArchSuffix - " - -BUILD_REQUIRES=" - haiku${secondaryArchSuffix}_devel - devel:libz$secondaryArchSuffix - devel:libLLVM_7$secondaryArchSuffix - " -BUILD_PREREQUIRES=" - cmd:aclocal - cmd:autoconf - cmd:automake - cmd:llvm_config - cmd:egrep - cmd:gcc$secondaryArchSuffix - cmd:ld$secondaryArchSuffix - cmd:libtoolize$secondaryArchSuffix - cmd:make - cmd:pkg_config$secondaryArchSuffix - cmd:which - " - -defineDebugInfoPackage mesa$secondaryArchSuffix \ - "${addOnsDir/mesa$secondaryArchSuffix/mesa${secondaryArchSuffix}_swpipe}/opengl/Software Pipe" \ - "$libDir"/libEGL.so.$libVersion \ - "$libDir"/libGL.so.$libVersion \ - "$libDir"/libOSMesa.so.$libOSMesaVersion \ - -BUILD() -{ - if [ -n "$secondaryArchSuffix" ]; then - export HAIKU_SECONDARY_ARCH="$effectiveTargetArchitecture" - fi - - autoreconf -fi - # for whatever reason, the llvm_require_version function is busted, so we - # manually patch it here - sed -i 's@"\$LLVM_VERSION_MAJOR" -gt "\$llvm_target_version_major"@true@' configure - sed -i 's@-DHAVE_LLVM=0x0\$LLVM_VERSION_INT@-DHAVE_LLVM=0x0700@' configure - LDFLAGS="-lstdc++" runConfigure ./configure \ - --enable-llvm \ - --disable-dri \ - --disable-glx \ - --disable-glx-tls \ - --disable-gbm \ - --disable-gles1 \ - --disable-gles2 \ - --disable-shared-glapi \ - --with-gallium-drivers=swrast \ - --enable-texture-float \ - --enable-osmesa \ - --with-platforms=haiku - - make $jobArgs -} - -INSTALL() -{ - make install - - rm $libDir/lib*.la - - # Our rendering add-ons - mkdir -p $addOnsDir/opengl - mv $(find $libDir -name 'libswpipe.so') \ - "$addOnsDir/opengl/Software Pipe" - rm -rf $libDir/haiku - - # Set some nice version info - appVersion=${portVersion//\./ } - setversion "$libDir/libGL.so" -app $appVersion -long "Haiku OpenGL kit" - setversion "$libDir/libEGL.so.1" -app $appVersion -long "Mesa EGL" - setversion "$addOnsDir/opengl/Software Pipe" -app $appVersion -long \ - "Gallium LLVM software pipe renderer" - - prepareInstalledDevelLibs \ - libGL libEGL libOSMesa - fixPkgconfig - - # for compatibility - symlinkRelative -s $libDir/libGL.so.1 $libDir/libGL.so - - # OpenGL Kit - mkdir -p $includeDir/os/opengl - cp ./include/HaikuGL/OpenGLKit.h $includeDir/os/ - cp ./include/HaikuGL/GLView.h $includeDir/os/opengl/ - cp ./include/HaikuGL/GLRenderer.h $includeDir/os/opengl/ - - # Create GL symlink in opengl kit - symlinkRelative -s $includeDir/GL $includeDir/os/opengl/GL - # Create EGL symlink in opengl kit - symlinkRelative -s $includeDir/EGL $includeDir/os/opengl/EGL - # Create KHR symlink in opengl kit - symlinkRelative -s $includeDir/KHR $includeDir/os/opengl/KHR - - # devel package - packageEntries devel \ - $developDir - - # swpipe renderer package - packageEntries swpipe \ - "$addOnsDir/opengl/Software Pipe" - - rmdir "$addOnsDir"/opengl -} - -TEST() -{ - make check -} diff --git a/sys-libs/mesa/mesa-21.0.3.recipe b/sys-libs/mesa/mesa-21.2.3.recipe similarity index 94% rename from sys-libs/mesa/mesa-21.0.3.recipe rename to sys-libs/mesa/mesa-21.2.3.recipe index 64f83435b..a04eb9d93 100644 --- a/sys-libs/mesa/mesa-21.0.3.recipe +++ b/sys-libs/mesa/mesa-21.2.3.recipe @@ -8,12 +8,12 @@ COPYRIGHT="1999-2021 Brian Paul" LICENSE="MIT" REVISION="1" SOURCE_URI="https://mesa.freedesktop.org/archive/mesa-${portVersion}.tar.xz" -CHECKSUM_SHA256="565c6f4bd2d5747b919454fc1d439963024fc78ca56fd05158c3b2cde2f6912b" +CHECKSUM_SHA256="7245284a159d2484770e1835a673e79e4322a9ddf43b17859668244946db7174" SOURCE_DIR="mesa-${portVersion}" -#PATCHES="mesa-${portVersion}.patchset" +PATCHES="mesa-$portVersion.patchset" -ARCHITECTURES="?all !x86_gcc2" -SECONDARY_ARCHITECTURES="?x86" +ARCHITECTURES="all !x86_gcc2" +SECONDARY_ARCHITECTURES="x86" libVersion=1.0.0 libOSMesaVersion=8.0.0 @@ -75,7 +75,7 @@ BUILD_REQUIRES=" " BUILD_PREREQUIRES=" python3$secondaryArchSuffix - mako_python3$secondaryArchSuffix + mako_python3 cmd:ninja cmd:bison cmd:find @@ -104,8 +104,9 @@ BUILD() mkdir -p build meson build -Dosmesa=true -Degl=true -Dgallium-drivers=swrast \ + --buildtype=release \ --prefix=$prefix \ - --libdir=$libDir \ + --libdir=$libDir \ --includedir=$includeDir ninja -C build $jobArgs } diff --git a/sys-libs/mesa/patches/mesa-17.1.10.patchset b/sys-libs/mesa/patches/mesa-17.1.10.patchset deleted file mode 100644 index beb2d742b..000000000 --- a/sys-libs/mesa/patches/mesa-17.1.10.patchset +++ /dev/null @@ -1,793 +0,0 @@ -From bf51cc6f0cc89c0e159e472fd3ce108f28a28cec Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Mon, 11 Sep 2017 21:29:14 +0200 -Subject: Haiku patch - - -diff --git a/configure.ac b/configure.ac -index 3be6f54..e05f4d6 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -272,6 +272,9 @@ case "$host_os" in - *-android*) - android=yes - ;; -+*haiku) -+ haiku=yes -+ ;; - linux*|*-gnu*|gnu*|cygwin*) - DEFINES="$DEFINES -D_GNU_SOURCE" - ;; -@@ -281,6 +284,7 @@ solaris*) - esac - - AM_CONDITIONAL(HAVE_ANDROID, test "x$android" = xyes) -+AM_CONDITIONAL(HAVE_HAIKU, test "x$haiku" = xyes) - - dnl Add flags for gcc and g++ - if test "x$GCC" = xyes; then -@@ -862,12 +866,18 @@ dnl According to the manual when using pthreads, one should add -pthread to - dnl both compile and link-time arguments. - dnl In practise that should be sufficient for all platforms, since any - dnl platforms build with GCC and Clang support the flag. --PTHREAD_LIBS="$PTHREAD_LIBS -pthread" -+case "$host_os" in -+haiku*) -+ ;; -+* ) -+ PTHREAD_LIBS="$PTHREAD_LIBS -pthread" -+ ;; -+esac - - dnl pthread-stubs is mandatory on BSD platforms, due to the nature of the - dnl project. Even then there's a notable issue as described in the project README - case "$host_os" in --linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu*) -+linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu* | haiku*) - pthread_stubs_possible="no" - ;; - * ) -@@ -1511,11 +1521,21 @@ require_dri_shared_libs_and_glapi() { - if test "x$enable_dri" != xyes; then - # There is only a single backend which won't be build/used otherwise. - # XXX: Revisit this as the egl/haiku is a thing. -- AC_MSG_ERROR([$1 requires --enable-dri]) -+ case "$host_os" in -+ haiku*) -+ ;; -+ *) -+ AC_MSG_ERROR([$1 requires --enable-dri]) ;; -+ esac - fi - - if test "x$enable_shared_glapi" != xyes; then -- AC_MSG_ERROR([$1 requires --enable-shared-glapi]) -+ case "$host_os" in -+ haiku*) -+ ;; -+ *) -+ AC_MSG_ERROR([$1 requires --enable-shared-glapi]) ;; -+ esac - fi - } - -@@ -1731,6 +1751,10 @@ for plat in $platforms; do - DEFINES="$DEFINES -DHAVE_ANDROID_PLATFORM" - ;; - -+ haiku) -+ DEFINES="$DEFINES -DHAVE_HAIKU_PLATFORM" -+ ;; -+ - *) - AC_MSG_ERROR([platform '$plat' does not exist]) - ;; -@@ -2790,6 +2814,7 @@ AC_CONFIG_FILES([Makefile - src/gallium/state_trackers/clover/Makefile - src/gallium/state_trackers/dri/Makefile - src/gallium/state_trackers/glx/xlib/Makefile -+ src/gallium/state_trackers/hgl/Makefile - src/gallium/state_trackers/nine/Makefile - src/gallium/state_trackers/omx/Makefile - src/gallium/state_trackers/osmesa/Makefile -@@ -2800,6 +2825,7 @@ AC_CONFIG_FILES([Makefile - src/gallium/targets/d3dadapter9/Makefile - src/gallium/targets/d3dadapter9/d3d.pc - src/gallium/targets/dri/Makefile -+ src/gallium/targets/haiku-softpipe/Makefile - src/gallium/targets/libgl-xlib/Makefile - src/gallium/targets/omx/Makefile - src/gallium/targets/opencl/Makefile -@@ -2823,6 +2849,7 @@ AC_CONFIG_FILES([Makefile - src/gallium/winsys/amdgpu/drm/Makefile - src/gallium/winsys/svga/drm/Makefile - src/gallium/winsys/sw/dri/Makefile -+ src/gallium/winsys/sw/hgl/Makefile - src/gallium/winsys/sw/kms-dri/Makefile - src/gallium/winsys/sw/null/Makefile - src/gallium/winsys/sw/wrapper/Makefile -@@ -2838,6 +2865,8 @@ AC_CONFIG_FILES([Makefile - src/glx/windows/Makefile - src/glx/windows/windowsdriproto.pc - src/gtest/Makefile -+ src/hgl/Makefile -+ src/hgl/gl.pc - src/intel/Makefile - src/loader/Makefile - src/mapi/Makefile -diff --git a/src/Makefile.am b/src/Makefile.am -index aa5f8aa..91439df 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -113,6 +113,10 @@ if HAVE_PLATFORM_WAYLAND - SUBDIRS += egl/wayland/wayland-egl - endif - -+if HAVE_HAIKU -+SUBDIRS += hgl -+endif -+ - if HAVE_EGL - SUBDIRS += egl - endif -diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am -index 8109038..07c2a16 100644 ---- a/src/egl/Makefile.am -+++ b/src/egl/Makefile.am -@@ -45,6 +45,7 @@ libEGL_common_la_LIBADD = \ - - dri2_backend_FILES = - dri3_backend_FILES = -+haiku_backend_FILES = - - if HAVE_PLATFORM_X11 - AM_CFLAGS += $(XCB_DRI2_CFLAGS) -@@ -83,6 +84,22 @@ libEGL_common_la_LIBADD += $(ANDROID_LIBS) - dri2_backend_FILES += drivers/dri2/platform_android.c - endif - -+if HAVE_HAIKU -+AM_CPPFLAGS = \ -+ -I$(top_srcdir)/include \ -+ -I$(top_srcdir)/include/HaikuGL \ -+ -I$(top_srcdir)/src/egl/main \ -+ -I$(top_srcdir)/src/ \ -+ -D_EGL_BUILT_IN_DRIVER_HAIKU \ -+ -D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) -+haiku_backend_FILES += drivers/haiku/egl_haiku.cpp -+libEGL_common_la_LIBADD += $(top_builddir)/src/hgl/libGL.la -+libEGL_common_la_SOURCES += \ -+ $(haiku_backend_FILES) -+ -+endif -+ -+if !HAVE_HAIKU - AM_CFLAGS += \ - -I$(top_srcdir)/src/loader \ - -I$(top_srcdir)/src/egl/drivers/dri2 \ -@@ -121,6 +138,8 @@ g_egldispatchstubs.h: $(GLVND_GEN_DEPS) - BUILT_SOURCES = g_egldispatchstubs.c g_egldispatchstubs.h - CLEANFILES = $(BUILT_SOURCES) - -+endif -+ - if USE_LIBGLVND - AM_CFLAGS += \ - $(GLVND_CFLAGS) -@@ -177,7 +196,6 @@ TESTS = egl-symbols-check \ - EXTRA_DIST = \ - $(TESTS) \ - SConscript \ -- drivers/haiku \ - main/egl.def \ - main/README.txt \ - $(GLVND_GEN_DEPS) \ -diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am -index 38da63b..49b457d 100644 ---- a/src/gallium/Makefile.am -+++ b/src/gallium/Makefile.am -@@ -110,6 +110,10 @@ if HAVE_DRISW_KMS - SUBDIRS += winsys/sw/kms-dri - endif - -+if HAVE_HAIKU -+SUBDIRS += winsys/sw/hgl -+endif -+ - SUBDIRS += winsys/sw/wrapper - - ## -@@ -173,6 +177,10 @@ if HAVE_ST_NINE - SUBDIRS += state_trackers/nine targets/d3dadapter9 - endif - -+if HAVE_HAIKU -+SUBDIRS += state_trackers/hgl targets/haiku-softpipe -+endif -+ - ## - ## Don't forget to bundle the remaining (non autotools) state-trackers/targets - ## -@@ -182,7 +190,6 @@ EXTRA_DIST += \ - state_trackers/README \ - state_trackers/wgl targets/libgl-gdi \ - targets/graw-gdi targets/graw-null targets/graw-xlib \ -- state_trackers/hgl targets/haiku-softpipe \ - tools - - -diff --git a/src/gallium/state_trackers/hgl/Makefile.am b/src/gallium/state_trackers/hgl/Makefile.am -new file mode 100644 -index 0000000..5b55be8 ---- /dev/null -+++ b/src/gallium/state_trackers/hgl/Makefile.am -@@ -0,0 +1,39 @@ -+# Copyright © 2017 Haiku, Inc. All rights reserved. -+# -+# 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 Makefile.sources -+include $(top_srcdir)/src/gallium/Automake.inc -+ -+ -+AM_CPPFLAGS = \ -+ -I$(top_srcdir)/src \ -+ -I$(top_srcdir)/src/mapi \ -+ -I$(top_srcdir)/src/mesa \ -+ -I$(top_srcdir)/include/HaikuGL \ -+ $(GALLIUM_CFLAGS) -+ -+noinst_LTLIBRARIES = libhgl.la -+libhgl_la_LIBADD = -ltranslation -+libhgl_la_SOURCES = $(common_SOURCES) -+ -+ -+EXTRA_DIST = SConscript -diff --git a/src/gallium/state_trackers/hgl/Makefile.sources b/src/gallium/state_trackers/hgl/Makefile.sources -new file mode 100644 -index 0000000..3076ba3 ---- /dev/null -+++ b/src/gallium/state_trackers/hgl/Makefile.sources -@@ -0,0 +1,3 @@ -+common_SOURCES := \ -+ hgl.c \ -+ bitmap_wrapper.cpp -diff --git a/src/gallium/targets/haiku-softpipe/Makefile.am b/src/gallium/targets/haiku-softpipe/Makefile.am -new file mode 100644 -index 0000000..94599a3 ---- /dev/null -+++ b/src/gallium/targets/haiku-softpipe/Makefile.am -@@ -0,0 +1,69 @@ -+include $(top_srcdir)/src/gallium/Automake.inc -+ -+AM_CPPFLAGS = \ -+ -I$(top_srcdir)/src/mapi \ -+ -I$(top_srcdir)/src/mesa \ -+ -I$(top_srcdir)/src/mesa/main \ -+ -I$(top_srcdir)/include/HaikuGL \ -+ -I$(top_srcdir)/src/gallium/include \ -+ -I$(top_srcdir)/src/gallium/winsys \ -+ -I$(top_srcdir)/src/gallium/state_trackers/hgl \ -+ -I/boot/system/develop/headers/private \ -+ $(GALLIUM_TARGET_CFLAGS) \ -+ $(DEFINES) \ -+ -DGALLIUM_SOFTPIPE \ -+ -DGALLIUM_RBUG \ -+ -DGALLIUM_TRACE -+ -+hswpipedir = ${libdir}/haiku -+hswpipe_LTLIBRARIES = libswpipe.la -+ -+libswpipe_la_SOURCES = \ -+ GalliumContext.cpp \ -+ SoftwareRenderer.cpp -+ -+libswpipe_la_LDFLAGS = \ -+ -shared \ -+ -shrext .so \ -+ -module \ -+ -avoid-version \ -+ $(GC_SECTIONS) -+ -+libswpipe_la_LIBADD = \ -+ $(top_builddir)/src/hgl/libGL.la \ -+ $(top_builddir)/src/gallium/winsys/sw/hgl/libswhgl.la \ -+ $(top_builddir)/src/gallium/state_trackers/hgl/libhgl.la \ -+ $(top_builddir)/src/gallium/drivers/rbug/librbug.la \ -+ $(top_builddir)/src/gallium/drivers/trace/libtrace.la \ -+ $(top_builddir)/src/gallium/auxiliary/libgallium.la \ -+ $(top_builddir)/src/mesa/libmesagallium.la \ -+ $(top_builddir)/src/gallium/drivers/softpipe/libsoftpipe.la \ -+ $(GALLIUM_COMMON_LIB_DEPS) \ -+ -lnetwork -+ -+EXTRA_DIST = \ -+ SConscript -+ -+TARGET_DRIVERS = -+TARGET_CPPFLAGS = -+TARGET_LIB_DEPS = -+ -+include $(top_srcdir)/src/gallium/drivers/softpipe/Automake.inc -+include $(top_srcdir)/src/gallium/drivers/llvmpipe/Automake.inc -+include $(top_srcdir)/src/gallium/drivers/swr/Automake.inc -+ -+ -+if HAVE_GALLIUM_LLVM -+AM_CPPFLAGS += -DGALLIUM_LLVMPIPE -+ -+libswpipe_la_LIBADD += $(LLVM_LIBS) \ -+ $(top_builddir)/src/gallium/drivers/llvmpipe/libllvmpipe.la -+libswpipe_la_LDFLAGS += $(LLVM_LDFLAGS) -+endif -+ -+if HAVE_GALLIUM_SWR -+AM_CPPFLAGS += -DGALLIUM_SWR -+ -+libswpipe_la_LIBADD += \ -+ $(top_builddir)/src/gallium/drivers/swr/libmesaswr.la -+endif -diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -index 18cb1ac..4e4888a 100644 ---- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -+++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -@@ -33,6 +33,8 @@ - - extern const char* color_space_name(color_space space); - -+#undef _EXPORT -+#define _EXPORT __attribute__((__visibility__("default"))) - - extern "C" _EXPORT BGLRenderer* - instantiate_gl_renderer(BGLView *view, ulong opts, BGLDispatcher *dispatcher) -diff --git a/src/gallium/winsys/sw/hgl/Makefile.am b/src/gallium/winsys/sw/hgl/Makefile.am -new file mode 100644 -index 0000000..8e5d403 ---- /dev/null -+++ b/src/gallium/winsys/sw/hgl/Makefile.am -@@ -0,0 +1,34 @@ -+# Copyright © 2017 Haiku, Inc. All rights reserved. -+# -+# 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 Makefile.sources -+include $(top_srcdir)/src/gallium/Automake.inc -+ -+AM_CFLAGS = \ -+ -I$(top_srcdir)/src/gallium/state_trackers/hgl \ -+ $(GALLIUM_WINSYS_CFLAGS) -+ -+noinst_LTLIBRARIES = libswhgl.la -+ -+libswhgl_la_SOURCES = $(C_SOURCES) -+ -+EXTRA_DIST = SConscript -diff --git a/src/gallium/winsys/sw/hgl/Makefile.sources b/src/gallium/winsys/sw/hgl/Makefile.sources -new file mode 100644 -index 0000000..52bfc88 ---- /dev/null -+++ b/src/gallium/winsys/sw/hgl/Makefile.sources -@@ -0,0 +1,3 @@ -+C_SOURCES := \ -+ hgl_sw_winsys.c \ -+ hgl_sw_winsys.h -diff --git a/src/hgl/Makefile.am b/src/hgl/Makefile.am -new file mode 100644 -index 0000000..f82602a ---- /dev/null -+++ b/src/hgl/Makefile.am -@@ -0,0 +1,50 @@ -+# Copyright © 2017 Haiku, Inc. All rights reserved. -+# -+# 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 Makefile.sources -+ -+AM_CPPFLAGS = \ -+ -I$(top_srcdir)/src \ -+ -I$(top_srcdir)/src/mapi \ -+ -I$(top_srcdir)/src/mesa \ -+ -I$(top_srcdir)/src/mesa/main \ -+ -I$(top_srcdir)/include/ \ -+ -I$(top_srcdir)/include/HaikuGL \ -+ -I/system/develop/headers/private \ -+ -I$(top_builddir)/src/mapi \ -+ $(DEFINES) -+ -+ -+lib_LTLIBRARIES = libGL.la -+ -+libGL_la_LIBADD = $(top_builddir)/src/mapi/glapi/libglapi.la -lbe -+libGL_la_SOURCES = $(COMMON_SOURCES) -+libGL_la_LDFLAGS = \ -+ -no-undefined \ -+ -version-number 1:0 \ -+ $(BSYMBOLIC) \ -+ $(GC_SECTIONS) \ -+ $(LD_NO_UNDEFINED) -+ -+pkgconfigdir = $(libdir)/pkgconfig -+pkgconfig_DATA = gl.pc -+ -+EXTRA_DIST = -diff --git a/src/hgl/Makefile.sources b/src/hgl/Makefile.sources -new file mode 100644 -index 0000000..5df230b ---- /dev/null -+++ b/src/hgl/Makefile.sources -@@ -0,0 +1,8 @@ -+COMMON_SOURCES := \ -+ GLView.cpp \ -+ GLRenderer.cpp \ -+ GLRendererRoster.cpp \ -+ GLRendererRoster.h \ -+ GLDispatcher.cpp \ -+ GLDispatcher.h -+ -diff --git a/src/hgl/gl.pc.in b/src/hgl/gl.pc.in -new file mode 100644 -index 0000000..7577bae ---- /dev/null -+++ b/src/hgl/gl.pc.in -@@ -0,0 +1,11 @@ -+prefix=@prefix@ -+exec_prefix=${prefix} -+libdir=@libdir@ -+includedir=@includedir@ -+ -+Name: gl -+Description: Mesa OpenGL library -+Version: @PACKAGE_VERSION@ -+Libs: -L${libdir} -lGL -+Libs.private: @GL_PC_LIB_PRIV@ -+Cflags: -I${includedir} @GL_PC_CFLAGS@ -diff --git a/src/mapi/glapi/glapi_dispatch.c b/src/mapi/glapi/glapi_dispatch.c -index df907ff..9f21a71 100644 ---- a/src/mapi/glapi/glapi_dispatch.c -+++ b/src/mapi/glapi/glapi_dispatch.c -@@ -144,6 +144,9 @@ GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLf - GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z); - GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer); - -+GL_API void GL_APIENTRY glBlendBarrier (void); -+GL_API void GL_APIENTRY glPrimitiveBoundingBox (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); -+ - /* Enable frame pointer elimination on Windows, otherwise forgetting to add - * APIENTRY to _mesa_* entrypoints will not cause crashes on debug builds, as - * the initial ESP value is saved in the EBP in the function prologue, then --- -2.19.1 - - -From db58020dc4a527d51ba6884f70172c06c0567064 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Michel=20D=C3=A4nzer?= -Date: Wed, 10 May 2017 17:26:07 +0900 -Subject: gallivm: Fix build against LLVM SVN >= r302589 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -deregisterEHFrames doesn't take any parameters anymore. - -Reviewed-by: Vedran Miletić -Reviewed-by: Marek Olšák - -diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp -index 2a388cb..0e4a531 100644 ---- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp -+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp -@@ -342,13 +342,19 @@ class DelegatingJITMemoryManager : public BaseMemoryManager { - virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) { - mgr()->registerEHFrames(Addr, LoadAddr, Size); - } -- virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) { -- mgr()->deregisterEHFrames(Addr, LoadAddr, Size); -- } - #else - virtual void registerEHFrames(llvm::StringRef SectionData) { - mgr()->registerEHFrames(SectionData); - } -+#endif -+#if HAVE_LLVM >= 0x0500 -+ virtual void deregisterEHFrames() { -+ mgr()->deregisterEHFrames(); -+ } -+#elif HAVE_LLVM >= 0x0304 -+ virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) { -+ mgr()->deregisterEHFrames(Addr, LoadAddr, Size); -+ } - #endif - virtual void *getPointerToNamedFunction(const std::string &Name, - bool AbortOnFailure=true) { --- -2.19.1 - - -From 5939a7f627d4444ecd144ea1e0fa6b63dda8981b Mon Sep 17 00:00:00 2001 -From: Augustin Cavalier -Date: Tue, 28 Aug 2018 21:32:38 -0400 -Subject: BGLView: Make LockGL recursive. - -This is the BeOS behavior, and the behavior of TinyGL's BGLView implementation -also. Fixes Flurry and other applications crashing. - -Also initialize fRenderer in the constructor. - -diff --git a/src/hgl/GLView.cpp b/src/hgl/GLView.cpp -index 9ae5b5c..9e01dcc 100644 ---- a/src/hgl/GLView.cpp -+++ b/src/hgl/GLView.cpp -@@ -51,6 +51,7 @@ BGLView::BGLView(BRect rect, const char* name, ulong resizingMode, ulong mode, - fDitherMap(NULL) - { - fRoster = new GLRendererRoster(this, options); -+ fRenderer = fRoster->GetRenderer(); - } - - -@@ -68,7 +69,7 @@ BGLView::LockGL() - // TODO: acquire the OpenGL API lock it on this glview - - fDisplayLock.Lock(); -- if (fRenderer) -+ if (fRenderer != NULL && fDisplayLock.CountLocks() == 1) - fRenderer->LockGL(); - } - -@@ -76,7 +77,7 @@ BGLView::LockGL() - void - BGLView::UnlockGL() - { -- if (fRenderer) -+ if (fRenderer != NULL && fDisplayLock.CountLocks() == 1) - fRenderer->UnlockGL(); - fDisplayLock.Unlock(); - -@@ -189,7 +190,6 @@ BGLView::AttachedToWindow() - for (BView* view = this; view != NULL; view = view->Parent()) - view->ConvertToParent(&fBounds); - -- fRenderer = fRoster->GetRenderer(); - if (fRenderer != NULL) { - // Jackburton: The following code was commented because it doesn't look - // good in "direct" mode: --- -2.19.1 - - -From 1238627607c5b15d80e1f8a166afd2c0f054309d Mon Sep 17 00:00:00 2001 -From: Sergei Reznikov -Date: Tue, 1 Jan 2019 04:21:25 +0300 -Subject: gallivm: Use new LLVM fast-math-flags API - - -diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp -index 0e4a531..768ac74 100644 ---- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp -+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp -@@ -791,7 +791,11 @@ lp_create_builder(LLVMContextRef ctx, enum lp_float_mode float_mode) - llvm::unwrap(builder)->setFastMathFlags(flags); - break; - case LP_FLOAT_MODE_UNSAFE_FP_MATH: -+#if HAVE_LLVM >= 0x0600 -+ flags.setFast(); -+#else - flags.setUnsafeAlgebra(); -+#endif - llvm::unwrap(builder)->setFastMathFlags(flags); - break; - } --- -2.19.1 - - -From 0779209bf54b024b8acbac0b9e32fce67eaa74e5 Mon Sep 17 00:00:00 2001 -From: Sergei Reznikov -Date: Tue, 1 Jan 2019 04:25:19 +0300 -Subject: gallivm: Fix include for LLVMAddPromoteMemoryToRegisterPass - - -diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c -index 9f1ade6..e53dcb7 100644 ---- a/src/gallium/auxiliary/gallivm/lp_bld_init.c -+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c -@@ -40,6 +40,9 @@ - - #include - #include -+#if HAVE_LLVM >= 0x0700 -+#include -+#endif - #include - - --- -2.19.1 - -From fdcea9ca68070bafb72bf4905e68b971bee6554a Mon Sep 17 00:00:00 2001 -From: X512 -Date: Thu, 19 Dec 2019 03:35:55 +0900 -Subject: [PATCH 2/4] Fix rendering area size - ---- - src/gallium/targets/haiku-softpipe/GalliumContext.cpp | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp -index 0356f65..0cf1f1d 100644 ---- a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp -+++ b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp -@@ -376,8 +376,8 @@ GalliumContext::Validate(uint32 width, uint32 height) - return false; - } - -- if (fContext[fCurrentContext]->width != width -- || fContext[fCurrentContext]->height != height) { -+ if (fContext[fCurrentContext]->width != width + 1 -+ || fContext[fCurrentContext]->height != height + 1) { - Invalidate(width, height); - return false; - } -@@ -393,8 +393,8 @@ GalliumContext::Invalidate(uint32 width, uint32 height) - assert(fContext[fCurrentContext]); - - // Update st_context dimensions -- fContext[fCurrentContext]->width = width; -- fContext[fCurrentContext]->height = height; -+ fContext[fCurrentContext]->width = width + 1; -+ fContext[fCurrentContext]->height = height + 1; - - // Is this the best way to invalidate? - p_atomic_inc(&fContext[fCurrentContext]->read->stfbi->stamp); --- -2.24.1 - -From 6bd4156830ceddc56fcc5c03551b7f802b0127fd Mon Sep 17 00:00:00 2001 -From: X512 -Date: Mon, 23 Dec 2019 04:01:22 +0900 -Subject: [PATCH 3/4] fix CopyPixels - ---- - src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -index 4e4888a..881d226 100644 ---- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -+++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -@@ -246,7 +246,7 @@ SoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap) - d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top)) - * bitmap->BytesPerRow()); - d += (uint32) dr.left; -- memcpy(d, s, dr.IntegerWidth() * 4); -+ memcpy(d, s, (dr.IntegerWidth() + 1) * 4); - } - - return B_OK; -@@ -288,7 +288,7 @@ SoftwareRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location) - * fBitmap->BytesPerRow()); - d += (uint32) dr.left; - -- memcpy(d, s, dr.IntegerWidth() * 4); -+ memcpy(d, s, (dr.IntegerWidth() + 1) * 4); - } - - return B_OK; --- -2.24.1 - -From e9ca6f798363f2f5695e754e8e3232fbc591b9d2 Mon Sep 17 00:00:00 2001 -From: X512 -Date: Mon, 23 Dec 2019 04:12:42 +0900 -Subject: [PATCH 4/4] fix artifacts in SwapBuffers for BDirectWindow - ---- - src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -index 881d226..4c584c3 100644 ---- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -+++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp -@@ -183,14 +183,13 @@ SoftwareRenderer::SwapBuffers(bool vsync) - int32 height = clip->bottom - clip->top + 1; - int32 bytesWidth - = (clip->right - clip->left + 1) * bytesPerPixel; -- bytesWidth -= bytesPerPixel; - uint8 *p = (uint8 *)fInfo->bits + clip->top - * fInfo->bytes_per_row + clip->left * bytesPerPixel; - uint8 *b = (uint8 *)fBitmap->Bits() - + (clip->top - fInfo->window_bounds.top) * bytesPerRow - + (clip->left - fInfo->window_bounds.left) * bytesPerPixel; - -- for (int y = 0; y < height - 1; y++) { -+ for (int y = 0; y < height; y++) { - memcpy(p, b, bytesWidth); - p += fInfo->bytes_per_row; - b += bytesPerRow; --- -2.24.1 - -From b3449b964046378676cd6251ab9d937041c86497 Mon Sep 17 00:00:00 2001 -From: X512 -Date: Mon, 23 Dec 2019 04:33:43 +0900 -Subject: [PATCH 5/5] Remove LockGL/UnlockGL in BGLView::FrameResized. Fixes - deadlocks. - ---- - src/hgl/GLView.cpp | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/src/hgl/GLView.cpp b/src/hgl/GLView.cpp -index 9e01dcc..71c4873 100644 ---- a/src/hgl/GLView.cpp -+++ b/src/hgl/GLView.cpp -@@ -260,12 +260,10 @@ BGLView::FrameResized(float width, float height) - v->ConvertToParent(&fBounds); - - if (fRenderer) { -- LockGL(); - _LockDraw(); - _CallDirectConnected(); - fRenderer->FrameResized(width, height); - _UnlockDraw(); -- UnlockGL(); - } - - BView::FrameResized(width, height); --- -2.24.1 - diff --git a/sys-libs/mesa/patches/mesa-21.2.3.patchset b/sys-libs/mesa/patches/mesa-21.2.3.patchset new file mode 100644 index 000000000..b97a3b074 --- /dev/null +++ b/sys-libs/mesa/patches/mesa-21.2.3.patchset @@ -0,0 +1,242 @@ +From b76d3e30001c8500ca57fc5f300ae8ed246989f6 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Sun, 8 Aug 2021 22:34:39 +1000 +Subject: Fix build for Haiku + + +diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c +index 765618f..50de2da 100644 +--- a/src/egl/main/egldisplay.c ++++ b/src/egl/main/egldisplay.c +@@ -53,6 +53,10 @@ + #include "eglimage.h" + #include "eglsync.h" + ++#ifdef __HAIKU__ ++#define static_assert _Static_assert ++#endif ++ + /* Includes for _eglNativePlatformDetectNativeDisplay */ + #ifdef HAVE_WAYLAND_PLATFORM + #include +diff --git a/src/util/disk_cache_os.c b/src/util/disk_cache_os.c +index e93e8c6..5bef62c 100644 +--- a/src/util/disk_cache_os.c ++++ b/src/util/disk_cache_os.c +@@ -164,10 +164,19 @@ choose_lru_file_matching(const char *dir_path, + if (dir == NULL) + return NULL; + ++#ifdef __HAIKU__ ++ struct stat info; ++#endif ++ + /* First count the number of files in the directory */ + unsigned total_file_count = 0; + while ((dir_ent = readdir(dir)) != NULL) { ++#ifdef __HAIKU__ ++ stat(dir_ent->d_name, &info); ++ if (S_ISREG(info.st_mode)) { ++#else + if (dir_ent->d_type == DT_REG) { /* If the entry is a regular file */ ++#endif + total_file_count++; + } + } +diff --git a/src/util/u_thread.h b/src/util/u_thread.h +index 013e8be..a80c2f7 100644 +--- a/src/util/u_thread.h ++++ b/src/util/u_thread.h +@@ -43,10 +43,6 @@ + #endif + #endif + +-#ifdef __HAIKU__ +-#include +-#endif +- + #if DETECT_OS_LINUX && !defined(ANDROID) + #include + #elif defined(_WIN32) && !defined(__CYGWIN__) && _WIN32_WINNT >= 0x0600 +@@ -61,6 +57,11 @@ + #define cpu_set_t cpuset_t + #endif + ++#ifdef __HAIKU__ ++#include ++#undef ALIGN ++#endif ++ + /* For util_set_thread_affinity to size the mask. */ + #define UTIL_MAX_CPUS 1024 /* this should be enough */ + #define UTIL_MAX_L3_CACHES UTIL_MAX_CPUS +@@ -359,11 +360,13 @@ static inline void util_barrier_wait(util_barrier *barrier) + * way), so thread_id's provide an alternative mechanism + */ + ++#ifndef __HAIKU__ + #ifdef _WIN32 + typedef DWORD thread_id; + #else + typedef thrd_t thread_id; + #endif ++#endif + + static inline thread_id + util_get_thread_id(void) +@@ -377,6 +380,8 @@ util_get_thread_id(void) + */ + #ifdef _WIN32 + return GetCurrentThreadId(); ++#elif defined(__HAIKU__) ++ return find_thread(NULL); + #else + return thrd_current(); + #endif +@@ -386,7 +391,7 @@ util_get_thread_id(void) + static inline int + util_thread_id_equal(thread_id t1, thread_id t2) + { +-#ifdef _WIN32 ++#if defined(_WIN32) || defined(__HAIKU__) + return t1 == t2; + #else + return thrd_equal(t1, t2); +-- +2.30.2 + + +From 4c33cd8a70f8d1bbf17e33c8f19fed1562cdfa4d Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Sun, 8 Aug 2021 22:35:54 +1000 +Subject: Add any color_space support + + +diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp +index 96f19ae..6939e53 100644 +--- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp ++++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp +@@ -14,6 +14,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -40,44 +41,50 @@ instantiate_gl_renderer(BGLView *view, ulong opts) + return new SoftwareRenderer(view, opts); + } + +-struct RasBuf32 ++struct RasBuffer + { + int32 width, height, stride; + int32 orgX, orgY; +- int32 *colors; ++ void *colors; ++ color_space pixel_format; ++ int32 pixel_size; + +- RasBuf32(int32 width, int32 height, int32 stride, int32 orgX, int32 orgY, int32 *colors): ++ RasBuffer(int32 width, int32 height, int32 stride, int32 orgX, int32 orgY, void *colors): + width(width), height(height), stride(stride), orgX(orgX), orgY(orgY), colors(colors) + {} + +- RasBuf32(BBitmap *bmp) ++ RasBuffer(BBitmap *bmp) + { + width = bmp->Bounds().IntegerWidth() + 1; + height = bmp->Bounds().IntegerHeight() + 1; +- stride = bmp->BytesPerRow()/4; ++ stride = bmp->BytesPerRow(); + orgX = 0; + orgY = 0; +- colors = (int32*)bmp->Bits(); ++ pixel_format = bmp->ColorSpace(); ++ pixel_size = stride / width; ++ colors = bmp->Bits(); + } + +- RasBuf32(direct_buffer_info *info) ++ RasBuffer(direct_buffer_info *info) + { + width = 0x7fffffff; + height = 0x7fffffff; +- stride = info->bytes_per_row/4; ++ stride = info->bytes_per_row; + orgX = 0; + orgY = 0; +- colors = (int32*)info->bits; ++ pixel_format = info->pixel_format; ++ pixel_size = info->bits_per_pixel / 8; ++ colors = info->bits; + } + + void ClipSize(int32 x, int32 y, int32 w, int32 h) + { + if (x < 0) {w += x; x = 0;} + if (y < 0) {h += y; y = 0;} +- if (x + w > width) {w = width - x;} ++ if (x + w > width) {w = width - x;} + if (y + h > height) {h = height - y;} + if ((w > 0) && (h > 0)) { +- colors += y*stride + x; ++ colors += (y * stride) + (x * pixel_size); + width = w; + height = h; + } else { +@@ -98,27 +105,21 @@ struct RasBuf32 + orgY += dy; + } + +- void Clear(int32 color) ++ void Blit(RasBuffer src) + { +- RasBuf32 dst = *this; +- dst.stride -= dst.width; +- for (; dst.height > 0; dst.height--) { +- for (int32 i = dst.width; i > 0; i--) +- *dst.colors++ = color; +- dst.colors += dst.stride; +- } +- } +- +- void Blit(RasBuf32 src) +- { +- RasBuf32 dst = *this; ++ RasBuffer dst = *this; + int32 x, y; + x = src.orgX - orgX; + y = src.orgY - orgY; + dst.ClipSize(x, y, src.width, src.height); + src.ClipSize(-x, -y, width, height); + for (; dst.height > 0; dst.height--) { +- memcpy(dst.colors, src.colors, 4*dst.width); ++ if (src.pixel_format == dst.pixel_format) { ++ memcpy(dst.colors, src.colors, src.width * src.pixel_size); ++ } else { ++ BPrivate::ConvertBits(src.colors, dst.colors, src.stride, dst.stride, ++ src.stride, dst.stride, src.pixel_format, dst.pixel_format, src.width, 1); ++ } + dst.colors += dst.stride; + src.colors += src.stride; + } +@@ -228,11 +229,11 @@ SoftwareRenderer::Display(BBitmap *bitmap, BRect *updateRect) + } else { + BAutolock lock(fInfoLocker); + if (fInfo != NULL) { +- RasBuf32 srcBuf(bitmap); +- RasBuf32 dstBuf(fInfo); ++ RasBuffer srcBuf(bitmap); ++ RasBuffer dstBuf(fInfo); + for (uint32 i = 0; i < fInfo->clip_list_count; i++) { + clipping_rect *clip = &fInfo->clip_list[i]; +- RasBuf32 dstClip = dstBuf; ++ RasBuffer dstClip = dstBuf; + dstClip.ClipRect(clip->left, clip->top, clip->right + 1, clip->bottom + 1); + dstClip.Shift(-fInfo->window_bounds.left, -fInfo->window_bounds.top); + dstClip.Blit(srcBuf); +-- +2.30.2 +