Merge branch 'master' into refactor-mesh-selection-generic

This commit is contained in:
Hans Goudey 2022-08-25 13:23:10 -04:00
commit 5116bfd51f
627 changed files with 9212 additions and 104477 deletions

View File

@ -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()
@ -112,6 +105,12 @@ blender_project_hack_post()
enable_testing()
#-----------------------------------------------------------------------------
# Test compiler/library features.
include(build_files/cmake/have_features.cmake)
#-----------------------------------------------------------------------------
# Redirect output files
@ -262,7 +261,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,48 +534,14 @@ 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)
if(WITH_GL_EGL)
# GLEW can only be built with either GLX or EGL support. Most binary distributions are
# built with GLX support and we have no automated way to detect this. So always build
# GLEW from source to be sure it has EGL support.
set(WITH_SYSTEM_GLEW OFF)
else()
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
endif()
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
else()
# System GLEW and GLES not an option on other platforms.
set(WITH_SYSTEM_GLEW OFF)
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_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
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_GLEW_ES
WITH_GL_PROFILE_ES20
WITH_GPU_BUILDTIME_SHADER_BUILDER
)
if(WITH_HEADLESS)
set(WITH_OPENGL OFF)
endif()
# Metal
if(APPLE)
@ -591,16 +555,6 @@ if(WITH_METAL_BACKEND)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE)
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(WITH_GLEW_ES AND WITH_SYSTEM_GLEW)
message(WARNING Ignoring WITH_SYSTEM_GLEW and using WITH_GLEW_ES)
set(WITH_SYSTEM_GLEW OFF)
endif()
if(WIN32)
getDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
@ -777,6 +731,13 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()
endif()
# Effective install path including config folder, as a generator expression.
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(GENERATOR_IS_MULTI_CONFIG)
string(REPLACE "\${BUILD_TYPE}" "$<CONFIG>" CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX})
else()
string(REPLACE "\${BUILD_TYPE}" "" CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX})
endif()
# Apple
@ -897,7 +858,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)
@ -1212,139 +1172,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 -DGLEW_EGL -DGLEW_INC_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)
@ -1388,66 +1219,6 @@ if(WITH_OPENMP)
)
endif()
#-----------------------------------------------------------------------------
# Configure GLEW
if(WITH_SYSTEM_GLEW)
find_package(GLEW)
# Note: There is an assumption here that the system GLEW is not a static library.
if(NOT GLEW_FOUND)
message(FATAL_ERROR "GLEW is required to build Blender. Install it or disable WITH_SYSTEM_GLEW.")
endif()
set(GLEW_INCLUDE_PATH "${GLEW_INCLUDE_DIR}")
set(BLENDER_GLEW_LIBRARIES ${GLEW_LIBRARY})
else()
if(WITH_GLEW_ES)
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include")
list(APPEND GL_DEFINITIONS -DGLEW_STATIC -DWITH_GLEW_ES)
# These definitions remove APIs from glew.h, making GLEW smaller, and catching unguarded API usage
if(WITH_GL_PROFILE_ES20)
list(APPEND GL_DEFINITIONS -DGLEW_ES_ONLY)
else()
# No ES functions are needed
list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
endif()
if(WITH_GL_PROFILE_ES20)
if(WITH_GL_EGL)
list(APPEND GL_DEFINITIONS -DGLEW_USE_LIB_ES20)
endif()
# ToDo: This is an experiment to eliminate ES 1 symbols,
# GLEW doesn't really properly provide this level of control
# (for example, without modification it eliminates too many symbols)
# so there are lots of modifications to GLEW to make this work,
# and no attempt to make it work beyond Blender at this point.
list(APPEND GL_DEFINITIONS -DGL_ES_VERSION_1_0=0 -DGL_ES_VERSION_CL_1_1=0 -DGL_ES_VERSION_CM_1_1=0)
endif()
set(BLENDER_GLEW_LIBRARIES extern_glew_es bf_intern_glew_mx)
else()
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
list(APPEND GL_DEFINITIONS -DGLEW_STATIC)
# This won't affect the non-experimental glew library,
# but is used for conditional compilation elsewhere.
list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
set(BLENDER_GLEW_LIBRARIES extern_glew)
endif()
endif()
list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
#-----------------------------------------------------------------------------
# Configure Bullet
@ -1973,7 +1744,6 @@ if(WITH_BLENDER)
# internal and external library information first, for test linking
add_subdirectory(source)
elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
add_subdirectory(intern/glew-mx)
add_subdirectory(intern/guardedalloc)
add_subdirectory(intern/libc_compat)
add_subdirectory(intern/sky)
@ -1991,9 +1761,6 @@ elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
if(WITH_HIP_DYNLOAD)
add_subdirectory(extern/hipew)
endif()
if(NOT WITH_SYSTEM_GLEW)
add_subdirectory(extern/glew)
endif()
endif()
#-----------------------------------------------------------------------------
@ -2086,8 +1853,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_SYSTEM_GLEW)
info_cfg_option(WITH_X11_ALPHA)
info_cfg_option(WITH_X11_XF86VMODE)
info_cfg_option(WITH_X11_XFIXES)
info_cfg_option(WITH_X11_XINPUT)
@ -2134,14 +1899,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_option(WITH_GLEW_ES)
info_cfg_text("")
message("${_config_msg}")

View File

@ -53,8 +53,8 @@ include(cmake/imath.cmake)
include(cmake/openexr.cmake)
include(cmake/brotli.cmake)
include(cmake/freetype.cmake)
include(cmake/epoxy.cmake)
include(cmake/freeglut.cmake)
include(cmake/glew.cmake)
include(cmake/alembic.cmake)
include(cmake/opensubdiv.cmake)
include(cmake/sdl.cmake)

View File

@ -12,21 +12,13 @@ if(UNIX)
automake
bison
${_libtoolize_name}
meson
ninja
pkg-config
tclsh
yasm
)
if(NOT APPLE)
set(_required_software
${_required_software}
# Needed for Mesa.
meson
ninja
)
endif()
foreach(_software ${_required_software})
find_program(_software_find NAMES ${_software})
if(NOT _software_find)
@ -57,7 +49,7 @@ if(UNIX)
" apt install autoconf automake libtool yasm tcl ninja-build meson python3-mako\n"
"\n"
"On macOS (with homebrew):\n"
" brew install autoconf automake bison flex libtool pkg-config yasm\n"
" brew install autoconf automake bison flex libtool meson ninja pkg-config yasm\n"
"\n"
"Other platforms:\n"
" Install equivalent packages.\n")

View File

@ -36,7 +36,7 @@ download_source(BLOSC)
download_source(PTHREADS)
download_source(OPENEXR)
download_source(FREETYPE)
download_source(GLEW)
download_source(EPOXY)
download_source(FREEGLUT)
download_source(ALEMBIC)
download_source(OPENSUBDIV)
@ -94,6 +94,7 @@ download_source(GMP)
download_source(POTRACE)
download_source(HARU)
download_source(ZSTD)
download_source(SSE2NEON)
download_source(FLEX)
download_source(BROTLI)
download_source(FMT)

View File

@ -0,0 +1,25 @@
# SPDX-License-Identifier: GPL-2.0-or-later
if(WIN32)
set(EPOXY_LIB_TYPE shared)
else()
set(EPOXY_LIB_TYPE static)
endif()
ExternalProject_Add(external_epoxy
URL file://${PACKAGE_DIR}/${EPOXY_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${EPOXY_HASH_TYPE}=${EPOXY_HASH}
PREFIX ${BUILD_DIR}/epoxy
PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/epoxy/src/external_epoxy/ < ${PATCH_DIR}/epoxy.diff
CONFIGURE_COMMAND ${CONFIGURE_ENV} && meson setup --prefix ${LIBDIR}/epoxy --default-library ${EPOXY_LIB_TYPE} --libdir lib ${BUILD_DIR}/epoxy/src/external_epoxy-build ${BUILD_DIR}/epoxy/src/external_epoxy -Dtests=false
BUILD_COMMAND ninja
INSTALL_COMMAND ninja install
)
if(BUILD_MODE STREQUAL Release AND WIN32)
ExternalProject_Add_Step(external_epoxy after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/epoxy/include ${HARVEST_TARGET}/epoxy/include
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/epoxy/bin/epoxy-0.dll ${HARVEST_TARGET}/epoxy/bin/epoxy-0.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/epoxy/lib/epoxy.lib ${HARVEST_TARGET}/epoxy/lib/epoxy.lib
DEPENDEES install
)
endif()

View File

@ -1,16 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
set(GLEW_EXTRA_ARGS
-DBUILD_UTILS=Off
-DBUILD_SHARED_LIBS=Off
)
ExternalProject_Add(external_glew
URL file://${PACKAGE_DIR}/${GLEW_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${GLEW_HASH_TYPE}=${GLEW_HASH}
PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_glew.txt ${BUILD_DIR}/glew/src/external_glew/CMakeLists.txt
PREFIX ${BUILD_DIR}/glew
CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${LIBDIR}/glew ${DEFAULT_CMAKE_FLAGS} ${GLEW_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/glew
)

View File

@ -22,9 +22,6 @@ if(BUILD_MODE STREQUAL Release)
# freeglut-> opengl
${CMAKE_COMMAND} -E copy ${LIBDIR}/freeglut/lib/freeglut_static.lib ${HARVEST_TARGET}/opengl/lib/freeglut_static.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freeglut/include/ ${HARVEST_TARGET}/opengl/include/ &&
# glew-> opengl
${CMAKE_COMMAND} -E copy ${LIBDIR}/glew/lib/libglew32.lib ${HARVEST_TARGET}/opengl/lib/glew.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/glew/include/ ${HARVEST_TARGET}/opengl/include/ &&
DEPENDS
)
endif()
@ -75,8 +72,8 @@ harvest(fftw3/lib fftw3/lib "*.a")
harvest(flac/lib sndfile/lib "libFLAC.a")
harvest(freetype/include freetype/include "*.h")
harvest(freetype/lib/libfreetype2ST.a freetype/lib/libfreetype.a)
harvest(glew/include glew/include "*.h")
harvest(glew/lib glew/lib "*.a")
harvest(epoxy/include epoxy/include "*.h")
harvest(epoxy/lib epoxy/lib "*.a")
harvest(gmp/include gmp/include "*.h")
harvest(gmp/lib gmp/lib "*.a")
harvest(jemalloc/include jemalloc/include "*.h")

View File

@ -27,6 +27,7 @@ if(WIN32)
PREFIX ${BUILD_DIR}/python
CONFIGURE_COMMAND ""
BUILD_COMMAND cd ${BUILD_DIR}/python/src/external_python/pcbuild/ && set IncludeTkinter=false && call build.bat -e -p x64 -c ${BUILD_MODE}
PATCH_COMMAND ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_windows.diff
INSTALL_COMMAND ${PYTHON_BINARY_INTERNAL} ${PYTHON_SRC}/PC/layout/main.py -b ${PYTHON_SRC}/PCbuild/amd64 -s ${PYTHON_SRC} -t ${PYTHON_SRC}/tmp/ --include-stable --include-pip --include-dev --include-launchers --include-venv --include-symbols ${PYTHON_EXTRA_INSTLAL_FLAGS} --copy ${LIBDIR}/python
)

View File

