d3d9: Explicitly convert between D3DFORMAT and WINED3DFORMAT values.

This commit is contained in:
Henri Verbeet 2009-02-19 16:59:42 +01:00 committed by Alexandre Julliard
parent d575b5fecb
commit 61a9efc4b9
11 changed files with 243 additions and 55 deletions

View File

@ -228,12 +228,13 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTU
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
WINED3DFORMAT format;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *) &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
@ -246,6 +247,9 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTU
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
return hr;
}
@ -355,7 +359,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9EX ifac
object->ref = 1;
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
Format, Pool, &object->wineD3DCubeTexture, pSharedHandle, (IUnknown*)object);
wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DCubeTexture,
pSharedHandle, (IUnknown*)object);
LeaveCriticalSection(&d3d9_cs);
if (hr != D3D_OK){

View File

@ -45,6 +45,8 @@ extern HRESULT vdecl_convert_fvf(
DWORD FVF,
D3DVERTEXELEMENT9** ppVertexElements);
extern CRITICAL_SECTION d3d9_cs;
D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format);
WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format);
/* ===========================================================================
Macros

View File

@ -25,6 +25,135 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format)
{
BYTE *c = (BYTE *)&format;
/* Don't translate FOURCC formats */
if (isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) return format;
switch(format)
{
case WINED3DFMT_UNKNOWN: return D3DFMT_UNKNOWN;
case WINED3DFMT_R8G8B8: return D3DFMT_R8G8B8;
case WINED3DFMT_A8R8G8B8: return D3DFMT_A8R8G8B8;
case WINED3DFMT_X8R8G8B8: return D3DFMT_X8R8G8B8;
case WINED3DFMT_R5G6B5: return D3DFMT_R5G6B5;
case WINED3DFMT_X1R5G5B5: return D3DFMT_X1R5G5B5;
case WINED3DFMT_A1R5G5B5: return D3DFMT_A1R5G5B5;
case WINED3DFMT_A4R4G4B4: return D3DFMT_A4R4G4B4;
case WINED3DFMT_R3G3B2: return D3DFMT_R3G3B2;
case WINED3DFMT_A8: return D3DFMT_A8;
case WINED3DFMT_A8R3G3B2: return D3DFMT_A8R3G3B2;
case WINED3DFMT_X4R4G4B4: return D3DFMT_X4R4G4B4;
case WINED3DFMT_A2B10G10R10: return D3DFMT_A2B10G10R10;
case WINED3DFMT_A8B8G8R8: return D3DFMT_A8B8G8R8;
case WINED3DFMT_X8B8G8R8: return D3DFMT_X8B8G8R8;
case WINED3DFMT_G16R16: return D3DFMT_G16R16;
case WINED3DFMT_A2R10G10B10: return D3DFMT_A2R10G10B10;
case WINED3DFMT_A16B16G16R16: return D3DFMT_A16B16G16R16;
case WINED3DFMT_A8P8: return D3DFMT_A8P8;
case WINED3DFMT_P8: return D3DFMT_P8;
case WINED3DFMT_L8: return D3DFMT_L8;
case WINED3DFMT_A8L8: return D3DFMT_A8L8;
case WINED3DFMT_A4L4: return D3DFMT_A4L4;
case WINED3DFMT_V8U8: return D3DFMT_V8U8;
case WINED3DFMT_L6V5U5: return D3DFMT_L6V5U5;
case WINED3DFMT_X8L8V8U8: return D3DFMT_X8L8V8U8;
case WINED3DFMT_Q8W8V8U8: return D3DFMT_Q8W8V8U8;
case WINED3DFMT_V16U16: return D3DFMT_V16U16;
case WINED3DFMT_A2W10V10U10: return D3DFMT_A2W10V10U10;
case WINED3DFMT_D16_LOCKABLE: return D3DFMT_D16_LOCKABLE;
case WINED3DFMT_D32: return D3DFMT_D32;
case WINED3DFMT_D15S1: return D3DFMT_D15S1;
case WINED3DFMT_D24S8: return D3DFMT_D24S8;
case WINED3DFMT_D24X8: return D3DFMT_D24X8;
case WINED3DFMT_D24X4S4: return D3DFMT_D24X4S4;
case WINED3DFMT_D16: return D3DFMT_D16;
case WINED3DFMT_L16: return D3DFMT_L16;
case WINED3DFMT_D32F_LOCKABLE: return D3DFMT_D32F_LOCKABLE;
case WINED3DFMT_D24FS8: return D3DFMT_D24FS8;
case WINED3DFMT_VERTEXDATA: return D3DFMT_VERTEXDATA;
case WINED3DFMT_INDEX16: return D3DFMT_INDEX16;
case WINED3DFMT_INDEX32: return D3DFMT_INDEX32;
case WINED3DFMT_Q16W16V16U16: return D3DFMT_Q16W16V16U16;
case WINED3DFMT_R16F: return D3DFMT_R16F;
case WINED3DFMT_G16R16F: return D3DFMT_G16R16F;
case WINED3DFMT_A16B16G16R16F: return D3DFMT_A16B16G16R16F;
case WINED3DFMT_R32F: return D3DFMT_R32F;
case WINED3DFMT_G32R32F: return D3DFMT_G32R32F;
case WINED3DFMT_A32B32G32R32F: return D3DFMT_A32B32G32R32F;
case WINED3DFMT_CxV8U8: return D3DFMT_CxV8U8;
default:
FIXME("Unhandled WINED3DFORMAT %#x\n", format);
return D3DFMT_UNKNOWN;
}
}
WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format)
{
BYTE *c = (BYTE *)&format;
/* Don't translate FOURCC formats */
if (isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) return format;
switch(format)
{
case D3DFMT_UNKNOWN: return WINED3DFMT_UNKNOWN;
case D3DFMT_R8G8B8: return WINED3DFMT_R8G8B8;
case D3DFMT_A8R8G8B8: return WINED3DFMT_A8R8G8B8;
case D3DFMT_X8R8G8B8: return WINED3DFMT_X8R8G8B8;
case D3DFMT_R5G6B5: return WINED3DFMT_R5G6B5;
case D3DFMT_X1R5G5B5: return WINED3DFMT_X1R5G5B5;
case D3DFMT_A1R5G5B5: return WINED3DFMT_A1R5G5B5;
case D3DFMT_A4R4G4B4: return WINED3DFMT_A4R4G4B4;
case D3DFMT_R3G3B2: return WINED3DFMT_R3G3B2;
case D3DFMT_A8: return WINED3DFMT_A8;
case D3DFMT_A8R3G3B2: return WINED3DFMT_A8R3G3B2;
case D3DFMT_X4R4G4B4: return WINED3DFMT_X4R4G4B4;
case D3DFMT_A2B10G10R10: return WINED3DFMT_A2B10G10R10;
case D3DFMT_A8B8G8R8: return WINED3DFMT_A8B8G8R8;
case D3DFMT_X8B8G8R8: return WINED3DFMT_X8B8G8R8;
case D3DFMT_G16R16: return WINED3DFMT_G16R16;
case D3DFMT_A2R10G10B10: return WINED3DFMT_A2R10G10B10;
case D3DFMT_A16B16G16R16: return WINED3DFMT_A16B16G16R16;
case D3DFMT_A8P8: return WINED3DFMT_A8P8;
case D3DFMT_P8: return WINED3DFMT_P8;
case D3DFMT_L8: return WINED3DFMT_L8;
case D3DFMT_A8L8: return WINED3DFMT_A8L8;
case D3DFMT_A4L4: return WINED3DFMT_A4L4;
case D3DFMT_V8U8: return WINED3DFMT_V8U8;
case D3DFMT_L6V5U5: return WINED3DFMT_L6V5U5;
case D3DFMT_X8L8V8U8: return WINED3DFMT_X8L8V8U8;
case D3DFMT_Q8W8V8U8: return WINED3DFMT_Q8W8V8U8;
case D3DFMT_V16U16: return WINED3DFMT_V16U16;
case D3DFMT_A2W10V10U10: return WINED3DFMT_A2W10V10U10;
case D3DFMT_D16_LOCKABLE: return WINED3DFMT_D16_LOCKABLE;
case D3DFMT_D32: return WINED3DFMT_D32;
case D3DFMT_D15S1: return WINED3DFMT_D15S1;
case D3DFMT_D24S8: return WINED3DFMT_D24S8;
case D3DFMT_D24X8: return WINED3DFMT_D24X8;
case D3DFMT_D24X4S4: return WINED3DFMT_D24X4S4;
case D3DFMT_D16: return WINED3DFMT_D16;
case D3DFMT_L16: return WINED3DFMT_L16;
case D3DFMT_D32F_LOCKABLE: return WINED3DFMT_D32F_LOCKABLE;
case D3DFMT_D24FS8: return WINED3DFMT_D24FS8;
case D3DFMT_VERTEXDATA: return WINED3DFMT_VERTEXDATA;
case D3DFMT_INDEX16: return WINED3DFMT_INDEX16;
case D3DFMT_INDEX32: return WINED3DFMT_INDEX32;
case D3DFMT_Q16W16V16U16: return WINED3DFMT_Q16W16V16U16;
case D3DFMT_R16F: return WINED3DFMT_R16F;
case D3DFMT_G16R16F: return WINED3DFMT_G16R16F;
case D3DFMT_A16B16G16R16F: return WINED3DFMT_A16B16G16R16F;
case D3DFMT_R32F: return WINED3DFMT_R32F;
case D3DFMT_G32R32F: return WINED3DFMT_G32R32F;
case D3DFMT_A32B32G32R32F: return WINED3DFMT_A32B32G32R32F;
case D3DFMT_CxV8U8: return WINED3DFMT_CxV8U8;
default:
FIXME("Unhandled D3DFORMAT %#x\n", format);
return WINED3DFMT_UNKNOWN;
}
}
/* IDirect3D IUnknown parts follow: */
static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX iface, REFIID riid, LPVOID* ppobj) {
@ -213,6 +342,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
return hr;
}
@ -372,7 +504,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
@ -380,7 +512,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
@ -394,7 +526,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
@ -402,7 +534,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
@ -511,11 +643,13 @@ static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UIN
object->lpVtbl = &Direct3DSurface9_Vtbl;
object->ref = 1;
TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, Format, Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage & WINED3DUSAGE_MASK, (WINED3DPOOL) Pool,MultiSample,MultisampleQuality,pSharedHandle,SURFACE_OPENGL,(IUnknown *)object);
hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, wined3dformat_from_d3dformat(Format),
Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage & WINED3DUSAGE_MASK, (WINED3DPOOL)Pool,
MultiSample, MultisampleQuality, pSharedHandle, SURFACE_OPENGL, (IUnknown *)object);
if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
/* free up object */
@ -1261,8 +1395,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDE
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex,
NumVertexIndices, PrimitiveCount, pIndexData, wined3dformat_from_d3dformat(IndexDataFormat),
pVertexStreamZeroData, VertexStreamZeroStride);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
@ -1810,8 +1945,9 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParen
if (pool == D3DPOOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC)) lockable = FALSE;
hr = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex *)This, width, height,
format, lockable, FALSE /* Discard */, level, (IDirect3DSurface9 **)&d3d_surface,
D3DRTYPE_SURFACE, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, NULL);
d3dformat_from_wined3dformat(format), lockable, FALSE /* Discard */, level,
(IDirect3DSurface9 **)&d3d_surface, D3DRTYPE_SURFACE, usage, pool,
D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, NULL);
if (FAILED(hr))
{
ERR("(%p) CreateSurface failed, returning %#x\n", iface, hr);
@ -1839,8 +1975,9 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDevice
"\tmultisample_quality %u, lockable %u, surface %p\n",
iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
hr = IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex *)This, width, height, format,
multisample_type, multisample_quality, lockable, (IDirect3DSurface9 **)&d3d_surface, NULL);
hr = IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex *)This, width, height,
d3dformat_from_wined3dformat(format), multisample_type, multisample_quality, lockable,
(IDirect3DSurface9 **)&d3d_surface, NULL);
if (FAILED(hr))
{
ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface, hr);
@ -1868,8 +2005,9 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3
"\tmultisample_quality %u, discard %u, surface %p\n",
iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
hr = IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex *)This, width, height, format,
multisample_type, multisample_quality, discard, (IDirect3DSurface9 **)&d3d_surface, NULL);
hr = IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex *)This, width, height,
d3dformat_from_wined3dformat(format), multisample_type, multisample_quality, discard,
(IDirect3DSurface9 **)&d3d_surface, NULL);
if (FAILED(hr))
{
ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface, hr);
@ -1939,7 +2077,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
/* Copy the presentation parameters */
local_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
local_parameters.BackBufferHeight = present_parameters->BackBufferHeight;
local_parameters.BackBufferFormat = present_parameters->BackBufferFormat;
local_parameters.BackBufferFormat = d3dformat_from_wined3dformat(present_parameters->BackBufferFormat);
local_parameters.BackBufferCount = present_parameters->BackBufferCount;
local_parameters.MultiSampleType = present_parameters->MultiSampleType;
local_parameters.MultiSampleQuality = present_parameters->MultiSampleQuality;
@ -1947,7 +2085,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
local_parameters.hDeviceWindow = present_parameters->hDeviceWindow;
local_parameters.Windowed = present_parameters->Windowed;
local_parameters.EnableAutoDepthStencil = present_parameters->EnableAutoDepthStencil;
local_parameters.AutoDepthStencilFormat = present_parameters->AutoDepthStencilFormat;
local_parameters.AutoDepthStencilFormat = d3dformat_from_wined3dformat(present_parameters->AutoDepthStencilFormat);
local_parameters.Flags = present_parameters->Flags;
local_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
local_parameters.PresentationInterval = present_parameters->PresentationInterval;
@ -1969,7 +2107,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
/* Copy back the presentation parameters */
present_parameters->BackBufferWidth = local_parameters.BackBufferWidth;
present_parameters->BackBufferHeight = local_parameters.BackBufferHeight;
present_parameters->BackBufferFormat = local_parameters.BackBufferFormat;
present_parameters->BackBufferFormat = wined3dformat_from_d3dformat(local_parameters.BackBufferFormat);
present_parameters->BackBufferCount = local_parameters.BackBufferCount;
present_parameters->MultiSampleType = local_parameters.MultiSampleType;
present_parameters->MultiSampleQuality = local_parameters.MultiSampleQuality;
@ -1977,7 +2115,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
present_parameters->hDeviceWindow = local_parameters.hDeviceWindow;
present_parameters->Windowed = local_parameters.Windowed;
present_parameters->EnableAutoDepthStencil = local_parameters.EnableAutoDepthStencil;
present_parameters->AutoDepthStencilFormat = local_parameters.AutoDepthStencilFormat;
present_parameters->AutoDepthStencilFormat = wined3dformat_from_d3dformat(local_parameters.AutoDepthStencilFormat);
present_parameters->Flags = local_parameters.Flags;
present_parameters->FullScreen_RefreshRateInHz = local_parameters.FullScreen_RefreshRateInHz;
present_parameters->PresentationInterval = local_parameters.PresentationInterval;

