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
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) {
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);
}
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
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. */
if(Format == D3DFMT_UNKNOWN)
if(Format != WINED3DFMT_X8R8G8B8 && Format != WINED3DFMT_R5G6B5)
return D3DERR_INVALIDCALL;
return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, (WINED3DDISPLAYMODE *) pMode);
}
......
......@@ -1166,11 +1166,31 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
LPDDENUMMODESCALLBACK2 cb)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw7, iface);
unsigned int modenum = 0;
unsigned int modenum, fmt;
WINED3DFORMAT pixelformat = WINED3DFMT_UNKNOWN;
WINED3DDISPLAYMODE mode;
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);
/* This looks sane */
......@@ -1182,11 +1202,20 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
pixelformat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
}
for(fmt = 0; fmt < (sizeof(checkFormatList) / sizeof(checkFormatList[0])); fmt++)
{
if(pixelformat != WINED3DFMT_UNKNOWN && checkFormatList[fmt] != pixelformat)
{
continue;
}
modenum = 0;
while(IWineD3D_EnumAdapterModes(This->wineD3D,
WINED3DADAPTER_DEFAULT,
pixelformat,
checkFormatList[fmt],
modenum++,
&mode) == WINED3D_OK) {
&mode) == WINED3D_OK)
{
if(DDSD)
{
if(DDSD->dwFlags & DDSD_WIDTH && mode.Width != DDSD->dwWidth) continue;
......@@ -1217,6 +1246,8 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
return DD_OK;
}
}
}
TRACE("End of enumeration\n");
return DD_OK;
}
......
......@@ -1117,6 +1117,7 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad
switch (Format)
{
case WINED3DFMT_UNKNOWN:
/* This is for D3D8, do not enumerate P8 here */
if (DevModeW.dmBitsPerPel == 32 ||
DevModeW.dmBitsPerPel == 16) i++;
break;
......@@ -1126,6 +1127,9 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad
case WINED3DFMT_R5G6B5:
if (DevModeW.dmBitsPerPel == 16) i++;
break;
case WINED3DFMT_P8:
if (DevModeW.dmBitsPerPel == 8) i++;
break;
default:
/* Skip other modes as they do not match the requested format */
break;
......@@ -1169,6 +1173,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
switch (Format)
{
case WINED3DFMT_UNKNOWN:
/* This is D3D8. Do not enumerate P8 here */
if (DevModeW.dmBitsPerPel == 32 ||
DevModeW.dmBitsPerPel == 16) i++;
break;
......@@ -1178,6 +1183,9 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
case WINED3DFMT_R5G6B5:
if (DevModeW.dmBitsPerPel == 16) i++;
break;
case WINED3DFMT_P8:
if (DevModeW.dmBitsPerPel == 8) i++;
break;
default:
/* 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));
......@@ -1203,6 +1211,9 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
{
switch (DevModeW.dmBitsPerPel)
{
case 8:
pMode->Format = WINED3DFMT_P8;
break;
case 16:
pMode->Format = WINED3DFMT_R5G6B5;
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