[PATCH v2 1/5] wined3d: Do not emit an upload for NOOVERWRITE maps on deferred contexts.

Zebediah Figura zfigura at codeweavers.com
Wed Sep 29 17:15:20 CDT 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/wined3d/cs.c              | 18 ++++++++++++------
 dlls/wined3d/wined3d_private.h |  3 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index dd8cae825fa..626dd0ac132 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -34,6 +34,7 @@ struct wined3d_deferred_upload
     unsigned int sub_resource_idx;
     uint8_t *sysmem;
     struct wined3d_box box;
+    uint32_t upload_flags;
 };
 
 struct wined3d_command_list
@@ -2429,9 +2430,9 @@ static void wined3d_device_context_upload_bo(struct wined3d_device_context *cont
 {
     struct wined3d_cs_update_sub_resource *op;
 
-    TRACE("context %p, resource %p, sub_resource_idx %u, box %s, bo %s, row_pitch %u, slice_pitch %u.\n",
+    TRACE("context %p, resource %p, sub_resource_idx %u, box %s, bo %s, flags %#x, row_pitch %u, slice_pitch %u.\n",
             context, resource, sub_resource_idx, debug_box(box),
-            debug_const_bo_address(&bo->addr), row_pitch, slice_pitch);
+            debug_const_bo_address(&bo->addr), bo->flags, row_pitch, slice_pitch);
 
     op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
     op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
@@ -2518,7 +2519,8 @@ HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context
         unsigned int row_pitch, slice_pitch;
 
         wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
-        wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &bo, row_pitch, slice_pitch);
+        if (bo.flags & UPLOAD_BO_UPLOAD_ON_UNMAP)
+            wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &bo, row_pitch, slice_pitch);
         return WINED3D_OK;
     }
 
@@ -2749,6 +2751,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
     op->box = *box;
     op->bo.addr.buffer_object = 0;
     op->bo.addr.addr = data;
+    op->bo.flags = 0;
     op->row_pitch = row_pitch;
     op->slice_pitch = slice_pitch;
 
@@ -3475,7 +3478,7 @@ static void wined3d_deferred_context_push_constants(struct wined3d_device_contex
     FIXME("context %p, p %#x, start_idx %u, count %u, constants %p, stub!\n", context, p, start_idx, count, constants);
 }
 
-static const struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3d_deferred_context *deferred,
+static struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3d_deferred_context *deferred,
         struct wined3d_resource *resource, unsigned int sub_resource_idx)
 {
     SIZE_T i = deferred->upload_count;
@@ -3519,13 +3522,13 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
 
     if (flags & WINED3D_MAP_NOOVERWRITE)
     {
-        const struct wined3d_deferred_upload *upload;
-
         if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx)))
         {
+            upload->upload_flags = 0;
             map_ptr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
             bo->addr.buffer_object = 0;
             bo->addr.addr = map_ptr;
+            bo->flags = 0;
             return map_ptr;
         }
 
@@ -3540,6 +3543,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
         return NULL;
 
     upload = &deferred->uploads[deferred->upload_count++];
+    upload->upload_flags = UPLOAD_BO_UPLOAD_ON_UNMAP;
     upload->resource = resource;
     wined3d_resource_incref(resource);
     upload->sub_resource_idx = sub_resource_idx;
@@ -3549,6 +3553,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
     bo->addr.buffer_object = 0;
     map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT);
     bo->addr.addr = map_ptr;
+    bo->flags = UPLOAD_BO_UPLOAD_ON_UNMAP;
     return map_ptr;
 }
 
@@ -3563,6 +3568,7 @@ static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context
         *box = upload->box;
         bo->addr.buffer_object = 0;
         bo->addr.addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
+        bo->flags = upload->upload_flags;
         return true;
     }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c801e5b3ce8..520eb968eb6 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3324,9 +3324,12 @@ bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
         const struct wined3d_gpu_description *gpu_description, enum wined3d_feature_level feature_level,
         UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
 
+#define UPLOAD_BO_UPLOAD_ON_UNMAP   0x1
+
 struct upload_bo
 {
     struct wined3d_const_bo_address addr;
+    uint32_t flags;
 };
 
 struct wined3d_adapter_ops
-- 
2.33.0




More information about the wine-devel mailing list