[PATCH 1/3] d3dx10: Implement D3DX10CreateTextureFromMemory initially.

Matteo Bruni matteo.mystral at gmail.com
Tue Jun 22 12:54:05 CDT 2021


On Fri, Jun 18, 2021 at 8:29 AM Ziqing Hui <zhui at codeweavers.com> wrote:
>
>
> Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
> ---
>  dlls/d3dx10_43/d3dx10_43_main.c |  11 --
>  dlls/d3dx10_43/tests/d3dx10.c   |   7 +-
>  dlls/d3dx10_43/texture.c        | 233 ++++++++++++++++++++++++++++++++
>  3 files changed, 236 insertions(+), 15 deletions(-)

> hr = D3DX10GetImageInfoFromMemory(src_data, src_data_size, NULL, &img_info, NULL);
>     if (FAILED(hr))
>         return E_FAIL;

You can put the function call into the if to make it more compact (and
follow more closely our current style), such as:

if (FAILED(D3DX10GetImageInfoFromMemory(src_data, src_data_size, NULL,
&img_info, NULL)))
    return E_FAIL;

Similarly below.

> +    WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);

I don't know WIC particularly well but it seems prudent to me to check
the return value of this function call.

> +    hr = ID3D10Device_CreateTexture2D(device, &texture_2d_desc, NULL, &texture_2d);
> +    if (FAILED(hr))
> +        goto end;
> +    ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_2d, 0, NULL, buffer, stride, frame_size);

I think you can pass the texture data directly to CreateTexture2D()
here, avoiding the separate UpdateSubresource().

> +    *texture = (ID3D10Resource *)texture_2d;

I wonder if that is supposed to be set to NULL on failure. Can you
please add a test for that?

> +    if (hr != S_OK)
> +        return E_FAIL;
> +    return S_OK;

Is this necessary? As opposed to a simple "return hr;".



More information about the wine-devel mailing list