Lags in basic apps with D3D

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

Recommended Posts

Hello, I am quite new to DirectX, using DirectX March 2008 with C++. I have started on "2D" project first (actually it is 3D, but its plane with zero z-coordinates) - Arkanoid - using manually vertex (and index) buffer. Now i have started 2nd project in 3D, using D3DXMesh (loaded from x-file). Both projects have the same serious problems - strange lags (on some pcs, on some the lags will appear if you start the application two times or more). Don't know what i have missed. Maybe some settings with D3D or wrong timing? I'll try to little describe my code (I could upload whole VS solution, if it helps). 1) setting D3DPRESENT_PARAMETERS

ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

2) setting Render-state
    // Turn on the zbuffer
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
// Turn on ambient lighting
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );

3) Arkanoid: Filling vertex and index buffer (few quads) / 2nd project: Loading 3 very basic models 4) Rendering: a) timing (originally different, now from article on gamedev - didn't help):
	do{
g_dwFrameEndTime = timeGetTime();
} while (g_dwFrameStartTime==g_dwFrameEndTime);
g_dwFrameTime = g_dwFrameEndTime - g_dwFrameStartTime;
g_dwFrameStartTime = g_dwFrameEndTime;

b) setting coords of objects (speed * g_dwFrameEndTime/1000.f) c) cleaning buffers, starting scene d) setting view and projection matrices e) setting lights - only in 2nd project f) drawing polygons (DrawIndexedPrimitive / DrawSubset) g) ending scene, Present() method Nothing moves smoothly, don't know what is wrong :-( Even if FPS is high (if not v-syncing), no smooth movement can be seen :-( Thanks. PS: Sorry for my english

Share on other sites
I have decided rather not to wait and uploaded the solution now:

http://fixlujeme.xf.cz/TD7000.zip

Share on other sites
After opening many instances it created huge HDD activity.
When application closes, release all devices, and all possible variables (ex. g_pd3dDevice->Release();) it's freeing up memory. Secondly try to use pointers. When you call code g_oTank.Draw();, it creates copy of g_oTank when processing Draw(), using up extra memory. With pointer it would use only few bytes for pointer data, not the whole memory, increasing overall speed

Share on other sites
I have already had Release() methods in Cleanup() function called on WM_DESTROY.

I have rewritten all 3D objects to be pointers as you suggested and added code to delete them to the Cleanup() function. Also I have created destructor for class Object3D with code:
pMesh->Release();

No change :-(

I have uploaded the new version with these changes and overwritten the original file.

Share on other sites
Ok - I have made new version, using DXUT... still same problem :-(

(I think you need to try it, but not on a modern PC)

If this uses DXUT, it uses its timing.. (i'm using fElapsedTime), so won't be the problem...

So what?

Maybe you won't notice it.. Do you think is there any chance, that elder SDK (like summer 2004) could solve the problem? I have no idea :-(

Thanks.

DXUT version: http://fixlujeme.xf.cz/TD7000DXUT.zip

Share on other sites
Well problem might be that my computer.. Wouldn't call it old, neither new, has support of DirectX 10, but some games don't run well on max settings (with AA and AF off).

I'm not familiar with DXUT to be honest. But it might be doing some useless calculations, even simple if() takes a bit of time, and calling it often might create some delay (felt no lag with over 10m if() calls per second), but not sure how it works on other systems.

This loop in Render() seems bit useless to me
	do{		g_dwFrameEndTime = timeGetTime();	} while (g_dwFrameStartTime==g_dwFrameEndTime);

Also you seem to be calling these two functions everytime you do rendering
		SetupMatrices();		SetupLights();

SetupMatrices seem to set up camera position, try to call it only when camera position is changed (right mouse button clicked or etc), not everytime.
Also you need to set up Lights only once, to enable/disable them, you don't need to recreate them, using extra memory.

Other parts seem to be standard.

Share on other sites
It runs perfectly fine on my PC and I took a look at the code and could see no problems. Is it possibly an old driver issue on your machine or something? Have you tested it on many machines?

Share on other sites
Quote:
 Original post by Ripiz

Nothing of those is in DXUT version (i got the same idea and rewrote it) - no change :-(

Quote:
 Original post by Trip99

I've tested it on a few different machines, I have also tried DX Summer 2004 (now it can be run alomst anywhere), still same lags on those machines :-(Another applications (3D games) runs well on those (WOW for example..., on another even The Doom 3 with quite good details)

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
18
5. 5

• 9
• 12
• 9
• 33
• 13
• Forum Statistics

• Total Topics
632589
• Total Posts
3007241

×

Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!