st/nine: SCRATCH does support all formats
authorAxel Davy <axel.davy@ens.fr>
Tue, 26 Jan 2016 17:27:39 +0000 (18:27 +0100)
committerAxel Davy <axel.davy@ens.fr>
Fri, 12 Feb 2016 22:26:36 +0000 (23:26 +0100)
Add new argument to d3d9_to_pipe_format_checked to
be able to bypass format support checks. This argument
is set to TRUE when the requested Pool is SCRATCH.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
src/gallium/state_trackers/nine/adapter9.c
src/gallium/state_trackers/nine/cubetexture9.c
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/nine_pipe.h
src/gallium/state_trackers/nine/surface9.c
src/gallium/state_trackers/nine/swapchain9.c
src/gallium/state_trackers/nine/texture9.c
src/gallium/state_trackers/nine/volume9.c
src/gallium/state_trackers/nine/volumetexture9.c

index 5e9c7f73a509853f5d12ed692b2f09b4d08aaa20..e677c7bd6b8ee04467aed24f4f0e3952cf8b1d67 100644 (file)
@@ -207,11 +207,11 @@ NineAdapter9_CheckDeviceType( struct NineAdapter9 *This,
     dfmt = d3d9_to_pipe_format_checked(screen, AdapterFormat, PIPE_TEXTURE_2D,
                                        1,
                                        PIPE_BIND_DISPLAY_TARGET |
-                                       PIPE_BIND_SHARED, FALSE);
+                                       PIPE_BIND_SHARED, FALSE, FALSE);
     bfmt = d3d9_to_pipe_format_checked(screen, BackBufferFormat, PIPE_TEXTURE_2D,
                                        1,
                                        PIPE_BIND_DISPLAY_TARGET |
-                                       PIPE_BIND_SHARED, FALSE);
+                                       PIPE_BIND_SHARED, FALSE, FALSE);
     if (dfmt == PIPE_FORMAT_NONE || bfmt == PIPE_FORMAT_NONE) {
         DBG("Unsupported Adapter/BackBufferFormat.\n");
         return D3DERR_NOTAVAILABLE;
@@ -270,7 +270,7 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This,
         return hr;
     pf = d3d9_to_pipe_format_checked(screen, AdapterFormat, PIPE_TEXTURE_2D, 0,
                                      PIPE_BIND_DISPLAY_TARGET |
-                                     PIPE_BIND_SHARED, FALSE);
+                                     PIPE_BIND_SHARED, FALSE, FALSE);
     if (pf == PIPE_FORMAT_NONE) {
         DBG("AdapterFormat %s not available.\n",
             d3dformat_to_string(AdapterFormat));
@@ -332,7 +332,8 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This,
 
 
     srgb = (Usage & (D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE)) != 0;
-    pf = d3d9_to_pipe_format_checked(screen, CheckFormat, target, 0, bind, srgb);
+    pf = d3d9_to_pipe_format_checked(screen, CheckFormat, target,
+                                     0, bind, srgb, FALSE);
     if (pf == PIPE_FORMAT_NONE) {
         DBG("NOT AVAILABLE\n");
         return D3DERR_NOTAVAILABLE;
@@ -379,7 +380,7 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This,
                PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_RENDER_TARGET;
 
     pf = d3d9_to_pipe_format_checked(screen, SurfaceFormat, PIPE_TEXTURE_2D,
-                                     MultiSampleType, bind, FALSE);
+                                     MultiSampleType, bind, FALSE, FALSE);
 
     if (pf == PIPE_FORMAT_NONE) {
         DBG("%s with %u samples not available.\n",
@@ -418,16 +419,16 @@ NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9 *This,
 
     dfmt = d3d9_to_pipe_format_checked(screen, AdapterFormat, PIPE_TEXTURE_2D, 0,
                                        PIPE_BIND_DISPLAY_TARGET |
-                                       PIPE_BIND_SHARED, FALSE);
+                                       PIPE_BIND_SHARED, FALSE, FALSE);
     bfmt = d3d9_to_pipe_format_checked(screen, RenderTargetFormat,
                                        PIPE_TEXTURE_2D, 0,
-                                       PIPE_BIND_RENDER_TARGET, FALSE);
+                                       PIPE_BIND_RENDER_TARGET, FALSE, FALSE);
     if (RenderTargetFormat == D3DFMT_NULL)
         bfmt = dfmt;
     zsfmt = d3d9_to_pipe_format_checked(screen, DepthStencilFormat,
                                         PIPE_TEXTURE_2D, 0,
                                         d3d9_get_pipe_depth_format_bindings(DepthStencilFormat),
-                                        FALSE);
+                                        FALSE, FALSE);
     if (dfmt == PIPE_FORMAT_NONE ||
         bfmt == PIPE_FORMAT_NONE ||
         zsfmt == PIPE_FORMAT_NONE) {
@@ -462,10 +463,10 @@ NineAdapter9_CheckDeviceFormatConversion( struct NineAdapter9 *This,
 
     dfmt = d3d9_to_pipe_format_checked(screen, TargetFormat, PIPE_TEXTURE_2D, 1,
                                        PIPE_BIND_DISPLAY_TARGET |
-                                       PIPE_BIND_SHARED, FALSE);
+                                       PIPE_BIND_SHARED, FALSE, FALSE);
     bfmt = d3d9_to_pipe_format_checked(screen, SourceFormat, PIPE_TEXTURE_2D, 1,
                                        PIPE_BIND_DISPLAY_TARGET |
-                                       PIPE_BIND_SHARED, FALSE);
+                                       PIPE_BIND_SHARED, FALSE, FALSE);
 
     if (dfmt == PIPE_FORMAT_NONE || bfmt == PIPE_FORMAT_NONE) {
         DBG("%s to %s not supported.\n",
index 03b5fcad60ec064e4cb40db2aeb0e0d0b274f1ab..1d39c8f2c818da716b1d2a015378a3725815e223 100644 (file)
@@ -65,7 +65,9 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
         Levels = 0;
 
     pf = d3d9_to_pipe_format_checked(screen, Format, PIPE_TEXTURE_CUBE, 0,
-                                     PIPE_BIND_SAMPLER_VIEW, FALSE);
+                                     PIPE_BIND_SAMPLER_VIEW, FALSE,
+                                     Pool == D3DPOOL_SCRATCH);
+
     if (pf == PIPE_FORMAT_NONE)
         return D3DERR_INVALIDCALL;
 
index 3ebff3a1b1fff61f524d9de35582724518e8f3d8..805cba5baa5f008c15a777bcac9ed12d434787c0 100644 (file)
@@ -1124,7 +1124,7 @@ create_zs_or_rt_surface(struct NineDevice9 *This,
     }
     templ.format = d3d9_to_pipe_format_checked(screen, Format, templ.target,
                                                templ.nr_samples, templ.bind,
-                                               FALSE);
+                                               FALSE, Pool == D3DPOOL_SCRATCH);
 
     if (templ.format == PIPE_FORMAT_NONE && Format != D3DFMT_NULL)
         return D3DERR_INVALIDCALL;
index 86117866ed5316281edfbfc64ea670d5421d7d38..1ffce7dc1d72e1679aea9ea5d75dd3f71cead208 100644 (file)
@@ -324,7 +324,8 @@ d3d9_to_pipe_format_checked(struct pipe_screen *screen,
                             enum pipe_texture_target target,
                             unsigned sample_count,
                             unsigned bindings,
-                            boolean srgb)
+                            boolean srgb,
+                            boolean bypass_check)
 {
     enum pipe_format result;
 
@@ -335,7 +336,10 @@ d3d9_to_pipe_format_checked(struct pipe_screen *screen,
     if (srgb)
         result = util_format_srgb(result);
 
-    if (format_check_internal(result))
+    /* bypass_check: Used for D3DPOOL_SCRATCH, which
+     * isn't limited to the formats supported by the
+     * device. */
+    if (bypass_check || format_check_internal(result))
         return result;
 
     /* fallback to another format for formats
index ce0f74ceabb359c92b6680c1481539daf9c8e74a..eaf142bb85fe569d9d5b1080f8ffe19eff0a0fec 100644 (file)
@@ -97,7 +97,8 @@ NineSurface9_ctor( struct NineSurface9 *This,
                                                          This->base.info.target,
                                                          This->base.info.nr_samples,
                                                          This->base.info.bind,
-                                                         FALSE);
+                                                         FALSE,
+                                                         pDesc->Pool == D3DPOOL_SCRATCH);
 
     if (pDesc->Usage & D3DUSAGE_RENDERTARGET)
         This->base.info.bind |= PIPE_BIND_RENDER_TARGET;
index 82d4173fbb2dc3d4010971ebbc2e9a499c1d13a0..313fedec7e5ac1fc4d09c47a022767f4185c1c85 100644 (file)
@@ -202,7 +202,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
 
     pf = d3d9_to_pipe_format_checked(This->screen, pParams->BackBufferFormat,
                                      PIPE_TEXTURE_2D, pParams->MultiSampleType,
-                                     PIPE_BIND_RENDER_TARGET, FALSE);
+                                     PIPE_BIND_RENDER_TARGET, FALSE, FALSE);
 
     if (This->actx->linear_framebuffer ||
         (pf != PIPE_FORMAT_B8G8R8X8_UNORM &&
@@ -304,7 +304,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
                                                    pParams->BackBufferFormat,
                                                    PIPE_TEXTURE_2D,
                                                    tmplt.nr_samples,
-                                                   tmplt.bind, FALSE);
+                                                   tmplt.bind, FALSE, FALSE);
         if (tmplt.format == PIPE_FORMAT_NONE)
             return D3DERR_INVALIDCALL;
         resource = This->screen->resource_create(This->screen, &tmplt);
@@ -360,7 +360,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
                                                    PIPE_TEXTURE_2D,
                                                    tmplt.nr_samples,
                                                    tmplt.bind,
-                                                   FALSE);
+                                                   FALSE, FALSE);
         if (tmplt.format == PIPE_FORMAT_NONE) {
             tmplt.bind &= ~PIPE_BIND_SAMPLER_VIEW;
             tmplt.format = d3d9_to_pipe_format_checked(This->screen,
@@ -368,7 +368,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
                                                        PIPE_TEXTURE_2D,
                                                        tmplt.nr_samples,
                                                        tmplt.bind,
-                                                       FALSE);
+                                                       FALSE, FALSE);
         }
 
         if (tmplt.format == PIPE_FORMAT_NONE)
index 3052937311c255523663449695db2234582a18de..6c4569b96df76f10e25e8f564bba6f5555db9dee 100644 (file)
@@ -106,7 +106,9 @@ NineTexture9_ctor( struct NineTexture9 *This,
         Levels = 0;
 
     pf = d3d9_to_pipe_format_checked(screen, Format, PIPE_TEXTURE_2D, 0,
-                                     PIPE_BIND_SAMPLER_VIEW, FALSE);
+                                     PIPE_BIND_SAMPLER_VIEW, FALSE,
+                                     Pool == D3DPOOL_SCRATCH);
+
     if (Format != D3DFMT_NULL && pf == PIPE_FORMAT_NONE)
         return D3DERR_INVALIDCALL;
 
index 5ef11414f3e00064fa81b7731776eb4cb5e4c4b0..8504ffa3d0e1bb8b4edd53a6c7d01aa17332c0b1 100644 (file)
@@ -106,7 +106,8 @@ NineVolume9_ctor( struct NineVolume9 *This,
                                                     pDesc->Format,
                                                     This->info.target,
                                                     This->info.nr_samples,
-                                                    This->info.bind, FALSE);
+                                                    This->info.bind, FALSE,
+                                                    pDesc->Pool == D3DPOOL_SCRATCH);
 
     if (This->info.format == PIPE_FORMAT_NONE)
         return D3DERR_DRIVERINTERNALERROR;
index cd94a36b64a9551a8e7c6d24b0b9f6d6cc580e99..439106d9f81f19e0644cbe0ce812cc5802a3ba4d 100644 (file)
@@ -59,7 +59,9 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This,
     user_assert(!(Usage & D3DUSAGE_AUTOGENMIPMAP), D3DERR_INVALIDCALL);
 
     pf = d3d9_to_pipe_format_checked(screen, Format, PIPE_TEXTURE_3D, 0,
-                                     PIPE_BIND_SAMPLER_VIEW, FALSE);
+                                     PIPE_BIND_SAMPLER_VIEW, FALSE,
+                                     Pool == D3DPOOL_SCRATCH);
+
     if (pf == PIPE_FORMAT_NONE)
         return D3DERR_INVALIDCALL;