diff options
author | Dave Parks <davep@lindenlab.com> | 2011-06-01 23:46:04 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-06-01 23:46:04 -0500 |
commit | 6992dbc1e32e1d8b803291aa1b87862fd6640c2a (patch) | |
tree | aef2f2d0d30105573f141190edb0d854d6d691b0 /indra/newview | |
parent | e881ee54d0f6cbddcc08bfd30d09232ed891df08 (diff) |
SH-1682 Use GL_ARB_map_buffer_range to mitigate impact of mapping larger vertex buffer objects. Limit number of textures per batch to 6 (prevents frame stalls on NVIDIA).
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 17 | ||||
-rw-r--r-- | indra/newview/lldrawpool.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lldrawpoolsimple.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llface.cpp | 112 | ||||
-rw-r--r-- | indra/newview/llspatialpartition.h | 4 | ||||
-rw-r--r-- | indra/newview/llviewercontrol.cpp | 1 | ||||
-rw-r--r-- | indra/newview/llvovolume.cpp | 43 |
7 files changed, 118 insertions, 88 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index bed7e4705e..b7ba9e3607 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7126,7 +7126,7 @@ <string>Vector3</string> <key>Value</key> <array> - <real>0.05</real> + <real>0.1</real> <real>0.0</real> <real>0.0</real> </array> @@ -7154,7 +7154,7 @@ <string>Vector3</string> <key>Value</key> <array> - <real>0.25</real> + <real>0.01</real> <real>0.0</real> <real>0.0</real> </array> @@ -7513,6 +7513,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>RenderMaxTextureIndex</key> + <map> + <key>Comment</key> + <string>Maximum texture index to use for indexed texture rendering.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>6</integer> + </map> <key>RenderDebugTextureBind</key> <map> <key>Comment</key> @@ -9011,7 +9022,7 @@ <key>Type</key> <string>Boolean</string> <key>Value</key> - <integer>1</integer> + <integer>0</integer> </map> <key>RenderUseStreamVBO</key> <map> diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index d92d9e92a1..f5483d969d 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -191,7 +191,7 @@ void LLDrawPool::renderPostDeferred(S32 pass) //virtual void LLDrawPool::endRenderPass( S32 pass ) { - for (U32 i = 1; i < gGLManager.mNumTextureImageUnits; i++) + for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++) { //dummy cleanup of any currently bound textures if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) { diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 6963fea26b..5dbb27cabb 100644 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -71,14 +71,7 @@ void LLDrawPoolGlow::renderPostDeferred(S32 pass) void LLDrawPoolGlow::endPostDeferredPass(S32 pass) { gDeferredFullbrightProgram.unbind(); - for (U32 i = 0; i < 8; i++) - { - if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) - { - gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType()); - gGL.getTexUnit(i)->disable(); - } - } + LLRenderPass::endRenderPass(pass); } void LLDrawPoolGlow::render(S32 pass) @@ -225,15 +218,6 @@ void LLDrawPoolSimple::endDeferredPass(S32 pass) LLRenderPass::endRenderPass(pass); gDeferredDiffuseProgram.unbind(); - - for (U32 i = 0; i < 8; i++) - { - if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) - { - gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType()); - gGL.getTexUnit(i)->disable(); - } - } } void LLDrawPoolSimple::renderDeferred(S32 pass) @@ -368,14 +352,7 @@ void LLDrawPoolFullbright::renderPostDeferred(S32 pass) void LLDrawPoolFullbright::endPostDeferredPass(S32 pass) { gDeferredFullbrightProgram.unbind(); - for (U32 i = 0; i < 8; i++) - { - if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) - { - gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType()); - gGL.getTexUnit(i)->disable(); - } - } + LLRenderPass::endRenderPass(pass); } void LLDrawPoolFullbright::beginRenderPass(S32 pass) diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index e30522d380..540ed054e9 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -429,11 +429,11 @@ U16 LLFace::getGeometryAvatar( if (mVertexBuffer.notNull()) { - mVertexBuffer->getVertexStrider (vertices, mGeomIndex); - mVertexBuffer->getNormalStrider (normals, mGeomIndex); - mVertexBuffer->getTexCoord0Strider (tex_coords, mGeomIndex); - mVertexBuffer->getWeightStrider(vertex_weights, mGeomIndex); - mVertexBuffer->getClothWeightStrider(clothing_weights, mGeomIndex); + mVertexBuffer->getVertexStrider (vertices, mGeomIndex, mGeomCount); + mVertexBuffer->getNormalStrider (normals, mGeomIndex, mGeomCount); + mVertexBuffer->getTexCoord0Strider (tex_coords, mGeomIndex, mGeomCount); + mVertexBuffer->getWeightStrider(vertex_weights, mGeomIndex, mGeomCount); + mVertexBuffer->getClothWeightStrider(clothing_weights, mGeomIndex, mGeomCount); } return mGeomIndex; @@ -446,17 +446,17 @@ U16 LLFace::getGeometry(LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &no if (mVertexBuffer.notNull()) { - mVertexBuffer->getVertexStrider(vertices, mGeomIndex); + mVertexBuffer->getVertexStrider(vertices, mGeomIndex, mGeomCount); if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL)) { - mVertexBuffer->getNormalStrider(normals, mGeomIndex); + mVertexBuffer->getNormalStrider(normals, mGeomIndex, mGeomCount); } if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD0)) { - mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex); + mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount); } - mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); + mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex, mIndicesCount); } return mGeomIndex; @@ -1092,27 +1092,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, const LLTextureEntry *tep = mVObjp->getTE(f); const U8 bump_code = tep ? tep->getBumpmap() : 0; - if (rebuild_pos) - { - mVertexBuffer->getVertexStrider(vert, mGeomIndex); - vertices = (LLVector4a*) vert.get(); - } - if (rebuild_normal) - { - mVertexBuffer->getNormalStrider(norm, mGeomIndex); - normals = (LLVector4a*) norm.get(); - } - if (rebuild_binormal) - { - mVertexBuffer->getBinormalStrider(binorm, mGeomIndex); - binormals = (LLVector4a*) binorm.get(); - } - if (rebuild_weights) - { - mVertexBuffer->getWeight4Strider(wght, mGeomIndex); - weights = (LLVector4a*) wght.get(); - } - F32 tcoord_xoffset = 0.f ; F32 tcoord_yoffset = 0.f ; F32 tcoord_xscale = 1.f ; @@ -1121,12 +1100,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_tcoord) { - mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex); - if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1)) - { - mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex); - } - in_atlas = isAtlasInUse() ; if(in_atlas) { @@ -1139,11 +1112,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, tcoord_yscale = tmp->mV[1] ; } } - if (rebuild_color) - { - mVertexBuffer->getColorStrider(colors, mGeomIndex); - } - + BOOL is_static = mDrawablep->isStatic(); BOOL is_global = is_static; @@ -1182,7 +1151,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, // INDICES if (full_rebuild) { - mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); + mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex, mIndicesCount, true); + __m128i* dst = (__m128i*) indicesp.get(); __m128i* src = (__m128i*) vf.mIndices; __m128i offset = _mm_set1_epi16(index_offset); @@ -1199,6 +1169,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { indicesp[i] = vf.mIndices[i]+index_offset; } + + mVertexBuffer->setBuffer(0); } LLMatrix4a mat_normal; @@ -1344,6 +1316,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (!in_atlas && !do_bump) { //not in atlas or not bump mapped, might be able to do a cheap update + mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount); + if (texgen != LLTextureEntry::TEX_GEN_PLANAR) { if (!do_tex_mat) @@ -1416,9 +1390,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } } + + mVertexBuffer->setBuffer(0); } else { //either bump mapped or in atlas, just do the whole expensive loop + mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount, true); + + std::vector<LLVector2> bump_tc; + for (S32 i = 0; i < num_vertices; i++) { LLVector2 tc(vf.mTexCoords[i]); @@ -1549,8 +1529,20 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, *tex_coords++ = tc; - - if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1)) + if (do_bump) + { + bump_tc.push_back(tc); + } + } + + mVertexBuffer->setBuffer(0); + + + if (do_bump) + { + mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex, mGeomCount, true); + + for (S32 i = 0; i < num_vertices; i++) { LLVector4a tangent; tangent.setCross3(vf.mBinormals[i], vf.mNormals[i]); @@ -1572,16 +1564,22 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } binormal.normalize3fast(); + LLVector2 tc = bump_tc[i]; tc += LLVector2( bump_s_primary_light_ray.dot3(tangent).getF32(), bump_t_primary_light_ray.dot3(binormal).getF32() ); *tex_coords2++ = tc; - } + } + + mVertexBuffer->setBuffer(0); } } } if (rebuild_pos) { + mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount, true); + vertices = (LLVector4a*) vert.get(); + LLMatrix4a mat_vert; mat_vert.loadu(mat_vert_in); @@ -1607,11 +1605,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, index_dst += 4; } while (index_dst < index_end); - + + mVertexBuffer->setBuffer(0); } if (rebuild_normal) { + mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, true); + normals = (LLVector4a*) norm.get(); + for (S32 i = 0; i < num_vertices; i++) { LLVector4a normal; @@ -1619,10 +1621,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, normal.normalize3fast(); normals[i] = normal; } + + mVertexBuffer->setBuffer(0); } if (rebuild_binormal) { + mVertexBuffer->getBinormalStrider(binorm, mGeomIndex, mGeomCount, true); + binormals = (LLVector4a*) binorm.get(); + for (S32 i = 0; i < num_vertices; i++) { LLVector4a binormal; @@ -1630,15 +1637,22 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, binormal.normalize3fast(); binormals[i] = binormal; } + + mVertexBuffer->setBuffer(0); } if (rebuild_weights && vf.mWeights) { + mVertexBuffer->getWeight4Strider(wght, mGeomIndex, mGeomCount, true); + weights = (LLVector4a*) wght.get(); LLVector4a::memcpyNonAliased16((F32*) weights, (F32*) vf.mWeights, num_vertices*4*sizeof(F32)); + mVertexBuffer->setBuffer(0); } if (rebuild_color) { + mVertexBuffer->getColorStrider(colors, mGeomIndex, mGeomCount, true); + LLVector4a src; U32 vec[4]; @@ -1657,6 +1671,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { dst[i] = src; } + + mVertexBuffer->setBuffer(0); } if (rebuild_tcoord) @@ -2073,13 +2089,13 @@ S32 LLFace::getColors(LLStrider<LLColor4U> &colors) } // llassert(mGeomIndex >= 0); - mVertexBuffer->getColorStrider(colors, mGeomIndex); + mVertexBuffer->getColorStrider(colors, mGeomIndex, mGeomCount); return mGeomIndex; } S32 LLFace::getIndices(LLStrider<U16> &indicesp) { - mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); + mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex, mIndicesCount); llassert(indicesp[0] != indicesp[1]); return mIndicesIndex; } diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index ae5d4fa463..db8a0c2992 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -209,7 +209,7 @@ public: typedef std::vector<LLPointer<LLDrawInfo> > drawmap_elem_t; typedef std::map<U32, drawmap_elem_t > draw_map_t; typedef std::vector<LLPointer<LLVertexBuffer> > buffer_list_t; - typedef std::map<LLPointer<LLViewerTexture>, buffer_list_t> buffer_texture_map_t; + typedef std::map<LLFace*, buffer_list_t> buffer_texture_map_t; typedef std::map<U32, buffer_texture_map_t> buffer_map_t; typedef LLOctreeListener<LLDrawable> BaseType; @@ -401,7 +401,7 @@ protected: public: bridge_list_t mBridgeList; - buffer_map_t mBufferMap; //used by volume buffers to store unique buffers per texture + buffer_map_t mBufferMap; //used by volume buffers to attempt to reuse vertex buffers F32 mBuilt; OctreeNode* mOctreeNode; diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 61200db2b9..87ca80260f 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -591,6 +591,7 @@ void settings_setup_listeners() gSavedSettings.getControl("OctreeMaxNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeAlphaDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); + gSavedSettings.getControl("RenderMaxTextureIndex")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); gSavedSettings.getControl("RenderUseTriStrips")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 125283d474..58e38ea9b1 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4426,6 +4426,33 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) llassert(!group || !group->isState(LLSpatialGroup::NEW_DRAWINFO)); } +struct CompareBatchBreakerModified +{ + bool operator()(const LLFace* const& lhs, const LLFace* const& rhs) + { + const LLTextureEntry* lte = lhs->getTextureEntry(); + const LLTextureEntry* rte = rhs->getTextureEntry(); + + if (lte->getBumpmap() != rte->getBumpmap()) + { + return lte->getBumpmap() < rte->getBumpmap(); + } + else if (lte->getFullbright() != rte->getFullbright()) + { + return lte->getFullbright() < rte->getFullbright(); + } + else if (lte->getGlow() != rte->getGlow()) + { + return lte->getGlow() < rte->getGlow(); + } + else + { + return lhs->getTexture() < rhs->getTexture(); + } + + } +}; + void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort, BOOL batch_textures) { //calculate maximum number of vertices to store in a single buffer @@ -4435,7 +4462,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: if (!distance_sort) { //sort faces by things that break batches - std::sort(faces.begin(), faces.end(), LLFace::CompareBatchBreaker()); + std::sort(faces.begin(), faces.end(), CompareBatchBreakerModified()); } else { @@ -4462,6 +4489,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: texture_index_channels = gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels; } + texture_index_channels = llmin(texture_index_channels, (S32) gSavedSettings.getU32("RenderMaxTextureIndex")); + while (face_iter != faces.end()) { @@ -4587,7 +4616,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: //create/delete/resize vertex buffer if needed LLVertexBuffer* buffer = NULL; - LLSpatialGroup::buffer_texture_map_t::iterator found_iter = group->mBufferMap[mask].find(tex); + LLSpatialGroup::buffer_texture_map_t::iterator found_iter = group->mBufferMap[mask].find(*face_iter); if (found_iter != group->mBufferMap[mask].end()) { @@ -4618,7 +4647,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } } - buffer_map[mask][tex].push_back(buffer); + buffer_map[mask][*face_iter].push_back(buffer); //add face geometry @@ -4649,12 +4678,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: U32 te_idx = facep->getTEOffset(); - if (facep->getGeometryVolume(*volume, te_idx, - vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset)) - { - buffer->markDirty(facep->getGeomIndex(), facep->getGeomCount(), - facep->getIndicesStart(), facep->getIndicesCount()); - } + facep->getGeometryVolume(*volume, te_idx, + vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset); } } |