From 52979b6b29b72ad2999fca73694fb6db8f6b90e1 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 4 Apr 2017 09:07:46 +0200 Subject: [PATCH] wined3d: Pass the draw rectangle to wined3d_blitter_ops.blitter_clear(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/arb_program_shader.c | 7 +++--- dlls/wined3d/device.c | 9 +++++--- dlls/wined3d/surface.c | 36 ++++++++++++++++++++----------- dlls/wined3d/wined3d_private.h | 4 ++-- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 139cd188e47..db07d761500 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7877,13 +7877,14 @@ static void arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli } static void arbfp_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device, - unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *rect, - DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) + unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *clear_rect, + const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) { struct wined3d_blitter *next; if ((next = blitter->next)) - next->ops->blitter_clear(next, device, rt_count, fb, rect, flags, colour, depth, stencil); + next->ops->blitter_clear(next, device, rt_count, fb, + clear_rect, draw_rect, flags, colour, depth, stencil); } static const struct wined3d_blitter_ops arbfp_blitter_ops = diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 4016b74be37..119775592ed 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4148,7 +4148,7 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi const struct wined3d_color *color, float depth, DWORD stencil) { struct wined3d_resource *resource; - RECT r; + RECT draw_rect, r; TRACE("device %p, view %p, rect %s, flags %#x, color %s, depth %.8e, stencil %u.\n", device, view, wine_dbgstr_rect(rect), flags, debug_color(color), depth, stencil); @@ -4185,15 +4185,18 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi return hr; } + SetRect(&draw_rect, 0, 0, view->width, view->height); if (flags == WINED3DCLEAR_TARGET) { struct wined3d_fb_state fb = {&view, NULL}; - device->blitter->ops->blitter_clear(device->blitter, device, 1, &fb, rect, flags, color, depth, stencil); + device->blitter->ops->blitter_clear(device->blitter, device, 1, &fb, + rect, &draw_rect, flags, color, depth, stencil); } else { struct wined3d_fb_state fb = {NULL, view}; - device->blitter->ops->blitter_clear(device->blitter, device, 0, &fb, rect, flags, color, depth, stencil); + device->blitter->ops->blitter_clear(device->blitter, device, 0, &fb, + rect, &draw_rect, flags, color, depth, stencil); } return WINED3D_OK; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index ac67149ec7f..b8f10ae8bbe 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -2449,13 +2449,14 @@ static void fbo_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_ } static void fbo_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device, - unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *rect, - DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) + unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *clear_rect, + const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) { struct wined3d_blitter *next; if ((next = blitter->next)) - next->ops->blitter_clear(next, device, rt_count, fb, rect, flags, colour, depth, stencil); + next->ops->blitter_clear(next, device, rt_count, fb, + clear_rect, draw_rect, flags, colour, depth, stencil); } static void fbo_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op, @@ -2585,11 +2586,10 @@ static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info, } static void ffp_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device, - unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *rect, - DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) + unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *clear_rect, + const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) { - struct wined3d_rendertarget_view *view = rt_count ? fb->render_targets[0] : fb->depth_stencil; - const RECT draw_rect = {0, 0, view->width, view->height}; + struct wined3d_rendertarget_view *view; struct wined3d_resource *resource; struct wined3d_blitter *next; unsigned int i; @@ -2627,12 +2627,14 @@ static void ffp_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de goto next; } - device_clear_render_targets(device, rt_count, fb, 1, rect, &draw_rect, flags, colour, depth, stencil); + device_clear_render_targets(device, rt_count, fb, 1, + clear_rect, draw_rect, flags, colour, depth, stencil); return; next: if ((next = blitter->next)) - next->ops->blitter_clear(next, device, rt_count, fb, rect, flags, colour, depth, stencil); + next->ops->blitter_clear(next, device, rt_count, fb, + clear_rect, draw_rect, flags, colour, depth, stencil); } static void ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op, @@ -3423,14 +3425,24 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view, } static void cpu_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device, - unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *rect, - DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) + unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *clear_rect, + const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) { - const struct wined3d_box box = {rect->left, rect->top, rect->right, rect->bottom, 0, 1}; struct wined3d_color c = {depth, 0.0f, 0.0f, 0.0f}; struct wined3d_rendertarget_view *view; + struct wined3d_box box; unsigned int i; + box.left = max(clear_rect->left, draw_rect->left); + box.top = max(clear_rect->top, draw_rect->top); + box.right = min(clear_rect->right, draw_rect->right); + box.bottom = min(clear_rect->bottom, draw_rect->bottom); + box.front = 0; + box.back = 1; + + if (box.left >= box.right || box.top >= box.bottom) + return; + if (flags & WINED3DCLEAR_TARGET) { for (i = 0; i < rt_count; ++i) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 17239e57245..ee25862821a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1877,8 +1877,8 @@ struct wined3d_blitter_ops { void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context); void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device, - unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *rect, - DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil); + unsigned int rt_count, const struct wined3d_fb_state *fb, const RECT *clear_rect, + const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil); void (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,