wined3d: Map resources through wined3d_device_context_ops.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-04-12 22:46:29 -05:00 committed by Alexandre Julliard
parent d1b2eea421
commit 2fd3ec79cd
3 changed files with 22 additions and 13 deletions

View File

@ -2279,9 +2279,11 @@ static void wined3d_cs_exec_map(struct wined3d_cs *cs, const void *data)
op->sub_resource_idx, op->map_desc, op->box, op->flags);
}
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)
static HRESULT wined3d_cs_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)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
struct wined3d_cs_map *op;
HRESULT hr;
@ -2289,7 +2291,7 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource,
* increasing the map count would be visible to applications. */
wined3d_not_from_cs(cs);
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_MAP);
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP);
op->opcode = WINED3D_CS_OP_MAP;
op->resource = resource;
op->sub_resource_idx = sub_resource_idx;
@ -2298,7 +2300,7 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource,
op->flags = flags;
op->hr = &hr;
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_MAP);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
wined3d_cs_finish(cs, WINED3D_CS_QUEUE_MAP);
return hr;
@ -2312,20 +2314,22 @@ static void wined3d_cs_exec_unmap(struct wined3d_cs *cs, const void *data)
*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)
static HRESULT wined3d_cs_unmap(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
struct wined3d_cs_unmap *op;
HRESULT hr;
wined3d_not_from_cs(cs);
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_MAP);
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP);
op->opcode = WINED3D_CS_OP_UNMAP;
op->resource = resource;
op->sub_resource_idx = sub_resource_idx;
op->hr = &hr;
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_MAP);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
wined3d_cs_finish(cs, WINED3D_CS_QUEUE_MAP);
return hr;
@ -2790,6 +2794,8 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops =
wined3d_cs_st_submit,
wined3d_cs_st_finish,
wined3d_cs_st_push_constants,
wined3d_cs_map,
wined3d_cs_unmap,
};
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue)
@ -2911,6 +2917,8 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_mt_submit,
wined3d_cs_mt_finish,
wined3d_cs_mt_push_constants,
wined3d_cs_map,
wined3d_cs_unmap,
};
static void poll_queries(struct wined3d_cs *cs)

View File

@ -376,14 +376,14 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i
flags = wined3d_resource_sanitise_map_flags(resource, flags);
wined3d_resource_wait_idle(resource);
return wined3d_cs_map(resource->device->cs, resource, sub_resource_idx, map_desc, box, flags);
return resource->device->cs->c.ops->map(&resource->device->cs->c, resource, sub_resource_idx, map_desc, box, flags);
}
HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
return wined3d_cs_unmap(resource->device->cs, resource, sub_resource_idx);
return resource->device->cs->c.ops->unmap(&resource->device->cs->c, resource, sub_resource_idx);
}
void CDECL wined3d_resource_preload(struct wined3d_resource *resource)

View File

@ -4687,6 +4687,11 @@ struct wined3d_device_context_ops
void (*finish)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id);
void (*push_constants)(struct wined3d_device_context *context, enum wined3d_push_constants p,
unsigned int start_idx, unsigned int count, const void *constants);
HRESULT (*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);
HRESULT (*unmap)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx);
};
struct wined3d_device_context
@ -4756,10 +4761,6 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform
void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_cs_init_object(struct wined3d_cs *cs,
void (*callback)(void *object), void *object) 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_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
{