st/nine: Add format checks to create_zs_or_rt_surface
authorAxel Davy <axel.davy@ens.fr>
Tue, 26 Jan 2016 17:21:26 +0000 (18:21 +0100)
committerAxel Davy <axel.davy@ens.fr>
Fri, 12 Feb 2016 22:26:36 +0000 (23:26 +0100)
Returns INVALIDCALL when trying to create a surface
of unsupported format.

In practice, apps are supposed to check for format
support before trying to create a render target
of that format. However some bad behaving apps
could just try to create the surface and deduce if
it failed that it wasn't supported.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
src/gallium/state_trackers/nine/device9.c

index b6e75b4514ffe2c90d675ae0cc1945d0c4e201b6..3ebff3a1b1fff61f524d9de35582724518e8f3d8 100644 (file)
@@ -1126,6 +1126,9 @@ create_zs_or_rt_surface(struct NineDevice9 *This,
                                                templ.nr_samples, templ.bind,
                                                FALSE);
 
+    if (templ.format == PIPE_FORMAT_NONE && Format != D3DFMT_NULL)
+        return D3DERR_INVALIDCALL;
+
     desc.Format = Format;
     desc.Type = D3DRTYPE_SURFACE;
     desc.Usage = 0;