Signed-off-by: Stefan Dösinger stefan@codeweavers.com --- dlls/wined3d/surface.c | 35 ++++++++++++++++++++-------------- dlls/wined3d/view.c | 14 ++++++++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 37 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 5feeba3be2d..448c8689342 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1276,17 +1276,9 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view,
c = wined3d_format_convert_from_float(view->format, colour); bpp = view->format->byte_count; - w = min(box->right, view->width) - min(box->left, view->width); - h = min(box->bottom, view->height) - min(box->top, view->height); - if (view->resource->type != WINED3D_RTYPE_TEXTURE_3D) - { - d = 1; - } - else - { - d = wined3d_texture_get_level_depth(texture, level); - d = min(box->back, d) - min(box->front, d); - } + w = box->right - box->left; + h = box->bottom - box->top; + d = box->back - box->front;
map_binding = texture->resource.map_binding; if (!wined3d_texture_load_location(texture, view->sub_resource_idx, context, map_binding)) @@ -1361,13 +1353,22 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view, context_release(context); }
+static bool wined3d_box_intersect(struct wined3d_box *ret, const struct wined3d_box *b1, + const struct wined3d_box *b2) +{ + wined3d_box_set(ret, max(b1->left, b2->left), max(b1->top, b2->top), + min(b1->right, b2->right), min(b1->bottom, b2->bottom), + max(b1->front, b2->front), min(b1->back, b2->back)); + return ret->right > ret->left && ret->bottom > ret->top && ret->back > ret->front; +} + static void cpu_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device, 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_box box, box_clip, box_view; struct wined3d_rendertarget_view *view; - struct wined3d_box box; unsigned int i, j;
if (!rect_count) @@ -1393,7 +1394,11 @@ static void cpu_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de for (j = 0; j < rt_count; ++j) { if ((view = fb->render_targets[j])) - surface_cpu_blt_colour_fill(view, &box, colour); + { + wined3d_rendertarget_view_get_box(view, &box_view); + if (wined3d_box_intersect(&box_clip, &box_view, &box)) + surface_cpu_blt_colour_fill(view, &box_clip, colour); + } } }
@@ -1403,7 +1408,9 @@ static void cpu_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de || (view->format->stencil_size && !(flags & WINED3DCLEAR_STENCIL))) FIXME("Clearing %#x on %s.\n", flags, debug_d3dformat(view->format->id));
- surface_cpu_blt_colour_fill(view, &box, &c); + wined3d_rendertarget_view_get_box(view, &box_view); + if (wined3d_box_intersect(&box_clip, &box_view, &box)) + surface_cpu_blt_colour_fill(view, &box_clip, &c); } } } diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 752563508c8..f2dea8f0f9a 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -534,6 +534,20 @@ DWORD wined3d_rendertarget_view_get_locations(const struct wined3d_rendertarget_ return ret; }
+void wined3d_rendertarget_view_get_box(struct wined3d_rendertarget_view *view, + struct wined3d_box *box) +{ + if (view->resource->type != WINED3D_RTYPE_TEXTURE_3D) + { + wined3d_box_set(box, 0, 0, view->width, view->height, 0, 1); + } + else + { + struct wined3d_texture *texture = texture_from_resource(view->resource); + wined3d_texture_get_level_box(texture, view->sub_resource_idx, box); + } +} + static void wined3d_render_target_view_gl_cs_init(void *object) { struct wined3d_rendertarget_view_gl *view_gl = object; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3a12f5ef261..17afc183adb 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -5287,6 +5287,8 @@ struct wined3d_rendertarget_view void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN; void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view, const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN; +void wined3d_rendertarget_view_get_box(struct wined3d_rendertarget_view *view, + struct wined3d_box *box) DECLSPEC_HIDDEN; void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view, DWORD location) DECLSPEC_HIDDEN; void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view,