Sign in to follow this  
jad_salloum

Managed Directx is too slow could the problem be in the settings ... (Corrected)

Recommended Posts

hi guys i am making a car racing game using c# but i am facing a big problem that is it runs very slow on VGA 128MB and CPU speed 2.8 GHz and 1.0 GB Ram the same game with same graphics was created before by another guy using visual C++ and directx 8.0 it is working on the same PC very Good !!!!!!! so what could be the problem ??? is Managed DirectX slower this much from Unmanaged DirectX or what could be the possible errors i made in my game and what are the things that affect the performance ??? i am simply loading the Stage and the Car .X files and drawing them what more i need to do to maximize the performance ??? [Edited by - jad_salloum on December 3, 2005 3:19:24 AM]

Share this post


Link to post
Share on other sites
Are you utilizing the same D3D optimization techniques as the "another guy"? Also, in managed code, the message pump has to be handled a little differently than in c++ to be of optimal performance.

There could be million different things affecting the performance of your application, so there's no general solution to your problem.

Share this post


Link to post
Share on other sites
no i am not using the same tecnique coz i don't know how he made the game coz i have only the executable for it . can u give some Common or important reasons to test if it is the problem or any recource to check with plzz and thanks alot for ur help

Share this post


Link to post
Share on other sites
Quote:
Original post by Nik02
Are you utilizing the same D3D optimization techniques as the "another guy"? Also, in managed code, the message pump has to be handled a little differently than in c++ to be of optimal performance.

There could be million different things affecting the performance of your application, so there's no general solution to your problem.


Nik,

Can you provide some hints or links that refer to handling input in MDX?

Share this post


Link to post
Share on other sites
Managed DirectX is a fantastic counterpart to the native API and where performance are almost identical. The fact that it's slow gives me a couple of things in mind to look at.
1) What Message loop are you using?
2) What Graphics Card do you have?
3) What kind of things are you using? (Shaders etc...)?
....
There are so questions I could ask and a few of them I can help you to look at.
1) Tom Millers Render loop is what everyone has been looking at and it's really good and efficient.
2) When using a card like the fx5200 and a simple normal mapping shader with specular highlights you could seriously slow down your game to a slow 5 Frames per second. This is not due to bad programming but the lack of speed on the fx5200.

It's all really relative to what you are using and looking at.

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
I was referring to Tom's method, to which Armadon provided the link, when I mentioned the message pump. The Application.DoEvents is bad because it allocates extra memory every time it is called, thus taxing the garbage collector (and causing stalling of the loop) - OnIdle doesn't have this disadvantage.

Share this post


Link to post
Share on other sites

could be the problem in the settings of the device ?? i noticed that in the SDK's they test the device for alot of details like choosing specific configurations for the adapter while i am using the default adapter and flags HardWareVertexProcessing and createFlags.PureDevice .

Share this post


Link to post
Share on other sites
The creation of the device and the present parameters that you create the device with are certainly a scenario to investigate. The width and the height of the backbuffer, the type of device you are creating (ie. Software, Reference, Hardware) also the Creation flags you specify (ie. HardwareVertexProcessing, SoftwareVertexProcessing). This all has an effect on the performance of your application and to gain the most out of your specific hardware alot of tests can be done to assure that you are using the opitimal performance of your graphics card like creating a device with HardwareVertexProcessing and specifying DeviceType.Hardware (the Hardware rasterization. Shading is done with software, hardware, or mixed transform and lighting.)

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
Managed DirectX is virtually the same speed as unmanaged DirectX. Check things like your renderstates, your batching algorithms, culling algorithms, and all that stuff. Fire up PIX and see if you are making any redundant DirectX calls, or doing anything particularly harmful on performance, and find out what's taking up the most of your application's time.

Of course, the performance problem could also be in your game code and not in your graphic's code.

And don't forget the obvious things like using the release versions of DirectX and compiling in release, and not debug mode.

Share this post


Link to post
Share on other sites
Just to chime in here, although .NET frees up a lot of memory problems, you also encounter some issues due to garbage collection (specically when you're dealing with boxing and unboxing). If your problems are memory issues, I'd try running the CLR Profiler. It'll make your game crawl, but you can still get some good info on memory allocation and garbage collection.

Share this post


Link to post
Share on other sites

thanks guys for all that help my game became faster when i used the way that microsoft use to get the best graphics utility in the SDK Samples and i found some errors in my code which increase the memory and i also made the size of the textures smaller

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You're not going to get better performance than Java using Managed DirectX, sorry. They're both compiled with the same goal in mind, and both are JITted in different, but common ways. Never have I seen a good game in Java, so I don't see why it's competitor will have any better advantage, other than some optimization during runtime. To get the best of speed, of course you should be using C++. Where in your code examples have you seen full 3d astonishing environments in C#/Java? There simply isn't any. Why? Because it cannot be done. I would recommend you to learn VC++ 2005 because you can use C++ while still taking advantage of the .NET framework. This can only help improve performance. C# is great for its purposes, but Managed DirectX isn't going anywhere as much as I'd like it to. If you want to use C# still, ignore using several methods and do not use autoboxing/unboxing. They kill performance, and even if you do these things, MS has a ton of this going on in the background. I love sharing good news.

Share this post


Link to post
Share on other sites
Thanks for posting that game loop, I tryed out DirectX with C# for a course a while ago, but I don't think the instructor knew how to set up the game loop properly to get good performance, I couldn't get my demo over 30 fps and there wasn't much going on so I'm gonna have to try implementing that.

Share this post


Link to post
Share on other sites
Quote:
Original post by algorhythmic
I'm using the Miller approach for my windowed dx app but it uses 95% cpu even when minimized and with the entire game loop commented out. What to do???
Cheers


Miller approach from which book ? i modified the SDK samples way and i am using it to create the best device and till now it is good and u feel ur game more relaxed with these settings

Share this post


Link to post
Share on other sites

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