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.
 
 
 
 
 
 

190 lines
6.3 KiB

//-----------------------------------------------------------------------------
//
// This file contains texture addressing functions.
//
// Copyright (C) Microsoft Corporation, 1997.
//
// WARNING WARNING WARNING
// This cpp file generated from mcp file.
// EDIT THE MCP FILE.
// I warned you.
// WARNING WARNING WARNING
//
//-----------------------------------------------------------------------------
include(`m4hdr.mh')dnl
#include "pch.cpp"
#pragma hdrstop
#include "ctest_mh.h"
dnl
dnl d_StencilOp
dnl
dnl Macro to do stencil operation test routine
dnl
dnl $1 is one of STENCILFUNC
dnl returns new stencil value in uS
dnl
define(`d_StencilOp', `
switch($1)
{
case D3DSTENCILOP_KEEP:
uS = uSB;
break;
case D3DSTENCILOP_ZERO:
uS = 0;
break;
case D3DSTENCILOP_REPLACE:
uS = uSR;
break;
case D3DSTENCILOP_INCRSAT:
uS = min(uSB + 1, 0xff);
break;
case D3DSTENCILOP_DECRSAT:
uS = (UINT32)max((INT32)uSB - 1, 0x00);
break;
case D3DSTENCILOP_INVERT:
uS = ~uSB;
break;
case D3DSTENCILOP_INCR:
uS = uSB + 1;
break;
case D3DSTENCILOP_DECR:
uS = uSB - 1;
break;
}
// do write mask, do not let stencil mess up Z bits
uS &= pCtx->pdwRenderState[D3DRENDERSTATE_STENCILWRITEMASK];
uSB &= ~(pCtx->pdwRenderState[D3DRENDERSTATE_STENCILWRITEMASK]);
uS |= uSB;
uS &= 0xff;
')dnl
dnl
dnl
dnl d_Test
dnl
dnl Macro to build test routine
dnl
dnl $1 is one of 16 32
dnl $2 is one of ZWrite NoZWrite (D3DRENDERSTATE_ZWRITEENABLE)
dnl $3 is one of ZDeferred NoZDeferred (is there an alpha test bead)
dnl $4 is one of ZAll ZNeverAlways ZLessGreaterEqual ZEqualNotEqual ZGreaterLessEqual
dnl $5 is one of NoStencil Stencil
dnl
define(`d_Test', `
void C_Test_$1_$2_$3_$4_$5(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
PD3DI_RASTSPAN pS)
{
ifelse(eval((d_index(`$1', `16') == 0) && (d_index(`$5', `Stencil') == 0)), `1', `
D3D_WARN(0, "16 bit Z with stencil should never be called");
DDASSERT(0);
', eval((d_index(`$4', `ZAll') == 0) && (d_index(`$5', `NoStencil') == 0)), `1', `
D3D_WARN(0, "ZAll AND NoStencil, more optimal code should be called");
DDASSERT(0);
', `
ifelse(`$1', `16', `
// 16 bit unsigned format
UINT16 uZ = (UINT16)(pS->uZ>>15);
UINT16 uZB = *((UINT16*)pS->pZ);', `
// 24S8 bit unsigned format
UINT32 uZ = pS->uZ;
UINT32 uZB = *((UINT32*)pS->pZ);
UINT32 uSB = uZB & 0xff;
ifelse(eval((d_index(`$4', `ZNeverAlways') == 0) && (d_index(`$5', `NoStencil') == 0)), `1', `', `
UINT32 uZBS = uZB >> 1;')')
pS->uZ += pP->iDZDX;
dnl
ifelse(`$5', `Stencil', `
uZ &= ~0x7f; // clear stencil region
uZBS &= ~0x7f;
uZB &= ~0xff;
UINT32 uS; // holds final stencil value
UINT32 uSR = pCtx->pdwRenderState[D3DRENDERSTATE_STENCILREF];
UINT32 uMask = pCtx->pdwRenderState[D3DRENDERSTATE_STENCILMASK];
pCtx->SI.bStencilPass = FALSE;
if (SCMP(pCtx, uSR&uMask, uSB&uMask))
{
if (ZCMP32(pCtx, uZ, uZBS))
{
// true only if should write RGB after potential alpha test
pCtx->SI.bStencilPass = TRUE;
d_StencilOp(pCtx->pdwRenderState[D3DRENDERSTATE_STENCILPASS])
ifelse(`$3', `NoZDeferred', `*((UINT32*)pS->pZ) = ifelse($2, `ZWrite', `(uZ<<1)', `uZB') | uS;',
`pCtx->SI.uZDeferred = ifelse($2, `ZWrite', `(uZ<<1)', `uZB') | uS;')
pCtx->pfnTestPassEnd(pCtx, pP, pS);
}
else
{
d_StencilOp(pCtx->pdwRenderState[D3DRENDERSTATE_STENCILZFAIL])
// write stencil only
ifelse(`$3', `NoZDeferred', `*((UINT32*)pS->pZ) = uZB | uS;',
`pCtx->SI.uZDeferred = uZB | uS;')
pCtx->pfnTestFailEnd(pCtx, pP, pS);
}
}
else
{
d_StencilOp(pCtx->pdwRenderState[D3DRENDERSTATE_STENCILFAIL])
// write stencil only
ifelse(`$3', `NoZDeferred', `*((UINT32*)pS->pZ) = uZB | uS;',
`pCtx->SI.uZDeferred = uZB | uS;')
pCtx->pfnTestFailEnd(pCtx, pP, pS);
}
', `
dnl
ifelse(eval((d_index(`$4', `ZNeverAlways') != 0) && (d_index(`$1', `16') != 0)), `1', `
uZ &= ~0x7f; // clear stencil bits so equal compare will work
uZBS &= ~0x7f;')
ifelse(`$4', `ZAll', `
ifelse(`$1', `16', `if (ZCMP16(pCtx, uZ, uZB))', `if (ZCMP32(pCtx, uZ, uZBS))')',
`$4', `ZNeverAlways', `
if (!(pCtx->iZXorMask))',
`$4', `ZLessGreaterEqual', `
// using bitwise XOR for logical op, OK since all bits of mask are set
if ((pCtx->iZXorMask)^(uZ >= ifelse(`$1', `16', `uZB', `uZBS')))',
`$4', `ZEqualNotEqual', `
if ((pCtx->iZXorMask)^(uZ != ifelse(`$1', `16', `uZB', `uZBS')))',
`$4', `ZGreaterLessEqual', `
if ((pCtx->iZXorMask)^(uZ > ifelse(`$1', `16', `uZB', `uZBS')))', `
#error Invalid arg to d_Test')
{
ifelse(`$3', `NoZDeferred',
`ifelse(`$1', `16',
`ifelse($2, `ZWrite',
`*((UINT16*)pS->pZ) = uZ;',
`//*((UINT16*)pS->pZ) = uZB; Done already')',
`ifelse($2, `ZWrite',
`*((UINT32*)pS->pZ) = (uZ<<1) | uSB;',
`*((UINT32*)pS->pZ) = uZB | uSB;')')',
`ifelse(`$1', `16',
`ifelse($2, `ZWrite',
`pCtx->SI.uZDeferred = uZ;',
`pCtx->SI.uZDeferred = uZB;')',
`ifelse($2, `ZWrite',
`pCtx->SI.uZDeferred = (uZ<<1) | uSB;',
`pCtx->SI.uZDeferred = uZB | uSB;')')')
pCtx->pfnTestPassEnd(pCtx, pP, pS);
}
else
{
ifelse(`$3', `ZDeferred', `pCtx->SI.uZDeferred = uZB;')
pCtx->pfnTestFailEnd(pCtx, pP, pS);
}
')')}')dnl
dnl
d_RepStr(`d_RepStr(`d_RepStr(`d_RepStr(`d_Test(AA, BB, CC, DD, NoStencil)',
`AA', `16', `32')',
`BB', `NoZWrite', `ZWrite')',
`CC', `NoZDeferred', `ZDeferred')',
`DD', `ZNeverAlways', `ZLessGreaterEqual', `ZEqualNotEqual', `ZGreaterLessEqual')
d_RepStr(`d_RepStr(`d_RepStr(`d_RepStr(`d_Test(AA, BB, CC, ZAll, DD)',
`AA', `16', `32')',
`BB', `NoZWrite', `ZWrite')',
`CC', `NoZDeferred', `ZDeferred')',
`DD', `NoStencil', `Stencil')