st/nine: Clean pSharedHandle Texture ctors checks
authorAxel Davy <axel.davy@ens.fr>
Tue, 26 Jan 2016 17:00:30 +0000 (18:00 +0100)
committerAxel Davy <axel.davy@ens.fr>
Fri, 12 Feb 2016 22:26:36 +0000 (23:26 +0100)
Clarify the behaviour and clean the checks

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

index c6fa397ef8ece969333b47b9427abdaf00247630..1749190b38a2ccc3cd34fd2da3dbeaf6c2bb4f4a 100644 (file)
@@ -54,12 +54,13 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
         Format, Pool, pSharedHandle);
 
     user_assert(EdgeLength, D3DERR_INVALIDCALL);
-    user_assert(!pSharedHandle || Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
-    user_assert(!(Usage & D3DUSAGE_AUTOGENMIPMAP) ||
-                (Pool != D3DPOOL_SYSTEMMEM && Levels <= 1), D3DERR_INVALIDCALL);
 
+    /* user_assert(!pSharedHandle || Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL); */
     user_assert(!pSharedHandle, D3DERR_INVALIDCALL); /* TODO */
 
+    user_assert(!(Usage & D3DUSAGE_AUTOGENMIPMAP) ||
+                (Pool != D3DPOOL_SYSTEMMEM && Levels <= 1), D3DERR_INVALIDCALL);
+
     if (Usage & D3DUSAGE_AUTOGENMIPMAP)
         Levels = 0;
 
index 73382156687286534aa4b106cc15e8354294728e..3052937311c255523663449695db2234582a18de 100644 (file)
@@ -61,18 +61,22 @@ NineTexture9_ctor( struct NineTexture9 *This,
         d3dformat_to_string(Format), nine_D3DPOOL_to_str(Pool), pSharedHandle);
 
     user_assert(Width && Height, D3DERR_INVALIDCALL);
+
+    /* pSharedHandle: can be non-null for ex only.
+     * D3DPOOL_SYSTEMMEM: Levels must be 1
+     * D3DPOOL_DEFAULT: no restriction for Levels
+     * Other Pools are forbidden. */
     user_assert(!pSharedHandle || pParams->device->ex, D3DERR_INVALIDCALL);
-    /* When is used shared handle, Pool must be
-     * SYSTEMMEM with Levels 1 or DEFAULT with any Levels */
-    user_assert(!pSharedHandle || Pool != D3DPOOL_SYSTEMMEM || Levels == 1,
-                D3DERR_INVALIDCALL);
-    user_assert(!pSharedHandle || Pool == D3DPOOL_SYSTEMMEM || Pool == D3DPOOL_DEFAULT,
-                D3DERR_INVALIDCALL);
-    user_assert((Usage != D3DUSAGE_AUTOGENMIPMAP || Levels <= 1), D3DERR_INVALIDCALL);
+    user_assert(!pSharedHandle ||
+                (Pool == D3DPOOL_SYSTEMMEM && Levels == 1) ||
+                Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
+
     user_assert(!(Usage & D3DUSAGE_AUTOGENMIPMAP) ||
-                (Pool != D3DPOOL_SYSTEMMEM && Levels <= 1), D3DERR_INVALIDCALL);
+                (Pool != D3DPOOL_SYSTEMMEM && Pool != D3DPOOL_SCRATCH && Levels <= 1),
+                D3DERR_INVALIDCALL);
 
-    /* TODO: implement buffer sharing (should work with cross process too)
+    /* TODO: implement pSharedHandle for D3DPOOL_DEFAULT (cross process
+     * buffer sharing).
      *
      * Gem names may have fit but they're depreciated and won't work on render-nodes.
      * One solution is to use shm buffers. We would use a /dev/shm file, fill the first
@@ -85,9 +89,6 @@ NineTexture9_ctor( struct NineTexture9 *This,
      * invalid handle, that we would fail to import. Please note that we don't advertise
      * the flag indicating the support for that feature, but apps seem to not care.
      */
-    user_assert(!pSharedHandle ||
-                Pool == D3DPOOL_SYSTEMMEM ||
-                Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
 
     if (pSharedHandle && Pool == D3DPOOL_DEFAULT) {
         if (!*pSharedHandle) {
index cdfe7f281986b2ae32f503b771c299532d0846e6..cdec21fcb76534ee04d095680917ebab6aecb3bf 100644 (file)
@@ -49,14 +49,15 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This,
         Usage, Format, Pool, pSharedHandle);
 
     user_assert(Width && Height && Depth, D3DERR_INVALIDCALL);
-    user_assert(!pSharedHandle || Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
+
+    /* user_assert(!pSharedHandle || Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL); */
+    user_assert(!pSharedHandle, D3DERR_INVALIDCALL); /* TODO */
+
     /* An IDirect3DVolume9 cannot be bound as a render target can it ? */
     user_assert(!(Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)),
                 D3DERR_INVALIDCALL);
     user_assert(!(Usage & D3DUSAGE_AUTOGENMIPMAP), D3DERR_INVALIDCALL);
 
-    user_assert(!pSharedHandle, D3DERR_INVALIDCALL); /* TODO */
-
     pf = d3d9_to_pipe_format_checked(screen, Format, PIPE_TEXTURE_3D, 0,
                                      PIPE_BIND_SAMPLER_VIEW, FALSE);
     if (pf == PIPE_FORMAT_NONE)