Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Device Lost Issues in SlimDX


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 JWBaker   Members   -  Reputation: 235

Like
0Likes
Like

Posted 21 March 2012 - 02:14 PM

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.

Sponsor:

#2 Adam_42   Crossbones+   -  Reputation: 2574

Like
0Likes
Like

Posted 21 March 2012 - 08:49 PM

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

#3 JWBaker   Members   -  Reputation: 235

Like
0Likes
Like

Posted 21 March 2012 - 09:05 PM

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.

#4 Adam_42   Crossbones+   -  Reputation: 2574

Like
0Likes
Like

Posted 22 March 2012 - 12:03 PM

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.

#5 JWBaker   Members   -  Reputation: 235

Like
0Likes
Like

Posted 22 March 2012 - 12:24 PM

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.

#6 JWBaker   Members   -  Reputation: 235

Like
0Likes
Like

Posted 22 March 2012 - 10:40 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS