summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-04-19 15:39:28 -0400
committerGitHub <noreply@github.com>2024-04-19 14:39:28 -0500
commite361671018068000a8b63b3cdc2ad87468def9a3 (patch)
tree89a8c8bde135e7055a01fa44e4613bf5b18893b1
parente459698a821d14d7274fa64bcf863b47f29c1607 (diff)
Port from OpenEXR to TinyEXR for reduced installer and library size (#1287)
-rw-r--r--autobuild.xml110
-rw-r--r--indra/cmake/CMakeLists.txt2
-rw-r--r--indra/cmake/Copy3rdPartyLibs.cmake6
-rw-r--r--indra/cmake/OpenEXR.cmake18
-rw-r--r--indra/cmake/TinyEXR.cmake7
-rw-r--r--indra/newview/CMakeLists.txt9
-rw-r--r--indra/newview/llreflectionmapmanager.cpp96
-rwxr-xr-xindra/newview/viewer_manifest.py8
8 files changed, 78 insertions, 178 deletions
diff --git a/autobuild.xml b/autobuild.xml
index 559b898c25..cfd8b9721b 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -2198,76 +2198,6 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>description</key>
<string>OpenAL Soft is a software implementation of the OpenAL 3D audio API.</string>
</map>
- <key>openexr</key>
- <map>
- <key>canonical_repo</key>
- <string>https://github.com/secondlife/3p-openexr</string>
- <key>copyright</key>
- <string>Copyright (c) Contributors to the OpenEXR Project. All rights reserved.</string>
- <key>description</key>
- <string>OpenEXR provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry.</string>
- <key>license</key>
- <string>OpenEXR</string>
- <key>license_file</key>
- <string>LICENSES/openexr.txt</string>
- <key>name</key>
- <string>openexr</string>
- <key>platforms</key>
- <map>
- <key>darwin64</key>
- <map>
- <key>archive</key>
- <map>
- <key>hash</key>
- <string>17cd63922214b588d9a36137fadf927237ec0f25</string>
- <key>hash_algorithm</key>
- <string>sha1</string>
- <key>url</key>
- <string>https://github.com/secondlife/3p-openexr/releases/download/v1.10/openexr-3.2.2-darwin64-df7544d.tar.zst</string>
- </map>
- <key>name</key>
- <string>darwin64</string>
- </map>
- <key>linux64</key>
- <map>
- <key>archive</key>
- <map>
- <key>hash</key>
- <string>b092658ab5ec009a5875e8b6e5b7109730ad6846</string>
- <key>hash_algorithm</key>
- <string>sha1</string>
- <key>url</key>
- <string>https://github.com/secondlife/3p-openexr/releases/download/v1.10/openexr-3.2.2-linux64-df7544d.tar.zst</string>
- </map>
- <key>name</key>
- <string>linux64</string>
- </map>
- <key>windows64</key>
- <map>
- <key>archive</key>
- <map>
- <key>hash</key>
- <string>c511ae9a3e401375af2199b498a75f32cebc010f</string>
- <key>hash_algorithm</key>
- <string>sha1</string>
- <key>url</key>
- <string>https://github.com/secondlife/3p-openexr/releases/download/v1.10/openexr-3.2.2-windows64-df7544d.tar.zst</string>
- </map>
- <key>name</key>
- <string>windows64</string>
- </map>
- </map>
- <key>source_type</key>
- <string>git</string>
- <key>vcs_branch</key>
- <string>debug_autobuild</string>
- <key>vcs_revision</key>
- <string>5cd1075295c17b5f7085e83d5c16b13c7ecb2eb1</string>
- <key>vcs_url</key>
- <string>https://github.com/secondlife/3p-openexr</string>
- <key>version</key>
- <string>3.2.2</string>
- </map>
<key>openjpeg</key>
<map>
<key>platforms</key>
@@ -3084,6 +3014,46 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>description</key>
<string>zlib data compression library for the next generation systems</string>
</map>
+ <key>tinyexr</key>
+ <map>
+ <key>platforms</key>
+ <map>
+ <key>common</key>
+ <map>
+ <key>archive</key>
+ <map>
+ <key>hash</key>
+ <string>9e0092c6a3aed1cb40a9e26df689c42c68142c9d</string>
+ <key>hash_algorithm</key>
+ <string>sha1</string>
+ <key>url</key>
+ <string>https://github.com/secondlife/3p-tinyexr/releases/download/v1.0.8-r1/tinyexr-v1.0.8-common-8755737750.tar.zst</string>
+ </map>
+ <key>name</key>
+ <string>common</string>
+ </map>
+ </map>
+ <key>license</key>
+ <string>3-clause BSD</string>
+ <key>license_file</key>
+ <string>LICENSES/tinyexr_license.txt</string>
+ <key>copyright</key>
+ <string>Copyright (c) 2014 - 2021, Syoyo Fujita and many contributors.</string>
+ <key>version</key>
+ <string>v1.0.8</string>
+ <key>name</key>
+ <string>tinyexr</string>
+ <key>vcs_branch</key>
+ <string>dependabot/github_actions/secondlife/action-autobuild-4</string>
+ <key>vcs_revision</key>
+ <string>4dc4d1d90d82a22843e2adf5130f9ecb5ee5769e</string>
+ <key>vcs_url</key>
+ <string>https://github.com/secondlife/3p-tinyexr</string>
+ <key>description</key>
+ <string>tinyexr import library</string>
+ <key>source_type</key>
+ <string>git</string>
+ </map>
</map>
<key>package_description</key>
<map>
diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt
index 05c51c018d..da7e4be464 100644
--- a/indra/cmake/CMakeLists.txt
+++ b/indra/cmake/CMakeLists.txt
@@ -56,6 +56,8 @@ set(cmake_SOURCE_FILES
PulseAudio.cmake
Python.cmake
TemplateCheck.cmake
+ TinyEXR.cmake
+ TinyGLTF.cmake
Tut.cmake
UI.cmake
UnixInstall.cmake
diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 873253b419..9f79c13a97 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -60,12 +60,6 @@ if(WINDOWS)
nghttp2.dll
libhunspell.dll
uriparser.dll
- Iex-3_2.dll
- IlmThread-3_2.dll
- Imath-3_1.dll
- OpenEXR-3_2.dll
- OpenEXRCore-3_2.dll
- OpenEXRUtil-3_2.dll
)
# ICU4C (same filenames for 32 and 64 bit builds)
diff --git a/indra/cmake/OpenEXR.cmake b/indra/cmake/OpenEXR.cmake
deleted file mode 100644
index ee21fac541..0000000000
--- a/indra/cmake/OpenEXR.cmake
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- cmake -*-
-
-include(Prebuilt)
-
-include_guard()
-add_library( ll::openexr INTERFACE IMPORTED )
-
-if(USE_CONAN )
- target_link_libraries( ll::openexr INTERFACE CONAN_PKG::openexr )
- return()
-endif()
-
-use_prebuilt_binary(openexr)
-
-target_link_libraries( ll::openexr INTERFACE Iex-3_2 IlmThread-3_2 Imath-3_1 OpenEXR-3_2 OpenEXRCore-3_2 OpenEXRUtil-3_2)
-
-target_include_directories( ll::openexr SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/OpenEXR ${LIBS_PREBUILT_DIR}/include/Imath)
-
diff --git a/indra/cmake/TinyEXR.cmake b/indra/cmake/TinyEXR.cmake
new file mode 100644
index 0000000000..e6d142d19d
--- /dev/null
+++ b/indra/cmake/TinyEXR.cmake
@@ -0,0 +1,7 @@
+# -*- cmake -*-
+include(Prebuilt)
+
+use_prebuilt_binary(tinyexr)
+
+set(TINYEXR_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/tinyexr)
+
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 011dccb910..ed617ba70e 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -34,11 +34,11 @@ include(LLWindow)
include(NDOF)
include(NVAPI)
include(OPENAL)
-include(OpenEXR)
include(OpenGL)
include(OpenSSL)
include(PNG)
include(TemplateCheck)
+include(TinyEXR)
include(ThreeJS)
include(Tracy)
include(UI)
@@ -1750,12 +1750,6 @@ if (WINDOWS)
media_plugin_cef
media_plugin_libvlc
media_plugin_example
- ${SHARED_LIB_STAGING_DIR}/Iex-3_2.dll
- ${SHARED_LIB_STAGING_DIR}/IlmThread-3_2.dll
- ${SHARED_LIB_STAGING_DIR}/Imath-3_1.dll
- ${SHARED_LIB_STAGING_DIR}/OpenEXR-3_2.dll
- ${SHARED_LIB_STAGING_DIR}/OpenEXRCore-3_2.dll
- ${SHARED_LIB_STAGING_DIR}/OpenEXRUtil-3_2.dll
)
if (ADDRESS_SIZE EQUAL 64)
@@ -1949,7 +1943,6 @@ target_link_libraries(${VIEWER_BINARY_NAME}
ll::bugsplat
ll::tracy
ll::icu4c
- ll::openexr
)
if( TARGET ll::intel_memops )
diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp
index 3e4992e4e7..5a8f44f5c2 100644
--- a/indra/newview/llreflectionmapmanager.cpp
+++ b/indra/newview/llreflectionmapmanager.cpp
@@ -41,14 +41,17 @@
#include "llviewermenufile.h"
#include "llnotificationsutil.h"
-
-// load an OpenEXR image from a file
-#define IMATH_HALF_NO_LOOKUP_TABLE 1
-#include <ImfInputFile.h>
-#include <ImfArray.h>
-#include <ImfHeader.h>
-#include <ImfFrameBuffer.h>
-#include <iostream>
+#if LL_WINDOWS
+#pragma warning (push)
+#pragma warning (disable : 4702) // compiler complains unreachable code
+#endif
+#define TINYEXR_USE_MINIZ 0
+#include "zlib.h"
+#define TINYEXR_IMPLEMENTATION
+#include "tinyexr/tinyexr.h"
+#if LL_WINDOWS
+#pragma warning (pop)
+#endif
LLPointer<LLImageGL> gEXRImage;
@@ -58,55 +61,14 @@ void load_exr(const std::string& filename)
gPipeline.mReflectionMapManager.reset();
gPipeline.mReflectionMapManager.initReflectionMaps();
- try {
- Imf::InputFile file(filename.c_str());
- Imath::Box2i dw = file.header().dataWindow();
- int width = dw.max.x - dw.min.x + 1;
- int height = dw.max.y - dw.min.y + 1;
-
- Imf::Array2D<Imath::half> rPixels;
- Imf::Array2D<Imath::half> gPixels;
- Imf::Array2D<Imath::half> bPixels;
-
- rPixels.resizeErase(height, width);
- gPixels.resizeErase(height, width);
- bPixels.resizeErase(height, width);
-
- Imf::FrameBuffer frameBuffer;
-
- frameBuffer.insert("R", // name
- Imf::Slice(Imf::HALF, // type
- (char*)(&rPixels[0][0] - // base
- dw.min.x -
- dw.min.y * width),
- sizeof(rPixels[0][0]) * 1, // xStride
- sizeof(rPixels[0][0]) * width, // yStride
- 1, 1, // x/y sampling
- 0.0)); // fillValue
-
- frameBuffer.insert("G", // name
- Imf::Slice(Imf::HALF, // type
- (char*)(&gPixels[0][0] - // base
- dw.min.x -
- dw.min.y * width),
- sizeof(gPixels[0][0]) * 1, // xStride
- sizeof(gPixels[0][0]) * width, // yStride
- 1, 1, // x/y sampling
- 0.0)); // fillValue
-
- frameBuffer.insert("B", // name
- Imf::Slice(Imf::HALF, // type
- (char*)(&bPixels[0][0] - // base
- dw.min.x -
- dw.min.y * width),
- sizeof(bPixels[0][0]) * 1, // xStride
- sizeof(bPixels[0][0]) * width, // yStride
- 1, 1, // x/y sampling
- FLT_MAX)); // fillValue
-
- file.setFrameBuffer(frameBuffer);
- file.readPixels(dw.min.y, dw.max.y);
+ float* out; // width * height * RGBA
+ int width;
+ int height;
+ const char* err = NULL; // or nullptr in C++11
+ int ret = LoadEXRWithLayer(&out, &width, &height, filename.c_str(), /* layername */ nullptr, &err);
+ if (ret == TINYEXR_SUCCESS)
+ {
U32 texName = 0;
LLImageGL::generateTextures(1, &texName);
@@ -117,27 +79,25 @@ void load_exr(const std::string& filename)
gGL.getTexUnit(0)->bind(gEXRImage);
- std::vector<F32> data(width * height * 3);
- for (int i = 0; i < width * height; ++i)
- {
- data[i * 3 + 0] = rPixels[i / width][i % width];
- data[i * 3 + 1] = gPixels[i / width][i % width];
- data[i * 3 + 2] = bPixels[i / width][i % width];
- }
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, width, height, 0, GL_RGBA, GL_FLOAT, out);
+ free(out); // release memory of image data
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, width, height, 0, GL_RGB, GL_FLOAT, data.data());
-
glGenerateMipmap(GL_TEXTURE_2D);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}
- catch (const std::exception& e) {
+ else
+ {
LLSD notif_args;
notif_args["WHAT"] = filename;
- notif_args["REASON"] = e.what();
+ notif_args["REASON"] = "Unknown";
+ if (err)
+ {
+ notif_args["REASON"] = std::string(err);
+ FreeEXRErrorMessage(err); // release memory of error message.
+ }
LLNotificationsUtil::add("CannotLoad", notif_args);
- return;
}
}
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index d51d86aa3c..4de4dc8fc5 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -587,14 +587,6 @@ class Windows_x86_64_Manifest(ViewerManifest):
self.path("libcrypto-1_1-x64.dll")
self.path("libssl-1_1-x64.dll")
- # OpenEXR
- self.path("Iex-3_2.dll")
- self.path("IlmThread-3_2.dll")
- self.path("Imath-3_1.dll")
- self.path("OpenEXR-3_2.dll")
- self.path("OpenEXRCore-3_2.dll")
- self.path("OpenEXRUtil-3_2.dll")
-
# HTTP/2
self.path("nghttp2.dll")