wined3d: Remove COM from the vertex declaration.

This commit is contained in:
Henri Verbeet 2011-02-02 20:22:50 +01:00 committed by Alexandre Julliard
parent 8ebff12b05
commit 5765632d9f
19 changed files with 81 additions and 110 deletions

View File

@ -1,6 +1,6 @@
MODULE = d3d10core.dll
IMPORTLIB = d3d10core
IMPORTS = dxguid uuid dxgi
IMPORTS = dxguid uuid dxgi wined3d
C_SRCS = \
async.c \

View File

@ -156,7 +156,7 @@ struct d3d10_input_layout
const struct ID3D10InputLayoutVtbl *vtbl;
LONG refcount;
IWineD3DVertexDeclaration *wined3d_decl;
struct wined3d_vertex_declaration *wined3d_decl;
};
HRESULT d3d10_input_layout_init(struct d3d10_input_layout *layout, struct d3d10_device *device,

View File

@ -131,7 +131,7 @@ static ULONG STDMETHODCALLTYPE d3d10_input_layout_AddRef(ID3D10InputLayout *ifac
if (refcount == 1)
{
IWineD3DVertexDeclaration_AddRef(This->wined3d_decl);
wined3d_vertex_declaration_incref(This->wined3d_decl);
}
return refcount;
@ -146,7 +146,7 @@ static ULONG STDMETHODCALLTYPE d3d10_input_layout_Release(ID3D10InputLayout *ifa
if (!refcount)
{
IWineD3DVertexDeclaration_Release(This->wined3d_decl);
wined3d_vertex_declaration_decref(This->wined3d_decl);
}
return refcount;

View File

@ -438,7 +438,7 @@ typedef struct {
DWORD *elements;
DWORD elements_size; /* Size of elements, in bytes */
IWineD3DVertexDeclaration *wined3d_vertex_declaration;
struct wined3d_vertex_declaration *wined3d_vertex_declaration;
DWORD shader_handle;
} IDirect3DVertexDeclaration8Impl;

View File

@ -2063,7 +2063,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(IDirect3DDevice8 *ifa
static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *iface, DWORD *ppShader)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IWineD3DVertexDeclaration *wined3d_declaration;
struct wined3d_vertex_declaration *wined3d_declaration;
IDirect3DVertexDeclaration8 *d3d8_declaration;
HRESULT hr;
@ -2086,8 +2086,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *ifa
return D3D_OK;
}
d3d8_declaration = IWineD3DVertexDeclaration_GetParent(wined3d_declaration);
IWineD3DVertexDeclaration_Release(wined3d_declaration);
d3d8_declaration = wined3d_vertex_declaration_get_parent(wined3d_declaration);
wined3d_vertex_declaration_decref(wined3d_declaration);
wined3d_mutex_unlock();
*ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;

View File

@ -53,7 +53,7 @@ static ULONG WINAPI IDirect3DVertexDeclaration8Impl_AddRef(IDirect3DVertexDeclar
if (ref_count == 1)
{
wined3d_mutex_lock();
IWineD3DVertexDeclaration_AddRef(This->wined3d_vertex_declaration);
wined3d_vertex_declaration_incref(This->wined3d_vertex_declaration);
wined3d_mutex_unlock();
}
@ -69,7 +69,7 @@ static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDecla
if (!ref_count) {
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
wined3d_vertex_declaration_decref(This->wined3d_vertex_declaration);
wined3d_mutex_unlock();
}

View File

@ -435,7 +435,7 @@ typedef struct IDirect3DVertexDeclaration9Impl {
UINT element_count;
/* IDirect3DVertexDeclaration9 fields */
IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
struct wined3d_vertex_declaration *wineD3DVertexDeclaration;
DWORD convFVF;
/* Parent reference */

View File

@ -2050,7 +2050,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9
static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface,
IDirect3DVertexDeclaration9 **declaration)
{
IWineD3DVertexDeclaration *wined3d_declaration = NULL;
struct wined3d_vertex_declaration *wined3d_declaration = NULL;
HRESULT hr;
TRACE("iface %p, declaration %p.\n", iface, declaration);
@ -2061,9 +2061,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9
hr = IWineD3DDevice_GetVertexDeclaration(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, &wined3d_declaration);
if (SUCCEEDED(hr) && wined3d_declaration)
{
*declaration = IWineD3DVertexDeclaration_GetParent(wined3d_declaration);
*declaration = wined3d_vertex_declaration_get_parent(wined3d_declaration);
IDirect3DVertexDeclaration9_AddRef(*declaration);
IWineD3DVertexDeclaration_Release(wined3d_declaration);
wined3d_vertex_declaration_decref(wined3d_declaration);
}
else
{

View File

@ -222,7 +222,7 @@ static ULONG WINAPI IDirect3DVertexDeclaration9Impl_AddRef(LPDIRECT3DVERTEXDECLA
if (!This->convFVF)
{
wined3d_mutex_lock();
IWineD3DVertexDeclaration_AddRef(This->wineD3DVertexDeclaration);
wined3d_vertex_declaration_incref(This->wineD3DVertexDeclaration);
wined3d_mutex_unlock();
}
}
@ -239,7 +239,7 @@ void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface)
}
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
wined3d_vertex_declaration_decref(This->wineD3DVertexDeclaration);
wined3d_mutex_unlock();
}

View File

@ -5638,14 +5638,13 @@ static const struct IDirect3DVtbl d3d1_vtbl =
* fvf: Fvf to find the decl for
*
* Returns:
* NULL in case of an error, the IWineD3DVertexDeclaration interface for the
* fvf otherwise.
* NULL in case of an error, the vertex declaration for the FVF otherwise.
*
*****************************************************************************/
IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf)
struct wined3d_vertex_declaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf)
{
struct wined3d_vertex_declaration *pDecl = NULL;
HRESULT hr;
IWineD3DVertexDeclaration* pDecl = NULL;
int p, low, high; /* deliberately signed */
struct FvfToDecl *convertedDecls = This->decls;
@ -5675,9 +5674,9 @@ IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf)
int grow = max(This->declArraySize / 2, 8);
convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
if(!convertedDecls) {
/* This will destroy it */
IWineD3DVertexDeclaration_Release(pDecl);
if (!convertedDecls)
{
wined3d_vertex_declaration_decref(pDecl);
return NULL;
}
This->decls = convertedDecls;

View File

@ -90,7 +90,7 @@ extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
struct FvfToDecl
{
DWORD fvf;
IWineD3DVertexDeclaration *decl;
struct wined3d_vertex_declaration *decl;
};
struct IDirectDrawImpl
@ -182,7 +182,7 @@ void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS *pIn, DDSCAPS2 *pOut) DECLSPEC_H
void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2 *pIn, DDDEVICEIDENTIFIER *pOut) DECLSPEC_HIDDEN;
HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf,
DDSURFACEDESC2 *desc, void *Context) DECLSPEC_HIDDEN;
IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf) DECLSPEC_HIDDEN;
struct wined3d_vertex_declaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf) DECLSPEC_HIDDEN;
/* The default surface type */
extern WINED3DSURFTYPE DefaultSurfaceType DECLSPEC_HIDDEN;
@ -579,7 +579,7 @@ struct IDirect3DVertexBufferImpl
/*** WineD3D and ddraw links ***/
IWineD3DBuffer *wineD3DVertexBuffer;
IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
struct wined3d_vertex_declaration *wineD3DVertexDeclaration;
IDirectDrawImpl *ddraw;
/*** Storage for D3D7 specific things ***/

