From b6841d75c2f259c84d5ab6b012bd2ae37d985451 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 15 Apr 2022 19:02:07 -0500 Subject: SL-17219 WIP - Texture pipeline overhaul --- indra/newview/llvovolume.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index f18f6b1116..a0d034850f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -668,12 +668,13 @@ void LLVOVolume::animateTextures() void LLVOVolume::updateTextures() { - const F32 TEXTURE_AREA_REFRESH_TIME = 5.f; // seconds - if (mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + //const F32 TEXTURE_AREA_REFRESH_TIME = 1.f; // seconds + //if (mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) { updateTextureVirtualSize(); - if (mDrawable.notNull() && !isVisible() && !mDrawable->isActive()) + /*if (mDrawable.notNull() && !isVisible() && !mDrawable->isActive()) { //delete vertex buffer to free up some VRAM LLSpatialGroup* group = mDrawable->getSpatialGroup(); if (group && (group->mVertexBuffer.notNull() || !group->mBufferMap.empty() || !group->mDrawMap.empty())) @@ -684,9 +685,7 @@ void LLVOVolume::updateTextures() //it becomes visible group->setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); } - } - - + }*/ } } @@ -760,6 +759,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) const S32 num_faces = mDrawable->getNumFaces(); F32 min_vsize=999999999.f, max_vsize=0.f; LLViewerCamera* camera = LLViewerCamera::getInstance(); + std::stringstream debug_text; for (S32 i = 0; i < num_faces; i++) { LLFace* face = mDrawable->getFace(i); @@ -786,10 +786,14 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) else { vsize = face->getTextureVirtualSize(); + imagep->addTextureStats(vsize); } - mPixelArea = llmax(mPixelArea, face->getPixelArea()); + mPixelArea = llmax(mPixelArea, face->getPixelArea()); + // if the face has gotten small enough to turn off texture animation and texture + // animation is running, rebuild the render batch for this face to turn off + // texture animation if (face->mTextureMatrix != NULL) { if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) || @@ -809,10 +813,11 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) LLViewerFetchedTexture* img = LLViewerTextureManager::staticCastToFetchedTexture(imagep) ; if(img) { - F32 pri = img->getDecodePriority(); + debug_text << img->getDiscardLevel() << ":" << img->getDesiredDiscardLevel() << ":" << img->getWidth() << ":" << (S32) sqrtf(vsize) << ":" << (S32) sqrtf(img->getMaxVirtualSize()) << "\n"; + /*F32 pri = img->getDecodePriority(); pri = llmax(pri, 0.0f); if (pri < min_vsize) min_vsize = pri; - if (pri > max_vsize) max_vsize = pri; + if (pri > max_vsize) max_vsize = pri;*/ } } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_FACE_AREA)) @@ -844,14 +849,6 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) F32 lodf = ((F32)(lod + 1.0f)/4.f); F32 tex_size = lodf * LLViewerTexture::sMaxSculptRez ; mSculptTexture->addTextureStats(2.f * tex_size * tex_size, FALSE); - - //if the sculpty very close to the view point, load first - { - LLVector3 lookAt = getPositionAgent() - camera->getOrigin(); - F32 dist = lookAt.normVec() ; - F32 cos_angle_to_view_dir = lookAt * camera->getXAxis() ; - mSculptTexture->setAdditionalDecodePriority(0.8f * LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist)) ; - } } S32 texture_discard = mSculptTexture->getCachedRawImageLevel(); //try to match the texture @@ -895,7 +892,8 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) { - setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize))); + //setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize))); + setDebugText(debug_text.str()); } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_FACE_AREA)) { -- cgit v1.3 From 54919fa7495910e6f7877228a0458736024dcdc4 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 2 May 2022 10:05:13 -0700 Subject: SL-17274: Stub for PBR DrawPool and shader --- indra/newview/CMakeLists.txt | 2 + .../shaders/class1/deferred/pbropaqueF.glsl | 52 ++++++++++++ .../shaders/class1/deferred/pbropaqueV.glsl | 52 ++++++++++++ indra/newview/lldrawpool.cpp | 4 + indra/newview/lldrawpool.h | 1 + indra/newview/lldrawpoolpbropaque.cpp | 92 ++++++++++++++++++++++ indra/newview/lldrawpoolpbropaque.h | 59 ++++++++++++++ indra/newview/llviewershadermgr.cpp | 20 +++++ indra/newview/llviewershadermgr.h | 2 + indra/newview/llvovolume.cpp | 14 ++++ indra/newview/pipeline.cpp | 22 ++++++ indra/newview/pipeline.h | 1 + 12 files changed, 321 insertions(+) create mode 100644 indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl create mode 100644 indra/newview/lldrawpoolpbropaque.cpp create mode 100644 indra/newview/lldrawpoolpbropaque.h (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5e50f58595..978c76285a 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -187,6 +187,7 @@ set(viewer_SOURCE_FILES lldrawpoolbump.cpp lldrawpoolground.cpp lldrawpoolmaterials.cpp + lldrawpoolpbropaque.cpp lldrawpoolsimple.cpp lldrawpoolsky.cpp lldrawpoolterrain.cpp @@ -823,6 +824,7 @@ set(viewer_HEADER_FILES lldrawpoolavatar.h lldrawpoolbump.h lldrawpoolmaterials.h + lldrawpoolpbropaque.h lldrawpoolground.h lldrawpoolsimple.h lldrawpoolsky.h diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl new file mode 100644 index 0000000000..4da64ed5ee --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -0,0 +1,52 @@ +/** + * @file pbropaqueF.glsl + * + * $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$ + */ + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +VARYING vec3 vary_normal; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +vec2 encode_normal(vec3 n); +vec3 linear_to_srgb(vec3 c); + +void main() +{ + vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; + + vec3 spec; + spec.rgb = vec3(vertex_color.a); +col.rgb = vec3( 1, 0, 1 ); // DEBUG + frag_data[0] = vec4(col, 0.0); + frag_data[1] = vec4(spec, vertex_color.a); // spec + vec3 nvn = normalize(vary_normal); + frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl new file mode 100644 index 0000000000..7c52b77711 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -0,0 +1,52 @@ +/** + * @file pbropaqueV.glsl + * + * $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$ + */ + +uniform mat3 normal_matrix; +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec3 normal; +ATTRIBUTE vec2 texcoord0; + +VARYING vec3 vary_normal; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void passTextureIndex(); + +void main() +{ + //transform vertex + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + + passTextureIndex(); + vary_normal = normalize(normal_matrix * normal); + + vertex_color = diffuse_color; +} diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index a3837fe10c..1e548141c8 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -37,6 +37,7 @@ #include "lldrawpoolbump.h" #include "lldrawpoolmaterials.h" #include "lldrawpoolground.h" +#include "lldrawpoolpbropaque.h" #include "lldrawpoolsimple.h" #include "lldrawpoolsky.h" #include "lldrawpooltree.h" @@ -117,6 +118,9 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerTexture *tex0) case POOL_WL_SKY: poolp = new LLDrawPoolWLSky(); break; + case POOL_PBR_OPAQUE: + poolp = new LLDrawPoolPBROpaque(); + break; default: LL_ERRS() << "Unknown draw pool type!" << LL_ENDL; return NULL; diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index fd1b022e5b..b73ae94bbb 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -67,6 +67,7 @@ public: POOL_WATER, POOL_GLOW, POOL_ALPHA, + POOL_PBR_OPAQUE, NUM_POOL_TYPES, // * invisiprims work by rendering to the depth buffer but not the color buffer, occluding anything rendered after them // - and the LLDrawPool types enum controls what order things are rendered in diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp new file mode 100644 index 0000000000..64850424f4 --- /dev/null +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -0,0 +1,92 @@ +/** + * @file lldrawpoolpbropaque.cpp + * @brief LLDrawPoolPBROpaque 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 "llviewerprecompiledheaders.h" + +#include "lldrawpool.h" +#include "lldrawpoolpbropaque.h" +#include "llviewershadermgr.h" +#include "pipeline.h" + +LLDrawPoolPBROpaque::LLDrawPoolPBROpaque() : + LLRenderPass(POOL_PBR_OPAQUE) +{ +} + +void LLDrawPoolPBROpaque::prerender() +{ + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); +} + +// Forward +void LLDrawPoolPBROpaque::beginRenderPass(S32 pass) +{ +} + +void LLDrawPoolPBROpaque::endRenderPass( S32 pass ) +{ +} + +void LLDrawPoolPBROpaque::render(S32 pass) +{ +} + +// Deferred +void LLDrawPoolPBROpaque::beginDeferredPass(S32 pass) +{ + gDeferredPBROpaqueProgram.bind(); +} + +void LLDrawPoolPBROpaque::endDeferredPass(S32 pass) +{ + gDeferredPBROpaqueProgram.unbind(); + LLRenderPass::endRenderPass(pass); +} + +void LLDrawPoolPBROpaque::renderDeferred(S32 pass) +{ + if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_MATERIALS)) + { + return; + } + + gGL.flush(); + + LLGLDisable blend(GL_BLEND); + LLGLDisable alpha_test(GL_ALPHA_TEST); + + // TODO: handle HUDs? + //if (LLPipeline::sRenderingHUDs) + // mShader->uniform1i(LLShaderMgr::NO_ATMO, 1); + //else + // mShader->uniform1i(LLShaderMgr::NO_ATMO, 0); + + // TODO: handle under water? + // if (LLPipeline::sUnderWaterRender) + // PASS_SIMPLE or PASS_MATERIAL + pushBatches(LLRenderPass::PASS_SIMPLE, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); +} + diff --git a/indra/newview/lldrawpoolpbropaque.h b/indra/newview/lldrawpoolpbropaque.h new file mode 100644 index 0000000000..735a84ec1d --- /dev/null +++ b/indra/newview/lldrawpoolpbropaque.h @@ -0,0 +1,59 @@ +/** + * @file lldrawpoolpbropaque.h + * @brief LLDrawPoolPBrOpaque class definition + * + * $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$ + */ + +#ifndef LL_LLDRAWPOOLPBROPAQUE_H +#define LL_LLDRAWPOOLPBROPAQUE_H + +#include "lldrawpool.h" + +class LLDrawPoolPBROpaque : public LLRenderPass +{ +public: + enum + { + VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX + | LLVertexBuffer::MAP_NORMAL + | LLVertexBuffer::MAP_TEXCOORD0 + }; + virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } + + LLDrawPoolPBROpaque(); + + /*virtual*/ S32 getNumDeferredPasses() { return 1; } + /*virtual*/ void beginDeferredPass(S32 pass); + /*virtual*/ void endDeferredPass(S32 pass); + /*virtual*/ void renderDeferred(S32 pass); + + // Non ALM isn't supported + /*virtual*/ void beginRenderPass(S32 pass); + /*virtual*/ void endRenderPass(S32 pass); + /*virtual*/ S32 getNumPasses() { return 0; } + /*virtual*/ void render(S32 pass = 0); + /*virtual*/ void prerender(); + +}; + +#endif // LL_LLDRAWPOOLPBROPAQUE_H diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 1cb2c6b9ee..50a0ff07fc 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -258,6 +258,7 @@ LLGLSLShader gNormalMapGenProgram; // Deferred materials shaders LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; +LLGLSLShader gDeferredPBROpaqueProgram; //helper for making a rigged variant of a given shader bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader) @@ -1300,6 +1301,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialProgram[i].unload(); gDeferredMaterialWaterProgram[i].unload(); } + + gDeferredPBROpaqueProgram.unload(); + return TRUE; } @@ -1584,6 +1588,22 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredMaterialWaterProgram[i].createShader(NULL, NULL);//&mWLUniforms); llassert(success); } + + if (success) + { + gDeferredPBROpaqueProgram.mName = "Deferred PBR Opaque Shader"; + gDeferredPBROpaqueProgram.mFeatures.encodesNormal = true; + gDeferredPBROpaqueProgram.mFeatures.hasSrgb = true; + + gDeferredPBROpaqueProgram.mShaderFiles.clear(); + gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredPBROpaqueProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + gDeferredPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + //gDeferredPBROpaqueProgram.addPermutation("HAS_NORMAL_MAP", "1"); + success = gDeferredPBROpaqueProgram.createShader(NULL, NULL); + llassert(success); + } } gDeferredMaterialProgram[1].mFeatures.hasLighting = true; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 93bb29a355..50a3daebaa 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -313,4 +313,6 @@ extern LLGLSLShader gNormalMapGenProgram; // Deferred materials shaders extern LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; extern LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; + +extern LLGLSLShader gDeferredPBROpaqueProgram; #endif diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 126a25115d..17d92fda38 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5674,6 +5674,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } +#if LL_RELEASE_WITH_DEBUG_INFO + const LLUUID pbr_id( "49c88210-7238-2a6b-70ac-92d4f35963cf" ); + const LLUUID obj_id( vobj->getID() ); + bool is_pbr = (obj_id == pbr_id); +#else + bool is_pbr = false; +#endif + //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group facep->setVertexBuffer(NULL); @@ -5739,6 +5747,12 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) BOOL force_simple = (facep->getPixelArea() < FORCE_SIMPLE_RENDER_AREA); U32 type = gPipeline.getPoolTypeFromTE(te, tex); + + if (is_pbr) + { + type = LLDrawPool::POOL_PBR_OPAQUE; + } + else if (type != LLDrawPool::POOL_ALPHA && force_simple) { type = LLDrawPool::POOL_SIMPLE; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ac7276e1e0..eaf28e9f4f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -462,6 +462,7 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_BUMP); getPool(LLDrawPool::POOL_MATERIALS); getPool(LLDrawPool::POOL_GLOW); + getPool(LLDrawPool::POOL_PBR_OPAQUE); resetFrameStats(); @@ -1597,6 +1598,10 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) poolp = mWLSkyPool; break; + case LLDrawPool::POOL_PBR_OPAQUE: + poolp = mPBROpaquePool; + break; + default: llassert(0); LL_ERRS() << "Invalid Pool Type in LLPipeline::findPool() type=" << type << LL_ENDL; @@ -5698,6 +5703,18 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; + case LLDrawPool::POOL_PBR_OPAQUE: + if( mPBROpaquePool ) + { + llassert(0); + LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate PBR Opaque Pool" << LL_ENDL; + } + else + { + mPBROpaquePool = new_poolp; + } + break; + default: llassert(0); LL_WARNS() << "Invalid Pool Type in LLPipeline::addPool()" << LL_ENDL; @@ -5814,6 +5831,11 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mGroundPool = NULL; break; + case LLDrawPool::POOL_PBR_OPAQUE: + llassert( poolp == mPBROpaquePool ); + mPBROpaquePool = NULL; + break; + default: llassert(0); LL_WARNS() << "Invalid Pool Type in LLPipeline::removeFromQuickLookup() type=" << poolp->getType() << LL_ENDL; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 150d3c7d58..c4f0c01182 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -864,6 +864,7 @@ protected: LLDrawPool* mBumpPool; LLDrawPool* mMaterialsPool; LLDrawPool* mWLSkyPool; + LLDrawPool* mPBROpaquePool; // Note: no need to keep an quick-lookup to avatar pools, since there's only one per avatar public: -- cgit v1.3 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 --- autobuild.xml | 4 +- indra/llrender/CMakeLists.txt | 2 + indra/llrender/llcubemap.cpp | 10 +- indra/llrender/llcubemaparray.cpp | 113 +++++ indra/llrender/llcubemaparray.h | 60 +++ indra/llrender/llgl.cpp | 33 +- indra/llrender/llgl.h | 1 + indra/llrender/llglheaders.h | 9 + indra/llrender/llglslshader.cpp | 61 ++- indra/llrender/llglslshader.h | 3 + indra/llrender/llimagegl.cpp | 51 +- indra/llrender/llrender.cpp | 4 + indra/llrender/llrender.h | 3 +- indra/llrender/llshadermgr.cpp | 13 +- indra/llrender/llshadermgr.h | 2 +- indra/newview/app_settings/settings.xml | 11 + .../shaders/class1/deferred/aoUtil.glsl | 14 +- .../shaders/class1/deferred/blurLightF.glsl | 29 +- .../shaders/class1/interface/reflectionmipF.glsl | 75 +++ .../shaders/class2/deferred/softenLightF.glsl | 274 +++++++++-- indra/newview/llagentcamera.cpp | 6 + indra/newview/lldrawpoolalpha.cpp | 4 +- indra/newview/lldrawpoolbump.cpp | 1 + indra/newview/lldrawpoolpbropaque.cpp | 2 +- indra/newview/llreflectionmap.cpp | 171 ++++++- indra/newview/llreflectionmap.h | 51 +- indra/newview/llreflectionmapmanager.cpp | 516 ++++++++++++++++++++- indra/newview/llreflectionmapmanager.h | 77 ++- indra/newview/llspatialpartition.cpp | 117 ++++- indra/newview/llspatialpartition.h | 19 + indra/newview/llviewerdisplay.cpp | 121 ++++- indra/newview/llviewermenu.cpp | 10 +- indra/newview/llviewershadermgr.cpp | 20 +- indra/newview/llviewershadermgr.h | 1 + indra/newview/llviewerwindow.cpp | 99 ++-- indra/newview/llviewerwindow.h | 6 +- indra/newview/llvovolume.cpp | 10 +- indra/newview/llworld.cpp | 3 +- indra/newview/pipeline.cpp | 505 ++++++++++---------- indra/newview/pipeline.h | 3 +- indra/newview/skins/default/xui/en/menu_viewer.xml | 16 +- 41 files changed, 2062 insertions(+), 468 deletions(-) create mode 100644 indra/llrender/llcubemaparray.cpp create mode 100644 indra/llrender/llcubemaparray.h create mode 100644 indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl (limited to 'indra/newview/llvovolume.cpp') diff --git a/autobuild.xml b/autobuild.xml index 9185b8af22..fa3f7b2743 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -1010,9 +1010,9 @@ archive hash - 1bd3214ac23474ea4c869e386970a1be + c5e9a59c7cf03c88a5cb4ab0a9c21091 url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/54835/510029/glext-68-darwin64-538965.tar.bz2 + https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/99835/880141/glext-68-darwin64-571812.tar.bz2 name darwin64 diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt index baab09a104..a30f47f1d9 100644 --- a/indra/llrender/CMakeLists.txt +++ b/indra/llrender/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories(SYSTEM set(llrender_SOURCE_FILES llatmosphere.cpp llcubemap.cpp + llcubemaparray.cpp llfontbitmapcache.cpp llfontfreetype.cpp llfontgl.cpp @@ -58,6 +59,7 @@ set(llrender_HEADER_FILES llatmosphere.h llcubemap.h + llcubemaparray.h llfontgl.h llfontfreetype.h llfontbitmapcache.h diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp index 6d872d0763..473447ad72 100644 --- a/indra/llrender/llcubemap.cpp +++ b/indra/llrender/llcubemap.cpp @@ -219,13 +219,17 @@ void LLCubeMap::initEnvironmentMap(const std::vector >& ra void LLCubeMap::generateMipMaps() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + mImages[0]->setUseMipMaps(TRUE); mImages[0]->setHasMipMaps(TRUE); enableTexture(0); bind(); - mImages[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - glGenerateMipmap(GL_TEXTURE_CUBE_MAP); + mImages[0]->setFilteringOption(LLTexUnit::TFO_BILINEAR); + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("cmgmm - glGenerateMipmap"); + glGenerateMipmap(GL_TEXTURE_CUBE_MAP); + } gGL.getTexUnit(0)->disable(); disable(); } 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; +} diff --git a/indra/llrender/llcubemaparray.h b/indra/llrender/llcubemaparray.h new file mode 100644 index 0000000000..52e21f1dda --- /dev/null +++ b/indra/llrender/llcubemaparray.h @@ -0,0 +1,60 @@ +/** + * @file llcubemaparray.h + * @brief LLCubeMap class definition + * + * $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$ + */ + +#pragma once + +#include "llgl.h" + +#include + +class LLVector3; + +// Environment map hack! +class LLCubeMapArray : public LLRefCount +{ +public: + LLCubeMapArray(); + + static GLenum sTargets[6]; + + // allocate a cube map array + // res - resolution of each cube face + // components - number of components per pixel + // count - number of cube maps in the array + void allocate(U32 res, U32 components, U32 count); + void bind(S32 stage); + void unbind(); + + GLuint getGLName(); + + void destroyGL(); + +protected: + friend class LLTexUnit; + ~LLCubeMapArray(); + LLPointer mImage; + S32 mTextureStage; +}; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 639d1fba32..6023796f7c 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -89,9 +89,10 @@ void APIENTRY gl_debug_callback(GLenum source, if (gGLDebugLoggingEnabled) { - if (severity != GL_DEBUG_SEVERITY_HIGH_ARB && - severity != GL_DEBUG_SEVERITY_MEDIUM_ARB && - severity != GL_DEBUG_SEVERITY_LOW_ARB) + if (severity != GL_DEBUG_SEVERITY_HIGH_ARB // && + //severity != GL_DEBUG_SEVERITY_MEDIUM_ARB && + //severity != GL_DEBUG_SEVERITY_LOW_ARB + ) { //suppress out-of-spec messages sent by nvidia driver (mostly vertexbuffer hints) return; } @@ -316,6 +317,15 @@ PFNGLGETUNIFORMIVARBPROC glGetUniformivARB = NULL; PFNGLGETSHADERSOURCEARBPROC glGetShaderSourceARB = NULL; PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL; +// GL_ARB_uniform_buffer_object +PFNGLGETUNIFORMINDICESPROC glGetUniformIndices = NULL; +PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv = NULL; +PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName = NULL; +PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex = NULL; +PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv = NULL; +PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName = NULL; +PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding = NULL; + #if LL_WINDOWS PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; #endif @@ -436,6 +446,7 @@ LLGLManager::LLGLManager() : mHasTextureRectangle(FALSE), mHasTextureMultisample(FALSE), mHasTransformFeedback(FALSE), + mHasUniformBufferObject(FALSE), mMaxSampleMaskWords(0), mMaxColorTextureSamples(0), mMaxDepthTextureSamples(0), @@ -1054,6 +1065,7 @@ void LLGLManager::initExtensions() mHasTextureMultisample = ExtensionExists("GL_ARB_texture_multisample", gGLHExts.mSysExts); mHasDebugOutput = ExtensionExists("GL_ARB_debug_output", gGLHExts.mSysExts); mHasTransformFeedback = mGLVersion >= 4.f ? TRUE : FALSE; + mHasUniformBufferObject = ExtensionExists("GL_ARB_uniform_buffer_object", gGLHExts.mSysExts); #if !LL_DARWIN mHasPointParameters = ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts); #endif @@ -1286,6 +1298,10 @@ void LLGLManager::initExtensions() mGLMaxVertexRange = 0; mGLMaxIndexRange = 0; } + + // same with glTexImage3D et al + glTexImage3D = (PFNGLTEXIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glTexImage3D"); + glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glCopyTexSubImage3D"); #endif // !LL_LINUX || LL_LINUX_NV_GL_HEADERS #if LL_LINUX_NV_GL_HEADERS // nvidia headers are critically different from mesa-esque @@ -1319,6 +1335,17 @@ void LLGLManager::initExtensions() glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfvARB"); } + if (mHasUniformBufferObject) + { + glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformIndices"); + glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformIndices"); + glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformName"); + glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformBlockIndex"); + glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformBlockiv"); + glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformBlockName"); + glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)GLH_EXT_GET_PROC_ADDRESS("glUniformBlockBinding"); + } + // Assume shader capabilities glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteObjectARB"); glGetHandleARB = (PFNGLGETHANDLEARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetHandleARB"); diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 52338364e6..eea53ed01e 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -104,6 +104,7 @@ public: BOOL mHasTextureRectangle; BOOL mHasTextureMultisample; BOOL mHasTransformFeedback; + BOOL mHasUniformBufferObject; S32 mMaxSampleMaskWords; S32 mMaxColorTextureSamples; S32 mMaxDepthTextureSamples; diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 3d93cc0762..aa429505c1 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -564,6 +564,15 @@ extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB; extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB; +// GL_ARB_uniform_buffer_object +extern PFNGLGETUNIFORMINDICESPROC glGetUniformIndices; +extern PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv; +extern PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName; +extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; +extern PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv; +extern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName; +extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; + #elif LL_DARWIN //---------------------------------------------------------------------------- // LL_DARWIN diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index a52dcd5aa1..0212c605c3 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -780,7 +780,8 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type, GLint LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; if ((type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB) || - type == GL_SAMPLER_2D_MULTISAMPLE) + type == GL_SAMPLER_2D_MULTISAMPLE || + type == GL_SAMPLER_CUBE_MAP_ARRAY_ARB) { //this here is a texture GLint ret = mActiveTextureChannels; if (size == 1) @@ -1289,6 +1290,30 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) } } +void LLGLSLShader::uniform4iv(U32 index, U32 count, const GLint* v) +{ + if (mProgramObject) + { + if (mUniform.size() <= index) + { + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; + return; + } + + if (mUniform[index] >= 0) + { + const auto& iter = mValue.find(mUniform[index]); + LLVector4 vec(v[0], v[1], v[2], v[3]); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + glUniform1ivARB(mUniform[index], count, v); + mValue[mUniform[index]] = vec; + } + } + } +} + + void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject) @@ -1526,6 +1551,40 @@ void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v) } } +void LLGLSLShader::uniform1iv(const LLStaticHashedString& uniform, U32 count, const GLint* v) +{ + GLint location = getUniformLocation(uniform); + + if (location >= 0) + { + LLVector4 vec(v[0], 0, 0, 0); + const auto& iter = mValue.find(location); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; + glUniform1ivARB(location, count, v); + mValue[location] = vec; + } + } +} + +void LLGLSLShader::uniform4iv(const LLStaticHashedString& uniform, U32 count, const GLint* v) +{ + GLint location = getUniformLocation(uniform); + + if (location >= 0) + { + LLVector4 vec(v[0], v[1], v[2], v[3]); + const auto& iter = mValue.find(location); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; + glUniform4ivARB(location, count, v); + mValue[location] = vec; + } + } +} + void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j) { GLint location = getUniformLocation(uniform); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 7d6b341d3d..fe0aaae467 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -178,6 +178,7 @@ public: void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z); void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void uniform1iv(U32 index, U32 count, const GLint* i); + void uniform4iv(U32 index, U32 count, const GLint* i); void uniform1fv(U32 index, U32 count, const GLfloat* v); void uniform2fv(U32 index, U32 count, const GLfloat* v); void uniform3fv(U32 index, U32 count, const GLfloat* v); @@ -188,6 +189,8 @@ public: void uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); void uniform1i(const LLStaticHashedString& uniform, GLint i); + void uniform1iv(const LLStaticHashedString& uniform, U32 count, const GLint* v); + void uniform4iv(const LLStaticHashedString& uniform, U32 count, const GLint* v); void uniform1f(const LLStaticHashedString& uniform, GLfloat v); void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y); void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z); diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 9bd3a0a6b0..f2da859e23 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1688,26 +1688,38 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) LL_PROFILE_ZONE_NAMED("cglt - sync"); if (gGLManager.mHasSync) { - // post a sync to the main thread (will execute before tex name swap lambda below) - // glFlush calls here are partly superstitious and partly backed by observation - // on AMD hardware - glFlush(); - auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - glFlush(); - LL::WorkQueue::postMaybe( - mMainQueue, - [=]() - { - LL_PROFILE_ZONE_NAMED("cglt - wait sync"); - { - LL_PROFILE_ZONE_NAMED("glWaitSync"); - glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); - } + if (gGLManager.mIsNVIDIA) + { + // wait for texture upload to finish before notifying main thread + // upload is complete + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + glClientWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + glDeleteSync(sync); + } + else + { + // post a sync to the main thread (will execute before tex name swap lambda below) + // glFlush calls here are partly superstitious and partly backed by observation + // on AMD hardware + glFlush(); + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + LL::WorkQueue::postMaybe( + mMainQueue, + [=]() { - LL_PROFILE_ZONE_NAMED("glDeleteSync"); - glDeleteSync(sync); - } - }); + LL_PROFILE_ZONE_NAMED("cglt - wait sync"); + { + LL_PROFILE_ZONE_NAMED("glWaitSync"); + glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + } + { + LL_PROFILE_ZONE_NAMED("glDeleteSync"); + glDeleteSync(sync); + } + }); + } } else { @@ -1726,6 +1738,7 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) }); } + void LLImageGL::syncTexName(LLGLuint texname) { if (texname != 0) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index a03a27cf94..3adb47f493 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -71,6 +71,7 @@ static const GLenum sGLTextureType[] = GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_CUBE_MAP_ARRAY_ARB, GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_3D }; @@ -888,6 +889,9 @@ void LLRender::init() glCullFace(GL_BACK); + // necessary for reflection maps + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) { //bind a dummy vertex array object so we're core profile compliant #ifdef GL_ARB_vertex_array_object diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index e2489876e4..095ed400f4 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -52,7 +52,7 @@ class LLTexture ; #define LL_MATRIX_STACK_DEPTH 32 -class LLTexUnit +class LLTexUnit { friend class LLRender; public: @@ -63,6 +63,7 @@ public: TT_TEXTURE = 0, // Standard 2D Texture TT_RECT_TEXTURE, // Non power of 2 texture TT_CUBE_MAP, // 6-sided cube map texture + TT_CUBE_MAP_ARRAY, // Array of cube maps TT_MULTISAMPLE_TEXTURE, // see GL_ARB_texture_multisample TT_TEXTURE_3D, // standard 3D Texture TT_NONE, // No texture type is currently enabled diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index cd7ec478bb..8e8f44e99b 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -712,8 +712,15 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade { if (major_version >= 4) { - //set version to 400 - shader_code_text[shader_code_count++] = strdup("#version 400\n"); + //set version to 400 or 420 + if (minor_version >= 20) + { + shader_code_text[shader_code_count++] = strdup("#version 420\n"); + } + else + { + shader_code_text[shader_code_count++] = strdup("#version 400\n"); + } } else if (major_version == 3) { @@ -1155,7 +1162,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("bumpMap"); mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); - mReservedUniforms.push_back("reflectionMap"); + mReservedUniforms.push_back("reflectionProbes"); mReservedUniforms.push_back("cloud_noise_texture"); mReservedUniforms.push_back("cloud_noise_texture_next"); mReservedUniforms.push_back("fullbright"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 7ca4862ed9..663ba28b6d 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -80,7 +80,7 @@ public: BUMP_MAP, // "bumpMap" BUMP_MAP2, // "bumpMap2" ENVIRONMENT_MAP, // "environmentMap" - REFLECTION_MAP, // "reflectionMap" + REFLECTION_PROBES, // "reflectionProbes" CLOUD_NOISE_MAP, // "cloud_noise_texture" CLOUD_NOISE_MAP_NEXT, // "cloud_noise_texture_next" FULLBRIGHT, // "fullbright" diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 20b708fe99..284b779be3 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10269,6 +10269,17 @@ 2 + RenderReflectionProbeDrawDistance + + Comment + Camera far clip to use when updating reflection probes. + Persist + 1 + Type + F32 + Value + 64 + RenderReflectionRes Comment diff --git a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl index 23adbded5e..73c125bbdc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl @@ -29,8 +29,6 @@ uniform sampler2DRect depthMap; uniform float ssao_radius; uniform float ssao_max_radius; -uniform float ssao_factor; -uniform float ssao_factor_inv; uniform mat4 inv_proj; uniform vec2 screen_res; @@ -83,14 +81,14 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen) { float ret = 1.0; vec3 pos_world = pos.xyz; - vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy/128.0).xy; + float angle_hidden = 0.0; float points = 0; - float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); - // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?) + float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); + vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy/128.0).xy; for (int i = 0; i < 8; i++) { vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect); @@ -105,14 +103,14 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen) //(k should vary inversely with # of samples, but this is taken care of later) float funky_val = (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) ? 1.0 : 0.0; - angle_hidden = angle_hidden + funky_val * min(1.0/dist2, ssao_factor_inv); + angle_hidden = angle_hidden + funky_val * min(1.0/dist2, 1.0); // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" float diffz_val = (diff.z > -1.0) ? 1.0 : 0.0; points = points + diffz_val; } - - angle_hidden = min(ssao_factor*angle_hidden/points, 1.0); + + angle_hidden = min(angle_hidden/points, 1.0); float points_val = (points > 0.0) ? 1.0 : 0.0; ret = (1.0 - (points_val * angle_hidden)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl index 596d0274af..fa3634f3b6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl @@ -69,36 +69,47 @@ void main() tc_mod *= 2.0; tc += ( (tc_mod - 0.5) * kern[1].z * dlt * 0.5 ); - for (int i = 1; i < 4; i++) + // TODO: move this to kern instead of building kernel per pixel + vec3 k[7]; + k[0] = kern[0]; + k[2] = kern[1]; + k[4] = kern[2]; + k[6] = kern[3]; + + k[1] = (k[0]+k[2])*0.5f; + k[3] = (k[2]+k[4])*0.5f; + k[5] = (k[4]+k[6])*0.5f; + + for (int i = 1; i < 7; i++) { - vec2 samptc = tc + kern[i].z*dlt; + vec2 samptc = tc + k[i].z*dlt*2.0; vec3 samppos = getPosition(samptc).xyz; float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane if (d*d <= pointplanedist_tolerance_pow2) { - col += texture2DRect(lightMap, samptc)*kern[i].xyxx; - defined_weight += kern[i].xy; + col += texture2DRect(lightMap, samptc)*k[i].xyxx; + defined_weight += k[i].xy; } } - for (int i = 1; i < 4; i++) + for (int i = 1; i < 7; i++) { - vec2 samptc = tc - kern[i].z*dlt; + vec2 samptc = tc - k[i].z*dlt*2.0; vec3 samppos = getPosition(samptc).xyz; float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane if (d*d <= pointplanedist_tolerance_pow2) { - col += texture2DRect(lightMap, samptc)*kern[i].xyxx; - defined_weight += kern[i].xy; + col += texture2DRect(lightMap, samptc)*k[i].xyxx; + defined_weight += k[i].xy; } } col /= defined_weight.xyxx; - col.y *= col.y; + //col.y *= max(col.y, 0.75); frag_color = col; diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl new file mode 100644 index 0000000000..ea687aab4f --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -0,0 +1,75 @@ +/** + * @file reflectionmipF.glsl + * + * $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$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect screenMap; + +VARYING vec2 vary_texcoord0; + +void main() +{ + float w[9]; + + float c = 1.0/16.0; //corner weight + float e = 1.0/8.0; //edge weight + float m = 1.0/4.0; //middle weight + + //float wsum = c*4+e*4+m; + + w[0] = c; w[1] = e; w[2] = c; + w[3] = e; w[4] = m; w[5] = e; + w[6] = c; w[7] = e; w[8] = c; + + vec2 tc[9]; + + float ed = 1; + float cd = 1; + + + tc[0] = vec2(-cd, cd); tc[1] = vec2(0, ed); tc[2] = vec2(cd, cd); + tc[3] = vec2(-ed, 0); tc[4] = vec2(0, 0); tc[5] = vec2(ed, 0); + tc[6] = vec2(-cd, -cd); tc[7] = vec2(0, -ed); tc[8] = vec2(cd, -1); + + vec3 color = vec3(0,0,0); + + for (int i = 0; i < 9; ++i) + { + color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]).rgb * w[i]; + //color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]*2.0).rgb * w[i]*0.5; + } + + //color /= wsum; + + frag_color = vec4(color, 1.0); +} diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 5bb64e18a7..3a1287e910 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -26,9 +26,10 @@ #extension GL_ARB_texture_rectangle : enable #extension GL_ARB_shader_texture_lod : enable -/*[EXTRA_CODE_HERE]*/ +#define FLT_MAX 3.402823466e+38 -#define REFMAP_COUNT 8 +#define REFMAP_COUNT 256 +#define REF_SAMPLE_COUNT 64 //maximum number of samples to consider #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; @@ -42,12 +43,26 @@ uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; uniform samplerCube environmentMap; -uniform samplerCube reflectionMap[REFMAP_COUNT]; +uniform samplerCubeArray reflectionProbes; uniform sampler2D lightFunc; -uniform int refmapCount; - -uniform vec3 refOrigin[REFMAP_COUNT]; +layout (std140, binding = 1) uniform ReflectionProbes +{ + // list of sphere based reflection probes sorted by distance to camera (closest first) + vec4 refSphere[REFMAP_COUNT]; + // index of cube map in reflectionProbes for a corresponding reflection probe + // e.g. cube map channel of refSphere[2] is stored in refIndex[2] + // refIndex.x - cubemap channel in reflectionProbes + // refIndex.y - index in refNeighbor of neighbor list (index is ivec4 index, not int index) + // refIndex.z - number of neighbors + ivec4 refIndex[REFMAP_COUNT]; + + // neighbor list data (refSphere indices, not cubemap array layer) + ivec4 refNeighbor[1024]; + + // number of reflection probes present in refSphere + int refmapCount; +}; uniform float blur_size; uniform float blur_fidelity; @@ -80,7 +95,116 @@ vec3 srgb_to_linear(vec3 c); vec4 applyWaterFogView(vec3 pos, vec4 color); #endif +// list of probeIndexes shader will actually use after "getRefIndex" is called +// (stores refIndex/refSphere indices, NOT rerflectionProbes layer) +int probeIndex[REF_SAMPLE_COUNT]; + +// number of probes stored in probeIndex +int probeInfluences = 0; + + +// return true if probe at index i influences position pos +bool shouldSampleProbe(int i, vec3 pos) +{ + vec3 delta = pos.xyz - refSphere[i].xyz; + float d = dot(delta, delta); + float r2 = refSphere[i].w; + r2 *= r2; + return d < r2; +} + +// populate "probeIndex" with N probe indices that influence pos where N is REF_SAMPLE_COUNT +// overall algorithm -- +void getRefIndex(vec3 pos) +{ + // TODO: make some sort of structure that reduces the number of distance checks + for (int i = 0; i < refmapCount; ++i) + { + // found an influencing probe + if (shouldSampleProbe(i, pos)) + { + probeIndex[probeInfluences] = i; + ++probeInfluences; + + int neighborIdx = refIndex[i].y; + if (neighborIdx != -1) + { + int neighborCount = min(refIndex[i].z, REF_SAMPLE_COUNT-1); + + int count = 0; + while (count < neighborCount) + { + // check up to REF_SAMPLE_COUNT-1 neighbors (neighborIdx is ivec4 index) + + int idx = refNeighbor[neighborIdx].x; + if (shouldSampleProbe(idx, pos)) + { + probeIndex[probeInfluences++] = idx; + if (probeInfluences == REF_SAMPLE_COUNT) + { + return; + } + } + count++; + if (count == neighborCount) + { + return; + } + + idx = refNeighbor[neighborIdx].y; + if (shouldSampleProbe(idx, pos)) + { + probeIndex[probeInfluences++] = idx; + if (probeInfluences == REF_SAMPLE_COUNT) + { + return; + } + } + count++; + if (count == neighborCount) + { + return; + } + + idx = refNeighbor[neighborIdx].z; + if (shouldSampleProbe(idx, pos)) + { + probeIndex[probeInfluences++] = idx; + if (probeInfluences == REF_SAMPLE_COUNT) + { + return; + } + } + count++; + if (count == neighborCount) + { + return; + } + + idx = refNeighbor[neighborIdx].w; + if (shouldSampleProbe(idx, pos)) + { + probeIndex[probeInfluences++] = idx; + if (probeInfluences == REF_SAMPLE_COUNT) + { + return; + } + } + count++; + if (count == neighborCount) + { + return; + } + + ++neighborIdx; + } + + return; + } + } + } +} // from https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection @@ -120,13 +244,10 @@ bool intersect(const Ray &ray) const } */ // adapted -- assume that origin is inside sphere, return distance from origin to edge of sphere -float sphereIntersect(vec3 origin, vec3 dir, vec4 sph ) +float sphereIntersect(vec3 origin, vec3 dir, vec3 center, float radius2) { float t0, t1; // solutions for t if the ray intersects - vec3 center = sph.xyz; - float radius2 = sph.w * sph.w; - vec3 L = center - origin; float tca = dot(L,dir); @@ -139,33 +260,78 @@ float sphereIntersect(vec3 origin, vec3 dir, vec4 sph ) return t1; } +// Tap a sphere based reflection probe +// pos - position of pixel +// dir - pixel normal +// lod - which mip to bias towards (lower is higher res, sharper reflections) +// c - center of probe +// r2 - radius of probe squared +// i - index of probe +// vi - point at which reflection vector struck the influence volume, in clip space +vec3 tapRefMap(vec3 pos, vec3 dir, float lod, vec3 c, float r2, int i, out vec3 vi) +{ + //lod = max(lod, 1); +// parallax adjustment + float d = sphereIntersect(pos, dir, c, r2); + + { + vec3 v = pos + dir * d; + vi = v; + v -= c.xyz; + v = env_mat * v; + + float min_lod = textureQueryLod(reflectionProbes,v).y; // lower is higher res + return textureLod(reflectionProbes, vec4(v.xyz, refIndex[i].x), max(min_lod, lod)).rgb; + //return texture(reflectionProbes, vec4(v.xyz, refIndex[i].x)).rgb; + } +} + vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) { float wsum = 0.0; - vec3 col = vec3(0,0,0); + float vd2 = dot(pos,pos); // view distance squared - for (int i = 0; i < refmapCount; ++i) - //int i = 0; + for (int idx = 0; idx < probeInfluences; ++idx) { - float r = 16.0; - vec3 delta = pos.xyz-refOrigin[i].xyz; - if (length(delta) < r) + int i = probeIndex[idx]; + float r = refSphere[i].w; // radius of sphere volume + float rr = r*r; // radius squred + float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) + vec3 delta = pos.xyz-refSphere[i].xyz; + float d2 = dot(delta,delta); + float r2 = r1*r1; + { - float w = 1.0/max(dot(delta, delta), r); - w *= w; - w *= w; + vec3 vi; + vec3 refcol = tapRefMap(pos, dir, lod, refSphere[i].xyz, rr, i, vi); + + float w = 1.0/d2; - // parallax adjustment - float d = sphereIntersect(pos, dir, vec4(refOrigin[i].xyz, r)); + float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); + w *= atten; - { - vec3 v = pos + dir * d; - v -= refOrigin[i].xyz; - v = env_mat * v; + col += refcol*w; + + wsum += w; + } + } - float min_lod = textureQueryLod(reflectionMap[i],v).y; // lower is higher res - col += textureLod(reflectionMap[i], v, max(min_lod, lod)).rgb*w; + if (probeInfluences <= 1) + { //edge-of-scene probe or no probe influence, mix in with embiggened version of probes closest to camera + for (int idx = 0; idx < 8; ++idx) + { + int i = idx; + vec3 delta = pos.xyz-refSphere[i].xyz; + float d2 = dot(delta,delta); + + { + vec3 vi; + vec3 refcol = tapRefMap(pos, dir, lod, refSphere[i].xyz, d2, i, vi); + + float w = 1.0/d2; + w *= w; + col += refcol*w; wsum += w; } } @@ -175,13 +341,6 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) { col *= 1.0/wsum; } - else - { - // this pixel not covered by a probe, fallback to "full scene" environment map - vec3 v = env_mat * dir; - float min_lod = textureQueryLod(environmentMap, v).y; // lower is higher res - col = textureLod(environmentMap, v, max(min_lod, lod)).rgb; - } return col; } @@ -202,13 +361,26 @@ vec3 sampleAmbient(vec3 pos, vec3 dir, float lod) col *= 0.333333; - return col*0.6; // fudge darker + return col*0.8; // fudge darker } +// brighten a color so that at least one component is 1 +vec3 brighten(vec3 c) +{ + float m = max(max(c.r, c.g), c.b); + + if (m == 0) + { + return vec3(1,1,1); + } + + return c * 1.0/m; +} + void main() { - float reflection_lods = 11; // TODO -- base this on resolution of reflection map instead of hard coding + float reflection_lods = 8; // TODO -- base this on resolution of reflection map instead of hard coding vec2 tc = vary_fragcoord.xy; float depth = texture2DRect(depthMap, tc.xy).r; @@ -238,14 +410,16 @@ void main() vec3 amblit; vec3 additive; vec3 atten; + + getRefIndex(pos.xyz); + calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, true); //vec3 amb_vec = env_mat * norm.xyz; - vec3 ambenv = sampleAmbient(pos.xyz, norm.xyz, reflection_lods-1); - amblit = mix(ambenv, amblit, amblit); - color.rgb = amblit; - + vec3 ambenv = sampleAmbient(pos.xyz, norm.xyz, reflection_lods); + amblit = max(ambenv, amblit); + color.rgb = amblit*ambocc; //float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); //ambient *= 0.5; @@ -255,6 +429,7 @@ void main() vec3 sun_contrib = min(da, scol) * sunlit; color.rgb += sun_contrib; + color.rgb = min(color.rgb, vec3(1,1,1)); color.rgb *= diffuse.rgb; vec3 refnormpersp = reflect(pos.xyz, norm.xyz); @@ -274,26 +449,23 @@ void main() float lod = (1.0-spec.a)*reflection_lods; vec3 reflected_color = sampleRefMap(pos.xyz, normalize(refnormpersp), lod); - reflected_color *= 0.5; // fudge darker, not sure where there's a multiply by two and it's late + reflected_color *= 0.35; // fudge darker float fresnel = 1.0+dot(normalize(pos.xyz), norm.xyz); - fresnel += spec.a; - fresnel *= fresnel; - //fresnel *= spec.a; + float minf = spec.a * 0.1; + fresnel = fresnel * (1.0-minf) + minf; reflected_color *= spec.rgb*min(fresnel, 1.0); - //reflected_color = srgb_to_linear(reflected_color); - vec3 mixer = clamp(color.rgb + vec3(1,1,1) - spec.rgb, vec3(0,0,0), vec3(1,1,1)); - color.rgb = mix(reflected_color, color, mixer); + color.rgb += reflected_color; } color.rgb = mix(color.rgb, diffuse.rgb, diffuse.a); if (envIntensity > 0.0) { // add environmentmap - vec3 reflected_color = sampleRefMap(pos.xyz, normalize(refnormpersp), 0.0); + vec3 reflected_color = sampleRefMap(pos.xyz, normalize(refnormpersp), 0.0)*0.5; //fudge darker float fresnel = 1.0+dot(normalize(pos.xyz), norm.xyz); fresnel *= fresnel; - fresnel = fresnel * 0.95 + 0.05; - reflected_color *= fresnel; + fresnel = min(fresnel+envIntensity, 1.0); + reflected_color *= (envIntensity*fresnel)*brighten(spec.rgb); color = mix(color.rgb, reflected_color, envIntensity); } @@ -311,5 +483,7 @@ void main() // convert to linear as fullscreen lights need to sum in linear colorspace // and will be gamma (re)corrected downstream... + //color = vec3(ambocc); + //color = ambenv; frag_color.rgb = srgb_to_linear(color.rgb); } diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 84a41113be..8d02bec53e 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1188,12 +1188,18 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera"); +extern BOOL gCubeSnapshot; + //----------------------------------------------------------------------------- // updateCamera() //----------------------------------------------------------------------------- void LLAgentCamera::updateCamera() { LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA); + if (gCubeSnapshot) + { + return; + } // - changed camera_skyward to the new global "mCameraUpVector" mCameraUpVector = LLVector3::z_axis; diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index eebd89f77f..47330debd3 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -129,6 +129,8 @@ static void prepare_alpha_shader(LLGLSLShader* shader, bool textureGamma, bool d } } +extern BOOL gCubeSnapshot; + void LLDrawPoolAlpha::renderPostDeferred(S32 pass) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; @@ -155,7 +157,7 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) forwardRender(); // final pass, render to depth for depth of field effects - if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField")) + if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField") && !gCubeSnapshot) { //update depth buffer sampler gPipeline.mScreen.flush(); diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 2892fc6f9f..0df0137b7a 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -735,6 +735,7 @@ void LLDrawPoolBump::renderDeferred(S32 pass) void LLDrawPoolBump::renderPostDeferred(S32 pass) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL for (int i = 0; i < 2; ++i) { // two passes -- static and rigged mRigged = (i == 1); diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 64850424f4..2478aa0cff 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -87,6 +87,6 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass) // TODO: handle under water? // if (LLPipeline::sUnderWaterRender) // PASS_SIMPLE or PASS_MATERIAL - pushBatches(LLRenderPass::PASS_SIMPLE, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + //pushBatches(LLRenderPass::PASS_SIMPLE, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index b75dba877e..0cf2f22822 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -29,36 +29,183 @@ #include "llreflectionmap.h" #include "pipeline.h" #include "llviewerwindow.h" +#include "llviewerregion.h" + +extern F32SecondsImplicit gFrameTimeSeconds; LLReflectionMap::LLReflectionMap() { + mLastUpdateTime = gFrameTimeSeconds; } -void LLReflectionMap::update(const LLVector3& origin, U32 resolution) +void LLReflectionMap::update(U32 resolution, U32 face) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + mLastUpdateTime = gFrameTimeSeconds; + llassert(mCubeArray.notNull()); + llassert(mCubeIndex != -1); llassert(LLPipeline::sRenderDeferred); - - // make sure resolution is < gPipeline.mDeferredScreen.getWidth() - + + // make sure we don't walk off the edge of the render target while (resolution > gPipeline.mDeferredScreen.getWidth() || resolution > gPipeline.mDeferredScreen.getHeight()) { resolution /= 2; } + gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face); +} - if (resolution == 0) - { - return; +bool LLReflectionMap::shouldUpdate() +{ + const F32 UPDATE_INTERVAL = 10.f; // update no more than this often + const F32 TIMEOUT_INTERVAL = 30.f; // update no less than this often + const F32 RENDER_TIMEOUT = 1.f; // don't update if hasn't been used for rendering for this long + + if (mLastBindTime > gFrameTimeSeconds - RENDER_TIMEOUT) + { + if (mDirty && mLastUpdateTime < gFrameTimeSeconds - UPDATE_INTERVAL) + { + return true; + } + + if (mLastUpdateTime < gFrameTimeSeconds - TIMEOUT_INTERVAL) + { + return true; + } } - mOrigin.load3(origin.mV); + return false; +} + +void LLReflectionMap::dirty() +{ + mDirty = true; + mLastUpdateTime = gFrameTimeSeconds; +} + +void LLReflectionMap::autoAdjustOrigin() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + if (mGroup) + { + const LLVector4a* bounds = mGroup->getBounds(); + auto* node = mGroup->getOctreeNode(); + + if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_TERRAIN) + { + // for terrain, make probes float a couple meters above the highest point in the surface patch + mOrigin = bounds[0]; + mOrigin.getF32ptr()[2] += bounds[1].getF32ptr()[2] + 3.f; + + // update radius to encompass bounding box + LLVector4a d; + d.setAdd(bounds[0], bounds[1]); + d.sub(mOrigin); + mRadius = d.getLength3().getF32(); + } + else if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) + { + // cast a ray towards 8 corners of bounding box + // nudge origin towards center of empty space + + if (node->isLeaf() || node->getChildCount() > 1 || node->getData().size() > 0) + { // use center of object bounding box for leaf nodes or nodes with multiple child nodes + mOrigin = bounds[0]; - mCubeMap = new LLCubeMap(false); - mCubeMap->initReflectionMap(resolution); + LLVector4a start; + LLVector4a end; - gViewerWindow->cubeSnapshot(origin, mCubeMap); + LLVector4a size = bounds[1]; - mCubeMap->generateMipMaps(); + LLVector4a corners[] = + { + { 1, 1, 1 }, + { -1, 1, 1 }, + { 1, -1, 1 }, + { -1, -1, 1 }, + { 1, 1, -1 }, + { -1, 1, -1 }, + { 1, -1, -1 }, + { -1, -1, -1 } + }; + + for (int i = 0; i < 8; ++i) + { + corners[i].mul(size); + corners[i].add(bounds[0]); + } + + LLVector4a extents[2]; + extents[0].setAdd(bounds[0], bounds[1]); + extents[1].setSub(bounds[0], bounds[1]); + + bool hit = false; + for (int i = 0; i < 8; ++i) + { + int face = -1; + LLVector4a intersection; + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, &face, &intersection); + if (drawable != nullptr) + { + hit = true; + update_min_max(extents[0], extents[1], intersection); + } + else + { + update_min_max(extents[0], extents[1], corners[i]); + } + } + + if (hit) + { + mOrigin.setAdd(extents[0], extents[1]); + mOrigin.mul(0.5f); + } + + // make sure radius encompasses all objects + LLSimdScalar r2 = 0.0; + for (int i = 0; i < 8; ++i) + { + LLVector4a v; + v.setSub(corners[i], mOrigin); + + LLSimdScalar d = v.dot3(v); + + if (d > r2) + { + r2 = d; + } + } + + mRadius = llmax(sqrtf(r2.getF32()), 8.f); + } + else + { + // use center of octree node volume for nodes that are just branches without data + mOrigin = node->getCenter(); + + // update radius to encompass entire octree node volume + mRadius = node->getSize().getLength3().getF32(); + + //mOrigin = bounds[0]; + //mRadius = bounds[1].getLength3().getF32(); + + } + } + } } +bool LLReflectionMap::intersects(LLReflectionMap* other) +{ + LLVector4a delta; + delta.setSub(other->mOrigin, mOrigin); + + F32 dist = delta.dot3(delta).getF32(); + + F32 r2 = mRadius + other->mRadius; + + r2 *= r2; + + return dist < r2; +} diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 7d39e7e562..ed1c2680b6 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -26,26 +26,61 @@ #pragma once -#include "llcubemap.h" +#include "llcubemaparray.h" +#include "llmemory.h" -class LLReflectionMap : public LLRefCount +class LLSpatialGroup; + +class alignas(16) LLReflectionMap : public LLRefCount { + LL_ALIGN_NEW public: // allocate an environment map of the given resolution LLReflectionMap(); // update this environment map - // origin - position in agent space to generate environment map from in agent space // resolution - size of cube map to generate - void update(const LLVector3& origin, U32 resolution); - - // point at which environment map was generated from (in agent space) - LLVector4a mOrigin; + void update(U32 resolution, U32 face); + + // return true if this probe should update *now* + bool shouldUpdate(); + // Mark this reflection map as needing an update (resets last update time, so spamming this call will cause a cube map to never update) + void dirty(); + + // for volume partition probes, try to place this probe in the best spot + void autoAdjustOrigin(); + + // return true if given Reflection Map's influence volume intersect's with this one's + bool intersects(LLReflectionMap* other); + + // point at which environment map was last generated from (in agent space) + LLVector4a mOrigin; + // distance from viewer camera F32 mDistance; + // radius of this probe's affected area + F32 mRadius = 16.f; + + // last time this probe was updated (or when its update timer got reset) + F32 mLastUpdateTime = 0.f; + + // last time this probe was bound for rendering + F32 mLastBindTime = 0.f; + // cube map used to sample this environment map - LLPointer mCubeMap; + LLPointer mCubeArray; + S32 mCubeIndex = -1; // index into cube map array or -1 if not currently stored in cube map array + + // index into array packed by LLReflectionMapManager::getReflectionMaps + // WARNING -- only valid immediately after call to getReflectionMaps + S32 mProbeIndex = -1; + + // set of any LLReflectionMaps that intersect this map (maintained by LLReflectionMapManager + std::vector mNeighbors; + + LLSpatialGroup* mGroup = nullptr; + bool mDirty = true; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 95b72e1d3b..a6b704d57d 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -28,30 +28,84 @@ #include "llreflectionmapmanager.h" #include "llviewercamera.h" +#include "llspatialpartition.h" +#include "llviewerregion.h" +#include "pipeline.h" +#include "llviewershadermgr.h" + +extern BOOL gCubeSnapshot; +extern BOOL gTeleportDisplay; + +//#pragma optimize("", off) LLReflectionMapManager::LLReflectionMapManager() { - + for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i) + { + mCubeFree[i] = true; + } } struct CompareReflectionMapDistance { - + }; struct CompareProbeDistance { - bool operator()(const LLReflectionMap& lhs, const LLReflectionMap& rhs) + bool operator()(const LLPointer& lhs, const LLPointer& rhs) { - return lhs.mDistance < rhs.mDistance; + return lhs->mDistance < rhs->mDistance; } }; // helper class to seed octree with probes void LLReflectionMapManager::update() { + if (!LLPipeline::sRenderDeferred || gTeleportDisplay) + { + return; + } + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(!gCubeSnapshot); // assert a snapshot is not in progress + if (LLAppViewer::instance()->logoutRequestSent()) + { + return; + } + + // =============== TODO -- move to an init function ================= + + if (mTexture.isNull()) + { + mTexture = new LLCubeMapArray(); + mTexture->allocate(LL_REFLECTION_PROBE_RESOLUTION, 3, LL_REFLECTION_PROBE_COUNT); + } + + if (!mRenderTarget.isComplete()) + { + U32 color_fmt = GL_RGBA; + const bool use_depth_buffer = true; + const bool use_stencil_buffer = true; + U32 targetRes = LL_REFLECTION_PROBE_RESOLUTION * 4; // super sample + mRenderTarget.allocate(targetRes, targetRes, color_fmt, use_depth_buffer, use_stencil_buffer, LLTexUnit::TT_RECT_TEXTURE); + } + + if (mMipChain.empty()) + { + U32 res = LL_REFLECTION_PROBE_RESOLUTION*2; + U32 count = log2((F32)res) + 0.5f; + + mMipChain.resize(count); + for (int i = 0; i < count; ++i) + { + mMipChain[i].allocate(res, res, GL_RGB, false, false, LLTexUnit::TT_RECT_TEXTURE); + res /= 2; + } + } + + // =============== TODO -- move to an init function ================= // naively drop probes every 16m as we move the camera around for now // later, use LLSpatialPartition to manage probes @@ -61,46 +115,462 @@ void LLReflectionMapManager::update() LLVector4a camera_pos; camera_pos.load3(LLViewerCamera::instance().getOrigin().mV); - for (auto& probe : mProbes) + // process kill list + for (int i = 0; i < mProbes.size(); ) { - LLVector4a d; - d.setSub(camera_pos, probe.mOrigin); - probe.mDistance = d.getLength3().getF32(); + auto& iter = std::find(mKillList.begin(), mKillList.end(), mProbes[i]); + if (iter != mKillList.end()) + { + deleteProbe(i); + mProbes.erase(mProbes.begin() + i); + mKillList.erase(iter); + } + else + { + ++i; + } } - if (mProbes.empty() || mProbes[0].mDistance > PROBE_SPACING) + mKillList.clear(); + + // process create list + for (auto& probe : mCreateList) { - addProbe(LLViewerCamera::instance().getOrigin()); + mProbes.push_back(probe); } - // update distance to camera for all probes - std::sort(mProbes.begin(), mProbes.end(), CompareProbeDistance()); + mCreateList.clear(); + + const F32 UPDATE_INTERVAL = 10.f; //update no more than once every 5 seconds + + bool did_update = false; + + if (mUpdatingProbe != nullptr) + { + did_update = true; + doProbeUpdate(); + } - if (mProbes.size() > MAX_PROBES) + for (int i = 0; i < mProbes.size(); ++i) { - mProbes.resize(MAX_PROBES); + LLReflectionMap* probe = mProbes[i]; + if (probe->getNumRefs() == 1) + { // no references held outside manager, delete this probe + deleteProbe(i); + --i; + continue; + } + + probe->mProbeIndex = i; + + LLVector4a d; + + if (probe->shouldUpdate() && !did_update && i < LL_REFLECTION_PROBE_COUNT) + { + if (probe->mCubeIndex == -1) + { + probe->mCubeArray = mTexture; + probe->mCubeIndex = allocateCubeIndex(); + } + + did_update = true; // only update one probe per frame + probe->autoAdjustOrigin(); + + mUpdatingProbe = probe; + doProbeUpdate(); + probe->mDirty = false; + } + + d.setSub(camera_pos, probe->mOrigin); + probe->mDistance = d.getLength3().getF32()-probe->mRadius; } + + // update distance to camera for all probes + std::sort(mProbes.begin(), mProbes.end(), CompareProbeDistance()); } void LLReflectionMapManager::addProbe(const LLVector3& pos) { - LLReflectionMap probe; - probe.update(pos, 1024); - mProbes.push_back(probe); + //LLReflectionMap* probe = new LLReflectionMap(); + //probe->update(pos, 1024); + //mProbes.push_back(probe); +} + +LLReflectionMap* LLReflectionMapManager::addProbe(LLSpatialGroup* group) +{ + LLReflectionMap* probe = new LLReflectionMap(); + probe->mGroup = group; + probe->mOrigin = group->getOctreeNode()->getCenter(); + probe->mDirty = true; + + if (gCubeSnapshot) + { //snapshot is in progress, mProbes is being iterated over, defer insertion until next update + mCreateList.push_back(probe); + } + else + { + mProbes.push_back(probe); + } + + return probe; } void LLReflectionMapManager::getReflectionMaps(std::vector& maps) { - // just null out for now - U32 i = 0; - for (i = 0; i < maps.size() && i < mProbes.size(); ++i) + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + U32 count = 0; + U32 lastIdx = 0; + for (U32 i = 0; count < maps.size() && i < mProbes.size(); ++i) + { + mProbes[i]->mLastBindTime = gFrameTimeSeconds; // something wants to use this probe, indicate it's been requested + if (mProbes[i]->mCubeIndex != -1) + { + mProbes[i]->mProbeIndex = count; + maps[count++] = mProbes[i]; + } + else + { + mProbes[i]->mProbeIndex = -1; + } + lastIdx = i; + } + + // set remaining probe indices to -1 + for (U32 i = lastIdx+1; i < mProbes.size(); ++i) + { + mProbes[i]->mProbeIndex = -1; + } + + // null terminate list + if (count < maps.size()) + { + maps[count] = nullptr; + } +} + +LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* group) +{ + if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) + { + OctreeNode* node = group->getOctreeNode(); + F32 size = node->getSize().getF32ptr()[0]; + if (size >= 7.f && size <= 17.f) + { + return addProbe(group); + } + } + + if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_TERRAIN) + { + OctreeNode* node = group->getOctreeNode(); + F32 size = node->getSize().getF32ptr()[0]; + if (size >= 15.f && size <= 17.f) + { + return addProbe(group); + } + } + + return nullptr; +} + +S32 LLReflectionMapManager::allocateCubeIndex() +{ + for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i) + { + if (mCubeFree[i]) + { + mCubeFree[i] = false; + return i; + } + } + + // no cubemaps free, steal one from the back of the probe list + for (int i = mProbes.size() - 1; i >= LL_REFLECTION_PROBE_COUNT; --i) + { + if (mProbes[i]->mCubeIndex != -1) + { + S32 ret = mProbes[i]->mCubeIndex; + mProbes[i]->mCubeIndex = -1; + return ret; + } + } + + llassert(false); // should never fail to allocate, something is probably wrong with mCubeFree + return -1; +} + +void LLReflectionMapManager::deleteProbe(U32 i) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + LLReflectionMap* probe = mProbes[i]; + + if (probe->mCubeIndex != -1) + { // mark the cube index used by this probe as being free + mCubeFree[probe->mCubeIndex] = true; + } + if (mUpdatingProbe == probe) + { + mUpdatingProbe = nullptr; + mUpdatingFace = 0; + } + + // remove from any Neighbors lists + for (auto& other : probe->mNeighbors) + { + auto& iter = std::find(other->mNeighbors.begin(), other->mNeighbors.end(), probe); + llassert(iter != other->mNeighbors.end()); + other->mNeighbors.erase(iter); + } + + mProbes.erase(mProbes.begin() + i); +} + + +void LLReflectionMapManager::doProbeUpdate() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(mUpdatingProbe != nullptr); + + mRenderTarget.bindTarget(); + mUpdatingProbe->update(mRenderTarget.getWidth(), mUpdatingFace); + mRenderTarget.flush(); + + // generate mipmaps { - maps[i] = &(mProbes[i]); + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + LLGLDisable cull(GL_CULL_FACE); + + gReflectionMipProgram.bind(); + gGL.matrixMode(gGL.MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + + gGL.matrixMode(gGL.MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + gGL.flush(); + U32 res = LL_REFLECTION_PROBE_RESOLUTION*4; + + S32 mips = log2((F32) LL_REFLECTION_PROBE_RESOLUTION)+0.5f; + + for (int i = 0; i < mMipChain.size(); ++i) + { + mMipChain[i].bindTarget(); + + if (i == 0) + { + gGL.getTexUnit(0)->bind(&mRenderTarget); + } + else + { + gGL.getTexUnit(0)->bind(&(mMipChain[i - 1])); + } + + gGL.begin(gGL.QUADS); + + gGL.texCoord2f(0, 0); + gGL.vertex2f(-1, -1); + + gGL.texCoord2f(res, 0); + gGL.vertex2f(1, -1); + + gGL.texCoord2f(res, res); + gGL.vertex2f(1, 1); + + gGL.texCoord2f(0, res); + gGL.vertex2f(-1, 1); + gGL.end(); + gGL.flush(); + + res /= 2; + + S32 mip = i - (mMipChain.size() - mips); + + if (mip >= 0) + { + mTexture->bind(0); + glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, mUpdatingProbe->mCubeIndex * 6 + mUpdatingFace, 0, 0, res, res); + mTexture->unbind(); + } + mMipChain[i].flush(); + } + + gGL.popMatrix(); + gGL.matrixMode(gGL.MM_MODELVIEW); + gGL.popMatrix(); + + gReflectionMipProgram.unbind(); + } + + if (++mUpdatingFace == 6) + { + updateNeighbors(mUpdatingProbe); + mUpdatingProbe = nullptr; + mUpdatingFace = 0; + } +} + +void LLReflectionMapManager::rebuild() +{ + for (auto& probe : mProbes) + { + probe->mLastUpdateTime = 0.f; } +} - for (++i; i < maps.size(); ++i) +void LLReflectionMapManager::shift(const LLVector4a& offset) +{ + for (auto& probe : mProbes) { - maps[i] = nullptr; + probe->mOrigin.add(offset); } } +void LLReflectionMapManager::updateNeighbors(LLReflectionMap* probe) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + //remove from existing neighbors + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmun - clear"); + + for (auto& other : probe->mNeighbors) + { + auto& iter = std::find(other->mNeighbors.begin(), other->mNeighbors.end(), probe); + llassert(iter != other->mNeighbors.end()); // <--- bug davep if this ever happens, something broke badly + other->mNeighbors.erase(iter); + } + + probe->mNeighbors.clear(); + } + + // search for new neighbors + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmun - search"); + for (auto& other : mProbes) + { + if (other != probe) + { + if (probe->intersects(other)) + { + probe->mNeighbors.push_back(other); + other->mNeighbors.push_back(probe); + } + } + } + } +} + +void LLReflectionMapManager::setUniforms() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + // structure for packing uniform buffer object + // see class2/deferred/softenLightF.glsl + struct ReflectionProbeData + { + LLVector4 refSphere[LL_REFLECTION_PROBE_COUNT]; //origin and radius of refmaps in clip space + GLint refIndex[LL_REFLECTION_PROBE_COUNT][4]; + GLint refNeighbor[4096]; + GLint refmapCount; + }; + + mReflectionMaps.resize(LL_REFLECTION_PROBE_COUNT); + getReflectionMaps(mReflectionMaps); + + ReflectionProbeData rpd; + + // load modelview matrix into matrix 4a + LLMatrix4a modelview; + modelview.loadu(gGLModelView); + LLVector4a oa; // scratch space for transformed origin + + S32 count = 0; + U32 nc = 0; // neighbor "cursor" - index into refNeighbor to start writing the next probe's list of neighbors + + for (auto* refmap : mReflectionMaps) + { + if (refmap == nullptr) + { + break; + } + + llassert(refmap->mProbeIndex == count); + llassert(mReflectionMaps[refmap->mProbeIndex] == refmap); + + llassert(refmap->mCubeIndex >= 0); // should always be true, if not, getReflectionMaps is bugged + + { + //LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - refSphere"); + + modelview.affineTransform(refmap->mOrigin, oa); + rpd.refSphere[count].set(oa.getF32ptr()); + rpd.refSphere[count].mV[3] = refmap->mRadius; + } + + rpd.refIndex[count][0] = refmap->mCubeIndex; + llassert(nc % 4 == 0); + rpd.refIndex[count][1] = nc / 4; + + S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors + { + //LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - refNeighbors"); + //pack neghbor list + for (auto& neighbor : refmap->mNeighbors) + { + if (ni >= 4096) + { // out of space + break; + } + + GLint idx = neighbor->mProbeIndex; + if (idx == -1) + { + continue; + } + + // this neighbor may be sampled + rpd.refNeighbor[ni++] = idx; + } + } + + if (nc == ni) + { + //no neighbors, tag as empty + rpd.refIndex[count][1] = -1; + } + else + { + rpd.refIndex[count][2] = ni - nc; + + // move the cursor forward + nc = ni; + if (nc % 4 != 0) + { // jump to next power of 4 for compatibility with ivec4 + nc += 4 - (nc % 4); + } + } + + + count++; + } + + rpd.refmapCount = count; + + //copy rpd into uniform buffer object + if (mUBO == 0) + { + glGenBuffersARB(1, &mUBO); + } + + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - update buffer"); + glBindBufferARB(GL_UNIFORM_BUFFER, mUBO); + glBufferDataARB(GL_UNIFORM_BUFFER, sizeof(ReflectionProbeData), &rpd, GL_STREAM_DRAW); + glBindBufferARB(GL_UNIFORM_BUFFER, 0); + } + + glBindBufferBase(GL_UNIFORM_BUFFER, 1, mUBO); +} diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 40e925d916..24ac40b264 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -27,9 +27,20 @@ #pragma once #include "llreflectionmap.h" +#include "llrendertarget.h" +#include "llcubemaparray.h" -class LLReflectionMapManager +class LLSpatialGroup; + +// number of reflection probes to keep in vram +#define LL_REFLECTION_PROBE_COUNT 256 + +// reflection probe resolution +#define LL_REFLECTION_PROBE_RESOLUTION 256 + +class alignas(16) LLReflectionMapManager { + LL_ALIGN_NEW public: // allocate an environment map of the given resolution LLReflectionMapManager(); @@ -40,12 +51,74 @@ public: // drop a reflection probe at the specified position in agent space void addProbe(const LLVector3& pos); + // add a probe for the given spatial group + LLReflectionMap* addProbe(LLSpatialGroup* group); + // Populate "maps" with the N most relevant Reflection Maps where N is no more than maps.size() // If less than maps.size() ReflectionMaps are available, will assign trailing elements to nullptr. // maps -- presized array of Reflection Map pointers void getReflectionMaps(std::vector& maps); + // called by LLSpatialGroup constructor + // If spatial group should receive a Reflection Probe, will create one for the specified spatial group + LLReflectionMap* registerSpatialGroup(LLSpatialGroup* group); + + // force an update of all probes + void rebuild(); + + // called on region crossing to "shift" probes into new coordinate frame + void shift(const LLVector4a& offset); + +private: + friend class LLPipeline; + + // delete the probe with the given index in mProbes + void deleteProbe(U32 i); + + // get a free cube index + // if no cube indices are free, free one starting from the back of the probe list + S32 allocateCubeIndex(); + + // update the neighbors of the given probe + void updateNeighbors(LLReflectionMap* probe); + + void setUniforms(); + + // render target for cube snapshots + // used to generate mipmaps without doing a copy-to-texture + LLRenderTarget mRenderTarget; + + std::vector mMipChain; + + // storage for reflection probes + LLPointer mTexture; + + // array indicating if a particular cubemap is free + bool mCubeFree[LL_REFLECTION_PROBE_COUNT]; + + // start tracking the given spatial group + void trackGroup(LLSpatialGroup* group); + + // perform an update on the currently updating Probe + void doProbeUpdate(); + // list of active reflection maps - std::vector mProbes; + std::vector > mProbes; + + // list of reflection maps to kill + std::vector > mKillList; + + // list of reflection maps to create + std::vector > mCreateList; + + // handle to UBO + U32 mUBO = 0; + + // list of maps being used for rendering + std::vector mReflectionMaps; + + LLReflectionMap* mUpdatingProbe = nullptr; + U32 mUpdatingFace = 0; + }; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 5c648c11e1..5909cd1f4c 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -554,9 +554,12 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : LLO sg_assert(mOctreeNode->getListenerCount() == 0); setState(SG_INITIAL_STATE_MASK); gPipeline.markRebuild(this, TRUE); + + // let the reflection map manager know about this spatial group + mReflectionProbe = gPipeline.mReflectionMapManager.registerSpatialGroup(this); - mRadius = 1; - mPixelArea = 1024.f; + mRadius = 1; + mPixelArea = 1024.f; } void LLSpatialGroup::updateDistance(LLCamera &camera) @@ -735,8 +738,17 @@ BOOL LLSpatialGroup::changeLOD() return FALSE; } +void LLSpatialGroup::dirtyReflectionProbe() +{ + if (mReflectionProbe != nullptr) + { + mReflectionProbe->dirty(); + } +} + void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* entry) { + dirtyReflectionProbe(); addObject((LLDrawable*)entry->getDrawable()); unbound(); setState(OBJECT_DIRTY); @@ -744,6 +756,7 @@ void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* entry) { + dirtyReflectionProbe(); removeObject((LLDrawable*)entry->getDrawable(), TRUE); LLViewerOctreeGroup::handleRemoval(node, entry); } @@ -780,6 +793,8 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c { LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL + dirtyReflectionProbe(); + if (child->getListenerCount() == 0) { new LLSpatialGroup(child, getSpatialPartition()); @@ -794,6 +809,11 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c assert_states_valid(this); } +void LLSpatialGroup::handleChildRemoval(const oct_node* parent, const oct_node* child) +{ + dirtyReflectionProbe(); +} + void LLSpatialGroup::destroyGL(bool keep_occlusion) { setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY); @@ -1398,7 +1418,9 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector* result return 0; } - + +extern BOOL gCubeSnapshot; + S32 LLSpatialPartition::cull(LLCamera &camera, bool do_occlusion) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; @@ -1417,7 +1439,7 @@ S32 LLSpatialPartition::cull(LLCamera &camera, bool do_occlusion) LLOctreeCullShadow culler(&camera); culler.traverse(mOctree); } - else if (mInfiniteFarClip || !LLPipeline::sUseFarClip) + else if (mInfiniteFarClip || (!LLPipeline::sUseFarClip && !gCubeSnapshot)) { LLOctreeCullNoFarClip culler(&camera); culler.traverse(mOctree); @@ -1737,12 +1759,71 @@ void renderOctree(LLSpatialGroup* group) } }*/ } - + // LLSpatialGroup::OctreeNode* node = group->mOctreeNode; // gGL.diffuseColor4f(0,1,0,1); // drawBoxOutline(LLVector3(node->getCenter()), LLVector3(node->getSize())); } +void renderReflectionProbes(LLSpatialGroup* group) +{ + if (group->mReflectionProbe) + { // draw lines from corners of object aabb to reflection probe + + const LLVector4a* bounds = group->getBounds(); + LLVector4a o = bounds[0]; + + gGL.flush(); + gGL.diffuseColor4f(0, 0, 1, 1); + F32* c = o.getF32ptr(); + + const F32* bc = bounds[0].getF32ptr(); + const F32* bs = bounds[1].getF32ptr(); + + // daaw blue lines from corners to center of node + gGL.begin(gGL.LINES); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] + bs[2]); + + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] - bs[2]); + gGL.end(); + + F32* po = group->mReflectionProbe->mOrigin.getF32ptr(); + //draw yellow line from center of node to reflection probe origin + gGL.flush(); + gGL.diffuseColor4f(1, 1, 0, 1); + gGL.begin(gGL.LINES); + gGL.vertex3fv(c); + gGL.vertex3fv(po); + gGL.end(); + gGL.flush(); + + //draw orange line from probe to neighbors + gGL.flush(); + gGL.diffuseColor4f(1, 0.5f, 0, 1); + gGL.begin(gGL.LINES); + for (auto& probe : group->mReflectionProbe->mNeighbors) + { + gGL.vertex3fv(po); + gGL.vertex3fv(probe->mOrigin.getF32ptr()); + } + gGL.end(); + gGL.flush(); + } +} std::set visible_selected_groups; void renderVisibility(LLSpatialGroup* group, LLCamera* camera) @@ -3289,6 +3370,12 @@ public: stop_glerror(); } + //draw reflection probes and links between them + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES)) + { + renderReflectionProbes(group); + } + //render visibility wireframe if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) { @@ -3703,7 +3790,8 @@ void LLSpatialPartition::renderDebug() //LLPipeline::RENDER_DEBUG_BUILD_QUEUE | LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA | LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY | - LLPipeline::RENDER_DEBUG_TEXEL_DENSITY)) + LLPipeline::RENDER_DEBUG_TEXEL_DENSITY | + LLPipeline::RENDER_DEBUG_REFLECTION_PROBES)) { return; } @@ -3947,6 +4035,23 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co return drawable; } +LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, + BOOL pick_transparent, + BOOL pick_rigged, + S32* face_hit, // return the face hit + LLVector4a* intersection, // return the intersection point + LLVector2* tex_coord, // return the texture coordinates of the intersection point + LLVector4a* normal, // return the surface normal at the intersection point + LLVector4a* tangent // return the surface tangent at the intersection point +) + +{ + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, face_hit, intersection, tex_coord, normal, tangent); + LLDrawable* drawable = intersect.check(getOctreeNode()); + + return drawable; +} + LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, LLViewerTexture* texture, LLVertexBuffer* buffer, bool selected, diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index acfcd63686..a30660b2de 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -53,6 +53,7 @@ class LLSpatialPartition; class LLSpatialBridge; class LLSpatialGroup; class LLViewerRegion; +class LLReflectionMap; void pushVerts(LLFace* face, U32 mask); @@ -300,6 +301,17 @@ public: void drawObjectBox(LLColor4 col); + LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, + BOOL pick_transparent, + BOOL pick_rigged, + S32* face_hit, // return the face hit + LLVector4a* intersection = NULL, // return the intersection point + LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point + LLVector4a* normal = NULL, // return the surface normal at the intersection point + LLVector4a* tangent = NULL // return the surface tangent at the intersection point + ); + + LLSpatialPartition* getSpatialPartition() {return (LLSpatialPartition*)mSpatialPartition;} //LISTENER FUNCTIONS @@ -307,6 +319,7 @@ public: virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face); virtual void handleDestruction(const TreeNode* node); virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child); + virtual void handleChildRemoval(const oct_node* parent, const oct_node* child); public: LL_ALIGN_16(LLVector4a mViewAngle); @@ -314,6 +327,8 @@ public: F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3() + void dirtyReflectionProbe(); + protected: virtual ~LLSpatialGroup(); @@ -338,6 +353,10 @@ public: F32 mPixelArea; F32 mRadius; + + // Reflection Probe associated with this node (if any) + LLPointer mReflectionProbe = nullptr; + } LL_ALIGN_POSTFIX(64); class LLGeometryManager diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 6a2b06d9b5..f375852dfe 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -97,6 +97,7 @@ BOOL gResizeScreenTexture = FALSE; BOOL gResizeShadowTexture = FALSE; BOOL gWindowResized = FALSE; BOOL gSnapshot = FALSE; +BOOL gCubeSnapshot = FALSE; BOOL gShaderProfileFrame = FALSE; // This is how long the sim will try to teleport you before giving up. @@ -193,15 +194,23 @@ void display_update_camera() // Cut draw distance in half when customizing avatar, // but on the viewer only. F32 final_far = gAgentCamera.mDrawDistance; - if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode()) + if (gCubeSnapshot) + { + final_far = gSavedSettings.getF32("RenderReflectionProbeDrawDistance"); + } + else if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode()) + { final_far *= 0.5f; } LLViewerCamera::getInstance()->setFar(final_far); gViewerWindow->setup3DRender(); - // Update land visibility too - LLWorld::getInstance()->setLandFarClip(final_far); + if (!gCubeSnapshot) + { + // Update land visibility too + LLWorld::getInstance()->setLandFarClip(final_far); + } } // Write some stats to LL_INFOS() @@ -1048,6 +1057,112 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } } +// WIP simplified copy of display() that does minimal work +void display_cube_face() +{ + LL_RECORD_BLOCK_TIME(FTM_RENDER); + llassert(!gSnapshot); + llassert(!gTeleportDisplay); + llassert(LLPipeline::sRenderDeferred); + llassert(LLStartUp::getStartupState() >= STATE_PRECACHE); + llassert(!LLAppViewer::instance()->logoutRequestSent()); + llassert(!gRestoreGL); + llassert(!gUseWireframe); + + bool rebuild = false; + + LLGLSDefault gls_default; + LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE, GL_LEQUAL); + + LLVertexBuffer::unbind(); + + gPipeline.disableLights(); + + gPipeline.mBackfaceCull = TRUE; + + LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); + gViewerWindow->setup3DViewport(); + + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) + { //don't draw hud objects in this frame + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); + } + + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES)) + { //don't draw hud particles in this frame + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES); + } + + display_update_camera(); + + LLSpatialGroup::sNoDelete = TRUE; + + S32 occlusion = LLPipeline::sUseOcclusion; + LLPipeline::sUseOcclusion = 0; // occlusion data is from main camera point of view, don't read or write it during cube snapshots + //gDepthDirty = TRUE; //let "real" render pipe know it can't trust the depth buffer for occlusion data + + static LLCullResult result; + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater(); + gPipeline.updateCull(*LLViewerCamera::getInstance(), result); + + gGL.setColorMask(true, true); + glClearColor(0, 0, 0, 0); + gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); + + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + { + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + gPipeline.stateSort(*LLViewerCamera::getInstance(), result); + + if (rebuild) + { + ////////////////////////////////////// + // + // rebuildPools + // + // + gPipeline.rebuildPools(); + stop_glerror(); + } + } + + LLPipeline::sUseOcclusion = occlusion; + + LLAppViewer::instance()->pingMainloopTimeout("Display:RenderStart"); + + LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; + + gGL.setColorMask(true, true); + + gPipeline.mDeferredScreen.bindTarget(); + glClearColor(1, 0, 1, 1); + gPipeline.mDeferredScreen.clear(); + + gGL.setColorMask(true, false); + + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + + gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance()); + + gGL.setColorMask(true, true); + + gPipeline.mDeferredScreen.flush(); + + gPipeline.renderDeferredLighting(&gPipeline.mScreen); + + LLPipeline::sUnderWaterRender = FALSE; + + // Finalize scene + gPipeline.renderFinalize(); + + LLSpatialGroup::sNoDelete = FALSE; + gPipeline.clearReferences(); + + gPipeline.rebuildGroups(); +} + void render_hud_attachments() { gGL.matrixMode(LLRender::MM_PROJECTION); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index f5ea060e82..8732bde35c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1081,6 +1081,10 @@ U64 info_display_from_string(std::string info_display) { return LLPipeline::RENDER_DEBUG_IMPOSTORS; } + else if ("reflection probes" == info_display) + { + return LLPipeline::RENDER_DEBUG_REFLECTION_PROBES; + } else { LL_WARNS() << "unrecognized feature name '" << info_display << "'" << LL_ENDL; @@ -8304,9 +8308,9 @@ void handle_cache_clear_immediately() LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache_immediately); } -void handle_override_environment_map() +void handle_rebuild_reflection_probes() { - gPipeline.overrideEnvironmentMap(); + gPipeline.mReflectionMapManager.rebuild(); } @@ -9409,7 +9413,7 @@ void initialize_menus() //Develop (clear cache immediately) commit.add("Develop.ClearCache", boost::bind(&handle_cache_clear_immediately) ); //Develop (override environment map) - commit.add("Develop.OverrideEnvironmentMap", boost::bind(&handle_override_environment_map)); + commit.add("Develop.RebuildReflectionProbes", boost::bind(&handle_rebuild_reflection_probes)); // Admin >Object view_listener_t::addMenu(new LLAdminForceTakeCopy(), "Admin.ForceTakeCopy"); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 50a0ff07fc..94af320a73 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -82,6 +82,7 @@ LLGLSLShader gOcclusionCubeProgram; LLGLSLShader gCustomAlphaProgram; LLGLSLShader gGlowCombineProgram; LLGLSLShader gSplatTextureRectProgram; +LLGLSLShader gReflectionMipProgram; LLGLSLShader gGlowCombineFXAAProgram; LLGLSLShader gTwoTextureAddProgram; LLGLSLShader gTwoTextureCompareProgram; @@ -635,7 +636,6 @@ void LLViewerShaderMgr::setShaders() } if (loaded) - { loaded = loadTransformShaders(); if (loaded) @@ -746,6 +746,7 @@ void LLViewerShaderMgr::unloadShaders() gCustomAlphaProgram.unload(); gGlowCombineProgram.unload(); gSplatTextureRectProgram.unload(); + gReflectionMipProgram.unload(); gGlowCombineFXAAProgram.unload(); gTwoTextureAddProgram.unload(); gTwoTextureCompareProgram.unload(); @@ -3587,7 +3588,6 @@ BOOL LLViewerShaderMgr::loadShadersInterface() } } - if (success) { gTwoTextureAddProgram.mName = "Two Texture Add Shader"; @@ -3763,6 +3763,22 @@ BOOL LLViewerShaderMgr::loadShadersInterface() success = gAlphaMaskProgram.createShader(NULL, NULL); } + if (success) + { + gReflectionMipProgram.mName = "Reflection Mip Shader"; + gReflectionMipProgram.mShaderFiles.clear(); + gReflectionMipProgram.mShaderFiles.push_back(make_pair("interface/splattexturerectV.glsl", GL_VERTEX_SHADER_ARB)); + gReflectionMipProgram.mShaderFiles.push_back(make_pair("interface/reflectionmipF.glsl", GL_FRAGMENT_SHADER_ARB)); + gReflectionMipProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; + success = gReflectionMipProgram.createShader(NULL, NULL); + if (success) + { + gReflectionMipProgram.bind(); + gReflectionMipProgram.uniform1i(sScreenMap, 0); + gReflectionMipProgram.unbind(); + } + } + if( !success ) { mShaderLevel[SHADER_INTERFACE] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 50a3daebaa..f0187db302 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -161,6 +161,7 @@ extern LLGLSLShader gOcclusionCubeProgram; extern LLGLSLShader gCustomAlphaProgram; extern LLGLSLShader gGlowCombineProgram; extern LLGLSLShader gSplatTextureRectProgram; +extern LLGLSLShader gReflectionMipProgram; extern LLGLSLShader gGlowCombineFXAAProgram; extern LLGLSLShader gDebugProgram; extern LLGLSLShader gClipProgram; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index f562a9458b..9bda4bbf92 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -228,6 +228,7 @@ extern BOOL gDebugClicks; extern BOOL gDisplaySwapBuffers; extern BOOL gDepthDirty; extern BOOL gResizeScreenTexture; +extern BOOL gCubeSnapshot; LLViewerWindow *gViewerWindow = NULL; @@ -5267,29 +5268,30 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ return true; } -BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) +void display_cube_face(); + +BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face) { // NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; llassert(LLPipeline::sRenderDeferred); + llassert(!gCubeSnapshot); //assert a snapshot isn't already in progress - U32 res = cubemap->getResolution(); + U32 res = LLRenderTarget::sCurResX; llassert(res <= gPipeline.mDeferredScreen.getWidth()); llassert(res <= gPipeline.mDeferredScreen.getHeight()); - - // save current view/camera settings so we can restore them afterwards S32 old_occlusion = LLPipeline::sUseOcclusion; // set new parameters specific to the 360 requirements LLPipeline::sUseOcclusion = 0; LLViewerCamera* camera = LLViewerCamera::getInstance(); - LLVector3 old_origin = camera->getOrigin(); - F32 old_fov = camera->getView(); - F32 old_aspect = camera->getAspect(); - F32 old_yaw = camera->getYaw(); + + LLViewerCamera saved_camera = LLViewerCamera::instance(); + glh::matrix4f saved_proj = get_current_projection(); + glh::matrix4f saved_mod = get_current_modelview(); // camera constants for the square, cube map capture image camera->setAspect(1.0); // must set aspect ratio first to avoid undesirable clamping of vertical FoV @@ -5297,8 +5299,6 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) camera->yaw(0.0); camera->setOrigin(origin); - gDisplaySwapBuffers = FALSE; - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI) ? TRUE : FALSE; @@ -5306,55 +5306,38 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) { LLPipeline::toggleRenderDebugFeature(LLPipeline::RENDER_DEBUG_FEATURE_UI); } - - LLPipeline::sShowHUDAttachments = FALSE; - LLRect window_rect = getWorldViewRectRaw(); - - LLRenderTarget scratch_space; // TODO: hold onto "scratch space" render target and allocate oncer per session (allocate takes > 1ms) - U32 color_fmt = GL_RGBA; - const bool use_depth_buffer = true; - const bool use_stencil_buffer = true; - if (scratch_space.allocate(res, res, color_fmt, use_depth_buffer, use_stencil_buffer)) - { - mWorldViewRectRaw.set(0, res, res, 0); - scratch_space.bindTarget(); - } - else + BOOL prev_draw_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES); + if (prev_draw_particles) { - return FALSE; + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); } + LLPipeline::sShowHUDAttachments = FALSE; + LLRect window_rect = getWorldViewRectRaw(); - // "target" parameter of glCopyTexImage2D for each side of cubemap - U32 targets[6] = { - GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB - }; + mWorldViewRectRaw.set(0, res, res, 0); - // these are the 6 directions we will point the camera, see LLCubeMap::mTargets + // these are the 6 directions we will point the camera, see LLCubeMapArray::sTargets LLVector3 look_dirs[6] = { - LLVector3(-1, 0, 0), LLVector3(1, 0, 0), - LLVector3(0, -1, 0), + LLVector3(-1, 0, 0), LLVector3(0, 1, 0), - LLVector3(0, 0, -1), - LLVector3(0, 0, 1) + LLVector3(0, -1, 0), + LLVector3(0, 0, 1), + LLVector3(0, 0, -1) }; LLVector3 look_upvecs[6] = { LLVector3(0, -1, 0), LLVector3(0, -1, 0), - LLVector3(0, 0, -1), LLVector3(0, 0, 1), + LLVector3(0, 0, -1), LLVector3(0, -1, 0), LLVector3(0, -1, 0) }; // for each of six sides of cubemap - for (int i = 0; i < 6; ++i) + //for (int i = 0; i < 6; ++i) + int i = face; { // set up camera to look in each direction camera->lookDir(look_dirs[i], look_upvecs[i]); @@ -5368,22 +5351,12 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) gDisplaySwapBuffers = FALSE; // actually render the scene - const U32 subfield = 0; - const bool do_rebuild = true; - const F32 zoom = 1.0; - const bool for_snapshot = TRUE; - display(do_rebuild, zoom, subfield, for_snapshot); - - // copy results to cube map face - cubemap->enable(0); - cubemap->bind(); - glCopyTexImage2D(targets[i], 0, GL_RGB, 0, 0, res, res, 0); - gGL.getTexUnit(0)->disable(); - cubemap->disable(); + gCubeSnapshot = TRUE; + display_cube_face(); + gCubeSnapshot = FALSE; } - gDisplaySwapBuffers = FALSE; - gDepthDirty = TRUE; + gDisplaySwapBuffers = TRUE; if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { @@ -5393,23 +5366,23 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) } } + if (prev_draw_particles) + { + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); + } + LLPipeline::sShowHUDAttachments = TRUE; gPipeline.resetDrawOrders(); mWorldViewRectRaw = window_rect; - scratch_space.flush(); - scratch_space.release(); // restore original view/camera/avatar settings settings - camera->setAspect(old_aspect); - camera->setView(old_fov); - camera->yaw(old_yaw); - camera->setOrigin(old_origin); - + *camera = saved_camera; + set_current_modelview(saved_mod); + set_current_projection(saved_proj); LLPipeline::sUseOcclusion = old_occlusion; // ==================================================== - return true; } diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index be4e9a17a5..ac7f8b2e39 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -69,6 +69,7 @@ class LLViewerWindowListener; class LLVOPartGroup; class LLPopupView; class LLCubeMap; +class LLCubeMapArray; #define PICK_HALF_WIDTH 5 #define PICK_DIAMETER (2 * PICK_HALF_WIDTH + 1) @@ -365,8 +366,9 @@ public: // take a cubemap snapshot // origin - vantage point to take the snapshot from - // cubemap - cubemap to store the results - BOOL cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap); + // cubearray - cubemap array for storing the results + // index - cube index in the array to use (cube index, not face-layer) + BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face); // special implementation of simpleSnapshot for reflection maps diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 17d92fda38..ef6ee4b910 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -106,6 +106,7 @@ LLPointer LLVOVolume::sObjectMediaClient = NULL; LLPointer LLVOVolume::sObjectMediaNavigateClient = NULL; extern BOOL gGLDebugLoggingEnabled; +extern BOOL gCubeSnapshot; // Implementation class of LLMediaDataClientObject. See llmediadataclient.h class LLMediaDataClientObjectImpl : public LLMediaDataClientObject @@ -718,7 +719,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; // Update the pixel area of all faces - if (mDrawable.isNull()) + if (mDrawable.isNull() || gCubeSnapshot) { return; } @@ -3388,6 +3389,11 @@ F32 LLVOVolume::getSpotLightPriority() const void LLVOVolume::updateSpotLightPriority() { + if (gCubeSnapshot) + { + return; + } + F32 r = getLightRadius(); LLVector3 pos = mDrawable->getPositionAgent(); @@ -5497,6 +5503,8 @@ static inline void add_face(T*** list, U32* count, T* face) void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; + llassert(!gCubeSnapshot); + if (group->changeLOD()) { group->mLastUpdateDistance = group->mDistance; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 8abb49fba8..8837038d02 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -820,7 +820,7 @@ void LLWorld::updateNetStats() void LLWorld::printPacketsLost() { - LL_INFOS() << "Simulators:" << LL_ENDL; + LL_INFOS() << "Simulators:" << LL_ENDL; LL_INFOS() << "----------" << LL_ENDL; LLCircuitData *cdp = NULL; @@ -855,6 +855,7 @@ F32 LLWorld::getLandFarClip() const void LLWorld::setLandFarClip(const F32 far_clip) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; static S32 const rwidth = (S32)REGION_WIDTH_U32; S32 const n1 = (llceil(mLandFarClip) - 1) / rwidth; S32 const n2 = (llceil(far_clip) - 1) / rwidth; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ef616f5d83..5eb9817fc4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -227,6 +227,7 @@ extern S32 gBoxFrame; //extern BOOL gHideSelectedObjects; extern BOOL gDisplaySwapBuffers; extern BOOL gDebugGL; +extern BOOL gCubeSnapshot; bool gAvatarBacklight = false; @@ -2006,6 +2007,7 @@ void LLPipeline::updateMove() //static F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera) { + llassert(!gCubeSnapshot); // shouldn't be doing ANY of this during cube snap shots LLVector3 lookAt = center - camera.getOrigin(); F32 dist = lookAt.length(); @@ -2475,7 +2477,7 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera) group->setVisible(); - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { group->updateDistance(camera); } @@ -2581,6 +2583,8 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(!gCubeSnapshot); downsampleDepthBuffer(source, dest, scratch_space); dest.bindTarget(); doOcclusion(camera); @@ -2823,7 +2827,7 @@ void LLPipeline::rebuildPriorityGroups() void LLPipeline::rebuildGroups() { - if (mGroupQ2.empty()) + if (mGroupQ2.empty() || gCubeSnapshot) { return; } @@ -2873,6 +2877,10 @@ void LLPipeline::updateGeom(F32 max_dtime) LLPointer drawablep; LL_RECORD_BLOCK_TIME(FTM_GEO_UPDATE); + if (gCubeSnapshot) + { + return; + } assertInitialized(); @@ -3112,6 +3120,8 @@ void LLPipeline::shiftObjects(const LLVector3 &offset) } } + mReflectionMapManager.shift(offseta); + LLHUDText::shiftAll(offset); LLHUDNameTag::shiftAll(offset); @@ -3292,7 +3302,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) } } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { LLSpatialGroup* last_group = NULL; BOOL fov_changed = LLViewerCamera::getInstance()->isDefaultFOVChanged(); @@ -3374,7 +3384,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) stateSort(drawablep, camera); } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { //avoid redundant stateSort calls group->mLastUpdateDistance = group->mDistance; } @@ -3443,7 +3453,7 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) } } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { //if (drawablep->isVisible()) isVisible() check here is redundant, if it wasn't visible, it wouldn't be here { @@ -3721,21 +3731,26 @@ void LLPipeline::postSort(LLCamera& camera) assertInitialized(); LL_PUSH_CALLSTACKS(); - //rebuild drawable geometry - for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i) - { - LLSpatialGroup* group = *i; - if (!sUseOcclusion || - !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) - { - group->rebuildGeom(); - } - } - LL_PUSH_CALLSTACKS(); - //rebuild groups - sCull->assertDrawMapsEmpty(); - rebuildPriorityGroups(); + if (!gCubeSnapshot) + { + //rebuild drawable geometry + for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i) + { + LLSpatialGroup* group = *i; + if (!sUseOcclusion || + !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) + { + group->rebuildGeom(); + } + } + LL_PUSH_CALLSTACKS(); + //rebuild groups + sCull->assertDrawMapsEmpty(); + + rebuildPriorityGroups(); + } + LL_PUSH_CALLSTACKS(); @@ -3751,7 +3766,7 @@ void LLPipeline::postSort(LLCamera& camera) continue; } - if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY)) + if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY) && !gCubeSnapshot) { //no way this group is going to be drawable without a rebuild group->rebuildGeom(); } @@ -3769,7 +3784,7 @@ void LLPipeline::postSort(LLCamera& camera) LLDrawInfo* info = *k; sCull->pushDrawInfo(j->first, info); - if (!sShadowRender && !sReflectionRender) + if (!sShadowRender && !sReflectionRender && !gCubeSnapshot) { touchTextures(info); addTrianglesDrawn(info->mCount, info->mDrawMode); @@ -3784,7 +3799,7 @@ void LLPipeline::postSort(LLCamera& camera) if (alpha != group->mDrawMap.end()) { //store alpha groups for sorting LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge(); - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { if (bridge) { @@ -4411,7 +4426,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) gGL.loadMatrix(gGLModelView); if (occlude) - { + { // catch uncommon condition where pools at drawpool grass and later are disabled occlude = false; gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -4607,6 +4622,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) if (occlude && cur_type >= LLDrawPool::POOL_GRASS) { + llassert(!gCubeSnapshot); // never do occlusion culling on cube snapshots occlude = false; gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -5925,6 +5941,7 @@ void LLPipeline::setupAvatarLights(bool for_edit) static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_dist) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; F32 inten = light->getLightIntensity(); if (inten < .001f) { @@ -5948,9 +5965,10 @@ static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_ void LLPipeline::calcNearbyLights(LLCamera& camera) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); - if (LLPipeline::sReflectionRender) + if (LLPipeline::sReflectionRender || gCubeSnapshot) { return; } @@ -6133,6 +6151,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) void LLPipeline::setupHWLights(LLDrawPool* pool) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); LLEnvironment& environment = LLEnvironment::instance(); @@ -7608,7 +7627,8 @@ void LLPipeline::renderFinalize() bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && - RenderDepthOfField; + RenderDepthOfField && + !gCubeSnapshot; bool multisample = RenderFSAASamples > 1 && mFXAABuffer.isComplete(); @@ -8196,45 +8216,13 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - channel = shader.enableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) + channel = shader.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); + if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { - mReflectionMaps.resize(8); //TODO -- declare the number of reflection maps the shader knows about somewhere sane - mReflectionMapManager.getReflectionMaps(mReflectionMaps); - LLVector3 origin[8]; //origin of refmaps in clip space - - // load modelview matrix into matrix 4a - LLMatrix4a modelview; - modelview.loadu(gGLModelView); - LLVector4a oa; // scratch space for transformed origin - - S32 count = 0; - for (auto* refmap : mReflectionMaps) - { - if (refmap) - { - LLCubeMap* cubemap = refmap->mCubeMap; - if (cubemap) - { - cubemap->enable(channel + count); - cubemap->bind(); - - modelview.affineTransform(refmap->mOrigin, oa); - origin[count].set(oa.getF32ptr()); - - count++; - } - } - } - - if (count > 0) - { - LLStaticHashedString refmapCount("refmapCount"); - LLStaticHashedString refOrigin("refOrigin"); - shader.uniform1i(refmapCount, count); - shader.uniform3fv(refOrigin, count, (F32*)origin); - setup_env_mat = true; - } + // see comments in class2/deferred/softenLightF.glsl for what these uniforms mean + mReflectionMapManager.mTexture->bind(channel); + mReflectionMapManager.setUniforms(); + setup_env_mat = true; } if (setup_env_mat) @@ -8276,7 +8264,14 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); + /*if (gCubeSnapshot) + { // we only really care about the first two values, but the shader needs increasing separation between clip planes + shader.uniform4f(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1.f, 64.f, 128.f, 256.f); + } + else*/ + { + shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); + } shader.uniform1f(LLShaderMgr::DEFERRED_SUN_WASH, RenderDeferredSunWash); shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_NOISE, RenderShadowNoise); shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); @@ -8469,66 +8464,78 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) } if (RenderDeferredSSAO) - { // soften direct lighting lightmap - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); - // blur lightmap - screen_target->bindTarget(); - glClearColor(1, 1, 1, 1); - screen_target->clear(GL_COLOR_BUFFER_BIT); - glClearColor(0, 0, 0, 0); - - bindDeferredShader(gDeferredBlurLightProgram); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - LLVector3 go = RenderShadowGaussian; - const U32 kern_length = 4; - F32 blur_size = RenderShadowBlurSize; - F32 dist_factor = RenderShadowBlurDistFactor; - - // sample symmetrically with the middle sample falling exactly on 0.0 - F32 x = 0.f; - - LLVector3 gauss[32]; // xweight, yweight, offset - - for (U32 i = 0; i < kern_length; i++) - { - gauss[i].mV[0] = llgaussian(x, go.mV[0]); - gauss[i].mV[1] = llgaussian(x, go.mV[1]); - gauss[i].mV[2] = x; - x += 1.f; + { + /*if (gCubeSnapshot) + { // SSAO and shadows disabled in reflection maps + deferred_light_target->bindTarget(); + glClearColor(1, 1, 1, 1); + deferred_light_target->clear(); + glClearColor(0, 0, 0, 0); + deferred_light_target->flush(); } + else*/ + { + // soften direct lighting lightmap + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); + // blur lightmap + screen_target->bindTarget(); + glClearColor(1, 1, 1, 1); + screen_target->clear(GL_COLOR_BUFFER_BIT); + glClearColor(0, 0, 0, 0); - gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); - gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor); - gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV); - gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length / 2.f - 0.5f)); + bindDeferredShader(gDeferredBlurLightProgram); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + LLVector3 go = RenderShadowGaussian; + const U32 kern_length = 4; + F32 blur_size = RenderShadowBlurSize; + F32 dist_factor = RenderShadowBlurDistFactor; - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } + // sample symmetrically with the middle sample falling exactly on 0.0 + F32 x = 0.f; + + LLVector3 gauss[32]; // xweight, yweight, offset - screen_target->flush(); - unbindDeferredShader(gDeferredBlurLightProgram); + for (U32 i = 0; i < kern_length; i++) + { + gauss[i].mV[0] = llgaussian(x, go.mV[0]); + gauss[i].mV[1] = llgaussian(x, go.mV[1]); + gauss[i].mV[2] = x; + x += 1.f; + } - bindDeferredShader(gDeferredBlurLightProgram, screen_target); + gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); + gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor); + gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV); + gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length / 2.f - 0.5f)); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - deferred_light_target->bindTarget(); + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } - gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); + screen_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + bindDeferredShader(gDeferredBlurLightProgram, screen_target); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + deferred_light_target->bindTarget(); + + gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); + + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } + deferred_light_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); } - deferred_light_target->flush(); - unbindDeferredShader(gDeferredBlurLightProgram); } stop_glerror(); @@ -8595,7 +8602,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) gPipeline.popRenderTypeMask(); } - bool render_local = RenderLocalLights; + bool render_local = RenderLocalLights; // && !gCubeSnapshot; if (render_local) { @@ -8604,9 +8611,12 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) LLDrawable::drawable_list_t spot_lights; LLDrawable::drawable_list_t fullscreen_spot_lights; - for (U32 i = 0; i < 2; i++) + if (!gCubeSnapshot) { - mTargetShadowSpotLight[i] = NULL; + for (U32 i = 0; i < 2; i++) + { + mTargetShadowSpotLight[i] = NULL; + } } std::list light_colors; @@ -8942,6 +8952,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) popRenderTypeMask(); } + if (!gCubeSnapshot) { // render highlights, etc. renderHighlights(); @@ -9053,6 +9064,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f); } + if (!gCubeSnapshot) { LLDrawable* potential = drawablep; //determine if this is a good light for casting shadows @@ -9146,14 +9158,10 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) } } - channel = shader.disableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) + channel = shader.disableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP); + if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { - for (int i = 0; i < mReflectionMaps.size(); ++i) - { - gGL.getTexUnit(channel + i)->disable(); - } - + mReflectionMapManager.mTexture->unbind(); if (channel == 0) { gGL.getTexUnit(channel)->enable(LLTexUnit::TT_TEXTURE); @@ -9176,7 +9184,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - if (!assertInitialized()) + if (!assertInitialized() || gCubeSnapshot) { return; } @@ -9767,7 +9775,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID - 1]; - doOcclusion(shadow_cam, occlusion_source, occlusion_target); + if (occlude > 1) + { + doOcclusion(shadow_cam, occlusion_source, occlusion_target); + } if (use_shader) { @@ -10163,6 +10174,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) clip = RenderShadowOrthoClipPlanes; mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); + //if (gCubeSnapshot) + { //always do a single 64m shadow in reflection maps + mSunClipPlanes.set(64.f, 128.f, 256.f); + mSunOrthoClipPlanes.set(64.f, 128.f, 256.f); + } + //currently used for amount to extrude frusta corners for constructing shadow frusta //LLVector3 n = RenderShadowNearDist; //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; @@ -10279,9 +10296,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) // convenience array of 4 near clip plane distances F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; - if (mSunDiffuse == LLColor4::black) - { //sun diffuse is totally black, shadows don't matter + { //sun diffuse is totally shadows don't matter LLGLDepthTest depth(GL_TRUE); for (S32 j = 0; j < 4; j++) @@ -10293,7 +10309,21 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - for (S32 j = 0; j < 4; j++) + /*if (gCubeSnapshot) + { + // do one shadow split for cube snapshots, clear the rest + mSunClipPlanes.set(64.f, 64.f, 64.f); + dist[1] = dist[2] = dist[3] = dist[4] = 64.f; + for (S32 j = 1; j < 4; j++) + { + mShadow[j].bindTarget(); + mShadow[j].clear(); + mShadow[j].flush(); + } + }*/ + + //for (S32 j = 0; j < (gCubeSnapshot ? 1 : 4); j++) + for (S32 j = 0; j < 4; j++) { if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) { @@ -10672,142 +10702,145 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (gen_shadow) { - LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); - F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); - - //update shadow targets - for (U32 i = 0; i < 2; i++) - { //for each current shadow - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); - - if (mShadowSpotLight[i].notNull() && - (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || - mShadowSpotLight[i] == mTargetShadowSpotLight[1])) - { //keep this spotlight - mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); - } - else - { //fade out this light - mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); + if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates + { + LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); + F32 fade_amt = gFrameIntervalSeconds.value() + * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + + //update shadow targets + for (U32 i = 0; i < 2; i++) + { //for each current shadow + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); + + if (mShadowSpotLight[i].notNull() && + (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || + mShadowSpotLight[i] == mTargetShadowSpotLight[1])) + { //keep this spotlight + mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); + } + else + { //fade out this light + mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); - if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) - { //faded out, grab one of the pending spots (whichever one isn't already taken) - if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) - { - mShadowSpotLight[i] = mTargetShadowSpotLight[0]; - } - else - { - mShadowSpotLight[i] = mTargetShadowSpotLight[1]; - } - } - } - } + if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) + { //faded out, grab one of the pending spots (whichever one isn't already taken) + if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) + { + mShadowSpotLight[i] = mTargetShadowSpotLight[0]; + } + else + { + mShadowSpotLight[i] = mTargetShadowSpotLight[1]; + } + } + } + } + + for (S32 i = 0; i < 2; i++) + { + set_current_modelview(saved_view); + set_current_projection(saved_proj); - for (S32 i = 0; i < 2; i++) - { - set_current_modelview(saved_view); - set_current_projection(saved_proj); + if (mShadowSpotLight[i].isNull()) + { + continue; + } - if (mShadowSpotLight[i].isNull()) - { - continue; - } + LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); - LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); + if (!volume) + { + mShadowSpotLight[i] = NULL; + continue; + } - if (!volume) - { - mShadowSpotLight[i] = NULL; - continue; - } + LLDrawable* drawable = mShadowSpotLight[i]; - LLDrawable* drawable = mShadowSpotLight[i]; + LLVector3 params = volume->getSpotLightParams(); + F32 fov = params.mV[0]; - LLVector3 params = volume->getSpotLightParams(); - F32 fov = params.mV[0]; + //get agent->light space matrix (modelview) + LLVector3 center = drawable->getPositionAgent(); + LLQuaternion quat = volume->getRenderRotation(); - //get agent->light space matrix (modelview) - LLVector3 center = drawable->getPositionAgent(); - LLQuaternion quat = volume->getRenderRotation(); + //get near clip plane + LLVector3 scale = volume->getScale(); + LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); + at_axis *= quat; - //get near clip plane - LLVector3 scale = volume->getScale(); - LLVector3 at_axis(0,0,-scale.mV[2]*0.5f); - at_axis *= quat; + LLVector3 np = center + at_axis; + at_axis.normVec(); - LLVector3 np = center+at_axis; - at_axis.normVec(); + //get origin that has given fov for plane np, at_axis, and given scale + F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); - //get origin that has given fov for plane np, at_axis, and given scale - F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f); + LLVector3 origin = np - at_axis * dist; - LLVector3 origin = np - at_axis*dist; + LLMatrix4 mat(quat, LLVector4(origin, 1.f)); - LLMatrix4 mat(quat, LLVector4(origin, 1.f)); + view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); - view[i+4] = glh::matrix4f((F32*) mat.mMatrix); + view[i + 4] = view[i + 4].inverse(); - view[i+4] = view[i+4].inverse(); + //get perspective matrix + F32 near_clip = dist + 0.01f; + F32 width = scale.mV[VX]; + F32 height = scale.mV[VY]; + F32 far_clip = dist + volume->getLightRadius() * 1.5f; - //get perspective matrix - F32 near_clip = dist+0.01f; - F32 width = scale.mV[VX]; - F32 height = scale.mV[VY]; - F32 far_clip = dist+volume->getLightRadius()*1.5f; + F32 fovy = fov * RAD_TO_DEG; + F32 aspect = width / height; - F32 fovy = fov * RAD_TO_DEG; - F32 aspect = width/height; - - proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip); + proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); - //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + //translate and scale to from [-1, 1] to [0, 1] + glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, + 0.f, 0.5f, 0.f, 0.5f, + 0.f, 0.f, 0.5f, 0.5f, + 0.f, 0.f, 0.f, 1.f); - set_current_modelview(view[i+4]); - set_current_projection(proj[i+4]); + set_current_modelview(view[i + 4]); + set_current_projection(proj[i + 4]); - mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view; - - for (U32 j = 0; j < 16; j++) - { - gGLLastModelView[j] = mShadowModelview[i+4].m[j]; - gGLLastProjection[j] = mShadowProjection[i+4].m[j]; - } + mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; - mShadowModelview[i+4] = view[i+4]; - mShadowProjection[i+4] = proj[i+4]; + for (U32 j = 0; j < 16; j++) + { + gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; + gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; + } - LLCamera shadow_cam = camera; - shadow_cam.setFar(far_clip); - shadow_cam.setOrigin(origin); + mShadowModelview[i + 4] = view[i + 4]; + mShadowProjection[i + 4] = proj[i + 4]; - LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); + LLCamera shadow_cam = camera; + shadow_cam.setFar(far_clip); + shadow_cam.setOrigin(origin); - stop_glerror(); + LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - mShadow[i+4].bindTarget(); - mShadow[i+4].getViewport(gGLViewport); - mShadow[i+4].clear(); + stop_glerror(); + + mShadow[i + 4].bindTarget(); + mShadow[i + 4].getViewport(gGLViewport); + mShadow[i + 4].clear(); - U32 target_width = mShadow[i+4].getWidth(); + U32 target_width = mShadow[i + 4].getWidth(); - static LLCullResult result[2]; + static LLCullResult result[2]; - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); - RenderSpotLight = drawable; + RenderSpotLight = drawable; - renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width); + renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], FALSE, FALSE, target_width); - RenderSpotLight = nullptr; + RenderSpotLight = nullptr; - mShadow[i+4].flush(); - } + mShadow[i + 4].flush(); + } + } } else { //no spotlight shadows @@ -11526,7 +11559,7 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id ) void LLPipeline::overrideEnvironmentMap() { - mReflectionMapManager.mProbes.clear(); - mReflectionMapManager.addProbe(LLViewerCamera::instance().getOrigin()); + //mReflectionMapManager.mProbes.clear(); + //mReflectionMapManager.addProbe(LLViewerCamera::instance().getOrigin()); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 975380929d..88eaca558a 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -578,7 +578,8 @@ public: RENDER_DEBUG_ATTACHMENT_BYTES = 0x20000000, // not used RENDER_DEBUG_TEXEL_DENSITY = 0x40000000, RENDER_DEBUG_TRIANGLE_COUNT = 0x80000000, - RENDER_DEBUG_IMPOSTORS = 0x100000000 + RENDER_DEBUG_IMPOSTORS = 0x100000000, + RENDER_DEBUG_REFLECTION_PROBES = 0x200000000 }; public: diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index db4e794ed4..0b0f8e17bc 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2911,6 +2911,16 @@ function="World.EnvPreset" function="Advanced.ToggleInfoDisplay" parameter="lights" /> + + + + @@ -3252,10 +3262,10 @@ function="World.EnvPreset" + label="Rebuild Reflection Probes" + name="Rebuild Reflection Probes"> + function="Develop.RebuildReflectionProbes" /> -- cgit v1.3 From 53c692c9597551c9a1ba8eee346432de51d9d22d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 17 May 2022 14:32:07 -0500 Subject: SL-17416 Quick 'n dirty reflection probe override hack. --- indra/newview/app_settings/settings.xml | 14 ++- .../shaders/class2/deferred/softenLightF.glsl | 4 +- indra/newview/llreflectionmap.cpp | 5 + indra/newview/llreflectionmap.h | 6 ++ indra/newview/llreflectionmapmanager.cpp | 101 +++++++++++++++++++++ indra/newview/llreflectionmapmanager.h | 14 +++ indra/newview/llspatialpartition.cpp | 69 +------------- indra/newview/llviewerobject.cpp | 9 +- indra/newview/llviewerobject.h | 8 +- indra/newview/llvovolume.cpp | 20 +++- indra/newview/pipeline.cpp | 7 +- 11 files changed, 183 insertions(+), 74 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9f39ea9c8c..aa2f1e9192 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10280,7 +10280,19 @@ Value 64 - RenderReflectionRes + RenderReflectionProbeTextureHackID + + Comment + HACK -- Any object with a diffuse texture with this ID will be treated as a user override reflection probe. (default is "Violet Info Hub" photo from Library) + Persist + 1 + Type + String + Value + 6b186931-05da-eafa-a3ed-a012a33bbfb6 + + + RenderReflectionRes Comment Reflection map resolution. diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 3a1287e910..3607c325a4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -55,6 +55,7 @@ layout (std140, binding = 1) uniform ReflectionProbes // refIndex.x - cubemap channel in reflectionProbes // refIndex.y - index in refNeighbor of neighbor list (index is ivec4 index, not int index) // refIndex.z - number of neighbors + // refIndex.w - priority ivec4 refIndex[REFMAP_COUNT]; // neighbor list data (refSphere indices, not cubemap array layer) @@ -296,6 +297,7 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) { int i = probeIndex[idx]; float r = refSphere[i].w; // radius of sphere volume + float p = float(refIndex[i].w); // priority float rr = r*r; // radius squred float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) vec3 delta = pos.xyz-refSphere[i].xyz; @@ -310,7 +312,7 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); w *= atten; - + w *= p; // boost weight based on priority col += refcol*w; wsum += w; diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 0cf2f22822..c146a888cf 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -194,6 +194,11 @@ void LLReflectionMap::autoAdjustOrigin() } } } + else if (mViewerObject) + { + mOrigin.load3(mViewerObject->getPositionAgent().mV); + mRadius = mViewerObject->getScale().mV[0]; + } } bool LLReflectionMap::intersects(LLReflectionMap* other) diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index ed1c2680b6..305f33af4b 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -30,6 +30,7 @@ #include "llmemory.h" class LLSpatialGroup; +class LLViewerObject; class alignas(16) LLReflectionMap : public LLRefCount { @@ -80,7 +81,12 @@ public: // set of any LLReflectionMaps that intersect this map (maintained by LLReflectionMapManager std::vector mNeighbors; + // spatial group this probe is tracking (if any) LLSpatialGroup* mGroup = nullptr; + + // viewer object this probe is tracking (if any) + LLViewerObject* mViewerObject = nullptr; + bool mDirty = true; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index a6b704d57d..53c4857b0f 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -274,6 +274,28 @@ LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* gr return nullptr; } +LLReflectionMap* LLReflectionMapManager::registerViewerObject(LLViewerObject* vobj) +{ + llassert(vobj != nullptr); + + LLReflectionMap* probe = new LLReflectionMap(); + probe->mViewerObject = vobj; + probe->mOrigin.load3(vobj->getPositionAgent().mV); + probe->mDirty = true; + + if (gCubeSnapshot) + { //snapshot is in progress, mProbes is being iterated over, defer insertion until next update + mCreateList.push_back(probe); + } + else + { + mProbes.push_back(probe); + } + + return probe; +} + + S32 LLReflectionMapManager::allocateCubeIndex() { for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i) @@ -513,6 +535,7 @@ void LLReflectionMapManager::setUniforms() rpd.refIndex[count][0] = refmap->mCubeIndex; llassert(nc % 4 == 0); rpd.refIndex[count][1] = nc / 4; + rpd.refIndex[count][3] = refmap->mViewerObject ? 10 : 1; S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors { @@ -574,3 +597,81 @@ void LLReflectionMapManager::setUniforms() glBindBufferBase(GL_UNIFORM_BUFFER, 1, mUBO); } + + +void renderReflectionProbe(LLReflectionMap* probe) +{ + + F32* po = probe->mOrigin.getF32ptr(); + + //draw orange line from probe to neighbors + gGL.flush(); + gGL.diffuseColor4f(1, 0.5f, 0, 1); + gGL.begin(gGL.LINES); + for (auto& neighbor : probe->mNeighbors) + { + gGL.vertex3fv(po); + gGL.vertex3fv(neighbor->mOrigin.getF32ptr()); + } + gGL.end(); + gGL.flush(); + +#if 0 + LLSpatialGroup* group = probe->mGroup; + if (group) + { // draw lines from corners of object aabb to reflection probe + + const LLVector4a* bounds = group->getBounds(); + LLVector4a o = bounds[0]; + + gGL.flush(); + gGL.diffuseColor4f(0, 0, 1, 1); + F32* c = o.getF32ptr(); + + const F32* bc = bounds[0].getF32ptr(); + const F32* bs = bounds[1].getF32ptr(); + + // daaw blue lines from corners to center of node + gGL.begin(gGL.LINES); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] + bs[2]); + + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] - bs[2]); + gGL.end(); + + //draw yellow line from center of node to reflection probe origin + gGL.flush(); + gGL.diffuseColor4f(1, 1, 0, 1); + gGL.begin(gGL.LINES); + gGL.vertex3fv(c); + gGL.vertex3fv(po); + gGL.end(); + gGL.flush(); + } +#endif +} + +void LLReflectionMapManager::renderDebug() +{ + gDebugProgram.bind(); + + for (auto& probe : mProbes) + { + renderReflectionProbe(probe); + } + + gDebugProgram.unbind(); +} diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 24ac40b264..f7feabbf66 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -31,6 +31,7 @@ #include "llcubemaparray.h" class LLSpatialGroup; +class LLViewerObject; // number of reflection probes to keep in vram #define LL_REFLECTION_PROBE_COUNT 256 @@ -38,6 +39,9 @@ class LLSpatialGroup; // reflection probe resolution #define LL_REFLECTION_PROBE_RESOLUTION 256 +// reflection probe mininum scale +#define LL_REFLECTION_PROBE_MINIMUM_SCALE 1.f; + class alignas(16) LLReflectionMapManager { LL_ALIGN_NEW @@ -63,12 +67,21 @@ public: // If spatial group should receive a Reflection Probe, will create one for the specified spatial group LLReflectionMap* registerSpatialGroup(LLSpatialGroup* group); + // presently hacked into LLViewerObject::setTE + // Used by LLViewerObjects that are Reflection Probes + // Guaranteed to not return null + LLReflectionMap* registerViewerObject(LLViewerObject* vobj); + // force an update of all probes void rebuild(); // called on region crossing to "shift" probes into new coordinate frame void shift(const LLVector4a& offset); + // debug display, called from llspatialpartition if reflection + // probe debug display is active + void renderDebug(); + private: friend class LLPipeline; @@ -82,6 +95,7 @@ private: // update the neighbors of the given probe void updateNeighbors(LLReflectionMap* probe); + // update UBO used for rendering void setUniforms(); // render target for cube snapshots diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 642b1c964f..b6bd07085b 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1766,65 +1766,6 @@ void renderOctree(LLSpatialGroup* group) // drawBoxOutline(LLVector3(node->getCenter()), LLVector3(node->getSize())); } -void renderReflectionProbes(LLSpatialGroup* group) -{ - if (group->mReflectionProbe) - { // draw lines from corners of object aabb to reflection probe - - const LLVector4a* bounds = group->getBounds(); - LLVector4a o = bounds[0]; - - gGL.flush(); - gGL.diffuseColor4f(0, 0, 1, 1); - F32* c = o.getF32ptr(); - - const F32* bc = bounds[0].getF32ptr(); - const F32* bs = bounds[1].getF32ptr(); - - // daaw blue lines from corners to center of node - gGL.begin(gGL.LINES); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] + bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] + bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] + bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] + bs[2]); - - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] - bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] - bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] - bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] - bs[2]); - gGL.end(); - - F32* po = group->mReflectionProbe->mOrigin.getF32ptr(); - //draw yellow line from center of node to reflection probe origin - gGL.flush(); - gGL.diffuseColor4f(1, 1, 0, 1); - gGL.begin(gGL.LINES); - gGL.vertex3fv(c); - gGL.vertex3fv(po); - gGL.end(); - gGL.flush(); - - //draw orange line from probe to neighbors - gGL.flush(); - gGL.diffuseColor4f(1, 0.5f, 0, 1); - gGL.begin(gGL.LINES); - for (auto& probe : group->mReflectionProbe->mNeighbors) - { - gGL.vertex3fv(po); - gGL.vertex3fv(probe->mOrigin.getF32ptr()); - } - gGL.end(); - gGL.flush(); - } -} std::set visible_selected_groups; void renderVisibility(LLSpatialGroup* group, LLCamera* camera) @@ -3371,12 +3312,6 @@ public: stop_glerror(); } - //draw reflection probes and links between them - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES)) - { - renderReflectionProbes(group); - } - //render visibility wireframe if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) { @@ -3791,8 +3726,7 @@ void LLSpatialPartition::renderDebug() //LLPipeline::RENDER_DEBUG_BUILD_QUEUE | LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA | LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY | - LLPipeline::RENDER_DEBUG_TEXEL_DENSITY | - LLPipeline::RENDER_DEBUG_REFLECTION_PROBES)) + LLPipeline::RENDER_DEBUG_TEXEL_DENSITY)) { return; } @@ -3826,7 +3760,6 @@ void LLSpatialPartition::renderDebug() LLOctreeRenderNonOccluded render_debug(camera); render_debug.traverse(mOctree); - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) { { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 16b294b8e9..6ecf9dd0c4 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -343,6 +343,13 @@ LLViewerObject::~LLViewerObject() { deleteTEImages(); + // unhook from reflection probe manager + if (mReflectionProbe.notNull()) + { + mReflectionProbe->mViewerObject = nullptr; + mReflectionProbe = nullptr; + } + if(mInventory) { mInventory->clear(); // will deref and delete entries @@ -4862,7 +4869,7 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) LLPrimitive::setTE(te, texture_entry); - const LLUUID& image_id = getTE(te)->getID(); + const LLUUID& image_id = getTE(te)->getID(); LLViewerTexture* bakedTexture = getBakedTextureForMagicId(image_id); mTEImages[te] = bakedTexture ? bakedTexture : LLViewerTextureManager::getFetchedTexture(image_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index bef8e3e7e3..5b6d24887c 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -43,6 +43,7 @@ #include "llvertexbuffer.h" #include "llbbox.h" #include "llrigginginfo.h" +#include "llreflectionmap.h" class LLAgent; // TODO: Get rid of this. class LLAudioSource; @@ -845,7 +846,7 @@ protected: F32 mLinksetCost; F32 mPhysicsCost; F32 mLinksetPhysicsCost; - + bool mCostStale; mutable bool mPhysicsShapeUnknown; @@ -904,6 +905,11 @@ private: LLUUID mAttachmentItemID; // ItemID of the associated object is in user inventory. EObjectUpdateType mLastUpdateType; BOOL mLastUpdateCached; + +public: + // reflection probe state + bool mIsReflectionProbe = false; // if true, this object should register itself with LLReflectionProbeManager + LLPointer mReflectionProbe = nullptr; // reflection probe coupled to this viewer object. If not null, should be deregistered when this object is destroyed }; /////////////////// diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index ef6ee4b910..784c0350fc 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2157,7 +2157,7 @@ void LLVOVolume::setNumTEs(const U8 num_tes) return ; } -//virtual +//virtual void LLVOVolume::changeTEImage(S32 index, LLViewerTexture* imagep) { BOOL changed = (mTEImages[index] != imagep); @@ -5690,6 +5690,24 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool is_pbr = false; #endif + // HACK - make this object a Reflection Probe if a certain UUID is detected + static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); + if (facep->getTextureEntry()->getID() == LLUUID(reflection_probe_id)) + { + if (!vobj->mIsReflectionProbe) + { + vobj->mIsReflectionProbe = true; + vobj->mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(vobj); + } + } + else + { + // not a refleciton probe any more + vobj->mIsReflectionProbe = false; + vobj->mReflectionProbe = nullptr; + } + // END HACK + //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group facep->setVertexBuffer(NULL); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5eb9817fc4..4cf8157623 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5150,7 +5150,6 @@ void LLPipeline::renderDebug() glPointSize(1.f); } - // Debug stuff. for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) @@ -5204,6 +5203,12 @@ void LLPipeline::renderDebug() visible_selected_groups.clear(); + //draw reflection probes and links between them + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES) && !hud_only) + { + mReflectionMapManager.renderDebug(); + } + gUIProgram.bind(); if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST) && !hud_only) -- cgit v1.3 From 220afbcda0961df86ad08bbd51d96b8c868b2e62 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 2 Jun 2022 18:42:38 -0500 Subject: SL-17285 Add proper reflection probe support to LLVOVolume, LLPrimitive, and LLPanelVolume --- indra/llprimitive/llprimitive.cpp | 95 +++++++++++++ indra/llprimitive/llprimitive.h | 44 ++++++ .../shaders/class3/deferred/reflectionProbeF.glsl | 21 ++- indra/newview/llpanelvolume.cpp | 100 +++++++++++++ indra/newview/llpanelvolume.h | 3 + indra/newview/llreflectionmap.cpp | 51 ++++--- indra/newview/llreflectionmap.h | 10 +- indra/newview/llreflectionmapmanager.cpp | 25 ++-- indra/newview/lltexturefetch.cpp | 1 + indra/newview/llviewerdisplay.cpp | 1 - indra/newview/llviewerobject.cpp | 5 + indra/newview/llviewerwindow.cpp | 3 +- indra/newview/llviewerwindow.h | 4 +- indra/newview/llvovolume.cpp | 157 ++++++++++++++++++--- indra/newview/llvovolume.h | 14 ++ .../newview/skins/default/xui/en/floater_tools.xml | 58 +++++++- 16 files changed, 519 insertions(+), 73 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index c46e5fb3c5..87a78eb447 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -81,6 +81,14 @@ const F32 LIGHT_MIN_CUTOFF = 0.0f; const F32 LIGHT_DEFAULT_CUTOFF = 0.0f; const F32 LIGHT_MAX_CUTOFF = 180.f; +// reflection probes +const F32 REFLECTION_PROBE_MIN_AMBIANCE = 0.f; +const F32 REFLECTION_PROBE_MAX_AMBIANCE = 1.f; +const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE = 0.f; +const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE = 0.f; +const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE = 1024.f; +const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE = 0.f; + // "Tension" => [0,10], increments of 0.1 const F32 FLEXIBLE_OBJECT_MIN_TENSION = 0.0f; const F32 FLEXIBLE_OBJECT_DEFAULT_TENSION = 1.0f; @@ -1811,6 +1819,93 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ +LLReflectionProbeParams::LLReflectionProbeParams() +{ + mType = PARAMS_REFLECTION_PROBE; +} + +BOOL LLReflectionProbeParams::pack(LLDataPacker& dp) const +{ + dp.packF32(mAmbiance, "ambiance"); + dp.packF32(mClipDistance, "clip_distance"); + dp.packU8(mVolumeType, "volume_type"); + return TRUE; +} + +BOOL LLReflectionProbeParams::unpack(LLDataPacker& dp) +{ + F32 ambiance; + F32 clip_distance; + U8 volume_type; + + dp.unpackF32(ambiance, "ambiance"); + setAmbiance(ambiance); + + dp.unpackF32(clip_distance, "clip_distance"); + setClipDistance(clip_distance); + + dp.unpackU8(volume_type, "volume_type"); + setVolumeType((EInfluenceVolumeType)volume_type); + + return TRUE; +} + +bool LLReflectionProbeParams::operator==(const LLNetworkData& data) const +{ + if (data.mType != PARAMS_REFLECTION_PROBE) + { + return false; + } + const LLReflectionProbeParams* param = (const LLReflectionProbeParams*)&data; + if (param->mAmbiance != mAmbiance) + { + return false; + } + if (param->mClipDistance != mClipDistance) + { + return false; + } + if (param->mVolumeType != mVolumeType) + { + return false; + } + return true; +} + +void LLReflectionProbeParams::copy(const LLNetworkData& data) +{ + const LLReflectionProbeParams* param = (LLReflectionProbeParams*)&data; + mType = param->mType; + mAmbiance = param->mAmbiance; + mClipDistance = param->mClipDistance; + mVolumeType = param->mVolumeType; +} + +LLSD LLReflectionProbeParams::asLLSD() const +{ + LLSD sd; + sd["ambiance"] = getAmbiance(); + sd["clip_distance"] = getClipDistance(); + sd["volume_type"] = getVolumeType(); + return sd; +} + +bool LLReflectionProbeParams::fromLLSD(LLSD& sd) +{ + if (!sd.has("ambiance") || + !sd.has("clip_distance") || + !sd.has("volume_type")) + { + return false; + } + + setAmbiance((F32)sd["ambiance"].asReal()); + setClipDistance((F32)sd["clip_distance"].asReal()); + setVolumeType((EInfluenceVolumeType)sd["volume_type"].asInteger()); + + return true; +} +//============================================================================ LLFlexibleObjectData::LLFlexibleObjectData() { mSimulateLOD = FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS; diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index e23ddd2916..2215133e16 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -108,6 +108,7 @@ public: PARAMS_MESH = 0x60, PARAMS_EXTENDED_MESH = 0x70, PARAMS_RENDER_MATERIAL = 0x80, + PARAMS_REFLECTION_PROBE = 0x90, }; public: @@ -171,6 +172,49 @@ public: F32 getCutoff() const { return mCutoff; } }; +extern const F32 REFLECTION_PROBE_MIN_AMBIANCE; +extern const F32 REFLECTION_PROBE_MAX_AMBIANCE; +extern const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE; +extern const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE; +extern const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE; +extern const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; + +class LLReflectionProbeParams : public LLNetworkData +{ +public: + enum EInfluenceVolumeType : U8 + { + VOLUME_TYPE_SPHERE = 0, // use a sphere influence volume + VOLUME_TYPE_BOX = 1, // use a box influence volume + DEFAULT_VOLUME_TYPE = VOLUME_TYPE_SPHERE + }; + +protected: + F32 mAmbiance = REFLECTION_PROBE_DEFAULT_AMBIANCE; + F32 mClipDistance = REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; + EInfluenceVolumeType mVolumeType = DEFAULT_VOLUME_TYPE; + +public: + LLReflectionProbeParams(); + /*virtual*/ BOOL pack(LLDataPacker& dp) const; + /*virtual*/ BOOL unpack(LLDataPacker& dp); + /*virtual*/ bool operator==(const LLNetworkData& data) const; + /*virtual*/ void copy(const LLNetworkData& data); + // LLSD implementations here are provided by Eddy Stryker. + // NOTE: there are currently unused in protocols + LLSD asLLSD() const; + operator LLSD() const { return asLLSD(); } + bool fromLLSD(LLSD& sd); + + void setAmbiance(F32 ambiance) { mAmbiance = llclamp(ambiance, REFLECTION_PROBE_MIN_AMBIANCE, REFLECTION_PROBE_MAX_AMBIANCE); } + void setClipDistance(F32 distance) { mClipDistance = llclamp(distance, REFLECTION_PROBE_MIN_CLIP_DISTANCE, REFLECTION_PROBE_MAX_CLIP_DISTANCE); } + void setVolumeType(EInfluenceVolumeType type) { mVolumeType = llclamp(type, VOLUME_TYPE_SPHERE, VOLUME_TYPE_BOX); } + + F32 getAmbiance() const { return mAmbiance; } + F32 getClipDistance() const { return mClipDistance; } + EInfluenceVolumeType getVolumeType() const { return mVolumeType; } +}; + //------------------------------------------------- // This structure is also used in the part of the // code that creates new flexible objects. diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 8c1323ba1a..eb9d3f485b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -1,5 +1,5 @@ /** - * @file class2/deferred/reflectionProbeF.glsl + * @file class3/deferred/reflectionProbeF.glsl * * $LicenseInfo:firstyear=2022&license=viewerlgpl$ * Second Life Viewer Source Code @@ -42,6 +42,8 @@ layout (std140, binding = 1) uniform ReflectionProbes mat4 refBox[REFMAP_COUNT]; // list of bounding spheres for reflection probes sorted by distance to camera (closest first) vec4 refSphere[REFMAP_COUNT]; + // extra parameters (currently only .x used for probe ambiance) + vec4 refParams[REFMAP_COUNT]; // index of cube map in reflectionProbes for a corresponding reflection probe // e.g. cube map channel of refSphere[2] is stored in refIndex[2] // refIndex.x - cubemap channel in reflectionProbes @@ -55,9 +57,6 @@ layout (std140, binding = 1) uniform ReflectionProbes // number of reflection probes present in refSphere int refmapCount; - - // intensity of ambient light from reflection probes - float reflectionAmbiance; }; // Inputs @@ -335,7 +334,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, float lod, vec3 c, float r2, int i) } } -vec3 sampleProbes(vec3 pos, vec3 dir, float lod) +vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) { float wsum = 0.0; vec3 col = vec3(0,0,0); @@ -360,7 +359,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); w *= atten; w *= p; // boost weight based on priority - col += refcol*w; + col += refcol*w*max(minweight, refParams[i].x); wsum += w; } @@ -383,7 +382,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) float w = 1.0/d2; w *= w; - col += refcol*w; + col += refcol*w*max(minweight, refParams[i].x); wsum += w; } } @@ -399,7 +398,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) vec3 sampleProbeAmbient(vec3 pos, vec3 dir, float lod) { - vec3 col = sampleProbes(pos, dir, lod); + vec3 col = sampleProbes(pos, dir, lod, 0.f); //desaturate vec3 hcol = col *0.5; @@ -413,7 +412,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, float lod) col *= 0.333333; - return col*reflectionAmbiance; + return col; } @@ -445,12 +444,12 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 l if (glossiness > 0.0) { float lod = (1.0-glossiness)*reflection_lods; - glossenv = sampleProbes(pos, normalize(refnormpersp), lod); + glossenv = sampleProbes(pos, normalize(refnormpersp), lod, 1.f); } if (envIntensity > 0.0) { - legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0); + legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0, 1.f); } } diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 89c558e4f8..e7bbe266e5 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -145,6 +145,16 @@ BOOL LLPanelVolume::postBuild() getChild("Light Ambiance")->setValidateBeforeCommit( precommitValidate); } + // REFLECTION PROBE Parameters + { + childSetCommitCallback("Reflection Probe Checkbox Ctrl", onCommitIsReflectionProbe, this); + childSetCommitCallback("Probe Shape Type Combo Ctrl", onCommitProbe, this); + childSetCommitCallback("Probe Ambiance", onCommitProbe, this); + childSetCommitCallback("Probe Near Clip", onCommitProbe, this); + + + } + // PHYSICS Parameters { // PhysicsShapeType combobox @@ -360,6 +370,40 @@ void LLPanelVolume::getState( ) getChildView("Light Ambiance")->setEnabled(false); } + // Reflection Probe + BOOL is_probe = volobjp && volobjp->getIsReflectionProbe(); + getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); + getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); + + bool probe_enabled = is_probe && editable && single_volume; + + getChildView("Probe Volume Type Ctrl")->setEnabled(probe_enabled); + getChildView("Probe Ambiance")->setEnabled(probe_enabled); + getChildView("Probe Near Clip")->setEnabled(probe_enabled); + + if (!probe_enabled) + { + getChild("Probe Volume Type Ctrl", true)->clear(); + getChild("Probe Ambiance", true)->clear(); + getChild("Probe Near Clip", true)->clear(); + } + else + { + std::string volume_type; + if (volobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + { + volume_type = "Box"; + } + else + { + volume_type = "Sphere"; + } + + getChild("Probe Volume Type Ctrl", true)->setValue(volume_type); + getChild("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); + getChild("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); + } + // Animated Mesh BOOL is_animated_mesh = single_root_volume && root_volobjp && root_volobjp->isAnimatedObject(); getChild("Animated Mesh Checkbox Ctrl")->setValue(is_animated_mesh); @@ -647,6 +691,10 @@ void LLPanelVolume::clearCtrls() getChildView("Light Radius")->setEnabled(false); getChildView("Light Falloff")->setEnabled(false); + getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(false);; + getChildView("Probe Volume Type Ctrl")->setEnabled(false); + getChildView("Probe Ambiance")->setEnabled(false); + getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); getChildView("Flexible1D Checkbox Ctrl")->setEnabled(false); getChildView("FlexNumSections")->setEnabled(false); @@ -684,6 +732,20 @@ void LLPanelVolume::sendIsLight() LL_INFOS() << "update light sent" << LL_ENDL; } +void LLPanelVolume::sendIsReflectionProbe() +{ + LLViewerObject* objectp = mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume* volobjp = (LLVOVolume*)objectp; + + BOOL value = getChild("Reflection Probe Checkbox Ctrl")->getValue(); + volobjp->setIsReflectionProbe(value); + LL_INFOS() << "update reflection probe sent" << LL_ENDL; +} + void LLPanelVolume::sendIsFlexible() { LLViewerObject* objectp = mObject; @@ -927,6 +989,35 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata ) } +//static +void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) +{ + LLPanelVolume* self = (LLPanelVolume*)userdata; + LLViewerObject* objectp = self->mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume* volobjp = (LLVOVolume*)objectp; + + + volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); + volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); + + std::string shape_type = self->getChild("Probe Volume Type Ctrl")->getValue().asString(); + LLReflectionProbeParams::EInfluenceVolumeType volume_type = LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + + if (shape_type == "Sphere") + { + volume_type = LLReflectionProbeParams::VOLUME_TYPE_SPHERE; + } + else if (shape_type == "Box") + { + volume_type = LLReflectionProbeParams::VOLUME_TYPE_BOX; + } + volobjp->setReflectionProbeVolumeType(volume_type); +} + // static void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata ) { @@ -949,6 +1040,15 @@ void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item } //---------------------------------------------------------------------------- +// static +void LLPanelVolume::onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata) +{ + LLPanelVolume* self = (LLPanelVolume*)userdata; + self->sendIsReflectionProbe(); +} + +//---------------------------------------------------------------------------- + // static void LLPanelVolume::onCommitFlexible( LLUICtrl* ctrl, void* userdata ) { diff --git a/indra/newview/llpanelvolume.h b/indra/newview/llpanelvolume.h index 6e49ccb742..16d9ac292d 100644 --- a/indra/newview/llpanelvolume.h +++ b/indra/newview/llpanelvolume.h @@ -56,12 +56,15 @@ public: void refresh(); void sendIsLight(); + void sendIsReflectionProbe(); void sendIsFlexible(); static bool precommitValidate(const LLSD& data); static void onCommitIsLight( LLUICtrl* ctrl, void* userdata); static void onCommitLight( LLUICtrl* ctrl, void* userdata); + static void onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata); + static void onCommitProbe(LLUICtrl* ctrl, void* userdata); void onCommitIsFlexible( LLUICtrl* ctrl, void* userdata); static void onCommitFlexible( LLUICtrl* ctrl, void* userdata); void onCommitAnimatedMeshCheckbox(LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 54a627efd4..f8a2020ccb 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -35,7 +35,6 @@ extern F32SecondsImplicit gFrameTimeSeconds; LLReflectionMap::LLReflectionMap() { - mLastUpdateTime = gFrameTimeSeconds; } void LLReflectionMap::update(U32 resolution, U32 face) @@ -52,7 +51,7 @@ void LLReflectionMap::update(U32 resolution, U32 face) { resolution /= 2; } - gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face); + gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip()); } bool LLReflectionMap::shouldUpdate() @@ -215,6 +214,35 @@ bool LLReflectionMap::intersects(LLReflectionMap* other) return dist < r2; } +extern LLControlGroup gSavedSettings; + +F32 LLReflectionMap::getAmbiance() +{ + static LLCachedControl minimum_ambiance(gSavedSettings, "RenderReflectionProbeAmbiance", 0.f); + + F32 ret = 0.f; + if (mViewerObject && mViewerObject->getVolume()) + { + ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeAmbiance(); + } + + return llmax(ret, minimum_ambiance()); +} + +F32 LLReflectionMap::getNearClip() +{ + const F32 MINIMUM_NEAR_CLIP = 0.1f; + + F32 ret = 0.f; + + if (mViewerObject && mViewerObject->getVolume()) + { + ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeNearClip(); + } + + return llmax(ret, MINIMUM_NEAR_CLIP); +} + bool LLReflectionMap::getBox(LLMatrix4& box) { if (mViewerObject) @@ -224,25 +252,8 @@ bool LLReflectionMap::getBox(LLMatrix4& box) { LLVOVolume* vobjp = (LLVOVolume*)mViewerObject; - U8 profile = volume->getProfileType(); - U8 path = volume->getPathType(); - - if (profile == LL_PCODE_PROFILE_SQUARE && - path == LL_PCODE_PATH_LINE) + if (vobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) { - // nope - /*box = vobjp->getRelativeXform(); - box *= vobjp->mDrawable->getRenderMatrix(); - LLMatrix4 modelview(gGLModelView); - box *= modelview; - box.invert();*/ - - // nope - /*box = LLMatrix4(gGLModelView); - box *= vobjp->mDrawable->getRenderMatrix(); - box *= vobjp->getRelativeXform(); - box.invert();*/ - glh::matrix4f mv(gGLModelView); glh::matrix4f scale; LLVector3 s = vobjp->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f)); diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 4f0f124118..a358bf5fdf 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -55,9 +55,15 @@ public: // return true if given Reflection Map's influence volume intersect's with this one's bool intersects(LLReflectionMap* other); + // Get the ambiance value to use for this probe + F32 getAmbiance(); + + // Get the near clip plane distance to use for this probe + F32 getNearClip(); + // get the encoded bounding box of this probe's influence volume - // will only return a box if this probe has a volume with a square - // profile and a linear path + // will only return a box if this probe is associated with a VOVolume + // with its reflection probe influence volume to to VOLUME_TYPE_BOX // return false if no bounding box (treat as sphere influence volume) bool getBox(LLMatrix4& box); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 34055653d4..60396b6c60 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -127,18 +127,12 @@ void LLReflectionMapManager::update() camera_pos.load3(LLViewerCamera::instance().getOrigin().mV); // process kill list - for (int i = 0; i < mProbes.size(); ) + for (auto& probe : mKillList) { - auto& iter = std::find(mKillList.begin(), mKillList.end(), mProbes[i]); - if (iter != mKillList.end()) + auto& iter = std::find(mProbes.begin(), mProbes.end(), probe); + if (iter != mProbes.end()) { - deleteProbe(i); - mProbes.erase(mProbes.begin() + i); - mKillList.erase(iter); - } - else - { - ++i; + deleteProbe(iter - mProbes.begin()); } } @@ -275,7 +269,7 @@ LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* gr { OctreeNode* node = group->getOctreeNode(); F32 size = node->getSize().getF32ptr()[0]; - if (size >= 7.f && size <= 17.f) + if (size >= 15.f && size <= 17.f) { return addProbe(group); } @@ -514,15 +508,15 @@ void LLReflectionMapManager::updateUniforms() LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; // structure for packing uniform buffer object - // see class2/deferred/softenLightF.glsl + // see class3/deferred/reflectionProbeF.glsl struct ReflectionProbeData { LLMatrix4 refBox[LL_REFLECTION_PROBE_COUNT]; // object bounding box as needed LLVector4 refSphere[LL_REFLECTION_PROBE_COUNT]; //origin and radius of refmaps in clip space + LLVector4 refParams[LL_REFLECTION_PROBE_COUNT]; //extra parameters (currently only ambiance) GLint refIndex[LL_REFLECTION_PROBE_COUNT][4]; GLint refNeighbor[4096]; GLint refmapCount; - GLfloat reflectionAmbiance; }; mReflectionMaps.resize(LL_REFLECTION_PROBE_COUNT); @@ -530,9 +524,6 @@ void LLReflectionMapManager::updateUniforms() ReflectionProbeData rpd; - static LLCachedControl ambiance(gSavedSettings, "RenderReflectionProbeAmbiance", 0.f); - rpd.reflectionAmbiance = ambiance; - // load modelview matrix into matrix 4a LLMatrix4a modelview; modelview.loadu(gGLModelView); @@ -573,6 +564,8 @@ void LLReflectionMapManager::updateUniforms() rpd.refIndex[count][3] = -rpd.refIndex[count][3]; } + rpd.refParams[count].set(refmap->getAmbiance(), 0.f, 0.f, 0.f); + S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors { //LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - refNeighbors"); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 0edaf40c66..35e4bb03ac 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -3400,6 +3400,7 @@ void LLTextureFetch::sendRequestListToSimulators() gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); } S32 packet = req->mLastPacket + 1; + LL_INFOS() << req->mID << ": " << req->mImagePriority << LL_ENDL; gMessageSystem->nextBlockFast(_PREHASH_RequestImage); gMessageSystem->addUUIDFast(_PREHASH_Image, req->mID); gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, (S8)req->mDesiredDiscard); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 1b8e53e667..6d98d9b10e 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1082,7 +1082,6 @@ void display_cube_face() gPipeline.mBackfaceCull = TRUE; - LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); gViewerWindow->setup3DViewport(); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 6ecf9dd0c4..732beab448 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -6028,6 +6028,11 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para { new_block = new LLRenderMaterialParams(); break; + } + case LLNetworkData::PARAMS_REFLECTION_PROBE: + { + new_block = new LLReflectionProbeParams(); + break; } default: { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index a6597e3233..6a60671040 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5270,7 +5270,7 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ void display_cube_face(); -BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face) +BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip) { // NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; @@ -5299,6 +5299,7 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea camera->setView(F_PI_BY_TWO); camera->yaw(0.0); camera->setOrigin(origin); + camera->setNear(near_clip); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index ac7f8b2e39..c9cf7da8c7 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -368,7 +368,9 @@ public: // origin - vantage point to take the snapshot from // cubearray - cubemap array for storing the results // index - cube index in the array to use (cube index, not face-layer) - BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face); + // face - which cube face to update + // near_clip - near clip setting to use + BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip); // special implementation of simpleSnapshot for reflection maps diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 784c0350fc..6aef9ee7c0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -985,7 +985,12 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) // Add it to the pipeline mLightSet gPipeline.setLight(mDrawable, TRUE); } - + + if (getIsReflectionProbe()) + { + updateReflectionProbePtr(); + } + updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away mDrawable->updateDistance(*LLViewerCamera::getInstance(), force_update); @@ -3496,6 +3501,121 @@ F32 LLVOVolume::getLightCutoff() const } } +void LLVOVolume::setIsReflectionProbe(BOOL is_probe) +{ + BOOL was_probe = getIsReflectionProbe(); + if (is_probe != was_probe) + { + if (is_probe) + { + setParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE, TRUE, true); + } + else + { + setParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE, FALSE, true); + } + } + + updateReflectionProbePtr(); +} + +void LLVOVolume::setReflectionProbeAmbiance(F32 ambiance) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getAmbiance() != ambiance) + { + param_block->setAmbiance(ambiance); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeNearClip(F32 near_clip) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getClipDistance() != near_clip) + { + param_block->setClipDistance(near_clip); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getVolumeType() != volume_type) + { + param_block->setVolumeType(volume_type); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + + +BOOL LLVOVolume::getIsReflectionProbe() const +{ + // HACK - make this object a Reflection Probe if a certain UUID is detected + static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); + LLUUID probe_id(reflection_probe_id); + + for (U8 i = 0; i < getNumTEs(); ++i) + { + if (getTE(i)->getID() == probe_id) + { + return true; + } + } + // END HACK + + return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); +} + +F32 LLVOVolume::getReflectionProbeAmbiance() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getAmbiance(); + } + else + { + return 0.f; + } +} + +F32 LLVOVolume::getReflectionProbeNearClip() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getClipDistance(); + } + else + { + return 0.f; + } +} + +LLReflectionProbeParams::EInfluenceVolumeType LLVOVolume::getReflectionProbeVolumeType() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getVolumeType(); + } + else + { + return LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + } +} + U32 LLVOVolume::getVolumeInterfaceID() const { if (mVolumeImpl) @@ -4381,6 +4501,23 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u gPipeline.setLight(mDrawable, is_light); } } + + updateReflectionProbePtr(); +} + +void LLVOVolume::updateReflectionProbePtr() +{ + if (getIsReflectionProbe()) + { + if (mReflectionProbe.isNull()) + { + mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(this); + } + } + else if (mReflectionProbe.notNull()) + { + mReflectionProbe = nullptr; + } } void LLVOVolume::setSelected(BOOL sel) @@ -5690,24 +5827,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool is_pbr = false; #endif - // HACK - make this object a Reflection Probe if a certain UUID is detected - static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); - if (facep->getTextureEntry()->getID() == LLUUID(reflection_probe_id)) - { - if (!vobj->mIsReflectionProbe) - { - vobj->mIsReflectionProbe = true; - vobj->mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(vobj); - } - } - else - { - // not a refleciton probe any more - vobj->mIsReflectionProbe = false; - vobj->mReflectionProbe = nullptr; - } - // END HACK - //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group facep->setVertexBuffer(NULL); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 4cb7a5481c..93a10781c2 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -178,6 +178,9 @@ public: /*virtual*/ void parameterChanged(U16 param_type, bool local_origin); /*virtual*/ void parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_use, bool local_origin); + // update mReflectionProbe based on isReflectionProbe() + void updateReflectionProbePtr(); + /*virtual*/ U32 processUpdateMessage(LLMessageSystem *mesgsys, void **user_data, U32 block_num, const EObjectUpdateType update_type, @@ -281,6 +284,17 @@ public: F32 getLightFalloff(const F32 fudge_factor = 1.f) const; F32 getLightCutoff() const; + // Reflection Probes + void setIsReflectionProbe(BOOL is_probe); + void setReflectionProbeAmbiance(F32 ambiance); + void setReflectionProbeNearClip(F32 near_clip); + void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); + + BOOL getIsReflectionProbe() const; + F32 getReflectionProbeAmbiance() const; + F32 getReflectionProbeNearClip() const; + LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; + // Flexible Objects U32 getVolumeInterfaceID() const; virtual BOOL isFlexible() const; diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 44bdcd86f9..ae4eb64264 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2353,7 +2353,7 @@ even though the user gets a free copy. layout="topleft" left="10" name="Light Intensity" - top_pad="3" + top_delta="32" width="128" /> - + + + + + + + Date: Thu, 9 Jun 2022 14:09:33 -0500 Subject: SL-17551 Add "Select Reflection Probes" menu option and make invisible objects less annoying when alt-zooming in edit mode. --- indra/newview/app_settings/settings.xml | 11 ++++++++ indra/newview/llcontrolavatar.cpp | 5 ++-- indra/newview/llcontrolavatar.h | 1 + indra/newview/llpanelvolume.cpp | 2 +- indra/newview/llreflectionmap.cpp | 2 +- indra/newview/llselectmgr.cpp | 8 +++--- indra/newview/llspatialpartition.cpp | 16 +++++++----- indra/newview/llspatialpartition.h | 2 ++ indra/newview/lltoolselect.cpp | 5 +++- indra/newview/llviewermenu.cpp | 13 ++++++++++ indra/newview/llviewerobject.cpp | 13 +--------- indra/newview/llviewerobject.h | 6 ++--- indra/newview/llviewerobjectlist.cpp | 6 +++++ indra/newview/llviewerwindow.cpp | 29 ++++++++++------------ indra/newview/llviewerwindow.h | 3 ++- indra/newview/llvoavatar.cpp | 4 ++- indra/newview/llvoavatar.h | 2 ++ indra/newview/llvograss.cpp | 2 +- indra/newview/llvograss.h | 1 + indra/newview/llvopartgroup.cpp | 1 + indra/newview/llvopartgroup.h | 1 + indra/newview/llvosurfacepatch.cpp | 2 +- indra/newview/llvosurfacepatch.h | 1 + indra/newview/llvotree.cpp | 2 +- indra/newview/llvotree.h | 1 + indra/newview/llvovolume.cpp | 18 ++++++++++---- indra/newview/llvovolume.h | 3 ++- indra/newview/pipeline.cpp | 11 ++++---- indra/newview/pipeline.h | 1 + indra/newview/skins/default/xui/en/menu_viewer.xml | 9 +++++++ 30 files changed, 120 insertions(+), 61 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f6c5d46c33..6df71e1019 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11191,6 +11191,17 @@ Value 0 + SelectReflectionProbes + + Comment + Select reflection probes + Persist + 1 + Type + Boolean + Value + 1 + SelectOwnedOnly Comment diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index 4a87273372..d4d4f641cf 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -610,6 +610,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -627,7 +628,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV { LLVector4a local_end = end; LLVector4a local_intersection; - if (mRootVolp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (mRootVolp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) @@ -644,7 +645,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV for (std::vector::iterator vol_it = volumes.begin(); vol_it != volumes.end(); ++vol_it) { LLVOVolume *volp = *vol_it; - if (mRootVolp != volp && volp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (mRootVolp != volp && volp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) diff --git a/indra/newview/llcontrolavatar.h b/indra/newview/llcontrolavatar.h index 8e87299f3e..ea91d70e69 100644 --- a/indra/newview/llcontrolavatar.h +++ b/indra/newview/llcontrolavatar.h @@ -68,6 +68,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index f456ee4d4b..fb2cf484f5 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -371,7 +371,7 @@ void LLPanelVolume::getState( ) } // Reflection Probe - BOOL is_probe = volobjp && volobjp->getIsReflectionProbe(); + BOOL is_probe = volobjp && volobjp->isReflectionProbe(); getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index f8a2020ccb..5991d7a170 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -139,7 +139,7 @@ void LLReflectionMap::autoAdjustOrigin() { int face = -1; LLVector4a intersection; - LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, &face, &intersection); + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); if (drawable != nullptr) { hit = true; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 82a165cb35..7b4ba51859 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1066,8 +1066,9 @@ void LLSelectMgr::highlightObjectOnly(LLViewerObject* objectp) return; } - if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) - || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced()))) + if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) + || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced())) + || (!gSavedSettings.getBOOL("SelectReflectionProbes") && !objectp->isReflectionProbe())) { // only select my own objects return; @@ -7127,7 +7128,8 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object, BOOL ignore_select_own if(!ignore_select_owned) { if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) || - (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced()))) + (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced())) || + (!gSavedSettings.getBOOL("SelectReflectionProbes") && object->isReflectionProbe())) { // only select my own objects return FALSE; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 39bb46e6fa..a9e807e0f6 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3819,8 +3819,9 @@ public: LLDrawable* mHit; BOOL mPickTransparent; BOOL mPickRigged; + BOOL mPickUnselectable; - LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) : mStart(start), mEnd(end), @@ -3831,7 +3832,8 @@ public: mTangent(tangent), mHit(NULL), mPickTransparent(pick_transparent), - mPickRigged(pick_rigged) + mPickRigged(pick_rigged), + mPickUnselectable(pick_unselectable) { } @@ -3916,7 +3918,7 @@ public: LLVOAvatar* avatar = (LLVOAvatar*) vobj; if ((mPickRigged) || ((avatar->isSelf()) && (LLFloater::isVisible(gFloaterTools)))) { - LLViewerObject* hit = avatar->lineSegmentIntersectRiggedAttachments(mStart, mEnd, -1, mPickTransparent, mPickRigged, mFaceHit, &intersection, mTexCoord, mNormal, mTangent); + LLViewerObject* hit = avatar->lineSegmentIntersectRiggedAttachments(mStart, mEnd, -1, mPickTransparent, mPickRigged, mPickUnselectable, mFaceHit, &intersection, mTexCoord, mNormal, mTangent); if (hit) { mEnd = intersection; @@ -3932,7 +3934,7 @@ public: } } - if (!skip_check && vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mPickRigged, mFaceHit, &intersection, mTexCoord, mNormal, mTangent)) + if (!skip_check && vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mPickRigged, mPickUnselectable, mFaceHit, &intersection, mTexCoord, mNormal, mTangent)) { mEnd = intersection; // shorten ray so we only find CLOSER hits if (mIntersection) @@ -3952,6 +3954,7 @@ public: LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3960,7 +3963,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co ) { - LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, face_hit, intersection, tex_coord, normal, tangent); + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, tex_coord, normal, tangent); LLDrawable* drawable = intersect.check(mOctree); return drawable; @@ -3969,6 +3972,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3977,7 +3981,7 @@ LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const ) { - LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, face_hit, intersection, tex_coord, normal, tangent); + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, tex_coord, normal, tangent); LLDrawable* drawable = intersect.check(getOctreeNode()); return drawable; diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index e9d84ecf06..bebd8aec85 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -317,6 +317,7 @@ public: LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -400,6 +401,7 @@ public: LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index e52bc0b015..790d9a8ec5 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -84,12 +84,14 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi } BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly"); BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly"); - + BOOL select_probe = gSavedSettings.getBOOL("SelectReflectionProbes"); + // *NOTE: These settings must be cleaned up at bottom of function. if (temp_select || LLSelectMgr::getInstance()->mAllowSelectAvatar) { gSavedSettings.setBOOL("SelectOwnedOnly", FALSE); gSavedSettings.setBOOL("SelectMovableOnly", FALSE); + gSavedSettings.setBOOL("SelectReflectionProbes", FALSE); LLSelectMgr::getInstance()->setForceSelection(TRUE); } @@ -241,6 +243,7 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi { gSavedSettings.setBOOL("SelectOwnedOnly", select_owned); gSavedSettings.setBOOL("SelectMovableOnly", select_movable); + gSavedSettings.setBOOL("SelectReflectionProbes", select_probe); LLSelectMgr::getInstance()->setForceSelection(FALSE); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9c8a666185..b99299528c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7971,6 +7971,18 @@ class LLToolsSelectOnlyMovableObjects : public view_listener_t } }; +class LLToolsSelectReflectionProbes : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + BOOL cur_val = gSavedSettings.getBOOL("SelectReflectionProbes"); + + gSavedSettings.setBOOL("SelectReflectionProbes", !cur_val); + + return true; + } +}; + class LLToolsSelectBySurrounding : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -9200,6 +9212,7 @@ void initialize_menus() view_listener_t::addMenu(new LLToolsSelectTool(), "Tools.SelectTool"); view_listener_t::addMenu(new LLToolsSelectOnlyMyObjects(), "Tools.SelectOnlyMyObjects"); view_listener_t::addMenu(new LLToolsSelectOnlyMovableObjects(), "Tools.SelectOnlyMovableObjects"); + view_listener_t::addMenu(new LLToolsSelectReflectionProbes(), "Tools.SelectReflectionProbes"); view_listener_t::addMenu(new LLToolsSelectBySurrounding(), "Tools.SelectBySurrounding"); view_listener_t::addMenu(new LLToolsShowHiddenSelection(), "Tools.ShowHiddenSelection"); view_listener_t::addMenu(new LLToolsShowSelectionLightRadius(), "Tools.ShowSelectionLightRadius"); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 732beab448..d60fccdee3 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4573,6 +4573,7 @@ BOOL LLViewerObject::lineSegmentIntersect(const LLVector4a& start, const LLVecto S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -5509,18 +5510,6 @@ S32 LLViewerObject::countInventoryContents(LLAssetType::EType type) return count; } - -void LLViewerObject::setCanSelect(BOOL canSelect) -{ - mbCanSelect = canSelect; - for (child_list_t::iterator iter = mChildList.begin(); - iter != mChildList.end(); iter++) - { - LLViewerObject* child = *iter; - child->mbCanSelect = canSelect; - } -} - void LLViewerObject::setDebugText(const std::string &utf8text) { if (utf8text.empty() && !mText) diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 5b6d24887c..ddb0adaa23 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -239,6 +239,7 @@ public: virtual BOOL isMesh() const { return FALSE; } virtual BOOL isRiggedMesh() const { return FALSE; } virtual BOOL hasLightTexture() const { return FALSE; } + virtual BOOL isReflectionProbe() const { return FALSE; } // This method returns true if the object is over land owned by // the agent, one of its groups, or it encroaches and @@ -280,6 +281,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -421,8 +423,6 @@ public: void sendMaterialUpdate() const; - void setCanSelect(BOOL canSelect); - void setDebugText(const std::string &utf8text); void initHudText(); void restoreHudText(); @@ -678,7 +678,7 @@ public: // Selection, picking and rendering variables U32 mGLName; // GL "name" used by selection code - BOOL mbCanSelect; // true if user can select this object by clicking + BOOL mbCanSelect; // true if user can select this object by clicking under any circumstances (even if pick_unselectable is true) private: // Grabbed from UPDATE_FLAGS diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 0e585f13fc..593f593a0f 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1838,6 +1838,8 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 ¢er) void LLViewerObjectList::generatePickList(LLCamera &camera) { + llassert(false); +#if 0 //deprecated LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; LLViewerObject *objectp; @@ -1961,10 +1963,13 @@ void LLViewerObjectList::generatePickList(LLCamera &camera) LLHUDIcon::generatePickIDs(i * step, step); } +#endif } LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) { + llassert(false); +#if 0 std::set::iterator pick_it; for (pick_it = mSelectPickList.begin(); pick_it != mSelectPickList.end(); ++pick_it) { @@ -1973,6 +1978,7 @@ LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) return (*pick_it); } } +#endif return NULL; } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 6a60671040..6613c8ac01 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3371,7 +3371,7 @@ void LLViewerWindow::updateUI() if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) { gDebugRaycastFaceHit = -1; - gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, + gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, &gDebugRaycastFaceHit, &gDebugRaycastIntersection, &gDebugRaycastTexCoord, @@ -4195,13 +4195,11 @@ void LLViewerWindow::pickAsync( S32 x, BOOL pick_rigged, BOOL pick_unselectable) { - BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); - if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) - { - // build mode allows interaction with all transparent objects - // "Show Debug Alpha" means no object actually transparent - pick_transparent = TRUE; - } + // "Show Debug Alpha" means no object actually transparent + if (LLDrawPoolAlpha::sShowDebugAlpha) + { + pick_transparent = TRUE; + } LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, FALSE, TRUE, pick_unselectable, callback); schedulePick(pick_info); @@ -4259,7 +4257,7 @@ void LLViewerWindow::returnEmptyPicks() } // Performs the GL object/land pick. -LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle) +LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, BOOL pick_unselectable) { BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) @@ -4308,6 +4306,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de S32 this_face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a *intersection, LLVector2 *uv, @@ -4378,7 +4377,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de { if (this_object->isHUDAttachment()) // is a HUD object? { - if (this_object->lineSegmentIntersect(mh_start, mh_end, this_face, pick_transparent, pick_rigged, + if (this_object->lineSegmentIntersect(mh_start, mh_end, this_face, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent)) { found = this_object; @@ -4386,7 +4385,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de } else // is a world object { - if (this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent, pick_rigged, + if (this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent)) { found = this_object; @@ -4400,7 +4399,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de if (!found) // if not found in HUD, look in world: { - found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, pick_rigged, + found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent); if (found && !pick_transparent) { @@ -5007,8 +5006,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei F32 depth_conversion_factor_1 = (LLViewerCamera::getInstance()->getFar() + LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear()); F32 depth_conversion_factor_2 = (LLViewerCamera::getInstance()->getFar() - LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear()); - gObjectList.generatePickList(*LLViewerCamera::getInstance()); - // Subimages are in fact partial rendering of the final view. This happens when the final view is bigger than the screen. // In most common cases, scale_factor is 1 and there's no more than 1 iteration on x and y for (int subimage_y = 0; subimage_y < scale_factor; ++subimage_y) @@ -6060,7 +6057,7 @@ void LLPickInfo::fetchResults() } LLViewerObject* hit_object = gViewerWindow->cursorIntersect(mMousePt.mX, mMousePt.mY, 512.f, - NULL, -1, mPickTransparent, mPickRigged, &face_hit, + NULL, -1, mPickTransparent, mPickRigged, mPickUnselectable, &face_hit, &intersection, &uv, &normal, &tangent, &start, &end); mPickPt = mMousePt; @@ -6205,7 +6202,7 @@ void LLPickInfo::getSurfaceInfo() if (objectp) { if (gViewerWindow->cursorIntersect(ll_round((F32)mMousePt.mX), ll_round((F32)mMousePt.mY), 1024.f, - objectp, -1, mPickTransparent, mPickRigged, + objectp, -1, mPickTransparent, mPickRigged, mPickUnselectable, &mObjectFace, &intersection, &mSTCoords, diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index c9cf7da8c7..38ec0e1ac8 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -405,7 +405,7 @@ public: BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, BOOL pick_unselectable = FALSE); - LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent, BOOL pick_rigged = FALSE, BOOL pick_particle = FALSE); + LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent, BOOL pick_rigged = FALSE, BOOL pick_particle = FALSE, BOOL pick_unselectable = TRUE); LLHUDIcon* cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 depth, LLVector4a* intersection); @@ -414,6 +414,7 @@ public: S32 this_face = -1, BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, LLVector4a *intersection = NULL, LLVector2 *uv = NULL, diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 314c22eb6c..4ec5c999ac 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1777,6 +1777,7 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -1883,6 +1884,7 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -1913,7 +1915,7 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector { LLViewerObject* attached_object = attachment_iter->get(); - if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 3c3decaad6..a085d773dc 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -164,6 +164,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -174,6 +175,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 9a41eedb54..d109b7b34f 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -758,7 +758,7 @@ void LLVOGrass::updateDrawable(BOOL force_damped) } // virtual -BOOL LLVOGrass::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOGrass::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvograss.h b/indra/newview/llvograss.h index 5634e048eb..63876dc099 100644 --- a/indra/newview/llvograss.h +++ b/indra/newview/llvograss.h @@ -79,6 +79,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 04e9a4f179..cb4315a774 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -485,6 +485,7 @@ BOOL LLVOPartGroup::lineSegmentIntersect(const LLVector4a& start, const LLVector S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h index 4e4d6e609d..a45d381dfa 100644 --- a/indra/newview/llvopartgroup.h +++ b/indra/newview/llvopartgroup.h @@ -74,6 +74,7 @@ public: S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index b0af565867..6b56eaeb4a 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -880,7 +880,7 @@ void LLVOSurfacePatch::getGeomSizesEast(const S32 stride, const S32 east_stride, } } -BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvosurfacepatch.h b/indra/newview/llvosurfacepatch.h index 884dbb3be3..aed67162d1 100644 --- a/indra/newview/llvosurfacepatch.h +++ b/indra/newview/llvosurfacepatch.h @@ -85,6 +85,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 493162b47b..e26791aa29 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -1170,7 +1170,7 @@ void LLVOTree::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) mDrawable->setPositionGroup(pos); } -BOOL LLVOTree::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOTree::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h index 93c22d2da3..996e970cf8 100644 --- a/indra/newview/llvotree.h +++ b/indra/newview/llvotree.h @@ -111,6 +111,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 6aef9ee7c0..8f5d2d1c29 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -986,7 +986,7 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) gPipeline.setLight(mDrawable, TRUE); } - if (getIsReflectionProbe()) + if (isReflectionProbe()) { updateReflectionProbePtr(); } @@ -3503,7 +3503,7 @@ F32 LLVOVolume::getLightCutoff() const void LLVOVolume::setIsReflectionProbe(BOOL is_probe) { - BOOL was_probe = getIsReflectionProbe(); + BOOL was_probe = isReflectionProbe(); if (is_probe != was_probe) { if (is_probe) @@ -3559,7 +3559,7 @@ void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenc } -BOOL LLVOVolume::getIsReflectionProbe() const +BOOL LLVOVolume::isReflectionProbe() const { // HACK - make this object a Reflection Probe if a certain UUID is detected static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); @@ -4507,7 +4507,7 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u void LLVOVolume::updateReflectionProbePtr() { - if (getIsReflectionProbe()) + if (isReflectionProbe()) { if (mReflectionProbe.isNull()) { @@ -4717,7 +4717,7 @@ LLVector3 LLVOVolume::volumeDirectionToAgent(const LLVector3& dir) const } -BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { @@ -4728,6 +4728,14 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& return FALSE; } + if (!pick_unselectable) + { + if (!LLSelectMgr::instance().canSelectObject(this)) + { + return FALSE; + } + } + BOOL ret = FALSE; LLVolume* volume = getVolume(); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 93a10781c2..ad7a2c5606 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -151,6 +151,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -290,7 +291,7 @@ public: void setReflectionProbeNearClip(F32 near_clip); void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); - BOOL getIsReflectionProbe() const; + BOOL isReflectionProbe() const override; F32 getReflectionProbeAmbiance() const; F32 getReflectionProbeNearClip() const; LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3332185bfd..20a21a685c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6988,7 +6988,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_PARTICLE); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, face_hit, &position, NULL, NULL, NULL); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, TRUE, face_hit, &position, NULL, NULL, NULL); if (hit) { drawable = hit; @@ -7016,6 +7016,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, bool pick_rigged, + bool pick_unselectable, S32* face_hit, LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -7049,7 +7050,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(j); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7106,7 +7107,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_AVATAR); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); if (hit) { LLVector4a delta; @@ -7194,7 +7195,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector4a& start, c LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); if (part) { - LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, face_hit, intersection, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, TRUE, face_hit, intersection, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7695,7 +7696,7 @@ void LLPipeline::renderFinalize() LLVector4a result; result.clear(); - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, NULL, &result); + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); focus_point.set(result.getF32ptr()); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index bb2e1d65ae..f4c55bde7d 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -188,6 +188,7 @@ public: LLViewerObject* lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, bool pick_rigged, + bool pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 0b0f8e17bc..159b9aebd0 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1417,6 +1417,15 @@ function="World.EnvPreset" function="Tools.SelectOnlyMovableObjects" parameter="movable" /> + + + + -- cgit v1.3 From 03d85bfb33f53e658256d8bedcf0b4262226cf90 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Jun 2022 19:43:21 -0500 Subject: SL-17573 Add "dynamic" checkbox, also followup on SL-17551 and do "Select Invisible Objects" checkbox instead of "Select Reflection Probes" --- indra/llprimitive/llprimitive.cpp | 103 +++++++++++++-------- indra/llprimitive/llprimitive.h | 15 +-- indra/newview/app_settings/settings.xml | 4 +- indra/newview/llpanelvolume.cpp | 37 ++++---- indra/newview/llreflectionmap.cpp | 14 ++- indra/newview/llreflectionmap.h | 3 + indra/newview/llselectmgr.cpp | 6 +- indra/newview/lltoolselect.cpp | 10 +- indra/newview/llviewermenu.cpp | 8 +- indra/newview/llviewerwindow.cpp | 46 +++++++-- indra/newview/llviewerwindow.h | 2 +- indra/newview/llvovolume.cpp | 36 +++++-- indra/newview/llvovolume.h | 6 +- indra/newview/pipeline.cpp | 9 -- .../newview/skins/default/xui/en/floater_tools.xml | 17 +++- indra/newview/skins/default/xui/en/menu_viewer.xml | 10 +- 16 files changed, 205 insertions(+), 121 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 6044048d09..9e0a079fd9 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1819,92 +1819,117 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ +//============================================================================ + LLReflectionProbeParams::LLReflectionProbeParams() { mType = PARAMS_REFLECTION_PROBE; } -BOOL LLReflectionProbeParams::pack(LLDataPacker& dp) const +BOOL LLReflectionProbeParams::pack(LLDataPacker &dp) const { - dp.packF32(mAmbiance, "ambiance"); + dp.packF32(mAmbiance, "ambiance"); dp.packF32(mClipDistance, "clip_distance"); - dp.packU8(mVolumeType, "volume_type"); - return TRUE; + dp.packU8(mFlags, "flags"); + return TRUE; } -BOOL LLReflectionProbeParams::unpack(LLDataPacker& dp) +BOOL LLReflectionProbeParams::unpack(LLDataPacker &dp) { - F32 ambiance; + F32 ambiance; F32 clip_distance; - U8 volume_type; - - dp.unpackF32(ambiance, "ambiance"); - setAmbiance(ambiance); + dp.unpackF32(ambiance, "ambiance"); + setAmbiance(ambiance); + dp.unpackF32(clip_distance, "clip_distance"); - setClipDistance(clip_distance); - - dp.unpackU8(volume_type, "volume_type"); - setVolumeType((EInfluenceVolumeType)volume_type); - - return TRUE; + setClipDistance(clip_distance); + + dp.unpackU8(mFlags, "flags"); + + return TRUE; } bool LLReflectionProbeParams::operator==(const LLNetworkData& data) const { - if (data.mType != PARAMS_REFLECTION_PROBE) - { - return false; - } - const LLReflectionProbeParams* param = (const LLReflectionProbeParams*)&data; - if (param->mAmbiance != mAmbiance) - { - return false; - } + if (data.mType != PARAMS_REFLECTION_PROBE) + { + return false; + } + const LLReflectionProbeParams *param = (const LLReflectionProbeParams*)&data; + if (param->mAmbiance != mAmbiance) + { + return false; + } if (param->mClipDistance != mClipDistance) { return false; } - if (param->mVolumeType != mVolumeType) + if (param->mFlags != mFlags) { return false; } - return true; + return true; } void LLReflectionProbeParams::copy(const LLNetworkData& data) { - const LLReflectionProbeParams* param = (LLReflectionProbeParams*)&data; - mType = param->mType; - mAmbiance = param->mAmbiance; + const LLReflectionProbeParams *param = (LLReflectionProbeParams*)&data; + mType = param->mType; + mAmbiance = param->mAmbiance; mClipDistance = param->mClipDistance; - mVolumeType = param->mVolumeType; + mFlags = param->mFlags; } LLSD LLReflectionProbeParams::asLLSD() const { - LLSD sd; - sd["ambiance"] = getAmbiance(); + LLSD sd; + sd["ambiance"] = getAmbiance(); sd["clip_distance"] = getClipDistance(); - sd["volume_type"] = (U8) getVolumeType(); - return sd; + sd["flags"] = mFlags; + return sd; } bool LLReflectionProbeParams::fromLLSD(LLSD& sd) { if (!sd.has("ambiance") || !sd.has("clip_distance") || - !sd.has("volume_type")) + !sd.has("flags")) { return false; } - setAmbiance((F32)sd["ambiance"].asReal()); + setAmbiance((F32)sd["ambiance"].asReal()); setClipDistance((F32)sd["clip_distance"].asReal()); - setVolumeType((EInfluenceVolumeType)sd["volume_type"].asInteger()); - + mFlags = (U8) sd["flags"].asInteger(); + return true; } + +void LLReflectionProbeParams::setIsBox(bool is_box) +{ + if (is_box) + { + mFlags |= FLAG_BOX_VOLUME; + } + else + { + mFlags &= ~FLAG_BOX_VOLUME; + } +} + +void LLReflectionProbeParams::setIsDynamic(bool is_dynamic) +{ + if (is_dynamic) + { + mFlags |= FLAG_DYNAMIC; + } + else + { + mFlags &= ~FLAG_DYNAMIC; + } +} + //============================================================================ LLFlexibleObjectData::LLFlexibleObjectData() { diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 2215133e16..25196fb894 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -182,17 +182,16 @@ extern const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; class LLReflectionProbeParams : public LLNetworkData { public: - enum EInfluenceVolumeType : U8 + enum EFlags : U8 { - VOLUME_TYPE_SPHERE = 0, // use a sphere influence volume - VOLUME_TYPE_BOX = 1, // use a box influence volume - DEFAULT_VOLUME_TYPE = VOLUME_TYPE_SPHERE + FLAG_BOX_VOLUME = 0x01, // use a box influence volume + FLAG_DYNAMIC = 0x02, // render dynamic objects (avatars) into this Reflection Probe }; protected: F32 mAmbiance = REFLECTION_PROBE_DEFAULT_AMBIANCE; F32 mClipDistance = REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; - EInfluenceVolumeType mVolumeType = DEFAULT_VOLUME_TYPE; + U8 mFlags = 0; public: LLReflectionProbeParams(); @@ -208,11 +207,13 @@ public: void setAmbiance(F32 ambiance) { mAmbiance = llclamp(ambiance, REFLECTION_PROBE_MIN_AMBIANCE, REFLECTION_PROBE_MAX_AMBIANCE); } void setClipDistance(F32 distance) { mClipDistance = llclamp(distance, REFLECTION_PROBE_MIN_CLIP_DISTANCE, REFLECTION_PROBE_MAX_CLIP_DISTANCE); } - void setVolumeType(EInfluenceVolumeType type) { mVolumeType = llclamp(type, VOLUME_TYPE_SPHERE, VOLUME_TYPE_BOX); } + void setIsBox(bool is_box); + void setIsDynamic(bool is_dynamic); F32 getAmbiance() const { return mAmbiance; } F32 getClipDistance() const { return mClipDistance; } - EInfluenceVolumeType getVolumeType() const { return mVolumeType; } + bool getIsBox() const { return (mFlags & FLAG_BOX_VOLUME) != 0; } + bool getIsDynamic() const { return (mFlags & FLAG_DYNAMIC) != 0; } }; //------------------------------------------------- diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 6df71e1019..327dfe6955 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11191,10 +11191,10 @@ Value 0 - SelectReflectionProbes + SelectInvisibleObjects Comment - Select reflection probes + Select invisible objects Persist 1 Type diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index fb2cf484f5..ddce22fa20 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -147,8 +147,9 @@ BOOL LLPanelVolume::postBuild() // REFLECTION PROBE Parameters { - childSetCommitCallback("Reflection Probe Checkbox Ctrl", onCommitIsReflectionProbe, this); - childSetCommitCallback("Probe Volume Type Ctrl", onCommitProbe, this); + childSetCommitCallback("Reflection Probe", onCommitIsReflectionProbe, this); + childSetCommitCallback("Probe Dynamic", onCommitProbe, this); + childSetCommitCallback("Probe Volume Type", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); @@ -372,25 +373,27 @@ void LLPanelVolume::getState( ) // Reflection Probe BOOL is_probe = volobjp && volobjp->isReflectionProbe(); - getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); - getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); + getChild("Reflection Probe")->setValue(is_probe); + getChildView("Reflection Probe")->setEnabled(editable && single_volume && volobjp); bool probe_enabled = is_probe && editable && single_volume; - getChildView("Probe Volume Type Ctrl")->setEnabled(probe_enabled); + getChildView("Probe Dynamic")->setEnabled(probe_enabled); + getChildView("Probe Volume Type")->setEnabled(probe_enabled); getChildView("Probe Ambiance")->setEnabled(probe_enabled); getChildView("Probe Near Clip")->setEnabled(probe_enabled); if (!probe_enabled) { - getChild("Probe Volume Type Ctrl", true)->clear(); + getChild("Probe Volume Type", true)->clear(); getChild("Probe Ambiance", true)->clear(); getChild("Probe Near Clip", true)->clear(); + getChild("Probe Dynamic", true)->clear(); } else { std::string volume_type; - if (volobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + if (volobjp->getReflectionProbeIsBox()) { volume_type = "Box"; } @@ -399,9 +402,10 @@ void LLPanelVolume::getState( ) volume_type = "Sphere"; } - getChild("Probe Volume Type Ctrl", true)->setValue(volume_type); + getChild("Probe Volume Type", true)->setValue(volume_type); getChild("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); getChild("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); + getChild("Probe Dynamic", true)->setValue(volobjp->getReflectionProbeIsDynamic()); } // Animated Mesh @@ -692,7 +696,8 @@ void LLPanelVolume::clearCtrls() getChildView("Light Falloff")->setEnabled(false); getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(false);; - getChildView("Probe Volume Type Ctrl")->setEnabled(false); + getChildView("Probe Volume Type")->setEnabled(false); + getChildView("Probe Dynamic")->setEnabled(false); getChildView("Probe Ambiance")->setEnabled(false); getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); @@ -1003,19 +1008,11 @@ void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); + volobjp->setReflectionProbeIsDynamic(self->getChild("Probe Dynamic")->getValue().asBoolean()); - std::string shape_type = self->getChild("Probe Volume Type Ctrl")->getValue().asString(); - LLReflectionProbeParams::EInfluenceVolumeType volume_type = LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + std::string shape_type = self->getChild("Probe Volume Type")->getValue().asString(); - if (shape_type == "Sphere") - { - volume_type = LLReflectionProbeParams::VOLUME_TYPE_SPHERE; - } - else if (shape_type == "Box") - { - volume_type = LLReflectionProbeParams::VOLUME_TYPE_BOX; - } - volobjp->setReflectionProbeVolumeType(volume_type); + volobjp->setReflectionProbeIsBox(shape_type == "Box"); } // static diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 5991d7a170..39e0841fc5 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -51,7 +51,7 @@ void LLReflectionMap::update(U32 resolution, U32 face) { resolution /= 2; } - gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip()); + gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip(), getIsDynamic()); } bool LLReflectionMap::shouldUpdate() @@ -243,6 +243,16 @@ F32 LLReflectionMap::getNearClip() return llmax(ret, MINIMUM_NEAR_CLIP); } +bool LLReflectionMap::getIsDynamic() +{ + if (mViewerObject && mViewerObject->getVolume()) + { + return ((LLVOVolume*)mViewerObject)->getReflectionProbeIsDynamic(); + } + + return false; +} + bool LLReflectionMap::getBox(LLMatrix4& box) { if (mViewerObject) @@ -252,7 +262,7 @@ bool LLReflectionMap::getBox(LLMatrix4& box) { LLVOVolume* vobjp = (LLVOVolume*)mViewerObject; - if (vobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + if (vobjp->getReflectionProbeIsBox()) { glh::matrix4f mv(gGLModelView); glh::matrix4f scale; diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index a358bf5fdf..071568e53c 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -61,6 +61,9 @@ public: // Get the near clip plane distance to use for this probe F32 getNearClip(); + // Return true if this probe should include avatars in its reflection map + bool getIsDynamic(); + // get the encoded bounding box of this probe's influence volume // will only return a box if this probe is associated with a VOVolume // with its reflection probe influence volume to to VOLUME_TYPE_BOX diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 7b4ba51859..853703b4d5 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1067,8 +1067,7 @@ void LLSelectMgr::highlightObjectOnly(LLViewerObject* objectp) } if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) - || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced())) - || (!gSavedSettings.getBOOL("SelectReflectionProbes") && !objectp->isReflectionProbe())) + || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced()))) { // only select my own objects return; @@ -7128,8 +7127,7 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object, BOOL ignore_select_own if(!ignore_select_owned) { if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) || - (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced())) || - (!gSavedSettings.getBOOL("SelectReflectionProbes") && object->isReflectionProbe())) + (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced()))) { // only select my own objects return FALSE; diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 790d9a8ec5..c6f3905ddc 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -65,7 +65,8 @@ BOOL LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask) { // do immediate pick query BOOL pick_rigged = false; //gSavedSettings.getBOOL("AnimatedObjectsAllowLeftClick"); - mPick = gViewerWindow->pickImmediate(x, y, TRUE, pick_rigged); + BOOL pick_transparent = gSavedSettings.getBOOL("SelectInvisibleObjects"); + mPick = gViewerWindow->pickImmediate(x, y, pick_transparent, pick_rigged); // Pass mousedown to agent LLTool::handleMouseDown(x, y, mask); @@ -84,15 +85,13 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi } BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly"); BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly"); - BOOL select_probe = gSavedSettings.getBOOL("SelectReflectionProbes"); - // *NOTE: These settings must be cleaned up at bottom of function. + // *NOTE: These settings must be cleaned up at bottom of function. if (temp_select || LLSelectMgr::getInstance()->mAllowSelectAvatar) { gSavedSettings.setBOOL("SelectOwnedOnly", FALSE); gSavedSettings.setBOOL("SelectMovableOnly", FALSE); - gSavedSettings.setBOOL("SelectReflectionProbes", FALSE); - LLSelectMgr::getInstance()->setForceSelection(TRUE); + LLSelectMgr::getInstance()->setForceSelection(TRUE); } BOOL extend_select = (pick.mKeyMask == MASK_SHIFT) || (pick.mKeyMask == MASK_CONTROL); @@ -243,7 +242,6 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi { gSavedSettings.setBOOL("SelectOwnedOnly", select_owned); gSavedSettings.setBOOL("SelectMovableOnly", select_movable); - gSavedSettings.setBOOL("SelectReflectionProbes", select_probe); LLSelectMgr::getInstance()->setForceSelection(FALSE); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index b99299528c..b7f94a7e0c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7971,13 +7971,13 @@ class LLToolsSelectOnlyMovableObjects : public view_listener_t } }; -class LLToolsSelectReflectionProbes : public view_listener_t +class LLToolsSelectInvisibleObjects : public view_listener_t { bool handleEvent(const LLSD& userdata) { - BOOL cur_val = gSavedSettings.getBOOL("SelectReflectionProbes"); + BOOL cur_val = gSavedSettings.getBOOL("SelectInvisibleObjects"); - gSavedSettings.setBOOL("SelectReflectionProbes", !cur_val); + gSavedSettings.setBOOL("SelectInvisibleObjects", !cur_val); return true; } @@ -9212,7 +9212,7 @@ void initialize_menus() view_listener_t::addMenu(new LLToolsSelectTool(), "Tools.SelectTool"); view_listener_t::addMenu(new LLToolsSelectOnlyMyObjects(), "Tools.SelectOnlyMyObjects"); view_listener_t::addMenu(new LLToolsSelectOnlyMovableObjects(), "Tools.SelectOnlyMovableObjects"); - view_listener_t::addMenu(new LLToolsSelectReflectionProbes(), "Tools.SelectReflectionProbes"); + view_listener_t::addMenu(new LLToolsSelectInvisibleObjects(), "Tools.SelectInvisibleObjects"); view_listener_t::addMenu(new LLToolsSelectBySurrounding(), "Tools.SelectBySurrounding"); view_listener_t::addMenu(new LLToolsShowHiddenSelection(), "Tools.ShowHiddenSelection"); view_listener_t::addMenu(new LLToolsShowSelectionLightRadius(), "Tools.ShowSelectionLightRadius"); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 6613c8ac01..1230a6d327 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4196,10 +4196,15 @@ void LLViewerWindow::pickAsync( S32 x, BOOL pick_unselectable) { // "Show Debug Alpha" means no object actually transparent + BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (LLDrawPoolAlpha::sShowDebugAlpha) { pick_transparent = TRUE; } + else if (in_build_mode && !gSavedSettings.getBOOL("SelectInvisibleObjects")) + { + pick_transparent = FALSE; + } LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, FALSE, TRUE, pick_unselectable, callback); schedulePick(pick_info); @@ -4260,7 +4265,7 @@ void LLViewerWindow::returnEmptyPicks() LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, BOOL pick_unselectable) { BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); - if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) + if ((in_build_mode && gSavedSettings.getBOOL("SelectInvisibleObjects")) || LLDrawPoolAlpha::sShowDebugAlpha) { // build mode allows interaction with all transparent objects // "Show Debug Alpha" means no object actually transparent @@ -5267,7 +5272,7 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ void display_cube_face(); -BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip) +BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip, bool dynamic_render) { // NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; @@ -5300,16 +5305,33 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + U32 dynamic_render_types[] = { + LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_CONTROL_AV, + LLPipeline::RENDER_TYPE_PARTICLES + }; + constexpr U32 dynamic_render_type_count = sizeof(dynamic_render_types) / sizeof(U32); + bool prev_dynamic_render_type[dynamic_render_type_count]; + + + if (!dynamic_render) + { + for (int i = 0; i < dynamic_render_type_count; ++i) + { + prev_dynamic_render_type[i] = gPipeline.hasRenderType(dynamic_render_types[i]); + if (prev_dynamic_render_type[i]) + { + gPipeline.toggleRenderType(dynamic_render_types[i]); + } + } + } + BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI) ? TRUE : FALSE; if (prev_draw_ui != false) { LLPipeline::toggleRenderDebugFeature(LLPipeline::RENDER_DEBUG_FEATURE_UI); } - BOOL prev_draw_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES); - if (prev_draw_particles) - { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); - } + LLPipeline::sShowHUDAttachments = FALSE; LLRect window_rect = getWorldViewRectRaw(); @@ -5365,9 +5387,15 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea } } - if (prev_draw_particles) + if (!dynamic_render) { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); + for (int i = 0; i < dynamic_render_type_count; ++i) + { + if (prev_dynamic_render_type[i]) + { + gPipeline.toggleRenderType(dynamic_render_types[i]); + } + } } LLPipeline::sShowHUDAttachments = TRUE; diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 38ec0e1ac8..387a2cb06f 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -370,7 +370,7 @@ public: // index - cube index in the array to use (cube index, not face-layer) // face - which cube face to update // near_clip - near clip setting to use - BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip); + BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip, bool render_avatars); // special implementation of simpleSnapshot for reflection maps diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8f5d2d1c29..3a619b4fcc 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3545,14 +3545,27 @@ void LLVOVolume::setReflectionProbeNearClip(F32 near_clip) } } -void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type) +void LLVOVolume::setReflectionProbeIsBox(bool is_box) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) { - if (param_block->getVolumeType() != volume_type) + if (param_block->getIsBox() != is_box) { - param_block->setVolumeType(volume_type); + param_block->setIsBox(is_box); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getIsDynamic() != is_dynamic) + { + param_block->setIsDynamic(is_dynamic); parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); } } @@ -3603,17 +3616,26 @@ F32 LLVOVolume::getReflectionProbeNearClip() const } } -LLReflectionProbeParams::EInfluenceVolumeType LLVOVolume::getReflectionProbeVolumeType() const +bool LLVOVolume::getReflectionProbeIsBox() const { const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) { - return param_block->getVolumeType(); + return param_block->getIsBox(); } - else + + return false; +} + +bool LLVOVolume::getReflectionProbeIsDynamic() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) { - return LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + return param_block->getIsDynamic(); } + + return false; } U32 LLVOVolume::getVolumeInterfaceID() const diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index ad7a2c5606..1ca6b49c7d 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -289,12 +289,14 @@ public: void setIsReflectionProbe(BOOL is_probe); void setReflectionProbeAmbiance(F32 ambiance); void setReflectionProbeNearClip(F32 near_clip); - void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); + void setReflectionProbeIsBox(bool is_box); + void setReflectionProbeIsDynamic(bool is_dynamic); BOOL isReflectionProbe() const override; F32 getReflectionProbeAmbiance() const; F32 getReflectionProbeNearClip() const; - LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; + bool getReflectionProbeIsBox() const; + bool getReflectionProbeIsDynamic() const; // Flexible Objects U32 getVolumeInterfaceID() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 20a21a685c..28dc3781ba 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6734,15 +6734,6 @@ void LLPipeline::toggleRenderType(U32 type) //static void LLPipeline::toggleRenderTypeControl(U32 type) { - U32 bit = (1< + + label="Select Invisible Objects" + name="Select Invisible Objects"> + control="SelectInvisibleObjects" /> + function="Tools.SelectInvisibleObjects" + parameter="invisible" /> Date: Thu, 23 Jun 2022 16:21:53 -0500 Subject: SL-17653 WIP - Apply GLTF material in Material Editor to selected object when you click "Save" --- indra/llprimitive/llmaterialid.cpp | 7 +++++ indra/llprimitive/llmaterialid.h | 1 + indra/llprimitive/lltextureentry.h | 8 ++++++ indra/newview/llmaterialeditor.cpp | 37 ++++++++++++++++++++++++- indra/newview/llmaterialeditor.h | 3 ++ indra/newview/llspatialpartition.h | 13 +++++++-- indra/newview/llviewerobject.cpp | 56 ++++++++++++++++++++++++++++---------- indra/newview/llviewerobject.h | 14 ++++++++++ indra/newview/llvovolume.cpp | 40 +++++++++++++++++++++++---- 9 files changed, 156 insertions(+), 23 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index f88a607c4f..340a83801c 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -155,6 +155,13 @@ std::string LLMaterialID::asString() const return materialIDString; } +LLUUID LLMaterialID::asUUID() const +{ + LLUUID ret; + memcpy(ret.mData, mID, MATERIAL_ID_SIZE); + return ret; +} + std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id) { s << material_id.asString(); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index ee663f8f99..e6165dfc91 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -61,6 +61,7 @@ public: LLSD asLLSD() const; std::string asString() const; + LLUUID asUUID() const; friend std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id); diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index dc2e201044..1549b2ce87 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -32,6 +32,7 @@ #include "llsd.h" #include "llmaterialid.h" #include "llmaterial.h" +#include "llgltfmaterial.h" // These bits are used while unpacking TEM messages to tell which aspects of // the texture entry changed. @@ -134,6 +135,10 @@ public: S32 setMaterialID(const LLMaterialID& pMaterialID); S32 setMaterialParams(const LLMaterialPtr pMaterialParams); + void setGLTFMaterial(LLGLTFMaterial* material) { mGLTFMaterial = material; } + LLGLTFMaterial* getGLTFMaterial() { return mGLTFMaterial; } + + virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } const F32 getAlpha() const { return mColor.mV[VALPHA]; } @@ -162,6 +167,8 @@ public: const LLMaterialID& getMaterialID() const { return mMaterialID; }; const LLMaterialPtr getMaterialParams() const { return mMaterial; }; + LLGLTFMaterial* getGLTFMaterial() const { return mGLTFMaterial; } + // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() // to NOT return NULL. @@ -219,6 +226,7 @@ protected: bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; + LLPointer mGLTFMaterial; // if present, ignore mMaterial // Note the media data is not sent via the same message structure as the rest of the TE LLMediaEntry* mMediaEntry; // The media data for the face diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 05e7ff524a..5a0c23d59b 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -31,6 +31,8 @@ #include "llviewermenufile.h" #include "llappviewer.h" #include "llviewertexture.h" +#include "llselectmgr.h" +#include "llvovolume.h" #include "tinygltf/tiny_gltf.h" @@ -195,6 +197,8 @@ static U32 write_texture(const LLUUID& id, tinygltf::Model& model) void LLMaterialEditor::onClickSave() { + applyToSelection(); + tinygltf::Model model; model.materials.resize(1); tinygltf::PbrMetallicRoughness& pbrMaterial = model.materials[0].pbrMetallicRoughness; @@ -450,4 +454,35 @@ void LLMaterialFilePicker::loadMaterial(const std::string& filename) void LLMaterialEditor::importMaterial() { (new LLMaterialFilePicker(this))->getFile(); -} \ No newline at end of file +} + +void LLMaterialEditor::applyToSelection() +{ + LLViewerObject* objectp = LLSelectMgr::instance().getSelection()->getFirstObject(); + if (objectp && objectp->getVolume()) + { + LLGLTFMaterial* mat = new LLGLTFMaterial(); + mat->mAlbedoColor = getAlbedoColor(); + mat->mAlbedoColor.mV[3] = getTransparency(); + mat->mAlbedoId = getAlbedoId(); + + mat->mNormalId = getNormalId(); + + mat->mMetallicRoughnessId = getMetallicRoughnessId(); + mat->mMetallicFactor = getMetalnessFactor(); + mat->mRoughnessFactor = getRoughnessFactor(); + + mat->mEmissiveColor = getEmissiveColor(); + mat->mEmissiveId = getEmissiveId(); + + mat->mDoubleSided = getDoubleSided(); + mat->setAlphaMode(getAlphaMode()); + + LLVOVolume* vobjp = (LLVOVolume*)objectp; + for (int i = 0; i < vobjp->getNumTEs(); ++i) + { + vobjp->getTE(i)->setGLTFMaterial(mat); + vobjp->updateTEMaterialTextures(i); + } + } +} diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index f0c5dca44d..e773ecd169 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -36,6 +36,9 @@ public: // open a file dialog and select a gltf/glb file for import void importMaterial(); + // for live preview, apply current material to currently selected object + void applyToSelection(); + void onClickSave(); // llpanel diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 07d62be7af..c3e9d8ceb9 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -113,9 +113,14 @@ public: LL_ALIGN_16(LLFace* mFace); //associated face F32 mDistance; U32 mDrawMode; - LLMaterialPtr mMaterial; // If this is null, the following parameters are unused. - LLMaterialID mMaterialID; - U32 mShaderMask; + + // Material points here are likely for debugging only and are immaterial (zing!) + LLMaterialPtr mMaterial; + LLPointer mGLTFMaterial; + + LLUUID mMaterialID; // id of LLGLTFMaterial or LLMaterial applied to this draw info + + U32 mShaderMask; U32 mBlendFuncSrc; U32 mBlendFuncDst; BOOL mHasGlow; @@ -123,6 +128,8 @@ public: const LLMatrix4* mSpecularMapMatrix; LLPointer mNormalMap; const LLMatrix4* mNormalMapMatrix; + LLPointer mEmissiveMap; + LLVector4 mSpecColor; // XYZ = Specular RGB, W = Specular Exponent F32 mEnvIntensity; F32 mAlphaMaskCutoff; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 857a94d7be..16479e02a2 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -406,6 +406,11 @@ void LLViewerObject::deleteTEImages() delete[] mTESpecularMaps; mTESpecularMaps = NULL; } + + mGLTFAlbedoMaps.clear(); + mGLTFNormalMaps.clear(); + mGLTFMetallicRoughnessMaps.clear(); + mGLTFEmissiveMaps.clear(); } void LLViewerObject::markDead() @@ -4731,6 +4736,11 @@ void LLViewerObject::setNumTEs(const U8 num_tes) mTEImages = new_images; mTENormalMaps = new_normmaps; mTESpecularMaps = new_specmaps; + + mGLTFAlbedoMaps.resize(num_tes); + mGLTFNormalMaps.resize(num_tes); + mGLTFMetallicRoughnessMaps.resize(num_tes); + mGLTFEmissiveMaps.resize(num_tes); } else { @@ -4859,23 +4869,28 @@ void LLViewerObject::updateAvatarMeshVisibility(const LLUUID& id, const LLUUID& } } -void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) + +void LLViewerObject::setTE(const U8 te, const LLTextureEntry& texture_entry) { - LLUUID old_image_id; - if (getTE(te)) - { - old_image_id = getTE(te)->getID(); - } - - LLPrimitive::setTE(te, texture_entry); + LLUUID old_image_id; + if (getTE(te)) + { + old_image_id = getTE(te)->getID(); + } - const LLUUID& image_id = getTE(te)->getID(); - LLViewerTexture* bakedTexture = getBakedTextureForMagicId(image_id); - mTEImages[te] = bakedTexture ? bakedTexture : LLViewerTextureManager::getFetchedTexture(image_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + LLPrimitive::setTE(te, texture_entry); - - updateAvatarMeshVisibility(image_id,old_image_id); + const LLUUID& image_id = getTE(te)->getID(); + LLViewerTexture* bakedTexture = getBakedTextureForMagicId(image_id); + mTEImages[te] = bakedTexture ? bakedTexture : LLViewerTextureManager::getFetchedTexture(image_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + + updateAvatarMeshVisibility(image_id, old_image_id); + updateTEMaterialTextures(te); +} + +void LLViewerObject::updateTEMaterialTextures(U8 te) +{ if (getTE(te)->getMaterialParams().notNull()) { const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID(); @@ -4884,6 +4899,20 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) const LLUUID& spec_id = getTE(te)->getMaterialParams()->getSpecularID(); mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); } + + auto fetch_texture = [](const LLUUID& id) + { + return LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); + }; + + LLGLTFMaterial* mat = getTE(te)->getGLTFMaterial(); + if (mat != nullptr) + { + mGLTFAlbedoMaps[te] = fetch_texture(mat->mAlbedoId); + mGLTFNormalMaps[te] = fetch_texture(mat->mNormalId); + mGLTFMetallicRoughnessMaps[te] = fetch_texture(mat->mMetallicRoughnessId); + mGLTFEmissiveMaps[te] = fetch_texture(mat->mEmissiveId); + } } void LLViewerObject::refreshBakeTexture() @@ -5424,7 +5453,6 @@ void LLViewerObject::fitFaceTexture(const U8 face) LL_INFOS() << "fitFaceTexture not implemented" << LL_ENDL; } - LLBBox LLViewerObject::getBoundingBoxAgent() const { LLVector3 position_agent; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 1c4cfc6466..5136a7e5ee 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -321,6 +321,7 @@ public: /*virtual*/ void setNumTEs(const U8 num_tes); /*virtual*/ void setTE(const U8 te, const LLTextureEntry &texture_entry); + void updateTEMaterialTextures(U8 te); /*virtual*/ S32 setTETexture(const U8 te, const LLUUID &uuid); /*virtual*/ S32 setTENormalMap(const U8 te, const LLUUID &uuid); /*virtual*/ S32 setTESpecularMap(const U8 te, const LLUUID &uuid); @@ -359,6 +360,12 @@ public: LLViewerTexture *getTEImage(const U8 te) const; LLViewerTexture *getTENormalMap(const U8 te) const; LLViewerTexture *getTESpecularMap(const U8 te) const; + + LLViewerTexture* getGLTFAlbedoMap(U8 te) const { return mGLTFAlbedoMaps[te]; } + LLViewerTexture* getGLTFNormalMap(U8 te) const { return mGLTFNormalMaps[te]; } + LLViewerTexture* getGLTFEmissiveMap(U8 te) const { return mGLTFEmissiveMaps[te]; } + LLViewerTexture* getGLTFMetallicRoughnessMap(U8 te) const { return mGLTFMetallicRoughnessMaps[te]; } + bool isImageAlphaBlended(const U8 te) const; @@ -675,6 +682,13 @@ public: LLPointer *mTEImages; LLPointer *mTENormalMaps; LLPointer *mTESpecularMaps; + + std::vector > mGLTFAlbedoMaps; + std::vector > mGLTFNormalMaps; + std::vector > mGLTFMetallicRoughnessMaps; + std::vector > mGLTFEmissiveMaps; + + // true if user can select this object by clicking under any circumstances (even if pick_unselectable is true) // can likely be factored out diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3a619b4fcc..302a172858 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5390,10 +5390,26 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLViewerTexture* tex = facep->getTexture(); + U8 index = facep->getTextureIndex(); - LLMaterial* mat = facep->getTextureEntry()->getMaterialParams().get(); - LLMaterialID mat_id = facep->getTextureEntry()->getMaterialID(); + LLMaterial* mat = nullptr; + + LLUUID mat_id; + + LLGLTFMaterial* gltf_mat = facep->getTextureEntry()->getGLTFMaterial(); + if (gltf_mat != nullptr) + { + mat_id = gltf_mat->getHash(); // TODO: cache this hash + } + else + { + mat = facep->getTextureEntry()->getMaterialParams().get(); + if (mat) + { + mat_id = facep->getTextureEntry()->getMaterialID().asUUID(); + } + } bool batchable = false; @@ -5415,7 +5431,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, if (index < FACE_DO_NOT_BATCH_TEXTURES && idx >= 0) { - if (mat || draw_vec[idx]->mMaterial) + if (mat || gltf_mat || draw_vec[idx]->mMaterial) { //can't batch textures when materials are present (yet) batchable = false; } @@ -5447,7 +5463,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && draw_vec[idx]->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && #endif - //draw_vec[idx]->mMaterial == mat && draw_vec[idx]->mMaterialID == mat_id && draw_vec[idx]->mFullbright == fullbright && draw_vec[idx]->mBump == bump && @@ -5504,11 +5519,22 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_info->mEnvIntensity = spec; draw_info->mSpecularMap = NULL; draw_info->mMaterial = mat; + draw_info->mGLTFMaterial = gltf_mat; draw_info->mShaderMask = shader_mask; draw_info->mAvatar = facep->mAvatar; draw_info->mSkinInfo = facep->mSkinInfo; - if (mat) + if (gltf_mat) + { + LLViewerObject* vobj = facep->getViewerObject(); + U8 te = facep->getTEOffset(); + + draw_info->mTexture = vobj->getGLTFAlbedoMap(te); + draw_info->mNormalMap = vobj->getGLTFNormalMap(te); + draw_info->mSpecularMap = vobj->getGLTFMetallicRoughnessMap(te); + draw_info->mEmissiveMap = vobj->getGLTFEmissiveMap(te); + } + else if (mat) { draw_info->mMaterialID = mat_id; @@ -5849,6 +5875,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } +#if 0 #if LL_RELEASE_WITH_DEBUG_INFO const LLUUID pbr_id( "49c88210-7238-2a6b-70ac-92d4f35963cf" ); const LLUUID obj_id( vobj->getID() ); @@ -5856,6 +5883,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) #else bool is_pbr = false; #endif +#else + bool is_pbr = facep->getTextureEntry()->getGLTFMaterial() != nullptr; +#endif //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group -- cgit v1.3 From 8b59e3b5a9c1105dc0c6c720fea5e71cc13d7741 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Jun 2022 20:18:08 -0500 Subject: SL-17653 Make batch builder send batches to LLDrawPoolPBROpaque --- indra/newview/llvovolume.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 302a172858..9ac5f908e7 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6730,15 +6730,24 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) ? TRUE : FALSE; - LLMaterial* mat = te->getMaterialParams().get(); + LLGLTFMaterial* gltf_mat = te->getGLTFMaterial(); - bool can_be_shiny = true; - if (mat) - { - U8 mode = mat->getDiffuseAlphaMode(); - can_be_shiny = mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE || - mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE; - } + LLMaterial* mat = nullptr; + bool can_be_shiny = false; + + // ignore traditional material if GLTF material is present + if (gltf_mat == nullptr) + { + mat = te->getMaterialParams().get(); + + can_be_shiny = true; + if (mat) + { + U8 mode = mat->getDiffuseAlphaMode(); + can_be_shiny = mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE || + mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE; + } + } F32 te_alpha = te->getColor().mV[3]; bool use_legacy_bump = te->getBumpmap() && (te->getBumpmap() < 18) && (!mat || mat->getNormalID().isNull()); @@ -6747,10 +6756,15 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace is_alpha = (is_alpha || transparent) ? TRUE : FALSE; - if (mat && LLPipeline::sRenderDeferred && !hud_group) + if ((gltf_mat || mat) && LLPipeline::sRenderDeferred && !hud_group) { bool material_pass = false; + if (gltf_mat) + { // all other parameters ignored if gltf material is present + registerFace(group, facep, LLRenderPass::PASS_PBR_OPAQUE); + } + else // do NOT use 'fullbright' for this logic or you risk sending // things without normals down the materials pipeline and will // render poorly if not crash NORSPEC-240,314 -- cgit v1.3 From 39f762c2d1e8666c93689e261380cd70e0fb1749 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Jun 2022 20:59:42 -0500 Subject: SL-17653 Make sure GLTF material associated vertex buffers have all their texture coordinates --- indra/newview/llface.cpp | 3 ++- indra/newview/llvovolume.cpp | 53 ++++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 22 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index a2d9c0ba2b..562042f8bc 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1794,10 +1794,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, scalea.load3(scale.mV); LLMaterial* mat = tep->getMaterialParams().get(); + LLGLTFMaterial* gltf_mat = tep->getGLTFMaterial(); bool do_bump = bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1); - if (mat && !do_bump) + if ((mat || gltf_mat) && !do_bump) { do_bump = mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1) || mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 9ac5f908e7..0706e26fb1 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6022,28 +6022,39 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (gPipeline.canUseWindLightShadersOnObjects() && LLPipeline::sRenderBump) { - if (LLPipeline::sRenderDeferred && te->getMaterialParams().notNull() && !te->getMaterialID().isNull()) + LLGLTFMaterial* gltf_mat = te->getGLTFMaterial(); + + if (LLPipeline::sRenderDeferred && + (gltf_mat != nullptr || (te->getMaterialParams().notNull() && !te->getMaterialID().isNull()))) { - LLMaterial* mat = te->getMaterialParams().get(); - if (mat->getNormalID().notNull()) - { - if (mat->getSpecularID().notNull()) - { //has normal and specular maps (needs texcoord1, texcoord2, and tangent) - add_face(sNormSpecFaces, normspec_count, facep); - } - else - { //has normal map (needs texcoord1 and tangent) - add_face(sNormFaces, norm_count, facep); - } - } - else if (mat->getSpecularID().notNull()) - { //has specular map but no normal map, needs texcoord2 - add_face(sSpecFaces, spec_count, facep); - } - else - { //has neither specular map nor normal map, only needs texcoord0 - add_face(sSimpleFaces, simple_count, facep); - } + if (gltf_mat != nullptr) + { + // all gltf materials have all vertex attributes for now + add_face(sNormSpecFaces, normspec_count, facep); + } + else + { + LLMaterial* mat = te->getMaterialParams().get(); + if (mat->getNormalID().notNull()) + { + if (mat->getSpecularID().notNull()) + { //has normal and specular maps (needs texcoord1, texcoord2, and tangent) + add_face(sNormSpecFaces, normspec_count, facep); + } + else + { //has normal map (needs texcoord1 and tangent) + add_face(sNormFaces, norm_count, facep); + } + } + else if (mat->getSpecularID().notNull()) + { //has specular map but no normal map, needs texcoord2 + add_face(sSpecFaces, spec_count, facep); + } + else + { //has neither specular map nor normal map, only needs texcoord0 + add_face(sSimpleFaces, simple_count, facep); + } + } } else if (te->getBumpmap()) { //needs normal + tangent -- cgit v1.3 From fd6b5ea8c3df7e8b4b648ac7ecc9f30eedd4b7c0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 Jun 2022 17:59:09 -0500 Subject: SL-17685 Drag and drop material support WIP --- indra/llprimitive/llprimitive.cpp | 109 ++++++++++++++++++++++++++----- indra/llprimitive/llprimitive.h | 24 +++++-- indra/newview/llinventorybridge.cpp | 2 + indra/newview/llpanelgroupnotices.cpp | 1 + indra/newview/llpanelobjectinventory.cpp | 1 + indra/newview/lltooldraganddrop.cpp | 82 ++++++++++++++++++++++- indra/newview/lltooldraganddrop.h | 10 +++ indra/newview/llviewerobject.cpp | 55 ++++++++++++++++ indra/newview/llviewerobject.h | 7 ++ indra/newview/llviewertexteditor.cpp | 1 + indra/newview/llvovolume.cpp | 25 ++----- indra/newview/llvovolume.h | 2 +- 12 files changed, 273 insertions(+), 46 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 9e0a079fd9..6df7111a47 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1700,7 +1700,7 @@ BOOL LLNetworkData::isValid(U16 param_type, U32 size) case PARAMS_EXTENDED_MESH: return (size == 4); case PARAMS_RENDER_MATERIAL: - return (size == 16); + return (size > 1); } return FALSE; @@ -2312,18 +2312,32 @@ LLRenderMaterialParams::LLRenderMaterialParams() mType = PARAMS_RENDER_MATERIAL; } -BOOL LLRenderMaterialParams::pack(LLDataPacker &dp) const +BOOL LLRenderMaterialParams::pack(LLDataPacker& dp) const { - return dp.packUUID(mMaterial, "material"); + U8 count = (U8)llmin((S32)mEntries.size(), 14); //limited to 255 bytes, no more than 14 material ids -// return TRUE; + dp.packU8(count, "count"); + for (auto& entry : mEntries) + { + dp.packU8(entry.te_idx, "te_idx"); + dp.packUUID(entry.id, "id"); + } + + return TRUE; } -BOOL LLRenderMaterialParams::unpack(LLDataPacker &dp) +BOOL LLRenderMaterialParams::unpack(LLDataPacker& dp) { - return dp.unpackUUID(mMaterial, "material"); + U8 count; + dp.unpackU8(count, "count"); + mEntries.resize(count); + for (auto& entry : mEntries) + { + dp.unpackU8(entry.te_idx, "te_idx"); + dp.unpackUUID(entry.id, "te_id"); + } -// return TRUE; + return TRUE; } bool LLRenderMaterialParams::operator==(const LLNetworkData& data) const @@ -2333,40 +2347,99 @@ bool LLRenderMaterialParams::operator==(const LLNetworkData& data) const return false; } - const LLRenderMaterialParams ¶m = static_cast(data); + const LLRenderMaterialParams& param = static_cast(data); + + if (param.mEntries.size() != mEntries.size()) + { + return false; + } + + for (auto& entry : mEntries) + { + if (param.getMaterial(entry.te_idx) != entry.id) + { + return false; + } + } - return param.mMaterial == mMaterial; + return true; } void LLRenderMaterialParams::copy(const LLNetworkData& data) { llassert_always(data.mType == PARAMS_RENDER_MATERIAL); - const LLRenderMaterialParams ¶m = static_cast(data); - mMaterial = param.mMaterial; + const LLRenderMaterialParams& param = static_cast(data); + mEntries = param.mEntries; } LLSD LLRenderMaterialParams::asLLSD() const { - return llsd::map("material", mMaterial); + LLSD ret; + + for (int i = 0; i < mEntries.size(); ++i) + { + ret[i]["te_idx"] = mEntries[i].te_idx; + ret[i]["id"] = mEntries[i].id; + } + + return ret; } bool LLRenderMaterialParams::fromLLSD(LLSD& sd) { - if (sd.has("material")) + if (sd.isArray()) { - setMaterial(sd["material"]); + mEntries.resize(sd.size()); + for (int i = 0; i < sd.size(); ++i) + { + if (sd[i].has("te_idx") && sd.has("id")) + { + mEntries[i].te_idx = sd[i]["te_idx"].asInteger(); + mEntries[i].id = sd[i]["id"].asUUID(); + } + else + { + return false; + } + } + return true; } return false; } -void LLRenderMaterialParams::setMaterial(const LLUUID & id) +void LLRenderMaterialParams::setMaterial(U8 te, const LLUUID& id) { - mMaterial = id; + for (int i = 0; i < mEntries.size(); ++i) + { + if (mEntries[i].te_idx == te) + { + if (id.isNull()) + { + mEntries.erase(mEntries.begin() + i); + } + else + { + mEntries[i].id = id; + } + return; + } + } + + mEntries.push_back({ te, id }); } -LLUUID LLRenderMaterialParams::getMaterial() const +LLUUID LLRenderMaterialParams::getMaterial(U8 te) const { - return mMaterial; + for (int i = 0; i < mEntries.size(); ++i) + { + if (mEntries[i].te_idx == te) + { + return mEntries[i].id; + } + } + + return LLUUID::null; } + diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 25196fb894..1c290185b0 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -369,22 +369,30 @@ public: class LLRenderMaterialParams : public LLNetworkData { private: - LLUUID mMaterial; + struct Entry + { + U8 te_idx; + LLUUID id; + }; + std::vector< Entry > mEntries; public: LLRenderMaterialParams(); - BOOL pack(LLDataPacker &dp) const override; - BOOL unpack(LLDataPacker &dp) override; + BOOL pack(LLDataPacker& dp) const override; + BOOL unpack(LLDataPacker& dp) override; bool operator==(const LLNetworkData& data) const override; void copy(const LLNetworkData& data) override; LLSD asLLSD() const; operator LLSD() const { return asLLSD(); } bool fromLLSD(LLSD& sd); - void setMaterial(const LLUUID & id); - LLUUID getMaterial() const; + void setMaterial(U8 te_idx, const LLUUID& id); + LLUUID getMaterial(U8 te_idx) const; + + bool isEmpty() { return mEntries.empty(); } }; + // This code is not naming-standards compliant. Leaving it like this for // now to make the connection to code in // BOOL packTEMessage(LLDataPacker &dp) const; @@ -480,12 +488,12 @@ public: virtual S32 setTEMediaFlags(const U8 te, const U8 flags); virtual S32 setTEGlow(const U8 te, const F32 glow); virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); + virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed virtual void setTESelected(const U8 te, bool sel); LLMaterialPtr getTEMaterialParams(const U8 index); - + void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; BOOL packTEMessage(LLMessageSystem *mesgsys) const; @@ -563,6 +571,8 @@ public: static LLPCode legacyToPCode(const U8 legacy); static U8 pCodeToLegacy(const LLPCode pcode); static bool getTESTAxes(const U8 face, U32* s_axis, U32* t_axis); + + BOOL hasRenderMaterialParams() const; inline static BOOL isPrimitive(const LLPCode pcode); inline static BOOL isApp(const LLPCode pcode); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 2bb2c9676b..d325831c8f 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4403,6 +4403,7 @@ BOOL LLFolderBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_GESTURE: case DAD_MESH: case DAD_SETTINGS: + case DAD_MATERIAL: accept = dragItemIntoFolder(inv_item, drop, tooltip_msg); break; case DAD_LINK: @@ -6032,6 +6033,7 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_GESTURE: case DAD_MESH: case DAD_SETTINGS: + case DAD_MATERIAL: { LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data; const LLPermissions& perm = inv_item->getPermissions(); diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index ab32ea3956..82f880c9ee 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -156,6 +156,7 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, case DAD_CALLINGCARD: case DAD_MESH: case DAD_SETTINGS: + case DAD_MATERIAL: { LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; if(gInventory.getItem(inv_item->getUUID()) diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index defd7025b8..998cffef4a 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -704,6 +704,7 @@ BOOL LLTaskCategoryBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_CALLINGCARD: case DAD_MESH: case DAD_SETTINGS: + case DAD_MATERIAL: accept = LLToolDragAndDrop::isInventoryDropAcceptable(object, (LLViewerInventoryItem*)cargo_data); if(accept && drop) { diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 50868d0fa5..a4b34bb5b6 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -256,7 +256,8 @@ LLToolDragAndDrop::LLDragAndDropDictionary::LLDragAndDropDictionary() // |-------------------------------|----------------------------------------------|-----------------------------------------------|---------------------------------------------------|--------------------------------| addEntry(DAD_NONE, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_TEXTURE, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dTextureObject, &LLToolDragAndDrop::dad3dNULL)); - addEntry(DAD_SOUND, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); + addEntry(DAD_MATERIAL, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dMaterialObject, &LLToolDragAndDrop::dad3dNULL)); + addEntry(DAD_SOUND, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_CALLINGCARD, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_LANDMARK, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_SCRIPT, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dRezScript, &LLToolDragAndDrop::dad3dNULL)); @@ -271,6 +272,7 @@ LLToolDragAndDrop::LLDragAndDropDictionary::LLDragAndDropDictionary() addEntry(DAD_LINK, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_MESH, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dMeshObject, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_SETTINGS, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); + // TODO: animation on self could play it? edit it? // TODO: gesture on self could play it? edit it? }; @@ -1062,6 +1064,66 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj, hit_obj->sendTEUpdate(); } + +void LLToolDragAndDrop::dropMaterialOneFace(LLViewerObject* hit_obj, + S32 hit_face, + LLInventoryItem* item, + LLToolDragAndDrop::ESource source, + const LLUUID& src_id) +{ + if (hit_face == -1) return; + if (!item || item->getInventoryType() != LLInventoryType::IT_MATERIAL) + { + LL_WARNS() << "LLToolDragAndDrop::dropTextureOneFace no material item." << LL_ENDL; + return; + } + LLUUID asset_id = item->getAssetUUID(); + BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + if (!success) + { + return; + } + + LLTextureEntry* tep = hit_obj ? (hit_obj->getTE(hit_face)) : NULL; + + hit_obj->setRenderMaterialID(hit_face, asset_id); + + dialog_refresh_all(); + + // send the update to the simulator + hit_obj->sendTEUpdate(); +} + + +void LLToolDragAndDrop::dropMaterialAllFaces(LLViewerObject* hit_obj, + LLInventoryItem* item, + LLToolDragAndDrop::ESource source, + const LLUUID& src_id) +{ + if (!item || item->getInventoryType() != LLInventoryType::IT_MATERIAL) + { + LL_WARNS() << "LLToolDragAndDrop::dropTextureAllFaces no material item." << LL_ENDL; + return; + } + LLUUID asset_id = item->getAssetUUID(); + BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + if (!success) + { + return; + } + + S32 num_faces = hit_obj->getNumTEs(); + for (S32 face = 0; face < num_faces; face++) + { + // update viewer side material in anticipation of update from simulator + hit_obj->setRenderMaterialID(face, asset_id); + dialog_refresh_all(); + } + // send the update to the simulator + hit_obj->sendTEUpdate(); +} + + void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj, LLInventoryItem* item, LLToolDragAndDrop::ESource source, @@ -1628,6 +1690,7 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_ case DAD_MESH: case DAD_CATEGORY: case DAD_SETTINGS: + case DAD_MATERIAL: { LLInventoryObject* inv_obj = (LLInventoryObject*)cargo_data; if(gInventory.getCategory(inv_obj->getUUID()) || (gInventory.getItem(inv_obj->getUUID()) @@ -1982,6 +2045,17 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject( dropTextureOneFace(obj, face, item, mSource, mSourceID); } } + else if (cargo_type == DAD_MATERIAL) + { + if ((mask & MASK_SHIFT)) + { + dropMaterialAllFaces(obj, item, mSource, mSourceID); + } + else + { + dropMaterialOneFace(obj, face, item, mSource, mSourceID); + } + } else if (cargo_type == DAD_MESH) { dropMesh(obj, item, mSource, mSourceID); @@ -2010,6 +2084,12 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject( return dad3dApplyToObject(obj, face, mask, drop, DAD_TEXTURE); } +EAcceptance LLToolDragAndDrop::dad3dMaterialObject( + LLViewerObject* obj, S32 face, MASK mask, BOOL drop) +{ + return dad3dApplyToObject(obj, face, mask, drop, DAD_MATERIAL); +} + EAcceptance LLToolDragAndDrop::dad3dMeshObject( LLViewerObject* obj, S32 face, MASK mask, BOOL drop) { diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h index 24a712029c..2f6423080e 100644 --- a/indra/newview/lltooldraganddrop.h +++ b/indra/newview/lltooldraganddrop.h @@ -168,6 +168,8 @@ protected: MASK mask, BOOL drop); EAcceptance dad3dTextureObject(LLViewerObject* obj, S32 face, MASK mask, BOOL drop); + EAcceptance dad3dMaterialObject(LLViewerObject* obj, S32 face, + MASK mask, BOOL drop); EAcceptance dad3dMeshObject(LLViewerObject* obj, S32 face, MASK mask, BOOL drop); // EAcceptance dad3dTextureSelf(LLViewerObject* obj, S32 face, @@ -249,6 +251,14 @@ public: LLInventoryItem* item, ESource source, const LLUUID& src_id); + static void dropMaterialOneFace(LLViewerObject* hit_obj, S32 hit_face, + LLInventoryItem* item, + ESource source, + const LLUUID& src_id); + static void dropMaterialAllFaces(LLViewerObject* hit_obj, + LLInventoryItem* item, + ESource source, + const LLUUID& src_id); static void dropMesh(LLViewerObject* hit_obj, LLInventoryItem* item, ESource source, diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 16479e02a2..232e51896e 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -6991,6 +6991,61 @@ LLVOAvatar* LLViewerObject::getAvatar() const return NULL; } +bool LLViewerObject::hasRenderMaterialParams() const +{ + return getParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL); +} + +void LLViewerObject::setHasRenderMaterialParams(bool has_materials) +{ + bool had_materials = hasRenderMaterialParams(); + + if (had_materials != has_materials) + { + if (has_materials) + { + setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, true); + } + else + { + setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, FALSE, true); + } + } +} + +const LLUUID& LLViewerObject::getRenderMaterialID(U8 te) const +{ + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + return param_block->getMaterial(te); + } + + return LLUUID::null; +} + +void LLViewerObject::setRenderMaterialID(U8 te, const LLUUID& id) +{ + if (id.notNull()) + { + setHasRenderMaterialParams(true); + } + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + param_block->setMaterial(te, id); + + if (param_block->isEmpty()) + { // might be empty if id is null + setHasRenderMaterialParams(false); + } + else + { + parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true); + } + } +} class ObjectPhysicsProperties : public LLHTTPNode { diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 5136a7e5ee..1392caa855 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -179,6 +179,13 @@ public: const std::string& getAttachmentItemName() const; virtual LLVOAvatar* getAvatar() const; //get the avatar this object is attached to, or NULL if object is not an attachment + + bool hasRenderMaterialParams() const; + void setHasRenderMaterialParams(bool has_params); + + const LLUUID& getRenderMaterialID(U8 te) const; + void setRenderMaterialID(U8 te, const LLUUID& id); + virtual BOOL isHUDAttachment() const { return FALSE; } virtual BOOL isTempAttachment() const; diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index e2de7ac825..7c860936a5 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -879,6 +879,7 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, case DAD_ANIMATION: case DAD_GESTURE: case DAD_MESH: + case DAD_MATERIAL: { supported = true; break; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 0706e26fb1..f220547499 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2162,6 +2162,7 @@ void LLVOVolume::setNumTEs(const U8 num_tes) return ; } + //virtual void LLVOVolume::changeTEImage(S32 index, LLViewerTexture* imagep) { @@ -3501,6 +3502,11 @@ F32 LLVOVolume::getLightCutoff() const } } +BOOL LLVOVolume::isReflectionProbe() const +{ + return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); +} + void LLVOVolume::setIsReflectionProbe(BOOL is_probe) { BOOL was_probe = isReflectionProbe(); @@ -3571,25 +3577,6 @@ void LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) } } - -BOOL LLVOVolume::isReflectionProbe() const -{ - // HACK - make this object a Reflection Probe if a certain UUID is detected - static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); - LLUUID probe_id(reflection_probe_id); - - for (U8 i = 0; i < getNumTEs(); ++i) - { - if (getTE(i)->getID() == probe_id) - { - return true; - } - } - // END HACK - - return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); -} - F32 LLVOVolume::getReflectionProbeAmbiance() const { const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index f0a4fd427e..79049851b4 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -284,7 +284,7 @@ public: F32 getLightRadius() const; F32 getLightFalloff(const F32 fudge_factor = 1.f) const; F32 getLightCutoff() const; - + // Reflection Probes void setIsReflectionProbe(BOOL is_probe); void setReflectionProbeAmbiance(F32 ambiance); -- cgit v1.3 From 6f6df8ed71702f0ee8d21a2b583818ae360dd093 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 Jun 2022 21:42:44 -0500 Subject: SL-17685 Drag and drop material support --- indra/llprimitive/llgltfmaterial.h | 2 ++ indra/llprimitive/llprimitive.cpp | 2 +- indra/llprimitive/llprimitive.h | 2 +- indra/newview/CMakeLists.txt | 2 ++ indra/newview/llmaterialeditor.cpp | 2 +- indra/newview/lltooldraganddrop.cpp | 2 -- indra/newview/llviewerobject.cpp | 29 +++++++++++++++++++++++++++++ indra/newview/llviewerobject.h | 1 + indra/newview/llvovolume.cpp | 2 ++ indra/newview/llvovolume.h | 2 +- 10 files changed, 40 insertions(+), 6 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index d6f59cd1a3..a8d5fb8e85 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -53,6 +53,8 @@ public: F32 mMetallicFactor = 0.f; F32 mRoughnessFactor = 0.f; + F32 mAlphaCutoff = 0.f; + bool mDoubleSided = false; AlphaMode mAlphaMode = ALPHA_MODE_OPAQUE; diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 6df7111a47..3f0059b759 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -2430,7 +2430,7 @@ void LLRenderMaterialParams::setMaterial(U8 te, const LLUUID& id) mEntries.push_back({ te, id }); } -LLUUID LLRenderMaterialParams::getMaterial(U8 te) const +const LLUUID& LLRenderMaterialParams::getMaterial(U8 te) const { for (int i = 0; i < mEntries.size(); ++i) { diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 1c290185b0..d2adfa4a3d 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -387,7 +387,7 @@ public: bool fromLLSD(LLSD& sd); void setMaterial(U8 te_idx, const LLUUID& id); - LLUUID getMaterial(U8 te_idx) const; + const LLUUID& getMaterial(U8 te_idx) const; bool isEmpty() { return mEntries.empty(); } }; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index d4bd1c8b57..b67bc91277 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -344,6 +344,7 @@ set(viewer_SOURCE_FILES llgesturemgr.cpp llgiveinventory.cpp llglsandbox.cpp + llgltfmateriallist.cpp llgroupactions.cpp llgroupiconctrl.cpp llgrouplist.cpp @@ -986,6 +987,7 @@ set(viewer_HEADER_FILES llgesturelistener.h llgesturemgr.h llgiveinventory.h + llgltfmateriallist.h llgroupactions.h llgroupiconctrl.h llgrouplist.h diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 2455ad2926..9fb9f723cd 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -43,7 +43,6 @@ #include "llviewerregion.h" #include "llvovolume.h" #include "roles_constants.h" -#include "tinygltf/tiny_gltf.h" #include "llviewerobjectlist.h" #include "llfloaterreg.h" #include "llfilesystem.h" @@ -52,6 +51,7 @@ #include "llviewertexturelist.h" #include "llfloaterperms.h" +#include "tinygltf/tiny_gltf.h" #include ///---------------------------------------------------------------------------- diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index a4b34bb5b6..55e8a3b98b 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1083,8 +1083,6 @@ void LLToolDragAndDrop::dropMaterialOneFace(LLViewerObject* hit_obj, { return; } - - LLTextureEntry* tep = hit_obj ? (hit_obj->getTE(hit_face)) : NULL; hit_obj->setRenderMaterialID(hit_face, asset_id); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 232e51896e..753fb014c9 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -107,6 +107,7 @@ #include "llcleanup.h" #include "llcallstack.h" #include "llmeshrepository.h" +#include "llgltfmateriallist.h" #include "llgl.h" //#define DEBUG_UPDATE_TYPE @@ -4906,6 +4907,18 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) }; LLGLTFMaterial* mat = getTE(te)->getGLTFMaterial(); + LLUUID mat_id = getRenderMaterialID(te); + if (mat == nullptr && mat_id.notNull()) + { + mat = gGLTFMaterialList.getMaterial(mat_id); + getTE(te)->setGLTFMaterial(mat); + } + else if (mat_id.isNull() && mat != nullptr) + { + mat = nullptr; + getTE(te)->setGLTFMaterial(nullptr); + } + if (mat != nullptr) { mGLTFAlbedoMaps[te] = fetch_texture(mat->mAlbedoId); @@ -4913,6 +4926,14 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) mGLTFMetallicRoughnessMaps[te] = fetch_texture(mat->mMetallicRoughnessId); mGLTFEmissiveMaps[te] = fetch_texture(mat->mEmissiveId); } + else + { + mGLTFAlbedoMaps[te] = nullptr; + mGLTFNormalMaps[te] = nullptr; + mGLTFMetallicRoughnessMaps[te] = nullptr; + mGLTFEmissiveMaps[te] = nullptr; + } + } void LLViewerObject::refreshBakeTexture() @@ -7028,8 +7049,16 @@ void LLViewerObject::setRenderMaterialID(U8 te, const LLUUID& id) { if (id.notNull()) { + getTE(te)->setGLTFMaterial(gGLTFMaterialList.getMaterial(id)); setHasRenderMaterialParams(true); } + else + { + getTE(te)->setGLTFMaterial(nullptr); + } + + faceMappingChanged(); + gPipeline.markTextured(mDrawable); LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); if (param_block) diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 1392caa855..109c96dc9c 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -207,6 +207,7 @@ public: // Graphical stuff for objects - maybe broken out into render class later? virtual void updateTextures(); + virtual void faceMappingChanged() {} virtual void boostTexturePriority(BOOL boost_children = TRUE); // When you just want to boost priority of this object virtual LLDrawable* createDrawable(LLPipeline *pipeline); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 685b24d5d6..4fa9f05c09 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5861,6 +5861,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } + // HACK -- brute force this check every time a drawable gets rebuilt + vobj->updateTEMaterialTextures(i); #if 0 #if LL_RELEASE_WITH_DEBUG_INFO const LLUUID pbr_id( "49c88210-7238-2a6b-70ac-92d4f35963cf" ); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 79049851b4..db586fd741 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -172,7 +172,7 @@ public: void markForUpdate(BOOL priority) override; void markForUnload() { LLViewerObject::markForUnload(TRUE); mVolumeChanged = TRUE; } - void faceMappingChanged() { mFaceMappingChanged=TRUE; }; + void faceMappingChanged() override { mFaceMappingChanged=TRUE; } /*virtual*/ void onShift(const LLVector4a &shift_vector) override; // Called when the drawable shifts -- cgit v1.3 From 01d03edd8512580575da515401a42021577c3c57 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 1 Sep 2022 13:38:22 -0700 Subject: SL-17967 - _ARB constant removal --- indra/llrender/llgl.cpp | 14 ++-- indra/llrender/llglstates.h | 2 +- indra/llrender/llrender.cpp | 20 +++--- indra/llrender/llvertexbuffer.cpp | 128 +++++++++++++++++------------------ indra/llrender/llvertexbuffer.h | 2 +- indra/newview/lldrawable.cpp | 2 +- indra/newview/lldrawpoolavatar.cpp | 8 +-- indra/newview/llface.cpp | 4 +- indra/newview/llglsandbox.cpp | 2 +- indra/newview/llselectmgr.cpp | 2 +- indra/newview/llspatialpartition.cpp | 6 +- indra/newview/llsprite.cpp | 2 +- indra/newview/llvograss.cpp | 6 +- indra/newview/llvoground.cpp | 2 +- indra/newview/llvopartgroup.cpp | 4 +- indra/newview/llvosky.cpp | 6 +- indra/newview/llvosurfacepatch.cpp | 4 +- indra/newview/llvotree.cpp | 4 +- indra/newview/llvovolume.cpp | 20 +++--- indra/newview/llvowater.cpp | 4 +- indra/newview/llvowlsky.cpp | 4 +- indra/newview/pipeline.cpp | 32 ++++----- 22 files changed, 139 insertions(+), 139 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 74d35a8dac..6181f7dd7e 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1658,8 +1658,8 @@ void LLGLState::initClass() // sStateMap[GL_TEXTURE_2D] = GL_TRUE; //make sure multisample defaults to disabled - sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE; - glDisable(GL_MULTISAMPLE_ARB); + sStateMap[GL_MULTISAMPLE] = GL_FALSE; + glDisable(GL_MULTISAMPLE); } //static @@ -1766,7 +1766,7 @@ void LLGLState::checkTextureChannels(const std::string& msg) stop_glerror(); GLint activeTexture; - glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture); stop_glerror(); BOOL error = FALSE; @@ -1794,12 +1794,12 @@ void LLGLState::checkTextureChannels(const std::string& msg) "GL_TEXTURE_2D", "GL_TEXTURE_COORD_ARRAY", "GL_TEXTURE_1D", - "GL_TEXTURE_CUBE_MAP_ARB", + "GL_TEXTURE_CUBE_MAP", "GL_TEXTURE_GEN_S", "GL_TEXTURE_GEN_T", "GL_TEXTURE_GEN_Q", "GL_TEXTURE_GEN_R", - "GL_TEXTURE_RECTANGLE_ARB", + "GL_TEXTURE_RECTANGLE", "GL_TEXTURE_2D_MULTISAMPLE" }; @@ -1808,12 +1808,12 @@ void LLGLState::checkTextureChannels(const std::string& msg) GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_TEXTURE_1D, - GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_CUBE_MAP, GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_Q, GL_TEXTURE_GEN_R, - GL_TEXTURE_RECTANGLE_ARB, + GL_TEXTURE_RECTANGLE, GL_TEXTURE_2D_MULTISAMPLE }; diff --git a/indra/llrender/llglstates.h b/indra/llrender/llglstates.h index a4924eba14..27ab142925 100644 --- a/indra/llrender/llglstates.h +++ b/indra/llrender/llglstates.h @@ -75,7 +75,7 @@ public: mLineStipple(GL_LINE_STIPPLE), mNormalize(GL_NORMALIZE), mPolygonSmooth(GL_POLYGON_SMOOTH), - mGLMultisample(GL_MULTISAMPLE_ARB) + mGLMultisample(GL_MULTISAMPLE) { } }; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 821109ba99..056714b039 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -69,9 +69,9 @@ static const U32 LL_NUM_LIGHT_UNITS = 8; static const GLenum sGLTextureType[] = { GL_TEXTURE_2D, - GL_TEXTURE_RECTANGLE_ARB, - GL_TEXTURE_CUBE_MAP_ARB, - GL_TEXTURE_CUBE_MAP_ARRAY_ARB, + GL_TEXTURE_RECTANGLE, + GL_TEXTURE_CUBE_MAP, + GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_3D }; @@ -340,7 +340,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) activate(); enable(LLTexUnit::TT_CUBE_MAP); mCurrTexture = cubeMap->mImages[0]->getTexName(); - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture); + glBindTexture(GL_TEXTURE_CUBE_MAP, mCurrTexture); mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps; cubeMap->mImages[0]->updateBindStats(); if (cubeMap->mImages[0]->mTexOptionsDirty) @@ -470,7 +470,7 @@ void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode) glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); if (mCurrTexType == TT_CUBE_MAP) { - glTexParameteri (GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); + glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); } } @@ -545,7 +545,7 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src) case TBS_PREV_ALPHA: case TBS_ONE_MINUS_PREV_COLOR: case TBS_ONE_MINUS_PREV_ALPHA: - return GL_PREVIOUS_ARB; + return GL_PREVIOUS; // All four cases should return the same value. case TBS_TEX_COLOR: @@ -559,18 +559,18 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src) case TBS_VERT_ALPHA: case TBS_ONE_MINUS_VERT_COLOR: case TBS_ONE_MINUS_VERT_ALPHA: - return GL_PRIMARY_COLOR_ARB; + return GL_PRIMARY_COLOR; // All four cases should return the same value. case TBS_CONST_COLOR: case TBS_CONST_ALPHA: case TBS_ONE_MINUS_CONST_COLOR: case TBS_ONE_MINUS_CONST_ALPHA: - return GL_CONSTANT_ARB; + return GL_CONSTANT; default: LL_WARNS() << "Unknown eTextureBlendSrc: " << src << ". Using Vertex Color instead." << LL_ENDL; - return GL_PRIMARY_COLOR_ARB; + return GL_PRIMARY_COLOR; } } @@ -639,7 +639,7 @@ void LLTexUnit::debugTextureUnit(void) if (mIndex < 0) return; GLint activeTexture; - glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture); if ((GL_TEXTURE0 + mIndex) != activeTexture) { U32 set_unit = (activeTexture - GL_TEXTURE0); diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index f2c863d057..4b639e9e84 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -83,11 +83,11 @@ const U32 LL_VBO_POOL_SEED_COUNT = vbo_block_index(LL_VBO_POOL_MAX_SEED_SIZE); //============================================================================ //static -LLVBOPool LLVertexBuffer::sStreamVBOPool(GL_STREAM_DRAW_ARB, GL_ARRAY_BUFFER_ARB); -LLVBOPool LLVertexBuffer::sDynamicVBOPool(GL_DYNAMIC_DRAW_ARB, GL_ARRAY_BUFFER_ARB); -LLVBOPool LLVertexBuffer::sDynamicCopyVBOPool(GL_DYNAMIC_COPY_ARB, GL_ARRAY_BUFFER_ARB); -LLVBOPool LLVertexBuffer::sStreamIBOPool(GL_STREAM_DRAW_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB); -LLVBOPool LLVertexBuffer::sDynamicIBOPool(GL_DYNAMIC_DRAW_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB); +LLVBOPool LLVertexBuffer::sStreamVBOPool(GL_STREAM_DRAW, GL_ARRAY_BUFFER); +LLVBOPool LLVertexBuffer::sDynamicVBOPool(GL_DYNAMIC_DRAW, GL_ARRAY_BUFFER); +LLVBOPool LLVertexBuffer::sDynamicCopyVBOPool(GL_DYNAMIC_COPY, GL_ARRAY_BUFFER); +LLVBOPool LLVertexBuffer::sStreamIBOPool(GL_STREAM_DRAW, GL_ELEMENT_ARRAY_BUFFER); +LLVBOPool LLVertexBuffer::sDynamicIBOPool(GL_DYNAMIC_DRAW, GL_ELEMENT_ARRAY_BUFFER); U32 LLVBOPool::sBytesPooled = 0; U32 LLVBOPool::sIndexBytesPooled = 0; @@ -183,7 +183,7 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) mMissCount[i]++; } - if (mType == GL_ARRAY_BUFFER_ARB) + if (mType == GL_ARRAY_BUFFER) { LLVertexBuffer::sAllocatedBytes += size; } @@ -192,10 +192,10 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) LLVertexBuffer::sAllocatedIndexBytes += size; } - if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB) + if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW) { glBufferData(mType, size, 0, mUsage); - if (mUsage != GL_DYNAMIC_COPY_ARB) + if (mUsage != GL_DYNAMIC_COPY) { //data will be provided by application ret = (U8*) ll_aligned_malloc<64>(size); if (!ret) @@ -212,7 +212,7 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) } else { //always use a true hint of static draw when allocating non-client-backed buffers - glBufferData(mType, size, 0, GL_STATIC_DRAW_ARB); + glBufferData(mType, size, 0, GL_STATIC_DRAW); } glBindBuffer(mType, 0); @@ -225,7 +225,7 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) rec.mGLName = name; rec.mClientData = ret; - if (mType == GL_ARRAY_BUFFER_ARB) + if (mType == GL_ARRAY_BUFFER) { sBytesPooled += size; } @@ -241,7 +241,7 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) name = mFreeList[i].front().mGLName; ret = mFreeList[i].front().mClientData; - if (mType == GL_ARRAY_BUFFER_ARB) + if (mType == GL_ARRAY_BUFFER) { sBytesPooled -= size; } @@ -263,7 +263,7 @@ void LLVBOPool::release(U32 name, U8* buffer, U32 size) deleteBuffer(name); ll_aligned_free_fallback((U8*) buffer); - if (mType == GL_ARRAY_BUFFER_ARB) + if (mType == GL_ARRAY_BUFFER) { LLVertexBuffer::sAllocatedBytes -= size; } @@ -322,7 +322,7 @@ void LLVBOPool::cleanup() l.pop_front(); - if (mType == GL_ARRAY_BUFFER_ARB) + if (mType == GL_ARRAY_BUFFER) { sBytesPooled -= size; LLVertexBuffer::sAllocatedBytes -= size; @@ -763,12 +763,12 @@ void LLVertexBuffer::unbind() if (sVBOActive) { - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); sVBOActive = false; } if (sIBOActive) { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); sIBOActive = false; } @@ -801,32 +801,32 @@ S32 LLVertexBuffer::determineUsage(S32 usage) ret_usage = 0; } - if (ret_usage == GL_STREAM_DRAW_ARB && !sUseStreamDraw) + if (ret_usage == GL_STREAM_DRAW && !sUseStreamDraw) { ret_usage = 0; } - if (ret_usage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw) + if (ret_usage == GL_DYNAMIC_DRAW && sPreferStreamDraw) { - ret_usage = GL_STREAM_DRAW_ARB; + ret_usage = GL_STREAM_DRAW; } if (ret_usage == 0 && LLRender::sGLCoreProfile) { //MUST use VBOs for all rendering - ret_usage = GL_STREAM_DRAW_ARB; + ret_usage = GL_STREAM_DRAW; } - if (ret_usage && ret_usage != GL_STREAM_DRAW_ARB) + if (ret_usage && ret_usage != GL_STREAM_DRAW) { //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default - if (ret_usage != GL_DYNAMIC_COPY_ARB) + if (ret_usage != GL_DYNAMIC_COPY) { if (sDisableVBOMapping) { //always use stream draw if VBO mapping is disabled - ret_usage = GL_STREAM_DRAW_ARB; + ret_usage = GL_STREAM_DRAW; } else { - ret_usage = GL_DYNAMIC_DRAW_ARB; + ret_usage = GL_DYNAMIC_DRAW; } } } @@ -859,7 +859,7 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) mMappable(false), mFence(NULL) { - mMappable = (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping); + mMappable = (mUsage == GL_DYNAMIC_DRAW && !sDisableVBOMapping); //zero out offsets for (U32 i = 0; i < TYPE_MAX; i++) @@ -982,11 +982,11 @@ void LLVertexBuffer::genBuffer(U32 size) { mSize = vbo_block_size(size); - if (mUsage == GL_STREAM_DRAW_ARB) + if (mUsage == GL_STREAM_DRAW) { mMappedData = sStreamVBOPool.allocate(mGLBuffer, mSize); } - else if (mUsage == GL_DYNAMIC_DRAW_ARB) + else if (mUsage == GL_DYNAMIC_DRAW) { mMappedData = sDynamicVBOPool.allocate(mGLBuffer, mSize); } @@ -1003,7 +1003,7 @@ void LLVertexBuffer::genIndices(U32 size) { mIndicesSize = vbo_block_size(size); - if (mUsage == GL_STREAM_DRAW_ARB) + if (mUsage == GL_STREAM_DRAW) { mMappedIndexData = sStreamIBOPool.allocate(mGLIndices, mIndicesSize); } @@ -1017,7 +1017,7 @@ void LLVertexBuffer::genIndices(U32 size) void LLVertexBuffer::releaseBuffer() { - if (mUsage == GL_STREAM_DRAW_ARB) + if (mUsage == GL_STREAM_DRAW) { sStreamVBOPool.release(mGLBuffer, mMappedData, mSize); } @@ -1034,7 +1034,7 @@ void LLVertexBuffer::releaseBuffer() void LLVertexBuffer::releaseIndices() { - if (mUsage == GL_STREAM_DRAW_ARB) + if (mUsage == GL_STREAM_DRAW) { sStreamIBOPool.release(mGLIndices, mMappedIndexData, mIndicesSize); } @@ -1499,7 +1499,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran #ifdef GL_ARB_map_buffer_range S32 offset = mOffsets[type] + sTypeSize[type]*index; S32 length = (sTypeSize[type]*count+0xF) & ~0xF; - src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER_ARB, offset, length, + src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER, offset, length, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_INVALIDATE_RANGE_BIT); @@ -1512,7 +1512,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran if (gDebugGL) { GLint size = 0; - glGetBufferParameteriv(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); + glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); if (size < mSize) { @@ -1520,7 +1520,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran } } - src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER_ARB, 0, mSize, + src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER, 0, mSize, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); #endif @@ -1531,20 +1531,20 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran if (map_range) { #ifndef LL_MESA_HEADLESS - glBufferParameteriAPPLE(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE); - glBufferParameteriAPPLE(GL_ARRAY_BUFFER_ARB, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE); + glBufferParameteriAPPLE(GL_ARRAY_BUFFER, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE); + glBufferParameteriAPPLE(GL_ARRAY_BUFFER, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE); #endif - src = (U8*) glMapBuffer(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + src = (U8*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); } else { - src = (U8*) glMapBuffer(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + src = (U8*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); } } else { map_range = false; - src = (U8*) glMapBuffer(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + src = (U8*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); } llassert(src != NULL); @@ -1568,8 +1568,8 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran //print out more debug info before crash LL_INFOS() << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << LL_ENDL; GLint size; - glGetBufferParameteriv(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); - LL_INFOS() << "GL_ARRAY_BUFFER_ARB size is " << size << LL_ENDL; + glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); + LL_INFOS() << "GL_ARRAY_BUFFER size is " << size << LL_ENDL; //-------------------- GLint buff; @@ -1684,7 +1684,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) #ifdef GL_ARB_map_buffer_range S32 offset = sizeof(U16)*index; S32 length = sizeof(U16)*count; - src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, + src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_INVALIDATE_RANGE_BIT); @@ -1693,7 +1693,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) else { #ifdef GL_ARB_map_buffer_range - src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, sizeof(U16)*mNumIndices, + src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(U16)*mNumIndices, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); #endif @@ -1704,20 +1704,20 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) if (map_range) { #ifndef LL_MESA_HEADLESS - glBufferParameteriAPPLE(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE); - glBufferParameteriAPPLE(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE); + glBufferParameteriAPPLE(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE); + glBufferParameteriAPPLE(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE); #endif - src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); } else { - src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); } } else { map_range = false; - src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); } llassert(src != NULL); @@ -1793,12 +1793,12 @@ void LLVertexBuffer::unmapBuffer() S32 length = sTypeSize[region.mType]*region.mCount; if (mSize >= length + offset) { - glBufferSubData(GL_ARRAY_BUFFER_ARB, offset, length, (U8*)mMappedData + offset); + glBufferSubData(GL_ARRAY_BUFFER, offset, length, (U8*)mMappedData + offset); } else { GLint size = 0; - glGetBufferParameteriv(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); + glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); LL_WARNS() << "Attempted to map regions to a buffer that is too small, " << "mapped size: " << mSize << ", gl buffer size: " << size @@ -1814,7 +1814,7 @@ void LLVertexBuffer::unmapBuffer() else { stop_glerror(); - glBufferSubData(GL_ARRAY_BUFFER_ARB, 0, getSize(), (U8*) mMappedData); + glBufferSubData(GL_ARRAY_BUFFER, 0, getSize(), (U8*) mMappedData); stop_glerror(); } } @@ -1833,13 +1833,13 @@ void LLVertexBuffer::unmapBuffer() if (gGLManager.mHasMapBufferRange) { #ifdef GL_ARB_map_buffer_range - glFlushMappedBufferRange(GL_ARRAY_BUFFER_ARB, offset, length); + glFlushMappedBufferRange(GL_ARRAY_BUFFER, offset, length); #endif } else if (gGLManager.mHasFlushBufferRange) { #ifndef LL_MESA_HEADLESS - glFlushMappedBufferRangeAPPLE(GL_ARRAY_BUFFER_ARB, offset, length); + glFlushMappedBufferRangeAPPLE(GL_ARRAY_BUFFER, offset, length); #endif } } @@ -1848,7 +1848,7 @@ void LLVertexBuffer::unmapBuffer() } } stop_glerror(); - glUnmapBuffer(GL_ARRAY_BUFFER_ARB); + glUnmapBuffer(GL_ARRAY_BUFFER); stop_glerror(); mMappedData = NULL; @@ -1873,12 +1873,12 @@ void LLVertexBuffer::unmapBuffer() S32 length = sizeof(U16)*region.mCount; if (mIndicesSize >= length + offset) { - glBufferSubData(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedIndexData+offset); + glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, offset, length, (U8*) mMappedIndexData+offset); } else { GLint size = 0; - glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); + glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); LL_WARNS() << "Attempted to map regions to a buffer that is too small, " << "mapped size: " << mIndicesSize << ", gl buffer size: " << size @@ -1894,7 +1894,7 @@ void LLVertexBuffer::unmapBuffer() else { stop_glerror(); - glBufferSubData(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, getIndicesSize(), (U8*) mMappedIndexData); + glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, getIndicesSize(), (U8*) mMappedIndexData); stop_glerror(); } } @@ -1913,14 +1913,14 @@ void LLVertexBuffer::unmapBuffer() if (gGLManager.mHasMapBufferRange) { #ifdef GL_ARB_map_buffer_range - glFlushMappedBufferRange(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length); + glFlushMappedBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length); #endif } else if (gGLManager.mHasFlushBufferRange) { #ifdef GL_APPLE_flush_buffer_range #ifndef LL_MESA_HEADLESS - glFlushMappedBufferRangeAPPLE(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length); + glFlushMappedBufferRangeAPPLE(GL_ELEMENT_ARRAY_BUFFER, offset, length); #endif #endif } @@ -1931,7 +1931,7 @@ void LLVertexBuffer::unmapBuffer() } } - glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB); + glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); mMappedIndexData = NULL; } @@ -2085,7 +2085,7 @@ bool LLVertexBuffer::bindGLBuffer(bool force_bind) if (useVBOs() && (force_bind || (mGLBuffer && (mGLBuffer != sGLRenderBuffer || !sVBOActive)))) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - glBindBuffer(GL_ARRAY_BUFFER_ARB, mGLBuffer); + glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); sGLRenderBuffer = mGLBuffer; sBindCount++; sVBOActive = true; @@ -2102,7 +2102,7 @@ bool LLVertexBuffer::bindGLBufferFast() { if (mGLBuffer != sGLRenderBuffer || !sVBOActive) { - glBindBuffer(GL_ARRAY_BUFFER_ARB, mGLBuffer); + glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); sGLRenderBuffer = mGLBuffer; sBindCount++; sVBOActive = true; @@ -2125,7 +2125,7 @@ bool LLVertexBuffer::bindGLIndices(bool force_bind) { LL_ERRS() << "VBO bound while another VBO mapped!" << LL_ENDL; }*/ - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, mGLIndices); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); sGLRenderIndices = mGLIndices; stop_glerror(); sBindCount++; @@ -2140,7 +2140,7 @@ bool LLVertexBuffer::bindGLIndicesFast() { if (mGLIndices != sGLRenderIndices || !sIBOActive) { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, mGLIndices); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); sGLRenderIndices = mGLIndices; sBindCount++; sIBOActive = true; @@ -2302,7 +2302,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { if (sVBOActive) { - glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); sBindCount++; sVBOActive = false; setup = true; // ... or a VBO is deactivated @@ -2317,7 +2317,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { if (sIBOActive) { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); sBindCount++; sIBOActive = false; } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index baf8407fc6..a7907f9cae 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -288,7 +288,7 @@ public: U8* getMappedIndices() const { return mMappedIndexData; } S32 getOffset(S32 type) const { return mOffsets[type]; } S32 getUsage() const { return mUsage; } - bool isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW_ARB) ? true : false; } + bool isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW) ? true : false; } void draw(U32 mode, U32 count, U32 indices_offset) const; void drawArrays(U32 mode, U32 offset, U32 count) const; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index bfb79f3a4c..70bc603a42 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1252,7 +1252,7 @@ LLSpatialPartition* LLDrawable::getSpatialPartition() LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask, LLViewerRegion* regionp) : LLDrawable(root->getVObj(), true), - LLSpatialPartition(data_mask, render_by_group, GL_STREAM_DRAW_ARB, regionp) + LLSpatialPartition(data_mask, render_by_group, GL_STREAM_DRAW, regionp) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 4a9a3caaec..67c3000410 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -54,7 +54,7 @@ #include "llviewertexturelist.h" static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK; -static U32 sBufferUsage = GL_STREAM_DRAW_ARB; +static U32 sBufferUsage = GL_STREAM_DRAW; static U32 sShaderLevel = 0; LLGLSLShader* LLDrawPoolAvatar::sVertexProgram = NULL; @@ -146,11 +146,11 @@ void LLDrawPoolAvatar::prerender() if (sShaderLevel > 0) { - sBufferUsage = GL_DYNAMIC_DRAW_ARB; + sBufferUsage = GL_DYNAMIC_DRAW; } else { - sBufferUsage = GL_STREAM_DRAW_ARB; + sBufferUsage = GL_STREAM_DRAW; } } @@ -934,7 +934,7 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const LLVertexBufferAvatar::LLVertexBufferAvatar() : LLVertexBuffer(sDataMask, - GL_STREAM_DRAW_ARB) //avatars are always stream draw due to morph targets + GL_STREAM_DRAW) //avatars are always stream draw due to morph targets { LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR } diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index ab5c655be0..534736e0a4 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1224,7 +1224,7 @@ void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf) mask |= LLVertexBuffer::MAP_WEIGHT4; } - LLVertexBuffer* buff = new LLVertexBuffer(mask, GL_STATIC_DRAW_ARB); + LLVertexBuffer* buff = new LLVertexBuffer(mask, GL_STATIC_DRAW); vf.mVertexBuffer = buff; buff->allocateBuffer(vf.mNumVertices, 0, true); @@ -1539,7 +1539,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, #ifdef GL_TRANSFORM_FEEDBACK_BUFFER if (use_transform_feedback && - mVertexBuffer->getUsage() == GL_DYNAMIC_COPY_ARB && + mVertexBuffer->getUsage() == GL_DYNAMIC_COPY && gTransformPositionProgram.mProgramObject && //transform shaders are loaded mVertexBuffer->useVBOs() && //target buffer is in VRAM !rebuild_weights && //TODO: add support for weights diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 9b9ab02dc1..d75f3eef6f 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -1084,7 +1084,7 @@ F32 gpu_benchmark() delete [] pixels; //make a dummy triangle to draw with - LLPointer buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, GL_STREAM_DRAW_ARB); + LLPointer buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, GL_STREAM_DRAW); if (!buff->allocateBuffer(3, 0, true)) { diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index fc5b1c60e2..690c7e1bd8 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6029,7 +6029,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) auto renderMeshSelection_f = [fogCfx, wireframe_selection](LLSelectNode* node, LLViewerObject* objectp, LLColor4 hlColor) { //Need to because crash on ATI 3800 (and similar cards) MAINT-5018 - LLGLDisable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLDisable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 10b3683cc8..d02c5861b1 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1581,7 +1581,7 @@ void renderOctree(LLSpatialGroup* group) if (group->mBuilt > 0.f) { group->mBuilt -= 2.f * gFrameIntervalSeconds.value(); - if (group->mBufferUsage == GL_STATIC_DRAW_ARB) + if (group->mBufferUsage == GL_STATIC_DRAW) { col.setVec(1.0f, 0, 0, group->mBuilt*0.5f); } @@ -1591,7 +1591,7 @@ void renderOctree(LLSpatialGroup* group) //col.setVec(1.0f, 1.0f, 0, sinf(group->mBuilt*3.14159f)*0.5f); } - if (group->mBufferUsage != GL_STATIC_DRAW_ARB) + if (group->mBufferUsage != GL_STATIC_DRAW) { LLGLDepthTest gl_depth(FALSE, FALSE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -1686,7 +1686,7 @@ void renderOctree(LLSpatialGroup* group) } else { - if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->isEmpty() + if (group->mBufferUsage == GL_STATIC_DRAW && !group->isEmpty() && group->getSpatialPartition()->mRenderByGroup) { col.setVec(0.8f, 0.4f, 0.1f, 0.1f); diff --git a/indra/newview/llsprite.cpp b/indra/newview/llsprite.cpp index c3eb70f850..0cdad86a76 100644 --- a/indra/newview/llsprite.cpp +++ b/indra/newview/llsprite.cpp @@ -190,7 +190,7 @@ void LLSprite::updateFace(LLFace &face) { LLVertexBuffer* buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, - GL_STREAM_DRAW_ARB); + GL_STREAM_DRAW); buff->allocateBuffer(4, 12, TRUE); face.setGeomIndex(0); face.setIndicesIndex(0); diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index d109b7b34f..36d66cccef 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -594,7 +594,7 @@ U32 LLVOGrass::getPartitionType() const } LLGrassPartition::LLGrassPartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW_ARB, regionp) +: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW, regionp) { mDrawableType = LLPipeline::RENDER_TYPE_GRASS; mPartitionType = LLViewerRegion::PARTITION_GRASS; @@ -602,7 +602,7 @@ LLGrassPartition::LLGrassPartition(LLViewerRegion* regionp) mDepthMask = TRUE; mSlopRatio = 0.1f; mRenderPass = LLRenderPass::PASS_GRASS; - mBufferUsage = GL_DYNAMIC_DRAW_ARB; + mBufferUsage = GL_DYNAMIC_DRAW; } void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count, U32& index_count) @@ -626,7 +626,7 @@ void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count if (drawablep->isAnimating()) { - group->mBufferUsage = GL_STREAM_DRAW_ARB; + group->mBufferUsage = GL_STREAM_DRAW; } U32 count = 0; diff --git a/indra/newview/llvoground.cpp b/indra/newview/llvoground.cpp index 52a6395618..28bd5a3c97 100644 --- a/indra/newview/llvoground.cpp +++ b/indra/newview/llvoground.cpp @@ -93,7 +93,7 @@ BOOL LLVOGround::updateGeometry(LLDrawable *drawable) if (!face->getVertexBuffer()) { face->setSize(5, 12); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolGround::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolGround::VERTEX_DATA_MASK, GL_STREAM_DRAW); if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) { LL_WARNS() << "Failed to allocate Vertex Buffer for VOGround to " diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index cb4315a774..2047e0a726 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -65,7 +65,7 @@ void LLVOPartGroup::restoreGL() { //TODO: optimize out binormal mask here. Specular and normal coords as well. - sVB = new LLVertexBuffer(VERTEX_DATA_MASK | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2, GL_STREAM_DRAW_ARB); + sVB = new LLVertexBuffer(VERTEX_DATA_MASK | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2, GL_STREAM_DRAW); U32 count = LL_MAX_PARTICLE_COUNT; if (!sVB->allocateBuffer(count*4, count*6, true)) { @@ -738,7 +738,7 @@ U32 LLVOPartGroup::getPartitionType() const } LLParticlePartition::LLParticlePartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW_ARB, regionp) +: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW, regionp) { mRenderPass = LLRenderPass::PASS_ALPHA; mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 1aa00bc894..b7a5a0667b 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -1010,7 +1010,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) face->setSize(4, 6); face->setGeomIndex(0); face->setIndicesIndex(0); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_STREAM_DRAW); buff->allocateBuffer(4, 6, TRUE); face->setVertexBuffer(buff); @@ -1139,7 +1139,7 @@ bool LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, F32 scale, const if (!facep->getVertexBuffer()) { facep->setSize(4, 6); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_STREAM_DRAW); if (!buff->allocateBuffer(facep->getGeomCount(), facep->getIndicesCount(), TRUE)) { LL_WARNS() << "Failed to allocate Vertex Buffer for vosky to " @@ -1379,7 +1379,7 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, if (!face->getVertexBuffer() || quads*4 != face->getGeomCount()) { face->setSize(quads * 4, quads * 6); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW); if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) { LL_WARNS() << "Failed to allocate Vertex Buffer for vosky to " diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 6b56eaeb4a..69ae3cf23b 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -51,7 +51,7 @@ class LLVertexBufferTerrain : public LLVertexBuffer { public: LLVertexBufferTerrain() : - LLVertexBuffer(MAP_VERTEX | MAP_NORMAL | MAP_TEXCOORD0 | MAP_TEXCOORD1 | MAP_COLOR, GL_DYNAMIC_DRAW_ARB) + LLVertexBuffer(MAP_VERTEX | MAP_NORMAL | MAP_TEXCOORD0 | MAP_TEXCOORD1 | MAP_COLOR, GL_DYNAMIC_DRAW) { //texture coordinates 2 and 3 exist, but use the same data as texture coordinate 1 }; @@ -1001,7 +1001,7 @@ U32 LLVOSurfacePatch::getPartitionType() const } LLTerrainPartition::LLTerrainPartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK, FALSE, GL_DYNAMIC_DRAW_ARB, regionp) +: LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK, FALSE, GL_DYNAMIC_DRAW, regionp) { mOcclusionEnabled = FALSE; mInfiniteFarClip = TRUE; diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index e26791aa29..b6f8d162ba 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -921,7 +921,7 @@ void LLVOTree::updateMesh() LLFace* facep = mDrawable->getFace(0); if (!facep) return; - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolTree::VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolTree::VERTEX_DATA_MASK, GL_STATIC_DRAW); if (!buff->allocateBuffer(vert_count, index_count, TRUE)) { LL_WARNS() << "Failed to allocate Vertex Buffer on mesh update to " @@ -1226,7 +1226,7 @@ U32 LLVOTree::getPartitionType() const } LLTreePartition::LLTreePartition(LLViewerRegion* regionp) -: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW_ARB, regionp) +: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW, regionp) { mDrawableType = LLPipeline::RENDER_TYPE_TREE; mPartitionType = LLViewerRegion::PARTITION_TREE; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index ad11fb3908..ad99ce1509 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5182,7 +5182,7 @@ U32 LLVOVolume::getPartitionType() const } LLVolumePartition::LLVolumePartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB, regionp), +: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW, regionp), LLVolumeGeometryManager() { mLODPeriod = 32; @@ -5190,7 +5190,7 @@ LLVolumeGeometryManager() mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; mPartitionType = LLViewerRegion::PARTITION_VOLUME; mSlopRatio = 0.25f; - mBufferUsage = GL_DYNAMIC_DRAW_ARB; + mBufferUsage = GL_DYNAMIC_DRAW; } LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep, LLViewerRegion* regionp) @@ -5202,7 +5202,7 @@ LLVolumeGeometryManager() mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; mPartitionType = LLViewerRegion::PARTITION_BRIDGE; - mBufferUsage = GL_DYNAMIC_DRAW_ARB; + mBufferUsage = GL_DYNAMIC_DRAW; mSlopRatio = 0.25f; } @@ -5788,7 +5788,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (drawablep->isAnimating()) { //fall back to stream draw for animating verts - useage = GL_STREAM_DRAW_ARB; + useage = GL_STREAM_DRAW; } LLVOVolume* vobj = drawablep->getVOVolume(); @@ -6408,10 +6408,10 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (use_transform_feedback && gTransformPositionProgram.mProgramObject && //transform shaders are loaded - buffer_usage == GL_DYNAMIC_DRAW_ARB && //target buffer is in VRAM + buffer_usage == GL_DYNAMIC_DRAW && //target buffer is in VRAM !(mask & LLVertexBuffer::MAP_WEIGHT4)) //TODO: add support for weights { - buffer_usage = GL_DYNAMIC_COPY_ARB; + buffer_usage = GL_DYNAMIC_COPY; } #if LL_DARWIN @@ -6645,9 +6645,9 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } - if (flexi && buffer_usage && buffer_usage != GL_STREAM_DRAW_ARB) + if (flexi && buffer_usage && buffer_usage != GL_STREAM_DRAW) { - buffer_usage = GL_STREAM_DRAW_ARB; + buffer_usage = GL_STREAM_DRAW; } //create vertex buffer @@ -7065,7 +7065,7 @@ void LLVolumeGeometryManager::addGeometryCount(LLSpatialGroup* group, U32& verte if (drawablep->isAnimating()) { //fall back to stream draw for animating verts - usage = GL_STREAM_DRAW_ARB; + usage = GL_STREAM_DRAW; } } @@ -7094,7 +7094,7 @@ void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_coun if (drawablep->isAnimating()) { //fall back to stream draw for animating verts - usage = GL_STREAM_DRAW_ARB; + usage = GL_STREAM_DRAW; } //for each face diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp index 089a7712c0..6f30092326 100644 --- a/indra/newview/llvowater.cpp +++ b/indra/newview/llvowater.cpp @@ -152,7 +152,7 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) LLVertexBuffer* buff = face->getVertexBuffer(); if (!buff || !buff->isWriteable()) { - buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW_ARB); + buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW); if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) { LL_WARNS() << "Failed to allocate Vertex Buffer on water update to " @@ -295,7 +295,7 @@ U32 LLVOVoidWater::getPartitionType() const } LLWaterPartition::LLWaterPartition(LLViewerRegion* regionp) -: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW_ARB, regionp) +: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW, regionp) { mInfiniteFarClip = TRUE; mDrawableType = LLPipeline::RENDER_TYPE_WATER; diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index d1f584cbca..c7df343ad0 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -151,7 +151,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) if (mFsSkyVerts.isNull()) { - mFsSkyVerts = new LLVertexBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); + mFsSkyVerts = new LLVertexBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW); if (!mFsSkyVerts->allocateBuffer(4, 6, TRUE)) { @@ -216,7 +216,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) for (U32 i = 0; i < strips_segments ;++i) { - LLVertexBuffer * segment = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); + LLVertexBuffer * segment = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW); mStripsVerts[i] = segment; U32 num_stacks_this_seg = stacks_per_seg; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2f6ff19100..3918770849 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -536,7 +536,7 @@ void LLPipeline::init() if (mCubeVB.isNull()) { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); } mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); @@ -2418,7 +2418,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla { if (mCubeVB.isNull()) { //cube VB will be used for issuing occlusion queries - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); } mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); } @@ -2677,7 +2677,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) if (mCubeVB.isNull()) { //cube VB will be used for issuing occlusion queries - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); } mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -4063,7 +4063,7 @@ void render_hud_elements() if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { - LLGLEnable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() // Draw the tracking overlays @@ -4371,7 +4371,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) gGL.matrixMode(LLRender::MM_MODELVIEW); LLGLSPipeline gls_pipeline; - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); LLGLState gls_color_material(GL_COLOR_MATERIAL, mLightingDetail < 2); @@ -4592,7 +4592,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) } } - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); LLVertexBuffer::unbind(); @@ -4682,7 +4682,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) LLGLEnable cull(GL_CULL_FACE); - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); calcNearbyLights(camera); setupHWLights(NULL); @@ -8078,7 +8078,7 @@ void LLPipeline::renderFinalize() gGL.getTexUnit(0)->bind(&mGlow[1]); gGL.getTexUnit(1)->bind(&mRT->screen); - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); buff->setBuffer(mask); buff->drawArrays(LLRender::TRIANGLE_STRIP, 0, 3); @@ -8246,8 +8246,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); stop_glerror(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); stop_glerror(); } } @@ -8268,8 +8268,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); stop_glerror(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); stop_glerror(); } } @@ -8448,7 +8448,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) GL_NEAREST); } - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { @@ -8717,7 +8717,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) if (mCubeVB.isNull()) { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); } mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -9224,7 +9224,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); } } @@ -9232,7 +9232,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); } } -- cgit v1.3 From 049fc419d1d1f41ac05e424d599a89366cee7ca7 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 9 Sep 2022 03:28:12 -0700 Subject: SL-17701: PBR: WIP Alpha Blending --- indra/newview/lldrawpoolalpha.cpp | 161 +++++++++++++++++++++++++----------- indra/newview/llviewershadermgr.cpp | 77 +++++++++++++++++ indra/newview/llviewershadermgr.h | 3 +- indra/newview/llvovolume.cpp | 11 ++- indra/newview/pipeline.cpp | 4 +- 5 files changed, 199 insertions(+), 57 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 89b8ec1ba2..883ba72c3c 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -50,6 +50,8 @@ #include "llglcommonfunc.h" #include "llvoavatar.h" +#include "llenvironment.h" + BOOL LLDrawPoolAlpha::sShowDebugAlpha = FALSE; #define current_shader (LLGLSLShader::sCurBoundShaderPtr) @@ -602,65 +604,74 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) } } - LLRenderPass::applyModelMatrix(params); + LLRenderPass::applyModelMatrix(params); - LLMaterial* mat = NULL; + LLMaterial* mat = NULL; + LLGLTFMaterial *gltf_mat = params.mGLTFMaterial; // Also see: LLPipeline::getPoolTypeFromTE() + bool is_pbr = LLPipeline::sRenderPBR && gltf_mat; - if (deferred_render) - { - mat = params.mMaterial; - } - - if (params.mFullbright) - { - // Turn off lighting if it hasn't already been so. - if (light_enabled || !initialized_lighting) - { - initialized_lighting = TRUE; - target_shader = fullbright_shader; + if (is_pbr && gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND) + { + target_shader = &gDeferredPBRAlphaProgram[rigged]; + } + else + { + if (deferred_render) + { + mat = params.mMaterial; + } - light_enabled = FALSE; - } - } - // Turn on lighting if it isn't already. - else if (!light_enabled || !initialized_lighting) - { - initialized_lighting = TRUE; - target_shader = simple_shader; - light_enabled = TRUE; - } + if (params.mFullbright) + { + // Turn off lighting if it hasn't already been so. + if (light_enabled || !initialized_lighting) + { + initialized_lighting = TRUE; + target_shader = fullbright_shader; - if (deferred_render && mat) - { - U32 mask = params.mShaderMask; + light_enabled = FALSE; + } + } + // Turn on lighting if it isn't already. + else if (!light_enabled || !initialized_lighting) + { + initialized_lighting = TRUE; + target_shader = simple_shader; + light_enabled = TRUE; + } - llassert(mask < LLMaterial::SHADER_COUNT); - target_shader = &(gDeferredMaterialProgram[mask]); + if (deferred_render && mat) + { + U32 mask = params.mShaderMask; - if (LLPipeline::sUnderWaterRender) - { - target_shader = &(gDeferredMaterialWaterProgram[mask]); - } + llassert(mask < LLMaterial::SHADER_COUNT); + target_shader = &(gDeferredMaterialProgram[mask]); - if (params.mAvatar != nullptr) + if (LLPipeline::sUnderWaterRender) + { + target_shader = &(gDeferredMaterialWaterProgram[mask]); + } + + if (params.mAvatar != nullptr) + { + llassert(target_shader->mRiggedVariant != nullptr); + target_shader = target_shader->mRiggedVariant; + } + + if (current_shader != target_shader) + { + gPipeline.bindDeferredShader(*target_shader); + } + } + else if (!params.mFullbright) { - llassert(target_shader->mRiggedVariant != nullptr); - target_shader = target_shader->mRiggedVariant; + target_shader = simple_shader; } - - if (current_shader != target_shader) - { - gPipeline.bindDeferredShader(*target_shader); - } - } - else if (!params.mFullbright) - { - target_shader = simple_shader; - } - else - { - target_shader = fullbright_shader; - } + else + { + target_shader = fullbright_shader; + } + } if (params.mAvatar != nullptr) { @@ -673,6 +684,56 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) target_shader->bind(); } + if (is_pbr) + { + if (params.mTexture.notNull()) + { + gGL.getTexUnit(0)->bindFast(params.mTexture); // diffuse + } + else + { + gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep); + } + + if (params.mNormalMap) + { + target_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap); + } + else + { + target_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); + } + + if (params.mSpecularMap) + { + target_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, params.mSpecularMap); // PBR linear packed Occlusion, Roughness, Metal. + } + else + { + target_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); + } + + if (params.mEmissiveMap) + { + target_shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, params.mEmissiveMap); // PBR sRGB Emissive + } + else + { + target_shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, LLViewerFetchedTexture::sWhiteImagep); + } + + target_shader->uniform1f(LLShaderMgr::ROUGHNESS_FACTOR, params.mGLTFMaterial->mRoughnessFactor); + target_shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, params.mGLTFMaterial->mMetallicFactor); + target_shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, params.mGLTFMaterial->mEmissiveColor.mV); + + LLEnvironment& environment = LLEnvironment::instance(); + target_shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + + // TODO? prepare_alpha_shader( target_shader, false, true ); + target_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, gPipeline.mTransformedSunDir.mV); + target_shader->uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, gPipeline.mTransformedMoonDir.mV); + } + LLVector4 spec_color(1, 1, 1, 1); F32 env_intensity = 0.0f; F32 brightness = 1.0f; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 0d9670d9ca..8ec51b3856 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -265,6 +265,7 @@ LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredPBROpaqueProgram; LLGLSLShader gDeferredSkinnedPBROpaqueProgram; +LLGLSLShader gDeferredPBRAlphaProgram[2]; // not skinned, skinned //helper for making a rigged variant of a given shader bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader) @@ -1283,6 +1284,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPBROpaqueProgram.unload(); gDeferredSkinnedPBROpaqueProgram.unload(); + gDeferredPBRAlphaProgram[0].unload(); + gDeferredPBRAlphaProgram[1].unload(); return TRUE; } @@ -1616,6 +1619,80 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() } llassert(success); } + + if (success) + { + for (int rigged = 0; rigged < 2 && success; ++rigged) + { + LLGLSLShader* shader = &gDeferredPBRAlphaProgram[rigged]; + shader->mName = rigged + ? "Skinned Deferred PBR Alpha Shader" + : "Deferred PBR Alpha Shader"; + shader->mRiggedVariant = rigged + ? &gDeferredPBRAlphaProgram[1] + : nullptr; + shader->mFeatures.hasObjectSkinning = (bool)rigged; + shader->mFeatures.calculatesLighting = false; + shader->mFeatures.hasLighting = false; + shader->mFeatures.isAlphaLighting = true; + shader->mFeatures.hasSrgb = true; + shader->mFeatures.encodesNormal = true; + shader->mFeatures.calculatesAtmospherics = true; + shader->mFeatures.hasAtmospherics = true; + shader->mFeatures.hasGamma = true; + shader->mFeatures.hasTransport = true; + shader->mFeatures.hasShadows = use_sun_shadow; + shader->mFeatures.isDeferred = true; // include deferredUtils + shader->mFeatures.hasReflectionProbes = mShaderLevel[SHADER_DEFERRED]; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaV.glsl", GL_VERTEX_SHADER_ARB)); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + + shader->clearPermutations(); + + U32 alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; + shader->addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); + shader->addPermutation("HAS_NORMAL_MAP", "1"); + shader->addPermutation("HAS_SPECULAR_MAP", "1"); // PBR: Packed: Occlusion, Metal, Roughness + shader->addPermutation("HAS_EMISSIVE_MAP", "1"); + shader->addPermutation("USE_VERTEX_COLOR", "1"); + if (use_sun_shadow) + { + shader->addPermutation("HAS_SHADOW", "1"); + } + + if (ambient_kill) + { + shader->addPermutation("AMBIENT_KILL", "1"); + } + + if (sunlight_kill) + { + shader->addPermutation("SUNLIGHT_KILL", "1"); + } + + if (local_light_kill) + { + shader->addPermutation("LOCAL_LIGHT_KILL", "1"); + } + + if (rigged) + { + shader->addPermutation("HAS_SKIN", "1"); + } + + shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + + success = shader->createShader(NULL, NULL); + llassert(success); + + // Alpha Shader Hack + shader->mFeatures.calculatesLighting = true; + shader->mFeatures.hasLighting = true; + } + } + if (success) { diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index ef49074959..38f67cd23c 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -321,5 +321,6 @@ extern LLGLSLShader gNormalMapGenProgram; extern LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; extern LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; -extern LLGLSLShader gDeferredPBROpaqueProgram; +extern LLGLSLShader gDeferredPBROpaqueProgram; +extern LLGLSLShader gDeferredPBRAlphaProgram[2]; // not skinned, skinned #endif diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index ad11fb3908..f1e3d27d7c 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5892,7 +5892,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool is_pbr = false; #endif #else - bool is_pbr = facep->getTextureEntry()->getGLTFMaterial() != nullptr; + LLGLTFMaterial *gltf_mat = facep->getTextureEntry()->getGLTFMaterial(); + bool is_pbr = gltf_mat != nullptr; #endif //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render @@ -5960,8 +5961,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) BOOL force_simple = (facep->getPixelArea() < FORCE_SIMPLE_RENDER_AREA); U32 type = gPipeline.getPoolTypeFromTE(te, tex); - - if (is_pbr) + if (is_pbr && gltf_mat && gltf_mat->mAlphaMode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) { type = LLDrawPool::POOL_PBR_OPAQUE; } @@ -6781,7 +6781,10 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (gltf_mat) { // all other parameters ignored if gltf material is present - registerFace(group, facep, LLRenderPass::PASS_PBR_OPAQUE); + if (gltf_mat->mAlphaMode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + registerFace(group, facep, LLRenderPass::PASS_ALPHA); + else + registerFace(group, facep, LLRenderPass::PASS_PBR_OPAQUE); } else // do NOT use 'fullbright' for this logic or you risk sending diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 67f0ea68c1..abf0d457e2 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1684,7 +1684,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } } - if (alpha) + if (alpha || (gltf_mat && gltf_mat->mAlphaMode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) { return LLDrawPool::POOL_ALPHA; } @@ -1692,7 +1692,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima { return LLDrawPool::POOL_BUMP; } - else if (gltf_mat && !alpha) + else if (gltf_mat) { return LLDrawPool::POOL_PBR_OPAQUE; } -- cgit v1.3 From cb902bf9a97177322c222a032715262987c98eb9 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 9 Sep 2022 15:34:02 -0700 Subject: SL-17701: Fix enum compare using wrong types which broke macOS build --- indra/newview/llvovolume.cpp | 4 ++-- indra/newview/pipeline.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index f1e3d27d7c..b5dd8379ce 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5961,7 +5961,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) BOOL force_simple = (facep->getPixelArea() < FORCE_SIMPLE_RENDER_AREA); U32 type = gPipeline.getPoolTypeFromTE(te, tex); - if (is_pbr && gltf_mat && gltf_mat->mAlphaMode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + if (is_pbr && gltf_mat && gltf_mat->mAlphaMode != LLGLTFMaterial::ALPHA_MODE_BLEND) { type = LLDrawPool::POOL_PBR_OPAQUE; } @@ -6781,7 +6781,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (gltf_mat) { // all other parameters ignored if gltf material is present - if (gltf_mat->mAlphaMode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND) registerFace(group, facep, LLRenderPass::PASS_ALPHA); else registerFace(group, facep, LLRenderPass::PASS_PBR_OPAQUE); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index abf0d457e2..5398243f55 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1684,7 +1684,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } } - if (alpha || (gltf_mat && gltf_mat->mAlphaMode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) + if (alpha || (gltf_mat && gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND)) { return LLDrawPool::POOL_ALPHA; } -- cgit v1.3 From 2ce39f3ad98fe855fb126dc29c82145751434421 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 14 Sep 2022 16:24:20 -0500 Subject: SL-17701 Fix for shadow passes not respecting double sided and alpha parameters for PBR materials. --- indra/newview/lldrawpool.cpp | 2 ++ indra/newview/llvovolume.cpp | 8 ++++++++ indra/newview/pipeline.cpp | 19 +++++++++---------- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 1e548141c8..7c4c2e4b7e 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -577,6 +577,8 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba params.mGroup->rebuildMesh(); } + LLGLDisable cull(params.mGLTFMaterial && params.mGLTFMaterial->mDoubleSided ? GL_CULL_FACE : 0); + LLGLEnableFunc stencil_test(GL_STENCIL_TEST, params.mSelected, &LLGLCommonFunc::selected_stencil_test); params.mVertexBuffer->setBufferFast(mask); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index b2365653ba..a02c18d99f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5539,6 +5539,14 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_info->mNormalMap = vobj->getGLTFNormalMap(te); draw_info->mSpecularMap = vobj->getGLTFMetallicRoughnessMap(te); draw_info->mEmissiveMap = vobj->getGLTFEmissiveMap(te); + if (draw_info->mGLTFMaterial->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) + { + draw_info->mAlphaMaskCutoff = gltf_mat->mAlphaCutoff * gltf_mat->mAlbedoColor.mV[3]; + } + else + { + draw_info->mAlphaMaskCutoff = 1.f; + } } else if (mat) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 160a1680c1..858cc90d04 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9753,9 +9753,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderPass::PASS_NORMMAP, LLRenderPass::PASS_NORMMAP_EMISSIVE, LLRenderPass::PASS_NORMSPEC, - LLRenderPass::PASS_NORMSPEC_EMISSIVE, - LLRenderPass::PASS_PBR_OPAQUE, // NOTE: Assumes PASS_PBR_OPAQUE_RIGGED is consecutive - //LLRenderPass::PASS_PBR_OPAQUE_RIGGED, + LLRenderPass::PASS_NORMSPEC_EMISSIVE }; LLGLEnable cull(GL_CULL_FACE); @@ -9839,7 +9837,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera if (use_shader) { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_GEOM); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); gDeferredShadowProgram.unbind(); renderGeomShadow(shadow_cam); @@ -9848,13 +9846,13 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera } else { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_GEOM); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow geom"); renderGeomShadow(shadow_cam); } { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); LL_PROFILE_GPU_ZONE("shadow alpha"); for (int i = 0; i < 2; ++i) { @@ -9870,19 +9868,19 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLVertexBuffer::MAP_TEXTURE_INDEX; { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_MASKED); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE, rigged); } { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_BLEND); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); renderAlphaObjects(mask, TRUE, TRUE, rigged); } { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_FULLBRIGHT_ALPHA_MASKED); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); gDeferredShadowFullbrightAlphaMaskProgram.bind(rigged); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); @@ -9891,7 +9889,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_GRASS); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); gDeferredTreeShadowProgram.bind(rigged); if (i == 0) { @@ -9904,6 +9902,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, no_idx_mask, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, no_idx_mask, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, no_idx_mask, true, false, rigged); + renderMaskedObjects(LLRenderPass::PASS_PBR_OPAQUE, no_idx_mask, true, false, rigged); } } } -- cgit v1.3 From a0a87db3d76bc78e245e89254db190ba68b3709e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 14 Sep 2022 17:04:33 -0500 Subject: SL-17701 Fix for PBR alpha trying to use indexed texture batching --- indra/newview/llvovolume.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index a02c18d99f..61589640fe 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5243,6 +5243,11 @@ bool can_batch_texture(LLFace* facep) return false; } + if (facep->getTextureEntry()->getGLTFMaterial() != nullptr) + { // PBR materials break indexed texture batching + return false; + } + return true; } -- cgit v1.3 From 8dc59e5ef37836b15d478fb0d04e3043a9f986de Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Sep 2022 16:25:26 -0500 Subject: SL-18128 Clear out much OpenGL cruft and switch to core profile on AMD --- indra/llmath/llvolume.cpp | 15 +- indra/llmath/llvolume.h | 11 +- indra/llprimitive/lldaeloader.cpp | 11 +- indra/llprimitive/llmodel.cpp | 9 - indra/llprimitive/llmodel.h | 1 - indra/llrender/llcubemap.cpp | 6 +- indra/llrender/llgl.cpp | 440 ++------------------- indra/llrender/llgl.h | 63 +-- indra/llrender/llglheaders.h | 277 ------------- indra/llrender/llimagegl.cpp | 110 ++---- indra/llrender/llimagegl.h | 2 +- indra/llrender/llrender.cpp | 50 +-- indra/llrender/llrender.h | 2 - indra/llrender/llrendertarget.cpp | 20 +- indra/llrender/llvertexbuffer.cpp | 200 +++------- indra/newview/app_settings/settings.xml | 12 - indra/newview/featuretable.txt | 7 +- indra/newview/lldrawpoolterrain.cpp | 17 - indra/newview/lldrawpoolwater.cpp | 8 +- indra/newview/lldynamictexture.cpp | 4 +- indra/newview/llface.cpp | 200 +--------- indra/newview/llface.h | 2 - indra/newview/llfeaturemanager.cpp | 38 +- indra/newview/llfloaterpreference.cpp | 11 +- indra/newview/llglsandbox.cpp | 22 +- indra/newview/llscenemonitor.cpp | 8 +- indra/newview/llviewercontrol.cpp | 2 +- indra/newview/llviewermenu.cpp | 40 -- indra/newview/llvieweroctree.cpp | 27 +- indra/newview/llviewershadermgr.cpp | 176 +-------- indra/newview/llviewershadermgr.h | 11 - indra/newview/llviewerwindow.cpp | 33 -- indra/newview/llvosky.cpp | 4 +- indra/newview/llvovolume.cpp | 32 +- indra/newview/pipeline.cpp | 19 +- indra/newview/skins/default/xui/en/menu_viewer.xml | 2 - 36 files changed, 221 insertions(+), 1671 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index ae753fc0f3..559d790d77 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -2783,7 +2783,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) } } - if (!cacheOptimize()) + if (!cacheOptimize(true)) { // Out of memory? LL_WARNS() << "Failed to optimize!" << LL_ENDL; @@ -2824,11 +2824,11 @@ void LLVolume::copyVolumeFaces(const LLVolume* volume) mSculptLevel = 0; } -bool LLVolume::cacheOptimize() +bool LLVolume::cacheOptimize(bool gen_tangents) { for (S32 i = 0; i < mVolumeFaces.size(); ++i) { - if (!mVolumeFaces[i].cacheOptimize()) + if (!mVolumeFaces[i].cacheOptimize(gen_tangents)) { return false; } @@ -5478,18 +5478,13 @@ struct MikktData }; -bool LLVolumeFace::cacheOptimize() +bool LLVolumeFace::cacheOptimize(bool gen_tangents) { //optimize for vertex cache according to Forsyth method: LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; llassert(!mOptimized); mOptimized = TRUE; - if (!mNormals || !mTexCoords) - { // can't perform this operation without normals and texture coordinates - return false; - } - - if (mMikktSpaceTangents == nullptr) + if (mMikktSpaceTangents == nullptr && gen_tangents && mNormals && mTexCoords) { // make sure to generate mikkt space tangents for cache optimizing since the index buffer may change allocateTangents(mNumVertices, true); diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index e373d0175d..6ea12c6920 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -907,7 +907,7 @@ public: void remap(); void optimize(F32 angle_cutoff = 2.f); - bool cacheOptimize(); + bool cacheOptimize(bool gen_tangents = false); void createOctree(F32 scaler = 0.25f, const LLVector4a& center = LLVector4a(0,0,0), const LLVector4a& size = LLVector4a(0.5f,0.5f,0.5f)); @@ -957,10 +957,6 @@ public: // indexes for mPositions/mNormals/mTexCoords U16* mIndices; - // vertex buffer filled in by LLFace to cache this volume face geometry in vram - // (declared as a LLPointer to LLRefCount to avoid dependency on LLVertexBuffer) - mutable LLPointer mVertexBuffer; - std::vector mEdge; //list of skin weights for rigged volumes @@ -1089,7 +1085,10 @@ public: void copyVolumeFaces(const LLVolume* volume); void copyFacesTo(std::vector &faces) const; void copyFacesFrom(const std::vector &faces); - bool cacheOptimize(); + + // use meshoptimizer to optimize index buffer for vertex shader cache + // gen_tangents - if true, generate MikkTSpace tangents if needed before optimizing index buffer + bool cacheOptimize(bool gen_tangents = false); private: void sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type); diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 9470146ce4..dbb34ab60b 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -2551,9 +2551,6 @@ bool LLDAELoader::loadModelsFromDomMesh(domMesh* mesh, std::vector& mo LLVolume::face_list_t remainder; do { - // generate tangents and cache optimize before normalizing - ret->preprocessVolumeFaces(); - // Insure we do this once with the whole gang and not per-model // if (!normalized && !mNoNormalize) @@ -2565,10 +2562,10 @@ bool LLDAELoader::loadModelsFromDomMesh(domMesh* mesh, std::vector& mo ret->trimVolumeFacesToSize(LL_SCULPT_MESH_MAX_FACES, &remainder); // remove unused/redundant vertices after normalizing - //if (!mNoOptimize) - //{ - // ret->remapVolumeFaces(); - //} + if (!mNoOptimize) + { + ret->remapVolumeFaces(); + } volume_faces = remainder.size(); diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index ab507edc40..eff47d9d98 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -187,15 +187,6 @@ void LLModel::trimVolumeFacesToSize(U32 new_count, LLVolume::face_list_t* remain } } -// generate mikkt space tangents and cache optimize -void LLModel::preprocessVolumeFaces() -{ - for (auto& face : mVolumeFaces) - { - face.cacheOptimize(); - } -} - // Shrink the model to fit // on a 1x1x1 cube centered at the origin. // The positions and extents diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index ea97851ce8..354ceb26b7 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -182,7 +182,6 @@ public: void addFace(const LLVolumeFace& face); void sortVolumeFacesByMaterialName(); - void preprocessVolumeFaces(); void normalizeVolumeFaces(); void trimVolumeFacesToSize(U32 new_count = LL_SCULPT_MESH_MAX_FACES, LLVolume::face_list_t* remainder = NULL); void remapVolumeFaces(); diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp index e41765622f..254288a86e 100644 --- a/indra/llrender/llcubemap.cpp +++ b/indra/llrender/llcubemap.cpp @@ -67,7 +67,7 @@ void LLCubeMap::initGL() { llassert(gGLManager.mInited); - if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) + if (LLCubeMap::sUseCubeMaps) { // Not initialized, do stuff. if (mImages[0].isNull()) @@ -252,7 +252,7 @@ void LLCubeMap::enable(S32 stage) void LLCubeMap::enableTexture(S32 stage) { mTextureStage = stage; - if (gGLManager.mHasCubeMap && stage >= 0 && LLCubeMap::sUseCubeMaps) + if (stage >= 0 && LLCubeMap::sUseCubeMaps) { gGL.getTexUnit(stage)->enable(LLTexUnit::TT_CUBE_MAP); } @@ -265,7 +265,7 @@ void LLCubeMap::disable(void) void LLCubeMap::disableTexture(void) { - if (gGLManager.mHasCubeMap && mTextureStage >= 0 && LLCubeMap::sUseCubeMaps) + if (mTextureStage >= 0 && LLCubeMap::sUseCubeMaps) { gGL.getTexUnit(mTextureStage)->disable(); if (mTextureStage == 0) diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 5253ed3d51..71303b0517 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -86,15 +86,15 @@ void APIENTRY gl_debug_callback(GLenum source, const GLchar* message, GLvoid* userParam) { - /*if (severity != GL_DEBUG_SEVERITY_HIGH_ARB // && - severity != GL_DEBUG_SEVERITY_MEDIUM_ARB && - severity != GL_DEBUG_SEVERITY_LOW_ARB + /*if (severity != GL_DEBUG_SEVERITY_HIGH // && + severity != GL_DEBUG_SEVERITY_MEDIUM && + severity != GL_DEBUG_SEVERITY_LOW ) { //suppress out-of-spec messages sent by nvidia driver (mostly vertexbuffer hints) return; }*/ - if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) + if (severity == GL_DEBUG_SEVERITY_HIGH) { LL_WARNS() << "----- GL ERROR --------" << LL_ENDL; } @@ -107,7 +107,15 @@ void APIENTRY gl_debug_callback(GLenum source, LL_WARNS() << "Severity: " << std::hex << severity << LL_ENDL; LL_WARNS() << "Message: " << message << LL_ENDL; LL_WARNS() << "-----------------------" << LL_ENDL; - if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) + + GLint vao = 0; + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &vao); + GLint vbo = 0; + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &vbo); + GLint ibo = 0; + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &ibo); + + if (severity == GL_DEBUG_SEVERITY_HIGH) { LL_ERRS() << "Halting on GL Error" << LL_ENDL; } @@ -931,44 +939,12 @@ LLGLManager gGLManager; LLGLManager::LLGLManager() : mInited(FALSE), mIsDisabled(FALSE), - - mHasMultitexture(FALSE), - mHasATIMemInfo(FALSE), - mHasAMDAssociations(FALSE), - mHasNVXMemInfo(FALSE), - mNumTextureUnits(1), - mHasMipMapGeneration(FALSE), - mHasCompressedTextures(FALSE), - mHasFramebufferObject(FALSE), mMaxSamples(0), - mHasBlendFuncSeparate(FALSE), - mHasSync(FALSE), - mHasVertexBufferObject(FALSE), - mHasVertexArrayObject(FALSE), - mHasMapBufferRange(FALSE), - mHasFlushBufferRange(FALSE), - mHasPBuffer(FALSE), - mNumTextureImageUnits(0), - mHasOcclusionQuery(FALSE), - mHasTimerQuery(FALSE), - mHasOcclusionQuery2(FALSE), - mHasPointParameters(FALSE), - mHasDrawBuffers(FALSE), - mHasTextureRectangle(FALSE), - mHasTextureMultisample(FALSE), - mHasTransformFeedback(FALSE), - mHasUniformBufferObject(FALSE), + mNumTextureImageUnits(1), mMaxSampleMaskWords(0), mMaxColorTextureSamples(0), mMaxDepthTextureSamples(0), mMaxIntegerSamples(0), - - mHasAnisotropic(FALSE), - mHasARBEnvCombine(FALSE), - mHasCubeMap(FALSE), - mHasCubeMapArray(FALSE), - mHasDebugOutput(FALSE), - mIsAMD(FALSE), mIsNVIDIA(FALSE), mIsIntel(FALSE), @@ -976,9 +952,6 @@ LLGLManager::LLGLManager() : mIsMobileGF(FALSE), #endif mHasRequirements(TRUE), - - mHasSeparateSpecularColor(FALSE), - mDriverVersionMajor(1), mDriverVersionMinor(0), mDriverVersionRelease(0), @@ -996,7 +969,6 @@ LLGLManager::LLGLManager() : //--------------------------------------------------------------------- void LLGLManager::initWGL() { - mHasPBuffer = FALSE; #if LL_WINDOWS && !LL_MESA_HEADLESS if (!glh_init_extensions("WGL_ARB_pixel_format")) { @@ -1035,10 +1007,6 @@ void LLGLManager::initWGL() { LL_WARNS("RenderInit") << "No ARB WGL render texture extensions" << LL_ENDL; } - - mHasPBuffer = ExtensionExists("WGL_ARB_pbuffer", gGLHExts.mSysExts) && - ExtensionExists("WGL_ARB_render_texture", gGLHExts.mSysExts) && - ExtensionExists("WGL_ARB_pixel_format", gGLHExts.mSysExts); #endif } @@ -1052,7 +1020,7 @@ bool LLGLManager::initGL() stop_glerror(); -#if LL_WINDOWS +#if 0 && LL_WINDOWS if (!glGetStringi) { glGetStringi = (PFNGLGETSTRINGIPROC) GLH_EXT_GET_PROC_ADDRESS("glGetStringi"); @@ -1199,23 +1167,6 @@ bool LLGLManager::initGL() } #endif - if (mHasATIMemInfo && mVRAM == 0) - { //ask the gl how much vram is free at startup and attempt to use no more than half of that - S32 meminfo[4]; - glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo); - - mVRAM = meminfo[0] / 1024; - LL_WARNS("RenderInit") << "VRAM Detected (ATIMemInfo):" << mVRAM << LL_ENDL; - } - - if (mHasNVXMemInfo && mVRAM == 0) - { - S32 dedicated_memory; - glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &dedicated_memory); - mVRAM = dedicated_memory/1024; - LL_WARNS("RenderInit") << "VRAM Detected (NVXMemInfo):" << mVRAM << LL_ENDL; - } - #if LL_WINDOWS if (mVRAM < 256) { @@ -1243,62 +1194,22 @@ bool LLGLManager::initGL() stop_glerror(); - GLint num_tex_image_units; - glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &num_tex_image_units); - mNumTextureImageUnits = llmin(num_tex_image_units, 32); - - if (mHasMultitexture) + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &mNumTextureImageUnits); + stop_glerror(); + glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &mMaxColorTextureSamples); + stop_glerror(); + glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &mMaxDepthTextureSamples); + stop_glerror(); + glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples); + stop_glerror(); + glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords); + stop_glerror(); + glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); + stop_glerror(); + if (mGLVersion >= 4.59f) { - if (LLRender::sGLCoreProfile) - { - mNumTextureUnits = llmin(mNumTextureImageUnits, MAX_GL_TEXTURE_UNITS); - } - else - { - GLint num_tex_units; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num_tex_units); - mNumTextureUnits = llmin(num_tex_units, (GLint)MAX_GL_TEXTURE_UNITS); - if (mIsIntel) - { - mNumTextureUnits = llmin(mNumTextureUnits, 2); - } - } + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &mMaxAnisotropy); } - else - { - mHasRequirements = FALSE; - - // We don't support cards that don't support the GL_ARB_multitexture extension - LL_WARNS("RenderInit") << "GL Drivers do not support GL_ARB_multitexture" << LL_ENDL; - return false; - } - - stop_glerror(); - - if (mHasTextureMultisample) - { - glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &mMaxColorTextureSamples); - glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &mMaxDepthTextureSamples); - glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples); - glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords); - } - - stop_glerror(); - - //HACK always disable texture multisample, use FXAA instead - mHasTextureMultisample = FALSE; -#if LL_WINDOWS - if (mIsIntel && mGLVersion <= 3.f) - { //never try to use framebuffer objects on older intel drivers (crashy) - mHasFramebufferObject = FALSE; - } -#endif - - if (mHasFramebufferObject) - { - glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); - } - stop_glerror(); initGLStates(); @@ -1406,62 +1317,22 @@ void LLGLManager::asLLSD(LLSD& info) info["vram"] = mVRAM; - // Extensions used by everyone - info["has_multitexture"] = mHasMultitexture; - info["has_ati_mem_info"] = mHasATIMemInfo; - info["has_nvx_mem_info"] = mHasNVXMemInfo; - info["num_texture_units"] = mNumTextureUnits; - info["has_mip_map_generation"] = mHasMipMapGeneration; - info["has_compressed_textures"] = mHasCompressedTextures; - info["has_framebuffer_object"] = mHasFramebufferObject; + // OpenGL limits info["max_samples"] = mMaxSamples; - info["has_blend_func_separate"] = mHasBlendFuncSeparate || LLRender::sGLCoreProfile; - - // ARB Extensions - info["has_vertex_buffer_object"] = mHasVertexBufferObject; - info["has_vertex_array_object"] = mHasVertexArrayObject; - info["has_sync"] = mHasSync; - info["has_map_buffer_range"] = mHasMapBufferRange; - info["has_flush_buffer_range"] = mHasFlushBufferRange; - info["has_pbuffer"] = mHasPBuffer; - info["has_shader_objects"] = std::string("Assumed TRUE"); // was mHasShaderObjects; - info["has_vertex_shader"] = std::string("Assumed TRUE"); // was mHasVertexShader; - info["has_fragment_shader"] = std::string("Assumed TRUE"); // was mHasFragmentShader; info["num_texture_image_units"] = mNumTextureImageUnits; - info["has_occlusion_query"] = mHasOcclusionQuery; - info["has_timer_query"] = mHasTimerQuery; - info["has_occlusion_query2"] = mHasOcclusionQuery2; - info["has_point_parameters"] = mHasPointParameters; - info["has_draw_buffers"] = mHasDrawBuffers; - info["has_depth_clamp"] = mHasDepthClamp; - info["has_texture_rectangle"] = mHasTextureRectangle; - info["has_texture_multisample"] = mHasTextureMultisample; - info["has_transform_feedback"] = mHasTransformFeedback; info["max_sample_mask_words"] = mMaxSampleMaskWords; info["max_color_texture_samples"] = mMaxColorTextureSamples; info["max_depth_texture_samples"] = mMaxDepthTextureSamples; info["max_integer_samples"] = mMaxIntegerSamples; + info["max_vertex_range"] = mGLMaxVertexRange; + info["max_index_range"] = mGLMaxIndexRange; + info["max_texture_size"] = mGLMaxTextureSize; - // Other extensions. - info["has_anisotropic"] = mHasAnisotropic; - info["has_arb_env_combine"] = mHasARBEnvCombine; - info["has_cube_map"] = mHasCubeMap; - info["has_debug_output"] = mHasDebugOutput; - info["has_srgb_texture"] = mHassRGBTexture; - info["has_srgb_framebuffer"] = mHassRGBFramebuffer; - info["has_texture_srgb_decode"] = mHasTexturesRGBDecode; - - // Vendor-specific extensions + // Which vendor info["is_ati"] = mIsAMD; // note, do not rename is_ati to is_amd without coordinating with DW info["is_nvidia"] = mIsNVIDIA; info["is_intel"] = mIsIntel; - // Other fields - info["has_requirements"] = mHasRequirements; - info["has_separate_specular_color"] = mHasSeparateSpecularColor; - info["max_vertex_range"] = mGLMaxVertexRange; - info["max_index_range"] = mGLMaxIndexRange; - info["max_texture_size"] = mGLMaxTextureSize; info["gl_renderer"] = mGLRenderer; } @@ -1480,60 +1351,6 @@ void LLGLManager::shutdownGL() void LLGLManager::initExtensions() { -#if LL_MESA_HEADLESS -# ifdef GL_ARB_multitexture - mHasMultitexture = TRUE; -# else - mHasMultitexture = FALSE; -# endif // GL_ARB_multitexture -# ifdef GL_ARB_texture_env_combine - mHasARBEnvCombine = TRUE; -# else - mHasARBEnvCombine = FALSE; -# endif // GL_ARB_texture_env_combine -# ifdef GL_ARB_texture_compression - mHasCompressedTextures = TRUE; -# else - mHasCompressedTextures = FALSE; -# endif // GL_ARB_texture_compression -# ifdef GL_ARB_vertex_buffer_object - mHasVertexBufferObject = TRUE; -# else - mHasVertexBufferObject = FALSE; -# endif // GL_ARB_vertex_buffer_object -# ifdef GL_EXT_framebuffer_object - mHasFramebufferObject = TRUE; -# else - mHasFramebufferObject = FALSE; -# endif // GL_EXT_framebuffer_object -# ifdef GL_ARB_draw_buffers - mHasDrawBuffers = TRUE; -#else - mHasDrawBuffers = FALSE; -# endif // GL_ARB_draw_buffers -# if defined(GL_NV_depth_clamp) || defined(GL_ARB_depth_clamp) - mHasDepthClamp = TRUE; -#else - mHasDepthClamp = FALSE; -#endif // defined(GL_NV_depth_clamp) || defined(GL_ARB_depth_clamp) -# if GL_EXT_blend_func_separate - mHasBlendFuncSeparate = TRUE; -#else - mHasBlendFuncSeparate = FALSE; -# endif // GL_EXT_blend_func_separate - mHasMipMapGeneration = FALSE; - mHasSeparateSpecularColor = FALSE; - mHasAnisotropic = FALSE; - mHasCubeMap = FALSE; - mHasOcclusionQuery = FALSE; - mHasPointParameters = FALSE; - mHasTextureRectangle = FALSE; -#else // LL_MESA_HEADLESS //important, gGLHExts.mSysExts is uninitialized until after glh_init_extensions is called - - mHasMultitexture = TRUE; - mHasCubeMap = TRUE; - mHasCompressedTextures = TRUE; - #if LL_DARWIN GLint num_extensions = 0; std::string all_extensions{""}; @@ -1550,173 +1367,12 @@ void LLGLManager::initExtensions() } #endif - mHasSeparateSpecularColor = ExtensionExists("GL_EXT_separate_specular_color", gGLHExts.mSysExts); - mHasAnisotropic = ExtensionExists("GL_EXT_texture_filter_anisotropic", gGLHExts.mSysExts); - - // In core profile - mHasARBEnvCombine = TRUE; //ExtensionExists("GL_ARB_texture_env_combine", gGLHExts.mSysExts); - mHasTimerQuery = FALSE; //FIXME //ExtensionExists("GL_ARB_timer_query", gGLHExts.mSysExts); - mHasOcclusionQuery = TRUE; //ExtensionExists("GL_ARB_occlusion_query", gGLHExts.mSysExts); - mHasOcclusionQuery2 = TRUE; // ExtensionExists("GL_ARB_occlusion_query2", gGLHExts.mSysExts); - mHasVertexBufferObject = TRUE; //ExtensionExists("GL_ARB_vertex_buffer_object", gGLHExts.mSysExts); - mHasVertexArrayObject = TRUE; //ExtensionExists("GL_ARB_vertex_array_object", gGLHExts.mSysExts); - mHasMapBufferRange = TRUE; ExtensionExists("GL_ARB_map_buffer_range", gGLHExts.mSysExts); - mHasFlushBufferRange = ExtensionExists("GL_APPLE_flush_buffer_range", gGLHExts.mSysExts); // Apple has mHasMapBufferRange now - mHasSync = TRUE; //ExtensionExists("GL_ARB_sync", gGLHExts.mSysExts); - mHasFramebufferObject = TRUE; //ExtensionExists("GL_ARB_framebuffer_object", gGLHExts.mSysExts); - mHassRGBFramebuffer = TRUE; //ExtensionExists("GL_ARB_framebuffer_sRGB", gGLHExts.mSysExts); - mHasDrawBuffers = TRUE; //ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts); - mHasTextureRectangle = TRUE; //ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts); - mHasTextureMultisample = TRUE; //ExtensionExists("GL_ARB_texture_multisample", gGLHExts.mSysExts); - mHasUniformBufferObject = TRUE; //ExtensionExists("GL_ARB_uniform_buffer_object", gGLHExts.mSysExts); - mHasCubeMapArray = TRUE; //ExtensionExists("GL_ARB_texture_cube_map_array", gGLHExts.mSysExts); - mHasPointParameters = TRUE; //ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts); - - mHasATIMemInfo = ExtensionExists("GL_ATI_meminfo", gGLHExts.mSysExts); //Basic AMD method, also see mHasAMDAssociations - mHasNVXMemInfo = ExtensionExists("GL_NVX_gpu_memory_info", gGLHExts.mSysExts); - // NOTE: Using extensions breaks reflections when Shadows are set to projector. See: SL-16727 - //mHasDepthClamp = ExtensionExists("GL_ARB_depth_clamp", gGLHExts.mSysExts) || ExtensionExists("GL_NV_depth_clamp", gGLHExts.mSysExts); - mHasDepthClamp = FALSE; - // mask out FBO support when packed_depth_stencil isn't there 'cause we need it for LLRenderTarget -Brad - -#ifdef GL_EXT_texture_sRGB - mHassRGBTexture = ExtensionExists("GL_EXT_texture_sRGB", gGLHExts.mSysExts); -#endif - - -#ifdef GL_EXT_texture_sRGB_decode - mHasTexturesRGBDecode = ExtensionExists("GL_EXT_texture_sRGB_decode", gGLHExts.mSysExts); -#else - mHasTexturesRGBDecode = ExtensionExists("GL_ARB_texture_sRGB_decode", gGLHExts.mSysExts); -#endif - - mHasMipMapGeneration = mHasFramebufferObject || mGLVersion >= 1.4f; + // OpenGL 4.x capabilities + mHasCubeMapArray = mGLVersion >= 3.99f; + mHasTransformFeedback = mGLVersion >= 3.99f; + mHasDebugOutput = mGLVersion >= 4.29f; - mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts); - mHasDebugOutput = mGLVersion >= 4.3f ? TRUE : FALSE; - mHasTransformFeedback = mGLVersion >= 4.f ? TRUE : FALSE; -#endif - -#if LL_LINUX - LL_INFOS() << "initExtensions() checking shell variables to adjust features..." << LL_ENDL; - // Our extension support for the Linux Client is very young with some - // potential driver gotchas, so offer a semi-secret way to turn it off. - if (getenv("LL_GL_NOEXT")) - { - //mHasMultitexture = FALSE; // NEEDED! - mHasDepthClamp = FALSE; - mHasARBEnvCombine = FALSE; - mHasCompressedTextures = FALSE; - mHasVertexBufferObject = FALSE; - mHasFramebufferObject = FALSE; - mHasDrawBuffers = FALSE; - mHasBlendFuncSeparate = FALSE; - mHasMipMapGeneration = FALSE; - mHasSeparateSpecularColor = FALSE; - mHasAnisotropic = FALSE; - mHasCubeMap = FALSE; - mHasOcclusionQuery = FALSE; - mHasPointParameters = FALSE; - LL_WARNS("RenderInit") << "GL extension support DISABLED via LL_GL_NOEXT" << LL_ENDL; - } - else if (getenv("LL_GL_BASICEXT")) /* Flawfinder: ignore */ - { - // This switch attempts to turn off all support for exotic - // extensions which I believe correspond to fatal driver - // bug reports. This should be the default until we get a - // proper blacklist/whitelist on Linux. - mHasMipMapGeneration = FALSE; - mHasAnisotropic = FALSE; - //mHasCubeMap = FALSE; // apparently fatal on Intel 915 & similar - //mHasOcclusionQuery = FALSE; // source of many ATI system hangs - mHasBlendFuncSeparate = FALSE; - LL_WARNS("RenderInit") << "GL extension support forced to SIMPLE level via LL_GL_BASICEXT" << LL_ENDL; - } - if (getenv("LL_GL_BLACKLIST")) /* Flawfinder: ignore */ - { - // This lets advanced troubleshooters disable specific - // GL extensions to isolate problems with their hardware. - // SL-28126 - const char *const blacklist = getenv("LL_GL_BLACKLIST"); /* Flawfinder: ignore */ - LL_WARNS("RenderInit") << "GL extension support partially disabled via LL_GL_BLACKLIST: " << blacklist << LL_ENDL; - if (strchr(blacklist,'a')) mHasARBEnvCombine = FALSE; - if (strchr(blacklist,'b')) mHasCompressedTextures = FALSE; - if (strchr(blacklist,'c')) mHasVertexBufferObject = FALSE; - if (strchr(blacklist,'d')) mHasMipMapGeneration = FALSE;//S -// if (strchr(blacklist,'f')) mHasNVVertexArrayRange = FALSE;//S -// if (strchr(blacklist,'g')) mHasNVFence = FALSE;//S - if (strchr(blacklist,'h')) mHasSeparateSpecularColor = FALSE; - if (strchr(blacklist,'i')) mHasAnisotropic = FALSE;//S - if (strchr(blacklist,'j')) mHasCubeMap = FALSE;//S -// if (strchr(blacklist,'k')) mHasATIVAO = FALSE;//S - if (strchr(blacklist,'l')) mHasOcclusionQuery = FALSE; - if (strchr(blacklist,'p')) mHasPointParameters = FALSE;//S - if (strchr(blacklist,'q')) mHasFramebufferObject = FALSE;//S - if (strchr(blacklist,'r')) mHasDrawBuffers = FALSE;//S - if (strchr(blacklist,'s')) mHasTextureRectangle = FALSE; - if (strchr(blacklist,'t')) mHasBlendFuncSeparate = FALSE;//S - if (strchr(blacklist,'u')) mHasDepthClamp = FALSE; - - } -#endif // LL_LINUX - - if (!mHasMultitexture) - { - LL_INFOS("RenderInit") << "Couldn't initialize multitexturing" << LL_ENDL; - } - if (!mHasMipMapGeneration) - { - LL_INFOS("RenderInit") << "Couldn't initialize mipmap generation" << LL_ENDL; - } - if (!mHasARBEnvCombine) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_texture_env_combine" << LL_ENDL; - } - if (!mHasSeparateSpecularColor) - { - LL_INFOS("RenderInit") << "Couldn't initialize separate specular color" << LL_ENDL; - } - if (!mHasAnisotropic) - { - LL_INFOS("RenderInit") << "Couldn't initialize anisotropic filtering" << LL_ENDL; - } - if (!mHasCompressedTextures) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_texture_compression" << LL_ENDL; - } - if (!mHasOcclusionQuery) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_occlusion_query" << LL_ENDL; - } - if (!mHasOcclusionQuery2) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_occlusion_query2" << LL_ENDL; - } - if (!mHasPointParameters) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_point_parameters" << LL_ENDL; - } - if (!mHasBlendFuncSeparate && !LLRender::sGLCoreProfile) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_EXT_blend_func_separate" << LL_ENDL; - } - if (!mHasDrawBuffers) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_draw_buffers" << LL_ENDL; - } - if (!mHasCubeMapArray) - { - LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_texture_cube_map_array" << LL_ENDL; - } - - // Disable certain things due to known bugs - if (mIsIntel && mHasMipMapGeneration) - { - LL_INFOS("RenderInit") << "Disabling mip-map generation for Intel GPUs" << LL_ENDL; - mHasMipMapGeneration = FALSE; - } - - // Misc + // Misc glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, (GLint*) &mGLMaxVertexRange); glGetIntegerv(GL_MAX_ELEMENTS_INDICES, (GLint*) &mGLMaxIndexRange); glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*) &mGLMaxTextureSize); @@ -2795,7 +2451,7 @@ void LLGLState::checkTextureChannels(const std::string& msg) glh::matrix4f identity; identity.identity(); - for (GLint i = 1; i < gGLManager.mNumTextureUnits; i++) + for (GLint i = 1; i < gGLManager.mNumTextureImageUnits; i++) { gGL.getTexUnit(i)->activate(); @@ -2833,12 +2489,6 @@ void LLGLState::checkTextureChannels(const std::string& msg) for (S32 j = (i == 0 ? 1 : 0); j < 9; j++) { - if (j == 8 && !gGLManager.mHasTextureRectangle || - j == 9 && !gGLManager.mHasTextureMultisample) - { - continue; - } - if (glIsEnabled(value[j])) { error = TRUE; @@ -3329,36 +2979,29 @@ LLGLSquashToFarClip::~LLGLSquashToFarClip() LLGLSyncFence::LLGLSyncFence() { -#ifdef GL_ARB_sync mSync = 0; -#endif } LLGLSyncFence::~LLGLSyncFence() { -#ifdef GL_ARB_sync if (mSync) { glDeleteSync(mSync); } -#endif } void LLGLSyncFence::placeFence() { -#ifdef GL_ARB_sync if (mSync) { glDeleteSync(mSync); } mSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); -#endif } bool LLGLSyncFence::isCompleted() { bool ret = true; -#ifdef GL_ARB_sync if (mSync) { GLenum status = glClientWaitSync(mSync, 0, 1); @@ -3367,13 +3010,11 @@ bool LLGLSyncFence::isCompleted() ret = false; } } -#endif return ret; } void LLGLSyncFence::wait() { -#ifdef GL_ARB_sync if (mSync) { while (glClientWaitSync(mSync, 0, FENCE_WAIT_TIME_NANOSECONDS) == GL_TIMEOUT_EXPIRED) @@ -3382,7 +3023,6 @@ void LLGLSyncFence::wait() waits++; } } -#endif } LLGLSPipelineSkyBox::LLGLSPipelineSkyBox() diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 3c40f85654..e3c07604aa 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -76,52 +76,27 @@ public: BOOL mInited; BOOL mIsDisabled; - // Extensions used by everyone - BOOL mHasMultitexture; - BOOL mHasATIMemInfo; - BOOL mHasAMDAssociations; - BOOL mHasNVXMemInfo; - S32 mNumTextureUnits; - BOOL mHasMipMapGeneration; - BOOL mHasCompressedTextures; - BOOL mHasFramebufferObject; + // OpenGL limits S32 mMaxSamples; - BOOL mHasBlendFuncSeparate; - - // ARB Extensions - BOOL mHasVertexBufferObject; - BOOL mHasVertexArrayObject; - BOOL mHasSync; - BOOL mHasMapBufferRange; - BOOL mHasFlushBufferRange; - BOOL mHasPBuffer; - S32 mNumTextureImageUnits; - BOOL mHasOcclusionQuery; - BOOL mHasTimerQuery; - BOOL mHasOcclusionQuery2; - BOOL mHasPointParameters; - BOOL mHasDrawBuffers; - BOOL mHasDepthClamp; - BOOL mHasTextureRectangle; - BOOL mHasTextureMultisample; - BOOL mHasTransformFeedback; - BOOL mHasUniformBufferObject; + S32 mNumTextureImageUnits; S32 mMaxSampleMaskWords; S32 mMaxColorTextureSamples; S32 mMaxDepthTextureSamples; S32 mMaxIntegerSamples; - - // Other extensions. - BOOL mHasAnisotropic; - BOOL mHasARBEnvCombine; - BOOL mHasCubeMap; - BOOL mHasCubeMapArray; - BOOL mHasDebugOutput; - BOOL mHassRGBTexture; - BOOL mHassRGBFramebuffer; - BOOL mHasTexturesRGBDecode; - + S32 mGLMaxVertexRange; + S32 mGLMaxIndexRange; + S32 mGLMaxTextureSize; + F32 mMaxAnisotropy = 0.f; + + // GL 4.x capabilities + bool mHasCubeMapArray = false; + bool mHasDebugOutput = false; + bool mHasTransformFeedback = false; + bool mHasAnisotropic = false; + // Vendor-specific extensions + bool mHasAMDAssociations = false; + BOOL mIsAMD; BOOL mIsNVIDIA; BOOL mIsIntel; @@ -134,9 +109,6 @@ public: // Whether this version of GL is good enough for SL to use BOOL mHasRequirements; - // Misc extensions - BOOL mHasSeparateSpecularColor; - S32 mDriverVersionMajor; S32 mDriverVersionMinor; S32 mDriverVersionRelease; @@ -147,9 +119,6 @@ public: std::string mGLVersionString; S32 mVRAM; // VRAM in MB - S32 mGLMaxVertexRange; - S32 mGLMaxIndexRange; - S32 mGLMaxTextureSize; void getPixelFormat(); // Get the best pixel format @@ -415,9 +384,7 @@ public: class LLGLSyncFence : public LLGLFence { public: -#ifdef GL_ARB_sync GLsync mSync; -#endif LLGLSyncFence(); virtual ~LLGLSyncFence(); diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index f2b51fbafb..0aacf3bf0e 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -41,277 +41,6 @@ # include "GL/glh_extensions.h" # undef __APPLE__ -#elif LL_LINUX -//---------------------------------------------------------------------------- -// LL_LINUX - -//---------------------------------------------------------------------------- -// Linux, MESA headers, but not necessarily assuming MESA runtime. -// quotes so we get libraries/.../GL/ version -#include "GL/gl.h" -#include "GL/glext.h" -#include "GL/glu.h" - - -#if LL_LINUX && !LL_MESA_HEADLESS -// The __APPLE__ kludge is to make glh_extensions.h not symbol-clash horribly -# define __APPLE__ -# include "GL/glh_extensions.h" -# undef __APPLE__ - -/* Although SDL very likely ends up calling glXGetProcAddress() itself, - if we use SDL_GL_GetProcAddress() then we get bogus addresses back on - some systems. Weird. */ -/*# include "SDL/SDL.h" - # define GLH_EXT_GET_PROC_ADDRESS(p) SDL_GL_GetProcAddress(p) */ -#define GLX_GLXEXT_PROTOTYPES 1 -# include "GL/glx.h" -# include "GL/glxext.h" -// Use glXGetProcAddressARB instead of glXGetProcAddress - the ARB symbol -// is considered 'legacy' but works on more machines. -# define GLH_EXT_GET_PROC_ADDRESS(p) glXGetProcAddress((const GLubyte*)(p)) -#endif // LL_LINUX && !LL_MESA_HEADLESS - -#if LL_LINUX && defined(WINGDIAPI) -// WINGDIAPI gets set if we are using the linux nvidia gl.h header which needs -// the functions below setting up. -# define LL_LINUX_NV_GL_HEADERS 1 -#else -# define LL_LINUX_NV_GL_HEADERS 0 -#endif // LL_LINUX && defined(WINGDIAPI) - - -#if LL_LINUX_NV_GL_HEADERS -// Missing functions when using nvidia headers: -extern PFNGLACTIVETEXTUREPROC glActiveTexture; -extern PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture; -extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements; -#endif // LL_LINUX_NV_GL_HEADERS - -// GL_ARB_vertex_array_object -extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; -extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; -extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; -extern PFNGLISVERTEXARRAYPROC glIsVertexArray; - -// GL_ARB_vertex_buffer_object -extern PFNGLBINDBUFFERPROC glBindBuffer; -extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; -extern PFNGLGENBUFFERSPROC glGenBuffers; -extern PFNGLISBUFFERPROC glIsBuffer; -extern PFNGLBUFFERDATAPROC glBufferData; -extern PFNGLBUFFERSUBDATAPROC glBufferSubData; -extern PFNGLGETBUFFERSUBDATAPROC glGetBufferSubData; -extern PFNGLMAPBUFFERPROC glMapBuffer; -extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; -extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv; -extern PFNGLGETBUFFERPOINTERVPROC glGetBufferPointerv; - -// GL_ARB_sync -extern PFNGLFENCESYNCPROC glFenceSync; -extern PFNGLISSYNCPROC glIsSync; -extern PFNGLDELETESYNCPROC glDeleteSync; -extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync; -extern PFNGLWAITSYNCPROC glWaitSync; -extern PFNGLGETINTEGER64VPROC glGetInteger64v; -extern PFNGLGETSYNCIVPROC glGetSynciv; - -// GL_APPLE_flush_buffer_range -extern PFNGLBUFFERPARAMETERIAPPLEPROC glBufferParameteriAPPLE; -extern PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC glFlushMappedBufferRangeAPPLE; - -// GL_ARB_map_buffer_range -extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; -extern PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange; - -// GL_ATI_vertex_array_object -extern PFNGLNEWOBJECTBUFFERATIPROC glNewObjectBufferATI; -extern PFNGLISOBJECTBUFFERATIPROC glIsObjectBufferATI; -extern PFNGLUPDATEOBJECTBUFFERATIPROC glUpdateObjectBufferATI; -extern PFNGLGETOBJECTBUFFERFVATIPROC glGetObjectBufferfvATI; -extern PFNGLGETOBJECTBUFFERIVATIPROC glGetObjectBufferivATI; -extern PFNGLFREEOBJECTBUFFERATIPROC glFreeObjectBufferATI; -extern PFNGLARRAYOBJECTATIPROC glArrayObjectATI; -extern PFNGLVERTEXATTRIBARRAYOBJECTATIPROC glVertexAttribArrayObjectATI; -extern PFNGLGETARRAYOBJECTFVATIPROC glGetArrayObjectfvATI; -extern PFNGLGETARRAYOBJECTIVATIPROC glGetArrayObjectivATI; -extern PFNGLVARIANTARRAYOBJECTATIPROC glVariantObjectArrayATI; -extern PFNGLGETVARIANTARRAYOBJECTFVATIPROC glGetVariantArrayObjectfvATI; -extern PFNGLGETVARIANTARRAYOBJECTIVATIPROC glGetVariantArrayObjectivATI; - -// GL_ARB_occlusion_query -extern PFNGLGENQUERIESPROC glGenQueries; -extern PFNGLDELETEQUERIESPROC glDeleteQueries; -extern PFNGLISQUERYPROC glIsQuery; -extern PFNGLBEGINQUERYPROC glBeginQuery; -extern PFNGLENDQUERYPROC glEndQuery; -extern PFNGLGETQUERYIVPROC glGetQueryiv; -extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv; -extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; - -// GL_ARB_timer_query -extern PFNGLQUERYCOUNTERPROC glQueryCounter; -extern PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v; -extern PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v; - -// GL_ARB_point_parameters -extern PFNGLPOINTPARAMETERFPROC glPointParameterf; -extern PFNGLPOINTPARAMETERFVPROC glPointParameterfv; - -// GL_ARB_shader_objects -extern PFNGLDELETEOBJECTPROC glDeleteObject; -extern PFNGLGETHANDLEPROC glGetHandle; -extern PFNGLDETACHOBJECTPROC glDetachObject; -extern PFNGLCREATESHADEROBJECTPROC glCreateShaderObject; -extern PFNGLSHADERSOURCEPROC glShaderSource; -extern PFNGLCOMPILESHADERPROC glCompileShader; -extern PFNGLCREATEPROGRAMOBJECTPROC glCreateProgramObject; -extern PFNGLATTACHOBJECTPROC glAttachObject; -extern PFNGLLINKPROGRAMPROC glLinkProgram; -extern PFNGLUSEPROGRAMOBJECTPROC glUseProgramObject; -extern PFNGLVALIDATEPROGRAMPROC glValidateProgram; -extern PFNGLUNIFORM1FPROC glUniform1f; -extern PFNGLUNIFORM2FPROC glUniform2f; -extern PFNGLUNIFORM3FPROC glUniform3f; -extern PFNGLUNIFORM4FPROC glUniform4f; -extern PFNGLUNIFORM1IPROC glUniform1i; -extern PFNGLUNIFORM2IPROC glUniform2i; -extern PFNGLUNIFORM3IPROC glUniform3i; -extern PFNGLUNIFORM4IPROC glUniform4i; -extern PFNGLUNIFORM1FVPROC glUniform1fv; -extern PFNGLUNIFORM2FVPROC glUniform2fv; -extern PFNGLUNIFORM3FVPROC glUniform3fv; -extern PFNGLUNIFORM4FVPROC glUniform4fv; -extern PFNGLUNIFORM1IVPROC glUniform1iv; -extern PFNGLUNIFORM2IVPROC glUniform2iv; -extern PFNGLUNIFORM3IVPROC glUniform3iv; -extern PFNGLUNIFORM4IVPROC glUniform4iv; -extern PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv; -extern PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv; -extern PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv; -extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; -extern PFNGLGETOBJECTPARAMETERFVPROC glGetObjectParameterfv; -extern PFNGLGETOBJECTPARAMETERIVPROC glGetObjectParameteriv; -extern PFNGLGETINFOLOGPROC glGetInfoLog; -extern PFNGLGETATTACHEDOBJECTSPROC glGetAttachedObjects; -extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; -extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; -extern PFNGLGETUNIFORMFVPROC glGetUniformfv; -extern PFNGLGETUNIFORMIVPROC glGetUniformiv; -extern PFNGLGETSHADERSOURCEPROC glGetShaderSource; - -// GL_ARB_vertex_shader -extern PFNGLVERTEXATTRIB1DPROC glVertexAttrib1d; -extern PFNGLVERTEXATTRIB1DVPROC glVertexAttrib1dv; -extern PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f; -extern PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv; -extern PFNGLVERTEXATTRIB1SPROC glVertexAttrib1s; -extern PFNGLVERTEXATTRIB1SVPROC glVertexAttrib1sv; -extern PFNGLVERTEXATTRIB2DPROC glVertexAttrib2d; -extern PFNGLVERTEXATTRIB2DVPROC glVertexAttrib2dv; -extern PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f; -extern PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv; -extern PFNGLVERTEXATTRIB2SPROC glVertexAttrib2s; -extern PFNGLVERTEXATTRIB2SVPROC glVertexAttrib2sv; -extern PFNGLVERTEXATTRIB3DPROC glVertexAttrib3d; -extern PFNGLVERTEXATTRIB3DVPROC glVertexAttrib3dv; -extern PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f; -extern PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv; -extern PFNGLVERTEXATTRIB3SPROC glVertexAttrib3s; -extern PFNGLVERTEXATTRIB3SVPROC glVertexAttrib3sv; -extern PFNGLVERTEXATTRIB4NBVPROC glVertexAttrib4nbv; -extern PFNGLVERTEXATTRIB4NIVPROC glVertexAttrib4niv; -extern PFNGLVERTEXATTRIB4NSVPROC glVertexAttrib4nsv; -extern PFNGLVERTEXATTRIB4NUBPROC glVertexAttrib4nub; -extern PFNGLVERTEXATTRIB4NUBVPROC glVertexAttrib4nubv; -extern PFNGLVERTEXATTRIB4NUIVPROC glVertexAttrib4nuiv; -extern PFNGLVERTEXATTRIB4NUSVPROC glVertexAttrib4nusv; -extern PFNGLVERTEXATTRIB4BVPROC glVertexAttrib4bv; -extern PFNGLVERTEXATTRIB4DPROC glVertexAttrib4d; -extern PFNGLVERTEXATTRIB4DVPROC glVertexAttrib4dv; -extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; -extern PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv; -extern PFNGLVERTEXATTRIB4IVPROC glVertexAttrib4iv; -extern PFNGLVERTEXATTRIB4SPROC glVertexAttrib4s; -extern PFNGLVERTEXATTRIB4SVPROC glVertexAttrib4sv; -extern PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv; -extern PFNGLVERTEXATTRIB4UIVPROC glVertexAttrib4uiv; -extern PFNGLVERTEXATTRIB4USVPROC glVertexAttrib4usv; -extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; -extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; -extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; -extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; -extern PFNGLPROGRAMSTRINGPROC glProgramString; -extern PFNGLBINDPROGRAMPROC glBindProgram; -extern PFNGLDELETEPROGRAMSPROC glDeletePrograms; -extern PFNGLGENPROGRAMSPROC glGenPrograms; -extern PFNGLPROGRAMENVPARAMETER4DPROC glProgramEnvParameter4d; -extern PFNGLPROGRAMENVPARAMETER4DVPROC glProgramEnvParameter4dv; -extern PFNGLPROGRAMENVPARAMETER4FPROC glProgramEnvParameter4f; -extern PFNGLPROGRAMENVPARAMETER4FVPROC glProgramEnvParameter4fv; -extern PFNGLPROGRAMLOCALPARAMETER4DPROC glProgramLocalParameter4d; -extern PFNGLPROGRAMLOCALPARAMETER4DVPROC glProgramLocalParameter4dv; -extern PFNGLPROGRAMLOCALPARAMETER4FPROC glProgramLocalParameter4f; -extern PFNGLPROGRAMLOCALPARAMETER4FVPROC glProgramLocalParameter4fv; -extern PFNGLGETPROGRAMENVPARAMETERDVPROC glGetProgramEnvParameterdv; -extern PFNGLGETPROGRAMENVPARAMETERFVPROC glGetProgramEnvParameterfv; -extern PFNGLGETPROGRAMLOCALPARAMETERDVPROC glGetProgramLocalParameterdv; -extern PFNGLGETPROGRAMLOCALPARAMETERFVPROC glGetProgramLocalParameterfv; -extern PFNGLGETPROGRAMIVPROC glGetProgramiv; -extern PFNGLGETPROGRAMSTRINGPROC glGetProgramString; -extern PFNGLGETVERTEXATTRIBDVPROC glGetVertexAttribdv; -extern PFNGLGETVERTEXATTRIBFVPROC glGetVertexAttribfv; -extern PFNGLGETVERTEXATTRIBIVPROC glGetVertexAttribiv; -extern PFNGLGETVERTEXATTRIBPOINTERVPROC glGetVertexAttribPointerv; -extern PFNGLISPROGRAMPROC glIsProgram; -extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; -extern PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib; -extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; - -extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D; -extern PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage; - -//GL_EXT_blend_func_separate -extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT; - -//GL_ARB_framebuffer_object -extern PFNGLISRENDERBUFFERPROC glIsRenderbuffer; -extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; -extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; -extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; -extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; -extern PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv; -extern PFNGLISFRAMEBUFFERPROC glIsFramebuffer; -extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; -extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; -extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; -extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; -extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; -extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; -extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; -extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; -extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; -extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; -extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; - -//GL_ARB_draw_buffers -extern PFNGLDRAWBUFFERSPROC glDrawBuffers; - -//GL_ARB_texture_multisample -extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample; -extern PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample; -extern PFNGLGETMULTISAMPLEFVPROC glGetMultisamplefv; -extern PFNGLSAMPLEMASKIPROC glSampleMaski; - -//transform feedback (4.0 core) -extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback; -extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback; -extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings; -extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange; -extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; - #elif LL_WINDOWS //---------------------------------------------------------------------------- // LL_WINDOWS @@ -345,12 +74,6 @@ extern PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT; // WGL_ARB_create_context extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; -// GL_VERSION_1_2 -//extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements; -//extern PFNGLTEXIMAGE3DPROC glTexImage3D; -//extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; -//extern PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D; - // GL_VERSION_1_3 extern PFNGLACTIVETEXTUREPROC glActiveTexture; extern PFNGLSAMPLECOVERAGEPROC glSampleCoverage; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index d8e312106c..6eb7da302f 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -352,7 +352,7 @@ void LLImageGL::updateStats(F32 current_time) //static void LLImageGL::destroyGL(BOOL save_state) { - for (S32 stage = 0; stage < gGLManager.mNumTextureUnits; stage++) + for (S32 stage = 0; stage < gGLManager.mNumTextureImageUnits; stage++) { gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); } @@ -520,7 +520,6 @@ void LLImageGL::init(BOOL usemipmaps) mPickMaskHeight = 0; mUseMipMaps = usemipmaps; mHasExplicitFormat = FALSE; - mAutoGenMips = FALSE; mIsMask = FALSE; mNeedsAlphaAndPickMask = TRUE ; @@ -1069,30 +1068,12 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image) mFormatType = GL_UNSIGNED_BYTE; break; case 3: -#if USE_SRGB_DECODE - if (gGLManager.mHasTexturesRGBDecode) - { - mFormatInternal = GL_SRGB8; - } - else -#endif - { - mFormatInternal = GL_RGB8; - } + mFormatInternal = GL_RGB8; mFormatPrimary = GL_RGB; mFormatType = GL_UNSIGNED_BYTE; break; case 4: -#if USE_SRGB_DECODE - if (gGLManager.mHasTexturesRGBDecode) - { - mFormatInternal = GL_SRGB8_ALPHA8; - } - else -#endif - { - mFormatInternal = GL_RGBA8; - } + mFormatInternal = GL_RGBA8; mFormatPrimary = GL_RGBA; mFormatType = GL_UNSIGNED_BYTE; break; @@ -1525,30 +1506,12 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S mFormatType = GL_UNSIGNED_BYTE; break; case 3: - #if USE_SRGB_DECODE - if (gGLManager.mHasTexturesRGBDecode) - { - mFormatInternal = GL_SRGB8; - } - else - #endif - { - mFormatInternal = GL_RGB8; - } + mFormatInternal = GL_RGB8; mFormatPrimary = GL_RGB; mFormatType = GL_UNSIGNED_BYTE; break; case 4: - #if USE_SRGB_DECODE - if (gGLManager.mHasTexturesRGBDecode) - { - mFormatInternal = GL_SRGB8_ALPHA8; - } - else - #endif - { - mFormatInternal = GL_RGBA8; - } + mFormatInternal = GL_RGBA8; mFormatPrimary = GL_RGBA; mFormatType = GL_UNSIGNED_BYTE; break; @@ -1637,7 +1600,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ if (mUseMipMaps) { - mAutoGenMips = gGLManager.mHasMipMapGeneration; + mAutoGenMips = true; } mCurrentDiscardLevel = discard_level; @@ -1694,44 +1657,37 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) { LL_PROFILE_ZONE_NAMED("cglt - sync"); - if (gGLManager.mHasSync) + if (gGLManager.mIsNVIDIA) { - if (gGLManager.mIsNVIDIA) - { - // wait for texture upload to finish before notifying main thread - // upload is complete - auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - glFlush(); - glClientWaitSync(sync, 0, GL_TIMEOUT_IGNORED); - glDeleteSync(sync); - } - else - { - // post a sync to the main thread (will execute before tex name swap lambda below) - // glFlush calls here are partly superstitious and partly backed by observation - // on AMD hardware - glFlush(); - auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - glFlush(); - LL::WorkQueue::postMaybe( - mMainQueue, - [=]() - { - LL_PROFILE_ZONE_NAMED("cglt - wait sync"); - { - LL_PROFILE_ZONE_NAMED("glWaitSync"); - glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); - } - { - LL_PROFILE_ZONE_NAMED("glDeleteSync"); - glDeleteSync(sync); - } - }); - } + // wait for texture upload to finish before notifying main thread + // upload is complete + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + glClientWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + glDeleteSync(sync); } else { - glFinish(); + // post a sync to the main thread (will execute before tex name swap lambda below) + // glFlush calls here are partly superstitious and partly backed by observation + // on AMD hardware + glFlush(); + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + LL::WorkQueue::postMaybe( + mMainQueue, + [=]() + { + LL_PROFILE_ZONE_NAMED("cglt - wait sync"); + { + LL_PROFILE_ZONE_NAMED("glWaitSync"); + glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + } + { + LL_PROFILE_ZONE_NAMED("glDeleteSync"); + glDeleteSync(sync); + } + }); } } diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index b4618fd35c..bbd024abd9 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -219,7 +219,7 @@ private: U16 mPickMaskHeight; S8 mUseMipMaps; BOOL mHasExplicitFormat; // If false (default), GL format is f(mComponents) - S8 mAutoGenMips; + bool mAutoGenMips = false; BOOL mIsMask; BOOL mNeedsAlphaAndPickMask; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 554721399a..6e659641fe 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -335,7 +335,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) if (mCurrTexture != cubeMap->mImages[0]->getTexName()) { - if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) + if (LLCubeMap::sUseCubeMaps) { activate(); enable(LLTexUnit::TT_CUBE_MAP); @@ -516,22 +516,15 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio } } - if (gGLManager.mHasAnisotropic) + if (gGLManager.mGLVersion >= 4.59f) { if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC) { - if (gGL.mMaxAnisotropy < 1.f) - { - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gGL.mMaxAnisotropy); - - LL_INFOS() << "gGL.mMaxAnisotropy: " << gGL.mMaxAnisotropy << LL_ENDL ; - gGL.mMaxAnisotropy = llmax(1.f, gGL.mMaxAnisotropy) ; - } - glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, gGL.mMaxAnisotropy); + glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, gGLManager.mMaxAnisotropy); } else { - glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, 1.f); } } } @@ -650,29 +643,6 @@ void LLTexUnit::debugTextureUnit(void) void LLTexUnit::setTextureColorSpace(eTextureColorSpace space) { mTexColorSpace = space; - -#if USE_SRGB_DECODE - if (gGLManager.mHasTexturesRGBDecode) - { - if (space == TCS_SRGB) - { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); - } - else - { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); - } - - if (gDebugGL) - { - assert_glerror(); - } - } - else - { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); - } -#endif } LLLightState::LLLightState(S32 index) @@ -846,8 +816,7 @@ LLRender::LLRender() mCount(0), mQuadCycle(0), mMode(LLRender::TRIANGLES), - mCurrTextureUnitIndex(0), - mMaxAnisotropy(0.f) + mCurrTextureUnitIndex(0) { mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS); for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) @@ -912,11 +881,9 @@ void LLRender::init() if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) { //bind a dummy vertex array object so we're core profile compliant -#ifdef GL_ARB_vertex_array_object U32 ret; glGenVertexArrays(1, &ret); glBindVertexArray(ret); -#endif } @@ -1492,12 +1459,7 @@ void LLRender::blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor, llassert(color_dfactor < BF_UNDEF); llassert(alpha_sfactor < BF_UNDEF); llassert(alpha_dfactor < BF_UNDEF); - if (!LLRender::sGLCoreProfile && !gGLManager.mHasBlendFuncSeparate) - { - LL_WARNS_ONCE("render") << "no glBlendFuncSeparateEXT(), using color-only blend func" << LL_ENDL; - blendFunc(color_sfactor, color_dfactor); - return; - } + if (mCurrBlendColorSFactor != color_sfactor || mCurrBlendColorDFactor != color_dfactor || mCurrBlendAlphaSFactor != alpha_sfactor || mCurrBlendAlphaDFactor != alpha_dfactor) { diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index b1fb60cf92..3e4a1fe933 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -493,8 +493,6 @@ private: eBlendFactor mCurrBlendAlphaSFactor; eBlendFactor mCurrBlendAlphaDFactor; - F32 mMaxAnisotropy; - std::vector mUIOffset; std::vector mUIScale; diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index fa23654978..015312e570 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -134,7 +134,7 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo mUsage = usage; mUseDepth = depth; - if ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject) + if ((sUseFBO || use_fbo)) { if (depth) { @@ -234,11 +234,9 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) llassert( offset < 4 ); return false; } - if( offset > 0 && (mFBO == 0 || !gGLManager.mHasDrawBuffers) ) + if( offset > 0 && (mFBO == 0) ) { - LL_WARNS() << "FBO not used or no drawbuffers available; mFBO=" << (U32)mFBO << " gGLManager.mHasDrawBuffers=" << (U32)gGLManager.mHasDrawBuffers << LL_ENDL; llassert( mFBO != 0 ); - llassert( gGLManager.mHasDrawBuffers ); return false; } @@ -484,14 +482,12 @@ void LLRenderTarget::bindTarget() sCurFBO = mFBO; stop_glerror(); - if (gGLManager.mHasDrawBuffers) - { //setup multiple render targets - GLenum drawbuffers[] = {GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT1, - GL_COLOR_ATTACHMENT2, - GL_COLOR_ATTACHMENT3}; - glDrawBuffers(mTex.size(), drawbuffers); - } + //setup multiple render targets + GLenum drawbuffers[] = {GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3}; + glDrawBuffers(mTex.size(), drawbuffers); if (mTex.empty()) { //no color buffer to draw to diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index a40ea2eb1e..d05f916d95 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -744,7 +744,7 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const //static void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping) { - sEnableVBOs = use_vbo && gGLManager.mHasVertexBufferObject; + sEnableVBOs = use_vbo; sDisableVBOMapping = sEnableVBOs && no_vbo_mapping; } @@ -753,9 +753,7 @@ void LLVertexBuffer::unbind() { if (sGLRenderArray) { -#if GL_ARB_vertex_array_object glBindVertexArray(0); -#endif sGLRenderArray = 0; sGLRenderIndices = 0; sIBOActive = false; @@ -923,9 +921,7 @@ LLVertexBuffer::~LLVertexBuffer() if (mGLArray) { -#if GL_ARB_vertex_array_object releaseVAOName(mGLArray); -#endif } sCount--; @@ -956,10 +952,7 @@ void LLVertexBuffer::placeFence() const { /*if (!mFence && useVBOs()) { - if (gGLManager.mHasSync) - { - mFence = new LLGLSyncFence(); - } + mFence = new LLGLSyncFence(); } if (mFence) @@ -1234,11 +1227,9 @@ bool LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) //actually allocate space for the vertex buffer if using VBO mapping flush(); //unmap - if (gGLManager.mHasVertexArrayObject && useVBOs() && sUseVAO) + if (useVBOs() && sUseVAO) { -#if GL_ARB_vertex_array_object mGLArray = getVAOName(); -#endif setupVertexArray(); } } @@ -1254,9 +1245,7 @@ void LLVertexBuffer::setupVertexArray() } LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; -#if GL_ARB_vertex_array_object glBindVertexArray(mGLArray); -#endif sGLRenderArray = mGLArray; static const U32 attrib_size[] = @@ -1443,7 +1432,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran if (useVBOs()) { - if (!mMappable || gGLManager.mHasMapBufferRange || gGLManager.mHasFlushBufferRange) + if (!mMappable) { if (count == -1) { @@ -1492,58 +1481,34 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran { U8* src = NULL; waitFence(); - if (gGLManager.mHasMapBufferRange) + if (map_range) { - if (map_range) - { -#ifdef GL_ARB_map_buffer_range - S32 offset = mOffsets[type] + sTypeSize[type]*index; - S32 length = (sTypeSize[type]*count+0xF) & ~0xF; - src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER, offset, length, - GL_MAP_WRITE_BIT | - GL_MAP_FLUSH_EXPLICIT_BIT | - GL_MAP_INVALIDATE_RANGE_BIT); -#endif - } - else + S32 offset = mOffsets[type] + sTypeSize[type]*index; + S32 length = (sTypeSize[type]*count+0xF) & ~0xF; + src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER, offset, length, + GL_MAP_WRITE_BIT | + GL_MAP_FLUSH_EXPLICIT_BIT | + GL_MAP_INVALIDATE_RANGE_BIT); + } + else + { + if (gDebugGL) { -#ifdef GL_ARB_map_buffer_range + GLint size = 0; + glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); - if (gDebugGL) + if (size < mSize) { - GLint size = 0; - glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); - - if (size < mSize) - { - LL_ERRS() << "Invalid buffer size." << LL_ENDL; - } + LL_ERRS() << "Invalid buffer size." << LL_ENDL; } - - src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER, 0, mSize, - GL_MAP_WRITE_BIT | - GL_MAP_FLUSH_EXPLICIT_BIT); -#endif - } - } - else if (gGLManager.mHasFlushBufferRange) - { - if (map_range) - { - src = (U8*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - } - else - { - src = (U8*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); } - } - else - { - map_range = false; - src = (U8*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); + + src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER, 0, mSize, + GL_MAP_WRITE_BIT | + GL_MAP_FLUSH_EXPLICIT_BIT); } - llassert(src != NULL); + llassert(src != NULL); mMappedData = LL_NEXT_ALIGNED_ADDRESS(src); mAlignedOffset = mMappedData - src; @@ -1569,7 +1534,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran //-------------------- GLint buff; - glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &buff); if ((GLuint)buff != mGLBuffer) { LL_ERRS() << "Invalid GL vertex buffer bound: " << buff << LL_ENDL; @@ -1590,7 +1555,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran map_range = false; } - if (map_range && gGLManager.mHasMapBufferRange && mMappable) + if (map_range && mMappable) { return mMappedData; } @@ -1616,7 +1581,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) if (useVBOs()) { - if (!mMappable || gGLManager.mHasMapBufferRange || gGLManager.mHasFlushBufferRange) + if (!mMappable) { if (count == -1) { @@ -1657,7 +1622,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) if (gDebugGL && useVBOs()) { GLint elem = 0; - glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &elem); + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &elem); if (elem != mGLIndices) { @@ -1673,48 +1638,24 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) { U8* src = NULL; waitFence(); - if (gGLManager.mHasMapBufferRange) + if (map_range) { - if (map_range) - { -#ifdef GL_ARB_map_buffer_range - S32 offset = sizeof(U16)*index; - S32 length = sizeof(U16)*count; - src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length, - GL_MAP_WRITE_BIT | - GL_MAP_FLUSH_EXPLICIT_BIT | - GL_MAP_INVALIDATE_RANGE_BIT); -#endif - } - else - { -#ifdef GL_ARB_map_buffer_range - src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(U16)*mNumIndices, - GL_MAP_WRITE_BIT | - GL_MAP_FLUSH_EXPLICIT_BIT); -#endif - } - } - else if (gGLManager.mHasFlushBufferRange) - { - if (map_range) - { - src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); - } - else - { - src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); - } + S32 offset = sizeof(U16)*index; + S32 length = sizeof(U16)*count; + src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length, + GL_MAP_WRITE_BIT | + GL_MAP_FLUSH_EXPLICIT_BIT | + GL_MAP_INVALIDATE_RANGE_BIT); } else { - map_range = false; - src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); + src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(U16)*mNumIndices, + GL_MAP_WRITE_BIT | + GL_MAP_FLUSH_EXPLICIT_BIT); } - + llassert(src != NULL); - mMappedIndexData = src; //LL_NEXT_ALIGNED_ADDRESS(src); mAlignedIndexOffset = mMappedIndexData - src; stop_glerror(); @@ -1729,7 +1670,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) if(mMappable) { GLint buff; - glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &buff); if ((GLuint)buff != mGLIndices) { LL_ERRS() << "Invalid GL index buffer bound: " << buff << LL_ENDL; @@ -1748,7 +1689,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) map_range = false; } - if (map_range && gGLManager.mHasMapBufferRange && mMappable) + if (map_range && mMappable) { return mMappedIndexData; } @@ -1812,25 +1753,20 @@ void LLVertexBuffer::unmapBuffer() } else { - if (gGLManager.mHasMapBufferRange || gGLManager.mHasFlushBufferRange) + if (!mMappedVertexRegions.empty()) { - if (!mMappedVertexRegions.empty()) + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - flush vertex"); + for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - flush vertex"); - for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) - { - const MappedRegion& region = mMappedVertexRegions[i]; - S32 offset = region.mIndex >= 0 ? mOffsets[region.mType]+sTypeSize[region.mType]*region.mIndex : 0; - S32 length = sTypeSize[region.mType]*region.mCount; - if (gGLManager.mHasMapBufferRange) - { - glFlushMappedBufferRange(GL_ARRAY_BUFFER, offset, length); - } - } - - mMappedVertexRegions.clear(); + const MappedRegion& region = mMappedVertexRegions[i]; + S32 offset = region.mIndex >= 0 ? mOffsets[region.mType]+sTypeSize[region.mType]*region.mIndex : 0; + S32 length = sTypeSize[region.mType]*region.mCount; + glFlushMappedBufferRange(GL_ARRAY_BUFFER, offset, length); } + + mMappedVertexRegions.clear(); } + stop_glerror(); glUnmapBuffer(GL_ARRAY_BUFFER); stop_glerror(); @@ -1884,25 +1820,19 @@ void LLVertexBuffer::unmapBuffer() } else { - if (gGLManager.mHasMapBufferRange || gGLManager.mHasFlushBufferRange) + if (!mMappedIndexRegions.empty()) { - if (!mMappedIndexRegions.empty()) + for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) { - for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - flush index"); - const MappedRegion& region = mMappedIndexRegions[i]; - S32 offset = region.mIndex >= 0 ? sizeof(U16)*region.mIndex : 0; - S32 length = sizeof(U16)*region.mCount; - if (gGLManager.mHasMapBufferRange) - { - glFlushMappedBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length); - } - stop_glerror(); - } - - mMappedIndexRegions.clear(); + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - flush index"); + const MappedRegion& region = mMappedIndexRegions[i]; + S32 offset = region.mIndex >= 0 ? sizeof(U16)*region.mIndex : 0; + S32 length = sizeof(U16)*region.mCount; + glFlushMappedBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length); + stop_glerror(); } + + mMappedIndexRegions.clear(); } glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); @@ -2034,9 +1964,7 @@ bool LLVertexBuffer::bindGLArray() { { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; -#if GL_ARB_vertex_array_object glBindVertexArray(mGLArray); -#endif sGLRenderArray = mGLArray; } @@ -2228,7 +2156,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) if (gDebugGL && !mGLArray) { GLint buff; - glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &buff); if ((GLuint)buff != mGLBuffer) { if (gDebugSession) @@ -2243,7 +2171,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) if (mGLIndices) { - glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &buff); if ((GLuint)buff != mGLIndices) { if (gDebugSession) @@ -2264,9 +2192,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { if (sGLRenderArray) { -#if GL_ARB_vertex_array_object glBindVertexArray(0); -#endif sGLRenderArray = 0; sGLRenderIndices = 0; sIBOActive = false; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9508c1dc2d..100bcf7ab9 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10784,18 +10784,6 @@ Value 0 - RenderUseTransformFeedback - - Comment - [EXPERIMENTAL] Use transform feedback shaders for LoD updates - Persist - 1 - Type - Boolean - Value - 0 - - RenderVBOMappingDisable Comment diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 6b4ab1be17..abc379a44f 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 36 +version 37 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -287,14 +287,9 @@ list Intel RenderAnisotropic 1 0 RenderFSAASamples 1 0 RenderGLMultiThreaded 1 0 -RenderGLContextCoreProfile 1 0 -// AMD cards generally perform better when not using VBOs for streaming data -// AMD cards also prefer an OpenGL Compatibility Profile Context // HACK: Current AMD drivers have bugged cubemap arrays, limit number of reflection probes to 16 list AMD -RenderUseStreamVBO 1 0 -RenderGLContextCoreProfile 1 0 RenderReflectionProbeCount 1 16 diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index be33e1b30a..55c8d84838 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -165,19 +165,6 @@ void LLDrawPoolTerrain::render(S32 pass) LLOverrideFaceColor override(this, 1.f, 1.f, 1.f, 1.f); - if (!gGLManager.mHasMultitexture) - { - // No multitexture, render simple land. - renderSimple(); // Render without multitexture - return; - } - // Render simplified land if video card can't do sufficient multitexturing - if (!gGLManager.mHasARBEnvCombine || (gGLManager.mNumTextureUnits < 2)) - { - renderSimple(); // Render without multitexture - return; - } - LLGLSPipeline gls; if (mShaderLevel > 1 && sShader->mShaderLevel > 0) @@ -194,10 +181,6 @@ void LLDrawPoolTerrain::render(S32 pass) { renderSimple(); } - else if (gGLManager.mNumTextureUnits < 4) - { - renderFull2TU(); - } else { renderFull4TU(); diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index a84f62036e..576024ead3 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -104,7 +104,7 @@ void LLDrawPoolWater::restoreGL() void LLDrawPoolWater::prerender() { - mShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; + mShaderLevel = LLCubeMap::sUseCubeMaps ? LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; } S32 LLDrawPoolWater::getNumPasses() @@ -188,12 +188,6 @@ void LLDrawPoolWater::render(S32 pass) stop_glerror(); - if (!gGLManager.mHasMultitexture) - { - // Ack! No multitexture! Bail! - return; - } - LLFace* refl_face = voskyp->getReflFace(); gPipeline.disableLights(); diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index 63e7887d81..361a7666fa 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -125,7 +125,7 @@ void LLViewerDynamicTexture::preRender(BOOL clear_depth) llassert(mFullHeight <= static_cast(gPipeline.mPhysicsDisplay.getHeight())); } - if (gGLManager.mHasFramebufferObject && gPipeline.mPhysicsDisplay.isComplete() && !gGLManager.mIsAMD) + if (gPipeline.mPhysicsDisplay.isComplete() && !gGLManager.mIsAMD) { //using offscreen render target, just use the bottom left corner mOrigin.set(0, 0); } @@ -212,7 +212,7 @@ BOOL LLViewerDynamicTexture::updateAllInstances() return TRUE; } - bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mBake.isComplete() && !gGLManager.mIsAMD; + bool use_fbo = gPipeline.mBake.isComplete() && !gGLManager.mIsAMD; if (use_fbo) { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 3f69815e38..5562f1d057 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1211,55 +1211,6 @@ bool LLFace::canRenderAsMask() return false; } - -//static -void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; - U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_NORMAL; - - if (vf.mWeights) - { - mask |= LLVertexBuffer::MAP_WEIGHT4; - } - - LLVertexBuffer* buff = new LLVertexBuffer(mask, GL_STATIC_DRAW); - vf.mVertexBuffer = buff; - - buff->allocateBuffer(vf.mNumVertices, 0, true); - - LLStrider f_vert; - LLStrider f_tangent; - LLStrider f_norm; - LLStrider f_tc; - - buff->getTangentStrider(f_tangent); - buff->getVertexStrider(f_vert); - buff->getNormalStrider(f_norm); - buff->getTexCoord0Strider(f_tc); - - for (U32 i = 0; i < vf.mNumVertices; ++i) - { - *f_vert++ = vf.mPositions[i]; - *f_tangent++ = vf.mTangents[i]; - *f_tc++ = vf.mTexCoords[i]; - (*f_norm++).set(vf.mNormals[i].getF32ptr()); - } - - if (vf.mWeights) - { - LLStrider f_wght; - buff->getWeight4Strider(f_wght); - for (U32 i = 0; i < vf.mNumVertices; ++i) - { - (*f_wght++).set(vf.mWeights[i].getF32ptr()); - } - } - - buff->flush(); -} - //helper function for pushing primitives for transform shaders and cleaning up //uninitialized data on the tail, plus tracking number of expected primitives void push_for_transform(LLVertexBuffer* buff, U32 source_count, U32 dest_count) @@ -1304,7 +1255,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, //don't use map range (generates many redundant unmap calls) - bool map_range = false; //gGLManager.mHasMapBufferRange || gGLManager.mHasFlushBufferRange; + bool map_range = false; if (mVertexBuffer.notNull()) { @@ -1535,155 +1486,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } - static LLCachedControl use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback", false); - -#ifdef GL_TRANSFORM_FEEDBACK_BUFFER - if (use_transform_feedback && - mVertexBuffer->getUsage() == GL_DYNAMIC_COPY && - gTransformPositionProgram.mProgramObject && //transform shaders are loaded - mVertexBuffer->useVBOs() && //target buffer is in VRAM - !rebuild_weights && //TODO: add support for weights - !volume.isUnique()) //source volume is NOT flexi - { //use transform feedback to pack vertex buffer - - LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - transform feedback"); - LLGLEnable discard(GL_RASTERIZER_DISCARD); - LLVertexBuffer* buff = (LLVertexBuffer*) vf.mVertexBuffer.get(); - - if (vf.mVertexBuffer.isNull() || buff->getNumVerts() != vf.mNumVertices) - { - mVObjp->getVolume()->genTangents(f); - LLFace::cacheFaceInVRAM(vf); - buff = (LLVertexBuffer*) vf.mVertexBuffer.get(); - } - - LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; - - gGL.pushMatrix(); - gGL.loadMatrix((GLfloat*) mat_vert_in.mMatrix); - - if (rebuild_pos) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - tf position"); - gTransformPositionProgram.bind(); - - mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_VERTEX, mGeomIndex, mGeomCount); - - U8 index = mTextureIndex < FACE_DO_NOT_BATCH_TEXTURES ? mTextureIndex : 0; - - S32 val = 0; - U8* vp = (U8*) &val; - vp[0] = index; - vp[1] = 0; - vp[2] = 0; - vp[3] = 0; - - gTransformPositionProgram.uniform1i(sTextureIndexIn, val); - glBeginTransformFeedback(GL_POINTS); - buff->setBuffer(LLVertexBuffer::MAP_VERTEX); - - push_for_transform(buff, vf.mNumVertices, mGeomCount); - - glEndTransformFeedback(); - } - - if (rebuild_color) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - tf color"); - gTransformColorProgram.bind(); - - mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_COLOR, mGeomIndex, mGeomCount); - - S32 val = *((S32*) color.mV); - - gTransformColorProgram.uniform1i(sColorIn, val); - glBeginTransformFeedback(GL_POINTS); - buff->setBuffer(LLVertexBuffer::MAP_VERTEX); - push_for_transform(buff, vf.mNumVertices, mGeomCount); - glEndTransformFeedback(); - } - - if (rebuild_emissive) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - tf emissive"); - gTransformColorProgram.bind(); - - mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_EMISSIVE, mGeomIndex, mGeomCount); - - U8 glow = (U8) llclamp((S32) (getTextureEntry()->getGlow()*255), 0, 255); - - S32 glow32 = glow | - (glow << 8) | - (glow << 16) | - (glow << 24); - - gTransformColorProgram.uniform1i(sColorIn, glow32); - glBeginTransformFeedback(GL_POINTS); - buff->setBuffer(LLVertexBuffer::MAP_VERTEX); - push_for_transform(buff, vf.mNumVertices, mGeomCount); - glEndTransformFeedback(); - } - - if (rebuild_normal) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - tf normal"); - gTransformNormalProgram.bind(); - - mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_NORMAL, mGeomIndex, mGeomCount); - - glBeginTransformFeedback(GL_POINTS); - buff->setBuffer(LLVertexBuffer::MAP_NORMAL); - push_for_transform(buff, vf.mNumVertices, mGeomCount); - glEndTransformFeedback(); - } - - if (rebuild_tangent) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - tf tangent"); - gTransformTangentProgram.bind(); - - mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_TANGENT, mGeomIndex, mGeomCount); - - glBeginTransformFeedback(GL_POINTS); - buff->setBuffer(LLVertexBuffer::MAP_TANGENT); - push_for_transform(buff, vf.mNumVertices, mGeomCount); - glEndTransformFeedback(); - } - - if (rebuild_tcoord) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - tf tcoord"); - gTransformTexCoordProgram.bind(); - - mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_TEXCOORD0, mGeomIndex, mGeomCount); - - glBeginTransformFeedback(GL_POINTS); - buff->setBuffer(LLVertexBuffer::MAP_TEXCOORD0); - push_for_transform(buff, vf.mNumVertices, mGeomCount); - glEndTransformFeedback(); - - bool do_bump = bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1); - - if (do_bump) - { - mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_TEXCOORD1, mGeomIndex, mGeomCount); - glBeginTransformFeedback(GL_POINTS); - buff->setBuffer(LLVertexBuffer::MAP_TEXCOORD0); - push_for_transform(buff, vf.mNumVertices, mGeomCount); - glEndTransformFeedback(); - } - } - - glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0); - gGL.popMatrix(); - - if (cur_shader) - { - cur_shader->bind(); - } - } - else -#endif { //if it's not fullbright and has no normals, bake sunlight based on face normal //bool bake_sunlight = !getTextureEntry()->getFullbright() && diff --git a/indra/newview/llface.h b/indra/newview/llface.h index aa00c9d052..4778a8110b 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -81,8 +81,6 @@ public: PARTICLE = 0x0080, }; - static void cacheFaceInVRAM(const LLVolumeFace& vf); - public: LLFace(LLDrawable* drawablep, LLViewerObject* objp) { diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 826d4892ef..2c770f6ab8 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -431,41 +431,9 @@ bool LLFeatureManager::loadGPUClass() LL_WARNS("RenderInit") << "Unable to get an accurate benchmark; defaulting to class 3" << LL_ENDL; mGPUClass = GPU_CLASS_3; #else - if (gGLManager.mGLVersion <= 2.f) - { - mGPUClass = GPU_CLASS_0; - } - else if (gGLManager.mGLVersion <= 3.f) - { - mGPUClass = GPU_CLASS_1; - } - else if (gGLManager.mGLVersion < 3.3f) - { - mGPUClass = GPU_CLASS_2; - } - else if (gGLManager.mGLVersion < 4.f) - { - mGPUClass = GPU_CLASS_3; - } - else - { - mGPUClass = GPU_CLASS_4; - } - if (gGLManager.mIsIntel && mGPUClass > GPU_CLASS_1) - { - // Intels are generally weaker then other GPUs despite having advanced features - mGPUClass = (EGPUClass)(mGPUClass - 1); - } + mGPUClass = GPU_CLASS_2; #endif } - else if (gGLManager.mGLVersion <= 2.f) - { - mGPUClass = GPU_CLASS_0; - } - else if (gGLManager.mGLVersion <= 3.f) - { - mGPUClass = GPU_CLASS_1; - } else if (gbps <= 5.f) { mGPUClass = GPU_CLASS_0; @@ -679,10 +647,6 @@ void LLFeatureManager::applyBaseMasks() { maskFeatures("TexUnit8orLess"); } - if (gGLManager.mHasMapBufferRange) - { - maskFeatures("MapBufferRange"); - } if (gGLManager.mVRAM > 512) { maskFeatures("VRAMGT512"); diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 68928e9c8f..7b01e9050b 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1198,7 +1198,7 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() LLTextBox* reflections_text = getChild("ReflectionsText"); // Reflections - BOOL reflections = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps; + BOOL reflections = LLCubeMap::sUseCubeMaps; ctrl_reflections->setEnabled(reflections); reflections_text->setEnabled(reflections); @@ -1227,14 +1227,7 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() // Hardware settings - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") || - !gGLManager.mHasVertexBufferObject) - { - getChildView("vbo")->setEnabled(FALSE); - } - - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures") || - !gGLManager.mHasVertexBufferObject) + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures")) { getChildView("texture compression")->setEnabled(FALSE); } diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index d75f3eef6f..38ec24cae8 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -987,9 +987,8 @@ private: //----------------------------------------------------------------------------- F32 gpu_benchmark() { - if (!gGLManager.mHasTimerQuery) + if (gGLManager.mGLVersion < 3.3f) { // don't bother benchmarking venerable drivers which don't support accurate timing anyway - // and are likely to be correctly identified by the GPU table already. return -1.f; } @@ -1115,16 +1114,6 @@ F32 gpu_benchmark() // ensure matched pair of bind() and unbind() calls ShaderBinder binder(gBenchmarkProgram); -#ifdef GL_ARB_vertex_array_object - U32 glarray = 0; - - if (LLRender::sGLCoreProfile) - { - glGenVertexArrays(1, &glarray); - glBindVertexArray(glarray); - } -#endif - buff->setBuffer(LLVertexBuffer::MAP_VERTEX); glFinish(); @@ -1157,15 +1146,6 @@ F32 gpu_benchmark() } } -#ifdef GL_ARB_vertex_array_object - if (LLRender::sGLCoreProfile) - { - glBindVertexArray(0); - glDeleteVertexArrays(1, &glarray); - } -#endif - - std::sort(results.begin(), results.end()); F32 gbps = results[results.size()/2]; diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 6a2f53aa42..49d5aa3e14 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -445,14 +445,14 @@ void LLSceneMonitor::calcDiffAggregate() if(mDiffState == EXECUTE_DIFF) { - glBeginQuery(GL_SAMPLES_PASSED_ARB, mQueryObject); + glBeginQuery(GL_SAMPLES_PASSED, mQueryObject); } gl_draw_scaled_target(0, 0, S32(mDiff->getWidth() * mDiffPixelRatio), S32(mDiff->getHeight() * mDiffPixelRatio), mDiff); if(mDiffState == EXECUTE_DIFF) { - glEndQuery(GL_SAMPLES_PASSED_ARB); + glEndQuery(GL_SAMPLES_PASSED); mDiffState = WAIT_ON_RESULT; } @@ -483,11 +483,11 @@ void LLSceneMonitor::fetchQueryResult() mDiffState = WAITING_FOR_NEXT_DIFF; GLuint available = 0; - glGetQueryObjectuiv(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available); + glGetQueryObjectuiv(mQueryObject, GL_QUERY_RESULT_AVAILABLE, &available); if(available) { GLuint count = 0; - glGetQueryObjectuiv(mQueryObject, GL_QUERY_RESULT_ARB, &count); + glGetQueryObjectuiv(mQueryObject, GL_QUERY_RESULT, &count); mDiffResult = sqrtf(count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio)); //0.5 -> (front face + back face) diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 9682945208..2413d7705a 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -381,7 +381,7 @@ static bool handleJoystickChanged(const LLSD& newvalue) static bool handleUseOcclusionChanged(const LLSD& newvalue) { - LLPipeline::sUseOcclusion = (newvalue.asBoolean() && gGLManager.mHasOcclusionQuery + LLPipeline::sUseOcclusion = (newvalue.asBoolean() && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") && !gUseWireframe) ? 2 : 0; return true; } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index dd82d43ab2..f10cb329a9 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2309,44 +2309,6 @@ class LLAdvancedCheckViewAdminOptions : public view_listener_t } }; -///////////////////////////////////// -// Enable Object Object Occlusion /// -///////////////////////////////////// -class LLAdvancedEnableObjectObjectOcclusion: public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - - bool new_value = gGLManager.mHasOcclusionQuery; // && LLFeatureManager::getInstance()->isFeatureAvailable(userdata.asString()); - return new_value; -} -}; - -///////////////////////////////////// -// Enable Framebuffer Objects /// -///////////////////////////////////// -class LLAdvancedEnableRenderFBO: public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - bool new_value = gGLManager.mHasFramebufferObject; - return new_value; - } -}; - -///////////////////////////////////// -// Enable Deferred Rendering /// -///////////////////////////////////// -class LLAdvancedEnableRenderDeferred: public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - bool new_value = gGLManager.mHasFramebufferObject && LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1 && - LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) > 0; - return new_value; - } -}; - ////////////////// // ADMIN STATUS // ////////////////// @@ -9367,8 +9329,6 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedToggleWireframe(), "Advanced.ToggleWireframe"); view_listener_t::addMenu(new LLAdvancedCheckWireframe(), "Advanced.CheckWireframe"); // Develop > Render - view_listener_t::addMenu(new LLAdvancedEnableObjectObjectOcclusion(), "Advanced.EnableObjectObjectOcclusion"); - view_listener_t::addMenu(new LLAdvancedToggleRandomizeFramerate(), "Advanced.ToggleRandomizeFramerate"); view_listener_t::addMenu(new LLAdvancedCheckRandomizeFramerate(), "Advanced.CheckRandomizeFramerate"); view_listener_t::addMenu(new LLAdvancedTogglePeriodicSlowFrame(), "Advanced.TogglePeriodicSlowFrame"); diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index c785c80cea..a75eb518f3 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -917,15 +917,12 @@ void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, Octr void LLOcclusionCullingGroup::releaseOcclusionQueryObjectNames() { - if (gGLManager.mHasOcclusionQuery) + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; ++i) { - for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; ++i) + if (mOcclusionQuery[i]) { - if (mOcclusionQuery[i]) - { - releaseOcclusionQueryObjectName(mOcclusionQuery[i]); - mOcclusionQuery[i] = 0; - } + releaseOcclusionQueryObjectName(mOcclusionQuery[i]); + mOcclusionQuery[i] = 0; } } } @@ -1129,7 +1126,7 @@ void LLOcclusionCullingGroup::checkOcclusion() GLuint available; { LL_PROFILE_ZONE_NAMED_CATEGORY_OCTREE("co - query available"); - glGetQueryObjectuiv(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available); + glGetQueryObjectuiv(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE, &available); } if (available) @@ -1137,7 +1134,7 @@ void LLOcclusionCullingGroup::checkOcclusion() GLuint query_result; // Will be # samples drawn, or a boolean depending on mHasOcclusionQuery2 (both are type GLuint) { LL_PROFILE_ZONE_NAMED_CATEGORY_OCTREE("co - query result"); - glGetQueryObjectuiv(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_ARB, &query_result); + glGetQueryObjectuiv(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT, &query_result); } #if LL_TRACK_PENDING_OCCLUSION_QUERIES sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]); @@ -1197,7 +1194,6 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh OCCLUSION_FUDGE_Z = 1.; } - // Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension if (earlyFail(camera, bounds)) { LL_PROFILE_ZONE_NAMED_CATEGORY_OCTREE("doOcclusion - early fail"); @@ -1221,17 +1217,12 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh // Depth clamp all water to avoid it being culled as a result of being // behind the far clip plane, and in the case of edge water to avoid // it being culled while still visible. - bool const use_depth_clamp = gGLManager.mHasDepthClamp && - (mSpatialPartition->mDrawableType == LLPipeline::RENDER_TYPE_WATER || + bool const use_depth_clamp = (mSpatialPartition->mDrawableType == LLPipeline::RENDER_TYPE_WATER || mSpatialPartition->mDrawableType == LLPipeline::RENDER_TYPE_VOIDWATER); - LLGLEnable clamp(use_depth_clamp ? GL_DEPTH_CLAMP : 0); + LLGLEnable clamp(use_depth_clamp ? GL_DEPTH_CLAMP : 0); -#if !LL_DARWIN - U32 mode = gGLManager.mHasOcclusionQuery2 ? GL_ANY_SAMPLES_PASSED : GL_SAMPLES_PASSED_ARB; -#else - U32 mode = GL_SAMPLES_PASSED_ARB; -#endif + U32 mode = gGLManager.mGLVersion >= 3.3f ? GL_ANY_SAMPLES_PASSED : GL_SAMPLES_PASSED; #if LL_TRACK_PENDING_OCCLUSION_QUERIES sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 2ebe0f826f..296a383ed0 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -70,13 +70,6 @@ bool LLViewerShaderMgr::sSkipReload = false; LLVector4 gShinyOrigin; -//transform shaders -LLGLSLShader gTransformPositionProgram; -LLGLSLShader gTransformTexCoordProgram; -LLGLSLShader gTransformNormalProgram; -LLGLSLShader gTransformColorProgram; -LLGLSLShader gTransformTangentProgram; - //utility shaders LLGLSLShader gOcclusionProgram; LLGLSLShader gSkinnedOcclusionProgram; @@ -469,7 +462,7 @@ void LLViewerShaderMgr::setShaders() initAttribsAndUniforms(); gPipeline.releaseGLBuffers(); - LLPipeline::sWaterReflections = gGLManager.mHasCubeMap && LLPipeline::sRenderTransparentWater; + LLPipeline::sWaterReflections = LLPipeline::sRenderTransparentWater; LLPipeline::sRenderGlow = gSavedSettings.getBOOL("RenderGlow"); LLPipeline::updateRenderDeferred(); @@ -513,13 +506,6 @@ void LLViewerShaderMgr::setShaders() S32 wl_class = 1; S32 water_class = 2; S32 deferred_class = 0; - S32 transform_class = gGLManager.mHasTransformFeedback ? 1 : 0; - - static LLCachedControl use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback", false); - if (!use_transform_feedback) - { - transform_class = 0; - } if (useRenderDeferred) { @@ -572,7 +558,6 @@ void LLViewerShaderMgr::setShaders() mShaderLevel[SHADER_EFFECT] = effect_class; mShaderLevel[SHADER_WINDLIGHT] = wl_class; mShaderLevel[SHADER_DEFERRED] = deferred_class; - mShaderLevel[SHADER_TRANSFORM] = transform_class; std::string shader_name = loadBasicShaders(); if (shader_name.empty()) @@ -657,20 +642,6 @@ void LLViewerShaderMgr::setShaders() } } - if (loaded) - { - loaded = loadTransformShaders(); - if (loaded) - { - LL_INFOS() << "Loaded transform shaders." << LL_ENDL; - } - else - { - LL_WARNS() << "Failed to load transform shaders." << LL_ENDL; - llassert(loaded); - } - } - if (loaded) { // Load max avatar shaders to set the max level @@ -816,12 +787,6 @@ void LLViewerShaderMgr::unloadShaders() gDeferredSkinnedDiffuseProgram.unload(); gDeferredSkinnedBumpProgram.unload(); - gTransformPositionProgram.unload(); - gTransformTexCoordProgram.unload(); - gTransformNormalProgram.unload(); - gTransformColorProgram.unload(); - gTransformTangentProgram.unload(); - mShaderLevel[SHADER_LIGHTING] = 0; mShaderLevel[SHADER_OBJECT] = 0; mShaderLevel[SHADER_AVATAR] = 0; @@ -830,7 +795,6 @@ void LLViewerShaderMgr::unloadShaders() mShaderLevel[SHADER_INTERFACE] = 0; mShaderLevel[SHADER_EFFECT] = 0; mShaderLevel[SHADER_WINDLIGHT] = 0; - mShaderLevel[SHADER_TRANSFORM] = 0; gPipeline.mShadersLoaded = false; } @@ -1643,8 +1607,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->mFeatures.hasReflectionProbes = mShaderLevel[SHADER_DEFERRED]; shader->mShaderFiles.clear(); - shader->mShaderFiles.push_back(make_pair("deferred/pbralphaV.glsl", GL_VERTEX_SHADER_ARB)); - shader->mShaderFiles.push_back(make_pair("deferred/pbralphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaV.glsl", GL_VERTEX_SHADER)); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaF.glsl", GL_FRAGMENT_SHADER)); shader->clearPermutations(); @@ -2437,10 +2401,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowV.glsl", GL_VERTEX_SHADER)); gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER)); gDeferredShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - if (gGLManager.mHasDepthClamp) - { - gDeferredShadowProgram.addPermutation("DEPTH_CLAMP", "1"); - } + // gDeferredShadowProgram.addPermutation("DEPTH_CLAMP", "1"); // disable depth clamp for now gDeferredShadowProgram.mRiggedVariant = &gDeferredSkinnedShadowProgram; success = gDeferredShadowProgram.createShader(NULL, NULL); llassert(success); @@ -2456,10 +2417,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowSkinnedV.glsl", GL_VERTEX_SHADER)); gDeferredSkinnedShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER)); gDeferredSkinnedShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - if (gGLManager.mHasDepthClamp) - { - gDeferredSkinnedShadowProgram.addPermutation("DEPTH_CLAMP", "1"); - } + // gDeferredSkinnedShadowProgram.addPermutation("DEPTH_CLAMP", "1"); // disable depth clamp for now success = gDeferredSkinnedShadowProgram.createShader(NULL, NULL); llassert(success); } @@ -2472,10 +2430,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredShadowCubeProgram.mShaderFiles.clear(); gDeferredShadowCubeProgram.mShaderFiles.push_back(make_pair("deferred/shadowCubeV.glsl", GL_VERTEX_SHADER)); gDeferredShadowCubeProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER)); - if (gGLManager.mHasDepthClamp) - { - gDeferredShadowCubeProgram.addPermutation("DEPTH_CLAMP", "1"); - } + // gDeferredShadowCubeProgram.addPermutation("DEPTH_CLAMP", "1"); gDeferredShadowCubeProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredShadowCubeProgram.createShader(NULL, NULL); llassert(success); @@ -2491,10 +2446,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredShadowFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER)); gDeferredShadowFullbrightAlphaMaskProgram.clearPermutations(); - if (gGLManager.mHasDepthClamp) - { - gDeferredShadowFullbrightAlphaMaskProgram.addPermutation("DEPTH_CLAMP", "1"); - } + gDeferredShadowFullbrightAlphaMaskProgram.addPermutation("DEPTH_CLAMP", "1"); gDeferredShadowFullbrightAlphaMaskProgram.addPermutation("IS_FULLBRIGHT", "1"); gDeferredShadowFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredShadowFullbrightAlphaMaskProgram.mRiggedVariant = &gDeferredSkinnedShadowFullbrightAlphaMaskProgram; @@ -2512,10 +2464,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedShadowFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER)); gDeferredSkinnedShadowFullbrightAlphaMaskProgram.clearPermutations(); - if (gGLManager.mHasDepthClamp) - { - gDeferredSkinnedShadowFullbrightAlphaMaskProgram.addPermutation("DEPTH_CLAMP", "1"); - } + gDeferredSkinnedShadowFullbrightAlphaMaskProgram.addPermutation("DEPTH_CLAMP", "1"); gDeferredSkinnedShadowFullbrightAlphaMaskProgram.addPermutation("IS_FULLBRIGHT", "1"); gDeferredSkinnedShadowFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredSkinnedShadowFullbrightAlphaMaskProgram.createShader(NULL, NULL); @@ -2530,10 +2479,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredShadowAlphaMaskProgram.mShaderFiles.clear(); gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskV.glsl", GL_VERTEX_SHADER)); gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER)); - if (gGLManager.mHasDepthClamp) - { - gDeferredShadowAlphaMaskProgram.addPermutation("DEPTH_CLAMP", "1"); - } gDeferredShadowAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredShadowAlphaMaskProgram.mRiggedVariant = &gDeferredSkinnedShadowAlphaMaskProgram; success = gDeferredShadowAlphaMaskProgram.createShader(NULL, NULL); @@ -2548,10 +2493,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedShadowAlphaMaskProgram.mShaderFiles.clear(); gDeferredSkinnedShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskSkinnedV.glsl", GL_VERTEX_SHADER)); gDeferredSkinnedShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER)); - if (gGLManager.mHasDepthClamp) - { - gDeferredSkinnedShadowAlphaMaskProgram.addPermutation("DEPTH_CLAMP", "1"); - } gDeferredSkinnedShadowAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredSkinnedShadowAlphaMaskProgram.createShader(NULL, NULL); llassert(success); @@ -2565,10 +2506,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarShadowProgram.mShaderFiles.clear(); gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowV.glsl", GL_VERTEX_SHADER)); gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowF.glsl", GL_FRAGMENT_SHADER)); - if (gGLManager.mHasDepthClamp) - { - gDeferredAvatarShadowProgram.addPermutation("DEPTH_CLAMP", "1"); - } gDeferredAvatarShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarShadowProgram.createShader(NULL, NULL); llassert(success); @@ -2581,7 +2518,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaShadowProgram.mShaderFiles.clear(); gDeferredAvatarAlphaShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaShadowV.glsl", GL_VERTEX_SHADER)); gDeferredAvatarAlphaShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaShadowF.glsl", GL_FRAGMENT_SHADER)); - gDeferredAvatarAlphaShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); gDeferredAvatarAlphaShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarAlphaShadowProgram.createShader(NULL, NULL); llassert(success); @@ -2594,7 +2530,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaMaskShadowProgram.mShaderFiles.clear(); gDeferredAvatarAlphaMaskShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaShadowV.glsl", GL_VERTEX_SHADER)); gDeferredAvatarAlphaMaskShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaMaskShadowF.glsl", GL_FRAGMENT_SHADER)); - gDeferredAvatarAlphaMaskShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); gDeferredAvatarAlphaMaskShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarAlphaMaskShadowProgram.createShader(NULL, NULL); llassert(success); @@ -2608,10 +2543,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAttachmentShadowProgram.mShaderFiles.clear(); gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowV.glsl", GL_VERTEX_SHADER)); gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowF.glsl", GL_FRAGMENT_SHADER)); - if (gGLManager.mHasDepthClamp) - { - gDeferredAttachmentShadowProgram.addPermutation("DEPTH_CLAMP", "1"); - } gDeferredAttachmentShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAttachmentShadowProgram.createShader(NULL, NULL); llassert(success); @@ -2624,7 +2555,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAttachmentAlphaShadowProgram.mShaderFiles.clear(); gDeferredAttachmentAlphaShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentAlphaShadowV.glsl", GL_VERTEX_SHADER)); gDeferredAttachmentAlphaShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentAlphaShadowF.glsl", GL_FRAGMENT_SHADER)); - gDeferredAttachmentAlphaShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); gDeferredAttachmentAlphaShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAttachmentAlphaShadowProgram.createShader(NULL, NULL); llassert(success); @@ -2637,7 +2567,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAttachmentAlphaMaskShadowProgram.mShaderFiles.clear(); gDeferredAttachmentAlphaMaskShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentAlphaShadowV.glsl", GL_VERTEX_SHADER)); gDeferredAttachmentAlphaMaskShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentAlphaMaskShadowF.glsl", GL_FRAGMENT_SHADER)); - gDeferredAttachmentAlphaMaskShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); gDeferredAttachmentAlphaMaskShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAttachmentAlphaMaskShadowProgram.createShader(NULL, NULL); llassert(success); @@ -3976,95 +3905,6 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() return success; } -BOOL LLViewerShaderMgr::loadTransformShaders() -{ - BOOL success = TRUE; - - if (mShaderLevel[SHADER_TRANSFORM] < 1) - { - gTransformPositionProgram.unload(); - gTransformTexCoordProgram.unload(); - gTransformNormalProgram.unload(); - gTransformColorProgram.unload(); - gTransformTangentProgram.unload(); - return TRUE; - } - - if (success) - { - gTransformPositionProgram.mName = "Position Transform Shader"; - gTransformPositionProgram.mShaderFiles.clear(); - gTransformPositionProgram.mShaderFiles.push_back(make_pair("transform/positionV.glsl", GL_VERTEX_SHADER)); - gTransformPositionProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; - - const char* varyings[] = { - "position_out", - "texture_index_out", - }; - - success = gTransformPositionProgram.createShader(NULL, NULL, 2, varyings); - } - - if (success) - { - gTransformTexCoordProgram.mName = "TexCoord Transform Shader"; - gTransformTexCoordProgram.mShaderFiles.clear(); - gTransformTexCoordProgram.mShaderFiles.push_back(make_pair("transform/texcoordV.glsl", GL_VERTEX_SHADER)); - gTransformTexCoordProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; - - const char* varyings[] = { - "texcoord_out", - }; - - success = gTransformTexCoordProgram.createShader(NULL, NULL, 1, varyings); - } - - if (success) - { - gTransformNormalProgram.mName = "Normal Transform Shader"; - gTransformNormalProgram.mShaderFiles.clear(); - gTransformNormalProgram.mShaderFiles.push_back(make_pair("transform/normalV.glsl", GL_VERTEX_SHADER)); - gTransformNormalProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; - - const char* varyings[] = { - "normal_out", - }; - - success = gTransformNormalProgram.createShader(NULL, NULL, 1, varyings); - } - - if (success) - { - gTransformColorProgram.mName = "Color Transform Shader"; - gTransformColorProgram.mShaderFiles.clear(); - gTransformColorProgram.mShaderFiles.push_back(make_pair("transform/colorV.glsl", GL_VERTEX_SHADER)); - gTransformColorProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; - - const char* varyings[] = { - "color_out", - }; - - success = gTransformColorProgram.createShader(NULL, NULL, 1, varyings); - } - - if (success) - { - gTransformTangentProgram.mName = "Binormal Transform Shader"; - gTransformTangentProgram.mShaderFiles.clear(); - gTransformTangentProgram.mShaderFiles.push_back(make_pair("transform/binormalV.glsl", GL_VERTEX_SHADER)); - gTransformTangentProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; - - const char* varyings[] = { - "tangent_out", - }; - - success = gTransformTangentProgram.createShader(NULL, NULL, 1, varyings); - } - - - return success; -} - std::string LLViewerShaderMgr::getShaderDirPrefix(void) { return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "shaders/class"); diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 19d8e87d66..464efd6e3f 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -62,7 +62,6 @@ public: BOOL loadShadersWater(); BOOL loadShadersInterface(); BOOL loadShadersWindLight(); - BOOL loadTransformShaders(); std::vector mShaderLevel; S32 mMaxAvatarShaderLevel; @@ -78,7 +77,6 @@ public: SHADER_WINDLIGHT, SHADER_WATER, SHADER_DEFERRED, - SHADER_TRANSFORM, SHADER_COUNT }; @@ -150,15 +148,6 @@ inline bool operator != (LLViewerShaderMgr::shader_iter const & a, LLViewerShade extern LLVector4 gShinyOrigin; -//transform shaders -extern LLGLSLShader gTransformPositionProgram; -extern LLGLSLShader gTransformTexCoordProgram; -extern LLGLSLShader gTransformNormalProgram; -extern LLGLSLShader gTransformColorProgram; -extern LLGLSLShader gTransformTangentProgram; - - - //utility shaders extern LLGLSLShader gOcclusionProgram; extern LLGLSLShader gOcclusionCubeProgram; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index e9815a7872..5474098d16 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -597,29 +597,6 @@ public: { LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording(); - if (gGLManager.mHasATIMemInfo) - { - S32 meminfo[4]; - glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo); - - addText(xpos, ypos, llformat("%.2f MB Texture Memory Free", meminfo[0]/1024.f)); - ypos += y_inc; - - if (gGLManager.mHasVertexBufferObject) - { - glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, meminfo); - addText(xpos, ypos, llformat("%.2f MB VBO Memory Free", meminfo[0]/1024.f)); - ypos += y_inc; - } - } - else if (gGLManager.mHasNVXMemInfo) - { - S32 free_memory; - glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &free_memory); - addText(xpos, ypos, llformat("%.2f MB Video Memory Free", free_memory/1024.f)); - ypos += y_inc; - } - //show streaming cost/triangle count of known prims in current region OR selection { F32 cost = 0.f; @@ -1979,11 +1956,6 @@ LLViewerWindow::LLViewerWindow(const Params& p) LL_DEBUGS("Window") << "Loading feature tables." << LL_ENDL; // Initialize OpenGL Renderer - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") || - !gGLManager.mHasVertexBufferObject) - { - gSavedSettings.setBOOL("RenderVBOEnable", FALSE); - } LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable"), gSavedSettings.getBOOL("RenderVBOMappingDisable")); LL_INFOS("RenderInit") << "LLVertexBuffer initialization done." << LL_ENDL ; gGL.init() ; @@ -1997,11 +1969,6 @@ LLViewerWindow::LLViewerWindow(const Params& p) gSavedSettings.setBOOL("ProbeHardwareOnStartup", FALSE); } - if (!gGLManager.mHasDepthClamp) - { - LL_INFOS("RenderInit") << "Missing feature GL_ARB_depth_clamp. Void water might disappear in rare cases." << LL_ENDL; - } - // If we crashed while initializng GL stuff last time, disable certain features if (gSavedSettings.getBOOL("RenderInitError")) { diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index b7a5a0667b..9f43fb9b82 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -531,7 +531,7 @@ void LLVOSky::initCubeMap() images.push_back(mShinyTex[side].getImageRaw()); } - if (!mCubeMap && gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) + if (!mCubeMap && gSavedSettings.getBOOL("RenderWater") && LLCubeMap::sUseCubeMaps) { mCubeMap = new LLCubeMap(false); } @@ -576,7 +576,7 @@ void LLVOSky::restoreGL() updateDirections(psky); - if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) + if (gSavedSettings.getBOOL("RenderWater") && LLCubeMap::sUseCubeMaps) { initCubeMap(); } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 61589640fe..ad1711d3fb 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1121,27 +1121,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bo } } - static LLCachedControl use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback", false); - - bool cache_in_vram = use_transform_feedback && gTransformPositionProgram.mProgramObject && - (!mVolumeImpl || !mVolumeImpl->isVolumeUnique()); - - if (cache_in_vram) - { //this volume might be used as source data for a transform object, put it in vram - LLVolume* volume = getVolume(); - for (S32 i = 0; i < volume->getNumFaces(); ++i) - { - const LLVolumeFace& face = volume->getVolumeFace(i); - if (face.mVertexBuffer.notNull()) - { //already cached - break; - } - volume->genTangents(i); - LLFace::cacheFaceInVRAM(face); - } - } - - return TRUE; + return TRUE; } else if (NO_LOD == lod) { @@ -6417,16 +6397,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace U32 geometryBytes = 0; U32 buffer_usage = group->mBufferUsage; - static LLCachedControl use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback", false); - - if (use_transform_feedback && - gTransformPositionProgram.mProgramObject && //transform shaders are loaded - buffer_usage == GL_DYNAMIC_DRAW && //target buffer is in VRAM - !(mask & LLVertexBuffer::MAP_WEIGHT4)) //TODO: add support for weights - { - buffer_usage = GL_DYNAMIC_COPY; - } - #if LL_DARWIN // HACK from Leslie: // Disable VBO usage for alpha on Mac OS X because it kills the framerate diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 858cc90d04..f8ab68e57d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -892,16 +892,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!addDeferredAttachments(mRT->deferredScreen)) return false; - GLuint screenFormat = GL_RGBA16; - if (gGLManager.mIsAMD) - { - screenFormat = GL_RGBA12; - } - - if (gGLManager.mGLVersion < 4.f && gGLManager.mIsNVIDIA) - { - screenFormat = GL_RGBA16F_ARB; - } + GLuint screenFormat = GL_RGBA; if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) @@ -1065,8 +1056,7 @@ void LLPipeline::refreshCachedSettings() LLPipeline::sUseOcclusion = (!gUseWireframe && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") - && gSavedSettings.getBOOL("UseOcclusion") - && gGLManager.mHasOcclusionQuery) ? 2 : 0; + && gSavedSettings.getBOOL("UseOcclusion")) ? 2 : 0; WindLightUseAtmosShaders = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("WindLightUseAtmosShaders"); RenderDeferred = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderDeferred"); @@ -2355,8 +2345,7 @@ static LLTrace::BlockTimerStatHandle FTM_CULL("Object Culling"); void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* planep) { static LLCachedControl use_occlusion(gSavedSettings,"UseOcclusion"); - static bool can_use_occlusion = LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") - && gGLManager.mHasOcclusionQuery; + static bool can_use_occlusion = LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion"); LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_CULL); @@ -9759,7 +9748,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLGLEnable cull(GL_CULL_FACE); //enable depth clamping if available - LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0); + //LLGLEnable depth_clamp(GL_DEPTH_CLAMP); if (use_shader) { diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index eb4f9f16fa..825d1202a6 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -3099,8 +3099,6 @@ function="World.EnvPreset" - -- cgit v1.3 From 8f1d22686551f4d6783d03cd3685085ed7fcb96c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 23 Sep 2022 11:19:56 -0500 Subject: SL-18134 Rename Albedo to Base Color to be more consistent with GLTF spec --- indra/llprimitive/llgltfmaterial.h | 4 +- indra/newview/llface.cpp | 2 +- indra/newview/lllocalgltfmaterials.cpp | 12 +- indra/newview/lllocalgltfmaterials.h | 2 +- indra/newview/llmaterialeditor.cpp | 152 ++++++++++----------- indra/newview/llmaterialeditor.h | 24 ++-- indra/newview/llpanelface.cpp | 20 +-- indra/newview/lltinygltfhelper.cpp | 16 +-- indra/newview/lltinygltfhelper.h | 4 +- indra/newview/llviewerobject.cpp | 8 +- indra/newview/llviewerobject.h | 4 +- indra/newview/llvovolume.cpp | 4 +- .../default/xui/en/floater_material_editor.xml | 14 +- .../skins/default/xui/en/panel_tools_texture.xml | 4 +- 14 files changed, 135 insertions(+), 135 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index ab381ca55e..36636c3b4e 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -43,12 +43,12 @@ public: ALPHA_MODE_MASK }; - LLUUID mAlbedoId; + LLUUID mBaseColorId; LLUUID mNormalId; LLUUID mMetallicRoughnessId; LLUUID mEmissiveId; - LLColor4 mAlbedoColor = LLColor4(1,1,1,1); + LLColor4 mBaseColor = LLColor4(1,1,1,1); LLColor3 mEmissiveColor = LLColor3(0,0,0); F32 mMetallicFactor = 0.f; diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 5562f1d057..5de8bda787 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1336,7 +1336,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (tep->getGLTFMaterial()) { - color = tep->getGLTFMaterial()->mAlbedoColor; + color = tep->getGLTFMaterial()->mBaseColor; } if (rebuild_color) diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp index 5373400e9d..524693e7ea 100644 --- a/indra/newview/lllocalgltfmaterials.cpp +++ b/indra/newview/lllocalgltfmaterials.cpp @@ -259,8 +259,8 @@ bool LLLocalGLTFMaterial::loadMaterial(LLPointer mat) std::string folder = gDirUtilp->getDirName(filename_lc); tinygltf::Material material_in = model_in.materials[0]; - // get albedo texture - LLPointer albedo_img = LLTinyGLTFHelper::getTexture(folder, model_in, material_in.pbrMetallicRoughness.baseColorTexture.index); + // get base color texture + LLPointer base_img = LLTinyGLTFHelper::getTexture(folder, model_in, material_in.pbrMetallicRoughness.baseColorTexture.index); // get normal map LLPointer normal_img = LLTinyGLTFHelper::getTexture(folder, model_in, material_in.normalTexture.index); // get metallic-roughness texture @@ -276,12 +276,12 @@ bool LLLocalGLTFMaterial::loadMaterial(LLPointer mat) // todo: pass it into local bitmaps? LLTinyGLTFHelper::initFetchedTextures(material_in, - albedo_img, normal_img, mr_img, emissive_img, occlusion_img, - mAlbedoFetched, mNormalFetched, mMRFetched, mEmissiveFetched); + base_img, normal_img, mr_img, emissive_img, occlusion_img, + mBaseColorFetched, mNormalFetched, mMRFetched, mEmissiveFetched); - if (mAlbedoFetched) + if (mBaseColorFetched) { - mat->mAlbedoId = mAlbedoFetched->getID(); + mat->mBaseColorId= mBaseColorFetched->getID(); } if (mNormalFetched) { diff --git a/indra/newview/lllocalgltfmaterials.h b/indra/newview/lllocalgltfmaterials.h index 1bca06ba2a..de775615a8 100644 --- a/indra/newview/lllocalgltfmaterials.h +++ b/indra/newview/lllocalgltfmaterials.h @@ -79,7 +79,7 @@ private: /* members */ S32 mUpdateRetries; // material needs to maintain textures - LLPointer mAlbedoFetched; + LLPointer mBaseColorFetched; LLPointer mNormalFetched; LLPointer mMRFetched; LLPointer mEmissiveFetched; diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 4efbf19572..12d21cf284 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -60,7 +60,7 @@ #include -const std::string MATERIAL_ALBEDO_DEFAULT_NAME = "Albedo"; +const std::string MATERIAL_BASE_COLOR_DEFAULT_NAME = "Base Color"; const std::string MATERIAL_NORMAL_DEFAULT_NAME = "Normal"; const std::string MATERIAL_METALLIC_DEFAULT_NAME = "Metallic Roughness"; const std::string MATERIAL_EMISSIVE_DEFAULT_NAME = "Emissive"; @@ -101,12 +101,12 @@ LLMaterialEditor::LLMaterialEditor(const LLSD& key) BOOL LLMaterialEditor::postBuild() { - mAlbedoTextureCtrl = getChild("albedo_texture"); + mBaseColorTextureCtrl = getChild("base_color_texture"); mMetallicTextureCtrl = getChild("metallic_roughness_texture"); mEmissiveTextureCtrl = getChild("emissive_texture"); mNormalTextureCtrl = getChild("normal_texture"); - mAlbedoTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitAlbedoTexture, this, _1, _2)); + mBaseColorTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitBaseColorTexture, this, _1, _2)); mMetallicTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitMetallicTexture, this, _1, _2)); mEmissiveTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitEmissiveTexture, this, _1, _2)); mNormalTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitNormalTexture, this, _1, _2)); @@ -116,7 +116,7 @@ BOOL LLMaterialEditor::postBuild() childSetAction("cancel", boost::bind(&LLMaterialEditor::onClickCancel, this)); S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(); - getChild("albedo_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); + getChild("base_color_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); getChild("metallic_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); getChild("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); getChild("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); @@ -130,8 +130,8 @@ BOOL LLMaterialEditor::postBuild() childSetCommitCallback("double sided", changes_callback, NULL); - // Albedo - childSetCommitCallback("albedo color", changes_callback, NULL); + // BaseColor + childSetCommitCallback("base color", changes_callback, NULL); childSetCommitCallback("transparency", changes_callback, NULL); childSetCommitCallback("alpha mode", changes_callback, NULL); childSetCommitCallback("alpha cutoff", changes_callback, NULL); @@ -177,18 +177,18 @@ void LLMaterialEditor::onClose(bool app_quitting) LLPreview::onClose(app_quitting); } -LLUUID LLMaterialEditor::getAlbedoId() +LLUUID LLMaterialEditor::getBaseColorId() { - return mAlbedoTextureCtrl->getValue().asUUID(); + return mBaseColorTextureCtrl->getValue().asUUID(); } -void LLMaterialEditor::setAlbedoId(const LLUUID& id) +void LLMaterialEditor::setBaseColorId(const LLUUID& id) { - mAlbedoTextureCtrl->setValue(id); - mAlbedoTextureCtrl->setDefaultImageAssetID(id); + mBaseColorTextureCtrl->setValue(id); + mBaseColorTextureCtrl->setDefaultImageAssetID(id); } -void LLMaterialEditor::setAlbedoUploadId(const LLUUID& id) +void LLMaterialEditor::setBaseColorUploadId(const LLUUID& id) { // Might be better to use local textures and // assign a fee in case of a local texture @@ -196,23 +196,23 @@ void LLMaterialEditor::setAlbedoUploadId(const LLUUID& id) { // todo: this does not account for posibility of texture // being from inventory, need to check that - childSetValue("albedo_upload_fee", getString("upload_fee_string")); + childSetValue("base_color_upload_fee", getString("upload_fee_string")); // Only set if we will need to upload this texture - mAlbedoTextureUploadId = id; + mBaseColorTextureUploadId = id; } setHasUnsavedChanges(true); } -LLColor4 LLMaterialEditor::getAlbedoColor() +LLColor4 LLMaterialEditor::getBaseColor() { - LLColor4 ret = linearColor4(LLColor4(childGetValue("albedo color"))); + LLColor4 ret = linearColor4(LLColor4(childGetValue("base color"))); ret.mV[3] = getTransparency(); return ret; } -void LLMaterialEditor::setAlbedoColor(const LLColor4& color) +void LLMaterialEditor::setBaseColor(const LLColor4& color) { - childSetValue("albedo color", srgbColor4(color).getValue()); + childSetValue("base color", srgbColor4(color).getValue()); setTransparency(color.mV[3]); } @@ -370,7 +370,7 @@ void LLMaterialEditor::setHasUnsavedChanges(bool value) } S32 upload_texture_count = 0; - if (mAlbedoTextureUploadId.notNull() && mAlbedoTextureUploadId == getAlbedoId()) + if (mBaseColorTextureUploadId.notNull() && mBaseColorTextureUploadId == getBaseColorId()) { upload_texture_count++; } @@ -401,23 +401,23 @@ void LLMaterialEditor::setCanSave(BOOL value) childSetEnabled("save", value); } -void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data) +void LLMaterialEditor::onCommitBaseColorTexture(LLUICtrl * ctrl, const LLSD & data) { // might be better to use arrays, to have a single callback // and not to repeat the same thing for each tecture control - LLUUID new_val = mAlbedoTextureCtrl->getValue().asUUID(); - if (new_val == mAlbedoTextureUploadId && mAlbedoTextureUploadId.notNull()) + LLUUID new_val = mBaseColorTextureCtrl->getValue().asUUID(); + if (new_val == mBaseColorTextureUploadId && mBaseColorTextureUploadId.notNull()) { - childSetValue("albedo_upload_fee", getString("upload_fee_string")); + childSetValue("base_color_upload_fee", getString("upload_fee_string")); } else { // Texture picker has 'apply now' with 'cancel' support. - // Keep mAlbedoJ2C and mAlbedoFetched, it's our storage in + // Keep mBaseColorJ2C and mBaseColorFetched, it's our storage in // case user decides to cancel changes. - // Without mAlbedoFetched, viewer will eventually cleanup + // Without mBaseColorFetched, viewer will eventually cleanup // the texture that is not in use - childSetValue("albedo_upload_fee", getString("no_upload_fee_string")); + childSetValue("base_color_upload_fee", getString("no_upload_fee_string")); } setHasUnsavedChanges(true); applyToSelection(); @@ -547,19 +547,19 @@ void LLMaterialEditor::getGLTFModel(tinygltf::Model& model) model.materials.resize(1); tinygltf::PbrMetallicRoughness& pbrMaterial = model.materials[0].pbrMetallicRoughness; - // write albedo - LLColor4 albedo_color = getAlbedoColor(); - albedo_color.mV[3] = getTransparency(); - write_color(albedo_color, pbrMaterial.baseColorFactor); + // write base color + LLColor4 base_color = getBaseColor(); + base_color.mV[3] = getTransparency(); + write_color(base_color, pbrMaterial.baseColorFactor); model.materials[0].alphaCutoff = getAlphaCutoff(); model.materials[0].alphaMode = getAlphaMode(); - LLUUID albedo_id = getAlbedoId(); + LLUUID base_color_id = getBaseColorId(); - if (albedo_id.notNull()) + if (base_color_id.notNull()) { - U32 texture_idx = write_texture(albedo_id, model); + U32 texture_idx = write_texture(base_color_id, model); pbrMaterial.baseColorTexture.index = texture_idx; } @@ -677,9 +677,9 @@ const std::string LLMaterialEditor::buildMaterialDescription() // control UUI for NULL is a valid metric for if it was loaded // or not but I suspect this code will change a lot so may need // to revisit - if (!mAlbedoTextureCtrl->getValue().asUUID().isNull()) + if (!mBaseColorTextureCtrl->getValue().asUUID().isNull()) { - desc << mAlbedoName; + desc << mBaseColorName; desc << ", "; } if (!mMetallicTextureCtrl->getValue().asUUID().isNull()) @@ -1050,22 +1050,22 @@ void LLMaterialFilePicker::notify(const std::vector& filenames) } static void pack_textures( - LLPointer& albedo_img, + LLPointer& base_color_img, LLPointer& normal_img, LLPointer& mr_img, LLPointer& emissive_img, LLPointer& occlusion_img, - LLPointer& albedo_j2c, + LLPointer& base_color_j2c, LLPointer& normal_j2c, LLPointer& mr_j2c, LLPointer& emissive_j2c) { // NOTE : remove log spam and lossless vs lossy comparisons when the logs are no longer useful - if (albedo_img) + if (base_color_img) { - albedo_j2c = LLViewerTextureList::convertToUploadFile(albedo_img); - LL_INFOS() << "Albedo: " << albedo_j2c->getDataSize() << LL_ENDL; + base_color_j2c = LLViewerTextureList::convertToUploadFile(base_color_img); + LL_INFOS() << "BaseColor: " << base_color_j2c->getDataSize() << LL_ENDL; } if (normal_img) @@ -1146,8 +1146,8 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) model_out.asset.version = "2.0"; model_out.materials.resize(1); - // get albedo texture - LLPointer albedo_img = LLTinyGLTFHelper::getTexture(folder, model_in, material_in.pbrMetallicRoughness.baseColorTexture.index, mAlbedoName); + // get base color texture + LLPointer base_color_img = LLTinyGLTFHelper::getTexture(folder, model_in, material_in.pbrMetallicRoughness.baseColorTexture.index, mBaseColorName); // get normal map LLPointer normal_img = LLTinyGLTFHelper::getTexture(folder, model_in, material_in.normalTexture.index, mNormalName); // get metallic-roughness texture @@ -1162,20 +1162,20 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) occlusion_img = LLTinyGLTFHelper::getTexture(folder, model_in, material_in.occlusionTexture.index, tmp); } - LLTinyGLTFHelper::initFetchedTextures(material_in, albedo_img, normal_img, mr_img, emissive_img, occlusion_img, - mAlbedoFetched, mNormalFetched, mMetallicRoughnessFetched, mEmissiveFetched); - pack_textures(albedo_img, normal_img, mr_img, emissive_img, occlusion_img, - mAlbedoJ2C, mNormalJ2C, mMetallicRoughnessJ2C, mEmissiveJ2C); + LLTinyGLTFHelper::initFetchedTextures(material_in, base_color_img, normal_img, mr_img, emissive_img, occlusion_img, + mBaseColorFetched, mNormalFetched, mMetallicRoughnessFetched, mEmissiveFetched); + pack_textures(base_color_img, normal_img, mr_img, emissive_img, occlusion_img, + mBaseColorJ2C, mNormalJ2C, mMetallicRoughnessJ2C, mEmissiveJ2C); - LLUUID albedo_id; - if (mAlbedoFetched.notNull()) + LLUUID base_color_id; + if (mBaseColorFetched.notNull()) { - mAlbedoFetched->forceToSaveRawImage(0, F32_MAX); - albedo_id = mAlbedoFetched->getID(); + mBaseColorFetched->forceToSaveRawImage(0, F32_MAX); + base_color_id = mBaseColorFetched->getID(); - if (mAlbedoName.empty()) + if (mBaseColorName.empty()) { - mAlbedoName = MATERIAL_ALBEDO_DEFAULT_NAME; + mBaseColorName = MATERIAL_BASE_COLOR_DEFAULT_NAME; } } @@ -1215,8 +1215,8 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) } } - setAlbedoId(albedo_id); - setAlbedoUploadId(albedo_id); + setBaseColorId(base_color_id); + setBaseColorUploadId(base_color_id); setMetallicRoughnessId(mr_id); setMetallicRoughnessUploadId(mr_id); setEmissiveId(emissive_id); @@ -1245,16 +1245,16 @@ bool LLMaterialEditor::setFromGltfModel(tinygltf::Model& model, bool set_texture S32 index; LLUUID id; - // get albedo texture + // get base color texture index = material_in.pbrMetallicRoughness.baseColorTexture.index; if (index >= 0) { id.set(model.images[index].uri); - setAlbedoId(id); + setBaseColorId(id); } else { - setAlbedoId(LLUUID::null); + setBaseColorId(LLUUID::null); } // get normal map @@ -1297,7 +1297,7 @@ bool LLMaterialEditor::setFromGltfModel(tinygltf::Model& model, bool set_texture setAlphaMode(material_in.alphaMode); setAlphaCutoff(material_in.alphaCutoff); - setAlbedoColor(LLTinyGLTFHelper::getColor(material_in.pbrMetallicRoughness.baseColorFactor)); + setBaseColor(LLTinyGLTFHelper::getColor(material_in.pbrMetallicRoughness.baseColorFactor)); setEmissiveColor(LLTinyGLTFHelper::getColor(material_in.emissiveFactor)); setMetalnessFactor(material_in.pbrMetallicRoughness.metallicFactor); @@ -1331,7 +1331,7 @@ const std::string LLMaterialEditor::getImageNameFromUri(std::string image_uri, c stripped_uri = stripped_uri.substr(0, max_texture_name_length - 1); } - // We intend to append the type of texture (albedo, emissive etc.) to the + // We intend to append the type of texture (base color, emissive etc.) to the // name of the texture but sometimes the creator already did that. To try // to avoid repeats (not perfect), we look for the texture type in the name // and if we find it, do not append the type, later on. One way this fails @@ -1357,7 +1357,7 @@ const std::string LLMaterialEditor::getImageNameFromUri(std::string image_uri, c // so we can include everything if (stripped_uri.length() > 0) { - // example "DamagedHelmet: base layer (Albedo)" + // example "DamagedHelmet: base layer" return STRINGIZE( mMaterialNameShort << ": " << @@ -1476,17 +1476,17 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, tinygltf { const tinygltf::Material& first_material = model.materials[0]; - mAlbedoName = MATERIAL_ALBEDO_DEFAULT_NAME; - // note: unlike the other textures, albedo doesn't have its own entry + mBaseColorName = MATERIAL_BASE_COLOR_DEFAULT_NAME; + // note: unlike the other textures, base color doesn't have its own entry // in the tinyGLTF Material struct. Rather, it is taken from a // sub-texture in the pbrMetallicRoughness member int index = first_material.pbrMetallicRoughness.baseColorTexture.index; if (index > -1 && index < model.images.size()) { // sanitize the name we decide to use for each texture - std::string texture_name = getImageNameFromUri(model.images[index].uri, MATERIAL_ALBEDO_DEFAULT_NAME); + std::string texture_name = getImageNameFromUri(model.images[index].uri, MATERIAL_BASE_COLOR_DEFAULT_NAME); LLInventoryObject::correctInventoryName(texture_name); - mAlbedoName = texture_name; + mBaseColorName = texture_name; } mEmissiveName = MATERIAL_EMISSIVE_DEFAULT_NAME; @@ -1559,9 +1559,9 @@ void LLMaterialEditor::applyToSelection() void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat) { - mat->mAlbedoColor = getAlbedoColor(); - mat->mAlbedoColor.mV[3] = getTransparency(); - mat->mAlbedoId = getAlbedoId(); + mat->mBaseColor = getBaseColor(); + mat->mBaseColor.mV[3] = getTransparency(); + mat->mBaseColorId = getBaseColorId(); mat->mNormalId = getNormalId(); @@ -1579,8 +1579,8 @@ void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat) void LLMaterialEditor::setFromGLTFMaterial(LLGLTFMaterial* mat) { - setAlbedoColor(mat->mAlbedoColor); - setAlbedoId(mat->mAlbedoId); + setBaseColor(mat->mBaseColor); + setBaseColorId(mat->mBaseColorId); setNormalId(mat->mNormalId); setMetallicRoughnessId(mat->mMetallicRoughnessId); @@ -1801,23 +1801,23 @@ S32 LLMaterialEditor::saveTextures() { S32 work_count = 0; LLSD key = getKey(); // must be locally declared for lambda's capture to work - if (mAlbedoTextureUploadId == getAlbedoId() && mAlbedoTextureUploadId.notNull()) + if (mBaseColorTextureUploadId == getBaseColorId() && mBaseColorTextureUploadId.notNull()) { mUploadingTexturesCount++; work_count++; - saveTexture(mAlbedoJ2C, mAlbedoName, mAlbedoTextureUploadId, [key](LLUUID newAssetId, LLSD response) + saveTexture(mBaseColorJ2C, mBaseColorName, mBaseColorTextureUploadId, [key](LLUUID newAssetId, LLSD response) { LLMaterialEditor* me = LLFloaterReg::findTypedInstance("material_editor", key); if (me) { if (response["success"].asBoolean()) { - me->setAlbedoId(newAssetId); + me->setBaseColorId(newAssetId); } else { // To make sure that we won't retry (some failures can cb immediately) - me->setAlbedoId(LLUUID::null); + me->setBaseColorId(LLUUID::null); } me->mUploadingTexturesCount--; @@ -1902,17 +1902,17 @@ S32 LLMaterialEditor::saveTextures() } // discard upload buffers once textures have been saved - mAlbedoJ2C = nullptr; + mBaseColorJ2C = nullptr; mNormalJ2C = nullptr; mEmissiveJ2C = nullptr; mMetallicRoughnessJ2C = nullptr; - mAlbedoFetched = nullptr; + mBaseColorFetched = nullptr; mNormalFetched = nullptr; mMetallicRoughnessFetched = nullptr; mEmissiveFetched = nullptr; - mAlbedoTextureUploadId.setNull(); + mBaseColorTextureUploadId.setNull(); mNormalTextureUploadId.setNull(); mMetallicTextureUploadId.setNull(); mEmissiveTextureUploadId.setNull(); diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index cc72193a0e..0d741614b8 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -108,14 +108,14 @@ public: void onClose(bool app_quitting) override; - LLUUID getAlbedoId(); - void setAlbedoId(const LLUUID& id); - void setAlbedoUploadId(const LLUUID& id); + LLUUID getBaseColorId(); + void setBaseColorId(const LLUUID& id); + void setBaseColorUploadId(const LLUUID& id); - LLColor4 getAlbedoColor(); + LLColor4 getBaseColor(); - // sets both albedo color and transparency - void setAlbedoColor(const LLColor4& color); + // sets both base color and transparency + void setBaseColor(const LLColor4& color); F32 getTransparency(); void setTransparency(F32 transparency); @@ -156,7 +156,7 @@ public: void setCanSaveAs(BOOL value); void setCanSave(BOOL value); - void onCommitAlbedoTexture(LLUICtrl* ctrl, const LLSD& data); + void onCommitBaseColorTexture(LLUICtrl* ctrl, const LLSD& data); void onCommitMetallicTexture(LLUICtrl* ctrl, const LLSD& data); void onCommitEmissiveTexture(LLUICtrl* ctrl, const LLSD& data); void onCommitNormalTexture(LLUICtrl* ctrl, const LLSD& data); @@ -169,32 +169,32 @@ private: LLUUID mAssetID; LLUUID mObjectID; - LLTextureCtrl* mAlbedoTextureCtrl; + LLTextureCtrl* mBaseColorTextureCtrl; LLTextureCtrl* mMetallicTextureCtrl; LLTextureCtrl* mEmissiveTextureCtrl; LLTextureCtrl* mNormalTextureCtrl; // 'Default' texture, unless it's null or from inventory is the one with the fee - LLUUID mAlbedoTextureUploadId; + LLUUID mBaseColorTextureUploadId; LLUUID mMetallicTextureUploadId; LLUUID mEmissiveTextureUploadId; LLUUID mNormalTextureUploadId; // last known name of each texture - std::string mAlbedoName; + std::string mBaseColorName; std::string mNormalName; std::string mMetallicRoughnessName; std::string mEmissiveName; // keep pointers to fetched textures or viewer will remove them // if user temporary selects something else with 'apply now' - LLPointer mAlbedoFetched; + LLPointer mBaseColorFetched; LLPointer mNormalFetched; LLPointer mMetallicRoughnessFetched; LLPointer mEmissiveFetched; // J2C versions of packed buffers for uploading - LLPointer mAlbedoJ2C; + LLPointer mBaseColorJ2C; LLPointer mNormalJ2C; LLPointer mMetallicRoughnessJ2C; LLPointer mEmissiveJ2C; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index f7eff39da7..a4a91baad8 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -105,7 +105,7 @@ const S32 MATTYPE_SPECULAR = 2; // Specular map const S32 ALPHAMODE_MASK = 2; // Alpha masking mode const S32 BUMPY_TEXTURE = 18; // use supplied normal map const S32 SHINY_TEXTURE = 4; // use supplied specular map -const S32 PBRTYPE_ALBEDO = 0; // PBR Albedo +const S32 PBRTYPE_BASE_COLOR = 0; // PBR Base Color const S32 PBRTYPE_NORMAL = 1; // PBR Normal const S32 PBRTYPE_METALLIC = 2; // PBR Metallic @@ -344,7 +344,7 @@ BOOL LLPanelFace::postBuild() if (radio_pbr_type) { radio_pbr_type->setCommitCallback(LLPanelFace::onCommitPbrType, this); - radio_pbr_type->selectNthItem(PBRTYPE_ALBEDO); + radio_pbr_type->selectNthItem(PBRTYPE_BASE_COLOR); } mCtrlGlow = getChild("glow"); @@ -897,9 +897,9 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) radio_mat_type->setEnabled(editable); LLRadioGroup* radio_pbr_type = getChild("radio_pbr_type"); - if (radio_pbr_type->getSelectedIndex() < PBRTYPE_ALBEDO) + if (radio_pbr_type->getSelectedIndex() < PBRTYPE_BASE_COLOR) { - radio_pbr_type->selectNthItem(PBRTYPE_ALBEDO); + radio_pbr_type->selectNthItem(PBRTYPE_BASE_COLOR); } radio_pbr_type->setEnabled(editable); @@ -2570,7 +2570,7 @@ void LLPanelFace::updateVisibility() bool show_texture = (show_media || (show_material && (material_type == MATTYPE_DIFFUSE) && mComboMatMedia->getEnabled())); bool show_bumpiness = show_material && (material_type == MATTYPE_NORMAL) && mComboMatMedia->getEnabled(); bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); - bool show_pbr_albedo = show_pbr && (pbr_type == PBRTYPE_ALBEDO) && mComboMatMedia->getEnabled(); + bool show_pbr_base_color = show_pbr && (pbr_type == PBRTYPE_BASE_COLOR) && mComboMatMedia->getEnabled(); bool show_pbr_normal = show_pbr && (pbr_type == PBRTYPE_NORMAL) && mComboMatMedia->getEnabled(); bool show_pbr_metallic = show_pbr && (pbr_type == PBRTYPE_METALLIC) && mComboMatMedia->getEnabled(); @@ -2594,11 +2594,11 @@ void LLPanelFace::updateVisibility() updateAlphaControls(); } // texture scale and position controls are shared between bpr and non-pbr textures - getChildView("TexScaleU")->setVisible(show_texture || show_pbr_albedo); - getChildView("TexScaleV")->setVisible(show_texture || show_pbr_albedo); - getChildView("TexRot")->setVisible(show_texture || show_pbr_albedo); - getChildView("TexOffsetU")->setVisible(show_texture || show_pbr_albedo); - getChildView("TexOffsetV")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexScaleU")->setVisible(show_texture || show_pbr_base_color); + getChildView("TexScaleV")->setVisible(show_texture || show_pbr_base_color); + getChildView("TexRot")->setVisible(show_texture || show_pbr_base_color); + getChildView("TexOffsetU")->setVisible(show_texture || show_pbr_base_color); + getChildView("TexOffsetV")->setVisible(show_texture || show_pbr_base_color); // Specular map controls getChildView("shinytexture control")->setVisible(show_shininess); diff --git a/indra/newview/lltinygltfhelper.cpp b/indra/newview/lltinygltfhelper.cpp index 935f8e7794..3125cacbd5 100644 --- a/indra/newview/lltinygltfhelper.cpp +++ b/indra/newview/lltinygltfhelper.cpp @@ -62,19 +62,19 @@ void copy_red_channel(LLPointer& src_img, LLPointer& dst } void LLTinyGLTFHelper::initFetchedTextures(tinygltf::Material& material, - LLPointer& albedo_img, + LLPointer& base_color_img, LLPointer& normal_img, LLPointer& mr_img, LLPointer& emissive_img, LLPointer& occlusion_img, - LLPointer& albedo_tex, + LLPointer& base_color_tex, LLPointer& normal_tex, LLPointer& mr_tex, LLPointer& emissive_tex) { - if (albedo_img) + if (base_color_img) { - albedo_tex = LLViewerTextureManager::getFetchedTexture(albedo_img, FTType::FTT_LOCAL_FILE, true); + base_color_tex = LLViewerTextureManager::getFetchedTexture(base_color_img, FTType::FTT_LOCAL_FILE, true); } if (normal_img) @@ -128,15 +128,15 @@ void LLTinyGLTFHelper::setFromModel(LLGLTFMaterial* mat, tinygltf::Model& model) auto& material_in = model.materials[0]; - // get albedo texture + // get base color texture index = material_in.pbrMetallicRoughness.baseColorTexture.index; if (index >= 0) { - mat->mAlbedoId.set(model.images[index].uri); + mat->mBaseColorId.set(model.images[index].uri); } else { - mat->mAlbedoId.setNull(); + mat->mBaseColorId.setNull(); } // get normal map @@ -175,7 +175,7 @@ void LLTinyGLTFHelper::setFromModel(LLGLTFMaterial* mat, tinygltf::Model& model) mat->setAlphaMode(material_in.alphaMode); mat->mAlphaCutoff = llclamp((F32)material_in.alphaCutoff, 0.f, 1.f); - mat->mAlbedoColor = getColor(material_in.pbrMetallicRoughness.baseColorFactor); + mat->mBaseColor= getColor(material_in.pbrMetallicRoughness.baseColorFactor); mat->mEmissiveColor = getColor(material_in.emissiveFactor); mat->mMetallicFactor = llclamp((F32)material_in.pbrMetallicRoughness.metallicFactor, 0.f, 1.f); diff --git a/indra/newview/lltinygltfhelper.h b/indra/newview/lltinygltfhelper.h index a25fdac41d..89e09b189e 100644 --- a/indra/newview/lltinygltfhelper.h +++ b/indra/newview/lltinygltfhelper.h @@ -42,12 +42,12 @@ namespace LLTinyGLTFHelper LLImageRaw* getTexture(const std::string& folder, const tinygltf::Model& model, S32 texture_index); void initFetchedTextures(tinygltf::Material& material, - LLPointer& albedo_img, + LLPointer& base_color_img, LLPointer& normal_img, LLPointer& mr_img, LLPointer& emissive_img, LLPointer& occlusion_img, - LLPointer& albedo_tex, + LLPointer& base_color_tex, LLPointer& normal_tex, LLPointer& mr_tex, LLPointer& emissive_tex); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f9c8f396a2..4e866658a6 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -415,7 +415,7 @@ void LLViewerObject::deleteTEImages() mTESpecularMaps = NULL; } - mGLTFAlbedoMaps.clear(); + mGLTFBaseColorMaps.clear(); mGLTFNormalMaps.clear(); mGLTFMetallicRoughnessMaps.clear(); mGLTFEmissiveMaps.clear(); @@ -4753,7 +4753,7 @@ void LLViewerObject::setNumTEs(const U8 num_tes) mTENormalMaps = new_normmaps; mTESpecularMaps = new_specmaps; - mGLTFAlbedoMaps.resize(num_tes); + mGLTFBaseColorMaps.resize(num_tes); mGLTFNormalMaps.resize(num_tes); mGLTFMetallicRoughnessMaps.resize(num_tes); mGLTFEmissiveMaps.resize(num_tes); @@ -4943,14 +4943,14 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) if (mat != nullptr) { - mGLTFAlbedoMaps[te] = fetch_texture(mat->mAlbedoId); + mGLTFBaseColorMaps[te] = fetch_texture(mat->mBaseColorId); mGLTFNormalMaps[te] = fetch_texture(mat->mNormalId); mGLTFMetallicRoughnessMaps[te] = fetch_texture(mat->mMetallicRoughnessId); mGLTFEmissiveMaps[te] = fetch_texture(mat->mEmissiveId); } else { - mGLTFAlbedoMaps[te] = nullptr; + mGLTFBaseColorMaps[te] = nullptr; mGLTFNormalMaps[te] = nullptr; mGLTFMetallicRoughnessMaps[te] = nullptr; mGLTFEmissiveMaps[te] = nullptr; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 32f03c7869..1bb67fa80f 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -371,7 +371,7 @@ public: LLViewerTexture *getTENormalMap(const U8 te) const; LLViewerTexture *getTESpecularMap(const U8 te) const; - LLViewerTexture* getGLTFAlbedoMap(U8 te) const { return mGLTFAlbedoMaps[te]; } + LLViewerTexture* getGLTFBaseColorMap(U8 te) const { return mGLTFBaseColorMaps[te]; } LLViewerTexture* getGLTFNormalMap(U8 te) const { return mGLTFNormalMaps[te]; } LLViewerTexture* getGLTFEmissiveMap(U8 te) const { return mGLTFEmissiveMaps[te]; } LLViewerTexture* getGLTFMetallicRoughnessMap(U8 te) const { return mGLTFMetallicRoughnessMaps[te]; } @@ -693,7 +693,7 @@ public: LLPointer *mTENormalMaps; LLPointer *mTESpecularMaps; - std::vector > mGLTFAlbedoMaps; + std::vector > mGLTFBaseColorMaps; std::vector > mGLTFNormalMaps; std::vector > mGLTFMetallicRoughnessMaps; std::vector > mGLTFEmissiveMaps; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index ad1711d3fb..d18997b780 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5520,13 +5520,13 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLViewerObject* vobj = facep->getViewerObject(); U8 te = facep->getTEOffset(); - draw_info->mTexture = vobj->getGLTFAlbedoMap(te); + draw_info->mTexture = vobj->getGLTFBaseColorMap(te); draw_info->mNormalMap = vobj->getGLTFNormalMap(te); draw_info->mSpecularMap = vobj->getGLTFMetallicRoughnessMap(te); draw_info->mEmissiveMap = vobj->getGLTFEmissiveMap(te); if (draw_info->mGLTFMaterial->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) { - draw_info->mAlphaMaskCutoff = gltf_mat->mAlphaCutoff * gltf_mat->mAlbedoColor.mV[3]; + draw_info->mAlphaMaskCutoff = gltf_mat->mAlphaCutoff * gltf_mat->mBaseColor.mV[3]; } else { diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml index eda28c5a4b..67cbb253d9 100644 --- a/indra/newview/skins/default/xui/en/floater_material_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -50,7 +50,7 @@ layout="topleft" left="1" mouse_opaque="false" - name="albedo_texture_pnl" + name="base_color_texture_pnl" top_pad="5" > - Albedo: + width="128"> + Base Color: No upload fee @@ -111,7 +111,7 @@ layout="topleft" left_delta="0" top_pad="5" - name="albedo color" + name="base color" width="40" /> Date: Wed, 5 Oct 2022 09:48:18 -0700 Subject: Initial pass at adding KHR_debug support This still needs some work - I'm not super satisfied with the overall structure of the code. Will continue to iterate as I add in proper RenderDoc support. --- indra/llcommon/llprofiler.h | 4 ++ indra/llrender/llglslshader.cpp | 11 +++ indra/llrender/llglslshader.h | 9 +++ indra/llrender/llvertexbuffer.cpp | 7 +- indra/llrender/llvertexbuffer.h | 9 +++ indra/newview/lldrawpool.h | 136 ++++++++++++++++++++++++++++++++++++++ indra/newview/llvovolume.cpp | 2 + 7 files changed, 177 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llcommon/llprofiler.h b/indra/llcommon/llprofiler.h index c0f5868db3..ac20209062 100644 --- a/indra/llcommon/llprofiler.h +++ b/indra/llcommon/llprofiler.h @@ -153,12 +153,16 @@ extern thread_local bool gProfilerEnabled; // disable memory tracking (incompatible with GPU tracing #define LL_PROFILE_ALLOC(ptr, size) (void)(ptr); (void)(size); #define LL_PROFILE_FREE(ptr) (void)(ptr); + +#define LL_LABEL_OBJECT_GL(type, name, length, label) glObjectLabel(type, name, length, label) #else #define LL_PROFILE_GPU_ZONE(name) (void)name; #define LL_PROFILE_GPU_ZONEC(name,color) (void)name;(void)color; #define LL_PROFILER_GPU_COLLECT #define LL_PROFILER_GPU_CONTEXT +#define LL_LABEL_OBJECT_GL(type, name, length, label) + #if LL_PROFILER_CONFIG > 1 #define LL_PROFILE_ALLOC(ptr, size) TracyAlloc(ptr, size) #define LL_PROFILE_FREE(ptr) TracyFree(ptr) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 55713eea80..f424a01541 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -504,6 +504,10 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, unbind(); } +#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + setLabel(mName); +#endif + return success; } @@ -1786,3 +1790,10 @@ void LLShaderUniforms::apply(LLGLSLShader* shader) shader->uniform3fv(uniform.mUniform, 1, uniform.mValue.mV); } } + +#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +void LLGLSLShader::setLabel(std::string label) { + LL_LABEL_OBJECT_GL(GL_PROGRAM, mProgramObject, label.length(), label.c_str()); +} + +#endif diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index c26ee014cb..01eca7ebfe 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -294,6 +294,10 @@ public: // this pointer should be set to whichever shader represents this shader's rigged variant LLGLSLShader* mRiggedVariant = nullptr; + #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + void setLabel(std::string label); + #endif + private: void unloadInternal(); }; @@ -305,5 +309,10 @@ extern LLGLSLShader gSolidColorProgram; //Alpha mask shader (declared here so llappearance can access properly) extern LLGLSLShader gAlphaMaskProgram; +#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#define LL_SET_SHADER_LABEL(shader) shader.setLabel(#shader) +#else +#define LL_SET_SHADER_LABEL(shader, label) +#endif #endif diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 981175d845..4ce04c17f6 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -175,7 +175,7 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) { //make a new buffer name = genBuffer(); - + glBindBuffer(mType, name); if (!for_seed && i < LL_VBO_POOL_SEED_COUNT) @@ -574,6 +574,10 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of } } +void LLVertexBuffer::setLabel(std::string label) { + LL_LABEL_OBJECT_GL(GL_BUFFER, mGLBuffer, label.length(), label.c_str()); +} + void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const { validateRange(start, end, count, indices_offset); @@ -1068,6 +1072,7 @@ bool LLVertexBuffer::createGLBuffer(U32 size) { static int gl_buffer_idx = 0; mGLBuffer = ++gl_buffer_idx; + mMappedData = (U8*)ll_aligned_malloc_16(size); mSize = size; } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index a7907f9cae..a7e5fddf8c 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -300,6 +300,9 @@ public: //for debugging, validate data in given range is valid void validateRange(U32 start, U32 end, U32 count, U32 offset) const; + #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + void setLabel(std::string label); + #endif protected: @@ -370,5 +373,11 @@ public: static U32 sSetCount; }; +#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#define LL_LABEL_VERTEX_BUFFER(buf, name) buf->setLabel(name) +#else +#define LL_LABEL_VERTEX_BUFFER(buf, name) +#endif + #endif // LL_LLVERTEXBUFFER_H diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index f7fc2d2061..e664208154 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -198,6 +198,142 @@ public: NUM_RENDER_TYPES, }; + #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + static std::string lookupPassName(U32 pass) + { + switch (pass) + { + case PASS_SIMPLE: + return "PASS_SIMPLE"; + case PASS_SIMPLE_RIGGED: + return "PASS_SIMPLE_RIGGED"; + case PASS_GRASS: + return "PASS_GRASS"; + case PASS_FULLBRIGHT: + return "PASS_FULLBRIGHT"; + case PASS_FULLBRIGHT_RIGGED: + return "PASS_FULLBRIGHT_RIGGED"; + case PASS_INVISIBLE: + return "PASS_INVISIBLE"; + case PASS_INVISIBLE_RIGGED: + return "PASS_INVISIBLE_RIGGED"; + case PASS_INVISI_SHINY: + return "PASS_INVISI_SHINY"; + case PASS_INVISI_SHINY_RIGGED: + return "PASS_INVISI_SHINY_RIGGED"; + case PASS_FULLBRIGHT_SHINY: + return "PASS_FULLBRIGHT_SHINY"; + case PASS_FULLBRIGHT_SHINY_RIGGED: + return "PASS_FULLBRIGHT_SHINY_RIGGED"; + case PASS_SHINY: + return "PASS_SHINY"; + case PASS_SHINY_RIGGED: + return "PASS_SHINY_RIGGED"; + case PASS_BUMP: + return "PASS_BUMP"; + case PASS_BUMP_RIGGED: + return "PASS_BUMP_RIGGED"; + case PASS_POST_BUMP: + return "PASS_POST_BUMP"; + case PASS_POST_BUMP_RIGGED: + return "PASS_POST_BUMP_RIGGED"; + case PASS_MATERIAL: + return "PASS_MATERIAL"; + case PASS_MATERIAL_RIGGED: + return "PASS_MATERIAL_RIGGED"; + case PASS_MATERIAL_ALPHA: + return "PASS_MATERIAL_ALPHA"; + case PASS_MATERIAL_ALPHA_RIGGED: + return "PASS_MATERIAL_ALPHA_RIGGED"; + case PASS_MATERIAL_ALPHA_MASK: + return "PASS_MATERIAL_ALPHA_MASK"; + case PASS_MATERIAL_ALPHA_MASK_RIGGED: + return "PASS_MATERIAL_ALPHA_MASK_RIGGED"; + case PASS_MATERIAL_ALPHA_EMISSIVE: + return "PASS_MATERIAL_ALPHA_EMISSIVE"; + case PASS_MATERIAL_ALPHA_EMISSIVE_RIGGED: + return "PASS_MATERIAL_ALPHA_EMISSIVE_RIGGED"; + case PASS_SPECMAP: + return "PASS_SPECMAP"; + case PASS_SPECMAP_RIGGED: + return "PASS_SPECMAP_RIGGED"; + case PASS_SPECMAP_BLEND: + return "PASS_SPECMAP_BLEND"; + case PASS_SPECMAP_BLEND_RIGGED: + return "PASS_SPECMAP_BLEND_RIGGED"; + case PASS_SPECMAP_MASK: + return "PASS_SPECMAP_MASK"; + case PASS_SPECMAP_MASK_RIGGED: + return "PASS_SPECMAP_MASK_RIGGED"; + case PASS_SPECMAP_EMISSIVE: + return "PASS_SPECMAP_EMISSIVE"; + case PASS_SPECMAP_EMISSIVE_RIGGED: + return "PASS_SPECMAP_EMISSIVE_RIGGED"; + case PASS_NORMMAP: + return "PASS_NORMAMAP"; + case PASS_NORMMAP_RIGGED: + return "PASS_NORMMAP_RIGGED"; + case PASS_NORMMAP_BLEND: + return "PASS_NORMMAP_BLEND"; + case PASS_NORMMAP_BLEND_RIGGED: + return "PASS_NORMMAP_BLEND_RIGGED"; + case PASS_NORMMAP_MASK: + return "PASS_NORMMAP_MASK"; + case PASS_NORMMAP_MASK_RIGGED: + return "PASS_NORMMAP_MASK_RIGGED"; + case PASS_NORMMAP_EMISSIVE: + return "PASS_NORMMAP_EMISSIVE"; + case PASS_NORMMAP_EMISSIVE_RIGGED: + return "PASS_NORMMAP_EMISSIVE_RIGGED"; + case PASS_NORMSPEC: + return "PASS_NORMSPEC"; + case PASS_NORMSPEC_RIGGED: + return "PASS_NORMSPEC_RIGGED"; + case PASS_NORMSPEC_BLEND: + return "PASS_NORMSPEC_BLEND"; + case PASS_NORMSPEC_BLEND_RIGGED: + return "PASS_NORMSPEC_BLEND_RIGGED"; + case PASS_NORMSPEC_MASK: + return "PASS_NORMSPEC_MASK"; + case PASS_NORMSPEC_MASK_RIGGED: + return "PASS_NORMSPEC_MASK_RIGGED"; + case PASS_NORMSPEC_EMISSIVE: + return "PASS_NORMSPEC_EMISSIVE"; + case PASS_NORMSPEC_EMISSIVE_RIGGED: + return "PASS_NORMSPEC_EMISSIVE_RIGGED"; + case PASS_GLOW: + return "PASS_GLOW"; + case PASS_GLOW_RIGGED: + return "PASS_GLOW_RIGGED"; + case PASS_ALPHA: + return "PASS_ALPHA"; + case PASS_ALPHA_RIGGED: + return "PASS_ALPHA_RIGGED"; + case PASS_ALPHA_MASK: + return "PASS_ALPHA_MASK"; + case PASS_ALPHA_MASK_RIGGED: + return "PASS_ALPHA_MASK_RIGGED"; + case PASS_FULLBRIGHT_ALPHA_MASK: + return "PASS_FULLBRIGHT_ALPHA_MASK"; + case PASS_FULLBRIGHT_ALPHA_MASK_RIGGED: + return "PASS_FULLBRIGHT_ALPHA_MASK_RIGGED"; + case PASS_ALPHA_INVISIBLE: + return "PASS_ALPHA_INVISIBLE"; + case PASS_ALPHA_INVISIBLE_RIGGED: + return "PASS_ALPHA_INVISIBLE_RIGGED"; + case PASS_PBR_OPAQUE: + return "PASS_PBR_OPAQUE"; + case PASS_PBR_OPAQUE_RIGGED: + return "PASS_PBR_OPAQUE_RIGGED"; + + default: + return "Unknown pass"; + } + } + #else + static std::string lookupPass(U32 pass) { return ""; } + #endif + LLRenderPass(const U32 type); virtual ~LLRenderPass(); /*virtual*/ LLViewerTexture* getDebugTexture() { return NULL; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index d18997b780..d312bb75d1 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5319,6 +5319,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, return; } + LL_LABEL_VERTEX_BUFFER(facep->getVertexBuffer(), LLRenderPass::lookupPassName(type)); + U32 passType = type; bool rigged = facep->isState(LLFace::RIGGED); -- cgit v1.3 From 07bca31e06e4219401f82ae04539418c65e22ea8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 10 Oct 2022 18:53:43 -0500 Subject: SL-18190 Fix alpha not playing nice with water surface by split LLDrawPoolAlpha into two passes, one above water, one below water, and clip against water plane. Currently brute forces two complete alpha passes, still need to cull against water plane and add support for fullbright shaders. --- .../shaders/class1/deferred/deferredUtil.glsl | 25 ++++++ .../shaders/class2/deferred/alphaF.glsl | 4 + .../shaders/class2/deferred/pbralphaF.glsl | 3 + .../shaders/class3/deferred/materialF.glsl | 6 +- indra/newview/lldrawable.cpp | 2 +- indra/newview/lldrawpool.cpp | 7 +- indra/newview/lldrawpool.h | 25 +++--- indra/newview/lldrawpoolalpha.cpp | 36 +++++++-- indra/newview/lldrawpoolalpha.h | 15 ++-- indra/newview/llface.cpp | 9 ++- indra/newview/llface.h | 2 + indra/newview/llsettingsvo.cpp | 2 + indra/newview/llviewerdisplay.cpp | 2 + indra/newview/llviewershadermgr.cpp | 1 + indra/newview/llvovolume.cpp | 4 +- indra/newview/pipeline.cpp | 92 +++++++++------------- indra/newview/pipeline.h | 35 ++++---- 17 files changed, 168 insertions(+), 102 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 2ec859fdae..9405a125fd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -505,3 +505,28 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, return color; } + +uniform vec4 waterPlane; +uniform float waterSign; + +// discard if given position in eye space is on the wrong side of the waterPlane according to waterSign +void waterClip(vec3 pos) +{ + // TODO: make this less branchy + if (waterSign > 0) + { + if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) < -0.1) + { + discard; + } + } + else + { + if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) > -0.1) + { + discard; + } + } + +} + diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index b4406aabc0..b3f15f81f1 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -69,6 +69,8 @@ uniform vec3 light_direction[8]; uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; +void waterClip(vec3 pos); + #ifdef WATER_FOG vec4 applyWaterFogView(vec3 pos, vec4 color); #endif @@ -181,6 +183,7 @@ void main() frag *= screen_res; vec4 pos = vec4(vary_position, 1.0); + waterClip(pos.xyz); vec3 norm = vary_norm; float shadow = 1.0f; @@ -295,6 +298,7 @@ void main() #endif // #else // FOR_IMPOSTOR + //color.rgb = waterPlane.xyz * 0.5 + 0.5; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index 9bbc4f87bf..922da0c441 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -84,6 +84,8 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness); +void waterClip(vec3 pos); + // PBR interface vec3 pbrIbl(vec3 diffuseColor, vec3 specularColor, @@ -139,6 +141,7 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; vec3 pos = vary_position; + waterClip(pos); // IF .mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; // vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 1150d40007..8016022d78 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -90,6 +90,7 @@ uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; float getAmbientClamp(); +void waterClip(vec3 pos); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { @@ -219,6 +220,10 @@ vec2 encode_normal(vec3 n); void main() { +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + waterClip(vary_position.xyz); +#endif + vec2 pos_screen = vary_texcoord0.xy; vec4 diffcol = texture2D(diffuseMap, vary_texcoord0.xy); @@ -277,7 +282,6 @@ void main() #endif #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - //forward rendering, output lit linear color diffcol.rgb = srgb_to_linear(diffcol.rgb); final_specular.rgb = srgb_to_linear(final_specular.rgb); diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 70bc603a42..74625423fe 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -882,7 +882,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) { LLFace* facep = getFace(i); if (facep && - (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA)) + (force_update || facep->isInAlphaPool())) { LLVector4a box; box.setSub(facep->mExtents[1], facep->mExtents[0]); diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 015e520179..7305177e4a 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -86,9 +86,12 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerTexture *tex0) case POOL_GLOW: poolp = new LLDrawPoolGlow(); break; - case POOL_ALPHA: - poolp = new LLDrawPoolAlpha(); + case POOL_ALPHA_PRE_WATER: + poolp = new LLDrawPoolAlpha(LLDrawPool::POOL_ALPHA_PRE_WATER); break; + case POOL_ALPHA_POST_WATER: + poolp = new LLDrawPoolAlpha(LLDrawPool::POOL_ALPHA_POST_WATER); + break; case POOL_AVATAR: case POOL_CONTROL_AV: poolp = new LLDrawPoolAvatar(type); diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 2b7ace7ae5..620438bb1b 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -49,29 +49,32 @@ public: { // Correspond to LLPipeline render type // Also controls render order, so passes that don't use alpha masking/blending should come before - // other passes and occlusion culling should happen just before rendering alpha masked passes - // in order to take advantage of hierarchical Z - // NOTE: Keep in sync with gPoolNames + // other passes to preserve hierarchical Z for occlusion queries. Occlusion queries happen just + // before grass, so grass should be the first alpha masked pool. Other ordering should be done + // based on fill rate and likelihood to occlude future passes (faster, large occluders first). + // POOL_SIMPLE = 1, POOL_GROUND, POOL_FULLBRIGHT, POOL_BUMP, - POOL_MATERIALS, - POOL_TERRAIN, - POOL_SKY, - POOL_WL_SKY, + POOL_TERRAIN, + POOL_MATERIALS, + POOL_GRASS, POOL_TREE, POOL_ALPHA_MASK, POOL_FULLBRIGHT_ALPHA_MASK, - POOL_GRASS, + POOL_SKY, + POOL_WL_SKY, POOL_INVISIBLE, // see below * POOL_AVATAR, POOL_CONTROL_AV, // Animesh - POOL_VOIDWATER, - POOL_WATER, POOL_GLOW, - POOL_ALPHA, + POOL_ALPHA_PRE_WATER, + POOL_VOIDWATER, + POOL_WATER, + POOL_ALPHA_POST_WATER, POOL_PBR_OPAQUE, + POOL_ALPHA, // note there is no actual "POOL_ALPHA" but pre-water and post-water pools consume POOL_ALPHA faces NUM_POOL_TYPES, // * invisiprims work by rendering to the depth buffer but not the color buffer, occluding anything rendered after them // - and the LLDrawPool types enum controls what order things are rendered in diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 8a912b00d9..0d9e83a976 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -56,6 +56,8 @@ BOOL LLDrawPoolAlpha::sShowDebugAlpha = FALSE; #define current_shader (LLGLSLShader::sCurBoundShaderPtr) +LLVector4 LLDrawPoolAlpha::sWaterPlane; + static BOOL deferred_render = FALSE; // minimum alpha before discarding a fragment @@ -96,11 +98,13 @@ S32 LLDrawPoolAlpha::getNumPostDeferredPasses() } // set some common parameters on the given shader to prepare for alpha rendering -static void prepare_alpha_shader(LLGLSLShader* shader, bool textureGamma, bool deferredEnvironment) +static void prepare_alpha_shader(LLGLSLShader* shader, bool textureGamma, bool deferredEnvironment, F32 water_sign) { static LLCachedControl displayGamma(gSavedSettings, "RenderDeferredDisplayGamma"); F32 gamma = displayGamma; + static LLStaticHashedString waterSign("waterSign"); + // Does this deferred shader need environment uniforms set such as sun_dir, etc. ? // NOTE: We don't actually need a gbuffer since we are doing forward rendering (for transparency) post deferred rendering // TODO: bindDeferredShader() probably should have the updating of the environment uniforms factored out into updateShaderEnvironmentUniforms() @@ -115,6 +119,8 @@ static void prepare_alpha_shader(LLGLSLShader* shader, bool textureGamma, bool d } shader->uniform1i(LLShaderMgr::NO_ATMO, (LLPipeline::sRenderingHUDs) ? 1 : 0); shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); + shader->uniform1f(waterSign, water_sign); + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); if (LLPipeline::sImpostorRender) { @@ -132,7 +138,7 @@ static void prepare_alpha_shader(LLGLSLShader* shader, bool textureGamma, bool d //also prepare rigged variant if (shader->mRiggedVariant && shader->mRiggedVariant != shader) { - prepare_alpha_shader(shader->mRiggedVariant, textureGamma, deferredEnvironment); + prepare_alpha_shader(shader->mRiggedVariant, textureGamma, deferredEnvironment, water_sign); } } @@ -143,19 +149,39 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; deferred_render = TRUE; + F32 water_sign = 1.f; + + if (getType() == LLDrawPool::POOL_ALPHA_PRE_WATER) + { + water_sign = -1.f; + } + + if (LLPipeline::sUnderWaterRender) + { + water_sign *= -1.f; + } + // prepare shaders emissive_shader = (LLPipeline::sRenderDeferred) ? &gDeferredEmissiveProgram : (LLPipeline::sUnderWaterRender) ? &gObjectEmissiveWaterProgram : &gObjectEmissiveProgram; - prepare_alpha_shader(emissive_shader, true, false); + prepare_alpha_shader(emissive_shader, true, false, water_sign); fullbright_shader = (LLPipeline::sImpostorRender) ? &gDeferredFullbrightAlphaMaskProgram : (LLPipeline::sUnderWaterRender) ? &gDeferredFullbrightWaterProgram : &gDeferredFullbrightAlphaMaskProgram; - prepare_alpha_shader(fullbright_shader, true, true); + prepare_alpha_shader(fullbright_shader, true, true, water_sign); simple_shader = (LLPipeline::sImpostorRender) ? &gDeferredAlphaImpostorProgram : (LLPipeline::sUnderWaterRender) ? &gDeferredAlphaWaterProgram : &gDeferredAlphaProgram; - prepare_alpha_shader(simple_shader, false, true); //prime simple shader (loads shadow relevant uniforms) + prepare_alpha_shader(simple_shader, false, true, water_sign); //prime simple shader (loads shadow relevant uniforms) + + + LLGLSLShader* materialShader = LLPipeline::sUnderWaterRender ? gDeferredMaterialWaterProgram : gDeferredMaterialProgram; + for (int i = 0; i < LLMaterial::SHADER_COUNT*2; ++i) + { + prepare_alpha_shader(&materialShader[i], false, false, water_sign); + } + prepare_alpha_shader(&gDeferredPBRAlphaProgram, false, false, water_sign); // first pass, render rigged objects only and render to depth buffer forwardRender(true); diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h index fa8ef0f227..2c1ec30958 100644 --- a/indra/newview/lldrawpoolalpha.h +++ b/indra/newview/lldrawpoolalpha.h @@ -35,9 +35,13 @@ class LLFace; class LLColor4; class LLGLSLShader; -class LLDrawPoolAlpha: public LLRenderPass +class LLDrawPoolAlpha final: public LLRenderPass { public: + + // set by llsettingsvo so lldrawpoolalpha has quick access to the water plane in eye space + static LLVector4 sWaterPlane; + enum { VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | @@ -47,7 +51,7 @@ public: }; virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } - LLDrawPoolAlpha(U32 type = LLDrawPool::POOL_ALPHA); + LLDrawPoolAlpha(U32 type); /*virtual*/ ~LLDrawPoolAlpha(); /*virtual*/ S32 getNumPostDeferredPasses(); @@ -91,11 +95,4 @@ private: bool mRigged = false; }; -class LLDrawPoolAlphaPostWater : public LLDrawPoolAlpha -{ -public: - LLDrawPoolAlphaPostWater(); - virtual void render(S32 pass = 0); -}; - #endif // LL_LLDRAWPOOLALPHA_H diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 431a9ebb29..4ae8335ca7 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1342,7 +1342,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_color) { //decide if shiny goes in alpha channel of color if (tep && - getPoolType() != LLDrawPool::POOL_ALPHA) // <--- alpha channel MUST contain transparency, not shiny + !isInAlphaPool()) // <--- alpha channel MUST contain transparency, not shiny { LLMaterial* mat = tep->getMaterialParams().get(); @@ -2601,3 +2601,10 @@ U64 LLFace::getSkinHash() { return mSkinInfo ? mSkinInfo->mHash : 0; } + +bool LLFace::isInAlphaPool() const +{ + return getPoolType() == LLDrawPool::POOL_ALPHA || + getPoolType() == LLDrawPool::POOL_ALPHA_PRE_WATER || + getPoolType() == LLDrawPool::POOL_ALPHA_POST_WATER; +} diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 4778a8110b..a5ea460061 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -237,6 +237,8 @@ public: void setDrawOrderIndex(U32 index) { mDrawOrderIndex = index; } U32 getDrawOrderIndex() const { return mDrawOrderIndex; } + // return true if this face is in an alpha draw pool + bool isInAlphaPool() const; public: //aligned members LLVector4a mExtents[2]; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6cd4c973d9..fdd988ddc0 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -949,6 +949,8 @@ void LLSettingsVOWater::applySpecial(void *ptarget, bool force) LLVector4 waterPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + LLDrawPoolAlpha::sWaterPlane = waterPlane; + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, waterPlane.mV); LLVector4 light_direction = env.getClampedLightNorm(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 112d669740..b3bc831670 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1221,6 +1221,8 @@ void render_hud_attachments() gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_SIMPLE); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_VOLUME); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA); + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA_PRE_WATER); + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA_POST_WATER); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA_MASK); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_FULLBRIGHT); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index d4c93eec06..e7dbdf2bea 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1924,6 +1924,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->mFeatures.hasTransport = true; shader->mFeatures.hasShadows = use_sun_shadow; shader->mFeatures.hasReflectionProbes = true; + shader->mFeatures.hasWaterFog = true; if (mShaderLevel[SHADER_DEFERRED] < 1) { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index d312bb75d1..bbe6814ce1 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4212,7 +4212,7 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const } } - if (face->getPoolType() == LLDrawPool::POOL_ALPHA) + if (face->isInAlphaPool()) { alpha = 1; } @@ -4576,7 +4576,7 @@ F32 LLVOVolume::getBinRadius() { LLFace* face = mDrawable->getFace(i); if (!face) continue; - if (face->getPoolType() == LLDrawPool::POOL_ALPHA && + if (face->isInAlphaPool() && !face->canRenderAsMask()) { alpha_wrap = TRUE; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 87a5cd9cc8..2f4ab3ac45 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -281,33 +281,6 @@ static LLStaticHashedString sKern("kern"); static LLStaticHashedString sKernScale("kern_scale"); //---------------------------------------- -#if 0 -std::string gPoolNames[LLDrawPool::NUM_POOL_TYPES] = -{ - // Correspond to LLDrawpool enum render type - "NONE" - , "POOL_SIMPLE" - , "POOL_GROUND" - , "POOL_FULLBRIGHT" - , "POOL_BUMP" - , "POOL_MATERIALS" - , "POOL_TERRAIN" - , "POOL_SKY" - , "POOL_WL_SKY" - , "POOL_TREE" - , "POOL_ALPHA_MASK" - , "POOL_FULLBRIGHT_ALPHA_MASK" - , "POOL_GRASS" - , "POOL_INVISIBLE" - , "POOL_AVATAR" - , "POOL_CONTROL_AV" // Animesh - , "POOL_VOIDWATER" - , "POOL_WATER" - , "POOL_GLOW" - , "POOL_ALPHA" - , "POOL_PBR_OPAQUE" -}; -#endif void drawBox(const LLVector4a& c, const LLVector4a& r); void drawBoxOutline(const LLVector3& pos, const LLVector3& size); @@ -397,21 +370,6 @@ LLPipeline::LLPipeline() : mGroupQ2Locked(false), mResetVertexBuffers(false), mLastRebuildPool(NULL), - mAlphaPool(NULL), - mSkyPool(NULL), - mTerrainPool(NULL), - mWaterPool(NULL), - mGroundPool(NULL), - mSimplePool(NULL), - mGrassPool(NULL), - mAlphaMaskPool(NULL), - mFullbrightAlphaMaskPool(NULL), - mFullbrightPool(NULL), - mInvisiblePool(NULL), - mGlowPool(NULL), - mBumpPool(NULL), - mMaterialsPool(NULL), - mWLSkyPool(NULL), mLightMask(0), mLightMovingMask(0), mLightingDetail(0) @@ -463,7 +421,8 @@ void LLPipeline::init() LL_WARNS() << "No GL errors yet. Pipeline initialization will continue." << LL_ENDL; // TODO: Remove after testing //create render pass pools - getPool(LLDrawPool::POOL_ALPHA); + getPool(LLDrawPool::POOL_ALPHA_PRE_WATER); + getPool(LLDrawPool::POOL_ALPHA_POST_WATER); getPool(LLDrawPool::POOL_SIMPLE); getPool(LLDrawPool::POOL_ALPHA_MASK); getPool(LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK); @@ -671,8 +630,10 @@ void LLPipeline::cleanup() LL_WARNS() << "Tree Pools not cleaned up" << LL_ENDL; } - delete mAlphaPool; - mAlphaPool = NULL; + delete mAlphaPoolPreWater; + mAlphaPoolPreWater = nullptr; + delete mAlphaPoolPostWater; + mAlphaPoolPostWater = nullptr; delete mSkyPool; mSkyPool = NULL; delete mTerrainPool; @@ -1589,9 +1550,12 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) case LLDrawPool::POOL_MATERIALS: poolp = mMaterialsPool; break; - case LLDrawPool::POOL_ALPHA: - poolp = mAlphaPool; + case LLDrawPool::POOL_ALPHA_PRE_WATER: + poolp = mAlphaPoolPreWater; break; + case LLDrawPool::POOL_ALPHA_POST_WATER: + poolp = mAlphaPoolPostWater; + break; case LLDrawPool::POOL_AVATAR: case LLDrawPool::POOL_CONTROL_AV: @@ -5733,17 +5697,28 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) mMaterialsPool = new_poolp; } break; - case LLDrawPool::POOL_ALPHA: - if( mAlphaPool ) + case LLDrawPool::POOL_ALPHA_PRE_WATER: + if( mAlphaPoolPreWater ) { llassert(0); - LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Alpha pool" << LL_ENDL; + LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Alpha pre-water pool" << LL_ENDL; } else { - mAlphaPool = (LLDrawPoolAlpha*) new_poolp; + mAlphaPoolPreWater = (LLDrawPoolAlpha*) new_poolp; } break; + case LLDrawPool::POOL_ALPHA_POST_WATER: + if (mAlphaPoolPostWater) + { + llassert(0); + LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Alpha post-water pool" << LL_ENDL; + } + else + { + mAlphaPoolPostWater = (LLDrawPoolAlpha*)new_poolp; + } + break; case LLDrawPool::POOL_AVATAR: case LLDrawPool::POOL_CONTROL_AV: @@ -5901,10 +5876,15 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mMaterialsPool = NULL; break; - case LLDrawPool::POOL_ALPHA: - llassert( poolp == mAlphaPool ); - mAlphaPool = NULL; + case LLDrawPool::POOL_ALPHA_PRE_WATER: + llassert( poolp == mAlphaPoolPreWater ); + mAlphaPoolPreWater = nullptr; break; + + case LLDrawPool::POOL_ALPHA_POST_WATER: + llassert(poolp == mAlphaPoolPostWater); + mAlphaPoolPostWater = nullptr; + break; case LLDrawPool::POOL_AVATAR: case LLDrawPool::POOL_CONTROL_AV: @@ -9078,6 +9058,8 @@ void LLPipeline::renderDeferredLighting() pushRenderTypeMask(); andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_ALPHA_PRE_WATER, + LLPipeline::RENDER_TYPE_ALPHA_POST_WATER, LLPipeline::RENDER_TYPE_FULLBRIGHT, LLPipeline::RENDER_TYPE_VOLUME, LLPipeline::RENDER_TYPE_GLOW, @@ -10296,6 +10278,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) pushRenderTypeMask(); andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE, LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_ALPHA_PRE_WATER, + LLPipeline::RENDER_TYPE_ALPHA_POST_WATER, LLPipeline::RENDER_TYPE_GRASS, LLPipeline::RENDER_TYPE_FULLBRIGHT, LLPipeline::RENDER_TYPE_BUMP, diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 23ddfb51e5..2c9b264fe6 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -477,6 +477,8 @@ public: RENDER_TYPE_VOIDWATER = LLDrawPool::POOL_VOIDWATER, RENDER_TYPE_WATER = LLDrawPool::POOL_WATER, RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA, + RENDER_TYPE_ALPHA_PRE_WATER = LLDrawPool::POOL_ALPHA_PRE_WATER, + RENDER_TYPE_ALPHA_POST_WATER = LLDrawPool::POOL_ALPHA_POST_WATER, RENDER_TYPE_GLOW = LLDrawPool::POOL_GLOW, RENDER_TYPE_PASS_SIMPLE = LLRenderPass::PASS_SIMPLE, RENDER_TYPE_PASS_SIMPLE_RIGGED = LLRenderPass::PASS_SIMPLE_RIGGED, @@ -890,22 +892,23 @@ protected: // For quick-lookups into mPools (mapped by texture pointer) std::map mTerrainPools; std::map mTreePools; - LLDrawPoolAlpha* mAlphaPool; - LLDrawPool* mSkyPool; - LLDrawPool* mTerrainPool; - LLDrawPool* mWaterPool; - LLDrawPool* mGroundPool; - LLRenderPass* mSimplePool; - LLRenderPass* mGrassPool; - LLRenderPass* mAlphaMaskPool; - LLRenderPass* mFullbrightAlphaMaskPool; - LLRenderPass* mFullbrightPool; - LLDrawPool* mInvisiblePool; - LLDrawPool* mGlowPool; - LLDrawPool* mBumpPool; - LLDrawPool* mMaterialsPool; - LLDrawPool* mWLSkyPool; - LLDrawPool* mPBROpaquePool; + LLDrawPoolAlpha* mAlphaPoolPreWater = nullptr; + LLDrawPoolAlpha* mAlphaPoolPostWater = nullptr; + LLDrawPool* mSkyPool = nullptr; + LLDrawPool* mTerrainPool = nullptr; + LLDrawPool* mWaterPool = nullptr; + LLDrawPool* mGroundPool = nullptr; + LLRenderPass* mSimplePool = nullptr; + LLRenderPass* mGrassPool = nullptr; + LLRenderPass* mAlphaMaskPool = nullptr; + LLRenderPass* mFullbrightAlphaMaskPool = nullptr; + LLRenderPass* mFullbrightPool = nullptr; + LLDrawPool* mInvisiblePool = nullptr; + LLDrawPool* mGlowPool = nullptr; + LLDrawPool* mBumpPool = nullptr; + LLDrawPool* mMaterialsPool = nullptr; + LLDrawPool* mWLSkyPool = nullptr; + LLDrawPool* mPBROpaquePool = nullptr; // Note: no need to keep an quick-lookup to avatar pools, since there's only one per avatar public: -- cgit v1.3 From c06fd0d753985297105e4656b7e2c39d155ba2b5 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 13 Oct 2022 10:07:09 -0500 Subject: SL-18367 Fix for some objects rendering purple -- globally set number of indexed texture channels instead of allowing it to vary from one shader to the next. --- indra/newview/llviewershadermgr.cpp | 47 +++++++------------------------------ indra/newview/llvovolume.cpp | 6 +---- 2 files changed, 9 insertions(+), 44 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 718ed9e666..a70c94ab89 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -440,16 +440,9 @@ void LLViewerShaderMgr::setShaders() } static LLCachedControl max_texture_index(gSavedSettings, "RenderMaxTextureIndex", 16); - LLGLSLShader::sIndexedTextureChannels = llmax(llmin(gGLManager.mNumTextureImageUnits, (S32) max_texture_index), 1); - - //NEVER use more than 16 texture channels (work around for prevalent driver bug) - LLGLSLShader::sIndexedTextureChannels = llmin(LLGLSLShader::sIndexedTextureChannels, 16); - - if (gGLManager.mGLSLVersionMajor < 1 || - (gGLManager.mGLSLVersionMajor == 1 && gGLManager.mGLSLVersionMinor <= 20)) - { //NEVER use indexed texture rendering when GLSL version is 1.20 or earlier - LLGLSLShader::sIndexedTextureChannels = 1; - } + + // when using indexed texture rendering, leave 8 texture units available for shadow and reflection maps + LLGLSLShader::sIndexedTextureChannels = llmax(llmin(gGLManager.mNumTextureImageUnits-8, (S32) max_texture_index), 1); reentrance = true; @@ -899,7 +892,7 @@ std::string LLViewerShaderMgr::loadBasicShaders() if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30) { //use indexed texture rendering for GLSL >= 1.30 - ch = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); + ch = llmax(LLGLSLShader::sIndexedTextureChannels, 1); } bool has_reflection_probes = gSavedSettings.getS32("RenderReflectionProbeDetail") >= 0 && gGLManager.mGLVersion > 3.99f; @@ -1939,15 +1932,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->mFeatures.hasShadows = use_sun_shadow; shader->mFeatures.hasReflectionProbes = true; shader->mFeatures.hasWaterFog = true; - - if (mShaderLevel[SHADER_DEFERRED] < 1) - { - shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - } - else - { //shave off some texture units for shadow maps - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); - } + shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; shader->mShaderFiles.clear(); shader->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER)); @@ -2016,15 +2001,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->mFeatures.encodesNormal = true; shader->mFeatures.hasShadows = use_sun_shadow; shader->mFeatures.hasReflectionProbes = true; - - if (mShaderLevel[SHADER_DEFERRED] < 1) - { - shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - } - else - { //shave off some texture units for shadow maps - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); - } + shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; shader->mShaderFiles.clear(); shader->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER)); @@ -2088,15 +2065,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader[i]->mFeatures.hasTransport = true; shader[i]->mFeatures.hasShadows = use_sun_shadow; shader[i]->mFeatures.hasReflectionProbes = true; - - if (mShaderLevel[SHADER_DEFERRED] < 1) - { - shader[i]->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - } - else - { //shave off some texture units for shadow maps - shader[i]->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); - } + shader[i]->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; shader[i]->mShaderGroup = LLGLSLShader::SG_WATER; shader[i]->mShaderFiles.clear(); shader[i]->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER)); @@ -2250,7 +2219,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightShinyProgram.mFeatures.hasGamma = true; gDeferredFullbrightShinyProgram.mFeatures.hasTransport = true; gDeferredFullbrightShinyProgram.mFeatures.hasSrgb = true; - gDeferredFullbrightShinyProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels-2; + gDeferredFullbrightShinyProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightShinyProgram.mShaderFiles.clear(); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyV.glsl", GL_VERTEX_SHADER)); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER)); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index bbe6814ce1..2a06331b63 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6464,11 +6464,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace buffer_index = -1; } - static LLCachedControl max_texture_index(gSavedSettings, "RenderMaxTextureIndex", 16); - texture_index_channels = llmin(texture_index_channels, (S32) max_texture_index); - - //NEVER use more than 16 texture index channels (workaround for prevalent driver bug) - texture_index_channels = llmin(texture_index_channels, 16); + texture_index_channels = LLGLSLShader::sIndexedTextureChannels; bool flexi = false; -- cgit v1.3 From de4c018499ddaebbe466fb5a8938554a2d4a3b19 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 19 Oct 2022 14:41:17 -0500 Subject: SL-18105 Hook up render pipe directly to LLTextureEntry::mGLTFMaterial and add LLViewerFetchedTextures to LLFetchedGLTFMaterial. Lower reflection probe resolution to 128x128 per side. --- indra/llprimitive/llgltfmaterial.cpp | 187 +++++++++++++++++++-- indra/llprimitive/llgltfmaterial.h | 71 ++++++-- indra/llprimitive/lltextureentry.h | 22 ++- indra/newview/app_settings/logcontrol.xml | 1 + .../shaders/class1/interface/irradianceGenF.glsl | 2 +- .../shaders/class1/interface/radianceGenF.glsl | 4 +- .../shaders/class3/deferred/reflectionProbeF.glsl | 2 +- indra/newview/featuretable.txt | 4 +- indra/newview/lldrawpoolalpha.cpp | 40 +---- indra/newview/lldrawpoolpbropaque.cpp | 55 +----- indra/newview/llfetchedgltfmaterial.cpp | 61 +++++++ indra/newview/llfetchedgltfmaterial.h | 14 +- indra/newview/llreflectionmapmanager.h | 2 +- indra/newview/llspatialpartition.h | 8 +- indra/newview/llviewerobject.cpp | 57 +++---- indra/newview/llviewerobject.h | 13 -- indra/newview/llvovolume.cpp | 18 +- indra/newview/pipeline.cpp | 23 ++- 18 files changed, 378 insertions(+), 206 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index 951b768678..19081cd76f 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -28,12 +28,44 @@ #include "llgltfmaterial.h" -#include "tiny_gltf.h" +#include "tinygltf/tiny_gltf.h" + +LLGLTFMaterial::LLGLTFMaterial(const LLGLTFMaterial& rhs) +{ + *this = rhs; +} + +LLGLTFMaterial& LLGLTFMaterial::operator=(const LLGLTFMaterial& rhs) +{ + //have to do a manual operator= because of LLRefCount + mBaseColorId = rhs.mBaseColorId; + mNormalId = rhs.mNormalId; + mMetallicRoughnessId = rhs.mMetallicRoughnessId; + mEmissiveId = rhs.mEmissiveId; + + mBaseColor = rhs.mBaseColor; + mEmissiveColor = rhs.mEmissiveColor; + + mMetallicFactor = rhs.mMetallicFactor; + mRoughnessFactor = rhs.mRoughnessFactor; + mAlphaCutoff = rhs.mAlphaCutoff; + + mDoubleSided = rhs.mDoubleSided; + mAlphaMode = rhs.mAlphaMode; + + for (S32 i = 0; i < 3; ++i) + { + mTextureTransform[i] = rhs.mTextureTransform[i]; + } + + return *this; +} bool LLGLTFMaterial::fromJSON(const std::string& json, std::string& warn_msg, std::string& error_msg) { +#if 1 tinygltf::TinyGLTF gltf; - + tinygltf::Model model_in; if (gltf.LoadASCIIFromString(&model_in, &error_msg, &warn_msg, json.c_str(), json.length(), "")) @@ -45,12 +77,13 @@ bool LLGLTFMaterial::fromJSON(const std::string& json, std::string& warn_msg, st return true; } - +#endif return false; } std::string LLGLTFMaterial::asJSON(bool prettyprint) const { +#if 1 tinygltf::TinyGLTF gltf; tinygltf::Model model_out; @@ -61,6 +94,9 @@ std::string LLGLTFMaterial::asJSON(bool prettyprint) const gltf.WriteGltfSceneToStream(&model_out, str, prettyprint, false); return str.str(); +#else + return ""; +#endif } void LLGLTFMaterial::setFromModel(const tinygltf::Model& model, S32 mat_index) @@ -130,7 +166,7 @@ void LLGLTFMaterial::setFromModel(const tinygltf::Model& model, S32 mat_index) void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const { - if (model.materials.size() < mat_index+1) + if (model.materials.size() < mat_index + 1) { model.materials.resize(mat_index + 1); } @@ -143,7 +179,7 @@ void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const U32 idx = model.images.size(); model.images.resize(idx + 1); model.textures.resize(idx + 1); - + material_out.pbrMetallicRoughness.baseColorTexture.index = idx; model.textures[idx].source = idx; model.images[idx].uri = mBaseColorId.asString(); @@ -160,7 +196,7 @@ void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const model.textures[idx].source = idx; model.images[idx].uri = mNormalId.asString(); } - + // set metallic-roughness texture if (mMetallicRoughnessId.notNull()) { @@ -187,7 +223,7 @@ void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const material_out.alphaMode = getAlphaMode(); material_out.alphaCutoff = mAlphaCutoff; - + mBaseColor.write(material_out.pbrMetallicRoughness.baseColorFactor); mEmissiveColor.write(material_out.emissiveFactor); @@ -195,11 +231,130 @@ void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const material_out.pbrMetallicRoughness.roughnessFactor = mRoughnessFactor; material_out.doubleSided = mDoubleSided; + + model.asset.version = "2.0"; +} + + +void LLGLTFMaterial::setBaseColorId(const LLUUID& id) +{ + mBaseColorId = id; +} + +void LLGLTFMaterial::setNormalId(const LLUUID& id) +{ + mNormalId = id; +} + +void LLGLTFMaterial::setMetallicRoughnessId(const LLUUID& id) +{ + mMetallicRoughnessId = id; +} + +void LLGLTFMaterial::setEmissiveId(const LLUUID& id) +{ + mEmissiveId = id; +} + +void LLGLTFMaterial::setBaseColorFactor(const LLColor3& baseColor, F32 transparency) +{ + mBaseColor.set(baseColor, transparency); + mBaseColor.clamp(); +} + +void LLGLTFMaterial::setAlphaCutoff(F32 cutoff) +{ + mAlphaCutoff = llclamp(cutoff, 0.f, 1.f); +} + +void LLGLTFMaterial::setEmissiveColorFactor(const LLColor3& emissiveColor) +{ + mEmissiveColor = emissiveColor; + mEmissiveColor.clamp(); +} + +void LLGLTFMaterial::setMetallicFactor(F32 metallic) +{ + mMetallicFactor = llclamp(metallic, 0.f, 1.f); +} + +void LLGLTFMaterial::setRoughnessFactor(F32 roughness) +{ + mRoughnessFactor = llclamp(roughness, 0.f, 1.f); +} + +void LLGLTFMaterial::setAlphaMode(S32 mode) +{ + mAlphaMode = (AlphaMode)llclamp(mode, (S32)ALPHA_MODE_OPAQUE, (S32)ALPHA_MODE_MASK); +} + +void LLGLTFMaterial::setDoubleSided(bool double_sided) +{ + // sure, no clamping will ever be needed for a bool, but include the + // setter for consistency with the clamping API + mDoubleSided = double_sided; +} + +// Default value accessors + +LLUUID LLGLTFMaterial::getDefaultBaseColorId() +{ + return LLUUID::null; +} + +LLUUID LLGLTFMaterial::getDefaultNormalId() +{ + return LLUUID::null; +} + +LLUUID LLGLTFMaterial::getDefaultEmissiveId() +{ + return LLUUID::null; +} + +LLUUID LLGLTFMaterial::getDefaultMetallicRoughnessId() +{ + return LLUUID::null; +} + +F32 LLGLTFMaterial::getDefaultAlphaCutoff() +{ + return 0.f; +} + +S32 LLGLTFMaterial::getDefaultAlphaMode() +{ + return (S32)ALPHA_MODE_OPAQUE; +} + +F32 LLGLTFMaterial::getDefaultMetallicFactor() +{ + return 0.f; +} + +F32 LLGLTFMaterial::getDefaultRoughnessFactor() +{ + return 0.f; +} + +LLColor4 LLGLTFMaterial::getDefaultBaseColor() +{ + return LLColor4::white; +} + +LLColor3 LLGLTFMaterial::getDefaultEmissiveColor() +{ + return LLColor3::black; +} + +bool LLGLTFMaterial::getDefaultDoubleSided() +{ + return false; } -void LLGLTFMaterial::writeOverridesToModel(tinygltf::Model & model, S32 mat_index, LLGLTFMaterial const * base_material) const +void LLGLTFMaterial::writeOverridesToModel(tinygltf::Model& model, S32 mat_index, LLGLTFMaterial const* base_material) const { - if (model.materials.size() < mat_index+1) + if (model.materials.size() < mat_index + 1) { model.materials.resize(mat_index + 1); } @@ -256,37 +411,37 @@ void LLGLTFMaterial::writeOverridesToModel(tinygltf::Model & model, S32 mat_inde model.images[idx].uri = mEmissiveId.asString(); } - if(mAlphaMode != base_material->mAlphaMode) + if (mAlphaMode != base_material->mAlphaMode) { material_out.alphaMode = getAlphaMode(); } - if(mAlphaCutoff != base_material->mAlphaCutoff) + if (mAlphaCutoff != base_material->mAlphaCutoff) { material_out.alphaCutoff = mAlphaCutoff; } - if(mBaseColor != base_material->mBaseColor) + if (mBaseColor != base_material->mBaseColor) { mBaseColor.write(material_out.pbrMetallicRoughness.baseColorFactor); } - if(mEmissiveColor != base_material->mEmissiveColor) + if (mEmissiveColor != base_material->mEmissiveColor) { mEmissiveColor.write(material_out.emissiveFactor); } - if(mMetallicFactor != base_material->mMetallicFactor) + if (mMetallicFactor != base_material->mMetallicFactor) { material_out.pbrMetallicRoughness.metallicFactor = mMetallicFactor; } - if(mRoughnessFactor != base_material->mRoughnessFactor) + if (mRoughnessFactor != base_material->mRoughnessFactor) { material_out.pbrMetallicRoughness.roughnessFactor = mRoughnessFactor; } - if(mDoubleSided != base_material->mDoubleSided) + if (mDoubleSided != base_material->mDoubleSided) { material_out.doubleSided = mDoubleSided; } diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index e8d1d67f1b..9c82f08805 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -27,8 +27,10 @@ #pragma once #include "llrefcount.h" +#include "llmemory.h" #include "v4color.h" #include "v3color.h" +#include "v2math.h" #include "lluuid.h" #include "llmd5.h" @@ -43,6 +45,13 @@ class LLGLTFMaterial : public LLRefCount { public: + struct TextureTransform + { + LLVector2 mOffset = { 0.f, 0.f }; + LLVector2 mScale = { 1.f, 1.f }; + F32 mRotation = 0.f; + }; + enum AlphaMode { ALPHA_MODE_OPAQUE = 0, @@ -50,6 +59,11 @@ public: ALPHA_MODE_MASK }; + LLGLTFMaterial() {} + LLGLTFMaterial(const LLGLTFMaterial& rhs); + + LLGLTFMaterial& operator=(const LLGLTFMaterial& rhs); + LLUUID mBaseColorId; LLUUID mNormalId; LLUUID mMetallicRoughnessId; @@ -65,17 +79,41 @@ public: bool mDoubleSided = false; AlphaMode mAlphaMode = ALPHA_MODE_OPAQUE; - // get a UUID based on a hash of this LLGLTFMaterial - LLUUID getHash() const + enum TextureTransformIdx : U32 { - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - LLMD5 md5; - md5.update((unsigned char*)this, sizeof(this)); - md5.finalize(); - LLUUID id; - md5.raw_digest(id.mData); - return id; - } + TEXTURE_TRANSFORM_DIFFUSE_EMISSIVE, + TEXTURE_TRANSFORM_NORMAL, + TEXTURE_TRANSFORM_METALLIC_ROUGHNESS + }; + TextureTransform mTextureTransform[3]; + + //setters for various members (will clamp to acceptable ranges) + + void setBaseColorId(const LLUUID& id); + void setNormalId(const LLUUID& id); + void setMetallicRoughnessId(const LLUUID& id); + void setEmissiveId(const LLUUID& id); + + void setBaseColorFactor(const LLColor3& baseColor, F32 transparency); + void setAlphaCutoff(F32 cutoff); + void setEmissiveColorFactor(const LLColor3& emissiveColor); + void setMetallicFactor(F32 metallic); + void setRoughnessFactor(F32 roughness); + void setAlphaMode(S32 mode); + void setDoubleSided(bool double_sided); + + // Default value accessors + static LLUUID getDefaultBaseColorId(); + static LLUUID getDefaultNormalId(); + static LLUUID getDefaultEmissiveId(); + static LLUUID getDefaultMetallicRoughnessId(); + static F32 getDefaultAlphaCutoff(); + static S32 getDefaultAlphaMode(); + static F32 getDefaultMetallicFactor(); + static F32 getDefaultRoughnessFactor(); + static LLColor4 getDefaultBaseColor(); + static LLColor3 getDefaultEmissiveColor(); + static bool getDefaultDoubleSided(); // set mAlphaMode from string. // Anything otherthan "MASK" or "BLEND" sets mAlphaMode to ALPHA_MODE_OPAQUE @@ -123,7 +161,18 @@ public: // write to given tinygltf::Model void writeToModel(tinygltf::Model& model, S32 mat_index) const; + // get a UUID based on a hash of this LLGLTFMaterial + LLUUID getHash() const + { + LLMD5 md5; + md5.update((unsigned char*)this, sizeof(this)); + md5.finalize(); + LLUUID id; + md5.raw_digest(id.mData); + return id; + } + // calculate the fields in this material that differ from a base material and write them out to a given tinygltf::Model - void writeOverridesToModel(tinygltf::Model & model, S32 mat_index, LLGLTFMaterial const * base_material) const; + void writeOverridesToModel(tinygltf::Model& model, S32 mat_index, LLGLTFMaterial const* base_material) const; }; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 24875f0d21..bb74d258fd 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -135,10 +135,6 @@ public: S32 setMaterialID(const LLMaterialID& pMaterialID); S32 setMaterialParams(const LLMaterialPtr pMaterialParams); - void setGLTFMaterial(LLGLTFMaterial* material) { mGLTFMaterial = material; } - LLGLTFMaterial* getGLTFMaterial() { return mGLTFMaterial; } - - virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } const F32 getAlpha() const { return mColor.mV[VALPHA]; } @@ -200,10 +196,18 @@ public: // Media flags enum { MF_NONE = 0x0, MF_HAS_MEDIA = 0x1 }; + // GLTF asset + void setGLTFMaterial(LLGLTFMaterial* material) { mGLTFMaterial = material; } + LLGLTFMaterial* getGLTFMaterial() { return mGLTFMaterial; } + // GLTF override LLGLTFMaterial* getGLTFMaterialOverride() { return mGLTFMaterialOverrides; } void setGLTFMaterialOverride(LLGLTFMaterial* mat) { mGLTFMaterialOverrides = mat; } + // GLTF render + LLGLTFMaterial* getGLTFRenderMaterial() { return mGLTFRenderMaterial; } + void setGLTFRenderMaterial(LLGLTFMaterial* mat) { mGLTFRenderMaterial = mat; } + public: F32 mScaleS; // S, T offset F32 mScaleT; // S, T offset @@ -230,12 +234,18 @@ protected: bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; - LLPointer mGLTFMaterial; // if present, ignore mMaterial + + // Reference to GLTF material asset state + // On the viewer, this should be the same LLGLTFMaterial instance that exists in LLGLTFMaterialList + LLPointer mGLTFMaterial; // GLTF material parameter overrides -- the viewer will use this data to override material parameters - // set by the asset + // set by the asset and store the results in mRenderGLTFMaterial LLPointer mGLTFMaterialOverrides; + // GLTF material to use for rendering -- will always be an LLFetchedGLTFMaterial + LLPointer mGLTFRenderMaterial; + // Note the media data is not sent via the same message structure as the rest of the TE LLMediaEntry* mMediaEntry; // The media data for the face diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index 482012cdd6..2a26cb9a43 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -73,6 +73,7 @@ Avatar Voice --> + Capabilities diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index b633813819..feaf562686 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -196,7 +196,7 @@ vec4 filterColor(vec3 N) // apply the bias to the lod lod += u_lodBias; - lod = clamp(lod, 0, 7); + lod = clamp(lod, 0, 6); // sample lambertian at a lower resolution to avoid fireflies vec4 lambertian = textureLod(reflectionProbes, vec4(H, sourceIdx), lod); diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index f4879b52de..32f157e9d2 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -127,7 +127,7 @@ vec4 prefilterEnvMap(vec3 R) float envMapDim = 256.0; int numSamples = 4; - float numMips = 7.0; + float numMips = 6.0; float roughness = mipLevel/numMips; @@ -151,7 +151,7 @@ vec4 prefilterEnvMap(vec3 R) // Solid angle of 1 pixel across all cube faces float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result - float mip = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); + float mip = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, numMips); //float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); color += textureLod(reflectionProbes, vec4(L,sourceIdx), mip) * dotNL; totalWeight += dotNL; diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 211e1f5d8d..ca436033f1 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -507,7 +507,7 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness, bool errorCorrect) { // TODO - don't hard code lods - float reflection_lods = 7; + float reflection_lods = 6; preProbeSample(pos); vec3 refnormpersp = reflect(pos.xyz, norm.xyz); diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 2cb48e51d0..efd498183d 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -286,9 +286,9 @@ RenderFSAASamples 1 0 RenderGLMultiThreaded 1 0 RenderGLContextCoreProfile 1 0 -// HACK: Current AMD drivers have bugged cubemap arrays, limit number of reflection probes to 16 +// HACK: Current AMD drivers have bugged cubemap arrays, limit number of reflection probes to 32 list AMD -RenderReflectionProbeCount 1 16 +RenderReflectionProbeCount 1 32 list GL3 RenderFSAASamples 0 0 diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 01b2647eaa..41e52846b3 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -675,45 +675,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) gPipeline.bindDeferredShader(*target_shader); } - if (params.mTexture.notNull()) - { - gGL.getTexUnit(0)->bindFast(params.mTexture); // diffuse - } - else - { - gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep); - } - - if (params.mNormalMap) - { - target_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap); - } - else - { - target_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); - } - - if (params.mSpecularMap) - { - target_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, params.mSpecularMap); // PBR linear packed Occlusion, Roughness, Metal. - } - else - { - target_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); - } - - if (params.mEmissiveMap) - { - target_shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, params.mEmissiveMap); // PBR sRGB Emissive - } - else - { - target_shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, LLViewerFetchedTexture::sWhiteImagep); - } - - target_shader->uniform1f(LLShaderMgr::ROUGHNESS_FACTOR, params.mGLTFMaterial->mRoughnessFactor); - target_shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, params.mGLTFMaterial->mMetallicFactor); - target_shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, params.mGLTFMaterial->mEmissiveColor.mV); + params.mGLTFMaterial->bind(target_shader); } else { diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 71f648a714..2f710e570b 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -95,57 +95,10 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass) for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) { LLDrawInfo* pparams = *i; - LLGLTFMaterial *mat = pparams->mGLTFMaterial; - - // glTF 2.0 Specification 3.9.4. Alpha Coverage - // mAlphaCutoff is only valid for LLGLTFMaterial::ALPHA_MODE_MASK - F32 min_alpha = -1.0; - if (mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) - { - min_alpha = mat->mAlphaCutoff; - } - shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha); - - if (pparams->mTexture.notNull()) - { - gGL.getTexUnit(0)->bindFast(pparams->mTexture); // diffuse - } - else - { - gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep); - } - - if (pparams->mNormalMap) - { - shader->bindTexture(LLShaderMgr::BUMP_MAP, pparams->mNormalMap); - } - else - { - shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); - } - - if (pparams->mSpecularMap) - { - shader->bindTexture(LLShaderMgr::SPECULAR_MAP, pparams->mSpecularMap); // PBR linear packed Occlusion, Roughness, Metal. - } - else - { - shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); - } - - if (pparams->mEmissiveMap) - { - shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, pparams->mEmissiveMap); // PBR sRGB Emissive - } - else - { - shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, LLViewerFetchedTexture::sWhiteImagep); - } - - shader->uniform1f(LLShaderMgr::ROUGHNESS_FACTOR, pparams->mGLTFMaterial->mRoughnessFactor); - shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, pparams->mGLTFMaterial->mMetallicFactor); - shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, pparams->mGLTFMaterial->mEmissiveColor.mV); - + auto& mat = pparams->mGLTFMaterial; + + mat->bind(shader); + LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); bool tex_setup = false; diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index a06dd276cd..2d3015635c 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -27,6 +27,10 @@ #include "llfetchedgltfmaterial.h" +#include "llviewertexturelist.h" +#include "llavatarappearancedefines.h" +#include "llshadermgr.h" + LLFetchedGLTFMaterial::LLFetchedGLTFMaterial() : LLGLTFMaterial() , mExpectedFlusTime(0.f) @@ -38,5 +42,62 @@ LLFetchedGLTFMaterial::LLFetchedGLTFMaterial() LLFetchedGLTFMaterial::~LLFetchedGLTFMaterial() { + +} + +void LLFetchedGLTFMaterial::bind(LLGLSLShader* shader) +{ + // glTF 2.0 Specification 3.9.4. Alpha Coverage + // mAlphaCutoff is only valid for LLGLTFMaterial::ALPHA_MODE_MASK + F32 min_alpha = -1.0; + + if (mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) + { + min_alpha = mAlphaCutoff; + } + shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha); + + if (mBaseColorTexture.notNull()) + { + gGL.getTexUnit(0)->bindFast(mBaseColorTexture); + } + else + { + gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep); + } + + + if (mNormalTexture.notNull()) + { + shader->bindTexture(LLShaderMgr::BUMP_MAP, mNormalTexture); + } + else + { + shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); + } + + if (mMetallicRoughnessTexture.notNull()) + { + shader->bindTexture(LLShaderMgr::SPECULAR_MAP, mMetallicRoughnessTexture); // PBR linear packed Occlusion, Roughness, Metal. + } + else + { + shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); + } + + if (mEmissiveTexture.notNull()) + { + shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, mEmissiveTexture); // PBR sRGB Emissive + } + else + { + shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, LLViewerFetchedTexture::sWhiteImagep); + } + + // NOTE: base color factor is baked into vertex stream + + shader->uniform1f(LLShaderMgr::ROUGHNESS_FACTOR, mRoughnessFactor); + shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, mMetallicFactor); + shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, mEmissiveColor.mV); } diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h index 4cbe6651c4..3b2801bf77 100644 --- a/indra/newview/llfetchedgltfmaterial.h +++ b/indra/newview/llfetchedgltfmaterial.h @@ -28,14 +28,26 @@ #include "llgltfmaterial.h" #include "llpointer.h" +#include "llviewertexture.h" -class LLFetchedGLTFMaterial : public LLGLTFMaterial +class LLGLSLShader; + +class LLFetchedGLTFMaterial: public LLGLTFMaterial { friend class LLGLTFMaterialList; // for lifetime management public: LLFetchedGLTFMaterial(); virtual ~LLFetchedGLTFMaterial(); + // bind this material for rendering + void bind(LLGLSLShader* shader); + + // Textures used for fetching/rendering + LLPointer mBaseColorTexture; + LLPointer mNormalTexture; + LLPointer mMetallicRoughnessTexture; + LLPointer mEmissiveTexture; + protected: //Lifetime management F64 mExpectedFlusTime; // since epoch in seconds diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 14b762998a..e0a2c00db3 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -38,7 +38,7 @@ class LLViewerObject; #define LL_MAX_REFLECTION_PROBE_COUNT 256 // reflection probe resolution -#define LL_REFLECTION_PROBE_RESOLUTION 256 +#define LL_REFLECTION_PROBE_RESOLUTION 128 #define LL_IRRADIANCE_MAP_RESOLUTION 64 // reflection probe mininum scale diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index c3e9d8ceb9..0d16b818f1 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -41,6 +41,7 @@ #include "llviewercamera.h" #include "llvector4a.h" #include "llvoavatar.h" +#include "llfetchedgltfmaterial.h" #include #include @@ -114,9 +115,11 @@ public: F32 mDistance; U32 mDrawMode; - // Material points here are likely for debugging only and are immaterial (zing!) + // Material pointer here is likely for debugging only and are immaterial (zing!) LLMaterialPtr mMaterial; - LLPointer mGLTFMaterial; + + // PBR material parameters + LLPointer mGLTFMaterial; LLUUID mMaterialID; // id of LLGLTFMaterial or LLMaterial applied to this draw info @@ -128,7 +131,6 @@ public: const LLMatrix4* mSpecularMapMatrix; LLPointer mNormalMap; const LLMatrix4* mNormalMapMatrix; - LLPointer mEmissiveMap; LLVector4 mSpecColor; // XYZ = Specular RGB, W = Specular Exponent F32 mEnvIntensity; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index a256b770b1..ccc1259c25 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -414,11 +414,6 @@ void LLViewerObject::deleteTEImages() delete[] mTESpecularMaps; mTESpecularMaps = NULL; } - - mGLTFBaseColorMaps.clear(); - mGLTFNormalMaps.clear(); - mGLTFMetallicRoughnessMaps.clear(); - mGLTFEmissiveMaps.clear(); } void LLViewerObject::markDead() @@ -4766,11 +4761,6 @@ void LLViewerObject::setNumTEs(const U8 num_tes) mTEImages = new_images; mTENormalMaps = new_normmaps; mTESpecularMaps = new_specmaps; - - mGLTFBaseColorMaps.resize(num_tes); - mGLTFNormalMaps.resize(num_tes); - mGLTFMetallicRoughnessMaps.resize(num_tes); - mGLTFEmissiveMaps.resize(num_tes); } else { @@ -4930,14 +4920,28 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); } - auto fetch_texture = [](const LLUUID& id, LLViewerObject *obj) + LLFetchedGLTFMaterial* mat = (LLFetchedGLTFMaterial*) getTE(te)->getGLTFMaterial(); + LLUUID mat_id = getRenderMaterialID(te); + if (mat == nullptr && mat_id.notNull()) + { + mat = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mat_id); + getTE(te)->setGLTFMaterial(mat); + } + else if (mat_id.isNull() && mat != nullptr) + { + mat = nullptr; + getTE(te)->setGLTFMaterial(nullptr); + } + + auto fetch_texture = [this](const LLUUID& id) { LLViewerFetchedTexture* img = nullptr; if (id.notNull()) { if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(id)) { - LLViewerTexture* viewerTexture = obj->getBakedTextureForMagicId(id); + // TODO -- fall back to LLTextureEntry::mGLTFRenderMaterial when overriding with baked texture + LLViewerTexture* viewerTexture = getBakedTextureForMagicId(id); img = viewerTexture ? dynamic_cast(viewerTexture) : nullptr; } else @@ -4950,34 +4954,13 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) return img; }; - LLGLTFMaterial* mat = getTE(te)->getGLTFMaterial(); - LLUUID mat_id = getRenderMaterialID(te); - if (mat == nullptr && mat_id.notNull()) - { - mat = gGLTFMaterialList.getMaterial(mat_id); - getTE(te)->setGLTFMaterial(mat); - } - else if (mat_id.isNull() && mat != nullptr) - { - mat = nullptr; - getTE(te)->setGLTFMaterial(nullptr); - } - if (mat != nullptr) { - mGLTFBaseColorMaps[te] = fetch_texture(mat->mBaseColorId, this); - mGLTFNormalMaps[te] = fetch_texture(mat->mNormalId, this); - mGLTFMetallicRoughnessMaps[te] = fetch_texture(mat->mMetallicRoughnessId, this); - mGLTFEmissiveMaps[te] = fetch_texture(mat->mEmissiveId, this); + mat->mBaseColorTexture = fetch_texture(mat->mBaseColorId); + mat->mNormalTexture = fetch_texture(mat->mNormalId); + mat->mMetallicRoughnessTexture = fetch_texture(mat->mMetallicRoughnessId); + mat->mEmissiveTexture= fetch_texture(mat->mEmissiveId); } - else - { - mGLTFBaseColorMaps[te] = nullptr; - mGLTFNormalMaps[te] = nullptr; - mGLTFMetallicRoughnessMaps[te] = nullptr; - mGLTFEmissiveMaps[te] = nullptr; - } - } void LLViewerObject::refreshBakeTexture() diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 9d80f095c9..5d72f7f3c3 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -371,12 +371,6 @@ public: LLViewerTexture *getTENormalMap(const U8 te) const; LLViewerTexture *getTESpecularMap(const U8 te) const; - LLViewerTexture* getGLTFBaseColorMap(U8 te) const { return mGLTFBaseColorMaps[te]; } - LLViewerTexture* getGLTFNormalMap(U8 te) const { return mGLTFNormalMaps[te]; } - LLViewerTexture* getGLTFEmissiveMap(U8 te) const { return mGLTFEmissiveMaps[te]; } - LLViewerTexture* getGLTFMetallicRoughnessMap(U8 te) const { return mGLTFMetallicRoughnessMaps[te]; } - - bool isImageAlphaBlended(const U8 te) const; void fitFaceTexture(const U8 face); @@ -693,13 +687,6 @@ public: LLPointer *mTENormalMaps; LLPointer *mTESpecularMaps; - std::vector > mGLTFBaseColorMaps; - std::vector > mGLTFNormalMaps; - std::vector > mGLTFMetallicRoughnessMaps; - std::vector > mGLTFEmissiveMaps; - - - // true if user can select this object by clicking under any circumstances (even if pick_unselectable is true) // can likely be factored out BOOL mbCanSelect; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 2a06331b63..c1c80d5adc 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5390,7 +5390,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLUUID mat_id; - LLGLTFMaterial* gltf_mat = facep->getTextureEntry()->getGLTFMaterial(); + auto* gltf_mat = (LLFetchedGLTFMaterial*) facep->getTextureEntry()->getGLTFMaterial(); if (gltf_mat != nullptr) { mat_id = gltf_mat->getHash(); // TODO: cache this hash @@ -5519,21 +5519,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, if (gltf_mat) { - LLViewerObject* vobj = facep->getViewerObject(); - U8 te = facep->getTEOffset(); - - draw_info->mTexture = vobj->getGLTFBaseColorMap(te); - draw_info->mNormalMap = vobj->getGLTFNormalMap(te); - draw_info->mSpecularMap = vobj->getGLTFMetallicRoughnessMap(te); - draw_info->mEmissiveMap = vobj->getGLTFEmissiveMap(te); - if (draw_info->mGLTFMaterial->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) - { - draw_info->mAlphaMaskCutoff = gltf_mat->mAlphaCutoff * gltf_mat->mBaseColor.mV[3]; - } - else - { - draw_info->mAlphaMaskCutoff = 1.f; - } + // nothing to do, render pools will reference the GLTF material } else if (mat) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0c27296440..cb54cec165 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3723,15 +3723,26 @@ void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) void LLPipeline::touchTextures(LLDrawInfo* info) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - for (int i = 0; i < info->mTextureList.size(); ++i) + + auto& mat = info->mGLTFMaterial; + if (mat.notNull()) { - touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); + touchTexture(mat->mBaseColorTexture, info->mVSize); + touchTexture(mat->mNormalTexture, info->mVSize); + touchTexture(mat->mMetallicRoughnessTexture, info->mVSize); + touchTexture(mat->mEmissiveTexture, info->mVSize); } + else + { + for (int i = 0; i < info->mTextureList.size(); ++i) + { + touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); + } - touchTexture(info->mTexture, info->mVSize); - touchTexture(info->mSpecularMap, info->mVSize); - touchTexture(info->mNormalMap, info->mVSize); - touchTexture(info->mEmissiveMap, info->mVSize); + touchTexture(info->mTexture, info->mVSize); + touchTexture(info->mSpecularMap, info->mVSize); + touchTexture(info->mNormalMap, info->mVSize); + } } void LLPipeline::postSort(LLCamera& camera) -- cgit v1.3 From 8741c05cc10d3f39f272bb4739e7313309539d07 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 19 Oct 2022 17:23:54 -0500 Subject: SL-18105 Hook up TE override material to render pipe by way of render material. --- indra/llprimitive/llgltfmaterial.cpp | 25 +++++++++++++++++++++++++ indra/llprimitive/llgltfmaterial.h | 3 +++ indra/llprimitive/lltextureentry.cpp | 19 +++++++++++++++++++ indra/llprimitive/lltextureentry.h | 13 ++++++------- indra/newview/llface.cpp | 6 +++--- indra/newview/llgltfmateriallist.cpp | 6 +++++- indra/newview/llviewerobject.cpp | 32 +++++++++++++++++++++++++++++++- indra/newview/llviewerobject.h | 1 + indra/newview/llvovolume.cpp | 10 +++++----- indra/newview/pipeline.cpp | 2 +- 10 files changed, 99 insertions(+), 18 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index 19081cd76f..b9ef2de61a 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -446,3 +446,28 @@ void LLGLTFMaterial::writeOverridesToModel(tinygltf::Model& model, S32 mat_index material_out.doubleSided = mDoubleSided; } } + +void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat) +{ + if (override_mat.mBaseColorId != getDefaultBaseColorId()) + { + mBaseColorId = override_mat.mBaseColorId; + } + + if (override_mat.mNormalId != getDefaultNormalId()) + { + mNormalId = override_mat.mNormalId; + } + + if (override_mat.mMetallicRoughnessId != getDefaultMetallicRoughnessId()) + { + mMetallicRoughnessId = override_mat.mMetallicRoughnessId; + } + + if (override_mat.mEmissiveId != getDefaultEmissiveId()) + { + mEmissiveId = override_mat.mEmissiveId; + } + + //TODO -- implement non texture parameters +} diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index 9c82f08805..32695d92f4 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -174,5 +174,8 @@ public: // calculate the fields in this material that differ from a base material and write them out to a given tinygltf::Model void writeOverridesToModel(tinygltf::Model& model, S32 mat_index, LLGLTFMaterial const* base_material) const; + + void applyOverride(const LLGLTFMaterial& override_mat); + }; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 284dfc15f4..e185404ada 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -491,6 +491,25 @@ S32 LLTextureEntry::setBumpShiny(U8 bump_shiny) return TEM_CHANGE_NONE; } +void LLTextureEntry::setGLTFMaterial(LLGLTFMaterial* material) +{ + mGLTFMaterial = material; + if (mGLTFMaterial == nullptr) + { + setGLTFRenderMaterial(nullptr); + } +} + +S32 LLTextureEntry::setGLTFRenderMaterial(LLGLTFMaterial* mat) +{ + if (mGLTFRenderMaterial != mat) + { + mGLTFRenderMaterial = mat; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + S32 LLTextureEntry::setMediaFlags(U8 media_flags) { media_flags &= TEM_MEDIA_MASK; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index bb74d258fd..2c932a10df 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -163,8 +163,6 @@ public: const LLMaterialID& getMaterialID() const { return mMaterialID; }; const LLMaterialPtr getMaterialParams() const { return mMaterial; }; - LLGLTFMaterial* getGLTFMaterial() const { return mGLTFMaterial; } - // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() // to NOT return NULL. @@ -197,16 +195,17 @@ public: enum { MF_NONE = 0x0, MF_HAS_MEDIA = 0x1 }; // GLTF asset - void setGLTFMaterial(LLGLTFMaterial* material) { mGLTFMaterial = material; } - LLGLTFMaterial* getGLTFMaterial() { return mGLTFMaterial; } + void setGLTFMaterial(LLGLTFMaterial* material); + LLGLTFMaterial* getGLTFMaterial() const { return mGLTFMaterial; } // GLTF override LLGLTFMaterial* getGLTFMaterialOverride() { return mGLTFMaterialOverrides; } void setGLTFMaterialOverride(LLGLTFMaterial* mat) { mGLTFMaterialOverrides = mat; } - // GLTF render - LLGLTFMaterial* getGLTFRenderMaterial() { return mGLTFRenderMaterial; } - void setGLTFRenderMaterial(LLGLTFMaterial* mat) { mGLTFRenderMaterial = mat; } + // GLTF render material + // nuanced behavior here -- if there is no render material, fall back to getGLTFMaterial, but ONLY for the getter, not the setter + LLGLTFMaterial* getGLTFRenderMaterial() const { return mGLTFRenderMaterial.notNull() ? mGLTFRenderMaterial : getGLTFMaterial(); } + S32 setGLTFRenderMaterial(LLGLTFMaterial* mat); public: F32 mScaleS; // S, T offset diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 4ae8335ca7..23b56aa579 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1334,9 +1334,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLColor4U color = tep->getColor(); - if (tep->getGLTFMaterial()) + if (tep->getGLTFRenderMaterial()) { - color = tep->getGLTFMaterial()->mBaseColor; + color = tep->getGLTFRenderMaterial()->mBaseColor; } if (rebuild_color) @@ -1599,7 +1599,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, scalea.load3(scale.mV); LLMaterial* mat = tep->getMaterialParams().get(); - LLGLTFMaterial* gltf_mat = tep->getGLTFMaterial(); + LLGLTFMaterial* gltf_mat = tep->getGLTFRenderMaterial(); bool do_bump = bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1); diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 9c04ef4c38..86f4faa9d0 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -36,6 +36,7 @@ #include "llviewercontrol.h" #include "llviewergenericmessage.h" #include "llviewerobjectlist.h" +#include "pipeline.h" #include "tinygltf/tiny_gltf.h" #include @@ -86,7 +87,10 @@ namespace if(obj) { - obj->getTE(side)->setGLTFMaterialOverride(override_data); + if (obj->setTEGLTFMaterialOverride(side, override_data)) + { + gPipeline.markTextured(obj->mDrawable); + } } LL_DEBUGS() << "successfully parsed override: " << override_data->asJSON() << LL_ENDL; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index ccc1259c25..4923771a31 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4920,7 +4920,7 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); } - LLFetchedGLTFMaterial* mat = (LLFetchedGLTFMaterial*) getTE(te)->getGLTFMaterial(); + LLFetchedGLTFMaterial* mat = (LLFetchedGLTFMaterial*) getTE(te)->getGLTFRenderMaterial(); LLUUID mat_id = getRenderMaterialID(te); if (mat == nullptr && mat_id.notNull()) { @@ -5319,6 +5319,36 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri return retval; } +S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_mat) +{ + S32 retval = TEM_CHANGE_NONE; + + LLTextureEntry* tep = getTE(te); + if (!tep) + { + LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL; + return retval; + } + + LLFetchedGLTFMaterial* src_mat = (LLFetchedGLTFMaterial*) tep->getGLTFMaterial(); + + tep->setGLTFMaterialOverride(override_mat); + + if (override_mat && src_mat) + { + LLFetchedGLTFMaterial* render_mat = new LLFetchedGLTFMaterial(*src_mat); + render_mat->applyOverride(*override_mat); + tep->setGLTFRenderMaterial(render_mat); + retval = TEM_CHANGE_TEXTURE; + } + else if (tep->setGLTFRenderMaterial(nullptr)) + { + retval = TEM_CHANGE_TEXTURE; + } + + return retval; +} + void LLViewerObject::refreshMaterials() { setChanged(TEXTURE); diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 5d72f7f3c3..bd70532ab7 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -356,6 +356,7 @@ public: /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); + S32 setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* mat); // Used by Materials update functions to properly kick off rebuilds // of VBs etc when materials updates require changes. diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c1c80d5adc..127abde19e 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5223,7 +5223,7 @@ bool can_batch_texture(LLFace* facep) return false; } - if (facep->getTextureEntry()->getGLTFMaterial() != nullptr) + if (facep->getTextureEntry()->getGLTFRenderMaterial() != nullptr) { // PBR materials break indexed texture batching return false; } @@ -5390,7 +5390,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLUUID mat_id; - auto* gltf_mat = (LLFetchedGLTFMaterial*) facep->getTextureEntry()->getGLTFMaterial(); + auto* gltf_mat = (LLFetchedGLTFMaterial*) facep->getTextureEntry()->getGLTFRenderMaterial(); if (gltf_mat != nullptr) { mat_id = gltf_mat->getHash(); // TODO: cache this hash @@ -5873,7 +5873,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool is_pbr = false; #endif #else - LLGLTFMaterial *gltf_mat = facep->getTextureEntry()->getGLTFMaterial(); + LLGLTFMaterial *gltf_mat = facep->getTextureEntry()->getGLTFRenderMaterial(); bool is_pbr = gltf_mat != nullptr; #endif @@ -6011,7 +6011,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (gPipeline.canUseWindLightShadersOnObjects() && LLPipeline::sRenderBump) { - LLGLTFMaterial* gltf_mat = te->getGLTFMaterial(); + LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); if (LLPipeline::sRenderDeferred && (gltf_mat != nullptr || (te->getMaterialParams().notNull() && !te->getMaterialID().isNull()))) @@ -6716,7 +6716,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) ? TRUE : FALSE; - LLGLTFMaterial* gltf_mat = te->getGLTFMaterial(); + LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); LLMaterial* mat = nullptr; bool can_be_shiny = false; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index cb54cec165..b6d9e5fd36 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1617,7 +1617,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } LLMaterial* mat = te->getMaterialParams().get(); - LLGLTFMaterial* gltf_mat = te->getGLTFMaterial(); + LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); bool color_alpha = te->getColor().mV[3] < 0.999f; bool alpha = color_alpha; -- cgit v1.3 From 40695bbd316ceb15db2c3eb203cbe35188a00aa9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 20 Oct 2022 13:55:42 -0500 Subject: SL-18105 Fix for overrides not showing until a forced mesh update. --- indra/newview/llgltfmateriallist.cpp | 6 +----- indra/newview/llviewerobject.cpp | 1 - indra/newview/llviewerobject.h | 2 +- indra/newview/llvovolume.cpp | 19 +++++++++++++++++++ indra/newview/llvovolume.h | 1 + 5 files changed, 22 insertions(+), 7 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 86f4faa9d0..0a104d1db5 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -36,7 +36,6 @@ #include "llviewercontrol.h" #include "llviewergenericmessage.h" #include "llviewerobjectlist.h" -#include "pipeline.h" #include "tinygltf/tiny_gltf.h" #include @@ -87,10 +86,7 @@ namespace if(obj) { - if (obj->setTEGLTFMaterialOverride(side, override_data)) - { - gPipeline.markTextured(obj->mDrawable); - } + obj->setTEGLTFMaterialOverride(side, override_data); } LL_DEBUGS() << "successfully parsed override: " << override_data->asJSON() << LL_ENDL; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 4923771a31..eaf0287dae 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5315,7 +5315,6 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri setTENormalMap(te, (pMaterialParams) ? pMaterialParams->getNormalID() : LLUUID::null); setTESpecularMap(te, (pMaterialParams) ? pMaterialParams->getSpecularID() : LLUUID::null); - refreshMaterials(); return retval; } diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index bd70532ab7..31e82545ec 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -356,7 +356,7 @@ public: /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); - S32 setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* mat); + virtual S32 setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* mat); // Used by Materials update functions to properly kick off rebuilds // of VBs etc when materials updates require changes. diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 127abde19e..98919921ff 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2609,6 +2609,24 @@ S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialPa return TEM_CHANGE_TEXTURE; } +S32 LLVOVolume::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* mat) +{ + S32 retval = LLViewerObject::setTEGLTFMaterialOverride(te, mat); + + if (retval == TEM_CHANGE_TEXTURE) + { + if (!mDrawable.isNull()) + { + gPipeline.markTextured(mDrawable); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); + } + mFaceMappingChanged = TRUE; + } + + return retval; +} + + S32 LLVOVolume::setTEScale(const U8 te, const F32 s, const F32 t) { S32 res = LLViewerObject::setTEScale(te, s, t); @@ -2642,6 +2660,7 @@ S32 LLVOVolume::setTEScaleT(const U8 te, const F32 t) return res; } + void LLVOVolume::updateTEData() { /*if (mDrawable.notNull()) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 391351c13e..f0c2ce7cce 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -209,6 +209,7 @@ public: static void setTEMaterialParamsCallbackTE(const LLUUID& objectID, const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) override; + S32 setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* mat) override; /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t) override; /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s) override; /*virtual*/ S32 setTEScaleT(const U8 te, const F32 t) override; -- cgit v1.3 From 5b5d24a74703d2a8d5da65ef57d9b8af6889e3d7 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Oct 2022 16:27:23 +0300 Subject: SL-17021 Fix some changes vanishing over merge to D559 --- indra/newview/llvovolume.cpp | 36 ++++++++++++++++++++++++++++++------ indra/newview/llvovolume.h | 12 ++++++++++-- 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 72c03b395f..84158c3a7d 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4773,7 +4773,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& { if ((pick_rigged) || (getAvatar() && (getAvatar()->isSelf()) && (LLFloater::isVisible(gFloaterTools)))) { - updateRiggedVolume(true); + updateRiggedVolume(true, LLRiggedVolume::DO_NOT_UPDATE_FACES); volume = mRiggedVolume; transform = false; } @@ -4848,6 +4848,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& continue; } + updateRiggedVolume(true, i); face_hit = volume->lineSegmentIntersect(local_start, local_end, i, &p, &tc, &n, &tn); @@ -4971,7 +4972,7 @@ void LLVOVolume::clearRiggedVolume() } } -void LLVOVolume::updateRiggedVolume(bool force_update) +void LLVOVolume::updateRiggedVolume(bool force_treat_as_rigged, LLRiggedVolume::FaceIndex face_index, bool rebuild_face_octrees) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; //Update mRiggedVolume to match current animation frame of avatar. @@ -5006,10 +5007,15 @@ void LLVOVolume::updateRiggedVolume(bool force_update) updateRelativeXform(); } - mRiggedVolume->update(skin, avatar, volume); + mRiggedVolume->update(skin, avatar, volume, face_index, rebuild_face_octrees); } -void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, const LLVolume* volume) +void LLRiggedVolume::update( + const LLMeshSkinInfo* skin, + LLVOAvatar* avatar, + const LLVolume* volume, + FaceIndex face_index, + bool rebuild_face_octrees) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; bool copy = false; @@ -5040,7 +5046,7 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons if (is_paused) { S32 frames_paused = LLFrameTimer::getFrameCount() - avatar->getMotionController().getPausedFrame(); - if (frames_paused > 2) + if (frames_paused > 1) { return; } @@ -5059,7 +5065,24 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons S32 rigged_vert_count = 0; S32 rigged_face_count = 0; LLVector4a box_min, box_max; - for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i) + S32 face_begin; + S32 face_end; + if (face_index == DO_NOT_UPDATE_FACES) + { + face_begin = 0; + face_end = 0; + } + else if (face_index == UPDATE_ALL_FACES) + { + face_begin = 0; + face_end = volume->getNumVolumeFaces(); + } + else + { + face_begin = face_index; + face_end = face_begin + 1; + } + for (S32 i = face_begin; i < face_end; ++i) { const LLVolumeFace& vol_face = volume->getVolumeFace(i); @@ -5144,6 +5167,7 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons } + if (rebuild_face_octrees) { dst_face.destroyOctree(); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 77e7043f40..003ab38d64 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -68,7 +68,12 @@ public: using FaceIndex = S32; static const FaceIndex UPDATE_ALL_FACES = -1; static const FaceIndex DO_NOT_UPDATE_FACES = -2; - void update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, const LLVolume* src_volume); + void update( + const LLMeshSkinInfo* skin, + LLVOAvatar* avatar, + const LLVolume* src_volume, + FaceIndex face_index = UPDATE_ALL_FACES, + bool rebuild_face_octrees = true); std::string mExtraDebugText; }; @@ -385,7 +390,10 @@ public: // Rigged volume update (for raycasting) // By default, this updates the bounding boxes of all the faces and builds an octree for precise per-triangle raycasting - void updateRiggedVolume(bool force_treat_as_rigged); + void updateRiggedVolume( + bool force_treat_as_rigged, + LLRiggedVolume::FaceIndex face_index = LLRiggedVolume::UPDATE_ALL_FACES, + bool rebuild_face_octrees = true); LLRiggedVolume* getRiggedVolume(); //returns true if volume should be treated as a rigged volume -- cgit v1.3 From 683bfcfdee76d34126810c181ca877afa1deb2b1 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Oct 2022 17:15:41 +0300 Subject: SL-17021 Fix some changes vanishing over merge to D559 #2 --- indra/newview/llvovolume.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 84158c3a7d..cb58c173d9 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4848,7 +4848,9 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& continue; } - updateRiggedVolume(true, i); + // This calculates the bounding box of the skinned mesh from scratch. It's actually quite expensive, but not nearly as expensive as building a full octree. + // rebuild_face_octrees = false because an octree for this face will be built later only if needed for narrow phase picking. + updateRiggedVolume(true, i, false); face_hit = volume->lineSegmentIntersect(local_start, local_end, i, &p, &tc, &n, &tn); @@ -4978,7 +4980,7 @@ void LLVOVolume::updateRiggedVolume(bool force_treat_as_rigged, LLRiggedVolume:: //Update mRiggedVolume to match current animation frame of avatar. //Also update position/size in octree. - if ((!force_update) && (!treatAsRigged())) + if ((!force_treat_as_rigged) && (!treatAsRigged())) { clearRiggedVolume(); -- cgit v1.3 From 620d2f4ee595ec013784a374e9136a43b99a355f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Oct 2022 17:15:41 +0300 Subject: SL-17532 Fix some changes vanishing over merge to D559 --- indra/newview/llvovolume.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index cb58c173d9..9c25606ce9 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4773,7 +4773,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& { if ((pick_rigged) || (getAvatar() && (getAvatar()->isSelf()) && (LLFloater::isVisible(gFloaterTools)))) { - updateRiggedVolume(true, LLRiggedVolume::DO_NOT_UPDATE_FACES); + updateRiggedVolume(true, LLRiggedVolume::DO_NOT_UPDATE_FACES); volume = mRiggedVolume; transform = false; } @@ -4980,7 +4980,7 @@ void LLVOVolume::updateRiggedVolume(bool force_treat_as_rigged, LLRiggedVolume:: //Update mRiggedVolume to match current animation frame of avatar. //Also update position/size in octree. - if ((!force_treat_as_rigged) && (!treatAsRigged())) + if ((!force_treat_as_rigged) && (!treatAsRigged())) { clearRiggedVolume(); @@ -5009,7 +5009,7 @@ void LLVOVolume::updateRiggedVolume(bool force_treat_as_rigged, LLRiggedVolume:: updateRelativeXform(); } - mRiggedVolume->update(skin, avatar, volume, face_index, rebuild_face_octrees); + mRiggedVolume->update(skin, avatar, volume, face_index, rebuild_face_octrees); } void LLRiggedVolume::update( @@ -5172,12 +5172,7 @@ void LLRiggedVolume::update( if (rebuild_face_octrees) { dst_face.destroyOctree(); - - LLVector4a size; - size.setSub(dst_face.mExtents[1], dst_face.mExtents[0]); - size.splat(size.getLength3().getF32()*0.5f); - - dst_face.createOctree(1.f); + dst_face.createOctree(); } } } @@ -5427,7 +5422,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLViewerTexture* tex = facep->getTexture(); - U8 index = facep->getTextureIndex(); LLMaterial* mat = nullptr; @@ -6421,6 +6415,13 @@ struct CompareBatchBreakerRigged } }; +struct CompareDrawOrder +{ + bool operator()(const LLFace* const& lhs, const LLFace* const& rhs) + { + return lhs->getDrawOrderIndex() < rhs->getDrawOrderIndex(); + } +}; U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace** faces, U32 face_count, BOOL distance_sort, BOOL batch_textures, BOOL rigged) { @@ -6455,6 +6456,11 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace //sort faces by things that break batches, including avatar and mesh id std::sort(faces, faces + face_count, CompareBatchBreakerRigged()); } + else + { + // preserve legacy draw order for rigged faces + std::sort(faces, faces + face_count, CompareDrawOrder()); + } } else if (!distance_sort) { -- cgit v1.3 From 4b37414dc0963a9db344c493055f501265f4e59a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Oct 2022 19:49:36 +0300 Subject: Re-merged llvovolume.cpp Too many issue were detected after merge, so did a clean remerge of the file. --- indra/newview/llvovolume.cpp | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 9c25606ce9..7c58d23d0e 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1994,7 +1994,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) if (mDrawable->isState(LLDrawable::REBUILD_RIGGED)) { - updateRiggedVolume(false); + updateRiggedVolume(false); genBBoxes(FALSE); mDrawable->clearState(LLDrawable::REBUILD_RIGGED); } @@ -5704,7 +5704,7 @@ static inline void add_face(T*** list, U32* count, T* face) { if (count[1] < MAX_FACE_COUNT) { - face->setDrawOrderIndex(count[1]); + //face->setDrawOrderIndex(count[1]); list[1][count[1]++] = face; } } @@ -5712,12 +5712,36 @@ static inline void add_face(T*** list, U32* count, T* face) { if (count[0] < MAX_FACE_COUNT) { - face->setDrawOrderIndex(count[0]); + //face->setDrawOrderIndex(count[0]); list[0][count[0]++] = face; } } } +// return index into linkset for given object (0 for root prim) +U32 get_linkset_index(LLVOVolume* vobj) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; + if (vobj->isRootEdit()) + { + return 0; + } + + LLViewerObject* root = vobj->getRootEdit(); + U32 idx = 1; + for (const auto& child : root->getChildren()) + { + if (child == vobj) + { + return idx; + } + ++idx; + } + + llassert(false); + return idx; //should never get here +} + void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; @@ -5881,6 +5905,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) avatar->addAttachmentOverridesForObject(vobj, NULL, false); } + U32 linkset_index = get_linkset_index(vobj); + // Standard rigged mesh attachments: bool rigged = !vobj->isAnimatedObject() && skinInfo && vobj->isAttachment(); // Animated objects. Have to check for isRiggedMesh() to @@ -5900,6 +5926,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } + // order by linkset index first and face index second + facep->setDrawOrderIndex(linkset_index * 100 + i); + // HACK -- brute force this check every time a drawable gets rebuilt vobj->updateTEMaterialTextures(i); #if 0 @@ -5939,11 +5968,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (facep->isState(LLFace::RIGGED)) { //face is not rigged but used to be, remove from rigged face pool - LLDrawPoolAvatar* pool = (LLDrawPoolAvatar*) facep->getPool(); - if (pool) - { - pool->removeFace(facep); - } facep->clearState(LLFace::RIGGED); facep->mAvatar = NULL; facep->mSkinInfo = NULL; @@ -6251,7 +6275,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) { LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable(); - if (drawablep && !drawablep->isDead() && drawablep->isState(LLDrawable::REBUILD_ALL) && !drawablep->isState(LLDrawable::RIGGED) ) + if (drawablep && !drawablep->isDead() && drawablep->isState(LLDrawable::REBUILD_ALL)) { LLVOVolume* vobj = drawablep->getVOVolume(); @@ -6285,8 +6309,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) LLVertexBuffer* buff = face->getVertexBuffer(); if (buff) { - llassert(!face->isState(LLFace::RIGGED)); - if (!face->getGeometryVolume(*volume, face->getTEOffset(), vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex())) { //something's gone wrong with the vertex buffer accounting, rebuild this group -- cgit v1.3 From 5c86ec6a6130bef9348d6155c6a7404914c20418 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 24 Oct 2022 16:26:42 -0500 Subject: SL-18105 Add mechanism for applying overrides that were received before associated ViewerObject was ready to receive them. --- indra/llprimitive/lltextureentry.cpp | 11 ++++++++ indra/llprimitive/lltextureentry.h | 4 +-- indra/newview/llgltfmateriallist.cpp | 49 ++++++++++++++++++++++++++++++++---- indra/newview/llgltfmateriallist.h | 10 ++++++++ indra/newview/llviewerobject.cpp | 5 ++-- indra/newview/llvovolume.cpp | 4 +++ 6 files changed, 74 insertions(+), 9 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 68de480d87..d810c6ed25 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -519,6 +519,17 @@ void LLTextureEntry::setGLTFMaterial(LLGLTFMaterial* material) } } +LLGLTFMaterial* LLTextureEntry::getGLTFRenderMaterial() const +{ + if (mGLTFRenderMaterial.notNull()) + { + return mGLTFRenderMaterial; + } + + llassert(getGLTFMaterialOverride() == nullptr); + return getGLTFMaterial(); +} + S32 LLTextureEntry::setGLTFRenderMaterial(LLGLTFMaterial* mat) { if (mGLTFRenderMaterial != mat) diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 8dc3434a01..e37bc9a3b6 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -199,12 +199,12 @@ public: LLGLTFMaterial* getGLTFMaterial() const { return mGLTFMaterial; } // GLTF override - LLGLTFMaterial* getGLTFMaterialOverride() { return mGLTFMaterialOverrides; } + LLGLTFMaterial* getGLTFMaterialOverride() const { return mGLTFMaterialOverrides; } void setGLTFMaterialOverride(LLGLTFMaterial* mat) { mGLTFMaterialOverrides = mat; } // GLTF render material // nuanced behavior here -- if there is no render material, fall back to getGLTFMaterial, but ONLY for the getter, not the setter - LLGLTFMaterial* getGLTFRenderMaterial() const { return mGLTFRenderMaterial.notNull() ? mGLTFRenderMaterial.get() : getGLTFMaterial(); } + LLGLTFMaterial* getGLTFRenderMaterial() const; S32 setGLTFRenderMaterial(LLGLTFMaterial* mat); public: diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 4861c2a33b..cd60d34d2f 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -43,6 +43,8 @@ #include "json/reader.h" #include "json/value.h" +LLGLTFMaterialList gGLTFMaterialList; + namespace { class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler @@ -72,24 +74,27 @@ namespace LL_WARNS() << "LLGLTFMaterialOverrideDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; } } + + LLUUID object_id = message["object_id"].asUUID(); - LLViewerObject * obj = gObjectList.findObject(message["object_id"].asUUID()); - llassert(obj); // should never get an override for an object we don't know about + LLViewerObject * obj = gObjectList.findObject(object_id); S32 side = message["side"].asInteger(); std::string gltf_json = message["gltf_json"].asString(); std::string warn_msg, error_msg; LLPointer override_data = new LLGLTFMaterial(); bool success = override_data->fromJSON(gltf_json, warn_msg, error_msg); + if (!success) { LL_WARNS() << "failed to parse GLTF override data. errors: " << error_msg << " | warnings: " << warn_msg << LL_ENDL; } else { - if (obj) + if (!obj || !obj->setTEGLTFMaterialOverride(side, override_data)) { - obj->setTEGLTFMaterialOverride(side, override_data); + // object not ready to receive override data, queue for later + gGLTFMaterialList.queueOverrideUpdate(object_id, side, override_data); } } @@ -99,7 +104,41 @@ namespace LLGLTFMaterialOverrideDispatchHandler handle_gltf_override_message; } -LLGLTFMaterialList gGLTFMaterialList; +void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data) +{ + override_list_t& overrides = mQueuedOverrides[id]; + + if (overrides.size() < side + 1) + { + overrides.resize(side + 1); + } + + overrides[side] = override_data; +} + +void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) +{ + const LLUUID& id = obj->getID(); + auto& iter = mQueuedOverrides.find(id); + + if (iter != mQueuedOverrides.end()) + { + override_list_t& overrides = iter->second; + for (int i = 0; i < overrides.size(); ++i) + { + if (overrides[i].notNull()) + { + if (!obj->getTE(i)->getGLTFMaterial()) + { // object doesn't have its base GLTF material yet, don't apply override (yet) + return; + } + obj->setTEGLTFMaterialOverride(i, overrides[i]); + } + } + + mQueuedOverrides.erase(iter); + } +} LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id) { diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h index 4b905e32c9..ee32dc8825 100644 --- a/indra/newview/llgltfmateriallist.h +++ b/indra/newview/llgltfmateriallist.h @@ -48,10 +48,20 @@ public: void flushMaterials(); static void registerCallbacks(); + + // save an override update for later (for example, if an override arrived for an unknown object) + void queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data); + + void applyQueuedOverrides(LLViewerObject* obj); + private: typedef std::unordered_map > uuid_mat_map_t; uuid_mat_map_t mList; + typedef std::vector > override_list_t; + typedef std::unordered_map queued_override_map_t; + queued_override_map_t mQueuedOverrides; + LLUUID mLastUpdateKey; }; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 603dcc4fa7..ac519970b7 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -247,6 +247,7 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco LL_WARNS() << "Unknown object pcode " << (S32)pcode << LL_ENDL; res = NULL; break; } + return res; } @@ -5324,8 +5325,8 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma LLTextureEntry* tep = getTE(te); if (!tep) - { - LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL; + { // this could happen if the object is not fully formed yet + // returning TEM_CHANGE_NONE here signals to LLGLTFMaterialList to queue the override for later return retval; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index cb58c173d9..aea4353bc8 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -88,6 +88,7 @@ #include "llcallstack.h" #include "llsculptidsize.h" #include "llavatarappearancedefines.h" +#include "llgltfmateriallist.h" const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; const F32 FORCE_CULL_AREA = 8.f; @@ -5823,6 +5824,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } + // apply any pending material overrides + gGLTFMaterialList.applyQueuedOverrides(vobj); + std::string vobj_name = llformat("Vol%p", vobj); bool is_mesh = vobj->isMesh(); -- cgit v1.3 From 81553613551ffc7c8253d67a3fb3a24137d19d51 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 28 Oct 2022 11:19:43 -0500 Subject: SL-18453 WIP -- Use GLTF draw pool to render shadows. Still need a GLTF specific shadow shader to multiply alpha. --- .../shaders/class1/deferred/shadowAlphaMaskF.glsl | 20 +------ indra/newview/lldrawpool.cpp | 4 +- indra/newview/lldrawpool.h | 18 +++--- indra/newview/lldrawpoolpbropaque.cpp | 48 ++++------------ indra/newview/lldrawpoolpbropaque.h | 19 +++---- indra/newview/llfetchedgltfmaterial.cpp | 65 +++++++++++----------- indra/newview/llvovolume.cpp | 4 +- indra/newview/pipeline.cpp | 16 +++--- indra/newview/pipeline.h | 5 +- 9 files changed, 79 insertions(+), 120 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl index 9b8df0a5a4..32e9714a75 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl @@ -43,29 +43,11 @@ void main() { float alpha = diffuseLookup(vary_texcoord0.xy).a; - // mask cutoff 0 -> no shadow SL-11051 - if (minimum_alpha == 0) + if (alpha < minimum_alpha) { discard; } -#if !defined(IS_FULLBRIGHT) - alpha *= vertex_color.a; -#endif - - if (alpha < 0.05) // treat as totally transparent - { - discard; - } - - if (alpha < 0.88) // treat as semi-transparent - { - if (fract(0.5*floor(target_pos_x / post_pos.w )) < 0.25) - { - discard; - } - } - frag_color = vec4(1,1,1,1); #if !defined(DEPTH_CLAMP) diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 7305177e4a..bfcc24fd13 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -121,8 +121,8 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerTexture *tex0) case POOL_WL_SKY: poolp = new LLDrawPoolWLSky(); break; - case POOL_PBR_OPAQUE: - poolp = new LLDrawPoolPBROpaque(); + case POOL_GLTF_PBR: + poolp = new LLDrawPoolGLTFPBR(); break; default: LL_ERRS() << "Unknown draw pool type!" << LL_ENDL; diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 620438bb1b..cc5d2ddb26 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -60,6 +60,7 @@ public: POOL_TERRAIN, POOL_MATERIALS, POOL_GRASS, + POOL_GLTF_PBR, POOL_TREE, POOL_ALPHA_MASK, POOL_FULLBRIGHT_ALPHA_MASK, @@ -73,7 +74,6 @@ public: POOL_VOIDWATER, POOL_WATER, POOL_ALPHA_POST_WATER, - POOL_PBR_OPAQUE, POOL_ALPHA, // note there is no actual "POOL_ALPHA" but pre-water and post-water pools consume POOL_ALPHA faces NUM_POOL_TYPES, // * invisiprims work by rendering to the depth buffer but not the color buffer, occluding anything rendered after them @@ -114,8 +114,8 @@ public: virtual S32 getNumShadowPasses(); virtual void renderShadow(S32 pass = 0); - virtual void render(S32 pass = 0) = 0; - virtual void prerender() = 0; + virtual void render(S32 pass = 0) {}; + virtual void prerender() {}; virtual U32 getVertexDataMask() = 0; virtual BOOL verify() const { return TRUE; } // Verify that all data in the draw pool is correct! virtual S32 getShaderLevel() const { return mShaderLevel; } @@ -199,8 +199,8 @@ public: PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, PASS_ALPHA_INVISIBLE, PASS_ALPHA_INVISIBLE_RIGGED, - PASS_PBR_OPAQUE, - PASS_PBR_OPAQUE_RIGGED, + PASS_GLTF_PBR, + PASS_GLTF_PBR_RIGGED, NUM_RENDER_TYPES, }; @@ -327,10 +327,10 @@ public: return "PASS_ALPHA_INVISIBLE"; case PASS_ALPHA_INVISIBLE_RIGGED: return "PASS_ALPHA_INVISIBLE_RIGGED"; - case PASS_PBR_OPAQUE: - return "PASS_PBR_OPAQUE"; - case PASS_PBR_OPAQUE_RIGGED: - return "PASS_PBR_OPAQUE_RIGGED"; + case PASS_GLTF_PBR: + return "PASS_GLTF_PBR"; + case PASS_GLTF_PBR_RIGGED: + return "PASS_GLTF_PBR_RIGGED"; default: return "Unknown pass"; diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 2f710e570b..d0c588b65a 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -1,6 +1,6 @@ /** * @file lldrawpoolpbropaque.cpp - * @brief LLDrawPoolPBROpaque class implementation + * @brief LLDrawPoolGLTFPBR class implementation * * $LicenseInfo:firstyear=2022&license=viewerlgpl$ * Second Life Viewer Source Code @@ -31,54 +31,24 @@ #include "llviewershadermgr.h" #include "pipeline.h" -LLDrawPoolPBROpaque::LLDrawPoolPBROpaque() : - LLRenderPass(POOL_PBR_OPAQUE) +LLDrawPoolGLTFPBR::LLDrawPoolGLTFPBR() : + LLRenderPass(POOL_GLTF_PBR) { } -void LLDrawPoolPBROpaque::prerender() +void LLDrawPoolGLTFPBR::renderDeferred(S32 pass) { - mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); -} - -// Forward -void LLDrawPoolPBROpaque::beginRenderPass(S32 pass) -{ -} - -void LLDrawPoolPBROpaque::endRenderPass( S32 pass ) -{ -} - -void LLDrawPoolPBROpaque::render(S32 pass) -{ -} - -void LLDrawPoolPBROpaque::renderDeferred(S32 pass) -{ - if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_MATERIALS)) - { - return; - } - - const U32 type = LLPipeline::RENDER_TYPE_PASS_PBR_OPAQUE; - if (!gPipeline.hasRenderType(type)) - { - return; - } + const U32 type = LLPipeline::RENDER_TYPE_PASS_GLTF_PBR; gGL.flush(); - LLGLDisable blend(GL_BLEND); - LLGLDisable alpha_test(GL_ALPHA_TEST); - LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; for (int i = 0; i < 2; ++i) { bool rigged = (i == 1); - LLGLSLShader* shader = &gDeferredPBROpaqueProgram; + LLGLSLShader* shader = LLPipeline::sShadowRender ? &gDeferredShadowAlphaMaskProgram : &gDeferredPBROpaqueProgram; U32 vertex_data_mask = getVertexDataMask(); if (rigged) @@ -138,3 +108,9 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass) LLGLSLShader::sCurBoundShaderPtr->unbind(); } + +void LLDrawPoolGLTFPBR::renderShadow(S32 pass) +{ + renderDeferred(pass); +} + diff --git a/indra/newview/lldrawpoolpbropaque.h b/indra/newview/lldrawpoolpbropaque.h index c355b10b12..3d80a0657e 100644 --- a/indra/newview/lldrawpoolpbropaque.h +++ b/indra/newview/lldrawpoolpbropaque.h @@ -29,7 +29,7 @@ #include "lldrawpool.h" -class LLDrawPoolPBROpaque : public LLRenderPass +class LLDrawPoolGLTFPBR final : public LLRenderPass { public: enum @@ -44,20 +44,17 @@ public: | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_COLOR }; - virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } + U32 getVertexDataMask() override { return VERTEX_DATA_MASK; } - LLDrawPoolPBROpaque(); + LLDrawPoolGLTFPBR(); - /*virtual*/ S32 getNumDeferredPasses() { return 1; } - /*virtual*/ void renderDeferred(S32 pass); + S32 getNumDeferredPasses() override { return 1; } + void renderDeferred(S32 pass) override; - // Non ALM isn't supported - /*virtual*/ void beginRenderPass(S32 pass); - /*virtual*/ void endRenderPass(S32 pass); - /*virtual*/ S32 getNumPasses() { return 0; } - /*virtual*/ void render(S32 pass = 0); - /*virtual*/ void prerender(); + S32 getNumShadowPasses() override { return 1; } + void renderShadow(S32 pass) override; + }; #endif // LL_LLDRAWPOOLPBROPAQUE_H diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 2d3015635c..22be8a03dd 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -30,6 +30,7 @@ #include "llviewertexturelist.h" #include "llavatarappearancedefines.h" #include "llshadermgr.h" +#include "pipeline.h" LLFetchedGLTFMaterial::LLFetchedGLTFMaterial() : LLGLTFMaterial() @@ -66,38 +67,40 @@ void LLFetchedGLTFMaterial::bind(LLGLSLShader* shader) gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep); } - - if (mNormalTexture.notNull()) - { - shader->bindTexture(LLShaderMgr::BUMP_MAP, mNormalTexture); - } - else - { - shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); - } - - if (mMetallicRoughnessTexture.notNull()) - { - shader->bindTexture(LLShaderMgr::SPECULAR_MAP, mMetallicRoughnessTexture); // PBR linear packed Occlusion, Roughness, Metal. - } - else + if (!LLPipeline::sShadowRender) { - shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); + if (mNormalTexture.notNull()) + { + shader->bindTexture(LLShaderMgr::BUMP_MAP, mNormalTexture); + } + else + { + shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); + } + + if (mMetallicRoughnessTexture.notNull()) + { + shader->bindTexture(LLShaderMgr::SPECULAR_MAP, mMetallicRoughnessTexture); // PBR linear packed Occlusion, Roughness, Metal. + } + else + { + shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); + } + + if (mEmissiveTexture.notNull()) + { + shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, mEmissiveTexture); // PBR sRGB Emissive + } + else + { + shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, LLViewerFetchedTexture::sWhiteImagep); + } + + // NOTE: base color factor is baked into vertex stream + + shader->uniform1f(LLShaderMgr::ROUGHNESS_FACTOR, mRoughnessFactor); + shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, mMetallicFactor); + shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, mEmissiveColor.mV); } - if (mEmissiveTexture.notNull()) - { - shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, mEmissiveTexture); // PBR sRGB Emissive - } - else - { - shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, LLViewerFetchedTexture::sWhiteImagep); - } - - // NOTE: base color factor is baked into vertex stream - - shader->uniform1f(LLShaderMgr::ROUGHNESS_FACTOR, mRoughnessFactor); - shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, mMetallicFactor); - shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, mEmissiveColor.mV); - } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 663dd2d9ec..cf104aa89d 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5986,7 +5986,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 type = gPipeline.getPoolTypeFromTE(te, tex); if (is_pbr && gltf_mat && gltf_mat->mAlphaMode != LLGLTFMaterial::ALPHA_MODE_BLEND) { - type = LLDrawPool::POOL_PBR_OPAQUE; + type = LLDrawPool::POOL_GLTF_PBR; } else if (type != LLDrawPool::POOL_ALPHA && force_simple) @@ -6790,7 +6790,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND) registerFace(group, facep, LLRenderPass::PASS_ALPHA); else - registerFace(group, facep, LLRenderPass::PASS_PBR_OPAQUE); + registerFace(group, facep, LLRenderPass::PASS_GLTF_PBR); } else // do NOT use 'fullbright' for this logic or you risk sending diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a0fec90f87..aacf6fa73e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -428,7 +428,7 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_BUMP); getPool(LLDrawPool::POOL_MATERIALS); getPool(LLDrawPool::POOL_GLOW); - getPool(LLDrawPool::POOL_PBR_OPAQUE); + getPool(LLDrawPool::POOL_GLTF_PBR); resetFrameStats(); @@ -1568,7 +1568,7 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) poolp = mWLSkyPool; break; - case LLDrawPool::POOL_PBR_OPAQUE: + case LLDrawPool::POOL_GLTF_PBR: poolp = mPBROpaquePool; break; @@ -1649,7 +1649,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } else if (gltf_mat) { - return LLDrawPool::POOL_PBR_OPAQUE; + return LLDrawPool::POOL_GLTF_PBR; } else if (mat && !alpha) { @@ -5777,7 +5777,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; - case LLDrawPool::POOL_PBR_OPAQUE: + case LLDrawPool::POOL_GLTF_PBR: if( mPBROpaquePool ) { llassert(0); @@ -5910,7 +5910,7 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mGroundPool = NULL; break; - case LLDrawPool::POOL_PBR_OPAQUE: + case LLDrawPool::POOL_GLTF_PBR: llassert( poolp == mPBROpaquePool ); mPBROpaquePool = NULL; break; @@ -9604,7 +9604,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, no_idx_mask, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, no_idx_mask, true, false, rigged); renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, no_idx_mask, true, false, rigged); - renderMaskedObjects(LLRenderPass::PASS_PBR_OPAQUE, no_idx_mask, true, false, rigged); } } } @@ -9943,6 +9942,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_ALPHA_PRE_WATER, LLPipeline::RENDER_TYPE_ALPHA_POST_WATER, LLPipeline::RENDER_TYPE_GRASS, + LLPipeline::RENDER_TYPE_GLTF_PBR, LLPipeline::RENDER_TYPE_FULLBRIGHT, LLPipeline::RENDER_TYPE_BUMP, LLPipeline::RENDER_TYPE_VOLUME, @@ -10000,8 +10000,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_PASS_NORMSPEC_BLEND_RIGGED, LLPipeline::RENDER_TYPE_PASS_NORMSPEC_MASK_RIGGED, LLPipeline::RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED, - LLPipeline::RENDER_TYPE_PASS_PBR_OPAQUE, - LLPipeline::RENDER_TYPE_PASS_PBR_OPAQUE_RIGGED, + LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, + LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED, END_RENDER_TYPES); gGL.setColorMask(false, false); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 3b41d60356..7bad1cbe87 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -475,6 +475,7 @@ public: RENDER_TYPE_INVISIBLE = LLDrawPool::POOL_INVISIBLE, RENDER_TYPE_VOIDWATER = LLDrawPool::POOL_VOIDWATER, RENDER_TYPE_WATER = LLDrawPool::POOL_WATER, + RENDER_TYPE_GLTF_PBR = LLDrawPool::POOL_GLTF_PBR, RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA, RENDER_TYPE_ALPHA_PRE_WATER = LLDrawPool::POOL_ALPHA_PRE_WATER, RENDER_TYPE_ALPHA_POST_WATER = LLDrawPool::POOL_ALPHA_POST_WATER, @@ -535,8 +536,8 @@ public: RENDER_TYPE_PASS_NORMSPEC_MASK_RIGGED = LLRenderPass::PASS_NORMSPEC_MASK_RIGGED, RENDER_TYPE_PASS_NORMSPEC_EMISSIVE = LLRenderPass::PASS_NORMSPEC_EMISSIVE, RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED = LLRenderPass::PASS_NORMSPEC_EMISSIVE_RIGGED, - RENDER_TYPE_PASS_PBR_OPAQUE = LLRenderPass::PASS_PBR_OPAQUE, - RENDER_TYPE_PASS_PBR_OPAQUE_RIGGED = LLRenderPass::PASS_PBR_OPAQUE_RIGGED, + RENDER_TYPE_PASS_GLTF_PBR = LLRenderPass::PASS_GLTF_PBR, + RENDER_TYPE_PASS_GLTF_PBR_RIGGED = LLRenderPass::PASS_GLTF_PBR_RIGGED, // Following are object types (only used in drawable mRenderType) RENDER_TYPE_HUD = LLRenderPass::NUM_RENDER_TYPES, RENDER_TYPE_VOLUME, -- cgit v1.3 From 8d2ac419b22c8c9475f2efb312dd198ac8eb9fb7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 16 Nov 2022 14:49:17 -0600 Subject: SL-18154 Profile guided optimizations vs release viewer. Trim some unused abilities and remove some more fast timers. --- indra/llcommon/llprofiler.h | 14 +++- indra/llrender/llglslshader.cpp | 5 +- indra/llrender/llglslshader.h | 4 +- indra/llrender/llvertexbuffer.cpp | 2 +- indra/llrender/llvertexbuffer.h | 4 +- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llappviewer.cpp | 39 +++------- indra/newview/lldrawpool.cpp | 14 ++-- indra/newview/lldrawpool.h | 2 +- indra/newview/lldrawpoolalpha.cpp | 17 +++-- indra/newview/lldrawpoolbump.cpp | 5 +- indra/newview/lldrawpoolmaterials.cpp | 2 +- indra/newview/llface.cpp | 9 +-- indra/newview/llspatialpartition.cpp | 4 +- indra/newview/llspatialpartition.h | 6 +- indra/newview/llviewercontrol.cpp | 1 - indra/newview/llviewerdisplay.cpp | 67 +++++------------ indra/newview/llviewermenu.cpp | 27 ------- indra/newview/llviewerstats.cpp | 12 +-- indra/newview/llviewertexture.cpp | 62 ---------------- indra/newview/llviewertexturelist.cpp | 4 +- indra/newview/llvovolume.cpp | 6 -- indra/newview/llvowlsky.cpp | 4 +- indra/newview/pipeline.cpp | 85 +++++++++++----------- indra/newview/pipeline.h | 6 +- indra/newview/skins/default/xui/en/menu_viewer.xml | 9 --- 26 files changed, 122 insertions(+), 290 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llcommon/llprofiler.h b/indra/llcommon/llprofiler.h index ac20209062..c03b2e93f4 100644 --- a/indra/llcommon/llprofiler.h +++ b/indra/llcommon/llprofiler.h @@ -86,8 +86,12 @@ extern thread_local bool gProfilerEnabled; #define TRACY_ONLY_IPV4 1 #include "Tracy.hpp" - // Disable memory tracing when enabled, but enabled + // Enable OpenGL profiling #define LL_PROFILER_ENABLE_TRACY_OPENGL 1 + + // Enable RenderDoc labeling + #define LL_PROFILER_ENABLE_RENDER_DOC 0 + #endif #if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY @@ -153,8 +157,6 @@ extern thread_local bool gProfilerEnabled; // disable memory tracking (incompatible with GPU tracing #define LL_PROFILE_ALLOC(ptr, size) (void)(ptr); (void)(size); #define LL_PROFILE_FREE(ptr) (void)(ptr); - -#define LL_LABEL_OBJECT_GL(type, name, length, label) glObjectLabel(type, name, length, label) #else #define LL_PROFILE_GPU_ZONE(name) (void)name; #define LL_PROFILE_GPU_ZONEC(name,color) (void)name;(void)color; @@ -173,6 +175,12 @@ extern thread_local bool gProfilerEnabled; #endif +#if LL_PROFILER_ENABLE_RENDER_DOC +#define LL_LABEL_OBJECT_GL(type, name, length, label) glObjectLabel(type, name, length, label) +#else +#define LL_LABEL_OBJECT_GL(type, name, length, label) +#endif + #include "llprofilercategories.h" #endif // LL_PROFILER_H diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 0a834b28e3..661ea6c4fa 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -505,7 +505,7 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, unbind(); } -#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#ifdef LL_PROFILER_ENABLE_RENDER_DOC setLabel(mName.c_str()); #endif @@ -1792,9 +1792,8 @@ void LLShaderUniforms::apply(LLGLSLShader* shader) } } -#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#ifdef LL_PROFILER_ENABLE_RENDER_DOC void LLGLSLShader::setLabel(const char* label) { LL_LABEL_OBJECT_GL(GL_PROGRAM, mProgramObject, strlen(label), label); } - #endif diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 0df0531dce..57bd4987bc 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -300,7 +300,7 @@ public: // this pointer should be set to whichever shader represents this shader's rigged variant LLGLSLShader* mRiggedVariant = nullptr; - #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + #ifdef LL_PROFILER_ENABLE_RENDER_DOC void setLabel(const char* label); #endif @@ -315,7 +315,7 @@ extern LLGLSLShader gSolidColorProgram; //Alpha mask shader (declared here so llappearance can access properly) extern LLGLSLShader gAlphaMaskProgram; -#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#ifdef LL_PROFILER_ENABLE_RENDER_DOC #define LL_SET_SHADER_LABEL(shader) shader.setLabel(#shader) #else #define LL_SET_SHADER_LABEL(shader, label) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index f51000b9a6..fc24c6846d 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -574,7 +574,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of } } -#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#ifdef LL_PROFILER_ENABLE_RENDER_DOC void LLVertexBuffer::setLabel(const char* label) { LL_LABEL_OBJECT_GL(GL_BUFFER, mGLBuffer, strlen(label), label); } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 99b8b54d69..e846ab70e2 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -303,7 +303,7 @@ public: //for debugging, validate data in given range is valid void validateRange(U32 start, U32 end, U32 count, U32 offset) const; - #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + #ifdef LL_PROFILER_ENABLE_RENDER_DOC void setLabel(const char* label); #endif @@ -376,7 +376,7 @@ public: static U32 sSetCount; }; -#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#ifdef LL_PROFILER_ENABLE_RENDER_DOC #define LL_LABEL_VERTEX_BUFFER(buf, name) buf->setLabel(name) #else #define LL_LABEL_VERTEX_BUFFER(buf, name) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 71611a58bc..9f10e5cac5 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10563,7 +10563,7 @@ RenderUseTriStrips Comment - Use triangle strips for rendering prims. + DEPRECATED - now always assumed to be false - Use triangle strips for rendering prims. Persist 1 Type diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index f3f512a6f2..efc2726785 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1311,23 +1311,6 @@ void LLAppViewer::initMaxHeapSize() LLMemory::initMaxHeapSizeGB(max_heap_size_gb); } -static LLTrace::BlockTimerStatHandle FTM_MESSAGES("System Messages"); -static LLTrace::BlockTimerStatHandle FTM_SLEEP1("Sleep1"); -static LLTrace::BlockTimerStatHandle FTM_SLEEP2("Sleep2"); -static LLTrace::BlockTimerStatHandle FTM_YIELD("Yield"); - -static LLTrace::BlockTimerStatHandle FTM_TEXTURE_CACHE("Texture Cache"); -static LLTrace::BlockTimerStatHandle FTM_DECODE("Image Decode"); -static LLTrace::BlockTimerStatHandle FTM_FETCH("Image Fetch"); - -static LLTrace::BlockTimerStatHandle FTM_LFS("LFS Thread"); -static LLTrace::BlockTimerStatHandle FTM_PAUSE_THREADS("Pause Threads"); -static LLTrace::BlockTimerStatHandle FTM_IDLE("Idle"); -static LLTrace::BlockTimerStatHandle FTM_PUMP("Pump"); -static LLTrace::BlockTimerStatHandle FTM_PUMP_SERVICE("Service"); -static LLTrace::BlockTimerStatHandle FTM_SERVICE_CALLBACK("Callback"); -static LLTrace::BlockTimerStatHandle FTM_AGENT_AUTOPILOT("Autopilot"); -static LLTrace::BlockTimerStatHandle FTM_AGENT_UPDATE("Update"); // externally visible timers LLTrace::BlockTimerStatHandle FTM_FRAME("Frame"); @@ -1406,7 +1389,7 @@ bool LLAppViewer::doFrame() if (gViewerWindow) { - LL_RECORD_BLOCK_TIME(FTM_MESSAGES); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("System Messages"); gViewerWindow->getWindow()->processMiscNativeEvents(); } @@ -1417,7 +1400,7 @@ bool LLAppViewer::doFrame() if (gViewerWindow) { - LL_RECORD_BLOCK_TIME(FTM_MESSAGES); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("System Messages"); if (!restoreErrorTrap()) { LL_WARNS() << " Someone took over my signal/exception handler (post messagehandling)!" << LL_ENDL; @@ -1480,7 +1463,7 @@ bool LLAppViewer::doFrame() } { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df idle"); //LL_RECORD_BLOCK_TIME(FTM_IDLE); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df idle"); idle(); } @@ -1541,7 +1524,7 @@ bool LLAppViewer::doFrame() static LLCachedControl yield_time(gSavedSettings, "YieldTime", -1); if(yield_time >= 0) { - LL_RECORD_BLOCK_TIME(FTM_YIELD); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("Yield"); LL_PROFILE_ZONE_NUM( yield_time ) ms_sleep(yield_time); } @@ -1594,7 +1577,7 @@ bool LLAppViewer::doFrame() work_pending += updateTextureThreads(max_time); { - LL_RECORD_BLOCK_TIME(FTM_LFS); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("LFS Thread"); io_pending += LLLFSThread::updateClass(1); } @@ -1663,15 +1646,15 @@ S32 LLAppViewer::updateTextureThreads(F32 max_time) { S32 work_pending = 0; { - LL_RECORD_BLOCK_TIME(FTM_TEXTURE_CACHE); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("Texture Cache"); work_pending += LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread } { - LL_RECORD_BLOCK_TIME(FTM_DECODE); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("Image Decode"); work_pending += LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread } { - LL_RECORD_BLOCK_TIME(FTM_FETCH); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("Image Fetch"); work_pending += LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread } return work_pending; @@ -4787,7 +4770,7 @@ void LLAppViewer::idle() } { - LL_RECORD_BLOCK_TIME(FTM_AGENT_AUTOPILOT); + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("Autopilot"); // Handle automatic walking towards points gAgentPilot.updateTarget(); gAgent.autoPilot(&yaw); @@ -4803,7 +4786,7 @@ void LLAppViewer::idle() || (agent_force_update_time > (1.0f / (F32) AGENT_FORCE_UPDATES_PER_SECOND)); if (force_update || (agent_update_time > (1.0f / (F32) AGENT_UPDATES_PER_SECOND))) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; //LL_RECORD_BLOCK_TIME(FTM_AGENT_UPDATE); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; // Send avatar and camera info mLastAgentControlFlags = gAgent.getControlFlags(); mLastAgentForceUpdate = force_update ? 0 : agent_force_update_time; @@ -4854,7 +4837,7 @@ void LLAppViewer::idle() if (!gDisconnected) { - LL_RECORD_BLOCK_TIME(FTM_NETWORK); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Network"); //////////////////////////////////////////////// // diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index bfcc24fd13..b3ae673aed 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -566,17 +566,13 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba } } - if (params.mGroup) - { - params.mGroup->rebuildMesh(); - } - - LLGLDisable cull(params.mGLTFMaterial && params.mGLTFMaterial->mDoubleSided ? GL_CULL_FACE : 0); - - //LLGLEnableFunc stencil_test(GL_STENCIL_TEST, params.mSelected, &LLGLCommonFunc::selected_stencil_test); + //if (params.mGroup) // TOO LATE! + //{ + // params.mGroup->rebuildMesh(); + //} params.mVertexBuffer->setBufferFast(mask); - params.mVertexBuffer->drawRangeFast(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); if (tex_setup) { diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index cc5d2ddb26..2c8d6ff652 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -204,7 +204,7 @@ public: NUM_RENDER_TYPES, }; - #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + #ifdef LL_PROFILER_ENABLE_RENDER_DOC static inline const char* lookupPassName(U32 pass) { switch (pass) diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index aa8d4d167e..71b568a436 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -406,7 +406,7 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask) params.mGroup->rebuildMesh(); } params.mVertexBuffer->setBufferFast(rigged ? mask | LLVertexBuffer::MAP_WEIGHT4 : mask); - params.mVertexBuffer->drawRangeFast(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); } } } @@ -435,7 +435,7 @@ inline void Draw(LLDrawInfo* draw, U32 mask) { draw->mVertexBuffer->setBufferFast(mask); LLRenderPass::applyModelMatrix(*draw); - draw->mVertexBuffer->drawRangeFast(draw->mDrawMode, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); + draw->mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); } bool LLDrawPoolAlpha::TexSetup(LLDrawInfo* draw, bool use_material) @@ -531,7 +531,7 @@ void LLDrawPoolAlpha::drawEmissive(U32 mask, LLDrawInfo* draw) { LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, 1.f); draw->mVertexBuffer->setBufferFast((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); - draw->mVertexBuffer->drawRangeFast(draw->mDrawMode, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); + draw->mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); } @@ -678,7 +678,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) if (current_shader != target_shader) { - gPipeline.bindDeferredShader(*target_shader); + target_shader->bind(); + //gPipeline.bindDeferredShader(*target_shader); } params.mGLTFMaterial->bind(target_shader); @@ -729,7 +730,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) if (current_shader != target_shader) { - gPipeline.bindDeferredShader(*target_shader); + //gPipeline.bindDeferredShader(*target_shader); + target_shader->bind(); } } else if (!params.mFullbright) @@ -750,7 +752,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) if (current_shader != target_shader) {// If we need shaders, and we're not ALREADY using the proper shader, then bind it // (this way we won't rebind shaders unnecessarily). - gPipeline.bindDeferredShader(*target_shader); + //gPipeline.bindDeferredShader(*target_shader); + target_shader->bind(); } LLVector4 spec_color(1, 1, 1, 1); @@ -821,7 +824,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) } params.mVertexBuffer->setBufferFast(drawMask); - params.mVertexBuffer->drawRangeFast(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); if (reset_minimum_alpha) { diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 75917d0ae3..86473beace 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -562,8 +562,7 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL params.mGroup->rebuildMesh(); } params.mVertexBuffer->setBuffer(mask); - params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); - gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); } } @@ -1439,7 +1438,7 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL params.mGroup->rebuildMesh(); } params.mVertexBuffer->setBufferFast(mask); - params.mVertexBuffer->drawRangeFast(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); if (tex_setup) { diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index d97f0714ef..1c9fb55d06 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -263,7 +263,7 @@ void LLDrawPoolMaterials::pushMaterialsBatch(LLDrawInfo& params, U32 mask, bool //LLGLEnableFunc stencil_test(GL_STENCIL_TEST, params.mSelected, &LLGLCommonFunc::selected_stencil_test); params.mVertexBuffer->setBufferFast(mask); - params.mVertexBuffer->drawRangeFast(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); if (tex_setup) { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 528675072b..6557bcb81d 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -2460,13 +2460,8 @@ S32 LLFace::pushVertices(const U16* index_array) const { if (mIndicesCount) { - U32 render_type = LLRender::TRIANGLES; - if (mDrawInfo) - { - render_type = mDrawInfo->mDrawMode; - } - mVertexBuffer->drawRange(render_type, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex); - gPipeline.addTrianglesDrawn(mIndicesCount, render_type); + mVertexBuffer->drawRange(LLRender::TRIANGLES, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex); + gPipeline.addTrianglesDrawn(mIndicesCount); } return mIndicesCount; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 61e9d261f7..7d1bc7fc48 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -4049,7 +4049,6 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, mGroup(NULL), mFace(NULL), mDistance(0.f), - mDrawMode(LLRender::TRIANGLES), mMaterial(NULL), mShaderMask(0), mSpecColor(1.0f, 1.0f, 1.0f, 0.5f), @@ -4058,8 +4057,7 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, mHasGlow(FALSE), mEnvIntensity(0.0f), mAlphaMaskCutoff(0.5f), - mDiffuseAlphaMode(0), - mSelected(selected) + mDiffuseAlphaMode(0) { mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset); diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 0d16b818f1..692aae6fa4 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -97,7 +97,6 @@ public: // used to update the decode priority of textures in this DrawInfo std::vector mTextureListVSize; - S32 mDebugColor; const LLMatrix4* mTextureMatrix; const LLMatrix4* mModelMatrix; U16 mStart; @@ -107,13 +106,14 @@ public: BOOL mFullbright; U8 mBump; U8 mShiny; + U8 mTextureTimer = 0; BOOL mParticle; F32 mPartSize; F32 mVSize; LLSpatialGroup* mGroup; LL_ALIGN_16(LLFace* mFace); //associated face F32 mDistance; - U32 mDrawMode; + S32 mDebugColor; // Material pointer here is likely for debugging only and are immaterial (zing!) LLMaterialPtr mMaterial; @@ -136,11 +136,9 @@ public: F32 mEnvIntensity; F32 mAlphaMaskCutoff; U8 mDiffuseAlphaMode; - bool mSelected; LLPointer mAvatar = nullptr; LLMeshSkinInfo* mSkinInfo = nullptr; - struct CompareTexture { bool operator()(const LLDrawInfo& lhs, const LLDrawInfo& rhs) diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 98627f8313..0c9324cc42 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -689,7 +689,6 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "OctreeAlphaDistanceFactor", handleRepartition); setting_setup_signal_listener(gSavedSettings, "OctreeAttachmentSizeFactor", handleRepartition); setting_setup_signal_listener(gSavedSettings, "RenderMaxTextureIndex", handleSetShaderChanged); - setting_setup_signal_listener(gSavedSettings, "RenderUseTriStrips", handleResetVertexBuffersChanged); setting_setup_signal_listener(gSavedSettings, "RenderUIBuffer", handleWindowResized); setting_setup_signal_listener(gSavedSettings, "RenderDepthOfField", handleReleaseGLBufferChanged); setting_setup_signal_listener(gSavedSettings, "RenderFSAASamples", handleReleaseGLBufferChanged); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 7709054d24..40857b732c 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -184,11 +184,9 @@ void display_startup() glClear(GL_DEPTH_BUFFER_BIT); } -static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Update Camera"); - void display_update_camera() { - LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Update Camera"); // TODO: cut draw distance down if customizing avatar? // TODO: cut draw distance on per-parcel basis? @@ -246,32 +244,15 @@ void display_stats() } } -static LLTrace::BlockTimerStatHandle FTM_PICK("Picking"); -static LLTrace::BlockTimerStatHandle FTM_RENDER("Render"); -static LLTrace::BlockTimerStatHandle FTM_RENDER_HUD("Render HUD"); -static LLTrace::BlockTimerStatHandle FTM_UPDATE_SKY("Update Sky"); -static LLTrace::BlockTimerStatHandle FTM_UPDATE_DYNAMIC_TEXTURES("Update Dynamic Textures"); -static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE("Update Images"); -static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_CLASS("Class"); -static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_BUMP("Image Update Bump"); -static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_LIST("List"); -static LLTrace::BlockTimerStatHandle FTM_MATERIALS_FLUSH("GLTF Materials Cleanup"); -static LLTrace::BlockTimerStatHandle FTM_RESIZE_WINDOW("Resize Window"); -static LLTrace::BlockTimerStatHandle FTM_HUD_UPDATE("HUD Update"); -static LLTrace::BlockTimerStatHandle FTM_DISPLAY_UPDATE_GEOM("Update Geom"); -static LLTrace::BlockTimerStatHandle FTM_TEXTURE_UNBIND("Texture Unbind"); -static LLTrace::BlockTimerStatHandle FTM_TELEPORT_DISPLAY("Teleport Display"); -static LLTrace::BlockTimerStatHandle FTM_EEP_UPDATE("Env Update"); - // Paint the display! void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { - LL_RECORD_BLOCK_TIME(FTM_RENDER); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Render"); if (gWindowResized) { //skip render on frames where window has been resized LL_DEBUGS("Window") << "Resizing window" << LL_ENDL; - LL_RECORD_BLOCK_TIME(FTM_RESIZE_WINDOW); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Resize Window"); gGL.flush(); glClear(GL_COLOR_BUFFER_BIT); gViewerWindow->getWindow()->swapBuffers(); @@ -293,11 +274,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) for_snapshot = FALSE; } - if (LLPipeline::sRenderFrameTest) - { - send_agent_pause(); - } - gSnapshot = for_snapshot; LLGLSDefault gls_default; @@ -342,8 +318,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gViewerWindow->checkSettings(); { - LL_RECORD_BLOCK_TIME(FTM_PICK); - LLAppViewer::instance()->pingMainloopTimeout("Display:Pick"); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Picking"); gViewerWindow->performPick(); } @@ -421,7 +396,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (gTeleportDisplay) { - LL_RECORD_BLOCK_TIME(FTM_TELEPORT_DISPLAY); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Teleport Display"); LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport"); static LLCachedControl teleport_arrival_delay(gSavedSettings, "TeleportArrivalDelay"); static LLCachedControl teleport_local_delay(gSavedSettings, "TeleportLocalDelay"); @@ -633,7 +608,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) { LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures"); - LL_RECORD_BLOCK_TIME(FTM_UPDATE_DYNAMIC_TEXTURES); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Update Dynamic Textures"); if (LLViewerDynamicTexture::updateAllInstances()) { gGL.setColorMask(true, true); @@ -664,21 +639,21 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) stop_glerror(); { - LL_RECORD_BLOCK_TIME(FTM_EEP_UPDATE); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Env Update"); // update all the sky/atmospheric/water settings LLEnvironment::instance().update(LLViewerCamera::getInstance()); } // *TODO: merge these two methods { - LL_RECORD_BLOCK_TIME(FTM_HUD_UPDATE); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("HUD Update"); LLHUDManager::getInstance()->updateEffects(); LLHUDObject::updateAll(); stop_glerror(); } { - LL_RECORD_BLOCK_TIME(FTM_DISPLAY_UPDATE_GEOM); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Update Geom"); const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds.value(); // 50 ms/second update time gPipeline.createObjects(max_geom_update_time); gPipeline.processPartitionQ(); @@ -789,27 +764,27 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages"); { - LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE); + LL_PROFILE_ZONE_NAMED("Update Images"); { - LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_CLASS); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Class"); LLViewerTexture::updateClass(); } { - LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_BUMP); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Image Update Bump"); gBumpImageList.updateImages(); // must be called before gTextureList version so that it's textures are thrown out first. } { - LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_LIST); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("List"); F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds.value(); // 50 ms/second decode time max_image_decode_time = llclamp(max_image_decode_time, 0.002f, 0.005f ); // min 2ms/frame, max 5ms/frame) gTextureList.updateImages(max_image_decode_time); } { - LL_RECORD_BLOCK_TIME(FTM_MATERIALS_FLUSH); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("GLTF Materials Cleanup"); //remove dead gltf materials gGLTFMaterialList.flushMaterials(); } @@ -988,7 +963,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } { - LL_RECORD_BLOCK_TIME(FTM_TEXTURE_UNBIND); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Texture Unbind"); for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++) { //dummy cleanup of any currently bound textures if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) @@ -1041,12 +1016,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) stop_glerror(); - if (LLPipeline::sRenderFrameTest) - { - send_agent_resume(); - LLPipeline::sRenderFrameTest = FALSE; - } - display_stats(); LLAppViewer::instance()->pingMainloopTimeout("Display:Done"); @@ -1063,7 +1032,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // WIP simplified copy of display() that does minimal work void display_cube_face() { - LL_RECORD_BLOCK_TIME(FTM_RENDER); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Render Cube Face"); LL_PROFILE_GPU_ZONE("display cube face"); llassert(!gSnapshot); @@ -1451,11 +1420,9 @@ void render_ui(F32 zoom_factor, int subfield) } } -static LLTrace::BlockTimerStatHandle FTM_SWAP("Swap"); - void swap() { - LL_RECORD_BLOCK_TIME(FTM_SWAP); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Swap"); LL_PROFILE_GPU_ZONE("swap"); if (gDisplaySwapBuffers) { diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index ca96baee0a..c214ea164d 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1185,31 +1185,6 @@ class LLAdvancedCheckPeriodicSlowFrame : public view_listener_t }; - -//////////////// -// FRAME TEST // -//////////////// - - -class LLAdvancedToggleFrameTest : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - LLPipeline::sRenderFrameTest = !(LLPipeline::sRenderFrameTest); - return true; - } -}; - -class LLAdvancedCheckFrameTest : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - bool new_value = LLPipeline::sRenderFrameTest; - return new_value; - } -}; - - /////////////////////////// // SELECTED TEXTURE INFO // // @@ -9438,8 +9413,6 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedCheckRandomizeFramerate(), "Advanced.CheckRandomizeFramerate"); view_listener_t::addMenu(new LLAdvancedTogglePeriodicSlowFrame(), "Advanced.TogglePeriodicSlowFrame"); view_listener_t::addMenu(new LLAdvancedCheckPeriodicSlowFrame(), "Advanced.CheckPeriodicSlowFrame"); - view_listener_t::addMenu(new LLAdvancedToggleFrameTest(), "Advanced.ToggleFrameTest"); - view_listener_t::addMenu(new LLAdvancedCheckFrameTest(), "Advanced.CheckFrameTest"); view_listener_t::addMenu(new LLAdvancedHandleAttachedLightParticles(), "Advanced.HandleAttachedLightParticles"); view_listener_t::addMenu(new LLAdvancedCheckRenderShadowOption(), "Advanced.CheckRenderShadowOption"); view_listener_t::addMenu(new LLAdvancedClickRenderShadowOption(), "Advanced.ClickRenderShadowOption"); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 0be9abadbb..32fb7c13a9 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -319,6 +319,8 @@ extern U32 gVisTested; void update_statistics() { + LL_PROFILE_ZONE_SCOPED; + gTotalWorldData += gVLManager.getTotalBytes(); gTotalObjectData += gObjectData; @@ -350,16 +352,8 @@ void update_statistics() typedef LLTrace::StatType::instance_tracker_t stat_type_t; - F64Seconds idle_secs = last_frame_recording.getSum(*stat_type_t::getInstance("Idle")); - F64Seconds network_secs = last_frame_recording.getSum(*stat_type_t::getInstance("Network")); - record(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*stat_type_t::getInstance("Frame"))); - record(LLStatViewer::UPDATE_STACKTIME, idle_secs - network_secs); - record(LLStatViewer::NETWORK_STACKTIME, network_secs); - record(LLStatViewer::IMAGE_STACKTIME, last_frame_recording.getSum(*stat_type_t::getInstance("Update Images"))); - record(LLStatViewer::REBUILD_STACKTIME, last_frame_recording.getSum(*stat_type_t::getInstance("Sort Draw State"))); - record(LLStatViewer::RENDER_STACKTIME, last_frame_recording.getSum(*stat_type_t::getInstance("Render Geometry"))); - + if (gAgent.getRegion() && isAgentAvatarValid()) { LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 590f24d359..c2e09b2882 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1792,68 +1792,6 @@ void LLViewerFetchedTexture::processTextureStats() void LLViewerFetchedTexture::updateVirtualSize() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - if(!mMaxVirtualSizeResetCounter) - { - addTextureStats(0.f, FALSE);//reset - } - - if (getBoostLevel() >= LLViewerTexture::BOOST_HIGH) - { //always load boosted textures at highest priority full res - addTextureStats(sMaxVirtualSize); - return; - } - - if (sDesiredDiscardBias > 0.f) - { - // running out of video memory, don't hold onto high res textures in the background - mMaxVirtualSize = 0.f; - } - - for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) - { - llassert(mNumFaces[ch] <= mFaceList[ch].size()); - - for(U32 i = 0; i < mNumFaces[ch]; i++) - { - LLFace* facep = mFaceList[ch][i]; - if( facep ) - { - LLDrawable* drawable = facep->getDrawable(); - if (drawable) - { - if(drawable->isRecentlyVisible()) - { - if ((getBoostLevel() == LLViewerTexture::BOOST_NONE || getBoostLevel() == LLViewerTexture::BOOST_ALM) - && drawable->getVObj() - && drawable->getVObj()->isSelected()) - { - setBoostLevel(LLViewerTexture::BOOST_SELECTED); - } - addTextureStats(facep->getVirtualSize()); - //drawable->getVObj()->setDebugText(llformat("%d:%d", (S32)sqrtf(facep->getVirtualSize()), (S32)sqrtf(getMaxVirtualSize()))); - } - else - { - //drawable->getVObj()->setDebugText(""); - } - } - } - } - } - //reset whether or not a face was selected after 10 seconds - const F32 SELECTION_RESET_TIME = 10.f; - - if (getBoostLevel() == LLViewerTexture::BOOST_SELECTED && - gFrameTimeSeconds - mSelectedTime > SELECTION_RESET_TIME) - { - // Could have been BOOST_ALM, but if user was working with this texture, better keep it as NONE - setBoostLevel(LLViewerTexture::BOOST_NONE); - } - - if(mMaxVirtualSizeResetCounter > 0) - { - mMaxVirtualSizeResetCounter--; - } reorganizeFaceList(); reorganizeVolumeList(); } diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 55a735e906..338aac2ccc 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1048,8 +1048,8 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) U32 update_count = 0; static const S32 MIN_UPDATE_COUNT = gSavedSettings.getS32("TextureFetchUpdateMinCount"); // default: 32 // WIP -- dumb code here - //update MIN_UPDATE_COUNT or 10% of other textures, whichever is greater - update_count = llmax((U32) MIN_UPDATE_COUNT, (U32) mUUIDMap.size()/10); + //update MIN_UPDATE_COUNT or 5% of other textures, whichever is greater + update_count = llmax((U32) MIN_UPDATE_COUNT, (U32) mUUIDMap.size()/20); update_count = llmin(update_count, (U32) mUUIDMap.size()); { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index cf104aa89d..41b57b8a6b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5502,7 +5502,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_vec[idx]->mTextureMatrix == tex_mat && draw_vec[idx]->mModelMatrix == model_mat && draw_vec[idx]->mShaderMask == shader_mask && - draw_vec[idx]->mSelected == selected && draw_vec[idx]->mAvatar == facep->mAvatar && draw_vec[idx]->getSkinHash() == facep->getSkinHash()) { @@ -5601,11 +5600,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_info->mExtents[0] = facep->mExtents[0]; draw_info->mExtents[1] = facep->mExtents[1]; - if (LLPipeline::sUseTriStrips) - { - draw_info->mDrawMode = LLRender::TRIANGLE_STRIP; - } - if (index < FACE_DO_NOT_BATCH_TEXTURES) { //initialize texture list for texture batching draw_info->mTextureList.resize(index+1); diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index c7df343ad0..524fd4c49e 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -304,7 +304,7 @@ void LLVOWLSky::drawFsSky(void) mFsSkyVerts->setBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK); mFsSkyVerts->drawRange(LLRender::TRIANGLES, 0, mFsSkyVerts->getNumVerts() - 1, mFsSkyVerts->getNumIndices(), 0); - gPipeline.addTrianglesDrawn(mFsSkyVerts->getNumIndices(), LLRender::TRIANGLES); + gPipeline.addTrianglesDrawn(mFsSkyVerts->getNumIndices()); LLVertexBuffer::unbind(); } @@ -331,7 +331,7 @@ void LLVOWLSky::drawDome(void) LLRender::TRIANGLE_STRIP, 0, strips_segment->getNumVerts()-1, strips_segment->getNumIndices(), 0); - gPipeline.addTrianglesDrawn(strips_segment->getNumIndices(), LLRender::TRIANGLE_STRIP); + gPipeline.addTrianglesDrawn(strips_segment->getNumIndices()); } LLVertexBuffer::unbind(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index dff84bda0e..d2c079baa6 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -313,7 +313,6 @@ bool LLPipeline::sRenderTransparentWater = true; bool LLPipeline::sRenderBump = true; bool LLPipeline::sBakeSunlight = false; bool LLPipeline::sNoAlpha = false; -bool LLPipeline::sUseTriStrips = true; bool LLPipeline::sUseFarClip = true; bool LLPipeline::sShadowRender = false; bool LLPipeline::sRenderGlow = false; @@ -323,7 +322,6 @@ bool LLPipeline::sImpostorRender = false; bool LLPipeline::sImpostorRenderAlphaDepthPass = false; bool LLPipeline::sUnderWaterRender = false; bool LLPipeline::sTextureBindTest = false; -bool LLPipeline::sRenderFrameTest = false; bool LLPipeline::sRenderAttachedLights = true; bool LLPipeline::sRenderAttachedParticles = true; bool LLPipeline::sRenderDeferred = false; @@ -406,7 +404,6 @@ void LLPipeline::init() gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); - sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips"); LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); @@ -3716,31 +3713,40 @@ void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) tex->addTextureStats(vsize); } } - - } + void LLPipeline::touchTextures(LLDrawInfo* info) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - - auto& mat = info->mGLTFMaterial; - if (mat.notNull()) - { - touchTexture(mat->mBaseColorTexture, info->mVSize); - touchTexture(mat->mNormalTexture, info->mVSize); - touchTexture(mat->mMetallicRoughnessTexture, info->mVSize); - touchTexture(mat->mEmissiveTexture, info->mVSize); - } - else + if (--info->mTextureTimer == 0) { - for (int i = 0; i < info->mTextureList.size(); ++i) + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + // reset texture timer in a noisy fashion to avoid clumping of updates + const U32 MIN_WAIT_TIME = 8; + const U32 MAX_WAIT_TIME = 16; + + info->mTextureTimer = ll_rand() % (MAX_WAIT_TIME - MIN_WAIT_TIME) + MIN_WAIT_TIME; + + auto& mat = info->mGLTFMaterial; + if (mat.notNull()) { - touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); + touchTexture(mat->mBaseColorTexture, info->mVSize); + touchTexture(mat->mNormalTexture, info->mVSize); + touchTexture(mat->mMetallicRoughnessTexture, info->mVSize); + touchTexture(mat->mEmissiveTexture, info->mVSize); } + else + { + info->mTextureTimer += (U8) info->mTextureList.size(); - touchTexture(info->mTexture, info->mVSize); - touchTexture(info->mSpecularMap, info->mVSize); - touchTexture(info->mNormalMap, info->mVSize); + for (int i = 0; i < info->mTextureList.size(); ++i) + { + touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); + } + + touchTexture(info->mTexture, info->mVSize); + touchTexture(info->mSpecularMap, info->mVSize); + touchTexture(info->mNormalMap, info->mVSize); + } } } @@ -3829,7 +3835,7 @@ void LLPipeline::postSort(LLCamera& camera) if (!sShadowRender && !sReflectionRender && !gCubeSnapshot) { touchTextures(info); - addTrianglesDrawn(info->mCount, info->mDrawMode); + addTrianglesDrawn(info->mCount); } } } @@ -4831,28 +4837,19 @@ void LLPipeline::renderGeomShadow(LLCamera& camera) } -void LLPipeline::addTrianglesDrawn(S32 index_count, U32 render_type) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - assertInitialized(); - S32 count = 0; - if (render_type == LLRender::TRIANGLE_STRIP) - { - count = index_count-2; - } - else - { - count = index_count/3; - } +static U32 sIndicesDrawnCount = 0; - record(sStatBatchSize, count); - add(LLStatViewer::TRIANGLES_DRAWN, LLUnits::Triangles::fromValue(count)); +void LLPipeline::addTrianglesDrawn(S32 index_count) +{ + sIndicesDrawnCount += index_count; +} - if (LLPipeline::sRenderFrameTest) - { - gViewerWindow->getWindow()->swapBuffers(); - ms_sleep(16); - } +void LLPipeline::recordTrianglesDrawn() +{ + assertInitialized(); + U32 count = sIndicesDrawnCount / 3; + sIndicesDrawnCount = 0; + add(LLStatViewer::TRIANGLES_DRAWN, LLUnits::Triangles::fromValue(count)); } void LLPipeline::renderPhysicsDisplay() @@ -7385,7 +7382,6 @@ void LLPipeline::doResetVertexBuffers(bool forced) updateRenderBump(); updateRenderDeferred(); - sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips"); LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); @@ -8246,6 +8242,9 @@ void LLPipeline::renderFinalize() LLGLState::checkStates(); LLGLState::checkTextureChannels(); + + // flush calls made to "addTrianglesDrawn" so far to stats machinery + recordTrianglesDrawn(); } void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index c61fbd8404..5b068fc386 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -354,8 +354,8 @@ public: LLCullResult::sg_iterator beginRiggedAlphaGroups(); LLCullResult::sg_iterator endRiggedAlphaGroups(); - - void addTrianglesDrawn(S32 index_count, U32 render_type = LLRender::TRIANGLES); + void addTrianglesDrawn(S32 index_count); + void recordTrianglesDrawn(); bool hasRenderDebugFeatureMask(const U32 mask) const { return bool(mRenderDebugFeatureMask & mask); } bool hasRenderDebugMask(const U64 mask) const { return bool(mRenderDebugMask & mask); } @@ -631,7 +631,6 @@ public: static bool sRenderBump; static bool sBakeSunlight; static bool sNoAlpha; - static bool sUseTriStrips; static bool sUseFarClip; static bool sShadowRender; static bool sDynamicLOD; @@ -643,7 +642,6 @@ public: static bool sUnderWaterRender; static bool sRenderGlow; static bool sTextureBindTest; - static bool sRenderFrameTest; static bool sRenderAttachedLights; static bool sRenderAttachedParticles; static bool sRenderDeferred; diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index cb2f24334c..cb1dec6c61 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2744,15 +2744,6 @@ function="World.EnvPreset" function="Advanced.TogglePeriodicSlowFrame" parameter="points" /> - - - - -- cgit v1.3 From e46323b0b9fea77522ee4637a82e2e86de15bb83 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 29 Nov 2022 10:50:25 -0600 Subject: SL-18682 WIP -- Clear BOOST_SELECTED as needed. GL 3.2 compatibility pass. Fix for stack underflow when reflection probes disabled. --- .gitignore | 13 ++++++ indra/newview/app_settings/settings.xml | 2 +- indra/newview/lldrawpoolbump.cpp | 1 - indra/newview/llfloaterpreference.cpp | 10 ++++ indra/newview/llviewerobject.cpp | 2 +- indra/newview/llviewerobjectlist.cpp | 54 +++++++++++----------- indra/newview/llvovolume.cpp | 8 +++- .../en/floater_preferences_graphics_advanced.xml | 2 +- 8 files changed, 60 insertions(+), 32 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/.gitignore b/.gitignore index 839d14bc0d..e9b544a6ce 100755 --- a/.gitignore +++ b/.gitignore @@ -7,9 +7,18 @@ *.pyc *.rej *.swp +*.vcxproj +*.filters +*.sln +*.depend +*.stamp +*.rc + *~ # Specific paths and/or names +CMakeCache.txt +cmake_install.cmake LICENSES build-darwin-* build-linux-* @@ -17,6 +26,10 @@ debian/files debian/secondlife-appearance-utility* debian/secondlife-viewer* indra/.distcc +indra/cmake/* +indra/out/* + +indra/packages/* build-vc80/ build-vc100/ build-vc120/ diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 8c96ccd107..bea54f0b69 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9235,7 +9235,7 @@ RenderMaxVRAMBudget Comment - Maximum amount of texture memory to budget for, or 0 for autodetect. Requires restart. + Maximum amount of texture memory to budget for (in MB), or 0 for autodetect. Requires restart. Persist 1 Type diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index cd9ff0192e..684cf55b6b 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -535,7 +535,6 @@ void LLDrawPoolBump::endFullbrightShiny() if( cube_map ) { cube_map->disable(); - cube_map->restoreMatrix(); if (shader->mFeatures.hasReflectionProbes) { gPipeline.unbindReflectionProbes(*shader); diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index b3403fda0f..81b3c23417 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1215,6 +1215,16 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() ctrl_shadow->setEnabled(enabled); shadow_text->setEnabled(enabled); + if (!LLFeatureManager::instance().isFeatureAvailable("RenderFSAASamples")) + { + getChildView("fsaa")->setEnabled(FALSE); + } + + if (!LLFeatureManager::instance().isFeatureAvailable("RenderReflectionProbeDetail")) + { + getChildView("ReflectionDetail")->setEnabled(FALSE); + } + // Hardware settings if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures")) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 47cb9e9732..2e76103773 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4062,7 +4062,7 @@ void LLViewerObject::updateTextures() void LLViewerObject::boostTexturePriority(BOOL boost_children /* = TRUE */) { - if (isDead()) + if (isDead() || !getVolume()) { return; } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index dc0785f990..816fa6607e 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -789,7 +789,33 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) max_value = llmin((S32) mObjects.size(), mCurLazyUpdateIndex + num_updates); } -#if 0 + // Iterate through some of the objects and lazy update their texture priorities + for (i = mCurLazyUpdateIndex; i < max_value; i++) + { + objectp = mObjects[i]; + if (!objectp->isDead()) + { + num_objects++; + + // Update distance & gpw + objectp->setPixelAreaAndAngle(agent); // Also sets the approx. pixel area + objectp->updateTextures(); // Update the image levels of textures for this object. + } + } + + mCurLazyUpdateIndex = max_value; + if (mCurLazyUpdateIndex == mObjects.size()) + { + // restart + mCurLazyUpdateIndex = 0; + mCurBin = 0; // keep in sync with index (mObjects.size() could have changed) + } + else + { + mCurBin = (mCurBin + 1) % NUM_BINS; + } + +#if 1 // Slam priorities for textures that we care about (hovered, selected, and focused) // Hovered // Assumes only one level deep of parenting @@ -822,32 +848,6 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func); #endif - // Iterate through some of the objects and lazy update their texture priorities - for (i = mCurLazyUpdateIndex; i < max_value; i++) - { - objectp = mObjects[i]; - if (!objectp->isDead()) - { - num_objects++; - - // Update distance & gpw - objectp->setPixelAreaAndAngle(agent); // Also sets the approx. pixel area - objectp->updateTextures(); // Update the image levels of textures for this object. - } - } - - mCurLazyUpdateIndex = max_value; - if (mCurLazyUpdateIndex == mObjects.size()) - { - // restart - mCurLazyUpdateIndex = 0; - mCurBin = 0; // keep in sync with index (mObjects.size() could have changed) - } - else - { - mCurBin = (mCurBin + 1) % NUM_BINS; - } - LLVOAvatar::cullAvatarsByPixelArea(); } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 41b57b8a6b..038935963d 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -800,7 +800,13 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) { continue; } - + + // clear out boost selected periodically + if (imagep->getBoostLevel() == LLGLTexture::BOOST_SELECTED) + { + imagep->setBoostLevel(LLGLTexture::BOOST_NONE); + } + F32 vsize; F32 old_size = face->getVirtualSize(); diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index 4a08cc5285..75b50c0e39 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -666,7 +666,7 @@ layout="topleft" left_delta="130" top_delta="0" - name="ReflectionDetial" + name="ReflectionDetail" width="150"> Date: Tue, 29 Nov 2022 21:42:43 +0200 Subject: SL-12069 Backed out changeset: 544a91982eba (#13) Originally a fix for MAINT-4773/SL-5842 (transparent alpha being white). Reverting due to a critical flaw of the fix replacing material (sometimes server side included). And ignoring user and script input in some cases that makes scripts misbehave. Viewer should Not modify existing content of own volition. --- indra/newview/llface.cpp | 28 ----- indra/newview/llface.h | 3 - indra/newview/llviewertexture.cpp | 30 ----- indra/newview/llviewertexture.h | 5 +- indra/newview/llvovolume.cpp | 236 +------------------------------------- indra/newview/llvovolume.h | 20 ---- 6 files changed, 3 insertions(+), 319 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 6557bcb81d..878022a2c8 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -342,34 +342,6 @@ void LLFace::dirtyTexture() gPipeline.markTextured(drawablep); } -void LLFace::notifyAboutCreatingTexture(LLViewerTexture *texture) -{ - LLDrawable* drawablep = getDrawable(); - if(mVObjp.notNull() && mVObjp->getVolume()) - { - LLVOVolume *vobj = drawablep->getVOVolume(); - if(vobj && vobj->notifyAboutCreatingTexture(texture)) - { - gPipeline.markTextured(drawablep); - gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME); - } - } -} - -void LLFace::notifyAboutMissingAsset(LLViewerTexture *texture) -{ - LLDrawable* drawablep = getDrawable(); - if(mVObjp.notNull() && mVObjp->getVolume()) - { - LLVOVolume *vobj = drawablep->getVOVolume(); - if(vobj && vobj->notifyAboutMissingAsset(texture)) - { - gPipeline.markTextured(drawablep); - gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME); - } - } -} - void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture) { llassert(ch < LLRender::NUM_TEXTURE_CHANNELS); diff --git a/indra/newview/llface.h b/indra/newview/llface.h index a5ea460061..0cb986b8ed 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -228,9 +228,6 @@ public: LLVertexBuffer* getVertexBuffer() const { return mVertexBuffer; } S32 getRiggedIndex(U32 type) const; - void notifyAboutCreatingTexture(LLViewerTexture *texture); - void notifyAboutMissingAsset(LLViewerTexture *texture); - // used to preserve draw order of faces that are batched together. // Allows content creators to manipulate linked sets and face ordering // for consistent alpha sorting results, particularly for rigged attachments diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index c2e09b2882..0fd796afba 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -659,8 +659,6 @@ S8 LLViewerTexture::getType() const void LLViewerTexture::cleanup() { - notifyAboutMissingAsset(); - if (LLAppViewer::getTextureFetch()) { LLAppViewer::getTextureFetch()->updateRequestPriority(mID, 0.f); @@ -673,30 +671,6 @@ void LLViewerTexture::cleanup() mVolumeList[LLRender::SCULPT_TEX].clear(); } -void LLViewerTexture::notifyAboutCreatingTexture() -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - for(U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) - { - for(U32 f = 0; f < mNumFaces[ch]; f++) - { - mFaceList[ch][f]->notifyAboutCreatingTexture(this); - } - } -} - -void LLViewerTexture::notifyAboutMissingAsset() -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - for(U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) - { - for(U32 f = 0; f < mNumFaces[ch]; f++) - { - mFaceList[ch][f]->notifyAboutMissingAsset(this); - } - } -} - // virtual void LLViewerTexture::dump() { @@ -1579,8 +1553,6 @@ void LLViewerFetchedTexture::postCreateTexture() mGLTexturep->checkActiveThread(); #endif - notifyAboutCreatingTexture(); - setActive(); if (!needsToSaveRawImage()) @@ -2221,8 +2193,6 @@ void LLViewerFetchedTexture::setIsMissingAsset(BOOL is_missing) } if (is_missing) { - notifyAboutMissingAsset(); - if (mUrl.empty()) { LL_WARNS() << mID << ": Marking image as missing" << LL_ENDL; diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 312e2ca365..5fa5d893e7 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -177,10 +177,7 @@ protected: void cleanup() ; void init(bool firstinit) ; void reorganizeFaceList() ; - void reorganizeVolumeList() ; - - void notifyAboutMissingAsset(); - void notifyAboutCreatingTexture(); + void reorganizeVolumeList(); private: friend class LLBumpImageList; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 038935963d..f06719634e 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2367,243 +2367,11 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) return res; } -bool LLVOVolume::notifyAboutCreatingTexture(LLViewerTexture *texture) -{ //Ok, here we have confirmation about texture creation, check our wait-list - //and make changes, or return false - - std::pair range = mWaitingTextureInfo.equal_range(texture->getID()); - - typedef std::map map_te_material; - map_te_material new_material; - - for(mmap_UUID_MAP_t::iterator range_it = range.first; range_it != range.second; ++range_it) - { - LLMaterialPtr cur_material = getTEMaterialParams(range_it->second.te); - - //here we just interesting in DIFFUSE_MAP only! - if(NULL != cur_material.get() && LLRender::DIFFUSE_MAP == range_it->second.map && GL_RGBA != texture->getPrimaryFormat()) - { //ok let's check the diffuse mode - switch(cur_material->getDiffuseAlphaMode()) - { - case LLMaterial::DIFFUSE_ALPHA_MODE_BLEND: - case LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE: - case LLMaterial::DIFFUSE_ALPHA_MODE_MASK: - { //uups... we have non 32 bit texture with LLMaterial::DIFFUSE_ALPHA_MODE_* => LLMaterial::DIFFUSE_ALPHA_MODE_NONE - - LLMaterialPtr mat = NULL; - map_te_material::iterator it = new_material.find(range_it->second.te); - if(new_material.end() == it) { - mat = new LLMaterial(cur_material->asLLSD()); - new_material.insert(map_te_material::value_type(range_it->second.te, mat)); - } else { - mat = it->second; - } - - mat->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - - } break; - } //switch - } //if - } //for - - //setup new materials - for(map_te_material::const_iterator it = new_material.begin(), end = new_material.end(); it != end; ++it) - { - LLMaterialMgr::getInstance()->put(getID(), it->first, *it->second); - LLViewerObject::setTEMaterialParams(it->first, it->second); - } - - //clear wait-list - mWaitingTextureInfo.erase(range.first, range.second); - - return 0 != new_material.size(); -} - -bool LLVOVolume::notifyAboutMissingAsset(LLViewerTexture *texture) -{ //Ok, here if we wait information about texture and it's missing - //then depending from the texture map (diffuse, normal, or specular) - //make changes in material and confirm it. If not return false. - std::pair range = mWaitingTextureInfo.equal_range(texture->getID()); - if(range.first == range.second) return false; - - typedef std::map map_te_material; - map_te_material new_material; - - for(mmap_UUID_MAP_t::iterator range_it = range.first; range_it != range.second; ++range_it) - { - LLMaterialPtr cur_material = getTEMaterialParams(range_it->second.te); - if (cur_material.isNull()) - continue; - - switch(range_it->second.map) - { - case LLRender::DIFFUSE_MAP: - { - if(LLMaterial::DIFFUSE_ALPHA_MODE_NONE != cur_material->getDiffuseAlphaMode()) - { //missing texture + !LLMaterial::DIFFUSE_ALPHA_MODE_NONE => LLMaterial::DIFFUSE_ALPHA_MODE_NONE - LLMaterialPtr mat = NULL; - map_te_material::iterator it = new_material.find(range_it->second.te); - if(new_material.end() == it) { - mat = new LLMaterial(cur_material->asLLSD()); - new_material.insert(map_te_material::value_type(range_it->second.te, mat)); - } else { - mat = it->second; - } - - mat->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - } - } break; - case LLRender::NORMAL_MAP: - { //missing texture => reset material texture id - LLMaterialPtr mat = NULL; - map_te_material::iterator it = new_material.find(range_it->second.te); - if(new_material.end() == it) { - mat = new LLMaterial(cur_material->asLLSD()); - new_material.insert(map_te_material::value_type(range_it->second.te, mat)); - } else { - mat = it->second; - } - - mat->setNormalID(LLUUID::null); - } break; - case LLRender::SPECULAR_MAP: - { //missing texture => reset material texture id - LLMaterialPtr mat = NULL; - map_te_material::iterator it = new_material.find(range_it->second.te); - if(new_material.end() == it) { - mat = new LLMaterial(cur_material->asLLSD()); - new_material.insert(map_te_material::value_type(range_it->second.te, mat)); - } else { - mat = it->second; - } - - mat->setSpecularID(LLUUID::null); - } break; - case LLRender::NUM_TEXTURE_CHANNELS: - //nothing to do, make compiler happy - break; - } //switch - } //for - - //setup new materials - for(map_te_material::const_iterator it = new_material.begin(), end = new_material.end(); it != end; ++it) - { - LLMaterialMgr::getInstance()->setLocalMaterial(getRegion()->getRegionID(), it->second); - LLViewerObject::setTEMaterialParams(it->first, it->second); - } - - //clear wait-list - mWaitingTextureInfo.erase(range.first, range.second); - - return 0 != new_material.size(); -} - S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { - LLMaterialPtr pMaterial = const_cast(pMaterialParams); - - if(pMaterialParams) - { //check all of them according to material settings - - LLViewerTexture *img_diffuse = getTEImage(te); - LLViewerTexture *img_normal = getTENormalMap(te); - LLViewerTexture *img_specular = getTESpecularMap(te); - - llassert(NULL != img_diffuse); - - LLMaterialPtr new_material = NULL; - - //diffuse - if(NULL != img_diffuse) - { //guard - if(0 == img_diffuse->getPrimaryFormat() && !img_diffuse->isMissingAsset()) - { //ok here we don't have information about texture, let's belief and leave material settings - //but we remember this case - mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(img_diffuse->getID(), material_info(LLRender::DIFFUSE_MAP, te))); - } - else - { - bool bSetDiffuseNone = false; - if(img_diffuse->isMissingAsset()) - { - bSetDiffuseNone = true; - } - else - { - switch(pMaterialParams->getDiffuseAlphaMode()) - { - case LLMaterial::DIFFUSE_ALPHA_MODE_BLEND: - case LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE: - case LLMaterial::DIFFUSE_ALPHA_MODE_MASK: - { //all of them modes available only for 32 bit textures - LLTextureEntry* tex_entry = getTE(te); - bool bIsBakedImageId = false; - if (tex_entry && LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(tex_entry->getID())) - { - bIsBakedImageId = true; - } - if (GL_RGBA != img_diffuse->getPrimaryFormat() && !bIsBakedImageId) - { - bSetDiffuseNone = true; - } - } break; - } - } //else - - - if(bSetDiffuseNone) - { //upps... we should substitute this material with LLMaterial::DIFFUSE_ALPHA_MODE_NONE - new_material = new LLMaterial(pMaterialParams->asLLSD()); - new_material->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - } - } - } - - //normal - if(LLUUID::null != pMaterialParams->getNormalID()) - { - if(img_normal && img_normal->isMissingAsset() && img_normal->getID() == pMaterialParams->getNormalID()) - { - if(!new_material) { - new_material = new LLMaterial(pMaterialParams->asLLSD()); - } - new_material->setNormalID(LLUUID::null); - } - else if(NULL == img_normal || 0 == img_normal->getPrimaryFormat()) - { //ok here we don't have information about texture, let's belief and leave material settings - //but we remember this case - mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(pMaterialParams->getNormalID(), material_info(LLRender::NORMAL_MAP,te))); - } - - } - - - //specular - if(LLUUID::null != pMaterialParams->getSpecularID()) - { - if(img_specular && img_specular->isMissingAsset() && img_specular->getID() == pMaterialParams->getSpecularID()) - { - if(!new_material) { - new_material = new LLMaterial(pMaterialParams->asLLSD()); - } - new_material->setSpecularID(LLUUID::null); - } - else if(NULL == img_specular || 0 == img_specular->getPrimaryFormat()) - { //ok here we don't have information about texture, let's belief and leave material settings - //but we remember this case - mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(pMaterialParams->getSpecularID(), material_info(LLRender::SPECULAR_MAP, te))); - } - } - - if(new_material) { - pMaterial = new_material; - LLMaterialMgr::getInstance()->setLocalMaterial(getRegion()->getRegionID(), pMaterial); - } - } - - S32 res = LLViewerObject::setTEMaterialParams(te, pMaterial); + S32 res = LLViewerObject::setTEMaterialParams(te, pMaterialParams); - LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterial) ? pMaterial->asLLSD() : LLSD("null")) << " res " << res + LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterialParams) ? pMaterialParams->asLLSD() : LLSD("null")) << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) << LL_ENDL; setChanged(ALL_CHANGED); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 003ab38d64..2c269d745d 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -476,26 +476,6 @@ protected: static S32 sNumLODChanges; friend class LLVolumeImplFlexible; - -public: - bool notifyAboutCreatingTexture(LLViewerTexture *texture); - bool notifyAboutMissingAsset(LLViewerTexture *texture); - -private: - struct material_info - { - LLRender::eTexIndex map; - U8 te; - - material_info(LLRender::eTexIndex map_, U8 te_) - : map(map_) - , te(te_) - {} - }; - - typedef std::multimap mmap_UUID_MAP_t; - mmap_UUID_MAP_t mWaitingTextureInfo; - }; #endif // LL_LLVOVOLUME_H -- cgit v1.3 From 5fcfe95422b4c3a5434b3eb711cd12401d4329d3 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 13 Dec 2022 16:13:49 -0600 Subject: SL-18782 Make primitive parameters automatically follow Reflection Probe controls. --- indra/newview/llpanelvolume.cpp | 55 ++++++++++++++++++++-- indra/newview/llvovolume.cpp | 24 ++++++++-- indra/newview/llvovolume.h | 10 ++-- .../newview/skins/default/xui/en/notifications.xml | 12 +++++ 4 files changed, 88 insertions(+), 13 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index db37938448..0cbc2b0bad 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -48,6 +48,7 @@ #include "lltexturectrl.h" #include "llcombobox.h" //#include "llfirstuse.h" +#include "llfloaterreg.h" #include "llfocusmgr.h" #include "llmanipscale.h" #include "llinventorymodel.h" @@ -378,7 +379,7 @@ void LLPanelVolume::getState( ) // Reflection Probe BOOL is_probe = volobjp && volobjp->isReflectionProbe(); getChild("Reflection Probe")->setValue(is_probe); - getChildView("Reflection Probe")->setEnabled(editable && single_volume && volobjp); + getChildView("Reflection Probe")->setEnabled(editable && single_volume && volobjp && !volobjp->isMesh()); bool probe_enabled = is_probe && editable && single_volume; @@ -746,8 +747,30 @@ void LLPanelVolume::sendIsReflectionProbe() LLVOVolume* volobjp = (LLVOVolume*)objectp; BOOL value = getChild("Reflection Probe")->getValue(); + BOOL old_value = volobjp->isReflectionProbe(); + volobjp->setIsReflectionProbe(value); LL_INFOS() << "update reflection probe sent" << LL_ENDL; + + if (value && !old_value) + { // has become a reflection probe, slam to a 10m sphere and pop up a message + // warning people about the pitfalls of reflection probes + auto* select_mgr = LLSelectMgr::getInstance(); + + mObject->setScale(LLVector3(10.f, 10.f, 10.f)); + select_mgr->sendMultipleUpdate(UPD_ROTATION | UPD_POSITION | UPD_SCALE); + + select_mgr->selectionUpdatePhantom(true); + select_mgr->selectionSetGLTFMaterial(LLUUID::null); + select_mgr->selectionSetAlphaOnly(0.f); + + LLVolumeParams params; + params.getPathParams().setCurveType(LL_PCODE_PATH_CIRCLE); + params.getProfileParams().setCurveType(LL_PCODE_PROFILE_CIRCLE_HALF); + mObject->updateVolume(params); + + LLNotificationsUtil::add("ReflectionProbeApplied"); + } } void LLPanelVolume::sendIsFlexible() @@ -1309,14 +1332,40 @@ void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) } LLVOVolume* volobjp = (LLVOVolume*)objectp; - volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); volobjp->setReflectionProbeIsDynamic(self->getChild("Probe Dynamic")->getValue().asBoolean()); std::string shape_type = self->getChild("Probe Volume Type")->getValue().asString(); - volobjp->setReflectionProbeIsBox(shape_type == "Box"); + bool is_box = shape_type == "Box"; + + if (volobjp->setReflectionProbeIsBox(is_box)) + { + // make the volume match the probe + U8 profile, path; + + if (!is_box) + { + profile = LL_PCODE_PROFILE_CIRCLE_HALF; + path = LL_PCODE_PATH_CIRCLE; + + F32 scale = volobjp->getScale().mV[0]; + volobjp->setScale(LLVector3(scale, scale, scale), FALSE); + LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_ROTATION | UPD_POSITION | UPD_SCALE); + } + else + { + profile = LL_PCODE_PROFILE_SQUARE; + path = LL_PCODE_PATH_LINE; + } + + LLVolumeParams params; + params.getProfileParams().setCurveType(profile); + params.getPathParams().setCurveType(path); + objectp->updateVolume(params); + } + } // static diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index f06719634e..8660b6d9ea 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3300,7 +3300,7 @@ BOOL LLVOVolume::isReflectionProbe() const return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); } -void LLVOVolume::setIsReflectionProbe(BOOL is_probe) +bool LLVOVolume::setIsReflectionProbe(BOOL is_probe) { BOOL was_probe = isReflectionProbe(); if (is_probe != was_probe) @@ -3316,9 +3316,11 @@ void LLVOVolume::setIsReflectionProbe(BOOL is_probe) } updateReflectionProbePtr(); + + return was_probe != is_probe; } -void LLVOVolume::setReflectionProbeAmbiance(F32 ambiance) +bool LLVOVolume::setReflectionProbeAmbiance(F32 ambiance) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) @@ -3327,11 +3329,14 @@ void LLVOVolume::setReflectionProbeAmbiance(F32 ambiance) { param_block->setAmbiance(ambiance); parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + return true; } } + + return false; } -void LLVOVolume::setReflectionProbeNearClip(F32 near_clip) +bool LLVOVolume::setReflectionProbeNearClip(F32 near_clip) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) @@ -3340,11 +3345,14 @@ void LLVOVolume::setReflectionProbeNearClip(F32 near_clip) { param_block->setClipDistance(near_clip); parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + return true; } } + + return false; } -void LLVOVolume::setReflectionProbeIsBox(bool is_box) +bool LLVOVolume::setReflectionProbeIsBox(bool is_box) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) @@ -3353,11 +3361,14 @@ void LLVOVolume::setReflectionProbeIsBox(bool is_box) { param_block->setIsBox(is_box); parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + return true; } } + + return false; } -void LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) +bool LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) @@ -3366,8 +3377,11 @@ void LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) { param_block->setIsDynamic(is_dynamic); parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + return true; } } + + return false; } F32 LLVOVolume::getReflectionProbeAmbiance() const diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 2c269d745d..1c44ddfc5d 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -295,11 +295,11 @@ public: F32 getLightCutoff() const; // Reflection Probes - void setIsReflectionProbe(BOOL is_probe); - void setReflectionProbeAmbiance(F32 ambiance); - void setReflectionProbeNearClip(F32 near_clip); - void setReflectionProbeIsBox(bool is_box); - void setReflectionProbeIsDynamic(bool is_dynamic); + bool setIsReflectionProbe(BOOL is_probe); + bool setReflectionProbeAmbiance(F32 ambiance); + bool setReflectionProbeNearClip(F32 near_clip); + bool setReflectionProbeIsBox(bool is_box); + bool setReflectionProbeIsDynamic(bool is_dynamic); BOOL isReflectionProbe() const override; F32 getReflectionProbeAmbiance() const; diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 1dc979fda6..270fa492de 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -12019,4 +12019,16 @@ Unpacking: [UNPACK_TIME]s [USIZE]KB type="notifytip"> Material successfully created. Asset ID: [ASSET_ID] + + + Your object has been set to the default Reflection Probe state, which is an invisible, phantom, 5m sphere. To learn more about Reflection Probes and how to use them, see the Knowledge Base. + + + -- cgit v1.3 From d27d23ab269f6d22483c4b4dc1db1664cf3e441e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Dec 2022 11:12:06 -0600 Subject: SL-18852 Refactor GLTF material rendering to not be special compared to other types. Hook GLTF alpha masking up to highlight transparent. --- indra/newview/lldrawpool.cpp | 79 +++++++++++++++++++++++++++++++++ indra/newview/lldrawpool.h | 4 ++ indra/newview/lldrawpoolalpha.cpp | 41 +++++++++-------- indra/newview/lldrawpoolpbropaque.cpp | 75 +++---------------------------- indra/newview/lldrawpoolpbropaque.h | 5 --- indra/newview/llfetchedgltfmaterial.cpp | 4 +- indra/newview/llfetchedgltfmaterial.h | 2 +- indra/newview/llvovolume.cpp | 8 ++++ indra/newview/pipeline.cpp | 45 ++++++++++++++----- indra/newview/pipeline.h | 4 +- 10 files changed, 162 insertions(+), 105 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index b3ae673aed..dd6b914783 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -425,6 +425,85 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, U32 mask, } } +void setup_texture_matrix(LLDrawInfo& params) +{ + if (params.mTextureMatrix) + { //special case implementation of texture animation here because of special handling of textures for PBR batches + gGL.getTexUnit(0)->activate(); + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadMatrix((GLfloat*)params.mTextureMatrix->mMatrix); + gPipeline.mTextureMatrixOps++; + } +} + +void teardown_texture_matrix(LLDrawInfo& params) +{ + if (params.mTextureMatrix) + { + gGL.matrixMode(LLRender::MM_TEXTURE0); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + } +} + +void LLRenderPass::pushGLTFBatches(U32 type, U32 mask) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; + for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushGLTFBatch"); + LLDrawInfo& params = **i; + auto& mat = params.mGLTFMaterial; + + mat->bind(); + + LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); + + setup_texture_matrix(params); + + applyModelMatrix(params); + + params.mVertexBuffer->setBufferFast(mask); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + + teardown_texture_matrix(params); + } +} + +void LLRenderPass::pushRiggedGLTFBatches(U32 type, U32 mask) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; + LLVOAvatar* lastAvatar = nullptr; + U64 lastMeshId = 0; + mask |= LLVertexBuffer::MAP_WEIGHT4; + for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushRiggedGLTFBatch"); + LLDrawInfo& params = **i; + auto& mat = params.mGLTFMaterial; + + mat->bind(); + + LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); + + setup_texture_matrix(params); + + applyModelMatrix(params); + + if (params.mAvatar.notNull() && (lastAvatar != params.mAvatar || lastMeshId != params.mSkinInfo->mHash)) + { + uploadMatrixPalette(params); + lastAvatar = params.mAvatar; + lastMeshId = params.mSkinInfo->mHash; + } + + params.mVertexBuffer->setBufferFast(mask); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + + teardown_texture_matrix(params); + } +} + void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 2c8d6ff652..9a4b09b973 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -201,6 +201,8 @@ public: PASS_ALPHA_INVISIBLE_RIGGED, PASS_GLTF_PBR, PASS_GLTF_PBR_RIGGED, + PASS_GLTF_PBR_ALPHA_MASK, + PASS_GLTF_PBR_ALPHA_MASK_RIGGED, NUM_RENDER_TYPES, }; @@ -350,6 +352,8 @@ public: static void applyModelMatrix(const LLDrawInfo& params); virtual void pushBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); virtual void pushRiggedBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); + void pushGLTFBatches(U32 type, U32 mask); + void pushRiggedGLTFBatches(U32 type, U32 mask); virtual void pushMaskBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); virtual void pushRiggedMaskBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 6e0913705d..dc7e5f51df 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -317,39 +317,42 @@ void LLDrawPoolAlpha::renderDebugAlpha() gGL.diffuseColor4f(1, 0, 0, 1); gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::getSmokeImage()); - renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0); + U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0; - pushBatches(LLRenderPass::PASS_ALPHA_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushBatches(LLRenderPass::PASS_ALPHA_INVISIBLE, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); + renderAlphaHighlight(mask); + + pushBatches(LLRenderPass::PASS_ALPHA_MASK, mask, FALSE); + pushBatches(LLRenderPass::PASS_ALPHA_INVISIBLE, mask, FALSE); // Material alpha mask gGL.diffuseColor4f(0, 0, 1, 1); - pushBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushBatches(LLRenderPass::PASS_NORMMAP_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushBatches(LLRenderPass::PASS_SPECMAP_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushBatches(LLRenderPass::PASS_NORMSPEC_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); + pushBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, mask, FALSE); + pushBatches(LLRenderPass::PASS_NORMMAP_MASK, mask, FALSE); + pushBatches(LLRenderPass::PASS_SPECMAP_MASK, mask, FALSE); + pushBatches(LLRenderPass::PASS_NORMSPEC_MASK, mask, FALSE); + pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, mask, FALSE); + pushBatches(LLRenderPass::PASS_GLTF_PBR_ALPHA_MASK, mask, FALSE); gGL.diffuseColor4f(0, 1, 0, 1); - pushBatches(LLRenderPass::PASS_INVISIBLE, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); + pushBatches(LLRenderPass::PASS_INVISIBLE, mask, FALSE); gHighlightProgram.mRiggedVariant->bind(); gGL.diffuseColor4f(1, 0, 0, 1); - pushRiggedBatches(LLRenderPass::PASS_ALPHA_MASK_RIGGED, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushRiggedBatches(LLRenderPass::PASS_ALPHA_INVISIBLE_RIGGED, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); + pushRiggedBatches(LLRenderPass::PASS_ALPHA_MASK_RIGGED, mask, FALSE); + pushRiggedBatches(LLRenderPass::PASS_ALPHA_INVISIBLE_RIGGED, mask, FALSE); // Material alpha mask gGL.diffuseColor4f(0, 0, 1, 1); - pushRiggedBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK_RIGGED, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushRiggedBatches(LLRenderPass::PASS_NORMMAP_MASK_RIGGED, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushRiggedBatches(LLRenderPass::PASS_SPECMAP_MASK_RIGGED, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushRiggedBatches(LLRenderPass::PASS_NORMSPEC_MASK_RIGGED, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); - pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); + pushRiggedBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK_RIGGED, mask, FALSE); + pushRiggedBatches(LLRenderPass::PASS_NORMMAP_MASK_RIGGED, mask, FALSE); + pushRiggedBatches(LLRenderPass::PASS_SPECMAP_MASK_RIGGED, mask, FALSE); + pushRiggedBatches(LLRenderPass::PASS_NORMSPEC_MASK_RIGGED, mask, FALSE); + pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, mask, FALSE); + pushRiggedBatches(LLRenderPass::PASS_GLTF_PBR_ALPHA_MASK_RIGGED, mask, FALSE); gGL.diffuseColor4f(0, 1, 0, 1); - pushRiggedBatches(LLRenderPass::PASS_INVISIBLE_RIGGED, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); + pushRiggedBatches(LLRenderPass::PASS_INVISIBLE_RIGGED, mask, FALSE); LLGLSLShader::sCurBoundShaderPtr->unbind(); } } @@ -679,7 +682,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) gPipeline.bindDeferredShaderFast(*target_shader); } - params.mGLTFMaterial->bind(target_shader); + params.mGLTFMaterial->bind(); } else { diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index c39060a326..0e44a9be28 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -38,79 +38,18 @@ LLDrawPoolGLTFPBR::LLDrawPoolGLTFPBR() : void LLDrawPoolGLTFPBR::renderDeferred(S32 pass) { - const U32 type = LLPipeline::RENDER_TYPE_PASS_GLTF_PBR; + const U32 types[] = { LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK }; - gGL.flush(); - - LLVOAvatar* lastAvatar = nullptr; - U64 lastMeshId = 0; - - for (int i = 0; i < 2; ++i) + for (U32 type : types) { - bool rigged = (i == 1); - LLGLSLShader* shader = LLPipeline::sShadowRender ? &gDeferredShadowGLTFAlphaMaskProgram : &gDeferredPBROpaqueProgram; - U32 vertex_data_mask = getVertexDataMask(); - - if (rigged) - { - shader = shader->mRiggedVariant; - vertex_data_mask |= LLVertexBuffer::MAP_WEIGHT4; - } - - shader->bind(); - - LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type+i); - LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type+i); - - for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) - { - LLDrawInfo* pparams = *i; - auto& mat = pparams->mGLTFMaterial; - - mat->bind(shader); - - LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); - - bool tex_setup = false; - if (pparams->mTextureMatrix) - { //special case implementation of texture animation here because of special handling of textures for PBR batches - tex_setup = true; - gGL.getTexUnit(0)->activate(); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadMatrix((GLfloat*)pparams->mTextureMatrix->mMatrix); - gPipeline.mTextureMatrixOps++; - } - - if (rigged) - { - if (pparams->mAvatar.notNull() && (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash)) - { - uploadMatrixPalette(*pparams); - lastAvatar = pparams->mAvatar; - lastMeshId = pparams->mSkinInfo->mHash; - } - - pushBatch(*pparams, vertex_data_mask, FALSE, FALSE); - } - else - { - pushBatch(*pparams, vertex_data_mask, FALSE, FALSE); - } - - if (tex_setup) - { - gGL.matrixMode(LLRender::MM_TEXTURE0); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - } - } + gDeferredPBROpaqueProgram.bind(); + pushGLTFBatches(type, getVertexDataMask()); + + gDeferredPBROpaqueProgram.bind(true); + pushRiggedGLTFBatches(type+1, getVertexDataMask()); } LLGLSLShader::sCurBoundShaderPtr->unbind(); } -void LLDrawPoolGLTFPBR::renderShadow(S32 pass) -{ - renderDeferred(pass); -} diff --git a/indra/newview/lldrawpoolpbropaque.h b/indra/newview/lldrawpoolpbropaque.h index 3d80a0657e..2fe0695c69 100644 --- a/indra/newview/lldrawpoolpbropaque.h +++ b/indra/newview/lldrawpoolpbropaque.h @@ -50,11 +50,6 @@ public: S32 getNumDeferredPasses() override { return 1; } void renderDeferred(S32 pass) override; - - S32 getNumShadowPasses() override { return 1; } - void renderShadow(S32 pass) override; - - }; #endif // LL_LLDRAWPOOLPBROPAQUE_H diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index a873d062bd..b095b74519 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -46,12 +46,14 @@ LLFetchedGLTFMaterial::~LLFetchedGLTFMaterial() } -void LLFetchedGLTFMaterial::bind(LLGLSLShader* shader) +void LLFetchedGLTFMaterial::bind() { // glTF 2.0 Specification 3.9.4. Alpha Coverage // mAlphaCutoff is only valid for LLGLTFMaterial::ALPHA_MODE_MASK F32 min_alpha = -1.0; + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + if (mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) { min_alpha = mAlphaCutoff; diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h index 3b2801bf77..4f6c56012e 100644 --- a/indra/newview/llfetchedgltfmaterial.h +++ b/indra/newview/llfetchedgltfmaterial.h @@ -40,7 +40,7 @@ public: virtual ~LLFetchedGLTFMaterial(); // bind this material for rendering - void bind(LLGLSLShader* shader); + void bind(); // Textures used for fetching/rendering LLPointer mBaseColorTexture; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8660b6d9ea..afebf27d8b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6570,9 +6570,17 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (gltf_mat) { // all other parameters ignored if gltf material is present if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND) + { registerFace(group, facep, LLRenderPass::PASS_ALPHA); + } + else if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) + { + registerFace(group, facep, LLRenderPass::PASS_GLTF_PBR_ALPHA_MASK); + } else + { registerFace(group, facep, LLRenderPass::PASS_GLTF_PBR); + } } else // do NOT use 'fullbright' for this logic or you risk sending diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 633c86ad28..3aa6551202 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9437,7 +9437,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderPass::PASS_NORMMAP, LLRenderPass::PASS_NORMMAP_EMISSIVE, LLRenderPass::PASS_NORMSPEC, - LLRenderPass::PASS_NORMSPEC_EMISSIVE + LLRenderPass::PASS_NORMSPEC_EMISSIVE, + LLRenderPass::PASS_GLTF_PBR }; LLGLEnable cull(GL_CULL_FACE); @@ -9538,6 +9539,12 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); LL_PROFILE_GPU_ZONE("shadow alpha"); + + U32 mask = LLVertexBuffer::MAP_VERTEX | + LLVertexBuffer::MAP_TEXCOORD0 | + LLVertexBuffer::MAP_COLOR | + LLVertexBuffer::MAP_TEXTURE_INDEX; + for (int i = 0; i < 2; ++i) { bool rigged = i == 1; @@ -9546,11 +9553,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - U32 mask = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_COLOR | - LLVertexBuffer::MAP_TEXTURE_INDEX; - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE, rigged); @@ -9562,7 +9564,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderAlphaObjects(mask, TRUE, TRUE, rigged); } - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); gDeferredShadowFullbrightAlphaMaskProgram.bind(rigged); @@ -9571,7 +9572,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderFullbrightMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, mask, TRUE, TRUE, rigged); } - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); gDeferredTreeShadowProgram.bind(rigged); @@ -9588,9 +9588,32 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, no_idx_mask, true, false, rigged); } } - } - //glCullFace(GL_BACK); + for (int i = 0; i < 2; ++i) + { + bool rigged = i == 1; + gDeferredShadowGLTFAlphaMaskProgram.bind(rigged); + LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; + + U32 type = LLRenderPass::PASS_GLTF_PBR_ALPHA_MASK; + + if (rigged) + { + mAlphaMaskPool->pushRiggedGLTFBatches(type + 1, mask); + } + else + { + mAlphaMaskPool->pushGLTFBatches(type, mask); + } + + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; + } + } gDeferredShadowCubeProgram.bind(); gGLLastMatrix = NULL; @@ -9929,6 +9952,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLPipeline::RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED, + LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK_RIGGED, END_RENDER_TYPES); gGL.setColorMask(false, false); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 7661cd1b42..0097b863ab 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -538,7 +538,9 @@ public: RENDER_TYPE_PASS_NORMSPEC_EMISSIVE = LLRenderPass::PASS_NORMSPEC_EMISSIVE, RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED = LLRenderPass::PASS_NORMSPEC_EMISSIVE_RIGGED, RENDER_TYPE_PASS_GLTF_PBR = LLRenderPass::PASS_GLTF_PBR, - RENDER_TYPE_PASS_GLTF_PBR_RIGGED = LLRenderPass::PASS_GLTF_PBR_RIGGED, + RENDER_TYPE_PASS_GLTF_PBR_RIGGED = LLRenderPass::PASS_GLTF_PBR_RIGGED, + RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK = LLRenderPass::PASS_GLTF_PBR_ALPHA_MASK, + RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK_RIGGED = LLRenderPass::PASS_GLTF_PBR_ALPHA_MASK_RIGGED, // Following are object types (only used in drawable mRenderType) RENDER_TYPE_HUD = LLRenderPass::NUM_RENDER_TYPES, RENDER_TYPE_VOLUME, -- cgit v1.3 From a710bf9067bd4c4217b9febc0ad277a1636ec882 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 9 Jan 2023 15:18:57 -0600 Subject: SL-18869 Optimizations -- Use _mm_prefetch to cut down on cache misses when iterating over render batches. --- indra/newview/lldrawpool.cpp | 100 +++++++++++++++++++--------------- indra/newview/lldrawpoolalpha.cpp | 2 +- indra/newview/lldrawpoolbump.cpp | 4 +- indra/newview/lldrawpoolmaterials.cpp | 4 +- indra/newview/llspatialpartition.cpp | 40 -------------- indra/newview/llspatialpartition.h | 19 ++++++- indra/newview/llvograss.cpp | 3 - indra/newview/llvopartgroup.cpp | 3 - indra/newview/llvovolume.cpp | 4 -- indra/newview/pipeline.cpp | 22 +++----- 10 files changed, 89 insertions(+), 112 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index dd6b914783..2abbe2f2f8 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -449,10 +449,14 @@ void teardown_texture_matrix(LLDrawInfo& params) void LLRenderPass::pushGLTFBatches(U32 type, U32 mask) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushGLTFBatch"); LLDrawInfo& params = **i; + LLCullResult::increment_iterator(i, end); + auto& mat = params.mGLTFMaterial; mat->bind(); @@ -476,10 +480,14 @@ void LLRenderPass::pushRiggedGLTFBatches(U32 type, U32 mask) LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; mask |= LLVertexBuffer::MAP_WEIGHT4; - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushRiggedGLTFBatch"); LLDrawInfo& params = **i; + LLCullResult::increment_iterator(i, end); + auto& mat = params.mGLTFMaterial; mat->bind(); @@ -507,13 +515,14 @@ void LLRenderPass::pushRiggedGLTFBatches(U32 type, U32 mask) void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) - { - LLDrawInfo* pparams = *i; - if (pparams) - { - pushBatch(*pparams, mask, texture, batch_textures); - } + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) + { + LLDrawInfo* pparams = *i; + LLCullResult::increment_iterator(i, end); + + pushBatch(*pparams, mask, texture, batch_textures); } } @@ -523,34 +532,35 @@ void LLRenderPass::pushRiggedBatches(U32 type, U32 mask, BOOL texture, BOOL batc LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; mask |= LLVertexBuffer::MAP_WEIGHT4; - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; - if (pparams) - { - if (pparams->mAvatar.notNull() && (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash)) - { - uploadMatrixPalette(*pparams); - lastAvatar = pparams->mAvatar; - lastMeshId = pparams->mSkinInfo->mHash; - } + LLCullResult::increment_iterator(i, end); - pushBatch(*pparams, mask, texture, batch_textures); + if (pparams->mAvatar.notNull() && (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash)) + { + uploadMatrixPalette(*pparams); + lastAvatar = pparams->mAvatar; + lastMeshId = pparams->mSkinInfo->mHash; } + + pushBatch(*pparams, mask, texture, batch_textures); } } void LLRenderPass::pushMaskBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { - LLDrawInfo* pparams = *i; - if (pparams) - { - LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); - pushBatch(*pparams, mask, texture, batch_textures); - } + LLDrawInfo* pparams = *i; + LLCullResult::increment_iterator(i, end); + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); + pushBatch(*pparams, mask, texture, batch_textures); } } @@ -559,29 +569,31 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, U32 mask, BOOL texture, BOOL LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; - if (pparams) - { - if (LLGLSLShader::sCurBoundShaderPtr) - { - LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); - } - else - { - gGL.flush(); - } - if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) - { - uploadMatrixPalette(*pparams); - lastAvatar = pparams->mAvatar; - lastMeshId = pparams->mSkinInfo->mHash; - } + LLCullResult::increment_iterator(i, end); - pushBatch(*pparams, mask | LLVertexBuffer::MAP_WEIGHT4, texture, batch_textures); + if (LLGLSLShader::sCurBoundShaderPtr) + { + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); + } + else + { + gGL.flush(); } + + if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) + { + uploadMatrixPalette(*pparams); + lastAvatar = pparams->mAvatar; + lastMeshId = pparams->mSkinInfo->mHash; + } + + pushBatch(*pparams, mask | LLVertexBuffer::MAP_WEIGHT4, texture, batch_textures); } } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index dc7e5f51df..3ce2ced255 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -634,7 +634,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) continue; } - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("ra - push batch") + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("ra - push batch"); U32 have_mask = params.mVertexBuffer->getTypeMask() & mask; if (have_mask != mask) diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 6af4e2274c..4379fdc603 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -724,10 +724,12 @@ void LLDrawPoolBump::renderDeferred(S32 pass) LLVOAvatar* avatar = nullptr; U64 skin = 0; - for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo& params = **i; + LLCullResult::increment_iterator(i, end); + LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(params.mAlphaMaskCutoff); LLDrawPoolBump::bindBumpMap(params, bump_channel); diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index ec1ac6a88c..858fb871d3 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -203,11 +203,13 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) LLVOAvatar* lastAvatar = nullptr; - for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LL_PROFILE_ZONE_NAMED_CATEGORY_MATERIAL("materials draw loop"); LLDrawInfo& params = **i; + LLCullResult::increment_iterator(i, end); + if (specular > -1 && params.mSpecColor != lastSpecular) { lastSpecular = params.mSpecColor; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 113cd98164..7653913c2b 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2872,42 +2872,6 @@ void renderBatchSize(LLDrawInfo* params) } } -void renderShadowFrusta(LLDrawInfo* params) -{ - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ADD); - - LLVector4a center; - center.setAdd(params->mExtents[1], params->mExtents[0]); - center.mul(0.5f); - LLVector4a size; - size.setSub(params->mExtents[1],params->mExtents[0]); - size.mul(0.5f); - - if (gPipeline.mShadowCamera[4].AABBInFrustum(center, size)) - { - gGL.diffuseColor3f(1,0,0); - pushVerts(params, LLVertexBuffer::MAP_VERTEX); - } - if (gPipeline.mShadowCamera[5].AABBInFrustum(center, size)) - { - gGL.diffuseColor3f(0,1,0); - pushVerts(params, LLVertexBuffer::MAP_VERTEX); - } - if (gPipeline.mShadowCamera[6].AABBInFrustum(center, size)) - { - gGL.diffuseColor3f(0,0,1); - pushVerts(params, LLVertexBuffer::MAP_VERTEX); - } - if (gPipeline.mShadowCamera[7].AABBInFrustum(center, size)) - { - gGL.diffuseColor3f(1,0,1); - pushVerts(params, LLVertexBuffer::MAP_VERTEX); - } - - gGL.setSceneBlendType(LLRender::BT_ALPHA); -} - void renderTexelDensity(LLDrawable* drawable) { if (LLViewerTexture::sDebugTexelsMode == LLViewerTexture::DEBUG_TEXELS_OFF @@ -3492,10 +3456,6 @@ public: { renderBatchSize(draw_info); } - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) - { - renderShadowFrusta(draw_info); - } } } } diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 020a010405..b765bd1632 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -87,8 +87,6 @@ public: // return mSkinHash->mHash, or 0 if mSkinHash is null U64 getSkinHash(); - LLVector4a mExtents[2]; - LLPointer mVertexBuffer; LLPointer mTexture; std::vector > mTextureList; @@ -505,6 +503,23 @@ public: typedef LLDrawInfo** drawinfo_iterator; typedef LLDrawable** drawable_iterator; + // Helper function for taking advantage of _mm_prefetch when iterating over cull results + static inline void increment_iterator(LLCullResult::drawinfo_iterator& i, const LLCullResult::drawinfo_iterator& end) + { + ++i; + + if (i != end) + { + _mm_prefetch((char*)(*i)->mVertexBuffer.get(), _MM_HINT_NTA); + + auto* ni = i + 1; + if (ni != end) + { + _mm_prefetch((char*)*ni, _MM_HINT_NTA); + } + } + } + void clear(); sg_iterator beginVisibleGroups(); diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 36d66cccef..b4b2db5d51 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -731,9 +731,6 @@ void LLGrassPartition::getGeometry(LLSpatialGroup* group) //facep->getTexture(), buffer, object->isSelected(), fullbright); - const LLVector4a* exts = group->getObjectExtents(); - info->mExtents[0] = exts[0]; - info->mExtents[1] = exts[1]; info->mVSize = vsize; draw_vec.push_back(info); //for alpha sorting diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 0c09cbf2c2..a5c65d6ed4 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -963,9 +963,6 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) LLDrawInfo* info = new LLDrawInfo(start,end,count,offset,facep->getTexture(), buffer, object->isSelected(), fullbright); - const LLVector4a* exts = group->getObjectExtents(); - info->mExtents[0] = exts[0]; - info->mExtents[1] = exts[1]; info->mVSize = vsize; info->mBlendFuncDst = bf_dst; info->mBlendFuncSrc = bf_src; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index afebf27d8b..53158ee66f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5305,8 +5305,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_vec[idx]->mTextureListVSize[index] = vsize; } draw_vec[idx]->validate(); - update_min_max(draw_vec[idx]->mExtents[0], draw_vec[idx]->mExtents[1], facep->mExtents[0]); - update_min_max(draw_vec[idx]->mExtents[0], draw_vec[idx]->mExtents[1], facep->mExtents[1]); } else { @@ -5385,8 +5383,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, { //for alpha sorting facep->setDrawInfo(draw_info); } - draw_info->mExtents[0] = facep->mExtents[0]; - draw_info->mExtents[1] = facep->mExtents[1]; if (index < FACE_DO_NOT_BATCH_TEXTURES) { //initialize texture list for texture batching diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 10c271cddc..9851d4bc6a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2863,6 +2863,8 @@ void LLPipeline::clearRebuildDrawables() void LLPipeline::rebuildPriorityGroups() { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("rebuildPriorityGroups"); + LLTimer update_timer; assertInitialized(); @@ -7412,18 +7414,7 @@ void LLPipeline::renderShadowSimple(U32 type) { LLDrawInfo& params = **i; - ++i; - - if (i != end) - { - _mm_prefetch((char*) (*i)->mVertexBuffer.get(), _MM_HINT_NTA); - - auto* ni = i + 1; - if (ni != end) - { - _mm_prefetch((char*)*ni, _MM_HINT_NTA); - } - } + LLCullResult::increment_iterator(i, end); LLVertexBuffer* vb = params.mVertexBuffer; if (vb != last_vb) @@ -7448,11 +7439,16 @@ void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, U32 type = LLRenderPass::PASS_ALPHA; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + auto* begin = gPipeline.beginRenderMap(type); + auto* end = gPipeline.endRenderMap(type); + + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; if (pparams) { + LLCullResult::increment_iterator(i, end); + if (rigged) { if (pparams->mAvatar != nullptr) -- cgit v1.3 From 7bd9d21e19b923096ba2b5ea3cbc8be3e13d7aa0 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 19 Jan 2023 09:13:45 -0600 Subject: Optimizations, decruft, and intel compatibility pass (#53) SL-18869, SL-18772 Overhaul VBO management, restore occlusion culling, intel compatibility pass, etc --- indra/llprimitive/llmaterial.cpp | 13 + indra/llprimitive/llmaterial.h | 1 + indra/llrender/llgl.cpp | 217 +-- indra/llrender/llgl.h | 9 +- indra/llrender/llglslshader.cpp | 21 + indra/llrender/llrender.cpp | 37 +- indra/llrender/llrender.h | 46 +- indra/llrender/llrendernavprim.cpp | 2 +- indra/llrender/llshadermgr.cpp | 29 +- indra/llrender/llvertexbuffer.cpp | 1442 ++++++-------------- indra/llrender/llvertexbuffer.h | 205 ++- indra/llwindow/llwindowwin32.cpp | 36 +- indra/newview/app_settings/settings.xml | 2 +- .../shaders/class3/deferred/reflectionProbeF.glsl | 7 +- indra/newview/featuretable.txt | 4 +- indra/newview/featuretable_mac.txt | 4 +- indra/newview/llappviewer.cpp | 1 - indra/newview/lldrawable.cpp | 11 +- indra/newview/lldrawpool.cpp | 48 +- indra/newview/lldrawpool.h | 19 +- indra/newview/lldrawpoolalpha.cpp | 59 +- indra/newview/lldrawpoolavatar.cpp | 19 - indra/newview/lldrawpoolavatar.h | 6 - indra/newview/lldrawpoolbump.cpp | 55 +- indra/newview/lldrawpoolbump.h | 8 +- indra/newview/lldrawpoolmaterials.cpp | 6 +- indra/newview/lldrawpoolpbropaque.cpp | 6 +- indra/newview/lldrawpoolsimple.cpp | 97 +- indra/newview/lldrawpoolterrain.cpp | 5 +- indra/newview/lldrawpoolterrain.h | 14 +- indra/newview/lldrawpooltree.cpp | 6 +- indra/newview/lldrawpoolwater.cpp | 393 +----- indra/newview/lldrawpoolwater.h | 10 - indra/newview/llface.cpp | 215 +-- indra/newview/llface.h | 9 +- indra/newview/llflexibleobject.cpp | 1 + indra/newview/llfloaterimagepreview.cpp | 6 +- indra/newview/llglsandbox.cpp | 8 +- indra/newview/llhudobject.cpp | 2 +- indra/newview/llhudtext.cpp | 2 - indra/newview/llmodelpreview.cpp | 28 +- indra/newview/llreflectionmapmanager.cpp | 10 +- indra/newview/llspatialpartition.cpp | 218 ++- indra/newview/llspatialpartition.h | 133 +- indra/newview/llsprite.cpp | 7 +- indra/newview/llstartup.cpp | 2 - indra/newview/llviewerdisplay.cpp | 37 +- indra/newview/llviewerjointmesh.cpp | 19 +- indra/newview/llviewerobject.cpp | 15 +- indra/newview/llviewerobject.h | 13 +- indra/newview/llvieweroctree.cpp | 8 +- indra/newview/llviewershadermgr.cpp | 29 +- indra/newview/llviewertexture.cpp | 2 +- indra/newview/llviewertexturelist.cpp | 41 + indra/newview/llviewerwindow.cpp | 20 +- indra/newview/llvoavatar.cpp | 17 +- indra/newview/llvograss.cpp | 17 +- indra/newview/llvoground.cpp | 6 +- indra/newview/llvopartgroup.cpp | 196 ++- indra/newview/llvopartgroup.h | 9 +- indra/newview/llvosky.cpp | 18 +- indra/newview/llvosurfacepatch.cpp | 29 +- indra/newview/llvotree.cpp | 22 +- indra/newview/llvovolume.cpp | 269 ++-- indra/newview/llvowater.cpp | 21 +- indra/newview/llvowlsky.cpp | 28 +- indra/newview/pipeline.cpp | 618 ++------- indra/newview/pipeline.h | 20 +- 68 files changed, 1362 insertions(+), 3571 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index f546ac1645..0ab97a0df3 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -27,6 +27,7 @@ #include "linden_common.h" #include "llmaterial.h" +#include "llmd5.h" /** * Materials cap parameters @@ -475,4 +476,16 @@ U32 LLMaterial::getShaderMask(U32 alpha_mode) return ret; } +LLUUID LLMaterial::getHash() const +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + LLMD5 md5; + // HACK - hash the bytes of this LLMaterial, but trim off the S32 in LLRefCount + md5.update((unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); + md5.finalize(); + LLUUID id; + md5.raw_digest(id.mData); + // *TODO: Hash the overrides + return id; +} diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 2f8aafc2cf..d715671ae1 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -125,6 +125,7 @@ public: bool operator != (const LLMaterial& rhs) const; U32 getShaderMask(U32 alpha_mode = DIFFUSE_ALPHA_MODE_DEFAULT); + LLUUID getHash() const; protected: LLUUID mNormalID; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 67bd9e277e..9dfe5ef9ff 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -2395,234 +2395,39 @@ void LLGLState::dumpStates() } } -void LLGLState::checkStates(const std::string& msg) +void LLGLState::checkStates(GLboolean writeAlpha) { if (!gDebugGL) { return; } - stop_glerror(); - GLint src; GLint dst; glGetIntegerv(GL_BLEND_SRC, &src); glGetIntegerv(GL_BLEND_DST, &dst); - - stop_glerror(); - - BOOL error = FALSE; - - /*if (src != GL_SRC_ALPHA || dst != GL_ONE_MINUS_SRC_ALPHA) - { - if (gDebugSession) - { - gFailLog << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << std::dec << std::endl; - error = TRUE; - } - else - { - LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << std::dec << LL_ENDL; - } - }*/ + llassert_always(src == GL_SRC_ALPHA); + llassert_always(dst == GL_ONE_MINUS_SRC_ALPHA); + + GLboolean colorMask[4]; + glGetBooleanv(GL_COLOR_WRITEMASK, colorMask); + llassert_always(colorMask[0]); + llassert_always(colorMask[1]); + llassert_always(colorMask[2]); + llassert_always(colorMask[3] == writeAlpha); for (boost::unordered_map::iterator iter = sStateMap.begin(); iter != sStateMap.end(); ++iter) { LLGLenum state = iter->first; LLGLboolean cur_state = iter->second; - stop_glerror(); LLGLboolean gl_state = glIsEnabled(state); - stop_glerror(); if(cur_state != gl_state) { dumpStates(); - if (gDebugSession) - { - gFailLog << llformat("LLGLState error. State: 0x%04x",state) << std::endl; - error = TRUE; - } - else - { - LL_GL_ERRS << llformat("LLGLState error. State: 0x%04x",state) << LL_ENDL; - } - } - } - - if (error) - { - ll_fail("LLGLState::checkStates failed."); - } - stop_glerror(); -} - -void LLGLState::checkTextureChannels(const std::string& msg) -{ -#if 0 - if (!gDebugGL) - { - return; - } - stop_glerror(); - - GLint activeTexture; - glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture); - stop_glerror(); - - BOOL error = FALSE; - - if (activeTexture == GL_TEXTURE0) - { - GLint tex_env_mode = 0; - - glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &tex_env_mode); - stop_glerror(); - - if (tex_env_mode != GL_MODULATE) - { - error = TRUE; - LL_WARNS("RenderState") << "GL_TEXTURE_ENV_MODE invalid: " << std::hex << tex_env_mode << std::dec << LL_ENDL; - if (gDebugSession) - { - gFailLog << "GL_TEXTURE_ENV_MODE invalid: " << std::hex << tex_env_mode << std::dec << std::endl; - } + LL_GL_ERRS << llformat("LLGLState error. State: 0x%04x",state) << LL_ENDL; } } - - static const char* label[] = - { - "GL_TEXTURE_2D", - "GL_TEXTURE_COORD_ARRAY", - "GL_TEXTURE_1D", - "GL_TEXTURE_CUBE_MAP", - "GL_TEXTURE_GEN_S", - "GL_TEXTURE_GEN_T", - "GL_TEXTURE_GEN_Q", - "GL_TEXTURE_GEN_R", - "GL_TEXTURE_RECTANGLE", - "GL_TEXTURE_2D_MULTISAMPLE" - }; - - static GLint value[] = - { - GL_TEXTURE_2D, - GL_TEXTURE_COORD_ARRAY, - GL_TEXTURE_1D, - GL_TEXTURE_CUBE_MAP, - GL_TEXTURE_GEN_S, - GL_TEXTURE_GEN_T, - GL_TEXTURE_GEN_Q, - GL_TEXTURE_GEN_R, - GL_TEXTURE_RECTANGLE, - GL_TEXTURE_2D_MULTISAMPLE - }; - - GLint stackDepth = 0; - - glh::matrix4f mat; - glh::matrix4f identity; - identity.identity(); - - for (GLint i = 1; i < gGLManager.mNumTextureImageUnits; i++) - { - gGL.getTexUnit(i)->activate(); - - if (i < gGLManager.mNumTextureUnits) - { - glClientActiveTexture(GL_TEXTURE0+i); - stop_glerror(); - glGetIntegerv(GL_TEXTURE_STACK_DEPTH, &stackDepth); - stop_glerror(); - - if (stackDepth != 1) - { - error = TRUE; - LL_WARNS("RenderState") << "Texture matrix stack corrupted." << LL_ENDL; - - if (gDebugSession) - { - gFailLog << "Texture matrix stack corrupted." << std::endl; - } - } - - glGetFloatv(GL_TEXTURE_MATRIX, (GLfloat*) mat.m); - stop_glerror(); - - if (mat != identity) - { - error = TRUE; - LL_WARNS("RenderState") << "Texture matrix in channel " << i << " corrupt." << LL_ENDL; - if (gDebugSession) - { - gFailLog << "Texture matrix in channel " << i << " corrupt." << std::endl; - } - } - - for (S32 j = (i == 0 ? 1 : 0); - j < 9; j++) - { - if (glIsEnabled(value[j])) - { - error = TRUE; - LL_WARNS("RenderState") << "Texture channel " << i << " still has " << label[j] << " enabled." << LL_ENDL; - if (gDebugSession) - { - gFailLog << "Texture channel " << i << " still has " << label[j] << " enabled." << std::endl; - } - } - stop_glerror(); - } - - glGetFloatv(GL_TEXTURE_MATRIX, mat.m); - stop_glerror(); - - if (mat != identity) - { - error = TRUE; - LL_WARNS("RenderState") << "Texture matrix " << i << " is not identity." << LL_ENDL; - if (gDebugSession) - { - gFailLog << "Texture matrix " << i << " is not identity." << std::endl; - } - } - } - - { - GLint tex = 0; - stop_glerror(); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex); - stop_glerror(); - - if (tex != 0) - { - error = TRUE; - LL_WARNS("RenderState") << "Texture channel " << i << " still has texture " << tex << " bound." << LL_ENDL; - - if (gDebugSession) - { - gFailLog << "Texture channel " << i << " still has texture " << tex << " bound." << std::endl; - } - } - } - } - - stop_glerror(); - gGL.getTexUnit(0)->activate(); - glClientActiveTexture(GL_TEXTURE0); - stop_glerror(); - - if (error) - { - if (gDebugSession) - { - ll_fail("LLGLState::checkTextureChannels failed."); - } - else - { - LL_GL_ERRS << "GL texture state corruption detected. " << msg << LL_ENDL; - } - } -#endif } /////////////////////////////////////////////////////////////////////// diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index e3c07604aa..eb0650d998 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -231,9 +231,12 @@ public: static void resetTextureStates(); static void dumpStates(); - static void checkStates(const std::string& msg = ""); - static void checkTextureChannels(const std::string& msg = ""); - + + // make sure GL blend function, GL states, and GL color mask match + // what we expect + // writeAlpha - whether or not writing to alpha channel is expected + static void checkStates(GLboolean writeAlpha = GL_TRUE); + protected: static boost::unordered_map sStateMap; diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index c5f4efd2c0..982b2a847a 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -154,15 +154,33 @@ void LLGLSLShader::finishProfile(bool emit_report) std::sort(sorted.begin(), sorted.end(), LLGLSLShaderCompareTimeElapsed()); + bool unbound = false; for (std::vector::iterator iter = sorted.begin(); iter != sorted.end(); ++iter) { (*iter)->dumpStats(); + if ((*iter)->mBinds == 0) + { + unbound = true; + } } LL_INFOS() << "-----------------------------------" << LL_ENDL; LL_INFOS() << "Total rendering time: " << llformat("%.4f ms", sTotalTimeElapsed / 1000000.f) << LL_ENDL; LL_INFOS() << "Total samples drawn: " << llformat("%.4f million", sTotalSamplesDrawn / 1000000.f) << LL_ENDL; LL_INFOS() << "Total triangles drawn: " << llformat("%.3f million", sTotalTrianglesDrawn / 1000000.f) << LL_ENDL; + LL_INFOS() << "-----------------------------------" << LL_ENDL; + + if (unbound) + { + LL_INFOS() << "The following shaders were unused: " << LL_ENDL; + for (std::vector::iterator iter = sorted.begin(); iter != sorted.end(); ++iter) + { + if ((*iter)->mBinds == 0) + { + LL_INFOS() << (*iter)->mName << LL_ENDL; + } + } + } } } @@ -985,6 +1003,8 @@ void LLGLSLShader::bind() { LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; + llassert(mProgramObject != 0); + gGL.flush(); if (sCurBoundShader != mProgramObject) // Don't re-bind current shader @@ -998,6 +1018,7 @@ void LLGLSLShader::bind() sCurBoundShader = mProgramObject; sCurBoundShaderPtr = this; placeProfileQuery(); + LLVertexBuffer::setupClientArrays(mAttributeMask); } if (mUniformsDirty) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index bba6a46e43..a8db69a9a4 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -164,13 +164,10 @@ void LLTexUnit::enable(eTextureType type) if ( (mCurrTexType != type || gGL.mDirty) && (type != TT_NONE) ) { - stop_glerror(); activate(); - stop_glerror(); if (mCurrTexType != TT_NONE && !gGL.mDirty) { disable(); // Force a disable of a previous texture type if it's enabled. - stop_glerror(); } mCurrTexType = type; @@ -184,11 +181,7 @@ void LLTexUnit::disable(void) if (mCurrTexType != TT_NONE) { - activate(); unbind(mCurrTexType); - gGL.flush(); - setTextureColorSpace(TCS_LINEAR); - mCurrTexType = TT_NONE; } } @@ -196,7 +189,7 @@ void LLTexUnit::disable(void) void LLTexUnit::bindFast(LLTexture* texture) { LLImageGL* gl_tex = texture->getGLTexture(); - + texture->setActive(); glActiveTexture(GL_TEXTURE0 + mIndex); gGL.mCurrTextureUnitIndex = mIndex; mCurrTexture = gl_tex->getTexName(); @@ -889,12 +882,11 @@ void LLRender::init(bool needs_vertex_buffer) // necessary for reflection maps glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) - { //bind a dummy vertex array object so we're core profile compliant - U32 ret; - glGenVertexArrays(1, &ret); - glBindVertexArray(ret); - } + { //bind a dummy vertex array object so we're core profile compliant + U32 ret; + glGenVertexArrays(1, &ret); + glBindVertexArray(ret); + } if (needs_vertex_buffer) { @@ -906,8 +898,8 @@ void LLRender::initVertexBuffer() { llassert_always(mBuffer.isNull()); stop_glerror(); - mBuffer = new LLVertexBuffer(immediate_mask, 0); - mBuffer->allocateBuffer(4096, 0, TRUE); + mBuffer = new LLVertexBuffer(immediate_mask); + mBuffer->allocateBuffer(4096, 0); mBuffer->getVertexStrider(mVerticesp); mBuffer->getTexCoord0Strider(mTexcoordsp); mBuffer->getColorStrider(mColorsp); @@ -1604,6 +1596,7 @@ void LLRender::flush() if (mCount > 0) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + llassert(LLGLSLShader::sCurBoundShaderPtr != nullptr); if (!mUIOffset.empty()) { sUICalls++; @@ -1691,8 +1684,11 @@ void LLRender::flush() else { LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache miss"); - vb = new LLVertexBuffer(attribute_mask, GL_STATIC_DRAW); - vb->allocateBuffer(count, 0, true); + vb = new LLVertexBuffer(attribute_mask); + vb->allocateBuffer(count, 0); + + vb->setBuffer(); + vb->setPositionData((LLVector4a*) mVerticesp.get()); if (attribute_mask & LLVertexBuffer::MAP_TEXCOORD0) @@ -1733,7 +1729,7 @@ void LLRender::flush() } } - vb->setBuffer(attribute_mask); + vb->setBuffer(); if (mMode == LLRender::QUADS && sGLCoreProfile) { @@ -2034,8 +2030,7 @@ void LLRender::texCoord2fv(const GLfloat* tc) void LLRender::color4ub(const GLubyte& r, const GLubyte& g, const GLubyte& b, const GLubyte& a) { - if (!LLGLSLShader::sCurBoundShaderPtr || - LLGLSLShader::sCurBoundShaderPtr->mAttributeMask & LLVertexBuffer::MAP_COLOR) + if (!LLGLSLShader::sCurBoundShaderPtr || LLGLSLShader::sCurBoundShaderPtr->mAttributeMask & LLVertexBuffer::MAP_COLOR) { mColorsp[mCount] = LLColor4U(r,g,b,a); } diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 9fabeb1d7a..cbd3de5736 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -277,7 +277,7 @@ class LLRender friend class LLTexUnit; public: - enum eTexIndex + enum eTexIndex : U8 { DIFFUSE_MAP = 0, ALTERNATE_DIFFUSE_MAP = 1, @@ -286,14 +286,15 @@ public: NUM_TEXTURE_CHANNELS = 3, }; - enum eVolumeTexIndex + enum eVolumeTexIndex : U8 { LIGHT_TEX = 0, SCULPT_TEX, NUM_VOLUME_TEXTURE_CHANNELS, }; - typedef enum { + enum eGeomModes : U8 + { TRIANGLES = 0, TRIANGLE_STRIP, TRIANGLE_FAN, @@ -303,9 +304,9 @@ public: QUADS, LINE_LOOP, NUM_MODES - } eGeomModes; + }; - typedef enum + enum eCompareFunc : U8 { CF_NEVER = 0, CF_ALWAYS, @@ -316,9 +317,9 @@ public: CF_GREATER_EQUAL, CF_GREATER, CF_DEFAULT - } eCompareFunc; + }; - typedef enum + enum eBlendType : U8 { BT_ALPHA = 0, BT_ADD, @@ -327,25 +328,26 @@ public: BT_MULT_ALPHA, BT_MULT_X2, BT_REPLACE - } eBlendType; + }; - typedef enum + // WARNING: this MUST match the LL_PART_BF enum in LLPartData, so set values explicitly in case someone + // decides to add more or reorder them + enum eBlendFactor : U8 { BF_ONE = 0, - BF_ZERO, - BF_DEST_COLOR, - BF_SOURCE_COLOR, - BF_ONE_MINUS_DEST_COLOR, - BF_ONE_MINUS_SOURCE_COLOR, - BF_DEST_ALPHA, - BF_SOURCE_ALPHA, - BF_ONE_MINUS_DEST_ALPHA, - BF_ONE_MINUS_SOURCE_ALPHA, - + BF_ZERO = 1, + BF_DEST_COLOR = 2, + BF_SOURCE_COLOR = 3, + BF_ONE_MINUS_DEST_COLOR = 4, + BF_ONE_MINUS_SOURCE_COLOR = 5, + BF_DEST_ALPHA = 6, + BF_SOURCE_ALPHA = 7, + BF_ONE_MINUS_DEST_ALPHA = 8, + BF_ONE_MINUS_SOURCE_ALPHA = 9, BF_UNDEF - } eBlendFactor; + }; - typedef enum + enum eMatrixMode : U8 { MM_MODELVIEW = 0, MM_PROJECTION, @@ -355,7 +357,7 @@ public: MM_TEXTURE3, NUM_MATRIX_MODES, MM_TEXTURE - } eMatrixMode; + }; LLRender(); ~LLRender(); diff --git a/indra/llrender/llrendernavprim.cpp b/indra/llrender/llrendernavprim.cpp index ca72964832..d610a44bc6 100644 --- a/indra/llrender/llrendernavprim.cpp +++ b/indra/llrender/llrendernavprim.cpp @@ -53,7 +53,7 @@ void LLRenderNavPrim::renderLLTri( const LLVector3& a, const LLVector3& b, const //============================================================================= void LLRenderNavPrim::renderNavMeshVB( U32 mode, LLVertexBuffer* pVBO, int vertCnt ) { - pVBO->setBuffer( LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_NORMAL ); + pVBO->setBuffer(); pVBO->drawArrays( mode, 0, vertCnt ); } //============================================================================= diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index b189e5452c..ee8ac359c7 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -590,6 +590,7 @@ static std::string get_shader_log(GLuint ret) static std::string get_program_log(GLuint ret) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; std::string res; //get log length @@ -1113,16 +1114,24 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev BOOL LLShaderMgr::linkProgramObject(GLuint obj, BOOL suppress_errors) { //check for errors - glLinkProgram(obj); - GLint success = GL_TRUE; - glGetProgramiv(obj, GL_LINK_STATUS, &success); - if (!suppress_errors && success == GL_FALSE) - { - //an error occured, print log - LL_SHADER_LOADING_WARNS() << "GLSL Linker Error:" << LL_ENDL; - dumpObjectLog(obj, TRUE, "linker"); - return success; - } + { + LL_PROFILE_ZONE_NAMED_CATEGORY_SHADER("glLinkProgram"); + glLinkProgram(obj); + } + + GLint success = GL_TRUE; + + { + LL_PROFILE_ZONE_NAMED_CATEGORY_SHADER("glsl check link status"); + glGetProgramiv(obj, GL_LINK_STATUS, &success); + if (!suppress_errors && success == GL_FALSE) + { + //an error occured, print log + LL_SHADER_LOADING_WARNS() << "GLSL Linker Error:" << LL_ENDL; + dumpObjectLog(obj, TRUE, "linker"); + return success; + } + } std::string log = get_program_log(obj); LLStringUtil::toLower(log); diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index bc33591ed7..f1d71ec94d 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -70,25 +70,6 @@ struct CompareMappedRegion } }; - -const U32 LL_VBO_BLOCK_SIZE = 2048; -const U32 LL_VBO_POOL_MAX_SEED_SIZE = 256*1024; - -U32 vbo_block_size(U32 size) -{ //what block size will fit size? - U32 mod = size % LL_VBO_BLOCK_SIZE; - return mod == 0 ? size : size + (LL_VBO_BLOCK_SIZE-mod); -} - -U32 vbo_block_index(U32 size) -{ - U32 blocks = vbo_block_size(size)/LL_VBO_BLOCK_SIZE; // block count reqd - llassert(blocks > 0); - return blocks - 1; // Adj index, i.e. single-block allocations are at index 0, etc -} - -const U32 LL_VBO_POOL_SEED_COUNT = vbo_block_index(LL_VBO_POOL_MAX_SEED_SIZE) + 1; - #define ENABLE_GL_WORK_QUEUE 0 #if ENABLE_GL_WORK_QUEUE @@ -294,6 +275,8 @@ static GLuint gen_buffer() return sNamePool[--sIndex]; } +#define ANALYZE_VBO_POOL 0 + class LLVBOPool { public: @@ -316,13 +299,42 @@ public: Pool mVBOPool; Pool mIBOPool; - U32 mMissCount = 0; + U32 mTouchCount = 0; + +#if ANALYZE_VBO_POOL + U64 mDistributed = 0; + U64 mAllocated = 0; + U64 mReserved = 0; + U32 mMisses = 0; + U32 mHits = 0; +#endif + + // increase the size to some common value (e.g. a power of two) to increase hit rate + void adjustSize(U32& size) + { + // size = nhpo2(size); // (193/303)/580 MB (distributed/allocated)/reserved in VBO Pool. Overhead: 66 percent. Hit rate: 77 percent + + //(245/276)/385 MB (distributed/allocated)/reserved in VBO Pool. Overhead: 57 percent. Hit rate: 69 percent + //(187/209)/397 MB (distributed/allocated)/reserved in VBO Pool. Overhead: 112 percent. Hit rate: 76 percent + U32 block_size = llmax(nhpo2(size) / 8, (U32) 16); + size += block_size - (size % block_size); + } void allocate(GLenum type, U32 size, GLuint& name, U8*& data) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - - size = nhpo2(size); + llassert(type == GL_ARRAY_BUFFER || type == GL_ELEMENT_ARRAY_BUFFER); + llassert(name == 0); // non zero name indicates a gl name that wasn't freed + llassert(data == nullptr); // non null data indicates a buffer that wasn't freed + llassert(size >= 2); // any buffer size smaller than a single index is nonsensical + +#if ANALYZE_VBO_POOL + mDistributed += size; + adjustSize(size); + mAllocated += size; +#else + adjustSize(size); +#endif auto& pool = type == GL_ELEMENT_ARRAY_BUFFER ? mIBOPool : mVBOPool; @@ -332,13 +344,9 @@ public: LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vbo pool miss"); LL_PROFILE_GPU_ZONE("vbo alloc"); - ++mMissCount; - if (mMissCount > 1024) - { //clean cache on every 1024 misses - mMissCount = 0; - clean(); - } - +#if ANALYZE_VBO_POOL + mMisses++; +#endif name = gen_buffer(); glBindBuffer(type, name); glBufferData(type, size, nullptr, GL_DYNAMIC_DRAW); @@ -355,22 +363,47 @@ public: } else { +#if ANALYZE_VBO_POOL + mHits++; + llassert(mReserved >= size); // assert if accounting gets messed up + mReserved -= size; +#endif + std::list& entries = iter->second; Entry& entry = entries.back(); name = entry.mGLName; data = entry.mData; - + entries.pop_back(); if (entries.empty()) { pool.erase(iter); } } + + clean(); } void free(GLenum type, U32 size, GLuint name, U8* data) { - size = nhpo2(size); + LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; + llassert(type == GL_ARRAY_BUFFER || type == GL_ELEMENT_ARRAY_BUFFER); + llassert(size >= 2); + llassert(name != 0); + llassert(data != nullptr); + + clean(); + +#if ANALYZE_VBO_POOL + llassert(mDistributed >= size); + mDistributed -= size; + adjustSize(size); + llassert(mAllocated >= size); + mAllocated -= size; + mReserved += size; +#else + adjustSize(size); +#endif auto& pool = type == GL_ELEMENT_ARRAY_BUFFER ? mIBOPool : mVBOPool; @@ -386,10 +419,19 @@ public: { iter->second.push_front({ data, name, std::chrono::steady_clock::now() }); } + } + // clean periodically (clean gets called for every alloc/free) void clean() { + mTouchCount++; + if (mTouchCount < 1024) // clean every 1k touches + { + return; + } + mTouchCount = 0; + LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; std::unordered_map>* pools[] = { &mVBOPool, &mIBOPool }; @@ -410,7 +452,12 @@ public: auto& entry = entries.back(); ll_aligned_free_16(entry.mData); glDeleteBuffers(1, &entry.mGLName); +#if ANALYZE_VBO_POOL + llassert(mReserved >= iter->first); + mReserved -= iter->first; +#endif entries.pop_back(); + } if (entries.empty()) @@ -423,6 +470,16 @@ public: } } } + +#if ANALYZE_VBO_POOL + LL_INFOS() << llformat("(%d/%d)/%d MB (distributed/allocated)/total in VBO Pool. Overhead: %d percent. Hit rate: %d percent", + mDistributed / 1000000, + mAllocated / 1000000, + (mAllocated + mReserved) / 1000000, // total bytes + ((mAllocated+mReserved-mDistributed)*100)/llmax(mDistributed, (U64) 1), // overhead percent + (mHits*100)/llmax(mMisses+mHits, (U32)1)) // hit rate percent + << LL_ENDL; +#endif } void clear() @@ -445,6 +502,10 @@ public: } } +#if ANALYZE_VBO_POOL + mReserved = 0; +#endif + mIBOPool.clear(); mVBOPool.clear(); } @@ -457,35 +518,14 @@ static LLVBOPool* sVBOPool = nullptr; //============================================================================ // //static -std::list LLVertexBuffer::sAvailableVAOName; -U32 LLVertexBuffer::sCurVAOName = 1; - -U32 LLVertexBuffer::sAllocatedIndexBytes = 0; -U32 LLVertexBuffer::sIndexCount = 0; - -U32 LLVertexBuffer::sBindCount = 0; -U32 LLVertexBuffer::sSetCount = 0; -S32 LLVertexBuffer::sCount = 0; -S32 LLVertexBuffer::sGLCount = 0; -S32 LLVertexBuffer::sMappedCount = 0; -bool LLVertexBuffer::sDisableVBOMapping = false; -bool LLVertexBuffer::sEnableVBOs = true; U32 LLVertexBuffer::sGLRenderBuffer = 0; -U32 LLVertexBuffer::sGLRenderArray = 0; U32 LLVertexBuffer::sGLRenderIndices = 0; U32 LLVertexBuffer::sLastMask = 0; -bool LLVertexBuffer::sVBOActive = false; -bool LLVertexBuffer::sIBOActive = false; -U32 LLVertexBuffer::sAllocatedBytes = 0; U32 LLVertexBuffer::sVertexCount = 0; -bool LLVertexBuffer::sMapped = false; -bool LLVertexBuffer::sUseStreamDraw = true; -bool LLVertexBuffer::sUseVAO = false; -bool LLVertexBuffer::sPreferStreamDraw = false; //NOTE: each component must be AT LEAST 4 bytes in size to avoid a performance penalty on AMD hardware -const S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = +const U32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = { sizeof(LLVector4), // TYPE_VERTEX, sizeof(LLVector4), // TYPE_NORMAL, @@ -534,62 +574,34 @@ const U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = }; //static -U32 LLVertexBuffer::getVAOName() -{ - U32 ret = 0; - - if (!sAvailableVAOName.empty()) - { - ret = sAvailableVAOName.front(); - sAvailableVAOName.pop_front(); - } - else - { -#ifdef GL_ARB_vertex_array_object - glGenVertexArrays(1, &ret); -#endif - } - - return ret; -} - -//static -void LLVertexBuffer::releaseVAOName(U32 name) +void LLVertexBuffer::setupClientArrays(U32 data_mask) { - sAvailableVAOName.push_back(name); -} + if (sLastMask != data_mask) + { + for (U32 i = 0; i < TYPE_MAX; ++i) + { + S32 loc = i; + U32 mask = 1 << i; -//static -void LLVertexBuffer::setupClientArrays(U32 data_mask) -{ - if (sLastMask != data_mask) - { + if (sLastMask & (1 << i)) + { //was enabled + if (!(data_mask & mask)) + { //needs to be disabled + glDisableVertexAttribArray(loc); + } + } + else + { //was disabled + if (data_mask & mask) + { //needs to be enabled + glEnableVertexAttribArray(loc); + } + } + } + } - for (U32 i = 0; i < TYPE_MAX; ++i) - { - S32 loc = i; - - U32 mask = 1 << i; - - if (sLastMask & (1 << i)) - { //was enabled - if (!(data_mask & mask)) - { //needs to be disabled - glDisableVertexAttribArray(loc); - } - } - else - { //was disabled - if (data_mask & mask) - { //needs to be enabled - glEnableVertexAttribArray(loc); - } - } - } - - sLastMask = data_mask; - } + sLastMask = data_mask; } //static @@ -606,7 +618,7 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector& pos) } //static -void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, S32 num_indices, const U16* indicesp) +void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, U32 num_indices, const U16* indicesp) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; llassert(LLGLSLShader::sCurBoundShaderPtr != NULL); @@ -644,8 +656,13 @@ void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVecto gGL.flush(); } -void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_offset) const +bool LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_offset) const { + if (!gDebugGL) + { + return true; + } + llassert(start < (U32)mNumVerts); llassert(end < (U32)mNumVerts); @@ -663,9 +680,8 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of LL_ERRS() << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << LL_ENDL; } - if (gDebugGL && !useVBOs()) { - U16* idx = ((U16*) getIndicesPointer())+indices_offset; + U16* idx = (U16*) mMappedIndexData+indices_offset; for (U32 i = 0; i < count; ++i) { llassert(idx[i] >= start); @@ -681,22 +697,20 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of if (shader && shader->mFeatures.mIndexedTextureChannels > 1) { - LLStrider v; - //hack to get non-const reference - LLVertexBuffer* vb = (LLVertexBuffer*) this; - vb->getVertexStrider(v); - + LLVector4a* v = (LLVector4a*) mMappedData; + for (U32 i = start; i < end; i++) { - S32 idx = (S32) (v[i][3]+0.25f); - llassert(idx >= 0); - if (idx < 0 || idx >= shader->mFeatures.mIndexedTextureChannels) + U32 idx = (U32) (v[i][3]+0.25f); + if (idx >= shader->mFeatures.mIndexedTextureChannels) { LL_ERRS() << "Bad texture index found in vertex data stream." << LL_ENDL; } } } } + + return true; } #ifdef LL_PROFILER_ENABLE_RENDER_DOC @@ -707,124 +721,35 @@ void LLVertexBuffer::setLabel(const char* label) { void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const { - validateRange(start, end, count, indices_offset); - gGL.syncMatrices(); - - llassert(mNumVerts >= 0); - llassert(LLGLSLShader::sCurBoundShaderPtr != NULL); - - if (mGLIndices != sGLRenderIndices) - { - LL_ERRS() << "Wrong index buffer bound." << LL_ENDL; - } - - if (mGLBuffer != sGLRenderBuffer) - { - LL_ERRS() << "Wrong vertex buffer bound." << LL_ENDL; - } - - if (gDebugGL && useVBOs()) - { - GLint elem = 0; - glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &elem); - - if (elem != mGLIndices) - { - LL_ERRS() << "Wrong index buffer bound!" << LL_ENDL; - } - } - - if (mode >= LLRender::NUM_MODES) - { - LL_ERRS() << "Invalid draw mode: " << mode << LL_ENDL; - return; - } - - U16* idx = ((U16*) getIndicesPointer())+indices_offset; - - glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, - idx); -} - -void LLVertexBuffer::drawRangeFast(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const -{ + llassert(validateRange(start, end, count, indices_offset)); + llassert(mGLBuffer == sGLRenderBuffer); + llassert(mGLIndices == sGLRenderIndices); gGL.syncMatrices(); - U16* idx = ((U16*)getIndicesPointer()) + indices_offset; - - glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, - idx); + glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, + (GLvoid*) (indices_offset * sizeof(U16))); } void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const { - llassert(LLGLSLShader::sCurBoundShaderPtr != NULL); - gGL.syncMatrices(); - - llassert(mNumIndices >= 0); - if (indices_offset >= (U32) mNumIndices || - indices_offset + count > (U32) mNumIndices) - { - LL_ERRS() << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << LL_ENDL; - } - - - if (mGLIndices != sGLRenderIndices) - { - LL_ERRS() << "Wrong index buffer bound." << LL_ENDL; - } - - if (mGLBuffer != sGLRenderBuffer) - { - LL_ERRS() << "Wrong vertex buffer bound." << LL_ENDL; - } - - if (mode >= LLRender::NUM_MODES) - { - LL_ERRS() << "Invalid draw mode: " << mode << LL_ENDL; - return; - } - - glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, - ((U16*) getIndicesPointer()) + indices_offset); + drawRange(mode, 0, mNumVerts, count, indices_offset); } void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - llassert(LLGLSLShader::sCurBoundShaderPtr != NULL); + llassert(first + count <= mNumVerts); + llassert(mGLBuffer == sGLRenderBuffer); + llassert(mGLIndices == sGLRenderIndices); + gGL.syncMatrices(); - -#ifndef LL_RELEASE_FOR_DOWNLOAD - llassert(mNumVerts >= 0); - if (first >= (U32) mNumVerts || - first + count > (U32) mNumVerts) - { - LL_ERRS() << "Bad vertex buffer draw range: [" << first << ", " << first+count << "]" << LL_ENDL; - } - - if (mGLBuffer != sGLRenderBuffer || useVBOs() != sVBOActive) - { - LL_ERRS() << "Wrong vertex buffer bound." << LL_ENDL; - } - - if (mode >= LLRender::NUM_MODES) - { - LL_ERRS() << "Invalid draw mode: " << mode << LL_ENDL; - return; - } -#endif - glDrawArrays(sGLMode[mode], first, count); } //static void LLVertexBuffer::initClass(LLWindow* window) { - sEnableVBOs = true; - sDisableVBOMapping = true; - + llassert(sVBOPool == nullptr); sVBOPool = new LLVBOPool(); #if ENABLE_GL_WORK_QUEUE @@ -841,29 +766,11 @@ void LLVertexBuffer::initClass(LLWindow* window) //static void LLVertexBuffer::unbind() { - if (sGLRenderArray) - { - glBindVertexArray(0); - sGLRenderArray = 0; - sGLRenderIndices = 0; - sIBOActive = false; - } - - if (sVBOActive) - { - glBindBuffer(GL_ARRAY_BUFFER, 0); - sVBOActive = false; - } - if (sIBOActive) - { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - sIBOActive = false; - } + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); sGLRenderBuffer = 0; sGLRenderIndices = 0; - - setupClientArrays(0); } //static @@ -886,67 +793,26 @@ void LLVertexBuffer::cleanupClass() delete sQueue; sQueue = nullptr; #endif - - //llassert(0 == sAllocatedBytes); - //llassert(0 == sAllocatedIndexBytes); } //---------------------------------------------------------------------------- -S32 LLVertexBuffer::determineUsage(S32 usage) -{ - S32 ret_usage = usage; - - if (!sEnableVBOs) - { - ret_usage = 0; - } - - if (ret_usage == GL_STREAM_DRAW && !sUseStreamDraw) - { - ret_usage = 0; - } - - // dynamic draw or nothing - ret_usage = GL_DYNAMIC_DRAW; - - return ret_usage; -} - -LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) +LLVertexBuffer::LLVertexBuffer(U32 typemask) : LLRefCount(), - - mNumVerts(0), - mNumIndices(0), - mSize(0), - mIndicesSize(0), - mTypeMask(typemask), - mUsage(LLVertexBuffer::determineUsage(usage)), - mGLBuffer(0), - mGLIndices(0), - mMappedData(NULL), - mMappedIndexData(NULL), - mMappedDataUsingVBOs(false), - mMappedIndexDataUsingVBOs(false), - mVertexLocked(false), - mIndexLocked(false), - mFinal(false), - mEmpty(true) + mTypeMask(typemask) { //zero out offsets for (U32 i = 0; i < TYPE_MAX; i++) { mOffsets[i] = 0; } - - sCount++; } //static -S32 LLVertexBuffer::calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices) +U32 LLVertexBuffer::calcOffsets(const U32& typemask, U32* offsets, U32 num_vertices) { - S32 offset = 0; - for (S32 i=0; iallocate(GL_ARRAY_BUFFER, size, mGLBuffer, mMappedData); - } - - sGLCount++; -} - -void LLVertexBuffer::genIndices(U32 size) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - - mIndicesSize = size; + llassert(mSize == 0); + llassert(mGLBuffer == 0); + llassert(mMappedData == nullptr); - if (sVBOPool) - { - sVBOPool->allocate(GL_ELEMENT_ARRAY_BUFFER, size, mGLIndices, mMappedIndexData); + mSize = size; + sVBOPool->allocate(GL_ARRAY_BUFFER, mSize, mGLBuffer, mMappedData); } - sGLCount++; } -void LLVertexBuffer::releaseBuffer() +void LLVertexBuffer::genIndices(U32 size) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; + llassert(sVBOPool); if (sVBOPool) { - sVBOPool->free(GL_ARRAY_BUFFER, mSize, mGLBuffer, mMappedData); - } - - mGLBuffer = 0; - mMappedData = nullptr; - - sGLCount--; -} - -void LLVertexBuffer::releaseIndices() -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - - if (sVBOPool) - { - sVBOPool->free(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mGLIndices, mMappedIndexData); + llassert(mIndicesSize == 0); + llassert(mGLIndices == 0); + llassert(mMappedIndexData == nullptr); + mIndicesSize = size; + sVBOPool->allocate(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mGLIndices, mMappedIndexData); } - - mMappedIndexData = nullptr; - - sGLCount--; } bool LLVertexBuffer::createGLBuffer(U32 size) @@ -1080,23 +911,8 @@ bool LLVertexBuffer::createGLBuffer(U32 size) bool success = true; - mEmpty = true; - - mMappedDataUsingVBOs = useVBOs(); + genBuffer(size); - if (mMappedDataUsingVBOs) - { - genBuffer(size); - } - else - { - static int gl_buffer_idx = 0; - mGLBuffer = ++gl_buffer_idx; - - mMappedData = (U8*)ll_aligned_malloc_16(size); - mSize = size; - } - if (!mMappedData) { success = false; @@ -1118,27 +934,8 @@ bool LLVertexBuffer::createGLIndices(U32 size) bool success = true; - mEmpty = true; - - //pad by 16 bytes for aligned copies - size += 16; - - mMappedIndexDataUsingVBOs = useVBOs(); - - if (mMappedIndexDataUsingVBOs) - { - //pad by another 16 bytes for VBO pointer adjustment - size += 16; - genIndices(size); - } - else - { - mMappedIndexData = (U8*)ll_aligned_malloc_16(size); - static int gl_buffer_idx = 0; - mGLIndices = ++gl_buffer_idx; - mIndicesSize = size; - } - + genIndices(size); + if (!mMappedIndexData) { success = false; @@ -1150,43 +947,37 @@ void LLVertexBuffer::destroyGLBuffer() { if (mGLBuffer || mMappedData) { - if (mMappedDataUsingVBOs) - { - releaseBuffer(); - } - else - { - ll_aligned_free_16((void*)mMappedData); - mMappedData = NULL; - mEmpty = true; - } + LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; + //llassert(sVBOPool); + if (sVBOPool) + { + sVBOPool->free(GL_ARRAY_BUFFER, mSize, mGLBuffer, mMappedData); + } + + mSize = 0; + mGLBuffer = 0; + mMappedData = nullptr; } - - mGLBuffer = 0; - //unbind(); } void LLVertexBuffer::destroyGLIndices() { if (mGLIndices || mMappedIndexData) { - if (mMappedIndexDataUsingVBOs) - { - releaseIndices(); - } - else - { - ll_aligned_free_16((void*)mMappedIndexData); - mMappedIndexData = NULL; - mEmpty = true; - } - } + LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; + //llassert(sVBOPool); + if (sVBOPool) + { + sVBOPool->free(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mGLIndices, mMappedIndexData); + } - mGLIndices = 0; - //unbind(); + mIndicesSize = 0; + mGLIndices = 0; + mMappedIndexData = nullptr; + } } -bool LLVertexBuffer::updateNumVerts(S32 nverts) +bool LLVertexBuffer::updateNumVerts(U32 nverts) { llassert(nverts >= 0); @@ -1200,19 +991,17 @@ bool LLVertexBuffer::updateNumVerts(S32 nverts) U32 needed_size = calcOffsets(mTypeMask, mOffsets, nverts); - if (needed_size > mSize || needed_size <= mSize/2) - { - success &= createGLBuffer(needed_size); - } + if (needed_size != mSize) + { + success &= createGLBuffer(needed_size); + } - sVertexCount -= mNumVerts; + llassert(mSize == needed_size); mNumVerts = nverts; - sVertexCount += mNumVerts; - return success; } -bool LLVertexBuffer::updateNumIndices(S32 nindices) +bool LLVertexBuffer::updateNumIndices(U32 nindices) { llassert(nindices >= 0); @@ -1220,22 +1009,18 @@ bool LLVertexBuffer::updateNumIndices(S32 nindices) U32 needed_size = sizeof(U16) * nindices; - if (needed_size > mIndicesSize || needed_size <= mIndicesSize/2) + if (needed_size != mIndicesSize) { success &= createGLIndices(needed_size); } - sIndexCount -= mNumIndices; + llassert(mIndicesSize == needed_size); mNumIndices = nindices; - sIndexCount += mNumIndices; - return success; } -bool LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) +bool LLVertexBuffer::allocateBuffer(U32 nverts, U32 nindices) { - stop_glerror(); - if (nverts < 0 || nindices < 0 || nverts > 65536) { @@ -1247,44 +1032,14 @@ bool LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) success &= updateNumVerts(nverts); success &= updateNumIndices(nindices); - if (create && (nverts || nindices)) - { - //actually allocate space for the vertex buffer if using VBO mapping - flush(); //unmap - } - return success; } -bool LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) -{ - llassert(newnverts >= 0); - llassert(newnindices >= 0); - - bool success = true; - - success &= updateNumVerts(newnverts); - success &= updateNumIndices(newnindices); - - if (useVBOs()) - { - flush(); //unmap - } - - return success; -} - -bool LLVertexBuffer::useVBOs() const -{ - //it's generally ineffective to use VBO for things that are streaming on apple - return (mUsage != 0); -} - //---------------------------------------------------------------------------- // if no gap between region and given range exists, expand region to cover given range and return true // otherwise return false -bool expand_region(LLVertexBuffer::MappedRegion& region, S32 start, S32 end) +bool expand_region(LLVertexBuffer::MappedRegion& region, U32 start, U32 end) { if (end < region.mStart || @@ -1301,152 +1056,79 @@ bool expand_region(LLVertexBuffer::MappedRegion& region, S32 start, S32 end) // Map for data access -U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range) +U8* LLVertexBuffer::mapVertexBuffer(LLVertexBuffer::AttributeType type, U32 index, S32 count) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - if (mFinal) - { - LL_ERRS() << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << LL_ENDL; - } - if (!useVBOs() && !mMappedData && !mMappedIndexData) - { - LL_ERRS() << "LLVertexBuffer::mapVertexBuffer() called on unallocated buffer." << LL_ENDL; - } + + if (count == -1) + { + count = mNumVerts - index; + } + U32 start = mOffsets[type] + sTypeSize[type] * index; + U32 end = start + sTypeSize[type] * count-1; - if (useVBOs()) - { - if (count == -1) + bool flagged = false; + // flag region as mapped + for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) + { + MappedRegion& region = mMappedVertexRegions[i]; + if (expand_region(region, start, end)) { - count = mNumVerts - index; + flagged = true; + break; } - - S32 start = mOffsets[type] + sTypeSize[type] * index; - S32 end = start + sTypeSize[type] * count; - - bool flagged = false; - // flag region as mapped - for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) - { - MappedRegion& region = mMappedVertexRegions[i]; - if (expand_region(region, start, end)) - { - flagged = true; - break; - } - } - - if (!flagged) - { - //didn't expand an existing region, make a new one - mMappedVertexRegions.push_back({ start, end }); - } - - if (mVertexLocked && map_range) - { - LL_ERRS() << "Attempted to map a specific range of a buffer that was already mapped." << LL_ENDL; - } - - if (!mVertexLocked) - { - mVertexLocked = true; - sMappedCount++; - stop_glerror(); - - map_range = false; - - if (!mMappedData) - { - log_glerror(); - - //check the availability of memory - LLMemory::logMemoryInfo(true); - - LL_ERRS() << "memory allocation for vertex data failed." << LL_ENDL; - - } - } } - else + + if (!flagged) { - map_range = false; + //didn't expand an existing region, make a new one + mMappedVertexRegions.push_back({ start, end }); } return mMappedData+mOffsets[type]+sTypeSize[type]*index; } -U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) +U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - if (mFinal) - { - LL_ERRS() << "LLVertexBuffer::mapIndexBuffer() called on a finalized buffer." << LL_ENDL; - } - if (!useVBOs() && !mMappedData && !mMappedIndexData) + + if (count == -1) { - LL_ERRS() << "LLVertexBuffer::mapIndexBuffer() called on unallocated buffer." << LL_ENDL; + count = mNumIndices-index; } - if (useVBOs()) - { - if (count == -1) - { - count = mNumIndices-index; - } - - S32 start = sizeof(U16) * index; - S32 end = start + sizeof(U16) * count; - - bool flagged = false; - // flag region as mapped - for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) - { - MappedRegion& region = mMappedIndexRegions[i]; - if (expand_region(region, start, end)) - { - flagged = true; - break; - } - } + U32 start = sizeof(U16) * index; + U32 end = start + sizeof(U16) * count-1; - if (!flagged) + bool flagged = false; + // flag region as mapped + for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) + { + MappedRegion& region = mMappedIndexRegions[i]; + if (expand_region(region, start, end)) { - //didn't expand an existing region, make a new one - mMappedIndexRegions.push_back({ start, end }); + flagged = true; + break; } + } - if (mIndexLocked && map_range) - { - LL_ERRS() << "Attempted to map a specific range of a buffer that was already mapped." << LL_ENDL; - } - - if (!mIndexLocked) - { - mIndexLocked = true; - sMappedCount++; - stop_glerror(); - - map_range = false; - } - - if (!mMappedIndexData) - { - log_glerror(); - LLMemory::logMemoryInfo(true); - - LL_ERRS() << "memory allocation for Index data failed. " << LL_ENDL; - } - } - else - { - map_range = false; - } + if (!flagged) + { + //didn't expand an existing region, make a new one + mMappedIndexRegions.push_back({ start, end }); + } return mMappedIndexData + sizeof(U16)*index; } -static void flush_vbo(GLenum target, S32 start, S32 end, void* data) +// flush the given byte range +// target -- "targret" parameter for glBufferSubData +// start -- first byte to copy +// end -- last byte to copy (NOT last byte + 1) +// data -- mMappedData or mMappedIndexData +static void flush_vbo(GLenum target, U32 start, U32 end, void* data) { if (end != 0) { @@ -1455,122 +1137,109 @@ static void flush_vbo(GLenum target, S32 start, S32 end, void* data) LL_PROFILE_ZONE_NUM(end); LL_PROFILE_ZONE_NUM(end-start); - constexpr S32 block_size = 65536; + constexpr U32 block_size = 8192; - for (S32 i = start; i < end; i += block_size) + for (U32 i = start; i <= end; i += block_size) { LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("glBufferSubData block"); - LL_PROFILE_GPU_ZONE("glBufferSubData"); - S32 tend = llmin(i + block_size, end); - glBufferSubData(target, i, tend - i, (U8*) data + (i-start)); + //LL_PROFILE_GPU_ZONE("glBufferSubData"); + U32 tend = llmin(i + block_size, end); + glBufferSubData(target, i, tend - i+1, (U8*) data + (i-start)); } } } void LLVertexBuffer::unmapBuffer() { - if (!useVBOs()) - { - return; //nothing to unmap - } + struct SortMappedRegion + { + bool operator()(const MappedRegion& lhs, const MappedRegion& rhs) + { + return lhs.mStart < rhs.mStart; + } + }; - bool updated_all = false; - LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - if (mMappedData && mVertexLocked) + if (!mMappedVertexRegions.empty()) { LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - vertex"); - bindGLBuffer(true); - updated_all = mIndexLocked; //both vertex and index buffers done updating - - if (!mMappedVertexRegions.empty()) - { - S32 start = 0; - S32 end = 0; - - for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) - { - const MappedRegion& region = mMappedVertexRegions[i]; - if (region.mStart == end + 1) - { - end = region.mEnd; - } - else - { - flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start); - start = region.mStart; - end = region.mEnd; - } - } + if (sGLRenderBuffer != mGLBuffer) + { + glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); + sGLRenderBuffer = mGLBuffer; + } + + U32 start = 0; + U32 end = 0; - flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start); + std::sort(mMappedVertexRegions.begin(), mMappedVertexRegions.end(), SortMappedRegion()); - mMappedVertexRegions.clear(); - } - else + for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) { - llassert(false); // this shouldn't happen -- a buffer must always be explicitly mapped + const MappedRegion& region = mMappedVertexRegions[i]; + if (region.mStart == end + 1) + { + end = region.mEnd; + } + else + { + flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start); + start = region.mStart; + end = region.mEnd; + } } - - mVertexLocked = false; - sMappedCount--; + + flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start); + + mMappedVertexRegions.clear(); } - if (mMappedIndexData && mIndexLocked) + if (!mMappedIndexRegions.empty()) { LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - index"); - bindGLIndices(); - - if (!mMappedIndexRegions.empty()) - { - S32 start = 0; - S32 end = 0; - for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) + if (mGLIndices != sGLRenderIndices) + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); + sGLRenderIndices = mGLIndices; + } + U32 start = 0; + U32 end = 0; + + std::sort(mMappedIndexRegions.begin(), mMappedIndexRegions.end(), SortMappedRegion()); + + for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) + { + const MappedRegion& region = mMappedIndexRegions[i]; + if (region.mStart == end + 1) { - const MappedRegion& region = mMappedIndexRegions[i]; - if (region.mStart == end + 1) - { - end = region.mEnd; - } - else - { - flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start); - start = region.mStart; - end = region.mEnd; - } + end = region.mEnd; } + else + { + flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start); + start = region.mStart; + end = region.mEnd; + } + } - flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start); - - mMappedIndexRegions.clear(); - } - else - { - llassert(false); // this shouldn't happen -- a buffer must always be explicitly mapped - } - - mIndexLocked = false; - sMappedCount--; - } + flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start); - if(updated_all) - { - mEmpty = false; + mMappedIndexRegions.clear(); } } //---------------------------------------------------------------------------- -template struct VertexBufferStrider +template struct VertexBufferStrider { typedef LLStrider strider_t; static bool get(LLVertexBuffer& vbo, strider_t& strider, - S32 index, S32 count, bool map_range) + S32 index, S32 count) { if (type == LLVertexBuffer::TYPE_INDEX) { - U8* ptr = vbo.mapIndexBuffer(index, count, map_range); + U8* ptr = vbo.mapIndexBuffer(index, count); if (ptr == NULL) { @@ -1584,9 +1253,9 @@ template struct VertexBufferStrider } else if (vbo.hasDataType(type)) { - S32 stride = LLVertexBuffer::sTypeSize[type]; + U32 stride = LLVertexBuffer::sTypeSize[type]; - U8* ptr = vbo.mapVertexBuffer(type, index, count, map_range); + U8* ptr = vbo.mapVertexBuffer(type, index, count); if (ptr == NULL) { @@ -1606,500 +1275,157 @@ template struct VertexBufferStrider } }; -bool LLVertexBuffer::getVertexStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getVertexStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getVertexStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getVertexStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getIndexStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getIndexStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getTexCoord0Strider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getTexCoord0Strider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getTexCoord1Strider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getTexCoord1Strider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getTexCoord2Strider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getTexCoord2Strider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getNormalStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getNormalStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getTangentStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getTangentStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getTangentStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getTangentStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getColorStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getColorStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getEmissiveStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getEmissiveStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getWeightStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getWeightStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getWeight4Strider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getWeight4Strider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } -bool LLVertexBuffer::getClothWeightStrider(LLStrider& strider, S32 index, S32 count, bool map_range) +bool LLVertexBuffer::getClothWeightStrider(LLStrider& strider, U32 index, S32 count) { - return VertexBufferStrider::get(*this, strider, index, count, map_range); + return VertexBufferStrider::get(*this, strider, index, count); } //---------------------------------------------------------------------------- -bool LLVertexBuffer::bindGLBuffer(bool force_bind) + +// Set for rendering +void LLVertexBuffer::setBuffer() { - bool ret = false; + // no data may be pending + llassert(mMappedVertexRegions.empty()); + llassert(mMappedIndexRegions.empty()); - if (useVBOs() && (force_bind || (mGLBuffer && (mGLBuffer != sGLRenderBuffer || !sVBOActive)))) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); - sGLRenderBuffer = mGLBuffer; - sBindCount++; - sVBOActive = true; - ret = true; - } + // a shader must be bound + llassert(LLGLSLShader::sCurBoundShaderPtr); - return ret; -} + U32 data_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask; -bool LLVertexBuffer::bindGLBufferFast() -{ - if (mGLBuffer != sGLRenderBuffer || !sVBOActive) + // this Vertex Buffer must provide all necessary attributes for currently bound shader + llassert(((~data_mask & mTypeMask) > 0) || (mTypeMask == data_mask)); + + if (sGLRenderBuffer != mGLBuffer) { glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); sGLRenderBuffer = mGLBuffer; - sBindCount++; - sVBOActive = true; - return true; - } - - return false; -} - -bool LLVertexBuffer::bindGLIndices(bool force_bind) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; - - bool ret = false; - if (useVBOs() && (force_bind || (mGLIndices && (mGLIndices != sGLRenderIndices || !sIBOActive)))) - { - /*if (sMapped) - { - LL_ERRS() << "VBO bound while another VBO mapped!" << LL_ENDL; - }*/ - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); - sGLRenderIndices = mGLIndices; - stop_glerror(); - sBindCount++; - sIBOActive = true; - ret = true; - } - - return ret; -} - -bool LLVertexBuffer::bindGLIndicesFast() -{ - if (mGLIndices != sGLRenderIndices || !sIBOActive) - { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); - sGLRenderIndices = mGLIndices; - sBindCount++; - sIBOActive = true; - - return true; + setupVertexBuffer(); } - - return false; -} - -void LLVertexBuffer::flush(bool discard) -{ - if (useVBOs()) - { - unmapBuffer(); - } -} - -// bind for transform feedback (quick 'n dirty) -void LLVertexBuffer::bindForFeedback(U32 channel, U32 type, U32 index, U32 count) -{ -#ifdef GL_TRANSFORM_FEEDBACK_BUFFER - U32 offset = mOffsets[type] + sTypeSize[type]*index; - U32 size= (sTypeSize[type]*count); - glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, channel, mGLBuffer, offset, size); -#endif -} - -// Set for rendering -void LLVertexBuffer::setBuffer(U32 data_mask) -{ - flush(); - - //set up pointers if the data mask is different ... - bool setup = (sLastMask != data_mask); - - if (gDebugGL && data_mask != 0) - { //make sure data requirements are fulfilled - LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; - if (shader) - { - U32 required_mask = 0; - for (U32 i = 0; i < LLVertexBuffer::TYPE_TEXTURE_INDEX; ++i) - { - if (shader->getAttribLocation(i) > -1) - { - U32 required = 1 << i; - if ((data_mask & required) == 0) - { - LL_WARNS() << "Missing attribute: " << LLShaderMgr::instance()->mReservedAttribs[i] << LL_ENDL; - } - - required_mask |= required; - } - } - - if ((data_mask & required_mask) != required_mask) - { - - U32 unsatisfied_mask = (required_mask & ~data_mask); - - for (U32 i = 0; i < TYPE_MAX; i++) - { - U32 unsatisfied_flag = unsatisfied_mask & (1 << i); - switch (unsatisfied_flag) - { - case 0: break; - case MAP_VERTEX: LL_INFOS() << "Missing vert pos" << LL_ENDL; break; - case MAP_NORMAL: LL_INFOS() << "Missing normals" << LL_ENDL; break; - case MAP_TEXCOORD0: LL_INFOS() << "Missing TC 0" << LL_ENDL; break; - case MAP_TEXCOORD1: LL_INFOS() << "Missing TC 1" << LL_ENDL; break; - case MAP_TEXCOORD2: LL_INFOS() << "Missing TC 2" << LL_ENDL; break; - case MAP_TEXCOORD3: LL_INFOS() << "Missing TC 3" << LL_ENDL; break; - case MAP_COLOR: LL_INFOS() << "Missing vert color" << LL_ENDL; break; - case MAP_EMISSIVE: LL_INFOS() << "Missing emissive" << LL_ENDL; break; - case MAP_TANGENT: LL_INFOS() << "Missing tangent" << LL_ENDL; break; - case MAP_WEIGHT: LL_INFOS() << "Missing weight" << LL_ENDL; break; - case MAP_WEIGHT4: LL_INFOS() << "Missing weightx4" << LL_ENDL; break; - case MAP_CLOTHWEIGHT: LL_INFOS() << "Missing clothweight" << LL_ENDL; break; - case MAP_TEXTURE_INDEX: LL_INFOS() << "Missing tex index" << LL_ENDL; break; - default: LL_INFOS() << "Missing who effin knows: " << unsatisfied_flag << LL_ENDL; - } - } - - // TYPE_INDEX is beyond TYPE_MAX, so check for it individually - if (unsatisfied_mask & (1 << TYPE_INDEX)) - { - LL_INFOS() << "Missing indices" << LL_ENDL; - } - - LL_ERRS() << "Shader consumption mismatches data provision." << LL_ENDL; - } - } - } - - if (useVBOs()) - { - const bool bindBuffer = bindGLBuffer(); - const bool bindIndices = bindGLIndices(); - - setup = setup || bindBuffer || bindIndices; - - if (gDebugGL) - { - GLint buff; - glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &buff); - if ((GLuint)buff != mGLBuffer) - { - if (gDebugSession) - { - gFailLog << "Invalid GL vertex buffer bound: " << buff << std::endl; - } - else - { - LL_ERRS() << "Invalid GL vertex buffer bound: " << buff << LL_ENDL; - } - } - - if (mGLIndices) - { - glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &buff); - if ((GLuint)buff != mGLIndices) - { - if (gDebugSession) - { - gFailLog << "Invalid GL index buffer bound: " << buff << std::endl; - } - else - { - LL_ERRS() << "Invalid GL index buffer bound: " << buff << LL_ENDL; - } - } - } - } - - - } - else - { - if (sGLRenderArray) - { - glBindVertexArray(0); - sGLRenderArray = 0; - sGLRenderIndices = 0; - sIBOActive = false; - } - - if (mGLBuffer) - { - if (sVBOActive) - { - glBindBuffer(GL_ARRAY_BUFFER, 0); - sBindCount++; - sVBOActive = false; - setup = true; // ... or a VBO is deactivated - } - if (sGLRenderBuffer != mGLBuffer) - { - sGLRenderBuffer = mGLBuffer; - setup = true; // ... or a client memory pointer changed - } - } - if (mGLIndices) - { - if (sIBOActive) - { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - sBindCount++; - sIBOActive = false; - } - - sGLRenderIndices = mGLIndices; - } - } - - setupClientArrays(data_mask); - - if (mGLBuffer) - { - if (data_mask && setup) - { - setupVertexBuffer(data_mask); // subclass specific setup (virtual function) - sSetCount++; - } - } -} - -void LLVertexBuffer::setBufferFast(U32 data_mask) -{ - if (useVBOs()) + else if (sLastMask != data_mask) { - //set up pointers if the data mask is different ... - bool setup = (sLastMask != data_mask); - - const bool bindBuffer = bindGLBufferFast(); - const bool bindIndices = bindGLIndicesFast(); - - setup = setup || bindBuffer || bindIndices; - - setupClientArrays(data_mask); - - if (data_mask && setup) - { - setupVertexBufferFast(data_mask); - sSetCount++; - } + setupVertexBuffer(); + sLastMask = data_mask; } - else + + if (mGLIndices != sGLRenderIndices) { - //fallback to slow path when not using VBOs - setBuffer(data_mask); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); + sGLRenderIndices = mGLIndices; } } // virtual (default) -void LLVertexBuffer::setupVertexBuffer(U32 data_mask) -{ - stop_glerror(); - U8* base = useVBOs() ? nullptr: mMappedData; - - if (gDebugGL && ((data_mask & mTypeMask) != data_mask)) - { - for (U32 i = 0; i < LLVertexBuffer::TYPE_MAX; ++i) - { - U32 mask = 1 << i; - if (mask & data_mask && !(mask & mTypeMask)) - { //bit set in data_mask, but not set in mTypeMask - LL_WARNS() << "Missing required component " << vb_type_name[i] << LL_ENDL; - } - } - LL_ERRS() << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << LL_ENDL; - } - - if (data_mask & MAP_NORMAL) - { - S32 loc = TYPE_NORMAL; - void* ptr = (void*)(base + mOffsets[TYPE_NORMAL]); - glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_NORMAL], ptr); - } - if (data_mask & MAP_TEXCOORD3) - { - S32 loc = TYPE_TEXCOORD3; - void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD3]); - glVertexAttribPointer(loc,2,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD3], ptr); - } - if (data_mask & MAP_TEXCOORD2) - { - S32 loc = TYPE_TEXCOORD2; - void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD2]); - glVertexAttribPointer(loc,2,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD2], ptr); - } - if (data_mask & MAP_TEXCOORD1) - { - S32 loc = TYPE_TEXCOORD1; - void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD1]); - glVertexAttribPointer(loc,2,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], ptr); - } - if (data_mask & MAP_TANGENT) - { - S32 loc = TYPE_TANGENT; - void* ptr = (void*)(base + mOffsets[TYPE_TANGENT]); - glVertexAttribPointer(loc, 4,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TANGENT], ptr); - } - if (data_mask & MAP_TEXCOORD0) - { - S32 loc = TYPE_TEXCOORD0; - void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD0]); - glVertexAttribPointer(loc,2,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], ptr); - } - if (data_mask & MAP_COLOR) - { - S32 loc = TYPE_COLOR; - //bind emissive instead of color pointer if emissive is present - void* ptr = (data_mask & MAP_EMISSIVE) ? (void*)(base + mOffsets[TYPE_EMISSIVE]) : (void*)(base + mOffsets[TYPE_COLOR]); - glVertexAttribPointer(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_COLOR], ptr); - } - if (data_mask & MAP_EMISSIVE) - { - S32 loc = TYPE_EMISSIVE; - void* ptr = (void*)(base + mOffsets[TYPE_EMISSIVE]); - glVertexAttribPointer(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], ptr); - - if (!(data_mask & MAP_COLOR)) - { //map emissive to color channel when color is not also being bound to avoid unnecessary shader swaps - loc = TYPE_COLOR; - glVertexAttribPointer(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], ptr); - } - } - if (data_mask & MAP_WEIGHT) - { - S32 loc = TYPE_WEIGHT; - void* ptr = (void*)(base + mOffsets[TYPE_WEIGHT]); - glVertexAttribPointer(loc, 1, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], ptr); - } - if (data_mask & MAP_WEIGHT4) - { - S32 loc = TYPE_WEIGHT4; - void* ptr = (void*)(base+mOffsets[TYPE_WEIGHT4]); - glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], ptr); - } - if (data_mask & MAP_CLOTHWEIGHT) - { - S32 loc = TYPE_CLOTHWEIGHT; - void* ptr = (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]); - glVertexAttribPointer(loc, 4, GL_FLOAT, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], ptr); - } - if (data_mask & MAP_TEXTURE_INDEX && - (gGLManager.mGLSLVersionMajor >= 2 || gGLManager.mGLSLVersionMinor >= 30)) //indexed texture rendering requires GLSL 1.30 or later - { - S32 loc = TYPE_TEXTURE_INDEX; - void *ptr = (void*) (base + mOffsets[TYPE_VERTEX] + 12); - glVertexAttribIPointer(loc, 1, GL_UNSIGNED_INT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr); - } - if (data_mask & MAP_VERTEX) - { - S32 loc = TYPE_VERTEX; - void* ptr = (void*)(base + mOffsets[TYPE_VERTEX]); - glVertexAttribPointer(loc, 3,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr); - } - - llglassertok(); - } - -void LLVertexBuffer::setupVertexBufferFast(U32 data_mask) +void LLVertexBuffer::setupVertexBuffer() { U8* base = nullptr; + U32 data_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask; + if (data_mask & MAP_NORMAL) { - S32 loc = TYPE_NORMAL; + AttributeType loc = TYPE_NORMAL; void* ptr = (void*)(base + mOffsets[TYPE_NORMAL]); glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_NORMAL], ptr); } if (data_mask & MAP_TEXCOORD3) { - S32 loc = TYPE_TEXCOORD3; + AttributeType loc = TYPE_TEXCOORD3; void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD3]); glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD3], ptr); } if (data_mask & MAP_TEXCOORD2) { - S32 loc = TYPE_TEXCOORD2; + AttributeType loc = TYPE_TEXCOORD2; void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD2]); glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD2], ptr); } if (data_mask & MAP_TEXCOORD1) { - S32 loc = TYPE_TEXCOORD1; + AttributeType loc = TYPE_TEXCOORD1; void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD1]); glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], ptr); } if (data_mask & MAP_TANGENT) { - S32 loc = TYPE_TANGENT; + AttributeType loc = TYPE_TANGENT; void* ptr = (void*)(base + mOffsets[TYPE_TANGENT]); glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TANGENT], ptr); } if (data_mask & MAP_TEXCOORD0) { - S32 loc = TYPE_TEXCOORD0; + AttributeType loc = TYPE_TEXCOORD0; void* ptr = (void*)(base + mOffsets[TYPE_TEXCOORD0]); glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], ptr); } if (data_mask & MAP_COLOR) { - S32 loc = TYPE_COLOR; + AttributeType loc = TYPE_COLOR; //bind emissive instead of color pointer if emissive is present void* ptr = (data_mask & MAP_EMISSIVE) ? (void*)(base + mOffsets[TYPE_EMISSIVE]) : (void*)(base + mOffsets[TYPE_COLOR]); glVertexAttribPointer(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_COLOR], ptr); } if (data_mask & MAP_EMISSIVE) { - S32 loc = TYPE_EMISSIVE; + AttributeType loc = TYPE_EMISSIVE; void* ptr = (void*)(base + mOffsets[TYPE_EMISSIVE]); glVertexAttribPointer(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], ptr); @@ -2111,31 +1437,31 @@ void LLVertexBuffer::setupVertexBufferFast(U32 data_mask) } if (data_mask & MAP_WEIGHT) { - S32 loc = TYPE_WEIGHT; + AttributeType loc = TYPE_WEIGHT; void* ptr = (void*)(base + mOffsets[TYPE_WEIGHT]); glVertexAttribPointer(loc, 1, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], ptr); } if (data_mask & MAP_WEIGHT4) { - S32 loc = TYPE_WEIGHT4; + AttributeType loc = TYPE_WEIGHT4; void* ptr = (void*)(base + mOffsets[TYPE_WEIGHT4]); glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], ptr); } if (data_mask & MAP_CLOTHWEIGHT) { - S32 loc = TYPE_CLOTHWEIGHT; + AttributeType loc = TYPE_CLOTHWEIGHT; void* ptr = (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]); glVertexAttribPointer(loc, 4, GL_FLOAT, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], ptr); } if (data_mask & MAP_TEXTURE_INDEX) { - S32 loc = TYPE_TEXTURE_INDEX; + AttributeType loc = TYPE_TEXTURE_INDEX; void* ptr = (void*)(base + mOffsets[TYPE_VERTEX] + 12); glVertexAttribIPointer(loc, 1, GL_UNSIGNED_INT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr); } if (data_mask & MAP_VERTEX) { - S32 loc = TYPE_VERTEX; + AttributeType loc = TYPE_VERTEX; void* ptr = (void*)(base + mOffsets[TYPE_VERTEX]); glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr); } @@ -2143,20 +1469,20 @@ void LLVertexBuffer::setupVertexBufferFast(U32 data_mask) void LLVertexBuffer::setPositionData(const LLVector4a* data) { - bindGLBuffer(); - flush_vbo(GL_ARRAY_BUFFER, 0, sizeof(LLVector4a) * getNumVerts(), (U8*) data); + llassert(sGLRenderBuffer == mGLBuffer); + flush_vbo(GL_ARRAY_BUFFER, 0, sizeof(LLVector4a) * getNumVerts()-1, (U8*) data); } void LLVertexBuffer::setTexCoordData(const LLVector2* data) { - bindGLBuffer(); - flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_TEXCOORD0], mOffsets[TYPE_TEXCOORD0] + sTypeSize[TYPE_TEXCOORD0] * getNumVerts(), (U8*)data); + llassert(sGLRenderBuffer == mGLBuffer); + flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_TEXCOORD0], mOffsets[TYPE_TEXCOORD0] + sTypeSize[TYPE_TEXCOORD0] * getNumVerts() - 1, (U8*)data); } void LLVertexBuffer::setColorData(const LLColor4U* data) { - bindGLBuffer(); - flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_COLOR], mOffsets[TYPE_COLOR] + sTypeSize[TYPE_COLOR] * getNumVerts(), (U8*) data); + llassert(sGLRenderBuffer == mGLBuffer); + flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_COLOR], mOffsets[TYPE_COLOR] + sTypeSize[TYPE_COLOR] * getNumVerts() - 1, (U8*) data); } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 926d37b052..571856f013 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -53,17 +53,16 @@ //============================================================================ // base class class LLPrivateMemoryPool; -class LLVertexBuffer : public LLRefCount +class LLVertexBuffer final : public LLRefCount { public: struct MappedRegion { - S32 mStart; - S32 mEnd; + U32 mStart; + U32 mEnd; }; LLVertexBuffer(const LLVertexBuffer& rhs) - : mUsage(rhs.mUsage) { *this = rhs; } @@ -74,42 +73,31 @@ public: return *this; } - static std::list sAvailableVAOName; - static U32 sCurVAOName; - - static bool sUseStreamDraw; - static bool sUseVAO; - static bool sPreferStreamDraw; - - static U32 getVAOName(); - static void releaseVAOName(U32 name); - static void initClass(LLWindow* window); static void cleanupClass(); static void setupClientArrays(U32 data_mask); static void drawArrays(U32 mode, const std::vector& pos); - static void drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, S32 num_indices, const U16* indicesp); + static void drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, U32 num_indices, const U16* indicesp); static void unbind(); //unbind any bound vertex buffer //get the size of a vertex with the given typemask - static S32 calcVertexSize(const U32& typemask); + static U32 calcVertexSize(const U32& typemask); //get the size of a buffer with the given typemask and vertex count //fill offsets with the offset of each vertex component array into the buffer // indexed by the following enum - static S32 calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices); + static U32 calcOffsets(const U32& typemask, U32* offsets, U32 num_vertices); //WARNING -- when updating these enums you MUST // 1 - update LLVertexBuffer::sTypeSize // 2 - update LLVertexBuffer::vb_type_name // 3 - add a strider accessor // 4 - modify LLVertexBuffer::setupVertexBuffer - // 5 - modify LLVertexBuffer::setupVertexBufferFast // 6 - modify LLViewerShaderMgr::mReservedAttribs // clang-format off - enum { // Shader attribute name, set in LLShaderMgr::initAttribsAndUniforms() + enum AttributeType { // Shader attribute name, set in LLShaderMgr::initAttribsAndUniforms() TYPE_VERTEX = 0, // "position" TYPE_NORMAL, // "normal" TYPE_TEXCOORD0, // "texcoord0" @@ -147,45 +135,37 @@ public: protected: friend class LLRender; - virtual ~LLVertexBuffer(); // use unref() + ~LLVertexBuffer(); // use unref() - virtual void setupVertexBuffer(U32 data_mask); - void setupVertexBufferFast(U32 data_mask); + void setupVertexBuffer(); void genBuffer(U32 size); void genIndices(U32 size); - bool bindGLBuffer(bool force_bind = false); - bool bindGLBufferFast(); - bool bindGLIndices(bool force_bind = false); - bool bindGLIndicesFast(); - void releaseBuffer(); - void releaseIndices(); bool createGLBuffer(U32 size); bool createGLIndices(U32 size); void destroyGLBuffer(); void destroyGLIndices(); - bool updateNumVerts(S32 nverts); - bool updateNumIndices(S32 nindices); - void unmapBuffer(); - + bool updateNumVerts(U32 nverts); + bool updateNumIndices(U32 nindices); + public: - LLVertexBuffer(U32 typemask, S32 usage); + LLVertexBuffer(U32 typemask); - // map for data access - U8* mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range); - U8* mapIndexBuffer(S32 index, S32 count, bool map_range); + // allocate buffer + bool allocateBuffer(U32 nverts, U32 nindices); - void bindForFeedback(U32 channel, U32 type, U32 index, U32 count); + // map for data access (see also getFooStrider below) + U8* mapVertexBuffer(AttributeType type, U32 index, S32 count = -1); + U8* mapIndexBuffer(U32 index, S32 count = -1); + void unmapBuffer(); // set for rendering - virtual void setBuffer(U32 data_mask); // calls setupVertexBuffer() if data_mask is not 0 - void setBufferFast(U32 data_mask); // calls setupVertexBufferFast(), assumes data_mask is not 0 among other assumptions - - void flush(bool discard = false); //flush pending data to GL memory, if discard is true, discard previous VBO - // allocate buffer - bool allocateBuffer(S32 nverts, S32 nindices, bool create); - virtual bool resizeBuffer(S32 newnverts, S32 newnindices); - + // assumes (and will assert on) the following: + // - this buffer has no pending unampBuffer call + // - a shader is currently bound + // - This buffer has sufficient attributes within it to satisfy the needs of the currently bound shader + void setBuffer(); + // Only call each getVertexPointer, etc, once before calling unmapBuffer() // call unmapBuffer() after calls to getXXXStrider() before any cals to setBuffer() // example: @@ -193,57 +173,49 @@ public: // vb->getNormalStrider(norms); // setVertsNorms(verts, norms); // vb->unmapBuffer(); - bool getVertexStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getVertexStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getIndexStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTexCoord0Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTexCoord1Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTexCoord2Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getNormalStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTangentStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTangentStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getColorStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getEmissiveStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getWeightStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getWeight4Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getClothWeightStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getBasecolorTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getNormalTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getMetallicRoughnessTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getEmissiveTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); + bool getVertexStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getVertexStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getIndexStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTexCoord0Strider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTexCoord1Strider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTexCoord2Strider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getNormalStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTangentStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTangentStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getColorStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getEmissiveStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getWeightStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getWeight4Strider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getClothWeightStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getBasecolorTexcoordStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getNormalTexcoordStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getMetallicRoughnessTexcoordStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getEmissiveTexcoordStrider(LLStrider& strider, U32 index=0, S32 count = -1); void setPositionData(const LLVector4a* data); void setTexCoordData(const LLVector2* data); void setColorData(const LLColor4U* data); - bool useVBOs() const; - bool isEmpty() const { return mEmpty; } - bool isLocked() const { return mVertexLocked || mIndexLocked; } - S32 getNumVerts() const { return mNumVerts; } - S32 getNumIndices() const { return mNumIndices; } + U32 getNumVerts() const { return mNumVerts; } + U32 getNumIndices() const { return mNumIndices; } - U8* getIndicesPointer() const { return useVBOs() ? nullptr : mMappedIndexData; } - U8* getVerticesPointer() const { return useVBOs() ? nullptr : mMappedData; } U32 getTypeMask() const { return mTypeMask; } - bool hasDataType(S32 type) const { return ((1 << type) & getTypeMask()); } - S32 getSize() const; - S32 getIndicesSize() const { return mIndicesSize; } + bool hasDataType(AttributeType type) const { return ((1 << type) & getTypeMask()); } + U32 getSize() const { return mSize; } + U32 getIndicesSize() const { return mIndicesSize; } U8* getMappedData() const { return mMappedData; } U8* getMappedIndices() const { return mMappedIndexData; } - S32 getOffset(S32 type) const { return mOffsets[type]; } - S32 getUsage() const { return mUsage; } - bool isWriteable() const { return (mUsage == GL_STREAM_DRAW) ? true : false; } - + U32 getOffset(AttributeType type) const { return mOffsets[type]; } + + // these functions assume (and assert on) the current VBO being bound + // Detailed error checking can be enabled by setting gDebugGL to true void draw(U32 mode, U32 count, U32 indices_offset) const; void drawArrays(U32 mode, U32 offset, U32 count) const; - void drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const; - - //implementation for inner loops that does no safety checking - void drawRangeFast(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const; + void drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const; //for debugging, validate data in given range is valid - void validateRange(U32 start, U32 end, U32 count, U32 offset) const; + bool validateRange(U32 start, U32 end, U32 count, U32 offset) const; #ifdef LL_PROFILER_ENABLE_RENDER_DOC void setLabel(const char* label); @@ -251,62 +223,45 @@ public: protected: - U32 mGLBuffer; // GL VBO handle - U32 mGLIndices; // GL IBO handle + U32 mGLBuffer = 0; // GL VBO handle + U32 mGLIndices = 0; // GL IBO handle + U32 mNumVerts = 0; // Number of vertices allocated + U32 mNumIndices = 0; // Number of indices allocated + U32 mOffsets[TYPE_MAX]; // byte offsets into mMappedData of each attribute - U32 mTypeMask; + U8* mMappedData = nullptr; // pointer to currently mapped data (NULL if unmapped) + U8* mMappedIndexData = nullptr; // pointer to currently mapped indices (NULL if unmapped) - S32 mNumVerts; // Number of vertices allocated - S32 mNumIndices; // Number of indices allocated - - S32 mSize; - S32 mIndicesSize; - - const S32 mUsage; // GL usage - - U8* mMappedData; // pointer to currently mapped data (NULL if unmapped) - U8* mMappedIndexData; // pointer to currently mapped indices (NULL if unmapped) - - U32 mMappedDataUsingVBOs : 1; - U32 mMappedIndexDataUsingVBOs : 1; - U32 mVertexLocked : 1; // if true, vertex buffer is being or has been written to in client memory - U32 mIndexLocked : 1; // if true, index buffer is being or has been written to in client memory - U32 mFinal : 1; // if true, buffer can not be mapped again - U32 mEmpty : 1; // if true, client buffer is empty (or NULL). Old values have been discarded. + U32 mTypeMask = 0; // bitmask of present vertex attributes - S32 mOffsets[TYPE_MAX]; - - std::vector mMappedVertexRegions; - std::vector mMappedIndexRegions; + U32 mSize = 0; // size in bytes of mMappedData + U32 mIndicesSize = 0; // size in bytes of mMappedIndexData - static S32 determineUsage(S32 usage); + std::vector mMappedVertexRegions; // list of mMappedData byte ranges that must be sent to GL + std::vector mMappedIndexRegions; // list of mMappedIndexData byte ranges that must be sent to GL private: - static LLPrivateMemoryPool* sPrivatePoolp; + // DEPRECATED + // These function signatures are deprecated, but for some reason + // there are classes in an external package that depend on LLVertexBuffer + + // TODO: move these classes into viewer repository + friend class LLNavShapeVBOManager; + friend class LLNavMeshVBOManager; + + LLVertexBuffer(U32 typemask, U32 usage) + : LLVertexBuffer(typemask) + {} + + bool allocateBuffer(S32 nverts, S32 nindices, BOOL create) { return allocateBuffer(nverts, nindices); } public: - static S32 sCount; - static S32 sGLCount; - static S32 sMappedCount; - static bool sMapped; - typedef std::list buffer_list_t; - - static bool sDisableVBOMapping; //disable glMapBufferARB - static bool sEnableVBOs; - static const S32 sTypeSize[TYPE_MAX]; + static const U32 sTypeSize[TYPE_MAX]; static const U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLRenderBuffer; - static U32 sGLRenderArray; static U32 sGLRenderIndices; - static bool sVBOActive; - static bool sIBOActive; static U32 sLastMask; - static U32 sAllocatedBytes; - static U32 sAllocatedIndexBytes; static U32 sVertexCount; - static U32 sIndexCount; - static U32 sBindCount; - static U32 sSetCount; }; #ifdef LL_PROFILER_ENABLE_RENDER_DOC diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 7787e2eb26..a195964bb1 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1051,16 +1051,19 @@ BOOL LLWindowWin32::maximize() BOOL success = FALSE; if (!mWindowHandle) return success; - WINDOWPLACEMENT placement; - placement.length = sizeof(WINDOWPLACEMENT); - - success = GetWindowPlacement(mWindowHandle, &placement); - if (!success) return success; + mWindowThread->post([=] + { + WINDOWPLACEMENT placement; + placement.length = sizeof(WINDOWPLACEMENT); - placement.showCmd = SW_MAXIMIZE; + if (GetWindowPlacement(mWindowHandle, &placement)) + { + placement.showCmd = SW_MAXIMIZE; + SetWindowPlacement(mWindowHandle, &placement); + } + }); - success = SetWindowPlacement(mWindowHandle, &placement); - return success; + return TRUE; } BOOL LLWindowWin32::getFullscreen() @@ -1408,14 +1411,6 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen& size, BO return FALSE; } - if (pfd.cAlphaBits < 8) - { - OSMessageBox(mCallbacks->translateString("MBAlpha"), - mCallbacks->translateString("MBError"), OSMB_OK); - close(); - return FALSE; - } - if (!SetPixelFormat(mhDC, pixel_format, &pfd)) { OSMessageBox(mCallbacks->translateString("MBPixelFmtSetErr"), @@ -1474,7 +1469,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen& size, BO attrib_list[cur_attrib++] = 24; attrib_list[cur_attrib++] = WGL_ALPHA_BITS_ARB; - attrib_list[cur_attrib++] = 8; + attrib_list[cur_attrib++] = 0; U32 end_attrib = 0; if (mFSAASamples > 0) @@ -1705,13 +1700,6 @@ const S32 max_format = (S32)num_formats - 1; return FALSE; } - if (pfd.cAlphaBits < 8) - { - OSMessageBox(mCallbacks->translateString("MBAlpha"), mCallbacks->translateString("MBError"), OSMB_OK); - close(); - return FALSE; - } - mhRC = 0; if (wglCreateContextAttribsARB) { //attempt to create a specific versioned context diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ac449e45ef..ec4125c2bf 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8745,7 +8745,7 @@ Vector3 Value - 0.01 + 0.25 0.0 0.0 diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index ea41ac5f2d..0cb966296a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -505,7 +505,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, vec3 c, int i) v -= c; v = env_mat * v; { - return texture(irradianceProbes, vec4(v.xyz, refIndex[i].x)).rgb * refParams[i].x; + return textureLod(irradianceProbes, vec4(v.xyz, refIndex[i].x), 0).rgb * refParams[i].x; } } @@ -676,14 +676,15 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + ambenv = sampleProbeAmbient(pos, norm); - + if (glossiness > 0.0) { float lod = (1.0-glossiness)*reflection_lods; glossenv = sampleProbes(pos, normalize(refnormpersp), lod, false); } - + if (envIntensity > 0.0) { legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0, false); diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index f8a5086130..90de369424 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 43 +version 44 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -55,7 +55,7 @@ RenderVBOEnable 1 1 RenderVBOMappingDisable 1 1 RenderVolumeLODFactor 1 2.0 UseStartScreen 1 1 -UseOcclusion 1 0 +UseOcclusion 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 Disregard128DefaultDrawDistance 1 1 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 0f84ade82a..45e3827f60 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 42 +version 43 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -53,7 +53,7 @@ RenderVBOEnable 1 1 RenderVBOMappingDisable 1 1 RenderVolumeLODFactor 1 2.0 UseStartScreen 1 1 -UseOcclusion 1 0 +UseOcclusion 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 Disregard128DefaultDrawDistance 1 1 diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index d4d8b985ce..dd4363d2a4 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -535,7 +535,6 @@ static void settings_to_globals() LLRender::sGLCoreProfile = gSavedSettings.getBOOL("RenderGLContextCoreProfile"); #endif LLRender::sNsightDebugSupport = gSavedSettings.getBOOL("RenderNsightDebugSupport"); - LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); LLImageGL::sGlobalUseAnisotropic = gSavedSettings.getBOOL("RenderAnisotropic"); LLImageGL::sCompressTextures = gSavedSettings.getBOOL("RenderCompressTextures"); LLVOVolume::sLODFactor = llclamp(gSavedSettings.getF32("RenderVolumeLODFactor"), 0.01f, MAX_LOD_FACTOR); diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 74625423fe..7d869562ca 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -702,7 +702,8 @@ F32 LLDrawable::updateXform(BOOL undamped) ((dist_vec_squared(old_pos, target_pos) > 0.f) || (1.f - dot(old_rot, target_rot)) > 0.f)) { //fix for BUG-840, MAINT-2275, MAINT-1742, MAINT-2247 - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + mVObjp->shrinkWrap(); + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); } else if (!getVOVolume() && !isAvatar()) { @@ -1252,10 +1253,10 @@ LLSpatialPartition* LLDrawable::getSpatialPartition() LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask, LLViewerRegion* regionp) : LLDrawable(root->getVObj(), true), - LLSpatialPartition(data_mask, render_by_group, GL_STREAM_DRAW, regionp) + LLSpatialPartition(data_mask, render_by_group, regionp) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE - + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; + mOcclusionEnabled = false; mBridge = this; mDrawable = root; root->setSpatialBridge(this); @@ -1758,7 +1759,7 @@ LLDrawable* LLDrawable::getRoot() } LLBridgePartition::LLBridgePartition(LLViewerRegion* regionp) -: LLSpatialPartition(0, FALSE, 0, regionp) +: LLSpatialPartition(0, false, regionp) { mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; mPartitionType = LLViewerRegion::PARTITION_BRIDGE; diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 2abbe2f2f8..a5990492b1 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -385,7 +385,7 @@ LLRenderPass::~LLRenderPass() } -void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture) +void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, bool texture) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; @@ -395,19 +395,18 @@ void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL t LLDrawInfo *pparams = *k; if (pparams) { - pushBatch(*pparams, mask, texture); + pushBatch(*pparams, texture); } } } -void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture) +void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool texture) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - mask |= LLVertexBuffer::MAP_WEIGHT4; - + for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo* pparams = *k; @@ -420,7 +419,7 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, U32 mask, lastMeshId = pparams->mSkinInfo->mHash; } - pushBatch(*pparams, mask, texture); + pushBatch(*pparams, texture); } } } @@ -446,7 +445,7 @@ void teardown_texture_matrix(LLDrawInfo& params) } } -void LLRenderPass::pushGLTFBatches(U32 type, U32 mask) +void LLRenderPass::pushGLTFBatches(U32 type) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; auto* begin = gPipeline.beginRenderMap(type); @@ -467,19 +466,19 @@ void LLRenderPass::pushGLTFBatches(U32 type, U32 mask) applyModelMatrix(params); - params.mVertexBuffer->setBufferFast(mask); - params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); teardown_texture_matrix(params); } } -void LLRenderPass::pushRiggedGLTFBatches(U32 type, U32 mask) +void LLRenderPass::pushRiggedGLTFBatches(U32 type) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - mask |= LLVertexBuffer::MAP_WEIGHT4; + auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); for (LLCullResult::drawinfo_iterator i = begin; i != end; ) @@ -505,14 +504,14 @@ void LLRenderPass::pushRiggedGLTFBatches(U32 type, U32 mask) lastMeshId = params.mSkinInfo->mHash; } - params.mVertexBuffer->setBufferFast(mask); - params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); teardown_texture_matrix(params); } } -void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) +void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; auto* begin = gPipeline.beginRenderMap(type); @@ -522,16 +521,15 @@ void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_text LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); - pushBatch(*pparams, mask, texture, batch_textures); + pushBatch(*pparams, texture, batch_textures); } } -void LLRenderPass::pushRiggedBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) +void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - mask |= LLVertexBuffer::MAP_WEIGHT4; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); for (LLCullResult::drawinfo_iterator i = begin; i != end; ) @@ -546,11 +544,11 @@ void LLRenderPass::pushRiggedBatches(U32 type, U32 mask, BOOL texture, BOOL batc lastMeshId = pparams->mSkinInfo->mHash; } - pushBatch(*pparams, mask, texture, batch_textures); + pushBatch(*pparams, texture, batch_textures); } } -void LLRenderPass::pushMaskBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) +void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; auto* begin = gPipeline.beginRenderMap(type); @@ -560,11 +558,11 @@ void LLRenderPass::pushMaskBatches(U32 type, U32 mask, BOOL texture, BOOL batch_ LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); - pushBatch(*pparams, mask, texture, batch_textures); + pushBatch(*pparams, texture, batch_textures); } } -void LLRenderPass::pushRiggedMaskBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) +void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; @@ -593,7 +591,7 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, U32 mask, BOOL texture, BOOL lastMeshId = pparams->mSkinInfo->mHash; } - pushBatch(*pparams, mask | LLVertexBuffer::MAP_WEIGHT4, texture, batch_textures); + pushBatch(*pparams, texture, batch_textures); } } @@ -612,7 +610,7 @@ void LLRenderPass::applyModelMatrix(const LLDrawInfo& params) } } -void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures) +void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; if (!params.mCount) @@ -662,8 +660,8 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba // params.mGroup->rebuildMesh(); //} - params.mVertexBuffer->setBufferFast(mask); - params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); if (tex_setup) { diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 9a4b09b973..7050723116 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -333,7 +333,6 @@ public: return "PASS_GLTF_PBR"; case PASS_GLTF_PBR_RIGGED: return "PASS_GLTF_PBR_RIGGED"; - default: return "Unknown pass"; } @@ -350,17 +349,17 @@ public: void resetDrawOrders() { } static void applyModelMatrix(const LLDrawInfo& params); - virtual void pushBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); - virtual void pushRiggedBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); - void pushGLTFBatches(U32 type, U32 mask); - void pushRiggedGLTFBatches(U32 type, U32 mask); - virtual void pushMaskBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); - virtual void pushRiggedMaskBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE); - virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE); + virtual void pushBatches(U32 type, bool texture = true, bool batch_textures = false); + virtual void pushRiggedBatches(U32 type, bool texture = true, bool batch_textures = false); + void pushGLTFBatches(U32 type); + void pushRiggedGLTFBatches(U32 type); + virtual void pushMaskBatches(U32 type, bool texture = true, bool batch_textures = false); + virtual void pushRiggedMaskBatches(U32 type, bool texture = true, bool batch_textures = false); + virtual void pushBatch(LLDrawInfo& params, bool texture, bool batch_textures = false); static bool uploadMatrixPalette(LLDrawInfo& params); static bool uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo); - virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE); - virtual void renderRiggedGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE); + virtual void renderGroup(LLSpatialGroup* group, U32 type, bool texture = true); + virtual void renderRiggedGroup(LLSpatialGroup* group, U32 type, bool texture = true); }; class LLFacePool : public LLDrawPool diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 07381acd25..ed952689fa 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -379,11 +379,6 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask) { LLDrawInfo& params = **k; - if (params.mParticle) - { - continue; - } - bool rigged = (params.mAvatar != nullptr); gHighlightProgram.bind(rigged); gGL.diffuseColor4f(1, 0, 0, 1); @@ -403,12 +398,8 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask) } LLRenderPass::applyModelMatrix(params); - if (params.mGroup) - { - params.mGroup->rebuildMesh(); - } - params.mVertexBuffer->setBufferFast(rigged ? mask | LLVertexBuffer::MAP_WEIGHT4 : mask); - params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); } } } @@ -435,9 +426,9 @@ inline bool IsEmissive(LLDrawInfo& params) inline void Draw(LLDrawInfo* draw, U32 mask) { - draw->mVertexBuffer->setBufferFast(mask); + draw->mVertexBuffer->setBuffer(); LLRenderPass::applyModelMatrix(*draw); - draw->mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); + draw->mVertexBuffer->drawRange(LLRender::TRIANGLES, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); } bool LLDrawPoolAlpha::TexSetup(LLDrawInfo* draw, bool use_material) @@ -530,8 +521,8 @@ void LLDrawPoolAlpha::RestoreTexSetup(bool tex_setup) void LLDrawPoolAlpha::drawEmissive(U32 mask, LLDrawInfo* draw) { LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, 1.f); - draw->mVertexBuffer->setBufferFast((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); - draw->mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); + draw->mVertexBuffer->setBuffer(); + draw->mVertexBuffer->drawRange(LLRender::TRIANGLES, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); } @@ -665,30 +656,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("ra - push batch"); - U32 have_mask = params.mVertexBuffer->getTypeMask() & mask; - if (have_mask != mask) - { //FIXME! - LL_WARNS_ONCE() << "Missing required components, expected mask: " << mask - << " present: " << have_mask - << ". Skipping render batch." << LL_ENDL; - continue; - } - - if(depth_only) - { - // when updating depth buffer, discard faces that are more than 90% transparent - LLFace* face = params.mFace; - if(face) - { - const LLTextureEntry* tep = face->getTextureEntry(); - if(tep) - { // don't render faces that are more than 90% transparent - if(tep->getColor().mV[3] < MINIMUM_IMPOSTOR_ALPHA) - continue; - } - } - } - LLRenderPass::applyModelMatrix(params); LLMaterial* mat = NULL; @@ -835,18 +802,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) reset_minimum_alpha = true; } - U32 drawMask = mask; - if (params.mFullbright) - { - drawMask &= ~(LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2); - } - if (params.mAvatar != nullptr) - { - drawMask |= LLVertexBuffer::MAP_WEIGHT4; - } - - params.mVertexBuffer->setBufferFast(drawMask); - params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); if (reset_minimum_alpha) { diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 67c3000410..8a3ab20ab4 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -53,8 +53,6 @@ #include "llviewercontrol.h" // for gSavedSettings #include "llviewertexturelist.h" -static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK; -static U32 sBufferUsage = GL_STREAM_DRAW; static U32 sShaderLevel = 0; LLGLSLShader* LLDrawPoolAvatar::sVertexProgram = NULL; @@ -143,15 +141,6 @@ void LLDrawPoolAvatar::prerender() mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR); sShaderLevel = mShaderLevel; - - if (sShaderLevel > 0) - { - sBufferUsage = GL_DYNAMIC_DRAW; - } - else - { - sBufferUsage = GL_STREAM_DRAW; - } } LLMatrix4& LLDrawPoolAvatar::getModelView() @@ -932,11 +921,3 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const } -LLVertexBufferAvatar::LLVertexBufferAvatar() -: LLVertexBuffer(sDataMask, - GL_STREAM_DRAW) //avatars are always stream draw due to morph targets -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR -} - - diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h index 21add39b21..ff78c6c60a 100644 --- a/indra/newview/lldrawpoolavatar.h +++ b/indra/newview/lldrawpoolavatar.h @@ -129,12 +129,6 @@ typedef enum static LLGLSLShader* sVertexProgram; }; -class LLVertexBufferAvatar : public LLVertexBuffer -{ -public: - LLVertexBufferAvatar(); -}; - extern S32 AVATAR_OFFSET_POS; extern S32 AVATAR_OFFSET_NORMAL; extern S32 AVATAR_OFFSET_TEX0; diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 4379fdc603..9c871514f7 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -353,22 +353,22 @@ void LLDrawPoolBump::renderShiny() { if (mRigged) { - LLRenderPass::pushRiggedBatches(LLRenderPass::PASS_SHINY_RIGGED, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + LLRenderPass::pushRiggedBatches(LLRenderPass::PASS_SHINY_RIGGED, true, true); } else { - LLRenderPass::pushBatches(LLRenderPass::PASS_SHINY, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + LLRenderPass::pushBatches(LLRenderPass::PASS_SHINY, true, true); } } else { if (mRigged) { - gPipeline.renderRiggedGroups(this, LLRenderPass::PASS_SHINY_RIGGED, sVertexMask, TRUE); + gPipeline.renderRiggedGroups(this, LLRenderPass::PASS_SHINY_RIGGED, true); } else { - gPipeline.renderGroups(this, LLRenderPass::PASS_SHINY, sVertexMask, TRUE); + gPipeline.renderGroups(this, LLRenderPass::PASS_SHINY, true); } } } @@ -508,22 +508,22 @@ void LLDrawPoolBump::renderFullbrightShiny() { if (mRigged) { - LLRenderPass::pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY_RIGGED, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + LLRenderPass::pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY_RIGGED, true, true); } else { - LLRenderPass::pushBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + LLRenderPass::pushBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY, true, true); } } else { if (mRigged) { - LLRenderPass::pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY_RIGGED, sVertexMask); + LLRenderPass::pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY_RIGGED); } else { - LLRenderPass::pushBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY, sVertexMask); + LLRenderPass::pushBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY); } } } @@ -549,7 +549,7 @@ void LLDrawPoolBump::endFullbrightShiny() mShiny = FALSE; } -void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE) +void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, bool texture = true) { LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; @@ -559,11 +559,7 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL applyModelMatrix(params); - if (params.mGroup) - { - params.mGroup->rebuildMesh(); - } - params.mVertexBuffer->setBuffer(mask); + params.mVertexBuffer->setBuffer(); params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); } } @@ -574,7 +570,7 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel) { U8 bump_code = params.mBump; - return bindBumpMap(bump_code, params.mTexture, params.mVSize, channel); + return bindBumpMap(bump_code, params.mTexture, channel); } //static @@ -584,14 +580,14 @@ BOOL LLDrawPoolBump::bindBumpMap(LLFace* face, S32 channel) if (te) { U8 bump_code = te->getBumpmap(); - return bindBumpMap(bump_code, face->getTexture(), face->getVirtualSize(), channel); + return bindBumpMap(bump_code, face->getTexture(), channel); } return FALSE; } //static -BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, F32 vsize, S32 channel) +BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, S32 channel) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //Note: texture atlas does not support bump texture now. @@ -617,7 +613,7 @@ BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, F32 vsi if( bump_code < LLStandardBumpmap::sStandardBumpmapCount ) { bump = gStandardBumpmapList[bump_code].mImage; - gBumpImageList.addTextureStats(bump_code, tex->getID(), vsize); + gBumpImageList.addTextureStats(bump_code, tex->getID(), tex->getMaxVirtualSize()); } break; } @@ -674,7 +670,7 @@ void LLDrawPoolBump::renderBump(U32 pass) /// Get rid of z-fighting with non-bump pass. LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -1.0f); - renderBump(pass, sVertexMask); + pushBumpBatches(pass); } //static @@ -719,8 +715,6 @@ void LLDrawPoolBump::renderDeferred(S32 pass) LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); - U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_COLOR; - LLVOAvatar* avatar = nullptr; U64 skin = 0; @@ -741,11 +735,11 @@ void LLDrawPoolBump::renderDeferred(S32 pass) avatar = params.mAvatar; skin = params.mSkinInfo->mHash; } - pushBatch(params, mask | LLVertexBuffer::MAP_WEIGHT4, TRUE, FALSE); + pushBatch(params, true, false); } else { - pushBatch(params, mask, TRUE, FALSE); + pushBatch(params, true, false); } } @@ -1342,7 +1336,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI } } -void LLDrawPoolBump::renderBump(U32 type, U32 mask) +void LLDrawPoolBump::pushBumpBatches(U32 type) { LLVOAvatar* avatar = nullptr; U64 skin = 0; @@ -1350,7 +1344,6 @@ void LLDrawPoolBump::renderBump(U32 type, U32 mask) if (mRigged) { // nudge type enum and include skinweights for rigged pass type += 1; - mask |= LLVertexBuffer::MAP_WEIGHT4; } LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); @@ -1377,12 +1370,12 @@ void LLDrawPoolBump::renderBump(U32 type, U32 mask) } } } - pushBatch(params, mask, FALSE); + pushBatch(params, false); } } } -void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures) +void LLDrawPoolBump::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; applyModelMatrix(params); @@ -1435,12 +1428,8 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL } } - if (params.mGroup) - { - params.mGroup->rebuildMesh(); - } - params.mVertexBuffer->setBufferFast(mask); - params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); if (tex_setup) { diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index cf463f4458..4400308451 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -55,10 +55,10 @@ public: virtual void render(S32 pass = 0) override; virtual S32 getNumPasses() override; /*virtual*/ void prerender() override; - void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE) override; + void pushBatch(LLDrawInfo& params, bool texture, bool batch_textures = false) override; - void renderBump(U32 type, U32 mask); - void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture) override; + void pushBumpBatches(U32 type); + void renderGroup(LLSpatialGroup* group, U32 type, bool texture) override; S32 numBumpPasses(); @@ -87,7 +87,7 @@ public: static BOOL bindBumpMap(LLFace* face, S32 channel = -2); private: - static BOOL bindBumpMap(U8 bump_code, LLViewerTexture* tex, F32 vsize, S32 channel); + static BOOL bindBumpMap(U8 bump_code, LLViewerTexture* tex, S32 channel); bool mRigged = false; // if true, doing a rigged pass }; diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index 858fb871d3..735f32ddbb 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -156,8 +156,6 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) type += 1; } - U32 mask = mShader->mAttributeMask; - LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); @@ -304,8 +302,8 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) params.mGroup->rebuildMesh(); }*/ - params.mVertexBuffer->setBufferFast(mask); - params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); if (tex_setup) { diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 0e44a9be28..9dd1bc0ba2 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -43,13 +43,11 @@ void LLDrawPoolGLTFPBR::renderDeferred(S32 pass) for (U32 type : types) { gDeferredPBROpaqueProgram.bind(); - pushGLTFBatches(type, getVertexDataMask()); + pushGLTFBatches(type); gDeferredPBROpaqueProgram.bind(true); - pushRiggedGLTFBatches(type+1, getVertexDataMask()); + pushRiggedGLTFBatches(type+1); } - - LLGLSLShader::sCurBoundShaderPtr->unbind(); } diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 57aa1c73f0..3a659e0efc 100644 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -99,12 +99,12 @@ void LLDrawPoolGlow::render(LLGLSLShader* shader) //first pass -- static objects setup_glow_shader(shader); - pushBatches(LLRenderPass::PASS_GLOW, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushBatches(LLRenderPass::PASS_GLOW, true, true); // second pass -- rigged objects shader = shader->mRiggedVariant; setup_glow_shader(shader); - pushRiggedBatches(LLRenderPass::PASS_GLOW_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushRiggedBatches(LLRenderPass::PASS_GLOW_RIGGED, true, true); gGL.setColorMask(true, false); gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -161,21 +161,19 @@ void LLDrawPoolSimple::render(S32 pass) gPipeline.enableLightsDynamic(); - U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX; - // first pass -- static objects { setup_simple_shader(shader); - pushBatches(LLRenderPass::PASS_SIMPLE, mask, TRUE, TRUE); + pushBatches(LLRenderPass::PASS_SIMPLE, true, true); if (LLPipeline::sRenderDeferred) { //if deferred rendering is enabled, bump faces aren't registered as simple //render bump faces here as simple so bump faces will appear under water - pushBatches(LLRenderPass::PASS_BUMP, mask, TRUE, TRUE); - pushBatches(LLRenderPass::PASS_MATERIAL, mask, TRUE, TRUE); - pushBatches(LLRenderPass::PASS_SPECMAP, mask, TRUE, TRUE); - pushBatches(LLRenderPass::PASS_NORMMAP, mask, TRUE, TRUE); - pushBatches(LLRenderPass::PASS_NORMSPEC, mask, TRUE, TRUE); + pushBatches(LLRenderPass::PASS_BUMP, true, true); + pushBatches(LLRenderPass::PASS_MATERIAL, true, true); + pushBatches(LLRenderPass::PASS_SPECMAP, true, true); + pushBatches(LLRenderPass::PASS_NORMMAP, true, true); + pushBatches(LLRenderPass::PASS_NORMSPEC, true, true); } } @@ -183,16 +181,16 @@ void LLDrawPoolSimple::render(S32 pass) { shader = shader->mRiggedVariant; setup_simple_shader(shader); - pushRiggedBatches(LLRenderPass::PASS_SIMPLE_RIGGED, mask, TRUE, TRUE); + pushRiggedBatches(LLRenderPass::PASS_SIMPLE_RIGGED, true, true); if (LLPipeline::sRenderDeferred) { //if deferred rendering is enabled, bump faces aren't registered as simple //render bump faces here as simple so bump faces will appear under water - pushRiggedBatches(LLRenderPass::PASS_BUMP_RIGGED, mask, TRUE, TRUE); - pushRiggedBatches(LLRenderPass::PASS_MATERIAL_RIGGED, mask, TRUE, TRUE); - pushRiggedBatches(LLRenderPass::PASS_SPECMAP_RIGGED, mask, TRUE, TRUE); - pushRiggedBatches(LLRenderPass::PASS_NORMMAP_RIGGED, mask, TRUE, TRUE); - pushRiggedBatches(LLRenderPass::PASS_NORMSPEC_RIGGED, mask, TRUE, TRUE); + pushRiggedBatches(LLRenderPass::PASS_BUMP_RIGGED, true, true); + pushRiggedBatches(LLRenderPass::PASS_MATERIAL_RIGGED, true, true); + pushRiggedBatches(LLRenderPass::PASS_SPECMAP_RIGGED, true, true); + pushRiggedBatches(LLRenderPass::PASS_NORMMAP_RIGGED, true, true); + pushRiggedBatches(LLRenderPass::PASS_NORMSPEC_RIGGED, true, true); } } } @@ -228,19 +226,19 @@ void LLDrawPoolAlphaMask::render(S32 pass) // render static setup_simple_shader(shader); - pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushMaskBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushMaskBatches(LLRenderPass::PASS_SPECMAP_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushMaskBatches(LLRenderPass::PASS_NORMMAP_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushMaskBatches(LLRenderPass::PASS_NORMSPEC_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, true, true); + pushMaskBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, true, true); + pushMaskBatches(LLRenderPass::PASS_SPECMAP_MASK, true, true); + pushMaskBatches(LLRenderPass::PASS_NORMMAP_MASK, true, true); + pushMaskBatches(LLRenderPass::PASS_NORMSPEC_MASK, true, true); // render rigged setup_simple_shader(shader->mRiggedVariant); - pushRiggedMaskBatches(LLRenderPass::PASS_ALPHA_MASK_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushRiggedMaskBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushRiggedMaskBatches(LLRenderPass::PASS_SPECMAP_MASK_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushRiggedMaskBatches(LLRenderPass::PASS_NORMMAP_MASK_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - pushRiggedMaskBatches(LLRenderPass::PASS_NORMSPEC_MASK_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushRiggedMaskBatches(LLRenderPass::PASS_ALPHA_MASK_RIGGED, true, true); + pushRiggedMaskBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK_RIGGED, true, true); + pushRiggedMaskBatches(LLRenderPass::PASS_SPECMAP_MASK_RIGGED, true, true); + pushRiggedMaskBatches(LLRenderPass::PASS_NORMMAP_MASK_RIGGED, true, true); + pushRiggedMaskBatches(LLRenderPass::PASS_NORMSPEC_MASK_RIGGED, true, true); } LLDrawPoolFullbrightAlphaMask::LLDrawPoolFullbrightAlphaMask() : @@ -269,11 +267,11 @@ void LLDrawPoolFullbrightAlphaMask::render(S32 pass) // render static setup_fullbright_shader(shader); - pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, true, true); // render rigged setup_fullbright_shader(shader->mRiggedVariant); - pushRiggedMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushRiggedMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, true, true); } //=============================== @@ -293,11 +291,11 @@ void LLDrawPoolSimple::renderDeferred(S32 pass) //render static setup_simple_shader(&gDeferredDiffuseProgram); - pushBatches(LLRenderPass::PASS_SIMPLE, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushBatches(LLRenderPass::PASS_SIMPLE, true, true); //render rigged setup_simple_shader(gDeferredDiffuseProgram.mRiggedVariant); - pushRiggedBatches(LLRenderPass::PASS_SIMPLE_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushRiggedBatches(LLRenderPass::PASS_SIMPLE_RIGGED, true, true); } static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_MASK_DEFERRED("Deferred Alpha Mask"); @@ -310,11 +308,11 @@ void LLDrawPoolAlphaMask::renderDeferred(S32 pass) //render static setup_simple_shader(shader); - pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, true, true); //render rigged setup_simple_shader(shader->mRiggedVariant); - pushRiggedMaskBatches(LLRenderPass::PASS_ALPHA_MASK_RIGGED, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + pushRiggedMaskBatches(LLRenderPass::PASS_ALPHA_MASK_RIGGED, true, true); } // grass drawpool @@ -453,15 +451,14 @@ void LLDrawPoolFullbright::renderPostDeferred(S32 pass) } gGL.setSceneBlendType(LLRender::BT_ALPHA); - U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX; // render static setup_fullbright_shader(shader); - pushBatches(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask, TRUE, TRUE); + pushBatches(LLRenderPass::PASS_FULLBRIGHT, true, true); // render rigged setup_fullbright_shader(shader->mRiggedVariant); - pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_RIGGED, fullbright_mask, TRUE, TRUE); + pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_RIGGED, true, true); } void LLDrawPoolFullbright::render(S32 pass) @@ -480,24 +477,21 @@ void LLDrawPoolFullbright::render(S32 pass) shader = &gObjectFullbrightProgram; } - - U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX; - // render static setup_fullbright_shader(shader); - pushBatches(LLRenderPass::PASS_FULLBRIGHT, mask, TRUE, TRUE); - pushBatches(LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE, mask, TRUE, TRUE); - pushBatches(LLRenderPass::PASS_SPECMAP_EMISSIVE, mask, TRUE, TRUE); - pushBatches(LLRenderPass::PASS_NORMMAP_EMISSIVE, mask, TRUE, TRUE); - pushBatches(LLRenderPass::PASS_NORMSPEC_EMISSIVE, mask, TRUE, TRUE); + pushBatches(LLRenderPass::PASS_FULLBRIGHT, true, true); + pushBatches(LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE, true, true); + pushBatches(LLRenderPass::PASS_SPECMAP_EMISSIVE, true, true); + pushBatches(LLRenderPass::PASS_NORMMAP_EMISSIVE, true, true); + pushBatches(LLRenderPass::PASS_NORMSPEC_EMISSIVE, true, true); // render rigged setup_fullbright_shader(shader->mRiggedVariant); - pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_RIGGED, mask, TRUE, TRUE); - pushRiggedBatches(LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE_RIGGED, mask, TRUE, TRUE); - pushRiggedBatches(LLRenderPass::PASS_SPECMAP_EMISSIVE_RIGGED, mask, TRUE, TRUE); - pushRiggedBatches(LLRenderPass::PASS_NORMMAP_EMISSIVE_RIGGED, mask, TRUE, TRUE); - pushRiggedBatches(LLRenderPass::PASS_NORMSPEC_EMISSIVE_RIGGED, mask, TRUE, TRUE); + pushRiggedBatches(LLRenderPass::PASS_FULLBRIGHT_RIGGED, true, true); + pushRiggedBatches(LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE_RIGGED, true, true); + pushRiggedBatches(LLRenderPass::PASS_SPECMAP_EMISSIVE_RIGGED, true, true); + pushRiggedBatches(LLRenderPass::PASS_NORMMAP_EMISSIVE_RIGGED, true, true); + pushRiggedBatches(LLRenderPass::PASS_NORMSPEC_EMISSIVE_RIGGED, true, true); } S32 LLDrawPoolFullbright::getNumPasses() @@ -531,14 +525,13 @@ void LLDrawPoolFullbrightAlphaMask::renderPostDeferred(S32 pass) } LLGLDisable blend(GL_BLEND); - U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX; - + // render static setup_fullbright_shader(shader); - pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, fullbright_mask, TRUE, TRUE); + pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, true, true); // render rigged setup_fullbright_shader(shader->mRiggedVariant); - pushRiggedMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, fullbright_mask, TRUE, TRUE); + pushRiggedMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, true, true); } diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index 55c8d84838..64178f0a59 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -148,7 +148,7 @@ void LLDrawPoolTerrain::boostTerrainDetailTextures() for (S32 i = 0; i < 4; i++) { compp->mDetailTextures[i]->setBoostLevel(LLGLTexture::BOOST_TERRAIN); - gPipeline.touchTexture(compp->mDetailTextures[i], 1024.f * 1024.f); + compp->mDetailTextures[i]->addTextureStats(1024.f * 1024.f); } } @@ -821,8 +821,7 @@ void LLDrawPoolTerrain::renderOwnership() iter != mDrawFace.end(); iter++) { LLFace *facep = *iter; - facep->renderIndexed(LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0); + facep->renderIndexed(); } gGL.matrixMode(LLRender::MM_TEXTURE); diff --git a/indra/newview/lldrawpoolterrain.h b/indra/newview/lldrawpoolterrain.h index 5b4558020d..e00e0c4720 100644 --- a/indra/newview/lldrawpoolterrain.h +++ b/indra/newview/lldrawpoolterrain.h @@ -33,14 +33,12 @@ class LLDrawPoolTerrain : public LLFacePool { LLPointer mTexturep; public: - enum - { - VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_NORMAL | - LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_TEXCOORD1 | - LLVertexBuffer::MAP_TEXCOORD2 | - LLVertexBuffer::MAP_TEXCOORD3 + enum + { + VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | + LLVertexBuffer::MAP_NORMAL | + LLVertexBuffer::MAP_TEXCOORD0 | + LLVertexBuffer::MAP_TEXCOORD1 }; virtual U32 getVertexDataMask(); diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index facfb235c9..61a8e20b54 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -93,7 +93,7 @@ void LLDrawPoolTree::render(S32 pass) LLGLState test(GL_ALPHA_TEST, 0); gGL.getTexUnit(sDiffTex)->bindFast(mTexturep); - gPipeline.touchTexture(mTexturep, 1024.f * 1024.f); // <=== keep Linden tree textures at full res + mTexturep->addTextureStats(1024.f * 1024.f); // <=== keep Linden tree textures at full res for (std::vector::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++) @@ -117,8 +117,8 @@ void LLDrawPoolTree::render(S32 pass) gPipeline.mMatrixOpCount++; } - buff->setBufferFast(LLDrawPoolTree::VERTEX_DATA_MASK); - buff->drawRangeFast(LLRender::TRIANGLES, 0, buff->getNumVerts()-1, buff->getNumIndices(), 0); + buff->setBuffer(); + buff->drawRange(LLRender::TRIANGLES, 0, buff->getNumVerts()-1, buff->getNumIndices(), 0); } } } diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index c2fe52683b..1808fb5987 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -92,36 +92,19 @@ void LLDrawPoolWater::setNormalMaps(const LLUUID& normalMapId, const LLUUID& nex mWaterNormp[1]->addTextureStats(1024.f*1024.f); } -//static -void LLDrawPoolWater::restoreGL() -{ - /*LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); - if (pwater) - { - setTransparentTextures(pwater->getTransparentTextureID(), pwater->getNextTransparentTextureID()); - setOpaqueTexture(pwater->GetDefaultOpaqueTextureAssetId()); - setNormalMaps(pwater->getNormalMapID(), pwater->getNextNormalMapID()); - }*/ -} - void LLDrawPoolWater::prerender() { mShaderLevel = LLCubeMap::sUseCubeMaps ? LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; } -S32 LLDrawPoolWater::getNumPasses() -{ - if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f) - { - return 1; - } - - return 0; -} - S32 LLDrawPoolWater::getNumPostDeferredPasses() { - return 1; + if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f) + { + return 1; + } + + return 0; } void LLDrawPoolWater::beginPostDeferredPass(S32 pass) @@ -134,13 +117,6 @@ void LLDrawPoolWater::beginPostDeferredPass(S32 pass) LLRenderTarget& src = gPipeline.mRT->screen; LLRenderTarget& dst = gPipeline.mWaterDis; -#if 0 - dst.copyContents(src, - 0, 0, src.getWidth(), src.getHeight(), - 0, 0, dst.getWidth(), dst.getHeight(), - GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, - GL_NEAREST); -#else dst.bindTarget(); gCopyDepthProgram.bind(); @@ -150,369 +126,14 @@ void LLDrawPoolWater::beginPostDeferredPass(S32 pass) gGL.getTexUnit(diff_map)->bind(&src); gGL.getTexUnit(depth_map)->bind(&src, true); - gPipeline.mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + gPipeline.mScreenTriangleVB->setBuffer(); gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); dst.flush(); -#endif } } void LLDrawPoolWater::renderPostDeferred(S32 pass) -{ - renderWater(); -} - - -S32 LLDrawPoolWater::getNumDeferredPasses() -{ - return 0; -} - -//=============================== -//DEFERRED IMPLEMENTATION -//=============================== -void LLDrawPoolWater::renderDeferred(S32 pass) -{ -#if 0 - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); - - if (!LLPipeline::sRenderTransparentWater) - { - // Will render opaque water without use of ALM - render(pass); - return; - } - - deferred_render = TRUE; - renderWater(); - deferred_render = FALSE; -#endif -} - -//========================================= - -void LLDrawPoolWater::render(S32 pass) -{ -#if 0 - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); - if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1) - { - return; - } - - //do a quick 'n dirty depth sort - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace* facep = *iter; - facep->mDistance = -facep->mCenterLocal.mV[2]; - } - - std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater()); - - // See if we are rendering water as opaque or not - if (!LLPipeline::sRenderTransparentWater) - { - // render water for low end hardware - renderOpaqueLegacyWater(); - return; - } - - LLGLEnable blend(GL_BLEND); - - if ((mShaderLevel > 0) && !sSkipScreenCopy) - { - renderWater(); - return; - } - - LLVOSky *voskyp = gSky.mVOSkyp; - - stop_glerror(); - - LLFace* refl_face = voskyp->getReflFace(); - - gPipeline.disableLights(); - - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - - LLGLDisable cullFace(GL_CULL_FACE); - - // Set up second pass first - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->bind(mWaterImagep[0]) ; - - gGL.getTexUnit(2)->activate(); - gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(2)->bind(mWaterImagep[1]) ; - - LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); - F32 up_dot = camera_up * LLVector3::z_axis; - - LLColor4 water_color; - if (LLViewerCamera::getInstance()->cameraUnderWater()) - { - water_color.setVec(1.f, 1.f, 1.f, 0.4f); - } - else - { - water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - } - - gGL.diffuseColor4fv(water_color.mV); - - // Automatically generate texture coords for detail map - glEnable(GL_TEXTURE_GEN_S); //texture unit 1 - glEnable(GL_TEXTURE_GEN_T); //texture unit 1 - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - - // Slowly move over time. - F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f); - F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f}; - F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f}; - glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); - glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); - - gGL.getTexUnit(0)->activate(); - - glClearStencil(1); - glClear(GL_STENCIL_BUFFER_BIT); - //LLGLEnable gls_stencil(GL_STENCIL_TEST); - glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP); - glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - continue; - } - gGL.getTexUnit(0)->bind(face->getTexture()); - face->renderIndexed(); - } - - // Now, disable texture coord generation on texture state 1 - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->disable(); - - glDisable(GL_TEXTURE_GEN_S); //texture unit 1 - glDisable(GL_TEXTURE_GEN_T); //texture unit 1 - - gGL.getTexUnit(2)->activate(); - gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(2)->disable(); - - glDisable(GL_TEXTURE_GEN_S); //texture unit 1 - glDisable(GL_TEXTURE_GEN_T); //texture unit 1 - - // Disable texture coordinate and color arrays - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - stop_glerror(); - - if (gSky.mVOSkyp->getCubeMap() && !LLPipeline::sReflectionProbesEnabled) - { - gSky.mVOSkyp->getCubeMap()->enable(0); - gSky.mVOSkyp->getCubeMap()->bind(); - - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview(); - LLMatrix4 camera_rot(camera_mat.getMat3()); - camera_rot.invert(); - - gGL.loadMatrix((F32 *)camera_rot.mMatrix); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f, 0.5f*up_dot); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - //refl_face = face; - continue; - } - - if (face->getGeomCount() > 0) - { - face->renderIndexed(); - } - } - - gSky.mVOSkyp->getCubeMap()->disable(); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - - } - - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - if (refl_face) - { - glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); - renderReflection(refl_face); - } -#endif -} - -// for low end hardware -void LLDrawPoolWater::renderOpaqueLegacyWater() -{ -#if 0 - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - LLVOSky *voskyp = gSky.mVOSkyp; - - if (voskyp == NULL) - { - return; - } - - LLGLSLShader* shader = NULL; - if (LLPipeline::sUnderWaterRender) - { - shader = &gObjectSimpleNonIndexedTexGenWaterProgram; - } - else - { - shader = &gObjectSimpleNonIndexedTexGenProgram; - } - - shader->bind(); - - stop_glerror(); - - // Depth sorting and write to depth buffer - // since this is opaque, we should see nothing - // behind the water. No blending because - // of no transparency. And no face culling so - // that the underside of the water is also opaque. - LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); - LLGLDisable no_cull(GL_CULL_FACE); - LLGLDisable no_blend(GL_BLEND); - - gPipeline.disableLights(); - - // Activate the texture binding and bind one - // texture since all images will have the same texture - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->bind(mOpaqueWaterImagep); - - // Automatically generate texture coords for water texture - if (!shader) - { - glEnable(GL_TEXTURE_GEN_S); //texture unit 0 - glEnable(GL_TEXTURE_GEN_T); //texture unit 0 - glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - } - - // Use the fact that we know all water faces are the same size - // to save some computation - - // Slowly move texture coordinates over time so the watter appears - // to be moving. - F32 movement_period_secs = 50.f; - - F32 offset = fmod(gFrameTimeSeconds, movement_period_secs); - - if (movement_period_secs != 0) - { - offset /= movement_period_secs; - } - else - { - offset = 0; - } - - F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset }; - F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset }; - - if (!shader) - { - glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); - glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); - } - else - { - shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0); - shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1); - } - - gGL.diffuseColor3f(1.f, 1.f, 1.f); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - continue; - } - - face->renderIndexed(); - } - - stop_glerror(); - - if (!shader) - { - // Reset the settings back to expected values - glDisable(GL_TEXTURE_GEN_S); //texture unit 0 - glDisable(GL_TEXTURE_GEN_T); //texture unit 0 - } - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); -#endif -} - - -void LLDrawPoolWater::renderReflection(LLFace* face) -{ -#if 0 - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - LLVOSky *voskyp = gSky.mVOSkyp; - - if (!voskyp) - { - return; - } - - if (!face->getGeomCount()) - { - return; - } - - S8 dr = voskyp->getDrawRefl(); - if (dr < 0) - { - return; - } - - LLGLSNoFog noFog; - - gGL.getTexUnit(0)->bind((dr == 0) ? voskyp->getSunTex() : voskyp->getMoonTex()); - - LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV)); - face->renderIndexed(); -#endif -} - -void LLDrawPoolWater::renderWater() { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; if (!deferred_render) diff --git a/indra/newview/lldrawpoolwater.h b/indra/newview/lldrawpoolwater.h index 418430d68a..3158b0a59b 100644 --- a/indra/newview/lldrawpoolwater.h +++ b/indra/newview/lldrawpoolwater.h @@ -61,25 +61,15 @@ public: LLDrawPoolWater(); /*virtual*/ ~LLDrawPoolWater(); - static void restoreGL(); - - S32 getNumPostDeferredPasses() override; void beginPostDeferredPass(S32 pass) override; void renderPostDeferred(S32 pass) override; - S32 getNumDeferredPasses() override; - void renderDeferred(S32 pass = 0) override; - S32 getNumPasses() override; - void render(S32 pass = 0) override; void prerender() override; LLViewerTexture *getDebugTexture() override; LLColor3 getDebugColor() const; // For AGP debug display - void renderReflection(LLFace* face); - void renderWater(); - void setTransparentTextures(const LLUUID& transparentTextureId, const LLUUID& nextTransparentTextureId); void setOpaqueTexture(const LLUUID& opaqueTextureId); void setNormalMaps(const LLUUID& normalMapId, const LLUUID& nextNormalMapId); diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 878022a2c8..345fb81ada 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -192,7 +192,6 @@ void LLFace::destroy() if (isState(LLFace::PARTICLE)) { - LLVOPartGroup::freeVBSlot(getGeomIndex()/4); clearState(LLFace::PARTICLE); } @@ -539,6 +538,7 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) if (mDrawablep->isState(LLDrawable::RIGGED)) { +#if 0 // TODO -- there is no way this won't destroy our GL machine as implemented, rewrite it to not rely on software skinning LLVOVolume* volume = mDrawablep->getVOVolume(); if (volume) { @@ -562,12 +562,13 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) glDisableClientState(GL_TEXTURE_COORD_ARRAY); } } +#endif } else { // cheaters sometimes prosper... // - mVertexBuffer->setBuffer(mVertexBuffer->getTypeMask()); + mVertexBuffer->setBuffer(); mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); } @@ -654,54 +655,8 @@ void LLFace::renderOneWireframe(const LLColor4 &color, F32 fogCfx, bool wirefram } } -/* removed in lieu of raycast uv detection -void LLFace::renderSelectedUV() -{ - LLViewerTexture* red_blue_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test1.j2c", TRUE, LLGLTexture::BOOST_UI); - LLViewerTexture* green_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test2.tga", TRUE, LLGLTexture::BOOST_UI); - - LLGLSUVSelect object_select; - - // use red/blue gradient to get coarse UV coordinates - renderSelected(red_blue_imagep, LLColor4::white); - - static F32 bias = 0.f; - static F32 factor = -10.f; - glPolygonOffset(factor, bias); - - // add green dither pattern on top of red/blue gradient - gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_ONE); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.pushMatrix(); - // make green pattern repeat once per texel in red/blue texture - gGL.scalef(256.f, 256.f, 1.f); - gGL.matrixMode(LLRender::MM_MODELVIEW); - - renderSelected(green_imagep, LLColor4::white); - - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); -} -*/ - void LLFace::setDrawInfo(LLDrawInfo* draw_info) { - if (draw_info) - { - if (draw_info->mFace) - { - draw_info->mFace->setDrawInfo(NULL); - } - draw_info->mFace = this; - } - - if (mDrawInfo) - { - mDrawInfo->mFace = NULL; - } - mDrawInfo = draw_info; } @@ -1225,10 +1180,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, updateRebuildFlags(); } - - //don't use map range (generates many redundant unmap calls) - bool map_range = false; - if (mVertexBuffer.notNull()) { if (num_indices + (S32) mIndicesIndex > mVertexBuffer->getNumIndices()) @@ -1355,7 +1306,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (full_rebuild) { LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - indices"); - mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex, mIndicesCount, map_range); + mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex, mIndicesCount); volatile __m128i* dst = (__m128i*) indicesp.get(); __m128i* src = (__m128i*) vf.mIndices; @@ -1378,11 +1329,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, *idx++ = vf.mIndices[i]+index_offset; } } - - if (map_range) - { - mVertexBuffer->flush(); - } } F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0; @@ -1694,11 +1640,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } } - - if (map_range) - { - mVertexBuffer->flush(); - } } else { //bump mapped or has material, just do the whole expensive loop @@ -1718,12 +1659,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, switch (ch) { case 0: - mVertexBuffer->getTexCoord0Strider(dst, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getTexCoord0Strider(dst, mGeomIndex, mGeomCount); break; case 1: if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1)) { - mVertexBuffer->getTexCoord1Strider(dst, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getTexCoord1Strider(dst, mGeomIndex, mGeomCount); if (mat && !tex_anim) { r = mat->getNormalRotation(); @@ -1743,7 +1684,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, case 2: if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2)) { - mVertexBuffer->getTexCoord2Strider(dst, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getTexCoord2Strider(dst, mGeomIndex, mGeomCount); if (mat && !tex_anim) { r = mat->getSpecularRotation(); @@ -1802,14 +1743,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } - if (map_range) - { - mVertexBuffer->flush(); - } - if ((!mat && !gltf_mat) && do_bump) { - mVertexBuffer->getTexCoord1Strider(tex_coords1, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getTexCoord1Strider(tex_coords1, mGeomIndex, mGeomCount); mVObjp->getVolume()->genTangents(f); @@ -1844,11 +1780,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, *tex_coords1++ = tc; } - - if (map_range) - { - mVertexBuffer->flush(); - } } } } @@ -1864,7 +1795,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, llassert(num_vertices > 0); - mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount); F32* dst = (F32*) vert.get(); @@ -1910,18 +1841,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, res0.store4a((F32*) dst); dst += 4; } - - if (map_range) - { - mVertexBuffer->flush(); - } } if (rebuild_normal) { LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - normal"); - mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount); F32* normals = (F32*) norm.get(); LLVector4a* src = vf.mNormals; LLVector4a* end = src+num_vertices; @@ -1933,17 +1859,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, normal.store4a(normals); normals += 4; } - - if (map_range) - { - mVertexBuffer->flush(); - } } if (rebuild_tangent) { LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - tangent"); - mVertexBuffer->getTangentStrider(tangent, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getTangentStrider(tangent, mGeomIndex, mGeomCount); F32* tangents = (F32*) tangent.get(); mVObjp->getVolume()->genTangents(f); @@ -1965,29 +1886,20 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, src++; tangents += 4; } - - if (map_range) - { - mVertexBuffer->flush(); - } } if (rebuild_weights && vf.mWeights) { LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - weight"); - mVertexBuffer->getWeight4Strider(wght, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getWeight4Strider(wght, mGeomIndex, mGeomCount); F32* weights = (F32*) wght.get(); LLVector4a::memcpyNonAliased16(weights, (F32*) vf.mWeights, num_vertices*4*sizeof(F32)); - if (map_range) - { - mVertexBuffer->flush(); - } } if (rebuild_color && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_COLOR) ) { LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - color"); - mVertexBuffer->getColorStrider(colors, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getColorStrider(colors, mGeomIndex, mGeomCount); LLVector4a src; @@ -2008,18 +1920,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, src.store4a(dst); dst += 4; } - - if (map_range) - { - mVertexBuffer->flush(); - } } if (rebuild_emissive) { LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - emissive"); LLStrider emissive; - mVertexBuffer->getEmissiveStrider(emissive, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getEmissiveStrider(emissive, mGeomIndex, mGeomCount); U8 glow = (U8) llclamp((S32) (getTextureEntry()->getGlow()*255), 0, 255); @@ -2047,11 +1954,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, src.store4a(dst); dst += 4; } - - if (map_range) - { - mVertexBuffer->flush(); - } } } @@ -2074,6 +1976,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, return TRUE; } +void LLFace::renderIndexed() +{ + if (mVertexBuffer.notNull()) + { + mVertexBuffer->setBuffer(); + mVertexBuffer->drawRange(LLRender::TRIANGLES, getGeomIndex(), getGeomIndex() + getGeomCount()-1, getIndicesCount(), getIndicesStart()); + } +} + //check if the face has a media BOOL LLFace::hasMedia() const { @@ -2405,92 +2316,12 @@ void LLFace::setViewerObject(LLViewerObject* objp) mVObjp = objp; } -const LLColor4& LLFace::getRenderColor() const -{ - if (isState(USE_FACE_COLOR)) - { - return mFaceColor; // Face Color - } - else - { - const LLTextureEntry* tep = getTextureEntry(); - return (tep ? tep->getColor() : LLColor4::white); - } -} - -void LLFace::renderSetColor() const -{ - if (!LLFacePool::LLOverrideFaceColor::sOverrideFaceColor) - { - const LLColor4* color = &(getRenderColor()); - - gGL.diffuseColor4fv(color->mV); - } -} - -S32 LLFace::pushVertices(const U16* index_array) const -{ - if (mIndicesCount) - { - mVertexBuffer->drawRange(LLRender::TRIANGLES, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex); - gPipeline.addTrianglesDrawn(mIndicesCount); - } - - return mIndicesCount; -} const LLMatrix4& LLFace::getRenderMatrix() const { return mDrawablep->getRenderMatrix(); } -S32 LLFace::renderElements(const U16 *index_array) const -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE - - S32 ret = 0; - - if (isState(GLOBAL)) - { - ret = pushVertices(index_array); - } - else - { - gGL.pushMatrix(); - gGL.multMatrix((float*)getRenderMatrix().mMatrix); - ret = pushVertices(index_array); - gGL.popMatrix(); - } - - return ret; -} - -S32 LLFace::renderIndexed() -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE - - if(mDrawablep == NULL || mDrawPoolp == NULL) - { - return 0; - } - - return renderIndexed(mDrawPoolp->getVertexDataMask()); -} - -S32 LLFace::renderIndexed(U32 mask) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE - - if (mVertexBuffer.isNull()) - { - return 0; - } - - mVertexBuffer->setBuffer(mask); - U16* index_array = (U16*) mVertexBuffer->getIndicesPointer(); - return renderElements(index_array); -} - //============================================================================ // From llface.inl diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 0cb986b8ed..ee8316018b 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -125,12 +125,6 @@ public: S32 getIndexInTex(U32 ch) const {llassert(ch < LLRender::NUM_TEXTURE_CHANNELS); return mIndexInTex[ch];} void setIndexInTex(U32 ch, S32 index) { llassert(ch < LLRender::NUM_TEXTURE_CHANNELS); mIndexInTex[ch] = index ;} - - void renderSetColor() const; - S32 renderElements(const U16 *index_array) const; - S32 renderIndexed (); - S32 renderIndexed (U32 mask); - S32 pushVertices(const U16* index_array) const; void setWorldMatrix(const LLMatrix4& mat); const LLTextureEntry* getTextureEntry() const { return mVObjp->getTE(mTEOffset); } @@ -151,11 +145,12 @@ public: void setDrawable(LLDrawable *drawable); void setTEOffset(const S32 te_offset); + void renderIndexed(); void setFaceColor(const LLColor4& color); // override material color void unsetFaceColor(); // switch back to material color const LLColor4& getFaceColor() const { return mFaceColor; } - const LLColor4& getRenderColor() const; + //for volumes void updateRebuildFlags(); diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index d5115df35f..500e3cc41b 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -399,6 +399,7 @@ void LLVolumeImplFlexible::doIdleUpdate() updateRenderRes(); + mVO->shrinkWrap(); gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE); } } diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index 89ba687d25..b2be6a925e 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -797,8 +797,8 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance) U32 num_indices = vf.mNumIndices; U32 num_vertices = vf.mNumVertices; - mVertexBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0, 0); - if (!mVertexBuffer->allocateBuffer(num_vertices, num_indices, TRUE)) + mVertexBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0); + if (!mVertexBuffer->allocateBuffer(num_vertices, num_indices)) { LL_WARNS() << "Failed to allocate Vertex Buffer for image preview to" << num_vertices << " vertices and " @@ -906,7 +906,7 @@ BOOL LLImagePreviewSculpted::render() const F32 BRIGHTNESS = 0.9f; gGL.diffuseColor3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); - mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0); + mVertexBuffer->setBuffer(); mVertexBuffer->draw(LLRender::TRIANGLES, num_indices, 0); gGL.popMatrix(); diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 78dba81d9a..fe7c1c8f2c 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -1083,9 +1083,9 @@ F32 gpu_benchmark() delete [] pixels; //make a dummy triangle to draw with - LLPointer buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, GL_STREAM_DRAW); + LLPointer buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX); - if (!buff->allocateBuffer(3, 0, true)) + if (!buff->allocateBuffer(3, 0)) { LL_WARNS("Benchmark") << "Failed to allocate buffer during benchmark." << LL_ENDL; // abandon the benchmark test @@ -1109,12 +1109,12 @@ F32 gpu_benchmark() v[1].set(-1, -3, 0); v[2].set(3, 1, 0); - buff->flush(); + buff->unmapBuffer(); // ensure matched pair of bind() and unbind() calls ShaderBinder binder(gBenchmarkProgram); - buff->setBuffer(LLVertexBuffer::MAP_VERTEX); + buff->setBuffer(); glFinish(); F32 time_passed = 0; // seconds diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp index fe6793ce73..292045f25d 100644 --- a/indra/newview/llhudobject.cpp +++ b/indra/newview/llhudobject.cpp @@ -269,9 +269,9 @@ void LLHUDObject::renderAll() { LLGLSUIDefault gls_ui; + gUIProgram.bind(); gGL.color4f(1, 1, 1, 1); - gUIProgram.bind(); LLGLDepthTest depth(GL_FALSE, GL_FALSE); LLHUDObject *hud_objp; diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index 5544f33aea..22dca07096 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -573,7 +573,6 @@ void LLHUDText::markDead() void LLHUDText::renderAllHUD() { LLGLState::checkStates(); - LLGLState::checkTextureChannels(); { LLGLEnable color_mat(GL_COLOR_MATERIAL); @@ -590,7 +589,6 @@ void LLHUDText::renderAllHUD() LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); } void LLHUDText::shiftAll(const LLVector3& offset) diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 914528c7ce..df1a29d039 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -2788,9 +2788,9 @@ void LLModelPreview::genBuffers(S32 lod, bool include_skin_weights) mask |= LLVertexBuffer::MAP_WEIGHT4; } - vb = new LLVertexBuffer(mask, 0); + vb = new LLVertexBuffer(mask); - if (!vb->allocateBuffer(num_vertices, num_indices, TRUE)) + if (!vb->allocateBuffer(num_vertices, num_indices)) { // We are likely to crash due this failure, if this happens, find a way to gracefully stop preview std::ostringstream out; @@ -2861,7 +2861,7 @@ void LLModelPreview::genBuffers(S32 lod, bool include_skin_weights) *(index_strider++) = vf.mIndices[i]; } - vb->flush(); + vb->unmapBuffer(); mVertexBuffer[lod][mdl].push_back(vb); @@ -3055,11 +3055,11 @@ void LLModelPreview::addEmptyFace(LLModel* pTarget) { U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; - LLPointer buff = new LLVertexBuffer(type_mask, 0); + LLPointer buff = new LLVertexBuffer(type_mask); - buff->allocateBuffer(1, 3, true); + buff->allocateBuffer(1, 3); memset((U8*)buff->getMappedData(), 0, buff->getSize()); - memset((U8*)buff->getIndicesPointer(), 0, buff->getIndicesSize()); + memset((U8*)buff->getMappedIndices(), 0, buff->getIndicesSize()); buff->validateRange(0, buff->getNumVerts() - 1, buff->getNumIndices(), 0); @@ -3316,8 +3316,6 @@ BOOL LLModelPreview::render() gGL.pushMatrix(); gGL.color4fv(PREVIEW_EDGE_COL.mV); - const U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; - LLGLEnable normalize(GL_NORMALIZE); if (!mBaseModel.empty() && mVertexBuffer[5].empty()) @@ -3380,7 +3378,7 @@ BOOL LLModelPreview::render() { LLVertexBuffer* buffer = mVertexBuffer[mPreviewLOD][model][i]; - buffer->setBuffer(type_mask & buffer->getTypeMask()); + buffer->setBuffer(); if (textures) { @@ -3417,7 +3415,7 @@ BOOL LLModelPreview::render() glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.f); } - buffer->flush(); + buffer->unmapBuffer(); } gGL.popMatrix(); } @@ -3531,7 +3529,7 @@ BOOL LLModelPreview::render() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.diffuseColor4fv(PREVIEW_PSYH_FILL_COL.mV); - buffer->setBuffer(type_mask & buffer->getTypeMask()); + buffer->setBuffer(); buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0); gGL.diffuseColor4fv(PREVIEW_PSYH_EDGE_COL.mV); @@ -3542,7 +3540,7 @@ BOOL LLModelPreview::render() glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.f); - buffer->flush(); + buffer->unmapBuffer(); } } } @@ -3592,7 +3590,7 @@ BOOL LLModelPreview::render() { LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][v]; - buffer->setBuffer(type_mask & buffer->getTypeMask()); + buffer->setBuffer(); LLStrider pos_strider; buffer->getVertexStrider(pos_strider, 0); @@ -3614,7 +3612,7 @@ BOOL LLModelPreview::render() } } - buffer->flush(); + buffer->unmapBuffer(); } } } @@ -3745,7 +3743,7 @@ BOOL LLModelPreview::render() const std::string& binding = instance.mModel->mMaterialList[i]; const LLImportMaterial& material = instance.mMaterial[binding]; - buffer->setBuffer(type_mask & buffer->getTypeMask()); + buffer->setBuffer(); gGL.diffuseColor4fv(material.mDiffuseColor.mV); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index d9d6341617..b87406cb6e 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -513,7 +513,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) { //generate radiance map gRadianceGenProgram.bind(); - mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX); + mVertexBuffer->setBuffer(); S32 channel = gRadianceGenProgram.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); mTexture->bind(channel); @@ -563,7 +563,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) mTexture->bind(channel); gIrradianceGenProgram.uniform1i(sSourceIdx, targetIdx); - mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX); + mVertexBuffer->setBuffer(); int start_mip = 0; // find the mip target to start with based on irradiance map resolution for (start_mip = 0; start_mip < mMipChain.size(); ++start_mip) @@ -900,8 +900,8 @@ void LLReflectionMapManager::initReflectionMaps() if (mVertexBuffer.isNull()) { U32 mask = LLVertexBuffer::MAP_VERTEX; - LLPointer buff = new LLVertexBuffer(mask, GL_STATIC_DRAW); - buff->allocateBuffer(4, 0, TRUE); + LLPointer buff = new LLVertexBuffer(mask); + buff->allocateBuffer(4, 0); LLStrider v; @@ -912,7 +912,7 @@ void LLReflectionMapManager::initReflectionMaps() v[2] = LLVector3(-1, 1, -1); v[3] = LLVector3(1, 1, -1); - buff->flush(); + buff->unmapBuffer(); mVertexBuffer = buff; } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 7653913c2b..2f199cc8e7 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -59,12 +59,12 @@ extern bool gShiftFrame; static U32 sZombieGroups = 0; U32 LLSpatialGroup::sNodeCount = 0; -BOOL LLSpatialGroup::sNoDelete = FALSE; +bool LLSpatialGroup::sNoDelete = false; static F32 sLastMaxTexPriority = 1.f; static F32 sCurMaxTexPriority = 1.f; -BOOL LLSpatialPartition::sTeleportRequested = FALSE; +bool LLSpatialPartition::sTeleportRequested = false; //static counter for frame to switch LOD on @@ -309,14 +309,13 @@ void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group) if (vertex_count > 0 && index_count > 0) { //create vertex buffer containing volume geometry for this node { - group->mBuilt = 1.f; - if (group->mVertexBuffer.isNull() || - !group->mVertexBuffer->isWriteable() || - (group->mBufferUsage != group->mVertexBuffer->getUsage() && LLVertexBuffer::sEnableVBOs)) + if (group->mVertexBuffer.isNull() || + group->mVertexBuffer->getNumVerts() != vertex_count || + group->mVertexBuffer->getNumVerts() != index_count) { - group->mVertexBuffer = createVertexBuffer(mVertexDataMask, group->mBufferUsage); - if (!group->mVertexBuffer->allocateBuffer(vertex_count, index_count, true)) + group->mVertexBuffer = new LLVertexBuffer(mVertexDataMask); + if (!group->mVertexBuffer->allocateBuffer(vertex_count, index_count)) { LL_WARNS() << "Failed to allocate Vertex Buffer on rebuild to " << vertex_count << " vertices and " @@ -325,18 +324,6 @@ void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group) group->mBufferMap.clear(); } } - else - { - if (!group->mVertexBuffer->resizeBuffer(vertex_count, index_count)) - { - // Is likely to cause a crash. If this gets triggered find a way to avoid it (don't forget to reset face) - LL_WARNS() << "Failed to resize Vertex Buffer on rebuild to " - << vertex_count << " vertices and " - << index_count << " indices" << LL_ENDL; - group->mVertexBuffer = NULL; - group->mBufferMap.clear(); - } - } } if (group->mVertexBuffer) @@ -538,7 +525,6 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : LLO mSurfaceArea(0.f), mBuilt(0.f), mVertexBuffer(NULL), - mBufferUsage(part->mBufferUsage), mDistance(0.f), mDepth(0.f), mLastUpdateDistance(-1.f), @@ -567,6 +553,7 @@ void LLSpatialGroup::updateDistance(LLCamera &camera) if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { LL_WARNS() << "Attempted to update distance for camera other than world camera!" << LL_ENDL; + llassert(false); return; } @@ -838,13 +825,12 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion) //============================================== -LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 buffer_usage, LLViewerRegion* regionp) +LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, LLViewerRegion* regionp) : mRenderByGroup(render_by_group), mBridge(NULL) { mRegionp = regionp; mPartitionType = LLViewerRegion::PARTITION_NONE; mVertexDataMask = data_mask; - mBufferUsage = buffer_usage; mDepthMask = FALSE; mSlopRatio = 0.25f; mInfiniteFarClip = FALSE; @@ -1437,15 +1423,15 @@ S32 LLSpatialPartition::cull(LLCamera &camera, bool do_occlusion) return 0; } -void pushVerts(LLDrawInfo* params, U32 mask) +void pushVerts(LLDrawInfo* params) { LLRenderPass::applyModelMatrix(*params); - params->mVertexBuffer->setBuffer(mask); - params->mVertexBuffer->drawRange(params->mParticle ? LLRender::POINTS : LLRender::TRIANGLES, + params->mVertexBuffer->setBuffer(); + params->mVertexBuffer->drawRange(LLRender::TRIANGLES, params->mStart, params->mEnd, params->mCount, params->mOffset); } -void pushVerts(LLSpatialGroup* group, U32 mask) +void pushVerts(LLSpatialGroup* group) { LLDrawInfo* params = NULL; @@ -1454,36 +1440,25 @@ void pushVerts(LLSpatialGroup* group, U32 mask) for (LLSpatialGroup::drawmap_elem_t::iterator j = i->second.begin(); j != i->second.end(); ++j) { params = *j; - pushVerts(params, mask); + pushVerts(params); } } } -void pushVerts(LLFace* face, U32 mask) +void pushVerts(LLFace* face) { if (face) { llassert(face->verify()); - - LLVertexBuffer* buffer = face->getVertexBuffer(); - - if (buffer && (face->getGeomCount() >= 3)) - { - buffer->setBuffer(mask); - U16 start = face->getGeomStart(); - U16 end = start + face->getGeomCount()-1; - U32 count = face->getIndicesCount(); - U16 offset = face->getIndicesStart(); - buffer->drawRange(LLRender::TRIANGLES, start, end, count, offset); - } + face->renderIndexed(); } } -void pushVerts(LLDrawable* drawable, U32 mask) +void pushVerts(LLDrawable* drawable) { for (S32 i = 0; i < drawable->getNumFaces(); ++i) { - pushVerts(drawable->getFace(i), mask); + pushVerts(drawable->getFace(i)); } } @@ -1497,16 +1472,16 @@ void pushVerts(LLVolume* volume) } } -void pushBufferVerts(LLVertexBuffer* buffer, U32 mask) +void pushBufferVerts(LLVertexBuffer* buffer) { if (buffer) { - buffer->setBuffer(mask); + buffer->setBuffer(); buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); } } -void pushBufferVerts(LLSpatialGroup* group, U32 mask, bool push_alpha = true) +void pushBufferVerts(LLSpatialGroup* group, bool push_alpha = true) { if (group->getSpatialPartition()->mRenderByGroup) { @@ -1517,7 +1492,7 @@ void pushBufferVerts(LLSpatialGroup* group, U32 mask, bool push_alpha = true) if (push_alpha) { - pushBufferVerts(group->mVertexBuffer, mask); + pushBufferVerts(group->mVertexBuffer); } for (LLSpatialGroup::buffer_map_t::iterator i = group->mBufferMap.begin(); i != group->mBufferMap.end(); ++i) @@ -1526,7 +1501,7 @@ void pushBufferVerts(LLSpatialGroup* group, U32 mask, bool push_alpha = true) { for (LLSpatialGroup::buffer_list_t::iterator k = j->second.begin(); k != j->second.end(); ++k) { - pushBufferVerts(*k, mask); + pushBufferVerts(*k); } } } @@ -1539,7 +1514,7 @@ void pushBufferVerts(LLSpatialGroup* group, U32 mask, bool push_alpha = true) }*/ } -void pushVertsColorCoded(LLSpatialGroup* group, U32 mask) +void pushVertsColorCoded(LLSpatialGroup* group) { LLDrawInfo* params = NULL; @@ -1564,8 +1539,8 @@ void pushVertsColorCoded(LLSpatialGroup* group, U32 mask) params = *j; LLRenderPass::applyModelMatrix(*params); gGL.diffuseColor4f(colors[col].mV[0], colors[col].mV[1], colors[col].mV[2], 0.5f); - params->mVertexBuffer->setBuffer(mask); - params->mVertexBuffer->drawRange(params->mParticle ? LLRender::POINTS : LLRender::TRIANGLES, + params->mVertexBuffer->setBuffer(); + params->mVertexBuffer->drawRange(LLRender::TRIANGLES, params->mStart, params->mEnd, params->mCount, params->mOffset); col = (col+1)%col_count; } @@ -1637,17 +1612,8 @@ void renderOctree(LLSpatialGroup* group) if (group->mBuilt > 0.f) { group->mBuilt -= 2.f * gFrameIntervalSeconds.value(); - if (group->mBufferUsage == GL_STATIC_DRAW) - { - col.setVec(1.0f, 0, 0, group->mBuilt*0.5f); - } - else - { - col.setVec(0.1f,0.1f,1,0.1f); - //col.setVec(1.0f, 1.0f, 0, sinf(group->mBuilt*3.14159f)*0.5f); - } - - if (group->mBufferUsage != GL_STATIC_DRAW) + col.setVec(0.1f,0.1f,1,0.1f); + { LLGLDepthTest gl_depth(FALSE, FALSE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -1708,20 +1674,36 @@ void renderOctree(LLSpatialGroup* group) LLFace* face = drawable->getFace(j); if (face && face->getVertexBuffer()) { - if (gFrameTimeSeconds - face->mLastUpdateTime < 0.5f) - { - gGL.diffuseColor4f(0, 1, 0, group->mBuilt); - } - else if (gFrameTimeSeconds - face->mLastMoveTime < 0.5f) - { - gGL.diffuseColor4f(1, 0, 0, group->mBuilt); - } - else - { - continue; - } + LLVOVolume* vol = drawable->getVOVolume(); - face->getVertexBuffer()->setBuffer(LLVertexBuffer::MAP_VERTEX | (rigged ? LLVertexBuffer::MAP_WEIGHT4 : 0)); + if (gFrameTimeSeconds - face->mLastUpdateTime < 0.5f) + { + if (vol && vol->isShrinkWrapped()) + { + gGL.diffuseColor4f(0, 1, 1, group->mBuilt); + } + else + { + gGL.diffuseColor4f(0, 1, 0, group->mBuilt); + } + } + else if (gFrameTimeSeconds - face->mLastMoveTime < 0.5f) + { + if (vol && vol->isShrinkWrapped()) + { + gGL.diffuseColor4f(1, 1, 0, group->mBuilt); + } + else + { + gGL.diffuseColor4f(1, 0, 0, group->mBuilt); + } + } + else + { + continue; + } + + face->getVertexBuffer()->setBuffer(); //drawBox((face->mExtents[0] + face->mExtents[1])*0.5f, // (face->mExtents[1]-face->mExtents[0])*0.5f); face->getVertexBuffer()->draw(LLRender::TRIANGLES, face->getIndicesCount(), face->getIndicesStart()); @@ -1743,18 +1725,6 @@ void renderOctree(LLSpatialGroup* group) gGL.diffuseColor4f(1,1,1,1); } } - else - { - if (group->mBufferUsage == GL_STATIC_DRAW && !group->isEmpty() - && group->getSpatialPartition()->mRenderByGroup) - { - col.setVec(0.8f, 0.4f, 0.1f, 0.1f); - } - else - { - col.setVec(0.1f, 0.1f, 1.f, 0.1f); - } - } gGL.diffuseColor4fv(col.mV); LLVector4a fudge; @@ -1907,7 +1877,7 @@ void renderXRay(LLSpatialGroup* group, LLCamera* camera) if (render_objects) { - pushBufferVerts(group, LLVertexBuffer::MAP_VERTEX, false); + pushBufferVerts(group, false); bool selected = false; @@ -1989,7 +1959,7 @@ void renderUpdateType(LLDrawable* drawablep) { for (S32 i = 0; i < num_faces; ++i) { - pushVerts(drawablep->getFace(i), LLVertexBuffer::MAP_VERTEX); + pushVerts(drawablep->getFace(i)); } } } @@ -2080,7 +2050,7 @@ void renderComplexityDisplay(LLDrawable* drawablep) { for (S32 i = 0; i < num_faces; ++i) { - pushVerts(drawablep->getFace(i), LLVertexBuffer::MAP_VERTEX); + pushVerts(drawablep->getFace(i)); } } LLViewerObject::const_child_list_t children = voVol->getChildren(); @@ -2094,7 +2064,7 @@ void renderComplexityDisplay(LLDrawable* drawablep) { for (S32 i = 0; i < num_faces; ++i) { - pushVerts(child->mDrawable->getFace(i), LLVertexBuffer::MAP_VERTEX); + pushVerts(child->mDrawable->getFace(i)); } } } @@ -2736,7 +2706,7 @@ void renderPhysicsShapes(LLSpatialGroup* group, bool wireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - buff->setBuffer(LLVertexBuffer::MAP_VERTEX); + buff->setBuffer(); gGL.diffuseColor4f(0.2f, 0.5f, 0.3f, 0.5f); buff->draw(LLRender::TRIANGLES, buff->getNumIndices(), 0); @@ -2842,7 +2812,7 @@ void renderTextureAnim(LLDrawInfo* params) LLGLEnable blend(GL_BLEND); gGL.diffuseColor4f(1,1,0,0.5f); - pushVerts(params, LLVertexBuffer::MAP_VERTEX); + pushVerts(params); } void renderBatchSize(LLDrawInfo* params) @@ -2850,7 +2820,6 @@ void renderBatchSize(LLDrawInfo* params) LLGLEnable offset(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.f, 1.f); LLGLSLShader* old_shader = LLGLSLShader::sCurBoundShaderPtr; - U32 mask = LLVertexBuffer::MAP_VERTEX; bool bind = false; if (params->mAvatar) { @@ -2859,11 +2828,11 @@ void renderBatchSize(LLDrawInfo* params) bind = true; old_shader->mRiggedVariant->bind(); LLRenderPass::uploadMatrixPalette(*params); - mask |= LLVertexBuffer::MAP_WEIGHT4; } - gGL.diffuseColor4ubv((GLubyte*)&(params->mDebugColor)); - pushVerts(params, mask); + + gGL.diffuseColor4ubv(params->getDebugColor().mV); + pushVerts(params); if (bind) { @@ -2919,7 +2888,7 @@ void renderTexelDensity(LLDrawable* drawable) if (buffer && (facep->getGeomCount() >= 3)) { - buffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); + buffer->setBuffer(); U16 start = facep->getGeomStart(); U16 end = start + facep->getGeomCount()-1; U32 count = facep->getIndicesCount(); @@ -2994,7 +2963,7 @@ void renderLights(LLDrawable* drawablep) LLFace * face = drawablep->getFace(i); if (face) { - pushVerts(face, LLVertexBuffer::MAP_VERTEX); + pushVerts(face); } } @@ -3967,58 +3936,46 @@ LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, LLViewerTexture* texture, LLVertexBuffer* buffer, - bool selected, - BOOL fullbright, U8 bump, BOOL particle, F32 part_size) + bool fullbright, U8 bump) : mVertexBuffer(buffer), mTexture(texture), - mTextureMatrix(NULL), - mModelMatrix(NULL), mStart(start), mEnd(end), mCount(count), mOffset(offset), mFullbright(fullbright), mBump(bump), - mParticle(particle), - mPartSize(part_size), - mVSize(0.f), - mGroup(NULL), - mFace(NULL), - mDistance(0.f), - mMaterial(NULL), - mShaderMask(0), - mSpecColor(1.0f, 1.0f, 1.0f, 0.5f), mBlendFuncSrc(LLRender::BF_SOURCE_ALPHA), mBlendFuncDst(LLRender::BF_ONE_MINUS_SOURCE_ALPHA), - mHasGlow(FALSE), + mHasGlow(false), mEnvIntensity(0.0f), - mAlphaMaskCutoff(0.5f), - mDiffuseAlphaMode(0) + mAlphaMaskCutoff(0.5f) { mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset); - - mDebugColor = (rand() << 16) + rand(); - ((U8*)&mDebugColor)[3] = 200; } LLDrawInfo::~LLDrawInfo() { - /*if (LLSpatialGroup::sNoDelete) - { - LL_ERRS() << "LLDrawInfo deleted illegally!" << LL_ENDL; - }*/ - - if (mFace) - { - mFace->setDrawInfo(NULL); - } - if (gDebugGL) { gPipeline.checkReferences(this); } } +LLColor4U LLDrawInfo::getDebugColor() const +{ + LLColor4U color; + + LLCRC hash; + hash.update((U8*)this + sizeof(S32), sizeof(LLDrawInfo) - sizeof(S32)); + + *((U32*) color.mV) = hash.getCRC(); + + color.mV[3] = 200; + + return color; +} + void LLDrawInfo::validate() { mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset); @@ -4029,11 +3986,6 @@ U64 LLDrawInfo::getSkinHash() return mSkinInfo ? mSkinInfo->mHash : 0; } -LLVertexBuffer* LLGeometryManager::createVertexBuffer(U32 type_mask, U32 usage) -{ - return new LLVertexBuffer(type_mask, usage); -} - LLCullResult::LLCullResult() { mVisibleGroupsAllocated = 0; diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index b765bd1632..bc0eabfa0e 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -56,9 +56,15 @@ class LLSpatialGroup; class LLViewerRegion; class LLReflectionMap; -void pushVerts(LLFace* face, U32 mask); +void pushVerts(LLFace* face); -class LLDrawInfo : public LLRefCount +/* + Class that represents a single Draw Call + + Make every effort to keep size minimal. + Member ordering is important for cache coherency +*/ +class LLDrawInfo final : public LLRefCount { LL_ALIGN_NEW; protected: @@ -75,11 +81,13 @@ public: LL_ERRS() << "Illegal operation!" << LL_ENDL; return *this; } + + // return a hash of this LLDrawInfo as a debug color + LLColor4U getDebugColor() const; LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, - LLViewerTexture* image, LLVertexBuffer* buffer, - bool selected, - BOOL fullbright = FALSE, U8 bump = 0, BOOL particle = FALSE, F32 part_size = 0); + LLViewerTexture* image, LLVertexBuffer* buffer, + bool fullbright = false, U8 bump = 0); void validate(); @@ -88,54 +96,46 @@ public: U64 getSkinHash(); LLPointer mVertexBuffer; + U16 mStart = 0; + U16 mEnd = 0; + U32 mCount = 0; + U32 mOffset = 0; + LLPointer mTexture; - std::vector > mTextureList; + LLPointer mSpecularMap; + LLPointer mNormalMap; - // virtual size of mTexture and mTextureList textures - // used to update the decode priority of textures in this DrawInfo - std::vector mTextureListVSize; - - const LLMatrix4* mTextureMatrix; - const LLMatrix4* mModelMatrix; - U16 mStart; - U16 mEnd; - U32 mCount; - U32 mOffset; - BOOL mFullbright; - U8 mBump; - U8 mShiny; - U8 mTextureTimer = 1; - BOOL mParticle; - F32 mPartSize; - F32 mVSize; - LLSpatialGroup* mGroup; - LL_ALIGN_16(LLFace* mFace); //associated face - F32 mDistance; - S32 mDebugColor; + const LLMatrix4* mSpecularMapMatrix = nullptr; + const LLMatrix4* mNormalMapMatrix = nullptr; + const LLMatrix4* mTextureMatrix = nullptr; + const LLMatrix4* mModelMatrix = nullptr; + + LLPointer mAvatar = nullptr; + LLMeshSkinInfo* mSkinInfo = nullptr; // Material pointer here is likely for debugging only and are immaterial (zing!) - LLMaterialPtr mMaterial; - + LLPointer mMaterial; + // PBR material parameters LLPointer mGLTFMaterial; - + + LLVector4 mSpecColor = LLVector4(1.f, 1.f, 1.f, 0.5f); // XYZ = Specular RGB, W = Specular Exponent + + std::vector > mTextureList; + LLUUID mMaterialID; // id of LLGLTFMaterial or LLMaterial applied to this draw info - U32 mShaderMask; - U32 mBlendFuncSrc; - U32 mBlendFuncDst; - BOOL mHasGlow; - LLPointer mSpecularMap; - const LLMatrix4* mSpecularMapMatrix; - LLPointer mNormalMap; - const LLMatrix4* mNormalMapMatrix; - - LLVector4 mSpecColor; // XYZ = Specular RGB, W = Specular Exponent - F32 mEnvIntensity; - F32 mAlphaMaskCutoff; - U8 mDiffuseAlphaMode; - LLPointer mAvatar = nullptr; - LLMeshSkinInfo* mSkinInfo = nullptr; + U32 mShaderMask = 0; + F32 mEnvIntensity = 0.f; + F32 mAlphaMaskCutoff = 0.5f; + + LLRender::eBlendFactor mBlendFuncSrc = LLRender::BF_SOURCE_ALPHA; + LLRender::eBlendFactor mBlendFuncDst = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; + U8 mDiffuseAlphaMode = 0; + U8 mBump = 0; + U8 mShiny = 0; + bool mFullbright = false; + bool mHasGlow = false; struct CompareTexture { @@ -196,19 +196,9 @@ public: && (lhs.isNull() || (rhs.notNull() && lhs->mBump > rhs->mBump)); } }; - - struct CompareDistanceGreater - { - bool operator()(const LLPointer& lhs, const LLPointer& rhs) - { - // sort by mBump value, sort NULL down to the end - return lhs.get() != rhs.get() - && (lhs.isNull() || (rhs.notNull() && lhs->mDistance > rhs->mDistance)); - } - }; }; -LL_ALIGN_PREFIX(64) +LL_ALIGN_PREFIX(16) class LLSpatialGroup : public LLOcclusionCullingGroup { friend class LLSpatialPartition; @@ -227,7 +217,7 @@ public: } static U32 sNodeCount; - static BOOL sNoDelete; //deletion of spatial groups and draw info not allowed if TRUE + static bool sNoDelete; //deletion of spatial groups and draw info not allowed if TRUE typedef std::vector > sg_vector_t; typedef std::vector > bridge_list_t; @@ -343,25 +333,21 @@ public: LL_ALIGN_16(LLVector4a mViewAngle); LL_ALIGN_16(LLVector4a mLastUpdateViewAngle); - F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3() - protected: virtual ~LLSpatialGroup(); public: + LLPointer mVertexBuffer; + draw_map_t mDrawMap; + bridge_list_t mBridgeList; buffer_map_t mBufferMap; //used by volume buffers to attempt to reuse vertex buffers + F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3() U32 mGeometryBytes; //used by volumes to track how many bytes of geometry data are in this node F32 mSurfaceArea; //used by volumes to track estimated surface area of geometry in this node - F32 mBuilt; - LLPointer mVertexBuffer; - - U32 mBufferUsage; - draw_map_t mDrawMap; - F32 mDistance; F32 mDepth; F32 mLastUpdateDistance; @@ -375,8 +361,7 @@ public: U32 mRenderOrder = 0; // Reflection Probe associated with this node (if any) LLPointer mReflectionProbe = nullptr; - -} LL_ALIGN_POSTFIX(64); +} LL_ALIGN_POSTFIX(16); class LLGeometryManager { @@ -387,14 +372,12 @@ public: virtual void rebuildMesh(LLSpatialGroup* group) = 0; virtual void getGeometry(LLSpatialGroup* group) = 0; virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32 &index_count); - - virtual LLVertexBuffer* createVertexBuffer(U32 type_mask, U32 usage); }; class LLSpatialPartition: public LLViewerOctreePartition, public LLGeometryManager { public: - LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 mBufferUsage, LLViewerRegion* regionp); + LLSpatialPartition(U32 data_mask, BOOL render_by_group, LLViewerRegion* regionp); virtual ~LLSpatialPartition(); LLSpatialGroup *put(LLDrawable *drawablep, BOOL was_visible = FALSE); @@ -445,14 +428,13 @@ public: // use a pointer instead of making "isBridge" and "asBridge" virtual so it's safe // to call asBridge() from the destructor - BOOL mInfiniteFarClip; // if TRUE, frustum culling ignores far clip plane - U32 mBufferUsage; - const BOOL mRenderByGroup; + bool mInfiniteFarClip; // if TRUE, frustum culling ignores far clip plane + const bool mRenderByGroup; U32 mVertexDataMask; F32 mSlopRatio; //percentage distance must change before drawables receive LOD update (default is 0.25); - BOOL mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering + bool mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering - static BOOL sTeleportRequested; //started to issue a teleport request + static bool sTeleportRequested; //started to issue a teleport request }; // class for creating bridges between spatial partitions @@ -631,7 +613,6 @@ class LLTerrainPartition : public LLSpatialPartition public: LLTerrainPartition(LLViewerRegion* regionp); virtual void getGeometry(LLSpatialGroup* group); - virtual LLVertexBuffer* createVertexBuffer(U32 type_mask, U32 usage); }; //spatial partition for trees diff --git a/indra/newview/llsprite.cpp b/indra/newview/llsprite.cpp index 0cdad86a76..b641afc1ef 100644 --- a/indra/newview/llsprite.cpp +++ b/indra/newview/llsprite.cpp @@ -189,9 +189,8 @@ void LLSprite::updateFace(LLFace &face) if (!face.getVertexBuffer()) { LLVertexBuffer* buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0, - GL_STREAM_DRAW); - buff->allocateBuffer(4, 12, TRUE); + LLVertexBuffer::MAP_TEXCOORD0 ); + buff->allocateBuffer(4, 12); face.setGeomIndex(0); face.setIndicesIndex(0); face.setVertexBuffer(buff); @@ -243,7 +242,7 @@ void LLSprite::updateFace(LLFace &face) *indicesp++ = 3 + index_offset; } - face.getVertexBuffer()->flush(); + face.getVertexBuffer()->unmapBuffer(); face.mCenterAgent = mPosition; } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 76b7347b21..0019038c76 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1559,12 +1559,10 @@ bool idle_startup() LL_DEBUGS("AppInit") << "Initializing sky..." << LL_ENDL; // Initialize all of the viewer object classes for the first time (doing things like texture fetches. LLGLState::checkStates(); - LLGLState::checkTextureChannels(); gSky.init(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); display_startup(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index d1a89a5846..5af03477d6 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -148,7 +148,6 @@ void display_startup() static S32 frame_count = 0; LLGLState::checkStates(); - LLGLState::checkTextureChannels(); if (frame_count++ > 1) // make sure we have rendered a frame first { @@ -160,7 +159,6 @@ void display_startup() } LLGLState::checkStates(); - LLGLState::checkTextureChannels(); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); // | GL_STENCIL_BUFFER_BIT); LLGLSUIDefault gls_ui; @@ -168,7 +166,6 @@ void display_startup() if (gViewerWindow) gViewerWindow->setup2DRender(); - gGL.color4f(1,1,1,1); if (gViewerWindow) gViewerWindow->draw(); gGL.flush(); @@ -176,7 +173,6 @@ void display_startup() LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); if (gViewerWindow && gViewerWindow->getWindow()) gViewerWindow->getWindow()->swapBuffers(); @@ -282,7 +278,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); stop_glerror(); @@ -324,7 +319,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:CheckStates"); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); ////////////////////////////////////////////////////////// // @@ -681,7 +675,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gDepthDirty = FALSE; LLGLState::checkStates(); - LLGLState::checkTextureChannels(); static LLCullResult result; LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; @@ -690,7 +683,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) stop_glerror(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); LLAppViewer::instance()->pingMainloopTimeout("Display:Swap"); @@ -706,7 +698,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) glClearColor(0,0,0,0); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); if (!for_snapshot) { @@ -719,7 +710,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); glh::matrix4f proj = get_current_projection(); glh::matrix4f mod = get_current_modelview(); @@ -736,10 +726,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gViewerWindow->setup3DViewport(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - } - glClear(GL_DEPTH_BUFFER_BIT); // | GL_STENCIL_BUFFER_BIT); + glClear(GL_DEPTH_BUFFER_BIT); } ////////////////////////////////////// @@ -925,19 +913,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } gOcclusionProgram.unbind(); - } - - gGL.setColorMask(true, false); - if (LLPipeline::sRenderDeferred) - { - gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance(), true); } - else - { - gPipeline.renderGeom(*LLViewerCamera::getInstance(), TRUE); - } + gGL.setColorMask(true, true); + gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance(), true); //store this frame's modelview matrix for use //when rendering next frame's occlusion queries @@ -1099,14 +1079,10 @@ void display_cube_face() } gPipeline.mRT->deferredScreen.clear(); - gGL.setColorMask(true, false); - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance()); - gGL.setColorMask(true, true); - gPipeline.mRT->deferredScreen.flush(); gPipeline.renderDeferredLighting(); @@ -1340,9 +1316,12 @@ void render_ui(F32 zoom_factor, int subfield) } { + LLGLState::checkStates(); + // Render our post process prior to the HUD, UI, etc. gPipeline.renderPostProcess(); + LLGLState::checkStates(); // draw hud and 3D ui elements into screen render target so they'll be able to use // the depth buffer (avoids extra copy of depth buffer per frame) gPipeline.screenTarget()->bindTarget(); @@ -1354,6 +1333,7 @@ void render_ui(F32 zoom_factor, int subfield) // 3. Use transient zones LL_PROFILE_ZONE_NAMED_CATEGORY_UI("HUD"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_HUD); render_hud_elements(); + LLGLState::checkStates(); render_hud_attachments(); LLGLState::checkStates(); @@ -1364,8 +1344,6 @@ void render_ui(F32 zoom_factor, int subfield) gPipeline.disableLights(); } - gGL.color4f(1,1,1,1); - bool render_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI); if (render_ui) { @@ -1507,6 +1485,7 @@ void render_ui_3d() stop_glerror(); gUIProgram.bind(); + gGL.color4f(1, 1, 1, 1); // Coordinate axes if (gSavedSettings.getBOOL("ShowAxes")) diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index f3b0e82b3a..be2a1da968 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -1,4 +1,4 @@ -/** + /** * @file llviewerjointmesh.cpp * @brief Implementation of LLViewerJointMesh class * @@ -62,10 +62,6 @@ extern PFNGLWEIGHTFVARBPROC glWeightfvARB; extern PFNGLVERTEXBLENDARBPROC glVertexBlendARB; #endif -static const U32 sRenderMask = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_NORMAL | - LLVertexBuffer::MAP_TEXCOORD0; - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // LLViewerJointMesh @@ -287,8 +283,6 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) gGL.getTexUnit(diffuse_channel)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT)); } - U32 mask = sRenderMask; - U32 start = mMesh->mFaceVertexOffset; U32 end = start + mMesh->mFaceVertexCount - 1; U32 count = mMesh->mFaceIndexCount; @@ -304,14 +298,9 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) { uploadJointMatrices(); } - mask = mask | LLVertexBuffer::MAP_WEIGHT; - if (mFace->getPool()->getShaderLevel() > 1) - { - mask = mask | LLVertexBuffer::MAP_CLOTHWEIGHT; - } } - buff->setBuffer(mask); + buff->setBuffer(); buff->drawRange(LLRender::TRIANGLES, start, end, count, offset); } else @@ -319,7 +308,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) gGL.pushMatrix(); LLMatrix4 jointToWorld = getWorldMatrix(); gGL.multMatrix((GLfloat*)jointToWorld.mMatrix); - buff->setBuffer(mask); + buff->setBuffer(); buff->drawRange(LLRender::TRIANGLES, start, end, count, offset); gGL.popMatrix(); } @@ -506,7 +495,7 @@ void LLViewerJointMesh::updateGeometry(LLFace *mFace, LLPolyMesh *mMesh) } } - buffer->flush(); + buffer->unmapBuffer(); } void LLViewerJointMesh::updateJointGeometry() diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 2bd0de4d6c..f416080f9e 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5477,6 +5477,7 @@ S32 LLViewerObject::setTERotation(const U8 te, const F32 r) if (mDrawable.notNull() && retval) { gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD); + shrinkWrap(); } return retval; } @@ -6865,7 +6866,7 @@ F32 LLAlphaObject::getPartSize(S32 idx) return 0.f; } -void LLAlphaObject::getBlendFunc(S32 face, U32& src, U32& dst) +void LLAlphaObject::getBlendFunc(S32 face, LLRender::eBlendFactor& src, LLRender::eBlendFactor& dst) { } @@ -7278,6 +7279,18 @@ void LLViewerObject::setRenderMaterialIDs(const LLRenderMaterialParams* material } } +void LLViewerObject::shrinkWrap() +{ + if (!mShouldShrinkWrap) + { + mShouldShrinkWrap = true; + if (mDrawable) + { // we weren't shrink wrapped before but we are now, update the spatial partition + gPipeline.markPartitionMove(mDrawable); + } + } +} + class ObjectPhysicsProperties : public LLHTTPNode { public: diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 71d7a7ebbb..fae29c3bc2 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -602,6 +602,14 @@ public: virtual void parameterChanged(U16 param_type, bool local_origin); virtual void parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_use, bool local_origin); + bool isShrinkWrapped() const { return mShouldShrinkWrap; } + + // Used to improve performance. If an object is likely to rebuild its vertex buffer often + // as a side effect of some update (color update, scale, etc), setting this to true + // will cause it to be pushed deeper into the octree and isolate it from other nodes + // so that nearby objects won't attempt to share a vertex buffer with this object. + void shrinkWrap(); + friend class LLViewerObjectList; friend class LLViewerMediaList; @@ -866,6 +874,9 @@ protected: F32 mPhysicsCost; F32 mLinksetPhysicsCost; + // If true, "shrink wrap" this volume in its spatial partition. See "shrinkWrap" + bool mShouldShrinkWrap = false; + bool mCostStale; mutable bool mPhysicsShapeUnknown; @@ -978,7 +989,7 @@ public: LLStrider& emissivep, LLStrider& indicesp) = 0; - virtual void getBlendFunc(S32 face, U32& src, U32& dst); + virtual void getBlendFunc(S32 face, LLRender::eBlendFactor& src, LLRender::eBlendFactor& dst); F32 mDepth; }; diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 1f16161780..7d6c18ae67 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -103,11 +103,11 @@ U8* get_box_fan_indices_ptr(LLCamera* camera, const LLVector4a& center) } //create a vertex buffer for efficiently rendering cubes -LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage) +LLVertexBuffer* ll_create_cube_vb(U32 type_mask) { - LLVertexBuffer* ret = new LLVertexBuffer(type_mask, usage); + LLVertexBuffer* ret = new LLVertexBuffer(type_mask); - ret->allocateBuffer(8, 64, true); + ret->allocateBuffer(8, 64); LLStrider pos; LLStrider idx; @@ -129,7 +129,7 @@ LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage) idx[i] = sOcclusionIndices[i]; } - ret->flush(); + ret->unmapBuffer(); return ret; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 5d79c8e6b2..ebc6df22ac 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -192,7 +192,6 @@ LLGLSLShader gDeferredUnderWaterProgram; LLGLSLShader gDeferredDiffuseProgram; LLGLSLShader gDeferredDiffuseAlphaMaskProgram; LLGLSLShader gDeferredSkinnedDiffuseAlphaMaskProgram; -LLGLSLShader gDeferredNonIndexedDiffuseProgram; LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskProgram; LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram; LLGLSLShader gDeferredSkinnedDiffuseProgram; @@ -435,6 +434,7 @@ S32 LLViewerShaderMgr::getShaderLevel(S32 type) void LLViewerShaderMgr::setShaders() { + LL_PROFILE_ZONE_SCOPED; //setShaders might be called redundantly by gSavedSettings, so return on reentrance static bool reentrance = false; @@ -792,7 +792,6 @@ void LLViewerShaderMgr::unloadShaders() gDeferredSkinnedDiffuseAlphaMaskProgram.unload(); gDeferredNonIndexedDiffuseAlphaMaskProgram.unload(); gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.unload(); - gDeferredNonIndexedDiffuseProgram.unload(); gDeferredSkinnedDiffuseProgram.unload(); gDeferredSkinnedBumpProgram.unload(); @@ -969,6 +968,7 @@ std::string LLViewerShaderMgr::loadBasicShaders() BOOL LLViewerShaderMgr::loadShadersEnvironment() { + LL_PROFILE_ZONE_SCOPED; #if 1 // DEPRECATED -- forward rendering is deprecated BOOL success = TRUE; @@ -1039,6 +1039,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() BOOL LLViewerShaderMgr::loadShadersWater() { + LL_PROFILE_ZONE_SCOPED; #if 1 // DEPRECATED -- forward rendering is deprecated BOOL success = TRUE; BOOL terrainWaterSuccess = TRUE; @@ -1179,6 +1180,7 @@ BOOL LLViewerShaderMgr::loadShadersWater() BOOL LLViewerShaderMgr::loadShadersEffects() { + LL_PROFILE_ZONE_SCOPED; BOOL success = TRUE; if (mShaderLevel[SHADER_EFFECT] == 0) @@ -1224,6 +1226,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() BOOL LLViewerShaderMgr::loadShadersDeferred() { + LL_PROFILE_ZONE_SCOPED; bool use_sun_shadow = mShaderLevel[SHADER_DEFERRED] > 1 && gSavedSettings.getS32("RenderShadowDetail") > 0; @@ -1237,14 +1240,13 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredTreeShadowProgram.unload(); gDeferredSkinnedTreeShadowProgram.unload(); gDeferredDiffuseProgram.unload(); + gDeferredSkinnedDiffuseProgram.unload(); gDeferredDiffuseAlphaMaskProgram.unload(); gDeferredSkinnedDiffuseAlphaMaskProgram.unload(); gDeferredNonIndexedDiffuseAlphaMaskProgram.unload(); gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.unload(); - gDeferredNonIndexedDiffuseProgram.unload(); - gDeferredSkinnedDiffuseProgram.unload(); - gDeferredSkinnedBumpProgram.unload(); gDeferredBumpProgram.unload(); + gDeferredSkinnedBumpProgram.unload(); gDeferredImpostorProgram.unload(); gDeferredTerrainProgram.unload(); gDeferredTerrainWaterProgram.unload(); @@ -1410,19 +1412,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() llassert(success); } - if (success) - { - gDeferredNonIndexedDiffuseProgram.mName = "Non Indexed Deferred Diffuse Shader"; - gDeferredNonIndexedDiffuseProgram.mShaderFiles.clear(); - gDeferredNonIndexedDiffuseProgram.mFeatures.encodesNormal = true; - gDeferredNonIndexedDiffuseProgram.mFeatures.hasSrgb = true; - gDeferredNonIndexedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER)); - gDeferredNonIndexedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER)); - gDeferredNonIndexedDiffuseProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - success = gDeferredNonIndexedDiffuseProgram.createShader(NULL, NULL); - llassert(success); - } - if (success) { gDeferredBumpProgram.mName = "Deferred Bump Shader"; @@ -2961,6 +2950,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() BOOL LLViewerShaderMgr::loadShadersObject() { + LL_PROFILE_ZONE_SCOPED; BOOL success = TRUE; if (success) @@ -3487,6 +3477,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() BOOL LLViewerShaderMgr::loadShadersAvatar() { + LL_PROFILE_ZONE_SCOPED; #if 1 // DEPRECATED -- forward rendering is deprecated BOOL success = TRUE; @@ -3585,6 +3576,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() BOOL LLViewerShaderMgr::loadShadersInterface() { + LL_PROFILE_ZONE_SCOPED; BOOL success = TRUE; if (success) @@ -3964,6 +3956,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() BOOL LLViewerShaderMgr::loadShadersWindLight() { + LL_PROFILE_ZONE_SCOPED; BOOL success = TRUE; #if 1 // DEPRECATED -- forward rendering is deprecated if (mShaderLevel[SHADER_WINDLIGHT] < 2) diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index c295bc76c0..721498572f 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1018,7 +1018,7 @@ LLViewerFetchedTexture* LLViewerFetchedTexture::getSmokeImage() sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE); } - gPipeline.touchTexture(sSmokeImagep, 1024.f * 1024.f); + sSmokeImagep->addTextureStats(1024.f * 1024.f); return sSmokeImagep; } diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 1b9154a158..312bc31faa 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -861,6 +861,14 @@ void LLViewerTextureList::clearFetchingRequests() } } +static void touch_texture(LLViewerFetchedTexture* tex, F32 vsize) +{ + if (tex) + { + tex->addTextureStats(vsize); + } +} + void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep) { if (imagep->isInDebug() || imagep->isUnremovable()) @@ -869,6 +877,39 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag return; //is in debug, ignore. } + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE + { + for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) + { + for (U32 fi = 0; fi < imagep->getNumFaces(i); ++fi) + { + const LLFace* face = (*(imagep->getFaceList(i)))[fi]; + + if (face && face->getViewerObject() && face->getTextureEntry()) + { + F32 vsize = face->getVirtualSize(); + + // if a GLTF material is present, ignore that face + // as far as this texture stats go, but update the GLTF material + // stats + const LLTextureEntry* te = face->getTextureEntry(); + LLFetchedGLTFMaterial* mat = te ? (LLFetchedGLTFMaterial*)te->getGLTFRenderMaterial() : nullptr; + if (mat) + { + touch_texture(mat->mBaseColorTexture, vsize); + touch_texture(mat->mNormalTexture, vsize); + touch_texture(mat->mMetallicRoughnessTexture, vsize); + touch_texture(mat->mEmissiveTexture, vsize); + } + else + { + imagep->addTextureStats(vsize); + } + } + } + } + } + F32 lazy_flush_timeout = 30.f; // stop decoding F32 max_inactive_time = 20.f; // actually delete S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 5848cbfd9d..bccb2a5e77 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -658,18 +658,6 @@ public: } - addText(xpos, ypos, llformat("%d Vertex Buffers", LLVertexBuffer::sGLCount)); - ypos += y_inc; - - addText(xpos, ypos, llformat("%d Mapped Buffers", LLVertexBuffer::sMappedCount)); - ypos += y_inc; - - addText(xpos, ypos, llformat("%d Vertex Buffer Binds", LLVertexBuffer::sBindCount)); - ypos += y_inc; - - addText(xpos, ypos, llformat("%d Vertex Buffer Sets", LLVertexBuffer::sSetCount)); - ypos += y_inc; - addText(xpos, ypos, llformat("%d Texture Binds", LLImageGL::sBindCount)); ypos += y_inc; @@ -744,9 +732,7 @@ public: ypos += y_inc; } - LLVertexBuffer::sBindCount = LLImageGL::sBindCount = - LLVertexBuffer::sSetCount = LLImageGL::sUniqueCount = - gPipeline.mNumVisibleNodes = LLPipeline::sVisibleLightCount = 0; + gPipeline.mNumVisibleNodes = LLPipeline::sVisibleLightCount = 0; } if (gSavedSettings.getBOOL("DebugShowAvatarRenderInfo")) { @@ -2641,10 +2627,10 @@ void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid) void LLViewerWindow::drawDebugText() { + gUIProgram.bind(); gGL.color4f(1,1,1,1); gGL.pushMatrix(); gGL.pushUIMatrix(); - gUIProgram.bind(); { // scale view by UI global scale factor and aspect ratio correction factor gGL.scaleUI(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f); @@ -2701,6 +2687,7 @@ void LLViewerWindow::draw() // No translation needed, this view is glued to 0,0 gUIProgram.bind(); + gGL.color4f(1, 1, 1, 1); gGL.pushMatrix(); LLUI::pushMatrix(); @@ -5688,7 +5675,6 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) gSky.restoreGL(); gPipeline.restoreGL(); - LLDrawPoolWater::restoreGL(); LLManipTranslate::restoreGL(); gBumpImageList.restoreGL(); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index ee12019da2..05fac036fb 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2348,15 +2348,15 @@ void LLVOAvatar::updateMeshData() LLVertexBuffer* buff = facep->getVertexBuffer(); if(!facep->getVertexBuffer()) { - buff = new LLVertexBufferAvatar(); - if (!buff->allocateBuffer(num_vertices, num_indices, TRUE)) + buff = new LLVertexBuffer(LLDrawPoolAvatar::VERTEX_DATA_MASK); + if (!buff->allocateBuffer(num_vertices, num_indices)) { LL_WARNS() << "Failed to allocate Vertex Buffer for Mesh to " << num_vertices << " vertices and " << num_indices << " indices" << LL_ENDL; // Attempt to create a dummy triangle (one vertex, 3 indices, all 0) facep->setSize(1, 3); - buff->allocateBuffer(1, 3, true); + buff->allocateBuffer(1, 3); memset((U8*) buff->getMappedData(), 0, buff->getSize()); memset((U8*) buff->getMappedIndices(), 0, buff->getIndicesSize()); } @@ -2371,12 +2371,13 @@ void LLVOAvatar::updateMeshData() } else { - if (!buff->resizeBuffer(num_vertices, num_indices)) - { + buff = new LLVertexBuffer(buff->getTypeMask()); + if (!buff->allocateBuffer(num_vertices, num_indices)) + { LL_WARNS() << "Failed to allocate vertex buffer for Mesh, Substituting" << LL_ENDL; // Attempt to create a dummy triangle (one vertex, 3 indices, all 0) facep->setSize(1, 3); - buff->resizeBuffer(1, 3); + buff->allocateBuffer(1, 3); memset((U8*) buff->getMappedData(), 0, buff->getSize()); memset((U8*) buff->getMappedIndices(), 0, buff->getIndicesSize()); } @@ -2413,7 +2414,7 @@ void LLVOAvatar::updateMeshData() } stop_glerror(); - buff->flush(); + buff->unmapBuffer(); if(!f_num) { @@ -5039,7 +5040,7 @@ U32 LLVOAvatar::renderSkinned() LLVertexBuffer* vb = face->getVertexBuffer(); if (vb) { - vb->flush(); + vb->unmapBuffer(); } } } diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index b4b2db5d51..56faab92c5 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -594,7 +594,7 @@ U32 LLVOGrass::getPartitionType() const } LLGrassPartition::LLGrassPartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW, regionp) +: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, regionp) { mDrawableType = LLPipeline::RENDER_TYPE_GRASS; mPartitionType = LLViewerRegion::PARTITION_GRASS; @@ -602,13 +602,10 @@ LLGrassPartition::LLGrassPartition(LLViewerRegion* regionp) mDepthMask = TRUE; mSlopRatio = 0.1f; mRenderPass = LLRenderPass::PASS_GRASS; - mBufferUsage = GL_DYNAMIC_DRAW; } void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count, U32& index_count) { - group->mBufferUsage = mBufferUsage; - mFaceList.clear(); LLViewerCamera* camera = LLViewerCamera::getInstance(); @@ -624,11 +621,6 @@ void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count LLAlphaObject* obj = (LLAlphaObject*) drawablep->getVObj().get(); obj->mDepth = 0.f; - if (drawablep->isAnimating()) - { - group->mBufferUsage = GL_STREAM_DRAW; - } - U32 count = 0; for (S32 j = 0; j < drawablep->getNumFaces(); ++j) { @@ -707,8 +699,7 @@ void LLGrassPartition::getGeometry(LLSpatialGroup* group) S32 idx = draw_vec.size()-1; - BOOL fullbright = facep->isState(LLFace::FULLBRIGHT); - F32 vsize = facep->getVirtualSize(); + bool fullbright = facep->isState(LLFace::FULLBRIGHT); if (idx >= 0 && draw_vec[idx]->mEnd == facep->getGeomIndex()-1 && draw_vec[idx]->mTexture == facep->getTexture() && @@ -719,7 +710,6 @@ void LLGrassPartition::getGeometry(LLSpatialGroup* group) { draw_vec[idx]->mCount += facep->getIndicesCount(); draw_vec[idx]->mEnd += facep->getGeomCount(); - draw_vec[idx]->mVSize = llmax(draw_vec[idx]->mVSize, vsize); } else { @@ -731,14 +721,13 @@ void LLGrassPartition::getGeometry(LLSpatialGroup* group) //facep->getTexture(), buffer, object->isSelected(), fullbright); - info->mVSize = vsize; draw_vec.push_back(info); //for alpha sorting facep->setDrawInfo(info); } } - buffer->flush(); + buffer->unmapBuffer(); mFaceList.clear(); } diff --git a/indra/newview/llvoground.cpp b/indra/newview/llvoground.cpp index 28bd5a3c97..c2f7d4fef6 100644 --- a/indra/newview/llvoground.cpp +++ b/indra/newview/llvoground.cpp @@ -93,8 +93,8 @@ BOOL LLVOGround::updateGeometry(LLDrawable *drawable) if (!face->getVertexBuffer()) { face->setSize(5, 12); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolGround::VERTEX_DATA_MASK, GL_STREAM_DRAW); - if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolGround::VERTEX_DATA_MASK); + if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount())) { LL_WARNS() << "Failed to allocate Vertex Buffer for VOGround to " << face->getGeomCount() << " vertices and " @@ -160,7 +160,7 @@ BOOL LLVOGround::updateGeometry(LLDrawable *drawable) *(texCoordsp++) = LLVector2(0.f, 1.f); *(texCoordsp++) = LLVector2(0.5f, 0.5f); - face->getVertexBuffer()->flush(); + face->getVertexBuffer()->unmapBuffer(); LLPipeline::sCompiles++; return TRUE; } diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index a5c65d6ed4..ac302ef421 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -46,18 +46,8 @@ extern U64MicrosecondsImplicit gFrameTime; -LLPointer LLVOPartGroup::sVB = NULL; -S32 LLVOPartGroup::sVBSlotFree[]; -S32* LLVOPartGroup::sVBSlotCursor = NULL; - void LLVOPartGroup::initClass() { - for (S32 i = 0; i < LL_MAX_PARTICLE_COUNT; ++i) - { - sVBSlotFree[i] = i; - } - - sVBSlotCursor = sVBSlotFree; } //static @@ -65,9 +55,10 @@ void LLVOPartGroup::restoreGL() { //TODO: optimize out binormal mask here. Specular and normal coords as well. - sVB = new LLVertexBuffer(VERTEX_DATA_MASK | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2, GL_STREAM_DRAW); +#if 0 + sVB = new LLVertexBuffer(VERTEX_DATA_MASK | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2); U32 count = LL_MAX_PARTICLE_COUNT; - if (!sVB->allocateBuffer(count*4, count*6, true)) + if (!sVB->allocateBuffer(count*4, count*6)) { LL_WARNS() << "Failed to allocate Vertex Buffer to " << count*4 << " vertices and " @@ -117,27 +108,14 @@ void LLVOPartGroup::restoreGL() *texcoordsp++ = LLVector2(1.f, 0.f); } - sVB->flush(); + sVB->unmapBuffer(); +#endif } //static void LLVOPartGroup::destroyGL() { - sVB = NULL; -} - -//static -S32 LLVOPartGroup::findAvailableVBSlot() -{ - if (sVBSlotCursor >= sVBSlotFree + LL_MAX_PARTICLE_COUNT) - { //no more available slots - return -1; - } - - S32 ret = *sVBSlotCursor; - sVBSlotCursor++; - return ret; } bool ll_is_part_idx_allocated(S32 idx, S32* start, S32* end) @@ -155,20 +133,6 @@ bool ll_is_part_idx_allocated(S32 idx, S32* start, S32* end) return false; } -//static -void LLVOPartGroup::freeVBSlot(S32 idx) -{ - llassert(idx < LL_MAX_PARTICLE_COUNT && idx >= 0); - //llassert(sVBSlotCursor > sVBSlotFree); - //llassert(ll_is_part_idx_allocated(idx, sVBSlotCursor, sVBSlotFree+LL_MAX_PARTICLE_COUNT)); - - if (sVBSlotCursor > sVBSlotFree) - { - sVBSlotCursor--; - *sVBSlotCursor = idx; - } -} - LLVOPartGroup::LLVOPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) : LLAlphaObject(id, pcode, regionp), mViewerPartGroupp(NULL) @@ -291,13 +255,13 @@ F32 LLVOPartGroup::getPartSize(S32 idx) return 0.f; } -void LLVOPartGroup::getBlendFunc(S32 idx, U32& src, U32& dst) +void LLVOPartGroup::getBlendFunc(S32 idx, LLRender::eBlendFactor& src, LLRender::eBlendFactor& dst) { if (idx < (S32) mViewerPartGroupp->mParticles.size()) { LLViewerPart* part = mViewerPartGroupp->mParticles[idx]; - src = part->mBlendFuncSource; - dst = part->mBlendFuncDest; + src = (LLRender::eBlendFactor) part->mBlendFuncSource; + dst = (LLRender::eBlendFactor) part->mBlendFuncDest; } } @@ -738,7 +702,7 @@ U32 LLVOPartGroup::getPartitionType() const } LLParticlePartition::LLParticlePartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW, regionp) +: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, regionp) { mRenderPass = LLRenderPass::PASS_ALPHA; mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES; @@ -758,32 +722,68 @@ void LLParticlePartition::rebuildGeom(LLSpatialGroup* group) { LL_PROFILE_ZONE_SCOPED; LL_PROFILE_GPU_ZONE("particle vbo"); - if (group->isDead() || !group->hasState(LLSpatialGroup::GEOM_DIRTY)) - { - return; - } + if (group->isDead() || !group->hasState(LLSpatialGroup::GEOM_DIRTY)) + { + return; + } - if (group->changeLOD()) - { - group->mLastUpdateDistance = group->mDistance; - group->mLastUpdateViewAngle = group->mViewAngle; - } - - group->clearDrawMap(); - - //get geometry count - U32 index_count = 0; - U32 vertex_count = 0; + if (group->changeLOD()) + { + group->mLastUpdateDistance = group->mDistance; + group->mLastUpdateViewAngle = group->mViewAngle; + } - addGeometryCount(group, vertex_count, index_count); - + group->clearDrawMap(); + + //get geometry count + U32 index_count = 0; + U32 vertex_count = 0; + + addGeometryCount(group, vertex_count, index_count); - if (vertex_count > 0 && index_count > 0 && LLVOPartGroup::sVB) - { - group->mBuilt = 1.f; - //use one vertex buffer for all groups - group->mVertexBuffer = LLVOPartGroup::sVB; - getGeometry(group); + + if (vertex_count > 0 && index_count > 0) + { + group->mBuilt = 1.f; + if (group->mVertexBuffer.isNull() || + group->mVertexBuffer->getNumVerts() < vertex_count || group->mVertexBuffer->getNumIndices() < index_count) + { + group->mVertexBuffer = new LLVertexBuffer(LLVOPartGroup::VERTEX_DATA_MASK); + group->mVertexBuffer->allocateBuffer(vertex_count, index_count); + + // initialize index and texture coordinates only when buffer is reallocated + U16* indicesp = (U16*)group->mVertexBuffer->mapIndexBuffer(0, index_count); + + U16 geom_idx = 0; + for (U32 i = 0; i < index_count; i += 6) + { + *indicesp++ = geom_idx + 0; + *indicesp++ = geom_idx + 1; + *indicesp++ = geom_idx + 2; + + *indicesp++ = geom_idx + 1; + *indicesp++ = geom_idx + 3; + *indicesp++ = geom_idx + 2; + + geom_idx += 4; + } + + LLStrider texcoordsp; + + group->mVertexBuffer->getTexCoord0Strider(texcoordsp); + + for (U32 i = 0; i < vertex_count; i += 4) + { + *texcoordsp++ = LLVector2(0.f, 1.f); + *texcoordsp++ = LLVector2(0.f, 0.f); + *texcoordsp++ = LLVector2(1.f, 1.f); + *texcoordsp++ = LLVector2(1.f, 0.f); + } + + } + + + getGeometry(group); } else { @@ -797,8 +797,6 @@ void LLParticlePartition::rebuildGeom(LLSpatialGroup* group) void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count, U32& index_count) { - group->mBufferUsage = mBufferUsage; - mFaceList.clear(); LLViewerCamera* camera = LLViewerCamera::getInstance(); @@ -851,10 +849,8 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) LLVertexBuffer* buffer = group->mVertexBuffer; - LLStrider indicesp; LLStrider verticesp; LLStrider normalsp; - LLStrider texcoordsp; LLStrider colorsp; LLStrider emissivep; @@ -863,7 +859,9 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) buffer->getColorStrider(colorsp); buffer->getEmissiveStrider(emissivep); - + S32 geom_idx = 0; + S32 indices_idx = 0; + LLSpatialGroup::drawmap_elem_t& draw_vec = group->mDrawMap[mRenderPass]; for (std::vector::iterator i = mFaceList.begin(); i != mFaceList.end(); ++i) @@ -871,56 +869,44 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) LLFace* facep = *i; LLAlphaObject* object = (LLAlphaObject*) facep->getViewerObject(); - if (!facep->isState(LLFace::PARTICLE)) - { //set the indices of this face - S32 idx = LLVOPartGroup::findAvailableVBSlot(); - if (idx >= 0) - { - facep->setGeomIndex(idx*4); - facep->setIndicesIndex(idx*6); - facep->setVertexBuffer(LLVOPartGroup::sVB); - facep->setPoolType(LLDrawPool::POOL_ALPHA); - facep->setState(LLFace::PARTICLE); - } - else - { - continue; //out of space in particle buffer - } - } - - S32 geom_idx = (S32) facep->getGeomIndex(); + facep->setGeomIndex(geom_idx); + facep->setIndicesIndex(indices_idx); - LLStrider cur_idx = indicesp + facep->getIndicesStart(); LLStrider cur_vert = verticesp + geom_idx; LLStrider cur_norm = normalsp + geom_idx; - LLStrider cur_tc = texcoordsp + geom_idx; LLStrider cur_col = colorsp + geom_idx; LLStrider cur_glow = emissivep + geom_idx; + // not actually used + LLStrider cur_tc; + LLStrider cur_idx; + + + geom_idx += 4; + indices_idx += 6; + LLColor4U* start_glow = cur_glow.get(); object->getGeometry(facep->getTEOffset(), cur_vert, cur_norm, cur_tc, cur_col, cur_glow, cur_idx); - BOOL has_glow = FALSE; + bool has_glow = FALSE; if (cur_glow.get() != start_glow) { - has_glow = TRUE; + has_glow = true; } llassert(facep->getGeomCount() == 4); llassert(facep->getIndicesCount() == 6); - - + S32 idx = draw_vec.size()-1; - BOOL fullbright = facep->isState(LLFace::FULLBRIGHT); - F32 vsize = facep->getVirtualSize(); + bool fullbright = facep->isState(LLFace::FULLBRIGHT); bool batched = false; - U32 bf_src = LLRender::BF_SOURCE_ALPHA; - U32 bf_dst = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; + LLRender::eBlendFactor bf_src = LLRender::BF_SOURCE_ALPHA; + LLRender::eBlendFactor bf_dst = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; object->getBlendFunc(facep->getTEOffset(), bf_src, bf_dst); @@ -940,7 +926,6 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) batched = true; info->mCount += facep->getIndicesCount(); info->mEnd += facep->getGeomCount(); - info->mVSize = llmax(draw_vec[idx]->mVSize, vsize); } else if (draw_vec[idx]->mStart == facep->getGeomIndex()+facep->getGeomCount()+1) { @@ -948,12 +933,10 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) info->mCount += facep->getIndicesCount(); info->mStart -= facep->getGeomCount(); info->mOffset = facep->getIndicesStart(); - info->mVSize = llmax(draw_vec[idx]->mVSize, vsize); } } } - if (!batched) { U32 start = facep->getGeomIndex(); @@ -961,19 +944,18 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) U32 offset = facep->getIndicesStart(); U32 count = facep->getIndicesCount(); LLDrawInfo* info = new LLDrawInfo(start,end,count,offset,facep->getTexture(), - buffer, object->isSelected(), fullbright); + buffer, fullbright); - info->mVSize = vsize; info->mBlendFuncDst = bf_dst; info->mBlendFuncSrc = bf_src; info->mHasGlow = has_glow; - info->mParticle = TRUE; draw_vec.push_back(info); //for alpha sorting facep->setDrawInfo(info); } } + buffer->unmapBuffer(); mFaceList.clear(); } diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h index a45d381dfa..4d471134d4 100644 --- a/indra/newview/llvopartgroup.h +++ b/indra/newview/llvopartgroup.h @@ -40,16 +40,9 @@ class LLVOPartGroup : public LLAlphaObject { public: - //vertex buffer for holding all particles - static LLPointer sVB; - static S32 sVBSlotFree[LL_MAX_PARTICLE_COUNT]; - static S32 *sVBSlotCursor; - static void initClass(); static void restoreGL(); static void destroyGL(); - static S32 findAvailableVBSlot(); - static void freeVBSlot(S32 idx); enum { @@ -99,7 +92,7 @@ public: void updateFaceSize(S32 idx) { } F32 getPartSize(S32 idx); - void getBlendFunc(S32 idx, U32& src, U32& dst); + void getBlendFunc(S32 idx, LLRender::eBlendFactor& src, LLRender::eBlendFactor& dst); LLUUID getPartOwner(S32 idx); LLUUID getPartSource(S32 idx); diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index d5979b2280..59fcacf914 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -1010,8 +1010,8 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) face->setSize(4, 6); face->setGeomIndex(0); face->setIndicesIndex(0); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_STREAM_DRAW); - buff->allocateBuffer(4, 6, TRUE); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK); + buff->allocateBuffer(4, 6); face->setVertexBuffer(buff); index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); @@ -1046,7 +1046,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) *indicesp++ = index_offset + 3; *indicesp++ = index_offset + 2; - buff->flush(); + buff->unmapBuffer(); } } @@ -1139,8 +1139,8 @@ bool LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, F32 scale, const if (!facep->getVertexBuffer()) { facep->setSize(4, 6); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_STREAM_DRAW); - if (!buff->allocateBuffer(facep->getGeomCount(), facep->getIndicesCount(), TRUE)) + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK); + if (!buff->allocateBuffer(facep->getGeomCount(), facep->getIndicesCount())) { LL_WARNS() << "Failed to allocate Vertex Buffer for vosky to " << facep->getGeomCount() << " vertices and " @@ -1179,7 +1179,7 @@ bool LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, F32 scale, const *indicesp++ = index_offset + 2; *indicesp++ = index_offset + 3; - facep->getVertexBuffer()->flush(); + facep->getVertexBuffer()->unmapBuffer(); return TRUE; } @@ -1379,8 +1379,8 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, if (!face->getVertexBuffer() || quads*4 != face->getGeomCount()) { face->setSize(quads * 4, quads * 6); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW); - if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK); + if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount())) { LL_WARNS() << "Failed to allocate Vertex Buffer for vosky to " << face->getGeomCount() << " vertices and " @@ -1523,7 +1523,7 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, } } - face->getVertexBuffer()->flush(); + face->getVertexBuffer()->unmapBuffer(); } } diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 69ae3cf23b..067272ec44 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -45,26 +45,6 @@ F32 LLVOSurfacePatch::sLODFactor = 1.f; -//============================================================================ - -class LLVertexBufferTerrain : public LLVertexBuffer -{ -public: - LLVertexBufferTerrain() : - LLVertexBuffer(MAP_VERTEX | MAP_NORMAL | MAP_TEXCOORD0 | MAP_TEXCOORD1 | MAP_COLOR, GL_DYNAMIC_DRAW) - { - //texture coordinates 2 and 3 exist, but use the same data as texture coordinate 1 - }; - - // virtual - void setupVertexBuffer(U32 data_mask) - { - LLVertexBuffer::setupVertexBuffer(data_mask & ~(MAP_TEXCOORD2 | MAP_TEXCOORD3)); - } -}; - -//============================================================================ - LLVOSurfacePatch::LLVOSurfacePatch(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) : LLStaticViewerObject(id, pcode, regionp), mDirtiedPatch(FALSE), @@ -1001,7 +981,7 @@ U32 LLVOSurfacePatch::getPartitionType() const } LLTerrainPartition::LLTerrainPartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK, FALSE, GL_DYNAMIC_DRAW, regionp) +: LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK, FALSE, regionp) { mOcclusionEnabled = FALSE; mInfiniteFarClip = TRUE; @@ -1009,11 +989,6 @@ LLTerrainPartition::LLTerrainPartition(LLViewerRegion* regionp) mPartitionType = LLViewerRegion::PARTITION_TERRAIN; } -LLVertexBuffer* LLTerrainPartition::createVertexBuffer(U32 type_mask, U32 usage) -{ - return new LLVertexBufferTerrain(); -} - void LLTerrainPartition::getGeometry(LLSpatialGroup* group) { LL_PROFILE_ZONE_SCOPED; @@ -1051,7 +1026,7 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) index_offset += facep->getGeomCount(); } - buffer->flush(); + buffer->unmapBuffer(); mFaceList.clear(); } diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index b6f8d162ba..0da77e4f8b 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -538,8 +538,8 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable) max_vertices += sLODVertexCount[lod]; } - mReferenceBuffer = new LLVertexBuffer(LLDrawPoolTree::VERTEX_DATA_MASK, 0); - if (!mReferenceBuffer->allocateBuffer(max_vertices, max_indices, TRUE)) + mReferenceBuffer = new LLVertexBuffer(LLDrawPoolTree::VERTEX_DATA_MASK); + if (!mReferenceBuffer->allocateBuffer(max_vertices, max_indices)) { LL_WARNS() << "Failed to allocate Vertex Buffer on update to " << max_vertices << " vertices and " @@ -862,7 +862,7 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable) slices /= 2; } - mReferenceBuffer->flush(); + mReferenceBuffer->unmapBuffer(); llassert(vertex_count == max_vertices); llassert(index_count == max_indices); } @@ -921,19 +921,19 @@ void LLVOTree::updateMesh() LLFace* facep = mDrawable->getFace(0); if (!facep) return; - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolTree::VERTEX_DATA_MASK, GL_STATIC_DRAW); - if (!buff->allocateBuffer(vert_count, index_count, TRUE)) + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolTree::VERTEX_DATA_MASK); + if (!buff->allocateBuffer(vert_count, index_count)) { LL_WARNS() << "Failed to allocate Vertex Buffer on mesh update to " << vert_count << " vertices and " << index_count << " indices" << LL_ENDL; - buff->allocateBuffer(1, 3, true); + buff->allocateBuffer(1, 3); memset((U8*)buff->getMappedData(), 0, buff->getSize()); memset((U8*)buff->getMappedIndices(), 0, buff->getIndicesSize()); facep->setSize(1, 3); facep->setVertexBuffer(buff); - mReferenceBuffer->flush(); - buff->flush(); + mReferenceBuffer->unmapBuffer(); + buff->unmapBuffer(); return; } @@ -954,8 +954,8 @@ void LLVOTree::updateMesh() genBranchPipeline(vertices, normals, tex_coords, colors, indices, idx_offset, scale_mat, mTrunkLOD, stop_depth, mDepth, mTrunkDepth, 1.0, mTwist, droop, mBranches, alpha); - mReferenceBuffer->flush(); - buff->flush(); + mReferenceBuffer->unmapBuffer(); + buff->unmapBuffer(); } void LLVOTree::appendMesh(LLStrider& vertices, @@ -1226,7 +1226,7 @@ U32 LLVOTree::getPartitionType() const } LLTreePartition::LLTreePartition(LLViewerRegion* regionp) -: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW, regionp) +: LLSpatialPartition(0, FALSE, regionp) { mDrawableType = LLPipeline::RENDER_TYPE_TREE; mPartitionType = LLViewerRegion::PARTITION_TREE; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 53158ee66f..02d1654878 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -95,7 +95,6 @@ const F32 FORCE_CULL_AREA = 8.f; U32 JOINT_COUNT_REQUIRED_FOR_FULLRIG = 1; BOOL gAnimateTextures = TRUE; -//extern BOOL gHideSelectedObjects; F32 LLVOVolume::sLODFactor = 1.f; F32 LLVOVolume::sLODSlopDistanceFactor = 0.5f; //Changing this to zero, effectively disables the LOD transition slop @@ -526,6 +525,10 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, if (result & teDirtyBits) { updateTEData(); + if (mDrawable) + { //on the fly TE updates break batches, isolate in octree + shrinkWrap(); + } } if (result & TEM_CHANGE_MEDIA) { @@ -585,6 +588,7 @@ void LLVOVolume::animateTextures() { if (!mDead) { + shrinkWrap(); F32 off_s = 0.f, off_t = 0.f, scale_s = 1.f, scale_t = 1.f, rot = 0.f; S32 result = mTextureAnimp->animateTextures(off_s, off_t, scale_s, scale_t, rot); @@ -976,6 +980,11 @@ void LLVOVolume::setScale(const LLVector3 &scale, BOOL damped) //since drawable transforms do not include scale, changing volume scale //requires an immediate rebuild of volume verts. gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION, TRUE); + + if (mDrawable) + { + shrinkWrap(); + } } } @@ -2197,7 +2206,12 @@ S32 LLVOVolume::setTETexture(const U8 te, const LLUUID &uuid) S32 res = LLViewerObject::setTETexture(te, uuid); if (res) { - gPipeline.markTextured(mDrawable); + if (mDrawable) + { + // dynamic texture changes break batches, isolate in octree + shrinkWrap(); + gPipeline.markTextured(mDrawable); + } mFaceMappingChanged = TRUE; } return res; @@ -2232,6 +2246,7 @@ S32 LLVOVolume::setTEColor(const U8 te, const LLColor4& color) // These should only happen on updates which are not the initial update. mColorChanged = TRUE; mDrawable->setState(LLDrawable::REBUILD_COLOR); + shrinkWrap(); dirtyMesh(); } } @@ -2321,7 +2336,11 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) S32 res = LLViewerObject::setTEGlow(te, glow); if (res) { - gPipeline.markTextured(mDrawable); + if (mDrawable) + { + gPipeline.markTextured(mDrawable); + shrinkWrap(); + } mFaceMappingChanged = TRUE; } return res; @@ -4359,83 +4378,61 @@ void LLVOVolume::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) F32 LLVOVolume::getBinRadius() { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; - F32 radius; - - F32 scale = 1.f; - - static LLCachedControl octree_size_factor(gSavedSettings, "OctreeStaticObjectSizeFactor", 3); - static LLCachedControl octree_attachment_size_factor(gSavedSettings, "OctreeAttachmentSizeFactor", 4); - static LLCachedControl octree_distance_factor(gSavedSettings, "OctreeDistanceFactor", LLVector3(0.01f, 0.f, 0.f)); - static LLCachedControl octree_alpha_distance_factor(gSavedSettings, "OctreeAlphaDistanceFactor", LLVector3(0.1f, 0.f, 0.f)); + F32 radius; - S32 size_factor = llmax((S32)octree_size_factor, 1); - S32 attachment_size_factor = llmax((S32)octree_attachment_size_factor, 1); - LLVector3 distance_factor = octree_distance_factor; - LLVector3 alpha_distance_factor = octree_alpha_distance_factor; + static LLCachedControl octree_size_factor(gSavedSettings, "OctreeStaticObjectSizeFactor", 3); + static LLCachedControl octree_attachment_size_factor(gSavedSettings, "OctreeAttachmentSizeFactor", 4); + static LLCachedControl octree_distance_factor(gSavedSettings, "OctreeDistanceFactor", LLVector3(0.01f, 0.f, 0.f)); + static LLCachedControl octree_alpha_distance_factor(gSavedSettings, "OctreeAlphaDistanceFactor", LLVector3(0.1f, 0.f, 0.f)); - const LLVector4a* ext = mDrawable->getSpatialExtents(); - - BOOL shrink_wrap = mDrawable->isAnimating(); - BOOL alpha_wrap = FALSE; + S32 size_factor = llmax((S32)octree_size_factor, 1); + LLVector3 alpha_distance_factor = octree_alpha_distance_factor; - if (!isHUDAttachment()) - { - for (S32 i = 0; i < mDrawable->getNumFaces(); i++) - { - LLFace* face = mDrawable->getFace(i); - if (!face) continue; - if (face->isInAlphaPool() && - !face->canRenderAsMask()) - { - alpha_wrap = TRUE; - break; - } - } - } - else - { - shrink_wrap = FALSE; - } + //const LLVector4a* ext = mDrawable->getSpatialExtents(); - if (alpha_wrap) - { - LLVector3 bounds = getScale(); - radius = llmin(bounds.mV[1], bounds.mV[2]); - radius = llmin(radius, bounds.mV[0]); - radius *= 0.5f; - radius *= 1.f+mDrawable->mDistanceWRTCamera*alpha_distance_factor[1]; - radius += mDrawable->mDistanceWRTCamera*alpha_distance_factor[0]; - } - else if (shrink_wrap) - { - LLVector4a rad; - rad.setSub(ext[1], ext[0]); - - radius = rad.getLength3().getF32()*0.5f; - } - else if (mDrawable->isStatic()) - { - F32 szf = size_factor; + bool shrink_wrap = mShouldShrinkWrap || mDrawable->isAnimating(); + bool alpha_wrap = FALSE; - radius = llmax(mDrawable->getRadius(), szf); - - radius = powf(radius, 1.f+szf/radius); + if (!isHUDAttachment() && mDrawable->mDistanceWRTCamera < alpha_distance_factor[2]) + { + for (S32 i = 0; i < mDrawable->getNumFaces(); i++) + { + LLFace* face = mDrawable->getFace(i); + if (!face) continue; + if (face->isInAlphaPool() && + !face->canRenderAsMask()) + { + alpha_wrap = TRUE; + break; + } + } + } + else + { + shrink_wrap = FALSE; + } - radius *= 1.f + mDrawable->mDistanceWRTCamera * distance_factor[1]; - radius += mDrawable->mDistanceWRTCamera * distance_factor[0]; - } - else if (mDrawable->getVObj()->isAttachment()) - { - radius = llmax((S32) mDrawable->getRadius(),1)*attachment_size_factor; - } - else - { - radius = mDrawable->getRadius(); - radius *= 1.f + mDrawable->mDistanceWRTCamera * distance_factor[1]; - radius += mDrawable->mDistanceWRTCamera * distance_factor[0]; - } + if (alpha_wrap) + { + LLVector3 bounds = getScale(); + radius = llmin(bounds.mV[1], bounds.mV[2]); + radius = llmin(radius, bounds.mV[0]); + radius *= 0.5f; + //radius *= 1.f+mDrawable->mDistanceWRTCamera*alpha_distance_factor[1]; + //radius += mDrawable->mDistanceWRTCamera*alpha_distance_factor[0]; + } + else if (shrink_wrap) + { + radius = mDrawable->getRadius() * 0.25f; + } + else + { + F32 szf = size_factor; + radius = llmax(mDrawable->getRadius(), szf); + //radius = llmax(radius, mDrawable->mDistanceWRTCamera * distance_factor[0]); + } - return llclamp(radius*scale, 0.5f, 256.f); + return llclamp(radius, 0.5f, 256.f); } const LLVector3 LLVOVolume::getPivotPositionAgent() const @@ -4478,6 +4475,11 @@ void LLVOVolume::markForUpdate(BOOL priority) } } + if (mDrawable) + { + shrinkWrap(); + } + LLViewerObject::markForUpdate(priority); mVolumeChanged = TRUE; } @@ -4990,7 +4992,7 @@ U32 LLVOVolume::getPartitionType() const } LLVolumePartition::LLVolumePartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW, regionp), +: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, regionp), LLVolumeGeometryManager() { mLODPeriod = 32; @@ -4998,7 +5000,6 @@ LLVolumeGeometryManager() mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; mPartitionType = LLViewerRegion::PARTITION_VOLUME; mSlopRatio = 0.25f; - mBufferUsage = GL_DYNAMIC_DRAW; } LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep, LLViewerRegion* regionp) @@ -5010,8 +5011,6 @@ LLVolumeGeometryManager() mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; mPartitionType = LLViewerRegion::PARTITION_BRIDGE; - mBufferUsage = GL_DYNAMIC_DRAW; - mSlopRatio = 0.25f; } @@ -5164,7 +5163,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, S32 idx = draw_vec.size()-1; - BOOL fullbright = (type == LLRenderPass::PASS_FULLBRIGHT) || + bool fullbright = (type == LLRenderPass::PASS_FULLBRIGHT) || (type == LLRenderPass::PASS_INVISIBLE) || (type == LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK) || (type == LLRenderPass::PASS_ALPHA && facep->isState(LLFace::FULLBRIGHT)) || @@ -5227,7 +5226,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, mat = facep->getTextureEntry()->getMaterialParams().get(); if (mat) { - mat_id = facep->getTextureEntry()->getMaterialID().asUUID(); + //mat_id = facep->getTextureEntry()->getMaterialID().asUUID(); + mat_id = facep->getTextureEntry()->getMaterialParams()->getHash(); } } @@ -5247,8 +5247,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, } } - F32 vsize = facep->getVirtualSize(); //TODO -- adjust by texture scale? - if (index < FACE_DO_NOT_BATCH_TEXTURES && idx >= 0) { if (mat || gltf_mat || draw_vec[idx]->mMaterial) @@ -5261,12 +5259,10 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, { batchable = true; draw_vec[idx]->mTextureList[index] = tex; - draw_vec[idx]->mTextureListVSize[index] = vsize; } else if (draw_vec[idx]->mTextureList[index] == tex) { //this face's texture index can be used with this batch batchable = true; - draw_vec[idx]->mTextureListVSize[index] = llmax(vsize, draw_vec[idx]->mTextureListVSize[index]); } } else @@ -5295,14 +5291,11 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, { draw_vec[idx]->mCount += facep->getIndicesCount(); draw_vec[idx]->mEnd += facep->getGeomCount(); - draw_vec[idx]->mVSize = llmax(draw_vec[idx]->mVSize, vsize); if (index < FACE_DO_NOT_BATCH_TEXTURES && index >= draw_vec[idx]->mTextureList.size()) { draw_vec[idx]->mTextureList.resize(index+1); draw_vec[idx]->mTextureList[index] = tex; - draw_vec[idx]->mTextureListVSize.resize(index + 1); - draw_vec[idx]->mTextureListVSize[index] = vsize; } draw_vec[idx]->validate(); } @@ -5312,10 +5305,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 end = start + facep->getGeomCount()-1; U32 offset = facep->getIndicesStart(); U32 count = facep->getIndicesCount(); - LLPointer draw_info = new LLDrawInfo(start,end,count,offset, tex, - facep->getVertexBuffer(), selected, fullbright, bump); - draw_info->mGroup = group; - draw_info->mVSize = vsize; + LLPointer draw_info = new LLDrawInfo(start,end,count,offset, tex, + facep->getVertexBuffer(), fullbright, bump); draw_vec.push_back(draw_info); draw_info->mTextureMatrix = tex_mat; draw_info->mModelMatrix = model_mat; @@ -5388,8 +5379,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, { //initialize texture list for texture batching draw_info->mTextureList.resize(index+1); draw_info->mTextureList[index] = tex; - draw_info->mTextureListVSize.resize(index + 1); - draw_info->mTextureListVSize[index] = vsize; } draw_info->validate(); } @@ -5551,8 +5540,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 spec_count[2] = { 0 }; U32 normspec_count[2] = { 0 }; - U32 useage = group->getSpatialPartition()->mBufferUsage; - static LLCachedControl max_vbo_size(gSavedSettings, "RenderMaxVBOSize", 512); static LLCachedControl max_node_size(gSavedSettings, "RenderMaxNodeSize", 65536); U32 max_vertices = (max_vbo_size * 1024)/LLVertexBuffer::calcVertexSize(group->getSpatialPartition()->mVertexDataMask); @@ -5584,11 +5571,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } - if (drawablep->isAnimating()) - { //fall back to stream draw for animating verts - useage = GL_STREAM_DRAW; - } - LLVOVolume* vobj = drawablep->getVOVolume(); if (!vobj) @@ -5928,8 +5910,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } } - group->mBufferUsage = useage; - //PROCESS NON-ALPHA FACES U32 simple_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR; U32 alpha_mask = simple_mask | 0x80000000; //hack to give alpha verts their own VBO @@ -6022,8 +6002,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) group->mBuilt = 1.f; - S32 num_mapped_vertex_buffer = LLVertexBuffer::sMappedCount ; - const U32 MAX_BUFFER_COUNT = 4096; LLVertexBuffer* locked_buffer[MAX_BUFFER_COUNT]; @@ -6074,11 +6052,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) gPipeline.markRebuild(group, TRUE); } - - if (buff->isLocked() && buffer_count < MAX_BUFFER_COUNT) - { - locked_buffer[buffer_count++] = buff; - } + buff->unmapBuffer(); } } } @@ -6096,44 +6070,17 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) LL_PROFILE_ZONE_NAMED("rebuildMesh - flush"); for (LLVertexBuffer** iter = locked_buffer, ** end_iter = locked_buffer+buffer_count; iter != end_iter; ++iter) { - (*iter)->flush(); + (*iter)->unmapBuffer(); } // don't forget alpha if(group != NULL && - !group->mVertexBuffer.isNull() && - group->mVertexBuffer->isLocked()) + !group->mVertexBuffer.isNull()) { - group->mVertexBuffer->flush(); - } - } - - //if not all buffers are unmapped - if(num_mapped_vertex_buffer != LLVertexBuffer::sMappedCount) - { - LL_WARNS() << "Not all mapped vertex buffers are unmapped!" << LL_ENDL ; - for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) - { - LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable(); - if(!drawablep) - { - continue; - } - for (S32 i = 0; i < drawablep->getNumFaces(); ++i) - { - LLFace* face = drawablep->getFace(i); - if (face) - { - LLVertexBuffer* buff = face->getVertexBuffer(); - if (buff && buff->isLocked()) - { - buff->flush(); - } - } - } + group->mVertexBuffer->unmapBuffer(); } } - + group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); } } @@ -6200,18 +6147,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; U32 geometryBytes = 0; - U32 buffer_usage = group->mBufferUsage; - -#if LL_DARWIN - // HACK from Leslie: - // Disable VBO usage for alpha on Mac OS X because it kills the framerate - // due to implicit calls to glTexSubImage that are beyond our control. - // (this works because the only calls here that sort by distance are alpha) - if (distance_sort) - { - buffer_usage = 0x0; - } -#endif //calculate maximum number of vertices to store in a single buffer static LLCachedControl max_vbo_size(gSavedSettings, "RenderMaxVBOSize", 512); @@ -6428,19 +6363,13 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } } - - if (flexi && buffer_usage && buffer_usage != GL_STREAM_DRAW) - { - buffer_usage = GL_STREAM_DRAW; - } - //create vertex buffer LLPointer buffer; { LL_PROFILE_ZONE_NAMED("genDrawInfo - allocate"); - buffer = createVertexBuffer(mask, buffer_usage); - if(!buffer->allocateBuffer(geom_count, index_count, TRUE)) + buffer = new LLVertexBuffer(mask); + if(!buffer->allocateBuffer(geom_count, index_count)) { LL_WARNS() << "Failed to allocate group Vertex Buffer to " << geom_count << " vertices and " @@ -6830,7 +6759,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (buffer) { - buffer->flush(); + buffer->unmapBuffer(); } } @@ -6845,9 +6774,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace void LLVolumeGeometryManager::addGeometryCount(LLSpatialGroup* group, U32& vertex_count, U32& index_count) { - //initialize to default usage for this partition - U32 usage = group->getSpatialPartition()->mBufferUsage; - //for each drawable for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) { @@ -6857,23 +6783,13 @@ void LLVolumeGeometryManager::addGeometryCount(LLSpatialGroup* group, U32& verte { continue; } - - if (drawablep->isAnimating()) - { //fall back to stream draw for animating verts - usage = GL_STREAM_DRAW; - } } - - group->mBufferUsage = usage; } void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32 &index_count) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; - //initialize to default usage for this partition - U32 usage = group->getSpatialPartition()->mBufferUsage; - //clear off any old faces mFaceList.clear(); @@ -6887,11 +6803,6 @@ void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_coun continue; } - if (drawablep->isAnimating()) - { //fall back to stream draw for animating verts - usage = GL_STREAM_DRAW; - } - //for each face for (S32 i = 0; i < drawablep->getNumFaces(); i++) { @@ -6916,8 +6827,6 @@ void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_coun } } } - - group->mBufferUsage = usage; } LLHUDPartition::LLHUDPartition(LLViewerRegion* regionp) : LLBridgePartition(regionp) diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp index 6f30092326..2356e72aab 100644 --- a/indra/newview/llvowater.cpp +++ b/indra/newview/llvowater.cpp @@ -150,10 +150,14 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) indices_per_quad * num_quads); LLVertexBuffer* buff = face->getVertexBuffer(); - if (!buff || !buff->isWriteable()) + if (!buff || + buff->getNumIndices() != face->getIndicesCount() || + buff->getNumVerts() != face->getGeomCount() || + face->getIndicesStart() != 0 || + face->getGeomIndex() != 0) { - buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW); - if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) + buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK); + if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount())) { LL_WARNS() << "Failed to allocate Vertex Buffer on water update to " << face->getGeomCount() << " vertices and " @@ -163,13 +167,6 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) face->setGeomIndex(0); face->setVertexBuffer(buff); } - else - { - if (!buff->resizeBuffer(face->getGeomCount(), face->getIndicesCount())) - { - LL_WARNS() << "Failed to resize Vertex Buffer" << LL_ENDL; - } - } index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); @@ -230,7 +227,7 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) } } - buff->flush(); + buff->unmapBuffer(); mDrawable->movePartition(); LLPipeline::sCompiles++; @@ -295,7 +292,7 @@ U32 LLVOVoidWater::getPartitionType() const } LLWaterPartition::LLWaterPartition(LLViewerRegion* regionp) -: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW, regionp) +: LLSpatialPartition(0, FALSE, regionp) { mInfiniteFarClip = TRUE; mDrawableType = LLPipeline::RENDER_TYPE_WATER; diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 524fd4c49e..86e4853280 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -151,9 +151,9 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) if (mFsSkyVerts.isNull()) { - mFsSkyVerts = new LLVertexBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW); + mFsSkyVerts = new LLVertexBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK); - if (!mFsSkyVerts->allocateBuffer(4, 6, TRUE)) + if (!mFsSkyVerts->allocateBuffer(4, 6)) { LL_WARNS() << "Failed to allocate Vertex Buffer on full screen sky update" << LL_ENDL; } @@ -184,7 +184,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) *indices++ = 3; *indices++ = 2; - mFsSkyVerts->flush(); + mFsSkyVerts->unmapBuffer(); } { @@ -216,7 +216,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) for (U32 i = 0; i < strips_segments ;++i) { - LLVertexBuffer * segment = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW); + LLVertexBuffer * segment = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK); mStripsVerts[i] = segment; U32 num_stacks_this_seg = stacks_per_seg; @@ -237,7 +237,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) const U32 num_indices_this_seg = 1+num_stacks_this_seg*(2+2*verts_per_stack); llassert(num_indices_this_seg * sizeof(U16) <= max_buffer_bytes); - bool allocated = segment->allocateBuffer(num_verts_this_seg, num_indices_this_seg, TRUE); + bool allocated = segment->allocateBuffer(num_verts_this_seg, num_indices_this_seg); #if RELEASE_SHOW_WARNS if( !allocated ) { @@ -267,7 +267,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) buildStripsBuffer(begin_stack, end_stack, vertices, texCoords, indices, dome_radius, verts_per_stack, total_stacks); // and unlock the buffer - segment->flush(); + segment->unmapBuffer(); } #if RELEASE_SHOW_DEBUG @@ -288,7 +288,7 @@ void LLVOWLSky::drawStars(void) // render the stars as a sphere centered at viewer camera if (mStarsVerts.notNull()) { - mStarsVerts->setBuffer(LLDrawPoolWLSky::STAR_VERTEX_DATA_MASK); + mStarsVerts->setBuffer(); mStarsVerts->drawArrays(LLRender::TRIANGLES, 0, getStarsNumVerts()*4); } } @@ -302,7 +302,7 @@ void LLVOWLSky::drawFsSky(void) LLGLDisable disable_blend(GL_BLEND); - mFsSkyVerts->setBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK); + mFsSkyVerts->setBuffer(); mFsSkyVerts->drawRange(LLRender::TRIANGLES, 0, mFsSkyVerts->getNumVerts() - 1, mFsSkyVerts->getNumIndices(), 0); gPipeline.addTrianglesDrawn(mFsSkyVerts->getNumIndices()); LLVertexBuffer::unbind(); @@ -317,15 +317,13 @@ void LLVOWLSky::drawDome(void) LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - const U32 data_mask = LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK; - std::vector< LLPointer >::const_iterator strips_vbo_iter, end_strips; end_strips = mStripsVerts.end(); for(strips_vbo_iter = mStripsVerts.begin(); strips_vbo_iter != end_strips; ++strips_vbo_iter) { LLVertexBuffer * strips_segment = strips_vbo_iter->get(); - strips_segment->setBuffer(data_mask); + strips_segment->setBuffer(); strips_segment->drawRange( LLRender::TRIANGLE_STRIP, @@ -518,10 +516,10 @@ BOOL LLVOWLSky::updateStarGeometry(LLDrawable *drawable) LLStrider colorsp; LLStrider texcoordsp; - if (mStarsVerts.isNull() || !mStarsVerts->isWriteable()) + if (mStarsVerts.isNull()) { - mStarsVerts = new LLVertexBuffer(LLDrawPoolWLSky::STAR_VERTEX_DATA_MASK, GL_DYNAMIC_DRAW); - if (!mStarsVerts->allocateBuffer(getStarsNumVerts()*6, 0, TRUE)) + mStarsVerts = new LLVertexBuffer(LLDrawPoolWLSky::STAR_VERTEX_DATA_MASK); + if (!mStarsVerts->allocateBuffer(getStarsNumVerts()*6, 0)) { LL_WARNS() << "Failed to allocate Vertex Buffer for Sky to " << getStarsNumVerts() * 6 << " vertices" << LL_ENDL; } @@ -578,6 +576,6 @@ BOOL LLVOWLSky::updateStarGeometry(LLDrawable *drawable) *(colorsp++) = LLColor4U(mStarColors[vtx]); } - mStarsVerts->flush(); + mStarsVerts->unmapBuffer(); return TRUE; } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index cedbe4d117..beaa3cdb69 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -285,7 +285,7 @@ static LLStaticHashedString sKernScale("kern_scale"); void drawBox(const LLVector4a& c, const LLVector4a& r); void drawBoxOutline(const LLVector3& pos, const LLVector3& size); U32 nhpo2(U32 v); -LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage); +LLVertexBuffer* ll_create_cube_vb(U32 type_mask); void display_update_camera(); //---------------------------------------- @@ -416,9 +416,6 @@ void LLPipeline::init() gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); - LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); - LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); - LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights"); sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles"); @@ -498,15 +495,15 @@ void LLPipeline::init() if (mCubeVB.isNull()) { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX); } - mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); - mDeferredVB->allocateBuffer(8, 0, true); + mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK); + mDeferredVB->allocateBuffer(8, 0); { - mScreenTriangleVB = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); - mScreenTriangleVB->allocateBuffer(3, 0, true); + mScreenTriangleVB = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->allocateBuffer(3, 0); LLStrider vert; mScreenTriangleVB->getVertexStrider(vert); @@ -514,7 +511,7 @@ void LLPipeline::init() vert[1].set(-1, -3, 0); vert[2].set(3, 1, 0); - mScreenTriangleVB->flush(); + mScreenTriangleVB->unmapBuffer(); } setLightingDetail(-1); @@ -706,11 +703,6 @@ void LLPipeline::destroyGL() releaseGLBuffers(); - if (LLVertexBuffer::sEnableVBOs) - { - LLVertexBuffer::sEnableVBOs = FALSE; - } - if (mMeshDirtyQueryObject) { glDeleteQueries(1, &mMeshDirtyQueryObject); @@ -2505,14 +2497,6 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d dest.bindTarget(); dest.clear(GL_DEPTH_BUFFER_BIT); - LLStrider vert; - mDeferredVB->getVertexStrider(vert); - LLStrider tc0; - - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); - if (source.getUsage() == LLTexUnit::TT_TEXTURE) { shader = &gDownsampleDepthRectProgram; @@ -2532,8 +2516,8 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d { LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } dest.flush(); @@ -2552,6 +2536,8 @@ void LLPipeline::doOcclusion(LLCamera& camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("doOcclusion"); + llassert(!gCubeSnapshot); + if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck)) { @@ -2572,25 +2558,13 @@ void LLPipeline::doOcclusion(LLCamera& camera) LLGLDisable cull(GL_CULL_FACE); - - bool bind_shader = (LLGLSLShader::sCurBoundShader == 0); - if (bind_shader) - { - if (LLPipeline::sShadowRender) - { - gDeferredShadowCubeProgram.bind(); - } - else - { - gOcclusionCubeProgram.bind(); - } - } + gOcclusionCubeProgram.bind(); if (mCubeVB.isNull()) { //cube VB will be used for issuing occlusion queries - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX); } - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mCubeVB->setBuffer(); for (LLCullResult::sg_iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter) { @@ -2610,19 +2584,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) } } - if (bind_shader) - { - if (LLPipeline::sShadowRender) - { - gDeferredShadowCubeProgram.unbind(); - } - else - { - gOcclusionCubeProgram.unbind(); - } - } - - gGL.setColorMask(true, false); + gGL.setColorMask(true, true); } } @@ -3661,50 +3623,6 @@ void renderSoundHighlights(LLDrawable *drawablep) } } -void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) -{ - if (tex) - { - tex->setActive(); - tex->addTextureStats(vsize); - } -} - -void LLPipeline::touchTextures(LLDrawInfo* info) -{ - if (--info->mTextureTimer == 0) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - // reset texture timer in a noisy fashion to avoid clumping of updates - const U32 MIN_WAIT_TIME = 8; - const U32 MAX_WAIT_TIME = 16; - - info->mTextureTimer = ll_rand() % (MAX_WAIT_TIME - MIN_WAIT_TIME) + MIN_WAIT_TIME; - - auto& mat = info->mGLTFMaterial; - if (mat.notNull()) - { - touchTexture(mat->mBaseColorTexture, info->mVSize); - touchTexture(mat->mNormalTexture, info->mVSize); - touchTexture(mat->mMetallicRoughnessTexture, info->mVSize); - touchTexture(mat->mEmissiveTexture, info->mVSize); - } - else - { - info->mTextureTimer += (U8) info->mTextureList.size(); - - for (int i = 0; i < info->mTextureList.size(); ++i) - { - touchTexture(info->mTextureList[i], info->mTextureListVSize[i]); - } - - touchTexture(info->mTexture, info->mVSize); - touchTexture(info->mSpecularMap, info->mVSize); - touchTexture(info->mNormalMap, info->mVSize); - } - } -} - void LLPipeline::postSort(LLCamera &camera) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -3757,28 +3675,6 @@ void LLPipeline::postSort(LLCamera &camera) continue; } - // DEBUG -- force a texture virtual size update every frame - /*if (group->getSpatialPartition()->mDrawableType == LLPipeline::RENDER_TYPE_VOLUME) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("plps - update vsize"); - auto& entries = group->getData(); - for (auto& entry : entries) - { - if (entry) - { - auto* data = entry->getDrawable(); - if (data) - { - LLVOVolume* volume = ((LLDrawable*)data)->getVOVolume(); - if (volume) - { - volume->updateTextureVirtualSize(true); - } - } - } - } - }*/ - for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) { LLDrawInfo *info = *k; @@ -3786,7 +3682,6 @@ void LLPipeline::postSort(LLCamera &camera) sCull->pushDrawInfo(j->first, info); if (!sShadowRender && !sReflectionRender && !gCubeSnapshot) { - touchTextures(info); addTrianglesDrawn(info->mCount); } } @@ -3830,17 +3725,6 @@ void LLPipeline::postSort(LLCamera &camera) } } - // flush particle VB - if (LLVOPartGroup::sVB) - { - LL_PROFILE_GPU_ZONE("flush particle vb"); - LLVOPartGroup::sVB->flush(); - } - else - { - LL_WARNS_ONCE() << "Missing particle buffer" << LL_ENDL; - } - /*bool use_transform_feedback = gTransformPositionProgram.mProgramObject && !mMeshDirtyGroup.empty(); if (use_transform_feedback) @@ -3989,9 +3873,8 @@ void render_hud_elements() //glStencilMask(0xFFFFFFFF); //glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - gGL.color4f(1,1,1,1); - gUIProgram.bind(); + gGL.color4f(1, 1, 1, 1); LLGLDepthTest depth(GL_TRUE, GL_FALSE); if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) @@ -4151,261 +4034,6 @@ void LLPipeline::renderHighlights() //debug use U32 LLPipeline::sCurRenderPoolType = 0 ; -void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) -{ -#if 0 - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); - LL_PROFILE_GPU_ZONE("renderGeom"); - assertInitialized(); - - F32 saved_modelview[16]; - F32 saved_projection[16]; - - //HACK: preserve/restore matrices around HUD render - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - for (U32 i = 0; i < 16; i++) - { - saved_modelview[i] = gGLModelView[i]; - saved_projection[i] = gGLProjection[i]; - } - } - - /////////////////////////////////////////// - // - // Sync and verify GL state - // - // - - stop_glerror(); - - LLVertexBuffer::unbind(); - - // Do verification of GL state - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - if (mRenderDebugMask & RENDER_DEBUG_VERIFY) - { - if (!verify()) - { - LL_ERRS() << "Pipeline verification failed!" << LL_ENDL; - } - } - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:ForceVBO"); - - // Initialize lots of GL state to "safe" values - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - - LLGLSPipeline gls_pipeline; - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); - - LLGLState gls_color_material(GL_COLOR_MATERIAL, mLightingDetail < 2); - - // Toggle backface culling for debugging - LLGLEnable cull_face(mBackfaceCull ? GL_CULL_FACE : 0); - // Set fog - bool use_fog = hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOG); - LLGLEnable fog_enable(use_fog && - !gPipeline.canUseWindLightShadersOnObjects() ? GL_FOG : 0); - gSky.updateFog(camera.getFar()); - if (!use_fog) - { - sUnderWaterRender = false; - } - - gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sDefaultImagep); - LLViewerFetchedTexture::sDefaultImagep->setAddressMode(LLTexUnit::TAM_WRAP); - - - ////////////////////////////////////////////// - // - // Actually render all of the geometry - // - // - stop_glerror(); - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDrawPools"); - - for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) - { - LLDrawPool *poolp = *iter; - if (hasRenderType(poolp->getType())) - { - poolp->prerender(); - } - } - - { - bool occlude = sUseOcclusion > 1; -#if 1 // DEPRECATED -- requires forward rendering - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pools"); //LL_RECORD_BLOCK_TIME(FTM_POOLS); - - // HACK: don't calculate local lights if we're rendering the HUD! - // Removing this check will cause bad flickering when there are - // HUD elements being rendered AND the user is in flycam mode -nyx - if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - calcNearbyLights(camera); - setupHWLights(NULL); - } - - U32 cur_type = 0; - - pool_set_t::iterator iter1 = mPools.begin(); - while ( iter1 != mPools.end() ) - { - LLDrawPool *poolp = *iter1; - - cur_type = poolp->getType(); - - //debug use - sCurRenderPoolType = cur_type ; - - if (occlude && cur_type >= LLDrawPool::POOL_GRASS) - { - occlude = false; - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - LLGLSLShader::bindNoShader(); - doOcclusion(camera); - } - - - pool_set_t::iterator iter2 = iter1; - if (hasRenderType(poolp->getType()) && poolp->getNumPasses() > 0) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pool render"); //LL_RECORD_BLOCK_TIME(FTM_POOLRENDER); - - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - - for( S32 i = 0; i < poolp->getNumPasses(); i++ ) - { - LLVertexBuffer::unbind(); - poolp->beginRenderPass(i); - for (iter2 = iter1; iter2 != mPools.end(); iter2++) - { - LLDrawPool *p = *iter2; - if (p->getType() != cur_type) - { - break; - } - - if ( !p->getSkipRenderFlag() ) { p->render(i); } - } - poolp->endRenderPass(i); - LLVertexBuffer::unbind(); - if (gDebugGL) - { - std::string msg = llformat("pass %d", i); - LLGLState::checkStates(msg); - //LLGLState::checkTextureChannels(msg); - //LLGLState::checkClientArrays(msg); - } - } - } - else - { - // Skip all pools of this type - for (iter2 = iter1; iter2 != mPools.end(); iter2++) - { - LLDrawPool *p = *iter2; - if (p->getType() != cur_type) - { - break; - } - } - } - iter1 = iter2; - stop_glerror(); - - } - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDrawPoolsEnd"); - - LLVertexBuffer::unbind(); -#endif - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - - if (occlude) - { // catch uncommon condition where pools at drawpool grass and later are disabled - occlude = false; - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - LLGLSLShader::bindNoShader(); - doOcclusion(camera); - } - } - - LLVertexBuffer::unbind(); - LLGLState::checkStates(); - - if (!LLPipeline::sImpostorRender) - { - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderHighlights"); - - if (!sReflectionRender) - { - renderHighlights(); - } - - // Contains a list of the faces of objects that are physical or - // have touch-handlers. - mHighlightFaces.clear(); - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDebug"); - - renderDebug(); - - LLVertexBuffer::unbind(); - - if (!LLPipeline::sReflectionRender && !LLPipeline::sRenderDeferred) - { - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) - { - // Render debugging beacons. - gObjectList.renderObjectBeacons(); - gObjectList.resetObjectBeacons(); - gSky.addSunMoonBeacons(); - } - else - { - // Make sure particle effects disappear - LLHUDObject::renderAllForTimer(); - } - } - else - { - // Make sure particle effects disappear - LLHUDObject::renderAllForTimer(); - } - - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomEnd"); - - //HACK: preserve/restore matrices around HUD render - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - for (U32 i = 0; i < 16; i++) - { - gGLModelView[i] = saved_modelview[i]; - gGLProjection[i] = saved_projection[i]; - } - } - } - - LLVertexBuffer::unbind(); - - LLGLState::checkStates(); -// LLGLState::checkTextureChannels(); -// LLGLState::checkClientArrays(); -#endif -} - void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) { LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); @@ -4438,7 +4066,6 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); if (LLViewerShaderMgr::instance()->mShaderLevel[LLViewerShaderMgr::SHADER_DEFERRED] > 1) { @@ -4464,9 +4091,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) occlude = false; gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - LLGLSLShader::bindNoShader(); doOcclusion(camera); - gGL.setColorMask(true, false); } pool_set_t::iterator iter2 = iter1; @@ -4586,7 +4211,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) if (gDebugGL || gDebugPipeline) { - LLGLState::checkStates(); + LLGLState::checkStates(GL_FALSE); } } } @@ -4667,8 +4292,6 @@ void LLPipeline::renderGeomShadow(LLCamera& camera) } poolp->endShadowPass(i); LLVertexBuffer::unbind(); - - LLGLState::checkStates(); } } else @@ -5049,8 +4672,6 @@ void LLPipeline::renderDebug() } } - gGL.color4f(1,1,1,1); - gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); gGL.setColorMask(true, false); @@ -5059,6 +4680,7 @@ void LLPipeline::renderDebug() if (!hud_only && !mDebugBlips.empty()) { //render debug blips gUIProgram.bind(); + gGL.color4f(1, 1, 1, 1); gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep, true); @@ -5154,7 +4776,7 @@ void LLPipeline::renderDebug() LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("probe debug display"); bindDeferredShader(gReflectionProbeDisplayProgram, NULL); - mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); // Provide our projection matrix. set_camera_projection_matrix(gReflectionProbeDisplayProgram); @@ -7259,45 +6881,35 @@ void LLPipeline::doResetVertexBuffers(bool forced) LLVOPartGroup::destroyGL(); gGL.resetVertexBuffer(); - if (LLVertexBuffer::sGLCount != 0) - { - LL_WARNS() << "VBO wipe failed -- " << LLVertexBuffer::sGLCount << " buffers remaining." << LL_ENDL; - } - LLVertexBuffer::unbind(); updateRenderBump(); updateRenderDeferred(); - LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); - LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); - LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); - LLVertexBuffer::sEnableVBOs = gSavedSettings.getBOOL("RenderVBOEnable"); - LLVertexBuffer::sDisableVBOMapping = LLVertexBuffer::sEnableVBOs && gSavedSettings.getBOOL("RenderVBOMappingDisable") ; sBakeSunlight = gSavedSettings.getBOOL("RenderBakeSunlight"); sNoAlpha = gSavedSettings.getBOOL("RenderNoAlpha"); LLPipeline::sTextureBindTest = gSavedSettings.getBOOL("RenderDebugTextureBind"); gGL.initVertexBuffer(); - mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0); - mDeferredVB->allocateBuffer(8, 0, true); + mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK); + mDeferredVB->allocateBuffer(8, 0); LLVOPartGroup::restoreGL(); } -void LLPipeline::renderObjects(U32 type, U32 mask, bool texture, bool batch_texture, bool rigged) +void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; if (rigged) { - mSimplePool->pushRiggedBatches(type + 1, mask, texture, batch_texture); + mSimplePool->pushRiggedBatches(type + 1, texture, batch_texture); } else { - mSimplePool->pushBatches(type, mask, texture, batch_texture); + mSimplePool->pushBatches(type, texture, batch_texture); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -7326,8 +6938,8 @@ void LLPipeline::renderShadowSimple(U32 type) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("push shadow simple"); mSimplePool->applyModelMatrix(params); - vb->setBufferFast(LLVertexBuffer::MAP_VERTEX); - vb->drawRangeFast(LLRender::TRIANGLES, 0, vb->getNumVerts()-1, vb->getNumIndices(), 0); + vb->setBuffer(); + vb->drawRange(LLRender::TRIANGLES, 0, vb->getNumVerts()-1, vb->getNumIndices(), 0); last_vb = vb; } } @@ -7335,7 +6947,7 @@ void LLPipeline::renderShadowSimple(U32 type) gGLLastMatrix = NULL; } -void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, bool rigged) +void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigged) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; assertInitialized(); @@ -7363,12 +6975,12 @@ void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, lastMeshId = pparams->mSkinInfo->mHash; } - mSimplePool->pushBatch(*pparams, mask | LLVertexBuffer::MAP_WEIGHT4, texture, batch_texture); + mSimplePool->pushBatch(*pparams, texture, batch_texture); } } else if (pparams->mAvatar == nullptr) { - mSimplePool->pushBatch(*pparams, mask, texture, batch_texture); + mSimplePool->pushBatch(*pparams, texture, batch_texture); } } @@ -7376,35 +6988,35 @@ void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, gGLLastMatrix = NULL; } -void LLPipeline::renderMaskedObjects(U32 type, U32 mask, bool texture, bool batch_texture, bool rigged) +void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; if (rigged) { - mAlphaMaskPool->pushRiggedMaskBatches(type+1, mask, texture, batch_texture); + mAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); } else { - mAlphaMaskPool->pushMaskBatches(type, mask, texture, batch_texture); + mAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; } -void LLPipeline::renderFullbrightMaskedObjects(U32 type, U32 mask, bool texture, bool batch_texture, bool rigged) +void LLPipeline::renderFullbrightMaskedObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; if (rigged) { - mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, mask, texture, batch_texture); + mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); } else { - mFullbrightAlphaMaskPool->pushMaskBatches(type, mask, texture, batch_texture); + mFullbrightAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -7476,7 +7088,6 @@ void LLPipeline::renderPostProcess() { LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); assertInitialized(); @@ -7486,7 +7097,6 @@ void LLPipeline::renderPostProcess() LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); LL_PROFILE_GPU_ZONE("renderPostProcess"); - gGL.color4f(1, 1, 1, 1); LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); LLGLDisable cull(GL_CULL_FACE); @@ -7605,6 +7215,7 @@ void LLPipeline::renderPostProcess() } gGlowProgram.unbind(); + gGL.setSceneBlendType(LLRender::BT_ALPHA); } else // !sRenderGlow, skip the glow ping-pong and just clear the result target { @@ -7920,7 +7531,6 @@ void LLPipeline::renderFinalize() { LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); assertInitialized(); @@ -7952,7 +7562,7 @@ void LLPipeline::renderFinalize() LL_PROFILE_GPU_ZONE("screen space reflections"); bindDeferredShader(gPostScreenSpaceReflectionProgram, NULL); - mScreenTriangleVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); set_camera_projection_matrix(gPostScreenSpaceReflectionProgram); @@ -7993,7 +7603,7 @@ void LLPipeline::renderFinalize() // Apply gamma correction to the frame here. gDeferredPostGammaCorrectProgram.bind(); - // mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + S32 channel = 0; channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); if (channel > -1) @@ -8134,7 +7744,7 @@ void LLPipeline::renderFinalize() { U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1; LLPointer buff = new LLVertexBuffer(mask, 0); - buff->allocateBuffer(3, 0, TRUE); + buff->allocateBuffer(3, 0); LLStrider v; LLStrider uv1; @@ -8167,7 +7777,7 @@ void LLPipeline::renderFinalize() LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); - buff->setBuffer(mask); + buff->setBuffer(); buff->drawArrays(LLRender::TRIANGLE_STRIP, 0, 3); gGlowCombineProgram.unbind(); @@ -8190,7 +7800,6 @@ void LLPipeline::renderFinalize() LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); // flush calls made to "addTrianglesDrawn" so far to stats machinery recordTrianglesDrawn(); @@ -8301,7 +7910,6 @@ void LLPipeline::bindDeferredShaderFast(LLGLSLShader& shader) void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - LL_PROFILE_GPU_ZONE("bindDeferredShader"); LLRenderTarget* deferred_target = &mRT->deferredScreen; //LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; LLRenderTarget* deferred_light_target = &mRT->deferredLight; @@ -8602,13 +8210,6 @@ void LLPipeline::renderDeferredLighting() glh::matrix4f mat = copy_matrix(gGLModelView); - LLStrider vert; - mDeferredVB->getVertexStrider(vert); - - vert[0].set(-1, 1, 0); - vert[1].set(-1, -3, 0); - vert[2].set(3, 1, 0); - setupHWLights(NULL); // to set mSun/MoonDir; glh::vec4f tc(mSunDir.mV); @@ -8626,7 +8227,7 @@ void LLPipeline::renderDeferredLighting() { // paint shadow/SSAO light map (direct lighting lightmap) LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - sun shadow"); bindDeferredShader(gDeferredSunProgram, deferred_light_target); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); glClearColor(1, 1, 1, 1); deferred_light_target->clear(GL_COLOR_BUFFER_BIT); glClearColor(0, 0, 0, 0); @@ -8658,9 +8259,7 @@ void LLPipeline::renderDeferredLighting() { LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } unbindDeferredShader(gDeferredSunProgram); @@ -8690,7 +8289,7 @@ void LLPipeline::renderDeferredLighting() glClearColor(0, 0, 0, 0); bindDeferredShader(gDeferredBlurLightProgram); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); LLVector3 go = RenderShadowGaussian; const U32 kern_length = 4; F32 blur_size = RenderShadowBlurSize; @@ -8719,9 +8318,7 @@ void LLPipeline::renderDeferredLighting() { LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } screen_target->flush(); @@ -8729,7 +8326,7 @@ void LLPipeline::renderDeferredLighting() bindDeferredShader(gDeferredBlurLightProgram, screen_target); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); deferred_light_target->bindTarget(); gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); @@ -8737,9 +8334,7 @@ void LLPipeline::renderDeferredLighting() { LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } deferred_light_target->flush(); unbindDeferredShader(gDeferredBlurLightProgram); @@ -8781,9 +8376,8 @@ void LLPipeline::renderDeferredLighting() // full screen blit - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } @@ -8836,10 +8430,10 @@ void LLPipeline::renderDeferredLighting() if (mCubeVB.isNull()) { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW); + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX); } - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mCubeVB->setBuffer(); LLGLDepthTest depth(GL_TRUE, GL_FALSE); // mNearbyLights already includes distance calculation and excludes muted avatars. @@ -8942,7 +8536,7 @@ void LLPipeline::renderDeferredLighting() LLGLDepthTest depth(GL_TRUE, GL_FALSE); bindDeferredShader(gDeferredSpotLightProgram); - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mCubeVB->setBuffer(); gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); @@ -8976,12 +8570,6 @@ void LLPipeline::renderDeferredLighting() unbindDeferredShader(gDeferredSpotLightProgram); } - // reset mDeferredVB to fullscreen triangle - mDeferredVB->getVertexStrider(vert); - vert[0].set(-1, 1, 0); - vert[1].set(-1, -3, 0); - vert[2].set(3, 1, 0); - { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - fullscreen lights"); LLGLDepthTest depth(GL_FALSE); @@ -9014,8 +8602,8 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; count = 0; - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); unbindDeferredShader(gDeferredMultiLightProgram[idx]); } } @@ -9024,7 +8612,7 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mScreenTriangleVB->setBuffer(); for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) { @@ -9049,7 +8637,7 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, light_falloff_final); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); @@ -9098,6 +8686,8 @@ void LLPipeline::renderDeferredLighting() } screen_target->flush(); + + gGL.setColorMask(true, true); } void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) @@ -9534,7 +9124,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { if (rigged) { - renderObjects(type, LLVertexBuffer::MAP_VERTEX, FALSE, FALSE, rigged); + renderObjects(type, false, false, rigged); } else { @@ -9571,11 +9161,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha"); LL_PROFILE_GPU_ZONE("shadow alpha"); - U32 mask = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_COLOR | - LLVertexBuffer::MAP_TEXTURE_INDEX; - for (int i = 0; i < 2; ++i) { bool rigged = i == 1; @@ -9586,37 +9171,44 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha masked"); - renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE, rigged); + LL_PROFILE_GPU_ZONE("shadow alpha masked"); + renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, true, true, rigged); } { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); + LL_PROFILE_GPU_ZONE("shadow alpha blend"); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); - renderAlphaObjects(mask, TRUE, TRUE, rigged); + renderAlphaObjects(true, true, rigged); } { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow fullbright alpha masked"); + LL_PROFILE_GPU_ZONE("shadow alpha masked"); gDeferredShadowFullbrightAlphaMaskProgram.bind(rigged); LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - renderFullbrightMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, mask, TRUE, TRUE, rigged); + renderFullbrightMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, true, true, rigged); } { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha grass"); + LL_PROFILE_GPU_ZONE("shadow alpha grass"); gDeferredTreeShadowProgram.bind(rigged); if (i == 0) { LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); - renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE); + renderObjects(LLRenderPass::PASS_GRASS, true); } - U32 no_idx_mask = mask & ~LLVertexBuffer::MAP_TEXTURE_INDEX; - renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, no_idx_mask, true, false, rigged); - renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, no_idx_mask, true, false, rigged); - renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, no_idx_mask, true, false, rigged); - renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, no_idx_mask, true, false, rigged); + { + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha material"); + LL_PROFILE_GPU_ZONE("shadow alpha material"); + renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, true, false, rigged); + renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, true, false, rigged); + renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, true, false, rigged); + renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, true, false, rigged); + } } } @@ -9634,11 +9226,11 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera if (rigged) { - mAlphaMaskPool->pushRiggedGLTFBatches(type + 1, mask); + mAlphaMaskPool->pushRiggedGLTFBatches(type + 1); } else { - mAlphaMaskPool->pushGLTFBatches(type, mask); + mAlphaMaskPool->pushGLTFBatches(type); } gGL.loadMatrix(gGLModelView); @@ -9891,7 +9483,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) bool skip_avatar_update = false; if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) { - skip_avatar_update = true; } @@ -10005,12 +9596,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) clip = RenderShadowOrthoClipPlanes; mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); - //if (gCubeSnapshot) - { //always do a single 64m shadow in reflection maps - mSunClipPlanes.set(64.f, 128.f, 256.f); - mSunOrthoClipPlanes.set(64.f, 128.f, 256.f); - } - //currently used for amount to extrude frusta corners for constructing shadow frusta //LLVector3 n = RenderShadowNearDist; //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; @@ -10515,7 +10100,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { static LLCullResult result[4]; - renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, FALSE, target_width); + renderShadow(view[j], proj[j], shadow_cam, result[j], true, true, target_width); } mRT->shadow[j].flush(); @@ -10670,7 +10255,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) RenderSpotLight = drawable; - renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], FALSE, FALSE, target_width); + renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], false, true, target_width); RenderSpotLight = nullptr; @@ -10698,7 +10283,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) gGL.loadMatrix(proj[1].m); gGL.matrixMode(LLRender::MM_MODELVIEW); } - gGL.setColorMask(true, false); + gGL.setColorMask(true, true); for (U32 i = 0; i < 16; i++) { @@ -10714,7 +10299,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } } -void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, bool texture) +void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, bool texture) { for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) { @@ -10724,12 +10309,12 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, bool textu gPipeline.hasRenderType(group->getSpatialPartition()->mDrawableType) && group->mDrawMap.find(type) != group->mDrawMap.end()) { - pass->renderGroup(group,type,mask,texture); + pass->renderGroup(group,type,texture); } } } -void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, U32 mask, bool texture) +void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture) { for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) { @@ -10739,7 +10324,7 @@ void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, U32 mask, bool gPipeline.hasRenderType(group->getSpatialPartition()->mDrawableType) && group->mDrawMap.find(type) != group->mDrawMap.end()) { - pass->renderRiggedGroup(group, type, mask, texture); + pass->renderRiggedGroup(group, type, texture); } } } @@ -10751,7 +10336,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) LL_RECORD_BLOCK_TIME(FTM_GENERATE_IMPOSTOR); LL_PROFILE_GPU_ZONE("generateImpostor"); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); static LLCullResult result; result.clear(); @@ -10977,17 +10561,10 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) if (preview_avatar) { // previews don't care about imposters - if (LLPipeline::sRenderDeferred) - { - renderGeomDeferred(camera); - renderGeomPostDeferred(camera); - } - else - { - renderGeom(camera); - } + renderGeomDeferred(camera); + renderGeomPostDeferred(camera); } - else if (LLPipeline::sRenderDeferred) + else { avatar->mImpostor.clear(); renderGeomDeferred(camera); @@ -11009,28 +10586,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) sImpostorRenderAlphaDepthPass = false; } - else - { - LLGLEnable scissor(GL_SCISSOR_TEST); - glScissor(0, 0, resX, resY); - avatar->mImpostor.clear(); - renderGeom(camera); - - // Shameless hack time: render it all again, - // this time writing the depth - // values we need to generate the alpha mask below - // while preserving the alpha-sorted color rendering - // from the previous pass - // - sImpostorRenderAlphaDepthPass = true; - - // depth-only here... - // - gGL.setColorMask(false,false); - renderGeom(camera); - - sImpostorRenderAlphaDepthPass = false; - } LLDrawPoolAvatar::sMinimumAlpha = old_alpha; @@ -11121,7 +10676,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); } bool LLPipeline::hasRenderBatches(const U32 type) const diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index d3793da347..689dc385ae 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -266,21 +266,17 @@ public: void stateSort(LLDrawable* drawablep, LLCamera& camera); void postSort(LLCamera& camera); - //update stats for textures in given DrawInfo - void touchTextures(LLDrawInfo* info); - void touchTexture(LLViewerTexture* tex, F32 vsize); - void forAllVisibleDrawables(void (*func)(LLDrawable*)); - void renderObjects(U32 type, U32 mask, bool texture = true, bool batch_texture = false, bool rigged = false); + void renderObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false); void renderShadowSimple(U32 type); - void renderAlphaObjects(U32 mask, bool texture = true, bool batch_texture = false, bool rigged = false); - void renderMaskedObjects(U32 type, U32 mask, bool texture = true, bool batch_texture = false, bool rigged = false); - void renderFullbrightMaskedObjects(U32 type, U32 mask, bool texture = true, bool batch_texture = false, bool rigged = false); + void renderAlphaObjects(bool texture = true, bool batch_texture = false, bool rigged = false); + void renderMaskedObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false); + void renderFullbrightMaskedObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false); - void renderGroups(LLRenderPass* pass, U32 type, U32 mask, bool texture); - void renderRiggedGroups(LLRenderPass* pass, U32 type, U32 mask, bool texture); + void renderGroups(LLRenderPass* pass, U32 type, bool texture); + void renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture); void grabReferences(LLCullResult& result); void clearReferences(); @@ -290,9 +286,7 @@ public: void checkReferences(LLDrawable* drawable); void checkReferences(LLDrawInfo* draw_info); void checkReferences(LLSpatialGroup* group); - - - void renderGeom(LLCamera& camera, bool forceVBOUpdate = false); + void renderGeomDeferred(LLCamera& camera, bool do_occlusion = false); void renderGeomPostDeferred(LLCamera& camera); void renderGeomShadow(LLCamera& camera); -- cgit v1.3 From 93b1da52f56293663d9bfe5272a83a77185f4cff Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 2 Feb 2023 14:35:09 -0600 Subject: SL-18908 Make media texture override base color and emissive texture on PBR materials when present. --- indra/llprimitive/llgltfmaterial.h | 12 +++++------- indra/llprimitive/llmaterial.cpp | 8 ++------ indra/newview/lldrawpool.cpp | 4 ++-- indra/newview/lldrawpoolalpha.cpp | 2 +- indra/newview/llface.cpp | 2 +- indra/newview/llfetchedgltfmaterial.cpp | 14 +++++++++----- indra/newview/llfetchedgltfmaterial.h | 3 ++- indra/newview/llvovolume.cpp | 5 ++++- 8 files changed, 26 insertions(+), 24 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index dec7b696f8..2bd2d34b53 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -33,7 +33,7 @@ #include "v3color.h" #include "v2math.h" #include "lluuid.h" -#include "llmd5.h" +#include "hbxxh.h" #include @@ -98,12 +98,10 @@ public: LLUUID getHash() const { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - LLMD5 md5; - md5.update((unsigned char*)this, sizeof(this)); - md5.finalize(); - LLUUID id; - md5.raw_digest(id.mData); - return id; + // HACK - hash the bytes of this object but don't include the ref count + LLUUID hash; + HBXXH128::digest(hash, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); + return hash; } enum TextureInfo : U32 diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 0ab97a0df3..a694a666c6 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -27,7 +27,7 @@ #include "linden_common.h" #include "llmaterial.h" -#include "llmd5.h" +#include "hbxxh.h" /** * Materials cap parameters @@ -479,13 +479,9 @@ U32 LLMaterial::getShaderMask(U32 alpha_mode) LLUUID LLMaterial::getHash() const { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - LLMD5 md5; // HACK - hash the bytes of this LLMaterial, but trim off the S32 in LLRefCount - md5.update((unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); - md5.finalize(); LLUUID id; - md5.raw_digest(id.mData); - // *TODO: Hash the overrides + HBXXH128::digest(id, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); return id; } diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index a5990492b1..e35e889a69 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -458,7 +458,7 @@ void LLRenderPass::pushGLTFBatches(U32 type) auto& mat = params.mGLTFMaterial; - mat->bind(); + mat->bind(params.mTexture); LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); @@ -489,7 +489,7 @@ void LLRenderPass::pushRiggedGLTFBatches(U32 type) auto& mat = params.mGLTFMaterial; - mat->bind(); + mat->bind(params.mTexture); LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 4c8d32fad2..d3d5235770 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -679,7 +679,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) gPipeline.bindDeferredShaderFast(*target_shader); } - params.mGLTFMaterial->bind(); + params.mGLTFMaterial->bind(params.mTexture); } else { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 811f475705..45e7709409 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -362,7 +362,7 @@ void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture) if (ch == LLRender::DIFFUSE_MAP) { - getViewerObject()->changeTEImage(mTEOffset, new_texture) ; + getViewerObject()->changeTEImage(mTEOffset, new_texture) ; } setTexture(ch, new_texture) ; diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 047f1a4965..003b373e50 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -46,7 +46,7 @@ LLFetchedGLTFMaterial::~LLFetchedGLTFMaterial() } -void LLFetchedGLTFMaterial::bind() +void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) { // glTF 2.0 Specification 3.9.4. Alpha Coverage // mAlphaCutoff is only valid for LLGLTFMaterial::ALPHA_MODE_MASK @@ -54,15 +54,19 @@ void LLFetchedGLTFMaterial::bind() LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + // override emissive and base color textures with media tex if present + LLViewerTexture* baseColorTex = media_tex ? media_tex : mBaseColorTexture; + LLViewerTexture* emissiveTex = media_tex ? media_tex : mEmissiveTexture; + if (mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) { min_alpha = mAlphaCutoff; } shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha); - if (mBaseColorTexture.notNull()) + if (baseColorTex != nullptr) { - gGL.getTexUnit(0)->bindFast(mBaseColorTexture); + gGL.getTexUnit(0)->bindFast(baseColorTex); } else { @@ -89,9 +93,9 @@ void LLFetchedGLTFMaterial::bind() shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); } - if (mEmissiveTexture.notNull()) + if (emissiveTex != nullptr) { - shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, mEmissiveTexture); // PBR sRGB Emissive + shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, emissiveTex); // PBR sRGB Emissive } else { diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h index f784f19c4f..96f7fbea8e 100644 --- a/indra/newview/llfetchedgltfmaterial.h +++ b/indra/newview/llfetchedgltfmaterial.h @@ -43,7 +43,8 @@ public: void onMaterialComplete(std::function material_complete); // bind this material for rendering - void bind(); + // media_tex - optional media texture that may override the base color texture + void bind(LLViewerTexture* media_tex = nullptr); // Textures used for fetching/rendering LLPointer mBaseColorTexture; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 02d1654878..c9fbe680c7 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5220,13 +5220,16 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, if (gltf_mat != nullptr) { mat_id = gltf_mat->getHash(); // TODO: cache this hash + if (!facep->hasMedia()) + { // no media texture, face texture will be unused + tex = nullptr; + } } else { mat = facep->getTextureEntry()->getMaterialParams().get(); if (mat) { - //mat_id = facep->getTextureEntry()->getMaterialID().asUUID(); mat_id = facep->getTextureEntry()->getMaterialParams()->getHash(); } } -- cgit v1.3 From a2647e953aeee26ef99e62e0146adcd37c8afca1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Feb 2023 18:25:22 -0600 Subject: SL-18229 Fix for PBR materials on HUDs misbehaving. Incidental decruft. --- indra/llrender/llglslshader.cpp | 1 - indra/llrender/llglslshader.h | 1 - indra/llrender/llshadermgr.cpp | 75 ------------------ .../shaders/class1/deferred/pbralphaV.glsl | 61 +++++++++++---- .../shaders/class1/deferred/pbropaqueF.glsl | 49 ++++++++++++ .../shaders/class1/deferred/pbropaqueV.glsl | 45 ++++++++++- .../class1/lighting/lightFullbrightAlphaMaskF.glsl | 59 -------------- .../shaders/class1/lighting/lightFullbrightF.glsl | 54 ------------- .../lightFullbrightNonIndexedAlphaMaskF.glsl | 63 --------------- .../lighting/lightFullbrightNonIndexedF.glsl | 50 ------------ .../lighting/lightFullbrightWaterAlphaMaskF.glsl | 57 -------------- .../class1/lighting/lightFullbrightWaterF.glsl | 48 ------------ .../lightFullbrightWaterNonIndexedAlphaMaskF.glsl | 57 -------------- .../lighting/lightFullbrightWaterNonIndexedF.glsl | 48 ------------ .../shaders/class1/objects/fullbrightF.glsl | 33 -------- .../shaders/class1/objects/fullbrightV.glsl | 65 ---------------- .../shaders/class2/deferred/pbralphaF.glsl | 58 ++++++++++++++ indra/newview/lldrawpoolalpha.cpp | 10 ++- indra/newview/lldrawpoolalpha.h | 1 + indra/newview/lldrawpoolpbropaque.cpp | 32 +++++++- indra/newview/lldrawpoolpbropaque.h | 5 +- indra/newview/llviewerdisplay.cpp | 3 + indra/newview/llviewershadermgr.cpp | 91 ++++++++++------------ indra/newview/llviewershadermgr.h | 3 +- indra/newview/llvovolume.cpp | 72 ++++++++++------- indra/newview/pipeline.cpp | 4 + 26 files changed, 326 insertions(+), 719 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 4e32e2bd25..59e8e86fbb 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -86,7 +86,6 @@ LLShaderFeatures::LLShaderFeatures() , calculatesAtmospherics(false) , hasLighting(false) , isAlphaLighting(false) - , isFullbright(false) , isSpecular(false) , hasWaterFog(false) , hasTransport(false) diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 2b709cc6b4..b0d5f308f3 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -39,7 +39,6 @@ public: bool calculatesAtmospherics; bool hasLighting; // implies no transport (it's possible to have neither though) bool isAlphaLighting; // indicates lighting shaders need not be linked in (lighting performed directly in alpha shader to match deferred lighting functions) - bool isFullbright; // implies no lighting bool isSpecular; bool hasWaterFog; // implies no gamma bool hasTransport; // implies no lighting (it's possible to have neither though) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 54dbb0d025..7a7c5beb38 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -380,82 +380,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } } - // NOTE order of shader object attaching is VERY IMPORTANT!!! - else if (features->isFullbright) - { - if (features->hasWaterFog) - { - if (features->disableTextureIndex) - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl")) - { - return FALSE; - } - } - else if (!shader->attachFragmentObject("lighting/lightFullbrightWaterNonIndexedF.glsl")) - { - return FALSE; - } - } - else - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightWaterAlphaMaskF.glsl")) - { - return FALSE; - } - } - else if (!shader->attachFragmentObject("lighting/lightFullbrightWaterF.glsl")) - { - return FALSE; - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - else - { - if (features->disableTextureIndex) - { - - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightNonIndexedAlphaMaskF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightFullbrightNonIndexedF.glsl")) - { - return FALSE; - } - } - } - else - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightAlphaMaskF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightFullbrightF.glsl")) - { - return FALSE; - } - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - } if (features->mIndexedTextureChannels <= 1) { if (!shader->attachVertexObject("objects/nonindexedTextureV.glsl")) diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index a2ad1b70fb..597ab22f42 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -23,10 +23,10 @@ * $/LicenseInfo$ */ -#define DIFFUSE_ALPHA_MODE_IGNORE 0 -#define DIFFUSE_ALPHA_MODE_BLEND 1 -#define DIFFUSE_ALPHA_MODE_MASK 2 -#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#ifndef IS_HUD + +// default alpha implementation #ifdef HAS_SKIN uniform mat4 modelview_matrix; @@ -38,13 +38,12 @@ uniform mat4 modelview_projection_matrix; #endif uniform mat4 texture_matrix0; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - #if !defined(HAS_SKIN) - uniform mat4 modelview_matrix; - #endif - VARYING vec3 vary_position; +#if !defined(HAS_SKIN) +uniform mat4 modelview_matrix; #endif +out vec3 vary_position; + uniform mat3 texture_basecolor_matrix; uniform mat3 texture_normal_matrix; uniform mat3 texture_metallic_roughness_matrix; @@ -79,9 +78,7 @@ void main() mat4 mat = getObjectSkinnedTransform(); mat = modelview_matrix * mat; vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vary_position = pos; -#endif vec4 vert = projection_matrix * vec4(pos,1.0); #else //transform vertex @@ -112,9 +109,45 @@ void main() vertex_color = diffuse_color; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - #if !defined(HAS_SKIN) +#if !defined(HAS_SKIN) vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; - #endif #endif } + +#else + +// fullbright HUD alpha implementation + +uniform mat4 modelview_projection_matrix; + +uniform mat4 texture_matrix0; + +uniform mat4 modelview_matrix; + +out vec3 vary_position; + +uniform mat3 texture_basecolor_matrix; +uniform mat3 texture_emissive_matrix; + +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; + +out vec2 basecolor_texcoord; +out vec2 emissive_texcoord; + +out vec4 vertex_color; + +void main() +{ + //transform vertex + vec4 vert = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = vert; + + basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy; + emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy; + + vertex_color = diffuse_color; +} + +#endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index 39419e9d78..483ce4c3d0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -25,6 +25,11 @@ /*[EXTRA_CODE_HERE]*/ + +#ifndef IS_HUD + +// deferred opaque implementation + uniform sampler2D diffuseMap; //always in sRGB space uniform float metallicFactor; @@ -101,3 +106,47 @@ void main() frag_data[2] = vec4(encode_normal(tnorm), vertex_color.a, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags frag_data[3] = vec4(emissive,0); // PBR sRGB Emissive } + +#else + +// forward fullbright implementation for HUDs + +uniform sampler2D diffuseMap; //always in sRGB space + +uniform vec3 emissiveColor; +uniform sampler2D emissiveMap; + +out vec4 frag_color; + +in vec3 vary_position; +in vec4 vertex_color; + +in vec2 basecolor_texcoord; +in vec2 emissive_texcoord; + +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() + +vec3 linear_to_srgb(vec3 c); +vec3 srgb_to_linear(vec3 c); + +void main() +{ + vec4 basecolor = texture2D(diffuseMap, basecolor_texcoord.xy).rgba; + if (basecolor.a < minimum_alpha) + { + discard; + } + + vec3 col = vertex_color.rgb * srgb_to_linear(basecolor.rgb); + + vec3 emissive = emissiveColor; + emissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb); + + col += emissive; + + // HUDs are rendered after gamma correction, output in sRGB space + frag_color.rgb = linear_to_srgb(col); + frag_color.a = 0.0; +} + +#endif \ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index 5a69da641a..8320640e42 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -23,10 +23,10 @@ * $/LicenseInfo$ */ -#define DIFFUSE_ALPHA_MODE_IGNORE 0 -#define DIFFUSE_ALPHA_MODE_BLEND 1 -#define DIFFUSE_ALPHA_MODE_MASK 2 -#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#ifndef IS_HUD + +//deferred opaque implementation #ifdef HAS_SKIN uniform mat4 modelview_matrix; @@ -95,3 +95,40 @@ void main() vertex_color = diffuse_color; } + +#else + +// fullbright HUD implementation + +uniform mat4 modelview_projection_matrix; + +uniform mat4 texture_matrix0; + +uniform mat3 texture_basecolor_matrix; +uniform mat3 texture_normal_matrix; +uniform mat3 texture_metallic_roughness_matrix; +uniform mat3 texture_emissive_matrix; + +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; + +out vec2 basecolor_texcoord; +out vec2 emissive_texcoord; + +out vec4 vertex_color; + +void main() +{ + //transform vertex + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + + basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy; + emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy; + + vertex_color = diffuse_color; +} + +#endif + + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl deleted file mode 100644 index 00749213db..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform float minimum_alpha; -uniform float texture_gamma; // either 1.0 or 2.2; see: "::TEXTURE_GAMMA" - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void fullbright_lighting() -{ - vec4 color = diffuseLookup(vary_texcoord0.xy); - - if (color.a < minimum_alpha) - { - discard; - } - - color *= vertex_color; - - color.rgb = pow(color.rgb, vec3(texture_gamma)); - - color.rgb = fullbrightAtmosTransport(color.rgb); - color.rgb = fullbrightScaleSoftClip(color.rgb); - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl deleted file mode 100644 index b9dc332043..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -uniform float texture_gamma; - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -void fullbright_lighting() -{ - vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; - - color.rgb = pow(color.rgb, vec3(texture_gamma)); - - color.rgb = fullbrightAtmosTransport(color.rgb); - color.rgb = fullbrightScaleSoftClip(color.rgb); - - color.rgb = pow(color.rgb, vec3(1.0/texture_gamma)); - - frag_color = color; - -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl deleted file mode 100644 index e8e71beb44..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightNonIndexedAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform float minimum_alpha; -uniform float texture_gamma; - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -uniform sampler2D diffuseMap; - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void fullbright_lighting() -{ - vec4 color = texture2D(diffuseMap,vary_texcoord0.xy); - - if (color.a < minimum_alpha) - { - discard; - } - - color.rgb *= vertex_color.rgb; - - color.rgb = pow(color.rgb, vec3(texture_gamma)); - color.rgb = fullbrightAtmosTransport(color.rgb); - - color.rgb = fullbrightScaleSoftClip(color.rgb); - - color.rgb = pow(color.rgb, vec3(1.0/texture_gamma)); - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl deleted file mode 100644 index 11a0919086..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -uniform sampler2D diffuseMap; - -void fullbright_lighting() -{ - vec4 color = texture2D(diffuseMap,vary_texcoord0.xy) * vertex_color; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - color.rgb = fullbrightScaleSoftClip(color.rgb); - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl deleted file mode 100644 index 37cac5f437..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightWaterAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform float minimum_alpha; - -/* vec4 diffuseLookup(vec2 texcoord); */ - -vec3 fullbrightAtmosTransport(vec3 light); -vec4 applyWaterFog(vec4 color); - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void fullbright_lighting_water() -{ - vec4 color = diffuseLookup(vary_texcoord0.xy); - - if (color.a < minimum_alpha) - { - discard; - } - - color.rgb *= vertex_color.rgb; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = applyWaterFog(color); -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl deleted file mode 100644 index 27880b720c..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightWaterF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -/* vec4 diffuseLookup(vec2 texcoord); */ - -vec3 fullbrightAtmosTransport(vec3 light); -vec4 applyWaterFog(vec4 color); - -void fullbright_lighting_water() -{ - vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = applyWaterFog(color); -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl deleted file mode 100644 index c98db4795c..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightWaterNonIndexedAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform float minimum_alpha; - -uniform sampler2D diffuseMap; - -vec3 fullbrightAtmosTransport(vec3 light); -vec4 applyWaterFog(vec4 color); - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void fullbright_lighting_water() -{ - vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); - - if (color.a < minimum_alpha) - { - discard; - } - - color.rgb *= vertex_color.rgb; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = applyWaterFog(color); -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl deleted file mode 100644 index e9fd8ac820..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightWaterF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -uniform sampler2D diffuseMap; - -vec3 fullbrightAtmosTransport(vec3 light); -vec4 applyWaterFog(vec4 color); - -void fullbright_lighting_water() -{ - vec4 color = texture2D(diffuseMap, vary_texcoord0.xy) * vertex_color; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = applyWaterFog(color); -} - diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl deleted file mode 100644 index 31a262f1db..0000000000 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file objects/fullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$F - */ - - - -void fullbright_lighting(); - -void main() -{ - fullbright_lighting(); -} diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl deleted file mode 100644 index 5af42f1fcf..0000000000 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file fullbrightV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_matrix; -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -void passTextureIndex(); -ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec3 normal; -ATTRIBUTE vec4 diffuse_color; - -void calcAtmospherics(vec3 inPositionEye); - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -#ifdef HAS_SKIN -mat4 getObjectSkinnedTransform(); -uniform mat4 projection_matrix; -#endif - -void main() -{ - //transform vertex - vec4 vert = vec4(position.xyz,1.0); - passTextureIndex(); -#ifdef HAS_SKIN - mat4 mat = getObjectSkinnedTransform(); - mat = modelview_matrix * mat; - vec4 pos = mat * vert; - gl_Position = projection_matrix * pos; -#else - vec4 pos = (modelview_matrix * vert); - gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); -#endif - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - - calcAtmospherics(pos.xyz); - - vertex_color = diffuse_color; -} diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index 35e22ef3a2..35ccc65a8e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -25,6 +25,8 @@ /*[EXTRA_CODE_HERE]*/ +#ifndef IS_HUD + uniform sampler2D diffuseMap; //always in sRGB space uniform sampler2D bumpMap; uniform sampler2D emissiveMap; @@ -249,3 +251,59 @@ void main() a += f; frag_color = vec4(color.rgb,a); } + +#else + +uniform sampler2D diffuseMap; //always in sRGB space +uniform sampler2D emissiveMap; + +uniform vec3 emissiveColor; + +out vec4 frag_color; + +in vec3 vary_position; + +in vec2 basecolor_texcoord; +in vec2 emissive_texcoord; + +in vec4 vertex_color; + +#ifdef HAS_ALPHA_MASK +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() +#endif + +vec3 srgb_to_linear(vec3 c); +vec3 linear_to_srgb(vec3 c); + + +void main() +{ + vec3 color = vec3(0,0,0); + + vec3 pos = vary_position; + + vec4 basecolor = texture(diffuseMap, basecolor_texcoord.xy).rgba; + basecolor.rgb = srgb_to_linear(basecolor.rgb); +#ifdef HAS_ALPHA_MASK + if (basecolor.a < minimum_alpha) + { + discard; + } +#endif + + color = vertex_color.rgb * basecolor.rgb; + + // emissiveColor is the emissive color factor from GLTF and is already in linear space + vec3 colorEmissive = emissiveColor; + // emissiveMap here is a vanilla RGB texture encoded as sRGB, manually convert to linear + colorEmissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb); + + + float a = basecolor.a*vertex_color.a; + a = 1.0; + color += colorEmissive; + color = linear_to_srgb(color); + frag_color = vec4(color.rgb,a); +} + +#endif diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index a7ce1a9f87..3dda24595e 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -199,7 +199,9 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) prepare_alpha_shader(&materialShader[i], false, true, water_sign); } - prepare_alpha_shader(&gDeferredPBRAlphaProgram, false, true, water_sign); + pbr_shader = LLPipeline::sRenderingHUDs ? &gHUDPBRAlphaProgram : &gDeferredPBRAlphaProgram; + + prepare_alpha_shader(pbr_shader, false, true, water_sign); if (!LLPipeline::sRenderingHUDs) { @@ -211,10 +213,10 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) forwardRender(); // final pass, render to depth for depth of field effects - if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField") && !gCubeSnapshot) + if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField") && !gCubeSnapshot && !LLPipeline::sRenderingHUDs) { //update depth buffer sampler - simple_shader = fullbright_shader = &gObjectFullbrightAlphaMaskProgram; + simple_shader = fullbright_shader = &gDeferredFullbrightAlphaMaskProgram; simple_shader->bind(); simple_shader->setMinimumAlpha(0.33f); @@ -630,7 +632,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) if (gltf_mat && gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND) { - target_shader = &gDeferredPBRAlphaProgram; + target_shader = pbr_shader; if (params.mAvatar != nullptr) { target_shader = target_shader->mRiggedVariant; diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h index b6cf54a7dd..1e10bb5566 100644 --- a/indra/newview/lldrawpoolalpha.h +++ b/indra/newview/lldrawpoolalpha.h @@ -77,6 +77,7 @@ private: LLGLSLShader* simple_shader = nullptr; LLGLSLShader* fullbright_shader = nullptr; LLGLSLShader* emissive_shader = nullptr; + LLGLSLShader* pbr_shader = nullptr; void drawEmissive(U32 mask, LLDrawInfo* draw); void renderEmissives(U32 mask, std::vector& emissives); diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 9dd1bc0ba2..c5413a068a 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -31,22 +31,46 @@ #include "llviewershadermgr.h" #include "pipeline.h" +static const U32 gltf_render_types[] = { LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK }; + LLDrawPoolGLTFPBR::LLDrawPoolGLTFPBR() : LLRenderPass(POOL_GLTF_PBR) { } +S32 LLDrawPoolGLTFPBR::getNumDeferredPasses() +{ + return 1; +} + void LLDrawPoolGLTFPBR::renderDeferred(S32 pass) { - const U32 types[] = { LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK }; + llassert(!LLPipeline::sRenderingHUDs); - for (U32 type : types) + for (U32 type : gltf_render_types) { gDeferredPBROpaqueProgram.bind(); pushGLTFBatches(type); - + gDeferredPBROpaqueProgram.bind(true); - pushRiggedGLTFBatches(type+1); + pushRiggedGLTFBatches(type + 1); + } +} + +S32 LLDrawPoolGLTFPBR::getNumPostDeferredPasses() +{ + return LLPipeline::sRenderingHUDs ? 1 : 0; +} + +void LLDrawPoolGLTFPBR::renderPostDeferred(S32 pass) +{ + // only HUD rendering should execute this pass + llassert(LLPipeline::sRenderingHUDs); + + gHUDPBROpaqueProgram.bind(); + for (U32 type : gltf_render_types) + { + pushGLTFBatches(type); } } diff --git a/indra/newview/lldrawpoolpbropaque.h b/indra/newview/lldrawpoolpbropaque.h index 2fe0695c69..69e063b322 100644 --- a/indra/newview/lldrawpoolpbropaque.h +++ b/indra/newview/lldrawpoolpbropaque.h @@ -48,8 +48,11 @@ public: LLDrawPoolGLTFPBR(); - S32 getNumDeferredPasses() override { return 1; } + S32 getNumDeferredPasses() override; void renderDeferred(S32 pass) override; + + S32 getNumPostDeferredPasses() override; + void renderPostDeferred(S32 pass) override; }; #endif // LL_LLDRAWPOOLPBROPAQUE_H diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 2e20d61b15..62144b2d31 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1161,6 +1161,7 @@ void render_hud_attachments() gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA_MASK); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_FULLBRIGHT); + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_GLTF_PBR); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_BUMP); @@ -1171,6 +1172,8 @@ void render_hud_attachments() gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_SHINY); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_INVISIBLE); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY); + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_GLTF_PBR); + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK); gPipeline.stateSort(hud_cam, result); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 23cb32357c..ccb2a86128 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -205,8 +205,10 @@ LLGLSLShader gDeferredGenBrdfLutProgram; // Deferred materials shaders LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; +LLGLSLShader gHUDPBROpaqueProgram; LLGLSLShader gDeferredPBROpaqueProgram; LLGLSLShader gDeferredSkinnedPBROpaqueProgram; +LLGLSLShader gHUDPBRAlphaProgram; LLGLSLShader gDeferredPBRAlphaProgram; LLGLSLShader gDeferredSkinnedPBRAlphaProgram; @@ -284,6 +286,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredWLMoonProgram); mShaderList.push_back(&gDeferredWLSunProgram); mShaderList.push_back(&gDeferredPBRAlphaProgram); + mShaderList.push_back(&gHUDPBRAlphaProgram); mShaderList.push_back(&gDeferredSkinnedPBRAlphaProgram); } @@ -555,7 +558,6 @@ void LLViewerShaderMgr::unloadShaders() gImpostorProgram.unload(); gObjectBumpProgram.unload(); gSkinnedObjectBumpProgram.unload(); - gObjectFullbrightAlphaMaskProgram.unload(); gSkinnedObjectFullbrightAlphaMaskProgram.unload(); gObjectAlphaMaskNoColorProgram.unload(); @@ -738,21 +740,13 @@ std::string LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/screenSpaceReflUtil.glsl", ssr ? 3 : 1) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - + for (U32 i = 0; i < shaders.size(); i++) { // Note usage of GL_FRAGMENT_SHADER @@ -1021,6 +1015,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialWaterProgram[i].unload(); } + gHUDPBROpaqueProgram.unload(); gDeferredPBROpaqueProgram.unload(); gDeferredSkinnedPBROpaqueProgram.unload(); gDeferredPBRAlphaProgram.unload(); @@ -1321,11 +1316,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueV.glsl", GL_VERTEX_SHADER)); gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueF.glsl", GL_FRAGMENT_SHADER)); gDeferredPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - gDeferredPBROpaqueProgram.addPermutation("HAS_NORMAL_MAP", "1"); - gDeferredPBROpaqueProgram.addPermutation("HAS_SPECULAR_MAP", "1"); - gDeferredPBROpaqueProgram.addPermutation("HAS_EMISSIVE_MAP", "1"); - gDeferredPBROpaqueProgram.addPermutation("DIFFUSE_ALPHA_MODE", "0"); - + success = make_rigged_variant(gDeferredPBROpaqueProgram, gDeferredSkinnedPBROpaqueProgram); if (success) { @@ -1334,6 +1325,22 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() llassert(success); } + if (success) + { + gHUDPBROpaqueProgram.mName = "HUD PBR Opaque Shader"; + gHUDPBROpaqueProgram.mFeatures.hasSrgb = true; + gHUDPBROpaqueProgram.mShaderFiles.clear(); + gHUDPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueV.glsl", GL_VERTEX_SHADER)); + gHUDPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueF.glsl", GL_FRAGMENT_SHADER)); + gHUDPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + gHUDPBROpaqueProgram.clearPermutations(); + gHUDPBROpaqueProgram.addPermutation("IS_HUD", "1"); + + success = gHUDPBROpaqueProgram.createShader(NULL, NULL); + + llassert(success); + } + if (success) { LLGLSLShader* shader = &gDeferredPBRAlphaProgram; @@ -1370,21 +1377,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->addPermutation("HAS_SUN_SHADOW", "1"); } - if (ambient_kill) - { - shader->addPermutation("AMBIENT_KILL", "1"); - } - - if (sunlight_kill) - { - shader->addPermutation("SUNLIGHT_KILL", "1"); - } - - if (local_light_kill) - { - shader->addPermutation("LOCAL_LIGHT_KILL", "1"); - } - shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = make_rigged_variant(*shader, gDeferredSkinnedPBRAlphaProgram); if (success) @@ -1402,6 +1394,25 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->mRiggedVariant->mFeatures.hasLighting = true; } + if (success) + { + LLGLSLShader* shader = &gHUDPBRAlphaProgram; + shader->mName = "HUD PBR Alpha Shader"; + + shader->mFeatures.hasSrgb = true; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaV.glsl", GL_VERTEX_SHADER)); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaF.glsl", GL_FRAGMENT_SHADER)); + + shader->clearPermutations(); + + shader->addPermutation("IS_HUD", "1"); + + shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = shader->createShader(NULL, NULL); + llassert(success); + } if (success) { @@ -2593,7 +2604,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLSunProgram.mFeatures.hasTransport = true; gDeferredWLSunProgram.mFeatures.hasGamma = true; gDeferredWLSunProgram.mFeatures.hasAtmospherics = true; - gDeferredWLSunProgram.mFeatures.isFullbright = true; gDeferredWLSunProgram.mFeatures.disableTextureIndex = true; gDeferredWLSunProgram.mFeatures.hasSrgb = true; gDeferredWLSunProgram.mShaderFiles.clear(); @@ -2613,7 +2623,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mFeatures.hasGamma = true; gDeferredWLMoonProgram.mFeatures.hasAtmospherics = true; gDeferredWLMoonProgram.mFeatures.hasSrgb = true; - gDeferredWLMoonProgram.mFeatures.isFullbright = true; gDeferredWLMoonProgram.mFeatures.disableTextureIndex = true; gDeferredWLMoonProgram.mShaderFiles.clear(); @@ -2785,24 +2794,6 @@ BOOL LLViewerShaderMgr::loadShadersObject() gPhysicsPreviewProgram.mFeatures.hasLighting = false; } - if (success) - { - gObjectFullbrightAlphaMaskProgram.mName = "Fullbright Alpha Mask Shader"; - gObjectFullbrightAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.hasGamma = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.isFullbright = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.hasAlphaMask = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.hasSrgb = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = 0; - gObjectFullbrightAlphaMaskProgram.mShaderFiles.clear(); - gObjectFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER)); - gObjectFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER)); - gObjectFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; - success = make_rigged_variant(gObjectFullbrightAlphaMaskProgram, gSkinnedObjectFullbrightAlphaMaskProgram); - success = success && gObjectFullbrightAlphaMaskProgram.createShader(NULL, NULL); - } - if (!success) { mShaderLevel[SHADER_OBJECT] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index d5a7a4d359..027dea6f8d 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -170,7 +170,6 @@ extern LLGLSLShader gOneTextureFilterProgram; //object shaders extern LLGLSLShader gObjectPreviewProgram; extern LLGLSLShader gPhysicsPreviewProgram; -extern LLGLSLShader gObjectFullbrightAlphaMaskProgram; extern LLGLSLShader gSkinnedObjectFullbrightAlphaMaskProgram; extern LLGLSLShader gObjectBumpProgram; extern LLGLSLShader gSkinnedObjectBumpProgram; @@ -268,6 +267,8 @@ extern LLGLSLShader gDeferredGenBrdfLutProgram; extern LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; extern LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; +extern LLGLSLShader gHUDPBROpaqueProgram; extern LLGLSLShader gDeferredPBROpaqueProgram; extern LLGLSLShader gDeferredPBRAlphaProgram; +extern LLGLSLShader gHUDPBRAlphaProgram; #endif diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 865c3df1e4..0c5aac4d0f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5306,33 +5306,35 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, } } - if (idx >= 0 && - draw_vec[idx]->mVertexBuffer == facep->getVertexBuffer() && - draw_vec[idx]->mEnd == facep->getGeomIndex()-1 && + LLDrawInfo* info = idx >= 0 ? draw_vec[idx] : nullptr; + + if (info && + info->mVertexBuffer == facep->getVertexBuffer() && + info->mEnd == facep->getGeomIndex()-1 && (LLPipeline::sTextureBindTest || draw_vec[idx]->mTexture == tex || batchable) && #if LL_DARWIN - draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && - draw_vec[idx]->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && + info->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && + info->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && #endif - draw_vec[idx]->mMaterialID == mat_id && - draw_vec[idx]->mFullbright == fullbright && - draw_vec[idx]->mBump == bump && - (!mat || (draw_vec[idx]->mShiny == shiny)) && // need to break batches when a material is shared, but legacy settings are different - draw_vec[idx]->mTextureMatrix == tex_mat && - draw_vec[idx]->mModelMatrix == model_mat && - draw_vec[idx]->mShaderMask == shader_mask && - draw_vec[idx]->mAvatar == facep->mAvatar && - draw_vec[idx]->getSkinHash() == facep->getSkinHash()) + info->mMaterialID == mat_id && + info->mFullbright == fullbright && + info->mBump == bump && + (!mat || (info->mShiny == shiny)) && // need to break batches when a material is shared, but legacy settings are different + info->mTextureMatrix == tex_mat && + info->mModelMatrix == model_mat && + info->mShaderMask == shader_mask && + info->mAvatar == facep->mAvatar && + info->getSkinHash() == facep->getSkinHash()) { - draw_vec[idx]->mCount += facep->getIndicesCount(); - draw_vec[idx]->mEnd += facep->getGeomCount(); + info->mCount += facep->getIndicesCount(); + info->mEnd += facep->getGeomCount(); - if (index < FACE_DO_NOT_BATCH_TEXTURES && index >= draw_vec[idx]->mTextureList.size()) + if (index < FACE_DO_NOT_BATCH_TEXTURES && index >= info->mTextureList.size()) { - draw_vec[idx]->mTextureList.resize(index+1); - draw_vec[idx]->mTextureList[index] = tex; + info->mTextureList.resize(index+1); + info->mTextureList[index] = tex; } - draw_vec[idx]->validate(); + info->validate(); } else { @@ -5342,6 +5344,9 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 count = facep->getIndicesCount(); LLPointer draw_info = new LLDrawInfo(start,end,count,offset, tex, facep->getVertexBuffer(), fullbright, bump); + + info = draw_info; + draw_vec.push_back(draw_info); draw_info->mTextureMatrix = tex_mat; draw_info->mModelMatrix = model_mat; @@ -5417,6 +5422,13 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, } draw_info->validate(); } + + llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR || info->mGLTFMaterial != nullptr); + llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED || info->mGLTFMaterial != nullptr); + llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK || info->mGLTFMaterial != nullptr); + llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK_RIGGED || info->mGLTFMaterial != nullptr); + + llassert(type != LLRenderPass::PASS_NORMSPEC || info->mNormalMap.notNull()); } void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group) @@ -5790,7 +5802,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } facep->setPoolType(type); - if (vobj->isHUDAttachment()) + if (vobj->isHUDAttachment() && !is_pbr) { facep->setState(LLFace::FULLBRIGHT); } @@ -6487,17 +6499,17 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace fullbright = TRUE; } - if (hud_group) + const LLTextureEntry* te = facep->getTextureEntry(); + LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); + + if (hud_group && gltf_mat == nullptr) { //all hud attachments are fullbright fullbright = TRUE; } - - const LLTextureEntry* te = facep->getTextureEntry(); + tex = facep->getTexture(); BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) ? TRUE : FALSE; - - LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); LLMaterial* mat = nullptr; bool can_be_shiny = false; @@ -6523,7 +6535,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace is_alpha = (is_alpha || transparent) ? TRUE : FALSE; - if ((gltf_mat || mat) && LLPipeline::sRenderDeferred && !hud_group) + if (gltf_mat || (mat && !hud_group)) { bool material_pass = false; @@ -6692,7 +6704,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace registerFace(group, facep, LLRenderPass::PASS_INVISI_SHINY); registerFace(group, facep, LLRenderPass::PASS_INVISIBLE); } - else if (LLPipeline::sRenderDeferred && !hud_group) + else if (!hud_group) { //deferred rendering if (te->getFullbright()) { //register in post deferred fullbright shiny pass @@ -6737,7 +6749,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace { registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); } - if (LLPipeline::sRenderDeferred && !hud_group && LLPipeline::sRenderBump && use_legacy_bump) + if (!hud_group && LLPipeline::sRenderBump && use_legacy_bump) { //if this is the deferred render and a bump map is present, register in post deferred bump registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); } @@ -6773,7 +6785,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } //not sure why this is here, and looks like it might cause bump mapped objects to get rendered redundantly -- davep 5/11/2010 - if (!is_alpha && (hud_group || !LLPipeline::sRenderDeferred)) + if (!is_alpha && hud_group) { llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6905450e26..039ad9cf8f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3934,6 +3934,8 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); LL_PROFILE_GPU_ZONE("renderGeomDeferred"); + llassert(!sRenderingHUDs); + if (gUseWireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -7998,6 +8000,8 @@ void LLPipeline::renderDeferredLighting() return; } + llassert(!sRenderingHUDs); + static LLCachedControl ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); F32 light_scale = 1.f; -- cgit v1.3 From 577f6a46f02ecfa4efabc0b379e44e4f53a0b391 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Feb 2023 17:00:36 -0600 Subject: SL-19181 Modulate "glow" by PBR emissive. --- .../shaders/class1/deferred/pbrglowF.glsl | 67 +++++++++++++++ .../shaders/class1/deferred/pbrglowV.glsl | 70 ++++++++++++++++ indra/newview/lldrawpool.h | 2 + indra/newview/lldrawpoolalpha.cpp | 97 +++++++++++++++++++--- indra/newview/lldrawpoolalpha.h | 9 +- indra/newview/lldrawpoolpbropaque.cpp | 25 ++++-- indra/newview/llfetchedgltfmaterial.cpp | 4 +- indra/newview/llviewershadermgr.cpp | 22 +++++ indra/newview/llviewershadermgr.h | 1 + indra/newview/llvovolume.cpp | 14 +++- indra/newview/pipeline.cpp | 2 + indra/newview/pipeline.h | 2 + 12 files changed, 290 insertions(+), 25 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/deferred/pbrglowF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrglowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrglowF.glsl new file mode 100644 index 0000000000..8dc9e02f7a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrglowF.glsl @@ -0,0 +1,67 @@ +/** + * @file pbrglowF.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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$ + */ + +/*[EXTRA_CODE_HERE]*/ + +// forward fullbright implementation for HUDs + +uniform sampler2D diffuseMap; //always in sRGB space + +uniform vec3 emissiveColor; +uniform sampler2D emissiveMap; + +out vec4 frag_color; + +in vec3 vary_position; +in vec4 vertex_emissive; + +in vec2 basecolor_texcoord; +in vec2 emissive_texcoord; + +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() + +vec3 linear_to_srgb(vec3 c); +vec3 srgb_to_linear(vec3 c); + +void main() +{ + vec4 basecolor = texture2D(diffuseMap, basecolor_texcoord.xy).rgba; + + if (basecolor.a < minimum_alpha) + { + discard; + } + + vec3 emissive = emissiveColor; + emissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb); + + float lum = max(max(emissive.r, emissive.g), emissive.b); + lum *= vertex_emissive.a; + + // HUDs are rendered after gamma correction, output in sRGB space + frag_color.rgb = vec3(0); + frag_color.a = lum; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl new file mode 100644 index 0000000000..75b24336c5 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl @@ -0,0 +1,70 @@ +/** + * @file pbgglowV.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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$ + */ + + +#ifdef HAS_SKIN +uniform mat4 modelview_matrix; +uniform mat4 projection_matrix; +mat4 getObjectSkinnedTransform(); +#else +uniform mat4 modelview_projection_matrix; +#endif + +uniform mat4 texture_matrix0; + +uniform mat3 texture_basecolor_matrix; +uniform mat3 texture_emissive_matrix; + +in vec3 position; +in vec4 emissive; + +in vec2 texcoord0; + +out vec2 basecolor_texcoord; +out vec2 emissive_texcoord; + +out vec4 vertex_emissive; + +void main() +{ +#ifdef HAS_SKIN + mat4 mat = getObjectSkinnedTransform(); + + mat = modelview_matrix * mat; + + vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; + + gl_Position = projection_matrix*vec4(pos,1.0); +#else + //transform vertex + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); +#endif + + basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy; + emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy; + + vertex_emissive = emissive; +} + diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index a60d09c154..2c5e31f579 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -184,6 +184,8 @@ public: PASS_NORMSPEC_EMISSIVE_RIGGED, PASS_GLOW, PASS_GLOW_RIGGED, + PASS_GLTF_GLOW, + PASS_GLTF_GLOW_RIGGED, PASS_ALPHA, PASS_ALPHA_RIGGED, PASS_ALPHA_MASK, diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 3dda24595e..f4b426c5ab 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -175,9 +175,12 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) llassert(LLPipeline::sRenderDeferred); emissive_shader = &gDeferredEmissiveProgram; - prepare_alpha_shader(emissive_shader, true, false, water_sign); + pbr_emissive_shader = &gPBRGlowProgram; + prepare_alpha_shader(pbr_emissive_shader, true, false, water_sign); + + fullbright_shader = (LLPipeline::sImpostorRender) ? &gDeferredFullbrightAlphaMaskProgram : (LLPipeline::sUnderWaterRender) ? &gDeferredFullbrightWaterAlphaProgram : @@ -482,7 +485,7 @@ void LLDrawPoolAlpha::RestoreTexSetup(bool tex_setup) } } -void LLDrawPoolAlpha::drawEmissive(U32 mask, LLDrawInfo* draw) +void LLDrawPoolAlpha::drawEmissive(LLDrawInfo* draw) { LLGLSLShader::sCurBoundShaderPtr->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, 1.f); draw->mVertexBuffer->setBuffer(); @@ -490,7 +493,7 @@ void LLDrawPoolAlpha::drawEmissive(U32 mask, LLDrawInfo* draw) } -void LLDrawPoolAlpha::renderEmissives(U32 mask, std::vector& emissives) +void LLDrawPoolAlpha::renderEmissives(std::vector& emissives) { emissive_shader->bind(); emissive_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, 1.f); @@ -498,12 +501,25 @@ void LLDrawPoolAlpha::renderEmissives(U32 mask, std::vector& emissi for (LLDrawInfo* draw : emissives) { bool tex_setup = TexSetup(draw, false); - drawEmissive(mask, draw); + drawEmissive(draw); RestoreTexSetup(tex_setup); } } -void LLDrawPoolAlpha::renderRiggedEmissives(U32 mask, std::vector& emissives) +void LLDrawPoolAlpha::renderPbrEmissives(std::vector& emissives) +{ + pbr_emissive_shader->bind(); + + for (LLDrawInfo* draw : emissives) + { + llassert(draw->mGLTFMaterial); + draw->mGLTFMaterial->bind(draw->mTexture); + draw->mVertexBuffer->setBuffer(); + draw->mVertexBuffer->drawRange(LLRender::TRIANGLES, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); + } +} + +void LLDrawPoolAlpha::renderRiggedEmissives(std::vector& emissives) { LLGLDepthTest depth(GL_TRUE, GL_FALSE); //disable depth writes since "emissive" is additive so sorting doesn't matter LLGLSLShader* shader = emissive_shader->mRiggedVariant; @@ -513,8 +529,6 @@ void LLDrawPoolAlpha::renderRiggedEmissives(U32 mask, std::vector& LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - mask |= LLVertexBuffer::MAP_WEIGHT4; - for (LLDrawInfo* draw : emissives) { bool tex_setup = TexSetup(draw, false); @@ -527,11 +541,37 @@ void LLDrawPoolAlpha::renderRiggedEmissives(U32 mask, std::vector& lastAvatar = draw->mAvatar; lastMeshId = draw->mSkinInfo->mHash; } - drawEmissive(mask, draw); + drawEmissive(draw); RestoreTexSetup(tex_setup); } } +void LLDrawPoolAlpha::renderRiggedPbrEmissives(std::vector& emissives) +{ + LLGLDepthTest depth(GL_TRUE, GL_FALSE); //disable depth writes since "emissive" is additive so sorting doesn't matter + pbr_emissive_shader->bind(true); + + LLVOAvatar* lastAvatar = nullptr; + U64 lastMeshId = 0; + + for (LLDrawInfo* draw : emissives) + { + if (lastAvatar != draw->mAvatar || lastMeshId != draw->mSkinInfo->mHash) + { + if (!uploadMatrixPalette(*draw)) + { // failed to upload matrix palette, skip rendering + continue; + } + lastAvatar = draw->mAvatar; + lastMeshId = draw->mSkinInfo->mHash; + } + + draw->mGLTFMaterial->bind(draw->mTexture); + draw->mVertexBuffer->setBuffer(); + draw->mVertexBuffer->drawRange(LLRender::TRIANGLES, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); + } +} + void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; @@ -600,8 +640,13 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) static std::vector emissives; static std::vector rigged_emissives; + static std::vector pbr_emissives; + static std::vector pbr_rigged_emissives; + emissives.resize(0); rigged_emissives.resize(0); + pbr_emissives.resize(0); + pbr_rigged_emissives.resize(0); bool is_particle_or_hud_particle = group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_PARTICLE || group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_HUD_PARTICLE; @@ -787,11 +832,25 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) { if (params.mAvatar != nullptr) { - rigged_emissives.push_back(¶ms); + if (params.mGLTFMaterial.isNull()) + { + rigged_emissives.push_back(¶ms); + } + else + { + pbr_rigged_emissives.push_back(¶ms); + } } else { - emissives.push_back(¶ms); + if (params.mGLTFMaterial.isNull()) + { + emissives.push_back(¶ms); + } + else + { + pbr_emissives.push_back(¶ms); + } } } @@ -818,14 +877,28 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) if (!emissives.empty()) { light_enabled = true; - renderEmissives(mask, emissives); + renderEmissives(emissives); + rebind = true; + } + + if (!pbr_emissives.empty()) + { + light_enabled = true; + renderPbrEmissives(pbr_emissives); rebind = true; } if (!rigged_emissives.empty()) { light_enabled = true; - renderRiggedEmissives(mask, rigged_emissives); + renderRiggedEmissives(rigged_emissives); + rebind = true; + } + + if (!pbr_rigged_emissives.empty()) + { + light_enabled = true; + renderRiggedPbrEmissives(pbr_rigged_emissives); rebind = true; } diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h index 1e10bb5566..f2f802d85e 100644 --- a/indra/newview/lldrawpoolalpha.h +++ b/indra/newview/lldrawpoolalpha.h @@ -77,11 +77,14 @@ private: LLGLSLShader* simple_shader = nullptr; LLGLSLShader* fullbright_shader = nullptr; LLGLSLShader* emissive_shader = nullptr; + LLGLSLShader* pbr_emissive_shader = nullptr; LLGLSLShader* pbr_shader = nullptr; - void drawEmissive(U32 mask, LLDrawInfo* draw); - void renderEmissives(U32 mask, std::vector& emissives); - void renderRiggedEmissives(U32 mask, std::vector& emissives); + void drawEmissive(LLDrawInfo* draw); + void renderEmissives(std::vector& emissives); + void renderRiggedEmissives(std::vector& emissives); + void renderPbrEmissives(std::vector& emissives); + void renderRiggedPbrEmissives(std::vector& emissives); bool TexSetup(LLDrawInfo* draw, bool use_material); void RestoreTexSetup(bool tex_setup); diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index c5413a068a..d30fc22393 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -59,18 +59,29 @@ void LLDrawPoolGLTFPBR::renderDeferred(S32 pass) S32 LLDrawPoolGLTFPBR::getNumPostDeferredPasses() { - return LLPipeline::sRenderingHUDs ? 1 : 0; + return 1; } void LLDrawPoolGLTFPBR::renderPostDeferred(S32 pass) { - // only HUD rendering should execute this pass - llassert(LLPipeline::sRenderingHUDs); - - gHUDPBROpaqueProgram.bind(); - for (U32 type : gltf_render_types) + if (LLPipeline::sRenderingHUDs) { - pushGLTFBatches(type); + gHUDPBROpaqueProgram.bind(); + for (U32 type : gltf_render_types) + { + pushGLTFBatches(type); + } + } + else + { + gGL.setColorMask(false, true); + gPBRGlowProgram.bind(); + pushGLTFBatches(LLRenderPass::PASS_GLTF_GLOW); + + gPBRGlowProgram.bind(true); + pushRiggedGLTFBatches(LLRenderPass::PASS_GLTF_GLOW_RIGGED); + + gGL.setColorMask(true, false); } } diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 003b373e50..f3583daa0a 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -60,7 +60,9 @@ void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) if (mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) { - min_alpha = mAlphaCutoff; + // dividing the alpha cutoff by transparency here allows the shader to compare against + // the alpha value of the texture without needing the transparency value + min_alpha = mAlphaCutoff/mBaseColor.mV[3]; } shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ccb2a86128..2775a98869 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -206,6 +206,8 @@ LLGLSLShader gDeferredGenBrdfLutProgram; LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gHUDPBROpaqueProgram; +LLGLSLShader gPBRGlowProgram; +LLGLSLShader gPBRGlowSkinnedProgram; LLGLSLShader gDeferredPBROpaqueProgram; LLGLSLShader gDeferredSkinnedPBROpaqueProgram; LLGLSLShader gHUDPBRAlphaProgram; @@ -1016,6 +1018,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() } gHUDPBROpaqueProgram.unload(); + gPBRGlowProgram.unload(); gDeferredPBROpaqueProgram.unload(); gDeferredSkinnedPBROpaqueProgram.unload(); gDeferredPBRAlphaProgram.unload(); @@ -1325,6 +1328,23 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() llassert(success); } + if (success) + { + gPBRGlowProgram.mName = " PBR Glow Shader"; + gPBRGlowProgram.mFeatures.hasSrgb = true; + gPBRGlowProgram.mShaderFiles.clear(); + gPBRGlowProgram.mShaderFiles.push_back(make_pair("deferred/pbrglowV.glsl", GL_VERTEX_SHADER)); + gPBRGlowProgram.mShaderFiles.push_back(make_pair("deferred/pbrglowF.glsl", GL_FRAGMENT_SHADER)); + gPBRGlowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + + success = make_rigged_variant(gPBRGlowProgram, gPBRGlowSkinnedProgram); + if (success) + { + success = gPBRGlowProgram.createShader(NULL, NULL); + } + llassert(success); + } + if (success) { gHUDPBROpaqueProgram.mName = "HUD PBR Opaque Shader"; @@ -1341,6 +1361,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() llassert(success); } + + if (success) { LLGLSLShader* shader = &gDeferredPBRAlphaProgram; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 027dea6f8d..9bd01dbdf5 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -268,6 +268,7 @@ extern LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; extern LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; extern LLGLSLShader gHUDPBROpaqueProgram; +extern LLGLSLShader gPBRGlowProgram; extern LLGLSLShader gDeferredPBROpaqueProgram; extern LLGLSLShader gDeferredPBRAlphaProgram; extern LLGLSLShader gHUDPBRAlphaProgram; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 0c5aac4d0f..9f51509f96 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5201,8 +5201,11 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, (type == LLRenderPass::PASS_ALPHA && facep->isState(LLFace::FULLBRIGHT)) || (facep->getTextureEntry()->getFullbright()); - if (!fullbright && type != LLRenderPass::PASS_GLOW && !facep->getVertexBuffer()->hasDataType(LLVertexBuffer::TYPE_NORMAL)) + if (!fullbright && + type != LLRenderPass::PASS_GLOW && + !facep->getVertexBuffer()->hasDataType(LLVertexBuffer::TYPE_NORMAL)) { + llassert(false); LL_WARNS() << "Non fullbright face has no normals!" << LL_ENDL; return; } @@ -6798,7 +6801,14 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (!is_alpha && LLPipeline::sRenderGlow && te->getGlow() > 0.f) { - registerFace(group, facep, LLRenderPass::PASS_GLOW); + if (gltf_mat) + { + registerFace(group, facep, LLRenderPass::PASS_GLTF_GLOW); + } + else + { + registerFace(group, facep, LLRenderPass::PASS_GLOW); + } } ++face_iter; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 039ad9cf8f..65d9d4e060 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8443,6 +8443,7 @@ void LLPipeline::renderDeferredLighting() LLPipeline::RENDER_TYPE_VOLUME, LLPipeline::RENDER_TYPE_GLOW, LLPipeline::RENDER_TYPE_BUMP, + LLPipeline::RENDER_TYPE_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_SIMPLE, LLPipeline::RENDER_TYPE_PASS_ALPHA, LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, @@ -8452,6 +8453,7 @@ void LLPipeline::renderDeferredLighting() LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, LLPipeline::RENDER_TYPE_PASS_GLOW, + LLPipeline::RENDER_TYPE_PASS_GLTF_GLOW, LLPipeline::RENDER_TYPE_PASS_GRASS, LLPipeline::RENDER_TYPE_PASS_SHINY, LLPipeline::RENDER_TYPE_PASS_INVISIBLE, diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 37d5dbd9c6..282f28e736 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -492,6 +492,8 @@ public: RENDER_TYPE_PASS_POST_BUMP_RIGGED = LLRenderPass::PASS_POST_BUMP_RIGGED, RENDER_TYPE_PASS_GLOW = LLRenderPass::PASS_GLOW, RENDER_TYPE_PASS_GLOW_RIGGED = LLRenderPass::PASS_GLOW_RIGGED, + RENDER_TYPE_PASS_GLTF_GLOW = LLRenderPass::PASS_GLTF_GLOW, + RENDER_TYPE_PASS_GLTF_GLOW_RIGGED = LLRenderPass::PASS_GLTF_GLOW_RIGGED, RENDER_TYPE_PASS_ALPHA = LLRenderPass::PASS_ALPHA, RENDER_TYPE_PASS_ALPHA_MASK = LLRenderPass::PASS_ALPHA_MASK, RENDER_TYPE_PASS_ALPHA_MASK_RIGGED = LLRenderPass::PASS_ALPHA_MASK_RIGGED, -- cgit v1.3 From 1b19b7cdc9e3d7560c3bd952d81076aee5ae13c2 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 14 Feb 2023 12:22:51 -0600 Subject: SL-18983 and SL-18680 Disable automatic alpha masking on HUDs. --- indra/newview/llvovolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 9f51509f96..fec9f1cdd1 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6681,7 +6681,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace { //100% transparent, don't render unless we're highlighting transparent registerFace(group, facep, LLRenderPass::PASS_ALPHA_INVISIBLE); } - else if (facep->canRenderAsMask()) + else if (facep->canRenderAsMask() && !hud_group) { if (te->getFullbright() || LLPipeline::sNoAlpha) { -- cgit v1.3 From 7a533f368231c7e1135891c05e03412d0fdb9fdb Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 24 Feb 2023 18:10:49 -0800 Subject: SL-19269: For PBR materials, apply texture animation independently of the underlying texture transform --- .../shaders/class1/deferred/textureUtilV.glsl | 3 ++- indra/newview/llvovolume.cpp | 31 +++++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl index 6ad317ca63..39cc07d2d1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl @@ -62,13 +62,14 @@ vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf { vec2 texcoord = vertex_texcoord; + // Apply texture animation first to avoid shearing and other artifacts + texcoord = (sl_animation_transform * vec4(texcoord, 0, 1)).xy; // Convert to left-handed coordinate system. The offset of 1 is necessary // for rotations to be applied correctly. texcoord.y = 1.0 - texcoord.y; texcoord = khr_texture_transform(texcoord, khr_gltf_scale, khr_gltf_rotation, khr_gltf_offset); // Convert back to right-handed coordinate system texcoord.y = 1.0 - texcoord.y; - texcoord = (sl_animation_transform * vec4(texcoord, 0, 1)).xy; // To make things more confusing, all SL image assets are upside-down // We may need an additional sign flip here when we implement a Vulkan backend diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index fec9f1cdd1..42e764b492 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -625,18 +625,24 @@ void LLVOVolume::animateTextures() continue; } - if (!(result & LLViewerTextureAnim::ROTATE)) - { - te->getRotation(&rot); - } - if (!(result & LLViewerTextureAnim::TRANSLATE)) - { - te->getOffset(&off_s,&off_t); - } - if (!(result & LLViewerTextureAnim::SCALE)) - { - te->getScale(&scale_s, &scale_t); - } + LLGLTFMaterial *gltf_mat = te->getGLTFRenderMaterial(); + const bool is_pbr = gltf_mat != nullptr; + + if (!is_pbr) + { + if (!(result & LLViewerTextureAnim::ROTATE)) + { + te->getRotation(&rot); + } + if (!(result & LLViewerTextureAnim::TRANSLATE)) + { + te->getOffset(&off_s,&off_t); + } + if (!(result & LLViewerTextureAnim::SCALE)) + { + te->getScale(&scale_s, &scale_t); + } + } if (!facep->mTextureMatrix) { @@ -645,6 +651,7 @@ void LLVOVolume::animateTextures() LLMatrix4& tex_mat = *facep->mTextureMatrix; tex_mat.setIdentity(); + LLVector3 trans ; trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); -- cgit v1.3 From db44e06d66cfa11e55660663ea33e604b604ace3 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 1 Mar 2023 16:15:26 -0800 Subject: SL-19294: Fix Blinn-Phong texture transforms affecting GLTF materials --- indra/newview/llface.cpp | 95 +++++++++++++++++++++++++------------------- indra/newview/llvovolume.cpp | 3 ++ 2 files changed, 58 insertions(+), 40 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index a74950dad2..d05e367c12 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1524,7 +1524,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, || mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2); } - bool do_tex_mat = tex_mode && mTextureMatrix; + // For GLTF materials: Transforms will be applied later + bool do_tex_mat = tex_mode && mTextureMatrix && !gltf_mat; if (!do_bump) { //not bump mapped, might be able to do a cheap update @@ -1614,7 +1615,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, *tex_coords0++ = tc; } } - else + else if (do_xform) { for (S32 i = 0; i < num_vertices; i++) { @@ -1627,6 +1628,20 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, xform(tc, cos_ang, sin_ang, os, ot, ms, mt); + *tex_coords0++ = tc; + } + } + else + { + for (S32 i = 0; i < num_vertices; i++) + { + LLVector2 tc(vf.mTexCoords[i]); + LLVector4a& norm = vf.mNormals[i]; + LLVector4a& center = *(vf.mCenter); + LLVector4a vec = vf.mPositions[i]; + vec.mul(scalea); + planarProjection(tc, norm, center, vec); + *tex_coords0++ = tc; } } @@ -1694,44 +1709,44 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } - for (S32 i = 0; i < num_vertices; i++) - { - LLVector2 tc(vf.mTexCoords[i]); - - LLVector4a& norm = vf.mNormals[i]; - - LLVector4a& center = *(vf.mCenter); - - if (texgen != LLTextureEntry::TEX_GEN_DEFAULT) - { - LLVector4a vec = vf.mPositions[i]; - - vec.mul(scalea); - - if (texgen == LLTextureEntry::TEX_GEN_PLANAR) - { - planarProjection(tc, norm, center, vec); - } - } - - if (tex_mode && mTextureMatrix) - { - LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f); - tmp = tmp * *mTextureMatrix; - tc.mV[0] = tmp.mV[0]; - tc.mV[1] = tmp.mV[1]; - } - else - { - xform(tc, cos_ang, sin_ang, os, ot, ms, mt); - } - - *dst++ = tc; - if (do_bump) - { - bump_tc.push_back(tc); - } - } + for (S32 i = 0; i < num_vertices; i++) + { + LLVector2 tc(vf.mTexCoords[i]); + + LLVector4a& norm = vf.mNormals[i]; + + LLVector4a& center = *(vf.mCenter); + + if (texgen != LLTextureEntry::TEX_GEN_DEFAULT) + { + LLVector4a vec = vf.mPositions[i]; + + vec.mul(scalea); + + if (texgen == LLTextureEntry::TEX_GEN_PLANAR) + { + planarProjection(tc, norm, center, vec); + } + } + + if (tex_mode && mTextureMatrix) + { + LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f); + tmp = tmp * *mTextureMatrix; + tc.mV[0] = tmp.mV[0]; + tc.mV[1] = tmp.mV[1]; + } + else if (do_xform) + { + xform(tc, cos_ang, sin_ang, os, ot, ms, mt); + } + + *dst++ = tc; + if (do_bump) + { + bump_tc.push_back(tc); + } + } } if ((!mat && !gltf_mat) && do_bump) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 42e764b492..d88713a690 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5878,6 +5878,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (gltf_mat != nullptr) { // all gltf materials have all vertex attributes for now + // *TODO: More finely enumerate vertex attributes for GLTF materials so + // that LLFace::getGeometryVolume can use a more optimal computation path + // as appropriate. (see: "whole expensive loop") -Cosmic,2023-03-01 add_face(sNormSpecFaces, normspec_count, facep); } else -- cgit v1.3 From dc7ad02aa577bb572e8bf9d7f39a55de5cd2adef Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 2 Mar 2023 14:37:16 -0800 Subject: SL-19294: Avoid unnecessary vertex buffer data in GLTF materials --- indra/newview/llspatialpartition.h | 1 + indra/newview/llvovolume.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index bc0eabfa0e..9b2cb0d44c 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -686,6 +686,7 @@ private: static LLFace** sNormFaces[2]; static LLFace** sSpecFaces[2]; static LLFace** sNormSpecFaces[2]; + static LLFace** sPbrFaces[2]; static LLFace** sAlphaFaces[2]; }; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index d88713a690..2eb3db6765 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5105,6 +5105,7 @@ LLFace** LLVolumeGeometryManager::sSimpleFaces[2] = { NULL }; LLFace** LLVolumeGeometryManager::sNormFaces[2] = { NULL }; LLFace** LLVolumeGeometryManager::sSpecFaces[2] = { NULL }; LLFace** LLVolumeGeometryManager::sNormSpecFaces[2] = { NULL }; +LLFace** LLVolumeGeometryManager::sPbrFaces[2] = { NULL }; LLFace** LLVolumeGeometryManager::sAlphaFaces[2] = { NULL }; LLVolumeGeometryManager::LLVolumeGeometryManager() @@ -5141,6 +5142,7 @@ void LLVolumeGeometryManager::allocateFaces(U32 pMaxFaceCount) sNormFaces[i] = static_cast(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); sSpecFaces[i] = static_cast(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); sNormSpecFaces[i] = static_cast(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); + sPbrFaces[i] = static_cast(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); sAlphaFaces[i] = static_cast(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); } } @@ -5155,6 +5157,7 @@ void LLVolumeGeometryManager::freeFaces() ll_aligned_free<64>(sNormFaces[i]); ll_aligned_free<64>(sSpecFaces[i]); ll_aligned_free<64>(sNormSpecFaces[i]); + ll_aligned_free<64>(sPbrFaces[i]); ll_aligned_free<64>(sAlphaFaces[i]); sFullbrightFaces[i] = NULL; @@ -5163,6 +5166,7 @@ void LLVolumeGeometryManager::freeFaces() sNormFaces[i] = NULL; sSpecFaces[i] = NULL; sNormSpecFaces[i] = NULL; + sPbrFaces[i] = NULL; sAlphaFaces[i] = NULL; } } @@ -5596,6 +5600,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 norm_count[2] = { 0 }; U32 spec_count[2] = { 0 }; U32 normspec_count[2] = { 0 }; + U32 pbr_count[2] = { 0 }; static LLCachedControl max_vbo_size(gSavedSettings, "RenderMaxVBOSize", 512); static LLCachedControl max_node_size(gSavedSettings, "RenderMaxNodeSize", 65536); @@ -5877,11 +5882,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { if (gltf_mat != nullptr) { - // all gltf materials have all vertex attributes for now - // *TODO: More finely enumerate vertex attributes for GLTF materials so - // that LLFace::getGeometryVolume can use a more optimal computation path - // as appropriate. (see: "whole expensive loop") -Cosmic,2023-03-01 - add_face(sNormSpecFaces, normspec_count, facep); + add_face(sPbrFaces, pbr_count, facep); } else { @@ -5980,6 +5981,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 normspec_mask = norm_mask | LLVertexBuffer::MAP_TEXCOORD2; U32 spec_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD2; + U32 pbr_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TANGENT; + if (emissive) { //emissive faces are present, include emissive byte to preserve batching simple_mask = simple_mask | LLVertexBuffer::MAP_EMISSIVE; @@ -5989,6 +5992,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) norm_mask = norm_mask | LLVertexBuffer::MAP_EMISSIVE; normspec_mask = normspec_mask | LLVertexBuffer::MAP_EMISSIVE; spec_mask = spec_mask | LLVertexBuffer::MAP_EMISSIVE; + pbr_mask = pbr_mask | LLVertexBuffer::MAP_EMISSIVE; } BOOL batch_textures = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 1; @@ -6019,6 +6023,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) geometryBytes += genDrawInfo(group, norm_mask | extra_mask, sNormFaces[i], norm_count[i], FALSE, FALSE, rigged); geometryBytes += genDrawInfo(group, spec_mask | extra_mask, sSpecFaces[i], spec_count[i], FALSE, FALSE, rigged); geometryBytes += genDrawInfo(group, normspec_mask | extra_mask, sNormSpecFaces[i], normspec_count[i], FALSE, FALSE, rigged); + geometryBytes += genDrawInfo(group, pbr_mask | extra_mask, sPbrFaces[i], pbr_count[i], FALSE, FALSE, rigged); // for rigged set, add weights and disable alpha sorting (rigged items use depth buffer) extra_mask |= LLVertexBuffer::MAP_WEIGHT4; -- cgit v1.3 From 69f9e41019e424a9193164623fbc4f12407f1ca6 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 2 Mar 2023 16:22:46 -0800 Subject: SL-19293: Use Blinn-Phong texture transform as hint for texture animation direction on PBR materials --- indra/newview/llvovolume.cpp | 68 ++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 2eb3db6765..853c580964 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -628,6 +628,14 @@ void LLVOVolume::animateTextures() LLGLTFMaterial *gltf_mat = te->getGLTFRenderMaterial(); const bool is_pbr = gltf_mat != nullptr; + if (!facep->mTextureMatrix) + { + facep->mTextureMatrix = new LLMatrix4(); + } + + LLMatrix4& tex_mat = *facep->mTextureMatrix; + tex_mat.setIdentity(); + if (!is_pbr) { if (!(result & LLViewerTextureAnim::ROTATE)) @@ -642,32 +650,50 @@ void LLVOVolume::animateTextures() { te->getScale(&scale_s, &scale_t); } - } - if (!facep->mTextureMatrix) - { - facep->mTextureMatrix = new LLMatrix4(); - } + LLVector3 trans ; - LLMatrix4& tex_mat = *facep->mTextureMatrix; - tex_mat.setIdentity(); - - LLVector3 trans ; + trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); + tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); - trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); - tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); + LLVector3 scale(scale_s, scale_t, 1.f); + LLQuaternion quat; + quat.setQuat(rot, 0, 0, -1.f); + + tex_mat.rotate(quat); - LLVector3 scale(scale_s, scale_t, 1.f); - LLQuaternion quat; - quat.setQuat(rot, 0, 0, -1.f); - - tex_mat.rotate(quat); + LLMatrix4 mat; + mat.initAll(scale, LLQuaternion(), LLVector3()); + tex_mat *= mat; + + tex_mat.translate(trans); + } + else + { + // For PBR materials, use Blinn-Phong rotation as hint for + // translation direction. In a Blinn-Phong material, the + // translation direction would be a byproduct the texture + // transform. + F32 rot_frame; + te->getRotation(&rot_frame); + + tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); + + LLQuaternion quat; + quat.setQuat(rot, 0, 0, -1.f); + tex_mat.rotate(quat); + + LLMatrix4 mat; + LLVector3 scale(scale_s, scale_t, 1.f); + mat.initAll(scale, LLQuaternion(), LLVector3()); + tex_mat *= mat; + + LLVector3 off(off_s, off_t, 0.f); + off.rotVec(rot_frame, 0, 0, 1.f); + tex_mat.translate(off); - LLMatrix4 mat; - mat.initAll(scale, LLQuaternion(), LLVector3()); - tex_mat *= mat; - - tex_mat.translate(trans); + tex_mat.translate(LLVector3(0.5f, 0.5f, 0.f)); + } } } else -- cgit v1.3 From 65fe41eb6e0df6029e9187a26e1aee5f27fa70d6 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 8 Mar 2023 10:02:53 -0800 Subject: SL-19330: Fix texture animation in wrong direction when setting material on another side --- indra/newview/llvovolume.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 853c580964..e69dea3444 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -670,6 +670,21 @@ void LLVOVolume::animateTextures() } else { + if (!(result & LLViewerTextureAnim::ROTATE)) + { + rot = 0.0f; + } + if (!(result & LLViewerTextureAnim::TRANSLATE)) + { + off_s = 0.0f; + off_t = 0.0f; + } + if (!(result & LLViewerTextureAnim::SCALE)) + { + scale_s = 1.0f; + scale_t = 1.0f; + } + // For PBR materials, use Blinn-Phong rotation as hint for // translation direction. In a Blinn-Phong material, the // translation direction would be a byproduct the texture -- cgit v1.3 From 25ede8638209fac8dde5b71bece4bc1dfa30ea16 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 10 Mar 2023 10:52:35 -0600 Subject: SL-19172 Texture streaming tune up. Incidental decruft. --- indra/llcommon/llcommon.cpp | 29 ++++- indra/llcommon/llprofiler.h | 6 +- indra/llcommon/llprofilercategories.h | 2 +- indra/llrender/llgltexture.h | 2 - indra/llrender/llrender.cpp | 34 ++--- indra/llrender/llrender.h | 17 ++- indra/llrender/llvertexbuffer.cpp | 31 ++--- indra/llrender/llvertexbuffer.h | 2 + indra/llwindow/llwindowwin32.cpp | 3 +- indra/newview/app_settings/settings.xml | 17 +-- indra/newview/lldrawable.cpp | 8 +- indra/newview/llface.cpp | 2 - indra/newview/llface.h | 1 + indra/newview/llspatialpartition.cpp | 62 +++++++++- indra/newview/lltextureview.cpp | 4 - indra/newview/llviewerobject.cpp | 10 +- indra/newview/llviewerobjectlist.cpp | 20 +-- indra/newview/llviewertexture.cpp | 211 +++++++++++++------------------- indra/newview/llviewertexture.h | 3 - indra/newview/llviewertexturelist.cpp | 36 ++++-- indra/newview/llvovolume.cpp | 19 +-- indra/newview/pipeline.cpp | 2 + 22 files changed, 265 insertions(+), 256 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index d2c4e66160..6e988260a9 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -37,12 +37,13 @@ thread_local bool gProfilerEnabled = false; #if (TRACY_ENABLE) // Override new/delete for tracy memory profiling -void *operator new(size_t size) + +void* ll_tracy_new(size_t size) { void* ptr; if (gProfilerEnabled) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; + //LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; ptr = (malloc)(size); } else @@ -57,12 +58,22 @@ void *operator new(size_t size) return ptr; } -void operator delete(void *ptr) noexcept +void* operator new(size_t size) +{ + return ll_tracy_new(size); +} + +void* operator new[](std::size_t count) +{ + return ll_tracy_new(count); +} + +void ll_tracy_delete(void* ptr) { TracyFree(ptr); if (gProfilerEnabled) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; + //LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; (free)(ptr); } else @@ -71,6 +82,16 @@ void operator delete(void *ptr) noexcept } } +void operator delete(void *ptr) noexcept +{ + ll_tracy_delete(ptr); +} + +void operator delete[](void* ptr) noexcept +{ + ll_tracy_delete(ptr); +} + // C-style malloc/free can't be so easily overridden, so we define tracy versions and use // a pre-processor #define in linden_common.h to redirect to them. The parens around the native // functions below prevents recursive substitution by the preprocessor. diff --git a/indra/llcommon/llprofiler.h b/indra/llcommon/llprofiler.h index 394fbd05f6..736a069f49 100644 --- a/indra/llcommon/llprofiler.h +++ b/indra/llcommon/llprofiler.h @@ -138,10 +138,6 @@ extern thread_local bool gProfilerEnabled; #define LL_PROFILE_ZONE_ERR(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0XFF0000 ) // RGB yellow #define LL_PROFILE_ZONE_INFO(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0X00FFFF ) // RGB cyan #define LL_PROFILE_ZONE_WARN(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0x0FFFF00 ) // RGB red - //#define LL_PROFILE_ALLOC(ptr, size) TracyAlloc(ptr, size) // memory allocation tracking currently not working - //#define LL_PROFILE_FREE(ptr) TracyFree(ptr) - #define LL_PROFILE_ALLOC(ptr, size) (void)(ptr); (void)(size); - #define LL_PROFILE_FREE(ptr) (void)(ptr); #endif #else #define LL_PROFILER_FRAME_END @@ -165,7 +161,7 @@ extern thread_local bool gProfilerEnabled; #define LL_LABEL_OBJECT_GL(type, name, length, label) -#if LL_PROFILER_CONFIG > 1 +#if LL_PROFILER_CONFIGURATION > 1 #define LL_PROFILE_ALLOC(ptr, size) TracyAlloc(ptr, size) #define LL_PROFILE_FREE(ptr) TracyFree(ptr) #else diff --git a/indra/llcommon/llprofilercategories.h b/indra/llcommon/llprofilercategories.h index 8db29468cc..617431f629 100644 --- a/indra/llcommon/llprofilercategories.h +++ b/indra/llcommon/llprofilercategories.h @@ -52,7 +52,7 @@ #define LL_PROFILER_CATEGORY_ENABLE_LOGGING 1 #define LL_PROFILER_CATEGORY_ENABLE_MATERIAL 1 #define LL_PROFILER_CATEGORY_ENABLE_MEDIA 1 -#define LL_PROFILER_CATEGORY_ENABLE_MEMORY 1 +#define LL_PROFILER_CATEGORY_ENABLE_MEMORY 0 #define LL_PROFILER_CATEGORY_ENABLE_NETWORK 1 #define LL_PROFILER_CATEGORY_ENABLE_OCTREE 1 #define LL_PROFILER_CATEGORY_ENABLE_PIPELINE 1 diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h index 8cfe7b62de..3732333f8f 100644 --- a/indra/llrender/llgltexture.h +++ b/indra/llrender/llgltexture.h @@ -49,10 +49,8 @@ public: enum EBoostLevel { BOOST_NONE = 0, - BOOST_ALM , //acts like NONE when ALM is on, max discard when ALM is off BOOST_AVATAR_BAKED , BOOST_AVATAR , - BOOST_CLOUDS , BOOST_SCULPTED , BOOST_HIGH = 10, diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 5b814f03cb..8430d13093 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -70,9 +70,6 @@ bool LLRender::sGLCoreProfile = false; bool LLRender::sNsightDebugSupport = false; LLVector2 LLRender::sUIGLScaleFactor = LLVector2(1.f, 1.f); -static const U32 LL_NUM_TEXTURE_LAYERS = 32; -static const U32 LL_NUM_LIGHT_UNITS = 8; - struct LLVBCache { LLPointer vb; @@ -823,16 +820,14 @@ LLRender::LLRender() mMode(LLRender::TRIANGLES), mCurrTextureUnitIndex(0) { - mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS); for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) { - mTexUnits.push_back(new LLTexUnit(i)); + mTexUnits[i].mIndex = i; } - mDummyTexUnit = new LLTexUnit(-1); for (U32 i = 0; i < LL_NUM_LIGHT_UNITS; ++i) { - mLightState.push_back(new LLLightState(i)); + mLightState[i].mIndex = i; } for (U32 i = 0; i < 4; i++) @@ -915,19 +910,6 @@ void LLRender::resetVertexBuffer() void LLRender::shutdown() { - for (U32 i = 0; i < mTexUnits.size(); i++) - { - delete mTexUnits[i]; - } - mTexUnits.clear(); - delete mDummyTexUnit; - mDummyTexUnit = NULL; - - for (U32 i = 0; i < mLightState.size(); ++i) - { - delete mLightState[i]; - } - mLightState.clear(); resetVertexBuffer(); } @@ -939,10 +921,10 @@ void LLRender::refreshState(void) for (U32 i = 0; i < mTexUnits.size(); i++) { - mTexUnits[i]->refreshState(); + mTexUnits[i].refreshState(); } - mTexUnits[active_unit]->activate(); + mTexUnits[active_unit].activate(); setColorMask(mCurrColorMask[0], mCurrColorMask[1], mCurrColorMask[2], mCurrColorMask[3]); @@ -974,7 +956,7 @@ void LLRender::syncLightState() for (U32 i = 0; i < LL_NUM_LIGHT_UNITS; i++) { - LLLightState *light = mLightState[i]; + LLLightState *light = &mLightState[i]; position[i] = light->mPosition; direction[i] = light->mSpotDirection; @@ -1501,12 +1483,12 @@ LLTexUnit* LLRender::getTexUnit(U32 index) { if (index < mTexUnits.size()) { - return mTexUnits[index]; + return &mTexUnits[index]; } else { LL_DEBUGS() << "Non-existing texture unit layer requested: " << index << LL_ENDL; - return mDummyTexUnit; + return &mDummyTexUnit; } } @@ -1514,7 +1496,7 @@ LLLightState* LLRender::getLight(U32 index) { if (index < mLightState.size()) { - return mLightState[index]; + return &mLightState[index]; } return NULL; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index e8baf6bb7e..6f61627235 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -52,6 +52,9 @@ class LLTexture ; #define LL_MATRIX_STACK_DEPTH 32 +constexpr U32 LL_NUM_TEXTURE_LAYERS = 32; +constexpr U32 LL_NUM_LIGHT_UNITS = 8; + class LLTexUnit { friend class LLRender; @@ -135,7 +138,7 @@ public: TCS_SRGB } eTextureColorSpace; - LLTexUnit(S32 index); + LLTexUnit(S32 index = -1); // Refreshes renderer state of the texture unit to the cached values // Needed when the render context has changed and invalidated the current state @@ -212,7 +215,9 @@ public: eTextureColorSpace getCurrColorSpace() { return mTexColorSpace; } protected: - const S32 mIndex; + friend class LLRender; + + S32 mIndex; U32 mCurrTexture; eTextureType mCurrTexType; eTextureColorSpace mTexColorSpace; @@ -230,7 +235,7 @@ protected: class LLLightState { public: - LLLightState(S32 index); + LLLightState(S32 index = -1); void enable(); void disable(); @@ -488,9 +493,9 @@ private: LLStrider mVerticesp; LLStrider mTexcoordsp; LLStrider mColorsp; - std::vector mTexUnits; - LLTexUnit* mDummyTexUnit; - std::vector mLightState; + std::array mTexUnits; + LLTexUnit mDummyTexUnit; + std::array mLightState; eBlendFactor mCurrBlendColorSFactor; eBlendFactor mCurrBlendColorDFactor; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index e5e6882ba1..cf4964169a 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -314,13 +314,16 @@ public: U32 mTouchCount = 0; -#if ANALYZE_VBO_POOL U64 mDistributed = 0; U64 mAllocated = 0; U64 mReserved = 0; U32 mMisses = 0; U32 mHits = 0; -#endif + + U64 getVramBytesUsed() + { + return mAllocated + mReserved; + } // increase the size to some common value (e.g. a power of two) to increase hit rate void adjustSize(U32& size) @@ -341,13 +344,9 @@ public: llassert(data == nullptr); // non null data indicates a buffer that wasn't freed llassert(size >= 2); // any buffer size smaller than a single index is nonsensical -#if ANALYZE_VBO_POOL mDistributed += size; adjustSize(size); mAllocated += size; -#else - adjustSize(size); -#endif auto& pool = type == GL_ELEMENT_ARRAY_BUFFER ? mIBOPool : mVBOPool; @@ -357,9 +356,7 @@ public: LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vbo pool miss"); LL_PROFILE_GPU_ZONE("vbo alloc"); -#if ANALYZE_VBO_POOL mMisses++; -#endif name = gen_buffer(); glBindBuffer(type, name); glBufferData(type, size, nullptr, GL_DYNAMIC_DRAW); @@ -376,11 +373,9 @@ public: } else { -#if ANALYZE_VBO_POOL mHits++; llassert(mReserved >= size); // assert if accounting gets messed up mReserved -= size; -#endif std::list& entries = iter->second; Entry& entry = entries.back(); @@ -407,16 +402,12 @@ public: clean(); -#if ANALYZE_VBO_POOL llassert(mDistributed >= size); mDistributed -= size; adjustSize(size); llassert(mAllocated >= size); mAllocated -= size; mReserved += size; -#else - adjustSize(size); -#endif auto& pool = type == GL_ELEMENT_ARRAY_BUFFER ? mIBOPool : mVBOPool; @@ -465,10 +456,8 @@ public: auto& entry = entries.back(); ll_aligned_free_16(entry.mData); glDeleteBuffers(1, &entry.mGLName); -#if ANALYZE_VBO_POOL llassert(mReserved >= iter->first); mReserved -= iter->first; -#endif entries.pop_back(); } @@ -484,7 +473,7 @@ public: } } -#if ANALYZE_VBO_POOL +#if 0 LL_INFOS() << llformat("(%d/%d)/%d MB (distributed/allocated)/total in VBO Pool. Overhead: %d percent. Hit rate: %d percent", mDistributed / 1000000, mAllocated / 1000000, @@ -515,9 +504,7 @@ public: } } -#if ANALYZE_VBO_POOL mReserved = 0; -#endif mIBOPool.clear(); mVBOPool.clear(); @@ -528,6 +515,12 @@ public: static LLVBOPool* sVBOPool = nullptr; +//static +U64 LLVertexBuffer::getBytesAllocated() +{ + return sVBOPool ? sVBOPool->getVramBytesUsed() : 0; +} + //============================================================================ // //static diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 571856f013..f2d146d4bb 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -256,6 +256,8 @@ private: bool allocateBuffer(S32 nverts, S32 nindices, BOOL create) { return allocateBuffer(nverts, nindices); } public: + + static U64 getBytesAllocated(); static const U32 sTypeSize[TYPE_MAX]; static const U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLRenderBuffer; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 10cf7513b5..666adcf672 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -4857,13 +4857,14 @@ void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage() DXGI_QUERY_VIDEO_MEMORY_INFO info; mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info); - #if 0 // debug 0 budget and 0 CU info.Budget = 0; info.CurrentUsage = 0; #endif U32 budget_mb = info.Budget / 1024 / 1024; + gGLManager.mVRAM = llmax(gGLManager.mVRAM, (S32) budget_mb); + U32 afr_mb = info.AvailableForReservation / 1024 / 1024; // correct for systems that misreport budget if (budget_mb == 0) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ffe2202a6d..a369b22ef1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12627,27 +12627,16 @@ Value 20.0 - TextureCameraMotionThreshold + TextureBiasDistanceScale Comment - If the overall motion is lower than this value, textures will be loaded faster + When biasing textures to lower resolution due to lack of vram, weight to put on distance factor. Persist 1 Type F32 Value - 0.2 - - TextureCameraMotionBoost - - Comment - Progressive discard level decrement when the camera is still - Persist - 1 - Type - S32 - Value - 3 + 8.0 TextureDecodeDisabled diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 45df4d0eee..04b6ebd14c 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1094,11 +1094,11 @@ void LLDrawable::updateUVMinMax() bool LLDrawable::isVisible() const { if (LLViewerOctreeEntryData::isVisible()) -{ - return true; -} + { + return true; + } -{ + { LLViewerOctreeGroup* group = mEntry->getGroup(); if (group && group->isVisible()) { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 87abb06285..1ae13e06f5 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -357,8 +357,6 @@ void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture) llassert(mTexture[ch].notNull()); - new_texture->addTextureStats(mTexture[ch]->getMaxVirtualSize()) ; - if (ch == LLRender::DIFFUSE_MAP) { getViewerObject()->changeTEImage(mTEOffset, new_texture) ; diff --git a/indra/newview/llface.h b/indra/newview/llface.h index ee8316018b..0a66dc6ba6 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -235,6 +235,7 @@ public: //aligned members LLVector4a mExtents[2]; private: + friend class LLViewerTextureList; F32 adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius ); BOOL calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) ; public: diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 35e11b8991..d81d7ab674 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3095,6 +3095,60 @@ void renderAgentTarget(LLVOAvatar* avatar) } } +static void setTextureAreaDebugText(LLDrawable* drawablep) +{ + LLVOVolume* vobjp = drawablep->getVOVolume(); + + if (vobjp) + { + if (drawablep->mDistanceWRTCamera < 32.f) + { + std::ostringstream str; + + for (S32 i = 0; i < vobjp->getNumTEs(); ++i) + { + if (i < drawablep->getNumFaces()) + { + LLFace* facep = drawablep->getFace(i); + + if (facep) + { + LLViewerTexture* imagep = facep->getTexture(); + + if (imagep) + { + str << llformat("D - %.2f", sqrtf(imagep->getMaxVirtualSize())); + } + + imagep = vobjp->getTENormalMap(i); + + if (imagep && imagep != LLViewerFetchedTexture::sDefaultImagep) + { + str << llformat("\nN - %.2f", sqrtf(imagep->getMaxVirtualSize())); + } + + imagep = vobjp->getTESpecularMap(i); + + if (imagep && imagep != LLViewerFetchedTexture::sDefaultImagep) + { + str << llformat("\nS - %.2f", sqrtf(imagep->getMaxVirtualSize())); + } + + str << "\n\n"; + } + + vobjp->setDebugText(str.str()); + } + break; + } + } + else + { + vobjp->setDebugText("."); + } + } +} + class LLOctreeRenderNonOccluded : public OctreeTraveler { public: @@ -3183,7 +3237,12 @@ public: size.mul(0.5f); drawBoxOutline(center, size); } - } + } + + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) + { + setTextureAreaDebugText(drawable); + } /*if (drawable->getVOVolume() && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) { @@ -3514,6 +3573,7 @@ void LLSpatialPartition::renderDebug() LLPipeline::RENDER_DEBUG_NORMALS | LLPipeline::RENDER_DEBUG_POINTS | //LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY | + LLPipeline::RENDER_DEBUG_TEXTURE_AREA | LLPipeline::RENDER_DEBUG_TEXTURE_ANIM | LLPipeline::RENDER_DEBUG_RAYCAST | LLPipeline::RENDER_DEBUG_AVATAR_VOLUME | diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 1f4f086352..ca93eb648b 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -175,10 +175,6 @@ void LLTextureBar::draw() { color = LLColor4::green4; } - else if (mImagep->getBoostLevel() > LLGLTexture::BOOST_ALM) - { - color = LLColor4::magenta; // except none and alm - } else if (mImagep->getMaxVirtualSize() <= 0.0f) { color = LLColor4::grey; color[VALPHA] = .7f; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index e217ede067..fd3c8de3e9 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4950,10 +4950,10 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) if (getTE(te)->getMaterialParams().notNull()) { const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID(); - mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); + mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); const LLUUID& spec_id = getTE(te)->getMaterialParams()->getSpecularID(); - mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); + mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); } LLFetchedGLTFMaterial* mat = (LLFetchedGLTFMaterial*) getTE(te)->getGLTFRenderMaterial(); @@ -4982,7 +4982,7 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) } else { - img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); + img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); img->addTextureStats(64.f * 64.f, TRUE); } } @@ -5140,14 +5140,14 @@ S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid) S32 LLViewerObject::setTENormalMap(const U8 te, const LLUUID& uuid) { LLViewerFetchedTexture *image = (uuid == LLUUID::null) ? NULL : LLViewerTextureManager::getFetchedTexture( - uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); + uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); return setTENormalMapCore(te, image); } S32 LLViewerObject::setTESpecularMap(const U8 te, const LLUUID& uuid) { LLViewerFetchedTexture *image = (uuid == LLUUID::null) ? NULL : LLViewerTextureManager::getFetchedTexture( - uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); + uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); return setTESpecularMapCore(te, image); } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 816fa6607e..bb22d90cd9 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -815,19 +815,19 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) mCurBin = (mCurBin + 1) % NUM_BINS; } -#if 1 +#if 0 // Slam priorities for textures that we care about (hovered, selected, and focused) // Hovered // Assumes only one level deep of parenting LLSelectNode* nodep = LLSelectMgr::instance().getHoverNode(); - if (nodep) - { - objectp = nodep->getObject(); - if (objectp) - { - objectp->boostTexturePriority(); - } - } + if (nodep) + { + objectp = nodep->getObject(); + if (objectp) + { + objectp->boostTexturePriority(); + } + } // Focused objectp = gAgentCamera.getFocusObject(); @@ -835,6 +835,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) { objectp->boostTexturePriority(); } +#endif // Selected struct f : public LLSelectedObjectFunctor @@ -846,7 +847,6 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) } } func; LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func); -#endif LLVOAvatar::cullAvatarsByPixelArea(); } diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 578deb8b3f..f677a38f34 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -89,8 +89,6 @@ S32 LLViewerTexture::sAuxCount = 0; LLFrameTimer LLViewerTexture::sEvaluationTimer; F32 LLViewerTexture::sDesiredDiscardBias = 0.f; F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; -S8 LLViewerTexture::sCameraMovingDiscardBias = 0; -F32 LLViewerTexture::sCameraMovingBias = 0.0f; S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64; const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez; @@ -552,29 +550,26 @@ void LLViewerTexture::updateClass() LLViewerMediaTexture::updateClass(); - if(isMemoryForTextureLow()) - { - // Note: isMemoryForTextureLow() uses 1s delay, make sure we waited enough for it to recheck - if (sEvaluationTimer.getElapsedTimeF32() > GPU_MEMORY_CHECK_WAIT_TIME) - { - sDesiredDiscardBias += discard_bias_delta; - sEvaluationTimer.reset(); - } - } - else if (sDesiredDiscardBias > 0.0f - && isMemoryForTextureSuficientlyFree()) - { - // If we are using less texture memory than we should, - // scale down the desired discard level - if (sEvaluationTimer.getElapsedTimeF32() > discard_delta_time) - { - sDesiredDiscardBias -= discard_bias_delta; - sEvaluationTimer.reset(); - } - } - sDesiredDiscardBias = llclamp(sDesiredDiscardBias, desired_discard_bias_min, desired_discard_bias_max); + static LLCachedControl max_vram_budget(gSavedSettings, "RenderMaxVRAMBudget", 0); + + // get an estimate of how much video memory we're using + // NOTE: our metrics miss about half the vram we use, so this biases high but turns out to typically be within 5% of the real number + F32 used = (LLImageGL::getTextureBytesAllocated() + LLVertexBuffer::getBytesAllocated()) / 1024 / 512; + + F32 budget = max_vram_budget == 0 ? gGLManager.mVRAM : max_vram_budget; + + // try to leave half a GB for everyone else, but keep at least 768MB for ourselves + F32 target = llmax(budget - 512.f, 768.f); + + F32 over_pct = llmax((used-target) / target, 0.f); + sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct); - LLViewerTexture::sFreezeImageUpdates = sDesiredDiscardBias > (desired_discard_bias_max - 1.0f); + if (sDesiredDiscardBias > 1.f) + { + sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01; + } + + LLViewerTexture::sFreezeImageUpdates = false; // sDesiredDiscardBias > (desired_discard_bias_max - 1.0f); } //end of static functions @@ -627,7 +622,6 @@ LLViewerTexture::~LLViewerTexture() // virtual void LLViewerTexture::init(bool firstinit) { - mSelectedTime = 0.f; mMaxVirtualSize = 0.f; mMaxVirtualSizeResetInterval = 1; mMaxVirtualSizeResetCounter = mMaxVirtualSizeResetInterval; @@ -685,7 +679,6 @@ void LLViewerTexture::setBoostLevel(S32 level) { mBoostLevel = level; if(mBoostLevel != LLViewerTexture::BOOST_NONE && - mBoostLevel != LLViewerTexture::BOOST_ALM && mBoostLevel != LLViewerTexture::BOOST_SELECTED && mBoostLevel != LLViewerTexture::BOOST_ICON) { @@ -698,12 +691,6 @@ void LLViewerTexture::setBoostLevel(S32 level) { mMaxVirtualSize = 2048.f * 2048.f; } - - if (mBoostLevel == LLViewerTexture::BOOST_SELECTED) - { - mSelectedTime = gFrameTimeSeconds; - } - } bool LLViewerTexture::isActiveFetching() @@ -1710,10 +1697,6 @@ void LLViewerFetchedTexture::processTextureStats() { mDesiredDiscardLevel = 0; } - else if (!LLPipeline::sRenderDeferred && mBoostLevel == LLGLTexture::BOOST_ALM) - { // ??? don't load spec and normal maps when alm is disabled ??? - mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; - } else if (mDontDiscard && mBoostLevel == LLGLTexture::BOOST_ICON) { if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) @@ -1831,8 +1814,7 @@ bool LLViewerFetchedTexture::updateFetch() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; static LLCachedControl textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled", false); - static LLCachedControl sCameraMotionThreshold(gSavedSettings,"TextureCameraMotionThreshold", 0.2); - static LLCachedControl sCameraMotionBoost(gSavedSettings,"TextureCameraMotionBoost", 3); + if(textures_decode_disabled) // don't fetch the surface textures in wireframe mode { return false; @@ -2055,32 +2037,9 @@ bool LLViewerFetchedTexture::updateFetch() make_request = false; switchToCachedImage(); //use the cached raw data first } - //else if (!isJustBound() && mCachedRawImageReady) - //{ - // make_request = false; - //} if (make_request) { -#if 0 - // Load the texture progressively: we try not to rush to the desired discard too fast. - // If the camera is not moving, we do not tweak the discard level notch by notch but go to the desired discard with larger boosted steps - // This mitigates the "textures stay blurry" problem when loading while not killing the texture memory while moving around - S32 delta_level = (mBoostLevel > LLGLTexture::BOOST_ALM) ? 2 : 1; - if (current_discard < 0) - { - desired_discard = llmax(desired_discard, getMaxDiscardLevel() - delta_level); - } - else if (LLViewerTexture::sCameraMovingBias < sCameraMotionThreshold) - { - desired_discard = llmax(desired_discard, current_discard - sCameraMotionBoost); - } - else - { - desired_discard = llmax(desired_discard, current_discard - delta_level); - } -#endif - if (mIsFetching) { // already requested a higher resolution mip @@ -3095,10 +3054,6 @@ void LLViewerLODTexture::processTextureStats() if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 } - else if (!LLPipeline::sRenderDeferred && mBoostLevel == LLGLTexture::BOOST_ALM) - { - mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; - } else if (mBoostLevel < LLGLTexture::BOOST_HIGH && mMaxVirtualSize <= 10.f) { // If the image has not been significantly visible in a while, we don't want it @@ -3108,72 +3063,70 @@ void LLViewerLODTexture::processTextureStats() { mDesiredDiscardLevel = getMaxDiscardLevel(); } - else - { - //static const F64 log_2 = log(2.0); - static const F64 log_4 = log(4.0); + else + { + //static const F64 log_2 = log(2.0); + static const F64 log_4 = log(4.0); - F32 discard_level = 0.f; + F32 discard_level = 0.f; - // If we know the output width and height, we can force the discard - // level to the correct value, and thus not decode more texture - // data than we need to. - if (mKnownDrawWidth && mKnownDrawHeight) - { - S32 draw_texels = mKnownDrawWidth * mKnownDrawHeight; - draw_texels = llclamp(draw_texels, MIN_IMAGE_AREA, MAX_IMAGE_AREA); + // If we know the output width and height, we can force the discard + // level to the correct value, and thus not decode more texture + // data than we need to. + if (mKnownDrawWidth && mKnownDrawHeight) + { + S32 draw_texels = mKnownDrawWidth * mKnownDrawHeight; + draw_texels = llclamp(draw_texels, MIN_IMAGE_AREA, MAX_IMAGE_AREA); - // Use log_4 because we're in square-pixel space, so an image - // with twice the width and twice the height will have mTexelsPerImage - // 4 * draw_size - discard_level = (F32)(log(mTexelsPerImage/draw_texels) / log_4); - } - else - { - // Calculate the required scale factor of the image using pixels per texel - discard_level = (F32)(log(mTexelsPerImage/mMaxVirtualSize) / log_4); - mDiscardVirtualSize = mMaxVirtualSize; - mCalculatedDiscardLevel = discard_level; - } - if (mBoostLevel < LLGLTexture::BOOST_SCULPTED) - { - discard_level += sDesiredDiscardBias; - discard_level *= sDesiredDiscardScale; // scale - discard_level += sCameraMovingDiscardBias; - } - discard_level = floorf(discard_level); + // Use log_4 because we're in square-pixel space, so an image + // with twice the width and twice the height will have mTexelsPerImage + // 4 * draw_size + discard_level = (F32)(log(mTexelsPerImage / draw_texels) / log_4); + } + else + { + // Calculate the required scale factor of the image using pixels per texel + discard_level = (F32)(log(mTexelsPerImage / mMaxVirtualSize) / log_4); + mDiscardVirtualSize = mMaxVirtualSize; + mCalculatedDiscardLevel = discard_level; + } + if (mBoostLevel < LLGLTexture::BOOST_SCULPTED) + { + //discard_level += sDesiredDiscardBias; // gradually increases to a maximum of 5 as vram runs low + discard_level *= sDesiredDiscardScale; // scale (default 1.1f) + } + discard_level = floorf(discard_level); - F32 min_discard = 0.f; - U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 - if (mBoostLevel <= LLGLTexture::BOOST_SCULPTED) - { - desired_size = DESIRED_NORMAL_TEXTURE_SIZE; - } - if (mFullWidth > desired_size || mFullHeight > desired_size) - min_discard = 1.f; + F32 min_discard = 0.f; + U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 + if (mBoostLevel <= LLGLTexture::BOOST_SCULPTED) + { + desired_size = DESIRED_NORMAL_TEXTURE_SIZE; + } + if (mFullWidth > desired_size || mFullHeight > desired_size) + min_discard = 1.f; - discard_level = llclamp(discard_level, min_discard, (F32)MAX_DISCARD_LEVEL); - - // Can't go higher than the max discard level - mDesiredDiscardLevel = llmin(getMaxDiscardLevel() + 1, (S32)discard_level); - // Clamp to min desired discard - mDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel, mDesiredDiscardLevel); + discard_level = llclamp(discard_level, min_discard, (F32)MAX_DISCARD_LEVEL); - // - // At this point we've calculated the quality level that we want, - // if possible. Now we check to see if we have it, and take the - // proper action if we don't. - // + // Can't go higher than the max discard level + mDesiredDiscardLevel = llmin(getMaxDiscardLevel() + 1, (S32)discard_level); + // Clamp to min desired discard + mDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel, mDesiredDiscardLevel); - S32 current_discard = getDiscardLevel(); - if (sDesiredDiscardBias > 0.0f && mBoostLevel < LLGLTexture::BOOST_SCULPTED && current_discard >= 0) - { - if(desired_discard_bias_max <= sDesiredDiscardBias && !mForceToSaveRawImage) - { - //needs to release texture memory urgently - scaleDown(); - } - } + // + // At this point we've calculated the quality level that we want, + // if possible. Now we check to see if we have it, and take the + // proper action if we don't. + // + + S32 current_discard = getDiscardLevel(); + if (mBoostLevel < LLGLTexture::BOOST_SCULPTED && current_discard >= 0) + { + if (current_discard < (mDesiredDiscardLevel-1) && !mForceToSaveRawImage) + { // should scale down + scaleDown(); + } + } if (isUpdateFrozen() // we are out of memory and nearing max allowed bias && mBoostLevel < LLGLTexture::BOOST_SCULPTED @@ -3188,6 +3141,16 @@ void LLViewerLODTexture::processTextureStats() { mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel); } + + // decay max virtual size over time + mMaxVirtualSize *= 0.8f; + + // selection manager will immediately reset BOOST_SELECTED but never unsets it + // unset it immediately after we consume it + if (getBoostLevel() == BOOST_SELECTED) + { + setBoostLevel(BOOST_NONE); + } } bool LLViewerLODTexture::scaleDown() diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index facf05e52f..1370f4debe 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -195,7 +195,6 @@ protected: LLUUID mID; S32 mTextureListType; // along with mID identifies where to search for this texture in TextureList - F32 mSelectedTime; // time texture was last selected mutable F32 mMaxVirtualSize = 0.f; // The largest virtual size of the image, in pixels - how much data to we need? mutable S32 mMaxVirtualSizeResetCounter; mutable S32 mMaxVirtualSizeResetInterval; @@ -223,8 +222,6 @@ public: static LLFrameTimer sEvaluationTimer; static F32 sDesiredDiscardBias; static F32 sDesiredDiscardScale; - static S8 sCameraMovingDiscardBias; - static F32 sCameraMovingBias; static S32 sMaxSculptRez ; static U32 sMinLargeImageSize ; static U32 sMaxSmallImageSize ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 611aace4b4..8db4db795e 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -61,6 +61,7 @@ #include "llviewerdisplay.h" #include "llviewerwindow.h" #include "llprogressview.h" + //////////////////////////////////////////////////////////////////////////// void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL; @@ -533,12 +534,6 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id, LLPointer imagep = findImage(image_id, get_element_type(boost_priority)); if (!imagep.isNull()) { - if (boost_priority != LLViewerTexture::BOOST_ALM && imagep->getBoostLevel() == LLViewerTexture::BOOST_ALM) - { - // Workaround: we need BOOST_ALM texture for something, 'rise' to NONE - imagep->setBoostLevel(LLViewerTexture::BOOST_NONE); - } - LLViewerFetchedTexture *texture = imagep.get(); if (request_from_host.isOk() && !texture->getTargetHost().isOk()) @@ -874,6 +869,8 @@ static void touch_texture(LLViewerFetchedTexture* tex, F32 vsize) } } +extern BOOL gCubeSnapshot; + void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep) { if (imagep->isInDebug() || imagep->isUnremovable()) @@ -882,18 +879,37 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag return; //is in debug, ignore. } + llassert(!gCubeSnapshot); + + static LLCachedControl bias_distance_scale(gSavedSettings, "TextureBiasDistanceScale", 1.f); + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE { for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) { for (U32 fi = 0; fi < imagep->getNumFaces(i); ++fi) { - const LLFace* face = (*(imagep->getFaceList(i)))[fi]; + LLFace* face = (*(imagep->getFaceList(i)))[fi]; if (face && face->getViewerObject() && face->getTextureEntry()) { - F32 vsize = face->getVirtualSize(); + F32 radius; + F32 cos_angle_to_view_dir; + BOOL in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); + F32 vsize = face->getPixelArea(); + +#if LL_DARWIN + vsize /= 1.f + LLViewerTexture::sDesiredDiscardBias*(1.f+face->getDrawable()->mDistanceWRTCamera*bias_distance_scale); +#else + vsize /= LLViewerTexture::sDesiredDiscardBias; + vsize /= llmax(1.f, (LLViewerTexture::sDesiredDiscardBias-1.f) * (1.f + face->getDrawable()->mDistanceWRTCamera * bias_distance_scale)); + + if (!in_frustum || !face->getDrawable()->isVisible()) + { // further reduce by discard bias when off screen or occluded + vsize /= LLViewerTexture::sDesiredDiscardBias; + } +#endif // if a GLTF material is present, ignore that face // as far as this texture stats go, but update the GLTF material // stats @@ -914,7 +930,9 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag } } } - + + //imagep->setDebugText(llformat("%.3f - %d", sqrtf(imagep->getMaxVirtualSize()), imagep->getBoostLevel())); + F32 lazy_flush_timeout = 30.f; // stop decoding F32 max_inactive_time = 20.f; // actually delete S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 853c580964..a96701003b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -843,12 +843,6 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) continue; } - // clear out boost selected periodically - if (imagep->getBoostLevel() == LLGLTexture::BOOST_SELECTED) - { - imagep->setBoostLevel(LLGLTexture::BOOST_NONE); - } - F32 vsize; F32 old_size = face->getVirtualSize(); @@ -863,7 +857,6 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) else { vsize = face->getTextureVirtualSize(); - imagep->addTextureStats(vsize); } mPixelArea = llmax(mPixelArea, face->getPixelArea()); @@ -880,12 +873,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) } } - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) - { - if (vsize < min_vsize) min_vsize = vsize; - if (vsize > max_vsize) max_vsize = vsize; - } - else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) { LLViewerFetchedTexture* img = LLViewerTextureManager::staticCastToFetchedTexture(imagep) ; if(img) @@ -950,7 +938,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) { LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE); LLUUID id = params->getLightTexture(); - mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM); + mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE); if (mLightTexture.notNull()) { F32 rad = getLightRadius(); @@ -3292,7 +3280,6 @@ void LLVOVolume::updateSpotLightPriority() if (mLightTexture.notNull()) { mLightTexture->addTextureStats(mSpotLightPriority); - mLightTexture->setBoostLevel(LLGLTexture::BOOST_CLOUDS); } } @@ -3316,7 +3303,7 @@ LLViewerTexture* LLVOVolume::getLightTexture() { if (mLightTexture.isNull() || id != mLightTexture->getID()) { - mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM); + mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE); } } else diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index deafa6900e..b053af3f96 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4319,6 +4319,8 @@ extern std::set visible_selected_groups; void LLPipeline::renderDebug() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + assertInitialized(); bool hud_only = hasRenderType(LLPipeline::RENDER_TYPE_HUD); -- cgit v1.3 From bd4b03de8b73ecb888f8e3111bada7c643f7fcfd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 10 Mar 2023 13:33:36 -0600 Subject: DRTVWR-559 Fix for assert in LLVertexBuffer, incidental decruft. --- indra/llrender/llvertexbuffer.cpp | 3 +- indra/newview/llappviewer.cpp | 3 +- indra/newview/llface.cpp | 30 ++---- indra/newview/llspatialpartition.cpp | 4 +- indra/newview/llviewerstats.cpp | 7 +- indra/newview/llvovolume.cpp | 52 +++-------- indra/newview/pipeline.cpp | 172 ++++++++++++++++------------------- indra/newview/pipeline.h | 3 - 8 files changed, 106 insertions(+), 168 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index cf4964169a..dd0ea0096c 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1357,7 +1357,8 @@ void LLVertexBuffer::setBuffer() // this Vertex Buffer must provide all necessary attributes for currently bound shader llassert_msg((data_mask & mTypeMask) == data_mask, - "Attribute mask mismatch! mTypeMask should be a superset of data_mask. data_mask: 0x" << std::hex << data_mask << " mTypeMask: 0x" << mTypeMask << std::dec); + "Attribute mask mismatch! mTypeMask should be a superset of data_mask. data_mask: 0x" + << std::hex << data_mask << " mTypeMask: 0x" << mTypeMask << " Missing: 0x" << (data_mask & ~mTypeMask) << std::dec); if (sGLRenderBuffer != mGLBuffer) { diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 061feba0a4..7731f37c94 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -572,8 +572,7 @@ static void settings_to_globals() static void settings_modify() { LLPipeline::sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater"); - LLPipeline::sRenderBump = TRUE; // FALSE is deprecated -- gSavedSettings.getBOOL("RenderObjectBump"); - LLPipeline::sRenderDeferred = TRUE; // FALSE is deprecated -- LLPipeline::sRenderBump&& gSavedSettings.getBOOL("RenderDeferred"); + LLPipeline::sRenderDeferred = TRUE; // FALSE is deprecated LLRenderTarget::sUseFBO = LLPipeline::sRenderDeferred; LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor"); LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4] diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 1ae13e06f5..d7e4632ab0 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1107,20 +1107,13 @@ bool LLFace::canRenderAsMask() (te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask getTexture()->getIsAlphaMask()) // texture actually qualifies for masking (lazily recalculated but expensive) { - if (LLPipeline::sRenderDeferred) - { - if (getViewerObject()->isHUDAttachment() || te->getFullbright()) - { //hud attachments and fullbright objects are NOT subject to the deferred rendering pipe - return LLPipeline::sAutoMaskAlphaNonDeferred; - } - else - { - return LLPipeline::sAutoMaskAlphaDeferred; - } + if (getViewerObject()->isHUDAttachment() || te->getFullbright()) + { //hud attachments and fullbright objects are NOT subject to the deferred rendering pipe + return LLPipeline::sAutoMaskAlphaNonDeferred; } else { - return LLPipeline::sAutoMaskAlphaNonDeferred; + return LLPipeline::sAutoMaskAlphaDeferred; } } @@ -1260,19 +1253,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, bool shiny_in_alpha = false; - if (LLPipeline::sRenderDeferred) - { //store shiny in alpha if we don't have a specular map - if (!mat || mat->getSpecularID().isNull()) - { - shiny_in_alpha = true; - } - } - else + //store shiny in alpha if we don't have a specular map + if (!mat || mat->getSpecularID().isNull()) { - if (!mat || mat->getDiffuseAlphaMode() != LLMaterial::DIFFUSE_ALPHA_MODE_MASK) - { - shiny_in_alpha = true; - } + shiny_in_alpha = true; } if (shiny_in_alpha) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index d81d7ab674..92fccfcfd6 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3105,7 +3105,8 @@ static void setTextureAreaDebugText(LLDrawable* drawablep) { std::ostringstream str; - for (S32 i = 0; i < vobjp->getNumTEs(); ++i) + //for (S32 i = 0; i < vobjp->getNumTEs(); ++i) + S32 i = 0; { if (i < drawablep->getNumFaces()) { @@ -3139,7 +3140,6 @@ static void setTextureAreaDebugText(LLDrawable* drawablep) vobjp->setDebugText(str.str()); } - break; } } else diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index ee39b7d02f..b1abd0a656 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -570,14 +570,11 @@ void send_viewer_stats(bool include_preferences) shader_level = 3; } } - else if (gPipeline.canUseWindLightShadersOnObjects()) + else { shader_level = 2; } - else if (gPipeline.shadersLoaded()) - { - shader_level = 1; - } + system["shader_level"] = shader_level; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 49939cbbf0..d1f4fa1c7a 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5469,7 +5469,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED || info->mGLTFMaterial != nullptr); llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK || info->mGLTFMaterial != nullptr); llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK_RIGGED || info->mGLTFMaterial != nullptr); - + + llassert(type != LLRenderPass::PASS_BUMP || (info->mVertexBuffer->getTypeMask() & LLVertexBuffer::MAP_TANGENT) != 0); llassert(type != LLRenderPass::PASS_NORMSPEC || info->mNormalMap.notNull()); } @@ -5742,7 +5743,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) rigged = rigged || (vobj->isAnimatedObject() && vobj->isRiggedMesh() && vobj->getControlAvatar() && vobj->getControlAvatar()->mPlaying); - bool bake_sunlight = LLPipeline::sBakeSunlight && drawablep->isStatic(); bool any_rigged_face = false; //for each face @@ -5900,13 +5900,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) facep->mLastUpdateTime = gFrameTimeSeconds; } - if (gPipeline.canUseWindLightShadersOnObjects() - && LLPipeline::sRenderBump) { LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); - if (LLPipeline::sRenderDeferred && - (gltf_mat != nullptr || (te->getMaterialParams().notNull() && !te->getMaterialID().isNull()))) + if (gltf_mat != nullptr || (te->getMaterialParams().notNull() && !te->getMaterialID().isNull())) { if (gltf_mat != nullptr) { @@ -5915,7 +5912,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) else { LLMaterial* mat = te->getMaterialParams().get(); - if (mat->getNormalID().notNull()) + if (mat->getNormalID().notNull() || // <-- has a normal map, needs tangents + (te->getBumpmap() && (te->getBumpmap() < 18))) // <-- has an emboss bump map, needs tangents { if (mat->getSpecularID().notNull()) { //has normal and specular maps (needs texcoord1, texcoord2, and tangent) @@ -5947,23 +5945,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) else { //doesn't need normal facep->setState(LLFace::FULLBRIGHT); - add_face(sFullbrightFaces, fullbright_count, facep); - } - } - else - { - if (te->getBumpmap() && LLPipeline::sRenderBump) - { //needs normal + tangent - add_face(sBumpFaces, bump_count, facep); - } - else if ((te->getShiny() && LLPipeline::sRenderBump) || - !(te->getFullbright() || bake_sunlight)) - { //needs normal - add_face(sSimpleFaces, simple_count, facep); - } - else - { //doesn't need normal - facep->setState(LLFace::FULLBRIGHT); add_face(sFullbrightFaces, fullbright_count, facep); } } @@ -6194,7 +6175,7 @@ struct CompareBatchBreaker { return lte->getFullbright() < rte->getFullbright(); } - else if (LLPipeline::sRenderDeferred && lte->getMaterialID() != rte->getMaterialID()) + else if (lte->getMaterialID() != rte->getMaterialID()) { return lte->getMaterialID() < rte->getMaterialID(); } @@ -6285,13 +6266,9 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace texture_index_channels = LLGLSLShader::sIndexedTextureChannels-1; //always reserve one for shiny for now just for simplicity; } - if (LLPipeline::sRenderDeferred && distance_sort) + if (distance_sort) { texture_index_channels = gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels; - } - - if (distance_sort) - { buffer_index = -1; } @@ -6647,6 +6624,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } else if (use_legacy_bump) { + llassert(mask & LLVertexBuffer::MAP_TANGENT); // we have a material AND legacy bump settings, but no normal map registerFace(group, facep, LLRenderPass::PASS_BUMP); } @@ -6706,7 +6684,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace registerFace(group, facep, LLRenderPass::PASS_ALPHA); } else if (gPipeline.shadersLoaded() - && LLPipeline::sRenderBump && te->getShiny() && can_be_shiny) { @@ -6741,7 +6718,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } } else if (gPipeline.shadersLoaded() - && LLPipeline::sRenderBump && te->getShiny() && can_be_shiny) { //shiny @@ -6762,6 +6738,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } else if (use_legacy_bump) { //register in deferred bump pass + llassert(mask& LLVertexBuffer::MAP_TANGENT); registerFace(group, facep, LLRenderPass::PASS_BUMP); } else @@ -6795,15 +6772,16 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace { registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); } - if (!hud_group && LLPipeline::sRenderBump && use_legacy_bump) + if (!hud_group && use_legacy_bump) { //if this is the deferred render and a bump map is present, register in post deferred bump registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); } } else { - if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && use_legacy_bump) + if (use_legacy_bump) { //non-shiny or fullbright deferred bump + llassert(mask& LLVertexBuffer::MAP_TANGENT); registerFace(group, facep, LLRenderPass::PASS_BUMP); } else @@ -6823,8 +6801,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (!gPipeline.shadersLoaded() && !is_alpha && - te->getShiny() && - LLPipeline::sRenderBump) + te->getShiny()) { //shiny as an extra pass when shaders are disabled registerFace(group, facep, LLRenderPass::PASS_SHINY); } @@ -6836,8 +6813,9 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); - if (!force_simple && LLPipeline::sRenderBump && use_legacy_bump) + if (!force_simple && use_legacy_bump) { + llassert(mask & LLVertexBuffer::MAP_TANGENT); registerFace(group, facep, LLRenderPass::PASS_BUMP); } } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b053af3f96..ffb314c013 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -308,7 +308,6 @@ bool LLPipeline::sDelayVBUpdate = true; bool LLPipeline::sAutoMaskAlphaDeferred = true; bool LLPipeline::sAutoMaskAlphaNonDeferred = false; bool LLPipeline::sRenderTransparentWater = true; -bool LLPipeline::sRenderBump = true; bool LLPipeline::sBakeSunlight = false; bool LLPipeline::sNoAlpha = false; bool LLPipeline::sUseFarClip = true; @@ -400,7 +399,6 @@ void LLPipeline::init() gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); - sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights"); sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles"); @@ -968,12 +966,6 @@ void LLPipeline::updateRenderTransparentWater() sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater"); } -//static -void LLPipeline::updateRenderBump() -{ - sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); -} - // static void LLPipeline::refreshCachedSettings() { @@ -1183,46 +1175,44 @@ void LLPipeline::createGLBuffers() mRT->width = 0; mRT->height = 0; - if (sRenderDeferred) - { - if (!mNoiseMap) - { - const U32 noiseRes = 128; - LLVector3 noise[noiseRes*noiseRes]; + + if (!mNoiseMap) + { + const U32 noiseRes = 128; + LLVector3 noise[noiseRes*noiseRes]; - F32 scaler = gSavedSettings.getF32("RenderDeferredNoise")/100.f; - for (U32 i = 0; i < noiseRes*noiseRes; ++i) - { - noise[i] = LLVector3(ll_frand()-0.5f, ll_frand()-0.5f, 0.f); - noise[i].normVec(); - noise[i].mV[2] = ll_frand()*scaler+1.f-scaler/2.f; - } + F32 scaler = gSavedSettings.getF32("RenderDeferredNoise")/100.f; + for (U32 i = 0; i < noiseRes*noiseRes; ++i) + { + noise[i] = LLVector3(ll_frand()-0.5f, ll_frand()-0.5f, 0.f); + noise[i].normVec(); + noise[i].mV[2] = ll_frand()*scaler+1.f-scaler/2.f; + } - LLImageGL::generateTextures(1, &mNoiseMap); + LLImageGL::generateTextures(1, &mNoiseMap); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } - if (!mTrueNoiseMap) + if (!mTrueNoiseMap) + { + const U32 noiseRes = 128; + F32 noise[noiseRes*noiseRes*3]; + for (U32 i = 0; i < noiseRes*noiseRes*3; i++) { - const U32 noiseRes = 128; - F32 noise[noiseRes*noiseRes*3]; - for (U32 i = 0; i < noiseRes*noiseRes*3; i++) - { - noise[i] = ll_frand()*2.0-1.0; - } - - LLImageGL::generateTextures(1, &mTrueNoiseMap); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + noise[i] = ll_frand()*2.0-1.0; } - createLUTBuffers(); + LLImageGL::generateTextures(1, &mTrueNoiseMap); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } + createLUTBuffers(); + gBumpImageList.restoreGL(); } @@ -1233,70 +1223,67 @@ F32 lerpf(F32 a, F32 b, F32 w) void LLPipeline::createLUTBuffers() { - if (sRenderDeferred) + if (!mLightFunc) { - if (!mLightFunc) + U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); + U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); + F32* ls = new F32[lightResX*lightResY]; + F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); + // Calculate the (normalized) blinn-phong specular lookup texture. (with a few tweaks) + for (U32 y = 0; y < lightResY; ++y) { - U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); - U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); - F32* ls = new F32[lightResX*lightResY]; - F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); - // Calculate the (normalized) blinn-phong specular lookup texture. (with a few tweaks) - for (U32 y = 0; y < lightResY; ++y) + for (U32 x = 0; x < lightResX; ++x) { - for (U32 x = 0; x < lightResX; ++x) - { - ls[y*lightResX+x] = 0; - F32 sa = (F32) x/(lightResX-1); - F32 spec = (F32) y/(lightResY-1); - F32 n = spec * spec * specExp; + ls[y*lightResX+x] = 0; + F32 sa = (F32) x/(lightResX-1); + F32 spec = (F32) y/(lightResY-1); + F32 n = spec * spec * specExp; - // Nothing special here. Just your typical blinn-phong term. - spec = powf(sa, n); + // Nothing special here. Just your typical blinn-phong term. + spec = powf(sa, n); - // Apply our normalization function. - // Note: This is the full equation that applies the full normalization curve, not an approximation. - // This is fine, given we only need to create our LUT once per buffer initialization. - spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); - - // Since we use R16F, we no longer have a dynamic range issue we need to work around here. - // Though some older drivers may not like this, newer drivers shouldn't have this problem. - ls[y*lightResX+x] = spec; - } + // Apply our normalization function. + // Note: This is the full equation that applies the full normalization curve, not an approximation. + // This is fine, given we only need to create our LUT once per buffer initialization. + spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); + + // Since we use R16F, we no longer have a dynamic range issue we need to work around here. + // Though some older drivers may not like this, newer drivers shouldn't have this problem. + ls[y*lightResX+x] = spec; } + } - U32 pix_format = GL_R16F; + U32 pix_format = GL_R16F; #if LL_DARWIN - // Need to work around limited precision with 10.6.8 and older drivers - // - pix_format = GL_R32F; + // Need to work around limited precision with 10.6.8 and older drivers + // + pix_format = GL_R32F; #endif - LLImageGL::generateTextures(1, &mLightFunc); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + LLImageGL::generateTextures(1, &mLightFunc); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - delete [] ls; - } + delete [] ls; + } - mPbrBrdfLut.allocate(512, 512, GL_RG16F); - mPbrBrdfLut.bindTarget(); - gDeferredGenBrdfLutProgram.bind(); + mPbrBrdfLut.allocate(512, 512, GL_RG16F); + mPbrBrdfLut.bindTarget(); + gDeferredGenBrdfLutProgram.bind(); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex2f(-1, -1); - gGL.vertex2f(-1, 1); - gGL.vertex2f(1, -1); - gGL.vertex2f(1, 1); - gGL.end(); - gGL.flush(); + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex2f(-1, -1); + gGL.vertex2f(-1, 1); + gGL.vertex2f(1, -1); + gGL.vertex2f(1, 1); + gGL.end(); + gGL.flush(); - gDeferredGenBrdfLutProgram.unbind(); - mPbrBrdfLut.flush(); - } + gDeferredGenBrdfLutProgram.unbind(); + mPbrBrdfLut.flush(); } @@ -1331,11 +1318,6 @@ bool LLPipeline::canUseWindLightShaders() const return true; } -bool LLPipeline::canUseWindLightShadersOnObjects() const -{ - return true; -} - bool LLPipeline::canUseAntiAliasing() const { return true; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 483fe08559..0faa0c3f20 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -224,7 +224,6 @@ public: bool shadersLoaded(); bool canUseWindLightShaders() const; - bool canUseWindLightShadersOnObjects() const; bool canUseAntiAliasing() const; // phases @@ -421,7 +420,6 @@ public: static void setRenderHighlightTextureChannel(LLRender::eTexIndex channel); // sets which UV setup to display in highlight overlay static void updateRenderTransparentWater(); - static void updateRenderBump(); static void refreshCachedSettings(); void addDebugBlip(const LLVector3& position, const LLColor4& color); @@ -623,7 +621,6 @@ public: static bool sAutoMaskAlphaDeferred; static bool sAutoMaskAlphaNonDeferred; static bool sRenderTransparentWater; - static bool sRenderBump; static bool sBakeSunlight; static bool sNoAlpha; static bool sUseFarClip; -- cgit v1.3 From c97b6034eec9ce27a9d8f22db9a77b60e7e28779 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Mar 2023 13:49:33 -0500 Subject: SL-19297 Hacky fix for MY EYES! --- indra/newview/llvovolume.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index d1f4fa1c7a..e1335acc17 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6655,12 +6655,19 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace LLRenderPass::PASS_NORMSPEC_EMISSIVE, }; - U32 mask = mat->getShaderMask(); + U32 alpha_mode = mat->getDiffuseAlphaMode(); + if (!distance_sort && alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + { // HACK - this should never happen, but sometimes we get a material that thinks it has alpha blending when it ought not + alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + } + U32 mask = mat->getShaderMask(alpha_mode); llassert(mask < sizeof(pass)/sizeof(U32)); mask = llmin(mask, (U32)(sizeof(pass)/sizeof(U32)-1)); + // if this is going into alpha pool, distance sort MUST be true + llassert(pass[mask] == LLRenderPass::PASS_ALPHA ? distance_sort : true); registerFace(group, facep, pass[mask]); } } -- cgit v1.3 From e23b3972a00370aff25d582ce33dc0db6d795213 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Mar 2023 18:25:47 -0500 Subject: DRTVWR-559 Fix for bad hashing of materials breaking render batches and who knows what else. --- indra/llprimitive/llgltfmaterial.cpp | 10 ++++++++++ indra/llprimitive/llgltfmaterial.h | 9 +-------- indra/llprimitive/llmaterial.cpp | 2 +- indra/newview/llvovolume.cpp | 3 ++- 4 files changed, 14 insertions(+), 10 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index 62b693919c..f3aa5b0648 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -692,3 +692,13 @@ void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat) } } } + +LLUUID LLGLTFMaterial::getHash() const +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + // HACK - hash the bytes of this object but don't include the ref count + LLUUID hash; + HBXXH128::digest(hash, (unsigned char*)this + sizeof(LLRefCount), sizeof(*this) - sizeof(LLRefCount)); + return hash; +} + diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index b453b91e67..a53b68a50f 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -115,14 +115,7 @@ public: bool mOverrideAlphaMode = false; // get a UUID based on a hash of this LLGLTFMaterial - LLUUID getHash() const - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - // HACK - hash the bytes of this object but don't include the ref count - LLUUID hash; - HBXXH128::digest(hash, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); - return hash; - } + LLUUID getHash() const; //setters for various members (will clamp to acceptable ranges) // for_override - set to true if this value is being set as part of an override (important for handling override to default value) diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index a694a666c6..37525e4a3d 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -481,7 +481,7 @@ LLUUID LLMaterial::getHash() const LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; // HACK - hash the bytes of this LLMaterial, but trim off the S32 in LLRefCount LLUUID id; - HBXXH128::digest(id, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); + HBXXH128::digest(id, (unsigned char*)this + sizeof(LLRefCount), sizeof(*this) - sizeof(LLRefCount)); return id; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index e1335acc17..237f9e34a0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5416,7 +5416,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, if (gltf_mat) { - // nothing to do, render pools will reference the GLTF material + // just remember the material ID, render pools will reference the GLTF material + draw_info->mMaterialID = mat_id; } else if (mat) { -- cgit v1.3 From af57bbf0ca70f0a6209a7e39261a806040f6ea92 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Mar 2023 11:39:45 -0500 Subject: SL-18458 Fix for one failure mode of overrides getting applied before base material is set. --- indra/newview/llvovolume.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 237f9e34a0..7be9394364 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5670,6 +5670,12 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } + // HACK -- brute force this check every time a drawable gets rebuilt + for (S32 i = 0; i < drawablep->getNumFaces(); ++i) + { + vobj->updateTEMaterialTextures(i); + } + // apply any pending material overrides gGLTFMaterialList.applyQueuedOverrides(vobj); @@ -5754,9 +5760,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { continue; } - - // HACK -- brute force this check every time a drawable gets rebuilt - vobj->updateTEMaterialTextures(i); #if 0 #if LL_RELEASE_WITH_DEBUG_INFO const LLUUID pbr_id( "49c88210-7238-2a6b-70ac-92d4f35963cf" ); -- cgit v1.3 From 9b96bf168e15d49bfb6857b3370b9c843b150390 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Mar 2023 16:31:49 -0500 Subject: SL-19478 Fix for assert when applying specular map. --- indra/newview/llvovolume.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 7be9394364..77849c668a 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5473,6 +5473,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, llassert(type != LLRenderPass::PASS_BUMP || (info->mVertexBuffer->getTypeMask() & LLVertexBuffer::MAP_TANGENT) != 0); llassert(type != LLRenderPass::PASS_NORMSPEC || info->mNormalMap.notNull()); + llassert(type != LLRenderPass::PASS_SPECMAP || (info->mVertexBuffer->getTypeMask() & LLVertexBuffer::MAP_TEXCOORD2) != 0); } void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group) @@ -6666,6 +6667,15 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } U32 mask = mat->getShaderMask(alpha_mode); + U32 vb_mask = facep->getVertexBuffer()->getTypeMask(); + + // HACK - this should also never happen, but sometimes we get here and the material thinks it has a specmap now + // even though it didn't appear to have a specmap when the face was added to the list of faces + if ((mask & 0x4) && !(vb_mask & LLVertexBuffer::MAP_TEXCOORD2)) + { + mask &= ~0x4; + } + llassert(mask < sizeof(pass)/sizeof(U32)); mask = llmin(mask, (U32)(sizeof(pass)/sizeof(U32)-1)); -- cgit v1.3 From d32bca67f17b978387ece4d9b220fc7b4d74a89b Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 14 Apr 2023 07:36:13 -0500 Subject: DRTVWR-559 Add paranoia checks around typecasts of LLGLTFMaterial to LLFetchedGLTFMaterial --- indra/newview/lllocalgltfmaterials.cpp | 1 + indra/newview/lltexturectrl.cpp | 1 + indra/newview/llviewerobject.cpp | 4 +++- indra/newview/llviewertexturelist.cpp | 1 + indra/newview/llvovolume.cpp | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp index d464ea0571..b7fdead3f9 100644 --- a/indra/newview/lllocalgltfmaterials.cpp +++ b/indra/newview/lllocalgltfmaterials.cpp @@ -179,6 +179,7 @@ bool LLLocalGLTFMaterial::updateSelf() LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)entry->getGLTFRenderMaterial(); if (render_mat) { + llassert(dynamic_cast(entry->getGLTFRenderMaterial()) != nullptr); *render_mat = *this; render_mat->applyOverride(*override_mat); } diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 6c38550049..0dd1ff5483 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -573,6 +573,7 @@ void LLFloaterTexturePicker::draw() if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) { mGLTFMaterial = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mImageAssetID); + llassert(mGLTFMaterial == nullptr || dynamic_cast(gGLTFMaterialList.getMaterial(mImageAssetID)) != nullptr); } else { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index e641ac4215..100c73377f 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4957,10 +4957,12 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) } LLFetchedGLTFMaterial* mat = (LLFetchedGLTFMaterial*) getTE(te)->getGLTFRenderMaterial(); + llassert(mat == nullptr || dynamic_cast(getTE(te)->getGLTFRenderMaterial()) != nullptr); LLUUID mat_id = getRenderMaterialID(te); if (mat == nullptr && mat_id.notNull()) { mat = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mat_id); + llassert(mat == nullptr || dynamic_cast(gGLTFMaterialList.getMaterial(mat_id)) != nullptr); if (mat->isFetching()) { // material is not loaded yet, rebuild draw info when the object finishes loading mat->onMaterialComplete([id=getID()] @@ -5383,7 +5385,7 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma } LLFetchedGLTFMaterial* src_mat = (LLFetchedGLTFMaterial*) tep->getGLTFMaterial(); - + llassert(src_mat == nullptr || dynamic_cast(tep->getGLTFMaterial()) != nullptr); // if override mat exists, we must also have a source mat if (!src_mat) { diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 1449844588..d4c5e5535e 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -914,6 +914,7 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag // stats const LLTextureEntry* te = face->getTextureEntry(); LLFetchedGLTFMaterial* mat = te ? (LLFetchedGLTFMaterial*)te->getGLTFRenderMaterial() : nullptr; + llassert(mat == nullptr || dynamic_cast(te->getGLTFRenderMaterial()) != nullptr); if (mat) { touch_texture(mat->mBaseColorTexture, vsize); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 77849c668a..9a5719d8b6 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5291,6 +5291,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLUUID mat_id; auto* gltf_mat = (LLFetchedGLTFMaterial*) facep->getTextureEntry()->getGLTFRenderMaterial(); + llassert(gltf_mat == nullptr || dynamic_cast(facep->getTextureEntry()->getGLTFRenderMaterial()) != nullptr); if (gltf_mat != nullptr) { mat_id = gltf_mat->getHash(); // TODO: cache this hash -- cgit v1.3 From aaedacf3f3da9051f9f704eb1d050fcae63d0d3b Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 19 Apr 2023 18:15:28 -0500 Subject: DRTVWR-559 Fix for bad vertex data getting sent to PBR alpha shader (auto alpha mask regression). --- indra/newview/llface.cpp | 20 +++++++++++++------- indra/newview/llvovolume.cpp | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index d7e4632ab0..5554112043 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1081,21 +1081,27 @@ void LLFace::updateRebuildFlags() bool LLFace::canRenderAsMask() { - if (LLPipeline::sNoAlpha) + const LLTextureEntry* te = getTextureEntry(); + if( !te || !getViewerObject() || !getTexture() ) { - return true; + return false; } + if (te->getGLTFRenderMaterial()) + { + return false; + } + + if (LLPipeline::sNoAlpha) + { + return true; + } + if (isState(LLFace::RIGGED)) { // never auto alpha-mask rigged faces return false; } - const LLTextureEntry* te = getTextureEntry(); - if( !te || !getViewerObject() || !getTexture() ) - { - return false; - } LLMaterial* mat = te->getMaterialParams(); if (mat && mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 9a5719d8b6..a73d149b10 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5467,6 +5467,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_info->validate(); } + llassert(info->mGLTFMaterial == nullptr || (info->mVertexBuffer->getTypeMask() & LLVertexBuffer::MAP_TANGENT) != 0); llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR || info->mGLTFMaterial != nullptr); llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED || info->mGLTFMaterial != nullptr); llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK || info->mGLTFMaterial != nullptr); -- cgit v1.3 From 97dc4755ff2559e81720bdf87051eb1a50ff9bbb Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 26 Apr 2023 11:53:09 -0700 Subject: SL-19653: Fix assert: Prims were added to glow draw pool when glow was at or near zero --- indra/newview/llvovolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index a73d149b10..421205af97 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5826,7 +5826,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) const LLTextureEntry* te = facep->getTextureEntry(); LLViewerTexture* tex = facep->getTexture(); - if (te->getGlow() >= 1.f/255.f) + if (te->getGlow() > 0.f) { emissive = true; } -- cgit v1.3 From 1b9a9cc976161080a821c85897c704b5af9a0e34 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 26 Apr 2023 11:58:05 -0700 Subject: SL-19653: Fix data mask assert: specular-normal blinn-phong in wrong bin --- indra/newview/llvovolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 421205af97..b482ded121 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5910,7 +5910,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); - if (gltf_mat != nullptr || (te->getMaterialParams().notNull() && !te->getMaterialID().isNull())) + if (gltf_mat != nullptr || (te->getMaterialParams().notNull())) { if (gltf_mat != nullptr) { -- cgit v1.3 From 334d71e9107ae3c4d35b181f2ed6e5c9ff1de519 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Mon, 1 May 2023 17:05:09 -0500 Subject: SL-19656 Rewrite avatar and attachment render metrics to not interfere with render pipe and be representative of actual render cost instead of driver synchronization time. * SL-19656 Rewrite avatar and attachment render metrics to not interfere with render pipe and be representative of actual render cost instead of driver synchronization time. * SL-19656 Remove now dead code (trackAttachments et al). * SL-19656 Fix for crash on GL <= 3.2 --- indra/newview/lldrawpool.cpp | 70 ---------- indra/newview/lldrawpoolalpha.cpp | 36 ----- indra/newview/lldrawpoolavatar.cpp | 5 +- indra/newview/lldrawpoolbump.cpp | 36 ----- indra/newview/lldrawpoolmaterials.cpp | 14 -- indra/newview/llfloaterperformance.cpp | 246 ++++++++++++++++++++------------- indra/newview/llfloaterperformance.h | 4 +- indra/newview/llperfstats.cpp | 13 +- indra/newview/llperfstats.h | 73 +--------- indra/newview/llviewerjointmesh.cpp | 10 -- indra/newview/llviewerobject.h | 4 + indra/newview/llvoavatar.cpp | 3 +- indra/newview/llvoavatar.h | 39 +++++- indra/newview/llvovolume.cpp | 22 +-- indra/newview/llworld.cpp | 8 +- indra/newview/llworld.h | 4 +- indra/newview/pipeline.cpp | 125 +++++++++++++++-- indra/newview/pipeline.h | 3 +- 18 files changed, 324 insertions(+), 391 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 34d8f8b9ce..187e290066 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -52,8 +52,6 @@ #include "llglcommonfunc.h" #include "llvoavatar.h" #include "llviewershadermgr.h" -#include "llperfstats.h" - S32 LLDrawPool::sNumDrawPools = 0; @@ -387,22 +385,11 @@ void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, bool texture) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; - std::unique_ptr ratPtr{}; // Perf stats for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo *pparams = *k; if (pparams) { -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(pparams->mFace) - { - LLViewerObject* vobj = pparams->mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments(vobj, false, &ratPtr); - } - } -#endif pushBatch(*pparams, texture); } } @@ -415,23 +402,11 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool textu LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - std::unique_ptr ratPtr{}; // Perf stats for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo* pparams = *k; if (pparams) { -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(pparams->mFace) - { - LLViewerObject* vobj = pparams->mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, true ,&ratPtr); - } - } -#endif - if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) { uploadMatrixPalette(*pparams); @@ -447,7 +422,6 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool textu void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - std::unique_ptr ratPtr{}; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); for (LLCullResult::drawinfo_iterator i = begin; i != end; ) @@ -455,16 +429,6 @@ void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(pparams->mFace) - { - LLViewerObject* vobj = pparams->mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, false, &ratPtr); - } - } -#endif pushBatch(*pparams, texture, batch_textures); } } @@ -476,23 +440,11 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures U64 lastMeshId = 0; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); - std::unique_ptr ratPtr{}; // Perf stats for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(pparams->mFace) - { - LLViewerObject* vobj = pparams->mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, true, &ratPtr); - } - } -#endif - if (pparams->mAvatar.notNull() && (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash)) { uploadMatrixPalette(*pparams); @@ -507,23 +459,12 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - std::unique_ptr ratPtr{}; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if((*pparams).mFace) - { - LLViewerObject* vobj = (*pparams).mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, false, &ratPtr); - } - } -#endif LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); pushBatch(*pparams, texture, batch_textures); } @@ -534,7 +475,6 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - std::unique_ptr ratPtr{}; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); for (LLCullResult::drawinfo_iterator i = begin; i != end; ) @@ -544,16 +484,6 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text LLCullResult::increment_iterator(i, end); llassert(pparams); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if((*pparams).mFace) - { - LLViewerObject* vobj = (*pparams).mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, true, &ratPtr); - } - } -#endif if (LLGLSLShader::sCurBoundShaderPtr) { diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index da4c963a97..404039189b 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -49,7 +49,6 @@ #include "llspatialpartition.h" #include "llglcommonfunc.h" #include "llvoavatar.h" -#include "llperfstats.h" #include "llenvironment.h" @@ -349,22 +348,10 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask) { LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA+pass]; // <-- hacky + pass to use PASS_ALPHA_RIGGED on second pass - std::unique_ptr ratPtr{}; // Render time Stats collection for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo& params = **k; -# if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - bool rigged = (params.mAvatar != nullptr); gHighlightProgram.bind(rigged); gGL.diffuseColor4f(1, 0, 0, 1); @@ -548,17 +535,9 @@ void LLDrawPoolAlpha::renderRiggedEmissives(std::vector& emissives) LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - std::unique_ptr ratPtr{}; // Render time Stats collection for (LLDrawInfo* draw : emissives) { LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("Emissives"); -# if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - auto vobj = draw->mFace?draw->mFace->getViewerObject():nullptr; - if(vobj && vobj->isAttachment()) - { - trackAttachments( vobj, draw->mFace->isState(LLFace::RIGGED), &ratPtr ); - } -#endif bool tex_setup = TexSetup(draw, false); if (lastAvatar != draw->mAvatar || lastMeshId != draw->mSkinInfo->mHash) @@ -687,7 +666,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) LLSpatialGroup::drawmap_elem_t& draw_info = rigged ? group->mDrawMap[LLRenderPass::PASS_ALPHA_RIGGED] : group->mDrawMap[LLRenderPass::PASS_ALPHA]; - std::unique_ptr ratPtr{}; // Render time Stats collection for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo& params = **k; @@ -700,18 +678,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) LLRenderPass::applyModelMatrix(params); -# if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - - if(vobj->isAttachment()) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - LLMaterial* mat = NULL; LLGLTFMaterial *gltf_mat = params.mGLTFMaterial; @@ -905,8 +871,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) } } - ratPtr.reset(); // force the final batch to terminate to avoid double counting on the subsidiary batches for FB and Emmissives - // render emissive faces into alpha channel for bloom effects if (!depth_only) { diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index c398087b20..19b23609a6 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -52,7 +52,6 @@ #include "llviewerpartsim.h" #include "llviewercontrol.h" // for gSavedSettings #include "llviewertexturelist.h" -#include "llperfstats.h" static U32 sShaderLevel = 0; @@ -370,9 +369,8 @@ void LLDrawPoolAvatar::renderShadow(S32 pass) { return; } - LLPerfStats::RecordAvatarTime T(avatarp->getID(), LLPerfStats::StatType_t::RENDER_SHADOWS); - LLVOAvatar::AvatarOverallAppearance oa = avatarp->getOverallAppearance(); + LLVOAvatar::AvatarOverallAppearance oa = avatarp->getOverallAppearance(); BOOL impostor = !LLPipeline::sImpostorRender && avatarp->isImpostor(); // no shadows if the shadows are causing this avatar to breach the limit. if (avatarp->isTooSlow() || impostor || (oa == LLVOAvatar::AOA_INVISIBLE)) @@ -741,7 +739,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) { return; } - LLPerfStats::RecordAvatarTime T(avatarp->getID(), LLPerfStats::StatType_t::RENDER_GEOMETRY); if (!single_avatar && !avatarp->isFullyLoaded() ) { diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index a548740ec4..9ed776f49e 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -49,7 +49,6 @@ #include "llspatialpartition.h" #include "llviewershadermgr.h" #include "llmodel.h" -#include "llperfstats.h" //#include "llimagebmp.h" //#include "../tools/imdebug/imdebug.h" @@ -406,19 +405,10 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, bool texture = { LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; - std::unique_ptr ratPtr{}; for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo& params = **k; -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - if( vobj && vobj->isAttachment() ) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } -#endif - applyModelMatrix(params); params.mVertexBuffer->setBuffer(); @@ -568,25 +558,12 @@ void LLDrawPoolBump::renderDeferred(S32 pass) LLVOAvatar* avatar = nullptr; U64 skin = 0; - std::unique_ptr ratPtr{}; for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo& params = **i; LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - - if(vobj && vobj->isAttachment()) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(params.mAlphaMaskCutoff); LLDrawPoolBump::bindBumpMap(params, bump_channel); @@ -1215,23 +1192,10 @@ void LLDrawPoolBump::pushBumpBatches(U32 type) LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); - std::unique_ptr ratPtr{}; for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) { LLDrawInfo& params = **i; -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - - if( vobj && vobj->isAttachment() ) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - if (LLDrawPoolBump::bindBumpMap(params)) { if (mRigged) diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index e025651cce..6a7e05ac74 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -32,7 +32,6 @@ #include "pipeline.h" #include "llglcommonfunc.h" #include "llvoavatar.h" -#include "llperfstats.h" LLDrawPoolMaterials::LLDrawPoolMaterials() : LLRenderPass(LLDrawPool::POOL_MATERIALS) @@ -151,7 +150,6 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); - std::unique_ptr ratPtr{}; F32 lastIntensity = 0.f; F32 lastFullbright = 0.f; F32 lastMinimumAlpha = 0.f; @@ -201,18 +199,6 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - - if( vobj && vobj->isAttachment() ) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - if (specular > -1 && params.mSpecColor != lastSpecular) { lastSpecular = params.mSpecColor; diff --git a/indra/newview/llfloaterperformance.cpp b/indra/newview/llfloaterperformance.cpp index 3321374f65..25b744a5ab 100644 --- a/indra/newview/llfloaterperformance.cpp +++ b/indra/newview/llfloaterperformance.cpp @@ -57,8 +57,6 @@ const S32 BAR_RIGHT_PAD = 5; const S32 BAR_BOTTOM_PAD = 9; constexpr auto AvType {LLPerfStats::ObjType_t::OT_AVATAR}; -constexpr auto AttType {LLPerfStats::ObjType_t::OT_ATTACHMENT}; -constexpr auto HudType {LLPerfStats::ObjType_t::OT_HUD}; class LLExceptionsContextMenu : public LLListContextMenu { @@ -83,8 +81,7 @@ protected: LLFloaterPerformance::LLFloaterPerformance(const LLSD& key) : LLFloater(key), - mUpdateTimer(new LLTimer()), - mNearbyMaxComplexity(0) + mUpdateTimer(new LLTimer()) { mContextMenu = new LLExceptionsContextMenu(this); } @@ -247,47 +244,82 @@ void LLFloaterPerformance::populateHUDList() mHUDList->clearRows(); mHUDList->updateColumns(true); - hud_complexity_list_t complexity_list = LLHUDRenderNotifier::getInstance()->getHUDComplexityList(); - - hud_complexity_list_t::iterator iter = complexity_list.begin(); - hud_complexity_list_t::iterator end = complexity_list.end(); - - auto huds_max_render_time_raw = LLPerfStats::StatsRecorder::getMax(HudType, LLPerfStats::StatType_t::RENDER_GEOMETRY); - for (iter = complexity_list.begin(); iter != end; ++iter) - { - LLHUDComplexity hud_object_complexity = *iter; - - auto hud_render_time_raw = LLPerfStats::StatsRecorder::get(HudType, hud_object_complexity.objectId, LLPerfStats::StatType_t::RENDER_GEOMETRY); - - LLSD item; - item["special_id"] = hud_object_complexity.objectId; - item["target"] = LLNameListCtrl::SPECIAL; - LLSD& row = item["columns"]; - row[0]["column"] = "complex_visual"; - row[0]["type"] = "bar"; - LLSD& value = row[0]["value"]; - value["ratio"] = (F32)hud_render_time_raw / huds_max_render_time_raw; - value["bottom"] = BAR_BOTTOM_PAD; - value["left_pad"] = BAR_LEFT_PAD; - value["right_pad"] = BAR_RIGHT_PAD; - - row[1]["column"] = "complex_value"; - row[1]["type"] = "text"; - row[1]["value"] = llformat( "%.f", llmax(LLPerfStats::raw_to_us(hud_render_time_raw), (double)1)); - row[1]["font"]["name"] = "SANSSERIF"; - - row[2]["column"] = "name"; - row[2]["type"] = "text"; - row[2]["value"] = hud_object_complexity.objectName; - row[2]["font"]["name"] = "SANSSERIF"; - - LLScrollListItem* obj = mHUDList->addElement(item); - if (obj) + LLVOAvatar* avatar = gAgentAvatarp; + + gPipeline.profileAvatar(avatar, true); + + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); + + // get max gpu render time of all attachments + F32 max_gpu_time = -1.f; + + for (iter = begin; iter != end; ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && attached_object->isHUDAttachment()) + { + max_gpu_time = llmax(max_gpu_time, attached_object->mGPURenderTime); + } + } + } + + + for (iter = begin; iter != end; ++iter) + { + if (!iter->second) { - LLScrollListText* value_text = dynamic_cast(obj->getColumn(1)); - if (value_text) + continue; + } + + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && attached_object->isHUDAttachment()) { - value_text->setAlignment(LLFontGL::HCENTER); + F32 gpu_time = attached_object->mGPURenderTime; + + LLSD item; + item["special_id"] = attached_object->getID(); + item["target"] = LLNameListCtrl::SPECIAL; + LLSD& row = item["columns"]; + row[0]["column"] = "complex_visual"; + row[0]["type"] = "bar"; + LLSD& value = row[0]["value"]; + value["ratio"] = gpu_time / max_gpu_time; + value["bottom"] = BAR_BOTTOM_PAD; + value["left_pad"] = BAR_LEFT_PAD; + value["right_pad"] = BAR_RIGHT_PAD; + + row[1]["column"] = "complex_value"; + row[1]["type"] = "text"; + // show gpu time in us + row[1]["value"] = llformat("%.f", gpu_time * 1000.f); + row[1]["font"]["name"] = "SANSSERIF"; + + row[2]["column"] = "name"; + row[2]["type"] = "text"; + row[2]["value"] = attached_object->getAttachmentItemName(); + row[2]["font"]["name"] = "SANSSERIF"; + + LLScrollListItem* obj = mHUDList->addElement(item); + if (obj) + { + LLScrollListText* value_text = dynamic_cast(obj->getColumn(1)); + if (value_text) + { + value_text->setAlignment(LLFontGL::HCENTER); + } + } } } } @@ -303,50 +335,82 @@ void LLFloaterPerformance::populateObjectList() mObjectList->clearRows(); mObjectList->updateColumns(true); - object_complexity_list_t complexity_list = LLAvatarRenderNotifier::getInstance()->getObjectComplexityList(); + LLVOAvatar* avatar = gAgentAvatarp; - object_complexity_list_t::iterator iter = complexity_list.begin(); - object_complexity_list_t::iterator end = complexity_list.end(); + gPipeline.profileAvatar(avatar, true); - // for consistency we lock the buffer while we build the list. In theory this is uncontended as the buffer should only toggle on end of frame - { - std::lock_guard guard{ LLPerfStats::bufferToggleLock }; - auto att_max_render_time_raw = LLPerfStats::StatsRecorder::getMax(AttType, LLPerfStats::StatType_t::RENDER_COMBINED); + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); - for (iter = complexity_list.begin(); iter != end; ++iter) - { - LLObjectComplexity object_complexity = *iter; + // get max gpu render time of all attachments + F32 max_gpu_time = -1.f; - auto attach_render_time_raw = LLPerfStats::StatsRecorder::get(AttType, object_complexity.objectId, LLPerfStats::StatType_t::RENDER_COMBINED); - LLSD item; - item["special_id"] = object_complexity.objectId; - item["target"] = LLNameListCtrl::SPECIAL; - LLSD& row = item["columns"]; - row[0]["column"] = "complex_visual"; - row[0]["type"] = "bar"; - LLSD& value = row[0]["value"]; - value["ratio"] = ((F32)attach_render_time_raw) / att_max_render_time_raw; - value["bottom"] = BAR_BOTTOM_PAD; - value["left_pad"] = BAR_LEFT_PAD; - value["right_pad"] = BAR_RIGHT_PAD; - - row[1]["column"] = "complex_value"; - row[1]["type"] = "text"; - row[1]["value"] = llformat("%.f", llmax(LLPerfStats::raw_to_us(attach_render_time_raw), (double)1)); - row[1]["font"]["name"] = "SANSSERIF"; + for (iter = begin; iter != end; ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && !attached_object->isHUDAttachment()) + { + max_gpu_time = llmax(max_gpu_time, attached_object->mGPURenderTime); + } + } + } - row[2]["column"] = "name"; - row[2]["type"] = "text"; - row[2]["value"] = object_complexity.objectName; - row[2]["font"]["name"] = "SANSSERIF"; + { + for (iter = begin; iter != end; ++iter) + { + if (!iter->second) + { + continue; + } - LLScrollListItem* obj = mObjectList->addElement(item); - if (obj) + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) { - LLScrollListText* value_text = dynamic_cast(obj->getColumn(1)); - if (value_text) + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && !attached_object->isHUDAttachment()) { - value_text->setAlignment(LLFontGL::HCENTER); + F32 gpu_time = attached_object->mGPURenderTime; + + LLSD item; + item["special_id"] = attached_object->getID(); + item["target"] = LLNameListCtrl::SPECIAL; + LLSD& row = item["columns"]; + row[0]["column"] = "complex_visual"; + row[0]["type"] = "bar"; + LLSD& value = row[0]["value"]; + value["ratio"] = gpu_time / max_gpu_time; + value["bottom"] = BAR_BOTTOM_PAD; + value["left_pad"] = BAR_LEFT_PAD; + value["right_pad"] = BAR_RIGHT_PAD; + + row[1]["column"] = "complex_value"; + row[1]["type"] = "text"; + // show gpu time in us + row[1]["value"] = llformat("%.f", gpu_time * 1000.f); + row[1]["font"]["name"] = "SANSSERIF"; + + row[2]["column"] = "name"; + row[2]["type"] = "text"; + row[2]["value"] = attached_object->getAttachmentItemName(); + row[2]["font"]["name"] = "SANSSERIF"; + + LLScrollListItem* obj = mObjectList->addElement(item); + if (obj) + { + LLScrollListText* value_text = dynamic_cast(obj->getColumn(1)); + if (value_text) + { + value_text->setAlignment(LLFontGL::HCENTER); + } + } } } } @@ -358,6 +422,7 @@ void LLFloaterPerformance::populateObjectList() void LLFloaterPerformance::populateNearbyList() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; static LLCachedControl showTunedART(gSavedSettings, "ShowTunedART"); S32 prev_pos = mNearbyList->getScrollPos(); LLUUID prev_selected_id = mNearbyList->getStringUUIDSelectedItem(); @@ -366,22 +431,16 @@ void LLFloaterPerformance::populateNearbyList() static LLCachedControl max_render_cost(gSavedSettings, "RenderAvatarMaxComplexity", 0); std::vector valid_nearby_avs; - mNearbyMaxComplexity = LLWorld::getInstance()->getNearbyAvatarsAndCompl(valid_nearby_avs); + mNearbyMaxGPUTime = LLWorld::getInstance()->getNearbyAvatarsAndMaxGPUTime(valid_nearby_avs); std::vector::iterator char_iter = valid_nearby_avs.begin(); - LLPerfStats::bufferToggleLock.lock(); - auto av_render_max_raw = LLPerfStats::StatsRecorder::getMax(AvType, LLPerfStats::StatType_t::RENDER_COMBINED); - LLPerfStats::bufferToggleLock.unlock(); - while (char_iter != valid_nearby_avs.end()) { LLVOAvatar* avatar = dynamic_cast(*char_iter); if (avatar && (LLVOAvatar::AOA_INVISIBLE != avatar->getOverallAppearance())) { - LLPerfStats::bufferToggleLock.lock(); - auto render_av_raw = LLPerfStats::StatsRecorder::get(AvType, avatar->getID(),LLPerfStats::StatType_t::RENDER_COMBINED); - LLPerfStats::bufferToggleLock.unlock(); + F32 render_av_gpu_ms = avatar->getGPURenderTime(); auto is_slow = avatar->isTooSlow(); LLSD item; @@ -392,7 +451,7 @@ void LLFloaterPerformance::populateNearbyList() LLSD& value = row[0]["value"]; // The ratio used in the bar is the current cost, as soon as we take action this changes so we keep the // pre-tune value for the numerical column and sorting. - value["ratio"] = (double)render_av_raw / av_render_max_raw; + value["ratio"] = render_av_gpu_ms / mNearbyMaxGPUTime; value["bottom"] = BAR_BOTTOM_PAD; value["left_pad"] = BAR_LEFT_PAD; value["right_pad"] = BAR_RIGHT_PAD; @@ -405,14 +464,15 @@ void LLFloaterPerformance::populateNearbyList() } else { - row[1]["value"] = llformat( "%.f", LLPerfStats::raw_to_us( render_av_raw ) ); + // use GPU time in us + row[1]["value"] = llformat( "%.f", render_av_gpu_ms * 1000.f); } row[1]["font"]["name"] = "SANSSERIF"; - row[2]["column"] = "name"; - row[2]["type"] = "text"; - row[2]["value"] = avatar->getFullname(); - row[2]["font"]["name"] = "SANSSERIF"; + row[3]["column"] = "name"; + row[3]["type"] = "text"; + row[3]["value"] = avatar->getFullname(); + row[3]["font"]["name"] = "SANSSERIF"; LLScrollListItem* av_item = mNearbyList->addElement(item); if(av_item) diff --git a/indra/newview/llfloaterperformance.h b/indra/newview/llfloaterperformance.h index 00f904f6d6..620dbac5bb 100644 --- a/indra/newview/llfloaterperformance.h +++ b/indra/newview/llfloaterperformance.h @@ -94,7 +94,9 @@ private: LLTimer* mUpdateTimer; - S32 mNearbyMaxComplexity; + // maximum GPU time of nearby avatars in ms according to LLWorld::getNearbyAvatarsAndMaxGPUTime + // -1.f if no profile has happened yet + F32 mNearbyMaxGPUTime = -1.f; boost::signals2::connection mMaxARTChangedSignal; }; diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index c63aae2089..b680d8761b 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -199,18 +199,7 @@ namespace LLPerfStats // LL_INFOS("scenestats") << "Scenestat: " << static_cast(statEntry) << " before=" << avg << " new=" << val << " newavg=" << statsDoubleBuffer[writeBuffer][static_cast(ObjType_t::OT_GENERAL)][LLUUID::null][static_cast(statEntry)] << LL_ENDL; } } -// Allow attachment times etc to update even when FPS limited or sleeping. - auto& statsMap = statsDoubleBuffer[writeBuffer][static_cast(ObjType_t::OT_ATTACHMENT)]; - for(auto& stat_entry : statsMap) - { - auto val = stat_entry.second[static_cast(ST::RENDER_COMBINED)]; - if(val > SMOOTHING_PERIODS){ - auto avg = statsDoubleBuffer[writeBuffer ^ 1][static_cast(ObjType_t::OT_ATTACHMENT)][stat_entry.first][static_cast(ST::RENDER_COMBINED)]; - stat_entry.second[static_cast(ST::RENDER_COMBINED)] = avg + (val / SMOOTHING_PERIODS) - (avg / SMOOTHING_PERIODS); - } - } - - + auto& statsMapAv = statsDoubleBuffer[writeBuffer][static_cast(ObjType_t::OT_AVATAR)]; for(auto& stat_entry : statsMapAv) { diff --git a/indra/newview/llperfstats.h b/indra/newview/llperfstats.h index dbb88a141d..a4768272b9 100644 --- a/indra/newview/llperfstats.h +++ b/indra/newview/llperfstats.h @@ -69,8 +69,6 @@ namespace LLPerfStats enum class ObjType_t{ OT_GENERAL=0, // Also Unknown. Used for n/a type stats such as scenery OT_AVATAR, - OT_ATTACHMENT, - OT_HUD, OT_COUNT }; enum class StatType_t{ @@ -260,31 +258,6 @@ namespace LLPerfStats doUpd(avKey, ot, type, val); return; } - - if (ot == ObjType_t::OT_ATTACHMENT) - { - if( !upd.isHUD ) // don't include HUD cost in self. - { - LL_PROFILE_ZONE_NAMED("Att as Av") - // For all attachments that are not rigged we add them to the avatar (for all avatars) cost. - doUpd(avKey, ObjType_t::OT_AVATAR, type, val); - } - if( avKey == focusAv ) - { - LL_PROFILE_ZONE_NAMED("Att as Att") - // For attachments that are for the focusAv (self for now) we record them for the attachment/complexity view - if(upd.isHUD) - { - ot = ObjType_t::OT_HUD; - } - // LL_INFOS("perfstats") << "frame: " << gFrameCount << " Attachment update("<< (type==StatType_t::RENDER_GEOMETRY?"GEOMETRY":"SHADOW") << ": " << key.asString() << " = " << val << LL_ENDL; - doUpd(key, ot, type, val); - } - // else - // { - // // LL_INFOS("perfstats") << "frame: " << gFrameCount << " non-self Att update("<< (type==StatType_t::RENDER_GEOMETRY?"GEOMETRY":"SHADOW") << ": " << key.asString() << " = " << val << " for av " << avKey.asString() << LL_ENDL; - // } - } } static inline void doUpd(const LLUUID& key, ObjType_t ot, StatType_t type, uint64_t val) @@ -409,51 +382,7 @@ namespace LLPerfStats using RecordSceneTime = RecordTime; using RecordAvatarTime = RecordTime; - using RecordAttachmentTime = RecordTime; - using RecordHudAttachmentTime = RecordTime; - -};// namespace LLPerfStats - -// helper functions -using RATptr = std::unique_ptr; -using RSTptr = std::unique_ptr; -template -static inline void trackAttachments(const T * vobj, bool isRigged, RATptr* ratPtrp) -{ - if( !vobj ){ ratPtrp->reset(); return;}; - - const T* rootAtt{vobj}; - if (rootAtt->isAttachment()) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; - - while( !rootAtt->isRootEdit() ) - { - rootAtt = (T*)(rootAtt->getParent()); - } - - auto avPtr = (T*)(rootAtt->getParent()); - if(!avPtr){ratPtrp->reset(); return;} - - auto& av = avPtr->getID(); - auto& obj = rootAtt->getAttachmentItemID(); - if (!*ratPtrp || (*ratPtrp)->stat.objID != obj || (*ratPtrp)->stat.avID != av) - { - if (*ratPtrp) - { - // deliberately reset to ensure destruction before construction of replacement. - ratPtrp->reset(); - }; - *ratPtrp = std::make_unique( - av, - obj, - ( LLPipeline::sShadowRender?LLPerfStats::StatType_t::RENDER_SHADOWS : LLPerfStats::StatType_t::RENDER_GEOMETRY ), - isRigged, - rootAtt->isHUDAttachment()); - } - } - return; -}; +};// namespace LLPerfStats #endif diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 00e1179896..5ce8f4023d 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -227,16 +227,6 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) return 0; } - // render time capture - // This path does not appear to have attachments. Prove this then remove. - std::unique_ptr ratPtr{}; - auto vobj = mFace->getViewerObject(); - if( vobj && vobj->isAttachment() ) - { - trackAttachments( vobj, mFace->isState(LLFace::RIGGED), &ratPtr ); - LL_WARNS("trackAttachments") << "Attachment render time is captuted." << LL_ENDL; - } - U32 triangle_count = 0; S32 diffuse_channel = LLDrawPoolAvatar::sDiffuseChannel; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index fe27227e6b..cd2363a1b9 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -941,6 +941,10 @@ public: // reflection probe state bool mIsReflectionProbe = false; // if true, this object should register itself with LLReflectionProbeManager LLPointer mReflectionProbe = nullptr; // reflection probe coupled to this viewer object. If not null, should be deregistered when this object is destroyed + + // the amount of GPU time (in ms) it took to render this object according to LLPipeline::profileAvatar + // -1.f if no profile data available + F32 mGPURenderTime = -1.f; }; /////////////////// diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5b8f4767db..e38a6457f4 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -8357,7 +8357,7 @@ void LLVOAvatar::updateTooSlow() { // use the cached values. render_time_raw = mRenderTime; - render_geom_time_raw = mGeomTime; + render_geom_time_raw = mGeomTime; } bool autotune = LLPerfStats::tunables.userAutoTuneEnabled && !mIsControlAvatar && !isSelf(); @@ -10984,6 +10984,7 @@ void LLVOAvatar::accountRenderComplexityForObject( // Calculations for mVisualComplexity value void LLVOAvatar::calculateUpdateRenderComplexity() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; /***************************************************************** * This calculation should not be modified by third party viewers, * since it is used to limit rendering and should be uniform for diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 1502c25b4d..0bb19c4420 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -305,8 +305,27 @@ public: static const U32 VISUAL_COMPLEXITY_UNKNOWN; void updateVisualComplexity(); - U32 getVisualComplexity() { return mVisualComplexity; }; // Numbers calculated here by rendering AV - F32 getAttachmentSurfaceArea() { return mAttachmentSurfaceArea; }; // estimated surface area of attachments + // get the GPU time in ms of rendering this avatar including all attachments + // returns -1 if this avatar has not been profiled using gPipeline.profileAvatar + F32 getGPURenderTime() { return mGPURenderTime; } + + // get the CPU time in ms of rendering this avatar including all attachments + // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar + F32 getCPURenderTime() { return mCPURenderTime; } + + // get the number of samples passed during the avatar profile + // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar + S32 getGPUSamplesPassed() { return mGPUSamplesPassed; } + + // get the number of triangles rendered during the avatar profile + // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar + S32 getGPUTrianglesRendered() { return mGPUTrianglesRendered; } + + // DEPRECATED -- obsolete avatar render cost + U32 getVisualComplexity() { return mVisualComplexity; }; + + // DEPRECATED -- obsolete surface area calculation + F32 getAttachmentSurfaceArea() { return mAttachmentSurfaceArea; }; U32 getReportedVisualComplexity() { return mReportedVisualComplexity; }; // Numbers as reported by the SL server void setReportedVisualComplexity(U32 value) { mReportedVisualComplexity = value; }; @@ -523,6 +542,7 @@ public: S32 mSpecialRenderMode; // special lighting private: + friend class LLPipeline; AvatarOverallAppearance mOverallAppearance; F32 mAttachmentSurfaceArea; //estimated surface area of attachments U32 mAttachmentVisibleTriangleCount; @@ -535,7 +555,22 @@ private: S32 mUpdatePeriod; S32 mNumInitFaces; //number of faces generated when creating the avatar drawable, does not inculde splitted faces due to long vertex buffer. + // profile results + + // GPU render time in ms + F32 mGPURenderTime = -1.f; + + // CPU render time in ms + F32 mCPURenderTime = -1.f; + + // number of samples passed according to GPU + S32 mGPUSamplesPassed = -1; + + // number of triangles rendered according to GPU + S32 mGPUTrianglesRendered = -1; + // the isTooComplex method uses these mutable values to avoid recalculating too frequently + // DEPRECATED -- obsolete avatar render cost values mutable U32 mVisualComplexity; mutable bool mVisualComplexityStale; U32 mReportedVisualComplexity; // from other viewers through the simulator diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 12ceb86e52..da5a505d3b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -88,7 +88,6 @@ #include "llcallstack.h" #include "llsculptidsize.h" #include "llavatarappearancedefines.h" -#include "llperfstats.h" #include "llgltfmateriallist.h" const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; @@ -5657,7 +5656,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) LL_PROFILE_ZONE_NAMED("rebuildGeom - face list"); //get all the faces into a list - std::unique_ptr ratPtr{}; for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) { @@ -5693,11 +5691,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } - if(vobj->isAttachment()) - { - trackAttachments( vobj, drawablep->isState(LLDrawable::RIGGED),&ratPtr); - } - LLVolume* volume = vobj->getVolume(); if (volume) { @@ -6095,8 +6088,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) U32 buffer_count = 0; - std::unique_ptr ratPtr{}; - for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) + for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) { LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable(); @@ -6106,11 +6098,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) if (!vobj) continue; - if (vobj->isAttachment()) - { - trackAttachments( vobj, drawablep->isState(LLDrawable::RIGGED), &ratPtr ); - } - if (debugLoggingEnabled("AnimatedObjectsLinkset")) { if (vobj->isAnimatedObject() && vobj->isRiggedMesh()) @@ -6479,16 +6466,11 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace U32 indices_index = 0; U16 index_offset = 0; - std::unique_ptr ratPtr; while (face_iter < i) { //update face indices for new buffer facep = *face_iter; - LLViewerObject* vobj = facep->getViewerObject(); - if(vobj && vobj->isAttachment()) - { - trackAttachments(vobj, LLPipeline::sShadowRender, &ratPtr); - } + if (buffer.isNull()) { // Bulk allocation failed diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 72c8cb371f..732ef1da6c 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1424,10 +1424,10 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector* positi } } -S32 LLWorld::getNearbyAvatarsAndCompl(std::vector &valid_nearby_avs) +F32 LLWorld::getNearbyAvatarsAndMaxGPUTime(std::vector &valid_nearby_avs) { static LLCachedControl render_far_clip(gSavedSettings, "RenderFarClip", 64); - S32 nearby_max_complexity = 0; + F32 nearby_max_complexity = 0; F32 radius = render_far_clip * render_far_clip; std::vector::iterator char_iter = LLCharacter::sInstances.begin(); while (char_iter != LLCharacter::sInstances.end()) @@ -1441,8 +1441,8 @@ S32 LLWorld::getNearbyAvatarsAndCompl(std::vector &valid_nearby_av char_iter++; continue; } - avatar->calculateUpdateRenderComplexity(); - nearby_max_complexity = llmax(nearby_max_complexity, (S32)avatar->getVisualComplexity()); + gPipeline.profileAvatar(avatar); + nearby_max_complexity = llmax(nearby_max_complexity, avatar->getGPURenderTime()); valid_nearby_avs.push_back(*char_iter); } char_iter++; diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index b2be36d72c..f78cbcaa48 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -172,7 +172,9 @@ public: // or if the circuit to this simulator had been lost. bool isRegionListed(const LLViewerRegion* region) const; - S32 getNearbyAvatarsAndCompl(std::vector &valid_nearby_avs); + // profile nearby avatars using gPipeline.profileAvatar and update their render times + // return max GPU time + F32 getNearbyAvatarsAndMaxGPUTime(std::vector &valid_nearby_avs); private: void clearHoleWaterObjects(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2912d0da82..df8b8a552a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10070,7 +10070,88 @@ void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture) static LLTrace::BlockTimerStatHandle FTM_GENERATE_IMPOSTOR("Generate Impostor"); -void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) +void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) +{ + if (gGLManager.mGLVersion < 3.25f) + { // profiling requires GL 3.3 or later + return; + } + LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; + + mRT->deferredScreen.bindTarget(); + mRT->deferredScreen.clear(); + + bool profile_enabled = LLGLSLShader::sProfileEnabled; + LLGLSLShader::sProfileEnabled = true; + + if (!profile_attachments) + { + // profile entire avatar all at once + + // use gDebugProgram as a proxy for getting profile results + gDebugProgram.clearStats(); + gDebugProgram.placeProfileQuery(); + LLGLSLShader::sProfileEnabled = false; + + LLTimer cpu_timer; + + generateImpostor(avatar, false, true); + + avatar->mCPURenderTime = (F32)cpu_timer.getElapsedTimeF32() * 1000.f; + + LLGLSLShader::sProfileEnabled = true; + gDebugProgram.readProfileQuery(); + + avatar->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; + + avatar->mGPUSamplesPassed = gDebugProgram.mSamplesDrawn; + avatar->mGPUTrianglesRendered = gDebugProgram.mTrianglesDrawn; + } + else + { + // profile attachments one at a time + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); + + for (iter = begin; + iter != end; + ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object) + { + gDebugProgram.clearStats(); + gDebugProgram.placeProfileQuery(); + LLGLSLShader::sProfileEnabled = false; + + generateImpostor(avatar, false, true, attached_object); + LLGLSLShader::sProfileEnabled = true; + gDebugProgram.readProfileQuery(); + + attached_object->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; + + // TODO: maybe also record triangles and samples + } + } + } + } + + LLGLSLShader::sProfileEnabled = profile_enabled; + mRT->deferredScreen.flush(); + + if (cur_shader) + { + cur_shader->bind(); + } +} + +void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool for_profile, LLViewerObject* specific_attachment) { LL_RECORD_BLOCK_TIME(FTM_GENERATE_IMPOSTOR); LL_PROFILE_GPU_ZONE("generateImpostor"); @@ -10090,11 +10171,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) assertInitialized(); // previews can't be muted or impostered - bool visually_muted = !preview_avatar && avatar->isVisuallyMuted(); + bool visually_muted = !for_profile && !preview_avatar && avatar->isVisuallyMuted(); LL_DEBUGS_ONCE("AvatarRenderPipeline") << "Avatar " << avatar->getID() << " is " << ( visually_muted ? "" : "not ") << "visually muted" << LL_ENDL; - bool too_complex = !preview_avatar && avatar->isTooComplex(); + bool too_complex = !for_profile && !preview_avatar && avatar->isTooComplex(); LL_DEBUGS_ONCE("AvatarRenderPipeline") << "Avatar " << avatar->getID() << " is " << ( too_complex ? "" : "not ") << "too complex" << LL_ENDL; @@ -10129,6 +10210,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) ); } + if (specific_attachment && specific_attachment->isHUDAttachment()) + { //enable HUD rendering + setRenderTypeMask(RENDER_TYPE_HUD, END_RENDER_TYPES); + } + S32 occlusion = sUseOcclusion; sUseOcclusion = 0; @@ -10185,20 +10271,30 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) } else { - LLVOAvatar::attachment_map_t::iterator iter; - for (iter = avatar->mAttachmentPoints.begin(); - iter != avatar->mAttachmentPoints.end(); - ++iter) + if (specific_attachment) { - LLViewerJointAttachment *attachment = iter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) + markVisible(specific_attachment->mDrawable->getSpatialBridge(), *viewer_camera); + } + else + { + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); + + for (iter = begin; + iter != end; + ++iter) { - LLViewerObject* attached_object = attachment_iter->get(); - if (attached_object) + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) { - markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera); + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object) + { + markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera); + } } } } @@ -10327,6 +10423,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) LLDrawPoolAvatar::sMinimumAlpha = old_alpha; + if (!for_profile) { //create alpha mask based on depth buffer (grey out if muted) if (LLPipeline::sRenderDeferred) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index dbd1a34f61..45842a3948 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -132,7 +132,8 @@ public: bool allocateShadowBuffer(U32 resX, U32 resY); void resetVertexBuffers(LLDrawable* drawable); - void generateImpostor(LLVOAvatar* avatar, bool preview_avatar = false); + void profileAvatar(LLVOAvatar* avatar, bool profile_attachments = false); + void generateImpostor(LLVOAvatar* avatar, bool preview_avatar = false, bool for_profile = false, LLViewerObject* specific_attachment = nullptr); void bindScreenToTexture(); void renderFinalize(); void copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* dst); -- cgit v1.3 From e09475713b7abe6fcb916f4a770081a1696b57ab Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 2 May 2023 18:47:21 -0500 Subject: DRTVWR-559 Optimization pass, make it so profileAvatar can read back GPU timer without a frame stall. --- indra/llcommon/llerror.cpp | 1 + indra/llrender/llglslshader.cpp | 72 ++++++++++++++++++++++++++------------ indra/llrender/llglslshader.h | 16 +++++++-- indra/llwindow/llwindowwin32.cpp | 12 +++---- indra/newview/lldrawable.cpp | 6 ---- indra/newview/lldrawpoolalpha.cpp | 8 ++--- indra/newview/llmeshrepository.cpp | 1 + indra/newview/llviewerobject.cpp | 1 + indra/newview/llvoavatar.cpp | 64 ++++++++++++++++++++++++++++----- indra/newview/llvoavatar.h | 26 ++++++-------- indra/newview/llvoavatarself.cpp | 1 + indra/newview/llvovolume.cpp | 34 +++--------------- indra/newview/pipeline.cpp | 71 ++++++++++++++----------------------- indra/newview/pipeline.h | 9 +++++ 14 files changed, 179 insertions(+), 143 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 56fb7c21ca..a7794cc045 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -1611,6 +1611,7 @@ namespace LLError bool debugLoggingEnabled(const std::string& tag) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; LLMutexTrylock lock(getMutex(), 5); if (!lock.isLocked()) { diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 04ac2476a7..b7f08aa9af 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -243,9 +243,9 @@ void LLGLSLShader::stopProfile() } } -void LLGLSLShader::placeProfileQuery() +void LLGLSLShader::placeProfileQuery(bool for_runtime) { - if (sProfileEnabled) + if (sProfileEnabled || for_runtime) { if (mTimerQuery == 0) { @@ -254,42 +254,70 @@ void LLGLSLShader::placeProfileQuery() glGenQueries(1, &mPrimitivesQuery); } - glBeginQuery(GL_SAMPLES_PASSED, mSamplesQuery); glBeginQuery(GL_TIME_ELAPSED, mTimerQuery); - glBeginQuery(GL_PRIMITIVES_GENERATED, mPrimitivesQuery); + + if (!for_runtime) + { + glBeginQuery(GL_SAMPLES_PASSED, mSamplesQuery); + glBeginQuery(GL_PRIMITIVES_GENERATED, mPrimitivesQuery); + } } } -void LLGLSLShader::readProfileQuery() +bool LLGLSLShader::readProfileQuery(bool for_runtime, bool force_read) { - if (sProfileEnabled) + if (sProfileEnabled || for_runtime) { - glEndQuery(GL_TIME_ELAPSED); - glEndQuery(GL_SAMPLES_PASSED); - glEndQuery(GL_PRIMITIVES_GENERATED); + if (!mProfilePending) + { + glEndQuery(GL_TIME_ELAPSED); + if (!for_runtime) + { + glEndQuery(GL_SAMPLES_PASSED); + glEndQuery(GL_PRIMITIVES_GENERATED); + } + mProfilePending = for_runtime; + } + + if (mProfilePending && for_runtime && !force_read) + { + GLuint64 result = 0; + glGetQueryObjectui64v(mTimerQuery, GL_QUERY_RESULT_AVAILABLE, &result); + + if (result != GL_TRUE) + { + return false; + } + } GLuint64 time_elapsed = 0; glGetQueryObjectui64v(mTimerQuery, GL_QUERY_RESULT, &time_elapsed); + mTimeElapsed += time_elapsed; + mProfilePending = false; - GLuint64 samples_passed = 0; - glGetQueryObjectui64v(mSamplesQuery, GL_QUERY_RESULT, &samples_passed); + if (!for_runtime) + { + GLuint64 samples_passed = 0; + glGetQueryObjectui64v(mSamplesQuery, GL_QUERY_RESULT, &samples_passed); - U64 primitives_generated = 0; - glGetQueryObjectui64v(mPrimitivesQuery, GL_QUERY_RESULT, &primitives_generated); - sTotalTimeElapsed += time_elapsed; - mTimeElapsed += time_elapsed; + U64 primitives_generated = 0; + glGetQueryObjectui64v(mPrimitivesQuery, GL_QUERY_RESULT, &primitives_generated); + sTotalTimeElapsed += time_elapsed; - sTotalSamplesDrawn += samples_passed; - mSamplesDrawn += samples_passed; + sTotalSamplesDrawn += samples_passed; + mSamplesDrawn += samples_passed; - U32 tri_count = (U32)primitives_generated / 3; + U32 tri_count = (U32)primitives_generated / 3; - mTrianglesDrawn += tri_count; - sTotalTrianglesDrawn += tri_count; + mTrianglesDrawn += tri_count; + sTotalTrianglesDrawn += tri_count; - sTotalBinds++; - mBinds++; + sTotalBinds++; + mBinds++; + } } + + return true; } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 9d187c972c..3e7dae6669 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -168,8 +168,16 @@ public: void unload(); void clearStats(); void dumpStats(); - void placeProfileQuery(); - void readProfileQuery(); + + // place query objects for profiling if profiling is enabled + // if for_runtime is true, will place timer query only whether or not profiling is enabled + void placeProfileQuery(bool for_runtime = false); + + // Readback query objects if profiling is enabled + // If for_runtime is true, will readback timer query iff query is available + // Will return false if a query is pending (try again later) + // If force_read is true, will force an immediate readback (severe performance penalty) + bool readProfileQuery(bool for_runtime = false, bool force_read = false); BOOL createShader(std::vector* attributes, std::vector* uniforms, @@ -292,6 +300,7 @@ public: defines_map_t mDefines; //statistics for profiling shader performance + bool mProfilePending = false; U32 mTimerQuery; U32 mSamplesQuery; U32 mPrimitivesQuery; @@ -308,6 +317,9 @@ public: // this pointer should be set to whichever shader represents this shader's rigged variant LLGLSLShader* mRiggedVariant = nullptr; + // hacky flag used for optimization in LLDrawPoolAlpha + bool mCanBindFast = false; + #ifdef LL_PROFILER_ENABLE_RENDER_DOC void setLabel(const char* label); #endif diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 651c04f32c..de2188efb2 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -4898,8 +4898,6 @@ void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage() { // current usage is sometimes unreliable on Intel GPUs, fall back to estimated usage cu_mb = llmax((U32)1, eu_mb); } - F32 eu_error = (F32)((S32)eu_mb - (S32)cu_mb) / (F32)cu_mb; - U32 target_mb = budget_mb; if (target_mb > 4096) // if 4GB are installed, try to leave 2GB free @@ -4913,6 +4911,9 @@ void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage() mAvailableVRAM = cu_mb < target_mb ? target_mb - cu_mb : 0; +#if 0 + + F32 eu_error = (F32)((S32)eu_mb - (S32)cu_mb) / (F32)cu_mb; LL_INFOS("Window") << "\nLocal\nAFR: " << info.AvailableForReservation / 1024 / 1024 << "\nBudget: " << info.Budget / 1024 / 1024 << "\nCR: " << info.CurrentReservation / 1024 / 1024 @@ -4920,12 +4921,7 @@ void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage() << "\nEU: " << eu_mb << llformat(" (%.2f)", eu_error) << "\nTU: " << target_mb << "\nAM: " << mAvailableVRAM << LL_ENDL; - - /*mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &info); - LL_INFOS("Window") << "\nNon-Local\nAFR: " << info.AvailableForReservation / 1024 / 1024 - << "\nBudget: " << info.Budget / 1024 / 1024 - << "\nCR: " << info.CurrentReservation / 1024 / 1024 - << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL;*/ +#endif } else if (mD3DDevice != NULL) { // fallback to D3D9 diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 04b6ebd14c..ea59a413fa 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -908,12 +908,6 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) LLVector3 cam_pos_from_agent = LLViewerCamera::getInstance()->getOrigin(); LLVector3 cam_to_box_offset = point_to_box_offset(cam_pos_from_agent, av_box); mDistanceWRTCamera = llmax(0.01f, ll_round(cam_to_box_offset.magVec(), 0.01f)); - LL_DEBUGS("DynamicBox") << volume->getAvatar()->getFullname() - << " pos (ignored) " << pos - << " cam pos " << cam_pos_from_agent - << " box " << av_box[0] << "," << av_box[1] - << " -> dist " << mDistanceWRTCamera - << LL_ENDL; mVObjp->updateLOD(); return; } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 404039189b..ec57e20d35 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -107,12 +107,10 @@ static void prepare_alpha_shader(LLGLSLShader* shader, bool textureGamma, bool d // i.e. shaders\class1\deferred\alphaF.glsl if (deferredEnvironment) { - gPipeline.bindDeferredShader( *shader ); - } - else - { - shader->bind(); + shader->mCanBindFast = false; } + + shader->bind(); shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f / 2.2f)); if (LLPipeline::sRenderingHUDs) diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index e8411dd573..d301e14e10 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -4548,6 +4548,7 @@ LLMeshCostData::LLMeshCostData() bool LLMeshCostData::init(const LLSD& header) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; mSizeByLOD.resize(4); mEstTrisByLOD.resize(4); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 2f4274d0d0..8334ca329a 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -3965,6 +3965,7 @@ U32 LLViewerObject::recursiveGetTriangleCount(S32* vcount) const // prim's scale. Should revisit at some point. F32 LLViewerObject::recursiveGetScaledSurfaceArea() const { + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; F32 area = 0.f; const LLDrawable* drawable = mDrawable; if (drawable) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index e38a6457f4..6a0ca74e7c 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2697,6 +2697,10 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time) if ((LLFrameTimer::getFrameCount() + mID.mData[0]) % compl_upd_freq == 0) { + // DEPRECATED + // replace with LLPipeline::profileAvatar? + // Avatar profile takes ~ 0.5ms while idleUpdateRenderComplexity takes ~5ms + // (both are unacceptably costly) idleUpdateRenderComplexity(); } idleUpdateDebugInfo(); @@ -10841,6 +10845,7 @@ void LLVOAvatar::accountRenderComplexityForObject( hud_complexity_list_t& hud_complexity_list, object_complexity_list_t& object_complexity_list) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (attached_object && !attached_object->isHUDAttachment()) { mAttachmentVisibleTriangleCount += attached_object->recursiveGetTriangleCount(); @@ -10984,23 +10989,24 @@ void LLVOAvatar::accountRenderComplexityForObject( // Calculations for mVisualComplexity value void LLVOAvatar::calculateUpdateRenderComplexity() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; /***************************************************************** * This calculation should not be modified by third party viewers, * since it is used to limit rendering and should be uniform for * everyone. If you have suggested improvements, submit them to * the official viewer for consideration. *****************************************************************/ - static const U32 COMPLEXITY_BODY_PART_COST = 200; - static LLCachedControl max_complexity_setting(gSavedSettings,"MaxAttachmentComplexity"); - F32 max_attachment_complexity = max_complexity_setting; - max_attachment_complexity = llmax(max_attachment_complexity, DEFAULT_MAX_ATTACHMENT_COMPLEXITY); - - // Diagnostic list of all textures on our avatar - static std::set all_textures; - if (mVisualComplexityStale) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; + + static const U32 COMPLEXITY_BODY_PART_COST = 200; + static LLCachedControl max_complexity_setting(gSavedSettings, "MaxAttachmentComplexity"); + F32 max_attachment_complexity = max_complexity_setting; + max_attachment_complexity = llmax(max_attachment_complexity, DEFAULT_MAX_ATTACHMENT_COMPLEXITY); + + // Diagnostic list of all textures on our avatar + static std::set all_textures; + U32 cost = VISUAL_COMPLEXITY_UNKNOWN; LLVOVolume::texture_cost_t textures; hud_complexity_list_t hud_complexity_list; @@ -11467,3 +11473,43 @@ BOOL LLVOAvatar::isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, // non-self avatars don't have wearables return FALSE; } + +void LLVOAvatar::placeProfileQuery() +{ + if (mGPUTimerQuery == 0) + { + glGenQueries(1, &mGPUTimerQuery); + } + + glBeginQuery(GL_TIME_ELAPSED, mGPUTimerQuery); +} + +void LLVOAvatar::readProfileQuery(S32 retries) +{ + if (!mGPUProfilePending) + { + glEndQuery(GL_TIME_ELAPSED); + mGPUProfilePending = true; + } + + GLuint64 result = 0; + glGetQueryObjectui64v(mGPUTimerQuery, GL_QUERY_RESULT_AVAILABLE, &result); + + if (result == GL_TRUE || --retries <= 0) + { // query available, readback result + GLuint64 time_elapsed = 0; + glGetQueryObjectui64v(mGPUTimerQuery, GL_QUERY_RESULT, &time_elapsed); + mGPURenderTime = time_elapsed / 1000000.f; + mGPUProfilePending = false; + } + else + { // wait until next frame + LLUUID id = getID(); + + LL::WorkQueue::getInstance("mainloop")->post([id, retries] { + LLVOAvatar* avatar = (LLVOAvatar*) gObjectList.findObject(id); + avatar->readProfileQuery(retries); + }); + } +} + diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 0bb19c4420..2ca44b041a 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -305,6 +305,9 @@ public: static const U32 VISUAL_COMPLEXITY_UNKNOWN; void updateVisualComplexity(); + void placeProfileQuery(); + void readProfileQuery(S32 retries); + // get the GPU time in ms of rendering this avatar including all attachments // returns -1 if this avatar has not been profiled using gPipeline.profileAvatar F32 getGPURenderTime() { return mGPURenderTime; } @@ -313,18 +316,11 @@ public: // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar F32 getCPURenderTime() { return mCPURenderTime; } - // get the number of samples passed during the avatar profile - // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar - S32 getGPUSamplesPassed() { return mGPUSamplesPassed; } - - // get the number of triangles rendered during the avatar profile - // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar - S32 getGPUTrianglesRendered() { return mGPUTrianglesRendered; } - - // DEPRECATED -- obsolete avatar render cost + + // avatar render cost U32 getVisualComplexity() { return mVisualComplexity; }; - // DEPRECATED -- obsolete surface area calculation + // surface area calculation F32 getAttachmentSurfaceArea() { return mAttachmentSurfaceArea; }; U32 getReportedVisualComplexity() { return mReportedVisualComplexity; }; // Numbers as reported by the SL server @@ -555,20 +551,18 @@ private: S32 mUpdatePeriod; S32 mNumInitFaces; //number of faces generated when creating the avatar drawable, does not inculde splitted faces due to long vertex buffer. + // profile handle + U32 mGPUTimerQuery = 0; + // profile results // GPU render time in ms F32 mGPURenderTime = -1.f; + bool mGPUProfilePending = false; // CPU render time in ms F32 mCPURenderTime = -1.f; - // number of samples passed according to GPU - S32 mGPUSamplesPassed = -1; - - // number of triangles rendered according to GPU - S32 mGPUTrianglesRendered = -1; - // the isTooComplex method uses these mutable values to avoid recalculating too frequently // DEPRECATED -- obsolete avatar render cost values mutable U32 mVisualComplexity; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index d8b82d3114..82dfb1ca2a 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -1155,6 +1155,7 @@ LLViewerObject* LLVOAvatarSelf::getWornAttachment(const LLUUID& inv_item_id) bool LLVOAvatarSelf::getAttachedPointName(const LLUUID& inv_item_id, std::string& name) const { + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (!gInventory.getItem(inv_item_id)) { name = "ATTACHMENT_MISSING_ITEM"; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index da5a505d3b..585c98bace 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1603,7 +1603,9 @@ BOOL LLVOVolume::updateLOD() { return FALSE; } - + + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; + BOOL lod_changed = FALSE; if (!LLSculptIDSize::instance().isUnloaded(getVolume()->getParams().getSculptID())) @@ -1617,16 +1619,6 @@ BOOL LLVOVolume::updateLOD() if (lod_changed) { - if (debugLoggingEnabled("AnimatedObjectsLinkset")) - { - if (isAnimatedObject() && isRiggedMesh()) - { - std::string vobj_name = llformat("Vol%p", this); - F32 est_tris = getEstTrianglesMax(); - LL_DEBUGS("AnimatedObjectsLinkset") << vobj_name << " updateLOD to " << getLOD() << ", tris " << est_tris << LL_ENDL; - } - } - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); mLODChanged = TRUE; } @@ -3938,6 +3930,7 @@ const LLMatrix4 LLVOVolume::getRenderMatrix() const // children, and cost should only be increased for unique textures -Nyx U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const { + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; /***************************************************************** * This calculation should not be modified by third party viewers, * since it is used to limit rendering and should be uniform for @@ -4532,16 +4525,6 @@ const LLMatrix4& LLVOVolume::getWorldMatrix(LLXformMatrix* xform) const void LLVOVolume::markForUpdate(BOOL priority) { - if (debugLoggingEnabled("AnimatedObjectsLinkset")) - { - if (isAnimatedObject() && isRiggedMesh()) - { - std::string vobj_name = llformat("Vol%p", this); - F32 est_tris = getEstTrianglesMax(); - LL_DEBUGS("AnimatedObjectsLinkset") << vobj_name << " markForUpdate, tris " << est_tris << LL_ENDL; - } - } - if (mDrawable) { shrinkWrap(); @@ -6098,15 +6081,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) if (!vobj) continue; - if (debugLoggingEnabled("AnimatedObjectsLinkset")) - { - if (vobj->isAnimatedObject() && vobj->isRiggedMesh()) - { - std::string vobj_name = llformat("Vol%p", vobj); - F32 est_tris = vobj->getEstTrianglesMax(); - LL_DEBUGS("AnimatedObjectsLinkset") << vobj_name << " rebuildMesh, tris " << est_tris << LL_ENDL; - } - } if (vobj->isNoLOD()) continue; vobj->preRebuild(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index df8b8a552a..4d9a8a594a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3016,18 +3016,6 @@ void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags f { if (drawablep && !drawablep->isDead() && assertInitialized()) { - if (debugLoggingEnabled("AnimatedObjectsLinkset")) - { - LLVOVolume *vol_obj = drawablep->getVOVolume(); - if (vol_obj && vol_obj->isAnimatedObject() && vol_obj->isRiggedMesh()) - { - std::string vobj_name = llformat("Vol%p", vol_obj); - F32 est_tris = vol_obj->getEstTrianglesMax(); - LL_DEBUGS("AnimatedObjectsLinkset") << vobj_name << " markRebuild, tris " << est_tris - << " priority " << (S32) priority << " flag " << std::hex << flag << LL_ENDL; - } - } - if (!drawablep->isState(LLDrawable::BUILT)) { priority = true; @@ -7697,10 +7685,18 @@ void LLPipeline::bindShadowMaps(LLGLSLShader& shader) void LLPipeline::bindDeferredShaderFast(LLGLSLShader& shader) { - shader.bind(); - bindLightFunc(shader); - bindShadowMaps(shader); - bindReflectionProbes(shader); + if (shader.mCanBindFast) + { // was previously fully bound, use fast path + shader.bind(); + bindLightFunc(shader); + bindShadowMaps(shader); + bindReflectionProbes(shader); + } + else + { //wasn't previously bound, use slow path + bindDeferredShader(shader); + shader.mCanBindFast = true; + } } void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) @@ -10068,30 +10064,24 @@ void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture) } } -static LLTrace::BlockTimerStatHandle FTM_GENERATE_IMPOSTOR("Generate Impostor"); - void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) { if (gGLManager.mGLVersion < 3.25f) { // profiling requires GL 3.3 or later return; } + + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; mRT->deferredScreen.bindTarget(); mRT->deferredScreen.clear(); - bool profile_enabled = LLGLSLShader::sProfileEnabled; - LLGLSLShader::sProfileEnabled = true; - if (!profile_attachments) { - // profile entire avatar all at once - - // use gDebugProgram as a proxy for getting profile results - gDebugProgram.clearStats(); - gDebugProgram.placeProfileQuery(); - LLGLSLShader::sProfileEnabled = false; + // profile entire avatar all at once and readback asynchronously + avatar->placeProfileQuery(); LLTimer cpu_timer; @@ -10099,13 +10089,7 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) avatar->mCPURenderTime = (F32)cpu_timer.getElapsedTimeF32() * 1000.f; - LLGLSLShader::sProfileEnabled = true; - gDebugProgram.readProfileQuery(); - - avatar->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; - - avatar->mGPUSamplesPassed = gDebugProgram.mSamplesDrawn; - avatar->mGPUTrianglesRendered = gDebugProgram.mTrianglesDrawn; + avatar->readProfileQuery(5); // allow up to 5 frames of latency } else { @@ -10126,23 +10110,19 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) LLViewerObject* attached_object = attachment_iter->get(); if (attached_object) { + // use gDebugProgram to do the GPU queries gDebugProgram.clearStats(); - gDebugProgram.placeProfileQuery(); - LLGLSLShader::sProfileEnabled = false; + gDebugProgram.placeProfileQuery(true); generateImpostor(avatar, false, true, attached_object); - LLGLSLShader::sProfileEnabled = true; - gDebugProgram.readProfileQuery(); + gDebugProgram.readProfileQuery(true, true); attached_object->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; - - // TODO: maybe also record triangles and samples } } } } - LLGLSLShader::sProfileEnabled = profile_enabled; mRT->deferredScreen.flush(); if (cur_shader) @@ -10153,7 +10133,7 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool for_profile, LLViewerObject* specific_attachment) { - LL_RECORD_BLOCK_TIME(FTM_GENERATE_IMPOSTOR); + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; LL_PROFILE_GPU_ZONE("generateImpostor"); LLGLState::checkStates(); @@ -10201,6 +10181,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool RENDER_TYPE_TREE, RENDER_TYPE_VOIDWATER, RENDER_TYPE_WATER, + RENDER_TYPE_ALPHA_POST_WATER, RENDER_TYPE_PASS_GRASS, RENDER_TYPE_HUD, RENDER_TYPE_PARTICLES, @@ -10392,9 +10373,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool LLDrawPoolAvatar::sMinimumAlpha = 0.f; } - if (preview_avatar) + if (preview_avatar || for_profile) { - // previews don't care about imposters + // previews and profiles don't care about imposters renderGeomDeferred(camera); renderGeomPostDeferred(camera); } @@ -10502,7 +10483,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); - if (!preview_avatar) + if (!preview_avatar && !for_profile) { avatar->mNeedsImpostorUpdate = FALSE; avatar->cacheImpostorValues(); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 45842a3948..8a0a9a7172 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -132,8 +132,17 @@ public: bool allocateShadowBuffer(U32 resX, U32 resY); void resetVertexBuffers(LLDrawable* drawable); + + // perform a profile of the given avatar + // if profile_attachments is true, run a profile for each attachment void profileAvatar(LLVOAvatar* avatar, bool profile_attachments = false); + + // generate an impostor for the given avatar + // preview_avatar - if true, a preview window render is being performed + // for_profile - if true, a profile is being performed, do not update actual impostor + // specific_attachment - specific attachment to profile, or nullptr to profile entire avatar void generateImpostor(LLVOAvatar* avatar, bool preview_avatar = false, bool for_profile = false, LLViewerObject* specific_attachment = nullptr); + void bindScreenToTexture(); void renderFinalize(); void copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* dst); -- cgit v1.3 From 1cadfd44fe5ddafaf3ba3560bd8ec8e1351b347d Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 3 May 2023 17:30:02 -0500 Subject: DRTVWR-559 WIP - optimize ARC calculation et al. --- indra/llcommon/llmutex.h | 5 +- indra/llmath/llvolume.cpp | 5 +- indra/newview/llmeshrepository.cpp | 141 +++++++++--------- indra/newview/llmeshrepository.h | 71 ++++++++- indra/newview/llselectmgr.cpp | 4 +- indra/newview/llspatialpartition.cpp | 115 -------------- indra/newview/llviewerobject.cpp | 9 +- indra/newview/llviewerobject.h | 2 +- indra/newview/llvoavatar.cpp | 280 +++++++++++++++-------------------- indra/newview/llvovolume.cpp | 275 +++++++++++++++++++--------------- indra/newview/llvovolume.h | 26 +++- indra/newview/pipeline.h | 1 - 12 files changed, 445 insertions(+), 489 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h index 838d7d34c0..0d70da6178 100644 --- a/indra/llcommon/llmutex.h +++ b/indra/llcommon/llmutex.h @@ -36,7 +36,8 @@ //============================================================================ -#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO) +//#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO) +#define MUTEX_DEBUG 0 //disable mutex debugging as it's interfering with profiles #if MUTEX_DEBUG #include @@ -61,7 +62,7 @@ protected: mutable LLThread::id_t mLockingThread; #if MUTEX_DEBUG - std::map mIsLocked; + std::unordered_map mIsLocked; #endif }; diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 2a906c8d41..b6cdcb2736 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -3351,12 +3351,12 @@ BOOL LLVolume::isFlat(S32 face) bool LLVolumeParams::isSculpt() const { - return mSculptID.notNull(); + return (mSculptType & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_NONE; } bool LLVolumeParams::isMeshSculpt() const { - return isSculpt() && ((mSculptType & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH); + return (mSculptType & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH; } bool LLVolumeParams::operator==(const LLVolumeParams ¶ms) const @@ -3771,6 +3771,7 @@ bool LLVolumeParams::validate(U8 prof_curve, F32 prof_begin, F32 prof_end, F32 h void LLVolume::getLoDTriangleCounts(const LLVolumeParams& params, S32* counts) { //attempt to approximate the number of triangles that will result from generating a volume LoD set for the //supplied LLVolumeParams -- inaccurate, but a close enough approximation for determining streaming cost + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; F32 detail[] = {1.f, 1.5f, 2.5f, 4.f}; for (S32 i = 0; i < 4; i++) { diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index d301e14e10..67bf6827ad 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1342,10 +1342,11 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id, bool can_retry) if (header_size > 0) { - const LLSD& header = header_it->second.second; - S32 version = header["version"].asInteger(); - S32 offset = header_size + header["skin"]["offset"].asInteger(); - S32 size = header["skin"]["size"].asInteger(); + const LLMeshHeader& header = header_it->second.second; + + S32 version = header.mVersion; + S32 offset = header_size + header.mSkinOffset; + S32 size = header.mSkinSize; mHeaderMutex->unlock(); @@ -1456,9 +1457,9 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) if (header_size > 0) { const auto& header = header_it->second.second; - S32 version = header["version"].asInteger(); - S32 offset = header_size + header["physics_convex"]["offset"].asInteger(); - S32 size = header["physics_convex"]["size"].asInteger(); + S32 version = header.mVersion; + S32 offset = header_size + header.mPhysicsConvexOffset; + S32 size = header.mPhysicsConvexSize; mHeaderMutex->unlock(); @@ -1555,9 +1556,9 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) if (header_size > 0) { const auto& header = header_it->second.second; - S32 version = header["version"].asInteger(); - S32 offset = header_size + header["physics_mesh"]["offset"].asInteger(); - S32 size = header["physics_mesh"]["size"].asInteger(); + S32 version = header.mVersion; + S32 offset = header_size + header.mPhysicsMeshOffset; + S32 size = header.mPhysicsMeshSize; mHeaderMutex->unlock(); @@ -1753,9 +1754,9 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, if (header_size > 0) { const auto& header = header_it->second.second; - S32 version = header["version"].asInteger(); - S32 offset = header_size + header[header_lod[lod]]["offset"].asInteger(); - S32 size = header[header_lod[lod]]["size"].asInteger(); + S32 version = header.mVersion; + S32 offset = header_size + header.mLodOffset[lod]; + S32 size = header.mLodSize[lod]; mHeaderMutex->unlock(); if (version <= MAX_MESH_VERSION && offset >= 0 && size > 0) @@ -1857,8 +1858,10 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* data, S32 data_size) { const LLUUID mesh_id = mesh_params.getSculptID(); - LLSD header; + LLSD header_data; + LLMeshHeader header; + U32 header_size = 0; if (data_size > 0) { @@ -1869,23 +1872,25 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes boost::iostreams::stream stream(result_ptr, data_size); - if (!LLSDSerialize::fromBinary(header, stream, data_size)) + if (!LLSDSerialize::fromBinary(header_data, stream, data_size)) { LL_WARNS(LOG_MESH) << "Mesh header parse error. Not a valid mesh asset! ID: " << mesh_id << LL_ENDL; return MESH_PARSE_FAILURE; } - if (!header.isMap()) + if (!header_data.isMap()) { LL_WARNS(LOG_MESH) << "Mesh header is invalid for ID: " << mesh_id << LL_ENDL; return MESH_INVALID; } - if (header.has("version") && header["version"].asInteger() > MAX_MESH_VERSION) + header.fromLLSD(header_data); + + if (header.mVersion > MAX_MESH_VERSION) { LL_INFOS(LOG_MESH) << "Wrong version in header for " << mesh_id << LL_ENDL; - header["404"] = 1; + header.m404 = true; } // make sure there is at least one lod, function returns -1 and marks as 404 otherwise else if (LLMeshRepository::getActualMeshLOD(header, 0) >= 0) @@ -1897,7 +1902,7 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes { LL_INFOS(LOG_MESH) << "Non-positive data size. Marking header as non-existent, will not retry. ID: " << mesh_id << LL_ENDL; - header["404"] = 1; + header.m404 = 1; } { @@ -1907,7 +1912,6 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes mMeshHeader[mesh_id] = { header_size, header }; LLMeshRepository::sCacheBytesHeaders += header_size; } - LLMutexLock lock(mMutex); // make sure only one thread access mPendingLOD at the same time. @@ -2977,7 +2981,7 @@ S32 LLMeshRepoThread::getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lo if (iter != mMeshHeader.end()) { - LLSD& header = iter->second.second; + auto& header = iter->second.second; return LLMeshRepository::getActualMeshLOD(header, lod); } @@ -2986,23 +2990,23 @@ S32 LLMeshRepoThread::getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lo } //static -S32 LLMeshRepository::getActualMeshLOD(LLSD& header, S32 lod) +S32 LLMeshRepository::getActualMeshLOD(LLMeshHeader& header, S32 lod) { lod = llclamp(lod, 0, 3); - if (header.has("404")) + if (header.m404) { return -1; } - S32 version = header["version"]; + S32 version = header.mVersion; if (version > MAX_MESH_VERSION) { return -1; } - if (header[header_lod[lod]]["size"].asInteger() > 0) + if (header.mLodSize[lod] > 0) { return lod; } @@ -3010,7 +3014,7 @@ S32 LLMeshRepository::getActualMeshLOD(LLSD& header, S32 lod) //search down to find the next available lower lod for (S32 i = lod-1; i >= 0; --i) { - if (header[header_lod[i]]["size"].asInteger() > 0) + if (header.mLodSize[i] > 0) { return i; } @@ -3019,15 +3023,16 @@ S32 LLMeshRepository::getActualMeshLOD(LLSD& header, S32 lod) //search up to find then ext available higher lod for (S32 i = lod+1; i < 4; ++i) { - if (header[header_lod[i]]["size"].asInteger() > 0) + if (header.mLodSize[i] > 0) { return i; } } //header exists and no good lod found, treat as 404 - header["404"] = 1; - return -1; + header.m404 = true; + + return -1; } // Handle failed or successful requests for mesh assets. @@ -3216,7 +3221,7 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b { // header was successfully retrieved from sim and parsed and is in cache S32 header_bytes = 0; - LLSD header; + LLMeshHeader header; gMeshRepo.mThread->mHeaderMutex->lock(); LLMeshRepoThread::mesh_header_map::iterator iter = gMeshRepo.mThread->mMeshHeader.find(mesh_id); @@ -3227,8 +3232,8 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b } if (header_bytes > 0 - && !header.has("404") - && (!header.has("version") || header["version"].asInteger() <= MAX_MESH_VERSION)) + && !header.m404 + && (header.mVersion <= MAX_MESH_VERSION)) { std::stringstream str; @@ -3237,13 +3242,12 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b for (U32 i = 0; i < LLModel::LOD_PHYSICS; ++i) { // figure out how many bytes we'll need to reserve in the file - const std::string & lod_name = header_lod[i]; - lod_bytes = llmax(lod_bytes, header[lod_name]["offset"].asInteger()+header[lod_name]["size"].asInteger()); + lod_bytes = llmax(lod_bytes, header.mLodOffset[i]+header.mLodSize[i]); } // just in case skin info or decomposition is at the end of the file (which it shouldn't be) - lod_bytes = llmax(lod_bytes, header["skin"]["offset"].asInteger() + header["skin"]["size"].asInteger()); - lod_bytes = llmax(lod_bytes, header["physics_convex"]["offset"].asInteger() + header["physics_convex"]["size"].asInteger()); + lod_bytes = llmax(lod_bytes, header.mSkinOffset+header.mSkinSize); + lod_bytes = llmax(lod_bytes, header.mPhysicsConvexOffset + header.mPhysicsConvexSize); // Do not unlock mutex untill we are done with LLSD. // LLSD is smart and can work like smart pointer, is not thread safe. @@ -4257,8 +4261,8 @@ bool LLMeshRepoThread::hasPhysicsShapeInHeader(const LLUUID& mesh_id) mesh_header_map::iterator iter = mMeshHeader.find(mesh_id); if (iter != mMeshHeader.end() && iter->second.first > 0) { - LLSD &mesh = iter->second.second; - if (mesh.has("physics_mesh") && mesh["physics_mesh"].has("size") && (mesh["physics_mesh"]["size"].asInteger() > 0)) + LLMeshHeader &mesh = iter->second.second; + if (mesh.mPhysicsMeshSize > 0) { return true; } @@ -4281,20 +4285,21 @@ void LLMeshRepository::uploadModel(std::vector& data, LLVector3 S32 LLMeshRepository::getMeshSize(const LLUUID& mesh_id, S32 lod) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; if (mThread && mesh_id.notNull() && LLPrimitive::NO_LOD != lod) { LLMutexLock lock(mThread->mHeaderMutex); LLMeshRepoThread::mesh_header_map::iterator iter = mThread->mMeshHeader.find(mesh_id); if (iter != mThread->mMeshHeader.end() && iter->second.first > 0) { - const LLSD& header = iter->second.second; + const LLMeshHeader& header = iter->second.second; - if (header.has("404")) + if (header.m404) { return -1; } - S32 size = header[header_lod[lod]]["size"].asInteger(); + S32 size = header.mLodSize[lod]; return size; } @@ -4430,11 +4435,11 @@ F32 LLMeshRepository::getStreamingCostLegacy(LLUUID mesh_id, F32 radius, S32* by // FIXME replace with calc based on LLMeshCostData //static -F32 LLMeshRepository::getStreamingCostLegacy(LLSD& header, F32 radius, S32* bytes, S32* bytes_visible, S32 lod, F32 *unscaled_value) +F32 LLMeshRepository::getStreamingCostLegacy(LLMeshHeader& header, F32 radius, S32* bytes, S32* bytes_visible, S32 lod, F32 *unscaled_value) { - if (header.has("404") - || !header.has("lowest_lod") - || (header.has("version") && header["version"].asInteger() > MAX_MESH_VERSION)) + if (header.m404 + || header.mLodSize[0] <= 0 + || (header.mVersion > MAX_MESH_VERSION)) { return 0.f; } @@ -4453,10 +4458,10 @@ F32 LLMeshRepository::getStreamingCostLegacy(LLSD& header, F32 radius, S32* byte F32 minimum_size = (F32)minimum_size_ch; F32 bytes_per_triangle = (F32)bytes_per_triangle_ch; - S32 bytes_lowest = header["lowest_lod"]["size"].asInteger(); - S32 bytes_low = header["low_lod"]["size"].asInteger(); - S32 bytes_mid = header["medium_lod"]["size"].asInteger(); - S32 bytes_high = header["high_lod"]["size"].asInteger(); + S32 bytes_lowest = header.mLodSize[0]; + S32 bytes_low = header.mLodSize[1]; + S32 bytes_mid = header.mLodSize[2]; + S32 bytes_high = header.mLodSize[3]; if (bytes_high == 0) { @@ -4486,10 +4491,10 @@ F32 LLMeshRepository::getStreamingCostLegacy(LLSD& header, F32 radius, S32* byte if (bytes) { *bytes = 0; - *bytes += header["lowest_lod"]["size"].asInteger(); - *bytes += header["low_lod"]["size"].asInteger(); - *bytes += header["medium_lod"]["size"].asInteger(); - *bytes += header["high_lod"]["size"].asInteger(); + *bytes += header.mLodSize[0]; + *bytes += header.mLodSize[1]; + *bytes += header.mLodSize[2]; + *bytes += header.mLodSize[3]; } if (bytes_visible) @@ -4497,7 +4502,7 @@ F32 LLMeshRepository::getStreamingCostLegacy(LLSD& header, F32 radius, S32* byte lod = LLMeshRepository::getActualMeshLOD(header, lod); if (lod >= 0 && lod <= 3) { - *bytes_visible = header[header_lod[lod]]["size"].asInteger(); + *bytes_visible = header.mLodSize[lod]; } } @@ -4539,34 +4544,29 @@ F32 LLMeshRepository::getStreamingCostLegacy(LLSD& header, F32 radius, S32* byte LLMeshCostData::LLMeshCostData() { - mSizeByLOD.resize(4); - mEstTrisByLOD.resize(4); - std::fill(mSizeByLOD.begin(), mSizeByLOD.end(), 0); std::fill(mEstTrisByLOD.begin(), mEstTrisByLOD.end(), 0.f); } -bool LLMeshCostData::init(const LLSD& header) +bool LLMeshCostData::init(const LLMeshHeader& header) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; - mSizeByLOD.resize(4); - mEstTrisByLOD.resize(4); - + std::fill(mSizeByLOD.begin(), mSizeByLOD.end(), 0); std::fill(mEstTrisByLOD.begin(), mEstTrisByLOD.end(), 0.f); - S32 bytes_high = header["high_lod"]["size"].asInteger(); - S32 bytes_med = header["medium_lod"]["size"].asInteger(); + S32 bytes_high = header.mLodSize[3]; + S32 bytes_med = header.mLodSize[2]; if (bytes_med == 0) { bytes_med = bytes_high; } - S32 bytes_low = header["low_lod"]["size"].asInteger(); + S32 bytes_low = header.mLodSize[1]; if (bytes_low == 0) { bytes_low = bytes_med; } - S32 bytes_lowest = header["lowest_lod"]["size"].asInteger(); + S32 bytes_lowest = header.mLodSize[0]; if (bytes_lowest == 0) { bytes_lowest = bytes_low; @@ -4701,6 +4701,7 @@ F32 LLMeshCostData::getTriangleBasedStreamingCost() bool LLMeshRepository::getCostData(LLUUID mesh_id, LLMeshCostData& data) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; data = LLMeshCostData(); if (mThread && mesh_id.notNull()) @@ -4709,11 +4710,11 @@ bool LLMeshRepository::getCostData(LLUUID mesh_id, LLMeshCostData& data) LLMeshRepoThread::mesh_header_map::iterator iter = mThread->mMeshHeader.find(mesh_id); if (iter != mThread->mMeshHeader.end() && iter->second.first > 0) { - LLSD& header = iter->second.second; + LLMeshHeader& header = iter->second.second; - bool header_invalid = (header.has("404") - || !header.has("lowest_lod") - || (header.has("version") && header["version"].asInteger() > MAX_MESH_VERSION)); + bool header_invalid = (header.m404 + || header.mLodSize[0] <= 0 + || header.mVersion > MAX_MESH_VERSION); if (!header_invalid) { return getCostData(header, data); @@ -4725,7 +4726,7 @@ bool LLMeshRepository::getCostData(LLUUID mesh_id, LLMeshCostData& data) return false; } -bool LLMeshRepository::getCostData(LLSD& header, LLMeshCostData& data) +bool LLMeshRepository::getCostData(LLMeshHeader& header, LLMeshCostData& data) { data = LLMeshCostData(); diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 6922367ff7..619e076fa6 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -194,6 +194,63 @@ private: LLFrameTimer mTimer; }; +class LLMeshHeader +{ +public: + + LLMeshHeader() {} + + explicit LLMeshHeader(const LLSD& header) + { + fromLLSD(header); + } + + void fromLLSD(const LLSD& header) + { + const char* lod[] = + { + "lowest_lod", + "low_lod", + "medium_lod", + "high_lod" + }; + + mVersion = header["version"].asInteger(); + + for (U32 i = 0; i < 4; ++i) + { + mLodOffset[i] = header[lod[i]]["offset"].asInteger(); + mLodSize[i] = header[lod[i]]["size"].asInteger(); + } + + mSkinOffset = header["skin"]["offset"].asInteger(); + mSkinSize = header["skin"]["size"].asInteger(); + + mPhysicsConvexOffset = header["physics_convex"]["offset"].asInteger(); + mPhysicsConvexSize = header["physics_convex"]["size"].asInteger(); + + mPhysicsMeshOffset = header["physics_mesh"]["offset"].asInteger(); + mPhysicsMeshSize = header["physics_mesh"]["size"].asInteger(); + + m404 = header.has("404"); + } + + S32 mVersion = -1; + S32 mSkinOffset = -1; + S32 mSkinSize = -1; + + S32 mPhysicsConvexOffset = -1; + S32 mPhysicsConvexSize = -1; + + S32 mPhysicsMeshOffset = -1; + S32 mPhysicsMeshSize = -1; + + S32 mLodOffset[4] = { -1 }; + S32 mLodSize[4] = { -1 }; + + bool m404 = false; +}; + class LLMeshRepoThread : public LLThread { public: @@ -210,7 +267,7 @@ public: LLCondition* mSignal; //map of known mesh headers - typedef boost::unordered_map> mesh_header_map; // pair is header_size and data + typedef boost::unordered_map> mesh_header_map; // pair is header_size and data mesh_header_map mMeshHeader; class HeaderRequest : public RequestStats @@ -497,7 +554,7 @@ class LLMeshCostData public: LLMeshCostData(); - bool init(const LLSD& header); + bool init(const LLMeshHeader& header); // Size for given LOD S32 getSizeByLOD(S32 lod); @@ -532,10 +589,10 @@ public: private: // From the "size" field of the mesh header. LOD 0=lowest, 3=highest. - std::vector mSizeByLOD; + std::array mSizeByLOD; // Estimated triangle counts derived from the LOD sizes. LOD 0=lowest, 3=highest. - std::vector mEstTrisByLOD; + std::array mEstTrisByLOD; }; class LLMeshRepository @@ -566,9 +623,9 @@ public: F32 getEstTrianglesMax(LLUUID mesh_id); F32 getEstTrianglesStreamingCost(LLUUID mesh_id); F32 getStreamingCostLegacy(LLUUID mesh_id, F32 radius, S32* bytes = NULL, S32* visible_bytes = NULL, S32 detail = -1, F32 *unscaled_value = NULL); - static F32 getStreamingCostLegacy(LLSD& header, F32 radius, S32* bytes = NULL, S32* visible_bytes = NULL, S32 detail = -1, F32 *unscaled_value = NULL); + static F32 getStreamingCostLegacy(LLMeshHeader& header, F32 radius, S32* bytes = NULL, S32* visible_bytes = NULL, S32 detail = -1, F32 *unscaled_value = NULL); bool getCostData(LLUUID mesh_id, LLMeshCostData& data); - bool getCostData(LLSD& header, LLMeshCostData& data); + bool getCostData(LLMeshHeader& header, LLMeshCostData& data); LLMeshRepository(); @@ -588,7 +645,7 @@ public: void notifyDecompositionReceived(LLModel::Decomposition* info); S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod); - static S32 getActualMeshLOD(LLSD& header, S32 lod); + static S32 getActualMeshLOD(LLMeshHeader& header, S32 lod); const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id, LLVOVolume* requesting_obj = nullptr); LLModel::Decomposition* getDecomposition(const LLUUID& mesh_id); void fetchPhysicsShape(const LLUUID& mesh_id); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 22c1176b05..045972b7a8 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -7833,7 +7833,7 @@ S32 LLObjectSelection::getSelectedObjectRenderCost() for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) { // add the cost of each individual texture in the linkset - cost += iter->second; + cost += LLVOVolume::getTextureCost(*iter); } textures.clear(); @@ -7855,7 +7855,7 @@ S32 LLObjectSelection::getSelectedObjectRenderCost() for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) { // add the cost of each individual texture in the linkset - cost += iter->second; + cost += LLVOVolume::getTextureCost(*iter); } textures.clear(); diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 4d99ee1386..f7df4286fe 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1826,116 +1826,6 @@ void renderUpdateType(LLDrawable* drawablep) } } -void renderComplexityDisplay(LLDrawable* drawablep) -{ - LLViewerObject* vobj = drawablep->getVObj(); - if (!vobj) - { - return; - } - - LLVOVolume *voVol = dynamic_cast(vobj); - - if (!voVol) - { - return; - } - - if (!voVol->isRoot()) - { - return; - } - - LLVOVolume::texture_cost_t textures; - F32 cost = (F32) voVol->getRenderCost(textures); - - // add any child volumes - LLViewerObject::const_child_list_t children = voVol->getChildren(); - for (LLViewerObject::const_child_list_t::const_iterator iter = children.begin(); iter != children.end(); ++iter) - { - const LLViewerObject *child = *iter; - const LLVOVolume *child_volume = dynamic_cast(child); - if (child_volume) - { - cost += child_volume->getRenderCost(textures); - } - } - - // add texture cost - for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) - { - // add the cost of each individual texture in the linkset - cost += iter->second; - } - - F32 cost_max = (F32) LLVOVolume::getRenderComplexityMax(); - - - - // allow user to set a static color scale - if (gSavedSettings.getS32("RenderComplexityStaticMax") > 0) - { - cost_max = gSavedSettings.getS32("RenderComplexityStaticMax"); - } - - F32 cost_ratio = cost / cost_max; - - // cap cost ratio at 1.0f in case cost_max is at a low threshold - cost_ratio = cost_ratio > 1.0f ? 1.0f : cost_ratio; - - LLGLEnable blend(GL_BLEND); - - LLColor4 color; - const LLColor4 color_min = gSavedSettings.getColor4("RenderComplexityColorMin"); - const LLColor4 color_mid = gSavedSettings.getColor4("RenderComplexityColorMid"); - const LLColor4 color_max = gSavedSettings.getColor4("RenderComplexityColorMax"); - - if (cost_ratio < 0.5f) - { - color = color_min * (1 - cost_ratio * 2) + color_mid * (cost_ratio * 2); - } - else - { - color = color_mid * (1 - (cost_ratio - 0.5) * 2) + color_max * ((cost_ratio - 0.5) * 2); - } - - LLSD color_val = color.getValue(); - - // don't highlight objects below the threshold - if (cost > gSavedSettings.getS32("RenderComplexityThreshold")) - { - glColor4f(color[0],color[1],color[2],0.5f); - - - S32 num_faces = drawablep->getNumFaces(); - if (num_faces) - { - for (S32 i = 0; i < num_faces; ++i) - { - pushVerts(drawablep->getFace(i)); - } - } - LLViewerObject::const_child_list_t children = voVol->getChildren(); - for (LLViewerObject::const_child_list_t::const_iterator iter = children.begin(); iter != children.end(); ++iter) - { - const LLViewerObject *child = *iter; - if (child) - { - num_faces = child->getNumFaces(); - if (num_faces) - { - for (S32 i = 0; i < num_faces; ++i) - { - pushVerts(child->mDrawable->getFace(i)); - } - } - } - } - } - - voVol->setDebugText(llformat("%4.0f", cost)); -} - void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE) { if (set_color) @@ -3261,10 +3151,6 @@ public: { renderUpdateType(drawable); } - if(gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY)) - { - renderComplexityDisplay(drawable); - } if(gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXEL_DENSITY)) { renderTexelDensity(drawable); @@ -3575,7 +3461,6 @@ void LLSpatialPartition::renderDebug() LLPipeline::RENDER_DEBUG_AGENT_TARGET | //LLPipeline::RENDER_DEBUG_BUILD_QUEUE | LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA | - LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY | LLPipeline::RENDER_DEBUG_TEXEL_DENSITY)) { return; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 8334ca329a..77b4804076 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -369,7 +369,7 @@ LLViewerObject::~LLViewerObject() } // Delete memory associated with extra parameters. - std::map::iterator iter; + std::unordered_map::iterator iter; for (iter = mExtraParameterList.begin(); iter != mExtraParameterList.end(); ++iter) { if(iter->second != NULL) @@ -1555,7 +1555,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, unpackParticleSource(block_num, owner_id); // Mark all extra parameters not used - std::map::iterator iter; + std::unordered_map::iterator iter; for (iter = mExtraParameterList.begin(); iter != mExtraParameterList.end(); ++iter) { iter->second->in_use = FALSE; @@ -1947,7 +1947,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, } // Mark all extra parameters not used - std::map::iterator iter; + std::unordered_map::iterator iter; for (iter = mExtraParameterList.begin(); iter != mExtraParameterList.end(); ++iter) { iter->second->in_use = FALSE; @@ -6242,7 +6242,8 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para LLViewerObject::ExtraParameter* LLViewerObject::getExtraParameterEntry(U16 param_type) const { - std::map::const_iterator itor = mExtraParameterList.find(param_type); + LL_PROFILE_ZONE_SCOPED_CATEGORY_VIEWER; + std::unordered_map::const_iterator itor = mExtraParameterList.find(param_type); if (itor != mExtraParameterList.end()) { return itor->second; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index cd2363a1b9..72505528f0 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -122,7 +122,7 @@ protected: BOOL in_use; LLNetworkData *data; }; - std::map mExtraParameterList; + std::unordered_map mExtraParameterList; public: typedef std::list > child_list_t; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 6a0ca74e7c..95e9321d6f 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1448,7 +1448,7 @@ void LLVOAvatar::calculateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) continue; } } - if (vol && vol->isRiggedMesh()) + if (vol && vol->isRiggedMeshFast()) { continue; } @@ -10834,6 +10834,7 @@ void LLVOAvatar::updateVisualComplexity() mVisualComplexityStale = true; } + // Account for the complexity of a single top-level object associated // with an avatar. This will be either an attached object or an animated // object. @@ -10847,143 +10848,144 @@ void LLVOAvatar::accountRenderComplexityForObject( { LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (attached_object && !attached_object->isHUDAttachment()) - { + { mAttachmentVisibleTriangleCount += attached_object->recursiveGetTriangleCount(); mAttachmentEstTriangleCount += attached_object->recursiveGetEstTrianglesMax(); mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea(); - textures.clear(); - const LLDrawable* drawable = attached_object->mDrawable; - if (drawable) - { - const LLVOVolume* volume = drawable->getVOVolume(); - if (volume) - { - F32 attachment_total_cost = 0; - F32 attachment_volume_cost = 0; - F32 attachment_texture_cost = 0; - F32 attachment_children_cost = 0; + textures.clear(); + const LLDrawable* drawable = attached_object->mDrawable; + if (drawable) + { + const LLVOVolume* volume = drawable->getVOVolume(); + if (volume) + { + F32 attachment_total_cost = 0; + F32 attachment_volume_cost = 0; + F32 attachment_texture_cost = 0; + F32 attachment_children_cost = 0; const F32 animated_object_attachment_surcharge = 1000; - if (attached_object->isAnimatedObject()) + if (volume->isAnimatedObjectFast()) { attachment_volume_cost += animated_object_attachment_surcharge; } - attachment_volume_cost += volume->getRenderCost(textures); + attachment_volume_cost += volume->getRenderCost(textures); - const_child_list_t children = volume->getChildren(); - for (const_child_list_t::const_iterator child_iter = children.begin(); - child_iter != children.end(); - ++child_iter) - { - LLViewerObject* child_obj = *child_iter; - LLVOVolume *child = dynamic_cast( child_obj ); - if (child) - { - attachment_children_cost += child->getRenderCost(textures); - } - } + const_child_list_t children = volume->getChildren(); + for (const_child_list_t::const_iterator child_iter = children.begin(); + child_iter != children.end(); + ++child_iter) + { + LLViewerObject* child_obj = *child_iter; + LLVOVolume* child = dynamic_cast(child_obj); + if (child) + { + attachment_children_cost += child->getRenderCost(textures); + } + } - for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin(); - volume_texture != textures.end(); - ++volume_texture) - { - // add the cost of each individual texture in the linkset - attachment_texture_cost += volume_texture->second; - } - attachment_total_cost = attachment_volume_cost + attachment_texture_cost + attachment_children_cost; - LL_DEBUGS("ARCdetail") << "Attachment costs " << attached_object->getAttachmentItemID() - << " total: " << attachment_total_cost - << ", volume: " << attachment_volume_cost - << ", " << textures.size() - << " textures: " << attachment_texture_cost - << ", " << volume->numChildren() - << " children: " << attachment_children_cost - << LL_ENDL; - // Limit attachment complexity to avoid signed integer flipping of the wearer's ACI - cost += (U32)llclamp(attachment_total_cost, MIN_ATTACHMENT_COMPLEXITY, max_attachment_complexity); - - if (isSelf()) - { - LLObjectComplexity object_complexity; - object_complexity.objectName = attached_object->getAttachmentItemName(); - object_complexity.objectId = attached_object->getAttachmentItemID(); - object_complexity.objectCost = attachment_total_cost; - object_complexity_list.push_back(object_complexity); - } - } - } - } - if (isSelf() - && attached_object - && attached_object->isHUDAttachment() - && !attached_object->isTempAttachment() - && attached_object->mDrawable) + for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin(); + volume_texture != textures.end(); + ++volume_texture) { - textures.clear(); - BOOL is_rigged_mesh = attached_object->isRiggedMesh(); + // add the cost of each individual texture in the linkset + attachment_texture_cost += LLVOVolume::getTextureCost(*volume_texture); + } + attachment_total_cost = attachment_volume_cost + attachment_texture_cost + attachment_children_cost; + LL_DEBUGS("ARCdetail") << "Attachment costs " << attached_object->getAttachmentItemID() + << " total: " << attachment_total_cost + << ", volume: " << attachment_volume_cost + << ", " << textures.size() + << " textures: " << attachment_texture_cost + << ", " << volume->numChildren() + << " children: " << attachment_children_cost + << LL_ENDL; + // Limit attachment complexity to avoid signed integer flipping of the wearer's ACI + cost += (U32)llclamp(attachment_total_cost, MIN_ATTACHMENT_COMPLEXITY, max_attachment_complexity); + + if (isSelf()) + { + LLObjectComplexity object_complexity; + object_complexity.objectName = attached_object->getAttachmentItemName(); + object_complexity.objectId = attached_object->getAttachmentItemID(); + object_complexity.objectCost = attachment_total_cost; + object_complexity_list.push_back(object_complexity); + } + } + } + } + if (isSelf() + && attached_object + && attached_object->isHUDAttachment() + && !attached_object->isTempAttachment() + && attached_object->mDrawable) + { + textures.clear(); mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea(); - const LLVOVolume* volume = attached_object->mDrawable->getVOVolume(); - if (volume) - { - LLHUDComplexity hud_object_complexity; - hud_object_complexity.objectName = attached_object->getAttachmentItemName(); - hud_object_complexity.objectId = attached_object->getAttachmentItemID(); - std::string joint_name; - gAgentAvatarp->getAttachedPointName(attached_object->getAttachmentItemID(), joint_name); - hud_object_complexity.jointName = joint_name; - // get cost and individual textures - hud_object_complexity.objectsCost += volume->getRenderCost(textures); - hud_object_complexity.objectsCount++; - - LLViewerObject::const_child_list_t& child_list = attached_object->getChildren(); - for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); - iter != child_list.end(); ++iter) - { - LLViewerObject* childp = *iter; - is_rigged_mesh |= childp->isRiggedMesh(); - const LLVOVolume* chld_volume = dynamic_cast(childp); - if (chld_volume) - { - // get cost and individual textures - hud_object_complexity.objectsCost += chld_volume->getRenderCost(textures); - hud_object_complexity.objectsCount++; - } - } - if (is_rigged_mesh && !attached_object->mRiggedAttachedWarned) - { - LLSD args; - LLViewerInventoryItem* itemp = gInventory.getItem(attached_object->getAttachmentItemID()); - args["NAME"] = itemp ? itemp->getName() : LLTrans::getString("Unknown"); - args["POINT"] = LLTrans::getString(getTargetAttachmentPoint(attached_object)->getName()); - LLNotificationsUtil::add("RiggedMeshAttachedToHUD", args); + const LLVOVolume* volume = attached_object->mDrawable->getVOVolume(); + if (volume) + { + BOOL is_rigged_mesh = volume->isRiggedMeshFast(); + LLHUDComplexity hud_object_complexity; + hud_object_complexity.objectName = attached_object->getAttachmentItemName(); + hud_object_complexity.objectId = attached_object->getAttachmentItemID(); + std::string joint_name; + gAgentAvatarp->getAttachedPointName(attached_object->getAttachmentItemID(), joint_name); + hud_object_complexity.jointName = joint_name; + // get cost and individual textures + hud_object_complexity.objectsCost += volume->getRenderCost(textures); + hud_object_complexity.objectsCount++; + + LLViewerObject::const_child_list_t& child_list = attached_object->getChildren(); + for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); + iter != child_list.end(); ++iter) + { + LLViewerObject* childp = *iter; + const LLVOVolume* chld_volume = dynamic_cast(childp); + if (chld_volume) + { + is_rigged_mesh = is_rigged_mesh || chld_volume->isRiggedMeshFast(); + // get cost and individual textures + hud_object_complexity.objectsCost += chld_volume->getRenderCost(textures); + hud_object_complexity.objectsCount++; + } + } + if (is_rigged_mesh && !attached_object->mRiggedAttachedWarned) + { + LLSD args; + LLViewerInventoryItem* itemp = gInventory.getItem(attached_object->getAttachmentItemID()); + args["NAME"] = itemp ? itemp->getName() : LLTrans::getString("Unknown"); + args["POINT"] = LLTrans::getString(getTargetAttachmentPoint(attached_object)->getName()); + LLNotificationsUtil::add("RiggedMeshAttachedToHUD", args); - attached_object->mRiggedAttachedWarned = true; - } + attached_object->mRiggedAttachedWarned = true; + } - hud_object_complexity.texturesCount += textures.size(); + hud_object_complexity.texturesCount += textures.size(); - for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin(); - volume_texture != textures.end(); - ++volume_texture) - { - // add the cost of each individual texture (ignores duplicates) - hud_object_complexity.texturesCost += volume_texture->second; - LLViewerFetchedTexture *tex = LLViewerTextureManager::getFetchedTexture(volume_texture->first); - if (tex) - { - // Note: Texture memory might be incorect since texture might be still loading. - hud_object_complexity.texturesMemoryTotal += tex->getTextureMemory(); - if (tex->getOriginalHeight() * tex->getOriginalWidth() >= HUD_OVERSIZED_TEXTURE_DATA_SIZE) - { - hud_object_complexity.largeTexturesCount++; - } - } - } - hud_complexity_list.push_back(hud_object_complexity); + for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin(); + volume_texture != textures.end(); + ++volume_texture) + { + // add the cost of each individual texture (ignores duplicates) + hud_object_complexity.texturesCost += LLVOVolume::getTextureCost(*volume_texture); + const LLViewerTexture* img = *volume_texture; + if (img->getType() == LLViewerTexture::FETCHED_TEXTURE) + { + LLViewerFetchedTexture* tex = (LLViewerFetchedTexture*)img; + // Note: Texture memory might be incorect since texture might be still loading. + hud_object_complexity.texturesMemoryTotal += tex->getTextureMemory(); + if (tex->getOriginalHeight() * tex->getOriginalWidth() >= HUD_OVERSIZED_TEXTURE_DATA_SIZE) + { + hud_object_complexity.largeTexturesCount++; } } + } + hud_complexity_list.push_back(hud_object_complexity); + } + } } // Calculations for mVisualComplexity value @@ -11005,7 +11007,7 @@ void LLVOAvatar::calculateUpdateRenderComplexity() max_attachment_complexity = llmax(max_attachment_complexity, DEFAULT_MAX_ATTACHMENT_COMPLEXITY); // Diagnostic list of all textures on our avatar - static std::set all_textures; + static std::unordered_set all_textures; U32 cost = VISUAL_COMPLEXITY_UNKNOWN; LLVOVolume::texture_cost_t textures; @@ -11074,44 +11076,6 @@ void LLVOAvatar::calculateUpdateRenderComplexity() } } - // Diagnostic output to identify all avatar-related textures. - // Does not affect rendering cost calculation. - if (isSelf() && debugLoggingEnabled("ARCdetail")) - { - // print any attachment textures we didn't already know about. - for (LLVOVolume::texture_cost_t::iterator it = textures.begin(); it != textures.end(); ++it) - { - LLUUID image_id = it->first; - if( ! (image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR) - && (all_textures.find(image_id) == all_textures.end())) - { - // attachment texture not previously seen. - LL_DEBUGS("ARCdetail") << "attachment_texture: " << image_id.asString() << LL_ENDL; - all_textures.insert(image_id); - } - } - - // print any avatar textures we didn't already know about - for (LLAvatarAppearanceDictionary::Textures::const_iterator iter = LLAvatarAppearance::getDictionary()->getTextures().begin(); - iter != LLAvatarAppearance::getDictionary()->getTextures().end(); - ++iter) - { - const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = iter->second; - // TODO: MULTI-WEARABLE: handle multiple textures for self - const LLViewerTexture* te_image = getImage(iter->first,0); - if (!te_image) - continue; - LLUUID image_id = te_image->getID(); - if( image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR) - continue; - if (all_textures.find(image_id) == all_textures.end()) - { - LL_DEBUGS("ARCdetail") << "local_texture: " << texture_dict->mName << ": " << image_id << LL_ENDL; - all_textures.insert(image_id); - } - } - } - if ( cost != mVisualComplexity ) { LL_DEBUGS("AvatarRender") << "Avatar "<< getID() diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 585c98bace..aa60578cee 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3190,7 +3190,13 @@ void LLVOVolume::setLightCutoff(F32 cutoff) BOOL LLVOVolume::getIsLight() const { - return getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT); + mIsLight = getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT); + return mIsLight; +} + +bool LLVOVolume::getIsLightFast() const +{ + return mIsLight; } LLColor3 LLVOVolume::getLightSRGBBaseColor() const @@ -3576,6 +3582,31 @@ BOOL LLVOVolume::hasLightTexture() const return FALSE; } +bool LLVOVolume::isFlexibleFast() const +{ + return mVolumep && mVolumep->getParams().getPathParams().getCurveType() == LL_PCODE_PATH_FLEXIBLE; +} + +bool LLVOVolume::isSculptedFast() const +{ + return mVolumep && mVolumep->getParams().isSculpt(); +} + +bool LLVOVolume::isMeshFast() const +{ + return mVolumep && mVolumep->getParams().isMeshSculpt(); +} + +bool LLVOVolume::isRiggedMeshFast() const +{ + return mSkinInfo.notNull(); +} + +bool LLVOVolume::isAnimatedObjectFast() const +{ + return mIsAnimatedObject; +} + BOOL LLVOVolume::isVolumeGlobal() const { if (mVolumeImpl) @@ -3736,8 +3767,8 @@ bool LLVOVolume::canBeAnimatedObject() const bool LLVOVolume::isAnimatedObject() const { LLVOVolume *root_vol = (LLVOVolume*)getRootEdit(); - bool root_is_animated_flag = root_vol->getExtendedMeshFlags() & LLExtendedMeshParams::ANIMATED_MESH_ENABLED_FLAG; - return root_is_animated_flag; + mIsAnimatedObject = root_vol->getExtendedMeshFlags() & LLExtendedMeshParams::ANIMATED_MESH_ENABLED_FLAG; + return mIsAnimatedObject; } // Called any time parenting changes for a volume. Update flags and @@ -3924,6 +3955,34 @@ const LLMatrix4 LLVOVolume::getRenderMatrix() const return mDrawable->getWorldMatrix(); } +//static +S32 LLVOVolume::getTextureCost(const LLViewerTexture* img) +{ + static const U32 ARC_TEXTURE_COST = 16; // multiplier for texture resolution - performance tested + + S32 texture_cost = 0; + S8 type = img->getType(); + if (type == LLViewerTexture::FETCHED_TEXTURE || type == LLViewerTexture::LOD_TEXTURE) + { + const LLViewerFetchedTexture* fetched_texturep = static_cast(img); + if (fetched_texturep + && fetched_texturep->getFTType() == FTT_LOCAL_FILE + && (img->getID() == IMG_ALPHA_GRAD_2D || img->getID() == IMG_ALPHA_GRAD) + ) + { + // These two textures appear to switch between each other, but are of different sizes (4x256 and 256x256). + // Hardcode cost from larger one to not cause random complexity changes + texture_cost = 320; + } + } + if (texture_cost == 0) + { + texture_cost = 256 + (S32)(ARC_TEXTURE_COST * (img->getFullHeight() / 128.f + img->getFullWidth() / 128.f)); + } + + return texture_cost; +} + // Returns a base cost and adds textures to passed in set. // total cost is returned value + 5 * size of the resulting set. // Cannot include cost of textures, as they may be re-used in linked @@ -3940,17 +3999,16 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const // Get access to params we'll need at various points. // Skip if this is object doesn't have a volume (e.g. is an avatar). - BOOL has_volume = (getVolume() != NULL); - LLVolumeParams volume_params; - LLPathParams path_params; - LLProfileParams profile_params; + if (getVolume() == NULL) + { + return 0; + } U32 num_triangles = 0; // per-prim costs static const U32 ARC_PARTICLE_COST = 1; // determined experimentally static const U32 ARC_PARTICLE_MAX = 2048; // default values - static const U32 ARC_TEXTURE_COST = 16; // multiplier for texture resolution - performance tested static const U32 ARC_LIGHT_COST = 500; // static cost for light-producing prims static const U32 ARC_MEDIA_FACE_COST = 1500; // static cost per media-enabled face @@ -3985,45 +4043,41 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const const LLDrawable* drawablep = mDrawable; U32 num_faces = drawablep->getNumFaces(); - if (has_volume) - { - volume_params = getVolume()->getParams(); - path_params = volume_params.getPathParams(); - profile_params = volume_params.getProfileParams(); + const LLVolumeParams& volume_params = getVolume()->getParams(); - LLMeshCostData costs; - if (getCostData(costs)) - { - if (isAnimatedObject() && isRiggedMesh()) - { - // Scaling here is to make animated object vs - // non-animated object ARC proportional to the - // corresponding calculations for streaming cost. - num_triangles = (ANIMATED_OBJECT_COST_PER_KTRI * 0.001 * costs.getEstTrisForStreamingCost())/0.06; - } - else - { - F32 radius = getScale().length()*0.5f; - num_triangles = costs.getRadiusWeightedTris(radius); - } - } + LLMeshCostData costs; + if (getCostData(costs)) + { + if (isAnimatedObjectFast() && isRiggedMeshFast()) + { + // Scaling here is to make animated object vs + // non-animated object ARC proportional to the + // corresponding calculations for streaming cost. + num_triangles = (ANIMATED_OBJECT_COST_PER_KTRI * 0.001 * costs.getEstTrisForStreamingCost())/0.06; + } + else + { + F32 radius = getScale().length()*0.5f; + num_triangles = costs.getRadiusWeightedTris(radius); + } } + if (num_triangles <= 0) { num_triangles = 4; } - if (isSculpted()) + if (isSculptedFast()) { - if (isMesh()) + if (isMeshFast()) { // base cost is dependent on mesh complexity // note that 3 is the highest LOD as of the time of this coding. S32 size = gMeshRepo.getMeshSize(volume_params.getSculptID(), getLOD()); if ( size > 0) { - if (isRiggedMesh()) + if (isRiggedMeshFast()) { // weighted attachment - 1 point for every 3 bytes weighted_mesh = 1; @@ -4037,21 +4091,15 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const } else { - const LLSculptParams *sculpt_params = (LLSculptParams *) getParameterEntry(LLNetworkData::PARAMS_SCULPT); - LLUUID sculpt_id = sculpt_params->getSculptTexture(); - if (textures.find(sculpt_id) == textures.end()) + LLViewerFetchedTexture* texture = mSculptTexture; + if (texture && textures.find(texture) == textures.end()) { - LLViewerFetchedTexture *texture = LLViewerTextureManager::getFetchedTexture(sculpt_id); - if (texture) - { - S32 texture_cost = 256 + (S32)(ARC_TEXTURE_COST * (texture->getFullHeight() / 128.f + texture->getFullWidth() / 128.f)); - textures.insert(texture_cost_t::value_type(sculpt_id, texture_cost)); - } + textures.insert(texture); } } } - if (isFlexible()) + if (isFlexibleFast()) { flexi = 1; } @@ -4060,85 +4108,66 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const particles = 1; } - if (getIsLight()) + if (getIsLightFast()) { produces_light = 1; } - for (S32 i = 0; i < num_faces; ++i) - { - const LLFace* face = drawablep->getFace(i); - if (!face) continue; - const LLTextureEntry* te = face->getTextureEntry(); - const LLViewerTexture* img = face->getTexture(); + { + LL_PROFILE_ZONE_NAMED_CATEGORY_VOLUME("ARC - face list"); + for (S32 i = 0; i < num_faces; ++i) + { + const LLFace* face = drawablep->getFace(i); + if (!face) continue; + const LLTextureEntry* te = face->getTextureEntry(); + const LLViewerTexture* img = face->getTexture(); - if (img) - { - if (textures.find(img->getID()) == textures.end()) - { - S32 texture_cost = 0; - S8 type = img->getType(); - if (type == LLViewerTexture::FETCHED_TEXTURE || type == LLViewerTexture::LOD_TEXTURE) + if (img) + { + textures.insert(img); + } + + if (face->isInAlphaPool()) + { + alpha = 1; + } + else if (img && img->getPrimaryFormat() == GL_ALPHA) + { + invisi = 1; + } + if (face->hasMedia()) + { + media_faces++; + } + + if (te) + { + if (te->getBumpmap()) { - const LLViewerFetchedTexture* fetched_texturep = static_cast(img); - if (fetched_texturep - && fetched_texturep->getFTType() == FTT_LOCAL_FILE - && (img->getID() == IMG_ALPHA_GRAD_2D || img->getID() == IMG_ALPHA_GRAD) - ) - { - // These two textures appear to switch between each other, but are of different sizes (4x256 and 256x256). - // Hardcode cost from larger one to not cause random complexity changes - texture_cost = 320; - } + // bump is a multiplier, don't add per-face + bump = 1; } - if (texture_cost == 0) + if (te->getShiny()) { - texture_cost = 256 + (S32)(ARC_TEXTURE_COST * (img->getFullHeight() / 128.f + img->getFullWidth() / 128.f)); + // shiny is a multiplier, don't add per-face + shiny = 1; } - textures.insert(texture_cost_t::value_type(img->getID(), texture_cost)); - } - } - - if (face->isInAlphaPool()) - { - alpha = 1; - } - else if (img && img->getPrimaryFormat() == GL_ALPHA) - { - invisi = 1; - } - if (face->hasMedia()) - { - media_faces++; - } - - if (te) - { - if (te->getBumpmap()) - { - // bump is a multiplier, don't add per-face - bump = 1; - } - if (te->getShiny()) - { - // shiny is a multiplier, don't add per-face - shiny = 1; - } - if (te->getGlow() > 0.f) - { - // glow is a multiplier, don't add per-face - glow = 1; - } - if (face->mTextureMatrix != NULL) - { - animtex = 1; - } - if (te->getTexGen()) - { - planar = 1; - } - } - } + if (te->getGlow() > 0.f) + { + // glow is a multiplier, don't add per-face + glow = 1; + } + if (face->mTextureMatrix != NULL) + { + animtex = 1; + } + if (te->getTexGen()) + { + planar = 1; + } + } + } + } // shame currently has the "base" cost of 1 point per 15 triangles, min 2. shame = num_triangles * 5.f; @@ -4217,7 +4246,7 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const // Streaming cost for animated objects includes a fixed cost // per linkset. Add a corresponding charge here translated into // triangles, but not weighted by any graphics properties. - if (isAnimatedObject() && isRootEdit()) + if (isAnimatedObjectFast() && isRootEdit()) { shame += (ANIMATED_OBJECT_BASE_COST/0.06) * 5.0f; } @@ -4232,7 +4261,7 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const F32 LLVOVolume::getEstTrianglesMax() const { - if (isMesh() && getVolume()) + if (isMeshFast() && getVolume()) { return gMeshRepo.getEstTrianglesMax(getVolume()->getParams().getSculptID()); } @@ -4241,7 +4270,7 @@ F32 LLVOVolume::getEstTrianglesMax() const F32 LLVOVolume::getEstTrianglesStreamingCost() const { - if (isMesh() && getVolume()) + if (isMeshFast() && getVolume()) { return gMeshRepo.getEstTrianglesStreamingCost(getVolume()->getParams().getSculptID()); } @@ -4256,7 +4285,7 @@ F32 LLVOVolume::getStreamingCost() const LLMeshCostData costs; if (getCostData(costs)) { - if (isAnimatedObject() && isRootEdit()) + if (isRootEdit() && isAnimatedObject()) { // Root object of an animated object has this to account for skeleton overhead. linkset_base_cost = ANIMATED_OBJECT_BASE_COST; @@ -4286,7 +4315,9 @@ F32 LLVOVolume::getStreamingCost() const // virtual bool LLVOVolume::getCostData(LLMeshCostData& costs) const { - if (isMesh()) + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; + + if (isMeshFast()) { return gMeshRepo.getCostData(getVolume()->getParams().getSculptID(), costs); } @@ -4296,11 +4327,11 @@ bool LLVOVolume::getCostData(LLMeshCostData& costs) const S32 counts[4]; LLVolume::getLoDTriangleCounts(volume->getParams(), counts); - LLSD header; - header["lowest_lod"]["size"] = counts[0] * 10; - header["low_lod"]["size"] = counts[1] * 10; - header["medium_lod"]["size"] = counts[2] * 10; - header["high_lod"]["size"] = counts[3] * 10; + LLMeshHeader header; + header.mLodSize[0] = counts[0] * 10; + header.mLodSize[1] = counts[1] * 10; + header.mLodSize[2] = counts[2] * 10; + header.mLodSize[3] = counts[3] * 10; return gMeshRepo.getCostData(header, costs); } diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 9cfd90a940..d509a7e2ab 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -34,8 +34,8 @@ #include "lllocalbitmaps.h" #include "m3math.h" // LLMatrix3 #include "m4math.h" // LLMatrix4 -#include -#include +#include +#include class LLViewerTextureAnim; @@ -146,7 +146,8 @@ public: const LLMatrix4& getRelativeXform() const { return mRelativeXform; } const LLMatrix3& getRelativeXformInvTrans() const { return mRelativeXformInvTrans; } /*virtual*/ const LLMatrix4 getRenderMatrix() const override; - typedef std::map texture_cost_t; + typedef std::unordered_set texture_cost_t; + static S32 getTextureCost(const LLViewerTexture* img); U32 getRenderCost(texture_cost_t &textures) const; /*virtual*/ F32 getEstTrianglesMax() const override; /*virtual*/ F32 getEstTrianglesStreamingCost() const override; @@ -267,6 +268,7 @@ public: void setSpotLightParams(LLVector3 params); BOOL getIsLight() const; + bool getIsLightFast() const; // Get the light color in sRGB color space NOT scaled by intensity. @@ -315,7 +317,15 @@ public: virtual BOOL isRiggedMesh() const override; virtual BOOL hasLightTexture() const override; - + // fast variants above that use state that is filled in later + // not reliable early in the life of an object, but should be used after + // object is loaded + bool isFlexibleFast() const; + bool isSculptedFast() const; + bool isMeshFast() const; + bool isRiggedMeshFast() const; + bool isAnimatedObjectFast() const; + BOOL isVolumeGlobal() const; BOOL canBeFlexible() const; BOOL setIsFlexible(BOOL is_flexible); @@ -461,6 +471,13 @@ private: S32 mIndexInTex[LLRender::NUM_VOLUME_TEXTURE_CHANNELS]; S32 mMDCImplCount; + // cached value of getIsLight to avoid redundant map lookups + // accessed by getIsLightFast + mutable bool mIsLight = false; + + // cached value of getIsAnimatedObject to avoid redundant map lookups + // accessed by getIsAnimatedObjectFast + mutable bool mIsAnimatedObject = false; bool mResetDebugText; LLPointer mRiggedVolume; @@ -475,7 +492,6 @@ public: static LLPointer sObjectMediaClient; static LLPointer sObjectMediaNavigateClient; - protected: static S32 sNumLODChanges; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 8a0a9a7172..e92fa32fc6 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -603,7 +603,6 @@ public: RENDER_DEBUG_PHYSICS_SHAPES = 0x02000000, RENDER_DEBUG_NORMALS = 0x04000000, RENDER_DEBUG_LOD_INFO = 0x08000000, - RENDER_DEBUG_RENDER_COMPLEXITY = 0x10000000, RENDER_DEBUG_ATTACHMENT_BYTES = 0x20000000, // not used RENDER_DEBUG_TEXEL_DENSITY = 0x40000000, RENDER_DEBUG_TRIANGLE_COUNT = 0x80000000, -- cgit v1.3 From 6f5f16e0319bde183534a779839299dca7fe50ab Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 17 May 2023 13:40:33 -0500 Subject: SL-19655 Remove concept of "low priority" updates (RenderDebugGLSession assertion stomping pass). Remove a couple unused debug settings and related code. --- indra/newview/app_settings/settings.xml | 22 ----- indra/newview/featuretable.txt | 1 - indra/newview/featuretable_mac.txt | 1 - indra/newview/llcontrolavatar.cpp | 6 +- indra/newview/lldrawable.cpp | 20 ++-- indra/newview/llface.cpp | 8 +- indra/newview/llflexibleobject.cpp | 6 +- indra/newview/llmanip.cpp | 4 +- indra/newview/llsculptidsize.cpp | 23 ----- indra/newview/llsky.cpp | 4 +- indra/newview/llspatialpartition.cpp | 14 +-- indra/newview/llviewercontrol.cpp | 3 - indra/newview/llviewermessage.cpp | 2 +- indra/newview/llviewerobject.cpp | 45 +++------ indra/newview/llviewerobject.h | 7 +- indra/newview/llviewerobjectlist.cpp | 2 +- indra/newview/llviewerpartsim.cpp | 6 +- indra/newview/llvoavatar.cpp | 4 +- indra/newview/llvoavatarself.cpp | 2 +- indra/newview/llvograss.cpp | 14 +-- indra/newview/llvopartgroup.cpp | 2 +- indra/newview/llvosky.cpp | 4 +- indra/newview/llvosurfacepatch.cpp | 4 +- indra/newview/llvotree.cpp | 4 +- indra/newview/llvovolume.cpp | 168 +++++--------------------------- indra/newview/llvovolume.h | 6 +- indra/newview/llvowlsky.cpp | 4 +- indra/newview/pipeline.cpp | 77 ++++----------- indra/newview/pipeline.h | 5 +- 29 files changed, 121 insertions(+), 347 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 97f07e5952..793a6a15f3 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10733,17 +10733,6 @@ Value 0 - RenderAutoMuteByteLimit - - Comment - If avatar attachment size exceed this value (in bytes) attachment will not be rendered. Excludes attachments worn by own avatar. - Persist - 1 - Type - U32 - Value - 0 - RenderAvatarMaxNonImpostors Comment @@ -14346,17 +14335,6 @@ Value 1 - RenderDelayVBUpdate - - Comment - Delay vertex buffer updates until just before rendering - Persist - 1 - Type - Boolean - Value - 0 - SocialPhotoResolution Comment diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 79d92adcc2..dd4530dae0 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -35,7 +35,6 @@ RenderAvatarMaxNonImpostors 1 16 RenderAvatarMaxComplexity 1 350000 RenderAutoMuteSurfaceAreaLimit 1 1000.0 RenderCubeMap 1 1 -RenderDelayVBUpdate 1 0 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 RenderFogRatio 1 4.0 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 72deabd9f1..ef7827e596 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -35,7 +35,6 @@ RenderAvatarMaxNonImpostors 1 16 RenderAvatarMaxComplexity 1 350000 RenderAutoMuteSurfaceAreaLimit 1 1000.0 RenderCubeMap 1 1 -RenderDelayVBUpdate 1 0 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 RenderFogRatio 1 4.0 diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index d4d4f641cf..9b06936c1c 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -312,8 +312,8 @@ void LLControlAvatar::updateVolumeGeom() } } - gPipeline.markRebuild(mRootVolp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); - mRootVolp->markForUpdate(TRUE); + gPipeline.markRebuild(mRootVolp->mDrawable, LLDrawable::REBUILD_ALL); + mRootVolp->markForUpdate(); // Note that attachment overrides aren't needed here, have already // been applied at the time the mControlAvatar was created, in @@ -597,7 +597,7 @@ void LLControlAvatar::updateAnimations() //if (!mRootVolp->isAnySelected()) { updateVolumeGeom(); - mRootVolp->recursiveMarkForUpdate(TRUE); + mRootVolp->recursiveMarkForUpdate(); } } diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index ea59a413fa..9d1b02cd8a 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -149,7 +149,7 @@ void LLDrawable::unload() { LLVOVolume *pVVol = getVOVolume(); pVVol->setNoLOD(); - pVVol->markForUpdate(TRUE); + pVVol->markForUpdate(); } // static @@ -535,7 +535,7 @@ void LLDrawable::makeActive() if (mVObjp->getPCode() == LL_PCODE_VOLUME) { - gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME); } updatePartition(); } @@ -583,7 +583,7 @@ void LLDrawable::makeStatic(BOOL warning_enabled) if (mVObjp->getPCode() == LL_PCODE_VOLUME) { - gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME); } if (mSpatialBridge) @@ -659,7 +659,7 @@ F32 LLDrawable::updateXform(BOOL undamped) if (getVOVolume() && !isRoot()) { //child prim snapping to some position, needs a rebuild - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION); } } } @@ -683,7 +683,7 @@ F32 LLDrawable::updateXform(BOOL undamped) if (vec*vec > MIN_INTERPOLATE_DISTANCE_SQUARED) { //scale change requires immediate rebuild - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION); } else if (!isRoot() && (!mVObjp->getAngularVelocity().isExactlyZero() || @@ -693,7 +693,7 @@ F32 LLDrawable::updateXform(BOOL undamped) if (!isState(LLDrawable::ANIMATED_CHILD)) { setState(LLDrawable::ANIMATED_CHILD); - gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL); mVObjp->dirtySpatialGroup(); } } @@ -702,7 +702,7 @@ F32 LLDrawable::updateXform(BOOL undamped) || (1.f - dot(old_rot, target_rot)) > 0.f)) { //fix for BUG-840, MAINT-2275, MAINT-1742, MAINT-2247 mVObjp->shrinkWrap(); - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION); } else if (!getVOVolume() && !isAvatar()) { @@ -813,7 +813,7 @@ void LLDrawable::updatePartition() else { //a child prim moved and needs its verts regenerated - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION); } } @@ -938,7 +938,7 @@ void LLDrawable::updateTexture() if (getVOVolume()) { - gPipeline.markRebuild(this, LLDrawable::REBUILD_MATERIAL, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_MATERIAL); } } @@ -981,7 +981,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector) if (rebuild) { - gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL); } for (S32 i = 0; i < getNumFaces(); i++) diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 5554112043..3c71d3e49d 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -211,7 +211,7 @@ void LLFace::destroy() if (group) { group->dirtyGeom(); - gPipeline.markRebuild(group, TRUE); + gPipeline.markRebuild(group); } } } @@ -250,7 +250,7 @@ void LLFace::setPool(LLFacePool* new_pool, LLViewerTexture *texturep) if (mDrawablep) { - gPipeline.markRebuild(mDrawablep, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawablep, LLDrawable::REBUILD_ALL); } } mGeomIndex = 0; @@ -332,7 +332,7 @@ void LLFace::dirtyTexture() vobj->updateVisualComplexity(); } - gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME, FALSE); + gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME); } } } @@ -1174,6 +1174,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { if (gDebugGL) { + llassert(false); LL_WARNS() << "Index buffer overflow!" << LL_ENDL; LL_WARNS() << "Indices Count: " << mIndicesCount << " VF Num Indices: " << num_indices @@ -1189,6 +1190,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { if (gDebugGL) { + llassert(false); LL_WARNS() << "Vertex buffer overflow!" << LL_ENDL; } return FALSE; diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index 500e3cc41b..c9370b49f1 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -348,7 +348,7 @@ void LLVolumeImplFlexible::doIdleUpdate() if (mRenderRes == -1) { updateRenderRes(); - gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE); + gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION); } else { @@ -361,7 +361,7 @@ void LLVolumeImplFlexible::doIdleUpdate() // MAINT-1890 Clamp the update period to ensure that the update_period is no greater than 32 frames update_period = llclamp(update_period, 1U, 32U); - // We control how fast flexies update, buy splitting updates among frames + // We control how fast flexies update, buy splitting updates among frames U64 virtual_frame_num = LLTimer::getElapsedSeconds() / SEC_PER_FLEXI_FRAME; if (visible) @@ -400,7 +400,7 @@ void LLVolumeImplFlexible::doIdleUpdate() updateRenderRes(); mVO->shrinkWrap(); - gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE); + gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION); } } } diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index 6589aa477f..feb691520f 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -72,14 +72,14 @@ void LLManip::rebuild(LLViewerObject* vobj) LLDrawable* drawablep = vobj->mDrawable; if (drawablep && drawablep->getVOVolume()) { - gPipeline.markRebuild(drawablep,LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(drawablep,LLDrawable::REBUILD_VOLUME); drawablep->setState(LLDrawable::MOVE_UNDAMPED); // force to UNDAMPED drawablep->updateMove(); LLSpatialGroup* group = drawablep->getSpatialGroup(); if (group) { group->dirtyGeom(); - gPipeline.markRebuild(group, TRUE); + gPipeline.markRebuild(group); } LLViewerObject::const_child_list_t& child_list = vobj->getChildren(); diff --git a/indra/newview/llsculptidsize.cpp b/indra/newview/llsculptidsize.cpp index 3d5102902d..5d051d0ebf 100644 --- a/indra/newview/llsculptidsize.cpp +++ b/indra/newview/llsculptidsize.cpp @@ -85,29 +85,6 @@ void LLSculptIDSize::inc(const LLDrawable *pdrawable, int sz) //trying insert the LLDrawable mSizeInfo.get().insert(Info(pdrawable, sz, nfo.mSharedSizeSum, sculptId)); } - - static LLCachedControl render_auto_mute_byte_limit(gSavedSettings, "RenderAutoMuteByteLimit", 0U); - - if (0 != render_auto_mute_byte_limit && total_size > render_auto_mute_byte_limit) - { - pair_iter_iter_BY_SCULPT_ID_t it_eqr = mSizeInfo.get().equal_range(sculptId); - for (; it_eqr.first != it_eqr.second; ++it_eqr.first) - { - const Info &i = *it_eqr.first; - LLVOVolume *pVVol = i.mDrawable->getVOVolume(); - if (pVVol - && !pVVol->isDead() - && pVVol->isAttachment() - && !pVVol->getAvatar()->isSelf() - && LLVOVolume::NO_LOD != pVVol->getLOD() - ) - { - addToUnloaded(sculptId); - //immediately - const_cast(i.mDrawable)->unload(); - } - } - } } void LLSculptIDSize::dec(const LLDrawable *pdrawable) diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp index c5d49a81f1..4926b86b14 100644 --- a/indra/newview/llsky.cpp +++ b/indra/newview/llsky.cpp @@ -116,13 +116,13 @@ void LLSky::resetVertexBuffers() if (gSky.mVOSkyp.notNull()) { gPipeline.resetVertexBuffers(gSky.mVOSkyp->mDrawable); - gPipeline.markRebuild(gSky.mVOSkyp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(gSky.mVOSkyp->mDrawable, LLDrawable::REBUILD_ALL); } if (gSky.mVOWLSkyp.notNull()) { gSky.mVOWLSkyp->resetVertexBuffers(); gPipeline.resetVertexBuffers(gSky.mVOWLSkyp->mDrawable); - gPipeline.markRebuild(gSky.mVOWLSkyp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(gSky.mVOWLSkyp->mDrawable, LLDrawable::REBUILD_ALL); } } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index f7df4286fe..ed1c7c8dea 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -246,7 +246,7 @@ BOOL LLSpatialGroup::addObject(LLDrawable *drawablep) drawablep->setGroup(this); setState(OBJECT_DIRTY | GEOM_DIRTY); setOcclusionState(LLSpatialGroup::DISCARD_QUERY, LLSpatialGroup::STATE_MODE_ALL_CAMERAS); - gPipeline.markRebuild(this, TRUE); + gPipeline.markRebuild(this); if (drawablep->isSpatialBridge()) { mBridgeList.push_back((LLSpatialBridge*) drawablep); @@ -368,7 +368,7 @@ BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree) { drawablep->setGroup(NULL); setState(GEOM_DIRTY); - gPipeline.markRebuild(this, TRUE); + gPipeline.markRebuild(this); if (drawablep->isSpatialBridge()) { @@ -411,7 +411,7 @@ void LLSpatialGroup::shift(const LLVector4a &offset) getSpatialPartition()->mPartitionType != LLViewerRegion::PARTITION_CONTROL_AV) { setState(GEOM_DIRTY); - gPipeline.markRebuild(this, TRUE); + gPipeline.markRebuild(this); } } @@ -537,7 +537,7 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : LLO sg_assert(mOctreeNode->getListenerCount() == 0); setState(SG_INITIAL_STATE_MASK); - gPipeline.markRebuild(this, TRUE); + gPipeline.markRebuild(this); // let the reflection map manager know about this spatial group mReflectionProbe = gPipeline.mReflectionMapManager.registerSpatialGroup(this); @@ -611,7 +611,7 @@ F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera) //NOTE: If there is a trivial way to detect that alpha sorting here would not change the render order, //not setting this node to dirty would be a very good thing group->setState(LLSpatialGroup::ALPHA_DIRTY); - gPipeline.markRebuild(group, FALSE); + gPipeline.markRebuild(group); } } } @@ -783,7 +783,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion) if (!keep_occlusion) { //going to need a rebuild - gPipeline.markRebuild(this, TRUE); + gPipeline.markRebuild(this); } mLastUpdateTime = gFrameTimeSeconds; @@ -1307,7 +1307,7 @@ public: } if (drawable->getVObj().notNull() && !group->getSpatialPartition()->mRenderByGroup) { - gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL); } } diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index faeebc33ee..aae4409167 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -592,8 +592,6 @@ bool toggle_show_object_render_cost(const LLSD& newvalue) return true; } -void handleRenderAutoMuteByteLimitChanged(const LLSD& new_value); - void handleTargetFPSChanged(const LLSD& newValue) { const auto targetFPS = gSavedSettings.getU32("TargetFPS"); @@ -826,7 +824,6 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "SpellCheckDictionary", handleSpellCheckChanged); setting_setup_signal_listener(gSavedSettings, "LoginLocation", handleLoginLocationChanged); setting_setup_signal_listener(gSavedSettings, "DebugAvatarJoints", handleDebugAvatarJointsChanged); - setting_setup_signal_listener(gSavedSettings, "RenderAutoMuteByteLimit", handleRenderAutoMuteByteLimitChanged); setting_setup_signal_listener(gSavedSettings, "TargetFPS", handleTargetFPSChanged); setting_setup_signal_listener(gSavedSettings, "AutoTuneFPS", handleAutoTuneFPSChanged); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 7c4bd2b069..d4c34a4e57 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4222,7 +4222,7 @@ void process_object_animation(LLMessageSystem *mesgsys, void **user_data) //if (!avatarp->mRootVolp->isAnySelected()) { avatarp->updateVolumeGeom(); - avatarp->mRootVolp->recursiveMarkForUpdate(TRUE); + avatarp->mRootVolp->recursiveMarkForUpdate(); } } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 77b4804076..e67750af7c 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -1051,7 +1051,7 @@ BOOL LLViewerObject::setDrawableParent(LLDrawable* parentp) parentp->setState(LLDrawable::ACTIVE_CHILD); } - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); if( (old_parent != parentp && old_parent) || (parentp && parentp->isActive())) { @@ -2504,7 +2504,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, { // LL_DEBUGS() << "Clearing force invisible: " << mID << ":" << getPCodeString() << ":" << getPositionAgent() << LL_ENDL; mDrawable->clearState(LLDrawable::FORCE_INVISIBLE); - gPipeline.markRebuild( mDrawable, LLDrawable::REBUILD_ALL, TRUE ); + gPipeline.markRebuild( mDrawable, LLDrawable::REBUILD_ALL); } } @@ -3166,7 +3166,7 @@ void LLViewerObject::linkControlAvatar() //if (!cav->mRootVolp->isAnySelected()) { cav->updateVolumeGeom(); - cav->mRootVolp->recursiveMarkForUpdate(TRUE); + cav->mRootVolp->recursiveMarkForUpdate(); } } } @@ -4976,7 +4976,7 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) { region->loadCacheMiscExtras(obj->getLocalID()); } - obj->markForUpdate(FALSE); + obj->markForUpdate(); } }); } @@ -5210,7 +5210,7 @@ S32 LLViewerObject::setTEBumpmap(const U8 te, const U8 bump) if (mDrawable.notNull() && retval) { gPipeline.markTextured(mDrawable); - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY); } } return retval; @@ -5300,10 +5300,8 @@ S32 LLViewerObject::setTEMediaFlags(const U8 te, const U8 media_flags) setChanged(TEXTURE); if (mDrawable.notNull() && retval) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD); gPipeline.markTextured(mDrawable); - // JC - probably only need this if changes texture coords - //gPipeline.markRebuild(mDrawable); } } return retval; @@ -6631,35 +6629,27 @@ void LLViewerObject::updateVolume(const LLVolumeParams& volume_params) { // Transmit the update to the simulator sendShapeUpdate(); - markForUpdate(TRUE); + markForUpdate(); } } -void LLViewerObject::recursiveMarkForUpdate(BOOL priority) +void LLViewerObject::recursiveMarkForUpdate() { for (LLViewerObject::child_list_t::iterator iter = mChildList.begin(); iter != mChildList.end(); iter++) { LLViewerObject* child = *iter; - child->markForUpdate(priority); + child->markForUpdate(); } - markForUpdate(priority); + markForUpdate(); } -void LLViewerObject::markForUpdate(BOOL priority) +void LLViewerObject::markForUpdate() { if (mDrawable.notNull()) { gPipeline.markTextured(mDrawable); - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, priority); - } -} - -void LLViewerObject::markForUnload(BOOL priority) -{ - if (mDrawable.notNull()) - { - gPipeline.markRebuild(mDrawable, LLDrawable::FOR_UNLOAD, priority); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY); } } @@ -6885,7 +6875,7 @@ U32 LLViewerObject::getPartitionType() const return LLViewerRegion::PARTITION_NONE; } -void LLViewerObject::dirtySpatialGroup(BOOL priority) const +void LLViewerObject::dirtySpatialGroup() const { if (mDrawable) { @@ -6893,7 +6883,7 @@ void LLViewerObject::dirtySpatialGroup(BOOL priority) const if (group) { group->dirtyGeom(); - gPipeline.markRebuild(group, priority); + gPipeline.markRebuild(group); } } } @@ -6903,11 +6893,6 @@ void LLViewerObject::dirtyMesh() if (mDrawable) { gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); - /*LLSpatialGroup* group = mDrawable->getSpatialGroup(); - if (group) - { - group->dirtyMesh(); - }*/ } } @@ -6928,7 +6913,7 @@ void LLStaticViewerObject::updateDrawable(BOOL force_damped) if (mDrawable.notNull()) { mDrawable->updateXform(TRUE); - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); } clearChanged(SHIFTED); } diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index a18d07d970..bf82c43cd3 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -449,9 +449,8 @@ public: void setIcon(LLViewerTexture* icon_image); void clearIcon(); - void recursiveMarkForUpdate(BOOL priority); - virtual void markForUpdate(BOOL priority); - void markForUnload(BOOL priority); + void recursiveMarkForUpdate(); + virtual void markForUpdate(); void updateVolume(const LLVolumeParams& volume_params); virtual void updateSpatialExtents(LLVector4a& min, LLVector4a& max); virtual F32 getBinRadius(); @@ -594,7 +593,7 @@ public: virtual S32 getLOD() const { return 3; } virtual U32 getPartitionType() const; - virtual void dirtySpatialGroup(BOOL priority = FALSE) const; + void dirtySpatialGroup() const; virtual void dirtyMesh(); virtual LLNetworkData* getParameterEntry(U16 param_type) const; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index ea2a955ab1..e576784db8 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -2075,7 +2075,7 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port) // Make the drawable visible again and set the drawable parent childp->mDrawable->clearState(LLDrawable::FORCE_INVISIBLE); childp->setDrawableParent(objectp->mDrawable); // LLViewerObjectList::findOrphans() - gPipeline.markRebuild( childp->mDrawable, LLDrawable::REBUILD_ALL, TRUE ); + gPipeline.markRebuild( childp->mDrawable, LLDrawable::REBUILD_ALL); } // Make certain particles, icon and HUD aren't hidden diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 449fd4ba43..0f20076b04 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -264,7 +264,7 @@ BOOL LLViewerPartGroup::addPart(LLViewerPart* part, F32 desired_size) return FALSE; } - gPipeline.markRebuild(mVOPartGroupp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mVOPartGroupp->mDrawable, LLDrawable::REBUILD_ALL); mParticles.push_back(part); part->mSkipOffset=mSkippedTime; @@ -426,7 +426,7 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt) // we removed one or more particles, so flag this group for update if (mVOPartGroupp.notNull()) { - gPipeline.markRebuild(mVOPartGroupp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mVOPartGroupp->mDrawable, LLDrawable::REBUILD_ALL); } LLViewerPartSim::decPartCount(removed); } @@ -766,7 +766,7 @@ void LLViewerPartSim::updateSimulation() { if (vobj && !vobj->isDead()) { - gPipeline.markRebuild(vobj->mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(vobj->mDrawable, LLDrawable::REBUILD_ALL); } mViewerPartGroups[i]->updateParticles(dt * visirate); mViewerPartGroups[i]->mSkippedTime=0.0f; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 341ef57d8c..55bda561f3 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1872,7 +1872,7 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& LLDrawable* drawable = attached_object->mDrawable; if (drawable->isState(LLDrawable::RIGGED)) { //regenerate octree for rigged attachment - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_RIGGED, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_RIGGED); } } } @@ -2289,7 +2289,7 @@ void LLVOAvatar::restoreMeshData() } // force mesh update as LOD might not have changed to trigger this - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY); } //----------------------------------------------------------------------------- diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 82dfb1ca2a..6e5b387b36 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -1038,7 +1038,7 @@ void LLVOAvatarSelf::restoreMeshData() updateAttachmentVisibility(gAgentCamera.getCameraMode()); // force mesh update as LOD might not have changed to trigger this - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY); } diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 0bbf47e5e0..b814f15232 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -264,7 +264,7 @@ U32 LLVOGrass::processUpdateMessage(LLMessageSystem *mesgsys, if (mDrawable) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); } return retval; @@ -290,12 +290,12 @@ void LLVOGrass::idleUpdate(LLAgent &agent, const F64 &time) if (!LLVOTree::isTreeRenderingStopped() && !mNumBlades)//restart grass rendering { mNumBlades = GRASS_MAX_BLADES; - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); return; } if (mPatch && (mLastPatchUpdateTime != mPatch->getLastUpdateTime())) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); } return; @@ -348,7 +348,7 @@ BOOL LLVOGrass::updateLOD() { mNumBlades = 0 ; face->setSize(0, 0); - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); } return TRUE ; } @@ -373,7 +373,7 @@ BOOL LLVOGrass::updateLOD() { face->setSize(mNumBlades*8, mNumBlades*12); } - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); } else if (num_blades <= (mNumBlades >> 1)) { @@ -386,7 +386,7 @@ BOOL LLVOGrass::updateLOD() { face->setSize(mNumBlades*8, mNumBlades*12); } - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); return TRUE; } @@ -737,7 +737,7 @@ void LLVOGrass::updateDrawable(BOOL force_damped) if (mDrawable.notNull()) { mDrawable->updateXform(TRUE); - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); } clearChanged(SHIFTED); } diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index ac302ef421..3ac04cf665 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -287,7 +287,7 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) if (group && group->isVisible()) { - dirtySpatialGroup(TRUE); + dirtySpatialGroup(); } if (!num_parts) diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 273eeb930c..20621665fa 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -585,7 +585,7 @@ void LLVOSky::restoreGL() if (mDrawable) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); } } @@ -770,7 +770,7 @@ bool LLVOSky::updateSky() if (mDrawable.notNull() && mDrawable->getFace(0) && !mDrawable->getFace(0)->getVertexBuffer()) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); } mCubeMapUpdateStage = -1; } diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 067272ec44..3f5f56d378 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -150,7 +150,7 @@ BOOL LLVOSurfacePatch::updateGeometry(LLDrawable *drawable) { LL_PROFILE_ZONE_SCOPED; - dirtySpatialGroup(TRUE); + dirtySpatialGroup(); S32 min_comp, max_comp, range; min_comp = lltrunc(mPatchp->getMinComposition()); @@ -785,7 +785,7 @@ void LLVOSurfacePatch::dirtyGeom() { if (mDrawable) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); LLFace* facep = mDrawable->getFace(0); if (facep) { diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 0da77e4f8b..36e6da802b 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -376,11 +376,11 @@ void LLVOTree::idleUpdate(LLAgent &agent, const F64 &time) if (mReferenceBuffer.isNull()) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); } else if (trunk_LOD != mTrunkLOD) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, FALSE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); } else { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index aa60578cee..7c7b91eae8 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -410,7 +410,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, if (setVolume(volume_params, 0)) { - markForUpdate(TRUE); + markForUpdate(); } } @@ -421,10 +421,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, // S32 result = unpackTEMessage(mesgsys, _PREHASH_ObjectData, (S32) block_num); - if (result & teDirtyBits) - { - updateTEData(); - } + if (result & TEM_CHANGE_MEDIA) { retval |= MEDIA_FLAGS_CHANGED; @@ -446,7 +443,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, if (setVolume(volume_params, 0)) { - markForUpdate(TRUE); + markForUpdate(); } S32 res2 = unpackTEMessage(*dp); if (TEM_INVALID == res2) @@ -464,10 +461,6 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, } else { - if (res2 & teDirtyBits) - { - updateTEData(); - } if (res2 & TEM_CHANGE_MEDIA) { retval |= MEDIA_FLAGS_CHANGED; @@ -529,8 +522,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, S32 result = unpackTEMessage(tdp); if (result & teDirtyBits) { - updateTEData(); - if (mDrawable) + if (mDrawable) { //on the fly TE updates break batches, isolate in octree shrinkWrap(); } @@ -755,24 +747,7 @@ void LLVOVolume::animateTextures() void LLVOVolume::updateTextures() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - //const F32 TEXTURE_AREA_REFRESH_TIME = 1.f; // seconds - //if (mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) - { - updateTextureVirtualSize(); - - /*if (mDrawable.notNull() && !isVisible() && !mDrawable->isActive()) - { //delete vertex buffer to free up some VRAM - LLSpatialGroup* group = mDrawable->getSpatialGroup(); - if (group && (group->mVertexBuffer.notNull() || !group->mBufferMap.empty() || !group->mDrawMap.empty())) - { - group->destroyGL(true); - - //flag the group as having changed geometry so it gets a rebuild next time - //it becomes visible - group->setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); - } - }*/ - } + updateTextureVirtualSize(); } BOOL LLVOVolume::isVisible() const @@ -884,7 +859,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) || (vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE)) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD, FALSE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD); } } @@ -935,7 +910,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) (texture_discard < current_discard || //texture has more data than last rebuild current_discard < 0)) //no previous rebuild { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); mSculptChanged = TRUE; } @@ -1017,7 +992,7 @@ void LLVOVolume::setScale(const LLVector3 &scale, BOOL damped) //since drawable transforms do not include scale, changing volume scale //requires an immediate rebuild of volume verts. - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION); if (mDrawable) { @@ -1250,7 +1225,7 @@ void LLVOVolume::updateVisualComplexity() void LLVOVolume::notifyMeshLoaded() { mSculptChanged = TRUE; - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY); LLVOAvatar *av = getAvatar(); if (av && !isAnimatedObject()) @@ -1381,7 +1356,7 @@ void LLVOVolume::sculpt() LLVOVolume* volume = (*(mSculptTexture->getVolumeList(LLRender::SCULPT_TEX)))[i]; if (volume != this && volume->getVolume() == getVolume()) { - gPipeline.markRebuild(volume->mDrawable, LLDrawable::REBUILD_GEOMETRY, FALSE); + gPipeline.markRebuild(volume->mDrawable, LLDrawable::REBUILD_GEOMETRY); } } } @@ -1619,7 +1594,7 @@ BOOL LLVOVolume::updateLOD() if (lod_changed) { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); mLODChanged = TRUE; } else @@ -1648,7 +1623,7 @@ BOOL LLVOVolume::setDrawableParent(LLDrawable* parentp) if (!mDrawable->isRoot()) { // rebuild vertices in parent relative space - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); if (mDrawable->isActive() && !parentp->isActive()) { @@ -1700,7 +1675,7 @@ BOOL LLVOVolume::setParent(LLViewerObject* parent) if (ret && mDrawable) { gPipeline.markMoved(mDrawable); - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); } onReparent(old_parent, parent); } @@ -2088,7 +2063,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) LLSpatialGroup* group = drawable->getSpatialGroup(); if (group) { - group->dirtyMesh(); + gPipeline.markRebuild(group); } updateRelativeXform(); @@ -2105,7 +2080,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) if (mVolumeChanged || mFaceMappingChanged) { - dirtySpatialGroup(drawable->isState(LLDrawable::IN_REBUILD_Q1)); + dirtySpatialGroup(); bool was_regen_faces = false; should_update_octree_bounds = true; @@ -2127,7 +2102,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) } else if (mLODChanged || mSculptChanged || mColorChanged) { - dirtySpatialGroup(drawable->isState(LLDrawable::IN_REBUILD_Q1)); + dirtySpatialGroup(); compiled = TRUE; lodOrSculptChanged(drawable, compiled, should_update_octree_bounds); @@ -2298,7 +2273,7 @@ S32 LLVOVolume::setTEColor(const U8 te, const LLColor4& color) gPipeline.markTextured(mDrawable); //treat this alpha change as an LoD update since render batches may need to get rebuilt mLODChanged = TRUE; - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME); } retval = LLPrimitive::setTEColor(te, color); if (mDrawable.notNull() && retval) @@ -2514,16 +2489,6 @@ S32 LLVOVolume::setTEScaleT(const U8 te, const F32 t) return res; } - -void LLVOVolume::updateTEData() -{ - /*if (mDrawable.notNull()) - { - mFaceMappingChanged = TRUE; - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_MATERIAL, TRUE); - }*/ -} - bool LLVOVolume::hasMedia() const { bool result = false; @@ -3666,7 +3631,7 @@ BOOL LLVOVolume::setIsFlexible(BOOL is_flexible) res = setVolume(volume_params, 1); if (res) { - markForUpdate(TRUE); + markForUpdate(); } } return res; @@ -3714,7 +3679,7 @@ void LLVOVolume::onSetExtendedMeshFlags(U32 flags) if (/*!getRootEdit()->isAnySelected() &&*/ mDrawable.notNull()) { // Need to trigger rebuildGeom(), which is where control avatars get created/removed - getRootEdit()->recursiveMarkForUpdate(TRUE); + getRootEdit()->recursiveMarkForUpdate(); } if (isAttachment() && getAvatarAncestor()) { @@ -4451,13 +4416,13 @@ void LLVOVolume::setSelected(BOOL sel) LLViewerObject::setSelected(sel); if (isAnimatedObject()) { - getRootEdit()->recursiveMarkForUpdate(TRUE); + getRootEdit()->recursiveMarkForUpdate(); } else { if (mDrawable.notNull()) { - markForUpdate(TRUE); + markForUpdate(); } } } @@ -4554,14 +4519,14 @@ const LLMatrix4& LLVOVolume::getWorldMatrix(LLXformMatrix* xform) const return xform->getWorldMatrix(); } -void LLVOVolume::markForUpdate(BOOL priority) +void LLVOVolume::markForUpdate() { if (mDrawable) { shrinkWrap(); } - LLViewerObject::markForUpdate(priority); + LLViewerObject::markForUpdate(); mVolumeChanged = TRUE; } @@ -5497,81 +5462,6 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group) } -void handleRenderAutoMuteByteLimitChanged(const LLSD& new_value) -{ - static LLCachedControl render_auto_mute_byte_limit(gSavedSettings, "RenderAutoMuteByteLimit", 0U); - - if (0 != render_auto_mute_byte_limit) - { - //for unload - LLSculptIDSize::container_BY_SIZE_view::iterator - itL = LLSculptIDSize::instance().getSizeInfo().get().lower_bound(render_auto_mute_byte_limit), - itU = LLSculptIDSize::instance().getSizeInfo().get().end(); - - for (; itL != itU; ++itL) - { - const LLSculptIDSize::Info &nfo = *itL; - LLVOVolume *pVVol = nfo.getPtrLLDrawable()->getVOVolume(); - if (pVVol - && !pVVol->isDead() - && pVVol->isAttachment() - && !pVVol->getAvatar()->isSelf() - && LLVOVolume::NO_LOD != pVVol->getLOD() - ) - { - //postponed - pVVol->markForUnload(); - LLSculptIDSize::instance().addToUnloaded(nfo.getSculptId()); - } - } - - //for load if it was unload - itL = LLSculptIDSize::instance().getSizeInfo().get().begin(); - itU = LLSculptIDSize::instance().getSizeInfo().get().upper_bound(render_auto_mute_byte_limit); - - for (; itL != itU; ++itL) - { - const LLSculptIDSize::Info &nfo = *itL; - LLVOVolume *pVVol = nfo.getPtrLLDrawable()->getVOVolume(); - if (pVVol - && !pVVol->isDead() - && pVVol->isAttachment() - && !pVVol->getAvatar()->isSelf() - && LLVOVolume::NO_LOD == pVVol->getLOD() - ) - { - LLSculptIDSize::instance().remFromUnloaded(nfo.getSculptId()); - pVVol->updateLOD(); - pVVol->markForUpdate(TRUE); - } - } - } - else - { - LLSculptIDSize::instance().clearUnloaded(); - - LLSculptIDSize::container_BY_SIZE_view::iterator - itL = LLSculptIDSize::instance().getSizeInfo().get().begin(), - itU = LLSculptIDSize::instance().getSizeInfo().get().end(); - - for (; itL != itU; ++itL) - { - const LLSculptIDSize::Info &nfo = *itL; - LLVOVolume *pVVol = nfo.getPtrLLDrawable()->getVOVolume(); - if (pVVol - && !pVVol->isDead() - && pVVol->isAttachment() - && !pVVol->getAvatar()->isSelf() - && LLVOVolume::NO_LOD == pVVol->getLOD() - ) - { - pVVol->updateLOD(); - pVVol->markForUpdate(TRUE); - } - } - } -} - // add a face pointer to a list of face pointers without going over MAX_COUNT faces template static inline void add_face(T*** list, U32* count, T* face) @@ -5608,7 +5498,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (!group->hasState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::ALPHA_DIRTY)) { - if (group->hasState(LLSpatialGroup::MESH_DIRTY) && !LLPipeline::sDelayVBUpdate) + if (group->hasState(LLSpatialGroup::MESH_DIRTY)) { rebuildMesh(group); } @@ -6062,7 +5952,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) group->mGeometryBytes = geometryBytes; - if (!LLPipeline::sDelayVBUpdate) { //drawables have been rebuilt, clear rebuild status for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) @@ -6078,12 +5967,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) group->mLastUpdateTime = gFrameTimeSeconds; group->mBuilt = 1.f; group->clearState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::ALPHA_DIRTY); - - if (LLPipeline::sDelayVBUpdate) - { - group->setState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); - } - } void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) @@ -6135,7 +6018,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex())) { //something's gone wrong with the vertex buffer accounting, rebuild this group group->dirtyGeom(); - gPipeline.markRebuild(group, TRUE); + gPipeline.markRebuild(group); } buff->unmapBuffer(); @@ -6497,7 +6380,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace //for debugging, set last time face was updated vs moved facep->updateRebuildFlags(); - if (!LLPipeline::sDelayVBUpdate) { //copy face geometry into vertex buffer LLDrawable* drawablep = facep->getDrawable(); LLVOVolume* vobj = drawablep->getVOVolume(); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index d509a7e2ab..acba18383f 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -179,8 +179,7 @@ public: F32 getVObjRadius() const override { return mVObjRadius; }; const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const override; - void markForUpdate(BOOL priority) override; - void markForUnload() { LLViewerObject::markForUnload(TRUE); mVolumeChanged = TRUE; } + void markForUpdate() override; void faceMappingChanged() override { mFaceMappingChanged=TRUE; } /*virtual*/ void onShift(const LLVector4a &shift_vector) override; // Called when the drawable shifts @@ -422,8 +421,7 @@ protected: S32 computeLODDetail(F32 distance, F32 radius, F32 lod_factor); BOOL calcLOD(); LLFace* addFace(S32 face_index); - void updateTEData(); - + // stats tracking for render complexity static S32 mRenderComplexity_last; static S32 mRenderComplexity_current; diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 86e4853280..9b2871c6a9 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -124,7 +124,7 @@ void LLVOWLSky::resetVertexBuffers() mStarsVerts = nullptr; mFsSkyVerts = nullptr; - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); } void LLVOWLSky::cleanupGL() @@ -139,7 +139,7 @@ void LLVOWLSky::cleanupGL() void LLVOWLSky::restoreGL() { LLDrawPoolWLSky::restoreGL(); - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); } BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7f1db9b61e..9960ce7bd0 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -283,7 +283,6 @@ bool LLPipeline::sRenderHighlight = true; LLRender::eTexIndex LLPipeline::sRenderHighlightTextureChannel = LLRender::DIFFUSE_MAP; bool LLPipeline::sForceOldBakedUpload = false; S32 LLPipeline::sUseOcclusion = 0; -bool LLPipeline::sDelayVBUpdate = true; bool LLPipeline::sAutoMaskAlphaDeferred = true; bool LLPipeline::sAutoMaskAlphaNonDeferred = false; bool LLPipeline::sRenderTransparentWater = true; @@ -474,7 +473,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderAutoMaskAlphaNonDeferred"); connectRefreshCachedSettingsSafe("RenderUseFarClip"); connectRefreshCachedSettingsSafe("RenderAvatarMaxNonImpostors"); - connectRefreshCachedSettingsSafe("RenderDelayVBUpdate"); connectRefreshCachedSettingsSafe("UseOcclusion"); // DEPRECATED -- connectRefreshCachedSettingsSafe("WindLightUseAtmosShaders"); // DEPRECATED -- connectRefreshCachedSettingsSafe("RenderDeferred"); @@ -953,7 +951,6 @@ void LLPipeline::refreshCachedSettings() LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip"); LLVOAvatar::sMaxNonImpostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors"); LLVOAvatar::updateImpostorRendering(LLVOAvatar::sMaxNonImpostors); - LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate"); LLPipeline::sUseOcclusion = (!gUseWireframe @@ -1759,7 +1756,7 @@ void LLPipeline::createObject(LLViewerObject* vobj) vobj->setDrawableParent(NULL); // LLPipeline::addObject 2 } - markRebuild(drawablep, LLDrawable::REBUILD_ALL, TRUE); + markRebuild(drawablep, LLDrawable::REBUILD_ALL); if (drawablep->getVOVolume() && RenderAnimateRes) { @@ -1875,10 +1872,10 @@ void LLPipeline::updateMovedList(LLDrawable::drawable_vector_t& moved_list) { //will likely not receive any future world matrix updates // -- this keeps attachments from getting stuck in space and falling off your avatar drawablep->clearState(LLDrawable::ANIMATED_CHILD); - markRebuild(drawablep, LLDrawable::REBUILD_VOLUME, TRUE); + markRebuild(drawablep, LLDrawable::REBUILD_VOLUME); if (drawablep->getVObj()) { - drawablep->getVObj()->dirtySpatialGroup(TRUE); + drawablep->getVObj()->dirtySpatialGroup(); } } iter = moved_list.erase(curiter); @@ -2977,67 +2974,31 @@ void LLPipeline::markMeshDirty(LLSpatialGroup* group) mMeshDirtyGroup.push_back(group); } -void LLPipeline::markRebuild(LLSpatialGroup* group, bool priority) +void LLPipeline::markRebuild(LLSpatialGroup* group) { if (group && !group->isDead() && group->getSpatialPartition()) { - if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_HUD) + if (!group->hasState(LLSpatialGroup::IN_BUILD_Q1)) { - priority = true; - } - - if (priority) - { - if (!group->hasState(LLSpatialGroup::IN_BUILD_Q1)) - { - llassert_always(!mGroupQ1Locked); - - mGroupQ1.push_back(group); - group->setState(LLSpatialGroup::IN_BUILD_Q1); - - if (group->hasState(LLSpatialGroup::IN_BUILD_Q2)) - { - LLSpatialGroup::sg_vector_t::iterator iter = std::find(mGroupQ2.begin(), mGroupQ2.end(), group); - if (iter != mGroupQ2.end()) - { - mGroupQ2.erase(iter); - } - group->clearState(LLSpatialGroup::IN_BUILD_Q2); - } - } - } - else if (!group->hasState(LLSpatialGroup::IN_BUILD_Q2 | LLSpatialGroup::IN_BUILD_Q1)) - { - llassert_always(!mGroupQ2Locked); - mGroupQ2.push_back(group); - group->setState(LLSpatialGroup::IN_BUILD_Q2); + llassert_always(!mGroupQ1Locked); + mGroupQ1.push_back(group); + group->setState(LLSpatialGroup::IN_BUILD_Q1); } } } -void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, bool priority) +void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag) { if (drawablep && !drawablep->isDead() && assertInitialized()) { - if (!drawablep->isState(LLDrawable::BUILT)) - { - priority = true; - } - if (priority) + if (!drawablep->isState(LLDrawable::IN_REBUILD_Q1)) { - if (!drawablep->isState(LLDrawable::IN_REBUILD_Q1)) - { - mBuildQ1.push_back(drawablep); - drawablep->setState(LLDrawable::IN_REBUILD_Q1); // mark drawable as being in priority queue - } + mBuildQ1.push_back(drawablep); + drawablep->setState(LLDrawable::IN_REBUILD_Q1); // mark drawable as being in priority queue } - else if (!drawablep->isState(LLDrawable::IN_REBUILD_Q2)) - { - mBuildQ2.push_back(drawablep); - drawablep->setState(LLDrawable::IN_REBUILD_Q2); // need flag here because it is just a list - } - if (flag & (LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION)) + + if (flag & (LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION)) { drawablep->getVObj()->setChanged(LLXform::SILHOUETTE); } @@ -3083,7 +3044,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) markVisible(drawablep, camera); } - if (!sDelayVBUpdate) { //rebuild mesh as soon as we know it's visible group->rebuildMesh(); } @@ -3139,7 +3099,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) group->setVisible(); stateSort(group, camera); - if (!sDelayVBUpdate) { //rebuild mesh as soon as we know it's visible group->rebuildMesh(); } @@ -10759,7 +10718,7 @@ void LLPipeline::hideObject( const LLUUID& id ) void LLPipeline::hideDrawable( LLDrawable *pDrawable ) { pDrawable->setState( LLDrawable::FORCE_INVISIBLE ); - markRebuild( pDrawable, LLDrawable::REBUILD_ALL, TRUE ); + markRebuild( pDrawable, LLDrawable::REBUILD_ALL); //hide the children LLViewerObject::const_child_list_t& child_list = pDrawable->getVObj()->getChildren(); for ( LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); @@ -10770,14 +10729,14 @@ void LLPipeline::hideDrawable( LLDrawable *pDrawable ) if ( drawable ) { drawable->setState( LLDrawable::FORCE_INVISIBLE ); - markRebuild( drawable, LLDrawable::REBUILD_ALL, TRUE ); + markRebuild( drawable, LLDrawable::REBUILD_ALL); } } } void LLPipeline::unhideDrawable( LLDrawable *pDrawable ) { pDrawable->clearState( LLDrawable::FORCE_INVISIBLE ); - markRebuild( pDrawable, LLDrawable::REBUILD_ALL, TRUE ); + markRebuild( pDrawable, LLDrawable::REBUILD_ALL); //restore children LLViewerObject::const_child_list_t& child_list = pDrawable->getVObj()->getChildren(); for ( LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); @@ -10788,7 +10747,7 @@ void LLPipeline::unhideDrawable( LLDrawable *pDrawable ) if ( drawable ) { drawable->clearState( LLDrawable::FORCE_INVISIBLE ); - markRebuild( drawable, LLDrawable::REBUILD_ALL, TRUE ); + markRebuild( drawable, LLDrawable::REBUILD_ALL); } } } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 7eede30d8f..3b6a11b378 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -191,8 +191,8 @@ public: void markShift(LLDrawable *drawablep); void markTextured(LLDrawable *drawablep); void markGLRebuild(LLGLUpdate* glu); - void markRebuild(LLSpatialGroup* group, bool priority = false); - void markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag = LLDrawable::REBUILD_ALL, bool priority = false); + void markRebuild(LLSpatialGroup* group); + void markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag = LLDrawable::REBUILD_ALL); void markPartitionMove(LLDrawable* drawablep); void markMeshDirty(LLSpatialGroup* group); @@ -637,7 +637,6 @@ public: static bool sShowHUDAttachments; static bool sForceOldBakedUpload; // If true will not use capabilities to upload baked textures. static S32 sUseOcclusion; // 0 = no occlusion, 1 = read only, 2 = read/write - static bool sDelayVBUpdate; static bool sAutoMaskAlphaDeferred; static bool sAutoMaskAlphaNonDeferred; static bool sRenderTransparentWater; -- cgit v1.3 From 39820e4750d5b9f661ef74ee9868df9e471c5f36 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 18 May 2023 18:41:53 -0500 Subject: DRTVWR-559 Fix for shower curtain not opening smoothly. Incidental decruft. --- indra/newview/lldrawable.cpp | 2 +- indra/newview/lldrawable.h | 2 +- indra/newview/llvovolume.cpp | 2 +- indra/newview/pipeline.cpp | 6 +++--- indra/newview/pipeline.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 9d1b02cd8a..6b9c159291 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -942,7 +942,7 @@ void LLDrawable::updateTexture() } } -BOOL LLDrawable::updateGeometry(BOOL priority) +BOOL LLDrawable::updateGeometry() { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 5ab1f52439..970e8c8b2a 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -166,7 +166,7 @@ public: void updateTexture(); void updateMaterial(); virtual void updateDistance(LLCamera& camera, bool force_update); - BOOL updateGeometry(BOOL priority); + BOOL updateGeometry(); void updateFaceSize(S32 idx); void updateSpecialHoverCursor(BOOL enabled); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 7c7b91eae8..8160785d75 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2063,7 +2063,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) LLSpatialGroup* group = drawable->getSpatialGroup(); if (group) { - gPipeline.markRebuild(group); + group->dirtyMesh(); } updateRelativeXform(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 40112421cd..715e2a2326 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2457,9 +2457,9 @@ void LLPipeline::doOcclusion(LLCamera& camera) } } -bool LLPipeline::updateDrawableGeom(LLDrawable* drawablep, bool priority) +bool LLPipeline::updateDrawableGeom(LLDrawable* drawablep) { - bool update_complete = drawablep->updateGeometry(priority); + bool update_complete = drawablep->updateGeometry(); if (update_complete && assertInitialized()) { drawablep->setState(LLDrawable::BUILT); @@ -2611,7 +2611,7 @@ void LLPipeline::updateGeom(F32 max_dtime) drawablep->clearState(LLDrawable::FOR_UNLOAD); } - if (updateDrawableGeom(drawablep, TRUE)) + if (updateDrawableGeom(drawablep)) { drawablep->clearState(LLDrawable::IN_REBUILD_Q); mBuildQ1.erase(curiter); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index d42253b8d7..ed110c7b9f 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -455,7 +455,7 @@ private: void unloadShaders(); void addToQuickLookup( LLDrawPool* new_poolp ); void removeFromQuickLookup( LLDrawPool* poolp ); - bool updateDrawableGeom(LLDrawable* drawable, bool priority); + bool updateDrawableGeom(LLDrawable* drawable); void assertInitializedDoError(); bool assertInitialized() { const bool is_init = isInit(); if (!is_init) assertInitializedDoError(); return is_init; }; void connectRefreshCachedSettingsSafe(const std::string name); -- cgit v1.3 From 4e6303792a49e4db7a30ab5774668eb54b6a50b2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 22 Jun 2023 00:53:18 +0300 Subject: SL-5161 Don't render meshes that are waiting for skin data --- indra/newview/llmeshrepository.cpp | 54 ++++++++++++++++++++++++++++++++ indra/newview/llmeshrepository.h | 4 +++ indra/newview/llvovolume.cpp | 63 ++++++++++++++++++++++++++++---------- indra/newview/llvovolume.h | 3 +- 4 files changed, 107 insertions(+), 17 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 67bf6827ad..9f90e132f8 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -4255,6 +4255,37 @@ bool LLMeshRepository::hasPhysicsShape(const LLUUID& mesh_id) return false; } +bool LLMeshRepository::hasSkinInfo(const LLUUID& mesh_id) +{ + if (mesh_id.isNull()) + { + return false; + } + + if (mThread->hasSkinInfoInHeader(mesh_id)) + { + return true; + } + + const LLMeshSkinInfo* skininfo = getSkinInfo(mesh_id); + if (skininfo) + { + return true; + } + + return false; +} + +bool LLMeshRepository::hasHeader(const LLUUID& mesh_id) +{ + if (mesh_id.isNull()) + { + return false; + } + + return mThread->hasHeader(mesh_id); +} + bool LLMeshRepoThread::hasPhysicsShapeInHeader(const LLUUID& mesh_id) { LLMutexLock lock(mHeaderMutex); @@ -4271,6 +4302,29 @@ bool LLMeshRepoThread::hasPhysicsShapeInHeader(const LLUUID& mesh_id) return false; } +bool LLMeshRepoThread::hasSkinInfoInHeader(const LLUUID& mesh_id) +{ + LLMutexLock lock(mHeaderMutex); + mesh_header_map::iterator iter = mMeshHeader.find(mesh_id); + if (iter != mMeshHeader.end() && iter->second.first > 0) + { + LLMeshHeader& mesh = iter->second.second; + if (mesh.mSkinOffset >= 0 + && mesh.mSkinSize > 0) + { + return true; + } + } + + return false; +} + +bool LLMeshRepoThread::hasHeader(const LLUUID& mesh_id) +{ + LLMutexLock lock(mHeaderMutex); + mesh_header_map::iterator iter = mMeshHeader.find(mesh_id); + return iter != mMeshHeader.end(); +} void LLMeshRepository::uploadModel(std::vector& data, LLVector3& scale, bool upload_textures, bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position, diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 619e076fa6..89cd2d867f 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -401,6 +401,8 @@ public: bool decompositionReceived(const LLUUID& mesh_id, U8* data, S32 data_size); EMeshProcessingResult physicsShapeReceived(const LLUUID& mesh_id, U8* data, S32 data_size); bool hasPhysicsShapeInHeader(const LLUUID& mesh_id); + bool hasSkinInfoInHeader(const LLUUID& mesh_id); + bool hasHeader(const LLUUID& mesh_id); void notifyLoadedMeshes(); S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod); @@ -650,6 +652,8 @@ public: LLModel::Decomposition* getDecomposition(const LLUUID& mesh_id); void fetchPhysicsShape(const LLUUID& mesh_id); bool hasPhysicsShape(const LLUUID& mesh_id); + bool hasSkinInfo(const LLUUID& mesh_id); + bool hasHeader(const LLUUID& mesh_id); void buildHull(const LLVolumeParams& params, S32 detail); void buildPhysicsMesh(LLModel::Decomposition& decomp); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8160785d75..805eb47431 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -230,7 +230,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re mColorChanged = FALSE; mSpotLightPriority = 0.f; - mSkinInfoFailed = false; + mSkinInfoUnavaliable = false; mSkinInfo = NULL; mMediaImplList.resize(getNumTEs()); @@ -1132,7 +1132,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bo if (mSkinInfo && mSkinInfo->mMeshID != volume_params.getSculptID()) { mSkinInfo = NULL; - mSkinInfoFailed = false; + mSkinInfoUnavaliable = false; } if (!getVolume()->isMeshAssetLoaded()) @@ -1145,13 +1145,24 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bo } } - if (!mSkinInfo && !mSkinInfoFailed) + if (!mSkinInfo && !mSkinInfoUnavaliable) { - const LLMeshSkinInfo* skin_info = gMeshRepo.getSkinInfo(volume_params.getSculptID(), this); - if (skin_info) - { - notifySkinInfoLoaded(skin_info); - } + LLUUID mesh_id = volume_params.getSculptID(); + if (gMeshRepo.hasHeader(mesh_id) && !gMeshRepo.hasSkinInfo(mesh_id)) + { + // If header is present but has no data about skin, + // no point fetching + mSkinInfoUnavaliable = true; + } + + if (!mSkinInfoUnavaliable) + { + const LLMeshSkinInfo* skin_info = gMeshRepo.getSkinInfo(mesh_id, this); + if (skin_info) + { + notifySkinInfoLoaded(skin_info); + } + } } } else // otherwise is sculptie @@ -1186,7 +1197,7 @@ void LLVOVolume::updateSculptTexture() mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); } - mSkinInfoFailed = false; + mSkinInfoUnavaliable = false; mSkinInfo = NULL; } else @@ -1227,6 +1238,16 @@ void LLVOVolume::notifyMeshLoaded() mSculptChanged = TRUE; gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY); + if (!mSkinInfo && !mSkinInfoUnavaliable) + { + // Header was loaded, update skin info state from header + LLUUID mesh_id = getVolume()->getParams().getSculptID(); + if (!gMeshRepo.hasSkinInfo(mesh_id)) + { + mSkinInfoUnavaliable = true; + } + } + LLVOAvatar *av = getAvatar(); if (av && !isAnimatedObject()) { @@ -1244,7 +1265,7 @@ void LLVOVolume::notifyMeshLoaded() void LLVOVolume::notifySkinInfoLoaded(const LLMeshSkinInfo* skin) { - mSkinInfoFailed = false; + mSkinInfoUnavaliable = false; mSkinInfo = skin; notifyMeshLoaded(); @@ -1252,7 +1273,7 @@ void LLVOVolume::notifySkinInfoLoaded(const LLMeshSkinInfo* skin) void LLVOVolume::notifySkinInfoUnavailable() { - mSkinInfoFailed = true; + mSkinInfoUnavaliable = true; mSkinInfo = nullptr; } @@ -5589,11 +5610,21 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) std::string vobj_name = llformat("Vol%p", vobj); bool is_mesh = vobj->isMesh(); - if (is_mesh && - ((vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded()) || !gMeshRepo.meshRezEnabled())) - { - continue; - } + if (is_mesh) + { + if ((vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded()) + || !gMeshRepo.meshRezEnabled()) + { + // Waiting for asset to fetch + continue; + } + + if (!vobj->getSkinInfo() && !vobj->isSkinInfoUnavaliable()) + { + // Waiting for skin info to fetch + continue; + } + } LLVolume* volume = vobj->getVolume(); if (volume) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index acba18383f..aadc1fbcf3 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -330,6 +330,7 @@ public: BOOL setIsFlexible(BOOL is_flexible); const LLMeshSkinInfo* getSkinInfo() const; + const bool isSkinInfoUnavaliable() const { return mSkinInfoUnavaliable; } //convenience accessor for mesh ID (which is stored in sculpt id for legacy reasons) const LLUUID& getMeshID() const { return getVolume()->getParams().getSculptID(); } @@ -480,7 +481,7 @@ private: LLPointer mRiggedVolume; - bool mSkinInfoFailed; + bool mSkinInfoUnavaliable; LLConstPointer mSkinInfo; // statics public: -- cgit v1.3 From 21b67896e9d1d181f39b8e44b9efe2b4c153d22b Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Mon, 26 Jun 2023 15:37:18 -0500 Subject: SL-19909 Fix for reflection probes on vehicles blocking mouse clicks. Incidental instrumentation and decruft. --- indra/newview/llappviewer.cpp | 2 -- indra/newview/llreflectionmap.cpp | 2 +- indra/newview/llviewerobject.cpp | 2 ++ indra/newview/llviewerobjectlist.cpp | 4 ++++ indra/newview/llviewerregion.cpp | 7 +++++++ indra/newview/llvovolume.cpp | 9 ++++++++- indra/newview/llworld.cpp | 3 ++- 7 files changed, 24 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index abef25e34f..cf84094aa4 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4675,7 +4675,6 @@ public: static LLTrace::BlockTimerStatHandle FTM_AUDIO_UPDATE("Update Audio"); static LLTrace::BlockTimerStatHandle FTM_CLEANUP("Cleanup"); static LLTrace::BlockTimerStatHandle FTM_CLEANUP_DRAWABLES("Drawables"); -static LLTrace::BlockTimerStatHandle FTM_CLEANUP_OBJECTS("Objects"); static LLTrace::BlockTimerStatHandle FTM_IDLE_CB("Idle Callbacks"); static LLTrace::BlockTimerStatHandle FTM_LOD_UPDATE("Update LOD"); static LLTrace::BlockTimerStatHandle FTM_OBJECTLIST_UPDATE("Update Objectlist"); @@ -4972,7 +4971,6 @@ void LLAppViewer::idle() { LL_RECORD_BLOCK_TIME(FTM_CLEANUP); { - LL_RECORD_BLOCK_TIME(FTM_CLEANUP_OBJECTS); gObjectList.cleanDeadObjects(); } { diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 72dab0cba8..efaf068bd2 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -117,7 +117,7 @@ void LLReflectionMap::autoAdjustOrigin() { int face = -1; LLVector4a intersection; - LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], false, false, true, &face, &intersection); if (drawable != nullptr) { hit = true; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index e67750af7c..628a787b9d 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -418,6 +418,7 @@ void LLViewerObject::markDead() { if (!mDead) { + LL_PROFILE_ZONE_SCOPED; //LL_INFOS() << "Marking self " << mLocalID << " as dead." << LL_ENDL; // Root object of this hierarchy unlinks itself. @@ -1153,6 +1154,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, const EObjectUpdateType update_type, LLDataPacker *dp) { + LL_PROFILE_ZONE_SCOPED; LL_DEBUGS_ONCE("SceneLoadTiming") << "Received viewer object data" << LL_ENDL; LL_DEBUGS("ObjectUpdate") << " mesgsys " << mesgsys << " dp " << dp << " id " << getID() << " update_type " << (S32) update_type << LL_ENDL; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index e576784db8..ce4f9b7e64 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1353,6 +1353,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp) BOOL LLViewerObjectList::killObject(LLViewerObject *objectp) { + LL_PROFILE_ZONE_SCOPED; // Don't ever kill gAgentAvatarp, just force it to the agent's region // unless region is NULL which is assumed to mean you are logging out. if ((objectp == gAgentAvatarp) && gAgent.getRegion()) @@ -1379,6 +1380,7 @@ BOOL LLViewerObjectList::killObject(LLViewerObject *objectp) void LLViewerObjectList::killObjects(LLViewerRegion *regionp) { + LL_PROFILE_ZONE_SCOPED; LLViewerObject *objectp; @@ -1438,6 +1440,8 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer) return; } + LL_PROFILE_ZONE_SCOPED; + S32 num_removed = 0; LLViewerObject *objectp; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index d60fae4bd6..6b92b16ef4 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -716,6 +716,7 @@ static LLTrace::BlockTimerStatHandle FTM_SAVE_REGION_CACHE("Save Region Cache"); LLViewerRegion::~LLViewerRegion() { + LL_PROFILE_ZONE_SCOPED; mDead = TRUE; mImpl->mActiveSet.clear(); mImpl->mVisibleEntries.clear(); @@ -1590,6 +1591,7 @@ void LLViewerRegion::lightIdleUpdate() void LLViewerRegion::idleUpdate(F32 max_update_time) { + LL_PROFILE_ZONE_SCOPED; LLTimer update_timer; F32 max_time; @@ -1693,6 +1695,10 @@ BOOL LLViewerRegion::isViewerCameraStatic() void LLViewerRegion::killInvisibleObjects(F32 max_time) { +#if 1 // TODO: kill this. This is ill-conceived, objects that aren't in the camera frustum should not be deleted from memory. + // because of this, every time you turn around the simulator sends a swarm of full object update messages from cache + // probe misses and objects have to be reloaded from scratch. From some reason, disabling this causes holes to + // appear in the scene when flying back and forth between regions if(!sVOCacheCullingEnabled) { return; @@ -1769,6 +1775,7 @@ void LLViewerRegion::killInvisibleObjects(F32 max_time) } return; +#endif } void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector& delete_list) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8160785d75..de1d3fc012 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -244,6 +244,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re LLVOVolume::~LLVOVolume() { + LL_PROFILE_ZONE_SCOPED; delete mTextureAnimp; mTextureAnimp = NULL; delete mVolumeImpl; @@ -267,6 +268,7 @@ void LLVOVolume::markDead() { if (!mDead) { + LL_PROFILE_ZONE_SCOPED; if (getVolume()) { LLSculptIDSize::instance().rem(getVolume()->getParams().getSculptID()); @@ -4676,7 +4678,12 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end_face = face+1; } pick_transparent |= isHiglightedOrBeacon(); - bool special_cursor = specialHoverCursor(); + + // we *probably* shouldn't care about special cursor at all, but we *definitely* + // don't care about special cursor for reflection probes -- makes alt-zoom + // go through reflection probes on vehicles + bool special_cursor = mReflectionProbe.isNull() && specialHoverCursor(); + for (S32 i = start_face; i < end_face; ++i) { if (!special_cursor && !pick_transparent && getTE(i) && getTE(i)->getColor().mV[3] == 0.f) diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 0e0dbdc071..709a457862 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -111,7 +111,7 @@ LLWorld::LLWorld() : gGL.getTexUnit(0)->bind(mDefaultWaterTexturep); mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - LLViewerRegion::sVOCacheCullingEnabled = gSavedSettings.getBOOL("RequestFullRegionCache") && gSavedSettings.getBOOL("ObjectCacheEnabled"); + LLViewerRegion::sVOCacheCullingEnabled = gSavedSettings.getBOOL("RequestFullRegionCache") && gSavedSettings.getBOOL("ObjectCacheEnabled"); } @@ -681,6 +681,7 @@ static LLTrace::SampleStatHandle<> sNumActiveCachedObjects("numactivecachedobjec void LLWorld::updateRegions(F32 max_update_time) { + LL_PROFILE_ZONE_SCOPED; LLTimer update_timer; mNumOfActiveCachedObjects = 0; -- cgit v1.3 From f8139b1bc47fd7b930498e0b2b19676834521025 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 18 Jul 2023 13:01:50 -0700 Subject: SL-20018: Fix PBR glow affected by Blinn-Phong alpha --- indra/newview/llvovolume.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 08d2e99c40..e8623b1cc3 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6484,12 +6484,15 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } } - F32 te_alpha = te->getColor().mV[3]; + F32 blinn_phong_alpha = te->getColor().mV[3]; bool use_legacy_bump = te->getBumpmap() && (te->getBumpmap() < 18) && (!mat || mat->getNormalID().isNull()); - bool opaque = te_alpha >= 0.999f; - bool transparent = te_alpha < 0.999f; + bool blinn_phong_opaque = blinn_phong_alpha >= 0.999f; + bool blinn_phong_transparent = blinn_phong_alpha < 0.999f; - is_alpha = (is_alpha || transparent) ? TRUE : FALSE; + if (!gltf_mat) + { + is_alpha = (is_alpha || blinn_phong_transparent) ? TRUE : FALSE; + } if (gltf_mat || (mat && !hud_group)) { @@ -6519,7 +6522,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace { if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) { - if (opaque) + if (blinn_phong_opaque) { registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK); } @@ -6540,7 +6543,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } else { - if (opaque) + if (blinn_phong_opaque) { registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); } @@ -6551,7 +6554,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } } } - else if (transparent) + else if (blinn_phong_transparent) { registerFace(group, facep, LLRenderPass::PASS_ALPHA); } -- cgit v1.3 From f479c54fbf4a2264f705f153dd944b637eaa860a Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Sat, 2 Sep 2023 18:17:33 +0200 Subject: SEC-430 'WARNING: LLFace::getGeometryVolume: Index buffer overflow' occuring 500 times plus per minute --- indra/newview/llface.cpp | 46 +++++++++++++++++++++++++++----------------- indra/newview/llface.h | 10 ++++++---- indra/newview/llvovolume.cpp | 18 +++++++++++------ 3 files changed, 46 insertions(+), 28 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index cec1f47a4c..c1776705f9 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1144,22 +1144,32 @@ void push_for_transform(LLVertexBuffer* buff, U32 source_count, U32 dest_count) } BOOL LLFace::getGeometryVolume(const LLVolume& volume, - const S32 &f, - const LLMatrix4& mat_vert_in, const LLMatrix3& mat_norm_in, - const U16 &index_offset, - bool force_rebuild) + S32 face_index, + const LLMatrix4& mat_vert_in, + const LLMatrix3& mat_norm_in, + U16 index_offset, + bool force_rebuild, + bool no_debug_assert) { LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; llassert(verify()); - if (volume.getNumVolumeFaces() <= f) { - LL_WARNS() << "Attempt get volume face out of range! Total Faces: " << volume.getNumVolumeFaces() << " Attempt get access to: " << f << LL_ENDL; - return FALSE; - } + if (face_index < 0 || face_index >= volume.getNumVolumeFaces()) + { + if (gDebugGL) + { + LL_WARNS() << "Face index is out of bounds!" << LL_ENDL; + LL_WARNS() << "Attempt get volume face out of range!" + " Total Faces: " << volume.getNumVolumeFaces() << + " Attempt get access to: " << face_index << LL_ENDL; + llassert(no_debug_assert); + } + return FALSE; + } bool rigged = isState(RIGGED); - const LLVolumeFace &vf = volume.getVolumeFace(f); + const LLVolumeFace &vf = volume.getVolumeFace(face_index); S32 num_vertices = (S32)vf.mNumVertices; S32 num_indices = (S32) vf.mNumIndices; @@ -1174,14 +1184,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { if (gDebugGL) { - LL_WARNS() << "Index buffer overflow!" << LL_ENDL; + LL_WARNS() << "Index buffer overflow!" << LL_ENDL; LL_WARNS() << "Indices Count: " << mIndicesCount << " VF Num Indices: " << num_indices << " Indices Index: " << mIndicesIndex << " VB Num Indices: " << mVertexBuffer->getNumIndices() << LL_ENDL; - LL_WARNS() << " Face Index: " << f + LL_WARNS() << " Face Index: " << face_index << " Pool Type: " << mPoolType << LL_ENDL; - llassert(false); + llassert(no_debug_assert); } return FALSE; } @@ -1191,7 +1201,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (gDebugGL) { LL_WARNS() << "Vertex buffer overflow!" << LL_ENDL; - llassert(false); + llassert(no_debug_assert); } return FALSE; } @@ -1228,7 +1238,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, bool rebuild_tangent = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TANGENT); bool rebuild_weights = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_WEIGHT4); - const LLTextureEntry *tep = mVObjp->getTE(f); + const LLTextureEntry *tep = mVObjp->getTE(face_index); const U8 bump_code = tep ? tep->getBumpmap() : 0; BOOL is_static = mDrawablep->isStatic(); @@ -1443,7 +1453,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (bump_code) { - mVObjp->getVolume()->genTangents(f); + mVObjp->getVolume()->genTangents(face_index); F32 offset_multiple; switch( bump_code ) { @@ -1492,7 +1502,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, U8 texgen = getTextureEntry()->getTexGen(); if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT) { //planar texgen needs binormals - mVObjp->getVolume()->genTangents(f); + mVObjp->getVolume()->genTangents(face_index); } U8 tex_mode = 0; @@ -1775,7 +1785,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { mVertexBuffer->getTexCoord1Strider(tex_coords1, mGeomIndex, mGeomCount); - mVObjp->getVolume()->genTangents(f); + mVObjp->getVolume()->genTangents(face_index); for (S32 i = 0; i < num_vertices; i++) { @@ -1895,7 +1905,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, mVertexBuffer->getTangentStrider(tangent, mGeomIndex, mGeomCount); F32* tangents = (F32*) tangent.get(); - mVObjp->getVolume()->genTangents(f); + mVObjp->getVolume()->genTangents(face_index); LLVector4Logical mask; mask.clear(); diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 0a66dc6ba6..eb3b47d6d6 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -156,10 +156,12 @@ public: void updateRebuildFlags(); bool canRenderAsMask(); // logic helper BOOL getGeometryVolume(const LLVolume& volume, - const S32 &f, - const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, - const U16 &index_offset, - bool force_rebuild = false); + S32 face_index, + const LLMatrix4& mat_vert, + const LLMatrix3& mat_normal, + U16 index_offset, + bool force_rebuild = false, + bool no_debug_assert = false); // For avatar U16 getGeometryAvatar( diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 34f55d3341..73b00489d4 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6080,12 +6080,18 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) LLVertexBuffer* buff = face->getVertexBuffer(); if (buff) { - if (!face->getGeometryVolume(*volume, face->getTEOffset(), - vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex())) - { //something's gone wrong with the vertex buffer accounting, rebuild this group - group->dirtyGeom(); - gPipeline.markRebuild(group); - } + if (!face->getGeometryVolume(*volume, // volume + face->getTEOffset(), // face_index + vobj->getRelativeXform(), // mat_vert_in + vobj->getRelativeXformInvTrans(), // mat_norm_in + face->getGeomIndex(), // index_offset + false, // force_rebuild + true)) // no_debug_assert + { // Something's gone wrong with the vertex buffer accounting, + // rebuild this group with no debug assert because MESH_DIRTY + group->dirtyGeom(); + gPipeline.markRebuild(group); + } buff->unmapBuffer(); } -- cgit v1.3 From 50133bdebe3f07e9d6889769077e4360b0a5ff8c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 4 Oct 2023 20:55:07 +0300 Subject: SL-20400 Fixed cannot touch objects with "Select Only My Objects" --- indra/newview/llvovolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c9f3d86793..20a6a189b4 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4617,7 +4617,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& if (!pick_unselectable) { - if (!LLSelectMgr::instance().canSelectObject(this)) + if (!LLSelectMgr::instance().canSelectObject(this, TRUE)) { return FALSE; } -- cgit v1.3 From 70abb3085d763f9d9dbb7bcaa49fe9e3004d54ed Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 3 Oct 2023 17:24:46 -0700 Subject: SL-20254: Fix blinn-phong alpha of 0 making GLTF materials invisible for non-root prims. --- indra/newview/llvovolume.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 20a6a189b4..468943423a 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5856,7 +5856,16 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } else { - if (te->getColor().mV[3] > 0.f || te->getGlow() > 0.f) + F32 alpha; + if (is_pbr) + { + alpha = gltf_mat ? gltf_mat->mBaseColor.mV[3] : 1.0; + } + else + { + alpha = te->getColor().mV[3]; + } + if (alpha > 0.f || te->getGlow() > 0.f) { //only treat as alpha in the pipeline if < 100% transparent drawablep->setState(LLDrawable::HAS_ALPHA); add_face(sAlphaFaces, alpha_count, facep); -- cgit v1.3 From 85470fc4d29cb2fd7d168debdeed3544778592b8 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 4 Oct 2023 16:56:49 -0700 Subject: SL-20396: Apply blinn-phong rotation to texture translation animations for GLTF materials, for more consistent behavior --- indra/newview/llvovolume.cpp | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 468943423a..f1d4d9039b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -666,7 +666,25 @@ void LLVOVolume::animateTextures() { if (!(result & LLViewerTextureAnim::ROTATE)) { - rot = 0.0f; + if (result & LLViewerTextureAnim::TRANSLATE) + { + // The current LSL texture animation system is + // based on Blinn-Phong texture transforms, which + // is incompatible with the GLTF texture + // transforms. As a compromise, apply Blinn-Phong + // texture rotation on top of the GLTF texture + // transforms during a translation animation. This + // ensures that the animation loops for trivial + // GLTF texture transforms, when it would for + // similar Blinn-Phong animations. This is not + // guaranteed to loop for nontrivial GLTF texture + // transforms. + te->getRotation(&rot); + } + else + { + rot = 0.0f; + } } if (!(result & LLViewerTextureAnim::TRANSLATE)) { @@ -679,29 +697,20 @@ void LLVOVolume::animateTextures() scale_t = 1.0f; } - // For PBR materials, use Blinn-Phong rotation as hint for - // translation direction. In a Blinn-Phong material, the - // translation direction would be a byproduct the texture - // transform. - F32 rot_frame; - te->getRotation(&rot_frame); - tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); LLQuaternion quat; quat.setQuat(rot, 0, 0, -1.f); - tex_mat.rotate(quat); + tex_mat.rotate(quat); LLMatrix4 mat; - LLVector3 scale(scale_s, scale_t, 1.f); + LLVector3 scale(scale_s, scale_t, 1.f); mat.initAll(scale, LLQuaternion(), LLVector3()); tex_mat *= mat; - - LLVector3 off(off_s, off_t, 0.f); - off.rotVec(rot_frame, 0, 0, 1.f); - tex_mat.translate(off); - tex_mat.translate(LLVector3(0.5f, 0.5f, 0.f)); + LLVector3 trans; + trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); + tex_mat.translate(trans); } } } -- cgit v1.3 From 7297f0270473c1c42dcd44741eb38b4d1e8c6ac6 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 6 Oct 2023 11:08:44 -0700 Subject: SL-20396: On second thought, just apply the whole Blinn-Phong transform stack to PBR, but only during texture animations --- indra/newview/llvovolume.cpp | 107 ++++++++++--------------------------------- 1 file changed, 25 insertions(+), 82 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index f1d4d9039b..ec2f490742 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -619,8 +619,18 @@ void LLVOVolume::animateTextures() continue; } - LLGLTFMaterial *gltf_mat = te->getGLTFRenderMaterial(); - const bool is_pbr = gltf_mat != nullptr; + if (!(result & LLViewerTextureAnim::ROTATE)) + { + te->getRotation(&rot); + } + if (!(result & LLViewerTextureAnim::TRANSLATE)) + { + te->getOffset(&off_s,&off_t); + } + if (!(result & LLViewerTextureAnim::SCALE)) + { + te->getScale(&scale_s, &scale_t); + } if (!facep->mTextureMatrix) { @@ -629,89 +639,22 @@ void LLVOVolume::animateTextures() LLMatrix4& tex_mat = *facep->mTextureMatrix; tex_mat.setIdentity(); + LLVector3 trans ; - if (!is_pbr) - { - if (!(result & LLViewerTextureAnim::ROTATE)) - { - te->getRotation(&rot); - } - if (!(result & LLViewerTextureAnim::TRANSLATE)) - { - te->getOffset(&off_s,&off_t); - } - if (!(result & LLViewerTextureAnim::SCALE)) - { - te->getScale(&scale_s, &scale_t); - } - - LLVector3 trans ; - - trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); - tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); - - LLVector3 scale(scale_s, scale_t, 1.f); - LLQuaternion quat; - quat.setQuat(rot, 0, 0, -1.f); - - tex_mat.rotate(quat); - - LLMatrix4 mat; - mat.initAll(scale, LLQuaternion(), LLVector3()); - tex_mat *= mat; - - tex_mat.translate(trans); - } - else - { - if (!(result & LLViewerTextureAnim::ROTATE)) - { - if (result & LLViewerTextureAnim::TRANSLATE) - { - // The current LSL texture animation system is - // based on Blinn-Phong texture transforms, which - // is incompatible with the GLTF texture - // transforms. As a compromise, apply Blinn-Phong - // texture rotation on top of the GLTF texture - // transforms during a translation animation. This - // ensures that the animation loops for trivial - // GLTF texture transforms, when it would for - // similar Blinn-Phong animations. This is not - // guaranteed to loop for nontrivial GLTF texture - // transforms. - te->getRotation(&rot); - } - else - { - rot = 0.0f; - } - } - if (!(result & LLViewerTextureAnim::TRANSLATE)) - { - off_s = 0.0f; - off_t = 0.0f; - } - if (!(result & LLViewerTextureAnim::SCALE)) - { - scale_s = 1.0f; - scale_t = 1.0f; - } - - tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); + trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); + tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); - LLQuaternion quat; - quat.setQuat(rot, 0, 0, -1.f); - tex_mat.rotate(quat); - - LLMatrix4 mat; - LLVector3 scale(scale_s, scale_t, 1.f); - mat.initAll(scale, LLQuaternion(), LLVector3()); - tex_mat *= mat; + LLVector3 scale(scale_s, scale_t, 1.f); + LLQuaternion quat; + quat.setQuat(rot, 0, 0, -1.f); + + tex_mat.rotate(quat); - LLVector3 trans; - trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); - tex_mat.translate(trans); - } + LLMatrix4 mat; + mat.initAll(scale, LLQuaternion(), LLVector3()); + tex_mat *= mat; + + tex_mat.translate(trans); } } else -- cgit v1.3