diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 52258b2e6..ebd92cb3f 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -2187,9 +2187,13 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE D3D9DeviceEx::SetClipPlane(DWORD Index, const float* pPlane) { D3D9DeviceLock lock = LockDevice(); - if (unlikely(Index >= caps::MaxClipPlanes || !pPlane)) + if (unlikely(!pPlane)) return D3DERR_INVALIDCALL; + // Higher indexes will be capped to the last valid index + if (unlikely(Index >= caps::MaxClipPlanes)) + Index = caps::MaxClipPlanes - 1; + if (unlikely(ShouldRecord())) return m_recorder->SetClipPlane(Index, pPlane); @@ -2213,9 +2217,13 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE D3D9DeviceEx::GetClipPlane(DWORD Index, float* pPlane) { D3D9DeviceLock lock = LockDevice(); - if (unlikely(Index >= caps::MaxClipPlanes || !pPlane)) + if (unlikely(!pPlane)) return D3DERR_INVALIDCALL; + // Higher indexes will be capped to the last valid index + if (unlikely(Index >= caps::MaxClipPlanes)) + Index = caps::MaxClipPlanes - 1; + for (uint32_t i = 0; i < 4; i++) pPlane[i] = m_state.clipPlanes[Index].coeff[i];