[PATCH 06/10] d3d9: use wined3d_rendertarget_view_create instead of wined3d_rendertarget_view_create_from_surface in d3d9_surface_get_rendertarget_view

Riccardo Bortolato rikyz619 at gmail.com
Tue Oct 20 11:05:51 CDT 2015

But d3d9_surface->sub_resource_idx is layer * container->level_count +
level so view->sub_resource_idx would still be ok, maybe view->depth
would be broken instead? But then it would be a problem of
layer_count, not layer_idx.

I know I'm somehow abusing wined3d_rendertarget_view_init() and the
desc structure but in practice it feels better than storing and
passing around an otherwise useless parameter (level idx)

Relevant snippet from wined3d/view.c:
        struct wined3d_texture *texture =
        struct wined3d_resource *sub_resource;

        view->sub_resource_idx = desc->u.texture.layer_idx *
texture->level_count + desc->u.texture.level_idx;
        sub_resource = wined3d_texture_get_sub_resource(texture,

        view->buffer_offset = 0;
        view->width = sub_resource->width;
        view->height = sub_resource->height;
        view->depth = desc->u.texture.layer_count;


2015-10-20 17:36 GMT+02:00 Henri Verbeet <hverbeet at gmail.com>:
> On 20 October 2015 at 16:42, Riccardo Bortolato <rikyz619 at gmail.com> wrote:
>> Is this different from d3d8?
> No, it's wrong there too, I just missed it. It happens to work in
> practice because wined3d_rendertarget_view_init() only uses the value
> to calculate the sub-resource index, but it would break as soon as we
> tried to create ARB_texture_view views for wined3d rendertarget views.

More information about the wine-devel mailing list