summaryrefslogtreecommitdiff
path: root/indra/newview
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 /indra/newview
parente459698a821d14d7274fa64bcf863b47f29c1607 (diff)
Port from OpenEXR to TinyEXR for reduced installer and library size (#1287)
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/CMakeLists.txt9
-rw-r--r--indra/newview/llreflectionmapmanager.cpp96
-rwxr-xr-xindra/newview/viewer_manifest.py8
3 files changed, 29 insertions, 84 deletions
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")