From 0abfb80dacf80c1f2d0a6a4142b9ab84695aa9e7 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Sun, 7 Dec 2014 16:51:49 +0100 Subject: st/nine: Return D3DERR_INVALIDCALL when trying to create a texture of bad format Reviewed-by: Ilia Mirkin Reviewed-by: David Heidelberg Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/cubetexture9.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/gallium/state_trackers/nine/cubetexture9.c') diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c index 2c607c06799..bb1219aa88f 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,9 +57,15 @@ 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; info->width0 = EdgeLength; info->height0 = EdgeLength; info->depth0 = 1; -- cgit v1.2.3