@ -1,9 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
ExternalProject_Add(external_sse2neon
GIT_REPOSITORY ${SSE2NEON_GIT}
GIT_TAG ${SSE2NEON_GIT_HASH}
URL file://${PACKAGE_DIR}/${SSE2NEON_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${SSE2NEON_HASH_TYPE}=${SSE2NEON_HASH}
PREFIX ${BUILD_DIR}/sse2neon
CONFIGURE_COMMAND echo sse2neon - Nothing to configure
BUILD_COMMAND echo sse2neon - nothing to build

View File

@ -80,11 +80,11 @@ set(FREETYPE_HASH bd4e3b007474319909a6b79d50908e85)
set(FREETYPE_HASH_TYPE MD5)
set(FREETYPE_FILE freetype-${FREETYPE_VERSION}.tar.gz)
set(GLEW_VERSION 1.13.0)
set(GLEW_URI http://prdownloads.sourceforge.net/glew/glew/${GLEW_VERSION}/glew-${GLEW_VERSION}.tgz)
set(GLEW_HASH 7cbada3166d2aadfc4169c4283701066)
set(GLEW_HASH_TYPE MD5)
set(GLEW_FILE glew-${GLEW_VERSION}.tgz)
set(EPOXY_VERSION 1.5.10)
set(EPOXY_URI https://github.com/anholt/libepoxy/archive/refs/tags/${EPOXY_VERSION}.tar.gz)
set(EPOXY_HASH f0730aad115c952e77591fcc805b1dc1)
set(EPOXY_HASH_TYPE MD5)
set(EPOXY_FILE libepoxy-${EPOXY_VERSION}.tar.gz)
set(FREEGLUT_VERSION 3.0.0)
set(FREEGLUT_URI http://prdownloads.sourceforge.net/freeglut/freeglut/${FREEGLUT_VERSION}/freeglut-${FREEGLUT_VERSION}.tar.gz)
@ -488,8 +488,11 @@ set(ZSTD_HASH 5194fbfa781fcf45b98c5e849651aa7b3b0a008c6b72d4a0db760f3002291e94)
set(ZSTD_HASH_TYPE SHA256)
set(ZSTD_FILE zstd-${ZSTD_VERSION}.tar.gz)
set(SSE2NEON_GIT https://github.com/DLTcollab/sse2neon.git)
set(SSE2NEON_GIT_HASH fe5ff00bb8d19b327714a3c290f3e2ce81ba3525)
set(SSE2NEON_VERSION fe5ff00bb8d19b327714a3c290f3e2ce81ba3525)
set(SSE2NEON_URI https://github.com/DLTcollab/sse2neon/archive/${SSE2NEON_VERSION}.tar.gz)
set(SSE2NEON_HASH 0780253525d299c31775ef95853698d03db9c7739942af8570000f4a25a5d605)
set(SSE2NEON_HASH_TYPE SHA256)
set(SSE2NEON_FILE sse2neon-${SSE2NEON_VERSION}.tar.gz)
set(BROTLI_VERSION v1.0.9)
set(BROTLI_URI https://github.com/google/brotli/archive/refs/tags/${BROTLI_VERSION}.tar.gz)

View File

@ -1193,7 +1193,7 @@ Those libraries should be available as packages in all recent distributions (opt
* libx11, libxcursor, libxi, libxrandr, libxinerama (and other libx... as needed).
* libwayland-client0, libwayland-cursor0, libwayland-egl1, libxkbcommon0, libdbus-1-3, libegl1 (Wayland)
* libsqlite3, libzstd, libbz2, libssl, libfftw3, libxml2, libtinyxml, yasm, libyaml-cpp, flex.
* libsdl2, libglew, libpugixml, libpotrace, [libgmp], fontconfig, [libharu/libhpdf].\""
* libsdl2, libepoxy, libpugixml, libpotrace, [libgmp], fontconfig, [libharu/libhpdf].\""
DEPS_SPECIFIC_INFO="\"BUILDABLE DEPENDENCIES:
@ -4062,7 +4062,7 @@ install_DEB() {
libxcursor-dev libxi-dev wget libsqlite3-dev libxrandr-dev libxinerama-dev \
libwayland-dev wayland-protocols libegl-dev libxkbcommon-dev libdbus-1-dev linux-libc-dev \
libbz2-dev libncurses5-dev libssl-dev liblzma-dev libreadline-dev \
libopenal-dev libglew-dev yasm \
libopenal-dev libepoxy-dev yasm \
libsdl2-dev libfftw3-dev patch bzip2 libxml2-dev libtinyxml-dev libjemalloc-dev \
libgmp-dev libpugixml-dev libpotrace-dev libhpdf-dev libzstd-dev libpystring-dev"
@ -4772,7 +4772,7 @@ install_RPM() {
libX11-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel \
wayland-devel wayland-protocols-devel mesa-libEGL-devel libxkbcommon-devel dbus-devel kernel-headers \
wget ncurses-devel readline-devel $OPENJPEG_DEV openal-soft-devel \
glew-devel yasm patch \
libepoxy-devel yasm patch \
libxml2-devel yaml-cpp-devel tinyxml-devel jemalloc-devel \
gmp-devel pugixml-devel potrace-devel libharu-devel libzstd-devel pystring-devel"
@ -5412,7 +5412,7 @@ install_ARCH() {
fi
_packages="$BASE_DEVEL git cmake fontconfig flex \
libxi libxcursor libxrandr libxinerama glew libpng libtiff wget openal \
libxi libxcursor libxrandr libxinerama libepoxy libpng libtiff wget openal \
$OPENJPEG_DEV yasm sdl2 fftw \
libxml2 yaml-cpp tinyxml python-requests jemalloc gmp potrace pugixml libharu \
zstd pystring"

View File

@ -1,2 +0,0 @@
cmake_minimum_required (VERSION 2.4)
add_subdirectory(build/cmake)

View File

@ -0,0 +1,19 @@
--- a/src/dispatch_wgl.c 2022-08-04 17:45:13.144924705 +0200
+++ b/src/dispatch_wgl.c 2022-08-04 17:45:47.657482971 +0200
@@ -78,6 +78,8 @@
if (!first_context_current) {
first_context_current = true;
} else {
+ /* BLENDER: disable slow dispatch table switching. */
+#if 0
if (!already_switched_to_dispatch_table) {
already_switched_to_dispatch_table = true;
gl_switch_to_dispatch_table();
@@ -86,6 +88,7 @@
gl_init_dispatch_table();
wgl_init_dispatch_table();
+#endif
}
}

View File

@ -0,0 +1,24 @@
diff -Naur orig/PCbuild/get_externals.bat Python-3.10.2/PCbuild/get_externals.bat
--- orig/PCbuild/get_externals.bat 2022-01-13 11:52:14 -0700
+++ Python-3.10.2/PCbuild/get_externals.bat 2022-08-17 11:24:42 -0600
@@ -51,7 +51,7 @@
echo.Fetching external libraries...
set libraries=
-set libraries=%libraries% bzip2-1.0.6
+set libraries=%libraries% bzip2-1.0.8
if NOT "%IncludeLibffiSrc%"=="false" set libraries=%libraries% libffi-3.3.0
if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.1m
set libraries=%libraries% sqlite-3.35.5.0
diff -Naur orig/PCbuild/python.props external_python/PCbuild/python.props
--- orig/PCbuild/python.props 2022-01-13 11:52:14 -0700
+++ external_python/PCbuild/python.props 2022-08-17 11:38:38 -0600
@@ -58,7 +58,7 @@
<ExternalsDir Condition="$(ExternalsDir) == ''">$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals`))</ExternalsDir>
<ExternalsDir Condition="!HasTrailingSlash($(ExternalsDir))">$(ExternalsDir)\</ExternalsDir>
<sqlite3Dir>$(ExternalsDir)sqlite-3.35.5.0\</sqlite3Dir>
- <bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>
+ <bz2Dir>$(ExternalsDir)bzip2-1.0.8\</bz2Dir>
<lzmaDir>$(ExternalsDir)xz-5.2.2\</lzmaDir>
<libffiDir>$(ExternalsDir)libffi-3.3.0\</libffiDir>
<libffiOutDir>$(ExternalsDir)libffi-3.3.0\$(ArchName)\</libffiOutDir>

View File

@ -0,0 +1,47 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2022 Blender Foundation.
# This module defines
# Epoxy_INCLUDE_DIRS, where to find epoxy/gl.h
# Epoxy_LIBRARY, where to find the epoxy library.
# Epoxy_ROOT_DIR, The base directory to search for epoxy.
# This can also be an environment variable.
# Epoxy_FOUND, If false, do not try to use epoxy.
IF(NOT EPOXY_ROOT_DIR AND NOT $ENV{EPOXY_ROOT_DIR} STREQUAL "")
SET(EPOXY_ROOT_DIR $ENV{EPOXY_ROOT_DIR})
ENDIF()
FIND_PATH(Epoxy_INCLUDE_DIR
NAMES
epoxy/gl.h
HINTS
${EPOXY_ROOT_DIR}
PATH_SUFFIXES
include
)
FIND_LIBRARY(Epoxy_LIBRARY
NAMES
epoxy
HINTS
${EPOXY_ROOT_DIR}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set Epoxy_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Epoxy DEFAULT_MSG
Epoxy_LIBRARY Epoxy_INCLUDE_DIR)
IF(Epoxy_FOUND)
SET(Epoxy_INCLUDE_DIRS ${Epoxy_INCLUDE_DIR})
SET(Epoxy_LIBRARIES ${Epoxy_LIBRARY})
ENDIF()
MARK_AS_ADVANCED(
Epoxy_INCLUDE_DIR
Epoxy_LIBRARY
)

View File

@ -1,58 +0,0 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014 Blender Foundation.
# - Find GLEW library
# Find the native Glew includes and library
# This module defines
# GLEW_INCLUDE_DIRS, where to find glew.h, Set when
# GLEW_INCLUDE_DIR is found.
# GLEW_ROOT_DIR, The base directory to search for Glew.
# This can also be an environment variable.
# GLEW_FOUND, If false, do not try to use Glew.
#
# also defined,
# GLEW_LIBRARY, where to find the Glew library.
# If GLEW_ROOT_DIR was defined in the environment, use it.
IF(NOT GLEW_ROOT_DIR AND NOT $ENV{GLEW_ROOT_DIR} STREQUAL "")
SET(GLEW_ROOT_DIR $ENV{GLEW_ROOT_DIR})
ENDIF()
SET(_glew_SEARCH_DIRS
${GLEW_ROOT_DIR}
)
FIND_PATH(GLEW_INCLUDE_DIR
NAMES
GL/glew.h
HINTS
${_glew_SEARCH_DIRS}
PATH_SUFFIXES
include
)
FIND_LIBRARY(GLEW_LIBRARY
NAMES
GLEW
HINTS
${_glew_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW DEFAULT_MSG
GLEW_LIBRARY GLEW_INCLUDE_DIR)
IF(GLEW_FOUND)
SET(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
ENDIF()
MARK_AS_ADVANCED(
GLEW_INCLUDE_DIR
GLEW_LIBRARY
)
UNSET(_glew_SEARCH_DIRS)

View File

@ -0,0 +1,47 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2022 Blender Foundation.
# This module defines
# LibEpoxy_INCLUDE_DIRS, where to find epoxy/gl.h
# LibEpoxy_LIBRARY, where to find the epoxy library.
# LibEpoxy_ROOT_DIR, The base directory to search for libepoxy.
# This can also be an environment variable.
# LibEpoxy_FOUND, If false, do not try to use libepoxy.
IF(NOT EPOXY_ROOT_DIR AND NOT $ENV{EPOXY_ROOT_DIR} STREQUAL "")
SET(EPOXY_ROOT_DIR $ENV{EPOXY_ROOT_DIR})
ENDIF()
FIND_PATH(LibEpoxy_INCLUDE_DIR
NAMES
epoxy/gl.h
HINTS
${EPOXY_ROOT_DIR}
PATH_SUFFIXES
include
)
FIND_LIBRARY(LibEpoxy_LIBRARY
NAMES
epoxy
HINTS
${EPOXY_ROOT_DIR}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set LibEpoxy_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibEpoxy DEFAULT_MSG
LibEpoxy_LIBRARY LibEpoxy_INCLUDE_DIR)
IF(LibEpoxy_FOUND)
SET(LibEpoxy_INCLUDE_DIRS ${LibEpoxy_INCLUDE_DIR})
SET(LibEpoxy_LIBRARIES ${LibEpoxy_LIBRARY})
ENDIF()
MARK_AS_ADVANCED(
LibEpoxy_INCLUDE_DIR
LibEpoxy_LIBRARY
)

View File

@ -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)

View File

@ -10,40 +10,77 @@ import tempfile
from typing import (
Any,
List,
Tuple,
)
USE_VERBOSE = (os.environ.get("VERBOSE", None) is not None)
# Could make configurable.
USE_VERBOSE_PROGRESS = True
USE_QUIET = (os.environ.get("QUIET", None) is not None)
CHECKER_BIN = "cppcheck"
CHECKER_IGNORE_PREFIX = [
"extern",
]
CHECKER_BIN = "cppcheck"
CHECKER_EXCLUDE_SOURCE_FILES = set(os.path.join(*f.split("/")) for f in (
# These files hang (taking longer than 5min with v2.8.2 at time of writing).
# All other files process in under around 10seconds.
"source/blender/editors/space_text/text_format_pov.c",
"source/blender/editors/space_text/text_format_pov_ini.c",
))
CHECKER_ARGS = [
# not sure why this is needed, but it is.
"-I" + os.path.join(project_source_info.SOURCE_DIR, "extern", "glew", "include"),
"--suppress=*:%s/extern/glew/include/GL/glew.h:241" % project_source_info.SOURCE_DIR,
"--max-configs=1", # speeds up execution
# "--check-config", # when includes are missing
"--enable=all", # if you want sixty hundred pedantic suggestions
# Speed up execution.
# As Blender has many defines, the total number of configurations is large making execution unreasonably slow.
# This could be increased but do so with care.
"--max-configs=1",
# Enable this when includes are missing.
# "--check-config",
# Shows many pedantic issues, some are quite useful.
"--enable=all",
# Also shows useful messages, even if some are false-positives.
"--inconclusive",
# Quiet output, otherwise all defines/includes are printed (overly verbose).
# Only enable this for troubleshooting (if defines are not set as expected for example).
"--quiet",
*(() if USE_VERBOSE else ("--quiet",))
# NOTE: `--cppcheck-build-dir=<dir>` is added later as a temporary directory.
]
if USE_QUIET:
CHECKER_ARGS.append("--quiet")
def source_info_filter(
source_info: List[Tuple[str, List[str], List[str]]],
) -> List[Tuple[str, List[str], List[str]]]:
source_dir = project_source_info.SOURCE_DIR
if not source_dir.endswith(os.sep):
source_dir += os.sep
source_info_result = []
for i, item in enumerate(source_info):
c = item[0]
if c.startswith(source_dir):
c_relative = c[len(source_dir):]
if c_relative in CHECKER_EXCLUDE_SOURCE_FILES:
CHECKER_EXCLUDE_SOURCE_FILES.remove(c_relative)
continue
source_info_result.append(item)
if CHECKER_EXCLUDE_SOURCE_FILES:
sys.stderr.write("Error: exclude file(s) are missing: %r\n" % list(sorted(CHECKER_EXCLUDE_SOURCE_FILES)))
sys.exit(1)
return source_info_result
def cppcheck() -> None:
source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX)
source_defines = project_source_info.build_defines_as_args()
# Apply exclusion.
source_info = source_info_filter(source_info)
check_commands = []
for c, inc_dirs, defs in source_info:
cmd = (
@ -60,7 +97,7 @@ def cppcheck() -> None:
process_functions = []
def my_process(i: int, c: str, cmd: List[str]) -> subprocess.Popen[Any]:
if not USE_QUIET:
if USE_VERBOSE_PROGRESS:
percent = 100.0 * (i / len(check_commands))
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"

View File

@ -87,7 +87,5 @@ if(NOT APPLE)
set(WITH_CYCLES_CUBIN_COMPILER OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_HIP_BINARIES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_ONEAPI ON CACHE BOOL "" FORCE)
# Disable AoT kernels compilations until buildbot can deliver them in a reasonable time.
set(WITH_CYCLES_ONEAPI_BINARIES OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_ONEAPI_BINARIES ON CACHE BOOL "" FORCE)
endif()

View File

@ -0,0 +1,33 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2022 Blender Foundation. All rights reserved.
# This file is used to test the system for headers & symbols.
# Variables should use the `HAVE_` prefix.
# Defines should use the same name as the CMAKE variable.
include(CheckSymbolExists)
# Used for: `intern/guardedalloc/intern/mallocn_intern.h`.
# Function `malloc_stats` is only available on GLIBC,
# so check that before defining `HAVE_MALLOC_STATS`.
check_symbol_exists(malloc_stats "malloc.h" HAVE_MALLOC_STATS_H)
# Used for: `source/creator/creator_signals.c`.
# The function `feenableexcept` is not present non-GLIBC systems,
# hence we need to check if it's available in the `fenv.h` file.
set(HAVE_FEENABLEEXCEPT OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
check_symbol_exists(feenableexcept "fenv.h" HAVE_FEENABLEEXCEPT)
endif()
# Used for: `source/blender/blenlib/intern/system.c`.
# `execinfo` is not available on non-GLIBC systems (at least not on MUSL-LIBC),
# so check the presence of the header before including it and using the it for back-trace.
set(HAVE_EXECINFO_H OFF)
if(NOT MSVC)
include(CheckIncludeFiles)
check_include_files("execinfo.h" HAVE_EXECINFO_H)
if(HAVE_EXECINFO_H)
add_definitions(-DHAVE_EXECINFO_H)
endif()
endif()

View File

@ -21,6 +21,18 @@ function(print_found_status
endif()
endfunction()
# Utility to install precompiled shared libraries.
macro(add_bundled_libraries library)
if(EXISTS ${LIBDIR})
set(_library_dir ${LIBDIR}/${library}/lib)
file(GLOB _all_library_versions ${_library_dir}/*\.dylib*)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_all_library_versions})
list(APPEND PLATFORM_BUNDLED_LIBRARY_DIRS ${_library_dir})
unset(_all_library_versions)
unset(_library_dir)
endif()
endmacro()
# ------------------------------------------------------------------------
# Find system provided libraries.
@ -226,6 +238,9 @@ if(WITH_SDL)
endif()
endif()
set(EPOXY_ROOT_DIR ${LIBDIR}/epoxy)
find_package(Epoxy REQUIRED)
set(PNG_ROOT ${LIBDIR}/png)
find_package(PNG REQUIRED)
@ -412,6 +427,7 @@ if(WITH_OPENMP)
set(OpenMP_LIBRARY_DIR "${LIBDIR}/openmp/lib/")
set(OpenMP_LINKER_FLAGS "-L'${OpenMP_LIBRARY_DIR}' -lomp")
set(OpenMP_LIBRARY "${OpenMP_LIBRARY_DIR}/libomp.dylib")
add_bundled_libraries(openmp)
endif()
endif()
@ -501,17 +517,27 @@ if(WITH_COMPILER_CCACHE)
endif()
endif()
# For binaries that are built but not installed (also not distributed) (datatoc,
# makesdna, tests, etc.), we add an rpath to the OpenMP library dir through
# CMAKE_BUILD_RPATH. This avoids having to make many copies of the dylib next to each binary.
#
# For the installed Python module and installed Blender executable, CMAKE_INSTALL_RPATH
# is modified to find the dylib in an adjacent folder. Install step puts the libraries there.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH "${OpenMP_LIBRARY_DIR}")
if(WITH_COMPILER_ASAN)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${COMPILER_ASAN_LIBRARY})
endif()
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/${BLENDER_VERSION}/lib")
if(PLATFORM_BUNDLED_LIBRARIES)
# For the installed Python module and installed Blender executable, we set the
# rpath to the location where install step will copy the shared libraries.
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
if(WITH_PYTHON_MODULE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/lib")
else()
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/lib")
endif()
# For binaries that are built but not installed (like makesdan or tests), we add
# the original directory of all shared libraries to the rpath. This is needed because
# these can be in different folders, and because the build and install folder may be
# different.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH ${PLATFORM_BUNDLED_LIBRARY_DIRS})
endif()
# Same as `CFBundleIdentifier` in Info.plist.
set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.blenderfoundation.blender")

View File

@ -81,6 +81,15 @@ macro(find_package_wrapper)
endif()
endmacro()
# Utility to install precompiled shared libraries.
macro(add_bundled_libraries library)
if(EXISTS ${LIBDIR})
file(GLOB _all_library_versions ${LIBDIR}/${library}/lib/*\.so*)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_all_library_versions})
unset(_all_library_versions)
endif()
endmacro()
# ----------------------------------------------------------------------------
# Precompiled Libraries
#
@ -95,12 +104,13 @@ find_package_wrapper(JPEG REQUIRED)
find_package_wrapper(PNG REQUIRED)
find_package_wrapper(ZLIB REQUIRED)
find_package_wrapper(Zstd REQUIRED)
find_package_wrapper(Epoxy REQUIRED)
function(check_freetype_for_brotli)
include(CheckSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${FREETYPE_INCLUDE_DIRS})
check_symbol_exists(FT_CONFIG_OPTION_USE_BROTLI
"freetype/config/ftconfig.h" HAVE_BROTLI)
check_symbol_exists(FT_CONFIG_OPTION_USE_BROTLI "freetype/config/ftconfig.h" HAVE_BROTLI)
unset(CMAKE_REQUIRED_INCLUDES)
if(NOT HAVE_BROTLI)
unset(HAVE_BROTLI CACHE)
message(FATAL_ERROR "Freetype needs to be compiled with brotli support!")
@ -956,6 +966,7 @@ function(CONFIGURE_ATOMIC_LIB_IF_NEEDED)
set(CMAKE_REQUIRED_LIBRARIES atomic)
check_cxx_source_compiles("${_source}" ATOMIC_OPS_WITH_LIBATOMIC)
unset(CMAKE_REQUIRED_LIBRARIES)
if(ATOMIC_OPS_WITH_LIBATOMIC)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -latomic" PARENT_SCOPE)
@ -969,3 +980,16 @@ function(CONFIGURE_ATOMIC_LIB_IF_NEEDED)
endfunction()
CONFIGURE_ATOMIC_LIB_IF_NEEDED()
if(PLATFORM_BUNDLED_LIBRARIES)
# For the installed Python module and installed Blender executable, we set the
# rpath to the relative path where the install step will copy the shared libraries.
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
list(APPEND CMAKE_INSTALL_RPATH $ORIGIN/lib)
# For executables that are built but not installed (mainly tests) we set an absolute
# rpath to the lib folder. This is needed because these can be in different folders,
# and because the build and install folder may be different.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH $ORIGIN/lib ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/lib)
endif()

View File

@ -323,6 +323,13 @@ if(NOT JPEG_FOUND)
set(JPEG_LIBRARIES ${LIBDIR}/jpeg/lib/libjpeg.lib)
endif()
set(EPOXY_ROOT_DIR ${LIBDIR}/epoxy)
windows_find_package(Epoxy REQUIRED)
if(NOT EPOXY_FOUND)
set(Epoxy_INCLUDE_DIRS ${LIBDIR}/epoxy/include)
set(Epoxy_LIBRARIES ${LIBDIR}/epoxy/lib/epoxy.lib)
endif()
set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC3.lib)

View File

@ -3,8 +3,8 @@ Extending the Button Context Menu
+++++++++++++++++++++++++++++++++
This example enables you to insert your own menu entry into the common
right click menu that you get while hovering over a value field,
color, string, etc.
right click menu that you get while hovering over a UI button (e.g. operator,
value field, color, string, etc.)
To make the example work, you have to first select an object
then right click on an user interface element (maybe a color in the
@ -14,7 +14,6 @@ Executing the operator will then print all values.
"""
import bpy
from bpy.types import Menu
def dump(obj, text):
@ -47,36 +46,20 @@ class WM_OT_button_context_test(bpy.types.Operator):
return {'FINISHED'}
# This class has to be exactly named like that to insert an entry in the right click menu
class WM_MT_button_context(Menu):
bl_label = "Unused"
def draw(self, context):
pass
def menu_func(self, context):
def draw_menu(self, context):
layout = self.layout
layout.separator()
layout.operator(WM_OT_button_context_test.bl_idname)
classes = (
WM_OT_button_context_test,
WM_MT_button_context,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.WM_MT_button_context.append(menu_func)
bpy.utils.register_class(WM_OT_button_context_test)
bpy.types.UI_MT_button_context_menu.append(draw_menu)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
bpy.types.WM_MT_button_context.remove(menu_func)
bpy.types.UI_MT_button_context_menu.remove(draw_menu)
bpy.utils.unregister_class(WM_OT_button_context_test)
if __name__ == "__main__":

View File

@ -32,14 +32,6 @@ if(WITH_BINRELOC)
add_subdirectory(binreloc)
endif()
if(NOT WITH_SYSTEM_GLEW)
if(WITH_GLEW_ES)
add_subdirectory(glew-es)
else()
add_subdirectory(glew)
endif()
endif()
if(WITH_LZO AND NOT WITH_SYSTEM_LZO)
add_subdirectory(lzo)
endif()

View File

@ -1,33 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2013 Blender Foundation. All rights reserved.
set(INC
include
)
set(INC_SYS
)
if(UNIX)
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
endif()
set(SRC
src/glew.c
include/GL/eglew.h
include/GL/glesew.h
include/GL/glew.h
include/GL/glxew.h
include/GL/wglew.h
)
set(LIB
)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(extern_glew_es "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -1,73 +0,0 @@
The OpenGL Extension Wrangler Library
Copyright (C) 2002-2007, Milan Ikits <milan ikits[]ieee org>
Copyright (C) 2002-2007, Marcelo E. Magallon <mmagallo[]debian org>
Copyright (C) 2002, Lev Povalahev
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the author may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Mesa 3-D graphics library
Version: 7.0
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2007 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Materials.
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.

View File

@ -1,5 +0,0 @@
Project: The OpenGL Extension Wrangler Library
URL: http://glew.sourceforge.net/
License: Check LICENSE.txt
Upstream version: 2.0.0
Local modifications: None

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

22401
extern/glew-es/src/glew.c vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,54 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2006 Blender Foundation. All rights reserved.
# avoid noisy warnings
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
add_c_flag(
"-Wno-strict-prototypes"
)
endif()
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "12.1"))
add_c_flag(
"-Wno-address"
)
endif()
# MSVC's inliner is not having a happy time with glewIsSupported
# causing this to be one of the most expensive things to build
# in blender. Optimize for size rather than speed sidesteps this
# problem, more details at
# https://developercommunity.visualstudio.com/content/problem/732941/slow-compilation-of-glewc-for-visual-studio-2019-x.html
if(MSVC)
add_c_flag("/Os")
endif()
set(INC
include
)
set(INC_SYS
)
if(UNIX)
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
endif()
set(SRC
src/glew.c
include/GL/eglew.h
include/GL/glew.h
include/GL/glxew.h
include/GL/wglew.h
)
set(LIB
)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -1,73 +0,0 @@
The OpenGL Extension Wrangler Library
Copyright (C) 2002-2007, Milan Ikits <milan ikits[]ieee org>
Copyright (C) 2002-2007, Marcelo E. Magallon <mmagallo[]debian org>
Copyright (C) 2002, Lev Povalahev
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the author may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Mesa 3-D graphics library
Version: 7.0
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2007 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Materials.
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.

View File

@ -1,5 +0,0 @@
Project: The OpenGL Extension Wrangler Library
URL: http://glew.sourceforge.net/
License: Check LICENSE.txt
Upstream version: 2.0.0
Local modifications: None

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

23952
extern/glew/src/glew.c vendored

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,6 @@ add_subdirectory(memutil)
add_subdirectory(opencolorio)
add_subdirectory(opensubdiv)
add_subdirectory(mikktspace)
add_subdirectory(glew-mx)
add_subdirectory(eigen)
add_subdirectory(sky)

View File

@ -43,9 +43,8 @@ else()
endif()
if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
add_definitions(${GL_DEFINITIONS})
list(APPEND INC_SYS ${GLEW_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
list(APPEND LIB ${CYCLES_GL_LIBRARIES} ${CYCLES_GLEW_LIBRARIES} ${SDL2_LIBRARIES})
list(APPEND INC_SYS ${Epoxy_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS})
list(APPEND LIB ${Epoxy_LIBRARIES} ${SDL2_LIBRARIES})
endif()
cycles_external_libraries_append(LIB)

View File

@ -7,8 +7,8 @@
#include "util/log.h"
#include "util/string.h"
#include <GL/glew.h>
#include <SDL.h>
#include <epoxy/gl.h>
CCL_NAMESPACE_BEGIN

View File

@ -6,7 +6,7 @@
#include "util/log.h"
#include "util/string.h"
#include <GL/glew.h>
#include <epoxy/gl.h>
CCL_NAMESPACE_BEGIN

View File

@ -11,8 +11,8 @@
#include "util/time.h"
#include "util/version.h"
#include <GL/glew.h>
#include <SDL.h>
#include <epoxy/gl.h>
CCL_NAMESPACE_BEGIN
@ -294,7 +294,6 @@ void window_main_loop(const char *title,
SDL_RaiseWindow(V.window);
V.gl_context = SDL_GL_CreateContext(V.window);
glewInit();
SDL_GL_MakeCurrent(V.window, nullptr);
window_reshape(width, height);

View File

@ -3,18 +3,18 @@
set(INC
..
../../glew-mx
../../guardedalloc
../../mikktspace
../../../source/blender/makesdna
../../../source/blender/makesrna
../../../source/blender/blenlib
../../../source/blender/gpu
${CMAKE_BINARY_DIR}/source/blender/makesrna/intern
)
set(INC_SYS
${Epoxy_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${GLEW_INCLUDE_DIR}
)
set(SRC
@ -64,6 +64,7 @@ set(LIB
cycles_subd
cycles_util
${Epoxy_LIBRARIES}
${PYTHON_LINKFLAGS}
${PYTHON_LIBRARIES}
)
@ -87,8 +88,6 @@ set(ADDON_FILES
addon/version_update.py
)
add_definitions(${GL_DEFINITIONS})
if(WITH_CYCLES_DEVICE_HIP)
add_definitions(-DWITH_HIP)
endif()

View File

@ -83,6 +83,7 @@ enum_use_layer_samples = (
enum_sampling_pattern = (
('SOBOL', "Sobol", "Use Sobol random sampling pattern", 0),
('PROGRESSIVE_MULTI_JITTER', "Progressive Multi-Jitter", "Use Progressive Multi-Jitter random sampling pattern", 1),
('SOBOL_BURLEY', "Sobol-Burley", "Use Sobol-Burley random sampling pattern", 2),
)
enum_volume_sampling = (

View File

@ -7,6 +7,8 @@
#include "util/log.h"
#include "util/opengl.h"
#include "GPU_platform.h"
extern "C" {
struct RenderEngine;
@ -507,6 +509,7 @@ class DrawTileAndPBO {
DrawTile tile;
GLPixelBufferObject buffer_object;
bool need_update_texture_pixels = false;
};
/* --------------------------------------------------------------------
@ -585,6 +588,8 @@ void BlenderDisplayDriver::next_tile_begin()
/* Moving to the next tile without giving render data for the current tile is not an expected
* situation. */
DCHECK(!need_clear_);
/* Texture should have been updated from the PBO at this point. */
DCHECK(!tiles_->current_tile.need_update_texture_pixels);
tiles_->finished_tiles.tiles.emplace_back(std::move(tiles_->current_tile.tile));
}
@ -702,8 +707,18 @@ void BlenderDisplayDriver::update_end()
* One concern with this approach is that if the update happens more often than drawing then
* doing the unpack here occupies GPU transfer for no good reason. However, the render scheduler
* takes care of ensuring updates don't happen that often. In regular applications redraw will
* happen much more often than this update. */
update_tile_texture_pixels(tiles_->current_tile);
* happen much more often than this update.
*
* On some older GPUs on macOS, there is a driver crash when updating the texture for viewport
* renders while Blender is drawing. As a workaround update texture during draw, under assumption
* that there is no graphics interop on macOS and viewport render has a single tile. */
if (use_gl_context_ &&
GPU_type_matches_ex(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_ANY)) {
tiles_->current_tile.need_update_texture_pixels = true;
}
else {
update_tile_texture_pixels(tiles_->current_tile);
}
gl_upload_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
@ -953,6 +968,11 @@ void BlenderDisplayDriver::draw(const Params &params)
glEnableVertexAttribArray(texcoord_attribute);
glEnableVertexAttribArray(position_attribute);
if (tiles_->current_tile.need_update_texture_pixels) {
update_tile_texture_pixels(tiles_->current_tile);
tiles_->current_tile.need_update_texture_pixels = false;
}
draw_tile(zoom_,
texcoord_attribute,
position_attribute,

View File

@ -66,12 +66,6 @@ bool BlenderSync::object_is_geometry(BObjectInfo &b_ob_info)
return true;
}
/* Other object types that are not meshes but evaluate to meshes are presented to render engines
* as separate instance objects. Metaballs have not been affected by that change yet. */
if (type == BL::Object::type_META) {
return true;
}
return b_ob_data.is_a(&RNA_Mesh);
}

View File

@ -248,6 +248,13 @@ static void get_tex_mapping(TextureNode *mapping, BL::TexMapping &b_mapping)
mapping->set_tex_mapping_z_mapping((TextureMapping::Mapping)b_mapping.mapping_z());
}
static bool is_image_animated(BL::Image::source_enum b_image_source, BL::ImageUser &b_image_user)
{
return (b_image_source == BL::Image::source_MOVIE ||
b_image_source == BL::Image::source_SEQUENCE) &&
b_image_user.use_auto_refresh();
}
static ShaderNode *add_node(Scene *scene,
BL::RenderEngine &b_engine,
BL::BlendData &b_data,
@ -748,10 +755,11 @@ static ShaderNode *add_node(Scene *scene,
get_tex_mapping(image, b_texture_mapping);
if (b_image) {
BL::Image::source_enum b_image_source = b_image.source();
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
image->set_colorspace(ustring(get_enum_identifier(colorspace_ptr, "name")));
image->set_animated(b_image_node.image_user().use_auto_refresh());
image->set_animated(is_image_animated(b_image_source, b_image_user));
image->set_alpha_type(get_image_alpha_type(b_image));
array<int> tiles;
@ -763,9 +771,9 @@ static ShaderNode *add_node(Scene *scene,
/* builtin images will use callback-based reading because
* they could only be loaded correct from blender side
*/
bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
(b_engine.is_preview() && b_image.source() != BL::Image::source_SEQUENCE);
bool is_builtin = b_image.packed_file() || b_image_source == BL::Image::source_GENERATED ||
b_image_source == BL::Image::source_MOVIE ||
(b_engine.is_preview() && b_image_source != BL::Image::source_SEQUENCE);
if (is_builtin) {
/* for builtin images we're using image datablock name to find an image to
@ -776,7 +784,7 @@ static ShaderNode *add_node(Scene *scene,
*/
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_image_user, b_image, scene_frame);
if (b_image.source() != BL::Image::source_TILED) {
if (b_image_source != BL::Image::source_TILED) {
image->handle = scene->image_manager->add_image(
new BlenderImageLoader(b_image, image_frame, 0, b_engine.is_preview()),
image->image_params());
@ -812,15 +820,15 @@ static ShaderNode *add_node(Scene *scene,
get_tex_mapping(env, b_texture_mapping);
if (b_image) {
BL::Image::source_enum b_image_source = b_image.source();
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
env->set_colorspace(ustring(get_enum_identifier(colorspace_ptr, "name")));
env->set_animated(b_env_node.image_user().use_auto_refresh());
env->set_animated(is_image_animated(b_image_source, b_image_user));
env->set_alpha_type(get_image_alpha_type(b_image));
bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
(b_engine.is_preview() && b_image.source() != BL::Image::source_SEQUENCE);
bool is_builtin = b_image.packed_file() || b_image_source == BL::Image::source_GENERATED ||
b_image_source == BL::Image::source_MOVIE ||
(b_engine.is_preview() && b_image_source != BL::Image::source_SEQUENCE);
if (is_builtin) {
int scene_frame = b_scene.frame_current();

View File

@ -39,10 +39,10 @@ enum BVHType {
BVH_NUM_TYPES,
};
/* Names bitflag type to denote which BVH layouts are supported by
/* Names bit-flag type to denote which BVH layouts are supported by
* particular area.
*
* Bitflags are the BVH_LAYOUT_* values.
* Bit-flags are the BVH_LAYOUT_* values.
*/
typedef int BVHLayoutMask;

View File

@ -505,26 +505,19 @@ if(CYCLES_STANDALONE_REPOSITORY)
endif()
###########################################################################
# GLEW
# Epoxy
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY)
if((WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI) OR
WITH_CYCLES_HYDRA_RENDER_DELEGATE)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(GLEW_LIBRARY "${_cycles_lib_dir}/opengl/lib/glew.lib")
set(GLEW_INCLUDE_DIR "${_cycles_lib_dir}/opengl/include")
add_definitions(-DGLEW_STATIC)
set(Epoxy_LIBRARIES "${_cycles_lib_dir}/epoxy/lib/epoxy.lib")
set(Epoxy_INCLUDE_DIRS "${_cycles_lib_dir}/epoxy/include")
else()
find_package(GLEW REQUIRED)
find_package(Epoxy REQUIRED)
endif()
set(CYCLES_GLEW_LIBRARIES ${GLEW_LIBRARY})
endif()
else()
# Workaround for unconventional variable name use in Blender.
set(GLEW_INCLUDE_DIR "${GLEW_INCLUDE_PATH}")
set(CYCLES_GLEW_LIBRARIES bf_intern_glew_mx ${BLENDER_GLEW_LIBRARIES})
endif()
###########################################################################
@ -556,25 +549,6 @@ if(EXISTS ${_cycles_lib_dir})
unset(_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
###########################################################################
@ -654,15 +628,29 @@ endif()
# oneAPI
###########################################################################
if (WITH_CYCLES_DEVICE_ONEAPI)
if(WITH_CYCLES_DEVICE_ONEAPI)
find_package(SYCL)
find_package(LevelZero)
if (SYCL_FOUND AND LEVEL_ZERO_FOUND)
if(SYCL_FOUND AND LEVEL_ZERO_FOUND)
message(STATUS "Found oneAPI: ${SYCL_LIBRARY}")
message(STATUS "Found Level Zero: ${LEVEL_ZERO_LIBRARY}")
if(WITH_CYCLES_ONEAPI_BINARIES)
if(NOT OCLOC_INSTALL_DIR)
get_filename_component(_sycl_compiler_root ${SYCL_COMPILER} DIRECTORY)
get_filename_component(OCLOC_INSTALL_DIR "${_sycl_compiler_root}/../lib/ocloc" ABSOLUTE)
unset(_sycl_compiler_root)
endif()
if(NOT EXISTS ${OCLOC_INSTALL_DIR})
message(STATUS "oneAPI ocloc not found in ${OCLOC_INSTALL_DIR}, disabling WITH_CYCLES_ONEAPI_BINARIES."
" A different ocloc directory can be set using OCLOC_INSTALL_DIR cmake variable.")
set(WITH_CYCLES_ONEAPI_BINARIES OFF)
endif()
endif()
else()
message(STATUS "oneAPI or Level Zero not found, disabling oneAPI device from Cycles")
message(STATUS "oneAPI or Level Zero not found, disabling WITH_CYCLES_DEVICE_ONEAPI")
set(WITH_CYCLES_DEVICE_ONEAPI OFF)
endif()
endif()

View File

@ -3,12 +3,9 @@
set(INC
..
../../glew-mx
)
set(INC_SYS
${GLEW_INCLUDE_DIR}
)
set(INC_SYS )
if(WITH_CYCLES_DEVICE_OPTIX OR WITH_CYCLES_DEVICE_CUDA)
if(WITH_CUDA_DYNLOAD)
@ -150,7 +147,6 @@ set(SRC
set(LIB
cycles_kernel
cycles_util
${CYCLES_GL_LIBRARIES}
)
if(WITH_CYCLES_DEVICE_OPTIX OR WITH_CYCLES_DEVICE_CUDA)
@ -171,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()

View File

@ -16,7 +16,6 @@
# include "util/log.h"
# include "util/map.h"
# include "util/md5.h"
# include "util/opengl.h"
# include "util/path.h"
# include "util/string.h"
# include "util/system.h"

View File

@ -171,7 +171,7 @@ struct NodeType {
#define SOCKET_DEFINE(name, ui_name, default_value, datatype, TYPE, flags, ...) \
{ \
static datatype defval = default_value; \
CHECK_TYPE(T::name, datatype); \
static_assert(std::is_same_v<decltype(T::name), datatype>); \
type->register_input(ustring(#name), \
ustring(ui_name), \
TYPE, \

View File

@ -10,14 +10,14 @@ set(INC
)
set(INC_SYS
${USD_INCLUDE_DIRS}
${GLEW_INCLUDE_DIR}
${Epoxy_INCLUDE_DIRS}
)
set(LIB
cycles_scene
cycles_session
cycles_graph
${CYCLES_GLEW_LIBRARIES}
${Epoxy_LIBRARIES}
)
cycles_external_libraries_append(LIB)
@ -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

View File

@ -11,7 +11,7 @@
#include "hydra/render_buffer.h"
#include "hydra/session.h"
#include <GL/glew.h>
#include <epoxy/gl.h>
#include <pxr/imaging/hgiGL/texture.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE

View File

@ -204,22 +204,26 @@ void PathTraceWorkGPU::alloc_integrator_sorting()
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE] =
(int *)integrator_shader_sort_counter_.device_pointer;
if (device_scene_->data.kernel_features & KERNEL_FEATURE_NODE_RAYTRACE) {
integrator_shader_sort_prefix_sum_.alloc(sort_buckets);
integrator_shader_sort_prefix_sum_.zero_to_device();
}
if (device_scene_->data.kernel_features & KERNEL_FEATURE_NODE_RAYTRACE) {
if (integrator_shader_raytrace_sort_counter_.size() < sort_buckets) {
integrator_shader_raytrace_sort_counter_.alloc(sort_buckets);
integrator_shader_raytrace_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE] =
(int *)integrator_shader_raytrace_sort_counter_.device_pointer;
}
}
if (device_scene_->data.kernel_features & KERNEL_FEATURE_MNEE) {
if (device_scene_->data.kernel_features & KERNEL_FEATURE_MNEE) {
if (integrator_shader_mnee_sort_counter_.size() < sort_buckets) {
integrator_shader_mnee_sort_counter_.alloc(sort_buckets);
integrator_shader_mnee_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE] =
(int *)integrator_shader_mnee_sort_counter_.device_pointer;
}
integrator_shader_sort_prefix_sum_.alloc(sort_buckets);
integrator_shader_sort_prefix_sum_.zero_to_device();
}
}

View File

@ -274,6 +274,8 @@ set(SRC_KERNEL_SAMPLE_HEADERS
sample/mapping.h
sample/mis.h
sample/pattern.h
sample/sobol_burley.h
sample/util.h
)
set(SRC_KERNEL_UTIL_HEADERS
@ -784,14 +786,6 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
get_filename_component(sycl_compiler_root ${SYCL_COMPILER} DIRECTORY)
get_filename_component(sycl_compiler_compiler_name ${SYCL_COMPILER} NAME_WE)
if(NOT OCLOC_INSTALL_DIR)
get_filename_component(OCLOC_INSTALL_DIR "${sycl_compiler_root}/../lib/ocloc" ABSOLUTE)
endif()
if(WITH_CYCLES_ONEAPI_BINARIES AND NOT EXISTS ${OCLOC_INSTALL_DIR})
message(FATAL_ERROR "WITH_CYCLES_ONEAPI_BINARIES requires ocloc but ${OCLOC_INSTALL_DIR} directory doesn't exist."
" A different ocloc directory can be set using OCLOC_INSTALL_DIR cmake variable.")
endif()
if(UNIX AND NOT APPLE)
if(NOT WITH_CXX11_ABI)
check_library_exists(sycl

View File

@ -29,11 +29,12 @@ using namespace metal::raytracing;
/* Qualifiers */
#if defined(__KERNEL_METAL_APPLE__)
/* Inline everything for Apple GPUs. This gives ~1.1x speedup and 10% spill
* reduction for integator_shade_surface. However it comes at the cost of
* longer compile times (~4.5 minutes on M1 Max) and is disabled for that
* reason, until there is a user option to manually enable it. */
/* Inline everything for Apple GPUs.
* This gives ~1.1x speedup and 10% spill reduction for integator_shade_surface
* at the cost of longer compile times (~4.5 minutes on M1 Max). */
#if 0 // defined(__KERNEL_METAL_APPLE__)
# define ccl_device __attribute__((always_inline))
# define ccl_device_inline __attribute__((always_inline))

View File

@ -818,7 +818,8 @@ char *oneapi_device_capabilities()
GET_NUM_ATTR(max_compute_units)
GET_NUM_ATTR(max_work_item_dimensions)
sycl::id<3> max_work_item_sizes = device.get_info<sycl::info::device::max_work_item_sizes>();
sycl::id<3> max_work_item_sizes =
device.get_info<sycl::info::device::max_work_item_sizes<3>>();
WRITE_ATTR("max_work_item_sizes_dim0", ((size_t)max_work_item_sizes.get(0)))
WRITE_ATTR("max_work_item_sizes_dim1", ((size_t)max_work_item_sizes.get(1)))
WRITE_ATTR("max_work_item_sizes_dim2", ((size_t)max_work_item_sizes.get(2)))

View File

@ -321,8 +321,10 @@ ccl_device_inline float path_state_rng_1D_hash(KernelGlobals kg,
/* Use a hash instead of dimension, this is not great but avoids adding
* more dimensions to each bounce which reduces quality of dimensions we
* are already using. */
return path_rng_1D(
kg, cmj_hash_simple(rng_state->rng_hash, hash), rng_state->sample, rng_state->rng_offset);
return path_rng_1D(kg,
hash_wang_seeded_uint(rng_state->rng_hash, hash),
rng_state->sample,
rng_state->rng_offset);
}
ccl_device_inline float path_branched_rng_1D(KernelGlobals kg,

View File

@ -229,7 +229,7 @@ ccl_device_inline bool subsurface_random_walk(KernelGlobals kg,
const float phase_log = logf((diffusion_length + 1.0f) / (diffusion_length - 1.0f));
/* Modify state for RNGs, decorrelated from other paths. */
rng_state.rng_hash = cmj_hash(rng_state.rng_hash + rng_state.rng_offset, 0xdeadbeef);
rng_state.rng_hash = hash_cmj_seeded_uint(rng_state.rng_hash + rng_state.rng_offset, 0xdeadbeef);
/* Random walk until we hit the surface again. */
bool hit = false;

View File

@ -1,20 +1,12 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#include "kernel/sample/util.h"
#include "util/hash.h"
#pragma once
CCL_NAMESPACE_BEGIN
ccl_device_inline uint32_t laine_karras_permutation(uint32_t x, uint32_t seed)
{
x += seed;
x ^= (x * 0x6c50b47cu);
x ^= x * 0xb82f1e52u;
x ^= x * 0xc7afe638u;
x ^= x * 0x8d22f6e6u;
return x;
}
ccl_device_inline uint32_t nested_uniform_scramble(uint32_t x, uint32_t seed)
{
x = reverse_integer_bits(x);
@ -24,46 +16,6 @@ ccl_device_inline uint32_t nested_uniform_scramble(uint32_t x, uint32_t seed)
return x;
}
ccl_device_inline uint cmj_hash(uint i, uint p)
{
i ^= p;
i ^= i >> 17;
i ^= i >> 10;
i *= 0xb36534e5;
i ^= i >> 12;
i ^= i >> 21;
i *= 0x93fc4795;
i ^= 0xdf6e307f;
i ^= i >> 17;
i *= 1 | p >> 18;
return i;
}
ccl_device_inline uint cmj_hash_simple(uint i, uint p)
{
i = (i ^ 61) ^ p;
i += i << 3;
i ^= i >> 4;
i *= 0x27d4eb2d;
return i;
}
ccl_device_inline float cmj_randfloat(uint i, uint p)
{
return cmj_hash(i, p) * (1.0f / 4294967808.0f);
}
ccl_device_inline float cmj_randfloat_simple(uint i, uint p)
{
return cmj_hash_simple(i, p) * (1.0f / (float)0xFFFFFFFF);
}
ccl_device_inline float cmj_randfloat_simple_dist(uint i, uint p, float d)
{
return cmj_hash_simple(i, p) * (d / (float)0xFFFFFFFF);
}
ccl_device float pmj_sample_1D(KernelGlobals kg, uint sample, uint rng_hash, uint dimension)
{
uint hash = rng_hash;
@ -71,16 +23,12 @@ ccl_device float pmj_sample_1D(KernelGlobals kg, uint sample, uint rng_hash, uin
if (kernel_data.integrator.scrambling_distance < 1.0f) {
hash = kernel_data.integrator.seed;
jitter_x = cmj_randfloat_simple_dist(
dimension, rng_hash, kernel_data.integrator.scrambling_distance);
jitter_x = hash_wang_seeded_float(dimension, rng_hash) *
kernel_data.integrator.scrambling_distance;
}
/* Perform Owen shuffle of the sample number to reorder the samples. */
#ifdef _SIMPLE_HASH_
const uint rv = cmj_hash_simple(dimension, hash);
#else /* Use a _REGULAR_HASH_. */
const uint rv = cmj_hash(dimension, hash);
#endif
const uint rv = hash_cmj_seeded_uint(dimension, hash);
#ifdef _XOR_SHUFFLE_
# warning "Using XOR shuffle."
const uint s = sample ^ rv;
@ -101,11 +49,7 @@ ccl_device float pmj_sample_1D(KernelGlobals kg, uint sample, uint rng_hash, uin
#ifndef _NO_CRANLEY_PATTERSON_ROTATION_
/* Use Cranley-Patterson rotation to displace the sample pattern. */
# ifdef _SIMPLE_HASH_
float dx = cmj_randfloat_simple(d, hash);
# else
float dx = cmj_randfloat(d, hash);
# endif
float dx = hash_cmj_seeded_float(d, hash);
/* Jitter sample locations and map back into [0 1]. */
fx = fx + dx + jitter_x;
fx = fx - floorf(fx);
@ -129,18 +73,14 @@ ccl_device void pmj_sample_2D(KernelGlobals kg,
if (kernel_data.integrator.scrambling_distance < 1.0f) {
hash = kernel_data.integrator.seed;
jitter_x = cmj_randfloat_simple_dist(
dimension, rng_hash, kernel_data.integrator.scrambling_distance);
jitter_y = cmj_randfloat_simple_dist(
dimension + 1, rng_hash, kernel_data.integrator.scrambling_distance);
jitter_x = hash_wang_seeded_float(dimension, rng_hash) *
kernel_data.integrator.scrambling_distance;
jitter_y = hash_wang_seeded_float(dimension + 1, rng_hash) *
kernel_data.integrator.scrambling_distance;
}
/* Perform a shuffle on the sample number to reorder the samples. */
#ifdef _SIMPLE_HASH_
const uint rv = cmj_hash_simple(dimension, hash);
#else /* Use a _REGULAR_HASH_. */
const uint rv = cmj_hash(dimension, hash);
#endif
const uint rv = hash_cmj_seeded_uint(dimension, hash);
#ifdef _XOR_SHUFFLE_
# warning "Using XOR shuffle."
const uint s = sample ^ rv;
@ -159,13 +99,8 @@ ccl_device void pmj_sample_2D(KernelGlobals kg,
#ifndef _NO_CRANLEY_PATTERSON_ROTATION_
/* Use Cranley-Patterson rotation to displace the sample pattern. */
# ifdef _SIMPLE_HASH_
float dx = cmj_randfloat_simple(d, hash);
float dy = cmj_randfloat_simple(d + 1, hash);
# else
float dx = cmj_randfloat(d, hash);
float dy = cmj_randfloat(d + 1, hash);
# endif
float dx = hash_cmj_seeded_float(d, hash);
float dy = hash_cmj_seeded_float(d + 1, hash);
/* Jitter sample locations and map back to the unit square [0 1]x[0 1]. */
float sx = fx + dx + jitter_x;
float sy = fy + dy + jitter_y;

View File

@ -4,6 +4,7 @@
#pragma once
#include "kernel/sample/jitter.h"
#include "kernel/sample/sobol_burley.h"
#include "util/hash.h"
CCL_NAMESPACE_BEGIN
@ -48,6 +49,10 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals kg,
return (float)drand48();
#endif
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_SOBOL_BURLEY) {
return sobol_burley_sample_1D(sample, dimension, rng_hash);
}
#ifdef __SOBOL__
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_PMJ)
#endif
@ -66,7 +71,7 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals kg,
/* Hash rng with dimension to solve correlation issues.
* See T38710, T50116.
*/
uint tmp_rng = cmj_hash_simple(dimension, rng_hash);
uint tmp_rng = hash_wang_seeded_uint(dimension, rng_hash);
shift = tmp_rng * (kernel_data.integrator.scrambling_distance / (float)0xFFFFFFFF);
return r + shift - floorf(r + shift);
@ -86,6 +91,11 @@ ccl_device_forceinline void path_rng_2D(KernelGlobals kg,
return;
#endif
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_SOBOL_BURLEY) {
sobol_burley_sample_2D(sample, dimension, rng_hash, fx, fy);
return;
}
#ifdef __SOBOL__
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_PMJ)
#endif

View File

@ -0,0 +1,143 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
/*
* A shuffled, Owen-scrambled Sobol sampler, implemented with the
* techniques from the paper "Practical Hash-based Owen Scrambling"
* by Brent Burley, 2020, Journal of Computer Graphics Techniques.
*
* Note that unlike a standard high-dimensional Sobol sequence, this
* Sobol sampler uses padding to achieve higher dimensions, as described
* in Burley's paper.
*/
#pragma once
#include "kernel/sample/util.h"
#include "util/hash.h"
#include "util/math.h"
#include "util/types.h"
CCL_NAMESPACE_BEGIN
/*
* Computes a single dimension of a sample from an Owen-scrambled
* Sobol sequence. This is used in the main sampling functions,
* sobol_burley_sample_#D(), below.
*
* - rev_bit_index: the sample index, with reversed order bits.
* - dimension: the sample dimension.
* - scramble_seed: the Owen scrambling seed.
*
* Note that the seed must be well randomized before being
* passed to this function.
*/
ccl_device_forceinline float sobol_burley(uint rev_bit_index, uint dimension, uint scramble_seed)
{
uint result = 0;
if (dimension == 0) {
// Fast-path for dimension 0, which is just Van der corput.
// This makes a notable difference in performance since we reuse
// dimensions for padding, and dimension 0 is reused the most.
result = reverse_integer_bits(rev_bit_index);
}
else {
uint i = 0;
while (rev_bit_index != 0) {
uint j = count_leading_zeros(rev_bit_index);
result ^= sobol_burley_table[dimension][i + j];
i += j + 1;
// We can't do "<<= j + 1" because that can overflow the shift
// operator, which doesn't do what we need on at least x86.
rev_bit_index <<= j;
rev_bit_index <<= 1;
}
}
// Apply Owen scrambling.
result = reverse_integer_bits(reversed_bit_owen(result, scramble_seed));
return uint_to_float_excl(result);
}
/*
* Computes a 1D Owen-scrambled and shuffled Sobol sample.
*/
ccl_device float sobol_burley_sample_1D(uint index, uint dimension, uint seed)
{
// Include the dimension in the seed, so we get decorrelated
// sequences for different dimensions via shuffling.
seed ^= hash_hp_uint(dimension);
// Shuffle.
index = reversed_bit_owen(reverse_integer_bits(index), seed ^ 0xbff95bfe);
return sobol_burley(index, 0, seed ^ 0x635c77bd);
}
/*
* Computes a 2D Owen-scrambled and shuffled Sobol sample.
*/
ccl_device void sobol_burley_sample_2D(
uint index, uint dimension_set, uint seed, ccl_private float *x, ccl_private float *y)
{
// Include the dimension set in the seed, so we get decorrelated
// sequences for different dimension sets via shuffling.
seed ^= hash_hp_uint(dimension_set);
// Shuffle.
index = reversed_bit_owen(reverse_integer_bits(index), seed ^ 0xf8ade99a);
*x = sobol_burley(index, 0, seed ^ 0xe0aaaf76);
*y = sobol_burley(index, 1, seed ^ 0x94964d4e);
}
/*
* Computes a 3D Owen-scrambled and shuffled Sobol sample.
*/
ccl_device void sobol_burley_sample_3D(uint index,
uint dimension_set,
uint seed,
ccl_private float *x,
ccl_private float *y,
ccl_private float *z)
{
// Include the dimension set in the seed, so we get decorrelated
// sequences for different dimension sets via shuffling.
seed ^= hash_hp_uint(dimension_set);
// Shuffle.
index = reversed_bit_owen(reverse_integer_bits(index), seed ^ 0xcaa726ac);
*x = sobol_burley(index, 0, seed ^ 0x9e78e391);
*y = sobol_burley(index, 1, seed ^ 0x67c33241);
*z = sobol_burley(index, 2, seed ^ 0x78c395c5);
}
/*
* Computes a 4D Owen-scrambled and shuffled Sobol sample.
*/
ccl_device void sobol_burley_sample_4D(uint index,
uint dimension_set,
uint seed,
ccl_private float *x,
ccl_private float *y,
ccl_private float *z,
ccl_private float *w)
{
// Include the dimension set in the seed, so we get decorrelated
// sequences for different dimension sets via shuffling.
seed ^= hash_hp_uint(dimension_set);
// Shuffle.
index = reversed_bit_owen(reverse_integer_bits(index), seed ^ 0xc2c1a055);
*x = sobol_burley(index, 0, seed ^ 0x39468210);
*y = sobol_burley(index, 1, seed ^ 0xe9d8a845);
*z = sobol_burley(index, 2, seed ^ 0x5f32b482);
*w = sobol_burley(index, 3, seed ^ 0x1524cc56);
}
CCL_NAMESPACE_END

View File

@ -0,0 +1,45 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#pragma once
#include "util/types.h"
CCL_NAMESPACE_BEGIN
/*
* Performs base-2 Owen scrambling on a reversed-bit integer.
*
* This is equivalent to the Laine-Karras permutation, but much higher
* quality. See https://psychopath.io/post/2021_01_30_building_a_better_lk_hash
*/
ccl_device_inline uint reversed_bit_owen(uint n, uint seed)
{
n ^= n * 0x3d20adea;
n += seed;
n *= (seed >> 16) | 1;
n ^= n * 0x05526c56;
n ^= n * 0x53a22864;
return n;
}
/*
* Performs base-2 Owen scrambling on a reversed-bit integer.
*
* This is here for backwards-compatibility, and can be replaced
* with reversed_bit_owen() above at some point.
* See https://developer.blender.org/D15679#426304
*/
ccl_device_inline uint laine_karras_permutation(uint x, uint seed)
{
x += seed;
x ^= (x * 0x6c50b47cu);
x ^= x * 0xb82f1e52u;
x ^= x * 0xc7afe638u;
x ^= x * 0x8d22f6e6u;
return x;
}
CCL_NAMESPACE_END

View File

@ -63,4 +63,57 @@ ccl_inline_constant float cie_colour_match[][3] = {
{0.0001f, 0.0000f, 0.0000f}, {0.0001f, 0.0000f, 0.0000f}, {0.0000f, 0.0000f, 0.0000f}
};
/*
* The direction vectors for the first four dimensions of the Sobol
* sequence, stored with reversed-order bits.
*
* This is used in the Sobol-Burley sampler implementation. We don't
* need more than four dimensions because we achieve higher dimensions
* with padding. They're stored with reversed bits because we need
* them reversed for the fast hash-based Owen scrambling anyway, and
* this avoids doing that at run time.
*/
ccl_inline_constant unsigned int sobol_burley_table[4][32] = {
{
0x00000001, 0x00000002, 0x00000004, 0x00000008,
0x00000010, 0x00000020, 0x00000040, 0x00000080,
0x00000100, 0x00000200, 0x00000400, 0x00000800,
0x00001000, 0x00002000, 0x00004000, 0x00008000,
0x00010000, 0x00020000, 0x00040000, 0x00080000,
0x00100000, 0x00200000, 0x00400000, 0x00800000,
0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000, 0x80000000,
},
{
0x00000001, 0x00000003, 0x00000005, 0x0000000f,
0x00000011, 0x00000033, 0x00000055, 0x000000ff,
0x00000101, 0x00000303, 0x00000505, 0x00000f0f,
0x00001111, 0x00003333, 0x00005555, 0x0000ffff,
0x00010001, 0x00030003, 0x00050005, 0x000f000f,
0x00110011, 0x00330033, 0x00550055, 0x00ff00ff,
0x01010101, 0x03030303, 0x05050505, 0x0f0f0f0f,
0x11111111, 0x33333333, 0x55555555, 0xffffffff,
},
{
0x00000001, 0x00000003, 0x00000006, 0x00000009,
0x00000017, 0x0000003a, 0x00000071, 0x000000a3,
0x00000116, 0x00000339, 0x00000677, 0x000009aa,
0x00001601, 0x00003903, 0x00007706, 0x0000aa09,
0x00010117, 0x0003033a, 0x00060671, 0x000909a3,
0x00171616, 0x003a3939, 0x00717777, 0x00a3aaaa,
0x01170001, 0x033a0003, 0x06710006, 0x09a30009,
0x16160017, 0x3939003a, 0x77770071, 0xaaaa00a3,
},
{
0x00000001, 0x00000003, 0x00000004, 0x0000000a,
0x0000001f, 0x0000002e, 0x00000045, 0x000000c9,
0x0000011b, 0x000002a4, 0x0000079a, 0x00000b67,
0x0000101e, 0x0000302d, 0x00004041, 0x0000a0c3,
0x0001f104, 0x0002e28a, 0x000457df, 0x000c9bae,
0x0011a105, 0x002a7289, 0x0079e7db, 0x00b6dba4,
0x0100011a, 0x030002a7, 0x0400079e, 0x0a000b6d,
0x1f001001, 0x2e003003, 0x45004004, 0xc900a00a,
},
};
/* clang-format on */

View File

@ -178,6 +178,7 @@ enum PathTraceDimension {
enum SamplingPattern {
SAMPLING_PATTERN_SOBOL = 0,
SAMPLING_PATTERN_PMJ = 1,
SAMPLING_PATTERN_SOBOL_BURLEY = 2,
SAMPLING_NUM_PATTERNS,
};

View File

@ -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})

View File

@ -89,6 +89,7 @@ NODE_DEFINE(Integrator)
static NodeEnum sampling_pattern_enum;
sampling_pattern_enum.insert("sobol", SAMPLING_PATTERN_SOBOL);
sampling_pattern_enum.insert("pmj", SAMPLING_PATTERN_PMJ);
sampling_pattern_enum.insert("sobol_burley", SAMPLING_PATTERN_SOBOL_BURLEY);
SOCKET_ENUM(sampling_pattern, "Sampling Pattern", sampling_pattern_enum, SAMPLING_PATTERN_SOBOL);
SOCKET_FLOAT(scrambling_distance, "Scrambling Distance", 1.0f);
@ -260,7 +261,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
dscene->sample_pattern_lut.copy_to_device();
}
else {
else if (kintegrator->sampling_pattern == SAMPLING_PATTERN_PMJ) {
constexpr int sequence_size = NUM_PMJ_SAMPLES;
constexpr int num_sequences = NUM_PMJ_PATTERNS;
float2 *directions = (float2 *)dscene->sample_pattern_lut.alloc(sequence_size *

View File

@ -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})

View File

@ -3,7 +3,6 @@
set(INC
..
../../glew-mx
)
set(INC_SYS
@ -149,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})

View File

@ -89,46 +89,6 @@
# define UNLIKELY(x) (x)
#endif
#if defined(__GNUC__) || defined(__clang__)
# if defined(__cplusplus)
/* Some magic to be sure we don't have reference in the type. */
template<typename T> static inline T decltype_helper(T x)
{
return x;
}
# define TYPEOF(x) decltype(decltype_helper(x))
# else
# define TYPEOF(x) typeof(x)
# endif
#endif
/* Causes warning:
* incompatible types when assigning to type 'Foo' from type 'Bar'
* ... the compiler optimizes away the temp var */
#ifdef __GNUC__
# define CHECK_TYPE(var, type) \
{ \
TYPEOF(var) * __tmp; \
__tmp = (type *)NULL; \
(void)__tmp; \
} \
(void)0
# define CHECK_TYPE_PAIR(var_a, var_b) \
{ \
TYPEOF(var_a) * __tmp; \
__tmp = (typeof(var_b) *)NULL; \
(void)__tmp; \
} \
(void)0
#else
# define CHECK_TYPE(var, type)
# define CHECK_TYPE_PAIR(var_a, var_b)
#endif
/* can be used in simple macros */
#define CHECK_TYPE_INLINE(val, type) ((void)(((type)0) != (val)))
#ifndef __KERNEL_GPU__
# include <cassert>
# define util_assert(statement) assert(statement)

View File

@ -8,6 +8,23 @@
CCL_NAMESPACE_BEGIN
/* [0, uint_max] -> [0.0, 1.0) */
ccl_device_forceinline float uint_to_float_excl(uint n)
{
// Note: we divide by 4294967808 instead of 2^32 because the latter
// leads to a [0.0, 1.0] mapping instead of [0.0, 1.0) due to floating
// point rounding error. 4294967808 unfortunately leaves (precisely)
// one unused ulp between the max number this outputs and 1.0, but
// that's the best you can do with this construction.
return (float)n * (1.0f / 4294967808.0f);
}
/* [0, uint_max] -> [0.0, 1.0] */
ccl_device_forceinline float uint_to_float_incl(uint n)
{
return (float)n * (1.0f / (float)0xFFFFFFFFu);
}
/* ***** Jenkins Lookup3 Hash Functions ***** */
/* Source: http://burtleburtle.net/bob/c/lookup3.c */
@ -116,22 +133,22 @@ ccl_device_inline uint hash_uint4(uint kx, uint ky, uint kz, uint kw)
ccl_device_inline float hash_uint_to_float(uint kx)
{
return (float)hash_uint(kx) / (float)0xFFFFFFFFu;
return uint_to_float_incl(hash_uint(kx));
}
ccl_device_inline float hash_uint2_to_float(uint kx, uint ky)
{
return (float)hash_uint2(kx, ky) / (float)0xFFFFFFFFu;
return uint_to_float_incl(hash_uint2(kx, ky));
}
ccl_device_inline float hash_uint3_to_float(uint kx, uint ky, uint kz)
{
return (float)hash_uint3(kx, ky, kz) / (float)0xFFFFFFFFu;
return uint_to_float_incl(hash_uint3(kx, ky, kz));
}
ccl_device_inline float hash_uint4_to_float(uint kx, uint ky, uint kz, uint kw)
{
return (float)hash_uint4(kx, ky, kz, kw) / (float)0xFFFFFFFFu;
return uint_to_float_incl(hash_uint4(kx, ky, kz, kw));
}
/* Hashing float or float[234] into a float in the range [0, 1]. */
@ -359,6 +376,101 @@ ccl_device_inline avxi hash_avxi4(avxi kx, avxi ky, avxi kz, avxi kw)
#endif
/* ***** Hash Prospector Hash Functions *****
*
* These are based on the high-quality 32-bit hash/mixings functions from
* https://github.com/skeeto/hash-prospector
*/
ccl_device_inline uint hash_hp_uint(uint i)
{
// The actual mixing function from Hash Prospector.
i ^= i >> 16;
i *= 0x21f0aaad;
i ^= i >> 15;
i *= 0xd35a2d97;
i ^= i >> 15;
// The xor is just to make input zero not map to output zero.
// The number is randomly selected and isn't special.
return i ^ 0xe6fe3beb;
}
/* Seedable version of hash_hp_uint() above. */
ccl_device_inline uint hash_hp_seeded_uint(uint i, uint seed)
{
// Manipulate the seed so it doesn't interact poorly with n when they
// are both e.g. incrementing. This isn't fool-proof, but is good
// enough for practical use.
seed ^= seed << 19;
return hash_hp_uint(i ^ seed);
}
/* Outputs [0.0, 1.0]. */
ccl_device_inline float hash_hp_seeded_float(uint i, uint seed)
{
return uint_to_float_incl(hash_hp_seeded_uint(i, seed));
}
/* ***** CMJ Hash Functions *****
*
* These are based on one of the hash functions in the paper
* "Correlated Multi-Jittered Sampling" by Andrew Kensler, 2013.
*
* These are here for backwards-compatibility, and can be replaced
* by the Hash Prospector hashes above at some point.
* See https://developer.blender.org/D15679#426304
*/
ccl_device_inline uint hash_cmj_seeded_uint(uint i, uint seed)
{
i ^= seed;
i ^= i >> 17;
i ^= i >> 10;
i *= 0xb36534e5;
i ^= i >> 12;
i ^= i >> 21;
i *= 0x93fc4795;
i ^= 0xdf6e307f;
i ^= i >> 17;
i *= 1 | seed >> 18;
return i;
}
/* Outputs [0.0, 1.0]. */
ccl_device_inline float hash_cmj_seeded_float(uint i, uint seed)
{
return uint_to_float_excl(hash_cmj_seeded_uint(i, seed));
}
/* ***** Modified Wang Hash Functions *****
*
* These are based on a bespoke modified version of the Wang hash, and
* can serve as a faster hash when quality isn't critical.
*
* The original Wang hash is documented here:
* https://www.burtleburtle.net/bob/hash/integer.html
*/
ccl_device_inline uint hash_wang_seeded_uint(uint i, uint seed)
{
i = (i ^ 61) ^ seed;
i += i << 3;
i ^= i >> 4;
i *= 0x27d4eb2d;
return i;
}
/* Outputs [0.0, 1.0]. */
ccl_device_inline float hash_wang_seeded_float(uint i, uint seed)
{
return uint_to_float_incl(hash_wang_seeded_uint(i, seed));
}
/* ********** */
#ifndef __KERNEL_GPU__
static inline uint hash_string(const char *str)
{

View File

@ -7,6 +7,6 @@
/* OpenGL header includes, used everywhere we use OpenGL, to deal with
* platform differences in one central place. */
#include <GL/glew.h>
#include <epoxy/gl.h>
#endif /* __UTIL_OPENGL_H__ */

View File

@ -4,14 +4,13 @@
set(INC
.
../clog
../glew-mx
../../source/blender/blenlib
../../source/blender/imbuf
../../source/blender/makesdna
)
set(INC_SYS
${GLEW_INCLUDE_PATH}
${Epoxy_INCLUDE_DIRS}
)
set(SRC
@ -74,8 +73,7 @@ set(SRC
)
set(LIB
bf_intern_glew_mx
${GLEW_LIBRARY}
${Epoxy_LIBRARIES}
)
if(WITH_GHOST_DEBUG)
@ -105,42 +103,39 @@ if(WITH_INPUT_NDOF)
)
endif()
if(WITH_HEADLESS OR WITH_GHOST_SDL)
if(WITH_HEADLESS)
list(APPEND SRC
intern/GHOST_DisplayManagerNULL.h
intern/GHOST_SystemNULL.h
intern/GHOST_WindowNULL.h
list(APPEND SRC
intern/GHOST_DisplayManagerNULL.h
intern/GHOST_SystemHeadless.h
intern/GHOST_WindowNULL.h
)
if(WITH_HEADLESS)
add_definitions(-DWITH_HEADLESS)
elseif (WITH_GHOST_SDL)
list(APPEND SRC
intern/GHOST_ContextSDL.cpp
intern/GHOST_DisplayManagerSDL.cpp
intern/GHOST_SystemSDL.cpp
intern/GHOST_WindowSDL.cpp
intern/GHOST_ContextSDL.h
intern/GHOST_DisplayManagerSDL.h
intern/GHOST_SystemSDL.h
intern/GHOST_WindowSDL.h
)
add_definitions(-DWITH_GHOST_SDL)
list(APPEND INC_SYS
${SDL_INCLUDE_DIR}
)
if(WITH_SDL_DYNLOAD)
list(APPEND LIB
extern_sdlew
)
add_definitions(-DWITH_HEADLESS)
else()
list(APPEND SRC
intern/GHOST_ContextSDL.cpp
intern/GHOST_DisplayManagerSDL.cpp
intern/GHOST_SystemSDL.cpp
intern/GHOST_WindowSDL.cpp
intern/GHOST_ContextSDL.h
intern/GHOST_DisplayManagerSDL.h
intern/GHOST_SystemSDL.h
intern/GHOST_WindowSDL.h
list(APPEND LIB
${SDL_LIBRARY}
)
add_definitions(-DWITH_GHOST_SDL)
endif()
if(NOT WITH_HEADLESS)
list(APPEND INC_SYS
${SDL_INCLUDE_DIR}
)
if(WITH_SDL_DYNLOAD)
list(APPEND LIB
extern_sdlew
)
else()
list(APPEND LIB
${SDL_LIBRARY}
)
endif()
endif()
elseif(APPLE AND NOT WITH_GHOST_X11)
@ -158,13 +153,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
@ -198,13 +191,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)
@ -251,10 +242,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
@ -301,6 +288,7 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
include(CheckSymbolExists)
set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
check_symbol_exists(memfd_create "sys/mman.h" HAVE_MEMFD_CREATE)
unset(CMAKE_REQUIRED_DEFINITIONS)
if(HAVE_MEMFD_CREATE)
add_definitions(-DHAVE_MEMFD_CREATE)
endif()
@ -434,13 +422,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)
@ -461,7 +447,7 @@ elseif(WIN32)
endif()
endif()
if(WITH_GL_EGL AND NOT (WITH_HEADLESS OR WITH_GHOST_SDL))
if(UNIX AND NOT APPLE)
list(APPEND SRC
intern/GHOST_ContextEGL.cpp
@ -551,11 +537,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()
@ -564,6 +547,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}")

View File

@ -27,6 +27,7 @@ typedef bool (*GHOST_EventCallbackProcPtr)(GHOST_EventHandle event, GHOST_TUserD
* \return a handle to the system.
*/
extern GHOST_SystemHandle GHOST_CreateSystem(void);
extern GHOST_SystemHandle GHOST_CreateSystemBackground(void);
/**
* Specifies whether debug messages are to be enabled for the specific system handle.

View File

@ -120,6 +120,7 @@ class GHOST_ISystem {
* \return An indication of success.
*/
static GHOST_TSuccess createSystem();
static GHOST_TSuccess createSystemBackground();
/**
* Disposes the one and only system.
@ -277,8 +278,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.

View File

@ -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 {

View File

@ -30,6 +30,14 @@ GHOST_SystemHandle GHOST_CreateSystem(void)
return (GHOST_SystemHandle)system;
}
GHOST_SystemHandle GHOST_CreateSystemBackground(void)
{
GHOST_ISystem::createSystemBackground();
GHOST_ISystem *system = GHOST_ISystem::getSystem();
return (GHOST_SystemHandle)system;
}
void GHOST_SystemInitDebug(GHOST_SystemHandle systemhandle, GHOST_Debug debug)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;

View File

@ -10,7 +10,7 @@
#include "GHOST_Context.h"
#ifdef _WIN32
# include <GL/wglew.h> // only for symbolic constants, do not use API functions
# include <epoxy/wgl.h>
# include <tchar.h>
#
# ifndef ERROR_PROFILE_DOES_NOT_MATCH_DEVICE
@ -123,11 +123,6 @@ bool win32_chk(bool result, const char *file, int line, const char *text)
#endif // _WIN32
void GHOST_Context::initContextGLEW()
{
GLEW_CHK(glewInit());
}
void GHOST_Context::initClearGL()
{
glClearColor(0.294, 0.294, 0.294, 0.000);

View File

@ -11,7 +11,7 @@
#include "GHOST_IContext.h"
#include "GHOST_Types.h"
#include "glew-mx.h"
#include <epoxy/gl.h>
#include <cstdlib> // for NULL
@ -136,8 +136,6 @@ class GHOST_Context : public GHOST_IContext {
}
protected:
void initContextGLEW();
bool m_stereoVisual;
/** Caller specified, not for internal use. */

View File

@ -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) */

View File

@ -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) {
@ -274,8 +267,6 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
}
#endif
initContextGLEW();
if (m_metalView) {
if (m_defaultFramebuffer == 0) {
/* Create a virtual frame-buffer. */

View File

@ -10,8 +10,7 @@
#include <iostream>
#include <string>
#include <GL/glew.h>
#include <GL/wglew.h>
#include <epoxy/wgl.h>
#include "GHOST_ContextD3D.h"
#include "GHOST_ContextWGL.h" /* For shared drawing */

View File

@ -151,19 +151,6 @@ static bool egl_chk(bool result,
# define EGL_CHK(x) egl_chk(x)
#endif
static inline bool bindAPI(EGLenum api)
{
if (EGLEW_VERSION_1_2) {
return (EGL_CHK(eglBindAPI(api)) == EGL_TRUE);
}
return false;
}
#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;
@ -256,7 +243,7 @@ GHOST_TSuccess GHOST_ContextEGL::swapBuffers()
GHOST_TSuccess GHOST_ContextEGL::setSwapInterval(int interval)
{
if (EGLEW_VERSION_1_1) {
if (epoxy_egl_version(m_display) >= 11) {
if (EGL_CHK(::eglSwapInterval(m_display, interval))) {
m_swap_interval = interval;
@ -313,26 +300,13 @@ GHOST_TSuccess GHOST_ContextEGL::releaseDrawingContext()
return GHOST_kFailure;
}
bool GHOST_ContextEGL::initContextEGLEW()
inline bool GHOST_ContextEGL::bindAPI(EGLenum api)
{
/* We have to manually get this function before we can call eglewInit, since
* it requires a display argument. glewInit() does the same, but we only want
* to initialize EGLEW here. */
eglGetDisplay = (PFNEGLGETDISPLAYPROC)eglGetProcAddress("eglGetDisplay");
if (eglGetDisplay == nullptr) {
return false;
if (epoxy_egl_version(m_display) >= 12) {
return (EGL_CHK(eglBindAPI(api)) == EGL_TRUE);
}
if (!EGL_CHK((m_display = ::eglGetDisplay(m_nativeDisplay)) != EGL_NO_DISPLAY)) {
return false;
}
if (GLEW_CHK(eglewInit(m_display)) != GLEW_OK) {
fprintf(stderr, "Warning! EGLEW failed to initialize properly.\n");
return false;
}
return true;
return false;
}
static const std::string &api_string(EGLenum api)
@ -355,34 +329,41 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
}
m_stereoVisual = false; /* It doesn't matter what the Window wants. */
if (!initContextEGLEW()) {
return GHOST_kFailure;
}
#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);
EGLContext prev_context = eglGetCurrentContext();
EGLint egl_major, egl_minor;
EGLint egl_major = 0, egl_minor = 0;
if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor))) {
if (!EGL_CHK((m_display = ::eglGetDisplay(m_nativeDisplay)) != EGL_NO_DISPLAY)) {
goto error;
}
if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor)) ||
(egl_major == 0 && egl_minor == 0)) {
/* We failed to create a regular render window, retry and see if we can create a headless
* render context. */
::eglTerminate(m_display);
const char *egl_extension_st = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
assert(egl_extension_st != nullptr);
assert(strstr(egl_extension_st, "EGL_MESA_platform_surfaceless") != nullptr);
if (egl_extension_st == nullptr ||
strstr(egl_extension_st, "EGL_MESA_platform_surfaceless") == nullptr) {
goto error;
}
m_display = eglGetPlatformDisplayEXT(
EGL_PLATFORM_SURFACELESS_MESA, EGL_DEFAULT_DISPLAY, nullptr);
if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor))) {
goto error;
}
/* Because the first eglInitialize will print an error to the terminal, print a "success"
* message here to let the user know that we successfully recovered from the error. */
fprintf(stderr, "\nManaged to successfully fallback to surfaceless EGL rendering!\n\n");
}
#ifdef WITH_GHOST_DEBUG
fprintf(stderr, "EGL Version %d.%d\n", egl_major, egl_minor);
#endif
@ -398,7 +379,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
attrib_list.reserve(20);
if (m_api == EGL_OPENGL_ES_API && EGLEW_VERSION_1_2) {
if (m_api == EGL_OPENGL_ES_API && epoxy_egl_version(m_display) >= 12) {
/* According to the spec it seems that you are required to set EGL_RENDERABLE_TYPE,
* but some implementations (ANGLE) do not seem to care. */
@ -421,9 +402,11 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
m_contextMinorVersion);
}
if (!((m_contextMajorVersion == 1) || (m_contextMajorVersion == 2 && EGLEW_VERSION_1_3) ||
(m_contextMajorVersion == 3 && /*EGLEW_VERSION_1_4 &&*/ EGLEW_KHR_create_context) ||
(m_contextMajorVersion == 3 && EGLEW_VERSION_1_5))) {
if (!((m_contextMajorVersion == 1) ||
(m_contextMajorVersion == 2 && epoxy_egl_version(m_display) >= 13) ||
(m_contextMajorVersion == 3 &&
epoxy_has_egl_extension(m_display, "KHR_create_context")) ||
(m_contextMajorVersion == 3 && epoxy_egl_version(m_display) >= 15))) {
fprintf(stderr,
"Warning! May not be able to create a version %d.%d ES context with version %d.%d "
"of EGL\n",
@ -488,7 +471,8 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
}
attrib_list.clear();
if (EGLEW_VERSION_1_5 || EGLEW_KHR_create_context) {
if (epoxy_egl_version(m_display) >= 15 ||
epoxy_has_egl_extension(m_display, "KHR_create_context")) {
if (m_api == EGL_OPENGL_API || m_api == EGL_OPENGL_ES_API) {
if (m_contextMajorVersion != 0) {
attrib_list.push_back(EGL_CONTEXT_MAJOR_VERSION_KHR);
@ -530,7 +514,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
}
}
if (m_api == EGL_OPENGL_API || EGLEW_VERSION_1_5) {
if (m_api == EGL_OPENGL_API || epoxy_egl_version(m_display) >= 15) {
if (m_contextResetNotificationStrategy != 0) {
attrib_list.push_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
attrib_list.push_back(m_contextResetNotificationStrategy);
@ -598,10 +582,10 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
goto error;
}
initContextGLEW();
initClearGL();
::eglSwapBuffers(m_display, m_surface);
if (m_nativeWindow != 0) {
initClearGL();
::eglSwapBuffers(m_display, m_surface);
}
return GHOST_kSuccess;

View File

@ -10,7 +10,8 @@
#include "GHOST_Context.h"
#include "GHOST_System.h"
#include <GL/eglew.h>
#include <epoxy/egl.h>
#include <epoxy/gl.h>
#ifndef GHOST_OPENGL_EGL_CONTEXT_FLAGS
# define GHOST_OPENGL_EGL_CONTEXT_FLAGS 0
@ -96,7 +97,7 @@ class GHOST_ContextEGL : public GHOST_Context {
EGLContext getContext() const;
private:
bool initContextEGLEW();
bool bindAPI(EGLenum api);
const GHOST_System *const m_system;
@ -129,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
};

View File

@ -95,11 +95,6 @@ GHOST_TSuccess GHOST_ContextGLX::releaseDrawingContext()
return ::glXMakeCurrent(m_display, None, nullptr) ? GHOST_kSuccess : GHOST_kFailure;
}
void GHOST_ContextGLX::initContextGLXEW()
{
initContextGLEW();
}
GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
{
GHOST_X11_ERROR_HANDLERS_OVERRIDE(handler_store);
@ -278,18 +273,11 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
glXMakeCurrent(m_display, m_window, m_context);
/* Seems that this has to be called after #glXMakeCurrent,
* which means we cannot use `glX` extensions until after we create a context. */
initContextGLXEW();
if (m_window) {
initClearGL();
::glXSwapBuffers(m_display, m_window);
}
/* re initialize to get the extensions properly */
initContextGLXEW();
version = glGetString(GL_VERSION);
if (!version || version[0] < '3' || ((version[0] == '3') && (version[2] < '3'))) {
@ -318,7 +306,7 @@ GHOST_TSuccess GHOST_ContextGLX::releaseNativeHandles()
GHOST_TSuccess GHOST_ContextGLX::setSwapInterval(int interval)
{
if (!GLXEW_EXT_swap_control) {
if (!epoxy_has_glx_extension(m_display, DefaultScreen(m_display), "GLX_EXT_swap_control")) {
::glXSwapIntervalEXT(m_display, m_window, interval);
return GHOST_kSuccess;
}
@ -327,7 +315,7 @@ GHOST_TSuccess GHOST_ContextGLX::setSwapInterval(int interval)
GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut)
{
if (GLXEW_EXT_swap_control) {
if (epoxy_has_glx_extension(m_display, DefaultScreen(m_display), "GLX_EXT_swap_control")) {
unsigned int interval = 0;
::glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &interval);

View File

@ -9,7 +9,7 @@
#include "GHOST_Context.h"
#include <GL/glxew.h>
#include <epoxy/glx.h>
#ifndef GHOST_OPENGL_GLX_CONTEXT_FLAGS
/* leave as convenience define for the future */
@ -89,8 +89,6 @@ class GHOST_ContextGLX : public GHOST_Context {
GHOST_TSuccess getSwapInterval(int &intervalOut);
private:
void initContextGLXEW();
Display *m_display;
GLXFBConfig m_fbconfig;
Window m_window;

View File

@ -138,8 +138,6 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
success = (SDL_GL_MakeCurrent(m_window, m_context) < 0) ? GHOST_kFailure : GHOST_kSuccess;
initContextGLEW();
initClearGL();
SDL_GL_SwapWindow(m_window);

View File

@ -87,7 +87,7 @@ GHOST_TSuccess GHOST_ContextWGL::swapBuffers()
GHOST_TSuccess GHOST_ContextWGL::setSwapInterval(int interval)
{
if (WGLEW_EXT_swap_control)
if (epoxy_has_wgl_extension(m_hDC, "WGL_EXT_swap_control"))
return WIN32_CHK(::wglSwapIntervalEXT(interval)) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
else
return GHOST_kFailure;
@ -95,7 +95,7 @@ GHOST_TSuccess GHOST_ContextWGL::setSwapInterval(int interval)
GHOST_TSuccess GHOST_ContextWGL::getSwapInterval(int &intervalOut)
{
if (WGLEW_EXT_swap_control) {
if (epoxy_has_wgl_extension(m_hDC, "WGL_EXT_swap_control")) {
intervalOut = ::wglGetSwapIntervalEXT();
return GHOST_kSuccess;
}
@ -266,89 +266,6 @@ static HWND clone_window(HWND hWnd, LPVOID lpParam)
return hwndCloned;
}
void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD)
{
HWND dummyHWND = NULL;
HDC dummyHDC = NULL;
HGLRC dummyHGLRC = NULL;
HDC prevHDC;
HGLRC prevHGLRC;
int iPixelFormat;
SetLastError(NO_ERROR);
prevHDC = ::wglGetCurrentDC();
WIN32_CHK(GetLastError() == NO_ERROR);
prevHGLRC = ::wglGetCurrentContext();
WIN32_CHK(GetLastError() == NO_ERROR);
iPixelFormat = choose_pixel_format_legacy(m_hDC, preferredPFD);
if (iPixelFormat == 0)
goto finalize;
PIXELFORMATDESCRIPTOR chosenPFD;
if (!WIN32_CHK(
::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &chosenPFD)))
goto finalize;
if (m_hWnd) {
dummyHWND = clone_window(m_hWnd, NULL);
if (dummyHWND == NULL)
goto finalize;
dummyHDC = GetDC(dummyHWND);
}
if (!WIN32_CHK(dummyHDC != NULL))
goto finalize;
if (!WIN32_CHK(::SetPixelFormat(dummyHDC, iPixelFormat, &chosenPFD)))
goto finalize;
dummyHGLRC = ::wglCreateContext(dummyHDC);
if (!WIN32_CHK(dummyHGLRC != NULL))
goto finalize;
if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC)))
goto finalize;
if (GLEW_CHK(glewInit()) != GLEW_OK) {
fprintf(stderr, "Warning! Dummy GLEW/WGLEW failed to initialize properly.\n");
}
/* The following are not technically WGLEW, but they also require a context to work. */
#ifndef NDEBUG
free((void *)m_dummyRenderer);
free((void *)m_dummyVendor);
free((void *)m_dummyVersion);
m_dummyRenderer = _strdup(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
m_dummyVendor = _strdup(reinterpret_cast<const char *>(glGetString(GL_VENDOR)));
m_dummyVersion = _strdup(reinterpret_cast<const char *>(glGetString(GL_VERSION)));
#endif
finalize:
WIN32_CHK(::wglMakeCurrent(prevHDC, prevHGLRC));
if (dummyHGLRC != NULL)
WIN32_CHK(::wglDeleteContext(dummyHGLRC));
if (dummyHWND != NULL) {
if (dummyHDC != NULL)
WIN32_CHK(::ReleaseDC(dummyHWND, dummyHDC));
WIN32_CHK(::DestroyWindow(dummyHWND));
}
}
static void makeAttribList(std::vector<int> &out, bool stereoVisual, bool needAlpha)
{
out.clear();
@ -385,6 +302,130 @@ static void makeAttribList(std::vector<int> &out, bool stereoVisual, bool needAl
out.push_back(0);
}
/* Temporary context used to create the actual context. We need ARB pixel format
* and context extensions, which are only available within a context. */
struct DummyContextWGL {
HWND dummyHWND = NULL;
HDC dummyHDC = NULL;
HGLRC dummyHGLRC = NULL;
HDC prevHDC = NULL;
HGLRC prevHGLRC = NULL;
int dummyPixelFormat = 0;
PIXELFORMATDESCRIPTOR preferredPFD;
bool has_WGL_ARB_pixel_format = false;
bool has_WGL_ARB_create_context = false;
bool has_WGL_ARB_create_context_profile = false;
bool has_WGL_ARB_create_context_robustness = false;
DummyContextWGL(HDC hDC, HWND hWnd, bool stereoVisual, bool needAlpha)
{
preferredPFD = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
(DWORD)(PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER | /* support double-buffering */
(stereoVisual ? PFD_STEREO : 0) | /* support stereo */
(
#ifdef WIN32_COMPOSITING
/* Support composition for transparent background. */
needAlpha ? PFD_SUPPORT_COMPOSITION :
#endif
0)),
PFD_TYPE_RGBA, /* color type */
(BYTE)(needAlpha ? 32 : 24), /* preferred color depth */
0,
0,
0,
0,
0,
0, /* color bits (ignored) */
(BYTE)(needAlpha ? 8 : 0), /* alpha buffer */
0, /* alpha shift (ignored) */
0, /* no accumulation buffer */
0,
0,
0,
0, /* accum bits (ignored) */
0, /* depth buffer */
0, /* stencil buffer */
0, /* no auxiliary buffers */
PFD_MAIN_PLANE, /* main layer */
0, /* reserved */
0,
0,
0 /* layer, visible, and damage masks (ignored) */
};
SetLastError(NO_ERROR);
prevHDC = ::wglGetCurrentDC();
WIN32_CHK(GetLastError() == NO_ERROR);
prevHGLRC = ::wglGetCurrentContext();
WIN32_CHK(GetLastError() == NO_ERROR);
dummyPixelFormat = choose_pixel_format_legacy(hDC, preferredPFD);
if (dummyPixelFormat == 0)
return;
PIXELFORMATDESCRIPTOR chosenPFD;
if (!WIN32_CHK(::DescribePixelFormat(
hDC, dummyPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &chosenPFD)))
return;
if (hWnd) {
dummyHWND = clone_window(hWnd, NULL);
if (dummyHWND == NULL)
return;
dummyHDC = GetDC(dummyHWND);
}
if (!WIN32_CHK(dummyHDC != NULL))
return;
if (!WIN32_CHK(::SetPixelFormat(dummyHDC, dummyPixelFormat, &chosenPFD)))
return;
dummyHGLRC = ::wglCreateContext(dummyHDC);
if (!WIN32_CHK(dummyHGLRC != NULL))
return;
if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC)))
return;
has_WGL_ARB_pixel_format = epoxy_has_wgl_extension(hDC, "WGL_ARB_pixel_format");
has_WGL_ARB_create_context = epoxy_has_wgl_extension(hDC, "WGL_ARB_create_context");
has_WGL_ARB_create_context_profile = epoxy_has_wgl_extension(hDC,
"WGL_ARB_create_context_profile");
has_WGL_ARB_create_context_robustness = epoxy_has_wgl_extension(
hDC, "WGL_ARB_create_context_robustness");
}
~DummyContextWGL()
{
WIN32_CHK(::wglMakeCurrent(prevHDC, prevHGLRC));
if (dummyHGLRC != NULL)
WIN32_CHK(::wglDeleteContext(dummyHGLRC));
if (dummyHWND != NULL) {
if (dummyHDC != NULL)
WIN32_CHK(::ReleaseDC(dummyHWND, dummyHDC));
WIN32_CHK(::DestroyWindow(dummyHWND));
}
}
};
int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, bool needAlpha)
{
std::vector<int> iAttributes;
@ -454,58 +495,6 @@ int GHOST_ContextWGL::choose_pixel_format_arb(bool stereoVisual, bool needAlpha)
return iPixelFormat;
}
int GHOST_ContextWGL::choose_pixel_format(bool stereoVisual, bool needAlpha)
{
PIXELFORMATDESCRIPTOR preferredPFD = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
(DWORD)(PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER | /* support double-buffering */
(stereoVisual ? PFD_STEREO : 0) | /* support stereo */
(
#ifdef WIN32_COMPOSITING
/* Support composition for transparent background. */
needAlpha ? PFD_SUPPORT_COMPOSITION :
#endif
0)),
PFD_TYPE_RGBA, /* color type */
(BYTE)(needAlpha ? 32 : 24), /* preferred color depth */
0,
0,
0,
0,
0,
0, /* color bits (ignored) */
(BYTE)(needAlpha ? 8 : 0), /* alpha buffer */
0, /* alpha shift (ignored) */
0, /* no accumulation buffer */
0,
0,
0,
0, /* accum bits (ignored) */
0, /* depth buffer */
0, /* stencil buffer */
0, /* no auxiliary buffers */
PFD_MAIN_PLANE, /* main layer */
0, /* reserved */
0,
0,
0 /* layer, visible, and damage masks (ignored) */
};
initContextWGLEW(preferredPFD);
int iPixelFormat = 0;
if (WGLEW_ARB_pixel_format)
iPixelFormat = choose_pixel_format_arb(stereoVisual, needAlpha);
if (iPixelFormat == 0)
iPixelFormat = choose_pixel_format_legacy(m_hDC, preferredPFD);
return iPixelFormat;
}
#ifndef NDEBUG
static void reportContextString(const char *name, const char *dummy, const char *context)
{
@ -526,107 +515,96 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
HDC prevHDC = ::wglGetCurrentDC();
WIN32_CHK(GetLastError() == NO_ERROR);
if (!WGLEW_ARB_create_context || ::GetPixelFormat(m_hDC) == 0) {
{
const bool needAlpha = m_alphaBackground;
int iPixelFormat;
int lastPFD;
DummyContextWGL dummy(m_hDC, m_hWnd, m_stereoVisual, needAlpha);
PIXELFORMATDESCRIPTOR chosenPFD;
if (!dummy.has_WGL_ARB_create_context || ::GetPixelFormat(m_hDC) == 0) {
int iPixelFormat = 0;
iPixelFormat = choose_pixel_format(m_stereoVisual, needAlpha);
if (dummy.has_WGL_ARB_pixel_format)
iPixelFormat = choose_pixel_format_arb(m_stereoVisual, needAlpha);
if (iPixelFormat == 0) {
goto error;
}
if (iPixelFormat == 0)
iPixelFormat = choose_pixel_format_legacy(m_hDC, dummy.preferredPFD);
lastPFD = ::DescribePixelFormat(
m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &chosenPFD);
if (!WIN32_CHK(lastPFD != 0)) {
goto error;
}
if (needAlpha && chosenPFD.cAlphaBits == 0)
fprintf(stderr, "Warning! Unable to find a pixel format with an alpha channel.\n");
if (!WIN32_CHK(::SetPixelFormat(m_hDC, iPixelFormat, &chosenPFD))) {
goto error;
}
}
if (WGLEW_ARB_create_context) {
int profileBitCore = m_contextProfileMask & WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
int profileBitCompat = m_contextProfileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
#ifdef WITH_GLEW_ES
int profileBitES = m_contextProfileMask & WGL_CONTEXT_ES_PROFILE_BIT_EXT;
#endif
if (!WGLEW_ARB_create_context_profile && profileBitCore)
fprintf(stderr, "Warning! OpenGL core profile not available.\n");
if (!WGLEW_ARB_create_context_profile && profileBitCompat)
fprintf(stderr, "Warning! OpenGL compatibility profile not available.\n");
#ifdef WITH_GLEW_ES
if (!WGLEW_EXT_create_context_es_profile && profileBitES && m_contextMajorVersion == 1)
fprintf(stderr, "Warning! OpenGL ES profile not available.\n");
if (!WGLEW_EXT_create_context_es2_profile && profileBitES && m_contextMajorVersion == 2)
fprintf(stderr, "Warning! OpenGL ES2 profile not available.\n");
#endif
int profileMask = 0;
if (WGLEW_ARB_create_context_profile && profileBitCore)
profileMask |= profileBitCore;
if (WGLEW_ARB_create_context_profile && profileBitCompat)
profileMask |= profileBitCompat;
#ifdef WITH_GLEW_ES
if (WGLEW_EXT_create_context_es_profile && profileBitES)
profileMask |= profileBitES;
#endif
if (profileMask != m_contextProfileMask)
fprintf(stderr, "Warning! Ignoring untested OpenGL context profile mask bits.");
std::vector<int> iAttributes;
if (profileMask) {
iAttributes.push_back(WGL_CONTEXT_PROFILE_MASK_ARB);
iAttributes.push_back(profileMask);
}
if (m_contextMajorVersion != 0) {
iAttributes.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);
iAttributes.push_back(m_contextMajorVersion);
}
if (m_contextMinorVersion != 0) {
iAttributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
iAttributes.push_back(m_contextMinorVersion);
}
if (m_contextFlags != 0) {
iAttributes.push_back(WGL_CONTEXT_FLAGS_ARB);
iAttributes.push_back(m_contextFlags);
}
if (m_contextResetNotificationStrategy != 0) {
if (WGLEW_ARB_create_context_robustness) {
iAttributes.push_back(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB);
iAttributes.push_back(m_contextResetNotificationStrategy);
if (iPixelFormat == 0) {
goto error;
}
else {
fprintf(stderr, "Warning! Cannot set the reset notification strategy.");
PIXELFORMATDESCRIPTOR chosenPFD;
int lastPFD = ::DescribePixelFormat(
m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &chosenPFD);
if (!WIN32_CHK(lastPFD != 0)) {
goto error;
}
if (needAlpha && chosenPFD.cAlphaBits == 0)
fprintf(stderr, "Warning! Unable to find a pixel format with an alpha channel.\n");
if (!WIN32_CHK(::SetPixelFormat(m_hDC, iPixelFormat, &chosenPFD))) {
goto error;
}
}
iAttributes.push_back(0);
if (dummy.has_WGL_ARB_create_context) {
int profileBitCore = m_contextProfileMask & WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
int profileBitCompat = m_contextProfileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
m_hGLRC = ::wglCreateContextAttribsARB(m_hDC, NULL, &(iAttributes[0]));
if (!dummy.has_WGL_ARB_create_context_profile && profileBitCore)
fprintf(stderr, "Warning! OpenGL core profile not available.\n");
if (!dummy.has_WGL_ARB_create_context_profile && profileBitCompat)
fprintf(stderr, "Warning! OpenGL compatibility profile not available.\n");
int profileMask = 0;
if (dummy.has_WGL_ARB_create_context_profile && profileBitCore)
profileMask |= profileBitCore;
if (dummy.has_WGL_ARB_create_context_profile && profileBitCompat)
profileMask |= profileBitCompat;
if (profileMask != m_contextProfileMask)
fprintf(stderr, "Warning! Ignoring untested OpenGL context profile mask bits.");
std::vector<int> iAttributes;
if (profileMask) {
iAttributes.push_back(WGL_CONTEXT_PROFILE_MASK_ARB);
iAttributes.push_back(profileMask);
}
if (m_contextMajorVersion != 0) {
iAttributes.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);
iAttributes.push_back(m_contextMajorVersion);
}
if (m_contextMinorVersion != 0) {
iAttributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
iAttributes.push_back(m_contextMinorVersion);
}
if (m_contextFlags != 0) {
iAttributes.push_back(WGL_CONTEXT_FLAGS_ARB);
iAttributes.push_back(m_contextFlags);
}
if (m_contextResetNotificationStrategy != 0) {
if (dummy.has_WGL_ARB_create_context_robustness) {
iAttributes.push_back(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB);
iAttributes.push_back(m_contextResetNotificationStrategy);
}
else {
fprintf(stderr, "Warning! Cannot set the reset notification strategy.");
}
}
iAttributes.push_back(0);
m_hGLRC = ::wglCreateContextAttribsARB(m_hDC, NULL, &(iAttributes[0]));
}
}
/* Silence warnings interpreted as errors by users when trying to get
@ -651,8 +629,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
goto error;
}
initContextGLEW();
if (is_crappy_intel_card()) {
/* Some Intel cards with context 4.1 or 4.2
* don't have the point sprite enabled by default.

View File

@ -11,7 +11,7 @@
#include "GHOST_Context.h"
#include <GL/wglew.h>
#include <epoxy/wgl.h>
#ifndef GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY
# define GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY 0
@ -86,12 +86,9 @@ class GHOST_ContextWGL : public GHOST_Context {
GHOST_TSuccess getSwapInterval(int &intervalOut);
private:
int choose_pixel_format(bool stereoVisual, bool needAlpha);
int choose_pixel_format_arb(bool stereoVisual, bool needAlpha);
int _choose_pixel_format_arb_1(bool stereoVisual, bool needAlpha);
void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD);
HWND m_hWnd;
HDC m_hDC;

View File

@ -8,38 +8,38 @@
#pragma once
#include "GHOST_DisplayManager.h"
#include "GHOST_SystemNULL.h"
#include "GHOST_SystemHeadless.h"
class GHOST_SystemNULL;
class GHOST_SystemHeadless;
class GHOST_DisplayManagerNULL : public GHOST_DisplayManager {
public:
GHOST_DisplayManagerNULL(GHOST_SystemNULL *system) : GHOST_DisplayManager(), m_system(system)
GHOST_DisplayManagerNULL() : GHOST_DisplayManager()
{ /* nop */
}
GHOST_TSuccess getNumDisplays(uint8_t &numDisplays) const
GHOST_TSuccess getNumDisplays(uint8_t & /*numDisplays*/) const override
{
return GHOST_kFailure;
}
GHOST_TSuccess getNumDisplaySettings(uint8_t display, int32_t &numSettings) const
GHOST_TSuccess getNumDisplaySettings(uint8_t /*display*/,
int32_t & /*numSettings*/) const override
{
return GHOST_kFailure;
}
GHOST_TSuccess getDisplaySetting(uint8_t display,
int32_t index,
GHOST_DisplaySetting &setting) const
GHOST_TSuccess getDisplaySetting(uint8_t /*display*/,
int32_t /*index*/,
GHOST_DisplaySetting & /*setting*/) const override
{
return GHOST_kFailure;
}
GHOST_TSuccess getCurrentDisplaySetting(uint8_t display, GHOST_DisplaySetting &setting) const
GHOST_TSuccess getCurrentDisplaySetting(uint8_t display,
GHOST_DisplaySetting &setting) const override
{
return getDisplaySetting(display, int32_t(0), setting);
}
GHOST_TSuccess setCurrentDisplaySetting(uint8_t display, const GHOST_DisplaySetting &setting)
GHOST_TSuccess setCurrentDisplaySetting(uint8_t /*display*/,
const GHOST_DisplaySetting & /*setting*/) override
{
return GHOST_kSuccess;
}
private:
GHOST_SystemNULL *m_system;
};

View File

@ -9,14 +9,14 @@
* Copyright (C) 2001 NaN Technologies B.V.
*/
#include "GHOST_ISystem.h"
#include <stdexcept>
#if defined(WITH_HEADLESS)
# include "GHOST_SystemNULL.h"
#elif defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND)
#include "GHOST_ISystem.h"
#include "GHOST_SystemHeadless.h"
#if defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND)
# include "GHOST_SystemWayland.h"
# include "GHOST_SystemX11.h"
# include <stdexcept>
#elif defined(WITH_GHOST_X11)
# include "GHOST_SystemX11.h"
#elif defined(WITH_GHOST_WAYLAND)
@ -49,26 +49,50 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
#endif
#if defined(WITH_HEADLESS)
m_system = new GHOST_SystemNULL();
/* Pass. */
#elif defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND)
/* Special case, try Wayland, fall back to X11. */
try {
m_system = has_wayland_libraries ? new GHOST_SystemWayland() : nullptr;
}
catch (const std::runtime_error &) {
/* fallback to X11. */
delete m_system;
m_system = nullptr;
}
if (!m_system) {
m_system = new GHOST_SystemX11();
/* Try to fallback to X11. */
try {
m_system = new GHOST_SystemX11();
}
catch (const std::runtime_error &) {
delete m_system;
m_system = nullptr;
}
}
#elif defined(WITH_GHOST_X11)
m_system = new GHOST_SystemX11();
try {
m_system = new GHOST_SystemX11();
}
catch (const std::runtime_error &) {
delete m_system;
m_system = nullptr;
}
#elif defined(WITH_GHOST_WAYLAND)
m_system = has_wayland_libraries ? new GHOST_SystemWayland() : nullptr;
try {
m_system = has_wayland_libraries ? new GHOST_SystemWayland() : nullptr;
}
catch (const std::runtime_error &) {
delete m_system;
m_system = nullptr;
}
#elif defined(WITH_GHOST_SDL)
m_system = new GHOST_SystemSDL();
try {
m_system = new GHOST_SystemSDL();
}
catch (const std::runtime_error &) {
delete m_system;
m_system = nullptr;
}
#elif defined(WIN32)
m_system = new GHOST_SystemWin32();
#elif defined(__APPLE__)
@ -85,6 +109,30 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
return success;
}
GHOST_TSuccess GHOST_ISystem::createSystemBackground()
{
GHOST_TSuccess success;
if (!m_system) {
#if !defined(WITH_HEADLESS)
/* Try to create a off-screen render surface with the graphical systems. */
success = createSystem();
if (success) {
return success;
}
/* Try to fallback to headless mode if all else fails. */
#endif
m_system = new GHOST_SystemHeadless();
success = m_system != nullptr ? GHOST_kSuccess : GHOST_kFailure;
}
else {
success = GHOST_kFailure;
}
if (success) {
success = m_system->init();
}
return success;
}
GHOST_TSuccess GHOST_ISystem::disposeSystem()
{
GHOST_TSuccess success = GHOST_kSuccess;

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -0,0 +1,166 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup GHOST
* Declaration of GHOST_SystemHeadless class.
*/
#pragma once
#include "../GHOST_Types.h"
#include "GHOST_DisplayManagerNULL.h"
#include "GHOST_System.h"
#include "GHOST_WindowNULL.h"
#ifdef __linux__
# include "GHOST_ContextEGL.h"
#endif
#include "GHOST_ContextNone.h"
class GHOST_WindowNULL;
class GHOST_SystemHeadless : public GHOST_System {
public:
GHOST_SystemHeadless() : GHOST_System()
{ /* nop */
}
~GHOST_SystemHeadless() override = default;
bool processEvents(bool /*waitForEvent*/) override
{
return false;
}
int setConsoleWindowState(GHOST_TConsoleWindowState /*action*/) override
{
return 0;
}
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys & /*keys*/) const override
{
return GHOST_kSuccess;
}
GHOST_TSuccess getButtons(GHOST_Buttons & /*buttons*/) const override
{
return GHOST_kSuccess;
}
char *getClipboard(bool /*selection*/) const override
{
return nullptr;
}
void putClipboard(const char * /*buffer*/, bool /*selection*/) const override
{ /* nop */
}
uint64_t getMilliSeconds() const override
{
return 0;
}
uint8_t getNumDisplays() const override
{
return uint8_t(1);
}
GHOST_TSuccess getCursorPosition(int32_t & /*x*/, int32_t & /*y*/) const override
{
return GHOST_kFailure;
}
GHOST_TSuccess setCursorPosition(int32_t /*x*/, int32_t /*y*/) override
{
return GHOST_kFailure;
}
void getMainDisplayDimensions(uint32_t & /*width*/, uint32_t & /*height*/) const override
{ /* nop */
}
void getAllDisplayDimensions(uint32_t & /*width*/, uint32_t & /*height*/) const override
{ /* nop */
}
GHOST_IContext *createOffscreenContext(GHOST_GLSettings /*glSettings*/) override
{
#ifdef __linux__
GHOST_Context *context;
for (int minor = 6; minor >= 0; --minor) {
context = new GHOST_ContextEGL((GHOST_System *)this,
false,
EGLNativeWindowType(0),
EGLNativeDisplayType(EGL_DEFAULT_DISPLAY),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
4,
minor,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
if (context->initializeDrawingContext()) {
return context;
}
delete context;
context = nullptr;
}
context = new GHOST_ContextEGL((GHOST_System *)this,
false,
EGLNativeWindowType(0),
EGLNativeDisplayType(EGL_DEFAULT_DISPLAY),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3,
3,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
if (context->initializeDrawingContext() != GHOST_kSuccess) {
delete context;
context = nullptr;
}
return context;
#else
return nullptr;
#endif
}
GHOST_TSuccess disposeContext(GHOST_IContext *context) override
{
delete context;
return GHOST_kSuccess;
}
GHOST_TSuccess init() override
{
GHOST_TSuccess success = GHOST_System::init();
if (success) {
m_displayManager = new GHOST_DisplayManagerNULL();
if (m_displayManager) {
return GHOST_kSuccess;
}
}
return GHOST_kFailure;
}
GHOST_IWindow *createWindow(const char *title,
int32_t left,
int32_t top,
uint32_t width,
uint32_t height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
GHOST_GLSettings glSettings,
const bool /*exclusive*/,
const bool /*is_dialog*/,
const GHOST_IWindow *parentWindow) override
{
return new GHOST_WindowNULL(title,
left,
top,
width,
height,
state,
parentWindow,
type,
((glSettings.flags & GHOST_glStereoVisual) != 0));
}
GHOST_IWindow *getWindowUnderCursor(int32_t /*x*/, int32_t /*y*/) override
{
return nullptr;
}
};

Some files were not shown because too many files have changed in this diff Show More