Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/ddraw/ddraw_private.h | 4 ++++ dlls/ddraw/device.c | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 0ae453287093..0b6666a85159 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -38,6 +38,8 @@ #include "wine/list.h" #include "wine/wined3d.h"
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) + extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN; extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
@@ -341,6 +343,8 @@ struct d3d_device /* Handle management */ struct ddraw_handle_table handle_table; D3DMATRIXHANDLE world, proj, view; + + struct wined3d_vec4 user_clip_planes[D3DMAXUSERCLIPPLANES]; };
HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface, diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 7d92df5603bf..32a2f1a6be50 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -6457,6 +6457,7 @@ static HRESULT WINAPI d3d_device7_GetLightEnable_FPUPreserve(IDirect3DDevice7 *i static HRESULT d3d_device7_SetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane) { struct d3d_device *device = impl_from_IDirect3DDevice7(iface); + const struct wined3d_vec4 *wined3d_plane; HRESULT hr;
TRACE("iface %p, idx %u, plane %p.\n", iface, idx, plane); @@ -6464,8 +6465,16 @@ static HRESULT d3d_device7_SetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DV if (!plane) return DDERR_INVALIDPARAMS;
+ wined3d_plane = (struct wined3d_vec4 *)plane; + wined3d_mutex_lock(); - hr = wined3d_device_set_clip_plane(device->wined3d_device, idx, (struct wined3d_vec4 *)plane); + hr = wined3d_device_set_clip_plane(device->wined3d_device, idx, wined3d_plane); + if (hr == WINED3DERR_INVALIDCALL && idx < ARRAY_SIZE(device->user_clip_planes)) + { + WARN("Clip plane %u is not supported.\n", idx); + device->user_clip_planes[idx] = *wined3d_plane; + hr = D3D_OK; + } wined3d_mutex_unlock();
return hr; @@ -6505,6 +6514,7 @@ static HRESULT WINAPI d3d_device7_SetClipPlane_FPUPreserve(IDirect3DDevice7 *ifa static HRESULT d3d_device7_GetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane) { struct d3d_device *device = impl_from_IDirect3DDevice7(iface); + struct wined3d_vec4 *wined3d_plane; HRESULT hr;
TRACE("iface %p, idx %u, plane %p.\n", iface, idx, plane); @@ -6512,8 +6522,16 @@ static HRESULT d3d_device7_GetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DV if (!plane) return DDERR_INVALIDPARAMS;
+ wined3d_plane = (struct wined3d_vec4 *)plane; + wined3d_mutex_lock(); - hr = wined3d_device_get_clip_plane(device->wined3d_device, idx, (struct wined3d_vec4 *)plane); + hr = wined3d_device_get_clip_plane(device->wined3d_device, idx, wined3d_plane); + if (hr == WINED3DERR_INVALIDCALL && idx < ARRAY_SIZE(device->user_clip_planes)) + { + WARN("Clip plane %u is not supported.\n", idx); + *wined3d_plane = device->user_clip_planes[idx]; + hr = D3D_OK; + } wined3d_mutex_unlock();
return hr;