Software Support > GroovyMAME

DirectDraw interlace screenmode switching on Win 7

<< < (2/9) > >>

Dr.Venom:
I'm thinking maybe it needs a specific Vista and later enumeration of modes? This is provided by DXGI and there's specific mention of listing interlaced modes:

DXGI Overview: http://msdn.microsoft.com/en-us/library/windows/desktop/hh404534%28v=vs.85%29.aspx

"The first Microsoft Direct3D runtime version to use DXGI is Microsoft Direct3D 10. Windows Vista and later client operating systems support Direct3D 10 and later. Windows Server 2008 and later server operating systems support Microsoft Direct3D 10.1 and later."

IDXGIOutput::GetDisplayModeList method: http://msdn.microsoft.com/en-us/library/windows/desktop/bb174549%28v=vs.85%29.aspx
mentions a specific option to include interlaced modes (DXGI_ENUM_MODES_INTERLACED;).

Shot in the dark, but maybe the information is valuable in some way.

Dr.Venom:
A shot in brighter daylight, maybe?

In the ChangeDisplaySettingsEx function (Windows) documentation http://msdn.microsoft.com/en-us/library/windows/desktop/dd183413%28v=vs.85%29.aspx it says you can use any of the following members of the DEVMODE structure:


--- Quote ---Member                      Meaning
dmBitsPerPel               Bits per pixel
dmPelsWidth               Pixel width
dmPelsHeight              Pixel height
dmDisplayFlags               Mode flags
dmDisplayFrequency     Mode frequency
dmPosition                  Position of the device in a multi-monitor configuration.
--- End quote ---

Looking up the possible flags for dmDisplayFlags in the DEVMODE structure http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565%28v=vs.85%29.aspx, near the bottom of the page it lists the following:


--- Quote ---dmDisplayFlags

Specifies the device's display mode. This member can be a combination of the following values.
   
    Value                           Meaning
    DM_GRAYSCALE             Specifies that the display is a noncolor device. If this flag is not set, color is assumed.
    DM_INTERLACED          Specifies that the display mode is interlaced. If the flag is not set, noninterlaced is assumed.
--- End quote ---

Possibly this DM_INTERLACED flag is not being set in MAME, causing the SetDisplayMode to fail for DirectDraw on interlaced screens?

Calamity:
Hi Dr.Venom,

The thing here is that the IDirectDraw7 interface has remained unchanged for years, and WinUAE seems to be using the same interface as us, and as long as the error happens when calling the SetDisplayMode method, we first should try to find which exact parameters WinUAE is using to invoke this method, then try to replicate the call on our code.

Do you have any experience compiling WinUAE? If only we could add a log right before the SetDisplayMode is called, in od-win32\dxwrap.cpp, HRESULT DirectDraw_SetDisplayMode function:


--- Code: --- getvsyncrate (freq, &dxdata.vblank_skip);
dxdata.vblank_skip_cnt = 0;
write_log (_T("IDirectDraw7_SetDisplayMode(%d,%d,%d,%d)\n"), width, height, bits, freq);
ddrval = IDirectDraw7_SetDisplayMode (dxdata.maindd, width, height, bits, freq, 0);

--- End code ---

Regarding the ChangeDisplaySettingsEx, you could try something else. In Arcade_OSD, try to set an interlaced mode. Instead of pressing "1", press "2", this will enter the menu without setting full screen on, then select "Set as desktop mode". This option invokes the ChangeDisplaySettingsEx API which is independent from DirectDraw.

Dr.Venom:

--- Quote from: Calamity on January 11, 2013, 04:29:52 am ---The thing here is that the IDirectDraw7 interface has remained unchanged for years, and WinUAE seems to be using the same interface as us, and as long as the error happens when calling the SetDisplayMode method, we first should try to find which exact parameters WinUAE is using to invoke this method, then try to replicate the call on our code.
--- End quote ---

Unfortunately I don't have experience compiling WinUAE. I did notice a guide recently that apparently makes it easier to do so. It's in this post here: http://eab.abime.net/showpost.php?p=847432&postcount=18. I don't have MSVC (but am using CodeBlocks with the "MAME" GCC package), which seems to be needed for succesful compilation, but then again I haven't tried it yet.

I was looking at some code at the GIT though and noticed these ddraw_fs_hack_free and ddraw_fs_hack_init routines. Interestingly the ddraw_fs_hack_init first calls the ddraw_fs_hack_free routine and then seems to create a fallback for when opening a directdraw screen fails. At first it calls it like this:
       
