Sign in to follow this  
dario_ramos

Present fails randomly on C++ Direct3D9 app

Recommended Posts

I have a mixed .NET application (managed and unmanaged code bridged by C++/CLI wrappers) which uses unmanaged Direct3D9 9.0c to do rendering inside a control which is wrapped inside a C++/CLI class which extends System.WIndows.Forns.UserControl.

Everything has been working fine for years now, but I recently put another instance of this Direct3D9 control inside a new Windows Form. That is, I have two concurrent instances of the control. I had done that before and it worked, but now I have issues. Perhaps the problem was always there, but because it's related to a race condition, it started happening now...

Ok, the details: When I try to render an image over a texture on the new instance of the control, sometimes it works, sometimes it doesn't. And when it doesn't, nothing is rendered, and from that point onwards, all Present calls fail (I log those failures). If I close the form and open it again, it might work or not. Nasty.

If I use DXGetErrorString and DXGetErrorDescription, all I get is something like:

EFAILED Undetermined error

Not really helpful... To make matters worse, I can't reproduce the issue in my development environment; I only see it in a production box.

As far as I know, the main reason Present fails like this is a Lost Device. But I implemented the usual scheme to handle that (I can post the code if necessary), and it seems like the device is not being lost... What else can I try?

Share this post


Link to post
Share on other sites
[b]Hi![/b]

Often applications fail randomly on bad pointers. I think you know it...
Maybe you would reinvestigate your code.

The other idea, not enough resources, VideoRAM. etc.
Please consider checking the debug console, also.

Share this post


Link to post
Share on other sites
It sounds possible that it's a hardware / driver issue. I'd try updating the driver on the machine that's failing first. If possible try replacing the graphics card too.

Out of curiosity which card / driver version is causing the problems?

Share this post


Link to post
Share on other sites
[quote name='kubera' timestamp='1335466667' post='4935168']
Often applications fail randomly on bad pointers. I think you know it...
Maybe you would reinvestigate your code.
[/quote]

If that were the case, the app would most surely crash. But it doesn't. Sometimes it renders, sometimes it doesn't. It never crashes. Based on that, I ruled out access violations, undefined behavior, and the like.


[quote name='kubera' timestamp='1335466667' post='4935168']
The other idea, not enough resources, VideoRAM. etc.
Please consider checking the debug console, also.
[/quote]

Same consideration. If resources were running out, the app wouldn't recover, or would stop rendering completely. As for checking the debug output of the runtime, that would be great, but the error only happens in a client's machine where only the Direct3D redistributable is installed. Since we operate it remotely and it's in another country, installing software is a hassle. If there is a way to capture Direct3D debug output without installing anything, I'm all eyes. Anyway, as a last resort, we could install the SDK and PIX... When we get desperate enough :P


[quote name='Adam_42' timestamp='1335469573' post='4935192']
It sounds possible that it's a hardware / driver issue. I'd try updating the driver on the machine that's failing first. If possible try replacing the graphics card too.
[/quote]

Good idea. It'll be quite a hassle, since we'll have to log remotely to the client machine, and maybe ask the operator over there to try changing the card. But I'll give it a shot and post back.

[quote name='Adam_42' timestamp='1335469573' post='4935192']
Out of curiosity which card / driver version is causing the problems?
[/quote]

I'll post this info tomorrow when I log remotely.

Share this post


Link to post
Share on other sites
[quote name='dario_ramos' timestamp='1335473692' post='4935215']
If resources were running out, the app wouldn't recover, or would stop rendering completely.
[/quote]
I am no sure.
I remember an issue on the Intel GPU.
I could not render all textures. The surface become white. After closing a few instances, others started working properly.
(I think that it was done without devices recreation)
The test was made on many instances of the same Direct3D9c app. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

P. S.
I think you are right. Everything should be checked.
Good luck.

Share this post


Link to post
Share on other sites
@[url="http://www.gamedev.net/user/105081-adam_42/"]Adam_42[/url]: It's an [color=#000000][font=arial, sans-serif][size=3]Nvidia quadro NVS 290, drivers version: [/size][/font][/color][color=#000000][font=arial, sans-serif][size=3]6.14.12.7533[/size][/font][/color]
[color=#000000][font=arial, sans-serif][size=3]@Everyone: We made a little change and the error seems to have disappeared. When getting the viewport dimensions, we were using ::GetWindowRect instead of ::GetClientRect. Now that we're using the second function, the error seems to not happen anymore. We came up with this idea when we compared the differences between the client's software version and ours. If the error happens again, I'll try your suggestions, that is, updating graphic drivers first, checking debgu spew later.[/size][/font][/color]

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