d3d9: Add a separate function for d3d9 initialization.
This commit is contained in:
parent
372984e053
commit
5b2d171043
|
@ -33,40 +33,52 @@ void WINAPI DebugSetMute(void) {
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
}
|
}
|
||||||
|
|
||||||
IDirect3D9* WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT SDKVersion) {
|
IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
|
||||||
IDirect3D9Impl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl));
|
{
|
||||||
|
IDirect3D9Impl *object;
|
||||||
|
|
||||||
object->IDirect3D9Ex_iface.lpVtbl = &Direct3D9_Vtbl;
|
TRACE("sdk_version %#x.\n", sdk_version);
|
||||||
object->ref = 1;
|
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||||
object->WineD3D = wined3d_create(9, 0);
|
|
||||||
wined3d_mutex_unlock();
|
|
||||||
|
|
||||||
TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
|
|
||||||
|
|
||||||
if (!object->WineD3D)
|
|
||||||
{
|
{
|
||||||
HeapFree( GetProcessHeap(), 0, object );
|
ERR("Failed to allocate d3d9 object memory.\n");
|
||||||
object = NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (IDirect3D9*) object;
|
|
||||||
|
if (!d3d9_init(object, FALSE))
|
||||||
|
{
|
||||||
|
WARN("Failed to initialize d3d9.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Created d3d9 object %p.\n", object);
|
||||||
|
|
||||||
|
return (IDirect3D9 *)&object->IDirect3D9Ex_iface;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **direct3d9ex) {
|
HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
|
||||||
IDirect3D9 *ret;
|
{
|
||||||
IDirect3D9Impl* object;
|
IDirect3D9Impl *object;
|
||||||
|
|
||||||
TRACE("Calling Direct3DCreate9\n");
|
TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
|
||||||
ret = Direct3DCreate9(SDKVersion);
|
|
||||||
if(!ret) {
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||||
*direct3d9ex = NULL;
|
{
|
||||||
|
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;
|
return D3DERR_NOTAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
object = (IDirect3D9Impl *) ret;
|
TRACE("Created d3d9 object %p.\n", object);
|
||||||
object->extended = TRUE; /* Enables QI for extended interfaces */
|
*d3d9ex = &object->IDirect3D9Ex_iface;
|
||||||
*direct3d9ex = &object->IDirect3D9Ex_iface;
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,19 +127,6 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_H
|
||||||
_pD3D9Caps->MaxVertexShader30InstructionSlots = _pWineCaps->MaxVertexShader30InstructionSlots; \
|
_pD3D9Caps->MaxVertexShader30InstructionSlots = _pWineCaps->MaxVertexShader30InstructionSlots; \
|
||||||
_pD3D9Caps->MaxPixelShader30InstructionSlots = _pWineCaps->MaxPixelShader30InstructionSlots;
|
_pD3D9Caps->MaxPixelShader30InstructionSlots = _pWineCaps->MaxPixelShader30InstructionSlots;
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
D3D9 interfaces
|
|
||||||
=========================================================================== */
|
|
||||||
|
|
||||||
/* ---------- */
|
|
||||||
/* IDirect3D9 */
|
|
||||||
/* ---------- */
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* Predeclare the interface implementation structures
|
|
||||||
*/
|
|
||||||
extern const IDirect3D9ExVtbl Direct3D9_Vtbl DECLSPEC_HIDDEN;
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* IDirect3D implementation structure
|
* IDirect3D implementation structure
|
||||||
*/
|
*/
|
||||||
|
@ -155,6 +142,7 @@ typedef struct IDirect3D9Impl
|
||||||
BOOL extended;
|
BOOL extended;
|
||||||
} IDirect3D9Impl;
|
} IDirect3D9Impl;
|
||||||
|
|
||||||
|
BOOL d3d9_init(IDirect3D9Impl *d3d9, BOOL extended) DECLSPEC_HIDDEN;
|
||||||
void filter_caps(D3DCAPS9* pCaps) DECLSPEC_HIDDEN;
|
void filter_caps(D3DCAPS9* pCaps) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
struct fvf_declaration
|
struct fvf_declaration
|
||||||
|
|
|
@ -551,8 +551,7 @@ static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct IDirect3D9ExVtbl Direct3D9_Vtbl =
|
||||||
const IDirect3D9ExVtbl Direct3D9_Vtbl =
|
|
||||||
{
|
{
|
||||||
/* IUnknown */
|
/* IUnknown */
|
||||||
IDirect3D9Impl_QueryInterface,
|
IDirect3D9Impl_QueryInterface,
|
||||||
|
@ -581,3 +580,18 @@ const IDirect3D9ExVtbl Direct3D9_Vtbl =
|
||||||
IDirect3D9ExImpl_GetAdapterLUID
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue