• Advertisement
Sign in to follow this  

ID3DXSprite Performace...

This topic is 4588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello everybody Im writeing a small 2d game using the ID3DXSprite interface. I was told that this interface is highly optimized, so i tried pushing 10000 sprites to the screen simultaneously. All the sprites used the same texture (of the size 16x16) and no alphablending. Yet i only get ~10fps. Is this normal? I mean thats only 20000 tris in the scene. In the DX sample "Enhanced mesh" i have 250000 tris in the scene at 40fps. And that sample uses lighting as well. Why is my program so slow? Im using a std::list to store the sprites, but that really shouldnt matter. //Emil

Share this post


Link to post
Share on other sites
Advertisement
The number of triangles shouldn't be the problem. How big are your sprites? (How much space do they occupy on the screen?)
It is highly probable that your application is fillrate-limited right now. You could try to move the sprites outside your canvas in order to verify my guess. (If the frame rate raises drastically I was right ;) )

[edit] Sorry, I read over the passage where you mentioned the size.
Which graphic card do you use?

Share this post


Link to post
Share on other sites
hello cannonicus.

I've suffered the same problem lately.

I did some testing:

I made a program that used the ID3DXSprite to draw 2000 sprites on the screen. The sprites were drawn using the same 256x256 full color texture and were drawn repeatedly from a simple for-loop between Begin and End. I used 0 as parameter to Begin. From this I got an fps around 10.

Then I suspected that the sprites werent batched properly by texture so I used D3DXSPRITE_SORT_TEXTURE as parameter to Begin and ran it again. Once again I got an fps around 10. So, either the sprites were batched by texture both of the times or they were not batched at all (contrary to what the docs said).

To see whether the sprites were being batched at all I added a call to ID3DXSprite::Flush() after every call to ID3DXSprite::Draw() in the for-loop. If the sprites were being batched the first two times then the fps would drop hevily in this case, since it would mean a DrawPrimitive-call at every single sprite. To my surprise I got the same fps as before, around 10 (with the slight drop that 2000 extra method calls would convey).

So either I have missed something crucial or the docs are lying about the sprites being batched. I did look over my fps calculation and there was nothing wrong with it. Or perhaps I have to do something extra to enable the batching.

Any thoughts?

Share this post


Link to post
Share on other sites
A few things:
1 - Are you using DX9? The sprite interface was highly enhanced only in DX9, so the DX8 one shouldn't be as fast.

2 - You're calling Sprite->Begin only once, right?

3 - Which GPU do you have? 10000 sprites * 16 pixels high * 16 pixels wide = 2560000 . Thats 2.56 MPixels. If you multiply that by 10 (FPS) you get 25.6 MP. My FX5200 is rated at 1000MP, but I doubt it can really do that. This might be reaching you card's fill rate.

Share this post


Link to post
Share on other sites
ok,

Slimtimmy:

The space occupied on the screen varies because i use the D3DXSPRITE_OBJECTSPACE flag. However i couldnt detect any significant increas of fps when i "looked" away from the sprites.
Im using a FX5600 on this computor. I don know the exact fillrate on this modell.

Staaf:

I tested to Flush() after different numbers of sprites too. I got the same result as you. So either were missing something important or the sprite interface isnt really that good?

Sirob:

1. yes im using dx9 june 2005 update.

2. yes, once per frame

3. im using a FX5600. as said above i dont know its fillrate, but it should be higher then 1000MPixel


Are there more people out there who have tested to render big quantities of sprites and either can confirm or counter staafs and mine results?

Edit:

Ive also tested to change the texture size to 64x64 and 4x4 instead of 16x16. I get the same framerate each time. This suggests that fillrate isnt the problem right?

[Edited by - cannonicus on July 30, 2005 11:09:01 AM]

Share this post


Link to post
Share on other sites
I did some more testing. Here is a summary of the results. All of the tests draw 2000 sprites in the top left corner of the screen.

#1 - 256x256 texture, drawn with ID3DXSprite as intended by the docs.
FPS: 10

#2 - 256x256 texture, drawn manually with a small vertex buffer filled with six vertices. No vertex transformation. 2000 DrawPrimitive calls.
FPS: 10

#3 - 256x256 texture, drawn manually with a vertex buffer filled with 12000 vertices. No vertex transformation. Only one DrawPrimitive call.
FPS: 10

#4 - 16x16 texture, drawn with ID3DXSprite as intended by the docs.
FPS: 190

#5 - 16x16 texture, drawn manually with a small vertex buffer filled with six vertices. No vertex transformation. 2000 DrawPrimitive calls.
FPS: 400

#6 - 16x16 texture, drawn manually with a vertex buffer filled with 12000 vertices. No vertex transformation. Only one DrawPrimitive call.
FPS: 1070

Conclusion: The 256x256 sprites probably all suffered from the maximum fillrate of the GPU as suggested by sirob. Otherwise test 1-3 wouldn't have produced the same FPS.

Note that the technique of tests 3 and 6 doesn't work in practice (AFAIK). I only included it for reference.

I find it interesting that ID3DXSprite in test 4 performs barely half as good as the manual DrawPrimitive method in test 5. I draw all the sprites in separate DrawPrimitive calls and still perform twice as good as ID3DXSprite.

I'll have to do some more diverse testing on those two techniques in various situations before I can rule any one of them out, but I must admit that I didn't expect this result.

Thoughts?

Share this post


Link to post
Share on other sites
Arg! Hold on! I just realized that tests 1 and 4 were run with a Flush call at every sprite. No wonder it performed so badly. Updated version:

#4 - 16x16 texture, drawn with ID3DXSprite as intended by the docs.
FPS: 480

That's more of what I expected. Well so much for that conclusion...[grin]

Test 1 still runs at 10 fps though...

Share this post


Link to post
Share on other sites
Quote:
Original post by staaf
Arg! Hold on! I just realized that tests 1 and 4 were run with a Flush call at every sprite. No wonder it performed so badly. Updated version:

#4 - 16x16 texture, drawn with ID3DXSprite as intended by the docs.
FPS: 480

That's more of what I expected. Well so much for that conclusion...[grin]

Test 1 still runs at 10 fps though...


Well, 480 is a good FPS for that kind of program.

As for the 256 x 256 textures:

256 height * 256 width * 2000 sprites * 10 FPS is 1310720000. Or 1.3 GPixels. Quite surprisingly, an FX 5600 does 1.3GPixels. So, you're pushing out the most you can with your card, no doubt there. I'd suggest you order the sprites from front to back (unless you're using alphablending or testing). This would let the z-buffer cut out some of the pixels (you're overdrawing at the moment).

Good luck :).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement