From 66e54fd682f494265b6059d2f04d766ec085f149 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 1 Sep 2016 20:34:47 +0200 Subject: [PATCH] wined3d: Send resource unmaps through the command stream. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/cs.c | 34 ++++++++++++++++++++++++++++++++++ dlls/wined3d/resource.c | 2 +- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index d86213be66b..7af0b812cdf 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -58,6 +58,7 @@ enum wined3d_cs_op WINED3D_CS_OP_PRELOAD_RESOURCE, WINED3D_CS_OP_UNLOAD_RESOURCE, WINED3D_CS_OP_MAP, + WINED3D_CS_OP_UNMAP, }; struct wined3d_cs_present @@ -301,6 +302,14 @@ struct wined3d_cs_map HRESULT *hr; }; +struct wined3d_cs_unmap +{ + enum wined3d_cs_op opcode; + struct wined3d_resource *resource; + unsigned int sub_resource_idx; + HRESULT *hr; +}; + static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_present *op = data; @@ -1342,6 +1351,30 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, return hr; } +static void wined3d_cs_exec_unmap(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_unmap *op = data; + struct wined3d_resource *resource = op->resource; + + *op->hr = resource->resource_ops->resource_sub_resource_unmap(resource, op->sub_resource_idx); +} + +HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resource, unsigned int sub_resource_idx) +{ + struct wined3d_cs_unmap *op; + HRESULT hr; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_UNMAP; + op->resource = resource; + op->sub_resource_idx = sub_resource_idx; + op->hr = &hr; + + cs->ops->submit(cs); + + return hr; +} + static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = { /* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present, @@ -1376,6 +1409,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_PRELOAD_RESOURCE */ wined3d_cs_exec_preload_resource, /* WINED3D_CS_OP_UNLOAD_RESOURCE */ wined3d_cs_exec_unload_resource, /* WINED3D_CS_OP_MAP */ wined3d_cs_exec_map, + /* WINED3D_CS_OP_UNMAP */ wined3d_cs_exec_unmap, }; static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size) diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 2285c3c3a0f..64841741a8c 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -324,7 +324,7 @@ HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned { TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx); - return resource->resource_ops->resource_sub_resource_unmap(resource, sub_resource_idx); + return wined3d_cs_unmap(resource->device->cs, resource, sub_resource_idx); } void CDECL wined3d_resource_preload(struct wined3d_resource *resource) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 48f613fdd6b..1f59f601de1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3098,6 +3098,8 @@ void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_vi void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN; HRESULT wined3d_cs_map(struct wined3d_cs *cs, 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; +HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resource, + unsigned int sub_resource_idx) DECLSPEC_HIDDEN; static inline void wined3d_cs_push_constants(struct wined3d_cs *cs, enum wined3d_push_constants p, unsigned int start_idx, unsigned int count, const void *constants)