[PATCH] d3dx9: Signature isn't part of the DDS header

Henri Verbeet hverbeet at gmail.com
Thu Jan 28 06:04:42 CST 2016


On 28 January 2016 at 00:20, Matteo Bruni <matteo.mystral at gmail.com> wrote:
>> @@ -437,8 +442,8 @@ static HRESULT load_surface_from_dds(IDirect3DSurface9 *dst_surface, const PALET
>>  {
>>      UINT size;
>>      UINT src_pitch;
>> -    const struct dds_header *header = src_data;
>> -    const BYTE *pixels = (BYTE *)(header + 1);
>> +    const struct DDS *dds = src_data;
>> +    const BYTE *pixels = (BYTE *)(dds + 1);
>
> I guess you could instead make the src_data parameter BYTE * and
> compute "pixels" as src_data + sizeof(struct dds) (or however you want
> to call the new struct). It's mostly a matter of taste though so it's
> fine to me either way.
>
If you define struct dds as
    struct dds
    {
        DWORD signature;
       struct dds_header header;
       BYTE data[1];
    };
you can just change load_surface_from_dds() to take "const struct dds
*dds" as parameter instead of src_data, and pass dds->data to
D3DXLoadSurfaceFromMemory(). Or just pass dds->data to
load_surface_from_dds() and rename that function, since it doesn't do
all that much with the information in the header.

It also means you can do things like "return FIELD_OFFSET(struct dds,
data[data_size]);" in calculate_dds_file_size().

You may also want to consider just merging surface.c and volume.c into
texture.c.

On 27 January 2016 at 10:29, Alistair Leslie-Hughes
<leslie_alistair at hotmail.com> wrote:
> +    memset(dds, 0, sizeof(*dds));
> +    dds->signature = MAKEFOURCC('D','D','S',' ');
> +    dds->header.size = sizeof(struct dds_header);
+    dds->header.size = sizeof(dds->header);



More information about the wine-devel mailing list