mirror of
https://github.com/reactos/wine.git
synced 2024-12-14 07:08:41 +00:00
wined3d: Validate blit parameters in wined3d_texture_blt().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
aaa431d8a8
commit
54c3f5c0bc
@ -3598,7 +3598,6 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
|
|||||||
unsigned int src_sub_resource_idx = 0;
|
unsigned int src_sub_resource_idx = 0;
|
||||||
DWORD src_ds_flags, dst_ds_flags;
|
DWORD src_ds_flags, dst_ds_flags;
|
||||||
BOOL scale, convert;
|
BOOL scale, convert;
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
static const DWORD simple_blit = WINED3D_BLT_ASYNC
|
static const DWORD simple_blit = WINED3D_BLT_ASYNC
|
||||||
| WINED3D_BLT_COLOR_FILL
|
| WINED3D_BLT_COLOR_FILL
|
||||||
@ -3632,20 +3631,6 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
|
|||||||
src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
|
src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
|
|
||||||
|| (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
|
|
||||||
{
|
|
||||||
WARN("Surface is busy, returning WINEDDERR_SURFACEBUSY.\n");
|
|
||||||
return WINEDDERR_SURFACEBUSY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FAILED(hr = wined3d_texture_check_box_dimensions(dst_texture, dst_surface->texture_level, &dst_box)))
|
|
||||||
return hr;
|
|
||||||
|
|
||||||
if (src_texture && FAILED(hr = wined3d_texture_check_box_dimensions(src_texture,
|
|
||||||
src_surface->texture_level, &src_box)))
|
|
||||||
return hr;
|
|
||||||
|
|
||||||
if (!fx || !(fx->fx))
|
if (!fx || !(fx->fx))
|
||||||
flags &= ~WINED3D_BLT_FX;
|
flags &= ~WINED3D_BLT_FX;
|
||||||
|
|
||||||
@ -3738,17 +3723,10 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
|
|||||||
if (SUCCEEDED(wined3d_surface_depth_fill(dst_surface, dst_rect, color.r)))
|
if (SUCCEEDED(wined3d_surface_depth_fill(dst_surface, dst_rect, color.r)))
|
||||||
return WINED3D_OK;
|
return WINED3D_OK;
|
||||||
}
|
}
|
||||||
else
|
else if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_texture->resource.draw_binding,
|
||||||
|
src_rect, dst_surface, dst_texture->resource.draw_binding, dst_rect)))
|
||||||
{
|
{
|
||||||
if (src_ds_flags != dst_ds_flags)
|
return WINED3D_OK;
|
||||||
{
|
|
||||||
WARN("Rejecting depth / stencil blit between incompatible formats.\n");
|
|
||||||
return WINED3DERR_INVALIDCALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_texture->resource.draw_binding,
|
|
||||||
src_rect, dst_surface, dst_texture->resource.draw_binding, dst_rect)))
|
|
||||||
return WINED3D_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2627,7 +2627,11 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned
|
|||||||
const RECT *dst_rect, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx,
|
const RECT *dst_rect, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx,
|
||||||
const RECT *src_rect, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
|
const RECT *src_rect, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
|
||||||
{
|
{
|
||||||
|
struct wined3d_box src_box = {src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1};
|
||||||
|
struct wined3d_box dst_box = {dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom, 0, 1};
|
||||||
struct wined3d_texture_sub_resource *dst_resource, *src_resource = NULL;
|
struct wined3d_texture_sub_resource *dst_resource, *src_resource = NULL;
|
||||||
|
unsigned int dst_format_flags, src_format_flags = 0;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("dst_texture %p, dst_sub_resource_idx %u, dst_rect %s, src_texture %p, "
|
TRACE("dst_texture %p, dst_sub_resource_idx %u, dst_rect %s, src_texture %p, "
|
||||||
"src_sub_resource_idx %u, src_rect %s, flags %#x, fx %p, filter %s.\n",
|
"src_sub_resource_idx %u, src_rect %s, flags %#x, fx %p, filter %s.\n",
|
||||||
@ -2638,11 +2642,42 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned
|
|||||||
|| dst_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
|
|| dst_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
|
|
||||||
|
dst_format_flags = dst_texture->resource.format_flags;
|
||||||
|
if (FAILED(hr = wined3d_texture_check_box_dimensions(dst_texture,
|
||||||
|
dst_sub_resource_idx % dst_texture->level_count, &dst_box)))
|
||||||
|
return hr;
|
||||||
|
|
||||||
if (src_texture)
|
if (src_texture)
|
||||||
{
|
{
|
||||||
if (!(src_resource = wined3d_texture_get_sub_resource(src_texture, src_sub_resource_idx))
|
if (!(src_resource = wined3d_texture_get_sub_resource(src_texture, src_sub_resource_idx))
|
||||||
|| src_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
|
|| src_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
|
|
||||||
|
src_format_flags = src_texture->resource.format_flags;
|
||||||
|
if (FAILED(hr = wined3d_texture_check_box_dimensions(src_texture,
|
||||||
|
src_sub_resource_idx % src_texture->level_count, &src_box)))
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
|
||||||
|
|| (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
|
||||||
|
{
|
||||||
|
WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
|
||||||
|
return WINEDDERR_SURFACEBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((dst_format_flags & WINED3DFMT_FLAG_BLOCKS) && (flags & WINED3D_BLT_COLOR_FILL))
|
||||||
|
{
|
||||||
|
WARN("Color fill not supported on block-based formats.\n");
|
||||||
|
return WINED3DERR_INVALIDCALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((src_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
|
||||||
|
!= (dst_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
|
||||||
|
&& !(flags & WINED3D_BLT_DEPTH_FILL))
|
||||||
|
{
|
||||||
|
WARN("Rejecting depth/stencil blit between incompatible formats.\n");
|
||||||
|
return WINED3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wined3d_surface_blt(dst_resource->u.surface, dst_rect,
|
return wined3d_surface_blt(dst_resource->u.surface, dst_rect,
|
||||||
|
Loading…
Reference in New Issue
Block a user