Archived

This topic is now archived and is closed to further replies.

red_sodium

Sprite rapid slowdown

Recommended Posts

Hey GDers, I have two sets of tiles being rendered on-screen. When just one set is rendered, my frame rate is fine (~80 FPS) but when I render any number of tiles from both sets on screen, it drops to less than 1 FPS. I am using ID3DXSprite for my sprites, and the tile sets share one common (small, power-of-two''d) texture each. As soon as I move my viewing frustrum to include both in my view, the frame rate drops and the game essentially freezes. I am quite sure it is the ID3DXSprite::Draw method where the dramatic slowdown occurs but I''m not sure why. Even if just one tile from the other set is shown on screen while the main tile set is on the screen, the frame rate drops. Surely there can''t be many things which cause this. It could be memory related but I''m not sure, I''m quite sure it won''t just be a local machine/memory problem though. Thanks Stay Clausal, Red Sodium

Share this post


Link to post
Share on other sites
To rule out the system-related error possibility, put the source up somewhere so we can try it.

ID3DXSprite is efficient because it batches everything passed to it through Draw(). At this stage, it just appends the vertices and transforms them through software algorithms. It actually only sends the data to the GPU when you call End().

So, could it be something with the two tiles sharing the same texture? I doubt it, but it''s possible. You could try calling ID3DXSprite::Flush() in between the two tile Draw() calls. This will force all the batched sprites to be submitted to the device.

Also, what graphics card do you have, and what drivers are you using?


Dustin Franklin
Mircrosoft DirectX MVP

Share this post


Link to post
Share on other sites
The Flush() idea didn''t work.

I am using a nVidia TNT2 card, with nVidia drivers.

It''s a very weird problem as it appears to be temperamental, which makes debugging by deduction that little bit harder. It also appears to happen with any texture. As for posting source code, I''ll need to try and isolate the problem area because there is quite a lot of code.

Thanks for your help so far.

Red Sodium

Share this post


Link to post
Share on other sites
Just one, and here's some parts of the code that may help:

(Call to Sprite::Render() is on line 37)
Inside main Render() function

Sprite class member functions Transformations() and Render()

Thanks for yor help.

Red Sodium
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life. - Terry Pratchett

[edited by - red_sodium on May 30, 2004 1:47:21 PM]

Share this post


Link to post
Share on other sites
Okay, I''ve managed to narrow it down to two factors:

-Where I create my texture
-If I initialize sounds or not

Sound class code

If I don''t create any sound buffers, I get no problems. But I have no idea why not: textures and sounds are not connected in any way, and I''m not even playing these sounds at all, just initializing them. It doesn''t appear to be related to a single instance of the Sound object, but any Sound object I create.

Red Sodium
Build a man a fire, and he''ll be warm for a day. Set a man on fire, and he''ll be warm for the rest of his life. - Terry Pratchett

Share this post


Link to post
Share on other sites
Oh yeah, I should mention that if i create my texture *before* I initialize my Sound (one object per sound, btw), I get no problems. But if I create afterwards, the 1-2 FPS problem.

It only appears to happen with my wall textures and not my tile textures.

The only thing I can think of at the moment is a memory problem, but that would give an access violation and NOT a very slow framerate.

Red Sodium
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life. - Terry Pratchett

[edited by - red_sodium on May 30, 2004 4:47:56 PM]

Share this post


Link to post
Share on other sites
As a test try setting your soundcard hardware acceleration to off. I have heard of a problem not unrelated to yours in the past which was due to this - don''t know why though

Share this post


Link to post
Share on other sites
quote:
Original post by Trip99
As a test try setting your soundcard hardware acceleration to off. I have heard of a problem not unrelated to yours in the past which was due to this - don''t know why though


Thanks for the tip but it didn''t make a difference.

Tonight I''ll try to deduct what the problem is. Unfortunately, I have another problem where I get an access violation from the sound buffer creation function when I unfocus my window while it is initializing the sound class (and therefore buffers). I don''t know if they''re related, but I''ll have to try and solve both problems. Any more ideas, anyone?


Red Sodium
Build a man a fire, and he''ll be warm for a day. Set a man on fire, and he''ll be warm for the rest of his life. - Terry Pratchett

Share this post


Link to post
Share on other sites
Okay, I've found the LINE of the problem:

The problem (in context)


free( pWavData );


I still don't know why, because I don't even understand how "free()" works, I would've thought that I would have to pass it a size to free. Come on, this must be very easy now, anyone?

Red Sodium
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life. - Terry Pratchett

[edited by - red_sodium on May 30, 2004 8:25:53 PM]

Share this post


Link to post
Share on other sites