wined3d: Introduce wined3d_resource_unmap().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2015-11-02 17:12:26 +01:00 committed by Alexandre Julliard
parent 535b3fe029
commit 7b9d06b494
8 changed files with 60 additions and 19 deletions

View File

@ -1149,12 +1149,25 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
return wined3d_buffer_map(buffer, offset, size, (BYTE **)&map_desc->data, flags);
}
static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
if (sub_resource_idx)
{
WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
return E_INVALIDARG;
}
wined3d_buffer_unmap(buffer_from_resource(resource));
return WINED3D_OK;
}
static const struct wined3d_resource_ops buffer_resource_ops =
{
buffer_resource_incref,
buffer_resource_decref,
buffer_unload,
buffer_resource_sub_resource_map,
buffer_resource_sub_resource_unmap,
};
static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device *device,

View File

@ -304,6 +304,13 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i
return resource->resource_ops->resource_sub_resource_map(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 resource->resource_ops->resource_sub_resource_unmap(resource, sub_resource_idx);
}
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
{
void **p;

View File

@ -1207,12 +1207,19 @@ static HRESULT surface_resource_sub_resource_map(struct wined3d_resource *resour
return WINED3DERR_INVALIDCALL;
}
static HRESULT surface_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
ERR("Not supported on sub-resources.\n");
return WINED3DERR_INVALIDCALL;
}
static const struct wined3d_resource_ops surface_resource_ops =
{
surface_resource_incref,
surface_resource_decref,
surface_unload,
surface_resource_sub_resource_map,
surface_resource_sub_resource_unmap,
};
static const struct wined3d_surface_ops surface_ops =

View File

@ -919,11 +919,6 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
}
}
static HRESULT texture2d_sub_resource_unmap(struct wined3d_resource *sub_resource)
{
return wined3d_surface_unmap(surface_from_resource(sub_resource));
}
static const struct wined3d_texture_ops texture2d_ops =
{
texture2d_sub_resource_load,
@ -932,7 +927,6 @@ static const struct wined3d_texture_ops texture2d_ops =
texture2d_sub_resource_invalidate_location,
texture2d_sub_resource_validate_location,
texture2d_sub_resource_upload_data,
texture2d_sub_resource_unmap,
texture2d_prepare_texture,
};
@ -976,12 +970,23 @@ static HRESULT texture2d_resource_sub_resource_map(struct wined3d_resource *reso
return wined3d_surface_map(surface_from_resource(sub_resource), map_desc, box, flags);
}
static HRESULT texture2d_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
struct wined3d_resource *sub_resource;
if (!(sub_resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(resource), sub_resource_idx)))
return E_INVALIDARG;
return wined3d_surface_unmap(surface_from_resource(sub_resource));
}
static const struct wined3d_resource_ops texture2d_resource_ops =
{
texture_resource_incref,
texture_resource_decref,
wined3d_texture_unload,
texture2d_resource_sub_resource_map,
texture2d_resource_sub_resource_unmap,
};
static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
@ -1312,11 +1317,6 @@ static void texture3d_prepare_texture(struct wined3d_texture *texture, struct wi
}
}
static HRESULT texture3d_sub_resource_unmap(struct wined3d_resource *sub_resource)
{
return wined3d_volume_unmap(volume_from_resource(sub_resource));
}
static const struct wined3d_texture_ops texture3d_ops =
{
texture3d_sub_resource_load,
@ -1325,7 +1325,6 @@ static const struct wined3d_texture_ops texture3d_ops =
texture3d_sub_resource_invalidate_location,
texture3d_sub_resource_validate_location,
texture3d_sub_resource_upload_data,
texture3d_sub_resource_unmap,
texture3d_prepare_texture,
};
@ -1340,12 +1339,23 @@ static HRESULT texture3d_resource_sub_resource_map(struct wined3d_resource *reso
return wined3d_volume_map(volume_from_resource(sub_resource), map_desc, box, flags);
}
static HRESULT texture3d_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
struct wined3d_resource *sub_resource;
if (!(sub_resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(resource), sub_resource_idx)))
return E_INVALIDARG;
return wined3d_volume_unmap(volume_from_resource(sub_resource));
}
static const struct wined3d_resource_ops texture3d_resource_ops =
{
texture_resource_incref,
texture_resource_decref,
wined3d_texture_unload,
texture3d_resource_sub_resource_map,
texture3d_resource_sub_resource_unmap,
};
static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
@ -1549,14 +1559,9 @@ HRESULT CDECL wined3d_texture_map(struct wined3d_texture *texture, unsigned int
HRESULT CDECL wined3d_texture_unmap(struct wined3d_texture *texture, unsigned int sub_resource_idx)
{
struct wined3d_resource *sub_resource;
TRACE("texture %p, sub_resource_idx %u.\n", texture, sub_resource_idx);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
return WINED3DERR_INVALIDCALL;
return texture->texture_ops->texture_sub_resource_unmap(sub_resource);
return texture->resource.resource_ops->resource_sub_resource_unmap(&texture->resource, sub_resource_idx);
}
HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC *dc)

View File

@ -707,12 +707,19 @@ static HRESULT volume_resource_sub_resource_map(struct wined3d_resource *resourc
return WINED3DERR_INVALIDCALL;
}
static HRESULT volume_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
ERR("Not supported on sub-resources.\n");
return WINED3DERR_INVALIDCALL;
}
static const struct wined3d_resource_ops volume_resource_ops =
{
volume_resource_incref,
volume_resource_decref,
volume_unload,
volume_resource_sub_resource_map,
volume_resource_sub_resource_unmap,
};
static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture *container,

View File

@ -185,6 +185,7 @@
@ cdecl wined3d_resource_map(ptr long ptr ptr long)
@ cdecl wined3d_resource_set_parent(ptr ptr)
@ cdecl wined3d_resource_set_priority(ptr long)
@ cdecl wined3d_resource_unmap(ptr long)
@ cdecl wined3d_rendertarget_view_create(ptr ptr ptr ptr ptr)
@ cdecl wined3d_rendertarget_view_create_from_surface(ptr ptr ptr ptr)

View File

@ -2158,6 +2158,7 @@ struct wined3d_resource_ops
void (*resource_unload)(struct wined3d_resource *resource);
HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
};
struct wined3d_resource
@ -2237,7 +2238,6 @@ struct wined3d_texture_ops
void (*texture_sub_resource_validate_location)(struct wined3d_resource *sub_resource, DWORD location);
void (*texture_sub_resource_upload_data)(struct wined3d_resource *sub_resource,
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data);
HRESULT (*texture_sub_resource_unmap)(struct wined3d_resource *sub_resource);
void (*texture_prepare_texture)(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb);
};

View File

@ -2426,6 +2426,7 @@ HRESULT __cdecl wined3d_resource_map(struct wined3d_resource *resource, unsigned
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent);
DWORD __cdecl wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority);
HRESULT __cdecl wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx);
HRESULT __cdecl wined3d_rendertarget_view_create(const struct wined3d_rendertarget_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,