[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    [PATCH 2/4] wined3d: Add fast-path for texture download blit.
From:       Andrew Wesie <awesie () gmail ! com>
Date:       2018-09-30 17:01:58
Message-ID: 1538326920-5825-2-git-send-email-awesie () gmail ! com
[Download RAW message or body]

Signed-off-by: Andrew Wesie <awesie@gmail.com>
---
 dlls/wined3d/surface.c         | 56 ++++++++++++++++++++++++++++++------------
 dlls/wined3d/texture.c         | 22 +++++++++++++++++
 dlls/wined3d/wined3d_private.h |  2 ++
 3 files changed, 64 insertions(+), 16 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 4942177..fe64a6d 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3218,22 +3218,7 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, \
unsigned int dst_sub_  goto cpu;
     }
 
-    blit_op = WINED3D_BLIT_OP_COLOR_BLIT;
-    if (flags & WINED3D_BLT_SRC_CKEY_OVERRIDE)
-    {
-        colour_key = &fx->src_color_key;
-        blit_op = WINED3D_BLIT_OP_COLOR_BLIT_CKEY;
-    }
-    else if (flags & WINED3D_BLT_SRC_CKEY)
-    {
-        colour_key = &src_texture->async.src_blt_color_key;
-        blit_op = WINED3D_BLIT_OP_COLOR_BLIT_CKEY;
-    }
-    else if (flags & WINED3D_BLT_ALPHA_TEST)
-    {
-        blit_op = WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST;
-    }
-    else if ((src_sub_resource->locations & surface_simple_locations)
+    if ((src_sub_resource->locations & surface_simple_locations)
             && !(dst_sub_resource->locations & surface_simple_locations))
     {
         /* Upload */
@@ -3257,6 +3242,45 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, \
unsigned int dst_sub_  return WINED3D_OK;
         }
     }
+    else if (!(src_sub_resource->locations & surface_simple_locations)
+            && (dst_sub_resource->locations & dst_texture->resource.map_binding))
+    {
+        /* Download */
+        if (scale)
+            TRACE("Not doing download because of scaling.\n");
+        else if (convert)
+            TRACE("Not doing download because of format conversion.\n");
+        else if (dst_texture->resource.format->conv_byte_count)
+            TRACE("Not doing download because the destination format needs \
conversion.\n"); +        else if (!texture2d_is_full_rect(src_texture, \
src_sub_resource_idx % src_texture->level_count, &src_rect)) +            TRACE("Not \
doing download because of partial download (src).\n"); +        else if \
(!texture2d_is_full_rect(dst_texture, dst_sub_resource_idx % \
dst_texture->level_count, &dst_rect)) +            TRACE("Not doing download because \
of partial download (dst).\n"); +        else if \
(is_multisample_location(src_texture, WINED3D_LOCATION_TEXTURE_RGB)) +            \
TRACE("Not doing download because of multisample source.\n"); +        else
+        {
+            wined3d_texture_download_from_texture(dst_texture, dst_sub_resource_idx, \
src_texture, +                    src_sub_resource_idx);
+            return WINED3D_OK;
+        }
+    }
+
+    blit_op = WINED3D_BLIT_OP_COLOR_BLIT;
+    if (flags & WINED3D_BLT_SRC_CKEY_OVERRIDE)
+    {
+        colour_key = &fx->src_color_key;
+        blit_op = WINED3D_BLIT_OP_COLOR_BLIT_CKEY;
+    }
+    else if (flags & WINED3D_BLT_SRC_CKEY)
+    {
+        colour_key = &src_texture->async.src_blt_color_key;
+        blit_op = WINED3D_BLIT_OP_COLOR_BLIT_CKEY;
+    }
+    else if (flags & WINED3D_BLT_ALPHA_TEST)
+    {
+        blit_op = WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST;
+    }
     else if (dst_swapchain && dst_swapchain->back_buffers
             && dst_texture == dst_swapchain->front_buffer
             && src_texture == dst_swapchain->back_buffers[0])
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 29bbdd7..60d1e5b 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -3798,3 +3798,25 @@ void wined3d_texture_upload_from_texture(struct \
                wined3d_texture *dst_texture, un
     wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, \
                WINED3D_LOCATION_TEXTURE_RGB);
     wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, \
~WINED3D_LOCATION_TEXTURE_RGB);  }
+
+/* Partial downloads are not supported. */
+void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, \
unsigned int dst_sub_resource_idx, +        struct wined3d_texture *src_texture, \
unsigned int src_sub_resource_idx) +{
+    struct wined3d_context *context;
+    struct wined3d_bo_address data;
+    DWORD dst_location = dst_texture->resource.map_binding;
+
+    context = context_acquire(src_texture->resource.device, NULL, 0);
+
+    wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, \
dst_location); +    wined3d_texture_get_memory(dst_texture, dst_sub_resource_idx, \
&data, dst_location); +    wined3d_texture_bind_and_dirtify(src_texture, context,
+            !(src_texture->sub_resources[src_sub_resource_idx].locations & \
WINED3D_LOCATION_TEXTURE_RGB)); +    wined3d_texture_download_data(src_texture, \
src_sub_resource_idx, context, &data); +
+    context_release(context);
+
+    wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, \
dst_location); +    wined3d_texture_invalidate_location(dst_texture, \
dst_sub_resource_idx, ~dst_location); +}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 7d35e55..34d5917 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3350,6 +3350,8 @@ HRESULT wined3d_texture_check_box_dimensions(const struct \
                wined3d_texture *textu
         unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
 void wined3d_texture_download_data(struct wined3d_texture *texture, unsigned int \
                sub_resource_idx,
         struct wined3d_context *context, const struct wined3d_bo_address *data) \
DECLSPEC_HIDDEN; +void wined3d_texture_download_from_texture(struct wined3d_texture \
*dst_texture, unsigned int dst_sub_resource_idx, +        struct wined3d_texture \
*src_texture, unsigned int src_sub_resource_idx) DECLSPEC_HIDDEN;  GLenum \
wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN; \
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int \
                sub_resource_idx,
         struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
-- 
2.7.4


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic