[PATCH v2 8/9] d3d11: Implement Texture1D.

Józef Kucia joseph.kucia at gmail.com
Thu Jan 4 05:21:31 CST 2018


On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse <shesse at codeweavers.com> wrote:
> Signed-off-by: Sven Hesse <shesse at codeweavers.com>
> ---
>  dlls/d3d11/d3d11_private.h |  24 ++
>  dlls/d3d11/device.c        |  13 +-
>  dlls/d3d11/texture.c       | 537 +++++++++++++++++++++++++++++++++++++++++++++
>  dlls/d3d11/utils.c         |   4 +
>  4 files changed, 576 insertions(+), 2 deletions(-)
>
> diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
> index 4d9f34ea42..6f4184b0b1 100644
> --- a/dlls/d3d11/d3d11_private.h
> +++ b/dlls/d3d11/d3d11_private.h
> @@ -112,6 +112,30 @@ void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
>  HRESULT parse_dxbc(const char *data, SIZE_T data_size,
>          HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN;
>
> +/* ID3D11Texture1D, ID3D10Texture1D */
> +struct d3d_texture1d
> +{
> +    ID3D11Texture1D ID3D11Texture1D_iface;
> +    ID3D10Texture1D ID3D10Texture1D_iface;
> +    LONG refcount;
> +
> +    struct wined3d_private_store private_store;
> +    IUnknown *dxgi_surface;
> +    struct wined3d_texture *wined3d_texture;
> +    D3D11_TEXTURE1D_DESC desc;
> +    ID3D11Device *device;
> +};
> +
> +static inline struct d3d_texture1d *impl_from_ID3D10Texture1D(ID3D10Texture1D *iface)
> +{
> +    return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface);
> +}

Please move impl_from_ID3D10Texture1D() to texture.c file.

> +
> +static void STDMETHODCALLTYPE d3d11_texture1d_GetDesc(ID3D11Texture1D *iface, D3D11_TEXTURE1D_DESC *desc)
> +{
> +    struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface);
> +    struct wined3d_resource_desc wined3d_desc;
> +
> +    TRACE("iface %p, desc %p.\n", iface, desc);
> +
> +    *desc = texture->desc;
> +
> +    wined3d_mutex_lock();
> +    wined3d_resource_get_desc(wined3d_texture_get_resource(texture->wined3d_texture), &wined3d_desc);
> +    wined3d_mutex_unlock();
> +
> +    /* FIXME: Resizing swapchain buffers can cause these to change. We'd like
> +     * to get everything from wined3d, but e.g. bind flags don't exist as such
> +     * there (yet). */
> +    desc->Width = wined3d_desc.width;
> +    desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format);
> +}

Is it possible to create swapchains with 1D textures? We do not ever
create such swapchains so the comment (and code) is not accurate.

> +
> +struct d3d_texture1d *unsafe_impl_from_ID3D10Texture1D(ID3D10Texture1D *iface)
> +{
> +    if (!iface)
> +        return NULL;
> +    assert(iface->lpVtbl == &d3d10_texture1d_vtbl);
> +    return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface);
> +}
> +
> +static const struct wined3d_parent_ops d3d_texture1d_wined3d_parent_ops =
> +{
> +    d3d_texture1d_wined3d_object_released,
> +};
> +
> +/*
> +static BOOL is_gdi_compatible_texture(const D3D11_TEXTURE1D_DESC *desc)
> +{
> +    if (!(desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM
> +            || desc->Format == DXGI_FORMAT_B8G8R8A8_TYPELESS
> +            || desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB))
> +        return FALSE;
> +
> +    if (desc->Usage != D3D11_USAGE_DEFAULT)
> +        return FALSE;
> +
> +    return TRUE;
> +}
> +
> +static BOOL validate_texture1d_desc(const D3D11_TEXTURE1D_DESC *desc)
> +{
> +    if (desc->MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE
> +            && desc->ArraySize < 6)
> +    {
> +        WARN("Invalid array size %u for cube texture.\n", desc->ArraySize);
> +        return FALSE;
> +    }
> +
> +    if (desc->MiscFlags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE
> +            && !is_gdi_compatible_texture(desc))
> +    {
> +        WARN("Incompatible description used to create GDI compatible texture.\n");
> +        return FALSE;
> +    }
> +
> +    return TRUE;
> +}

It would be good to test if 1D textures need GDI support.

> +*/
> +
> +HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc,
> +        const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **out)
> +{
> +    struct wined3d_resource_desc wined3d_desc;
> +    struct d3d_texture1d *texture;
> +    unsigned int levels;
> +    DWORD flags = 0;
> +    HRESULT hr;
> +
> +/*
> +    if (!validate_texture1d_desc(desc))
> +    {
> +        WARN("Failed to validate texture desc.\n");
> +        return E_INVALIDARG;
> +    }
> +*/
> +

Please do not introduce commented out code.

> diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c
> index e919c58da4..790e16eaaf 100644
> --- a/dlls/d3d11/utils.c
> +++ b/dlls/d3d11/utils.c
> @@ -607,6 +607,10 @@ struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *re
>              return wined3d_buffer_get_resource(unsafe_impl_from_ID3D11Buffer(
>                      (ID3D11Buffer *)resource)->wined3d_buffer);
>
> +        case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
> +            return wined3d_texture_get_resource(unsafe_impl_from_ID3D11Texture1D(
> +                    (ID3D11Texture1D *)resource)->wined3d_texture);
> +
>          case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
>              return wined3d_texture_get_resource(unsafe_impl_from_ID3D11Texture2D(
>                      (ID3D11Texture2D *)resource)->wined3d_texture);

You should also handle 1D textures in wined3d_resource_from_d3d10_resource().

> --
> 2.15.1
>
>
>



More information about the wine-devel mailing list