wined3d: Move clear box clipping to cpu_blitter_clear.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Stefan Dösinger 2022-05-13 15:54:34 +03:00 committed by Alexandre Julliard
parent 2a88b42036
commit 122643b6e2
3 changed files with 37 additions and 14 deletions

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -5286,6 +5286,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,