HRESULT APIENTRY WarpDdiCreateDevice(
HANDLE hAdapter,
D3DDDIARG_CREATEDEVICE *pDeviceData)
{
// DdiCreateDevice must not be NULL if this path hit
HRESULT ret = DdiCreateDevice(hAdapter, pDeviceData);
if (pDeviceData->pDeviceFuncs->pfnPresent && gDetourFuncTable.DdiPresent.isAttatched == FALSE)
{
DdiPresent = pDeviceData->pDeviceFuncs->pfnPresent;
ULONG_PTR realTramponLine = DetourDDiPresent();
gDetourFuncTable.DdiPresent.isAttatched = TRUE;
gDetourFuncTable.DdiPresent.preFuncPtr = DdiPresent;
gDetourFuncTable.DdiPresent.TrampoLinePtr = (PFND3DDDI_PRESENT)realTramponLine;
gDetourFuncTable.DdiPresent.warpFuncPtr = WarpDdiPresent;
}
if (pDeviceData->pDeviceFuncs->pfnPresent1 && gDetourFuncTable.DdiPresent1.isAttatched == FALSE)
{
DdiPresent1 = pDeviceData->pDeviceFuncs->pfnPresent1;
ULONG_PTR realTramponLine = DetourDDiPresent1();
gDetourFuncTable.DdiPresent1.isAttatched = TRUE;
gDetourFuncTable.DdiPresent1.preFuncPtr = DdiPresent1;
gDetourFuncTable.DdiPresent1.TrampoLinePtr = (PFND3DDDI_PRESENT1)realTramponLine;
gDetourFuncTable.DdiPresent1.warpFuncPtr = WarpDdiPresent1;
}
DdiLock = pDeviceData->pDeviceFuncs->pfnLock;
DdiCreateResource = pDeviceData->pDeviceFuncs->pfnCreateResource;
DdiCreateResource2 = pDeviceData->pDeviceFuncs->pfnCreateResource2;
DdiUnlock = pDeviceData->pDeviceFuncs->pfnUnlock;
DdiBlt = pDeviceData->pDeviceFuncs->pfnBlt;
return ret;
}
typedef struct _D3DDDIARG_CREATEDEVICE
{
HANDLE hDevice; // in: Runtime handle/out: Driver handle
UINT Interface; // in: Interface version
UINT Version; // in: Runtime Version
CONST D3DDDI_DEVICECALLBACKS* pCallbacks; // in: Pointer to runtime callbacks
VOID* pCommandBuffer; // in: Pointer to the first command buffer to use.
UINT CommandBufferSize; // in: Size of the first command buffer to use.
D3DDDI_ALLOCATIONLIST* pAllocationList; // out: Pointer to the first allocation list to use.
UINT AllocationListSize; // in: Size of the allocation list that will be available
// when the first command buffer is submitted.
D3DDDI_PATCHLOCATIONLIST* pPatchLocationList; // out: Pointer to the first patch location list to use.
UINT PatchLocationListSize; // in: Size of the patch location list that will be available
// when the first command buffer is submitted.
D3DDDI_DEVICEFUNCS* pDeviceFuncs; // out: Driver function table
D3DDDI_CREATEDEVICEFLAGS Flags; // in: Flags
#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WIN7)
D3DGPU_VIRTUAL_ADDRESS CommandBuffer; // out: GPU Virtual address to the command buffer to use. _ADVSCH_
#endif // D3D_UMD_INTERFACE_VERSION
} D3DDDIARG_CREATEDEVICE;