diff options
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/llcubemaparray.cpp | 2 | ||||
-rw-r--r-- | indra/llrender/llgltexture.h | 2 | ||||
-rw-r--r-- | indra/llrender/llimagegl.cpp | 77 | ||||
-rw-r--r-- | indra/llrender/llimagegl.h | 3 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 36 | ||||
-rw-r--r-- | indra/llrender/llrender.h | 17 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 2 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 35 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.h | 2 |
9 files changed, 84 insertions, 92 deletions
diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index 52118172c0..ac48a633c7 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -122,7 +122,7 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us bind(0); - U32 format = components == 4 ? GL_RGBA12 : GL_RGB10; + U32 format = components == 4 ? GL_RGBA12 : GL_RGB16F; U32 mip = 0; 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/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 50d4532fa7..b5c36ea35e 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1409,52 +1409,59 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt free_cur_tex_image(); #if LL_DARWIN - { - LL_PROFILE_ZONE_NAMED("glTexImage2D alloc"); - glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, use_scratch ? scratch : pixels); - } + const bool use_sub_image = false; #else - // break up calls to a manageable size for the GL command buffer + // glTexSubImage2D doesn't work with compressed textures on select tested Nvidia GPUs on Windows 10 -Cosmic,2023-03-08 + const bool use_sub_image = !allow_compression; +#endif + if (!use_sub_image) { LL_PROFILE_ZONE_NAMED("glTexImage2D alloc"); - glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, nullptr); + glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, use_scratch ? scratch : pixels); } - - U8* src = (U8*)(use_scratch ? scratch : pixels); - if (src) + else { - LL_PROFILE_ZONE_NAMED("glTexImage2D copy"); - U32 components = dataFormatComponents(pixformat); - U32 type_width = 0; - - switch (pixtype) + // break up calls to a manageable size for the GL command buffer { - case GL_UNSIGNED_BYTE: - case GL_BYTE: - case GL_UNSIGNED_INT_8_8_8_8_REV: - type_width = 1; - break; - case GL_UNSIGNED_SHORT: - case GL_SHORT: - type_width = 2; - break; - case GL_UNSIGNED_INT: - case GL_INT: - case GL_FLOAT: - type_width = 4; - break; - default: - LL_ERRS() << "Unknown type: " << pixtype << LL_ENDL; + LL_PROFILE_ZONE_NAMED("glTexImage2D alloc"); + glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, nullptr); } - U32 line_width = width * components * type_width; - for (U32 y = 0; y < height; ++y) + U8* src = (U8*)(use_scratch ? scratch : pixels); + if (src) { - glTexSubImage2D(target, miplevel, 0, y, width, 1, pixformat, pixtype, src); - src += line_width; + LL_PROFILE_ZONE_NAMED("glTexImage2D copy"); + U32 components = dataFormatComponents(pixformat); + U32 type_width = 0; + + switch (pixtype) + { + case GL_UNSIGNED_BYTE: + case GL_BYTE: + case GL_UNSIGNED_INT_8_8_8_8_REV: + type_width = 1; + break; + case GL_UNSIGNED_SHORT: + case GL_SHORT: + type_width = 2; + break; + case GL_UNSIGNED_INT: + case GL_INT: + case GL_FLOAT: + type_width = 4; + break; + default: + LL_ERRS() << "Unknown type: " << pixtype << LL_ENDL; + } + + U32 line_width = width * components * type_width; + for (U32 y = 0; y < height; ++y) + { + glTexSubImage2D(target, miplevel, 0, y, width, 1, pixformat, pixtype, src); + src += line_width; + } } } -#endif alloc_tex_image(width, height, pixformat); } stop_glerror(); diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index bbd024abd9..a03233323b 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -118,6 +118,9 @@ public: BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0, bool defer_copy = false, LLGLuint* tex_name = nullptr); void setImage(const LLImageRaw* imageraw); BOOL setImage(const U8* data_in, BOOL data_hasmips = FALSE, S32 usename = 0); + // *NOTE: force_fast_update should only be used if the texture is not + // compressed (i.e. RenderCompressTextures is 0). Partial image updates + // (glTexSubImage2D) do not work on compressed textures. BOOL setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height, BOOL force_fast_update = FALSE, LLGLuint use_name = 0); BOOL setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height, BOOL force_fast_update = FALSE, LLGLuint use_name = 0); BOOL setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index de74f2700a..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<LLVertexBuffer> 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; @@ -992,7 +974,7 @@ void LLRender::syncLightState() shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, LL_NUM_LIGHT_UNITS, diffuse[0].mV); shader->uniform3fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0); - shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); + //shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); } @@ -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<LLVector3> mVerticesp; LLStrider<LLVector2> mTexcoordsp; LLStrider<LLColor4U> mColorsp; - std::vector<LLTexUnit*> mTexUnits; - LLTexUnit* mDummyTexUnit; - std::vector<LLLightState*> mLightState; + std::array<LLTexUnit, LL_NUM_TEXTURE_LAYERS> mTexUnits; + LLTexUnit mDummyTexUnit; + std::array<LLLightState, LL_NUM_LIGHT_UNITS> mLightState; eBlendFactor mCurrBlendColorSFactor; eBlendFactor mCurrBlendColorDFactor; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6fb319fd5b..08a2e6779e 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -188,7 +188,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) /////////////////////////////////////// // NOTE order of shader object attaching is VERY IMPORTANT!!! - if (features->hasSrgb || features->hasAtmospherics || features->calculatesAtmospherics) + if (features->hasSrgb || features->hasAtmospherics || features->calculatesAtmospherics || features->isDeferred) { if (!shader->attachFragmentObject("environment/srgbF.glsl")) { diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 2fe80af373..dd0ea0096c 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<Entry>& 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 @@ -1363,7 +1356,9 @@ void LLVertexBuffer::setBuffer() U32 data_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask; // this Vertex Buffer must provide all necessary attributes for currently bound shader - //llassert((data_mask & mTypeMask) == data_mask); + 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 << " Missing: 0x" << (data_mask & ~mTypeMask) << std::dec); if (sGLRenderBuffer != mGLBuffer) { 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; |