[PATCH 07/10] wined3d: Add dirty region tracking in texture_resource_sub_resource_map().

Masanori Kakura kakurasan at gmail.com
Mon Apr 17 08:47:12 CDT 2017


Signed-off-by: Masanori Kakura <kakurasan at gmail.com>
---
 dlls/wined3d/texture.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index d2de16d73d..9406cd344c 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2001,7 +2001,42 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
 
     if (!(flags & WINED3D_MAP_READONLY)
             && (!(flags & WINED3D_MAP_NO_DIRTY_UPDATE) || (resource->usage & WINED3DUSAGE_DYNAMIC)))
+    {
         wined3d_texture_invalidate_location(texture, sub_resource_idx, ~resource->map_binding);
+        if (sub_resource_idx == 0)
+        {
+            UINT width = wined3d_texture_get_level_width(texture, 0);
+            UINT height = wined3d_texture_get_level_height(texture, 0);
+            UINT depth = wined3d_texture_get_level_depth(texture, 0);
+
+            if (box)
+            {
+                if (box->left < box->right && box->top < box->bottom && box->front < box->back)
+                {
+                    if (!wined3d_dirty_regions_add(&texture->resource.dirty_regions,
+                                                   box->left, box->top,
+                                                   min(width, box->right), min(height, box->bottom),
+                                                   box->front, min(depth, box->back)))
+                    {
+                        ERR("Failed to allocate memory.\n");
+                        if (context)
+                            context_release(context);
+                        return E_OUTOFMEMORY;
+                    }
+                }
+            }
+            else
+            {
+                if (!wined3d_resource_maximize_dirty_region(&texture->resource))
+                {
+                    ERR("Failed to allocate memory.\n");
+                    if (context)
+                        context_release(context);
+                    return E_OUTOFMEMORY;
+                }
+            }
+        }
+    }
 
     wined3d_texture_get_memory(texture, sub_resource_idx, &data, resource->map_binding);
     base_memory = wined3d_texture_map_bo_address(&data, sub_resource->size,
-- 
2.11.0




More information about the wine-patches mailing list