[PATCH 1/8] wined3d: Introduce wined3d_rendertarget_view_clear().
Józef Kucia
jkucia at codeweavers.com
Sun Mar 13 18:03:02 CDT 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/device.c | 18 +-----------------
dlls/wined3d/surface.c | 22 ++--------------------
dlls/wined3d/view.c | 40 ++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d_private.h | 3 +++
4 files changed, 46 insertions(+), 37 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d032184..5dced96 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4089,34 +4089,18 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color)
{
- struct wined3d_resource *resource;
RECT r;
TRACE("device %p, view %p, rect %s, color {%.8e, %.8e, %.8e, %.8e}.\n",
device, view, wine_dbgstr_rect(rect), color->r, color->g, color->b, color->a);
- resource = view->resource;
- if (resource->type != WINED3D_RTYPE_TEXTURE_2D)
- {
- FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
- return WINED3DERR_INVALIDCALL;
- }
-
- if (view->depth > 1)
- {
- FIXME("Layered clears not implemented.\n");
- return WINED3DERR_INVALIDCALL;
- }
-
if (!rect)
{
SetRect(&r, 0, 0, view->width, view->height);
rect = &r;
}
- resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(resource), view->sub_resource_idx);
-
- return surface_color_fill(surface_from_resource(resource), rect, color);
+ return wined3d_rendertarget_view_clear(view, rect, WINED3DCLEAR_TARGET, color, 0.0f, 0);
}
struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(const struct wined3d_device *device,
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 1169c00..2165cf9 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -914,19 +914,10 @@ static BOOL surface_convert_depth_to_float(const struct wined3d_surface *surface
static HRESULT wined3d_surface_depth_fill(struct wined3d_surface *surface, const RECT *rect, float depth)
{
struct wined3d_resource *resource = &surface->container->resource;
- struct wined3d_device *device = resource->device;
struct wined3d_rendertarget_view_desc view_desc;
struct wined3d_rendertarget_view *view;
- const struct blit_shader *blitter;
HRESULT hr;
- if (!(blitter = wined3d_select_blitter(&device->adapter->gl_info, &device->adapter->d3d_info,
- WINED3D_BLIT_OP_DEPTH_FILL, NULL, 0, 0, NULL, rect, resource->usage, resource->pool, resource->format)))
- {
- FIXME("No blitter is capable of performing the requested depth fill operation.\n");
- return WINED3DERR_INVALIDCALL;
- }
-
view_desc.format_id = resource->format->id;
view_desc.u.texture.level_idx = surface->texture_level;
view_desc.u.texture.layer_idx = surface->texture_layer;
@@ -938,7 +929,7 @@ static HRESULT wined3d_surface_depth_fill(struct wined3d_surface *surface, const
return hr;
}
- hr = blitter->depth_fill(device, view, rect, depth);
+ hr = wined3d_rendertarget_view_clear(view, rect, WINED3DCLEAR_ZBUFFER, NULL, depth, 0);
wined3d_rendertarget_view_decref(view);
return hr;
@@ -2938,19 +2929,10 @@ static void surface_blt_to_drawable(const struct wined3d_device *device,
HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const struct wined3d_color *color)
{
struct wined3d_resource *resource = &s->container->resource;
- struct wined3d_device *device = resource->device;
struct wined3d_rendertarget_view_desc view_desc;
struct wined3d_rendertarget_view *view;
- const struct blit_shader *blitter;
HRESULT hr;
- if (!(blitter = wined3d_select_blitter(&device->adapter->gl_info, &device->adapter->d3d_info,
- WINED3D_BLIT_OP_COLOR_FILL, NULL, 0, 0, NULL, rect, resource->usage, resource->pool, resource->format)))
- {
- FIXME("No blitter is capable of performing the requested color fill operation.\n");
- return WINED3DERR_INVALIDCALL;
- }
-
view_desc.format_id = resource->format->id;
view_desc.u.texture.level_idx = s->texture_level;
view_desc.u.texture.layer_idx = s->texture_layer;
@@ -2962,7 +2944,7 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
return hr;
}
- hr = blitter->color_fill(device, view, rect, color);
+ hr = wined3d_rendertarget_view_clear(view, rect, WINED3DCLEAR_TARGET, color, 0.0f, 0);
wined3d_rendertarget_view_decref(view);
return hr;
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index 8d4f7fd..5f0cc1d 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -88,6 +88,46 @@ struct wined3d_resource * CDECL wined3d_rendertarget_view_get_resource(const str
return view->resource;
}
+HRESULT wined3d_rendertarget_view_clear(struct wined3d_rendertarget_view *view, const RECT *rect,
+ DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
+{
+ const struct blit_shader *blitter;
+ struct wined3d_resource *resource;
+ struct wined3d_device *device;
+ enum wined3d_blit_op blit_op;
+
+ if (flags & WINED3DCLEAR_TARGET)
+ blit_op = WINED3D_BLIT_OP_COLOR_FILL;
+ else
+ blit_op = WINED3D_BLIT_OP_DEPTH_FILL;
+
+ resource = view->resource;
+ device = resource->device;
+ if (resource->type != WINED3D_RTYPE_TEXTURE_2D)
+ {
+ FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (view->depth > 1)
+ {
+ FIXME("Layered clears not implemented.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (!(blitter = wined3d_select_blitter(&device->adapter->gl_info, &device->adapter->d3d_info,
+ blit_op, NULL, 0, 0, NULL, rect, resource->usage, resource->pool, resource->format)))
+ {
+ FIXME("No blitter is capable of performing the requested fill operation.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (blit_op == WINED3D_BLIT_OP_COLOR_FILL)
+ return blitter->color_fill(device, view, rect, color);
+ else
+ return blitter->depth_fill(device, view, rect, depth);
+}
+
static void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
const struct wined3d_rendertarget_view_desc *desc, struct wined3d_resource *resource,
void *parent, const struct wined3d_parent_ops *parent_ops)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 8d64854..06e8f97 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2929,6 +2929,9 @@ static inline struct wined3d_surface *wined3d_rendertarget_view_get_surface(
return surface_from_resource(resource);
}
+HRESULT wined3d_rendertarget_view_clear(struct wined3d_rendertarget_view *view, const RECT *rect,
+ DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
+
struct wined3d_shader_resource_view
{
LONG refcount;
--
2.4.10
More information about the wine-patches
mailing list