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

Started by
10 comments, last by pilzburyx 12 years, 10 months ago
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.

Advertisement
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?

Previously "Krohm"

How big is the texture?
@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.

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.
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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

@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.

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

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.

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.

That still seems pretty odd that it killed performance so readily. What sort of hardware is it running on?

This topic is closed to new replies.

Advertisement