[Mesa-dev] [PATCH 08/12] st/nine: SCRATCH does support all formats

Axel Davy axel.davy at ens.fr
Sun Feb 7 23:13:15 UTC 2016


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 at ens.fr>
---
 src/gallium/state_trackers/nine/adapter9.c       | 21 +++++++++++----------
 src/gallium/state_trackers/nine/cubetexture9.c   |  4 +++-
 src/gallium/state_trackers/nine/device9.c        |  2 +-
 src/gallium/state_trackers/nine/nine_pipe.h      |  8 ++++++--
 src/gallium/state_trackers/nine/surface9.c       |  3 ++-
 src/gallium/state_trackers/nine/swapchain9.c     |  8 ++++----
 src/gallium/state_trackers/nine/texture9.c       |  4 +++-
 src/gallium/state_trackers/nine/volume9.c        |  3 ++-
 src/gallium/state_trackers/nine/volumetexture9.c |  4 +++-
 9 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c
index 5e9c7f7..e677c7b 100644
--- a/src/gallium/state_trackers/nine/adapter9.c
+++ b/src/gallium/state_trackers/nine/adapter9.c
@@ -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",
diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c
index 03b5fca..1d39c8f 100644
--- a/src/gallium/state_trackers/nine/cubetexture9.c
+++ b/src/gallium/state_trackers/nine/cubetexture9.c
@@ -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;
 
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 3ebff3a..805cba5 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -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;
diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h
index 8611786..1ffce7d 100644
--- a/src/gallium/state_trackers/nine/nine_pipe.h
+++ b/src/gallium/state_trackers/nine/nine_pipe.h
@@ -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
diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c
index ce0f74c..eaf142b 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -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;
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index 82d4173..313fede 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -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)
diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c
index 3052937..6c4569b 100644
--- a/src/gallium/state_trackers/nine/texture9.c
+++ b/src/gallium/state_trackers/nine/texture9.c
@@ -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;
 
diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c
index 5ef1141..8504ffa 100644
--- a/src/gallium/state_trackers/nine/volume9.c
+++ b/src/gallium/state_trackers/nine/volume9.c
@@ -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;
diff --git a/src/gallium/state_trackers/nine/volumetexture9.c b/src/gallium/state_trackers/nine/volumetexture9.c
index cd94a36..439106d 100644
--- a/src/gallium/state_trackers/nine/volumetexture9.c
+++ b/src/gallium/state_trackers/nine/volumetexture9.c
@@ -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;
 
-- 
2.7.0



More information about the mesa-dev mailing list