From eb45d168e18352b635255d10895521c6719bf357 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 22 Dec 2013 23:36:02 -0600 Subject: [PATCH] GL: Remove OpenGL kit, x86 Mesa * Depend on Mesa packages to provide functionality --- build/jam/ArchitectureRules | 5 +- build/jam/BuildFeatures | 148 +-- build/jam/BuildSetup | 1 - build/jam/HeadersRules | 4 +- build/jam/images/HaikuImage | 2 +- build/jam/packages/Haiku | 7 - build/jam/packages/HaikuDevel | 10 - build/jam/packages/HaikuDevelSecondary | 11 - build/jam/packages/HaikuSecondary | 7 - build/jam/repositories/HaikuPorts/x86 | 11 +- headers/{os/opengl => libs/glut}/GL/glut.h | 0 headers/os/OpenGLKit.h | 9 - headers/os/opengl/GLRenderer.h | 70 -- headers/os/opengl/GLView.h | 188 ---- src/add-ons/Jamfile | 1 - src/add-ons/opengl/Jamfile | 12 - src/add-ons/opengl/nvidia/Jamfile | 24 - .../opengl/nvidia/NVidiaHardwareRenderer.cpp | 46 - src/add-ons/opengl/radeon/Jamfile | 24 - .../opengl/radeon/RadeonHardwareRenderer.cpp | 55 -- src/add-ons/opengl/swpipe/GalliumContext.cpp | 528 ---------- src/add-ons/opengl/swpipe/GalliumContext.h | 82 -- .../opengl/swpipe/GalliumFramebuffer.cpp | 115 --- .../opengl/swpipe/GalliumFramebuffer.h | 34 - src/add-ons/opengl/swpipe/Jamfile | 47 - .../opengl/swpipe/SoftwareRenderer.cpp | 363 ------- src/add-ons/opengl/swpipe/SoftwareRenderer.h | 57 -- .../opengl/swpipe/SoftwareRenderer.rdef | 39 - src/add-ons/opengl/swpipe/SoftwareWinsys.cpp | 212 ----- src/add-ons/opengl/swpipe/SoftwareWinsys.h | 35 - src/add-ons/opengl/swpipe/bitmap_wrapper.cpp | 117 --- src/add-ons/opengl/swpipe/bitmap_wrapper.h | 42 - src/add-ons/opengl/swrast/Jamfile | 35 - .../opengl/swrast/MesaSoftwareRenderer.cpp | 723 -------------- .../opengl/swrast/MesaSoftwareRenderer.h | 97 -- .../opengl/swrast/MesaSoftwareRenderer.rdef | 39 - src/add-ons/opengl/swrast_legacy/Jamfile | 54 -- .../swrast_legacy/MesaSoftwareRenderer.cpp | 901 ------------------ .../swrast_legacy/MesaSoftwareRenderer.h | 131 --- .../swrast_legacy/MesaSoftwareRenderer.rdef | 39 - src/add-ons/screen_savers/flurry/Jamfile | 3 +- src/add-ons/screen_savers/glife/Jamfile | 3 +- src/add-ons/screen_savers/gravity/Jamfile | 3 +- src/apps/3dmov/Jamfile | 8 +- src/apps/glteapot/Jamfile | 3 +- src/apps/haiku3d/Jamfile | 3 +- src/kits/Jamfile | 1 - src/kits/opengl/GLDispatcher.cpp | 75 -- src/kits/opengl/GLDispatcher.h | 109 --- src/kits/opengl/GLRenderer.cpp | 104 -- src/kits/opengl/GLRendererRoster.cpp | 222 ----- src/kits/opengl/GLRendererRoster.h | 51 - src/kits/opengl/GLView.cpp | 642 ------------- src/kits/opengl/Jamfile | 66 -- src/libs/glut/Jamfile | 11 +- src/tests/kits/opengl/demos/gears/Jamfile | 4 +- src/tests/kits/opengl/direct_mode/Jamfile | 4 +- src/tests/kits/opengl/glinfo/Jamfile | 8 +- src/tests/kits/opengl/glsl/Jamfile | 4 +- src/tests/kits/opengl/glut/game_mode/Jamfile | 7 +- 60 files changed, 60 insertions(+), 5596 deletions(-) rename headers/{os/opengl => libs/glut}/GL/glut.h (100%) delete mode 100644 headers/os/OpenGLKit.h delete mode 100644 headers/os/opengl/GLRenderer.h delete mode 100644 headers/os/opengl/GLView.h delete mode 100644 src/add-ons/opengl/Jamfile delete mode 100644 src/add-ons/opengl/nvidia/Jamfile delete mode 100644 src/add-ons/opengl/nvidia/NVidiaHardwareRenderer.cpp delete mode 100644 src/add-ons/opengl/radeon/Jamfile delete mode 100644 src/add-ons/opengl/radeon/RadeonHardwareRenderer.cpp delete mode 100644 src/add-ons/opengl/swpipe/GalliumContext.cpp delete mode 100644 src/add-ons/opengl/swpipe/GalliumContext.h delete mode 100644 src/add-ons/opengl/swpipe/GalliumFramebuffer.cpp delete mode 100644 src/add-ons/opengl/swpipe/GalliumFramebuffer.h delete mode 100644 src/add-ons/opengl/swpipe/Jamfile delete mode 100644 src/add-ons/opengl/swpipe/SoftwareRenderer.cpp delete mode 100644 src/add-ons/opengl/swpipe/SoftwareRenderer.h delete mode 100644 src/add-ons/opengl/swpipe/SoftwareRenderer.rdef delete mode 100644 src/add-ons/opengl/swpipe/SoftwareWinsys.cpp delete mode 100644 src/add-ons/opengl/swpipe/SoftwareWinsys.h delete mode 100644 src/add-ons/opengl/swpipe/bitmap_wrapper.cpp delete mode 100644 src/add-ons/opengl/swpipe/bitmap_wrapper.h delete mode 100644 src/add-ons/opengl/swrast/Jamfile delete mode 100644 src/add-ons/opengl/swrast/MesaSoftwareRenderer.cpp delete mode 100644 src/add-ons/opengl/swrast/MesaSoftwareRenderer.h delete mode 100644 src/add-ons/opengl/swrast/MesaSoftwareRenderer.rdef delete mode 100644 src/add-ons/opengl/swrast_legacy/Jamfile delete mode 100644 src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.cpp delete mode 100644 src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.h delete mode 100644 src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.rdef delete mode 100644 src/kits/opengl/GLDispatcher.cpp delete mode 100644 src/kits/opengl/GLDispatcher.h delete mode 100644 src/kits/opengl/GLRenderer.cpp delete mode 100644 src/kits/opengl/GLRendererRoster.cpp delete mode 100644 src/kits/opengl/GLRendererRoster.h delete mode 100644 src/kits/opengl/GLView.cpp delete mode 100644 src/kits/opengl/Jamfile diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index 41b10b29c7..9d56f6b484 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -235,8 +235,8 @@ rule ArchitectureSetup architecture libraryGrist = $(architecture) ; } local i ; - for i in be bnetapi debug device game GL locale mail media midi midi2 - network opengl package root screensaver textencoding tracker + for i in be bnetapi debug device game locale mail media midi midi2 + network package root screensaver textencoding tracker translation z { local library = lib$(i).so ; HAIKU_LIBRARY_NAME_MAP_$(architecture)_$(i) @@ -609,7 +609,6 @@ rule ArchitectureSetupWarnings architecture EnableWerror src add-ons media plugins vorbis ; # EnableWerror src add-ons media plugins wav_reader ; EnableWerror src add-ons media plugins xvid_decoder ; - EnableWerror src add-ons opengl ; EnableWerror src add-ons print ; EnableWerror src add-ons screen_savers ; EnableWerror src add-ons tracker ; diff --git a/build/jam/BuildFeatures b/build/jam/BuildFeatures index 9f0ee68c1e..fa79ccfbf4 100644 --- a/build/jam/BuildFeatures +++ b/build/jam/BuildFeatures @@ -131,123 +131,6 @@ if $(HAIKU_BUILD_FEATURE_CLUCENE) { } # ! 1 -# TODO: Update to packages! -if ! 1 { - -# LLVM -if $(TARGET_ARCH) = x86 { - if $(TARGET_GCC_VERSION_$(architecture)[1]) >= 4 { - HAIKU_LLVM_FILE = llvm-3.2-x86-gcc4-2012-12-21.zip ; - local zipFile = [ DownloadFile $(HAIKU_LLVM_FILE) - : $(baseURL)/$(HAIKU_LLVM_FILE) ] ; - - HAIKU_LLVM_DIR = [ FDirName $(HAIKU_OPTIONAL_BUILD_PACKAGES_DIR) - $(HAIKU_LLVM_FILE:B) ] ; - - HAIKU_LLVM_HEADERS_DEPENDENCY = [ ExtractArchive $(HAIKU_LLVM_DIR) - : common/include/ : $(zipFile) : extracted-llvm ] ; - HAIKU_LLVM_HEADERS = [ FDirName $(HAIKU_LLVM_DIR) common include ] ; - - # We can't Glob these because they aren't extracted yet. - HAIKU_LLVM_LIBS = [ ExtractArchive $(HAIKU_LLVM_DIR) - : - common/lib/libLLVMAsmParser.a - common/lib/libLLVMInstrumentation.a - common/lib/libLLVMLinker.a - common/lib/libLLVMArchive.a - common/lib/libLLVMBitReader.a - common/lib/libLLVMDebugInfo.a - common/lib/libLLVMJIT.a - common/lib/libLLVMipo.a - common/lib/libLLVMVectorize.a - common/lib/libLLVMBitWriter.a - common/lib/libLLVMTableGen.a - #common/lib/libLLVMHexagonCodeGen.a - #common/lib/libLLVMHexagonAsmPrinter.a - #common/lib/libLLVMHexagonDesc.a - #common/lib/libLLVMHexagonInfo.a - #common/lib/libLLVMNVPTXCodeGen.a - #common/lib/libLLVMNVPTXDesc.a - #common/lib/libLLVMNVPTXInfo.a - #common/lib/libLLVMNVPTXAsmPrinter.a - #common/lib/libLLVMMBlazeCodeGen.a - #common/lib/libLLVMMBlazeAsmParser.a - #common/lib/libLLVMMBlazeDisassembler.a - #common/lib/libLLVMMBlazeDesc.a - #common/lib/libLLVMMBlazeInfo.a - #common/lib/libLLVMMBlazeAsmPrinter.a - common/lib/libLLVMCppBackendCodeGen.a - common/lib/libLLVMCppBackendInfo.a - #common/lib/libLLVMMSP430CodeGen.a - #common/lib/libLLVMMSP430Desc.a - #common/lib/libLLVMMSP430AsmPrinter.a - #common/lib/libLLVMMSP430Info.a - #common/lib/libLLVMXCoreCodeGen.a - #common/lib/libLLVMXCoreDesc.a - #common/lib/libLLVMXCoreInfo.a - #common/lib/libLLVMCellSPUCodeGen.a - #common/lib/libLLVMCellSPUDesc.a - #common/lib/libLLVMCellSPUInfo.a - #common/lib/libLLVMMipsAsmParser.a - #common/lib/libLLVMMipsCodeGen.a - #common/lib/libLLVMMipsDesc.a - #common/lib/libLLVMMipsAsmPrinter.a - #common/lib/libLLVMMipsDisassembler.a - #common/lib/libLLVMMipsInfo.a - #common/lib/libLLVMARMAsmParser.a - #common/lib/libLLVMARMCodeGen.a - #common/lib/libLLVMARMDisassembler.a - #common/lib/libLLVMARMDesc.a - #common/lib/libLLVMARMInfo.a - #common/lib/libLLVMARMAsmPrinter.a - #common/lib/libLLVMPowerPCCodeGen.a - #common/lib/libLLVMPowerPCDesc.a - #common/lib/libLLVMPowerPCInfo.a - #common/lib/libLLVMPowerPCAsmPrinter.a - #common/lib/libLLVMSparcCodeGen.a - #common/lib/libLLVMSparcDesc.a - #common/lib/libLLVMSparcInfo.a - common/lib/libLLVMX86AsmParser.a - common/lib/libLLVMX86CodeGen.a - common/lib/libLLVMSelectionDAG.a - common/lib/libLLVMAsmPrinter.a - common/lib/libLLVMX86Disassembler.a - common/lib/libLLVMX86Desc.a - common/lib/libLLVMX86Info.a - common/lib/libLLVMX86AsmPrinter.a - common/lib/libLLVMX86Utils.a - common/lib/libLLVMMCDisassembler.a - common/lib/libLLVMMCParser.a - common/lib/libLLVMInterpreter.a - common/lib/libLLVMCodeGen.a - common/lib/libLLVMScalarOpts.a - common/lib/libLLVMInstCombine.a - common/lib/libLLVMTransformUtils.a - common/lib/libLLVMipa.a - common/lib/libLLVMAnalysis.a - common/lib/libLLVMMCJIT.a - common/lib/libLLVMRuntimeDyld.a - common/lib/libLLVMExecutionEngine.a - common/lib/libLLVMTarget.a - common/lib/libLLVMMC.a - common/lib/libLLVMObject.a - common/lib/libLLVMCore.a - common/lib/libLLVMSupport.a - : $(zipFile) : extracted-llvm ] - ; - - EnableBuildFeatures llvm ; - } else { - # Nor will it ever be - Echo "LLVM not available on GCC2" ; - } -} else { - Echo "LLVM not yet available on $(TARGET_PACKAGING_ARCH)" ; -} - -} # ! 1 - - # GLU (GL Utilities) if [ IsPackageAvailable glu_devel ] { ExtractBuildFeatureArchives glu : @@ -265,33 +148,20 @@ if [ IsPackageAvailable glu_devel ] { } -# Mesa +# GL (GL Kit, Mesa3D) if [ IsPackageAvailable mesa_devel ] { - ExtractBuildFeatureArchives mesa : [ FFilterByBuildFeatures + ExtractBuildFeatureArchives mesa : + file: base mesa + runtime: lib file: devel mesa_devel - mesaLibrary: $(developLibDir)/libmesa.a - glapiLibrary: $(developLibDir)/libglapi.a - headers: $(developHeadersDir) - privateHeaders: $(developHeadersDir)/mesa_private - - !gcc2 @{ - glslLibrary: $(developLibDir)/libglsl.a - galliumLibrary: $(developLibDir)/libgallium.a - llvm @{ - galliumLlvmpipeLibrary: $(developLibDir)/libllvmpipe.a - }@ - !llvm @{ - galliumSoftpipeLibrary: $(developLibDir)/libsoftpipe.a - }@ - }@ # !gcc2 - ] ; - - Depends [ BuildFeatureAttribute mesa : galliumLlvmpipeLibrary ] - : $(HAIKU_LLVM_LIBS) ; + depends: base + library: $(developLibDir)/libGL.so + headers: $(developHeadersDir)/os/opengl + ; EnableBuildFeatures mesa ; } else { - Echo "Mesa 3D rendering support not available on $(TARGET_PACKAGING_ARCH)" ; + Echo "GL not yet available on $(TARGET_PACKAGING_ARCH)" ; } diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index a84563b730..00dd64e769 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -600,7 +600,6 @@ HOST_BE_API_HEADERS = [ FDirName $(HAIKU_TOP) headers build os kernel ] [ FDirName $(HAIKU_TOP) headers build os interface ] [ FDirName $(HAIKU_TOP) headers build os locale ] - [ FDirName $(HAIKU_TOP) headers build os opengl ] [ FDirName $(HAIKU_TOP) headers build os storage ] [ FDirName $(HAIKU_TOP) headers build os support ] [ FDirName $(HAIKU_TOP) headers build private ] diff --git a/build/jam/HeadersRules b/build/jam/HeadersRules index bad637f052..ad3c8f250b 100644 --- a/build/jam/HeadersRules +++ b/build/jam/HeadersRules @@ -435,7 +435,7 @@ rule FStandardOSHeaders add-ons/input_server add-ons/registrar add-ons/screen_saver add-ons/tracker app device drivers game interface - kernel locale media mail midi midi2 net opengl storage + kernel locale media mail midi midi2 net storage support translation ; return [ FDirName $(HAIKU_TOP) headers os ] @@ -449,7 +449,7 @@ rule FStandardHeaders architecture add-ons/input_server add-ons/registrar add-ons/screen_saver add-ons/tracker app device drivers game interface - kernel locale media mail midi midi2 net opengl storage + kernel locale media mail midi midi2 net storage support translation ; local headers = ; diff --git a/build/jam/images/HaikuImage b/build/jam/images/HaikuImage index a41f9392fe..4b7de4a98e 100644 --- a/build/jam/images/HaikuImage +++ b/build/jam/images/HaikuImage @@ -76,7 +76,7 @@ rule HaikuImageGetSystemLibs [ MultiArchDefaultGristFiles [ FFilterByBuildFeatures libbe.so libbsd.so libbnetapi.so libdebug.so libdevice.so - libgame.so libGL.so@x86 libglut.so@x86 + libgame.so libglut.so@x86 libgnu.so libmail.so libmedia.so libmidi.so libmidi2.so libnetwork.so libpackage.so diff --git a/build/jam/packages/Haiku b/build/jam/packages/Haiku index 430b92fcc1..6cf4eceb6f 100644 --- a/build/jam/packages/Haiku +++ b/build/jam/packages/Haiku @@ -260,13 +260,6 @@ AddFilesToPackage add-ons accelerants : $(SYSTEM_ADD_ONS_ACCELERANTS) ; AddFilesToPackage add-ons Translators : $(SYSTEM_ADD_ONS_TRANSLATORS) ; AddFilesToPackage add-ons locale catalogs : $(SYSTEM_ADD_ONS_LOCALE_CATALOGS) ; -AddFilesToPackage add-ons opengl : - x86 @{ - Legacy\ Software\ Rasterizer@gcc2 - Software\ Rasterizer@!gcc2 - }@ # x86 -; - AddFilesToPackage add-ons mail_daemon inbound_protocols : POP3 IMAP ; AddFilesToPackage add-ons mail_daemon outbound_protocols : SMTP ; AddFilesToPackage add-ons mail_daemon inbound_filters diff --git a/build/jam/packages/HaikuDevel b/build/jam/packages/HaikuDevel index deb21e74da..215034a0fc 100644 --- a/build/jam/packages/HaikuDevel +++ b/build/jam/packages/HaikuDevel @@ -76,16 +76,6 @@ if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 { : [ FDirName $(HAIKU_TOP) headers cpp ] : 2.95.3 ; } -# OpenGL headers -if $(TARGET_ARCH) = x86 && ! $(HAIKU_BOOTSTRAP_BUILD) { - local mesaGlHeaders - = [ FDirName [ BuildFeatureAttribute mesa : headers : path ] GL ] ; - local mesaGlHeadersDependency = [ BuildFeatureAttribute mesa : headers ] ; - mesaGlHeaders = $(mesaGlHeaders:G=$(mesaGlHeadersDependency:G)) ; - Depends $(mesaGlHeaders) : $(mesaGlHeadersDependency) ; - CopyDirectoryToPackage develop headers os opengl - : $(mesaGlHeaders) : : : isTarget ; -} # Deskbar menu symlinks AddSymlinkToPackage data deskbar menu Applications diff --git a/build/jam/packages/HaikuDevelSecondary b/build/jam/packages/HaikuDevelSecondary index 5c98f97b5e..baa7feb7d2 100644 --- a/build/jam/packages/HaikuDevelSecondary +++ b/build/jam/packages/HaikuDevelSecondary @@ -49,16 +49,5 @@ if $(HAIKU_GCC_VERSION_$(architecture)[1]) = 2 { : [ FDirName $(HAIKU_TOP) headers cpp ] : 2.95.3 ; } -# OpenGL headers -if $(TARGET_ARCH) = x86 && ! $(HAIKU_BOOTSTRAP_BUILD) { - local mesaGlHeaders - = [ FDirName [ BuildFeatureAttribute mesa : headers : path ] GL ] ; - local mesaGlHeadersDependency = [ BuildFeatureAttribute mesa : headers ] ; - mesaGlHeaders = $(mesaGlHeaders:G=$(mesaGlHeadersDependency:G)) ; - Depends $(mesaGlHeaders) : $(mesaGlHeadersDependency) ; - CopyDirectoryToPackage develop headers $(architecture) os opengl - : $(mesaGlHeaders) : : : isTarget ; -} - BuildHaikuPackage $(haikuDevelPackage) : haiku_devel_secondary ; diff --git a/build/jam/packages/HaikuSecondary b/build/jam/packages/HaikuSecondary index 1bacbc9b9c..1257052fb1 100644 --- a/build/jam/packages/HaikuSecondary +++ b/build/jam/packages/HaikuSecondary @@ -31,13 +31,6 @@ AddFilesToPackage $(addOnsDir) Translators # AddFilesToPackage $(addOnsDir) locale catalogs # : $(SYSTEM_ADD_ONS_LOCALE_CATALOGS) ; # -# AddFilesToPackage $(addOnsDir) opengl : -# x86 @{ -# Legacy\ Software\ Rasterizer@gcc2 -# Software\ Rasterizer@!gcc2 -# }@ # x86 -# ; -# # AddFilesToPackage $(addOnsDir) media : $(SYSTEM_ADD_ONS_MEDIA) ; # AddFilesToPackage $(addOnsDir) media plugins # : $(SYSTEM_ADD_ONS_MEDIA_PLUGINS) ; diff --git a/build/jam/repositories/HaikuPorts/x86 b/build/jam/repositories/HaikuPorts/x86 index ab1cd46972..d76c99c4b8 100644 --- a/build/jam/repositories/HaikuPorts/x86 +++ b/build/jam/repositories/HaikuPorts/x86 @@ -92,8 +92,9 @@ RemotePackageRepository HaikuPorts make-3.82-5 man-1.6g-3 mercurial-2.2.2-5 - mesa-9.1.1-1 - mesa_devel-9.1.1-1 + mesa-10.0.1-2 + mesa_swrast-10.0.1-2 + mesa_devel-10.0.1-2 mkdepend-1.7-3 nano-2.2.6-3 ncurses-5.9-10 @@ -165,8 +166,8 @@ RemotePackageRepository HaikuPorts libvpx_x86_gcc2_devel-1.0.0-2 libxml2_x86_gcc2-2.8.0-5 libxml2_x86_gcc2_devel-2.8.0-5 - mesa_x86_gcc2-7.8.2-3 - mesa_x86_gcc2_devel-7.8.2-3 +# mesa_x86_gcc2-7.9.2-2 +# mesa_x86_gcc2_devel-7.9.2-2 ncurses_x86_gcc2-5.9-10 ncurses_x86_gcc2_devel-5.9-10 openssl_x86_gcc2-1.0.0j-4 @@ -229,7 +230,7 @@ RemotePackageRepository HaikuPorts man mercurial mesa - mesa_x86_gcc2 +# mesa_x86_gcc2 mkdepend nano ncurses diff --git a/headers/os/opengl/GL/glut.h b/headers/libs/glut/GL/glut.h similarity index 100% rename from headers/os/opengl/GL/glut.h rename to headers/libs/glut/GL/glut.h diff --git a/headers/os/OpenGLKit.h b/headers/os/OpenGLKit.h deleted file mode 100644 index 9a6003b553..0000000000 --- a/headers/os/OpenGLKit.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Master include file for the OpenGL Kit. - * - */ - -#include -#include -#include -#include diff --git a/headers/os/opengl/GLRenderer.h b/headers/os/opengl/GLRenderer.h deleted file mode 100644 index 9bdbd865df..0000000000 --- a/headers/os/opengl/GLRenderer.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2006, Philippe Houdoin. All rights reserved. - * Distributed under the terms of the MIT License. - */ -#ifndef GLRENDERER_H -#define GLRENDERER_H - -#include -#include - -class BGLDispatcher; -class GLRendererRoster; - -typedef unsigned long renderer_id; - -class BGLRenderer -{ - - // Private unimplemented copy constructors - BGLRenderer(const BGLRenderer &); - BGLRenderer & operator=(const BGLRenderer &); - -public: - BGLRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher); - virtual ~BGLRenderer(); - - void Acquire(); - void Release(); - - virtual void LockGL(); - virtual void UnlockGL(); - - virtual void SwapBuffers(bool VSync = false); - virtual void Draw(BRect updateRect); - virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest); - virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest); - - virtual void FrameResized(float width, float height); - - virtual void DirectConnected(direct_buffer_info *info); - virtual void EnableDirectMode(bool enabled); - - inline int32 ReferenceCount() const { return fRefCount; }; - inline ulong Options() const { return fOptions; }; - inline BGLView * GLView() { return fView; }; - inline BGLDispatcher * GLDispatcher() { return fDispatcher; }; - -private: - friend class GLRendererRoster; - - virtual status_t _Reserved_Renderer_0(int32, void *); - virtual status_t _Reserved_Renderer_1(int32, void *); - virtual status_t _Reserved_Renderer_2(int32, void *); - virtual status_t _Reserved_Renderer_3(int32, void *); - virtual status_t _Reserved_Renderer_4(int32, void *); - - volatile int32 fRefCount; // How much we're still usefull? - BGLView* fView; // Never forget who is the boss! - ulong fOptions; // Keep that tune in memory - BGLDispatcher* fDispatcher; // Our personal OpenGL API call dispatcher - - GLRendererRoster* fOwningRoster; - renderer_id fID; -}; - -extern "C" _EXPORT BGLRenderer * instantiate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher); - - -#endif // GLRENDERER_H - diff --git a/headers/os/opengl/GLView.h b/headers/os/opengl/GLView.h deleted file mode 100644 index 16c7703dfb..0000000000 --- a/headers/os/opengl/GLView.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2008, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - */ -#ifndef BGLVIEW_H -#define BGLVIEW_H - -#include - -#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 - -#ifdef __cplusplus - -#include -#include -#include -#include -#include -#include - -struct glview_direct_info; -class BGLRenderer; -class GLRendererRoster; - -class 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(); // deprecated, returns NULL - 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: - - 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 &); - - void _DitherFront(); - bool _ConfirmDither(); - void _Draw(BRect rect); - void _CallDirectConnected(); - - void * fGc; - uint32 fOptions; - uint32 fDitherCount; - BLocker fDrawLock; - BLocker fDisplayLock; - glview_direct_info * fClipInfo; - - BGLRenderer *fRenderer; - GLRendererRoster *fRoster; - - BBitmap * fDitherMap; - BRect fBounds; - int16 * fErrorBuffer[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 --git a/src/add-ons/Jamfile b/src/add-ons/Jamfile index 039f33fad5..905ba43b60 100644 --- a/src/add-ons/Jamfile +++ b/src/add-ons/Jamfile @@ -9,7 +9,6 @@ SubInclude HAIKU_TOP src add-ons kernel ; SubInclude HAIKU_TOP src add-ons locale ; SubInclude HAIKU_TOP src add-ons mail_daemon ; SubInclude HAIKU_TOP src add-ons media ; -SubInclude HAIKU_TOP src add-ons opengl ; SubInclude HAIKU_TOP src add-ons print ; SubInclude HAIKU_TOP src add-ons screen_savers ; SubInclude HAIKU_TOP src add-ons translators ; diff --git a/src/add-ons/opengl/Jamfile b/src/add-ons/opengl/Jamfile deleted file mode 100644 index 7f405b3d2e..0000000000 --- a/src/add-ons/opengl/Jamfile +++ /dev/null @@ -1,12 +0,0 @@ -SubDir HAIKU_TOP src add-ons opengl ; - -# Haiku Mesa Software Rasterizer -SubInclude HAIKU_TOP src add-ons opengl swrast ; -SubInclude HAIKU_TOP src add-ons opengl swrast_legacy ; - -# Haiku Gallium Software Renderer -SubInclude HAIKU_TOP src add-ons opengl swpipe ; - -# SubInclude HAIKU_TOP src add-ons opengl nvidia ; -# SubInclude HAIKU_TOP src add-ons opengl radeon ; - diff --git a/src/add-ons/opengl/nvidia/Jamfile b/src/add-ons/opengl/nvidia/Jamfile deleted file mode 100644 index 6e762c81d1..0000000000 --- a/src/add-ons/opengl/nvidia/Jamfile +++ /dev/null @@ -1,24 +0,0 @@ -SubDir HAIKU_TOP src add-ons opengl nvidia ; - -SetSubDirSupportedPlatformsBeOSCompatible ; - -if $(TARGET_PLATFORM) != haiku { - UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ; - # We need our public GL headers also when not compiling for Haiku. -} - - -UseLibraryHeaders mesa ; - -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa main ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa glapi ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa tnl ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa x86 ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa ppc ] ; - -Addon NVidia\ Hardware\ Renderer : opengl : - NVidiaHardwareRenderer.cpp - : false - : libGL.so libmesa.a be -; diff --git a/src/add-ons/opengl/nvidia/NVidiaHardwareRenderer.cpp b/src/add-ons/opengl/nvidia/NVidiaHardwareRenderer.cpp deleted file mode 100644 index da2d5de751..0000000000 --- a/src/add-ons/opengl/nvidia/NVidiaHardwareRenderer.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2006-2012 Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - */ - - -#include - -#include -#include - - -extern "C" _EXPORT BGLRenderer* -instanciate_gl_renderer(BGLView* view, ulong options, BGLDispatcher* dispatcher) -{ - if (!view) - return NULL; - - BWindow *window = view->Window(); - if (!window) - return NULL; - - BScreen screen(window); - if (!screen.IsValid()) - return NULL; - - accelerant_device_info adi; - if (screen.GetDeviceInfo(&adi) !=B_OK) - return NULL; - - fprintf(stderr, "Accelerant device info:\n" - " version: %ud\n" - " name: %s\n" - " chipset: %s\n" - " serial#: %s\n", - (unsigned int) adi.version, adi.name, adi.chipset, adi.serial_no); - flush(stderr); - - // Check the view is attached to a screen driven by a NVidia chip: - if (strncmp(adi.name, "Nvidia", 6) == 0) { - // return new NVidiaHardwareRenderer(view, options, dispatcher); - return NULL; - } - - return NULL; -} diff --git a/src/add-ons/opengl/radeon/Jamfile b/src/add-ons/opengl/radeon/Jamfile deleted file mode 100644 index 58820dc707..0000000000 --- a/src/add-ons/opengl/radeon/Jamfile +++ /dev/null @@ -1,24 +0,0 @@ -SubDir HAIKU_TOP src add-ons opengl radeon ; - -SetSubDirSupportedPlatformsBeOSCompatible ; - -if $(TARGET_PLATFORM) != haiku { - UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ; - # We need our public GL headers also when not compiling for Haiku. -} - - -UseLibraryHeaders mesa ; - -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa main ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa glapi ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa tnl ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa x86 ] ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs mesa mesa ppc ] ; - -Addon Radeon\ Hardware\ Renderer : opengl : - RadeonHardwareRenderer.cpp - : false - : libGL.so libmesa.a be -; diff --git a/src/add-ons/opengl/radeon/RadeonHardwareRenderer.cpp b/src/add-ons/opengl/radeon/RadeonHardwareRenderer.cpp deleted file mode 100644 index 12ef0f8490..0000000000 --- a/src/add-ons/opengl/radeon/RadeonHardwareRenderer.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2006-2012 Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - */ - - -#include - -#include -#include - - -extern "C" _EXPORT BGLRenderer* -instanciate_gl_renderer(BGLView* view, ulong options, BGLDispatcher* dispatcher) -{ - if (!view) { - printf("view = NULL!\n"); - return NULL; - } - - BWindow* window = view->Window(); - if (!window) { - printf("view's window = NULL!\n"); - return NULL; - } - - BScreen screen(window); - if (!screen.IsValid()) { - printf("Failed to get window's screen!\n"); - return NULL; - } - - accelerant_device_info adi; - if (screen.GetDeviceInfo(&adi) != B_OK) { - printf("screen.GetDeviceInfo() failed!\n"); - return NULL; - } - - printf("Accelerant device info:\n" - " version: %ud\n" - " name: %s\n" - " chipset: %s\n" - " serial#: %s\n", - (unsigned int) adi.version, adi.name, adi.chipset, adi.serial_no); - - // Check the view is attached to a screen driven by a Radeon chip: - if (strcasecmp(adi.chipset, "radeon") == 0 || - strcasecmp(adi.chipset, "radeon") == 0) { - // return new RadeonHardwareRenderer(view, options, dispatcher); - return NULL; - } - - // We can't be a renderer for this view, sorry. - return NULL; -} diff --git a/src/add-ons/opengl/swpipe/GalliumContext.cpp b/src/add-ons/opengl/swpipe/GalliumContext.cpp deleted file mode 100644 index ef692a1afa..0000000000 --- a/src/add-ons/opengl/swpipe/GalliumContext.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Artur Wyszynski, harakash@gmail.com - * Alexander von Gluck IV, kallisti5@unixzen.com - */ - - -#include "GalliumContext.h" - -#include "GLView.h" - -#include "bitmap_wrapper.h" -#include "SoftwareWinsys.h" -extern "C" { -#include "glapi/glapi.h" -#include "main/context.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "pipe/p_format.h" -#include "state_tracker/st_cb_fbo.h" -#include "state_tracker/st_cb_flush.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_gl_api.h" -#include "state_tracker/st_manager.h" -#include "state_tracker/sw_winsys.h" -#ifdef HAVE_LLVM -#include "llvmpipe/lp_public.h" -#else -#include "softpipe/sp_public.h" -#endif -} - - -#define TRACE_CONTEXT -#ifdef TRACE_CONTEXT -# define TRACE(x...) printf("GalliumContext: " x) -# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__) -#else -# define TRACE(x...) -# define CALLED() -#endif -#define ERROR(x...) printf("GalliumContext: " x) - - -static void -hgl_viewport(struct gl_context* glContext, GLint x, GLint y, - GLsizei width, GLsizei height) -{ - TRACE("%s(glContext: %p, x: %d, y: %d, w: %d, h: %d\n", __func__, - glContext, x, y, width, height); - - struct gl_framebuffer *draw = glContext->WinSysDrawBuffer; - struct gl_framebuffer *read = glContext->WinSysReadBuffer; - - // TODO: SLOW! We need to check for changes in bitmap vs gl_framebuffer - // size before doing a _mesa_resize_framebuffer. - if (draw) - _mesa_resize_framebuffer(glContext, draw, width, height); - if (read) - _mesa_resize_framebuffer(glContext, read, width, height); -} - - -static st_visual* -hgl_fill_st_visual(gl_config* glVisual) -{ - struct st_visual* stVisual = CALLOC_STRUCT(st_visual); - if (!stVisual) { - ERROR("%s: Couldn't allocate st_visual\n", __func__); - return NULL; - } - - // Determine color format - if (glVisual->redBits == 8) { - if (glVisual->alphaBits == 8) - stVisual->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; - else - stVisual->color_format = PIPE_FORMAT_B8G8R8X8_UNORM; - } else { - stVisual->color_format = PIPE_FORMAT_B5G6R5_UNORM; - } - - // Determine depth stencil format - switch (glVisual->depthBits) { - default: - case 0: - stVisual->depth_stencil_format = PIPE_FORMAT_NONE; - break; - case 16: - stVisual->depth_stencil_format = PIPE_FORMAT_Z16_UNORM; - break; - case 24: - if (glVisual->stencilBits == 0) { - stVisual->depth_stencil_format = PIPE_FORMAT_Z24X8_UNORM; - // or PIPE_FORMAT_X8Z24_UNORM? - } else { - stVisual->depth_stencil_format = PIPE_FORMAT_Z24_UNORM_S8_UINT; - // or PIPE_FORMAT_S8_UINT_Z24_UNORM? - } - break; - case 32: - stVisual->depth_stencil_format = PIPE_FORMAT_Z32_UNORM; - break; - } - - stVisual->accum_format = (glVisual->haveAccumBuffer) - ? PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE; - - stVisual->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK; - stVisual->render_buffer = ST_ATTACHMENT_FRONT_LEFT; - if (glVisual->doubleBufferMode) { - stVisual->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK; - stVisual->render_buffer = ST_ATTACHMENT_BACK_LEFT; - } - - if (glVisual->stereoMode) { - stVisual->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK; - if (glVisual->doubleBufferMode) - stVisual->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK; - } - - if (glVisual->haveDepthBuffer || glVisual->haveStencilBuffer) - stVisual->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK; - - return stVisual; -} - - -static INLINE unsigned -round_up(unsigned n, unsigned multiple) -{ - return (n + multiple - 1) & ~(multiple - 1); -} - - -static int -hook_stm_get_param(struct st_manager *smapi, enum st_manager_param param) -{ - CALLED(); - - switch (param) { - case ST_MANAGER_BROKEN_INVALIDATE: - TRACE("%s: TODO: How should we handle BROKEN_INVALIDATE calls?\n", - __func__); - // For now we force validation of the framebuffer. - return 1; - } - - return 0; -} - - -GalliumContext::GalliumContext(ulong options) - : - fOptions(options), - fCurrentContext(0), - fScreen(NULL) -{ - CALLED(); - - // Make all contexts a known value - for (context_id i = 0; i < CONTEXT_MAX; i++) - fContext[i] = NULL; - - CreateScreen(); - - pipe_mutex_init(fMutex); -} - - -GalliumContext::~GalliumContext() -{ - CALLED(); - - // Destroy our contexts - pipe_mutex_lock(fMutex); - for (context_id i = 0; i < CONTEXT_MAX; i++) - DestroyContext(i); - pipe_mutex_unlock(fMutex); - - pipe_mutex_destroy(fMutex); - - // TODO: Destroy fScreen -} - - -status_t -GalliumContext::CreateScreen() -{ - CALLED(); - - // Allocate winsys and attach callback hooks - struct sw_winsys* winsys = winsys_connect_hooks(); - - if (!winsys) { - ERROR("%s: Couldn't allocate sw_winsys!\n", __func__); - return B_ERROR; - } - - #ifdef HAVE_LLVM - fScreen = llvmpipe_create_screen(winsys); - #else - fScreen = softpipe_create_screen(winsys); - #endif - - if (fScreen == NULL) { - ERROR("%s: Couldn't create screen!\n", __FUNCTION__); - FREE(winsys); - return B_ERROR; - } - - const char* driverName = fScreen->get_name(fScreen); - ERROR("%s: Using %s driver.\n", __func__, driverName); - - return B_OK; -} - - -context_id -GalliumContext::CreateContext(Bitmap *bitmap) -{ - CALLED(); - - struct hgl_context* context = CALLOC_STRUCT(hgl_context); - - if (!context) { - ERROR("%s: Couldn't create pipe context!\n", __FUNCTION__); - return 0; - } - - // Set up the initial things our context needs - context->bitmap = bitmap; - context->colorSpace = get_bitmap_color_space(bitmap); - context->draw = NULL; - context->read = NULL; - context->st = NULL; - - context->api = st_gl_api_create(); - if (!context->api) { - ERROR("%s: Couldn't obtain Mesa state tracker API!\n", __func__); - return -1; - } - - context->manager = CALLOC_STRUCT(st_manager); - if (!context->manager) { - ERROR("%s: Couldn't allocate Mesa state tracker manager!\n", __func__); - return -1; - } - context->manager->get_param = hook_stm_get_param; - - // Calculate visual configuration - const GLboolean rgbFlag = ((fOptions & BGL_INDEX) == 0); - const GLboolean alphaFlag = ((fOptions & BGL_ALPHA) == BGL_ALPHA); - const GLboolean dblFlag = ((fOptions & BGL_DOUBLE) == BGL_DOUBLE); - const GLboolean stereoFlag = false; - const GLint depth = (fOptions & BGL_DEPTH) ? 24 : 0; - const GLint stencil = (fOptions & BGL_STENCIL) ? 8 : 0; - const GLint accum = 0; // (options & BGL_ACCUM) ? 16 : 0; - const GLint red = rgbFlag ? 8 : 0; - const GLint green = rgbFlag ? 8 : 0; - const GLint blue = rgbFlag ? 8 : 0; - const GLint alpha = alphaFlag ? 8 : 0; - - TRACE("rgb :\t%d\n", (bool)rgbFlag); - TRACE("alpha :\t%d\n", (bool)alphaFlag); - TRACE("dbl :\t%d\n", (bool)dblFlag); - TRACE("stereo :\t%d\n", (bool)stereoFlag); - TRACE("depth :\t%d\n", depth); - TRACE("stencil :\t%d\n", stencil); - TRACE("accum :\t%d\n", accum); - TRACE("red :\t%d\n", red); - TRACE("green :\t%d\n", green); - TRACE("blue :\t%d\n", blue); - TRACE("alpha :\t%d\n", alpha); - - gl_config* glVisual = _mesa_create_visual(dblFlag, stereoFlag, red, green, - blue, alpha, depth, stencil, accum, accum, accum, alpha ? accum : 0, 1); - - if (!glVisual) { - ERROR("%s: Couldn't create Mesa visual!\n", __func__); - return -1; - } - - TRACE("depthBits :\t%d\n", glVisual->depthBits); - TRACE("stencilBits :\t%d\n", glVisual->stencilBits); - - // Convert Mesa calculated visual into state tracker visual - context->stVisual = hgl_fill_st_visual(glVisual); - - context->draw = new GalliumFramebuffer(context->stVisual, (void*)this); - context->read = new GalliumFramebuffer(context->stVisual, (void*)this); - - if (!context->draw || !context->read) { - ERROR("%s: Problem allocating framebuffer!\n", __func__); - _mesa_destroy_visual(glVisual); - return -1; - } - - // We need to assign the screen *before* calling st_api create_context - context->manager->screen = fScreen; - - // Build state tracker attributes - struct st_context_attribs attribs; - memset(&attribs, 0, sizeof(attribs)); - attribs.options.force_glsl_extensions_warn = false; - attribs.profile = ST_PROFILE_DEFAULT; - attribs.visual = *context->stVisual; - attribs.major = 1; - attribs.minor = 0; - //attribs.flags |= ST_CONTEXT_FLAG_DEBUG; - - struct st_api* api = context->api; - - // Create context using state tracker api call - enum st_context_error result; - context->st = api->create_context(api, context->manager, &attribs, - &result, context->st); - - if (!context->st) { - ERROR("%s: Couldn't create mesa state tracker context!\n", - __func__); - switch (result) { - case ST_CONTEXT_SUCCESS: - ERROR("%s: State tracker error: SUCCESS?\n", __func__); - break; - case ST_CONTEXT_ERROR_NO_MEMORY: - ERROR("%s: State tracker error: NO_MEMORY\n", __func__); - break; - case ST_CONTEXT_ERROR_BAD_API: - ERROR("%s: State tracker error: BAD_API\n", __func__); - break; - case ST_CONTEXT_ERROR_BAD_VERSION: - ERROR("%s: State tracker error: BAD_VERSION\n", __func__); - break; - case ST_CONTEXT_ERROR_BAD_FLAG: - ERROR("%s: State tracker error: BAD_FLAG\n", __func__); - break; - case ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE: - ERROR("%s: State tracker error: BAD_ATTRIBUTE\n", __func__); - break; - case ST_CONTEXT_ERROR_UNKNOWN_FLAG: - ERROR("%s: State tracker error: UNKNOWN_FLAG\n", __func__); - break; - } - - FREE(context); - return -1; - } - - // Init Gallium3D Post Processing - //context->postProcess = pp_init(fScreen, context->postProcessEnable); - - assert(!context->st->st_manager_private); - context->st->st_manager_private = (void*)this; - - struct st_context *stContext = (struct st_context*)context->st; - - stContext->ctx->Driver.Viewport = hgl_viewport; - - // TODO: Closely review this next context logic... - context_id contextNext = -1; - - pipe_mutex_lock(fMutex); - for (context_id i = 0; i < CONTEXT_MAX; i++) { - if (fContext[i] == NULL) { - fContext[i] = context; - contextNext = i; - break; - } - } - pipe_mutex_unlock(fMutex); - - if (contextNext < 0) { - ERROR("%s: The next context is invalid... something went wrong!\n", - __func__); - //st_destroy_context(context->st); - FREE(context); - _mesa_destroy_visual(glVisual); - return -1; - } - - TRACE("%s: context #%" B_PRIu64 " is the next available context\n", - __func__, contextNext); - - return contextNext; -} - - -void -GalliumContext::DestroyContext(context_id contextID) -{ - // fMutex should be locked *before* calling DestoryContext - - // See if context is used - if (!fContext[contextID]) - return; - - if (fContext[contextID]->st) { - fContext[contextID]->st->flush(fContext[contextID]->st, 0, NULL); - fContext[contextID]->st->destroy(fContext[contextID]->st); - } - - if (fContext[contextID]->postProcess) - pp_free(fContext[contextID]->postProcess); - - // Delete framebuffer objects - if (fContext[contextID]->read) - delete fContext[contextID]->read; - if (fContext[contextID]->draw) - delete fContext[contextID]->draw; - - if (fContext[contextID]->stVisual) - FREE(fContext[contextID]->stVisual); - - if (fContext[contextID]->manager) - FREE(fContext[contextID]->manager); - - FREE(fContext[contextID]); -} - - -status_t -GalliumContext::SetCurrentContext(Bitmap *bitmap, context_id contextID) -{ - CALLED(); - - if (contextID < 0 || contextID > CONTEXT_MAX) { - ERROR("%s: Invalid context ID range!\n", __func__); - return B_ERROR; - } - - pipe_mutex_lock(fMutex); - context_id oldContextID = fCurrentContext; - struct hgl_context* context = fContext[contextID]; - pipe_mutex_unlock(fMutex); - - if (!context) { - ERROR("%s: Invalid context provided (#%" B_PRIu64 ")!\n", - __func__, contextID); - return B_ERROR; - } - - struct st_api* api = context->api; - - if (!bitmap) { - api->make_current(context->api, NULL, NULL, NULL); - return B_OK; - } - - // Everything seems valid, lets set the new context. - fCurrentContext = contextID; - - if (oldContextID > 0 && oldContextID != contextID) { - fContext[oldContextID]->st->flush(fContext[oldContextID]->st, - ST_FLUSH_FRONT, NULL); - } - - // We need to lock and unlock framebuffers before accessing them - context->draw->Lock(); - context->read->Lock(); - api->make_current(context->api, context->st, context->draw->fBuffer, - context->read->fBuffer); - context->draw->Unlock(); - context->read->Unlock(); - - // TODO: Init textures before post-processing them - #if 0 - pp_init_fbos(context->postProcess, - context->textures[ST_ATTACHMENT_BACK_LEFT]->width0, - context->textures[ST_ATTACHMENT_BACK_LEFT]->height0); - #endif - - context->bitmap = bitmap; - //context->st->pipe->priv = context; - - return B_OK; -} - - -status_t -GalliumContext::SwapBuffers(context_id contextID) -{ - CALLED(); - - pipe_mutex_lock(fMutex); - struct hgl_context *context = fContext[contextID]; - pipe_mutex_unlock(fMutex); - - if (!context) { - ERROR("%s: context not found\n", __func__); - return B_ERROR; - } - - // TODO: Where did st_notify_swapbuffers go? - //st_notify_swapbuffers(context->draw->stfb); - - context->st->flush(context->st, ST_FLUSH_FRONT, NULL); - - struct st_context *stContext = (struct st_context*)context->st; - - unsigned nColorBuffers = stContext->state.framebuffer.nr_cbufs; - for (unsigned i = 0; i < nColorBuffers; i++) { - pipe_surface* surface = stContext->state.framebuffer.cbufs[i]; - if (!surface) { - ERROR("%s: Color buffer %d invalid!\n", __func__, i); - continue; - } - - TRACE("%s: Flushing color buffer #%d\n", __func__, i); - - // We pass our destination bitmap to flush_fronbuffer which passes it - // to the private winsys display call. - fScreen->flush_frontbuffer(fScreen, surface->texture, 0, 0, - context->bitmap); - } - - #if 0 - // TODO... should we flush the z stencil buffer? - pipe_surface* zSurface = stContext->state.framebuffer.zsbuf; - fScreen->flush_frontbuffer(fScreen, surface->texture, 0, 0, - context->bitmap); - #endif - - return B_OK; -} diff --git a/src/add-ons/opengl/swpipe/GalliumContext.h b/src/add-ons/opengl/swpipe/GalliumContext.h deleted file mode 100644 index b65803d884..0000000000 --- a/src/add-ons/opengl/swpipe/GalliumContext.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2009, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Alexander von Gluck IV, kallisti5@unixzen.com - */ -#ifndef GALLIUMCONTEXT_H -#define GALLIUMCONTEXT_H - - -#include - -extern "C" { -#include "state_tracker/st_api.h" -#include "pipe/p_compiler.h" -#include "pipe/p_screen.h" -#include "postprocess/filters.h" -#include "os/os_thread.h" -} -#include "bitmap_wrapper.h" -#include "GalliumFramebuffer.h" - - -#define CONTEXT_MAX 32 - - -typedef int64 context_id; - -struct hgl_context -{ - struct st_api* api; - // State Tracker API - struct st_manager* manager; - // State Tracker Manager - struct st_context_iface* st; - // State Tracker Interface Object - struct st_visual* stVisual; - // State Tracker Visual - - struct pipe_resource* textures[ST_ATTACHMENT_COUNT]; - - // Post processing - struct pp_queue_t* postProcess; - unsigned int postProcessEnable[PP_FILTERS]; - - Bitmap* bitmap; - color_space colorSpace; - - GalliumFramebuffer* draw; - GalliumFramebuffer* read; -}; - - -class GalliumContext { -public: - GalliumContext(ulong options); - ~GalliumContext(); - - context_id CreateContext(Bitmap* bitmap); - void DestroyContext(context_id contextID); - context_id GetCurrentContext() { return fCurrentContext; }; - status_t SetCurrentContext(Bitmap *bitmap, - context_id contextID); - - status_t SwapBuffers(context_id contextID); - -private: - status_t CreateScreen(); - void Flush(); - - ulong fOptions; - - struct hgl_context* fContext[CONTEXT_MAX]; - context_id fCurrentContext; - - struct pipe_screen* fScreen; - pipe_mutex fMutex; -}; - - -#endif /* GALLIUMCONTEXT_H */ diff --git a/src/add-ons/opengl/swpipe/GalliumFramebuffer.cpp b/src/add-ons/opengl/swpipe/GalliumFramebuffer.cpp deleted file mode 100644 index 7c8da37982..0000000000 --- a/src/add-ons/opengl/swpipe/GalliumFramebuffer.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Artur Wyszynski, harakash@gmail.com - * Alexander von Gluck IV, kallisti5@unixzen.com - */ - - -#include "GalliumFramebuffer.h" - -extern "C" { -#include "main/context.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "pipe/p_format.h" -} - - -#define TRACE_FRAMEBUFFER -#ifdef TRACE_FRAEMBUFFER -# define TRACE(x...) printf("GalliumFramebuffer: " x) -# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__) -#else -# define TRACE(x...) -# define CALLED() -#endif -#define ERROR(x...) printf("GalliumFramebuffer: " x) - - -static boolean -hgl_framebuffer_flush_front(struct st_context_iface *stctx, - struct st_framebuffer_iface* stfb, enum st_attachment_type statt) -{ - CALLED(); - // TODO: I have *NO* idea how we are going to access this data... - - #if 0 - struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb); - pipe_mutex_lock(stwfb->fb->mutex); - - struct pipe_resource* resource = textures[statt]; - if (resource) - stw_framebuffer_present_locked(...); - #endif - - return TRUE; -} - - -static boolean -hgl_framebuffer_validate(struct st_framebuffer_iface* stfb, - const enum st_attachment_type* statts, unsigned count, - struct pipe_resource** out) -{ - CALLED(); - - return TRUE; -} - - -GalliumFramebuffer::GalliumFramebuffer(struct st_visual* visual, - void* privateContext) - : - fBuffer(NULL) -{ - CALLED(); - fBuffer = CALLOC_STRUCT(st_framebuffer_iface); - if (!fBuffer) { - ERROR("%s: Couldn't calloc framebuffer!\n", __func__); - return; - } - fBuffer->visual = visual; - fBuffer->flush_front = hgl_framebuffer_flush_front; - fBuffer->validate = hgl_framebuffer_validate; - fBuffer->st_manager_private = privateContext; - - pipe_mutex_init(fMutex); -} - - -GalliumFramebuffer::~GalliumFramebuffer() -{ - CALLED(); - // We lock and unlock to try and make sure we wait for anything - // using the framebuffer to finish - Lock(); - if (!fBuffer) { - ERROR("%s: Strange, no Gallium Framebuffer to free?\n", __func__); - return; - } - FREE(fBuffer); - Unlock(); - - pipe_mutex_destroy(fMutex); -} - - -status_t -GalliumFramebuffer::Lock() -{ - CALLED(); - pipe_mutex_lock(fMutex); - return B_OK; -} - - -status_t -GalliumFramebuffer::Unlock() -{ - CALLED(); - pipe_mutex_unlock(fMutex); - return B_OK; -} diff --git a/src/add-ons/opengl/swpipe/GalliumFramebuffer.h b/src/add-ons/opengl/swpipe/GalliumFramebuffer.h deleted file mode 100644 index 11e6b73657..0000000000 --- a/src/add-ons/opengl/swpipe/GalliumFramebuffer.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Alexander von Gluck IV, kallisti5@unixzen.com - */ -#ifndef GALLIUMFRAMEBUFFER_H -#define GALLIUMFRAMEBUFFER_H - - -extern "C" { -#include "os/os_thread.h" -#include "pipe/p_screen.h" -#include "state_tracker/st_api.h" -} - - -class GalliumFramebuffer { -public: - GalliumFramebuffer(struct st_visual* visual, - void* privateContext); - ~GalliumFramebuffer(); - status_t Lock(); - status_t Unlock(); - - struct st_framebuffer_iface* fBuffer; - -private: - pipe_mutex fMutex; -}; - - -#endif /* GALLIUMFRAMEBUFFER_H */ diff --git a/src/add-ons/opengl/swpipe/Jamfile b/src/add-ons/opengl/swpipe/Jamfile deleted file mode 100644 index d741644223..0000000000 --- a/src/add-ons/opengl/swpipe/Jamfile +++ /dev/null @@ -1,47 +0,0 @@ -SubDir HAIKU_TOP src add-ons opengl swpipe ; -UseBuildFeatureHeaders mesa ; - -UsePrivateHeaders interface ; - -local sources = - SoftwareRenderer.cpp - SoftwareWinsys.cpp - GalliumContext.cpp - GalliumFramebuffer.cpp - bitmap_wrapper.cpp ; - -Includes [ FGristFiles $(sources) ] : [ BuildFeatureAttribute mesa : headers ] ; - -local privateHeaders = [ BuildFeatureAttribute mesa : privateHeaders : path ] ; -UseHeaders [ FDirName $(privateHeaders) gallium auxiliary ] ; -UseHeaders [ FDirName $(privateHeaders) gallium drivers ] ; -UseHeaders [ FDirName $(privateHeaders) gallium include ] ; -UseHeaders [ FDirName $(privateHeaders) mapi ] ; -UseHeaders [ FDirName $(privateHeaders) mesa ] ; - -AddResources Software\ Renderer : SoftwareRenderer.rdef ; - -if FIsBuildFeatureEnabled(llvm) { - Depends Software\ Renderer : $(HAIKU_LLVM_HEADERS_DEPENDENCY) ; - SubDirC++Flags [ FDefines HAVE_LLVM=0x0302 ] ; -} - -# LLVM Pipe enabled Gallium Software Renderer -# Requires: -# - LLVM optional package -# - Mesa optional package compiled with LLVM installed -# SoftPipe enabled Gallium Software Renderer -# Requires: -# - Mesa optional package compiled *without* LLVM installed -Addon Software\ Renderer : - $(sources) - : - libGL.so - [ BuildFeatureAttribute mesa : galliumSoftpipeLibrary ] - [ BuildFeatureAttribute mesa : galliumLlvmpipeLibrary ] - [ BuildFeatureAttribute mesa : mesaLibrary ] - [ BuildFeatureAttribute mesa : glslLibrary ] - [ BuildFeatureAttribute mesa : galliumLibrary ] - $(HAIKU_LLVM_LIBS) - be translation stdc++ $(TARGET_LIBSUPC++) -; diff --git a/src/add-ons/opengl/swpipe/SoftwareRenderer.cpp b/src/add-ons/opengl/swpipe/SoftwareRenderer.cpp deleted file mode 100644 index e9c133ae0b..0000000000 --- a/src/add-ons/opengl/swpipe/SoftwareRenderer.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright 2006-2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Jérôme Duval, korli@users.berlios.de - * Philippe Houdoin, philippe.houdoin@free.fr - * Artur Wyszynski, harakash@gmail.com - * Alexander von Gluck IV, kallisti5@unixzen.com - */ - - -#include "SoftwareRenderer.h" - -#include -#include -#include -#include -#include -#include -#include - - -#define TRACE_SOFTWARE -#ifdef TRACE_SOFTWARE -# define TRACE(x...) printf("SoftwareRenderer: " x) -# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__) -#else -# define TRACE(x...) -# define CALLED() -#endif -#define ERROR(x...) printf("SoftwareRenderer: " x) - - -extern const char* color_space_name(color_space space); - - -extern "C" _EXPORT BGLRenderer* -instantiate_gl_renderer(BGLView *view, ulong opts, BGLDispatcher *dispatcher) -{ - return new SoftwareRenderer(view, opts, dispatcher); -} - -SoftwareRenderer::SoftwareRenderer(BGLView *view, ulong options, - BGLDispatcher* dispatcher) - : - BGLRenderer(view, options, dispatcher), - fBitmap(NULL), - fDirectModeEnabled(false), - fInfo(NULL), - fInfoLocker("info locker"), - fOptions(options), - fColorSpace(B_NO_COLOR_SPACE) -{ - CALLED(); - - // Disable double buffer for the moment. - options &= ~BGL_DOUBLE; - - // Initialize the "Haiku Software GL Pipe" - time_t beg; - time_t end; - beg = time(NULL); - fContextObj = new GalliumContext(options); - end = time(NULL); - TRACE("Haiku Software GL Pipe initialization time: %f.\n", - difftime(end, beg)); - - // Allocate a bitmap - BRect b = view->Bounds(); - fColorSpace = BScreen(view->Window()).ColorSpace(); - TRACE("%s: Colorspace:\t%s\n", __func__, color_space_name(fColorSpace)); - - fWidth = (GLint)b.IntegerWidth(); - fHeight = (GLint)b.IntegerHeight(); - fNewWidth = fWidth; - fNewHeight = fHeight; - - _AllocateBitmap(); - - // Initialize the first "Haiku Software GL Pipe" context - beg = time(NULL); - fContextID = fContextObj->CreateContext(fBitmap); - end = time(NULL); - - if (fContextID < 0) - ERROR("%s: There was an error creating the context!\n", __func__); - else { - TRACE("%s: Haiku Software GL Pipe context creation time: %f.\n", - __func__, difftime(end, beg)); - } - - if (!fContextObj->GetCurrentContext()) - LockGL(); -} - - -SoftwareRenderer::~SoftwareRenderer() -{ - CALLED(); - - if (fContextObj) - delete fContextObj; - if (fBitmap) - delete fBitmap; -} - - -void -SoftwareRenderer::LockGL() -{ -// CALLED(); - BGLRenderer::LockGL(); - - color_space cs = BScreen(GLView()->Window()).ColorSpace(); - - BAutolock lock(fInfoLocker); - if (fDirectModeEnabled && fInfo != NULL) { - fNewWidth = fInfo->window_bounds.right - fInfo->window_bounds.left; - // + 1; - fNewHeight = fInfo->window_bounds.bottom - fInfo->window_bounds.top; - // + 1; - } - - if (fBitmap && cs == fColorSpace && fNewWidth == fWidth - && fNewHeight == fHeight) { - fContextObj->SetCurrentContext(fBitmap, fContextID); - return; - } - - fColorSpace = cs; - fWidth = fNewWidth; - fHeight = fNewHeight; - - _AllocateBitmap(); - fContextObj->SetCurrentContext(fBitmap, fContextID); -} - - -void -SoftwareRenderer::UnlockGL() -{ -// CALLED(); - if ((fOptions & BGL_DOUBLE) == 0) { - SwapBuffers(); - } - fContextObj->SetCurrentContext(NULL, fContextID); - BGLRenderer::UnlockGL(); -} - - -void -SoftwareRenderer::SwapBuffers(bool vsync) -{ -// CALLED(); - if (!fBitmap) - return; - - BScreen screen(GLView()->Window()); - - fContextObj->SwapBuffers(fContextID); - - BAutolock lock(fInfoLocker); - - if (!fDirectModeEnabled || fInfo == NULL) { - if (GLView()->LockLooperWithTimeout(1000) == B_OK) { - GLView()->DrawBitmap(fBitmap, B_ORIGIN); - GLView()->UnlockLooper(); - if (vsync) - screen.WaitForRetrace(); - } - return; - } - - // check the bitmap size still matches the size - if (fInfo->window_bounds.bottom - fInfo->window_bounds.top - != fBitmap->Bounds().IntegerHeight() - || fInfo->window_bounds.right - fInfo->window_bounds.left - != fBitmap->Bounds().IntegerWidth()) { - ERROR("%s: Bitmap size doesn't match size!\n", __func__); - return; - } - uint8 bytesPerPixel = fInfo->bits_per_pixel / 8; - uint32 bytesPerRow = fBitmap->BytesPerRow(); - for (uint32 i = 0; i < fInfo->clip_list_count; i++) { - clipping_rect *clip = &fInfo->clip_list[i]; - 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++) { - memcpy(p, b, bytesWidth); - p += fInfo->bytes_per_row; - b += bytesPerRow; - } - } - - if (vsync) - screen.WaitForRetrace(); -} - - -void -SoftwareRenderer::Draw(BRect updateRect) -{ -// CALLED(); - if ((!fDirectModeEnabled || fInfo == NULL) && fBitmap) - GLView()->DrawBitmap(fBitmap, updateRect, updateRect); -} - - -status_t -SoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap) -{ - CALLED(); - color_space scs = fBitmap->ColorSpace(); - color_space dcs = bitmap->ColorSpace(); - - if (scs != dcs && (scs != B_RGBA32 || dcs != B_RGB32)) { - ERROR("%s::CopyPixelsOut(): incompatible color space: %s != %s\n", - __PRETTY_FUNCTION__, color_space_name(scs), color_space_name(dcs)); - return B_BAD_TYPE; - } - - BRect sr = fBitmap->Bounds(); - BRect dr = bitmap->Bounds(); - -// int32 w1 = sr.IntegerWidth(); -// int32 h1 = sr.IntegerHeight(); -// int32 w2 = dr.IntegerWidth(); -// int32 h2 = dr.IntegerHeight(); - - sr = sr & dr.OffsetBySelf(location); - dr = sr.OffsetByCopy(-location.x, -location.y); - - uint8 *ps = (uint8 *) fBitmap->Bits(); - uint8 *pd = (uint8 *) bitmap->Bits(); - uint32 *s, *d; - uint32 y; - for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) { - s = (uint32 *)(ps + y * fBitmap->BytesPerRow()); - s += (uint32) sr.left; - - d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top)) - * bitmap->BytesPerRow()); - d += (uint32) dr.left; - memcpy(d, s, dr.IntegerWidth() * 4); - } - - return B_OK; -} - - -status_t -SoftwareRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location) -{ - CALLED(); - - color_space sourceCS = bitmap->ColorSpace(); - color_space destinationCS = fBitmap->ColorSpace(); - - if (sourceCS != destinationCS - && (sourceCS != B_RGB32 || destinationCS != B_RGBA32)) { - ERROR("%s::CopyPixelsIn(): incompatible color space: %s != %s\n", - __PRETTY_FUNCTION__, color_space_name(sourceCS), - color_space_name(destinationCS)); - return B_BAD_TYPE; - } - - BRect sr = bitmap->Bounds(); - BRect dr = fBitmap->Bounds(); - - sr = sr & dr.OffsetBySelf(location); - dr = sr.OffsetByCopy(-location.x, -location.y); - - uint8 *ps = (uint8 *) bitmap->Bits(); - uint8 *pd = (uint8 *) fBitmap->Bits(); - uint32 *s, *d; - uint32 y; - - for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) { - s = (uint32 *)(ps + y * bitmap->BytesPerRow()); - s += (uint32) sr.left; - - d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top)) - * fBitmap->BytesPerRow()); - d += (uint32) dr.left; - - memcpy(d, s, dr.IntegerWidth() * 4); - } - - return B_OK; -} - - -void -SoftwareRenderer::EnableDirectMode(bool enabled) -{ - fDirectModeEnabled = enabled; -} - - -void -SoftwareRenderer::DirectConnected(direct_buffer_info *info) -{ -// CALLED(); - BAutolock lock(fInfoLocker); - if (info) { - if (!fInfo) { - fInfo = (direct_buffer_info *)calloc(1, - DIRECT_BUFFER_INFO_AREA_SIZE); - } - memcpy(fInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); - } else if (fInfo) { - free(fInfo); - fInfo = NULL; - } -} - - -void -SoftwareRenderer::FrameResized(float width, float height) -{ -// CALLED(); - BAutolock lock(fInfoLocker); - fNewWidth = (GLuint)width; - fNewHeight = (GLuint)height; -} - - -void -SoftwareRenderer::_AllocateBitmap() -{ -// CALLED(); - - // allocate new size of back buffer bitmap - BAutolock lock(fInfoLocker); - delete fBitmap; - fBitmap = NULL; - if (fWidth < 1 || fHeight < 1) { - TRACE("%s: Can't allocate bitmap of %dx%d\n", __func__, - fWidth, fHeight); - return; - } - BRect rect(0.0, 0.0, fWidth, fHeight); - fBitmap = new (std::nothrow) BBitmap(rect, fColorSpace); - if (fBitmap == NULL) { - TRACE("%s: Can't create bitmap!\n", __func__); - return; - } - -#if 0 - // debug.. - void *data = fBitmap->Bits(); - memset(data, 0xcc, fBitmap->BitsLength()); -#endif -} diff --git a/src/add-ons/opengl/swpipe/SoftwareRenderer.h b/src/add-ons/opengl/swpipe/SoftwareRenderer.h deleted file mode 100644 index bb0066bf05..0000000000 --- a/src/add-ons/opengl/swpipe/SoftwareRenderer.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2006-2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Jérôme Duval, korli@users.berlios.de - * Philippe Houdoin, philippe.houdoin@free.fr - * Artur Wyszynski, harakash@gmail.com - * Alexander von Gluck IV, kallisti5@unixzen.com - */ -#ifndef SOFTWARERENDERER_H -#define SOFTWARERENDERER_H - - -#include "GLRenderer.h" -#include "GalliumContext.h" - - -class SoftwareRenderer : public BGLRenderer { -public: - SoftwareRenderer(BGLView *view, - ulong bgl_options, - BGLDispatcher *dispatcher); - virtual ~SoftwareRenderer(); - - virtual void LockGL(); - virtual void UnlockGL(); - - virtual void SwapBuffers(bool vsync = false); - virtual void Draw(BRect updateRect); - virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest); - virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest); - virtual void FrameResized(float width, float height); - - virtual void EnableDirectMode(bool enabled); - virtual void DirectConnected(direct_buffer_info *info); - -private: - - void _AllocateBitmap(); - - GalliumContext* fContextObj; - BBitmap* fBitmap; - context_id fContextID; - - bool fDirectModeEnabled; - direct_buffer_info* fInfo; - BLocker fInfoLocker; - ulong fOptions; - GLuint fWidth; - GLuint fHeight; - GLuint fNewWidth; - GLuint fNewHeight; - color_space fColorSpace; -}; - -#endif // SOFTPIPERENDERER_H diff --git a/src/add-ons/opengl/swpipe/SoftwareRenderer.rdef b/src/add-ons/opengl/swpipe/SoftwareRenderer.rdef deleted file mode 100644 index f9d01b2609..0000000000 --- a/src/add-ons/opengl/swpipe/SoftwareRenderer.rdef +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - */ - -resource app_signature "application/x-vnd.Haiku-swpipe"; - -resource app_version { - major = 9, - middle = 0, - minor = 0, - variety = 0, - internal = 0, - short_info = "Software Renderer", - long_info = "Haiku Gallium Software GL Renderer" -}; - -resource vector_icon { - $"6E6369660A0200140294A9FF18020014028DFFFF97058C0500020006023B10B7" - $"37F036BA1A993D466848C719BEBE2000919292FFD5D5D5020016023900000000" - $"000000003EE0004AE00048E0005EF884C702000203392E8D383001BAD97F3C12" - $"8B4786BD48B8AD0D97BBFFFF7B4168DBE9FF4168DB97020002023A0C1238D099" - $"BE44203F4BD14B38844678240DF56A7D9FE1EA064CC704016B0500090A044024" - $"2438404C5C380A044028243C40505C3C0A042438243B5C3C5C380608BFBE4D59" - $"4D59515957575659585560406044603C5E3A5C3CCB4FBFBA5E3ECA9DC11F564B" - $"584A544C504C0606AF0F2F3D2F3D393D4034BF593542324130432F42364432C0" - $"3FBC5A2F48354A2F480608AE9A22303EB5BD3AB42542B755422E412F3C29322D" - $"32223C0204263726372538263F253E263F304430443143303C313D303C02043D" - $"423D423C433D4A3C493D4A495049504A4F49474A484947060DAEAAAE014E445A" - $"3456365E325E3D5D3F5A3A5542544E4D573A4E364439463342324A2242310A0A" - $"0002020102403CA00C88888C8CC1401673C40D6544F2950A01010002403CA000" - $"0000000000401673C40D65446CF80A08020304023EC16A0000000000003EC16A" - $"45DD1844C6550A030105123EC16A0000000000003EC16A45DD1844C655011784" - $"22040A040105023EC16A0000000000003EC16A45DD1844C6550A030108123EC1" - $"6A0000000000003EC16A45DD1844C65501178422040A0503080706023EC16A00" - $"00000000003EC16A45DD1844C6550A030206071A3EC16A0000000000003EC16A" - $"45DD1844C65510FF0215810004178222040A060106023EC16A0000000000003E" - $"C16A45DD1844C6550A070107023EC16A0000000000003EC16A45DD1844C655" -}; diff --git a/src/add-ons/opengl/swpipe/SoftwareWinsys.cpp b/src/add-ons/opengl/swpipe/SoftwareWinsys.cpp deleted file mode 100644 index 420eb96e6c..0000000000 --- a/src/add-ons/opengl/swpipe/SoftwareWinsys.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2006-2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Artur Wyszynski, harakash@gmail.com - * Alexander von Gluck IV, kallisti5@unixzen.com - */ - - -#include "SoftwareWinsys.h" - -#include - -#include "bitmap_wrapper.h" -extern "C" { -#include "state_tracker/st_api.h" -#include "state_tracker/sw_winsys.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -} - - -#define TRACE_WINSYS -#ifdef TRACE_WINSYS -# define TRACE(x...) printf("GalliumWinsys: " x) -# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__) -#else -# define TRACE(x...) -# define CALLED() -#endif -#define ERROR(x...) printf("GalliumWinsys: " x) - - -// Cast -static INLINE struct haiku_displaytarget* -cast_haiku_displaytarget(struct sw_displaytarget* target) -{ - return (struct haiku_displaytarget *)target; -} - - -static void -hook_winsys_destroy(struct sw_winsys* winsys) -{ - CALLED(); - FREE(winsys); -} - - -static boolean -hook_winsys_is_displaytarget_format_supported(struct sw_winsys* winsys, - unsigned textureUsage, enum pipe_format format) -{ - CALLED(); - // TODO STUB - return true; -} - - -static struct sw_displaytarget* -hook_winsys_displaytarget_create(struct sw_winsys* winsys, - unsigned textureUsage, enum pipe_format format, unsigned width, - unsigned height, unsigned alignment, unsigned* stride) -{ - TRACE("%s: %dx%d\n", __func__, width, height); - - struct haiku_displaytarget* haikuDisplayTarget - = CALLOC_STRUCT(haiku_displaytarget); - - if (!haikuDisplayTarget) { - ERROR("%s: Couldn't allocate Haiku display target!\n", - __func__); - return NULL; - } - - haikuDisplayTarget->format = format; - haikuDisplayTarget->width = width; - haikuDisplayTarget->height = height; - - unsigned formatStride = util_format_get_stride(format, width); - unsigned blockSize = util_format_get_nblocksy(format, height); - - haikuDisplayTarget->stride = align(formatStride, alignment); - haikuDisplayTarget->size = haikuDisplayTarget->stride * blockSize; - - haikuDisplayTarget->data - = align_malloc(haikuDisplayTarget->size, alignment); - - if (!haikuDisplayTarget->data) { - ERROR("%s: Couldn't allocate Haiku display target data!\n", - __func__); - FREE(haikuDisplayTarget); - return NULL; - } - - *stride = haikuDisplayTarget->stride; - - // Cast to ghost sw_displaytarget type - return (struct sw_displaytarget*)haikuDisplayTarget; -} - - -static void -hook_winsys_displaytarget_destroy(struct sw_winsys* winsys, - struct sw_displaytarget* displayTarget) -{ - CALLED(); - - struct haiku_displaytarget* haikuDisplayTarget - = cast_haiku_displaytarget(displayTarget); - - if (!haikuDisplayTarget) { - ERROR("%s: Attempt to destroy non-existant display target!\n", - __func__); - return; - } - - if (haikuDisplayTarget->data != NULL) - align_free(haikuDisplayTarget->data); - - FREE(haikuDisplayTarget); -} - - -static struct sw_displaytarget* -hook_winsys_displaytarget_from_handle(struct sw_winsys* winsys, - const struct pipe_resource* templat, struct winsys_handle* whandle, - unsigned* stride) -{ - CALLED(); - return NULL; -} - - -static boolean -hook_winsys_displaytarget_get_handle(struct sw_winsys* winsys, - struct sw_displaytarget* displayTarget, struct winsys_handle* whandle) -{ - CALLED(); - return FALSE; -} - - -static void* -hook_winsys_displaytarget_map(struct sw_winsys* winsys, - struct sw_displaytarget* displayTarget, unsigned flags) -{ - CALLED(); - struct haiku_displaytarget* haikuDisplayTarget - = cast_haiku_displaytarget(displayTarget); - - return haikuDisplayTarget->data; -} - - -static void -hook_winsys_displaytarget_unmap(struct sw_winsys* winsys, - struct sw_displaytarget* disptarget) -{ - return; -} - - -static void -hook_winsys_displaytarget_display(struct sw_winsys* winsys, - struct sw_displaytarget* displayTarget, void* contextPrivate) -{ - CALLED(); - - if (!contextPrivate) { - ERROR("%s: Passed invalid private pointer!\n", __func__); - return; - } - - Bitmap* bitmap = (Bitmap*)contextPrivate; - - struct haiku_displaytarget* haikuDisplayTarget - = cast_haiku_displaytarget(displayTarget); - - copy_bitmap_bits(bitmap, haikuDisplayTarget->data, - haikuDisplayTarget->size); - - return; -} - - -struct sw_winsys* -winsys_connect_hooks() -{ - CALLED(); - - struct sw_winsys* winsys = CALLOC_STRUCT(sw_winsys); - - if (!winsys) - return NULL; - - // Attach winsys hooks for Haiku - winsys->destroy = hook_winsys_destroy; - winsys->is_displaytarget_format_supported - = hook_winsys_is_displaytarget_format_supported; - winsys->displaytarget_create = hook_winsys_displaytarget_create; - winsys->displaytarget_from_handle = hook_winsys_displaytarget_from_handle; - winsys->displaytarget_get_handle = hook_winsys_displaytarget_get_handle; - winsys->displaytarget_map = hook_winsys_displaytarget_map; - winsys->displaytarget_unmap = hook_winsys_displaytarget_unmap; - winsys->displaytarget_display = hook_winsys_displaytarget_display; - winsys->displaytarget_destroy = hook_winsys_displaytarget_destroy; - - return winsys; -} diff --git a/src/add-ons/opengl/swpipe/SoftwareWinsys.h b/src/add-ons/opengl/swpipe/SoftwareWinsys.h deleted file mode 100644 index 2cf1b8eaf5..0000000000 --- a/src/add-ons/opengl/swpipe/SoftwareWinsys.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2006-2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Alexander von Gluck IV, kallisti5@unixzen.com - */ -#ifndef SOFTWAREWINSYS_H -#define SOFTWAREWINSYS_H - - -extern "C" { -#include "pipe/p_defines.h" -#include "state_tracker/st_api.h" -#include "state_tracker/sw_winsys.h" -} - - -struct haiku_displaytarget -{ - enum pipe_format format; - unsigned width; - unsigned height; - unsigned stride; - - unsigned size; - - void* data; -}; - - -struct sw_winsys* winsys_connect_hooks(); - - -#endif \ No newline at end of file diff --git a/src/add-ons/opengl/swpipe/bitmap_wrapper.cpp b/src/add-ons/opengl/swpipe/bitmap_wrapper.cpp deleted file mode 100644 index 10726bd640..0000000000 --- a/src/add-ons/opengl/swpipe/bitmap_wrapper.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2009, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Based on gallium gdi winsys - * - * Authors: - * Artur Wyszynski - */ - - -#include -#include -#include -#include -#include -#include -#include "bitmap_wrapper.h" - - -extern "C" { -static int frameNo = 0; - - -Bitmap* -create_bitmap(int32 width, int32 height, color_space colorSpace) -{ - BBitmap *bb = new BBitmap(BRect(0, 0, width, height), colorSpace); - if (bb) - return (Bitmap*)bb; - return NULL; -} - - -void -get_bitmap_size(const Bitmap* bitmap, int32* width, int32* height) -{ - BBitmap *bb = (BBitmap*)bitmap; - if (bb && width && height) { - uint32 w = bb->Bounds().IntegerWidth() + 1; - uint32 h = bb->Bounds().IntegerHeight() + 1; - *width = w; - *height = h; - } -} - - -color_space -get_bitmap_color_space(const Bitmap* bitmap) -{ - BBitmap *bb = (BBitmap*)bitmap; - if (bb) - return bb->ColorSpace(); - return B_NO_COLOR_SPACE; -} - - -void -copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length) -{ - BBitmap *bb = (BBitmap*)bitmap; - if (bb) { - color_space cs = bb->ColorSpace(); - bb->ImportBits(data, length, bb->BytesPerRow(), 0, cs); - } -} - - -void -delete_bitmap(Bitmap* bitmap) -{ - BBitmap *bb = (BBitmap*)bitmap; - delete bb; -} - - -int32 -get_bitmap_bytes_per_row(const Bitmap* bitmap) -{ - BBitmap *bb = (BBitmap*)bitmap; - if (bb) - return bb->BytesPerRow(); - return 0; -} - - -int32 -get_bitmap_bits_length(const Bitmap* bitmap) -{ - BBitmap *bb = (BBitmap*)bitmap; - if (bb) - return bb->BitsLength(); - return 0; -} - - -void -dump_bitmap(const Bitmap* bitmap) -{ - - BBitmap *bb = (BBitmap*)bitmap; - if (!bb) - return; - - BString filename("/boot/home/frame_"); - filename << (int32)frameNo << ".png"; - - BTranslatorRoster *roster = BTranslatorRoster::Default(); - BBitmapStream stream(bb); - BFile dump(filename, B_CREATE_FILE | B_WRITE_ONLY); - - roster->Translate(&stream, NULL, NULL, &dump, 0); - - frameNo++; -} - -} diff --git a/src/add-ons/opengl/swpipe/bitmap_wrapper.h b/src/add-ons/opengl/swpipe/bitmap_wrapper.h deleted file mode 100644 index ad103ae688..0000000000 --- a/src/add-ons/opengl/swpipe/bitmap_wrapper.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2009, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Based on gallium gdi winsys - * - * Authors: - * Artur Wyszynski - */ -#ifndef __BBITMAP_WRAPPER_H__ -#define __BBITMAP_WRAPPER_H__ - - -#include -#include - - -typedef void Bitmap; - -#ifdef __cplusplus -extern "C" { -#endif - - -Bitmap* create_bitmap(int32 width, int32 height, color_space colorSpace); -void copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length); - -void get_bitmap_size(const Bitmap* bitmap, int32* width, int32* height); -color_space get_bitmap_color_space(const Bitmap* bitmap); -int32 get_bitmap_bytes_per_row(const Bitmap* bitmap); -int32 get_bitmap_bits_length(const Bitmap* bitmap); - -void delete_bitmap(Bitmap* bitmap); -void dump_bitmap(const Bitmap* bitmap); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __BBITMAP_WRAPPER_H__ */ diff --git a/src/add-ons/opengl/swrast/Jamfile b/src/add-ons/opengl/swrast/Jamfile deleted file mode 100644 index 90e0c0b510..0000000000 --- a/src/add-ons/opengl/swrast/Jamfile +++ /dev/null @@ -1,35 +0,0 @@ -SubDir HAIKU_TOP src add-ons opengl swrast ; - -SetSubDirSupportedPlatformsBeOSCompatible ; - -if $(TARGET_PLATFORM) != haiku { - UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ; - # We need our public GL headers also when not compiling for Haiku. -} - - -local defines = BEOS_THREADS GNU_ASSEMBLER ; -SubDirC++Flags [ FDefines $(defines) ] ; - -local sources = MesaSoftwareRenderer.cpp ; - -UsePrivateHeaders interface ; -UseBuildFeatureHeaders mesa ; -Includes [ FGristFiles $(sources) ] : [ BuildFeatureAttribute mesa : headers ] ; - -UseHeaders [ BuildFeatureAttribute mesa : headers : path ] ; -local privateHeaders = [ BuildFeatureAttribute mesa : privateHeaders : path ] ; -UseHeaders [ FDirName $(privateHeaders) mesa ] ; -UseHeaders [ FDirName $(privateHeaders) mesa main ] ; -UseHeaders [ FDirName $(privateHeaders) mapi ] ; -UseHeaders [ FDirName $(privateHeaders) mapi glapi ] ; - -AddResources Software\ Rasterizer : MesaSoftwareRenderer.rdef ; - -Addon Software\ Rasterizer : - MesaSoftwareRenderer.cpp - : - [ BuildFeatureAttribute mesa : mesaLibrary ] - [ BuildFeatureAttribute mesa : glslLibrary ] - libGL.so be $(TARGET_LIBSUPC++) -; diff --git a/src/add-ons/opengl/swrast/MesaSoftwareRenderer.cpp b/src/add-ons/opengl/swrast/MesaSoftwareRenderer.cpp deleted file mode 100644 index bfa526aad1..0000000000 --- a/src/add-ons/opengl/swrast/MesaSoftwareRenderer.cpp +++ /dev/null @@ -1,723 +0,0 @@ -/* - * Copyright 2006-2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Jérôme Duval, korli@users.berlios.de - * Philippe Houdoin, philippe.houdoin@free.fr - * Artur Wyszynski, harakash@gmail.com - * Alexander von Gluck, kallisti5@unixzen.com - */ - - -#include "MesaSoftwareRenderer.h" - -#include -#include -#include -#include -#include -#include - -extern "C" { -#include "extensions.h" -#include "drivers/common/driverfuncs.h" -#include "drivers/common/meta.h" -#include "main/api_exec.h" -#include "main/colormac.h" -#include "main/cpuinfo.h" -#include "main/buffers.h" -#include "main/formats.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/version.h" -#include "main/vtxfmt.h" -#include "swrast/swrast.h" -#include "swrast/s_renderbuffer.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "vbo/vbo.h" - - -//#define TRACE_SOFTGL -#ifdef TRACE_SOFTGL -# define TRACE(x...) printf("MesaSoftwareRenderer: " x) -# define CALLED() printf("MesaSoftwareRenderer: %s\n", __PRETTY_FUNCTION__) -#else -# define TRACE(x...) -# define CALLED() -#endif - -#define ERROR(x...) printf("MesaSoftwareRenderer: " x) -} - - -extern const char* color_space_name(color_space space); - - -extern "C" _EXPORT BGLRenderer* -instantiate_gl_renderer(BGLView* view, ulong options, - BGLDispatcher* dispatcher) -{ - return new MesaSoftwareRenderer(view, options, dispatcher); -} - - -MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options, - BGLDispatcher* dispatcher) - : BGLRenderer(view, options, dispatcher), - fBitmap(NULL), - fDirectModeEnabled(false), - fInfo(NULL), - fInfoLocker("info locker"), - fContext(NULL), - fVisual(NULL), - fFrameBuffer(NULL), - fFrontRenderBuffer(NULL), - fBackRenderBuffer(NULL), - fColorSpace(B_NO_COLOR_SPACE) -{ - CALLED(); - - fColorSpace = BScreen(GLView()->Window()).ColorSpace(); - - // We force single buffering for the time being - options &= ~BGL_DOUBLE; - - const GLboolean rgbFlag = ((options & BGL_INDEX) == 0); - const GLboolean alphaFlag = ((options & BGL_ALPHA) == BGL_ALPHA); - const GLboolean dblFlag = ((options & BGL_DOUBLE) == BGL_DOUBLE); - const GLboolean stereoFlag = false; - const GLint depth = (options & BGL_DEPTH) ? 16 : 0; - const GLint stencil = (options & BGL_STENCIL) ? 8 : 0; - const GLint accum = (options & BGL_ACCUM) ? 16 : 0; - const GLint red = rgbFlag ? 8 : 0; - const GLint green = rgbFlag ? 8 : 0; - const GLint blue = rgbFlag ? 8 : 0; - const GLint alpha = alphaFlag ? 8 : 0; - - fOptions = options; // | BGL_INDIRECT; - struct dd_function_table functions; - - fVisual = _mesa_create_visual(dblFlag, stereoFlag, red, green, - blue, alpha, depth, stencil, accum, accum, accum, - alpha ? accum : 0, 1); - - // Initialize device driver function table - _mesa_init_driver_functions(&functions); - - functions.GetString = _GetString; - functions.UpdateState = _UpdateState; - functions.MapRenderbuffer = _RenderBufferMap; - functions.GetBufferSize = NULL; - functions.Error = _Error; - functions.Flush = _Flush; - - // create core context - fContext = _mesa_create_context(API_OPENGL_COMPAT, fVisual, NULL, - &functions); - - if (!fContext) { - ERROR("%s: Failed to create Mesa context!\n", __func__); - _mesa_destroy_visual(fVisual); - return; - } - - /* Initialize the software rasterizer and helper modules. */ - _swrast_CreateContext(fContext); - _vbo_CreateContext(fContext); - _tnl_CreateContext(fContext); - _swsetup_CreateContext(fContext); - _swsetup_Wakeup(fContext); - - // Use default TCL pipeline - TNL_CONTEXT(fContext)->Driver.RunPipeline = _tnl_run_pipeline; - - _mesa_meta_init(fContext); - _mesa_enable_sw_extensions(fContext); - _mesa_enable_1_3_extensions(fContext); - _mesa_enable_1_4_extensions(fContext); - _mesa_enable_1_5_extensions(fContext); - _mesa_enable_2_0_extensions(fContext); - _mesa_enable_2_1_extensions(fContext); - - _mesa_compute_version(fContext); - - _mesa_initialize_dispatch_tables(fContext); - _mesa_initialize_vbo_vtxfmt(fContext); - - // create core framebuffer - fFrameBuffer = _mesa_create_framebuffer(fVisual); - if (fFrameBuffer == NULL) { - ERROR("%s: Unable to calloc GL FrameBuffer!\n", __func__); - _mesa_destroy_visual(fVisual); - return; - } - - // Setup front render buffer - fFrontRenderBuffer = _NewRenderBuffer(true); - if (fFrontRenderBuffer == NULL) { - ERROR("%s: FrontRenderBuffer is requested but unallocated!\n", - __func__); - _mesa_destroy_visual(fVisual); - free(fFrameBuffer); - return; - } - _mesa_add_renderbuffer(fFrameBuffer, BUFFER_FRONT_LEFT, - &fFrontRenderBuffer->Base); - - // Setup back render buffer (if requested) - if (fVisual->doubleBufferMode) { - fBackRenderBuffer = _NewRenderBuffer(false); - if (fBackRenderBuffer == NULL) { - ERROR("%s: BackRenderBuffer is requested but unallocated!\n", - __func__); - _mesa_destroy_visual(fVisual); - free(fFrameBuffer); - return; - } - _mesa_add_renderbuffer(fFrameBuffer, BUFFER_BACK_LEFT, - &fBackRenderBuffer->Base); - } - - _swrast_add_soft_renderbuffers(fFrameBuffer, GL_FALSE, - fVisual->haveDepthBuffer, fVisual->haveStencilBuffer, - fVisual->haveAccumBuffer, alphaFlag, GL_FALSE); - - BRect bounds = view->Bounds(); - fWidth = (GLint)bounds.Width(); - fHeight = (GLint)bounds.Height(); - - // some stupid applications (Quake2) don't even think about calling LockGL() - // before using glGetString and its glGet*() friends... - // so make sure there is at least a valid context. - - if (!_mesa_get_current_context()) { - LockGL(); - // not needed, we don't have a looper yet: UnlockLooper(); - } -} - - -MesaSoftwareRenderer::~MesaSoftwareRenderer() -{ - CALLED(); - _swsetup_DestroyContext(fContext); - _swrast_DestroyContext(fContext); - _tnl_DestroyContext(fContext); - _vbo_DestroyContext(fContext); - _mesa_destroy_visual(fVisual); - _mesa_destroy_framebuffer(fFrameBuffer); - _mesa_destroy_context(fContext); - - free(fInfo); - free(fFrameBuffer); - - delete fBitmap; -} - - -void -MesaSoftwareRenderer::LockGL() -{ - CALLED(); - BGLRenderer::LockGL(); - - _mesa_make_current(fContext, fFrameBuffer, fFrameBuffer); - - color_space colorSpace = BScreen(GLView()->Window()).ColorSpace(); - - GLuint width = fWidth; - GLuint height = fHeight; - - BAutolock lock(fInfoLocker); - if (fDirectModeEnabled && fInfo != NULL) { - width = fInfo->window_bounds.right - - fInfo->window_bounds.left + 1; - height = fInfo->window_bounds.bottom - - fInfo->window_bounds.top + 1; - } - - if (fColorSpace != colorSpace) { - fColorSpace = colorSpace; - _SetupRenderBuffer(&fFrontRenderBuffer->Base, fColorSpace); - if (fVisual->doubleBufferMode) - _SetupRenderBuffer(&fBackRenderBuffer->Base, fColorSpace); - } - - _CheckResize(width, height); -} - - -void -MesaSoftwareRenderer::UnlockGL() -{ - CALLED(); - _mesa_make_current(fContext, NULL, NULL); - BGLRenderer::UnlockGL(); -} - - -void -MesaSoftwareRenderer::SwapBuffers(bool VSync) -{ - CALLED(); - - if (!fBitmap) - return; - - if (fVisual->doubleBufferMode) - _mesa_notifySwapBuffers(fContext); - - if (!fDirectModeEnabled || fInfo == NULL) { - if (GLView()->LockLooperWithTimeout(1000) == B_OK) { - GLView()->DrawBitmap(fBitmap, B_ORIGIN); - GLView()->UnlockLooper(); - } - } else { - // TODO: Here the BGLView needs to be drawlocked. - _CopyToDirect(); - } - - if (VSync) { - BScreen screen(GLView()->Window()); - screen.WaitForRetrace(); - } -} - - -void -MesaSoftwareRenderer::Draw(BRect updateRect) -{ - CALLED(); - if (fBitmap && (!fDirectModeEnabled || (fInfo == NULL))) - GLView()->DrawBitmap(fBitmap, updateRect, updateRect); -} - - -status_t -MesaSoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap* bitmap) -{ - CALLED(); - color_space scs = fBitmap->ColorSpace(); - color_space dcs = bitmap->ColorSpace(); - - if (scs != dcs && (scs != B_RGBA32 || dcs != B_RGB32)) { - fprintf(stderr, "CopyPixelsOut(): incompatible color space: %s != %s\n", - color_space_name(scs), - color_space_name(dcs)); - return B_BAD_TYPE; - } - - BRect sr = fBitmap->Bounds(); - BRect dr = bitmap->Bounds(); - - sr = sr & dr.OffsetBySelf(location); - dr = sr.OffsetByCopy(-location.x, -location.y); - - uint8* ps = (uint8*)fBitmap->Bits(); - uint8* pd = (uint8*)bitmap->Bits(); - uint32* s; - uint32* d; - uint32 y; - for (y = (uint32)sr.top; y <= (uint32)sr.bottom; y++) { - s = (uint32*)(ps + y * fBitmap->BytesPerRow()); - s += (uint32)sr.left; - - d = (uint32*)(pd + (y + (uint32)(dr.top - sr.top)) - * bitmap->BytesPerRow()); - d += (uint32)dr.left; - - memcpy(d, s, dr.IntegerWidth() * 4); - } - return B_OK; -} - - -status_t -MesaSoftwareRenderer::CopyPixelsIn(BBitmap* bitmap, BPoint location) -{ - CALLED(); - color_space scs = bitmap->ColorSpace(); - color_space dcs = fBitmap->ColorSpace(); - - if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) { - fprintf(stderr, "CopyPixelsIn(): incompatible color space: %s != %s\n", - color_space_name(scs), - color_space_name(dcs)); - return B_BAD_TYPE; - } - - BRect sr = bitmap->Bounds(); - BRect dr = fBitmap->Bounds(); - - sr = sr & dr.OffsetBySelf(location); - dr = sr.OffsetByCopy(-location.x, -location.y); - - uint8* ps = (uint8*)bitmap->Bits(); - uint8* pd = (uint8*)fBitmap->Bits(); - uint32* s; - uint32* d; - uint32 y; - for (y = (uint32)sr.top; y <= (uint32)sr.bottom; y++) { - s = (uint32*)(ps + y * bitmap->BytesPerRow()); - s += (uint32)sr.left; - - d = (uint32*)(pd + (y + (uint32)(dr.top - sr.top)) - * fBitmap->BytesPerRow()); - d += (uint32)dr.left; - - memcpy(d, s, dr.IntegerWidth() * 4); - } - return B_OK; -} - - -void -MesaSoftwareRenderer::EnableDirectMode(bool enabled) -{ - fDirectModeEnabled = enabled; -} - - -void -MesaSoftwareRenderer::DirectConnected(direct_buffer_info* info) -{ - // TODO: I'm not sure we need to do this: BGLView already - // keeps a local copy of the direct_buffer_info passed by - // BDirectWindow::DirectConnected(). - BAutolock lock(fInfoLocker); - if (info) { - if (!fInfo) { - fInfo = (direct_buffer_info*)malloc(DIRECT_BUFFER_INFO_AREA_SIZE); - if (!fInfo) - return; - } - memcpy(fInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); - } else if (fInfo) { - free(fInfo); - fInfo = NULL; - } -} - - -void -MesaSoftwareRenderer::FrameResized(float width, float height) -{ - BAutolock lock(fInfoLocker); - _CheckResize((GLuint)width, (GLuint)height); -} - - -void -MesaSoftwareRenderer::_CheckResize(GLuint newWidth, GLuint newHeight) -{ - CALLED(); - - if (fBitmap && newWidth == fWidth - && newHeight == fHeight) { - return; - } - - _mesa_resize_framebuffer(fContext, fFrameBuffer, newWidth, newHeight); - fHeight = newHeight; - fWidth = newWidth; - - _AllocateBitmap(); -} - - -void -MesaSoftwareRenderer::_AllocateBitmap() -{ - CALLED(); - - // allocate new size of back buffer bitmap - delete fBitmap; - fBitmap = NULL; - - if (fWidth < 1 || fHeight < 1) { - TRACE("%s: Cannot allocate bitmap < 1x1!\n", __func__); - return; - } - - BRect rect(0.0, 0.0, fWidth - 1, fHeight - 1); - fBitmap = new BBitmap(rect, fColorSpace); - - #if 0 - // Used for platform optimized drawing - for (uint i = 0; i < fHeight; i++) { - fRowAddr[fHeight - i - 1] = (GLvoid *)((GLubyte *)fBitmap->Bits() - + i * fBitmap->BytesPerRow()); - } - #endif - - fFrameBuffer->Width = fWidth; - fFrameBuffer->Height = fHeight; - TRACE("%s: Bitmap Size: %" B_PRIu32 "\n", __func__, fBitmap->BitsLength()); - - fFrontRenderBuffer->Buffer = (GLubyte*)fBitmap->Bits(); -} - - -// #pragma mark - static - - -void -MesaSoftwareRenderer::_Error(gl_context* ctx) -{ - CALLED(); - #if 0 - // TODO: err. Mesa dropped DriverCtx - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; - if (mr && mr->GLView()) - mr->GLView()->ErrorCallback((unsigned long)ctx->ErrorValue); - #endif -} - - -const GLubyte* -MesaSoftwareRenderer::_GetString(gl_context* ctx, GLenum name) -{ - switch (name) { - case GL_VENDOR: - return (const GLubyte*) "Mesa Project"; - case GL_RENDERER: - return (const GLubyte*) "Software Rasterizer"; - default: - // Let core library handle all other cases - return NULL; - } -} - - -void -MesaSoftwareRenderer::_UpdateState(gl_context* ctx, GLuint new_state) -{ - if (!ctx) - return; - - CALLED(); - _swrast_InvalidateState(ctx, new_state); - _swsetup_InvalidateState(ctx, new_state); - _vbo_InvalidateState(ctx, new_state); - _tnl_InvalidateState(ctx, new_state); -} - - -GLboolean -MesaSoftwareRenderer::_RenderBufferStorage(gl_context* ctx, - struct gl_renderbuffer* render, GLenum internalFormat, - GLuint width, GLuint height) -{ - CALLED(); - - render->Width = width; - render->Height = height; - - struct swrast_renderbuffer *swRenderBuffer = swrast_renderbuffer(render); - - swRenderBuffer->RowStride = width * _mesa_get_format_bytes(render->Format); - - return GL_TRUE; -} - - -GLboolean -MesaSoftwareRenderer::_RenderBufferStorageMalloc(gl_context* ctx, - struct gl_renderbuffer* render, GLenum internalFormat, - GLuint width, GLuint height) -{ - CALLED(); - - render->Width = width; - render->Height = height; - - struct swrast_renderbuffer *swRenderBuffer = swrast_renderbuffer(render); - - if (swRenderBuffer != NULL) { - free(swRenderBuffer->Buffer); - swRenderBuffer->RowStride - = width * _mesa_get_format_bytes(render->Format); - - uint32 size = swRenderBuffer->RowStride * height; - TRACE("%s: Allocate %" B_PRIu32 " bytes for RenderBuffer\n", - __func__, size); - swRenderBuffer->Buffer = (GLubyte*)malloc(size); - if (!swRenderBuffer->Buffer) { - ERROR("%s: Memory allocation failure!\n", __func__); - return GL_FALSE; - } - } else { - ERROR("%s: Couldn't obtain software renderbuffer!\n", - __func__); - return GL_FALSE; - } - - return GL_TRUE; -} - - -void -MesaSoftwareRenderer::_Flush(gl_context* ctx) -{ - CALLED(); - #if 0 - // TODO: err. Mesa dropped DriverCtx - if ((fOptions & BGL_DOUBLE) == 0) { - // TODO: SwapBuffers() can call _CopyToDirect(), which should - // be always called with with the BGLView drawlocked. - // This is not always the case if called from here. - SwapBuffers(); - } - #endif -} - - -struct swrast_renderbuffer* -MesaSoftwareRenderer::_NewRenderBuffer(bool front) -{ - CALLED(); - struct swrast_renderbuffer *swRenderBuffer - = (struct swrast_renderbuffer*)calloc(1, sizeof *swRenderBuffer); - - if (!swRenderBuffer) { - ERROR("%s: Failed calloc RenderBuffer\n", __func__); - return NULL; - } - - _mesa_init_renderbuffer(&swRenderBuffer->Base, 0); - - swRenderBuffer->Base.ClassID = HAIKU_SWRAST_RENDERBUFFER_CLASS; - swRenderBuffer->Base.RefCount = 1; - swRenderBuffer->Base.Delete = _RenderBufferDelete; - - if (!front) - swRenderBuffer->Base.AllocStorage = _RenderBufferStorageMalloc; - else - swRenderBuffer->Base.AllocStorage = _RenderBufferStorage; - - if (_SetupRenderBuffer(&swRenderBuffer->Base, fColorSpace) != B_OK) { - free(swRenderBuffer); - return NULL; - } - - return swRenderBuffer; -} - - -status_t -MesaSoftwareRenderer::_SetupRenderBuffer(struct gl_renderbuffer* rb, - color_space colorSpace) -{ - CALLED(); - - rb->InternalFormat = GL_RGBA; - - switch (colorSpace) { - case B_RGBA32: - rb->_BaseFormat = GL_RGBA; - rb->Format = MESA_FORMAT_ARGB8888; - break; - case B_RGB32: - rb->_BaseFormat = GL_RGB; - rb->Format = MESA_FORMAT_XRGB8888; - break; - case B_RGB24: - rb->_BaseFormat = GL_RGB; - rb->Format = MESA_FORMAT_RGB888; - break; - case B_RGB16: - rb->_BaseFormat = GL_RGB; - rb->Format = MESA_FORMAT_RGB565; - break; - case B_RGB15: - rb->_BaseFormat = GL_RGB; - rb->Format = MESA_FORMAT_ARGB1555; - break; - default: - fprintf(stderr, "Unsupported screen color space %s\n", - color_space_name(fColorSpace)); - debugger("Unsupported OpenGL color space"); - return B_ERROR; - } - return B_OK; -} - - -/*! Y inverted Map RenderBuffer function - We use a BBitmap for storage which has Y inverted. - If the Mesa provided Map function ever allows external - control of this we can omit this function. -*/ -void -MesaSoftwareRenderer::_RenderBufferMap(gl_context *ctx, - struct gl_renderbuffer *rb, GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, GLubyte **mapOut, GLint *rowStrideOut) -{ - if (rb->ClassID == HAIKU_SWRAST_RENDERBUFFER_CLASS) { - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - const GLuint bpp = _mesa_get_format_bytes(rb->Format); - GLint rowStride = rb->Width * bpp; // in Bytes - - y = rb->Height - y - 1; - - *rowStrideOut = -rowStride; - *mapOut = (GLubyte *) srb->Buffer + y * rowStride + x * bpp; - } else { - _swrast_map_soft_renderbuffer(ctx, rb, x, y, w, h, mode, - mapOut, rowStrideOut); - } -} - - -void -MesaSoftwareRenderer::_RenderBufferDelete(struct gl_context *ctx, - struct gl_renderbuffer* rb) -{ - CALLED(); - if (rb != NULL) { - struct swrast_renderbuffer *swRenderBuffer - = swrast_renderbuffer(rb); - if (swRenderBuffer != NULL) - free(swRenderBuffer->Buffer); - } - free(rb); -} - - -void -MesaSoftwareRenderer::_CopyToDirect() -{ - BAutolock lock(fInfoLocker); - - // check the bitmap size still matches the size - if (fInfo->window_bounds.bottom - fInfo->window_bounds.top - != fBitmap->Bounds().IntegerHeight() - || fInfo->window_bounds.right - fInfo->window_bounds.left - != fBitmap->Bounds().IntegerWidth()) - return; - - uint8 bytesPerPixel = fInfo->bits_per_pixel / 8; - uint32 bytesPerRow = fBitmap->BytesPerRow(); - for (uint32 i = 0; i < fInfo->clip_list_count; i++) { - clipping_rect *clip = &fInfo->clip_list[i]; - int32 height = clip->bottom - clip->top + 1; - int32 bytesWidth - = (clip->right - clip->left + 1) * 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; y++) { - memcpy(p, b, bytesWidth); - p += fInfo->bytes_per_row; - b += bytesPerRow; - } - } -} diff --git a/src/add-ons/opengl/swrast/MesaSoftwareRenderer.h b/src/add-ons/opengl/swrast/MesaSoftwareRenderer.h deleted file mode 100644 index ba64751b86..0000000000 --- a/src/add-ons/opengl/swrast/MesaSoftwareRenderer.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2006-2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Jérôme Duval, korli@users.berlios.de - * Philippe Houdoin, philippe.houdoin@free.fr - * Artur Wyszynski, harakash@gmail.com - */ -#ifndef MESASOFTWARERENDERER_H -#define MESASOFTWARERENDERER_H - - -#define HAIKU_SWRAST_RENDERBUFFER_CLASS 0x737752 // swR - - -#include "GLRenderer.h" - -extern "C" { -#include "context.h" -#include "main/version.h" -#include "swrast/s_chan.h" -#include "swrast/s_context.h" -} - - -class MesaSoftwareRenderer : public BGLRenderer { -public: - MesaSoftwareRenderer(BGLView* view, - ulong bgl_options, - BGLDispatcher* dispatcher); - virtual ~MesaSoftwareRenderer(); - - virtual void LockGL(); - virtual void UnlockGL(); - - virtual void SwapBuffers(bool VSync = false); - virtual void Draw(BRect updateRect); - virtual status_t CopyPixelsOut(BPoint source, BBitmap* dest); - virtual status_t CopyPixelsIn(BBitmap* source, BPoint dest); - virtual void FrameResized(float width, float height); - - virtual void EnableDirectMode(bool enabled); - virtual void DirectConnected(direct_buffer_info* info); - -private: - static void _Error(gl_context* ctx); - static const GLubyte* _GetString(gl_context* ctx, GLenum name); - void _CheckResize(GLuint newWidth, GLuint newHeight); - static void _UpdateState(gl_context* ctx, GLuint newState); - static void _Flush(gl_context *ctx); - - struct swrast_renderbuffer* _NewRenderBuffer(bool front); - status_t _SetupRenderBuffer(struct gl_renderbuffer* rb, - color_space colorSpace); - -/* Mesa callbacks */ - static void _RenderBufferDelete(struct gl_context *ctx, - struct gl_renderbuffer* rb); - static GLboolean _RenderBufferStorage(gl_context* ctx, - struct gl_renderbuffer* render, - GLenum internalFormat, - GLuint width, GLuint height); - static GLboolean _RenderBufferStorageMalloc(gl_context* ctx, - struct gl_renderbuffer* render, - GLenum internalFormat, - GLuint width, GLuint height); - static void _RenderBufferMap(gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, GLubyte **mapOut, - GLint *rowStrideOut); - - void _AllocateBitmap(); - void _CopyToDirect(); - - BBitmap* fBitmap; - bool fDirectModeEnabled; - direct_buffer_info* fInfo; - BLocker fInfoLocker; - ulong fOptions; - - gl_context* fContext; - gl_config* fVisual; - - struct gl_framebuffer* fFrameBuffer; - struct swrast_renderbuffer* fFrontRenderBuffer; - struct swrast_renderbuffer* fBackRenderBuffer; - - GLuint fWidth; - GLuint fHeight; - color_space fColorSpace; - - void* fRowAddr[SWRAST_MAX_HEIGHT]; -}; - -#endif // MESASOFTWARERENDERER_H diff --git a/src/add-ons/opengl/swrast/MesaSoftwareRenderer.rdef b/src/add-ons/opengl/swrast/MesaSoftwareRenderer.rdef deleted file mode 100644 index cb60332100..0000000000 --- a/src/add-ons/opengl/swrast/MesaSoftwareRenderer.rdef +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - */ - -resource app_signature "application/x-vnd.Haiku-swrast"; - -resource app_version { - major = 9, - middle = 0, - minor = 0, - variety = 0, - internal = 0, - short_info = "Software Rasterizer", - long_info = "Haiku Mesa Software GL Rasterizer" -}; - -resource vector_icon { - $"6E6369660A0200140294A9FF18020014028DFFFF97058C0500020006023B10B7" - $"37F036BA1A993D466848C719BEBE2000919292FFD5D5D5020016023900000000" - $"000000003EE0004AE00048E0005EF884C702000203392E8D383001BAD97F3C12" - $"8B4786BD48B8AD0D97BBFFFF7B4168DBE9FF4168DB97020002023A0C1238D099" - $"BE44203F4BD14B38844678240DF56A7D9FE1EA064CC704016B0500090A044024" - $"2438404C5C380A044028243C40505C3C0A042438243B5C3C5C380608BFBE4D59" - $"4D59515957575659585560406044603C5E3A5C3CCB4FBFBA5E3ECA9DC11F564B" - $"584A544C504C0606AF0F2F3D2F3D393D4034BF593542324130432F42364432C0" - $"3FBC5A2F48354A2F480608AE9A22303EB5BD3AB42542B755422E412F3C29322D" - $"32223C0204263726372538263F253E263F304430443143303C313D303C02043D" - $"423D423C433D4A3C493D4A495049504A4F49474A484947060DAEAAAE014E445A" - $"3456365E325E3D5D3F5A3A5542544E4D573A4E364439463342324A2242310A0A" - $"0002020102403CA00C88888C8CC1401673C40D6544F2950A01010002403CA000" - $"0000000000401673C40D65446CF80A08020304023EC16A0000000000003EC16A" - $"45DD1844C6550A030105123EC16A0000000000003EC16A45DD1844C655011784" - $"22040A040105023EC16A0000000000003EC16A45DD1844C6550A030108123EC1" - $"6A0000000000003EC16A45DD1844C65501178422040A0503080706023EC16A00" - $"00000000003EC16A45DD1844C6550A030206071A3EC16A0000000000003EC16A" - $"45DD1844C65510FF0215810004178222040A060106023EC16A0000000000003E" - $"C16A45DD1844C6550A070107023EC16A0000000000003EC16A45DD1844C655" -}; diff --git a/src/add-ons/opengl/swrast_legacy/Jamfile b/src/add-ons/opengl/swrast_legacy/Jamfile deleted file mode 100644 index d5080f15d4..0000000000 --- a/src/add-ons/opengl/swrast_legacy/Jamfile +++ /dev/null @@ -1,54 +0,0 @@ -SubDir HAIKU_TOP src add-ons opengl swrast_legacy ; - -SetSubDirSupportedPlatformsBeOSCompatible ; - -if $(TARGET_PLATFORM) != haiku { - UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ; - # We need our public GL headers also when not compiling for Haiku. -} - - -{ - local defines ; - defines = BEOS_THREADS GNU_ASSEMBLER ; - - if $(TARGET_ARCH) = x86 { - defines += USE_X86_ASM USE_MMX_ASM USE_3DNOW_ASM USE_SSE_ASM ; - } else if $(TARGET_ARCH) = ppc { - # Not yet supported, as current Mesa3D PPC assembly is Linux-dependent! - # defines += USE_PPC_ASM ; - } else if $(TARGET_ARCH) = sparc { - defines += USE_SPARC_ASM ; - } - - SubDirC++Flags [ FDefines $(defines) ] ; -} - - -local sources = MesaSoftwareRenderer.cpp ; - -UsePrivateHeaders interface ; -UseBuildFeatureHeaders mesa ; -Includes [ FGristFiles $(sources) ] : [ BuildFeatureAttribute mesa : headers ] ; - -UseHeaders [ BuildFeatureAttribute mesa : headers : path ] ; -local privateHeaders = [ BuildFeatureAttribute mesa : privateHeaders : path ] ; -UseHeaders [ FDirName $(privateHeaders) mesa ] ; -UseHeaders [ FDirName $(privateHeaders) mesa main ] ; -UseHeaders [ FDirName $(privateHeaders) mapi ] ; -UseHeaders [ FDirName $(privateHeaders) mapi glapi ] ; - -# For older versions of Mesa -UseHeaders [ FDirName $(privateHeaders) mesa glapi ] ; -UseHeaders [ FDirName $(privateHeaders) mesa tnl ] ; -UseHeaders [ FDirName $(privateHeaders) mesa x86 ] ; - - -AddResources Legacy\ Software\ Rasterizer : MesaSoftwareRenderer.rdef ; - -Addon Legacy\ Software\ Rasterizer : - $(sources) - : - [ BuildFeatureAttribute mesa : mesaLibrary ] - libGL.so be $(TARGET_LIBSUPC++) -; diff --git a/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.cpp b/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.cpp deleted file mode 100644 index b974fa24df..0000000000 --- a/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.cpp +++ /dev/null @@ -1,901 +0,0 @@ -/* - * Copyright 2006-2011, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Jérôme Duval, korli@users.berlios.de - * Philippe Houdoin, philippe.houdoin@free.fr - * Artur Wyszynski, harakash@gmail.com - * Alexander von Gluck, kallisti5@unixzen.com - */ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - */ - - -#include "MesaSoftwareRenderer.h" - -#include -#include -#include -#include -#include -#include - -extern "C" { -#include "extensions.h" -#include "drivers/common/driverfuncs.h" -#include "drivers/common/meta.h" -#include "main/colormac.h" -#include "main/cpuinfo.h" -#include "main/buffers.h" -#include "main/formats.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "vbo/vbo.h" - - -//#define TRACE_SOFTGL -#ifdef TRACE_SOFTGL -# define TRACE(x...) printf("MesaSoftwareRenderer: " x) -# define CALLED() printf("MesaSoftwareRenderer: %s\n", __PRETTY_FUNCTION__) -#else -# define TRACE(x...) -# define CALLED() -#endif - -#define ERROR(x...) printf("MesaSoftwareRenderer: " x) -} - - -extern const char* color_space_name(color_space space); - - -// BeOS component ordering for B_RGBA32 bitmap format -#if B_HOST_IS_LENDIAN -#define BE_RCOMP 2 -#define BE_GCOMP 1 -#define BE_BCOMP 0 -#define BE_ACOMP 3 -#else -// Big Endian B_RGBA32 bitmap format -#define BE_RCOMP 1 -#define BE_GCOMP 2 -#define BE_BCOMP 3 -#define BE_ACOMP 0 -#endif - - -/**********************************************************************/ -/***** Read/write spans/arrays of pixels *****/ -/**********************************************************************/ -extern "C" { - -/* 32-bit RGBA */ -#define NAME(PREFIX) PREFIX##_RGBA32 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte* P = ((GLubyte**)mr->GetRows())[Y] + (X) * 4 -#define INC_PIXEL_PTR(P) P += 4 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - DST[BE_RCOMP] = VALUE[RCOMP]; \ - DST[BE_GCOMP] = VALUE[GCOMP]; \ - DST[BE_BCOMP] = VALUE[BCOMP]; \ - DST[BE_ACOMP] = VALUE[ACOMP] -#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ - DST[BE_RCOMP] = VALUE[RCOMP]; \ - DST[BE_GCOMP] = VALUE[GCOMP]; \ - DST[BE_BCOMP] = VALUE[BCOMP]; \ - DST[BE_ACOMP] = 255 -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = SRC[BE_RCOMP]; \ - DST[GCOMP] = SRC[BE_GCOMP]; \ - DST[BCOMP] = SRC[BE_BCOMP]; \ - DST[ACOMP] = SRC[BE_ACOMP] -#include "swrast/s_spantemp.h" - -/* 32-bit RGB */ -#define NAME(PREFIX) PREFIX##_RGB32 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint* P = (GLuint*)(((GLubyte**)mr->GetRows())[Y] + (X) * 4) -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - *DST = ( ((VALUE[RCOMP]) << 16) | \ - ((VALUE[GCOMP]) << 8) | \ - ((VALUE[BCOMP]) ) ) -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = ((*SRC & 0x00ff0000) >> 16); \ - DST[GCOMP] = ((*SRC & 0x0000ff00) >> 8); \ - DST[BCOMP] = ((*SRC & 0x000000ff)); \ - DST[ACOMP] = 0xff; -#include "swrast/s_spantemp.h" - -/* 24-bit RGB */ -#define NAME(PREFIX) PREFIX##_RGB24 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte* P = ((GLubyte**)mr->GetRows())[Y] + (X) * 3 -#define INC_PIXEL_PTR(P) P += 3 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - DST[BE_RCOMP] = VALUE[RCOMP]; \ - DST[BE_GCOMP] = VALUE[GCOMP]; \ - DST[BE_BCOMP] = VALUE[BCOMP]; -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = SRC[BE_RCOMP]; \ - DST[GCOMP] = SRC[BE_GCOMP]; \ - DST[BCOMP] = SRC[BE_BCOMP]; \ - DST[ACOMP] = 0xff; -#include "swrast/s_spantemp.h" - -/* 16-bit RGB */ -#define NAME(PREFIX) PREFIX##_RGB16 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort* P = (GLushort*)(((GLubyte**)mr->GetRows())[Y] + (X) * 2) -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - *DST = ( (((VALUE[RCOMP]) & 0xf8) << 8) | \ - (((VALUE[GCOMP]) & 0xfc) << 3) | \ - (((VALUE[BCOMP]) ) >> 3) ) -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = ((*SRC & 0xf800) >> 8); \ - DST[GCOMP] = ((*SRC & 0x07e0) >> 3); \ - DST[BCOMP] = ((*SRC & 0x001f) << 3); \ - DST[ACOMP] = 0xff -#include "swrast/s_spantemp.h" - -/* 15-bit RGB */ -#define NAME(PREFIX) PREFIX##_RGB15 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort* P = (GLushort*)(((GLubyte**)mr->GetRows())[Y] + (X) * 2) -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - *DST = ( (((VALUE[RCOMP]) & 0xf8) << 7) | \ - (((VALUE[GCOMP]) & 0xf8) << 2) | \ - (((VALUE[BCOMP]) ) >> 3) ) -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = ((*SRC & 0x7c00) >> 7); \ - DST[GCOMP] = ((*SRC & 0x03e0) >> 2); \ - DST[BCOMP] = ((*SRC & 0x001f) << 3); \ - DST[ACOMP] = 0xff -#include "swrast/s_spantemp.h" -} - - -extern "C" _EXPORT BGLRenderer* -instantiate_gl_renderer(BGLView* view, ulong options, - BGLDispatcher* dispatcher) -{ - return new MesaSoftwareRenderer(view, options, dispatcher); -} - - -MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options, - BGLDispatcher* dispatcher) - : BGLRenderer(view, options, dispatcher), - fBitmap(NULL), - fDirectModeEnabled(false), - fInfo(NULL), - fInfoLocker("info locker"), - fContext(NULL), - fVisual(NULL), - fFrameBuffer(NULL), - fFrontRenderBuffer(NULL), - fBackRenderBuffer(NULL), - fColorSpace(B_NO_COLOR_SPACE) -{ - CALLED(); - - fClearColor[BE_RCOMP] = 0; - fClearColor[BE_GCOMP] = 0; - fClearColor[BE_BCOMP] = 0; - fClearColor[BE_ACOMP] = 0; - - fClearIndex = 0; - - fColorSpace = BScreen(GLView()->Window()).ColorSpace(); - - // We force single buffering for the time being - options &= ~BGL_DOUBLE; - - const GLboolean rgbFlag = ((options & BGL_INDEX) == 0); - const GLboolean alphaFlag = ((options & BGL_ALPHA) == BGL_ALPHA); - const GLboolean dblFlag = ((options & BGL_DOUBLE) == BGL_DOUBLE); - const GLboolean stereoFlag = false; - const GLint depth = (options & BGL_DEPTH) ? 16 : 0; - const GLint stencil = (options & BGL_STENCIL) ? 8 : 0; - const GLint accum = (options & BGL_ACCUM) ? 16 : 0; - const GLint red = rgbFlag ? 8 : 0; - const GLint green = rgbFlag ? 8 : 0; - const GLint blue = rgbFlag ? 8 : 0; - const GLint alpha = alphaFlag ? 8 : 0; - - fOptions = options; // | BGL_INDIRECT; - struct dd_function_table functions; - - fVisual = _mesa_create_visual(dblFlag, stereoFlag, red, green, - blue, alpha, depth, stencil, accum, accum, accum, - alpha ? accum : 0, 1); - - // Initialize device driver function table - _mesa_init_driver_functions(&functions); - - functions.GetString = _GetString; - functions.UpdateState = _UpdateState; - functions.GetBufferSize = NULL; - functions.Error = _Error; - functions.Viewport = _Viewport; - functions.Flush = _Flush; - - // create core context - fContext = _mesa_create_context(fVisual, NULL, &functions, this); - - if (!fContext) { - ERROR("%s: Failed to create Mesa context!\n", __func__); - _mesa_destroy_visual(fVisual); - return; - } - - /* Initialize the software rasterizer and helper modules. */ - _swrast_CreateContext(fContext); - _vbo_CreateContext(fContext); - _tnl_CreateContext(fContext); - _swsetup_CreateContext(fContext); - _swsetup_Wakeup(fContext); - - // Use default TCL pipeline - TNL_CONTEXT(fContext)->Driver.RunPipeline = _tnl_run_pipeline; - - _mesa_meta_init(fContext); - _mesa_enable_sw_extensions(fContext); - _mesa_enable_1_3_extensions(fContext); - _mesa_enable_1_4_extensions(fContext); - _mesa_enable_1_5_extensions(fContext); - _mesa_enable_2_0_extensions(fContext); - _mesa_enable_2_1_extensions(fContext); - - // create core framebuffer - fFrameBuffer = (struct msr_framebuffer*)calloc(1, - sizeof(*fFrameBuffer)); - if (fFrameBuffer == NULL) { - ERROR("%s: Unable to calloc GL FrameBuffer!\n", __func__); - _mesa_destroy_visual(fVisual); - return; - } - _mesa_initialize_window_framebuffer(&fFrameBuffer->base, fVisual); - - // Setup front render buffer - fFrontRenderBuffer = _NewRenderBuffer(true); - if (fFrontRenderBuffer == NULL) { - ERROR("%s: FrontRenderBuffer is requested but unallocated!\n", - __func__); - _mesa_destroy_visual(fVisual); - free(fFrameBuffer); - return; - } - _mesa_add_renderbuffer(&fFrameBuffer->base, BUFFER_FRONT_LEFT, - &fFrontRenderBuffer->base); - - // Setup back render buffer (if requested) - if (fVisual->doubleBufferMode) { - fBackRenderBuffer = _NewRenderBuffer(false); - if (fBackRenderBuffer == NULL) { - ERROR("%s: BackRenderBuffer is requested but unallocated!\n", - __func__); - _mesa_destroy_visual(fVisual); - free(fFrameBuffer); - return; - } - _mesa_add_renderbuffer(&fFrameBuffer->base, BUFFER_BACK_LEFT, - &fBackRenderBuffer->base); - } - - _mesa_add_soft_renderbuffers(&fFrameBuffer->base, GL_FALSE, - fVisual->haveDepthBuffer, fVisual->haveStencilBuffer, - fVisual->haveAccumBuffer, alphaFlag, GL_FALSE); - - BRect bounds = view->Bounds(); - fWidth = fNewWidth = (GLint)bounds.Width(); - fHeight = fNewHeight = (GLint)bounds.Height(); - - // some stupid applications (Quake2) don't even think about calling LockGL() - // before using glGetString and its glGet*() friends... - // so make sure there is at least a valid context. - - if (!_mesa_get_current_context()) { - LockGL(); - // not needed, we don't have a looper yet: UnlockLooper(); - } -} - - -MesaSoftwareRenderer::~MesaSoftwareRenderer() -{ - CALLED(); - _swsetup_DestroyContext(fContext); - _swrast_DestroyContext(fContext); - _tnl_DestroyContext(fContext); - _vbo_DestroyContext(fContext); - _mesa_destroy_visual(fVisual); - _mesa_destroy_framebuffer(&fFrameBuffer->base); - _mesa_destroy_context(fContext); - - free(fInfo); - free(fFrameBuffer); - - delete fBitmap; -} - - -void -MesaSoftwareRenderer::LockGL() -{ - CALLED(); - BGLRenderer::LockGL(); - - _mesa_make_current(fContext, &fFrameBuffer->base, &fFrameBuffer->base); - - color_space colorSpace = BScreen(GLView()->Window()).ColorSpace(); - - BAutolock lock(fInfoLocker); - if (fDirectModeEnabled && fInfo != NULL) { - fNewWidth = fInfo->window_bounds.right - - fInfo->window_bounds.left + 1; - fNewHeight = fInfo->window_bounds.bottom - - fInfo->window_bounds.top + 1; - } - - if (fColorSpace != colorSpace) { - fColorSpace = colorSpace; - _SetupRenderBuffer(fFrontRenderBuffer, fColorSpace); - if (fVisual->doubleBufferMode) - _SetupRenderBuffer(fBackRenderBuffer, fColorSpace); - } - - _CheckResize(); -} - - -void -MesaSoftwareRenderer::UnlockGL() -{ - CALLED(); - _mesa_make_current(fContext, NULL, NULL); - BGLRenderer::UnlockGL(); -} - - -void -MesaSoftwareRenderer::SwapBuffers(bool VSync) -{ - CALLED(); - - if (!fBitmap) - return; - - if (fVisual->doubleBufferMode) - _mesa_notifySwapBuffers(fContext); - - if (!fDirectModeEnabled || fInfo == NULL) { - if (GLView()->LockLooperWithTimeout(1000) == B_OK) { - GLView()->DrawBitmap(fBitmap, B_ORIGIN); - GLView()->UnlockLooper(); - } - } else { - // TODO: Here the BGLView needs to be drawlocked. - _CopyToDirect(); - } - - if (VSync) { - BScreen screen(GLView()->Window()); - screen.WaitForRetrace(); - } -} - - -void -MesaSoftwareRenderer::Draw(BRect updateRect) -{ - CALLED(); - if (fBitmap && (!fDirectModeEnabled || (fInfo == NULL))) - GLView()->DrawBitmap(fBitmap, updateRect, updateRect); -} - - -status_t -MesaSoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap* bitmap) -{ - CALLED(); - color_space scs = fBitmap->ColorSpace(); - color_space dcs = bitmap->ColorSpace(); - - if (scs != dcs && (scs != B_RGBA32 || dcs != B_RGB32)) { - fprintf(stderr, "CopyPixelsOut(): incompatible color space: %s != %s\n", - color_space_name(scs), - color_space_name(dcs)); - return B_BAD_TYPE; - } - - BRect sr = fBitmap->Bounds(); - BRect dr = bitmap->Bounds(); - - sr = sr & dr.OffsetBySelf(location); - dr = sr.OffsetByCopy(-location.x, -location.y); - - uint8* ps = (uint8*) fBitmap->Bits(); - uint8* pd = (uint8*) bitmap->Bits(); - uint32* s; - uint32* d; - uint32 y; - for (y = (uint32) sr.top; y <= (uint32)sr.bottom; y++) { - s = (uint32*)(ps + y * fBitmap->BytesPerRow()); - s += (uint32) sr.left; - - d = (uint32*)(pd + (y + (uint32)(dr.top - sr.top)) - * bitmap->BytesPerRow()); - d += (uint32) dr.left; - - memcpy(d, s, dr.IntegerWidth() * 4); - } - return B_OK; -} - - -status_t -MesaSoftwareRenderer::CopyPixelsIn(BBitmap* bitmap, BPoint location) -{ - CALLED(); - color_space scs = bitmap->ColorSpace(); - color_space dcs = fBitmap->ColorSpace(); - - if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) { - fprintf(stderr, "CopyPixelsIn(): incompatible color space: %s != %s\n", - color_space_name(scs), - color_space_name(dcs)); - return B_BAD_TYPE; - } - - BRect sr = bitmap->Bounds(); - BRect dr = fBitmap->Bounds(); - - sr = sr & dr.OffsetBySelf(location); - dr = sr.OffsetByCopy(-location.x, -location.y); - - uint8* ps = (uint8*) bitmap->Bits(); - uint8* pd = (uint8*) fBitmap->Bits(); - uint32* s; - uint32* d; - uint32 y; - for (y = (uint32) sr.top; y <= (uint32)sr.bottom; y++) { - s = (uint32*)(ps + y * bitmap->BytesPerRow()); - s += (uint32) sr.left; - - d = (uint32*)(pd + (y + (uint32)(dr.top - sr.top)) - * fBitmap->BytesPerRow()); - d += (uint32) dr.left; - - memcpy(d, s, dr.IntegerWidth() * 4); - } - return B_OK; -} - - -void -MesaSoftwareRenderer::EnableDirectMode(bool enabled) -{ - fDirectModeEnabled = enabled; -} - - -void -MesaSoftwareRenderer::DirectConnected(direct_buffer_info* info) -{ - // TODO: I'm not sure we need to do this: BGLView already - // keeps a local copy of the direct_buffer_info passed by - // BDirectWindow::DirectConnected(). - BAutolock lock(fInfoLocker); - if (info) { - if (!fInfo) { - fInfo = (direct_buffer_info*)malloc(DIRECT_BUFFER_INFO_AREA_SIZE); - if (!fInfo) - return; - } - memcpy(fInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); - } else if (fInfo) { - free(fInfo); - fInfo = NULL; - } -} - - -void -MesaSoftwareRenderer::FrameResized(float width, float height) -{ - BAutolock lock(fInfoLocker); - fNewWidth = (GLuint)width; - fNewHeight = (GLuint)height; - _CheckResize(); -} - - -void -MesaSoftwareRenderer::_CheckResize() -{ - CALLED(); - - if (fBitmap && fNewWidth == fWidth - && fNewHeight == fHeight) { - return; - } - - fHeight = fNewHeight; - fWidth = fNewWidth; - _mesa_resize_framebuffer(fContext, &fFrameBuffer->base, fWidth, fHeight); - - _AllocateBitmap(); -} - - -void -MesaSoftwareRenderer::_AllocateBitmap() -{ - CALLED(); - // allocate new size of back buffer bitmap - delete fBitmap; - fBitmap = NULL; - - if (fWidth < 1 || fHeight < 1) { - TRACE("%s: Cannot allocate bitmap < 1x1!\n", __func__); - return; - } - - BRect rect(0.0, 0.0, fWidth - 1, fHeight - 1); - fBitmap = new BBitmap(rect, fColorSpace); - for (uint i = 0; i < fHeight; i++) { - fRowAddr[fHeight - i - 1] = (GLvoid *)((GLubyte *)fBitmap->Bits() - + i * fBitmap->BytesPerRow()); - } - - fFrontRenderBuffer->size = fBitmap->BitsLength(); - if (fVisual->doubleBufferMode) - fBackRenderBuffer->size = fBitmap->BitsLength(); - fFrameBuffer->width = fWidth; - fFrameBuffer->height = fHeight; - TRACE("%s: Bitmap Size: %" B_PRIu32 "\n", __func__, fBitmap->BitsLength()); - - fFrontRenderBuffer->base.Data = fBitmap->Bits(); -} - - -// #pragma mark - static - - -void -MesaSoftwareRenderer::_Error(gl_context* ctx) -{ - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; - if (mr && mr->GLView()) - mr->GLView()->ErrorCallback((unsigned long)ctx->ErrorValue); -} - - -const GLubyte* -MesaSoftwareRenderer::_GetString(gl_context* ctx, GLenum name) -{ - - switch (name) { - case GL_VENDOR: - return (const GLubyte*) "Mesa Project"; - case GL_RENDERER: { - _mesa_get_cpu_features(); - static char buffer[256] = { '\0' }; - - if (!buffer[0]) { - char* cpuInfo = _mesa_get_cpu_string(); - // Let's build an renderer string - sprintf(buffer, "Software Rasterizer for %s", cpuInfo); - free(cpuInfo); - } - return (const GLubyte*) buffer; - } - default: - // Let core library handle all other cases - return NULL; - } -} - - -void -MesaSoftwareRenderer::_Viewport(gl_context* ctx, GLint x, GLint y, GLsizei w, - GLsizei h) -{ - CALLED(); - - gl_framebuffer* draw = ctx->WinSysDrawBuffer; - gl_framebuffer* read = ctx->WinSysReadBuffer; - struct msr_framebuffer* msr = msr_framebuffer(draw); - - _mesa_resize_framebuffer(ctx, draw, msr->width, msr->height); - _mesa_resize_framebuffer(ctx, read, msr->width, msr->height); -} - - -void -MesaSoftwareRenderer::_UpdateState(gl_context* ctx, GLuint new_state) -{ - if (!ctx) - return; - - CALLED(); - _swrast_InvalidateState(ctx, new_state); - _swsetup_InvalidateState(ctx, new_state); - _vbo_InvalidateState(ctx, new_state); - _tnl_InvalidateState(ctx, new_state); -} - - -void -MesaSoftwareRenderer::_ClearFront(gl_context* ctx) -{ - CALLED(); - - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; - BGLView* bglview = mr->GLView(); - assert(bglview); - BBitmap* bitmap = mr->fBitmap; - assert(bitmap); - GLuint* start = (GLuint*)bitmap->Bits(); - size_t pixelSize = 0; - get_pixel_size_for(bitmap->ColorSpace(), &pixelSize, NULL, NULL); - const GLuint* clearPixelPtr = (const GLuint*)mr->fClearColor; - const GLuint clearPixel = B_LENDIAN_TO_HOST_INT32(*clearPixelPtr); - - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - uint32 width = ctx->DrawBuffer->_Xmax - x; - uint32 height = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (width == ctx->DrawBuffer->Width - && height == ctx->DrawBuffer->Height); - - if (all) { - const int numPixels = mr->fWidth * mr->fHeight; - if (clearPixel == 0) { - memset(start, 0, numPixels * pixelSize); - } else { - for (int i = 0; i < numPixels; i++) { - start[i] = clearPixel; - } - } - } else { - // XXX untested - start += y * mr->fWidth + x; - for (uint32 i = 0; i < height; i++) { - for (uint32 j = 0; j < width; j++) { - start[j] = clearPixel; - } - start += mr->fWidth; - } - } -} - - -GLboolean -MesaSoftwareRenderer::_FrontRenderbufferStorage(gl_context* ctx, - struct gl_renderbuffer* render, GLenum internalFormat, - GLuint width, GLuint height) -{ - CALLED(); - - render->Data = NULL; - render->Width = width; - render->Height = height; - - return GL_TRUE; -} - - -GLboolean -MesaSoftwareRenderer::_BackRenderbufferStorage(gl_context* ctx, - struct gl_renderbuffer* render, GLenum internalFormat, - GLuint width, GLuint height) -{ - CALLED(); - struct msr_renderbuffer* mrb = msr_renderbuffer(render); - - free(render->Data); - _FrontRenderbufferStorage(ctx, render, internalFormat, width, height); - - if (mrb->size) - ERROR("%s: suspicious malloc of 0 bytes.\n", __func__); - render->Data = malloc(mrb->size); - - return GL_TRUE; -} - - -void -MesaSoftwareRenderer::_Flush(gl_context* ctx) -{ - CALLED(); - MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; - if ((mr->fOptions & BGL_DOUBLE) == 0) { - // TODO: SwapBuffers() can call _CopyToDirect(), which should - // be always called with with the BGLView drawlocked. - // This is not always the case if called from here. - mr->SwapBuffers(); - } -} - - -struct msr_renderbuffer* -MesaSoftwareRenderer::_NewRenderBuffer(bool front) -{ - CALLED(); - struct msr_renderbuffer *msr - = (struct msr_renderbuffer*)calloc(1, sizeof *msr); - - if (!msr) { - ERROR("%s: Failed calloc RenderBuffer\n", __func__); - return NULL; - } - - _mesa_init_renderbuffer(&msr->base, 0); - - if (_SetupRenderBuffer(msr, fColorSpace) != B_OK) { - free(msr); - return NULL; - } - - if (front) - msr->base.AllocStorage = _FrontRenderbufferStorage; - else { - msr->base.AllocStorage = _BackRenderbufferStorage; - msr->base.Delete = _DeleteBackBuffer; - } - - return msr; -} - - -status_t -MesaSoftwareRenderer::_SetupRenderBuffer( - struct msr_renderbuffer* buffer, color_space colorSpace) -{ - CALLED(); - - buffer->base.DataType = GL_UNSIGNED_BYTE; - buffer->base.Data = NULL; - - switch (colorSpace) { - case B_RGBA32: - buffer->base._BaseFormat = GL_RGBA; - buffer->base.Format = MESA_FORMAT_ARGB8888; - - buffer->base.GetRow = get_row_RGBA32; - buffer->base.GetValues = get_values_RGBA32; - buffer->base.PutRow = put_row_RGBA32; - buffer->base.PutValues = put_values_RGBA32; - buffer->base.PutRowRGB = put_row_rgb_RGBA32; - buffer->base.PutMonoRow = put_mono_row_RGBA32; - buffer->base.PutMonoValues = put_values_RGBA32; - break; - case B_RGB32: - buffer->base._BaseFormat = GL_RGB; - buffer->base.Format = MESA_FORMAT_ARGB8888; - - buffer->base.GetRow = get_row_RGB32; - buffer->base.GetValues = get_values_RGB32; - buffer->base.PutRow = put_row_RGB32; - buffer->base.PutValues = put_values_RGB32; - buffer->base.PutRowRGB = put_row_rgb_RGB32; - buffer->base.PutMonoRow = put_mono_row_RGB32; - buffer->base.PutMonoValues = put_values_RGB32; - break; - case B_RGB24: - buffer->base._BaseFormat = GL_RGB; - buffer->base.Format = MESA_FORMAT_RGB888; - - buffer->base.GetRow = get_row_RGB24; - buffer->base.GetValues = get_values_RGB24; - buffer->base.PutRow = put_row_RGB24; - buffer->base.PutValues = put_values_RGB24; - buffer->base.PutRowRGB = put_row_rgb_RGB24; - buffer->base.PutMonoRow = put_mono_row_RGB24; - buffer->base.PutMonoValues = put_values_RGB24; - break; - case B_RGB16: - buffer->base._BaseFormat = GL_RGB; - buffer->base.Format = MESA_FORMAT_RGB565; - - buffer->base.GetRow = get_row_RGB16; - buffer->base.GetValues = get_values_RGB16; - buffer->base.PutRow = put_row_RGB16; - buffer->base.PutValues = put_values_RGB16; - buffer->base.PutRowRGB = put_row_rgb_RGB16; - buffer->base.PutMonoRow = put_mono_row_RGB16; - buffer->base.PutMonoValues = put_values_RGB16; - break; - case B_RGB15: - buffer->base._BaseFormat = GL_RGB; - buffer->base.Format = MESA_FORMAT_ARGB1555; - - buffer->base.GetRow = get_row_RGB15; - buffer->base.GetValues = get_values_RGB15; - buffer->base.PutRow = put_row_RGB15; - buffer->base.PutValues = put_values_RGB15; - buffer->base.PutRowRGB = put_row_rgb_RGB15; - buffer->base.PutMonoRow = put_mono_row_RGB15; - buffer->base.PutMonoValues = put_values_RGB15; - break; - default: - fprintf(stderr, "Unsupported screen color space %s\n", - color_space_name(fColorSpace)); - debugger("Unsupported OpenGL color space"); - return B_ERROR; - } - return B_OK; -} - - -void -MesaSoftwareRenderer::_DeleteBackBuffer(struct gl_renderbuffer* rb) -{ - CALLED(); - free(rb->Data); - free(rb); -} - - -void -MesaSoftwareRenderer::_CopyToDirect() -{ - BAutolock lock(fInfoLocker); - - // check the bitmap size still matches the size - if (fInfo->window_bounds.bottom - fInfo->window_bounds.top - != fBitmap->Bounds().IntegerHeight() - || fInfo->window_bounds.right - fInfo->window_bounds.left - != fBitmap->Bounds().IntegerWidth()) - return; - - uint8 bytesPerPixel = fInfo->bits_per_pixel / 8; - uint32 bytesPerRow = fBitmap->BytesPerRow(); - for (uint32 i = 0; i < fInfo->clip_list_count; i++) { - clipping_rect *clip = &fInfo->clip_list[i]; - int32 height = clip->bottom - clip->top + 1; - int32 bytesWidth - = (clip->right - clip->left + 1) * 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; y++) { - memcpy(p, b, bytesWidth); - p += fInfo->bytes_per_row; - b += bytesPerRow; - } - } -} diff --git a/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.h b/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.h deleted file mode 100644 index 06524f4842..0000000000 --- a/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2006-2008, Haiku. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Jérôme Duval, korli@users.berlios.de - * Philippe Houdoin, philippe.houdoin@free.fr - * Artur Wyszynski, harakash@gmail.com - */ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - */ -#ifndef MESASOFTWARERENDERER_H -#define MESASOFTWARERENDERER_H - - -#include "GLRenderer.h" - -extern "C" { -#include "context.h" -#include "main/version.h" - - -#define gl_context GLcontext -#define gl_config GLvisual - - -struct msr_renderbuffer { - struct gl_renderbuffer base; - uint32 size; -}; - - -static INLINE struct msr_renderbuffer* -msr_renderbuffer(struct gl_renderbuffer* rb) -{ - return (struct msr_renderbuffer*)rb; -} - - -struct msr_framebuffer { - struct gl_framebuffer base; - uint32 width; - uint32 height; -}; - - -static INLINE struct msr_framebuffer* -msr_framebuffer(struct gl_framebuffer* rb) -{ - return (struct msr_framebuffer*)rb; -} - - -} - - -class MesaSoftwareRenderer : public BGLRenderer { -public: - MesaSoftwareRenderer(BGLView* view, - ulong bgl_options, - BGLDispatcher* dispatcher); - virtual ~MesaSoftwareRenderer(); - - virtual void LockGL(); - virtual void UnlockGL(); - - virtual void SwapBuffers(bool VSync = false); - virtual void Draw(BRect updateRect); - virtual status_t CopyPixelsOut(BPoint source, BBitmap* dest); - virtual status_t CopyPixelsIn(BBitmap* source, BPoint dest); - virtual void FrameResized(float width, float height); - - GLvoid** GetRows() { return fRowAddr; } - - virtual void EnableDirectMode(bool enabled); - virtual void DirectConnected(direct_buffer_info* info); - -private: - static void _Error(gl_context* ctx); - static const GLubyte* _GetString(gl_context* ctx, GLenum name); - static void _Viewport(gl_context* ctx, GLint x, GLint y, - GLsizei w, GLsizei h); - void _CheckResize(); - static void _UpdateState(gl_context* ctx, GLuint newState); - static void _ClearFront(gl_context* ctx); - static GLboolean _FrontRenderbufferStorage(gl_context* ctx, - struct gl_renderbuffer* render, - GLenum internalFormat, - GLuint width, GLuint height); - static GLboolean _BackRenderbufferStorage(gl_context* ctx, - struct gl_renderbuffer* render, - GLenum internalFormat, - GLuint width, GLuint height); - static void _Flush(gl_context *ctx); - - struct msr_renderbuffer* _NewRenderBuffer(bool front); - status_t _SetupRenderBuffer(struct msr_renderbuffer* - buffer, color_space colorSpace); - static void _DeleteBackBuffer(struct gl_renderbuffer* rb); - - void _AllocateBitmap(); - void _CopyToDirect(); - - BBitmap* fBitmap; - bool fDirectModeEnabled; - direct_buffer_info* fInfo; - BLocker fInfoLocker; - ulong fOptions; - - gl_context* fContext; - gl_config* fVisual; - struct msr_framebuffer* fFrameBuffer; - struct msr_renderbuffer* fFrontRenderBuffer; - struct msr_renderbuffer* fBackRenderBuffer; - - GLchan fClearColor[4]; // buffer clear color - GLuint fClearIndex; // buffer clear color index - GLuint fWidth, fNewWidth; - GLuint fHeight, fNewHeight; - color_space fColorSpace; - - GLvoid* fRowAddr[MAX_HEIGHT]; - // address of first pixel in each image row -}; - -#endif // MESASOFTWARERENDERER_H - diff --git a/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.rdef b/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.rdef deleted file mode 100644 index 4386c88aaa..0000000000 --- a/src/add-ons/opengl/swrast_legacy/MesaSoftwareRenderer.rdef +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - */ - -resource app_signature "application/x-vnd.Haiku-swrast_legacy"; - -resource app_version { - major = 7, - middle = 8, - minor = 2, - variety = 0, - internal = 0, - short_info = "Legacy Software Rasterizer", - long_info = "Haiku Legacy Mesa Software GL Rasterizer (gcc2)" -}; - -resource vector_icon { - $"6E6369660A020014029448FF18020014028DA5FF50058C0500020006023B10B7" - $"37F036BA1A993D466848C719BEBE2000919292FFD5D5D5020016023900000000" - $"000000003EE0004AE00048E0005EF884C702000203392E8D383001BAD97F3C12" - $"8B4786BD48B8AD0D97BBFFFF7B4168DBE9FF4168DB97020002023A0C1238D099" - $"BE44203F4BD14B38844678240DF56A7D9FE1EA064CC704016B0500090A044024" - $"2438404C5C380A044028243C40505C3C0A042438243B5C3C5C380608BFBE4D59" - $"4D59515957575659585560406044603C5E3A5C3CCB4FBFBA5E3ECA9DC11F564B" - $"584A544C504C0606AF0F2F3D2F3D393D4034BF593542324130432F42364432C0" - $"3FBC5A2F48354A2F480608AE9A22303EB5BD3AB42542B755422E412F3C29322D" - $"32223C0204263726372538263F253E263F304430443143303C313D303C02043D" - $"423D423C433D4A3C493D4A495049504A4F49474A484947060DAEAAAE014E445A" - $"3456365E325E3D5D3F5A3A5542544E4D573A4E364439463342324A2242310A0A" - $"0002020102403CA00C88888C8CC1401673C40D6544F2950A01010002403CA000" - $"0000000000401673C40D65446CF80A08020304023EC16A0000000000003EC16A" - $"45DD1844C6550A030105123EC16A0000000000003EC16A45DD1844C655011784" - $"22040A040105023EC16A0000000000003EC16A45DD1844C6550A030108123EC1" - $"6A0000000000003EC16A45DD1844C65501178422040A0503080706023EC16A00" - $"00000000003EC16A45DD1844C6550A030206071A3EC16A0000000000003EC16A" - $"45DD1844C65510FF0215810004178222040A060106023EC16A0000000000003E" - $"C16A45DD1844C6550A070107023EC16A0000000000003EC16A45DD1844C655" -}; diff --git a/src/add-ons/screen_savers/flurry/Jamfile b/src/add-ons/screen_savers/flurry/Jamfile index dd23699279..d491c5f019 100644 --- a/src/add-ons/screen_savers/flurry/Jamfile +++ b/src/add-ons/screen_savers/flurry/Jamfile @@ -21,8 +21,9 @@ Includes [ FGristFiles $(sources) ] : ScreenSaver Flurry : $(sources) : - be screensaver GL localestub $(TARGET_LIBSUPC++) + be screensaver localestub $(TARGET_LIBSUPC++) [ BuildFeatureAttribute glu : library ] + [ BuildFeatureAttribute mesa : library ] ; DoCatalogs Flurry : diff --git a/src/add-ons/screen_savers/glife/Jamfile b/src/add-ons/screen_savers/glife/Jamfile index e2f374d138..06cfdf15bd 100644 --- a/src/add-ons/screen_savers/glife/Jamfile +++ b/src/add-ons/screen_savers/glife/Jamfile @@ -25,8 +25,9 @@ AddResources GLife : GLife.rdef ; ScreenSaver GLife : $(sources) : - be screensaver GL localestub $(TARGET_LIBSUPC++) + be screensaver localestub $(TARGET_LIBSUPC++) [ BuildFeatureAttribute glu : library ] + [ BuildFeatureAttribute mesa : library ] ; DoCatalogs GLife : diff --git a/src/add-ons/screen_savers/gravity/Jamfile b/src/add-ons/screen_savers/gravity/Jamfile index 9364d76ca9..14de4b94c8 100644 --- a/src/add-ons/screen_savers/gravity/Jamfile +++ b/src/add-ons/screen_savers/gravity/Jamfile @@ -28,8 +28,9 @@ Includes [ FGristFiles $(sources) ] : ScreenSaver Gravity : $(sources) : - be screensaver GL localestub $(TARGET_LIBSTDC++) + be screensaver localestub $(TARGET_LIBSTDC++) [ BuildFeatureAttribute glu : library ] + [ BuildFeatureAttribute mesa : library ] ; DoCatalogs Gravity : diff --git a/src/apps/3dmov/Jamfile b/src/apps/3dmov/Jamfile index 5c5afe3fd4..b196f51238 100644 --- a/src/apps/3dmov/Jamfile +++ b/src/apps/3dmov/Jamfile @@ -8,6 +8,7 @@ if $(TARGET_GCC_VERSION_$(TARGET_PACKAGING_ARCH)[1]) < 3 { SubDirC++Flags --no-warnings ; } + local sources = Application.cpp MainWindow.cpp @@ -17,13 +18,16 @@ local sources = ViewCube.cpp ViewSphere.cpp GLUtility.cpp - ; + ; Includes [ FGristFiles $(sources) ] : [ BuildFeatureAttribute mesa : headers ] ; Application 3DMov : $(sources) - : be GL game localestub media translation $(TARGET_LIBSUPC++) + : + be game + [ BuildFeatureAttribute mesa : library ] + localestub media translation $(TARGET_LIBSUPC++) : 3dmov.rdef ; diff --git a/src/apps/glteapot/Jamfile b/src/apps/glteapot/Jamfile index cc1125aebc..41bf054e0d 100644 --- a/src/apps/glteapot/Jamfile +++ b/src/apps/glteapot/Jamfile @@ -21,8 +21,9 @@ Includes [ FGristFiles $(sources) ] : Application GLTeapot : $(sources) : - be GL game localestub $(TARGET_LIBSUPC++) + be game localestub $(TARGET_LIBSUPC++) [ BuildFeatureAttribute glu : library ] + [ BuildFeatureAttribute mesa : library ] : GLTeapot.rdef ; diff --git a/src/apps/haiku3d/Jamfile b/src/apps/haiku3d/Jamfile index af495a2b3e..48d00d990a 100644 --- a/src/apps/haiku3d/Jamfile +++ b/src/apps/haiku3d/Jamfile @@ -38,7 +38,8 @@ Includes [ FGristFiles $(sources) ] : Application Haiku3d : $(sources) : - be game GL media translation $(TARGET_LIBSTDC++) + be game media translation $(TARGET_LIBSTDC++) [ BuildFeatureAttribute glu : library ] + [ BuildFeatureAttribute mesa : library ] : Haiku3d.rdef ; diff --git a/src/kits/Jamfile b/src/kits/Jamfile index 24dcc726d5..78fc00acc8 100644 --- a/src/kits/Jamfile +++ b/src/kits/Jamfile @@ -107,7 +107,6 @@ SubInclude HAIKU_TOP src kits media ; SubInclude HAIKU_TOP src kits midi ; SubInclude HAIKU_TOP src kits midi2 ; SubInclude HAIKU_TOP src kits network ; -SubInclude HAIKU_TOP src kits opengl ; SubInclude HAIKU_TOP src kits package ; SubInclude HAIKU_TOP src kits print ; SubInclude HAIKU_TOP src kits screensaver ; diff --git a/src/kits/opengl/GLDispatcher.cpp b/src/kits/opengl/GLDispatcher.cpp deleted file mode 100644 index b1c69d08c3..0000000000 --- a/src/kits/opengl/GLDispatcher.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000-2012 Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Brian Paul - * Philippe Houdoin - */ - - -extern "C" { -#include "glapi.h" -#if __GNUC__ > 2 -// New Mesa -#include "glapi_priv.h" -#endif - - -/* - * NOTE: this file portion implements C-based dispatch of the OpenGL entrypoints - * (glAccum, glBegin, etc). - * This code IS NOT USED if we're compiling on an x86 system and using - * the glapi_x86.S assembly code. - */ -#if !(defined(USE_X86_ASM) || defined(USE_SPARC_ASM)) - -#define KEYWORD1 PUBLIC -#define KEYWORD2 -#define NAME(func) gl##func - -#define DISPATCH(func, args, msg) \ - const struct _glapi_table* dispatch; \ - dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\ - (dispatch->func) args - -#define RETURN_DISPATCH(func, args, msg) \ - const struct _glapi_table* dispatch; \ - dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\ - return (dispatch->func) args - -#endif -} - - -/* NOTE: this file portion implement a thin OpenGL entrypoints dispatching - C++ wrapper class - */ - -#include "GLDispatcher.h" - -BGLDispatcher::BGLDispatcher() -{ -} - - -BGLDispatcher::~BGLDispatcher() -{ -} - - -status_t -BGLDispatcher::CheckTable(const struct _glapi_table* table) -{ - _glapi_check_table(table ? table : _glapi_get_dispatch()); - return B_OK; -} - - -status_t -BGLDispatcher::SetTable(struct _glapi_table* table) -{ - _glapi_set_dispatch(table); - return B_OK; -} diff --git a/src/kits/opengl/GLDispatcher.h b/src/kits/opengl/GLDispatcher.h deleted file mode 100644 index 95d3be81d9..0000000000 --- a/src/kits/opengl/GLDispatcher.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000-2012 Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Brian Paul - * Philippe Houdoin - */ -#ifndef GLDISPATCHER_H -#define GLDISPATCHER_H - - -#include -#include -#include - -#include "glheader.h" - -extern "C" { -#include "glapi.h" -} - - -class BGLDispatcher -{ - // Private unimplemented copy constructors - BGLDispatcher(const BGLDispatcher &); - BGLDispatcher & operator=(const BGLDispatcher &); - - public: - BGLDispatcher(); - ~BGLDispatcher(); - - void SetCurrentContext(void* context); - void* CurrentContext(); - - struct _glapi_table* Table(); - status_t CheckTable( - const struct _glapi_table* dispatch = NULL); - status_t SetTable(struct _glapi_table* dispatch); - uint32 TableSize(); - - const _glapi_proc operator[](const char* functionName); - const char* operator[](uint32 offset); - - const _glapi_proc AddressOf(const char* functionName); - uint32 OffsetOf(const char* functionName); -}; - - -// Inlines methods -inline void -BGLDispatcher::SetCurrentContext(void* context) -{ - _glapi_set_context(context); -} - - -inline void* -BGLDispatcher::CurrentContext() -{ - return _glapi_get_context(); -} - - -inline struct _glapi_table* -BGLDispatcher::Table() -{ - return _glapi_get_dispatch(); -} - - -inline uint32 -BGLDispatcher::TableSize() -{ - return _glapi_get_dispatch_table_size(); -} - - -inline const _glapi_proc -BGLDispatcher::operator[](const char* functionName) -{ - return _glapi_get_proc_address(functionName); -} - - -inline const char* -BGLDispatcher::operator[](uint32 offset) -{ - return _glapi_get_proc_name((GLuint) offset); -} - - -inline const _glapi_proc -BGLDispatcher::AddressOf(const char* functionName) -{ - return _glapi_get_proc_address(functionName); -} - - -inline uint32 -BGLDispatcher::OffsetOf(const char* functionName) -{ - return (uint32) _glapi_get_proc_offset(functionName); -} - - -#endif // GLDISPATCHER_H diff --git a/src/kits/opengl/GLRenderer.cpp b/src/kits/opengl/GLRenderer.cpp deleted file mode 100644 index cc0c95a869..0000000000 --- a/src/kits/opengl/GLRenderer.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2006-2008, Philippe Houdoin. All rights reserved. - * Distributed under the terms of the MIT License. - */ - - -#include "GLRenderer.h" - -#include "GLDispatcher.h" - - -BGLRenderer::BGLRenderer(BGLView* view, ulong glOptions, - BGLDispatcher* dispatcher) - : - fRefCount(1), - fView(view), - fOptions(glOptions), - fDispatcher(dispatcher) -{ -} - - -BGLRenderer::~BGLRenderer() -{ - delete fDispatcher; -} - - -void -BGLRenderer::Acquire() -{ - atomic_add(&fRefCount, 1); -} - - -void -BGLRenderer::Release() -{ - if (atomic_add(&fRefCount, -1) < 1) - delete this; -} - - -void -BGLRenderer::LockGL() -{ -} - - -void -BGLRenderer::UnlockGL() -{ -} - - -void -BGLRenderer::SwapBuffers(bool VSync) -{ -} - - -void -BGLRenderer::Draw(BRect updateRect) -{ -} - - -status_t -BGLRenderer::CopyPixelsOut(BPoint source, BBitmap* dest) -{ - return B_ERROR; -} - - -status_t -BGLRenderer::CopyPixelsIn(BBitmap* source, BPoint dest) -{ - return B_ERROR; -} - - -void -BGLRenderer::FrameResized(float width, float height) -{ -} - - -void -BGLRenderer::DirectConnected(direct_buffer_info* info) -{ -} - - -void -BGLRenderer::EnableDirectMode(bool enabled) -{ -} - - -status_t BGLRenderer::_Reserved_Renderer_0(int32 n, void* p) { return B_ERROR; } -status_t BGLRenderer::_Reserved_Renderer_1(int32 n, void* p) { return B_ERROR; } -status_t BGLRenderer::_Reserved_Renderer_2(int32 n, void* p) { return B_ERROR; } -status_t BGLRenderer::_Reserved_Renderer_3(int32 n, void* p) { return B_ERROR; } -status_t BGLRenderer::_Reserved_Renderer_4(int32 n, void* p) { return B_ERROR; } diff --git a/src/kits/opengl/GLRendererRoster.cpp b/src/kits/opengl/GLRendererRoster.cpp deleted file mode 100644 index 0e7a925bcc..0000000000 --- a/src/kits/opengl/GLRendererRoster.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Philippe Houdoin - */ - - -#include -#include -#include - -#include -#include -#include -#include -#include "GLDispatcher.h" -#include "GLRendererRoster.h" - -#include -#include - - -extern "C" status_t _kern_get_safemode_option(const char* parameter, - char* buffer, size_t* _bufferSize); - - -GLRendererRoster::GLRendererRoster(BGLView* view, ulong options) - : - fNextID(0), - fView(view), - fOptions(options), - fSafeMode(false), - fABISubDirectory(NULL) -{ - char parameter[32]; - size_t parameterLength = sizeof(parameter); - - if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE, - parameter, ¶meterLength) == B_OK) { - if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on") - || !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes") - || !strcasecmp(parameter, "enable") || !strcmp(parameter, "1")) - fSafeMode = true; - } - - if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, - parameter, ¶meterLength) == B_OK) { - if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on") - || !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes") - || !strcasecmp(parameter, "enable") || !strcmp(parameter, "1")) - fSafeMode = true; - } - - // We might run in compatibility mode on a system with a different ABI. The - // renderers matching our ABI can usually be found in respective - // subdirectories of the opengl add-ons directories. - system_info info; - if (get_system_info(&info) == B_OK - && (info.abi & B_HAIKU_ABI_MAJOR) - != (B_HAIKU_ABI & B_HAIKU_ABI_MAJOR)) { - switch (B_HAIKU_ABI & B_HAIKU_ABI_MAJOR) { - case B_HAIKU_ABI_GCC_2: - fABISubDirectory = "gcc2"; - break; - case B_HAIKU_ABI_GCC_4: - fABISubDirectory = "gcc4"; - break; - } - } - - AddDefaultPaths(); -} - - -GLRendererRoster::~GLRendererRoster() -{ - -} - - -BGLRenderer* -GLRendererRoster::GetRenderer(int32 id) -{ - RendererMap::const_iterator iterator = fRenderers.find(id); - if (iterator == fRenderers.end()) - return NULL; - - struct renderer_item item = iterator->second; - return item.renderer; -} - - -void -GLRendererRoster::AddDefaultPaths() -{ - // add user directories first, so that they can override system renderers - const directory_which paths[] = { - B_USER_NONPACKAGED_ADDONS_DIRECTORY, - B_USER_ADDONS_DIRECTORY, - B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY, - B_SYSTEM_ADDONS_DIRECTORY, - }; - - for (uint32 i = fSafeMode ? 4 : 0; - i < sizeof(paths) / sizeof(paths[0]); i++) { - BPath path; - status_t status = find_directory(paths[i], &path, true); - if (status == B_OK && path.Append("opengl") == B_OK) - AddPath(path.Path()); - } -} - - -status_t -GLRendererRoster::AddPath(const char* path) -{ - BDirectory directory(path); - status_t status = directory.InitCheck(); - if (status < B_OK) - return status; - - // if a subdirectory for our ABI exists, use that instead - if (fABISubDirectory != NULL) { - BEntry entry(&directory, fABISubDirectory); - if (entry.IsDirectory()) { - status = directory.SetTo(&entry); - if (status != B_OK) - return status; - } - } - - node_ref nodeRef; - status = directory.GetNodeRef(&nodeRef); - if (status < B_OK) - return status; - - int32 count = 0; - int32 files = 0; - - entry_ref ref; - BEntry entry; - while (directory.GetNextRef(&ref) == B_OK) { - entry.SetTo(&ref); - if (entry.InitCheck() == B_OK && !entry.IsFile()) - continue; - - if (CreateRenderer(ref) == B_OK) - count++; - - files++; - } - - if (files != 0 && count == 0) - return B_BAD_VALUE; - - return B_OK; -} - - -status_t -GLRendererRoster::AddRenderer(BGLRenderer* renderer, - image_id image, const entry_ref* ref, ino_t node) -{ - renderer_item item; - item.renderer = renderer; - item.image = image; - item.node = node; - if (ref != NULL) - item.ref = *ref; - - try { - fRenderers[fNextID] = item; - } catch (...) { - return B_NO_MEMORY; - } - - renderer->fOwningRoster = this; - renderer->fID = fNextID++; - return B_OK; -} - - -status_t -GLRendererRoster::CreateRenderer(const entry_ref& ref) -{ - BEntry entry(&ref); - node_ref nodeRef; - status_t status = entry.GetNodeRef(&nodeRef); - if (status < B_OK) - return status; - - BPath path(&ref); - image_id image = load_add_on(path.Path()); - if (image < B_OK) - return image; - - BGLRenderer* (*instantiate_renderer) - (BGLView* view, ulong options, BGLDispatcher* dispatcher); - - status = get_image_symbol(image, "instantiate_gl_renderer", - B_SYMBOL_TYPE_TEXT, (void**)&instantiate_renderer); - if (status == B_OK) { - BGLRenderer* renderer - = instantiate_renderer(fView, fOptions, new BGLDispatcher()); - if (!renderer) { - unload_add_on(image); - return B_UNSUPPORTED; - } - - if (AddRenderer(renderer, image, &ref, nodeRef.node) != B_OK) { - renderer->Release(); - // this will delete the renderer - unload_add_on(image); - } - return B_OK; - } - unload_add_on(image); - - return status; -} diff --git a/src/kits/opengl/GLRendererRoster.h b/src/kits/opengl/GLRendererRoster.h deleted file mode 100644 index 5c8da27119..0000000000 --- a/src/kits/opengl/GLRendererRoster.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2006-2012, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Philippe Houdoin - */ -#ifndef _GLRENDERER_ROSTER_H -#define _GLRENDERER_ROSTER_H - - -#include - -#include - - -struct renderer_item { - BGLRenderer* renderer; - entry_ref ref; - ino_t node; - image_id image; -}; - -typedef std::map RendererMap; - - -class GLRendererRoster { - public: - GLRendererRoster(BGLView* view, ulong options); - virtual ~GLRendererRoster(); - - BGLRenderer* GetRenderer(int32 id = 0); - - private: - void AddDefaultPaths(); - status_t AddPath(const char* path); - status_t AddRenderer(BGLRenderer* renderer, - image_id image, const entry_ref* ref, ino_t node); - status_t CreateRenderer(const entry_ref& ref); - - RendererMap fRenderers; - int32 fNextID; - BGLView* fView; - ulong fOptions; - bool fSafeMode; - const char* fABISubDirectory; - -}; - - -#endif /* _GLRENDERER_ROSTER_H */ diff --git a/src/kits/opengl/GLView.cpp b/src/kits/opengl/GLView.cpp deleted file mode 100644 index 730f7f02a7..0000000000 --- a/src/kits/opengl/GLView.cpp +++ /dev/null @@ -1,642 +0,0 @@ -/* - * Copyright 2006-2012, Haiku. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Jérôme Duval, korli@users.berlios.de - * Philippe Houdoin, philippe.houdoin@free.fr - * Stefano Ceccherini, burton666@libero.it - */ - - -#include - -#include -#include -#include -#include - -#include -#include - -#include "DirectWindowPrivate.h" -#include "GLDispatcher.h" -#include "GLRendererRoster.h" - - -struct glview_direct_info { - direct_buffer_info* direct_info; - bool direct_connected; - bool enable_direct_mode; - - glview_direct_info(); - ~glview_direct_info(); -}; - - -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), - // | B_FULL_UPDATE_ON_RESIZE) - fGc(NULL), - fOptions(options), - fDitherCount(0), - fDrawLock("BGLView draw lock"), - fDisplayLock("BGLView display lock"), - fClipInfo(NULL), - fRenderer(NULL), - fRoster(NULL), - fDitherMap(NULL) -{ - fRoster = new GLRendererRoster(this, options); -} - - -BGLView::~BGLView() -{ - delete fClipInfo; - if (fRenderer) - fRenderer->Release(); -} - - -void -BGLView::LockGL() -{ - // TODO: acquire the OpenGL API lock it on this glview - - fDisplayLock.Lock(); - if (fRenderer) - fRenderer->LockGL(); -} - - -void -BGLView::UnlockGL() -{ - if (fRenderer) - fRenderer->UnlockGL(); - fDisplayLock.Unlock(); - - // TODO: release the GL API lock to others glviews -} - - -void -BGLView::SwapBuffers() -{ - SwapBuffers(false); -} - - -void -BGLView::SwapBuffers(bool vSync) -{ - if (fRenderer) { - _LockDraw(); - fRenderer->SwapBuffers(vSync); - _UnlockDraw(); - } -} - - -BView* -BGLView::EmbeddedView() -{ - return NULL; -} - - -void* -BGLView::GetGLProcAddress(const char* procName) -{ - BGLDispatcher* glDispatcher = NULL; - - if (fRenderer) - glDispatcher = fRenderer->GLDispatcher(); - - if (glDispatcher) - return (void*)glDispatcher->AddressOf(procName); - - return NULL; -} - - -status_t -BGLView::CopyPixelsOut(BPoint source, BBitmap* dest) -{ - if (!fRenderer) - return B_ERROR; - - if (!dest || !dest->Bounds().IsValid()) - return B_BAD_VALUE; - - return fRenderer->CopyPixelsOut(source, dest); -} - - -status_t -BGLView::CopyPixelsIn(BBitmap* source, BPoint dest) -{ - if (!fRenderer) - return B_ERROR; - - if (!source || !source->Bounds().IsValid()) - return B_BAD_VALUE; - - return fRenderer->CopyPixelsIn(source, dest); -} - - -/*! 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) -{ - if (fRenderer) { - _LockDraw(); - fRenderer->Draw(updateRect); - _UnlockDraw(); - return; - } - // TODO: auto-size and center the string - MovePenTo(8, 32); - DrawString("No OpenGL renderer available!"); -} - - -void -BGLView::AttachedToWindow() -{ - BView::AttachedToWindow(); - - fBounds = Bounds(); - 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: - // when the window is moved, the app_server doesn't paint the view's - // background, and the stuff behind the window itself shows up. - // Setting the view color to black, instead, looks a bit more elegant. -#if 0 - // Don't paint white window background when resized - SetViewColor(B_TRANSPARENT_32_BIT); -#else - SetViewColor(0, 0, 0); -#endif - - // Set default OpenGL viewport: - LockGL(); - glViewport(0, 0, Bounds().IntegerWidth(), Bounds().IntegerHeight()); - UnlockGL(); - fRenderer->FrameResized(Bounds().IntegerWidth(), - Bounds().IntegerHeight()); - - if (fClipInfo) { - fRenderer->DirectConnected(fClipInfo->direct_info); - fRenderer->EnableDirectMode(fClipInfo->enable_direct_mode); - } - - return; - } - - fprintf(stderr, "no renderer found! \n"); - - // No Renderer, no rendering. Setup a minimal "No Renderer" string drawing - // context - SetFont(be_bold_font); - // SetFontSize(16); -} - - -void -BGLView::AllAttached() -{ - BView::AllAttached(); -} - - -void -BGLView::DetachedFromWindow() -{ - if (fRenderer) - fRenderer->Release(); - fRenderer = NULL; - - BView::DetachedFromWindow(); -} - - -void -BGLView::AllDetached() -{ - BView::AllDetached(); -} - - -void -BGLView::FrameResized(float width, float height) -{ - fBounds = Bounds(); - for (BView* v = this; v; v = v->Parent()) - v->ConvertToParent(&fBounds); - - if (fRenderer) { - LockGL(); - _LockDraw(); - _CallDirectConnected(); - fRenderer->FrameResized(width, height); - _UnlockDraw(); - UnlockGL(); - } - - BView::FrameResized(width, height); -} - - -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::GetPreferredSize(float* _width, float* _height) -{ - if (_width) - *_width = 0; - if (_height) - *_height = 0; -} - - -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::DirectConnected(direct_buffer_info* info) -{ - if (fClipInfo == NULL) { - fClipInfo = new (std::nothrow) glview_direct_info(); - if (fClipInfo == NULL) - return; - } - - direct_buffer_info* localInfo = fClipInfo->direct_info; - - switch (info->buffer_state & B_DIRECT_MODE_MASK) { - case B_DIRECT_START: - fClipInfo->direct_connected = true; - memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); - _UnlockDraw(); - break; - - case B_DIRECT_MODIFY: - _LockDraw(); - memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); - _UnlockDraw(); - break; - - case B_DIRECT_STOP: - fClipInfo->direct_connected = false; - _LockDraw(); - break; - } - - if (fRenderer) - _CallDirectConnected(); -} - - -void -BGLView::EnableDirectMode(bool enabled) -{ - if (fRenderer) - fRenderer->EnableDirectMode(enabled); - if (fClipInfo == NULL) { - fClipInfo = new (std::nothrow) glview_direct_info(); - if (fClipInfo == NULL) - return; - } - - fClipInfo->enable_direct_mode = enabled; -} - - -void -BGLView::_LockDraw() -{ - if (!fClipInfo || !fClipInfo->enable_direct_mode) - return; - - fDrawLock.Lock(); -} - - -void -BGLView::_UnlockDraw() -{ - if (!fClipInfo || !fClipInfo->enable_direct_mode) - return; - - fDrawLock.Unlock(); -} - - -void -BGLView::_CallDirectConnected() -{ - if (!fClipInfo) - return; - - direct_buffer_info* localInfo = fClipInfo->direct_info; - direct_buffer_info* info = (direct_buffer_info*)malloc( - DIRECT_BUFFER_INFO_AREA_SIZE); - if (info == NULL) - return; - - memcpy(info, localInfo, DIRECT_BUFFER_INFO_AREA_SIZE); - - // Collect the rects into a BRegion, then clip to the view's bounds - BRegion region; - for (uint32 c = 0; c < localInfo->clip_list_count; c++) - region.Include(localInfo->clip_list[c]); - BRegion boundsRegion = fBounds.OffsetByCopy(localInfo->window_bounds.left, - localInfo->window_bounds.top); - info->window_bounds = boundsRegion.RectAtInt(0); - // window_bounds are now view bounds - region.IntersectWith(&boundsRegion); - - info->clip_list_count = region.CountRects(); - info->clip_bounds = region.FrameInt(); - - for (uint32 c = 0; c < info->clip_list_count; c++) - info->clip_list[c] = region.RectAtInt(c); - fRenderer->DirectConnected(info); - free(info); -} - - -//---- 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 - - - -// 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), - fDitherCount(0), - fDrawLock("BGLView draw lock"), - fDisplayLock("BGLView display lock"), - fClipInfo(NULL), - fRenderer(NULL), - fRoster(NULL), - fDitherMap(NULL) -{ - fRoster = new GLRendererRoster(this, options); -} - - -#if 0 -// TODO: implement BGLScreen class... - - -BGLScreen::BGLScreen(char* name, ulong screenMode, ulong options, - status_t* error, bool debug) - : - BWindowScreen(name, screenMode, error, debug) -{ -} - - -BGLScreen::~BGLScreen() -{ -} - - -void -BGLScreen::LockGL() -{ -} - - -void -BGLScreen::UnlockGL() -{ -} - - -void -BGLScreen::SwapBuffers() -{ -} - - -void -BGLScreen::ErrorCallback(unsigned long errorCode) -{ - // Mesa's GLenum is not ulong but uint! - char msg[32]; - sprintf(msg, "GL: Error code $%04lx.", errorCode); - // debugger(msg); - fprintf(stderr, "%s\n", msg); - return; -} - - -void -BGLScreen::ScreenConnected(bool enabled) -{ -} - - -void -BGLScreen::FrameResized(float width, float height) -{ - return BWindowScreen::FrameResized(width, height); -} - - -status_t -BGLScreen::Perform(perform_code d, void* arg) -{ - return BWindowScreen::Perform(d, arg); -} - - -status_t -BGLScreen::Archive(BMessage* data, bool deep) const -{ - return BWindowScreen::Archive(data, deep); -} - - -void -BGLScreen::MessageReceived(BMessage* msg) -{ - BWindowScreen::MessageReceived(msg); -} - - -void -BGLScreen::Show() -{ - BWindowScreen::Show(); -} - - -void -BGLScreen::Hide() -{ - BWindowScreen::Hide(); -} - - -BHandler* -BGLScreen::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, - int32 form, const char* property) -{ - return BWindowScreen::ResolveSpecifier(msg, index, specifier, - form, property); -} - - -status_t -BGLScreen::GetSupportedSuites(BMessage* data) -{ - return BWindowScreen::GetSupportedSuites(data); -} - - -//---- virtual reserved methods ---------- - -void BGLScreen::_ReservedGLScreen1() {} -void BGLScreen::_ReservedGLScreen2() {} -void BGLScreen::_ReservedGLScreen3() {} -void BGLScreen::_ReservedGLScreen4() {} -void BGLScreen::_ReservedGLScreen5() {} -void BGLScreen::_ReservedGLScreen6() {} -void BGLScreen::_ReservedGLScreen7() {} -void BGLScreen::_ReservedGLScreen8() {} -#endif - - -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 --git a/src/kits/opengl/Jamfile b/src/kits/opengl/Jamfile deleted file mode 100644 index 90d8aefce9..0000000000 --- a/src/kits/opengl/Jamfile +++ /dev/null @@ -1,66 +0,0 @@ -SubDir HAIKU_TOP src kits opengl ; - -SetSubDirSupportedPlatformsBeOSCompatible ; - -local sources = - GLView.cpp - GLDispatcher.cpp - GLRenderer.cpp - GLRendererRoster.cpp - ; - - -if $(TARGET_PLATFORM) != haiku { - UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ; - # We need our public GL headers also when not compiling for Haiku. -} - -local architectureObject ; -for architectureObject in [ MultiArchSubDirSetup ] { - on $(architectureObject) { - local architecture = $(TARGET_PACKAGING_ARCH) ; - - UsePrivateHeaders interface ; - UsePrivateSystemHeaders ; - UseBuildFeatureHeaders glu ; - UseBuildFeatureHeaders mesa ; - - Includes [ FGristFiles $(sources) ] - : [ BuildFeatureAttribute glu : headers ] ; - Includes [ FGristFiles $(sources) ] - : [ BuildFeatureAttribute mesa : headers ] ; - - UseHeaders [ BuildFeatureAttribute mesa : headers : path ] ; - local privateHeaders - = [ BuildFeatureAttribute mesa : privateHeaders : path ] ; - UseHeaders [ FDirName $(privateHeaders) mesa ] ; - UseHeaders [ FDirName $(privateHeaders) mesa main ] ; - UseHeaders [ FDirName $(privateHeaders) mapi ] ; - UseHeaders [ FDirName $(privateHeaders) mapi glapi ] ; - - # For older versions of Mesa - UseHeaders [ FDirName $(privateHeaders) mesa glapi ] ; - - LINKFLAGS on libGL.so = [ on libGL.so return $(LINKFLAGS) ] - -Xlinker --whole-archive -Xlinker --no-undefined ; - - # For GCC2 - if $(architecture) = x86_gcc2 { - SubDirC++Flags --no-warnings ; - } - - SharedLibrary [ MultiArchDefaultGristFiles libGL.so ] : $(sources) : - # GLU - [ BuildFeatureAttribute glu : library ] - - # GLAPI Dispatch code (from Mesa buildpackage) - [ BuildFeatureAttribute mesa : glapiLibrary ] - - # External libraries: - game # BWindowScreen needed by BGLScreen stub class - network - be - $(TARGET_LIBSTDC++) - ; - } -} diff --git a/src/libs/glut/Jamfile b/src/libs/glut/Jamfile index 2204b807fd..6daf5b3c98 100644 --- a/src/libs/glut/Jamfile +++ b/src/libs/glut/Jamfile @@ -1,13 +1,9 @@ SubDir HAIKU_TOP src libs glut ; +UseLibraryHeaders glut ; + SetSubDirSupportedPlatformsBeOSCompatible ; -if $(TARGET_PLATFORM) != haiku { - UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ; - # We need our public GL headers also when not compiling for Haiku. -} - - local sourcesCc = # C sources glut_8x13.c @@ -71,7 +67,8 @@ for architectureObject in [ MultiArchSubDirSetup ] { $(sourcesCpp) $(sourcesCc) : - GL game be $(TARGET_LIBSTDC++) + game be $(TARGET_LIBSTDC++) + [ BuildFeatureAttribute mesa : library ] [ BuildFeatureAttribute glu : library ] ; } diff --git a/src/tests/kits/opengl/demos/gears/Jamfile b/src/tests/kits/opengl/demos/gears/Jamfile index bd1998c5cb..eddc768c0f 100644 --- a/src/tests/kits/opengl/demos/gears/Jamfile +++ b/src/tests/kits/opengl/demos/gears/Jamfile @@ -20,5 +20,7 @@ Includes [ FGristFiles $(sources) ] : [ BuildFeatureAttribute mesa : headers ] ; SimpleTest GLGears : $(sources) - : be GL + : + be + [ BuildFeatureAttribute mesa : library ] ; diff --git a/src/tests/kits/opengl/direct_mode/Jamfile b/src/tests/kits/opengl/direct_mode/Jamfile index 8929ed5949..1a8690f535 100644 --- a/src/tests/kits/opengl/direct_mode/Jamfile +++ b/src/tests/kits/opengl/direct_mode/Jamfile @@ -18,6 +18,8 @@ Includes [ FGristFiles $(sources) ] : [ BuildFeatureAttribute mesa : headers ] ; SimpleTest GLDirectMode : $(sources) - : be game GL $(TARGET_LIBSUPC++) + : + be game $(TARGET_LIBSUPC++) + [ BuildFeatureAttribute mesa : library ] : GLDirectMode.rdef ; diff --git a/src/tests/kits/opengl/glinfo/Jamfile b/src/tests/kits/opengl/glinfo/Jamfile index be8dec64a0..d7a6bd0329 100644 --- a/src/tests/kits/opengl/glinfo/Jamfile +++ b/src/tests/kits/opengl/glinfo/Jamfile @@ -1,8 +1,9 @@ SubDir HAIKU_TOP src tests kits opengl glinfo ; -UseBuildFeatureHeaders glu ; UseBuildFeatureHeaders mesa ; +UseBuildFeatureHeaders glu ; UsePrivateHeaders interface ; +UseLibraryHeaders glut ; local sources = OpenGLApp.cpp @@ -15,8 +16,8 @@ local sources = ; Includes [ FGristFiles $(sources) ] : - [ BuildFeatureAttribute glu : headers ] [ BuildFeatureAttribute mesa : headers ] + [ BuildFeatureAttribute glu : headers ] ; # Dependency needed to trigger downloading/unzipping the package before # compiling the files. @@ -24,9 +25,10 @@ Includes [ FGristFiles $(sources) ] : Preference GLInfo : $(sources) : - be GL libglut.so + be libglut.so translation libcolumnlistview.a localestub $(TARGET_LIBSUPC++) + [ BuildFeatureAttribute mesa : library ] [ BuildFeatureAttribute glu : library ] : GLInfo.rdef diff --git a/src/tests/kits/opengl/glsl/Jamfile b/src/tests/kits/opengl/glsl/Jamfile index 2709530593..cdac47678f 100644 --- a/src/tests/kits/opengl/glsl/Jamfile +++ b/src/tests/kits/opengl/glsl/Jamfile @@ -23,5 +23,7 @@ StaticLibrary libshaderutil.a : SimpleTest brick : brick.c - : libshaderutil.a be GL + : + libshaderutil.a be + [ BuildFeatureAttribute mesa : library ] ; diff --git a/src/tests/kits/opengl/glut/game_mode/Jamfile b/src/tests/kits/opengl/glut/game_mode/Jamfile index 23849dcae5..786464a84e 100644 --- a/src/tests/kits/opengl/glut/game_mode/Jamfile +++ b/src/tests/kits/opengl/glut/game_mode/Jamfile @@ -1,6 +1,9 @@ SubDir HAIKU_TOP src tests kits opengl glut game_mode ; UseBuildFeatureHeaders mesa ; +# GLUT +UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] ; + SetSubDirSupportedPlatformsBeOSCompatible ; if $(TARGET_PLATFORM) != haiku { @@ -18,5 +21,7 @@ Includes [ FGristFiles $(sources) ] : [ BuildFeatureAttribute mesa : headers ] ; SimpleTest GLUTGameMode : $(sources) - : be GL libglut.so + : + be libglut.so + [ BuildFeatureAttribute mesa : library ] ;