View File

@ -366,9 +366,9 @@ static ULONG WINAPI ddraw_surface7_Release(IDirectDrawSurface7 *iface)
IWineD3DDevice_SetIndexBuffer(ddraw->wineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL);
IWineD3DDevice_SetVertexDeclaration(ddraw->wineD3DDevice, NULL);
for(i = 0; i < ddraw->numConvertedDecls; i++)
for (i = 0; i < ddraw->numConvertedDecls; ++i)
{
IWineD3DVertexDeclaration_Release(ddraw->decls[i].decl);
wined3d_vertex_declaration_decref(ddraw->decls[i].decl);
}
HeapFree(GetProcessHeap(), 0, ddraw->decls);
ddraw->numConvertedDecls = 0;

View File

@ -163,7 +163,7 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
IWineD3DBuffer_Release(curVB); /* For the GetStreamSource */
}
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
wined3d_vertex_declaration_decref(This->wineD3DVertexDeclaration);
IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs);
HeapFree(GetProcessHeap(), 0, This);
@ -595,7 +595,7 @@ HRESULT d3d_vertex_buffer_init(IDirect3DVertexBufferImpl *buffer,
return DDERR_INVALIDPARAMS;
}
IWineD3DVertexDeclaration_AddRef(buffer->wineD3DVertexDeclaration);
wined3d_vertex_declaration_incref(buffer->wineD3DVertexDeclaration);
LeaveCriticalSection(&ddraw_cs);

View File

