From b98ece0d38ca3ec401370ccf95eb08946533850c Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 4 Apr 2017 09:07:47 +0200 Subject: [PATCH] wined3d: Use the blitter interface in wined3d_cs_exec_clear(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/arb_program_shader.c | 6 +-- dlls/wined3d/cs.c | 5 +-- dlls/wined3d/device.c | 4 +- dlls/wined3d/surface.c | 65 ++++++++++++++++++------------- dlls/wined3d/wined3d_private.h | 2 +- 5 files changed, 45 insertions(+), 37 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index db07d761500..4eb603f797d 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7877,14 +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 *clear_rect, + unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, 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, - clear_rect, draw_rect, flags, colour, depth, stencil); + next->ops->blitter_clear(next, device, rt_count, fb, rect_count, + clear_rects, draw_rect, flags, colour, depth, stencil); } static const struct wined3d_blitter_ops arbfp_blitter_ops = diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 423650c6adf..841ceca5c86 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -420,9 +420,8 @@ static void wined3d_cs_exec_clear(struct wined3d_cs *cs, const void *data) device = cs->device; wined3d_get_draw_rect(state, &draw_rect); - device_clear_render_targets(device, device->adapter->gl_info.limits.buffers, - state->fb, op->rect_count, op->rects, &draw_rect, op->flags, - &op->color, op->depth, op->stencil); + device->blitter->ops->blitter_clear(device->blitter, device, device->adapter->gl_info.limits.buffers, + state->fb, op->rect_count, op->rects, &draw_rect, op->flags, &op->color, op->depth, op->stencil); if (op->flags & WINED3DCLEAR_TARGET) { diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 119775592ed..11a56f28885 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4190,13 +4190,13 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi { struct wined3d_fb_state fb = {&view, NULL}; device->blitter->ops->blitter_clear(device->blitter, device, 1, &fb, - rect, &draw_rect, flags, color, depth, stencil); + 1, 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, &draw_rect, flags, color, depth, stencil); + 1, rect, &draw_rect, flags, color, depth, stencil); } return WINED3D_OK; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index b8f10ae8bbe..cc5444bb598 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -2449,14 +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 *clear_rect, + unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, 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, - clear_rect, draw_rect, flags, colour, depth, stencil); + next->ops->blitter_clear(next, device, rt_count, fb, rect_count, + clear_rects, draw_rect, flags, colour, depth, stencil); } static void fbo_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op, @@ -2586,7 +2586,7 @@ 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 *clear_rect, + unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) { struct wined3d_rendertarget_view *view; @@ -2627,14 +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, - clear_rect, draw_rect, flags, colour, depth, stencil); + device_clear_render_targets(device, rt_count, fb, rect_count, + clear_rects, draw_rect, flags, colour, depth, stencil); return; next: if ((next = blitter->next)) - next->ops->blitter_clear(next, device, rt_count, fb, - clear_rect, draw_rect, flags, colour, depth, stencil); + next->ops->blitter_clear(next, device, rt_count, fb, rect_count, + clear_rects, draw_rect, flags, colour, depth, stencil); } static void ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op, @@ -3425,35 +3425,44 @@ 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 *clear_rect, + unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil) { struct wined3d_color c = {depth, 0.0f, 0.0f, 0.0f}; struct wined3d_rendertarget_view *view; struct wined3d_box box; - unsigned int i; + unsigned int i, j; - 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) + if (!rect_count) { - for (i = 0; i < rt_count; ++i) - { - if ((view = fb->render_targets[i])) - surface_cpu_blt_colour_fill(view, &box, colour); - } + rect_count = 1; + clear_rects = draw_rect; } - if ((flags & WINED3DCLEAR_ZBUFFER) && (view = fb->depth_stencil)) - surface_cpu_blt_colour_fill(view, &box, &c); + for (i = 0; i < rect_count; ++i) + { + box.left = max(clear_rects[i].left, draw_rect->left); + box.top = max(clear_rects[i].top, draw_rect->top); + box.right = min(clear_rects[i].right, draw_rect->right); + box.bottom = min(clear_rects[i].bottom, draw_rect->bottom); + box.front = 0; + box.back = 1; + + if (box.left >= box.right || box.top >= box.bottom) + continue; + + if (flags & WINED3DCLEAR_TARGET) + { + for (j = 0; j < rt_count; ++j) + { + if ((view = fb->render_targets[j])) + surface_cpu_blt_colour_fill(view, &box, colour); + } + } + + if ((flags & WINED3DCLEAR_ZBUFFER) && (view = fb->depth_stencil)) + surface_cpu_blt_colour_fill(view, &box, &c); + } if (flags & ~(WINED3DCLEAR_TARGET | WINED3DCLEAR_ZBUFFER)) FIXME("flags %#x not implemented.\n", flags); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ee25862821a..0211d8e24bc 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1877,7 +1877,7 @@ 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 *clear_rect, + unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, 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,