View File

@ -137,7 +137,7 @@ static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT
}
EnterCriticalSection(&d3d9_cs);
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format);
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
LeaveCriticalSection(&d3d9_cs);
return hr;
}
@ -148,18 +148,27 @@ static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT
TRACE("(%p)->(%d, %d, %d, %p)\n", This, Adapter, Format, Mode, pMode);
/* 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 != WINED3DFMT_X8R8G8B8 && Format != WINED3DFMT_R5G6B5)
if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5)
return D3DERR_INVALIDCALL;
EnterCriticalSection(&d3d9_cs);
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, (WINED3DDISPLAYMODE *) pMode);
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
Mode, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
HRESULT hr;
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9EX iface,
@ -171,8 +180,8 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9EX iface,
BackBufferFormat, Windowed ? "true" : "false");
EnterCriticalSection(&d3d9_cs);
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, DisplayFormat,
BackBufferFormat, Windowed);
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
@ -185,8 +194,8 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9EX iface,
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, AdapterFormat,
Usage, RType, CheckFormat, SURFACE_OPENGL);
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
Usage, RType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
@ -199,8 +208,8 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9EX if
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, SurfaceFormat,
Windowed, MultiSampleType, pQualityLevels);
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, MultiSampleType, pQualityLevels);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
@ -213,8 +222,9 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9EX iface,
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, AdapterFormat,
RenderTargetFormat, DepthStencilFormat);
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
wined3dformat_from_d3dformat(DepthStencilFormat));
LeaveCriticalSection(&d3d9_cs);
return hr;
}
@ -225,8 +235,8 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX i
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType, SourceFormat,
TargetFormat);
hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SourceFormat), wined3dformat_from_d3dformat(TargetFormat));
LeaveCriticalSection(&d3d9_cs);
return hr;
}
@ -404,7 +414,7 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
@ -412,7 +422,7 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
@ -426,7 +436,7 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
@ -434,7 +444,7 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;

View File

@ -184,6 +184,9 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXB
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, (WINED3DINDEXBUFFER_DESC *) pDesc);
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
return hr;
}
@ -230,7 +233,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9EX iface,
object->lpVtbl = &Direct3DIndexBuffer9_Vtbl;
object->ref = 1;
TRACE("Calling wined3d create index buffer\n");
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK, Format, (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer, pSharedHandle, (IUnknown *)object);
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK,
wined3dformat_from_d3dformat(Format), (WINED3DPOOL)Pool, &object->wineD3DIndexBuffer,
pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */

View File

@ -201,11 +201,12 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
WINED3DFORMAT format;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
@ -218,6 +219,9 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
return hr;
}

View File

@ -126,6 +126,9 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
return hr;
}
@ -159,7 +162,7 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWA
pPresentationParameters->BackBufferWidth = winePresentParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = winePresentParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = winePresentParameters.BackBufferFormat;
pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(winePresentParameters.BackBufferFormat);
pPresentationParameters->BackBufferCount = winePresentParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = winePresentParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = winePresentParameters.MultiSampleQuality;
@ -167,7 +170,7 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWA
pPresentationParameters->hDeviceWindow = winePresentParameters.hDeviceWindow;
pPresentationParameters->Windowed = winePresentParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = winePresentParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = winePresentParameters.AutoDepthStencilFormat;
pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(winePresentParameters.AutoDepthStencilFormat);
pPresentationParameters->Flags = winePresentParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = winePresentParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = winePresentParameters.PresentationInterval;
@ -216,7 +219,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE
/* Allocate an associated WineD3DDevice object */
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
@ -224,7 +227,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
@ -237,7 +240,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
@ -245,7 +248,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;

View File

@ -227,10 +227,12 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 ifac
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
HRESULT hr;
WINED3DFORMAT format;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
@ -243,6 +245,9 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 ifac
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
return hr;
}
@ -347,7 +352,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9EX iface, U
object->ref = 1;
EnterCriticalSection(&d3d9_cs);
hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
Format, Pool, &object->wineD3DTexture, pSharedHandle, (IUnknown *)object);
wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DTexture, pSharedHandle, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
if (FAILED(hrc)) {

View File

@ -181,6 +181,9 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc);
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
return hr;
}

View File

@ -132,11 +132,13 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DV
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
WINED3DFORMAT format;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
@ -145,7 +147,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DV
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
return IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
return hr;
}
static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {

View File

@ -156,11 +156,13 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMET
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
WINED3DFORMAT format;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
@ -169,7 +171,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMET
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
return IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, IDirect3DVolume9** ppVolumeLevel) {
@ -259,7 +265,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9EX if
object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels,
Usage & WINED3DUSAGE_MASK, Format, Pool, &object->wineD3DVolumeTexture, pSharedHandle, (IUnknown *)object);
Usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(Format), Pool,
&object->wineD3DVolumeTexture, pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */