   need to speed up ID3DXSPRITE::Draw()
  I'm making an isometric 2D tycoon game. Every game cycle I have to draw the ground tiles, buildings, people, terrain transitions. To do that I have to run through this kind of loop a few times per game cycle.#define mapSize 32LPD3DXSPRITE d3dspt;//draw groundtilesfor (int j=0; j<mapSize*4; j++){for (int i=0; i<mapSize; i++){D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);int plotX=i*IMAGESIZE+(j % 2)*(IMAGESIZE/2)-l;int plotY=j*(IMAGESIZE/4)-m-IMAGESIZE;D3DXVECTOR3 position(plotX,plotY, 1.0f); d3dspt->Draw(tile[j].spri, NULL, &center, &position, D3DCOLOR_XRGB(255, 255, 255));}}In this loop I draw 4096 times and this takes 12ms. Is there a way I can speed it up? It's hogging cpu and creating noticable lag so I need to find a way to solve it.[Edited by - TaxCollector on April 16, 2010 5:54:15 PM]
  Well the first thing you need to do is figure out exactly where that time is being spent. It could be your code, it could code inside the the sprite class that transforms vertices on the CPU, or it could be time spent in the driver due to too many SetTexture or DrawPrimitive calls. Standard CPU profilers can help with this, as can graphics-specific tools like PIX or PerfHUD.If you find that SetTexture/DrawPrimitive calls are what's slowing you down, you should try grouping multiple tiles onto a single texture. This will allow ID3DXSprite to batch multiple sprites into a single SetTexture/DrawPrimitive call.   ;  I ran some tests with PIX and it seems I have about 3000 SetTexture calls per frame when using 1920x1200 resolution. I'm pretty sure that's what is slowing me down.Grouping tiles onto a single texture sounds like an interesting idea. Which methods should I look in to to achieve this?   