davep avatar davep committed e9bcd9d

MAINT-639 Fix for random rainbow effects on some prims.

Comments (0)

Files changed (3)

indra/newview/llface.cpp

 
 	mFaceColor = LLColor4(1,0,0,1);
 
-	mLastVertexBuffer = mVertexBuffer;
-	mLastGeomCount = mGeomCount;
-	mLastGeomIndex = mGeomIndex;
-	mLastIndicesCount = mIndicesCount;
-	mLastIndicesIndex = mIndicesIndex;
-
 	mImportanceToCamera = 0.f ;
 	mBoundingSphereRadius = 0.0f ;
 
 		mIndicesIndex != 0xFFFFFFFF)
 	{
 		LLVOPartGroup::freeVBSlot(getGeomIndex()/4);
+		mIndicesIndex = 0xFFFFFFFF;
 	}
 
 	if (mDrawPoolp)
 		mGeomCount    = num_vertices;
 		mIndicesCount = num_indices;
 		mVertexBuffer = NULL;
-		mLastVertexBuffer = NULL;
 	}
 
 	llassert(verify());
 		LLMatrix4a mat_normal;
 		mat_normal.loadu(mat_normal_in);
 
-		//if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME))
-		//{ //vertex buffer no longer valid
-		//	mVertexBuffer = NULL;
-		//	mLastVertexBuffer = NULL;
-		//}
-
 		//VECTORIZE THIS
 		LLVector4a min,max;
 	
 
 void LLFace::updateRebuildFlags()
 {
-	if (!mDrawablep->isState(LLDrawable::REBUILD_VOLUME))
-	{
-		BOOL moved = TRUE;
-		if (mLastVertexBuffer == mVertexBuffer && 
-			!mVertexBuffer->isEmpty())
-		{	//this face really doesn't need to be regenerated, try real hard not to do so
-			if (mLastGeomCount == mGeomCount &&
-				mLastGeomIndex == mGeomIndex &&
-				mLastIndicesCount == mIndicesCount &&
-				mLastIndicesIndex == mIndicesIndex)
-			{ //data is in same location in vertex buffer
-				moved = FALSE;
-			}
-		}
-		mLastMoveTime = gFrameTimeSeconds;
-		
-		if (moved)
-		{
-			mDrawablep->setState(LLDrawable::REBUILD_VOLUME);
-		}
+	if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME))
+	{ //this rebuild is zero overhead (direct consequence of some change that affects this face)
+		mLastUpdateTime = gFrameTimeSeconds;
 	}
 	else
-	{
-		mLastUpdateTime = gFrameTimeSeconds;
+	{ //this rebuild is overhead (side effect of some change that does not affect this face)
+		mLastMoveTime = gFrameTimeSeconds;
 	}
 }
 
 					<< " VF Num Indices: " << num_indices
 					<< " Indices Index: " << mIndicesIndex
 					<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
-			llwarns	<< "Last Indices Count: " << mLastIndicesCount
-					<< " Last Indices Index: " << mLastIndicesIndex
-					<< " Face Index: " << f
+			llwarns	<< " Face Index: " << f
 					<< " Pool Type: " << mPoolType << llendl;
 			return FALSE;
 		}
 	
 	static LLCachedControl<bool> use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback");
 
+#ifdef GL_TRANSFORM_FEEDBACK_BUFFER
 	if (use_transform_feedback &&
 		gTransformPositionProgram.mProgramObject && //transform shaders are loaded
 		mVertexBuffer->useVBOs() && //target buffer is in VRAM
 		}
 	}
 	else
+#endif
 	{
 		//if it's not fullbright and has no normals, bake sunlight based on face normal
 		//bool bake_sunlight = !getTextureEntry()->getFullbright() &&
 	}
 
 
-	mLastVertexBuffer = mVertexBuffer;
-	mLastGeomCount = mGeomCount;
-	mLastGeomIndex = mGeomIndex;
-	mLastIndicesCount = mIndicesCount;
-	mLastIndicesIndex = mIndicesIndex;
-
 	return TRUE;
 }
 
 void LLFace::clearVertexBuffer()
 {
 	mVertexBuffer = NULL;
-	mLastVertexBuffer = NULL;
 }
 
 //static

indra/newview/llface.h

 
 	//vertex buffer tracking
 	void setVertexBuffer(LLVertexBuffer* buffer);
-	void clearVertexBuffer(); //sets mVertexBuffer and mLastVertexBuffer to NULL
+	void clearVertexBuffer(); //sets mVertexBuffer to NULL
 	LLVertexBuffer* getVertexBuffer()	const	{ return mVertexBuffer; }
 	U32 getRiggedVertexBufferDataMask() const;
 	S32 getRiggedIndex(U32 type) const;
 
 private:
 	LLPointer<LLVertexBuffer> mVertexBuffer;
-	LLPointer<LLVertexBuffer> mLastVertexBuffer;
-	
+		
 	U32			mState;
 	LLFacePool*	mDrawPoolp;
 	U32			mPoolType;
 	U32			mIndicesIndex;		// index into draw pool for indices (yeah, I know!)
 	S32         mIndexInTex ;
 
-	//previous rebuild's geometry info
-	U16			mLastGeomCount;
-	U16			mLastGeomIndex;
-	U32			mLastIndicesCount;
-	U32			mLastIndicesIndex;
-
 	LLXformMatrix* mXform;
 	LLPointer<LLViewerTexture> mTexture;
 	LLPointer<LLDrawable> mDrawablep;

indra/newview/llvovolume.cpp

 			}
 		}
 
-		//create/delete/resize vertex buffer if needed
+		//create vertex buffer
 		LLVertexBuffer* buffer = NULL;
 
-		if (group->mBufferUsage != GL_DYNAMIC_DRAW_ARB)
-		{ //try to find a buffer to reuse
-			LLFastTimer t(FTM_GEN_DRAW_INFO_FIND_VB);
-			LLSpatialGroup::buffer_texture_map_t::iterator found_iter = group->mBufferMap[mask].find(*face_iter);
-		
-			if (found_iter != group->mBufferMap[mask].end())
-			{
-				if ((U32) buffer_index < found_iter->second.size())
-				{
-					buffer = found_iter->second[buffer_index];
-				}
-			}
-		}
-					
 		{
 			LLFastTimer t(FTM_GEN_DRAW_INFO_ALLOCATE);
-	
-			if (!buffer || !buffer->isWriteable())
-			{ //create new buffer if needed
-				buffer = createVertexBuffer(mask, buffer_usage);
-				buffer->allocateBuffer(geom_count, index_count, TRUE);
-			}
-			else 
-			{ //resize pre-existing buffer
-				LLFastTimer t(FTM_GEN_DRAW_INFO_RESIZE_VB);
-				if (LLVertexBuffer::sEnableVBOs && buffer->getUsage() != buffer_usage ||
-					buffer->getTypeMask() != mask)
-				{
-					buffer = createVertexBuffer(mask, buffer_usage);
-					buffer->allocateBuffer(geom_count, index_count, TRUE);
-				}
-				else
-				{
-					buffer->resizeBuffer(geom_count, index_count);
-				}
-			}
+			buffer = createVertexBuffer(mask, buffer_usage);
+			buffer->allocateBuffer(geom_count, index_count, TRUE);
 		}
 
 		group->mGeometryBytes += buffer->getSize() + buffer->getIndicesSize();
 					llassert(!facep->isState(LLFace::RIGGED));
 
 					facep->getGeometryVolume(*volume, te_idx, 
-						vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset);
+						vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true);
 
 					if (drawablep->isState(LLDrawable::ANIMATED_CHILD))
 					{
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.