Commit 5b2d1710 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Add a separate function for d3d9 initialization.

parent 372984e0
......@@ -33,40 +33,52 @@ void WINAPI DebugSetMute(void) {
/* nothing to do */
}
IDirect3D9* WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT SDKVersion) {
IDirect3D9Impl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl));
object->IDirect3D9Ex_iface.lpVtbl = &Direct3D9_Vtbl;
object->ref = 1;
IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
{
IDirect3D9Impl *object;
wined3d_mutex_lock();
object->WineD3D = wined3d_create(9, 0);
wined3d_mutex_unlock();
TRACE("sdk_version %#x.\n", sdk_version);
TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
{
ERR("Failed to allocate d3d9 object memory.\n");
return NULL;
}
if (!object->WineD3D)
if (!d3d9_init(object, FALSE))
{
HeapFree( GetProcessHeap(), 0, object );
object = NULL;
WARN("Failed to initialize d3d9.\n");
HeapFree(GetProcessHeap(), 0, object);
return NULL;
}
return (IDirect3D9*) object;
TRACE("Created d3d9 object %p.\n", object);
return (IDirect3D9 *)&object->IDirect3D9Ex_iface;
}
HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **direct3d9ex) {
IDirect3D9 *ret;
IDirect3D9Impl* object;
HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
{
IDirect3D9Impl *object;
TRACE("Calling Direct3DCreate9\n");
ret = Direct3DCreate9(SDKVersion);
if(!ret) {
*direct3d9ex = NULL;
TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
{
ERR("Failed to allocate d3d9 object memory.\n");
return E_OUTOFMEMORY;
}
if (!d3d9_init(object, TRUE))
{
WARN("Failed to initialize d3d9.\n");
HeapFree(GetProcessHeap(), 0, object);
return D3DERR_NOTAVAILABLE;
}
object = (IDirect3D9Impl *) ret;
object->extended = TRUE; /* Enables QI for extended interfaces */
*direct3d9ex = &object->IDirect3D9Ex_iface;
TRACE("Created d3d9 object %p.\n", object);
*d3d9ex = &object->IDirect3D9Ex_iface;
return D3D_OK;
}
......
......@@ -127,19 +127,6 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_H
_pD3D9Caps->MaxVertexShader30InstructionSlots = _pWineCaps->MaxVertexShader30InstructionSlots; \
_pD3D9Caps->MaxPixelShader30InstructionSlots = _pWineCaps->MaxPixelShader30InstructionSlots;
/* ===========================================================================
D3D9 interfaces
=========================================================================== */
/* ---------- */
/* IDirect3D9 */
/* ---------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3D9ExVtbl Direct3D9_Vtbl DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirect3D implementation structure
*/
......@@ -155,6 +142,7 @@ typedef struct IDirect3D9Impl
BOOL extended;
} IDirect3D9Impl;
BOOL d3d9_init(IDirect3D9Impl *d3d9, BOOL extended) DECLSPEC_HIDDEN;
void filter_caps(D3DCAPS9* pCaps) DECLSPEC_HIDDEN;
struct fvf_declaration
......
......@@ -551,8 +551,7 @@ static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT
return hr;
}
const IDirect3D9ExVtbl Direct3D9_Vtbl =
static const struct IDirect3D9ExVtbl Direct3D9_Vtbl =
{
/* IUnknown */
IDirect3D9Impl_QueryInterface,
......@@ -581,3 +580,18 @@ const IDirect3D9ExVtbl Direct3D9_Vtbl =
IDirect3D9ExImpl_GetAdapterLUID
};
BOOL d3d9_init(IDirect3D9Impl *d3d9, BOOL extended)
{
d3d9->IDirect3D9Ex_iface.lpVtbl = &Direct3D9_Vtbl;
d3d9->ref = 1;
wined3d_mutex_lock();
d3d9->WineD3D = wined3d_create(9, 0);
wined3d_mutex_unlock();
if (!d3d9->WineD3D)
return FALSE;
d3d9->extended = extended;
return TRUE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment