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.

192 lines
9.0 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // rampold.cpp
  4. //
  5. // Entry points for DX3/DX5 ramp assembly routines.
  6. //
  7. // Copyright (C) Microsoft Corporation, 1997.
  8. //
  9. //----------------------------------------------------------------------------
  10. #include "pch.cpp"
  11. #pragma hdrstop
  12. #ifdef _X86_
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. void __cdecl RLDDIR8_FTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  17. void __cdecl RLDDIR8_FTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  18. void __cdecl RLDDIR8_FGTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  19. void __cdecl RLDDIR8_FPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  20. void __cdecl RLDDIR8_FGPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  21. void __cdecl RLDDIR8_GTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  22. void __cdecl RLDDIR8_GTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  23. void __cdecl RLDDIR8_GGTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  24. void __cdecl RLDDIR8_GPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  25. void __cdecl RLDDIR8_GGPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  26. void __cdecl RLDDIR8_FZTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  27. void __cdecl RLDDIR8_FZTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  28. void __cdecl RLDDIR8_FZGTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  29. void __cdecl RLDDIR8_FZPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  30. void __cdecl RLDDIR8_FZGPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  31. void __cdecl RLDDIR8_GZTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  32. void __cdecl RLDDIR8_GZTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  33. void __cdecl RLDDIR8_GZGTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  34. void __cdecl RLDDIR8_GZPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  35. void __cdecl RLDDIR8_GZGPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  36. void __cdecl RLDDIR16_FTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  37. void __cdecl RLDDIR16_FTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  38. void __cdecl RLDDIR16_FGTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  39. void __cdecl RLDDIR16_FPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  40. void __cdecl RLDDIR16_FGPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  41. void __cdecl RLDDIR16_GTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  42. void __cdecl RLDDIR16_GTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  43. void __cdecl RLDDIR16_GGTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  44. void __cdecl RLDDIR16_GPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  45. void __cdecl RLDDIR16_GGPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  46. void __cdecl RLDDIR16_FZTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  47. void __cdecl RLDDIR16_FZTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  48. void __cdecl RLDDIR16_FZGTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  49. void __cdecl RLDDIR16_FZPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  50. void __cdecl RLDDIR16_FZGPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  51. void __cdecl RLDDIR16_GZTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  52. void __cdecl RLDDIR16_GZTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  53. void __cdecl RLDDIR16_GZGTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  54. void __cdecl RLDDIR16_GZPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  55. void __cdecl RLDDIR16_GZGPTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  56. void __cdecl RLDDIR16_GZTTriangle(PD3DI_RASTCTX drv, D3DINSTRUCTION* ins, D3DTLVERTEX* lpTLVert, D3DTRIANGLE* tri);
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. //----------------------------------------------------------------------------
  61. //
  62. // RampOldTri
  63. //
  64. // Entry point for DX3/DX5 ramp assembly routines.
  65. //
  66. //----------------------------------------------------------------------------
  67. HRESULT RampOldTri(PD3DI_RASTCTX pCtx,
  68. LPD3DTLVERTEX pV0,
  69. LPD3DTLVERTEX pV1,
  70. LPD3DTLVERTEX pV2)
  71. {
  72. HRESULT hr;
  73. hr = D3D_OK;
  74. D3DINSTRUCTION ins;
  75. ins.bOpcode = D3DOP_TRIANGLE;
  76. ins.bSize = sizeof(D3DTRIANGLE);
  77. ins.wCount = 1;
  78. D3DTRIANGLE tri;
  79. tri.v1 = 0;
  80. tri.v2 = 1;
  81. tri.v3 = 2;
  82. D3DTLVERTEX TLVert[3];
  83. TLVert[0] = *pV0;
  84. TLVert[1] = *pV1;
  85. TLVert[2] = *pV2;
  86. // Lego Island fix
  87. // 0x3f7ffe00 == 1 - 2/0xffff or 2 Z units from the maximum Z. Integer math is faster
  88. // and doesn't cause FP lib linker issues with the assembly.
  89. INT32* pZ;
  90. pZ = (INT32*)&TLVert[0].sz;
  91. *pZ = (*pZ > 0x3f7ffe00) ? (0x3f7ffe00) : (*pZ);
  92. pZ = (INT32*)&TLVert[1].sz;
  93. *pZ = (*pZ > 0x3f7ffe00) ? (0x3f7ffe00) : (*pZ);
  94. pZ = (INT32*)&TLVert[2].sz;
  95. *pZ = (*pZ > 0x3f7ffe00) ? (0x3f7ffe00) : (*pZ);
  96. pCtx->pFillParams = &pCtx->FillParams;
  97. pCtx->pFillParams->dwWrapU = pCtx->pdwWrap[0] & D3DWRAP_U;
  98. pCtx->pFillParams->dwWrapV = pCtx->pdwWrap[0] & D3DWRAP_V;
  99. pCtx->pFillParams->dwCullCCW = (pCtx->pdwRenderState[D3DRENDERSTATE_CULLMODE] == D3DCULL_CCW);
  100. pCtx->pFillParams->dwCullCW = (pCtx->pdwRenderState[D3DRENDERSTATE_CULLMODE] == D3DCULL_CW);
  101. pCtx->pfnRampOld(pCtx, &ins, TLVert, &tri);
  102. return hr;
  103. }
  104. // resurrect this if DX5 ramp assembly must be called with a triangle list for performance
  105. // reasons.
  106. #if 0
  107. HRESULT RampOldTriList(PD3DI_RASTCTX pCtx, DWORD dwStride, D3DTLVERTEX* pVtx, WORD cPrims, D3DTRIANGLE* pTri)
  108. {
  109. HRESULT hr;
  110. hr = D3D_OK;
  111. D3DINSTRUCTION ins;
  112. ins.bOpcode = D3DOP_TRIANGLE;
  113. ins.bSize = sizeof(D3DTRIANGLE);
  114. ins.wCount = cPrims;
  115. DDASSERT(dwStride == sizeof(D3DTLVERTEX));
  116. pCtx->pFillParams = &pCtx->FillParams;
  117. pCtx->pFillParams->dwWrapU = pCtx->pdwWrap[0] & D3DWRAP_U;
  118. pCtx->pFillParams->dwWrapV = pCtx->pdwWrap[0] & D3DWRAP_V;
  119. pCtx->pFillParams->dwCullCCW = (pCtx->pdwRenderState[D3DRENDERSTATE_CULLMODE] == D3DCULL_CCW);
  120. pCtx->pFillParams->dwCullCW = (pCtx->pdwRenderState[D3DRENDERSTATE_CULLMODE] == D3DCULL_CW);
  121. pCtx->pfnRampOld(pCtx, &ins, pVtx, pTri);
  122. return hr;
  123. }
  124. #endif // RampOldTriList
  125. //
  126. // [ROB_DEPTH_NUM]
  127. // [ROB_RENDER_Z_NUM]
  128. // [ROB_RENDER_GOURAUD_NUM]
  129. // [ROB_RENDER_TEXTURE_NUM][ROB_RENDER_TRANS_NUM]
  130. RAMPOLDBEADS g_RampOld_BeadTbl =
  131. {
  132. RLDDIR8_FTriangle, NULL, RLDDIR8_FTTriangle, RLDDIR8_FGTTriangle, RLDDIR8_FPTriangle, RLDDIR8_FGPTriangle,
  133. RLDDIR8_GTriangle, NULL, RLDDIR8_GTTriangle, RLDDIR8_GGTTriangle, RLDDIR8_GPTriangle, RLDDIR8_GGPTriangle,
  134. RLDDIR8_FZTriangle, NULL, RLDDIR8_FZTTriangle, RLDDIR8_FZGTTriangle, RLDDIR8_FZPTriangle, RLDDIR8_FZGPTriangle,
  135. RLDDIR8_GZTriangle, NULL, RLDDIR8_GZTTriangle, RLDDIR8_GZGTTriangle, RLDDIR8_GZPTriangle, RLDDIR8_GZGPTriangle,
  136. RLDDIR16_FTriangle, NULL, RLDDIR16_FTTriangle, RLDDIR16_FGTTriangle, RLDDIR16_FPTriangle, RLDDIR16_FGPTriangle,
  137. RLDDIR16_GTriangle, NULL, RLDDIR16_GTTriangle, RLDDIR16_GGTTriangle, RLDDIR16_GPTriangle, RLDDIR16_GGPTriangle,
  138. RLDDIR16_FZTriangle, NULL, RLDDIR16_FZTTriangle, RLDDIR16_FZGTTriangle,RLDDIR16_FZPTriangle, RLDDIR16_FZGPTriangle,
  139. RLDDIR16_GZTriangle, NULL, RLDDIR16_GZTTriangle, RLDDIR16_GZGTTriangle,RLDDIR16_GZPTriangle, RLDDIR16_GZGPTriangle,
  140. };
  141. #else // _X86_
  142. HRESULT RampOldTri(PD3DI_RASTCTX pCtx,
  143. LPD3DTLVERTEX pV0,
  144. LPD3DTLVERTEX pV1,
  145. LPD3DTLVERTEX pV2)
  146. {
  147. return D3D_OK;
  148. }
  149. // since all ramp beads are NULL, will never call RampOldTri
  150. RAMPOLDBEADS g_RampOld_BeadTbl = { NULL };
  151. #endif // _X86_