diff options
38 files changed, 254 insertions, 775 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index dd14feaeb25..f72521266aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,13 +25,6 @@ endif() cmake_minimum_required(VERSION 3.10) -# Prefer LEGACY OpenGL to be compatible with all the existing releases and -# platforms which don't have GLVND yet. Only do it if preference was not set -# externally. -if(NOT DEFINED OpenGL_GL_PREFERENCE) - set(OpenGL_GL_PREFERENCE "LEGACY") -endif() - if(NOT EXECUTABLE_OUTPUT_PATH) set(FIRST_RUN TRUE) else() @@ -262,7 +255,6 @@ if(WITH_GHOST_X11) option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON) option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON) option(WITH_X11_XFIXES "Enable X11 XWayland cursor warping workaround" ON) - option(WITH_X11_ALPHA "Enable X11 transparent background" ON) endif() if(UNIX AND NOT APPLE) @@ -536,29 +528,11 @@ endif() # OpenGL -# Experimental EGL option. -option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, GLX or WGL)" OFF) -mark_as_advanced(WITH_GL_EGL) - -if(WITH_GHOST_WAYLAND) - # Wayland can only use EGL to create OpenGL contexts, not GLX. - set(WITH_GL_EGL ON) -endif() - -if(UNIX AND NOT APPLE) - option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON) -else() - # System GLES not an option on other platforms. - set(WITH_SYSTEM_GLES OFF) -endif() - option(WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON) -option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)" OFF) option(WITH_GPU_BUILDTIME_SHADER_BUILDER "Shader builder is a developer option enabling linting on GLSL during compilation" OFF) mark_as_advanced( WITH_OPENGL - WITH_GL_PROFILE_ES20 WITH_GPU_BUILDTIME_SHADER_BUILDER ) @@ -580,11 +554,6 @@ if(WITH_METAL_BACKEND) endif() if(WIN32) - option(WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF) - mark_as_advanced(WITH_GL_ANGLE) -endif() - -if(WIN32) getDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES) set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${}) endif() @@ -880,7 +849,6 @@ if(WITH_GHOST_SDL OR WITH_HEADLESS) set(WITH_X11_XINPUT OFF) set(WITH_X11_XF86VMODE OFF) set(WITH_X11_XFIXES OFF) - set(WITH_X11_ALPHA OFF) set(WITH_GHOST_XDND OFF) set(WITH_INPUT_IME OFF) set(WITH_XR_OPENXR OFF) @@ -1195,139 +1163,10 @@ endif() #----------------------------------------------------------------------------- # Configure OpenGL. -find_package(OpenGL) -blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}") - if(WITH_OPENGL) add_definitions(-DWITH_OPENGL) endif() -if(WITH_SYSTEM_GLES) - find_package_wrapper(OpenGLES) -endif() - -if(WITH_GL_PROFILE_ES20) - if(WITH_SYSTEM_GLES) - if(NOT OPENGLES_LIBRARY) - message(FATAL_ERROR - "Unable to find OpenGL ES libraries. " - "Install them or disable WITH_SYSTEM_GLES." - ) - endif() - - list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}") - - else() - set(OPENGLES_LIBRARY "" CACHE FILEPATH "OpenGL ES 2.0 library file") - mark_as_advanced(OPENGLES_LIBRARY) - - list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}") - - if(NOT OPENGLES_LIBRARY) - message(FATAL_ERROR - "To compile WITH_GL_EGL you need to set OPENGLES_LIBRARY " - "to the file path of an OpenGL ES 2.0 library." - ) - endif() - - endif() - - if(WIN32) - # Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES - - set(OPENGLES_DLL "" CACHE FILEPATH "OpenGL ES 2.0 redistributable DLL file") - mark_as_advanced(OPENGLES_DLL) - - if(NOT OPENGLES_DLL) - message(FATAL_ERROR - "To compile WITH_GL_PROFILE_ES20 you need to set OPENGLES_DLL to the file " - "path of an OpenGL ES 2.0 runtime dynamic link library (DLL)." - ) - endif() - - if(WITH_GL_ANGLE) - list(APPEND GL_DEFINITIONS -DWITH_ANGLE) - - set(D3DCOMPILER_DLL "" CACHE FILEPATH "Direct3D Compiler redistributable DLL file (needed by ANGLE)") - - get_filename_component(D3DCOMPILER_FILENAME "${D3DCOMPILER_DLL}" NAME) - list(APPEND GL_DEFINITIONS "-DD3DCOMPILER=\"\\\"${D3DCOMPILER_FILENAME}\\\"\"") - - mark_as_advanced(D3DCOMPILER_DLL) - - if(D3DCOMPILER_DLL STREQUAL "") - message(FATAL_ERROR - "To compile WITH_GL_ANGLE you need to set D3DCOMPILER_DLL to the file " - "path of a copy of the DirectX redistributable DLL file: D3DCompiler_46.dll" - ) - endif() - - endif() - - endif() - -else() - if(OpenGL_GL_PREFERENCE STREQUAL "LEGACY" AND OPENGL_gl_LIBRARY) - list(APPEND BLENDER_GL_LIBRARIES ${OPENGL_gl_LIBRARY}) - else() - list(APPEND BLENDER_GL_LIBRARIES ${OPENGL_opengl_LIBRARY} ${OPENGL_glx_LIBRARY}) - endif() -endif() - -if(WITH_GL_EGL) - find_package(OpenGL REQUIRED EGL) - list(APPEND BLENDER_GL_LIBRARIES OpenGL::EGL) - - list(APPEND GL_DEFINITIONS -DWITH_GL_EGL) - - if(WITH_SYSTEM_GLES) - if(NOT OPENGLES_EGL_LIBRARY) - message(FATAL_ERROR - "Unable to find OpenGL ES libraries. " - "Install them or disable WITH_SYSTEM_GLES." - ) - endif() - - list(APPEND BLENDER_GL_LIBRARIES ${OPENGLES_EGL_LIBRARY}) - - else() - set(OPENGLES_EGL_LIBRARY "" CACHE FILEPATH "EGL library file") - mark_as_advanced(OPENGLES_EGL_LIBRARY) - - list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}" "${OPENGLES_EGL_LIBRARY}") - - if(NOT OPENGLES_EGL_LIBRARY) - message(FATAL_ERROR - "To compile WITH_GL_EGL you need to set OPENGLES_EGL_LIBRARY " - "to the file path of an EGL library." - ) - endif() - - endif() - - if(WIN32) - # Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES - - set(OPENGLES_EGL_DLL "" CACHE FILEPATH "EGL redistributable DLL file") - mark_as_advanced(OPENGLES_EGL_DLL) - - if(NOT OPENGLES_EGL_DLL) - message(FATAL_ERROR - "To compile WITH_GL_EGL you need to set OPENGLES_EGL_DLL " - "to the file path of an EGL runtime dynamic link library (DLL)." - ) - endif() - - endif() - -endif() - -if(WITH_GL_PROFILE_ES20) - list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_ES20) -else() - list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE) -endif() - #----------------------------------------------------------------------------- # Configure Metal. if(WITH_METAL_BACKEND) @@ -2005,7 +1844,6 @@ if(FIRST_RUN) info_cfg_option(WITH_INSTALL_PORTABLE) info_cfg_option(WITH_MEM_JEMALLOC) info_cfg_option(WITH_MEM_VALGRIND) - info_cfg_option(WITH_X11_ALPHA) info_cfg_option(WITH_X11_XF86VMODE) info_cfg_option(WITH_X11_XFIXES) info_cfg_option(WITH_X11_XINPUT) @@ -2052,13 +1890,6 @@ if(FIRST_RUN) info_cfg_option(WITH_MOD_OCEANSIM) info_cfg_option(WITH_MOD_REMESH) - info_cfg_text("OpenGL:") - if(WIN32) - info_cfg_option(WITH_GL_ANGLE) - endif() - info_cfg_option(WITH_GL_EGL) - info_cfg_option(WITH_GL_PROFILE_ES20) - info_cfg_text("") message("${_config_msg}") diff --git a/build_files/cmake/Modules/FindOpenGLES.cmake b/build_files/cmake/Modules/FindOpenGLES.cmake deleted file mode 100644 index 5e82984bed6..00000000000 --- a/build_files/cmake/Modules/FindOpenGLES.cmake +++ /dev/null @@ -1,80 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2014 Blender Foundation. - -# - Try to find OpenGLES -# Once done this will define -# -# OPENGLES_FOUND - system has OpenGLES and EGL -# OPENGL_EGL_FOUND - system has EGL -# OPENGLES_INCLUDE_DIR - the GLES include directory -# OPENGLES_LIBRARY - the GLES library -# OPENGLES_EGL_INCLUDE_DIR - the EGL include directory -# OPENGLES_EGL_LIBRARY - the EGL library -# OPENGLES_LIBRARIES - all libraries needed for OpenGLES -# OPENGLES_INCLUDES - all includes needed for OpenGLES - -# If OPENGLES_ROOT_DIR was defined in the environment, use it. -IF(NOT OPENGLES_ROOT_DIR AND NOT $ENV{OPENGLES_ROOT_DIR} STREQUAL "") - SET(OPENGLES_ROOT_DIR $ENV{OPENGLES_ROOT_DIR}) -ENDIF() - -SET(_opengles_SEARCH_DIRS - ${OPENGLES_ROOT_DIR} -) - -FIND_PATH(OPENGLES_INCLUDE_DIR - NAMES - GLES2/gl2.h - HINTS - ${_opengles_SEARCH_DIRS} -) - -FIND_LIBRARY(OPENGLES_LIBRARY - NAMES - GLESv2 - PATHS - ${_opengles_SEARCH_DIRS} - PATH_SUFFIXES - lib64 lib -) - -FIND_PATH(OPENGLES_EGL_INCLUDE_DIR - NAMES - EGL/egl.h - HINTS - ${_opengles_SEARCH_DIRS} -) - -FIND_LIBRARY(OPENGLES_EGL_LIBRARY - NAMES - EGL - HINTS - ${_opengles_SEARCH_DIRS} - PATH_SUFFIXES - lib64 lib -) - -IF(OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR) - SET(OPENGL_EGL_FOUND "YES") -ELSE() - SET(OPENGL_EGL_FOUND "NO") -ENDIF() - -IF(OPENGLES_LIBRARY AND OPENGLES_INCLUDE_DIR AND - OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR) - SET(OPENGLES_LIBRARIES ${OPENGLES_LIBRARY} ${OPENGLES_LIBRARIES} - ${OPENGLES_EGL_LIBRARY}) - SET(OPENGLES_INCLUDES ${OPENGLES_INCLUDE_DIR} ${OPENGLES_EGL_INCLUDE_DIR}) - SET(OPENGLES_FOUND "YES") -ELSE() - SET(OPENGLES_FOUND "NO") -ENDIF() - -MARK_AS_ADVANCED( - OPENGLES_EGL_INCLUDE_DIR - OPENGLES_EGL_LIBRARY - OPENGLES_LIBRARY - OPENGLES_INCLUDE_DIR -) - -UNSET(_opengles_SEARCH_DIRS) diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt index d46ece55256..0988b1c0ac4 100644 --- a/intern/cycles/app/CMakeLists.txt +++ b/intern/cycles/app/CMakeLists.txt @@ -43,9 +43,8 @@ else() endif() if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI) - add_definitions(${GL_DEFINITIONS}) list(APPEND INC_SYS ${Epoxy_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}) - list(APPEND LIB ${CYCLES_GL_LIBRARIES} ${Epoxy_LIBRARIES} ${SDL2_LIBRARIES}) + list(APPEND LIB ${Epoxy_LIBRARIES} ${SDL2_LIBRARIES}) endif() cycles_external_libraries_append(LIB) diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt index 095615f15d5..ab0937ac9eb 100644 --- a/intern/cycles/blender/CMakeLists.txt +++ b/intern/cycles/blender/CMakeLists.txt @@ -87,8 +87,6 @@ set(ADDON_FILES addon/version_update.py ) -add_definitions(${GL_DEFINITIONS}) - if(WITH_CYCLES_DEVICE_HIP) add_definitions(-DWITH_HIP) endif() diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake index bc859d830ba..af2f280ae84 100644 --- a/intern/cycles/cmake/external_libs.cmake +++ b/intern/cycles/cmake/external_libs.cmake @@ -550,25 +550,6 @@ if(EXISTS ${_cycles_lib_dir}) endif() ########################################################################### -# OpenGL -########################################################################### - -if((WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI) OR - WITH_CYCLES_HYDRA_RENDER_DELEGATE) - if(CYCLES_STANDALONE_REPOSITORY) - if(NOT DEFINED OpenGL_GL_PREFERENCE) - set(OpenGL_GL_PREFERENCE "LEGACY") - endif() - - find_package(OpenGL REQUIRED) - - set(CYCLES_GL_LIBRARIES ${OPENGL_gl_LIBRARY}) - else() - set(CYCLES_GL_LIBRARIES ${BLENDER_GL_LIBRARIES}) - endif() -endif() - -########################################################################### # SDL ########################################################################### diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt index 71789a76406..4ae123cd634 100644 --- a/intern/cycles/device/CMakeLists.txt +++ b/intern/cycles/device/CMakeLists.txt @@ -147,7 +147,6 @@ set(SRC set(LIB cycles_kernel cycles_util - ${CYCLES_GL_LIBRARIES} ) if(WITH_CYCLES_DEVICE_OPTIX OR WITH_CYCLES_DEVICE_CUDA) @@ -168,8 +167,6 @@ if(WITH_CYCLES_DEVICE_HIP AND WITH_HIP_DYNLOAD) ) endif() -add_definitions(${GL_DEFINITIONS}) - if(WITH_CYCLES_DEVICE_CUDA) add_definitions(-DWITH_CUDA) endif() diff --git a/intern/cycles/hydra/CMakeLists.txt b/intern/cycles/hydra/CMakeLists.txt index 60bb40a0d63..2bbd46db582 100644 --- a/intern/cycles/hydra/CMakeLists.txt +++ b/intern/cycles/hydra/CMakeLists.txt @@ -64,8 +64,6 @@ set(SRC_HD_CYCLES volume.cpp ) -add_definitions(${GL_DEFINITIONS}) - if(WITH_OPENVDB) add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS}) list(APPEND INC_SYS diff --git a/intern/cycles/scene/CMakeLists.txt b/intern/cycles/scene/CMakeLists.txt index 4904bf247ba..a30f408f207 100644 --- a/intern/cycles/scene/CMakeLists.txt +++ b/intern/cycles/scene/CMakeLists.txt @@ -148,6 +148,4 @@ endif() include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) -add_definitions(${GL_DEFINITIONS}) - cycles_add_library(cycles_scene "${LIB}" ${SRC} ${SRC_HEADERS}) diff --git a/intern/cycles/session/CMakeLists.txt b/intern/cycles/session/CMakeLists.txt index 6e4e6af6e71..4f3a0a99ee1 100644 --- a/intern/cycles/session/CMakeLists.txt +++ b/intern/cycles/session/CMakeLists.txt @@ -32,6 +32,4 @@ set(LIB include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) -add_definitions(${GL_DEFINITIONS}) - cycles_add_library(cycles_session "${LIB}" ${SRC} ${SRC_HEADERS}) diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index 2dafe729dfe..997d574a3b0 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -148,6 +148,4 @@ endif() include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) -add_definitions(${GL_DEFINITIONS}) - cycles_add_library(cycles_util "${LIB}" ${SRC} ${SRC_HEADERS}) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 8b19aad7043..84b68014e91 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -156,13 +156,11 @@ elseif(APPLE AND NOT WITH_GHOST_X11) intern/GHOST_WindowViewCocoa.h ) - if(NOT WITH_GL_EGL) - list(APPEND SRC - intern/GHOST_ContextCGL.mm + list(APPEND SRC + intern/GHOST_ContextCGL.mm - intern/GHOST_ContextCGL.h - ) - endif() + intern/GHOST_ContextCGL.h + ) if(WITH_INPUT_NDOF) list(APPEND SRC @@ -196,13 +194,11 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND) intern/GHOST_WindowX11.h ) - if(NOT WITH_GL_EGL) - list(APPEND SRC - intern/GHOST_ContextGLX.cpp + list(APPEND SRC + intern/GHOST_ContextGLX.cpp - intern/GHOST_ContextGLX.h - ) - endif() + intern/GHOST_ContextGLX.h + ) if(WITH_GHOST_XDND) add_definitions(-DWITH_XDND) @@ -249,10 +245,6 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND) ) endif() - if(WITH_X11_ALPHA) - add_definitions(-DWITH_X11_ALPHA) - endif() - if(WITH_X11_XINPUT) add_definitions(-DWITH_X11_XINPUT) list(APPEND INC_SYS @@ -432,13 +424,11 @@ elseif(WIN32) intern/GHOST_Wintab.h ) - if(NOT WITH_GL_EGL) - list(APPEND SRC - intern/GHOST_ContextWGL.cpp + list(APPEND SRC + intern/GHOST_ContextWGL.cpp - intern/GHOST_ContextWGL.h - ) - endif() + intern/GHOST_ContextWGL.h + ) if(WITH_INPUT_IME) add_definitions(-DWITH_INPUT_IME) @@ -459,7 +449,7 @@ elseif(WIN32) endif() endif() -if(WITH_GL_EGL AND NOT (WITH_HEADLESS OR WITH_GHOST_SDL)) +if(NOT (WITH_HEADLESS OR WITH_GHOST_SDL)) list(APPEND SRC intern/GHOST_ContextEGL.cpp @@ -549,11 +539,8 @@ if(WITH_XR_OPENXR) list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_WAYLAND) endif() if(WITH_GHOST_X11) - if(WITH_GL_EGL) - list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_EGL) - else() - list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_XLIB) - endif() + list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_EGL) + list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_XLIB) endif() endif() @@ -562,6 +549,4 @@ if(WITH_XR_OPENXR) unset(XR_PLATFORM_DEFINES) endif() -add_definitions(${GL_DEFINITIONS}) - blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 91cf1c4c558..89878a6d6a1 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -277,8 +277,7 @@ class GHOST_ISystem { */ virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting &setting, GHOST_IWindow **window, - const bool stereoVisual, - const bool alphaBackground = 0) = 0; + const bool stereoVisual) = 0; /** * Updates the resolution while in fullscreen mode. diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 495fb739978..adc45285f94 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -61,7 +61,6 @@ typedef struct { typedef enum { GHOST_glStereoVisual = (1 << 0), GHOST_glDebugContext = (1 << 1), - GHOST_glAlphaBackground = (1 << 2), } GHOST_GLFlags; typedef enum GHOST_DialogOptions { diff --git a/intern/ghost/intern/GHOST_ContextCGL.h b/intern/ghost/intern/GHOST_ContextCGL.h index badc3241107..fa6d6fc6fa0 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.h +++ b/intern/ghost/intern/GHOST_ContextCGL.h @@ -105,8 +105,6 @@ class GHOST_ContextCGL : public GHOST_Context { /** The virtualized default frame-buffer's texture. */ MTLTexture *m_defaultFramebufferMetalTexture; - bool m_coreProfile; - const bool m_debug; /** The first created OpenGL context (for sharing display lists) */ diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm index 19df38abb0a..6da44ec481c 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.mm +++ b/intern/ghost/intern/GHOST_ContextCGL.mm @@ -58,12 +58,6 @@ GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual, m_defaultFramebufferMetalTexture(nil), m_debug(false) { -#if defined(WITH_GL_PROFILE_CORE) - m_coreProfile = true; -#else - m_coreProfile = false; -#endif - if (m_metalView) { metalInit(); } @@ -197,7 +191,6 @@ GHOST_TSuccess GHOST_ContextCGL::updateDrawingContext() } static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs, - bool coreProfile, bool stereoVisual, bool needAlpha, bool softwareGL) @@ -205,7 +198,7 @@ static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs, attribs.clear(); attribs.push_back(NSOpenGLPFAOpenGLProfile); - attribs.push_back(coreProfile ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy); + attribs.push_back(NSOpenGLProfileVersion3_2Core); /* Pixel Format Attributes for the windowed NSOpenGLContext. */ attribs.push_back(NSOpenGLPFADoubleBuffer); @@ -245,7 +238,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext() std::vector<NSOpenGLPixelFormatAttribute> attribs; attribs.reserve(40); - makeAttribList(attribs, m_coreProfile, m_stereoVisual, needAlpha, softwareGL); + makeAttribList(attribs, m_stereoVisual, needAlpha, softwareGL); NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]]; if (pixelFormat == nil) { diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp index c29e11ccb1d..75c2655531f 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.cpp +++ b/intern/ghost/intern/GHOST_ContextEGL.cpp @@ -151,10 +151,6 @@ static bool egl_chk(bool result, # define EGL_CHK(x) egl_chk(x) #endif -#ifdef WITH_GL_ANGLE -HMODULE GHOST_ContextEGL::s_d3dcompiler = nullptr; -#endif - EGLContext GHOST_ContextEGL::s_gl_sharedContext = EGL_NO_CONTEXT; EGLint GHOST_ContextEGL::s_gl_sharedCount = 0; @@ -333,20 +329,6 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() } m_stereoVisual = false; /* It doesn't matter what the Window wants. */ -#ifdef WITH_GL_ANGLE - /* `d3dcompiler_XX.dll` needs to be loaded before ANGLE will work. */ - if (s_d3dcompiler == nullptr) { - s_d3dcompiler = LoadLibrary(D3DCOMPILER); - - WIN32_CHK(s_d3dcompiler != nullptr); - - if (s_d3dcompiler == nullptr) { - fprintf(stderr, "LoadLibrary(\"" D3DCOMPILER "\") failed!\n"); - return GHOST_kFailure; - } - } -#endif - EGLDisplay prev_display = eglGetCurrentDisplay(); EGLSurface prev_draw = eglGetCurrentSurface(EGL_DRAW); EGLSurface prev_read = eglGetCurrentSurface(EGL_READ); diff --git a/intern/ghost/intern/GHOST_ContextEGL.h b/intern/ghost/intern/GHOST_ContextEGL.h index 662ffa94aec..3ccd34f0338 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.h +++ b/intern/ghost/intern/GHOST_ContextEGL.h @@ -130,8 +130,4 @@ class GHOST_ContextEGL : public GHOST_Context { static EGLContext s_vg_sharedContext; static EGLint s_vg_sharedCount; - -#ifdef WITH_GL_ANGLE - static HMODULE s_d3dcompiler; -#endif }; diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h index 1246aa19a99..152b6b68026 100644 --- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h +++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h @@ -17,11 +17,8 @@ class GHOST_IXrGraphicsBinding { public: union { #if defined(WITH_GHOST_X11) -# if defined(WITH_GL_EGL) XrGraphicsBindingEGLMNDX egl; -# else XrGraphicsBindingOpenGLXlibKHR glx; -# endif #elif defined(WIN32) XrGraphicsBindingOpenGLWin32KHR wgl; XrGraphicsBindingD3D11KHR d3d11; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index cf04287af9f..bfb7c958048 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -110,8 +110,7 @@ bool GHOST_System::validWindow(GHOST_IWindow *window) GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting &setting, GHOST_IWindow **window, - const bool stereoVisual, - const bool alphaBackground) + const bool stereoVisual) { GHOST_TSuccess success = GHOST_kFailure; GHOST_ASSERT(m_windowManager, "GHOST_System::beginFullScreen(): invalid window manager"); @@ -125,8 +124,7 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting &setting setting); if (success == GHOST_kSuccess) { // GHOST_PRINT("GHOST_System::beginFullScreen(): creating full-screen window\n"); - success = createFullScreenWindow( - (GHOST_Window **)window, setting, stereoVisual, alphaBackground); + success = createFullScreenWindow((GHOST_Window **)window, setting, stereoVisual); if (success == GHOST_kSuccess) { m_windowManager->beginFullScreen(*window, stereoVisual); } @@ -373,18 +371,13 @@ GHOST_TSuccess GHOST_System::exit() GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window, const GHOST_DisplaySetting &settings, - const bool stereoVisual, - const bool alphaBackground) + const bool stereoVisual) { GHOST_GLSettings glSettings = {0}; if (stereoVisual) { glSettings.flags |= GHOST_glStereoVisual; } - if (alphaBackground) { - glSettings.flags |= GHOST_glAlphaBackground; - } - /* NOTE: don't use #getCurrentDisplaySetting() because on X11 we may * be zoomed in and the desktop may be bigger than the viewport. */ GHOST_ASSERT(m_displayManager, diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index d5558be3444..8c51b3421b2 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -120,8 +120,7 @@ class GHOST_System : public GHOST_ISystem { */ GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting &setting, GHOST_IWindow **window, - const bool stereoVisual, - const bool alphaBackground); + const bool stereoVisual); /** * Updates the resolution while in fullscreen mode. @@ -376,8 +375,7 @@ class GHOST_System : public GHOST_ISystem { */ GHOST_TSuccess createFullScreenWindow(GHOST_Window **window, const GHOST_DisplaySetting &settings, - const bool stereoVisual, - const bool alphaBackground = 0); + const bool stereoVisual); /** The display manager (platform dependent). */ GHOST_DisplayManager *m_displayManager; diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 18d91d43057..6a90cf5c71e 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -23,8 +23,6 @@ # include <wayland_dynload_API.h> /* For `ghost_wl_dynload_libraries`. */ #endif -#include <EGL/egl.h> - #ifdef WITH_GHOST_WAYLAND_DYNLOAD # include <wayland_dynload_egl.h> #endif diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 7c07ea6cd64..07c86cd84f2 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -227,7 +227,7 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(const char *title, state, type, ((glSettings.flags & GHOST_glStereoVisual) != 0), - ((glSettings.flags & GHOST_glAlphaBackground) != 0), + false, (GHOST_WindowWin32 *)parentWindow, ((glSettings.flags & GHOST_glDebugContext) != 0), is_dialog); @@ -272,7 +272,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GLSettings glSet HDC mHDC = GetDC(wnd); HDC prev_hdc = wglGetCurrentDC(); HGLRC prev_context = wglGetCurrentContext(); -#if defined(WITH_GL_PROFILE_CORE) + for (int minor = 5; minor >= 0; --minor) { context = new GHOST_ContextWGL(false, true, @@ -310,29 +310,6 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GLSettings glSet return NULL; } -#elif defined(WITH_GL_PROFILE_COMPAT) - // ask for 2.1 context, driver gives any GL version >= 2.1 - // (hopefully the latest compatibility profile) - // 2.1 ignores the profile bit & is incompatible with core profile - context = new GHOST_ContextWGL(false, - true, - NULL, - NULL, - 0, // no profile bit - 2, - 1, - (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), - GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); - - if (context->initializeDrawingContext()) { - return context; - } - else { - delete context; - } -#else -# error // must specify either core or compat at build time -#endif finished: wglMakeCurrent(prev_hdc, prev_context); return context; diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 0c29a825b8c..18660b3346a 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -33,12 +33,8 @@ #include "GHOST_Debug.h" -#if defined(WITH_GL_EGL) -# include "GHOST_ContextEGL.h" -# include <EGL/eglext.h> -#else -# include "GHOST_ContextGLX.h" -#endif +#include "GHOST_ContextEGL.h" +#include "GHOST_ContextGLX.h" #ifdef WITH_XF86KEYSYM # include <X11/XF86keysym.h> @@ -235,10 +231,6 @@ GHOST_SystemX11::~GHOST_SystemX11() clearXInputDevices(); #endif /* WITH_X11_XINPUT */ -#ifdef WITH_GL_EGL - ::eglTerminate(::eglGetDisplay(m_display)); -#endif - if (m_xkb_descr) { XkbFreeKeyboard(m_xkb_descr, XkbAllComponentsMask, true); } @@ -354,7 +346,6 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const char *title, is_dialog, ((glSettings.flags & GHOST_glStereoVisual) != 0), exclusive, - ((glSettings.flags & GHOST_glAlphaBackground) != 0), (glSettings.flags & GHOST_glDebugContext) != 0); if (window) { @@ -375,6 +366,56 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const char *title, return window; } +#ifdef USE_EGL +static GHOST_Context *create_egl_context( + GHOST_SystemX11 *system, Display *display, bool debug_context, int ver_major, int ver_minor) +{ + GHOST_Context *context; + context = new GHOST_ContextEGL(system, + false, + EGLNativeWindowType(nullptr), + EGLNativeDisplayType(display), + EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, + ver_major, + ver_minor, + GHOST_OPENGL_EGL_CONTEXT_FLAGS | + (debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0), + GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY, + EGL_OPENGL_API); + + if (context->initializeDrawingContext()) { + return context; + } + delete context; + + return nullptr; +} +#endif + +static GHOST_Context *create_glx_context(Display *display, + bool debug_context, + int ver_major, + int ver_minor) +{ + GHOST_Context *context; + context = new GHOST_ContextGLX(false, + (Window) nullptr, + display, + (GLXFBConfig) nullptr, + GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + ver_major, + ver_minor, + GHOST_OPENGL_GLX_CONTEXT_FLAGS | + (debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), + GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); + + if (context->initializeDrawingContext()) { + return context; + } + delete context; + + return nullptr; +} /** * Create a new off-screen context. * Never explicitly delete the context, use #disposeContext() instead. @@ -394,88 +435,33 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti const bool debug_context = (glSettings.flags & GHOST_glDebugContext) != 0; - const int profile_mask = -#ifdef WITH_GL_EGL -# if defined(WITH_GL_PROFILE_CORE) - EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT; -# elif defined(WITH_GL_PROFILE_COMPAT) - EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; -# else -# error // must specify either core or compat at build time -# endif -#else -# if defined(WITH_GL_PROFILE_CORE) - GLX_CONTEXT_CORE_PROFILE_BIT_ARB; -# elif defined(WITH_GL_PROFILE_COMPAT) - GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; -# else -# error // must specify either core or compat at build time -# endif -#endif - GHOST_Context *context; +#ifdef USE_EGL + /* Try to initialize an EGL context. */ for (int minor = 5; minor >= 0; --minor) { -#if defined(WITH_GL_EGL) - context = new GHOST_ContextEGL(this, - false, - EGLNativeWindowType(nullptr), - EGLNativeDisplayType(m_display), - profile_mask, - 4, - minor, - GHOST_OPENGL_EGL_CONTEXT_FLAGS | - (debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0), - GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY, - EGL_OPENGL_API); -#else - context = new GHOST_ContextGLX(false, - (Window) nullptr, - m_display, - (GLXFBConfig) nullptr, - profile_mask, - 4, - minor, - GHOST_OPENGL_GLX_CONTEXT_FLAGS | - (debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), - GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); -#endif - - if (context->initializeDrawingContext()) { + context = create_egl_context(this, m_display, debug_context, 4, minor); + if (context != nullptr) { return context; } - delete context; + } + context = create_egl_context(this, m_display, debug_context, 3, 3); + if (context != nullptr) { + return context; } -#if defined(WITH_GL_EGL) - context = new GHOST_ContextEGL(this, - false, - EGLNativeWindowType(nullptr), - EGLNativeDisplayType(m_display), - profile_mask, - 3, - 3, - GHOST_OPENGL_EGL_CONTEXT_FLAGS | - (debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0), - GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY, - EGL_OPENGL_API); -#else - context = new GHOST_ContextGLX(false, - (Window) nullptr, - m_display, - (GLXFBConfig) nullptr, - profile_mask, - 3, - 3, - GHOST_OPENGL_GLX_CONTEXT_FLAGS | - (debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), - GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); + /* EGL initialization failed, try to fallback to a GLX context. */ #endif - - if (context->initializeDrawingContext()) { + for (int minor = 5; minor >= 0; --minor) { + context = create_glx_context(m_display, debug_context, 4, minor); + if (context != nullptr) { + return context; + } + } + context = create_glx_context(m_display, debug_context, 3, 3); + if (context != nullptr) { return context; } - delete context; return nullptr; } diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 2e17454d24f..20ab71ac95a 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -580,7 +580,6 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty if (type == GHOST_kDrawingContextTypeOpenGL) { GHOST_Context *context; -#if defined(WITH_GL_PROFILE_CORE) /* - AMD and Intel give us exactly this version * - NVIDIA gives at least this version <-- desired behavior * So we ask for 4.5, 4.4 ... 3.3 in descending order @@ -619,30 +618,6 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty } return context; - -#elif defined(WITH_GL_PROFILE_COMPAT) - // ask for 2.1 context, driver gives any GL version >= 2.1 - // (hopefully the latest compatibility profile) - // 2.1 ignores the profile bit & is incompatible with core profile - context = new GHOST_ContextWGL(m_wantStereoVisual, - m_wantAlphaBackground, - m_hWnd, - m_hDC, - 0, // no profile bit - 2, - 1, - (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), - GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); - - if (context->initializeDrawingContext()) { - return context; - } - else { - delete context; - } -#else -# error // must specify either core or compat at build time -#endif } else if (type == GHOST_kDrawingContextTypeD3D) { GHOST_Context *context; diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 5057989d864..0b2617c1b9e 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -10,9 +10,7 @@ #include <X11/Xmd.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> -#ifdef WITH_X11_ALPHA -# include <X11/extensions/Xrender.h> -#endif + #include "GHOST_Debug.h" #include "GHOST_IconX11.h" #include "GHOST_SystemX11.h" @@ -23,12 +21,8 @@ # include "GHOST_DropTargetX11.h" #endif -#ifdef WITH_GL_EGL -# include "GHOST_ContextEGL.h" -# include <EGL/eglext.h> -#else -# include "GHOST_ContextGLX.h" -#endif +#include "GHOST_ContextEGL.h" +#include "GHOST_ContextGLX.h" /* for XIWarpPointer */ #ifdef WITH_X11_XINPUT @@ -88,9 +82,7 @@ enum { #define _NET_WM_STATE_ADD 1 // #define _NET_WM_STATE_TOGGLE 2 // UNUSED -#ifdef WITH_GL_EGL - -static XVisualInfo *x11_visualinfo_from_egl(Display *display) +static XVisualInfo *get_x11_visualinfo(Display *display) { int num_visuals; XVisualInfo vinfo_template; @@ -98,106 +90,6 @@ static XVisualInfo *x11_visualinfo_from_egl(Display *display) return XGetVisualInfo(display, VisualScreenMask, &vinfo_template, &num_visuals); } -#else - -static XVisualInfo *x11_visualinfo_from_glx(Display *display, - bool stereoVisual, - bool needAlpha, - GLXFBConfig *fbconfig) -{ - int glx_major, glx_minor, glx_version; /* GLX version: major.minor */ - int glx_attribs[64]; - - *fbconfig = nullptr; - - /* Set up the minimum attributes that we require and see if - * X can find us a visual matching those requirements. */ - - if (!glXQueryVersion(display, &glx_major, &glx_minor)) { - fprintf(stderr, - "%s:%d: X11 glXQueryVersion() failed, " - "verify working openGL system!\n", - __FILE__, - __LINE__); - - return nullptr; - } - glx_version = glx_major * 100 + glx_minor; -# ifndef WITH_X11_ALPHA - (void)glx_version; -# endif - -# ifdef WITH_X11_ALPHA - if (needAlpha && glx_version >= 103 && - (glXChooseFBConfig || (glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddressARB( - (const GLubyte *)"glXChooseFBConfig")) != nullptr) && - (glXGetVisualFromFBConfig || - (glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddressARB( - (const GLubyte *)"glXGetVisualFromFBConfig")) != nullptr)) { - - GHOST_X11_GL_GetAttributes(glx_attribs, 64, stereoVisual, needAlpha, true); - - int nbfbconfig; - GLXFBConfig *fbconfigs = glXChooseFBConfig( - display, DefaultScreen(display), glx_attribs, &nbfbconfig); - - /* Any sample level or even zero, which means oversampling disabled, is good - * but we need a valid visual to continue */ - if (nbfbconfig > 0) { - /* take a frame buffer config that has alpha cap */ - for (int i = 0; i < nbfbconfig; i++) { - XVisualInfo *visual = (XVisualInfo *)glXGetVisualFromFBConfig(display, fbconfigs[i]); - if (!visual) { - continue; - } - /* if we don't need a alpha background, the first config will do, otherwise - * test the alphaMask as it won't necessarily be present */ - if (needAlpha) { - XRenderPictFormat *pict_format = XRenderFindVisualFormat(display, visual->visual); - if (!pict_format) { - continue; - } - if (pict_format->direct.alphaMask <= 0) { - continue; - } - } - - *fbconfig = fbconfigs[i]; - XFree(fbconfigs); - - return visual; - } - - XFree(fbconfigs); - } - } - else -# endif - { - /* legacy, don't use extension */ - GHOST_X11_GL_GetAttributes(glx_attribs, 64, stereoVisual, needAlpha, false); - - XVisualInfo *visual = glXChooseVisual(display, DefaultScreen(display), glx_attribs); - - /* Any sample level or even zero, which means oversampling disabled, is good - * but we need a valid visual to continue */ - if (visual != nullptr) { - return visual; - } - } - - /* All options exhausted, cannot continue */ - fprintf(stderr, - "%s:%d: X11 glXChooseVisual() failed, " - "verify working openGL system!\n", - __FILE__, - __LINE__); - - return nullptr; -} - -#endif // WITH_GL_EGL - GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system, Display *display, const char *title, @@ -211,7 +103,6 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system, const bool is_dialog, const bool stereoVisual, const bool exclusive, - const bool alphaBackground, const bool is_debug) : GHOST_Window(width, height, state, stereoVisual, exclusive), m_display(display), @@ -235,13 +126,7 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system, m_is_debug_context(is_debug) { if (type == GHOST_kDrawingContextTypeOpenGL) { -#ifdef WITH_GL_EGL - m_visualInfo = x11_visualinfo_from_egl(m_display); - (void)alphaBackground; -#else - m_visualInfo = x11_visualinfo_from_glx( - m_display, stereoVisual, alphaBackground, (GLXFBConfig *)&m_fbconfig); -#endif + m_visualInfo = get_x11_visualinfo(m_display); } else { XVisualInfo tmp = {nullptr}; @@ -1293,6 +1178,65 @@ GHOST_WindowX11::~GHOST_WindowX11() } } +#ifdef USE_EGL +static GHOST_Context *create_egl_context(GHOST_SystemX11 *system, + Window window, + Display *display, + bool want_stereo, + bool debug_context, + int ver_major, + int ver_minor) +{ + GHOST_Context *context; + context = new GHOST_ContextEGL(system, + want_stereo, + EGLNativeWindowType(window), + EGLNativeDisplayType(display), + EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, + ver_major, + ver_minor, + GHOST_OPENGL_EGL_CONTEXT_FLAGS | + (debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0), + GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY, + EGL_OPENGL_API); + + if (context->initializeDrawingContext()) { + return context; + } + delete context; + + return nullptr; +} +#endif + +static GHOST_Context *create_glx_context(Window window, + Display *display, + GLXFBConfig fbconfig, + bool want_stereo, + bool debug_context, + int ver_major, + int ver_minor) +{ + GHOST_Context *context; + context = new GHOST_ContextGLX(want_stereo, + window, + display, + fbconfig, + GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + ver_major, + ver_minor, + GHOST_OPENGL_GLX_CONTEXT_FLAGS | + (debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), + GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); + + if (context->initializeDrawingContext()) { + return context; + } + delete context; + + return nullptr; +} + GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type) { if (type == GHOST_kDrawingContextTypeOpenGL) { @@ -1307,89 +1251,48 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type * - Try 3.3 core profile * - No fall-backs. */ - const int profile_mask = -#ifdef WITH_GL_EGL -# if defined(WITH_GL_PROFILE_CORE) - EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT; -# elif defined(WITH_GL_PROFILE_COMPAT) - EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; -# else -# error // must specify either core or compat at build time -# endif -#else -# if defined(WITH_GL_PROFILE_CORE) - GLX_CONTEXT_CORE_PROFILE_BIT_ARB; -# elif defined(WITH_GL_PROFILE_COMPAT) - GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; -# else -# error // must specify either core or compat at build time -# endif -#endif - GHOST_Context *context; +#ifdef USE_EGL + /* Try to initialize an EGL context. */ for (int minor = 5; minor >= 0; --minor) { -#ifdef WITH_GL_EGL - context = new GHOST_ContextEGL( - this->m_system, - m_wantStereoVisual, - EGLNativeWindowType(m_window), - EGLNativeDisplayType(m_display), - profile_mask, - 4, - minor, - GHOST_OPENGL_EGL_CONTEXT_FLAGS | - (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0), - GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY, - EGL_OPENGL_API); -#else - context = new GHOST_ContextGLX(m_wantStereoVisual, - m_window, - m_display, - (GLXFBConfig)m_fbconfig, - profile_mask, - 4, - minor, - GHOST_OPENGL_GLX_CONTEXT_FLAGS | - (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), - GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); -#endif - - if (context->initializeDrawingContext()) { + context = create_egl_context( + this->m_system, m_window, m_display, m_wantStereoVisual, m_is_debug_context, 4, minor); + if (context != nullptr) { return context; } - delete context; } -#ifdef WITH_GL_EGL - context = new GHOST_ContextEGL(this->m_system, - m_wantStereoVisual, - EGLNativeWindowType(m_window), - EGLNativeDisplayType(m_display), - profile_mask, - 3, - 3, - GHOST_OPENGL_EGL_CONTEXT_FLAGS | - (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0), - GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY, - EGL_OPENGL_API); -#else - context = new GHOST_ContextGLX(m_wantStereoVisual, - m_window, + context = create_egl_context( + this->m_system, m_window, m_display, m_wantStereoVisual, m_is_debug_context, 3, 3); + if (context != nullptr) { + return context; + } + + /* EGL initialization failed, try to fallback to a GLX context. */ +#endif + for (int minor = 5; minor >= 0; --minor) { + context = create_glx_context(m_window, m_display, (GLXFBConfig)m_fbconfig, - profile_mask, - 3, - 3, - GHOST_OPENGL_GLX_CONTEXT_FLAGS | - (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), - GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); -#endif - - if (context->initializeDrawingContext()) { + m_wantStereoVisual, + m_is_debug_context, + 4, + minor); + if (context != nullptr) { + return context; + } + } + context = create_glx_context(m_window, + m_display, + (GLXFBConfig)m_fbconfig, + m_wantStereoVisual, + m_is_debug_context, + 3, + 3); + if (context != nullptr) { return context; } - delete context; /* Ugly, but we get crashes unless a whole bunch of systems are patched. */ fprintf(stderr, "Error! Unsupported graphics card or driver.\n"); diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h index ac4edd83549..c7a6b5e7357 100644 --- a/intern/ghost/intern/GHOST_WindowX11.h +++ b/intern/ghost/intern/GHOST_WindowX11.h @@ -47,7 +47,6 @@ class GHOST_WindowX11 : public GHOST_Window { * \param parentWindow: Parent (embedder) window. * \param type: The type of drawing context installed in this window. * \param stereoVisual: Stereo visual for quad buffered stereo. - * \param alphaBackground: Enable alpha blending of window with display background. */ GHOST_WindowX11(GHOST_SystemX11 *system, Display *display, @@ -62,7 +61,6 @@ class GHOST_WindowX11 : public GHOST_Window { const bool is_dialog = false, const bool stereoVisual = false, const bool exclusive = false, - const bool alphaBackground = false, const bool is_debug = false); bool getValid() const; diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp index 2ac3d9ec2a5..413e2670750 100644 --- a/intern/ghost/intern/GHOST_XrContext.cpp +++ b/intern/ghost/intern/GHOST_XrContext.cpp @@ -436,9 +436,11 @@ void GHOST_XrContext::getExtensionsToEnable( r_ext_names.push_back(gpu_binding); } -#if defined(WITH_GHOST_X11) && defined(WITH_GL_EGL) - assert(openxr_extension_is_available(m_oxr->extensions, XR_MNDX_EGL_ENABLE_EXTENSION_NAME)); - r_ext_names.push_back(XR_MNDX_EGL_ENABLE_EXTENSION_NAME); +#if defined(WITH_GHOST_X11) + if (openxr_extension_is_available(m_oxr->extensions, XR_MNDX_EGL_ENABLE_EXTENSION_NAME)) { + /* Use EGL if that backend is available. */ + r_ext_names.push_back(XR_MNDX_EGL_ENABLE_EXTENSION_NAME); + } #endif for (const std::string_view &ext : try_ext) { diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp index aa230bf8deb..267d19dcecb 100644 --- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp +++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp @@ -8,17 +8,16 @@ #include <list> #include <sstream> -#if defined(WITH_GL_EGL) +#if defined(WITH_GHOST_X11) # include "GHOST_ContextEGL.h" -# if defined(WITH_GHOST_X11) -# include "GHOST_SystemX11.h" -# endif -# if defined(WITH_GHOST_WAYLAND) -# include "GHOST_SystemWayland.h" -# endif -#elif defined(WITH_GHOST_X11) # include "GHOST_ContextGLX.h" -#elif defined(WIN32) +# include "GHOST_SystemX11.h" +#endif +#if defined(WITH_GHOST_WAYLAND) +# include "GHOST_ContextEGL.h" +# include "GHOST_SystemWayland.h" +#endif +#if defined(WIN32) # include "GHOST_ContextD3D.h" # include "GHOST_ContextWGL.h" # include "GHOST_SystemWin32.h" @@ -61,19 +60,30 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { XrSystemId system_id, std::string *r_requirement_info) const override { -#if defined(WITH_GL_EGL) - GHOST_ContextEGL &ctx_gl = static_cast<GHOST_ContextEGL &>(ghost_ctx); -#elif defined(WITH_GHOST_X11) - GHOST_ContextGLX &ctx_gl = static_cast<GHOST_ContextGLX &>(ghost_ctx); -#else + int gl_major_version, gl_minor_version; +#if defined(WIN32) GHOST_ContextWGL &ctx_gl = static_cast<GHOST_ContextWGL &>(ghost_ctx); + gl_major_version = ctx_gl.m_contextMajorVersion; + gl_minor_version = ctx_gl.m_contextMinorVersion; +#elif defined(WITH_GHOST_X11) || defined(WITH_GHOST_WAYLAND) + if (dynamic_cast<GHOST_ContextEGL *>(&ghost_ctx)) { + GHOST_ContextEGL &ctx_gl = static_cast<GHOST_ContextEGL &>(ghost_ctx); + gl_major_version = ctx_gl.m_contextMajorVersion; + gl_minor_version = ctx_gl.m_contextMinorVersion; + } +# if defined(WITH_GHOST_X11) + else { + GHOST_ContextGLX &ctx_gl = static_cast<GHOST_ContextGLX &>(ghost_ctx); + gl_major_version = ctx_gl.m_contextMajorVersion; + gl_minor_version = ctx_gl.m_contextMinorVersion; + } +# endif #endif static PFN_xrGetOpenGLGraphicsRequirementsKHR s_xrGetOpenGLGraphicsRequirementsKHR_fn = nullptr; // static XrInstance s_instance = XR_NULL_HANDLE; XrGraphicsRequirementsOpenGLKHR gpu_requirements = {XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR}; - const XrVersion gl_version = XR_MAKE_VERSION( - ctx_gl.m_contextMajorVersion, ctx_gl.m_contextMinorVersion, 0); + const XrVersion gl_version = XR_MAKE_VERSION(gl_major_version, gl_minor_version, 0); /* Although it would seem reasonable that the proc address would not change if the instance was * the same, in testing, repeated calls to #xrGetInstanceProcAddress() with the same instance @@ -112,30 +122,41 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { void initFromGhostContext(GHOST_Context &ghost_ctx) override { -#if defined(WITH_GHOST_X11) -# if defined(WITH_GL_EGL) - GHOST_ContextEGL &ctx_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx); - - if (dynamic_cast<const GHOST_SystemX11 *const>(ctx_egl.m_system)) { - oxr_binding.egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX; - oxr_binding.egl.getProcAddress = eglGetProcAddress; - oxr_binding.egl.display = ctx_egl.getDisplay(); - oxr_binding.egl.config = ctx_egl.getConfig(); - oxr_binding.egl.context = ctx_egl.getContext(); +#if defined(WITH_GHOST_X11) || defined(WITH_GHOST_WAYLAND) + if (dynamic_cast<GHOST_ContextEGL *>(&ghost_ctx)) { + GHOST_ContextEGL &ctx_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx); + +# if defined(WITH_GHOST_WAYLAND) + if (dynamic_cast<const GHOST_SystemWayland *const>(ctx_egl.m_system)) { + oxr_binding.wl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR; + oxr_binding.wl.display = (struct wl_display *)ctx_egl.m_nativeDisplay; + } + else +# endif +# if defined(WITH_GHOST_X11) + { + /* SystemX11. */ + oxr_binding.egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX; + oxr_binding.egl.getProcAddress = eglGetProcAddress; + oxr_binding.egl.display = ctx_egl.getDisplay(); + oxr_binding.egl.config = ctx_egl.getConfig(); + oxr_binding.egl.context = ctx_egl.getContext(); + } } -# else - GHOST_ContextGLX &ctx_glx = static_cast<GHOST_ContextGLX &>(ghost_ctx); - XVisualInfo *visual_info = glXGetVisualFromFBConfig(ctx_glx.m_display, ctx_glx.m_fbconfig); + else { + GHOST_ContextGLX &ctx_glx = static_cast<GHOST_ContextGLX &>(ghost_ctx); + XVisualInfo *visual_info = glXGetVisualFromFBConfig(ctx_glx.m_display, ctx_glx.m_fbconfig); - oxr_binding.glx.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR; - oxr_binding.glx.xDisplay = ctx_glx.m_display; - oxr_binding.glx.glxFBConfig = ctx_glx.m_fbconfig; - oxr_binding.glx.glxDrawable = ctx_glx.m_window; - oxr_binding.glx.glxContext = ctx_glx.m_context; - oxr_binding.glx.visualid = visual_info->visualid; + oxr_binding.glx.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR; + oxr_binding.glx.xDisplay = ctx_glx.m_display; + oxr_binding.glx.glxFBConfig = ctx_glx.m_fbconfig; + oxr_binding.glx.glxDrawable = ctx_glx.m_window; + oxr_binding.glx.glxContext = ctx_glx.m_context; + oxr_binding.glx.visualid = visual_info->visualid; - XFree(visual_info); + XFree(visual_info); # endif + } #elif defined(WIN32) GHOST_ContextWGL &ctx_wgl = static_cast<GHOST_ContextWGL &>(ghost_ctx); @@ -144,14 +165,6 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { oxr_binding.wgl.hGLRC = ctx_wgl.m_hGLRC; #endif -#if defined(WITH_GHOST_WAYLAND) - GHOST_ContextEGL &ctx_wl_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx); - if (dynamic_cast<const GHOST_SystemWayland *const>(ctx_wl_egl.m_system)) { - oxr_binding.wl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR; - oxr_binding.wl.display = (struct wl_display *)ctx_wl_egl.m_nativeDisplay; - } -#endif - /* Generate a frame-buffer to use for blitting into the texture. */ glGenFramebuffers(1, &m_fbo); } diff --git a/intern/ghost/intern/GHOST_Xr_openxr_includes.h b/intern/ghost/intern/GHOST_Xr_openxr_includes.h index 9f993ae45c2..1c16f746f7a 100644 --- a/intern/ghost/intern/GHOST_Xr_openxr_includes.h +++ b/intern/ghost/intern/GHOST_Xr_openxr_includes.h @@ -28,11 +28,8 @@ # include <d3d12.h> #endif #ifdef WITH_GHOST_X11 -# ifdef WITH_GL_EGL -# include <epoxy/egl.h> -# else -# include <epoxy/glx.h> -# endif +# include <epoxy/egl.h> +# include <epoxy/glx.h> #endif #include <openxr/openxr.h> diff --git a/intern/ghost/test/CMakeLists.txt b/intern/ghost/test/CMakeLists.txt index 95415f4e9b9..3f74f97f115 100644 --- a/intern/ghost/test/CMakeLists.txt +++ b/intern/ghost/test/CMakeLists.txt @@ -89,8 +89,6 @@ if(UNIX AND NOT APPLE) set(WITH_GHOST_X11 ON) endif() -# for now... default to this -add_definitions(-DWITH_GL_PROFILE_COMPAT) # BLF needs this to ignore GPU library add_definitions(-DBLF_STANDALONE) diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt index d676079f3c2..8fe478d35c1 100644 --- a/intern/opencolorio/CMakeLists.txt +++ b/intern/opencolorio/CMakeLists.txt @@ -31,7 +31,6 @@ if(WITH_OPENCOLORIO) -DWITH_OCIO ) - add_definitions(${GL_DEFINITIONS}) add_definitions(${OPENCOLORIO_DEFINITIONS}) list(APPEND INC_SYS diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt index 058e29ea71c..596534fc82c 100644 --- a/intern/opensubdiv/CMakeLists.txt +++ b/intern/opensubdiv/CMakeLists.txt @@ -87,8 +87,6 @@ if(WITH_OPENSUBDIV) OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK) OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_COMPUTE) - add_definitions(${GL_DEFINITIONS}) - if(WIN32) add_definitions(-DNOMINMAX) add_definitions(-D_USE_MATH_DEFINES) diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 947fc32f8c0..5ef9ae1bbc6 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -94,8 +94,6 @@ endif() set(LIB ) -add_definitions(${GL_DEFINITIONS}) - blender_add_lib(bf_gpencil_modifiers "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") add_dependencies(bf_gpencil_modifiers bf_dna) diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 0b287fdcf2f..ec964b5d8f3 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -221,7 +221,6 @@ if(WITH_METAL_BACKEND) endif() set(LIB - ${BLENDER_GL_LIBRARIES} ${Epoxy_LIBRARIES} ) @@ -585,8 +584,6 @@ if(WITH_MOD_FLUID) add_definitions(-DWITH_FLUID) endif() -add_definitions(${GL_DEFINITIONS}) - if(WITH_IMAGE_DDS) add_definitions(-DWITH_DDS) endif() diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 25229262392..b0fb86c8bc3 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -449,8 +449,6 @@ set(LIB bf_editor_undo ) -add_definitions(${GL_DEFINITIONS}) - blender_add_lib(bf_rna "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") # Needed so we can use dna_type_offsets.h for defaults initialization. diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt index 713f2c5c09c..27b7ad28943 100644 --- a/source/blender/python/generic/CMakeLists.txt +++ b/source/blender/python/generic/CMakeLists.txt @@ -45,6 +45,4 @@ set(LIB ${PYTHON_LIBRARIES} ) -add_definitions(${GL_DEFINITIONS}) - blender_add_lib(bf_python_ext "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/python/gpu/CMakeLists.txt b/source/blender/python/gpu/CMakeLists.txt index 119aba29f60..e9db5c8716b 100644 --- a/source/blender/python/gpu/CMakeLists.txt +++ b/source/blender/python/gpu/CMakeLists.txt @@ -63,6 +63,4 @@ set(LIB ${PYTHON_LIBRARIES} ) -add_definitions(${GL_DEFINITIONS}) - blender_add_lib(bf_python_gpu "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 352110a5292..becba393a36 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -890,18 +890,6 @@ elseif(WIN32) unset(_PYTHON_VERSION_NO_DOTS) endif() - # EGL Runtime Components - if(WITH_GL_EGL) - if(WIN32) - install(FILES "${OPENGLES_DLL}" DESTINATION ".") - install(FILES "${OPENGLES_EGL_DLL}" DESTINATION ".") - - if(WITH_GL_ANGLE) - install(FILES "${D3DCOMPILER_DLL}" DESTINATION ".") - endif() - endif() - endif() - if(WITH_CODEC_FFMPEG) # Filenames change slightly between ffmpeg versions # check both 5.0 and fallback to 4.4 to ease the transition |