Optimizations?

3 views
Skip to first unread message

Charles Sanglimsuwan

unread,
Aug 25, 2008, 4:11:05 PM8/25/08
to fl...@googlegroups.com
Hi everyone,

I'm getting a measly 51fps on a simple flash file in my XNA project.  I've commented out the part of the code that polls for input to get to 51fps.  My computer's specs aren't too bad either: Core Duo 1.66ghz, Radeon x1400, 1gb ram.  The flash swf I have is 1280x720, and all it does is display a raster image.

I used some profilers and they're reporting these lines of code to be the culprit of slowness (in GeometryBatch::Draw()):
			mVertexBuffer.SetData<VertexPositionChunk>(mVertices, 0, mVertexAddPoint);

for (int b = 0; b < mBatchesData.Count - 1; ++b)
{
for (int i = b * CHUNKS_PER_BATCH; i < (b + 1) * CHUNKS_PER_BATCH; ++i)
{
mEffectParam_Xforms[i % CHUNKS_PER_BATCH].SetValue(mXforms[i]);
mEffectParam_Colours[i % CHUNKS_PER_BATCH].SetValue(mColours[i]);
mEffectParam_CxformMuls[i % CHUNKS_PER_BATCH].SetValue(mCxformMuls[i]);
mEffectParam_CxformAdds[i % CHUNKS_PER_BATCH].SetValue(mCxformAdds[i]);
mEffectParam_Textures[i % CHUNKS_PER_BATCH].SetValue(mTextures[i]);
mEffectParam_TextureMatrices[i % CHUNKS_PER_BATCH].SetValue(mTextureMatrices[i]);
}
mBatchEffect.CommitChanges();

mBatchEffect.Begin(SaveStateMode.SaveState);
EffectPass pass = mBatchEffect.CurrentTechnique.Passes[0];
pass.Begin();
mDevice.VertexDeclaration = mVertexDecl;
mDevice.Vertices[0].SetSource(mVertexBuffer, 0, VertexPositionChunk.SizeInBytes);
mDevice.DrawPrimitives(PrimitiveType.TriangleList, mBatchesData[b], (mBatchesData[b + 1] - mBatchesData[b]) / 3);
pass.End();
mBatchEffect.End();
}

Are there any optimizations that people can think of to improve this speed? 

I got rid of the % CHUNKS_PER_BATCH and replaced it with an iterative counter that resets everytime it reaches CHUNKS_PER_BATCH, but it doesn't seem to help very much.

Thanks,
Charles
Reply all
Reply to author
Forward
0 new messages