@ -3296,8 +3296,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* if
TRACE("(%p) : pDecl=%p\n", This, pDecl);
if (pDecl) IWineD3DVertexDeclaration_AddRef(pDecl);
if (oldDecl) IWineD3DVertexDeclaration_Release(oldDecl);
if (pDecl)
wined3d_vertex_declaration_incref(pDecl);
if (oldDecl)
wined3d_vertex_declaration_decref(oldDecl);
This->updateStateBlock->state.vertex_declaration = (IWineD3DVertexDeclarationImpl *)pDecl;
This->updateStateBlock->changed.vertexDecl = TRUE;
@ -3321,7 +3323,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexDeclaration(IWineD3DDevice* if
TRACE("(%p) : ppDecl=%p\n", This, ppDecl);
*ppDecl = (IWineD3DVertexDeclaration *)This->stateBlock->state.vertex_declaration;
if (*ppDecl) IWineD3DVertexDeclaration_AddRef(*ppDecl);
if (*ppDecl)
wined3d_vertex_declaration_incref(*ppDecl);
return WINED3D_OK;
}

View File

@ -477,7 +477,7 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
int counter;
if (stateblock->state.vertex_declaration)
IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)stateblock->state.vertex_declaration);
wined3d_vertex_declaration_incref(stateblock->state.vertex_declaration);
for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++)
{
@ -729,9 +729,9 @@ HRESULT CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
stateblock->state.vertex_declaration, src_state->vertex_declaration);
if (src_state->vertex_declaration)
IWineD3DVertexDeclaration_AddRef((IWineD3DVertexDeclaration *)src_state->vertex_declaration);
wined3d_vertex_declaration_incref(src_state->vertex_declaration);
if (stateblock->state.vertex_declaration)
IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)stateblock->state.vertex_declaration);
wined3d_vertex_declaration_decref(stateblock->state.vertex_declaration);
stateblock->state.vertex_declaration = src_state->vertex_declaration;
}

View File

@ -37,53 +37,36 @@ static void dump_wined3dvertexelement(const WINED3DVERTEXELEMENT *element) {
TRACE(" usage_idx: %u\n", element->usage_idx);
}
/* *******************************************
IWineD3DVertexDeclaration IUnknown parts follow
******************************************* */
static HRESULT WINAPI IWineD3DVertexDeclarationImpl_QueryInterface(IWineD3DVertexDeclaration *iface, REFIID riid, LPVOID *ppobj)
ULONG CDECL wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration)
{
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IWineD3DVertexDeclaration)){
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
ULONG refcount = InterlockedIncrement(&declaration->ref);
TRACE("%p increasing refcount to %u.\n", declaration, refcount);
return refcount;
}
static ULONG WINAPI IWineD3DVertexDeclarationImpl_AddRef(IWineD3DVertexDeclaration *iface) {
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
TRACE("(%p) : AddRef increasing from %d\n", This, This->ref);
return InterlockedIncrement(&This->ref);
}
ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)
{
ULONG refcount = InterlockedDecrement(&declaration->ref);
static ULONG WINAPI IWineD3DVertexDeclarationImpl_Release(IWineD3DVertexDeclaration *iface) {
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (!ref)
TRACE("%p decreasing refcount to %u.\n", declaration, refcount);
if (!refcount)
{
HeapFree(GetProcessHeap(), 0, This->elements);
This->parent_ops->wined3d_object_destroyed(This->parent);
HeapFree(GetProcessHeap(), 0, This);
HeapFree(GetProcessHeap(), 0, declaration->elements);
declaration->parent_ops->wined3d_object_destroyed(declaration->parent);
HeapFree(GetProcessHeap(), 0, declaration);
}
return ref;
return refcount;
}
/* *******************************************
IWineD3DVertexDeclaration parts follow
******************************************* */
static void * WINAPI IWineD3DVertexDeclarationImpl_GetParent(IWineD3DVertexDeclaration *iface)
void * CDECL wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration)
{
TRACE("iface %p.\n", iface);
TRACE("declaration %p.\n", declaration);
return ((IWineD3DVertexDeclarationImpl *)iface)->parent;
return declaration->parent;
}
static BOOL declaration_element_valid_ffp(const WINED3DVERTEXELEMENT *element)
@ -174,16 +157,6 @@ static BOOL declaration_element_valid_ffp(const WINED3DVERTEXELEMENT *element)
}
}
static const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl =
{
/* IUnknown */
IWineD3DVertexDeclarationImpl_QueryInterface,
IWineD3DVertexDeclarationImpl_AddRef,
IWineD3DVertexDeclarationImpl_Release,
/* IWineD3DVertexDeclaration */
IWineD3DVertexDeclarationImpl_GetParent,
};
HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
const WINED3DVERTEXELEMENT *elements, UINT element_count,
void *parent, const struct wined3d_parent_ops *parent_ops)
@ -200,7 +173,6 @@ HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWine
}
}
declaration->lpVtbl = &IWineD3DVertexDeclaration_Vtbl;
declaration->ref = 1;
declaration->parent = parent;
declaration->parent_ops = parent_ops;

