Zebediah Figura : wined3d: Return the map pitch from wined3d_device_context_emit_map().
Alexandre Julliard
julliard at winehq.org
Thu Oct 14 15:09:33 CDT 2021
Module: wine
Branch: master
Commit: 4b7beecbeb247cb81953da960f160847bd5560fd
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4b7beecbeb247cb81953da960f160847bd5560fd
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Tue Oct 12 16:15:42 2021 -0500
wined3d: Return the map pitch from wined3d_device_context_emit_map().
Partially undoes 61024aa12f.
We may want to be able to return an existing BO from
context->ops->map_upload_bo(), in which case it is structurally awkward to
request a specific memory layout. We may also want to give map_upload_bo() the
freedom to allocate either a new (smaller) BO, or use an existing (larger) one,
for partial uploads.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/cs.c | 29 ++++++++++++++++++++---------
dlls/wined3d/device.c | 5 +----
dlls/wined3d/wined3d_private.h | 2 +-
3 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 1b4ed519260..159b9ae05a9 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2489,27 +2489,32 @@ static void wined3d_cs_exec_map(struct wined3d_cs *cs, const void *data)
op->sub_resource_idx, op->map_ptr, op->box, op->flags);
}
-HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
- unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
+HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx,
+ struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
{
unsigned int row_pitch, slice_pitch;
struct wined3d_cs_map *op;
+ void *map_ptr;
HRESULT hr;
+ /* Mapping resources from the worker thread isn't an issue by itself, but
+ * increasing the map count would be visible to applications. */
+ wined3d_not_from_cs(context->device->cs);
+
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
- && (*map_ptr = context->ops->map_upload_bo(context, resource,
+ && (map_ptr = context->ops->map_upload_bo(context, resource,
sub_resource_idx, box, row_pitch, slice_pitch, flags)))
{
- TRACE("Returning map pointer %p, row pitch %u, slice pitch %u.\n", *map_ptr, row_pitch, slice_pitch);
+ TRACE("Returning map pointer %p, row pitch %u, slice pitch %u.\n", map_ptr, row_pitch, slice_pitch);
+ map_desc->data = map_ptr;
+ map_desc->row_pitch = row_pitch;
+ map_desc->slice_pitch = slice_pitch;
return WINED3D_OK;
}
- /* Mapping resources from the worker thread isn't an issue by itself, but
- * increasing the map count would be visible to applications. */
- wined3d_not_from_cs(context->device->cs);
-
wined3d_resource_wait_idle(resource);
if (!(op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP)))
@@ -2517,7 +2522,7 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
op->opcode = WINED3D_CS_OP_MAP;
op->resource = resource;
op->sub_resource_idx = sub_resource_idx;
- op->map_ptr = map_ptr;
+ op->map_ptr = &map_ptr;
op->box = box;
op->flags = flags;
op->hr = &hr;
@@ -2525,6 +2530,12 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
wined3d_device_context_finish(context, WINED3D_CS_QUEUE_MAP);
+ if (FAILED(hr))
+ return hr;
+
+ map_desc->data = map_ptr;
+ map_desc->row_pitch = row_pitch;
+ map_desc->slice_pitch = slice_pitch;
return hr;
}
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 436c4dfe854..b8c1630ee25 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4957,10 +4957,7 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
}
wined3d_mutex_lock();
- if (SUCCEEDED(hr = wined3d_device_context_emit_map(context, resource,
- sub_resource_idx, &map_desc->data, box, flags)))
- wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx,
- &map_desc->row_pitch, &map_desc->slice_pitch);
+ hr = wined3d_device_context_emit_map(context, resource, sub_resource_idx, map_desc, box, flags);
wined3d_mutex_unlock();
return hr;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 56c90ba6606..a2899e6a778 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4867,7 +4867,7 @@ void wined3d_device_context_emit_execute_command_list(struct wined3d_device_cont
void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context *context,
struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
- struct wined3d_resource *resource, unsigned int sub_resource_idx, void **map_ptr,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc,
const struct wined3d_box *box, unsigned int flags) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_reset_state(struct wined3d_device_context *context, bool invalidate) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context *context,
More information about the wine-cvs
mailing list