From 3400e5fd302c0d9dea6386c4d5bf38876f2cc287 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 16 May 2022 17:21:08 +0000 Subject: SL-17284 Reflection probe tuning and optimization take 1 --- indra/llrender/llcubemaparray.cpp | 113 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 indra/llrender/llcubemaparray.cpp (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp new file mode 100644 index 0000000000..e4081c1154 --- /dev/null +++ b/indra/llrender/llcubemaparray.cpp @@ -0,0 +1,113 @@ +/** + * @file llcubemaparray.cpp + * @brief LLCubeMap class implementation + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +#include "linden_common.h" + +#include "llworkerthread.h" + +#include "llcubemaparray.h" + +#include "v4coloru.h" +#include "v3math.h" +#include "v3dmath.h" +#include "m3math.h" +#include "m4math.h" + +#include "llrender.h" +#include "llglslshader.h" + +#include "llglheaders.h" + +//#pragma optimize("", off) + +// MUST match order of OpenGL face-layers +GLenum LLCubeMapArray::sTargets[6] = +{ + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB +}; + +LLCubeMapArray::LLCubeMapArray() + : mTextureStage(0) +{ + +} + +LLCubeMapArray::~LLCubeMapArray() +{ +} + +void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count) +{ + U32 texname = 0; + + LLImageGL::generateTextures(1, &texname); + + mImage = new LLImageGL(resolution, resolution, components, TRUE); + mImage->setTexName(texname); + mImage->setTarget(sTargets[0], LLTexUnit::TT_CUBE_MAP_ARRAY); + + mImage->setUseMipMaps(TRUE); + mImage->setHasMipMaps(TRUE); + + bind(0); + + glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY_ARB, 0, GL_RGB, resolution, resolution, count*6, 0, + GL_RGB, GL_UNSIGNED_BYTE, nullptr); + + mImage->setAddressMode(LLTexUnit::TAM_CLAMP); + + mImage->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + + glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY_ARB); + + unbind(); +} + +void LLCubeMapArray::bind(S32 stage) +{ + mTextureStage = stage; + gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_CUBE_MAP_ARRAY, getGLName(), TRUE); +} + +void LLCubeMapArray::unbind() +{ + gGL.getTexUnit(mTextureStage)->unbind(LLTexUnit::TT_CUBE_MAP_ARRAY); + mTextureStage = -1; +} + +GLuint LLCubeMapArray::getGLName() +{ + return mImage->getTexName(); +} + +void LLCubeMapArray::destroyGL() +{ + mImage = NULL; +} -- cgit v1.2.3 From 31e2fa5e50bc5aad265e8ec12613223eeb3ae3e1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Jun 2022 22:44:30 -0500 Subject: SL-17600 WIP -- Proper radiance maps (not just mipped cubemaps). --- indra/llrender/llcubemaparray.cpp | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index e4081c1154..438d92cdba 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -53,6 +53,50 @@ GLenum LLCubeMapArray::sTargets[6] = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB }; +LLVector3 LLCubeMapArray::sLookVecs[6] = +{ + LLVector3(1, 0, 0), + LLVector3(-1, 0, 0), + LLVector3(0, 1, 0), + LLVector3(0, -1, 0), + LLVector3(0, 0, 1), + LLVector3(0, 0, -1) +}; + +LLVector3 LLCubeMapArray::sUpVecs[6] = +{ + LLVector3(0, -1, 0), + LLVector3(0, -1, 0), + LLVector3(0, 0, 1), + LLVector3(0, 0, -1), + LLVector3(0, -1, 0), + LLVector3(0, -1, 0) +}; + +LLVector3 LLCubeMapArray::sClipToCubeLookVecs[6] = +{ + LLVector3(0, 0, -1), //GOOD + LLVector3(0, 0, 1), //GOOD + + LLVector3(1, 0, 0), // GOOD + LLVector3(1, 0, 0), // GOOD + + LLVector3(1, 0, 0), + LLVector3(-1, 0, 0), +}; + +LLVector3 LLCubeMapArray::sClipToCubeUpVecs[6] = +{ + LLVector3(-1, 0, 0), //GOOD + LLVector3(1, 0, 0), //GOOD + + LLVector3(0, 1, 0), // GOOD + LLVector3(0, -1, 0), // GOOD + + LLVector3(0, 0, -1), + LLVector3(0, 0, 1) +}; + LLCubeMapArray::LLCubeMapArray() : mTextureStage(0) { -- cgit v1.2.3 From 2082443220fe344bb027c3acbf50fea0a99159c3 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 1 Sep 2022 10:58:27 -0700 Subject: SL-17967 - Git rid of ARB that is in core --- indra/llrender/llcubemaparray.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index 438d92cdba..08ff7c9414 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -45,12 +45,12 @@ // MUST match order of OpenGL face-layers GLenum LLCubeMapArray::sTargets[6] = { - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB + GL_TEXTURE_CUBE_MAP_POSITIVE_X, + GL_TEXTURE_CUBE_MAP_NEGATIVE_X, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z }; LLVector3 LLCubeMapArray::sLookVecs[6] = @@ -122,14 +122,14 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count) bind(0); - glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY_ARB, 0, GL_RGB, resolution, resolution, count*6, 0, + glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGB, resolution, resolution, count*6, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); mImage->setAddressMode(LLTexUnit::TAM_CLAMP); mImage->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY_ARB); + glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY); unbind(); } -- cgit v1.2.3 From 1eeee12ecb4753cc4b651e18474bb80de45fcede Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 20 Sep 2022 12:28:45 -0500 Subject: SL-18190 Don't allocate mips for irradiance maps because they're never generated. Disable OpenGL core profile on Intel by default. --- indra/llrender/llcubemaparray.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index 08ff7c9414..bb4bd58121 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -107,18 +107,18 @@ LLCubeMapArray::~LLCubeMapArray() { } -void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count) +void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL use_mips) { U32 texname = 0; LLImageGL::generateTextures(1, &texname); - mImage = new LLImageGL(resolution, resolution, components, TRUE); + mImage = new LLImageGL(resolution, resolution, components, use_mips); mImage->setTexName(texname); mImage->setTarget(sTargets[0], LLTexUnit::TT_CUBE_MAP_ARRAY); - mImage->setUseMipMaps(TRUE); - mImage->setHasMipMaps(TRUE); + mImage->setUseMipMaps(use_mips); + mImage->setHasMipMaps(use_mips); bind(0); @@ -127,9 +127,15 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count) mImage->setAddressMode(LLTexUnit::TAM_CLAMP); - mImage->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - - glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY); + if (use_mips) + { + mImage->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY); + } + else + { + mImage->setFilteringOption(LLTexUnit::TFO_BILINEAR); + } unbind(); } @@ -137,7 +143,7 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count) void LLCubeMapArray::bind(S32 stage) { mTextureStage = stage; - gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_CUBE_MAP_ARRAY, getGLName(), TRUE); + gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_CUBE_MAP_ARRAY, getGLName(), mImage->getUseMipMaps()); } void LLCubeMapArray::unbind() -- cgit v1.2.3 From c466e44334fd60c8270b68c70b8ae999b8dbd395 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 20 Sep 2022 19:09:26 -0500 Subject: SL-18190 Reduce banding (stay in linear space as much as possible, increase precision of reflection probes). Faster radiance and irradiance map generation. --- indra/llrender/llcubemaparray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index bb4bd58121..0e452b3d0a 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -122,7 +122,7 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us bind(0); - glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGB, resolution, resolution, count*6, 0, + glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGB10_A2, resolution, resolution, count*6, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); mImage->setAddressMode(LLTexUnit::TAM_CLAMP); -- cgit v1.2.3 From 64cfcea3f4ea6d8120bdf2dedc034f61eb2c07fc Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 23 Sep 2022 18:13:20 -0500 Subject: SL-18190 Reduce banding - experiment with RGB16F reflection probes --- indra/llrender/llcubemaparray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index 0e452b3d0a..abb93093e0 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -122,7 +122,7 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us bind(0); - glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGB10_A2, resolution, resolution, count*6, 0, + glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGB16F, resolution, resolution, count*6, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); mImage->setAddressMode(LLTexUnit::TAM_CLAMP); -- cgit v1.2.3 From 9448db5d4af7bba094e5bc51f85e5c2491d3f5a1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 6 Oct 2022 18:40:01 -0500 Subject: SL-18190 Water shader WIP. Better parallax correction for sphere probes. Reduce probe memory footprint. Remove framebuffer copies and move to deprecate stencil buffer usage. --- indra/llrender/llcubemaparray.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index abb93093e0..a21f7d084e 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -122,7 +122,9 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us bind(0); - glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGB16F, resolution, resolution, count*6, 0, + U32 format = components == 4 ? GL_RGBA12 : GL_RGB10; + + glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, format, resolution, resolution, count*6, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); mImage->setAddressMode(LLTexUnit::TAM_CLAMP); -- cgit v1.2.3 From 29e344bbd0043bb1cd5f1defd6f9a193b0cc728e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 31 Oct 2022 15:19:28 -0500 Subject: SL-18483 Work around for crash on AMD when using glGenerateMipmap on cubemap array. --- indra/llrender/llcubemaparray.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index a21f7d084e..52118172c0 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -123,16 +123,28 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us bind(0); U32 format = components == 4 ? GL_RGBA12 : GL_RGB10; - - glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, format, resolution, resolution, count*6, 0, - GL_RGB, GL_UNSIGNED_BYTE, nullptr); + + U32 mip = 0; + + while (resolution >= 1) + { + glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, format, resolution, resolution, count * 6, 0, + GL_RGBA, GL_UNSIGNED_BYTE, nullptr); + + if (!use_mips) + { + break; + } + resolution /= 2; + ++mip; + } mImage->setAddressMode(LLTexUnit::TAM_CLAMP); if (use_mips) { mImage->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY); + //glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY); // <=== latest AMD drivers do not appreciate this method of allocating mipmaps } else { -- cgit v1.2.3 From bc7856098f70371dd392c74689df267cce819aa7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 2 Mar 2023 16:36:03 -0600 Subject: SL-19281 Unify handling of haze and gamma between fullbright and not and move haze back to sRGB color space to stay consistent with sky colors. Also fix broken "roughness" stuck at 0.2. --- indra/llrender/llcubemaparray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index 52118172c0..ac48a633c7 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -122,7 +122,7 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us bind(0); - U32 format = components == 4 ? GL_RGBA12 : GL_RGB10; + U32 format = components == 4 ? GL_RGBA12 : GL_RGB16F; U32 mip = 0; -- cgit v1.2.3 From 1f79379bf215c5368337c64b4f72c7c9ef3e09c2 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 5 Apr 2023 11:55:51 -0500 Subject: SL-19538 Followup -- tune exposure parameters and clamp local light ambiance. Make render targets 16F and scrube NaNs (thanks Rye). Update midday. (#154) --- indra/llrender/llcubemaparray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index ac48a633c7..7d3a92237b 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -122,7 +122,7 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us bind(0); - U32 format = components == 4 ? GL_RGBA12 : GL_RGB16F; + U32 format = components == 4 ? GL_RGBA16F : GL_RGB16F; U32 mip = 0; -- cgit v1.2.3 From a29f7c3b4ac50951aa86a71cb6ba20b712533c70 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Mon, 23 Oct 2023 13:54:00 -0500 Subject: SL-20498 Preserve default probe when resetting reflection probes. --- indra/llrender/llcubemaparray.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llrender/llcubemaparray.cpp') diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index 7d3a92237b..1debd33953 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -110,6 +110,8 @@ LLCubeMapArray::~LLCubeMapArray() void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL use_mips) { U32 texname = 0; + mWidth = resolution; + mCount = count; LLImageGL::generateTextures(1, &texname); -- cgit v1.2.3