wined3d: Introduce wined3d_resource_map().
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:
parent
c715127536
commit
535b3fe029
|
@ -1123,11 +1123,38 @@ static ULONG buffer_resource_decref(struct wined3d_resource *resource)
|
|||
return wined3d_buffer_decref(buffer_from_resource(resource));
|
||||
}
|
||||
|
||||
static HRESULT buffer_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)
|
||||
{
|
||||
struct wined3d_buffer *buffer = buffer_from_resource(resource);
|
||||
UINT offset, size;
|
||||
|
||||
if (sub_resource_idx)
|
||||
{
|
||||
WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (box)
|
||||
{
|
||||
offset = box->left;
|
||||
size = box->right - box->left;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = size = 0;
|
||||
}
|
||||
|
||||
map_desc->row_pitch = map_desc->slice_pitch = buffer->desc.byte_width;
|
||||
return wined3d_buffer_map(buffer, offset, size, (BYTE **)&map_desc->data, flags);
|
||||
}
|
||||
|
||||
static const struct wined3d_resource_ops buffer_resource_ops =
|
||||
{
|
||||
buffer_resource_incref,
|
||||
buffer_resource_decref,
|
||||
buffer_unload,
|
||||
buffer_resource_sub_resource_map,
|
||||
};
|
||||
|
||||
static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device *device,
|
||||
|
|
|
@ -295,6 +295,15 @@ void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, st
|
|||
desc->size = resource->size;
|
||||
}
|
||||
|
||||
HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx,
|
||||
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
|
||||
{
|
||||
TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %p, flags %#x.\n",
|
||||
resource, sub_resource_idx, map_desc, box, flags);
|
||||
|
||||
return resource->resource_ops->resource_sub_resource_map(resource, sub_resource_idx, map_desc, box, flags);
|
||||
}
|
||||
|
||||
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
|
||||
{
|
||||
void **p;
|
||||
|
|
|
@ -1200,11 +1200,19 @@ static void surface_unload(struct wined3d_resource *resource)
|
|||
resource_unload(resource);
|
||||
}
|
||||
|
||||
static HRESULT surface_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)
|
||||
{
|
||||
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,
|
||||
};
|
||||
|
||||
static const struct wined3d_surface_ops surface_ops =
|
||||
|
|
|
@ -919,12 +919,6 @@ 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));
|
||||
|
@ -938,7 +932,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_map,
|
||||
texture2d_sub_resource_unmap,
|
||||
texture2d_prepare_texture,
|
||||
};
|
||||
|
@ -972,11 +965,23 @@ static void wined3d_texture_unload(struct wined3d_resource *resource)
|
|||
wined3d_texture_unload_gl_texture(texture);
|
||||
}
|
||||
|
||||
static const struct wined3d_resource_ops texture_resource_ops =
|
||||
static HRESULT texture2d_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)
|
||||
{
|
||||
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_map(surface_from_resource(sub_resource), map_desc, box, flags);
|
||||
}
|
||||
|
||||
static const struct wined3d_resource_ops texture2d_resource_ops =
|
||||
{
|
||||
texture_resource_incref,
|
||||
texture_resource_decref,
|
||||
wined3d_texture_unload,
|
||||
texture2d_resource_sub_resource_map,
|
||||
};
|
||||
|
||||
static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
|
||||
|
@ -1034,7 +1039,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi
|
|||
}
|
||||
|
||||
if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 6, levels, desc,
|
||||
surface_flags, device, parent, parent_ops, &texture_resource_ops)))
|
||||
surface_flags, device, parent, parent_ops, &texture2d_resource_ops)))
|
||||
{
|
||||
WARN("Failed to initialize texture, returning %#x\n", hr);
|
||||
return hr;
|
||||
|
@ -1152,7 +1157,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
|
|||
}
|
||||
|
||||
if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 1, levels, desc,
|
||||
surface_flags, device, parent, parent_ops, &texture_resource_ops)))
|
||||
surface_flags, device, parent, parent_ops, &texture2d_resource_ops)))
|
||||
{
|
||||
WARN("Failed to initialize texture, returning %#x.\n", hr);
|
||||
return hr;
|
||||
|
@ -1307,12 +1312,6 @@ 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));
|
||||
|
@ -1326,11 +1325,29 @@ 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,
|
||||
};
|
||||
|
||||
static HRESULT texture3d_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)
|
||||
{
|
||||
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_map(volume_from_resource(sub_resource), map_desc, box, flags);
|
||||
}
|
||||
|
||||
static const struct wined3d_resource_ops texture3d_resource_ops =
|
||||
{
|
||||
texture_resource_incref,
|
||||
texture_resource_decref,
|
||||
wined3d_texture_unload,
|
||||
texture3d_resource_sub_resource_map,
|
||||
};
|
||||
|
||||
static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
|
||||
UINT levels, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops)
|
||||
{
|
||||
|
@ -1398,7 +1415,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
|
|||
}
|
||||
|
||||
if (FAILED(hr = wined3d_texture_init(texture, &texture3d_ops, 1, levels, desc,
|
||||
0, device, parent, parent_ops, &texture_resource_ops)))
|
||||
0, device, parent, parent_ops, &texture3d_resource_ops)))
|
||||
{
|
||||
WARN("Failed to initialize texture, returning %#x.\n", hr);
|
||||
return hr;
|
||||
|
@ -1523,15 +1540,11 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
|
|||
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;
|
||||
|
||||
TRACE("texture %p, sub_resource_idx %u, map_desc %p, box %p, flags %#x.\n",
|
||||
texture, sub_resource_idx, map_desc, box, flags);
|
||||
|
||||
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
return texture->texture_ops->texture_sub_resource_map(sub_resource, map_desc, box, flags);
|
||||
return texture->resource.resource_ops->resource_sub_resource_map(&texture->resource, sub_resource_idx,
|
||||
map_desc, box, flags);
|
||||
}
|
||||
|
||||
HRESULT CDECL wined3d_texture_unmap(struct wined3d_texture *texture, unsigned int sub_resource_idx)
|
||||
|
|
|
@ -700,11 +700,19 @@ static ULONG volume_resource_decref(struct wined3d_resource *resource)
|
|||
return wined3d_texture_decref(volume->container);
|
||||
}
|
||||
|
||||
static HRESULT volume_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)
|
||||
{
|
||||
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,
|
||||
};
|
||||
|
||||
static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture *container,
|
||||
|
|
|
@ -182,6 +182,7 @@
|
|||
@ cdecl wined3d_resource_get_desc(ptr ptr)
|
||||
@ cdecl wined3d_resource_get_parent(ptr)
|
||||
@ cdecl wined3d_resource_get_priority(ptr)
|
||||
@ cdecl wined3d_resource_map(ptr long ptr ptr long)
|
||||
@ cdecl wined3d_resource_set_parent(ptr ptr)
|
||||
@ cdecl wined3d_resource_set_priority(ptr long)
|
||||
|
||||
|
|
|
@ -2156,6 +2156,8 @@ struct wined3d_resource_ops
|
|||
ULONG (*resource_incref)(struct wined3d_resource *resource);
|
||||
ULONG (*resource_decref)(struct wined3d_resource *resource);
|
||||
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);
|
||||
};
|
||||
|
||||
struct wined3d_resource
|
||||
|
@ -2235,8 +2237,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_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);
|
||||
|
|
|
@ -2422,6 +2422,8 @@ void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource,
|
|||
struct wined3d_resource_desc *desc);
|
||||
void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource);
|
||||
DWORD __cdecl wined3d_resource_get_priority(const struct wined3d_resource *resource);
|
||||
HRESULT __cdecl wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx,
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue