Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

427 lines
15 KiB

//----------------------------------------------------------------------------
//
// nullif.mcp
//
// Null Device callback functions for D3DIM.
//
// Copyright (C) Microsoft Corporation, 1997.
//
//----------------------------------------------------------------------------
include(`m4hdr.mh')dnl
#include "pch.cpp"
#pragma hdrstop
// For BASE_VERTEX_COUNT and MAX_CLIP_VERTICES
#include "getcaps.h"
extern D3DDEVICEDESC g_nullDevDesc;
// give DX6 null device same caps as old DX6 reference device
static D3DDEVICEDESC RefDevDesc = { 0 };
static D3DHAL_D3DEXTENDEDCAPS RefExtCaps;
static void
FillOutDeviceCaps( void )
{
//
// set device description
//
RefDevDesc.dwSize = sizeof(RefDevDesc);
RefDevDesc.dwFlags =
D3DDD_COLORMODEL |
D3DDD_DEVCAPS |
D3DDD_TRANSFORMCAPS |
D3DDD_LIGHTINGCAPS |
D3DDD_BCLIPPING |
D3DDD_LINECAPS |
D3DDD_TRICAPS |
D3DDD_DEVICERENDERBITDEPTH |
D3DDD_DEVICEZBUFFERBITDEPTH |
D3DDD_MAXBUFFERSIZE |
D3DDD_MAXVERTEXCOUNT ;
RefDevDesc.dcmColorModel = D3DCOLOR_RGB;
RefDevDesc.dwDevCaps =
D3DDEVCAPS_FLOATTLVERTEX |
D3DDEVCAPS_EXECUTESYSTEMMEMORY |
D3DDEVCAPS_TLVERTEXSYSTEMMEMORY |
D3DDEVCAPS_TEXTURESYSTEMMEMORY |
D3DDEVCAPS_DRAWPRIMTLVERTEX ;
RefDevDesc.dtcTransformCaps.dwSize = sizeof(D3DTRANSFORMCAPS);
RefDevDesc.dtcTransformCaps.dwCaps = D3DTRANSFORMCAPS_CLIP;
RefDevDesc.bClipping = TRUE;
RefDevDesc.dlcLightingCaps.dwSize = sizeof(D3DLIGHTINGCAPS);
RefDevDesc.dlcLightingCaps.dwCaps =
D3DLIGHTCAPS_POINT |
D3DLIGHTCAPS_SPOT |
D3DLIGHTCAPS_DIRECTIONAL |
D3DLIGHTCAPS_PARALLELPOINT ;
RefDevDesc.dlcLightingCaps.dwLightingModel = D3DLIGHTINGMODEL_RGB;
RefDevDesc.dlcLightingCaps.dwNumLights = 0;
RefDevDesc.dpcTriCaps.dwSize = sizeof(D3DPRIMCAPS);
RefDevDesc.dpcTriCaps.dwMiscCaps =
D3DPMISCCAPS_CULLNONE |
D3DPMISCCAPS_CULLCW |
D3DPMISCCAPS_CULLCCW ;
RefDevDesc.dpcTriCaps.dwRasterCaps =
D3DPRASTERCAPS_DITHER |
// D3DPRASTERCAPS_ROP2 |
// D3DPRASTERCAPS_XOR |
// D3DPRASTERCAPS_PAT |
D3DPRASTERCAPS_ZTEST |
D3DPRASTERCAPS_SUBPIXEL |
D3DPRASTERCAPS_SUBPIXELX |
D3DPRASTERCAPS_FOGVERTEX |
D3DPRASTERCAPS_FOGTABLE |
// D3DPRASTERCAPS_STIPPLE |
// D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT |
D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT |
// D3DPRASTERCAPS_ANTIALIASEDGES |
D3DPRASTERCAPS_MIPMAPLODBIAS |
// D3DPRASTERCAPS_ZBIAS |
// D3DPRASTERCAPS_ZBUFFERLESSHSR |
D3DPRASTERCAPS_FOGRANGE |
D3DPRASTERCAPS_ANISOTROPY |
D3DPRASTERCAPS_WBUFFER |
D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT |
D3DPRASTERCAPS_WFOG;
RefDevDesc.dpcTriCaps.dwZCmpCaps =
D3DPCMPCAPS_NEVER |
D3DPCMPCAPS_LESS |
D3DPCMPCAPS_EQUAL |
D3DPCMPCAPS_LESSEQUAL |
D3DPCMPCAPS_GREATER |
D3DPCMPCAPS_NOTEQUAL |
D3DPCMPCAPS_GREATEREQUAL |
D3DPCMPCAPS_ALWAYS ;
RefDevDesc.dpcTriCaps.dwSrcBlendCaps =
D3DPBLENDCAPS_ZERO |
D3DPBLENDCAPS_ONE |
D3DPBLENDCAPS_SRCCOLOR |
D3DPBLENDCAPS_INVSRCCOLOR |
D3DPBLENDCAPS_SRCALPHA |
D3DPBLENDCAPS_INVSRCALPHA |
D3DPBLENDCAPS_DESTALPHA |
D3DPBLENDCAPS_INVDESTALPHA |
D3DPBLENDCAPS_DESTCOLOR |
D3DPBLENDCAPS_INVDESTCOLOR |
D3DPBLENDCAPS_SRCALPHASAT |
D3DPBLENDCAPS_BOTHSRCALPHA |
D3DPBLENDCAPS_BOTHINVSRCALPHA ;
RefDevDesc.dpcTriCaps.dwDestBlendCaps =
D3DPBLENDCAPS_ZERO |
D3DPBLENDCAPS_ONE |
D3DPBLENDCAPS_SRCCOLOR |
D3DPBLENDCAPS_INVSRCCOLOR |
D3DPBLENDCAPS_SRCALPHA |
D3DPBLENDCAPS_INVSRCALPHA |
D3DPBLENDCAPS_DESTALPHA |
D3DPBLENDCAPS_INVDESTALPHA |
D3DPBLENDCAPS_DESTCOLOR |
D3DPBLENDCAPS_INVDESTCOLOR |
D3DPBLENDCAPS_SRCALPHASAT ;
RefDevDesc.dpcTriCaps.dwAlphaCmpCaps =
RefDevDesc.dpcTriCaps.dwZCmpCaps;
RefDevDesc.dpcTriCaps.dwShadeCaps =
D3DPSHADECAPS_COLORFLATRGB |
D3DPSHADECAPS_COLORGOURAUDRGB |
D3DPSHADECAPS_SPECULARFLATRGB |
D3DPSHADECAPS_SPECULARGOURAUDRGB |
D3DPSHADECAPS_ALPHAFLATBLEND |
D3DPSHADECAPS_ALPHAGOURAUDBLEND |
D3DPSHADECAPS_FOGFLAT |
D3DPSHADECAPS_FOGGOURAUD ;
RefDevDesc.dpcTriCaps.dwTextureCaps =
D3DPTEXTURECAPS_PERSPECTIVE |
D3DPTEXTURECAPS_POW2 |
D3DPTEXTURECAPS_ALPHA |
D3DPTEXTURECAPS_TRANSPARENCY |
D3DPTEXTURECAPS_ALPHAPALETTE |
D3DPTEXTURECAPS_BORDER |
D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |
D3DPTEXTURECAPS_ALPHAPALETTE ;
RefDevDesc.dpcTriCaps.dwTextureFilterCaps =
D3DPTFILTERCAPS_NEAREST |
D3DPTFILTERCAPS_LINEAR |
D3DPTFILTERCAPS_MIPNEAREST |
D3DPTFILTERCAPS_MIPLINEAR |
D3DPTFILTERCAPS_LINEARMIPNEAREST |
D3DPTFILTERCAPS_LINEARMIPLINEAR |
D3DPTFILTERCAPS_MINFPOINT |
D3DPTFILTERCAPS_MINFLINEAR |
D3DPTFILTERCAPS_MINFANISOTROPIC |
D3DPTFILTERCAPS_MIPFPOINT |
D3DPTFILTERCAPS_MIPFLINEAR |
D3DPTFILTERCAPS_MAGFPOINT |
D3DPTFILTERCAPS_MAGFLINEAR |
D3DPTFILTERCAPS_MAGFANISOTROPIC ;
RefDevDesc.dpcTriCaps.dwTextureBlendCaps =
D3DPTBLENDCAPS_DECAL |
D3DPTBLENDCAPS_MODULATE |
D3DPTBLENDCAPS_DECALALPHA |
D3DPTBLENDCAPS_MODULATEALPHA |
// D3DPTBLENDCAPS_DECALMASK |
// D3DPTBLENDCAPS_MODULATEMASK |
D3DPTBLENDCAPS_COPY |
D3DPTBLENDCAPS_ADD ;
RefDevDesc.dpcTriCaps.dwTextureAddressCaps =
D3DPTADDRESSCAPS_WRAP |
D3DPTADDRESSCAPS_MIRROR |
D3DPTADDRESSCAPS_CLAMP |
D3DPTADDRESSCAPS_BORDER |
D3DPTADDRESSCAPS_INDEPENDENTUV ;
RefDevDesc.dpcTriCaps.dwStippleWidth = 0;
RefDevDesc.dpcTriCaps.dwStippleHeight = 0;
// line caps - copy tricaps and modify
memcpy( &RefDevDesc.dpcLineCaps, &RefDevDesc.dpcTriCaps, sizeof(D3DPRIMCAPS) );
RefDevDesc.dwDeviceRenderBitDepth = DDBD_16 | DDBD_24 | DDBD_32;
RefDevDesc.dwDeviceZBufferBitDepth = D3DSWRASTERIZER_ZBUFFERBITDEPTHFLAGS;
RefDevDesc.dwMaxBufferSize = 0;
RefDevDesc.dwMaxVertexCount = BASE_VERTEX_COUNT;
// DX5 stuff (should be in sync with the extended caps reported below)
RefDevDesc.dwMinTextureWidth = 1;
RefDevDesc.dwMaxTextureWidth = 4096;
RefDevDesc.dwMinTextureHeight = 1;
RefDevDesc.dwMaxTextureHeight = 4096;
RefDevDesc.dwMinStippleWidth = 0; // stipple unsupported
RefDevDesc.dwMaxStippleWidth = 0;
RefDevDesc.dwMinStippleHeight = 0;
RefDevDesc.dwMaxStippleHeight = 0;
//
// set extended caps
//
RefExtCaps.dwSize = sizeof(RefExtCaps);
RefExtCaps.dwMinTextureWidth = 1;
RefExtCaps.dwMaxTextureWidth = 4096;
RefExtCaps.dwMinTextureHeight = 1;
RefExtCaps.dwMaxTextureHeight = 4096;
RefExtCaps.dwMinStippleWidth = 0; // stipple unsupported
RefExtCaps.dwMaxStippleWidth = 0;
RefExtCaps.dwMinStippleHeight = 0;
RefExtCaps.dwMaxStippleHeight = 0;
RefExtCaps.dwMaxTextureRepeat = 32768;
RefExtCaps.dwMaxTextureAspectRatio = 0; // no limit
RefExtCaps.dwMaxAnisotropy = 16;
RefExtCaps.dvGuardBandLeft = -32768.f;
RefExtCaps.dvGuardBandTop = -32768.f;
RefExtCaps.dvGuardBandRight = 32767.f;
RefExtCaps.dvGuardBandBottom = 32767.f;
RefExtCaps.dvExtentsAdjust = 0.; // AA kernel is 1.0 x 1.0
RefExtCaps.dwStencilCaps =
D3DSTENCILCAPS_KEEP |
D3DSTENCILCAPS_ZERO |
D3DSTENCILCAPS_REPLACE|
D3DSTENCILCAPS_INCRSAT|
D3DSTENCILCAPS_DECRSAT|
D3DSTENCILCAPS_INVERT |
D3DSTENCILCAPS_INCR |
D3DSTENCILCAPS_DECR;
RefExtCaps.dwFVFCaps = 8; // max number of tex coord sets
RefExtCaps.dwTextureOpCaps =
D3DTEXOPCAPS_DISABLE |
D3DTEXOPCAPS_SELECTARG1 |
D3DTEXOPCAPS_SELECTARG2 |
D3DTEXOPCAPS_MODULATE |
D3DTEXOPCAPS_MODULATE2X |
D3DTEXOPCAPS_MODULATE4X |
D3DTEXOPCAPS_ADD |
D3DTEXOPCAPS_ADDSIGNED |
D3DTEXOPCAPS_ADDSIGNED2X |
D3DTEXOPCAPS_SUBTRACT |
D3DTEXOPCAPS_ADDSMOOTH |
D3DTEXOPCAPS_BLENDDIFFUSEALPHA |
D3DTEXOPCAPS_BLENDTEXTUREALPHA |
D3DTEXOPCAPS_BLENDFACTORALPHA |
D3DTEXOPCAPS_BLENDTEXTUREALPHAPM |
D3DTEXOPCAPS_BLENDCURRENTALPHA |
D3DTEXOPCAPS_PREMODULATE |
D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR |
D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR |
D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA |
D3DTEXOPCAPS_BUMPENVMAP |
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE |
D3DTEXOPCAPS_DOTPRODUCT3 ;
RefExtCaps.wMaxTextureBlendStages = 8;
RefExtCaps.wMaxSimultaneousTextures = 8;
}
static D3DHAL_GLOBALDRIVERDATA RefDriverData;
//----------------------------------------------------------------------------
//
// Null Device implementation section
//
//----------------------------------------------------------------------------
dnl
dnl Macro: NullFunc(fn_name)
dnl This macro generates a Null callback function
dnl Usage:
dnl NullFunc(ContextCreate) generates:
dnl
dnl //------------------------------------------------------------------------
dnl // NullDeviceContextCreate
dnl //------------------------------------------------------------------------
dnl DWORD __stdcall
dnl NullDeviceContextCreate(LPD3DHAL_CONTEXTCREATEDATA pCtxData)
dnl {
dnl pCtxData->ddrval = D3D_OK;
dnl return DDHAL_DRIVER_HANDLED;
dnl }
dnl
define(`Null_Func', `
//----------------------------------------------------------------------------
// NullDevice$1
//----------------------------------------------------------------------------
DWORD __stdcall
NullDevice$1(LPD3DHAL`_'d_UpCase($1)DATA pData)
{
pData->ddrval = D3D_OK;
return DDHAL_DRIVER_HANDLED;
}
')dnl
d_RepStr(`Null_Func(AA)', `AA',
`ContextCreate',
`ContextDestroy',
`SceneCapture',
`SetRenderTarget',
`DrawOneIndexedPrimitive',
`DrawOnePrimitive',
`DrawPrimitives',
`DrawPrimitives2',
`TextureCreate',
`TextureDestroy',
`TextureSwap',
`TextureGetSurf',
`RenderPrimitive',
`RenderState')dnl
//----------------------------------------------------------------------------
// NullDeviceValidateTextureStageState
//----------------------------------------------------------------------------
DWORD __stdcall
NullDeviceValidateTextureStageState(LPD3DHAL_VALIDATETEXTURESTAGESTATEDATA pData)
{
pData->dwNumPasses = 1;
pData->ddrval = D3D_OK;
return DDHAL_DRIVER_HANDLED;
}
//----------------------------------------------------------------------------
//
// NullDeviceHalProvider::GetCaps/GetInterface
//
// Returns the null device's HAL interface.
// RefRast's caps are reflected by this device. Only the actual callbacks
// are different.
//----------------------------------------------------------------------------
static D3DHAL_CALLBACKS NullCallbacks =
{
sizeof(D3DHAL_CALLBACKS),
NullDeviceContextCreate,
NullDeviceContextDestroy,
NULL,
NullDeviceSceneCapture,
NULL,
NULL,
NullDeviceRenderState,
NullDeviceRenderPrimitive,
NULL,
NullDeviceTextureCreate,
NullDeviceTextureDestroy,
NullDeviceTextureSwap,
NullDeviceTextureGetSurf,
// All others NULL.
};
static D3DHAL_CALLBACKS2 NullCallbacks2 =
{
sizeof(D3DHAL_CALLBACKS2),
D3DHAL2_CB32_SETRENDERTARGET |
D3DHAL2_CB32_DRAWONEPRIMITIVE |
D3DHAL2_CB32_DRAWONEINDEXEDPRIMITIVE |
D3DHAL2_CB32_DRAWPRIMITIVES,
NullDeviceSetRenderTarget,
NULL,
NullDeviceDrawOnePrimitive,
NullDeviceDrawOneIndexedPrimitive,
NullDeviceDrawPrimitives
};
static D3DHAL_CALLBACKS3 NullCallbacks3 =
{
sizeof(D3DHAL_CALLBACKS3),
D3DHAL3_CB32_VALIDATETEXTURESTAGESTATE |
D3DHAL3_CB32_DRAWPRIMITIVES2,
NULL, // Clear2
NULL, // lpvReserved
NullDeviceValidateTextureStageState,
NullDeviceDrawPrimitives2,
};
STDMETHODIMP
NullDeviceHalProvider::GetInterface(THIS_
LPDDRAWI_DIRECTDRAW_GBL pDdGbl,
LPD3DHALPROVIDER_INTERFACEDATA pInterfaceData,
DWORD dwVersion)
{
// fill out device description & extended caps (once)
if ( RefDevDesc.dwSize == 0 )
{
FillOutDeviceCaps();
D3DDeviceDescConvert(&RefDevDesc,NULL,&RefExtCaps); // add extended caps to RefDevDesc
}
// fill out GLOBALDRIVERDATA (initially zero)
RefDriverData.dwSize = sizeof(RefDriverData);
memcpy(&RefDriverData.hwCaps, &RefDevDesc, sizeof(RefDriverData.hwCaps));
RefDriverData.dwNumVertices = BASE_VERTEX_COUNT;
RefDriverData.dwNumClipVertices = MAX_CLIP_VERTICES;
RefDriverData.dwNumTextureFormats =
TextureFormats(&RefDriverData.lpTextureFormats, dwVersion, SW_RAST_REFNULL);
// set interface data for return
pInterfaceData->pGlobalData = &RefDriverData;
pInterfaceData->pExtCaps = &RefExtCaps;
pInterfaceData->pCallbacks = &NullCallbacks;
pInterfaceData->pCallbacks2 = &NullCallbacks2;
pInterfaceData->pCallbacks3 = &NullCallbacks3;
pInterfaceData->pfnRampService = NULL;
return S_OK;
}
STDMETHODIMP
NullDeviceHalProvider::GetCaps(THIS_
LPDDRAWI_DIRECTDRAW_GBL pDdGbl,
LPD3DDEVICEDESC pHwDesc,
LPD3DDEVICEDESC pHelDesc,
DWORD dwVersion)
{
*pHwDesc = g_nullDevDesc;
// fill out device description & extended caps (once)
if ( RefDevDesc.dwSize == 0 )
{
FillOutDeviceCaps();
D3DDeviceDescConvert(&RefDevDesc,NULL,&RefExtCaps); // add extended caps to RefDevDesc
}
*pHelDesc = RefDevDesc;
return D3D_OK;
}