diff options
Diffstat (limited to 'indra/llrender/llrender.cpp')
| -rw-r--r-- | indra/llrender/llrender.cpp | 197 |
1 files changed, 132 insertions, 65 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index cbb178b6f8..658947d531 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -124,7 +124,7 @@ static const GLenum sGLBlendFactor[] = LLTexUnit::LLTexUnit(S32 index) : mCurrTexType(TT_NONE), - mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0), + mCurrTexture(0), mHasMipMaps(false), mIndex(index) { @@ -203,6 +203,7 @@ void LLTexUnit::bindFast(LLTexture* texture) glActiveTexture(GL_TEXTURE0 + mIndex); gGL.mCurrTextureUnitIndex = mIndex; mCurrTexture = gl_tex->getTexName(); + mCurrTexType = gl_tex->getTarget(); if (!mCurrTexture) { LL_PROFILE_ZONE_NAMED("MISSING TEXTURE"); @@ -213,6 +214,14 @@ void LLTexUnit::bindFast(LLTexture* texture) } glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); mHasMipMaps = gl_tex->mHasMipMaps; +/* + if (gl_tex->mTexOptionsDirty) + { + gl_tex->mTexOptionsDirty = false; + setTextureAddressModeFast(gl_tex->mAddressMode, gl_tex->getTarget()); + setTextureFilteringOptionFast(gl_tex->mFilterOption, gl_tex->getTarget()); + } +*/ } bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) @@ -467,11 +476,24 @@ void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode) activate(); - glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]); - glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); +/* + setTextureAddressModeFast(mode, mCurrTexType); +} + +void LLTexUnit::setTextureAddressModeFast(eTextureAddressMode mode, eTextureType tex_type) +{ + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); + if (tex_type == TT_CUBE_MAP || tex_type == TT_CUBE_MAP_ARRAY || tex_type == TT_TEXTURE_3D) + { + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); + } +*/ + glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]); + glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); if (mCurrTexType == TT_CUBE_MAP) { - glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); + glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); } } @@ -479,41 +501,80 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio { if (mIndex < 0 || mCurrTexture == 0 || mCurrTexType == LLTexUnit::TT_MULTISAMPLE_TEXTURE) return; + GLenum target = sGLTextureType[mCurrTexType]; + + if (mCurrTexType == LLTexUnit::TT_NONE) + { + LL_WARNS() << "setTextureFilteringOption() Error: mCurrTexType==TT_NONE texture: " << mCurrTexture << LL_ENDL; + gGL.debugTexUnits(); + } + gGL.flush(); +/* + setTextureFilteringOptionFast(option, mCurrTexType); +} + +void LLTexUnit::setTextureFilteringOptionFast(LLTexUnit::eTextureFilterOptions option, eTextureType tex_type) +{ +*/ if (option == TFO_POINT) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MAG_FILTER, GL_NEAREST); +/* + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MAG_FILTER, GL_NEAREST); } else { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MAG_FILTER, GL_LINEAR); +*/ + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + else + { + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } if (option >= TFO_TRILINEAR && mHasMipMaps) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); +/* + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); +*/ + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } else if (option >= TFO_BILINEAR) { if (mHasMipMaps) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); +/* + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + } + else + { + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_LINEAR); +*/ + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); } else { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } } else { if (mHasMipMaps) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); +/* + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); } else { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_NEAREST); +*/ + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); + } + else + { + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } } @@ -521,11 +582,20 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio { if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC) { - glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, gGLManager.mMaxAnisotropy); +/* + glTexParameterf(sGLTextureType[tex_type], GL_TEXTURE_MAX_ANISOTROPY, gGLManager.mMaxAnisotropy); } else { - glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glTexParameterf(sGLTextureType[tex_type], GL_TEXTURE_MAX_ANISOTROPY, 1.f); +*/ + //glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, gGLManager.mMaxAnisotropy); + //We plan to add a setting. For now we stick to a low value. + glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, 4.0); + } + else + { + glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); } } } @@ -610,30 +680,6 @@ GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha) } } -void LLTexUnit::setColorScale(S32 scale) -{ - if (mCurrColorScale != scale || gGL.mDirty) - { - mCurrColorScale = scale; - gGL.flush(); -#if GL_VERSION_1_1 - glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale ); -#endif - } -} - -void LLTexUnit::setAlphaScale(S32 scale) -{ - if (mCurrAlphaScale != scale || gGL.mDirty) - { - mCurrAlphaScale = scale; - gGL.flush(); -#if GL_VERSION_1_1 - glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale ); -#endif - } -} - // Useful for debugging that you've manually assigned a texture operation to the correct // texture unit based on the currently set active texture in opengl. void LLTexUnit::debugTextureUnit(void) @@ -908,13 +954,12 @@ bool LLRender::init(bool needs_vertex_buffer) void LLRender::initVertexBuffer() { llassert_always(mBuffer.isNull()); - stop_glerror(); mBuffer = new LLVertexBuffer(immediate_mask); - mBuffer->allocateBuffer(4096, 0); + mBuffer->allocateBuffer(16384, 0); mBuffer->getVertexStrider(mVerticesp); mBuffer->getTexCoord0Strider(mTexcoordsp); mBuffer->getColorStrider(mColorsp); - stop_glerror(); + LOG_GLERROR("LLRender::initVertexBuffer()"); } void LLRender::resetVertexBuffer() @@ -1000,7 +1045,6 @@ void LLRender::syncLightState() void LLRender::syncMatrices() { - STOP_GLERROR; LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; static const U32 name[] = @@ -1145,7 +1189,7 @@ void LLRender::syncMatrices() syncLightState(); } } - STOP_GLERROR; + LOG_GLERROR("LLRender::syncMatrices()"); } void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z) @@ -1299,9 +1343,7 @@ void LLRender::translateUI(F32 x, F32 y, F32 z) LL_ERRS() << "Need to push a UI translation frame before offsetting" << LL_ENDL; } - mUIOffset.back().mV[0] += x; - mUIOffset.back().mV[1] += y; - mUIOffset.back().mV[2] += z; + mUIOffset.back().add(LLVector4a(x, y, z)); } void LLRender::scaleUI(F32 x, F32 y, F32 z) @@ -1311,14 +1353,14 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z) LL_ERRS() << "Need to push a UI transformation frame before scaling." << LL_ENDL; } - mUIScale.back().scaleVec(LLVector3(x,y,z)); + mUIScale.back().mul(LLVector4a(x, y, z)); } void LLRender::pushUIMatrix() { if (mUIOffset.empty()) { - mUIOffset.emplace_back(0.f,0.f,0.f); + mUIOffset.emplace_back(0.f); } else { @@ -1327,7 +1369,7 @@ void LLRender::pushUIMatrix() if (mUIScale.empty()) { - mUIScale.emplace_back(1.f,1.f,1.f); + mUIScale.emplace_back(1.f); } else { @@ -1349,18 +1391,20 @@ LLVector3 LLRender::getUITranslation() { if (mUIOffset.empty()) { - return LLVector3(0,0,0); + return LLVector3::zero; } - return mUIOffset.back(); + + return LLVector3(mUIOffset.back().getF32ptr()); } LLVector3 LLRender::getUIScale() { if (mUIScale.empty()) { - return LLVector3(1,1,1); + return LLVector3::all_one; } - return mUIScale.back(); + + return LLVector3(mUIScale.back().getF32ptr()); } @@ -1370,8 +1414,9 @@ void LLRender::loadUIIdentity() { LL_ERRS() << "Need to push UI translation frame before clearing offset." << LL_ENDL; } - mUIOffset.back().setVec(0,0,0); - mUIScale.back().setVec(1,1,1); + + mUIOffset.back().clear(); + mUIScale.back().splat(1); } void LLRender::setColorMask(bool writeColor, bool writeAlpha) @@ -1555,7 +1600,7 @@ void LLRender::begin(const GLuint& mode) mMode == LLRender::TRIANGLES || mMode == LLRender::POINTS) { - flush(); + flush("LLRender::begin"); } else if (mCount != 0) { @@ -1566,7 +1611,7 @@ void LLRender::begin(const GLuint& mode) } } -void LLRender::end() +void LLRender::end(std::string comment_) { if (mCount == 0) { @@ -1579,13 +1624,12 @@ void LLRender::end() mMode != LLRender::POINTS) || mCount > 2048) { - flush(); + flush("from end " + comment_); } } -void LLRender::flush() +void LLRender::flush(std::string comment_) { - STOP_GLERROR; if (mCount > 0) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -1654,9 +1698,16 @@ void LLRender::flush() } resetStriders(count); + + LOG_GLERROR("LLRender::flush() end " + comment_); } } +void LLRender::flush() +{ + flush(""); +} + LLVertexBuffer* LLRender::bufferfromCache(U32 attribute_mask, U32 count) { LLVertexBuffer *vb = nullptr; @@ -1751,9 +1802,11 @@ LLVertexBuffer* LLRender::genBuffer(U32 attribute_mask, S32 count) vb->setColorData(mColorsp.get()); } -#if LL_DARWIN + if(gGLManager.mIsApple && LLVertexBuffer::getVertexBufferMode() == 0) + { vb->unmapBuffer(); -#endif + } + vb->unbind(); return vb; @@ -1799,8 +1852,10 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) } else { - LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back()); - mVerticesp[mCount].set(vert.mV[VX], vert.mV[VY], vert.mV[VZ]); + LLVector4a vert(x, y, z); + vert.add(mUIOffset.back()); + vert.mul(mUIScale.back()); + mVerticesp[mCount] = vert; } mCount++; @@ -2026,7 +2081,8 @@ void LLRender::debugTexUnits(void) std::string active_enabled = "false"; for (U32 i = 0; i < mTexUnits.size(); i++) { - if (getTexUnit(i)->mCurrTexType != LLTexUnit::TT_NONE) + //if (getTexUnit(i)->mCurrTexType != LLTexUnit::TT_NONE) + if(1) { if (i == mCurrTextureUnitIndex) active_enabled = "true"; LL_INFOS("TextureUnit") << "TexUnit: " << i << " Enabled" << LL_ENDL; @@ -2044,8 +2100,19 @@ void LLRender::debugTexUnits(void) case LLTexUnit::TT_CUBE_MAP: LL_CONT << "Cube Map"; break; + case LLTexUnit::TT_CUBE_MAP_ARRAY: + LL_CONT << "Cube Map Array"; + break; + + case LLTexUnit::TT_MULTISAMPLE_TEXTURE: + LL_CONT << "Multisample Texture"; + break; + + case LLTexUnit::TT_TEXTURE_3D: + LL_CONT << "Texture 3D"; + break; default: - LL_CONT << "ARGH!!! NONE!"; + LL_CONT << "ARGH!!! NONE! -> type = " << getTexUnit(i)->mCurrTexType; break; } LL_CONT << ", Texture Bound: " << getTexUnit(i)->mCurrTexture << LL_ENDL; |
