On 2 November 2015 at 04:17, Józef Kucia <jkucia(a)codeweavers.com> wrote:
> +HRESULT CDECL wined3d_device_map_sub_resource(struct wined3d_device *device,
> + 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;
> +
> + TRACE("device %p, resource %p, sub_resource_idx %u, map_desc %p, box %p, flags %#x.\n",
> + device, resource, sub_resource_idx, map_desc, box, flags);
> +
> + if (!(sub_resource = sub_resource_from_resource(resource, sub_resource_idx)))
> + {
> + WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
> + return E_INVALIDARG;
> + }
> +
> + return sub_resource->resource_ops->resource_map(sub_resource, map_desc, box, flags);
> +}
I suppose in d3d11 this is part of ID3D11DeviceContext because of
deferred contexts maps. Perhaps once we have those in wined3d it will
end up in the device (although I think it's more likely to become part
of some interface on top of wined3d_cs), but right now the "device"
parameter isn't even used.
I think that for the time being the interface we want is just
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);
> diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
> index fd7bbc8..fb296b1 100644
> --- a/dlls/wined3d/wined3d_private.h
> +++ b/dlls/wined3d/wined3d_private.h
> @@ -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_map)(struct wined3d_resource *resource, struct wined3d_map_desc *map_desc,
> + const struct wined3d_box *box, DWORD flags);
> };
>
Here we'll probably want something like
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);
That implies having different resource ops for 2D and 3D textures, but
that's easy. It also implies returning an error when this is called on
a surface or volume.
I'm not sure how easy it would be at this point, but we'll probably
just want resource ops on sub-resources to print an ERR(). E.g.
ideally we'd never call resource_unload() on a surface, but only ever
on a texture. But that then means not adding sub-resources to the
device's resource list, etc.