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.

146 lines
4.0 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // refif.hpp
  4. //
  5. // Refrast front-end/rasterizer interface header.
  6. //
  7. // Copyright (C) Microsoft Corporation, 1997.
  8. //
  9. //----------------------------------------------------------------------------
  10. #ifndef _REFIF_HPP_
  11. #define _REFIF_HPP_
  12. // Vertex data is aligned on 32-byte boundaries.
  13. #define DP_VTX_ALIGN 32
  14. // Lock surfaces before rendering
  15. inline HRESULT LockSurface(LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl, LPVOID *ppData)
  16. {
  17. if (pDDSLcl)
  18. {
  19. if (!VIDEO_MEMORY(pDDSLcl))
  20. {
  21. if (SURFACE_LOCKED(pDDSLcl))
  22. return DDERR_SURFACEBUSY;
  23. *ppData = (LPVOID)SURFACE_MEMORY(pDDSLcl);
  24. return DD_OK;
  25. }
  26. else
  27. {
  28. HRESULT ddrval;
  29. do
  30. {
  31. ddrval = DDInternalLock(pDDSLcl, ppData);
  32. } while (ddrval == DDERR_WASSTILLDRAWING);
  33. return ddrval;
  34. }
  35. }
  36. return DD_OK;
  37. }
  38. // Unlock surfaces after rendering
  39. inline void UnlockSurface(LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl)
  40. {
  41. if (pDDSLcl && VIDEO_MEMORY(pDDSLcl))
  42. {
  43. DDInternalUnlock(pDDSLcl);
  44. }
  45. }
  46. HRESULT FASTCALL
  47. DoRendPoints(ReferenceRasterizer * pCtx,
  48. LPD3DINSTRUCTION pIns,
  49. LPD3DTLVERTEX pVtx,
  50. LPD3DPOINT pPt);
  51. HRESULT FASTCALL
  52. DoRendLines(ReferenceRasterizer * pCtx,
  53. LPD3DINSTRUCTION pIns,
  54. LPD3DTLVERTEX pVtx,
  55. LPD3DLINE pLine);
  56. HRESULT FASTCALL
  57. DoRendTriangles(ReferenceRasterizer *pCtx,
  58. LPD3DINSTRUCTION pIns,
  59. LPD3DTLVERTEX pVtx,
  60. LPD3DTRIANGLE pTri);
  61. HRESULT FASTCALL
  62. DoDrawPrimitives2(ReferenceRasterizer *pCtx,
  63. UINT16 dwStride,
  64. DWORD dwFvf,
  65. PUINT8 pVtx,
  66. DWORD dwNumVertices,
  67. LPD3DHAL_DP2COMMAND *ppCmd,
  68. LPDWORD lpdwRStates,
  69. BOOL bWireframe = FALSE
  70. );
  71. // Macros to check if a pointer is valid
  72. #if DBG
  73. // Validate context. pCtx should be declared before this macro
  74. // Type can be D3DContext or RefRast
  75. #define VALIDATE_CONTEXT(caller_name, data_ptr, pCtx, type) \
  76. { \
  77. if ((data_ptr) == NULL) \
  78. { \
  79. DPFM(0, DRV, ("in %s, data pointer = NULL", (caller_name))); \
  80. return DDHAL_DRIVER_HANDLED; \
  81. } \
  82. pCtx = (type)((data_ptr)->dwhContext); \
  83. if (!pCtx) \
  84. { \
  85. DPFM(0, DRV, ("in %s, dwhContext = NULL", (caller_name))); \
  86. (data_ptr)->ddrval = D3DHAL_CONTEXT_BAD; \
  87. return DDHAL_DRIVER_HANDLED; \
  88. } \
  89. }
  90. #else // !DBG
  91. // Validate context. pCtx should be declared before this macro
  92. // Type can be D3DContext or RefRast
  93. #define VALIDATE_CONTEXT(caller_name, data_ptr, pCtx, type) \
  94. { \
  95. pCtx = (type)((data_ptr)->dwhContext); \
  96. }
  97. #endif // !DBG
  98. // Validate ReferenceRasterizer. pRefRast should be declared before this macro
  99. #define VALIDATE_REFRAST_CONTEXT(caller_name, data_ptr) \
  100. { \
  101. VALIDATE_CONTEXT(caller_name, data_ptr, pRefRast, ReferenceRasterizer*);\
  102. }
  103. #define CHECK_FVF(ret, pDCtx, dwFlags) \
  104. { \
  105. if ((ret = pDCtx->CheckFVF(dwFlags)) != DD_OK) \
  106. { \
  107. return DDHAL_DRIVER_HANDLED; \
  108. } \
  109. }
  110. HRESULT FASTCALL
  111. FindOutSurfFormat(LPDDPIXELFORMAT pDdPixFmt,
  112. RRSurfaceType *pFmt);
  113. BOOL FASTCALL
  114. ValidTextureSize(INT16 iuSize, INT16 iuShift,
  115. INT16 ivSize, INT16 ivShift);
  116. BOOL FASTCALL
  117. ValidMipmapSize(INT16 iPreSize, INT16 iSize);
  118. DWORD __stdcall
  119. RefRastDrawPrimitives2(LPD3DHAL_DRAWPRIMITIVES2DATA pDPrim2Data);
  120. HRESULT
  121. RefRastLockTarget(ReferenceRasterizer *pRefRast);
  122. void
  123. RefRastUnlockTarget(ReferenceRasterizer *pRefRast);
  124. HRESULT
  125. RefRastLockTexture(ReferenceRasterizer *pRefRast);
  126. void
  127. RefRastUnlockTexture(ReferenceRasterizer *pRefRast);
  128. // DXT block size array
  129. extern int g_DXTBlkSize[];
  130. #endif // #ifndef _REFIF_HPP_