📄 d3dminit.c
字号:
/******************************************************************************
<module>
* Name : D3DM_Init.c
* Title : D3DM Callbacks
* Author(s) : Imagination Technologies
* Created : 2 March 2004
*
* Copyright : 2004 by Imagination Technologies Limited.
* All rights reserved. No part of this software, either
* material or conceptual may be copied or distributed,
* transmitted, transcribed, stored in a retrieval system
* or translated into any human or computer language in any
* form by any means, electronic, mechanical, manual or
* other-wise, or disclosed to third parties without the
* express written permission of Imagination Technologies
* Limited, Unit 8, HomePark Industrial Estate,
* King's Langley, Hertfordshire, WD4 8LZ, U.K.
*
* Description : Entry Points for D3DMobile initialisation and info functions.
*
* Platform : Windows CE
*
</module>
********************************************************************************/
#include "context.h"
/* ---------------------------------------------------------------------------
External Callback Prototypes
------------------------------------------------------------------------------*/
DWORD PVRD3DM_CreateContext(D3DM_CREATECONTEXT_DATA *pccd);
DWORD PVRD3DM_DestroyContext(D3DM_DESTROYCONTEXT_DATA *pdcd);
DWORD PVRD3DM_CreateSurface(D3DM_CREATESURFACE_DATA *pcsd);
DWORD PVRD3DM_DestroySurface(D3DM_DESTROYSURFACE_DATA *pdsd);
DWORD PVRD3DM_LockSurface(D3DM_LOCKSURFACE_DATA *plsd);
DWORD PVRD3DM_UnlockSurface(D3DM_UNLOCKSURFACE_DATA *pusd);
DWORD PVRD3DM_DrawPrimitive(D3DM_DRAWPRIMITIVE_DATA *pdpd);
DWORD PVRD3DM_ResourceManager(D3DM_RESOURCEMANAGER_DATA *prmd);
/*----------------------------------------------------------------------------
<function>
FUNCTION: PVRD3DM_GetAdapterInfo
PURPOSE:
PARAMETERS: In:
RETURNS: D3DM_DRIVER_HANDLED || D3DM_DRIVER_NOTHANDLED
</function>
------------------------------------------------------------------------------*/
DWORD PVRD3DM_GetAdapterInfo(D3DM_GETADAPTERINFO_DATA *pgai)
{
D3DMADAPTER_IDENTIFIER* pID = pgai->pIdentifier;
DWORD i = 0;
PROFILE_START_FUNC(PVRD3DM_GET_ADAPTER_INFO);
pgai->rval = D3DM_OK;
if(pID != NULL)
{
IMG_UINT32 ui32MBXIDData;
/* Set up adapter identifier */
_tcscpy(pID->Driver, TEXT("PowerVR D3DMobile HAL"));
_tcscpy(pID->Description, TEXT("PowerVR D3DMobile HAL"));
#ifdef PROD_VERSION
pID->DriverVersion.HighPart = MAKELONG(PVER_LIB_MA, PVER_LIB_MAX);
pID->DriverVersion.LowPart = MAKELONG(PVER_LIB_MIN, PVER_LIB_MI);
#else
pID->DriverVersion.HighPart = MAKELONG(FVER_LIB_MA, FVER_LIB_MAX);
pID->DriverVersion.LowPart = MAKELONG(FVER_LIB_MIN, FVER_LIB_MI);
#endif
ui32MBXIDData = GetMBXVersionInfo();
pID->VendorId = (ui32MBXIDData & MBX1_COMPANYID_MASK) >> MBX1_COMPANYID_SHIFT;
pID->DeviceId = (ui32MBXIDData & MBX1_VERSION_MAJOR_MASK) >> MBX1_VERSION_MAJOR_SHIFT;
pID->SubSysId = (ui32MBXIDData & MBX1_VERSION_MINOR_MASK) >> MBX1_VERSION_MINOR_SHIFT;
pID->Revision = (ui32MBXIDData & MBX1_VERSION_MAINT_MASK) >> MBX1_VERSION_MAINT_SHIFT;
pID->DeviceIdentifier = sDriverHWGUID;
/* Mod the GUID to embed hardware ID's */
pID->DeviceIdentifier.Data4[5] = pID->DeviceId;
pID->DeviceIdentifier.Data4[6] = pID->SubSysId;
pID->DeviceIdentifier.Data4[7] = pID->Revision;
}
/* Fill out caps */
if(pgai->pCaps != NULL)
{
*pgai->pCaps = sPVRD3DMCaps;
}
/* Fill in supported modes */
pgai->cDisplayMode = dwPVRNumSupportedDisplayModes;
if(pgai->pDisplayMode != NULL)
{
IMG_UINT32 ui32Angle = GetRotationAngle();
GetCurrentModeDetails();
for(i=0; i<dwPVRNumSupportedDisplayModes; i++)
{
pgai->pDisplayMode[i] = psPVRSupportedDisplayModes[i];
if(ui32Angle == 90 || ui32Angle == 270)
{
/* switch width and height */
pgai->pDisplayMode[i].Width = psPVRSupportedDisplayModes[i].Height;
pgai->pDisplayMode[i].Height = psPVRSupportedDisplayModes[i].Width;
}
}
}
pgai->nCurrentMode = 0;
/* Fill in supported formats */
pgai->nFormat = dwPVRNumSupportedFormats;
if(pgai->pFormat != NULL)
{
SetUpSupportedD3DMFormatList(pgai->pFormat);
}
/* Fill in supported multisample types */
pgai->nMultisample = dwPVRNumSupportedMultiSample;
if(pgai->pMultisample != NULL)
{
for(i=0; i<dwPVRNumSupportedMultiSample; i++)
{
pgai->pMultisample[i] = psPVRSupportedMultiSample[i];
}
}
/* Fill in supported D3DM Profiles */
pgai->nProfile = dwPVRNumSupportedProfiles;
if(pgai->pProfile)
{
for(i=0; i<dwPVRNumSupportedMultiSample; i++)
{
pgai->pProfile[i] = psPVRSupportedProfiles[i];
}
}
/* Fill in StretchRect format conversion types */
pgai->nConversionBytes = dwPVRNumSupportedFormatConversion;
if(pgai->pConversion)
{
BYTE *pSRConversions;
DWORD dwFmtConvSize = sizeof(D3DMFORMATCONVERSION) +
((STRETCH_RECT_DEST_CONV_FMT_COUNT - 1) * sizeof(D3DMFORMAT));
pSRConversions = (BYTE*) pgai->pConversion;
for(i=0; i<dwPVRNumSupportedFormatConversion; i++)
{
memcpy(pSRConversions, psPVRSupportedFormatConversion, dwFmtConvSize);
pSRConversions += dwFmtConvSize;
}
}
GetFBStats(&pgai->cTotalVRam, &pgai->cCurrentVRam);
PROFILE_STOP_FUNC(PVRD3DM_GET_ADAPTER_INFO);
return D3DM_DRIVER_HANDLED;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: PVRD3DM_ValidateDevice
PURPOSE:
PARAMETERS: In:
RETURNS: D3DM_DRIVER_HANDLED || D3DM_DRIVER_NOTHANDLED
</function>
------------------------------------------------------------------------------*/
DWORD PVRD3DM_ValidateDevice(D3DM_VALIDATEDEVICE_DATA *pvdd)
{
LPD3DM_CONTEXT psContext = (LPD3DM_CONTEXT) pvdd->nContextId;
PROFILE_START_FUNC(PVRD3DM_VALIDATE_DEVICE);
if(!psContext->psVertexSource)
{
pvdd->rval = D3DMERR_DRIVERINVALIDCALL;
goto Exit;
}
ValidateTextureStageState(pvdd);
Exit:
PROFILE_STOP_FUNC(PVRD3DM_VALIDATE_DEVICE);
return D3DM_DRIVER_HANDLED;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: PVRD3DM_GetInfo
PURPOSE:
PARAMETERS: In:
RETURNS: D3DM_DRIVER_HANDLED || D3DM_DRIVER_NOTHANDLED
</function>
------------------------------------------------------------------------------*/
DWORD PVRD3DM_GetInfo(D3DM_GETINFO_DATA *pgid)
{
return D3DM_DRIVER_NOTHANDLED;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: PVRD3DM_Initialize
PURPOSE: Driver initialisation entry point for D3D Mobile
PARAMETERS: In: pid - D3DM initialisation structure to be filled in by driver
RETURNS: D3DM_DRIVER_HANDLED
</function>
------------------------------------------------------------------------------*/
extern DWORD PVRD3DM_Initialize(D3DM_INITIALIZE_DATA *pid)
{
pid->pGetAdapterInfo = PVRD3DM_GetAdapterInfo;
pid->pCreateContext = PVRD3DM_CreateContext;
pid->pDestroyContext = PVRD3DM_DestroyContext;
pid->pCreateSurface = PVRD3DM_CreateSurface;
pid->pDestroySurface = PVRD3DM_DestroySurface;
pid->pLockSurface = PVRD3DM_LockSurface;
pid->pUnlockSurface = PVRD3DM_UnlockSurface;
pid->pDrawPrimitive = PVRD3DM_DrawPrimitive;
pid->pValidateDevice = PVRD3DM_ValidateDevice;
pid->pGetInfo = PVRD3DM_GetInfo;
pid->pResourceManager = PVRD3DM_ResourceManager;
return D3DM_DRIVER_HANDLED;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: DllMain
PURPOSE: Local dllmain for debug purposes
PARAMETERS:
RETURNS: D3DM_DRIVER_HANDLED
</function>
------------------------------------------------------------------------------*/
BOOL WINAPI DllMain (HANDLE hinstDLL,
DWORD dwReason,
LPVOID lpvReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
#if defined(DEBUG)
DEBUGREGISTER(hinstDLL);
#elif defined(D3DM_RETAIL_DBGOUT)
RETAILREGISTERZONES(hinstDLL);
#endif
}
break;
}
return TRUE;
}
/*****************************************************************************
End of file (D3DM_Init.c)
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -