0001_openexr3.patch 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. commit ade5af81ba7b039b42eff6efeb580b78bd54b6b3
  2. Author: CYBERDEViL <cyberdevil@notabug.org>
  3. Date: Sat Dec 16 02:23:16 2023 +0100
  4. openexr: fix header include
  5. Thanks to this patch: https://aur.archlinux.org/cgit/aur.git/tree/openexr3.patch?h=blender-2.7
  6. commit e00532824f88fbf8d6215df1509dd13ab33b8628
  7. Author: CYBERDEViL <cyberdevil@notabug.org>
  8. Date: Fri Dec 15 23:30:59 2023 +0100
  9. openexr: "Images: update code to support OpenEXR 3"
  10. Adjusted Blender ref: cd7550cfe7
  11. commit 7af9405f175999f38df80a421bde7166641183fd
  12. Author: CYBERDEViL <cyberdevil@notabug.org>
  13. Date: Fri Dec 15 22:23:21 2023 +0100
  14. openexr: "Build: update CMake to support OpenEXR 3"
  15. Applied whole Blender upstream ref: 2c9931699e2080639bb836357e116b8e340335d9
  16. diff --git a/blender-2.79b/build_files/cmake/Modules/FindOpenEXR.cmake b/blender-2.79b/build_files/cmake/Modules/FindOpenEXR.cmake
  17. index 41e60a7..7e1fdbd 100644
  18. --- a/blender-2.79b/build_files/cmake/Modules/FindOpenEXR.cmake
  19. +++ b/blender-2.79b/build_files/cmake/Modules/FindOpenEXR.cmake
  20. @@ -37,14 +37,6 @@ ENDIF()
  21. # Old versions (before 2.0?) do not have any version string, just assuming this should be fine though.
  22. SET(_openexr_libs_ver_init "2.0")
  23. -SET(_openexr_FIND_COMPONENTS
  24. - Half
  25. - Iex
  26. - IlmImf
  27. - IlmThread
  28. - Imath
  29. -)
  30. -
  31. SET(_openexr_SEARCH_DIRS
  32. ${OPENEXR_ROOT_DIR}
  33. /usr/local
  34. @@ -101,6 +93,24 @@ UNSET(_openexr_libs_ver_init)
  35. STRING(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _openexr_libs_ver ${OPENEXR_VERSION})
  36. +# Different library names in 3.0, and Imath and Half moved out.
  37. +IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
  38. + SET(_openexr_FIND_COMPONENTS
  39. + Iex
  40. + IlmThread
  41. + OpenEXR
  42. + OpenEXRCore
  43. + )
  44. +ELSE()
  45. + SET(_openexr_FIND_COMPONENTS
  46. + Half
  47. + Iex
  48. + IlmImf
  49. + IlmThread
  50. + Imath
  51. + )
  52. +ENDIF()
  53. +
  54. SET(_openexr_LIBRARIES)
  55. FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
  56. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  57. @@ -118,6 +128,57 @@ ENDFOREACH()
  58. UNSET(_openexr_libs_ver)
  59. +IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
  60. + # For OpenEXR 3.x, we also need to find the now separate Imath library.
  61. + # For simplicity we add it to the OpenEXR includes and libraries, as we
  62. + # have no direct dependency on Imath and it's simpler to support both
  63. + # 2.x and 3.x this way.
  64. +
  65. + # Find include directory
  66. + FIND_PATH(IMATH_INCLUDE_DIR
  67. + NAMES
  68. + Imath/ImathMath.h
  69. + HINTS
  70. + ${_openexr_SEARCH_DIRS}
  71. + PATH_SUFFIXES
  72. + include
  73. + )
  74. +
  75. + # Find version
  76. + FIND_FILE(_imath_config
  77. + NAMES
  78. + ImathConfig.h
  79. + PATHS
  80. + ${IMATH_INCLUDE_DIR}/Imath
  81. + NO_DEFAULT_PATH
  82. + )
  83. +
  84. + # Find line with version, extract string, and format for library suffix.
  85. + FILE(STRINGS "${_imath_config}" _imath_build_specification
  86. + REGEX "^[ \t]*#define[ \t]+IMATH_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
  87. + STRING(REGEX REPLACE ".*#define[ \t]+IMATH_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
  88. + "\\1" _imath_libs_ver ${_imath_build_specification})
  89. + STRING(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _imath_libs_ver ${_imath_libs_ver})
  90. +
  91. + # Find library, with or without version number.
  92. + FIND_LIBRARY(IMATH_LIBRARY
  93. + NAMES
  94. + Imath-${_imath_libs_ver} Imath
  95. + NAMES_PER_DIR
  96. + HINTS
  97. + ${_openexr_SEARCH_DIRS}
  98. + PATH_SUFFIXES
  99. + lib64 lib
  100. + )
  101. + LIST(APPEND _openexr_LIBRARIES "${IMATH_LIBRARY}")
  102. +
  103. + # In cmake version 3.21 and up, we can instead use the NO_CACHE option for
  104. + # FIND_FILE so we don't need to clear it from the cache here.
  105. + UNSET(_imath_config CACHE)
  106. + UNSET(_imath_libs_ver)
  107. + UNSET(_imath_build_specification)
  108. +ENDIF()
  109. +
  110. # handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if
  111. # all listed variables are TRUE
  112. INCLUDE(FindPackageHandleStandardArgs)
  113. @@ -126,13 +187,25 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG
  114. IF(OPENEXR_FOUND)
  115. SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES})
  116. - # Both include paths are needed because of dummy OSL headers mixing #include <OpenEXR/foo.h> and #include <foo.h> :(
  117. - SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR}/OpenEXR)
  118. + # Both include paths are needed because of dummy OSL headers mixing
  119. + # #include <OpenEXR/foo.h> and #include <foo.h>, as well as Alembic
  120. + # include <half.h> directly.
  121. + SET(OPENEXR_INCLUDE_DIRS
  122. + ${OPENEXR_INCLUDE_DIR}
  123. + ${OPENEXR_INCLUDE_DIR}/OpenEXR)
  124. +
  125. + IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
  126. + LIST(APPEND OPENEXR_INCLUDE_DIRS
  127. + ${IMATH_INCLUDE_DIR}
  128. + ${IMATH_INCLUDE_DIR}/Imath)
  129. + ENDIF()
  130. ENDIF()
  131. MARK_AS_ADVANCED(
  132. OPENEXR_INCLUDE_DIR
  133. OPENEXR_VERSION
  134. + IMATH_INCLUDE_DIR
  135. + IMATH_LIBRARY
  136. )
  137. FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
  138. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  139. diff --git a/blender-2.79b/source/blender/alembic/intern/abc_transform.cc b/blender-2.79b/source/blender/alembic/intern/abc_transform.cc
  140. index 5392387..9dc3200 100644
  141. --- a/blender-2.79b/source/blender/alembic/intern/abc_transform.cc
  142. +++ b/blender-2.79b/source/blender/alembic/intern/abc_transform.cc
  143. @@ -22,7 +22,7 @@
  144. #include "abc_transform.h"
  145. -#include <OpenEXR/ImathBoxAlgo.h>
  146. +#include <Imath/ImathBoxAlgo.h>
  147. #include "abc_util.h"
  148. diff --git a/blender-2.79b/source/blender/imbuf/intern/openexr/openexr_api.cpp b/blender-2.79b/source/blender/imbuf/intern/openexr/openexr_api.cpp
  149. index 5ad42bd..94c2232 100644
  150. --- a/blender-2.79b/source/blender/imbuf/intern/openexr/openexr_api.cpp
  151. +++ b/blender-2.79b/source/blender/imbuf/intern/openexr/openexr_api.cpp
  152. @@ -40,30 +40,46 @@
  153. #include <algorithm>
  154. #include <iostream>
  155. -#include <half.h>
  156. -#include <Iex.h>
  157. -#include <ImfVersion.h>
  158. -#include <ImathBox.h>
  159. -#include <ImfArray.h>
  160. -#include <ImfIO.h>
  161. -#include <ImfChannelList.h>
  162. -#include <ImfPixelType.h>
  163. -#include <ImfInputFile.h>
  164. -#include <ImfOutputFile.h>
  165. -#include <ImfCompression.h>
  166. -#include <ImfCompressionAttribute.h>
  167. -#include <ImfStringAttribute.h>
  168. -#include <ImfStandardAttributes.h>
  169. +/* The OpenEXR version can reliably be found in this header file from OpenEXR,
  170. + * for both 2.x and 3.x:
  171. + */
  172. +#include <OpenEXR/OpenEXRConfig.h>
  173. +#define COMBINED_OPENEXR_VERSION \
  174. + ((10000 * OPENEXR_VERSION_MAJOR) + (100 * OPENEXR_VERSION_MINOR) + OPENEXR_VERSION_PATCH)
  175. +
  176. +#if COMBINED_OPENEXR_VERSION >= 20599
  177. +/* >=2.5.99 -> OpenEXR >=3.0 */
  178. +# include <Imath/half.h>
  179. +# include <OpenEXR/ImfFrameBuffer.h>
  180. +# define exr_file_offset_t uint64_t
  181. +#else
  182. +/* OpenEXR 2.x, use the old locations. */
  183. +# include <OpenEXR/half.h>
  184. +# define exr_file_offset_t Int64
  185. +#endif
  186. +
  187. +#include <OpenEXR/Iex.h>
  188. +#include <OpenEXR/ImfArray.h>
  189. +#include <OpenEXR/ImfChannelList.h>
  190. +#include <OpenEXR/ImfCompression.h>
  191. +#include <OpenEXR/ImfCompressionAttribute.h>
  192. +#include <OpenEXR/ImfIO.h>
  193. +#include <OpenEXR/ImfInputFile.h>
  194. +#include <OpenEXR/ImfOutputFile.h>
  195. +#include <OpenEXR/ImfPixelType.h>
  196. +#include <OpenEXR/ImfStandardAttributes.h>
  197. +#include <OpenEXR/ImfStringAttribute.h>
  198. +#include <OpenEXR/ImfVersion.h>
  199. /* multiview/multipart */
  200. -#include <ImfMultiView.h>
  201. -#include <ImfMultiPartInputFile.h>
  202. -#include <ImfInputPart.h>
  203. -#include <ImfOutputPart.h>
  204. -#include <ImfMultiPartOutputFile.h>
  205. -#include <ImfTiledOutputPart.h>
  206. -#include <ImfPartType.h>
  207. -#include <ImfPartHelper.h>
  208. +#include <OpenEXR/ImfInputPart.h>
  209. +#include <OpenEXR/ImfMultiPartInputFile.h>
  210. +#include <OpenEXR/ImfMultiPartOutputFile.h>
  211. +#include <OpenEXR/ImfMultiView.h>
  212. +#include <OpenEXR/ImfOutputPart.h>
  213. +#include <OpenEXR/ImfPartHelper.h>
  214. +#include <OpenEXR/ImfPartType.h>
  215. +#include <OpenEXR/ImfTiledOutputPart.h>
  216. #include "DNA_scene_types.h" /* For OpenEXR compression constants */
  217. @@ -134,15 +150,15 @@ public:
  218. }
  219. virtual bool read(char c[], int n);
  220. - virtual Int64 tellg();
  221. - virtual void seekg(Int64 pos);
  222. + virtual exr_file_offset_t tellg();
  223. + virtual void seekg(exr_file_offset_t pos);
  224. virtual void clear();
  225. //virtual ~Mem_IStream() {}; // unused
  226. private:
  227. - Int64 _exrpos;
  228. - Int64 _exrsize;
  229. + exr_file_offset_t _exrpos;
  230. + exr_file_offset_t _exrsize;
  231. unsigned char *_exrbuf;
  232. };
  233. @@ -157,12 +173,12 @@ bool Mem_IStream::read(char c[], int n)
  234. return false;
  235. }
  236. -Int64 Mem_IStream::tellg()
  237. +exr_file_offset_t Mem_IStream::tellg()
  238. {
  239. return _exrpos;
  240. }
  241. -void Mem_IStream::seekg(Int64 pos)
  242. +void Mem_IStream::seekg(exr_file_offset_t pos)
  243. {
  244. _exrpos = pos;
  245. }
  246. @@ -202,12 +218,12 @@ public:
  247. return check_error();
  248. }
  249. - virtual Int64 tellg()
  250. + virtual exr_file_offset_t tellg()
  251. {
  252. return std::streamoff(ifs.tellg());
  253. }
  254. - virtual void seekg(Int64 pos)
  255. + virtual void seekg(exr_file_offset_t pos)
  256. {
  257. ifs.seekg(pos);
  258. check_error();
  259. @@ -262,12 +278,12 @@ public:
  260. check_error();
  261. }
  262. - virtual Int64 tellp()
  263. + virtual exr_file_offset_t tellp()
  264. {
  265. return std::streamoff(ofs.tellp());
  266. }
  267. - virtual void seekp(Int64 pos)
  268. + virtual void seekp(exr_file_offset_t pos)
  269. {
  270. ofs.seekp(pos);
  271. check_error();