[PATCH 4/5] wined3d: Reject unsupported pitches in wined3d_surface_update_desc().

Matteo Bruni matteo.mystral at gmail.com
Wed Feb 18 10:10:03 CST 2015

2015-02-18 16:44 GMT+01:00 Henri Verbeet <hverbeet at gmail.com>:
> On 18 February 2015 at 16:07, Stefan Dösinger <stefandoesinger at gmail.com> wrote:
>> Am 2015-02-18 um 14:20 schrieb Matteo Bruni:
>>> +    if (pitch & (texture_resource->format->byte_count - 1))
> I don't think this would do the right thing for formats where
> byte_count isn't a power of two. I also think the check belongs in
> wined3d_texture_update_desc(), since otherwise the texture would be in
> an inconsistent state if it fails. (That actually also applies to
> failing to create the DIB section, but that one seems much harder to
> avoid.)

In theory there are no non-power of two byte_count texture formats
from ddraw and d3d9ex always passes 0 as pitch. Actually initially I
wrote the check as:

if (WARN_ON(d3d) && pitch % texture_resource->format->byte_count)

I can go back to something like that, it's probably more consistent
with the point below.

>>> +    {
>>> +        WARN("Pitch unsupported, not a multiple of the texture format byte width.\n");
>>> +        return WINED3DERR_INVALIDCALL;
>>> +    }
>> I'd prefer this to be an ERR instead, and the return statement removed.
>> The idea is that since we don't ever expect this check to be true it
>> shouldn't result in different behavior and can be compiled out in a
>> build where debugging is disabled.
> It's a bit debatable in this case, since that depends on assumptions
> about callers outside of wined3d.

Yes, that was my reasoning for using WARN. I can change that though.
I'm certainly going to move the check to wined3d_texture_update_desc()
as you suggest.

More information about the wine-devel mailing list