Sign in to follow this  

[D3D9] Low FPS with 2 Texture Stages (200 Triangles)

This topic is 2393 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

I have been working on a basic terrain for my program, it is currently only a 10x10 grid of quads. When I use only a base texture for each quad the program runs fine at 60fps, but when I use a 2nd texture stage(Detail Texture) my program slows down to a crawl at 25fps. I can't seem to figure out why using 2 texture stage states is giving me so much of a slow down with only 200 triangles being rendered.

At first I was just using a loop to draw each individual quad, reading around everyone was saying that is a bad idea so I put them all in a VertexBuffer and draw it in one call now, still same problem.

I did also have my SetTexture command at the begining of the render loop which I moved outside the loop as well which didnt help.

I went around changing all sorts of settings trying to see if something just wasnt set up right and nothing has worked. The only thing that has any effect is disabling the 2nd texture stage and only using the base texture. The only thing in my loop is updating the camera position and the 1 draw call, everything else is done at the begining befor the program enters the loop.

Does anyone have any ideas to why this is happening? I've searched around for the past week trying to find an answer with no luck.

Share this post


Link to post
Share on other sites
Uhm, I have no idea.
But if disabling a texture makes the problem go away, I'd look in that direction. Perhaps the texture is not well formed. If you're using the debug binaries, a run in PIX will help. Maybe it's an unsupported format.
I suppose you're using fixed function pipeline?

Share this post


Link to post
Share on other sites
@Krohm: Thank you, I wasn't aware that program was there, Been messing around with it to see if I can figure anything out. So far nothing seems out of sorts that I can see. As to the format, I am just using basic .BMP images for testing this out, the 2nd Texture is the same format as the Base Texture. Yes, Using the FFP.

@Moe: Sorry forgot to say that, they are 256x256 each. Once this problem is sorted out I do plan to have an Image Sheet for each stage to cut back on texture usage. For now just using 1 "Tile" for each stage.

Share this post


Link to post
Share on other sites
Personally I would start by investigating why you're only getting 60fps when only rendering 200 triangles with a simple texture.
Also the drop from 60 to 25 doesn't seem that strange, a drop from 60 to 25 means you've a little more than doubled you're frametime. If the only thing you're rendering is 200 triangles with a texture and now you've added a detail texture to all of them it seems reasonable to double the frametime if you were already limited by pixel processing or texture sampling. I assume you're using fixed function?
Like I said I would start by figuring out why you're only getting 60 in the original case.

Share this post


Link to post
Share on other sites
60 FPS suggests vsync (D3DPRESENT_INTERVAL_ONE or _DEFAULT) so try switching to D3DPRESENT_INTERVAL_IMMEDIATE and re-time your program - profiling with vsync enabled is a total waste of time, as it's not going to give you any kind of useful or meaningful data.

You can easily drag a renderer to it's knees with a 256x256 texture - just set up your uv coords so that the texture is really really really small when sampled and you'll get there. So that's my best guess for what's happening; you say that you're using it as a detail texture and I'm betting that your texture coords for that stage are significantly larger than those for stage 0.

Share this post


Link to post
Share on other sites
@pekarn: The reason it is only getting 60fps is because of the refresh rate of my monitor and have it set to draw with the vsync. I Hadn't thought of it that way though, I was thinking maybe losing 5-10fps at the most.

@mhagain: Correct, I have it set to match the vsync, but I thought if I didn't it would cause screen tearing? I'll try turning it off and see what happens. I wasn't aware that a 256x256 texture was large, Always thought that was kind of small since most textures I see are in the area of 512x512 or 1024x1024, I'll try resizing it to 128x128 and see if it helps. My texture UV cords are the same in both stages, topleft is (u0.0,v0.0) and bottom right is (u1.0,v1.0) for each quad segment.

Thank you both for your comments.

Share this post


Link to post
Share on other sites
Well 256x256 ain't large, but the important thing is how you use it. You could for example draw a 4096x4096 texture on geometry who's extents are 4096x4096 and have good performance. You could tile a 256x256 texture on it 16 times in each dimension and it will probably be faster. You could tile the same 256x256 texture 1024 times in each dimension and it will be much slower. As you're using the same coords for each stage that's not relevant here.

Regarding vsync, if correctness is important then by all means use it for production code, but when profiling to find bottlenecks you most definitely want it disabled.

Share this post


Link to post
Share on other sites
Problem was the texture size, Very big improvement scaling them down to 128x128. With vsync getting 60fps, without vsync getting 130fps with a 50x50 grid now (5000 triangles). Wish I would of tried that a week ago befor trying to change everything in the code.

Thank you all for your help.

Share this post


Link to post
Share on other sites
[quote name='PilzburyX' timestamp='1306508615' post='4816450']
Problem was the texture size, Very big improvement scaling them down to 128x128. With vsync getting 60fps, without vsync getting 130fps with a 50x50 grid now (5000 triangles). Wish I would of tried that a week ago befor trying to change everything in the code.

Thank you all for your help.
[/quote]
That still seems pretty odd that it killed performance so readily. What sort of hardware is it running on?

Share this post


Link to post
Share on other sites
[quote name='Moe' timestamp='1306522494' post='4816522']
[quote name='PilzburyX' timestamp='1306508615' post='4816450']
Problem was the texture size, Very big improvement scaling them down to 128x128. With vsync getting 60fps, without vsync getting 130fps with a 50x50 grid now (5000 triangles). Wish I would of tried that a week ago befor trying to change everything in the code.

Thank you all for your help.
[/quote]
That still seems pretty odd that it killed performance so readily. What sort of hardware is it running on?
[/quote]




Do you think it was a cache-coherency issue? If you had the 256x256 textures with a single mip level, and if the pixel area for the geometry was smaller than the texture size (one pixel covers less than one texel), you would get that. I'm not sure if it would kill the framerate that much though.

Share this post


Link to post
Share on other sites
It does seem a bit odd, but I think is has to do with what gsamour is saying. Each quad segment is only 1.0 x 1.0 units so trying to shrink a 256x256 image onto each segment seems to be what was eating up the framerate. Just scaled down again to 64x64 and getting 160 fps now. In my previous tests I wasn't getting enough texture detail so I started using 256x256 textures, now with even smaller textures than I was using with the original test getting plenty of detail. Thank you all once again.

Share this post


Link to post
Share on other sites

This topic is 2393 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this