--- Code: ---hr = ddraw->SetDisplayMode (dpp.BackBufferWidth, dpp.BackBufferHeight, t_depth, dpp.FullScreen_RefreshRateInHz, 0);
--- End code ---

but if that fails, does it like this:
       
--- Code: ---hr = ddraw->SetDisplayMode (dpp.BackBufferWidth, dpp.BackBufferHeight, t_depth, 0, 0);
--- End code ---

and if that fails calls ddraw_fs_hack_free again

These routines are at line 117 and 135 respectively in the direct3d.cpp, which can be viewed here: https://github.com/tonioni/WinUAE/blob/master/od-win32/direct3d.cpp#L113


--- Quote ---Regarding the ChangeDisplaySettingsEx, you could try something else. In Arcade_OSD, try to set an interlaced mode. Instead of pressing "1", press "2", this will enter the menu without setting full screen on, then select "Set as desktop mode". This option invokes the ChangeDisplaySettingsEx API which is independent from DirectDraw.

--- End quote ---

I tried this, but it makes no difference whether I use the "1" or the "2" method. Also, for both methods the logs returns the earlier reported two lines (SetDisplayMode error & ActivateMode: DDrawInit error).

Calamity:

--- Quote from: Dr.Venom on January 11, 2013, 05:54:15 am ---I was looking at some code at the GIT though and noticed these ddraw_fs_hack_free and ddraw_fs_hack_init routines. Interestingly the ddraw_fs_hack_init first calls the ddraw_fs_hack_free routine and then seems to create a fallback for when opening a directdraw screen fails. At first it calls it like this:
       
--- Code: ---hr = ddraw->SetDisplayMode (dpp.BackBufferWidth, dpp.BackBufferHeight, t_depth, dpp.FullScreen_RefreshRateInHz, 0);
--- End code ---

but if that fails, does it like this:
       
--- Code: ---hr = ddraw->SetDisplayMode (dpp.BackBufferWidth, dpp.BackBufferHeight, t_depth, 0, 0);
--- End code ---

and if that fails calls ddraw_fs_hack_free again

--- End quote ---

Yes, I saw that before, I think he's using DirectDraw in for mode setting inside the Direct3D code, that's very interesting as I once tried something similar and didn't work, I'll need to have a look at it at some point. Anyway, although that's not the part of the code we're looking for, the same scheme seems to happen in the DirectDraw part, see:


--- Code: --- freq = getrefreshrate (width, height);
write_log (_T("set_ddraw: trying %dx%d, bits=%d, refreshrate=%d\n"), width, height, bits, freq);
ddrval = DirectDraw_SetDisplayMode (width, height, bits, freq);
if (SUCCEEDED (ddrval))
break;
olderr = ddrval;
if (freq) {
write_log (_T("set_ddraw: failed, trying without forced refresh rate\n"));
DirectDraw_SetCooperativeLevel (hAmigaWnd, dxfullscreen, TRUE);
ddrval = DirectDraw_SetDisplayMode (width, height, bits, 0);
if (SUCCEEDED (ddrval))
break;
}

--- End code ---

So this might be the way to do it: passing refresh as 0. So you can try this quick hack in MAME code, src/osd/windows/ddraw.c


--- Quote ---   // full screen mode: set the resolution
   if (window->fullscreen && video_config.switchres)
   {
      //result = IDirectDraw7_SetDisplayMode(dd->ddraw, dd->width, dd->height, 32, dd->refresh, 0);
      result = IDirectDraw7_SetDisplayMode(dd->ddraw, dd->width, dd->height, 32, 0, 0);
      if (result != DD_OK)
      {
         mame_printf_verbose("DirectDraw: Error %08X attempting to set video mode %dx%d@%d call\n", (int)result, dd->width, dd->height, dd->refresh);
         goto error;
      }
   }
--- End quote ---


--- Quote ---I tried this, but it makes no difference whether I use the "1" or the "2" method. Also, for both methods the logs returns the earlier reported two lines (SetDisplayMode error & ActivateMode: DDrawInit error).

--- End quote ---

I didn't mean "1" or "2" would make a difference, it is the result of "Set  as desktop mode" what is interesting, to see if the issue is with ChangeDisplaySettingsEx too.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version