Henri Verbeet : wined3d: Pass a wined3d_fb_state structure to wined3d_blitter_ops.blitter_clear().

Alexandre Julliard julliard at winehq.org
Tue Apr 4 14:54:52 CDT 2017


Module: wine
Branch: master
Commit: d8f9b6b7f7c3b704323d34aa744b9a0036ad93c3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d8f9b6b7f7c3b704323d34aa744b9a0036ad93c3

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Apr  4 09:07:45 2017 +0200

wined3d: Pass a wined3d_fb_state structure to wined3d_blitter_ops.blitter_clear().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/arb_program_shader.c |  6 +--
 dlls/wined3d/device.c             | 11 ++++-
 dlls/wined3d/surface.c            | 84 ++++++++++++++++++++++-----------------
 dlls/wined3d/wined3d_private.h    |  4 +-
 4 files changed, 63 insertions(+), 42 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 995900f..139cd18 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -7877,13 +7877,13 @@ 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,
-        struct wined3d_rendertarget_view *view, 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 *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, view, rect, flags, colour, depth, stencil);
+        next->ops->blitter_clear(next, device, rt_count, fb, 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 59d9769..4016b74 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4185,7 +4185,16 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi
             return hr;
     }
 
-    device->blitter->ops->blitter_clear(device->blitter, device, view, rect, flags, color, depth, stencil);
+    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);
+    }
+    else
+    {
+        struct wined3d_fb_state fb = {NULL, view};
+        device->blitter->ops->blitter_clear(device->blitter, device, 0, &fb, rect, flags, color, depth, stencil);
+    }
 
     return WINED3D_OK;
 }
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 09d291c..ac67149 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2449,13 +2449,13 @@ static void fbo_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_
 }
 
 static void fbo_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device,
-        struct wined3d_rendertarget_view *view, 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 *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, view, rect, flags, colour, depth, stencil);
+        next->ops->blitter_clear(next, device, rt_count, fb, rect, flags, colour, depth, stencil);
 }
 
 static void fbo_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
@@ -2585,45 +2585,54 @@ 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,
-        struct wined3d_rendertarget_view *view, 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 *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_resource *resource = view->resource;
-    struct wined3d_fb_state fb = {&view, NULL};
+    struct wined3d_resource *resource;
     struct wined3d_blitter *next;
+    unsigned int i;
 
-    if (resource->pool == WINED3D_POOL_SYSTEM_MEM)
-        goto next;
-
-    if (flags != WINED3DCLEAR_TARGET)
+    if (flags & WINED3DCLEAR_TARGET)
     {
-        struct wined3d_fb_state fb = {NULL, view};
+        for (i = 0; i < rt_count; ++i)
+        {
+            if (!(view = fb->render_targets[i]))
+                continue;
 
-        device_clear_render_targets(device, 0, &fb, 1, rect, &draw_rect, flags, NULL, depth, stencil);
-        return;
+            resource = view->resource;
+            if (resource->pool == WINED3D_POOL_SYSTEM_MEM)
+                goto next;
+
+            if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+            {
+                if (!((view->format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE)
+                        || (resource->usage & WINED3DUSAGE_RENDERTARGET)))
+                    goto next;
+            }
+            else if (!(resource->usage & WINED3DUSAGE_RENDERTARGET))
+            {
+                goto next;
+            }
+
+            /* FIXME: We should reject colour fills on formats with fixups,
+             * but this would break P8 colour fills for example. */
+        }
     }
 
-    if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+    if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL))
     {
-        if (!((view->format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE)
-                || (resource->usage & WINED3DUSAGE_RENDERTARGET)))
+        if (fb->depth_stencil && fb->depth_stencil->resource->pool == WINED3D_POOL_SYSTEM_MEM)
             goto next;
     }
-    else if (!(resource->usage & WINED3DUSAGE_RENDERTARGET))
-    {
-        goto next;
-    }
 
-    /* FIXME: We should reject colour fills on formats with fixups, but this
-     * would break P8 colour fills for example. */
-
-    device_clear_render_targets(device, 1, &fb, 1, rect, &draw_rect, flags, colour, 0.0f, 0);
+    device_clear_render_targets(device, rt_count, fb, 1, rect, &draw_rect, flags, colour, depth, stencil);
     return;
 
 next:
     if ((next = blitter->next))
-        next->ops->blitter_clear(next, device, view, rect, flags, colour, depth, stencil);
+        next->ops->blitter_clear(next, device, rt_count, fb, rect, flags, colour, depth, stencil);
 }
 
 static void ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
@@ -3414,25 +3423,28 @@ 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,
-        struct wined3d_rendertarget_view *view, 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 *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;
+    unsigned int i;
 
-    if (flags == WINED3DCLEAR_TARGET)
+    if (flags & WINED3DCLEAR_TARGET)
     {
-        surface_cpu_blt_colour_fill(view, &box, colour);
-        return;
+        for (i = 0; i < rt_count; ++i)
+        {
+            if ((view = fb->render_targets[i]))
+                surface_cpu_blt_colour_fill(view, &box, colour);
+        }
     }
 
-    if (flags == WINED3DCLEAR_ZBUFFER)
-    {
+    if ((flags & WINED3DCLEAR_ZBUFFER) && (view = fb->depth_stencil))
         surface_cpu_blt_colour_fill(view, &box, &c);
-        return;
-    }
 
-    FIXME("flags %#x not implemented.\n", flags);
+    if (flags & ~(WINED3DCLEAR_TARGET | WINED3DCLEAR_ZBUFFER))
+        FIXME("flags %#x not implemented.\n", flags);
 }
 
 static void cpu_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 799f63b..17239e5 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,
-            struct wined3d_rendertarget_view *view, 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 *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,




More information about the wine-cvs mailing list