d3d8: Allocate WINED3DCAPS on stack.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-02-20 13:12:12 +01:00 committed by Alexandre Julliard
parent ce0a60e1c7
commit f7ca55f63a
3 changed files with 61 additions and 69 deletions

View file

@ -46,59 +46,59 @@
=========================================================================== */
/* Not nice, but it lets wined3d support different versions of directx */
#define WINECAPSTOD3D8CAPS(_pD3D8Caps, _pWineCaps) \
_pD3D8Caps->DeviceType = (D3DDEVTYPE) _pWineCaps->DeviceType; \
_pD3D8Caps->AdapterOrdinal = _pWineCaps->AdapterOrdinal; \
_pD3D8Caps->Caps = _pWineCaps->Caps; \
_pD3D8Caps->Caps2 = _pWineCaps->Caps2; \
_pD3D8Caps->Caps3 = _pWineCaps->Caps3; \
_pD3D8Caps->PresentationIntervals = _pWineCaps->PresentationIntervals; \
_pD3D8Caps->CursorCaps = _pWineCaps->CursorCaps; \
_pD3D8Caps->DevCaps = _pWineCaps->DevCaps; \
_pD3D8Caps->PrimitiveMiscCaps = _pWineCaps->PrimitiveMiscCaps; \
_pD3D8Caps->RasterCaps = _pWineCaps->RasterCaps; \
_pD3D8Caps->ZCmpCaps = _pWineCaps->ZCmpCaps; \
_pD3D8Caps->SrcBlendCaps = _pWineCaps->SrcBlendCaps; \
_pD3D8Caps->DestBlendCaps = _pWineCaps->DestBlendCaps; \
_pD3D8Caps->AlphaCmpCaps = _pWineCaps->AlphaCmpCaps; \
_pD3D8Caps->ShadeCaps = _pWineCaps->ShadeCaps; \
_pD3D8Caps->TextureCaps = _pWineCaps->TextureCaps; \
_pD3D8Caps->TextureFilterCaps = _pWineCaps->TextureFilterCaps; \
_pD3D8Caps->CubeTextureFilterCaps = _pWineCaps->CubeTextureFilterCaps; \
_pD3D8Caps->VolumeTextureFilterCaps = _pWineCaps->VolumeTextureFilterCaps; \
_pD3D8Caps->TextureAddressCaps = _pWineCaps->TextureAddressCaps; \
_pD3D8Caps->VolumeTextureAddressCaps = _pWineCaps->VolumeTextureAddressCaps; \
_pD3D8Caps->LineCaps = _pWineCaps->LineCaps; \
_pD3D8Caps->MaxTextureWidth = _pWineCaps->MaxTextureWidth; \
_pD3D8Caps->MaxTextureHeight = _pWineCaps->MaxTextureHeight; \
_pD3D8Caps->MaxVolumeExtent = _pWineCaps->MaxVolumeExtent; \
_pD3D8Caps->MaxTextureRepeat = _pWineCaps->MaxTextureRepeat; \
_pD3D8Caps->MaxTextureAspectRatio = _pWineCaps->MaxTextureAspectRatio; \
_pD3D8Caps->MaxAnisotropy = _pWineCaps->MaxAnisotropy; \
_pD3D8Caps->MaxVertexW = _pWineCaps->MaxVertexW; \
_pD3D8Caps->GuardBandLeft = _pWineCaps->GuardBandLeft; \
_pD3D8Caps->GuardBandTop = _pWineCaps->GuardBandTop; \
_pD3D8Caps->GuardBandRight = _pWineCaps->GuardBandRight; \
_pD3D8Caps->GuardBandBottom = _pWineCaps->GuardBandBottom; \
_pD3D8Caps->ExtentsAdjust = _pWineCaps->ExtentsAdjust; \
_pD3D8Caps->StencilCaps = _pWineCaps->StencilCaps; \
_pD3D8Caps->FVFCaps = _pWineCaps->FVFCaps; \
_pD3D8Caps->TextureOpCaps = _pWineCaps->TextureOpCaps; \
_pD3D8Caps->MaxTextureBlendStages = _pWineCaps->MaxTextureBlendStages; \
_pD3D8Caps->MaxSimultaneousTextures = _pWineCaps->MaxSimultaneousTextures; \
_pD3D8Caps->VertexProcessingCaps = _pWineCaps->VertexProcessingCaps; \
_pD3D8Caps->MaxActiveLights = _pWineCaps->MaxActiveLights; \
_pD3D8Caps->MaxUserClipPlanes = _pWineCaps->MaxUserClipPlanes; \
_pD3D8Caps->MaxVertexBlendMatrices = _pWineCaps->MaxVertexBlendMatrices; \
_pD3D8Caps->MaxVertexBlendMatrixIndex = _pWineCaps->MaxVertexBlendMatrixIndex; \
_pD3D8Caps->MaxPointSize = _pWineCaps->MaxPointSize; \
_pD3D8Caps->MaxPrimitiveCount = _pWineCaps->MaxPrimitiveCount; \
_pD3D8Caps->MaxVertexIndex = _pWineCaps->MaxVertexIndex; \
_pD3D8Caps->MaxStreams = _pWineCaps->MaxStreams; \
_pD3D8Caps->MaxStreamStride = _pWineCaps->MaxStreamStride; \
_pD3D8Caps->VertexShaderVersion = _pWineCaps->VertexShaderVersion; \
_pD3D8Caps->MaxVertexShaderConst = _pWineCaps->MaxVertexShaderConst; \
_pD3D8Caps->PixelShaderVersion = _pWineCaps->PixelShaderVersion; \
_pD3D8Caps->MaxPixelShaderValue = _pWineCaps->PixelShader1xMaxValue;
_pD3D8Caps->DeviceType = (D3DDEVTYPE) (_pWineCaps)->DeviceType; \
_pD3D8Caps->AdapterOrdinal = (_pWineCaps)->AdapterOrdinal; \
_pD3D8Caps->Caps = (_pWineCaps)->Caps; \
_pD3D8Caps->Caps2 = (_pWineCaps)->Caps2; \
_pD3D8Caps->Caps3 = (_pWineCaps)->Caps3; \
_pD3D8Caps->PresentationIntervals = (_pWineCaps)->PresentationIntervals; \
_pD3D8Caps->CursorCaps = (_pWineCaps)->CursorCaps; \
_pD3D8Caps->DevCaps = (_pWineCaps)->DevCaps; \
_pD3D8Caps->PrimitiveMiscCaps = (_pWineCaps)->PrimitiveMiscCaps; \
_pD3D8Caps->RasterCaps = (_pWineCaps)->RasterCaps; \
_pD3D8Caps->ZCmpCaps = (_pWineCaps)->ZCmpCaps; \
_pD3D8Caps->SrcBlendCaps = (_pWineCaps)->SrcBlendCaps; \
_pD3D8Caps->DestBlendCaps = (_pWineCaps)->DestBlendCaps; \
_pD3D8Caps->AlphaCmpCaps = (_pWineCaps)->AlphaCmpCaps; \
_pD3D8Caps->ShadeCaps = (_pWineCaps)->ShadeCaps; \
_pD3D8Caps->TextureCaps = (_pWineCaps)->TextureCaps; \
_pD3D8Caps->TextureFilterCaps = (_pWineCaps)->TextureFilterCaps; \
_pD3D8Caps->CubeTextureFilterCaps = (_pWineCaps)->CubeTextureFilterCaps; \
_pD3D8Caps->VolumeTextureFilterCaps = (_pWineCaps)->VolumeTextureFilterCaps; \
_pD3D8Caps->TextureAddressCaps = (_pWineCaps)->TextureAddressCaps; \
_pD3D8Caps->VolumeTextureAddressCaps = (_pWineCaps)->VolumeTextureAddressCaps; \
_pD3D8Caps->LineCaps = (_pWineCaps)->LineCaps; \
_pD3D8Caps->MaxTextureWidth = (_pWineCaps)->MaxTextureWidth; \
_pD3D8Caps->MaxTextureHeight = (_pWineCaps)->MaxTextureHeight; \
_pD3D8Caps->MaxVolumeExtent = (_pWineCaps)->MaxVolumeExtent; \
_pD3D8Caps->MaxTextureRepeat = (_pWineCaps)->MaxTextureRepeat; \
_pD3D8Caps->MaxTextureAspectRatio = (_pWineCaps)->MaxTextureAspectRatio; \
_pD3D8Caps->MaxAnisotropy = (_pWineCaps)->MaxAnisotropy; \
_pD3D8Caps->MaxVertexW = (_pWineCaps)->MaxVertexW; \
_pD3D8Caps->GuardBandLeft = (_pWineCaps)->GuardBandLeft; \
_pD3D8Caps->GuardBandTop = (_pWineCaps)->GuardBandTop; \
_pD3D8Caps->GuardBandRight = (_pWineCaps)->GuardBandRight; \
_pD3D8Caps->GuardBandBottom = (_pWineCaps)->GuardBandBottom; \
_pD3D8Caps->ExtentsAdjust = (_pWineCaps)->ExtentsAdjust; \
_pD3D8Caps->StencilCaps = (_pWineCaps)->StencilCaps; \
_pD3D8Caps->FVFCaps = (_pWineCaps)->FVFCaps; \
_pD3D8Caps->TextureOpCaps = (_pWineCaps)->TextureOpCaps; \
_pD3D8Caps->MaxTextureBlendStages = (_pWineCaps)->MaxTextureBlendStages; \
_pD3D8Caps->MaxSimultaneousTextures = (_pWineCaps)->MaxSimultaneousTextures; \
_pD3D8Caps->VertexProcessingCaps = (_pWineCaps)->VertexProcessingCaps; \
_pD3D8Caps->MaxActiveLights = (_pWineCaps)->MaxActiveLights; \
_pD3D8Caps->MaxUserClipPlanes = (_pWineCaps)->MaxUserClipPlanes; \
_pD3D8Caps->MaxVertexBlendMatrices = (_pWineCaps)->MaxVertexBlendMatrices; \
_pD3D8Caps->MaxVertexBlendMatrixIndex = (_pWineCaps)->MaxVertexBlendMatrixIndex; \
_pD3D8Caps->MaxPointSize = (_pWineCaps)->MaxPointSize; \
_pD3D8Caps->MaxPrimitiveCount = (_pWineCaps)->MaxPrimitiveCount; \
_pD3D8Caps->MaxVertexIndex = (_pWineCaps)->MaxVertexIndex; \
_pD3D8Caps->MaxStreams = (_pWineCaps)->MaxStreams; \
_pD3D8Caps->MaxStreamStride = (_pWineCaps)->MaxStreamStride; \
_pD3D8Caps->VertexShaderVersion = (_pWineCaps)->VertexShaderVersion; \
_pD3D8Caps->MaxVertexShaderConst = (_pWineCaps)->MaxVertexShaderConst; \
_pD3D8Caps->PixelShaderVersion = (_pWineCaps)->PixelShaderVersion; \
_pD3D8Caps->MaxPixelShaderValue = (_pWineCaps)->PixelShader1xMaxValue;
void fixup_caps(WINED3DCAPS *pWineCaps) DECLSPEC_HIDDEN;

View file

@ -458,7 +458,7 @@ static HRESULT WINAPI d3d8_device_GetDirect3D(IDirect3DDevice8 *iface, IDirect3D
static HRESULT WINAPI d3d8_device_GetDeviceCaps(IDirect3DDevice8 *iface, D3DCAPS8 *caps)
{
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
WINED3DCAPS *wined3d_caps;
WINED3DCAPS wined3d_caps;
HRESULT hr;
TRACE("iface %p, caps %p.\n", iface, caps);
@ -466,16 +466,12 @@ static HRESULT WINAPI d3d8_device_GetDeviceCaps(IDirect3DDevice8 *iface, D3DCAPS
if (!caps)
return D3DERR_INVALIDCALL;
if (!(wined3d_caps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wined3d_caps))))
return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
wined3d_mutex_lock();
hr = wined3d_device_get_device_caps(device->wined3d_device, wined3d_caps);
hr = wined3d_device_get_device_caps(device->wined3d_device, &wined3d_caps);
wined3d_mutex_unlock();
fixup_caps(wined3d_caps);
WINECAPSTOD3D8CAPS(caps, wined3d_caps)
HeapFree(GetProcessHeap(), 0, wined3d_caps);
fixup_caps(&wined3d_caps);
WINECAPSTOD3D8CAPS(caps, &wined3d_caps)
return hr;
}

View file

@ -334,7 +334,7 @@ void fixup_caps(WINED3DCAPS *caps)
static HRESULT WINAPI d3d8_GetDeviceCaps(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type, D3DCAPS8 *caps)
{
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
WINED3DCAPS *wined3d_caps;
WINED3DCAPS wined3d_caps;
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, adapter, device_type, caps);
@ -342,16 +342,12 @@ static HRESULT WINAPI d3d8_GetDeviceCaps(IDirect3D8 *iface, UINT adapter, D3DDEV
if (!caps)
return D3DERR_INVALIDCALL;
if (!(wined3d_caps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wined3d_caps))))
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
hr = wined3d_get_device_caps(d3d8->wined3d, adapter, device_type, wined3d_caps);
hr = wined3d_get_device_caps(d3d8->wined3d, adapter, device_type, &wined3d_caps);
wined3d_mutex_unlock();
fixup_caps(wined3d_caps);
WINECAPSTOD3D8CAPS(caps, wined3d_caps)
HeapFree(GetProcessHeap(), 0, wined3d_caps);
fixup_caps(&wined3d_caps);
WINECAPSTOD3D8CAPS(caps, &wined3d_caps)
return hr;
}