Sign in to follow this  

SlimDX problem with full screen at lower resolution

This topic is 3109 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

I'm porting my apps from MDX to SlimDX, and I've got resizing and toggling to full screen working nicely, but only if I set the back buffer resolution to the monitor's max resolution when going to full screen. If I try to operate in full screen mode at a lower resolution to keep the frame-rate up, I run into problems. When I try that I can: 1. Toggle back and forth between windowed and full screen all day long, though toggling is extremely slow, or 2. resize the windowed app all day long, or 3. toggle back and forth between windowed and full screen, then resize the window. But, once I resize the windowed app, the next time I try to toggle to full screen, I get that unhandled exception on device.Reset(). To isolate this I've stripped the app down so it's doing nothing. And I mean nothing. I'm not rendering anything. I don't create any DirectX resources. The only thing I do is clear the back buffer then do an empty render and Present(). I've set up WindowPlacement structures for both the windowed mode and the full screen mode and I initialize the full screen placement structure to: fullscreenPlacement.length = WindowPlacement.Length; fullscreenPlacement.flags = 0; fullscreenPlacement.showCmd = SW_SHOWNORMAL; fullscreenPlacement.ptMaxPosition = new Point(-1, -1); fullscreenPlacement.ptMinPosition = new Point(-1, -1); fullscreenPlacement.rcNormalPosition.left = 0; fullscreenPlacement.rcNormalPosition.top = 0; I hook the Window_Resize event where I do the following: private void ResetDevice() { OnDeviceLost(); Result r = device.Reset(presentParams); //createParams = device.CreationParameters; OnDeviceReset(); } private void Window_Resize(object sender, System.EventArgs e) { presentParams.BackBufferWidth = Window.ClientRectangle.Width; presentParams.BackBufferHeight = Window.ClientRectangle.Height; ResetDevice(); } Right now the OnDeviceLost and OnDeviceReset methods are empty except for resetting the camera's aspect ration to the new value. And the ToggleFullScreen method looks like this: private void ToggleFullScreen() { if (presentParams.Windowed) { //Going FullScreen so save the windowed style and placement windowedstyle = GetWindowLong(Window.Handle, GWL_style); windowedPlacement.length = WindowPlacement.Length; GetWindowPlacement(Window.Handle, ref windowedPlacement); windowedWidth = presentParams.BackBufferWidth; windowedHeight = presentParams.BackBufferHeight; //Set the BackBuffer W & H to the screen W & H int screenWidth = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width; int screenHeight = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height; presentParams.BackBufferWidth = screenWidth; presentParams.BackBufferHeight = screenHeight; } else { presentParams.BackBufferWidth = windowedWidth; presentParams.BackBufferHeight = windowedHeight; } presentParams.Windowed = !presentParams.Windowed; ResetDevice(); if (presentParams.Windowed) { //Going windowed so restore the windowed style and placement SetWindowLong(Window.Handle, GWL_style, (uint)windowedstyle); SetWindowPlacement(Window.Handle, ref windowedPlacement); Window.TopMost = windowedTopMost; } else { //Going fullscreen so set a style and placement compatable with fullscreen int screenWidth = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width; int screenHeight = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height; SetWindowLong(Window.Handle, GWL_style, (uint)(WS_POPUP | WS_SYSMENU)); //now set the remaining parameters in fullscreenPlacement fullscreenPlacement.rcNormalPosition.right = presentParams.BackBufferWidth; fullscreenPlacement.rcNormalPosition.bottom = presentParams.BackBufferHeight; SetWindowPlacement(Window.Handle, ref fullscreenPlacement); } } Everything works fine in the above code until I comment out the four lines that set the BackBuffer W & H to the screen W & H. Then I run into trouble. Anyone got any ideas?

Share this post


Link to post
Share on other sites
In the ResetDevice method on the call to device.Reset it's throwing the unhandled exception D3DERR_INVALIDCALL (-2005530516) with no useful information. I've got the Degug Runtime turned on, but I'm using C# 2008 Express and I'm told that it doesn't provide much useful stuff.

Any suggestions.

Share this post


Link to post
Share on other sites
Actually I've the same problem, if i set the backbuffert width/height to e.g 1200x800 I get an exception, and in the outputwindow there is the following output:

Direct3D9: (ERROR) :Display mode is unsupported
Direct3D9: (ERROR) :Display mode is unsupported
Direct3D9: (ERROR) :Display mode is unsupported
Direct3D9: (ERROR) :Display mode is unsupported
Direct3D9: (ERROR) :Unable to set the new mode. CreateDevice/Reset Fails
Direct3D9: (ERROR) :ResetEx failed and ResetEx/TestCooperativeLevel/Release are the only legal APIs to be called subsequently
D3D9 Helper: IDirect3DDevice9::Reset failed: D3DERR_INVALIDCALL
A first chance exception of type 'SlimDX.Direct3D9.Direct3D9Exception' occurred in SlimDX.dll
An unhandled exception of type 'SlimDX.Direct3D9.Direct3D9Exception' occurred in SlimDX.dll

Additional information: D3DERR_INVALIDCALL: Invalid call (-2005530516)

But some sizes work in fullscreen, for example: 800x600, 1920x1200

regards,
Kevin

Share this post


Link to post
Share on other sites
My screen native resolution is 1280x1024. No problems when I go full screen at native resolution, but going full screen at 1024x768 or 800x600 throws the exception.

I'll download DebugView and give it a try.

Share this post


Link to post
Share on other sites
Sorry to dump so much info, but here is the DebugView output:

This was generated by startup:

[5680] Direct3D9: :====> ENTER: DLLMAIN(0489e6e0): Process Attach: 00001630, tid=00001720
[5680]
[5680] Direct3D9: :====> EXIT: DLLMAIN(0489e6e0): Process Attach: 00001630
[5680]
[5680] Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
[5680]
[5680] Direct3D9: (INFO) :======================= Hal HWVP device selected
[5680]
[5680] Direct3D9: (INFO) :HalDevice Driver style 9
[5680]
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.

This was generated when I toggled to fullscreen and back:

[5680] Direct3D9: :Subclassing window 00120552
[5680]
[5680] Direct3D9: :StartExclusiveMode
[5680]
[5680] Direct3D9: :WM_DISPLAYCHANGE: 800x600x32
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :Window 00030040 is on top of us!!
[5680]
[5680] Direct3D9: :Window 00030040 is on top of us!!
[5680]
[5680] Direct3D9: :Window 00030040 is on top of us!!
[5680]
[5680] Direct3D9: :Window 00030040 is on top of us!!
[5680]
[5680] Direct3D9: :Window 00030040 is on top of us!!
[5680]
[5680] Direct3D9: :Window 00030040 is on top of us!!
[5680]
[5680] Direct3D9: :Window 00030040 is on top of us!!
[5680]
[5680] Direct3D9: :Window 00030040 is on top of us!!
[5680]
[5680] Direct3D9: :StartExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] Direct3D9: :INACTIVE: 00001630: Restoring original mode (1280x1024x22x75) at adapter index 0
[5680]
[5680] Direct3D9: :WM_DISPLAYCHANGE: 1280x1024x32
[5680]
[5680] Direct3D9: :Unsubclassing window 00120552
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.

This was generated when I resized the windowed app:

[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.

This was generated when I again tried to toggle to fullscreen:

[5680] Direct3D9: :Subclassing window 00120552
[5680]
[5680] Direct3D9: :StartExclusiveMode
[5680]
[5680] Direct3D9: (ERROR) :The specified mode is unsupported. CreateDevice/Reset Fails
[5680]
[5680] Direct3D9: (ERROR) :Unable to set the new mode. CreateDevice/Reset Fails
[5680]
[5680] Direct3D9: (ERROR) :Reset failed and Reset/TestCooperativeLevel/Release are the only legal APIs to be called subsequently
[5680]
[5680] Direct3D9: :DoneExclusiveMode
[5680]
[5680] Direct3D9: :INACTIVE: 00001630: Restoring original mode (1280x1024x22x75) at adapter index 0
[5680]
[5680] Direct3D9: :Unsubclassing window 00120552
[5680]
[5680] D3D9 Helper: IDirect3DDevice9::Reset failed: D3DERR_INVALIDCALL

At this point the app threw the exception and I killed it.

Share this post


Link to post
Share on other sites
What is the full display mode (including bitdepth and refresh rate) that you're attempting to set, and did you check to see if the adapter supports that. The error message you are getting is suggesting that you're not properly setting one of the parameters, or that you're attempting to set a format that is not supported by the adapter.

Share this post


Link to post
Share on other sites
Washu:

I don't think that's the problem. My Adapter is an NVidia GeForce 8800 GT with 512KB of memory. All I'm trying to do is to set it to 1024x768 or 800x600 at full screen, X8R8G8B8 format, which I know it supports since I can set my desktop to that, and I've done plenty of gaming at those resolutions.

No, I think it's something a bit more hinky.

Jim

Share this post


Link to post
Share on other sites
You know, I had a similar issue about a month ago too. Honestly it did eventually work but I really never did figure out why.

After giving up on full screen for a while I decided to let off some steam by working on enumerator for the possible valid settings. It ended up defaulting to the best enumerated match of the desired setting rather than simply hard coding something that was 'supposed' to work. Then it stopped crashing. I never really had the time to go back and figure out why it worked though. More than likely it was probably some other setting I just forgot about though and the automated enumeration did it for me.

Share this post


Link to post
Share on other sites
Don't forget that setting any of the present parameters wrong can break it. Depth/stencil, multisampling, refresh rate, etc are all candidates.

Share this post


Link to post
Share on other sites
I figured it out. Promit, thanks for the hint.

I set up the app to start in a standard resolution (1024x768 or 800x600) windowed. As long as I didn't resize the window, when I toggled back and forth to fullscreen, it went to fullscreen at one of those standard resolutions. But after resizing the window, it's BackBuffer Width and Height are at some odd resolution (like 814x403) that the adapter doesn't support, so when I try to go to fullscreen at that resolution it throws the exception. The solution was to override the windowed resolution and set it to one of the supported resolutions (something close to the windowed resolution) before going full screen.

Interestingly enough, as a shortcut to enumerating proper PresentParameters I tried using a bit of the SlimDX SampleFramework, just as a quick test. Assuming that "FindValidSettings" would tell me if I was doing anything wrong I did the following to convert from PresentParameters to SampleFramework.DeviceSettings:

SampleFramework.DeviceSettings ds = new SampleFramework.DeviceSettings();
ds.AdapterOrdinal = createParams.AdapterOrdinal;
ds.BackBufferCount = presentParams.BackBufferCount;
ds.BackBufferFormat = presentParams.BackBufferFormat;
ds.BackBufferHeight = presentParams.BackBufferHeight;
ds.BackBufferWidth = presentParams.BackBufferWidth;
ds.DepthStencilFormat = presentParams.AutoDepthStencilFormat;
ds.DeviceType = createParams.DeviceType;
ds.EnableVSync = presentParams.PresentationInterval != PresentInterval.Immediate;
ds.MultisampleQuality = presentParams.MultisampleQuality;
ds.MultisampleType = presentParams.Multisample;
ds.RefreshRate = presentParams.FullScreenRefreshRateInHertz;
ds.Windowed = false;
ds = SampleFramework.DeviceSettings.FindValidSettings(ds);

However, even at an odd BackBuffer WidthxHeight of 814x403, "FindValidSettings" didn't make any changes and it still threw the exception.

Maybe one of the SlimDX people can tell me what I was doing wrong.

Thanks to all of you for your input.

Share this post


Link to post
Share on other sites

This topic is 3109 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.

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