From 6c4774bbe4f259cf7af329ce6493d9b50310689f Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Tue, 26 Jan 2016 18:00:30 +0100 Subject: [PATCH] st/nine: Clean pSharedHandle Texture ctors checks Clarify the behaviour and clean the checks Signed-off-by: Axel Davy Reviewed-by: Patrick Rudolph --- .../state_trackers/nine/cubetexture9.c | 7 +++--- src/gallium/state_trackers/nine/texture9.c | 25 ++++++++++--------- .../state_trackers/nine/volumetexture9.c | 7 +++--- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c index c6fa397ef8e..1749190b38a 100644 --- a/src/gallium/state_trackers/nine/cubetexture9.c +++ b/src/gallium/state_trackers/nine/cubetexture9.c @@ -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; diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c index 73382156687..3052937311c 100644 --- a/src/gallium/state_trackers/nine/texture9.c +++ b/src/gallium/state_trackers/nine/texture9.c @@ -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) { diff --git a/src/gallium/state_trackers/nine/volumetexture9.c b/src/gallium/state_trackers/nine/volumetexture9.c index cdfe7f28198..cdec21fcb76 100644 --- a/src/gallium/state_trackers/nine/volumetexture9.c +++ b/src/gallium/state_trackers/nine/volumetexture9.c @@ -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) -- 2.30.2