TRACE("%p increasing refcount to %u\n", This, refcount);
+ if (refcount == 1)
+ {
+ IWineD3DVertexDeclaration_AddRef(This->wined3d_decl);
+ }
+
return refcount;
}
if (!refcount)
{
IWineD3DVertexDeclaration_Release(This->wined3d_decl);
- HeapFree(GetProcessHeap(), 0, This);
}
return refcount;
d3d10_input_layout_SetPrivateDataInterface,
};
+static void STDMETHODCALLTYPE d3d10_input_layout_wined3d_object_destroyed(void *parent)
+{
+ HeapFree(GetProcessHeap(), 0, parent);
+}
+
+static const struct wined3d_parent_ops d3d10_input_layout_wined3d_parent_ops =
+{
+ d3d10_input_layout_wined3d_object_destroyed,
+};
+
HRESULT d3d10_input_layout_init(struct d3d10_input_layout *layout, struct d3d10_device *device,
const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
const void *shader_byte_code, SIZE_T shader_byte_code_length)
}
hr = IWineD3DDevice_CreateVertexDeclaration(device->wined3d_device, &layout->wined3d_decl,
- (IUnknown *)layout, wined3d_elements, wined3d_element_count);
+ (IUnknown *)layout, &d3d10_input_layout_wined3d_parent_ops, wined3d_elements, wined3d_element_count);
HeapFree(GetProcessHeap(), 0, wined3d_elements);
if (FAILED(hr))
{
ULONG ref_count = InterlockedIncrement(&This->ref_count);
TRACE("(%p) : AddRef increasing to %d\n", This, ref_count);
+ if (ref_count == 1)
+ {
+ wined3d_mutex_lock();
+ IWineD3DVertexDeclaration_AddRef(This->wined3d_vertex_declaration);
+ wined3d_mutex_unlock();
+ }
+
return ref_count;
}
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
wined3d_mutex_unlock();
-
- HeapFree(GetProcessHeap(), 0, This->elements);
- HeapFree(GetProcessHeap(), 0, This);
}
return ref_count;
IDirect3DVertexDeclaration8Impl_Release
};
+static void STDMETHODCALLTYPE d3d8_vertexdeclaration_wined3d_object_destroyed(void *parent)
+{
+ IDirect3DVertexDeclaration8Impl *declaration = parent;
+ HeapFree(GetProcessHeap(), 0, declaration->elements);
+ HeapFree(GetProcessHeap(), 0, declaration);
+}
+
+static const struct wined3d_parent_ops d3d8_vertexdeclaration_wined3d_parent_ops =
+{
+ d3d8_vertexdeclaration_wined3d_object_destroyed,
+};
+
HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration8Impl *declaration,
IDirect3DDevice8Impl *device, const DWORD *elements)
{
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, &declaration->wined3d_vertex_declaration,
- (IUnknown *)declaration, wined3d_elements, wined3d_element_count);
+ (IUnknown *)declaration, &d3d8_vertexdeclaration_wined3d_parent_ops,
+ wined3d_elements, wined3d_element_count);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
if (FAILED(hr))
declaration->shader_handle = fvf;
hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(device->WineD3DDevice,
- &declaration->wined3d_vertex_declaration, (IUnknown *)declaration, fvf);
+ &declaration->wined3d_vertex_declaration, (IUnknown *)declaration,
+ &d3d8_vertexdeclaration_wined3d_parent_ops, fvf);
if (FAILED(hr))
{
WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr);
if(ref == 1) {
IDirect3DDevice9Ex_AddRef(This->parentDevice);
+ if (!This->convFVF)
+ {
+ wined3d_mutex_lock();
+ IWineD3DVertexDeclaration_AddRef(This->wineD3DVertexDeclaration);
+ wined3d_mutex_unlock();
+ }
}
return ref;
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
wined3d_mutex_unlock();
-
- HeapFree(GetProcessHeap(), 0, This->elements);
- HeapFree(GetProcessHeap(), 0, This);
}
static ULONG WINAPI IDirect3DVertexDeclaration9Impl_Release(LPDIRECT3DVERTEXDECLARATION9 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- IDirect3DDevice9Ex *parentDevice = This->parentDevice;
-
+ IDirect3DDevice9Ex_Release(This->parentDevice);
if(!This->convFVF) {
IDirect3DVertexDeclaration9Impl_Destroy(iface);
}
- IDirect3DDevice9Ex_Release(parentDevice);
}
return ref;
}
IDirect3DVertexDeclaration9Impl_GetDeclaration
};
+static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed(void *parent)
+{
+ IDirect3DVertexDeclaration9Impl *declaration = parent;
+ HeapFree(GetProcessHeap(), 0, declaration->elements);
+ HeapFree(GetProcessHeap(), 0, declaration);
+}
+
+static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops =
+{
+ d3d9_vertexdeclaration_wined3d_object_destroyed,
+};
+
static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9* d3d9_elements,
WINED3DVERTEXELEMENT **wined3d_elements, UINT *element_count)
{
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, &declaration->wineD3DVertexDeclaration,
- (IUnknown *)declaration, wined3d_elements, wined3d_element_count);
+ (IUnknown *)declaration, &d3d9_vertexdeclaration_wined3d_parent_ops,
+ wined3d_elements, wined3d_element_count);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
if (FAILED(hr))
}
TRACE("not found. Creating and inserting at position %d.\n", low);
- hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(This->wineD3DDevice, &pDecl, (IUnknown *)This, fvf);
+ hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(This->wineD3DDevice, &pDecl,
+ (IUnknown *)This, &ddraw_null_wined3d_parent_ops, fvf);
if (hr != S_OK) return NULL;
if(This->declArraySize == This->numConvertedDecls) {
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice *iface,
- IWineD3DVertexDeclaration **declaration, IUnknown *parent,
+ IWineD3DVertexDeclaration **declaration, IUnknown *parent, const struct wined3d_parent_ops *parent_ops,
const WINED3DVERTEXELEMENT *elements, UINT element_count)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
return E_OUTOFMEMORY;
}
- hr = vertexdeclaration_init(object, This, elements, element_count, parent);
+ hr = vertexdeclaration_init(object, This, elements, element_count, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF(IWineD3DDevice *iface,
- IWineD3DVertexDeclaration **declaration, IUnknown *parent, DWORD fvf)
+ IWineD3DVertexDeclaration **declaration, IUnknown *parent,
+ const struct wined3d_parent_ops *parent_ops, DWORD fvf)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
WINED3DVERTEXELEMENT *elements;
size = ConvertFvfToDeclaration(This, fvf, &elements);
if (size == ~0U) return E_OUTOFMEMORY;
- hr = IWineD3DDevice_CreateVertexDeclaration(iface, declaration, parent, elements, size);
+ hr = IWineD3DDevice_CreateVertexDeclaration(iface, declaration, parent, parent_ops, elements, size);
HeapFree(GetProcessHeap(), 0, elements);
return hr;
}
}
HeapFree(GetProcessHeap(), 0, This->elements);
+ This->parent_ops->wined3d_object_destroyed(This->parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
};
HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
- const WINED3DVERTEXELEMENT *elements, UINT element_count, IUnknown *parent)
+ const WINED3DVERTEXELEMENT *elements, UINT element_count,
+ IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
WORD preloaded = 0; /* MAX_STREAMS, 16 */
declaration->lpVtbl = &IWineD3DVertexDeclaration_Vtbl;
declaration->ref = 1;
declaration->parent = parent;
+ declaration->parent_ops = parent_ops;
declaration->wineD3DDevice = device;
declaration->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*declaration->elements) * element_count);
if (!declaration->elements)
LONG ref;
IUnknown *parent;
+ const struct wined3d_parent_ops *parent_ops;
IWineD3DDeviceImpl *wineD3DDevice;
struct wined3d_vertex_declaration_element *elements;
BOOL half_float_conv_needed;
} IWineD3DVertexDeclarationImpl;
-HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *This, IWineD3DDeviceImpl *device,
- const WINED3DVERTEXELEMENT *elements, UINT element_count, IUnknown *parent) DECLSPEC_HIDDEN;
+HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
+ const WINED3DVERTEXELEMENT *elements, UINT element_count,
+ IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
/*****************************************************************************
* IWineD3DStateBlock implementation structure
HRESULT CreateVertexDeclaration(
[out] IWineD3DVertexDeclaration **declaration,
[in] IUnknown *parent,
+ [in] const struct wined3d_parent_ops *parent_ops,
[in] const WINED3DVERTEXELEMENT *elements,
[in] UINT element_count
);
HRESULT CreateVertexDeclarationFromFVF(
[out] IWineD3DVertexDeclaration **declaration,
[in] IUnknown *parent,
+ [in] const struct wined3d_parent_ops *parent_ops,
[in] DWORD fvf
);
HRESULT CreateVertexShader(