[Mesa-dev] [PATCH 11/53] st/nine: Return D3DERR_INVALIDCALL when trying to create a texture of bad format

Ilia Mirkin imirkin at alum.mit.edu
Wed Jan 7 08:59:12 PST 2015


On Wed, Jan 7, 2015 at 11:36 AM, Axel Davy <axel.davy at ens.fr> wrote:
> Reviewed-by: David Heidelberg <david at ixit.cz>
> Signed-off-by: Axel Davy <axel.davy at ens.fr>
> ---
>  src/gallium/state_trackers/nine/cubetexture9.c   |  8 ++++++++
>  src/gallium/state_trackers/nine/texture9.c       |  9 ++++++++-
>  src/gallium/state_trackers/nine/volumetexture9.c | 10 +++++++++-
>  3 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c
> index 2c607c0..43db8cb 100644
> --- a/src/gallium/state_trackers/nine/cubetexture9.c
> +++ b/src/gallium/state_trackers/nine/cubetexture9.c
> @@ -38,6 +38,8 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
>                         HANDLE *pSharedHandle )
>  {
>      struct pipe_resource *info = &This->base.base.info;
> +    struct pipe_screen *screen = pParams->device->screen;
> +    enum pipe_format pf;
>      unsigned i;
>      D3DSURFACE_DESC sfdesc;
>      HRESULT hr;
> @@ -55,6 +57,12 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
>      if (Usage & D3DUSAGE_AUTOGENMIPMAP)
>          Levels = 0;
>
> +    pf = d3d9_to_pipe_format(Format);
> +    if (pf == PIPE_FORMAT_NONE ||
> +        !screen->is_format_supported(screen, pf, PIPE_TEXTURE_CUBE, 0, PIPE_BIND_SAMPLER_VIEW)) {
> +        return D3DERR_INVALIDCALL;
> +    }
> +
>      info->screen = pParams->device->screen;
>      info->target = PIPE_TEXTURE_CUBE;
>      info->format = d3d9_to_pipe_format(Format);

info->format = pf; here as well for parity with the other code?

> diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c
> index 8852142..4d7e950 100644
> --- a/src/gallium/state_trackers/nine/texture9.c
> +++ b/src/gallium/state_trackers/nine/texture9.c
> @@ -47,6 +47,7 @@ NineTexture9_ctor( struct NineTexture9 *This,
>      struct pipe_screen *screen = pParams->device->screen;
>      struct pipe_resource *info = &This->base.base.info;
>      struct pipe_resource *resource;
> +    enum pipe_format pf;
>      unsigned l;
>      D3DSURFACE_DESC sfdesc;
>      HRESULT hr;
> @@ -92,9 +93,15 @@ NineTexture9_ctor( struct NineTexture9 *This,
>      if (Usage & D3DUSAGE_AUTOGENMIPMAP)
>          Levels = 0;
>
> +    pf = d3d9_to_pipe_format(Format);
> +    if (Format != D3DFMT_NULL && (pf == PIPE_FORMAT_NONE ||

None of the others have this check... is null valid here but not for
cube/volume?

  -ilia


More information about the mesa-dev mailing list