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.

131 lines
5.4 KiB

  1. #ifndef __MSPSGP_H_
  2. #define __MSPSGP_H_
  3. /*==========================================================================;
  4. *
  5. * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  6. *
  7. * File: mspsgp.h
  8. * Content: Defines for Microsoft's PSPG implementation
  9. *
  10. ***************************************************************************/
  11. #include "vvm.h"
  12. // DEBUG_PIPELINE is defined to check performance and to allow to choose
  13. // diifferent paths in the geometry pipeline
  14. // Undefine DEBUG_PIPELINE for final
  15. //#define DEBUG_PIPELINE
  16. #ifdef DEBUG_PIPELINE
  17. const DWORD __DEBUG_NORENDERING = 1; // Disable writing drawing command to the command buffer
  18. const DWORD __DEBUG_ONEPASS = 2; // Disable clip and light in one pass
  19. const DWORD __DEBUG_MODELSPACE = 4; // Disable lighting in model space
  20. #endif
  21. //---------------------------------------------------------------------
  22. // Returns TRUE if cipping is needed
  23. //
  24. inline BOOL CheckIfNeedClipping(LPD3DFE_PROCESSVERTICES pv)
  25. {
  26. if (pv->dwDeviceFlags & D3DDEV_GUARDBAND)
  27. {
  28. if (pv->dwClipUnion & ~__D3DCS_INGUARDBAND)
  29. return TRUE;
  30. }
  31. else
  32. if (pv->dwClipUnion)
  33. return TRUE;
  34. return FALSE;
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Direct3D default implementation of PVFUNCS
  38. //
  39. class D3DFE_PVFUNCSI : public ID3DFE_PVFUNCS
  40. {
  41. public:
  42. DWORD ProcessVertices(LPD3DFE_PROCESSVERTICES);
  43. HRESULT ProcessPrimitive(LPD3DFE_PROCESSVERTICES);
  44. HRESULT ProcessIndexedPrimitive(LPD3DFE_PROCESSVERTICES);
  45. int ClipSingleTriangle(D3DFE_PROCESSVERTICES *pv,
  46. ClipTriangle *tri,
  47. ClipVertex ***clipVertexPointer);
  48. HRESULT DoDrawIndexedPrimitive(LPD3DFE_PROCESSVERTICES pv);
  49. HRESULT DoDrawPrimitive(LPD3DFE_PROCESSVERTICES pv);
  50. HRESULT ProcessLineList(D3DFE_PROCESSVERTICES *pv);
  51. HRESULT ProcessLineStrip(D3DFE_PROCESSVERTICES *pv);
  52. DWORD ProcessVerticesVVM(LPD3DFE_PROCESSVERTICES pv);
  53. HRESULT CreateShader(CVElement* pElements, DWORD dwNumElements,
  54. DWORD* pdwShaderCode, DWORD dwOutputFVF,
  55. CPSGPShader** ppPSGPShader);
  56. HRESULT SetActiveShader(CPSGPShader* pPSGPShader);
  57. HRESULT LoadShaderConstants(DWORD start, DWORD count, LPVOID buffer);
  58. HRESULT GetShaderConstants(DWORD start, DWORD count, LPVOID buffer);
  59. HRESULT SetOutputFVF(DWORD dwFVF) {return D3D_OK;}
  60. HRESULT ProcessTriangleList(LPD3DFE_PROCESSVERTICES);
  61. HRESULT ProcessTriangleFan(LPD3DFE_PROCESSVERTICES);
  62. HRESULT ProcessTriangleStrip(LPD3DFE_PROCESSVERTICES);
  63. HRESULT Clip(D3DFE_PROCESSVERTICES *pv, ClipVertex *cv1,
  64. ClipVertex *cv2,
  65. ClipVertex *cv3);
  66. int ClipSingleLine(D3DFE_PROCESSVERTICES *pv, ClipTriangle *line);
  67. HRESULT ProcessClippedTriangleFan(D3DFE_PROCESSVERTICES *pv);
  68. HRESULT ProcessClippedIndexedTriangleFan(D3DFE_PROCESSVERTICES *pv);
  69. HRESULT ProcessClippedLine(D3DFE_PROCESSVERTICES *pv);
  70. HRESULT ProcessClippedTriangleList(D3DFE_PROCESSVERTICES *pv);
  71. HRESULT ProcessClippedTriangleStrip(D3DFE_PROCESSVERTICES *pv);
  72. HRESULT ProcessClippedIndexedTriangleList(D3DFE_PROCESSVERTICES *pv);
  73. HRESULT ProcessClippedIndexedTriangleStrip(D3DFE_PROCESSVERTICES *pv);
  74. HRESULT ProcessClippedIndexedLine(D3DFE_PROCESSVERTICES *pv);
  75. HRESULT ProcessClippedPoints(D3DFE_PROCESSVERTICES *pv);
  76. HRESULT ProcessClippedIndexedPoints(D3DFE_PROCESSVERTICES *pv);
  77. HRESULT ClipLine(D3DFE_PROCESSVERTICES *pv, ClipVertex *v1, ClipVertex *v2);
  78. CVertexVM m_VertexVM;
  79. };
  80. //-----------------------------------------------------------------------------
  81. // Does projected texture emulation
  82. // Parameters:
  83. // pOut - output texture coordinates
  84. // pIn - input texture coordinates
  85. // dwOutTexSize - size of output texture coordinates in bytes
  86. // Assumes that input texture coordinates have one float more than the output
  87. //
  88. inline void DoTextureProjection(float* pIn, float* pOut, DWORD dwOutTexSize)
  89. {
  90. UINT n = dwOutTexSize >> 2; // Number of output floats
  91. float w = 1.0f/pIn[n];
  92. for (UINT i=0; i < n; i++)
  93. {
  94. pOut[i] = pIn[i] * w;
  95. }
  96. }
  97. //-----------------------------------------------------------------------------
  98. inline void
  99. DoBlending(float blendFactor, D3DVECTOR* v1, D3DVECTOR* v2, D3DVECTOR* out)
  100. {
  101. out->x = v1->x + (v2->x - v1->x) * blendFactor;
  102. out->y = v1->y + (v2->y - v1->y) * blendFactor;
  103. out->z = v1->z + (v2->z - v1->z) * blendFactor;
  104. }
  105. //-----------------------------------------------------------------------------
  106. // Returns TRUE if we can do one pass transformation-lighting-clipping for
  107. // non-indexed primitives
  108. //
  109. inline BOOL DoOnePassPrimProcessing(D3DFE_PROCESSVERTICES* pv)
  110. {
  111. return ((pv->dwDeviceFlags & (D3DDEV_DONOTCLIP | D3DDEV_VERTEXSHADERS)) |
  112. (pv->dwFlags & (D3DPV_POSITION_TWEENING | D3DPV_NORMAL_TWEENING))) == 0;
  113. }
  114. //-----------------------------------------------------------------------------
  115. // Returns TRUE if we never read from the internal TL buffer
  116. //
  117. inline BOOL NeverReadFromTLBuffer(D3DFE_PROCESSVERTICES* pv)
  118. {
  119. return (pv->dwDeviceFlags & D3DDEV_DONOTCLIP) | DoOnePassPrimProcessing(pv);
  120. }
  121. #endif // __MSPSGP_H_