Jump to content
  • Advertisement
Sign in to follow this  
JoshuaBaker

Device Lost Issues in SlimDX

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Iv got some VERY simple code here...

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using SlimDX;
using SlimDX.Direct3D9;
using SlimDX.Windows;
namespace MiniTri {
static class Program {
[STAThread]
static void Main() {
Direct3D direct3d = new Direct3D();

RenderForm form = new RenderForm("DX9 Test");
form.ClientSize = new Size(800, 600);
form.TopMost = true;
form.FormBorderStyle = FormBorderStyle.None;
PresentParameters presentparameters = new PresentParameters();
presentparameters.BackBufferWidth = 800;
presentparameters.BackBufferHeight = 600;
presentparameters.Windowed = false;
presentparameters.BackBufferFormat = Format.X8R8G8B8;
Device device = new Device(direct3d, 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, presentparameters);
MessagePump.Run(form, () => {
device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
device.Present();
});

foreach (var item in ObjectTable.Objects)
item.Dispose();
}
}
}


It should simply make a fullscreen DX9 application. Yet on my PC i get continual device Lost errors. Iv stripped out everything to the bare minimum and still it crashes with device lost. I get the feeling it might be my dual monitors, as the code seemed ok on my laptop, but i'm not sure how to deal with that.

Share this post


Link to post
Share on other sites
Advertisement
You need to handle the device lost exception, and reset the device after freeing up all resources that aren't in the managed pool. You can then recreate those resources again after the reset.

Something like what's done in this sample code (search for "lost") http://code.google.com/p/slimdx/source/browse/trunk/samples/SampleFramework/Sample.cs

Share this post


Link to post
Share on other sites
Thanks!

I had tried that before, but i likely was handling it wrong. Using the format from the sample it seems to work. Any insight into why its ok on a single monitor? My laptop handled it just fine.

Share this post


Link to post
Share on other sites
One obvious possibility is that on Vista/7 less things will cause you to lose the device than under XP. Are both computers running the same OS?

To force a lost device on Vista/7 the simplest option is to press control-alt-del and then cancel it.

It doesn't really matter though - all DX9 programs need to be able to handle a lost device at any time. You can only avoid that requirement by dropping XP support and using D3D9Ex or D3D11.

Share this post


Link to post
Share on other sites
Both run Win7. I knew i would lose the device on a at tab or anythign that would minimize the fullscreen window so i expected that. This is getting a device lost immediately after running the program, which was odd. At times i could actually see things render for a frame, then it would immediately get device lost.

Share this post


Link to post
Share on other sites
So while my code TECHNICALLY works, its working in a bad way. The very first time i call present, i WILL get a device lost on my two monitor setup. This seems like an issue as no matter what, my first frame is always lost and i will have to reset everything...which can't be a good thing in a larger application. there must be something odd going on here.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!