[Mesa-stable] [PATCH v3 02/19] st/nine: Rework Basetexture9 and Resource9.

David Heidelberg david at ixit.cz
Mon Nov 24 15:38:02 PST 2014


From: Axel Davy <axel.davy at ens.fr>

Instead of having parts of the structures initialised by the parents,
have them initialised by the children.

Cc: "10.4" <mesa-stable at lists.freedesktop.org>
Tested-by: David Heidelberg <david at ixit.cz>
Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/basetexture9.c   | 19 +++++++++++--------
 src/gallium/state_trackers/nine/basetexture9.h   |  5 ++++-
 src/gallium/state_trackers/nine/cubetexture9.c   |  7 ++-----
 src/gallium/state_trackers/nine/indexbuffer9.c   |  4 ++--
 src/gallium/state_trackers/nine/resource9.c      |  8 +++++++-
 src/gallium/state_trackers/nine/resource9.h      |  4 +++-
 src/gallium/state_trackers/nine/surface9.c       |  6 ++----
 src/gallium/state_trackers/nine/texture9.c       |  5 +----
 src/gallium/state_trackers/nine/vertexbuffer9.c  |  4 ++--
 src/gallium/state_trackers/nine/volumetexture9.c |  7 ++-----
 10 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c
index 89f6269..6d41592 100644
--- a/src/gallium/state_trackers/nine/basetexture9.c
+++ b/src/gallium/state_trackers/nine/basetexture9.c
@@ -41,25 +41,28 @@
 HRESULT
 NineBaseTexture9_ctor( struct NineBaseTexture9 *This,
                        struct NineUnknownParams *pParams,
+                       struct pipe_resource *initResource,
                        D3DRESOURCETYPE Type,
-                       D3DPOOL Pool )
+                       D3DFORMAT format,
+                       D3DPOOL Pool,
+                       DWORD Usage)
 {
-    BOOL alloc = (Pool == D3DPOOL_DEFAULT) && !This->base.resource &&
-        (This->format != D3DFMT_NULL);
+    BOOL alloc = (Pool == D3DPOOL_DEFAULT) && !initResource &&
+        (format != D3DFMT_NULL);
     HRESULT hr;
-    DWORD usage = This->base.usage;
 
-    user_assert(!(usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) ||
+    user_assert(!(Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) ||
                 Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
-    user_assert(!(usage & D3DUSAGE_DYNAMIC) ||
+    user_assert(!(Usage & D3DUSAGE_DYNAMIC) ||
                 Pool != D3DPOOL_MANAGED, D3DERR_INVALIDCALL);
 
-    hr = NineResource9_ctor(&This->base, pParams, alloc, Type, Pool);
+    hr = NineResource9_ctor(&This->base, pParams, initResource, alloc, Type, Pool, Usage);
     if (FAILED(hr))
         return hr;
 
+    This->format = format;
     This->pipe = pParams->device->pipe;
-    This->mipfilter = (This->base.usage & D3DUSAGE_AUTOGENMIPMAP) ?
+    This->mipfilter = (Usage & D3DUSAGE_AUTOGENMIPMAP) ?
         D3DTEXF_LINEAR : D3DTEXF_NONE;
     This->lod = 0;
     This->lod_resident = -1;
diff --git a/src/gallium/state_trackers/nine/basetexture9.h b/src/gallium/state_trackers/nine/basetexture9.h
index d615376..0062771 100644
--- a/src/gallium/state_trackers/nine/basetexture9.h
+++ b/src/gallium/state_trackers/nine/basetexture9.h
@@ -59,8 +59,11 @@ NineBaseTexture9( void *data )
 HRESULT
 NineBaseTexture9_ctor( struct NineBaseTexture9 *This,
                        struct NineUnknownParams *pParams,
+                       struct pipe_resource *initResource,
                        D3DRESOURCETYPE Type,
-                       D3DPOOL Pool );
+                       D3DFORMAT format,
+                       D3DPOOL Pool,
+                       DWORD Usage);
 
 void
 NineBaseTexture9_dtor( struct NineBaseTexture9 *This );
diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c
index 77802e7..4f63162 100644
--- a/src/gallium/state_trackers/nine/cubetexture9.c
+++ b/src/gallium/state_trackers/nine/cubetexture9.c
@@ -50,9 +50,6 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
     if (Usage & D3DUSAGE_AUTOGENMIPMAP)
         Levels = 0;
 
-    This->base.format = Format;
-    This->base.base.usage = Usage;
-
     info->screen = pParams->device->screen;
     info->target = PIPE_TEXTURE_CUBE;
     info->format = d3d9_to_pipe_format(Format);
@@ -85,8 +82,8 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
     if (!This->surfaces)
         return E_OUTOFMEMORY;
 
-    hr = NineBaseTexture9_ctor(&This->base, pParams, D3DRTYPE_CUBETEXTURE,
-                               Pool);
+    hr = NineBaseTexture9_ctor(&This->base, pParams, NULL, D3DRTYPE_CUBETEXTURE,
+                               Format, Pool, Usage);
     if (FAILED(hr))
         return hr;
     This->base.pstype = 2;
diff --git a/src/gallium/state_trackers/nine/indexbuffer9.c b/src/gallium/state_trackers/nine/indexbuffer9.c
index c5606f1..48553fd 100644
--- a/src/gallium/state_trackers/nine/indexbuffer9.c
+++ b/src/gallium/state_trackers/nine/indexbuffer9.c
@@ -76,8 +76,8 @@ NineIndexBuffer9_ctor( struct NineIndexBuffer9 *This,
     info->last_level = 0;
     info->nr_samples = 0;
 
-    hr = NineResource9_ctor(&This->base, pParams, TRUE, D3DRTYPE_INDEXBUFFER,
-                            pDesc->Pool);
+    hr = NineResource9_ctor(&This->base, pParams, NULL, TRUE, D3DRTYPE_INDEXBUFFER,
+                            pDesc->Pool, pDesc->Usage);
     if (FAILED(hr))
         return hr;
 
diff --git a/src/gallium/state_trackers/nine/resource9.c b/src/gallium/state_trackers/nine/resource9.c
index 8f53558..c82180b 100644
--- a/src/gallium/state_trackers/nine/resource9.c
+++ b/src/gallium/state_trackers/nine/resource9.c
@@ -38,9 +38,11 @@
 HRESULT
 NineResource9_ctor( struct NineResource9 *This,
                     struct NineUnknownParams *pParams,
+                    struct pipe_resource *initResource,
                     BOOL Allocate,
                     D3DRESOURCETYPE Type,
-                    D3DPOOL Pool )
+                    D3DPOOL Pool,
+                    DWORD Usage)
 {
     struct pipe_screen *screen;
     HRESULT hr;
@@ -50,8 +52,11 @@ NineResource9_ctor( struct NineResource9 *This,
         return hr;
 
     This->info.screen = screen = This->base.device->screen;
+    if (initResource)
+        pipe_resource_reference(&This->resource, initResource);
 
     if (Allocate) {
+        assert(!initResource);
         DBG("(%p) Creating pipe_resource.\n", This);
         This->resource = screen->resource_create(screen, &This->info);
         if (!This->resource)
@@ -61,6 +66,7 @@ NineResource9_ctor( struct NineResource9 *This,
     This->data = NULL; /* FIXME remove, rather set it to null in surface9.c*/
     This->type = Type;
     This->pool = Pool;
+    This->usage = Usage;
     This->priority = 0;
 
     This->pdata = util_hash_table_create(ht_guid_hash, ht_guid_compare);
diff --git a/src/gallium/state_trackers/nine/resource9.h b/src/gallium/state_trackers/nine/resource9.h
index 0451498..d18f0cf 100644
--- a/src/gallium/state_trackers/nine/resource9.h
+++ b/src/gallium/state_trackers/nine/resource9.h
@@ -57,9 +57,11 @@ NineResource9( void *data )
 HRESULT
 NineResource9_ctor( struct NineResource9 *This,
                     struct NineUnknownParams *pParams,
+                    struct pipe_resource *initResource,
                     BOOL Allocate,
                     D3DRESOURCETYPE Type,
-                    D3DPOOL Pool );
+                    D3DPOOL Pool,
+                    DWORD Usage);
 
 void
 NineResource9_dtor( struct NineResource9 *This );
diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c
index 42a9e05..94b4d07 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -88,14 +88,12 @@ NineSurface9_ctor( struct NineSurface9 *This,
     } else {
         if (pResource && (pDesc->Usage & D3DUSAGE_DYNAMIC))
             pResource->flags |= NINE_RESOURCE_FLAG_LOCKABLE;
-        pipe_resource_reference(&This->base.resource, pResource);
     }
 
-    hr = NineResource9_ctor(&This->base, pParams, FALSE, D3DRTYPE_SURFACE,
-                            pDesc->Pool);
+    hr = NineResource9_ctor(&This->base, pParams, pResource, FALSE, D3DRTYPE_SURFACE,
+                            pDesc->Pool, pDesc->Usage);
     if (FAILED(hr))
         return hr;
-    This->base.usage = pDesc->Usage;
 
     This->pipe = This->base.base.device->pipe;
     This->transfer = NULL;
diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c
index c13268d..e30f955 100644
--- a/src/gallium/state_trackers/nine/texture9.c
+++ b/src/gallium/state_trackers/nine/texture9.c
@@ -94,9 +94,6 @@ NineTexture9_ctor( struct NineTexture9 *This,
     if (Usage & D3DUSAGE_AUTOGENMIPMAP)
         Levels = 0;
 
-    This->base.format = Format;
-    This->base.base.usage = Usage;
-
     info->screen = screen;
     info->target = PIPE_TEXTURE_2D;
     info->format = d3d9_to_pipe_format(Format);
@@ -148,7 +145,7 @@ NineTexture9_ctor( struct NineTexture9 *This,
     if (!This->surfaces)
         return E_OUTOFMEMORY;
 
-    hr = NineBaseTexture9_ctor(&This->base, pParams, D3DRTYPE_TEXTURE, Pool);
+    hr = NineBaseTexture9_ctor(&This->base, pParams, NULL, D3DRTYPE_TEXTURE, Format, Pool, Usage);
     if (FAILED(hr))
         return hr;
     This->base.pstype = (Height == 1) ? 1 : 0;
diff --git a/src/gallium/state_trackers/nine/vertexbuffer9.c b/src/gallium/state_trackers/nine/vertexbuffer9.c
index 6a57349..11cc60f 100644
--- a/src/gallium/state_trackers/nine/vertexbuffer9.c
+++ b/src/gallium/state_trackers/nine/vertexbuffer9.c
@@ -85,8 +85,8 @@ NineVertexBuffer9_ctor( struct NineVertexBuffer9 *This,
     info->last_level = 0;
     info->nr_samples = 0;
 
-    hr = NineResource9_ctor(&This->base, pParams, TRUE, D3DRTYPE_VERTEXBUFFER,
-                            pDesc->Pool);
+    hr = NineResource9_ctor(&This->base, pParams, NULL, TRUE,
+                            D3DRTYPE_VERTEXBUFFER, pDesc->Pool, pDesc->Usage);
     if (FAILED(hr))
         return hr;
 
diff --git a/src/gallium/state_trackers/nine/volumetexture9.c b/src/gallium/state_trackers/nine/volumetexture9.c
index 65d320c..a35d3f7 100644
--- a/src/gallium/state_trackers/nine/volumetexture9.c
+++ b/src/gallium/state_trackers/nine/volumetexture9.c
@@ -52,9 +52,6 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This,
     if (Usage & D3DUSAGE_AUTOGENMIPMAP)
         Levels = 0;
 
-    This->base.format = Format;
-    This->base.base.usage = Usage;
-
     info->screen = pParams->device->screen;
     info->target = PIPE_TEXTURE_3D;
     info->format = d3d9_to_pipe_format(Format);
@@ -83,8 +80,8 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This,
         return E_OUTOFMEMORY;
     This->base.pstype = 3;
 
-    hr = NineBaseTexture9_ctor(&This->base, pParams,
-                               D3DRTYPE_VOLUMETEXTURE, Pool);
+    hr = NineBaseTexture9_ctor(&This->base, pParams, NULL,
+                               D3DRTYPE_VOLUMETEXTURE, Format, Pool, Usage);
     if (FAILED(hr))
         return hr;
 
-- 
2.1.3



More information about the mesa-stable mailing list