mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 10:08:08 +02:00
st/nine: Rework Basetexture9 and Resource9.
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>
This commit is contained in:
parent
104b5a8193
commit
133b2087c5
10 changed files with 36 additions and 33 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue