st/nine: Rework Basetexture9 and Resource9.
authorAxel Davy <axel.davy@ens.fr>
Mon, 24 Nov 2014 23:38:02 +0000 (00:38 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 26 Nov 2014 20:09:10 +0000 (20:09 +0000)
Instead of having parts of the structures initialised by the parents,
have them initialised by the children.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/basetexture9.c
src/gallium/state_trackers/nine/basetexture9.h
src/gallium/state_trackers/nine/cubetexture9.c
src/gallium/state_trackers/nine/indexbuffer9.c
src/gallium/state_trackers/nine/resource9.c
src/gallium/state_trackers/nine/resource9.h
src/gallium/state_trackers/nine/surface9.c
src/gallium/state_trackers/nine/texture9.c
src/gallium/state_trackers/nine/vertexbuffer9.c
src/gallium/state_trackers/nine/volumetexture9.c

index 89f6269a742066c5f11577fc738e64d18aa05ad9..6d4159217990ffbeb491f5ccdceb1f5d03fa538f 100644 (file)
 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;
index d615376f09b10b9d103417317bbb79112ff78b05..006277104a069d020fd1b348ad875e82ac5d33de 100644 (file)
@@ -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 );
index 77802e70220d67c28520853544e556dff5748ef0..4f631620b9f56ede6654a31ad1f93ad7ffb5ad38 100644 (file)
@@ -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;
index c5606f1c757bf2919ffff65ec46406abaedfef7a..48553fd7451e07c1800363f8db1fd408815d2629 100644 (file)
@@ -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;
 
index 8f535580bbfe22630eae803db24a778115f0d17f..c82180be37c71b63611dc313e409a756baf132ed 100644 (file)
 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);
index 0451498a4bfa8da895758225ce786f62866b7969..d18f0cf2287321a3b798717198689df806921dd5 100644 (file)
@@ -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 );
index 42a9e05dabddc7a40352e49a046f694a4b2a9173..94b4d07a9005d1919e1d466ac3e140351070bb14 100644 (file)
@@ -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;
index c13268db9fd2492c67743d901ba67387a2aec150..e30f955aa0f68d2abff13ef2782417e99e237b28 100644 (file)
@@ -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;
index 6a57349e0dd9e09691c27caa3310143fd976dbcf..11cc60f5a514e460096e68e6f79c9643ca7920b1 100644 (file)
@@ -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;
 
index 65d320c6645ed00ebe09193d82474f1e13735256..a35d3f7917ad1e533316eab52e3911c712b8f8fb 100644 (file)
@@ -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;