View File

@ -18,11 +18,15 @@
@ cdecl wined3d_get_device_caps(ptr long long ptr)
@ cdecl wined3d_get_parent(ptr)
@ cdecl wined3d_incref(ptr)
@ cdecl wined3d_register_software_device(ptr ptr);
@ cdecl wined3d_register_software_device(ptr ptr)
@ cdecl wined3d_device_create(ptr long long ptr long ptr ptr);
@ cdecl wined3d_device_create(ptr long long ptr long ptr ptr)
@ cdecl wined3d_stateblock_apply(ptr)
@ cdecl wined3d_stateblock_capture(ptr)
@ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_vertex_declaration_decref(ptr)
@ cdecl wined3d_vertex_declaration_get_parent(ptr)
@ cdecl wined3d_vertex_declaration_incref(ptr)

View File

@ -59,6 +59,8 @@ typedef struct IWineD3DSwapChainImpl IWineD3DSwapChainImpl;
struct IWineD3DBaseShaderImpl;
struct IWineD3DBaseTextureImpl;
struct IWineD3DResourceImpl;
typedef struct wined3d_vertex_declaration IWineD3DVertexDeclaration;
typedef struct wined3d_vertex_declaration IWineD3DVertexDeclarationImpl;
/* Texture format fixups */
@ -2296,10 +2298,6 @@ void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *surface, BYTE table[256][4], BO
BOOL palette9_changed(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
/*****************************************************************************
* IWineD3DVertexDeclaration implementation structure
*/
struct wined3d_vertex_declaration_element
{
const struct wined3d_format *format;
@ -2312,11 +2310,9 @@ struct wined3d_vertex_declaration_element
BYTE usage_idx;
};
typedef struct IWineD3DVertexDeclarationImpl {
/* IUnknown Information */
const IWineD3DVertexDeclarationVtbl *lpVtbl;
LONG ref;
struct wined3d_vertex_declaration
{
LONG ref;
void *parent;
const struct wined3d_parent_ops *parent_ops;
IWineD3DDeviceImpl *device;
@ -2328,7 +2324,7 @@ typedef struct IWineD3DVertexDeclarationImpl {
UINT num_streams;
BOOL position_transformed;
BOOL half_float_conv_needed;
} IWineD3DVertexDeclarationImpl;
};
HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
const WINED3DVERTEXELEMENT *elements, UINT element_count,

View File

@ -2112,6 +2112,7 @@ interface IWineD3DSwapChain;
interface IWineD3DDevice;
struct wined3d;
struct wined3d_stateblock;
struct wined3d_vertex_declaration;
[
object,
@ -2518,15 +2519,6 @@ interface IWineD3DVolumeTexture : IWineD3DBaseTexture
);
}
[
object,
local,
uuid(7cd55be6-6f30-11d9-c687-00046142c14f)
]
interface IWineD3DVertexDeclaration : IWineD3DBase
{
}
[
object,
local,
@ -2775,13 +2767,13 @@ interface IWineD3DDevice : IUnknown
[in] UINT element_count,
[in] void *parent,
[in] const struct wined3d_parent_ops *parent_ops,
[out] IWineD3DVertexDeclaration **declaration
[out] struct wined3d_vertex_declaration **declaration
);
HRESULT CreateVertexDeclarationFromFVF(
[in] DWORD fvf,
[in] void *parent,
[in] const struct wined3d_parent_ops *parent_ops,
[out] IWineD3DVertexDeclaration **declaration
[out] struct wined3d_vertex_declaration **declaration
);
HRESULT CreateVertexShader(
[in] const DWORD *function,
@ -3083,10 +3075,10 @@ interface IWineD3DDevice : IUnknown
[out] WINED3DMATRIX *matrix
);
HRESULT SetVertexDeclaration(
[in] IWineD3DVertexDeclaration *declaration
[in] struct wined3d_vertex_declaration *declaration
);
HRESULT GetVertexDeclaration(
[out] IWineD3DVertexDeclaration **declaration
[out] struct wined3d_vertex_declaration **declaration
);
HRESULT SetVertexShader(
[in] IWineD3DVertexShader *shader
@ -3141,7 +3133,7 @@ interface IWineD3DDevice : IUnknown
[in] UINT dst_idx,
[in] UINT vertex_count,
[in] IWineD3DBuffer *dest_buffer,
[in] IWineD3DVertexDeclaration *declaration,
[in] struct wined3d_vertex_declaration *declaration,
[in] DWORD flags,
[in] DWORD DestFVF
);
@ -3310,3 +3302,7 @@ HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateb
HRESULT __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration);
void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration);
ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration);