Commit eac95d30 authored by Riccardo Bortolato's avatar Riccardo Bortolato Committed by Alexandre Julliard

wined3d: Introduce new wined3d_texture_(un)map functions.

Initial usage in d3d11. Also removed wined3d_volume_from_resource. Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com>
parent 1d148710
......@@ -357,7 +357,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN
{
struct d3d_texture2d *texture = impl_from_ID3D10Texture2D(iface);
struct wined3d_map_desc wined3d_map_desc;
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n",
......@@ -367,9 +366,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN
FIXME("Ignoring map_flags %#x.\n", map_flags);
wined3d_mutex_lock();
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = E_INVALIDARG;
else if (SUCCEEDED(hr = wined3d_surface_map(wined3d_surface_from_resource(sub_resource),
if (SUCCEEDED(hr = wined3d_texture_map(texture->wined3d_texture, sub_resource_idx,
&wined3d_map_desc, NULL, wined3d_map_flags_from_d3d10_map_type(map_type))))
{
mapped_texture->pData = wined3d_map_desc.data;
......@@ -383,18 +380,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN
static void STDMETHODCALLTYPE d3d10_texture2d_Unmap(ID3D10Texture2D *iface, UINT sub_resource_idx)
{
struct d3d_texture2d *texture = impl_from_ID3D10Texture2D(iface);
struct wined3d_resource *sub_resource;
TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx);
wined3d_mutex_lock();
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
{
wined3d_mutex_unlock();
return;
}
wined3d_surface_unmap(wined3d_surface_from_resource(sub_resource));
wined3d_texture_unmap(texture->wined3d_texture, sub_resource_idx);
wined3d_mutex_unlock();
}
......@@ -824,7 +814,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN
{
struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface);
struct wined3d_map_desc wined3d_map_desc;
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n",
......@@ -834,9 +823,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN
FIXME("Ignoring map_flags %#x.\n", map_flags);
wined3d_mutex_lock();
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = E_INVALIDARG;
else if (SUCCEEDED(hr = wined3d_volume_map(wined3d_volume_from_resource(sub_resource),
if (SUCCEEDED(hr = wined3d_texture_map(texture->wined3d_texture, sub_resource_idx,
&wined3d_map_desc, NULL, wined3d_map_flags_from_d3d10_map_type(map_type))))
{
mapped_texture->pData = wined3d_map_desc.data;
......@@ -851,18 +838,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN
static void STDMETHODCALLTYPE d3d10_texture3d_Unmap(ID3D10Texture3D *iface, UINT sub_resource_idx)
{
struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface);
struct wined3d_resource *sub_resource;
TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx);
wined3d_mutex_lock();
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
{
wined3d_mutex_unlock();
return;
}
wined3d_volume_unmap(wined3d_volume_from_resource(sub_resource));
wined3d_texture_unmap(texture->wined3d_texture, sub_resource_idx);
wined3d_mutex_unlock();
}
......
......@@ -915,6 +915,17 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
}
}
static HRESULT texture2d_sub_resource_map(struct wined3d_resource *sub_resource,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
{
return wined3d_surface_map(surface_from_resource(sub_resource), map_desc, box, flags);
}
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,
......@@ -923,6 +934,8 @@ 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_map,
texture2d_sub_resource_unmap,
texture2d_prepare_texture,
};
......@@ -1290,6 +1303,17 @@ static void texture3d_prepare_texture(struct wined3d_texture *texture, struct wi
}
}
static HRESULT texture3d_sub_resource_map(struct wined3d_resource *sub_resource,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
{
return wined3d_volume_map(volume_from_resource(sub_resource), map_desc, box, flags);
}
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,
......@@ -1298,6 +1322,8 @@ 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_map,
texture3d_sub_resource_unmap,
texture3d_prepare_texture,
};
......@@ -1465,3 +1491,24 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
return WINED3D_OK;
}
HRESULT CDECL wined3d_texture_map(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
{
struct wined3d_resource *sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx);
if (!sub_resource)
return WINED3DERR_INVALIDCALL;
return texture->texture_ops->texture_sub_resource_map(sub_resource, map_desc, box, flags);
}
HRESULT CDECL wined3d_texture_unmap(struct wined3d_texture *texture, unsigned int sub_resource_idx)
{
struct wined3d_resource *sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx);
if (!sub_resource)
return WINED3DERR_INVALIDCALL;
return texture->texture_ops->texture_sub_resource_unmap(sub_resource);
}
......@@ -676,11 +676,6 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
return WINED3D_OK;
}
struct wined3d_volume * CDECL wined3d_volume_from_resource(struct wined3d_resource *resource)
{
return volume_from_resource(resource);
}
HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume)
{
TRACE("volume %p.\n", volume);
......
......@@ -273,6 +273,8 @@
@ cdecl wined3d_texture_set_autogen_filter_type(ptr long)
@ cdecl wined3d_texture_set_color_key(ptr long ptr)
@ cdecl wined3d_texture_set_lod(ptr long)
@ cdecl wined3d_texture_map(ptr long ptr ptr long)
@ cdecl wined3d_texture_unmap(ptr long)
@ cdecl wined3d_texture_update_desc(ptr long long long long long ptr long)
@ cdecl wined3d_vertex_declaration_create(ptr ptr long ptr ptr ptr)
......@@ -281,7 +283,6 @@
@ cdecl wined3d_vertex_declaration_get_parent(ptr)
@ cdecl wined3d_vertex_declaration_incref(ptr)
@ cdecl wined3d_volume_from_resource(ptr)
@ cdecl wined3d_volume_get_resource(ptr)
@ cdecl wined3d_volume_map(ptr ptr ptr long)
@ cdecl wined3d_volume_unmap(ptr)
......@@ -2219,6 +2219,9 @@ 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_map)(struct wined3d_resource *sub_resource,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
HRESULT (*texture_sub_resource_unmap)(struct wined3d_resource *sub_resource);
void (*texture_prepare_texture)(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb);
};
......
......@@ -2549,6 +2549,9 @@ HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture *
HRESULT __cdecl wined3d_texture_set_color_key(struct wined3d_texture *texture,
DWORD flags, const struct wined3d_color_key *color_key);
DWORD __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod);
HRESULT __cdecl wined3d_texture_map(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
HRESULT __cdecl wined3d_texture_unmap(struct wined3d_texture *texture, unsigned int sub_resource_idx);
HRESULT __cdecl wined3d_texture_update_desc(struct wined3d_texture *texture,
UINT width, UINT height, enum wined3d_format_id format_id,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
......@@ -2564,7 +2567,6 @@ ULONG __cdecl wined3d_vertex_declaration_decref(struct wined3d_vertex_declaratio
void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration);
ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration);
struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource);
struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume);
HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment