Really weird performance problem with Direct3D

Started by
14 comments, last by Marc aka Foddex 20 years ago
Hi all. I have a very weird problem with Direct3D (using DirectX 7). My program loop - simplified - looks like this: while (loop) { render_some_test_stuff(); do_some_other_stuff(); Sleep(10); frame++; } This results in a framerate of 100. At least, the loop shown above is executed 100 times per second. I do not *see* 100 frames each second though! Instead it looks more like 10 FPS. If I remove the call to Sleep, the loop is executed more than a few thousand times per second, but the ''visible frame rate'' drops to 2 to 3 frames per second... this is so weird, I''m totally clueless. My only guess is that it has got something to do with swapping between buffers or something? You can find my test program here (virus/trojan free AFAIK, plz report if it''s infected!): http://130.89.227.64/foddex/test.zip At program start you can specify if you want the OpenGL or the Direct3D implementation (my render engine needs to support both). The OpenGL implementation uses VSYNC and shows a very smooth scene (on my GeForce 4 440 Go), the Direct3D implementation is kinda crappy. Test it yourself to see what I''m talking about. Does anyone have any idea what this problem can be? Thanks in advance! Marc
Advertisement
This won''t help you but I also had this problem. I haven''t worked through it yet (I''m just a hobbiest with limited time and a bad computer) but I wanted to let you know that it''s not just you.

Not to distract from Mark''s problem but my code was a simple loop that just drew a square that I moved by changing the world transform. If I had the loop setup for ~10 iterations I''d only see the first and last frames. If I set it up for 1000 iteration then I''d actually see the square move around.

I''m wondering if it has something to do with the presentation interval / refresh rate settings (I just used the default).



"Good code will come and go, but bad code sticks around."
"Good code will come and go, but bad code sticks around."
Are you handling Windows messages in your loop? Windows hates you if you don''t.

That''s my first thought.

I like pie.
[sub]My spoon is too big.[/sub]
quote:Original post by RenderTarget
Are you handling Windows messages in your loop? Windows hates you if you don''t.

That''s my first thought.

I like pie.


Yeah I do handle them: WM_ACTIVATE, WM_CLOSE, WM_QUIT, WM_KEY*, WM_MOUSE*, WM_MOVE, WM_SYSCOMMAND. Did I miss one maybe?
In my comp. at the office it seems the same fps in gl a d3d.

What''s your OS ?

quote:Original post by EverIce
In my comp. at the office it seems the same fps in gl a d3d.

What''s your OS ?



Hmm I run my program on my laptop: Windows 2000, P4 1.6 Ghz, GeForce 4 440 Go. I bet you have way faster hardware than that, aren''t you? Because I tested it on my other PC after your post, a P4 2.67 Ghz with a Radeon 9800 Pro 256 MB, and it seems to run way better on that one...

But it cannot be a video-card performance issue, since both cards can do the Far Cry demo and my program only shows 4 triangles
You won''t believe it. win2000 1.3Cel, 128mb, 4Mb integrated IBM video card ! 68 Fps !

It''s getting more weird.
quote:Original post by EverIce
You won''t believe it. win2000 1.3Cel, 128mb, 4Mb integrated IBM video card ! 68 Fps !

It''s getting more weird.


Weird .... :S

Well I''ve decided to put some code online, I''ve been looking at this code for days now and I''m not getting anywhere. Maybe if someone else can take a quick look at it, he or she could find the problem?

The Direct3D implementation of my abstract renderer class is located here:

http://130.89.227.64/foddex/test/renderer_direct3d.cpp
http://130.89.227.64/foddex/test/renderer_direct3d.h

To show how I use the renderer engine, I also have the code of my main program online:

http://130.89.227.64/foddex/test/main.cpp

This code cannot be compiled without changing it, since there''s alot of stuff missing that''s not directly related to my problem.

Many thanks in advance to anyone who takes a look at the code!

Marc
Why not remove all the D3D stuff between starting and ending the scene: i.e. don''t set texture states, render states, textures, don''t render anything, don''t set VB''s or IB''s. Can you check yoru FPS.

Could you still check yiour FPS?

Probably not.

Then just try rendering very very basic with no textures, colours etc.

Sorry if you''ve shown that in your posted code but I haven''t had a chance to look at that yet.

Good Luck

matt
Hi matt! Thanks for your suggestion, but the big problem is: there's almost nothing to remove I do nothing fancy, no special vertex buffers, I'm setting hardly any renderstates. Just 2 triangles and a quad... (i'm still in my Direct3D testing-phase )
So I guess it's not so much a video-card performance issue, but more something I do wrong in Direct3D

By the way, can I use D3DX and 'normal' D3D stuff together? None of the MS-SDK examples do it, but I don't know if it's a bad thing

Marc

[edited by - Marc aka Foddex on March 24, 2004 10:35:35 AM]

[edited by - Marc aka Foddex on March 24, 2004 10:35:46 AM]

This topic is closed to new replies.

Advertisement