From 7b20951ed41a657e6b0617d03169f8420cb6a7f0 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 24 Feb 2020 16:11:37 -0600 Subject: [PATCH] d3d8: Retrieve clip planes from the primary stateblock. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d8/d3d8_private.h | 2 +- dlls/d3d8/device.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 0fcc8bd7a0f..9bf92af7c9f 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -131,7 +131,7 @@ struct d3d8_device DWORD in_destruction : 1; DWORD padding : 14; - unsigned int vs_uniform_count; + unsigned int max_user_clip_planes, vs_uniform_count; /* The d3d8 API supports only one implicit swapchain (no D3DCREATE_ADAPTERGROUP_DEVICE, * no GetSwapchain, GetBackBuffer doesn't accept a swapchain number). */ diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 725286cd162..17ce954a7d9 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1829,15 +1829,20 @@ static HRESULT WINAPI d3d8_device_SetClipPlane(IDirect3DDevice8 *iface, DWORD in static HRESULT WINAPI d3d8_device_GetClipPlane(IDirect3DDevice8 *iface, DWORD index, float *plane) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - HRESULT hr; TRACE("iface %p, index %u, plane %p.\n", iface, index, plane); + if (index >= device->max_user_clip_planes) + { + TRACE("Plane %u requested, but only %u planes are supported.\n", index, device->max_user_clip_planes); + return WINED3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); - hr = wined3d_device_get_clip_plane(device->wined3d_device, index, (struct wined3d_vec4 *)plane); + memcpy(plane, &wined3d_stateblock_get_state(device->state)->clip_planes[index], sizeof(struct wined3d_vec4)); wined3d_mutex_unlock(); - return hr; + return D3D_OK; } static void resolve_depth_buffer(struct d3d8_device *device) @@ -3710,6 +3715,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine } wined3d_get_device_caps(wined3d, adapter, device_type, &caps); + device->max_user_clip_planes = caps.MaxUserClipPlanes; device->vs_uniform_count = caps.MaxVertexShaderConst; if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device, NULL, WINED3D_SBT_PRIMARY, &device->state)))