[PATCH 1/5] wined3d: Store the map pitch in the wined3d_texture_sub_resource structure.

Henri Verbeet hverbeet at gmail.com
Thu Jun 24 10:02:51 CDT 2021


On Wed, 23 Jun 2021 at 23:39, Zebediah Figura <z.figura12 at gmail.com> wrote:
> +static void wined3d_texture_get_map_pitch(const struct wined3d_texture *texture,
> +        unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
> +{
> +    if (texture->resource.format_flags & WINED3DFMT_FLAG_BROKEN_PITCH)
> +    {
> +        *row_pitch = wined3d_texture_get_level_width(texture, level) * texture->resource.format->byte_count;
> +        *slice_pitch = wined3d_texture_get_level_height(texture, level) * (*row_pitch);
> +    }
> +    else
> +    {
> +        wined3d_texture_get_pitch(texture, level, row_pitch, slice_pitch);
> +    }
> +}
> +
The helper seems fine, although the reason we don't already have one
is that it's really only needed in a single place.

> diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
> index da1cf638606..1e6a315e72c 100644
> --- a/dlls/wined3d/wined3d_private.h
> +++ b/dlls/wined3d/wined3d_private.h
> @@ -4259,6 +4259,8 @@ struct wined3d_texture
>          DWORD locations;
>          struct wined3d_bo_gl bo;
>
> +        unsigned int map_row_pitch, map_slice_pitch;
> +
>          void *user_memory;
>      } *sub_resources;
>  };
I'm not as convinced about storing the pitch in the
wined3d_texture_sub_resource structure though. The cost of calculating
the pitch seems insignificant compared to the cost of actually mapping
the resource, and with large texture arrays there can be quite a
number of sub-resources here, so there's a memory cost to balance this
against as well. That said, if this ends up making a difference in
e.g. benchmarks I'd find that sufficient justification.



More information about the wine-devel mailing list