Skip to content

Commit

Permalink
[WINESYNC] d3d8: Forbid setting a viewport larger than the render tar…
Browse files Browse the repository at this point in the history
…get.

Signed-off-by: Matteo Bruni <[email protected]>
Signed-off-by: Henri Verbeet <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>

wine commit id aa5fa7080631d9135dff10fdf96e21487e21e4f8 by Matteo Bruni <[email protected]>
  • Loading branch information
winesync authored and DarkFire01 committed Sep 12, 2023
1 parent 87b6312 commit cad494c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion dll/directx/wine/d3d8/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,18 +1619,37 @@ static HRESULT WINAPI d3d8_device_MultiplyTransform(IDirect3DDevice8 *iface,
static HRESULT WINAPI d3d8_device_SetViewport(IDirect3DDevice8 *iface, const D3DVIEWPORT8 *viewport)
{
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
struct wined3d_sub_resource_desc rt_desc;
struct wined3d_rendertarget_view *rtv;
struct d3d8_surface *surface;
struct wined3d_viewport vp;

TRACE("iface %p, viewport %p.\n", iface, viewport);

wined3d_mutex_lock();
if (!(rtv = wined3d_device_get_rendertarget_view(device->wined3d_device, 0)))
{
wined3d_mutex_unlock();
return D3DERR_NOTFOUND;
}
surface = wined3d_rendertarget_view_get_sub_resource_parent(rtv);
wined3d_texture_get_sub_resource_desc(surface->wined3d_texture, surface->sub_resource_idx, &rt_desc);

if (viewport->X > rt_desc.width || viewport->Width > rt_desc.width - viewport->X
|| viewport->Y > rt_desc.height || viewport->Height > rt_desc.height - viewport->Y)
{
WARN("Invalid viewport, returning D3DERR_INVALIDCALL.\n");
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}

vp.x = viewport->X;
vp.y = viewport->Y;
vp.width = viewport->Width;
vp.height = viewport->Height;
vp.min_z = viewport->MinZ;
vp.max_z = viewport->MaxZ;

wined3d_mutex_lock();
wined3d_device_set_viewport(device->wined3d_device, &vp);
wined3d_mutex_unlock();

Expand Down

0 comments on commit cad494c

Please sign in to comment.