Commit 8a5b6df4 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

d3d: Enumerate palettized formats for ddraw.

parent 3d92b293
...@@ -98,14 +98,20 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UIN ...@@ -98,14 +98,20 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UIN
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) { static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface; IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
/* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5 && Format != D3DFMT_UNKNOWN) {
return 0;
}
return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format); return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format);
} }
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) { static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface; IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
/* We can't pass this to WineD3D, otherwise it'll think it came from D3D8. /* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
It's supposed to fail anyway, so no harm returning failure. */ It's supposed to fail anyway, so no harm returning failure. */
if(Format == D3DFMT_UNKNOWN) if(Format != WINED3DFMT_X8R8G8B8 && Format != WINED3DFMT_R5G6B5)
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, (WINED3DDISPLAYMODE *) pMode); return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, (WINED3DDISPLAYMODE *) pMode);
} }
......
...@@ -1166,11 +1166,31 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface, ...@@ -1166,11 +1166,31 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
LPDDENUMMODESCALLBACK2 cb) LPDDENUMMODESCALLBACK2 cb)
{ {
ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw7, iface); ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw7, iface);
unsigned int modenum = 0; unsigned int modenum, fmt;
WINED3DFORMAT pixelformat = WINED3DFMT_UNKNOWN; WINED3DFORMAT pixelformat = WINED3DFMT_UNKNOWN;
WINED3DDISPLAYMODE mode; WINED3DDISPLAYMODE mode;
DDSURFACEDESC2 callback_sd; DDSURFACEDESC2 callback_sd;
WINED3DFORMAT checkFormatList[] =
{
WINED3DFMT_R8G8B8,
WINED3DFMT_A8R8G8B8,
WINED3DFMT_X8R8G8B8,
WINED3DFMT_R5G6B5,
WINED3DFMT_X1R5G5B5,
WINED3DFMT_A1R5G5B5,
WINED3DFMT_A4R4G4B4,
WINED3DFMT_R3G3B2,
WINED3DFMT_A8R3G3B2,
WINED3DFMT_X4R4G4B4,
WINED3DFMT_A2B10G10R10,
WINED3DFMT_A8B8G8R8,
WINED3DFMT_X8B8G8R8,
WINED3DFMT_A2R10G10B10,
WINED3DFMT_A8P8,
WINED3DFMT_P8
};
TRACE("(%p)->(%p,%p,%p): Relay\n", This, DDSD, Context, cb); TRACE("(%p)->(%p,%p,%p): Relay\n", This, DDSD, Context, cb);
/* This looks sane */ /* This looks sane */
...@@ -1182,41 +1202,52 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface, ...@@ -1182,41 +1202,52 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
pixelformat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat); pixelformat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
} }
while(IWineD3D_EnumAdapterModes(This->wineD3D, for(fmt = 0; fmt < (sizeof(checkFormatList) / sizeof(checkFormatList[0])); fmt++)
WINED3DADAPTER_DEFAULT, {
pixelformat, if(pixelformat != WINED3DFMT_UNKNOWN && checkFormatList[fmt] != pixelformat)
modenum++,
&mode) == WINED3D_OK) {
if(DDSD)
{ {
if(DDSD->dwFlags & DDSD_WIDTH && mode.Width != DDSD->dwWidth) continue; continue;
if(DDSD->dwFlags & DDSD_HEIGHT && mode.Height != DDSD->dwHeight) continue;
} }
memset(&callback_sd, 0, sizeof(callback_sd)); modenum = 0;
callback_sd.dwSize = sizeof(callback_sd); while(IWineD3D_EnumAdapterModes(This->wineD3D,
callback_sd.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); WINED3DADAPTER_DEFAULT,
checkFormatList[fmt],
callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH; modenum++,
if(Flags & DDEDM_REFRESHRATES) &mode) == WINED3D_OK)
{ {
callback_sd.dwFlags |= DDSD_REFRESHRATE; if(DDSD)
callback_sd.u2.dwRefreshRate = mode.RefreshRate; {
} if(DDSD->dwFlags & DDSD_WIDTH && mode.Width != DDSD->dwWidth) continue;
if(DDSD->dwFlags & DDSD_HEIGHT && mode.Height != DDSD->dwHeight) continue;
}
callback_sd.dwWidth = mode.Width; memset(&callback_sd, 0, sizeof(callback_sd));
callback_sd.dwHeight = mode.Height; callback_sd.dwSize = sizeof(callback_sd);
callback_sd.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
PixelFormat_WineD3DtoDD(&callback_sd.u4.ddpfPixelFormat, mode.Format); callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH;
if(Flags & DDEDM_REFRESHRATES)
{
callback_sd.dwFlags |= DDSD_REFRESHRATE;
callback_sd.u2.dwRefreshRate = mode.RefreshRate;
}
TRACE("Enumerating %dx%d@%d\n", callback_sd.dwWidth, callback_sd.dwHeight, callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount); callback_sd.dwWidth = mode.Width;
callback_sd.dwHeight = mode.Height;
if(cb(&callback_sd, Context) == DDENUMRET_CANCEL) PixelFormat_WineD3DtoDD(&callback_sd.u4.ddpfPixelFormat, mode.Format);
{
TRACE("Application asked to terminate the enumeration\n"); TRACE("Enumerating %dx%d@%d\n", callback_sd.dwWidth, callback_sd.dwHeight, callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount);
return DD_OK;
if(cb(&callback_sd, Context) == DDENUMRET_CANCEL)
{
TRACE("Application asked to terminate the enumeration\n");
return DD_OK;
}
} }
} }
TRACE("End of enumeration\n"); TRACE("End of enumeration\n");
return DD_OK; return DD_OK;
} }
......
...@@ -1117,6 +1117,7 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad ...@@ -1117,6 +1117,7 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad
switch (Format) switch (Format)
{ {
case WINED3DFMT_UNKNOWN: case WINED3DFMT_UNKNOWN:
/* This is for D3D8, do not enumerate P8 here */
if (DevModeW.dmBitsPerPel == 32 || if (DevModeW.dmBitsPerPel == 32 ||
DevModeW.dmBitsPerPel == 16) i++; DevModeW.dmBitsPerPel == 16) i++;
break; break;
...@@ -1126,6 +1127,9 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad ...@@ -1126,6 +1127,9 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad
case WINED3DFMT_R5G6B5: case WINED3DFMT_R5G6B5:
if (DevModeW.dmBitsPerPel == 16) i++; if (DevModeW.dmBitsPerPel == 16) i++;
break; break;
case WINED3DFMT_P8:
if (DevModeW.dmBitsPerPel == 8) i++;
break;
default: default:
/* Skip other modes as they do not match the requested format */ /* Skip other modes as they do not match the requested format */
break; break;
...@@ -1169,6 +1173,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte ...@@ -1169,6 +1173,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
switch (Format) switch (Format)
{ {
case WINED3DFMT_UNKNOWN: case WINED3DFMT_UNKNOWN:
/* This is D3D8. Do not enumerate P8 here */
if (DevModeW.dmBitsPerPel == 32 || if (DevModeW.dmBitsPerPel == 32 ||
DevModeW.dmBitsPerPel == 16) i++; DevModeW.dmBitsPerPel == 16) i++;
break; break;
...@@ -1178,6 +1183,9 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte ...@@ -1178,6 +1183,9 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
case WINED3DFMT_R5G6B5: case WINED3DFMT_R5G6B5:
if (DevModeW.dmBitsPerPel == 16) i++; if (DevModeW.dmBitsPerPel == 16) i++;
break; break;
case WINED3DFMT_P8:
if (DevModeW.dmBitsPerPel == 8) i++;
break;
default: default:
/* Modes that don't match what we support can get an early-out */ /* Modes that don't match what we support can get an early-out */
TRACE_(d3d_caps)("Searching for %s, returning D3DERR_INVALIDCALL\n", debug_d3dformat(Format)); TRACE_(d3d_caps)("Searching for %s, returning D3DERR_INVALIDCALL\n", debug_d3dformat(Format));
...@@ -1203,6 +1211,9 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte ...@@ -1203,6 +1211,9 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
{ {
switch (DevModeW.dmBitsPerPel) switch (DevModeW.dmBitsPerPel)
{ {
case 8:
pMode->Format = WINED3DFMT_P8;
break;
case 16: case 16:
pMode->Format = WINED3DFMT_R5G6B5; pMode->Format = WINED3DFMT_R5G6B5;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment