[PATCH 3/6] d3d8: Allocate WINED3DCAPS on stack.

Józef Kucia jkucia at codeweavers.com
Mon Feb 20 06:12:12 CST 2017


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/d3d8/d3d8_private.h | 106 +++++++++++++++++++++++------------------------
 dlls/d3d8/device.c       |  12 ++----
 dlls/d3d8/directx.c      |  12 ++----
 3 files changed, 61 insertions(+), 69 deletions(-)

diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 8177b5e..31485d0 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -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;
 
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 9592342..e2efa24 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -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;
 }
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index d307265..ca7af61 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -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;
 }
-- 
2.10.2




More information about the wine-patches mailing list