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.

162 lines
5.9 KiB

  1. // rastcoll.cpp - implementation of the CRastCollection class
  2. //
  3. // Copyright Microsoft Corporation, 1997.
  4. //
  5. #include "rgb_pch.h"
  6. #pragma hdrstop
  7. #include "RastCap.h"
  8. #include "rastcoll.h"
  9. #include "mlrfns.h"
  10. // MMX monolithic rasterizers are for X86 only
  11. #ifdef _X86_
  12. // table containing rasterzer capability bit vectors and
  13. // pointers to functions implementing MMX monolithic
  14. // rasterizers with those capabilities.
  15. //
  16. // note that table is sorted numerically by
  17. // capability bit vector, this is essential for the
  18. // search through the table.
  19. //
  20. static RASTFNREC s_RastListMMX[] = {
  21. {{ 0x00000000, 0x00000000, 0x00000100 }, MMXMLRast_22, 21, "MMX ml22" },
  22. {{ 0x00000000, 0x00000000, 0x00000102 }, MMXMLRast_8, 7, "MMX ml8 " },
  23. {{ 0x00000000, 0x00001100, 0x00000100 }, MMXMLRast_23, 22, "MMX ml23" },
  24. {{ 0x00000000, 0x00001102, 0x00000102 }, MMXMLRast_9, 8, "MMX ml9 " },
  25. {{ 0x00000000, 0x00003100, 0x00000100 }, MMXMLRast_26, 25, "MMX ml26" },
  26. {{ 0x00000000, 0x00003102, 0x00000102 }, MMXMLRast_12, 11, "MMX ml12" },
  27. {{ 0x00000000, 0x00101200, 0x00000100 }, MMXMLRast_24, 23, "MMX ml24" },
  28. {{ 0x00000000, 0x00101202, 0x00000102 }, MMXMLRast_10, 9, "MMX ml10" },
  29. {{ 0x00000000, 0x00103200, 0x00000100 }, MMXMLRast_27, 26, "MMX ml27" },
  30. {{ 0x00000000, 0x00103202, 0x00000102 }, MMXMLRast_13, 12, "MMX ml13" },
  31. {{ 0x00000000, 0x00111200, 0x00000100 }, MMXMLRast_25, 24, "MMX ml25" },
  32. {{ 0x00000000, 0x00111202, 0x00000102 }, MMXMLRast_11, 10, "MMX ml11" },
  33. {{ 0x00000000, 0x00113200, 0x00000100 }, MMXMLRast_28, 27, "MMX ml28" },
  34. {{ 0x00000000, 0x00113202, 0x00000102 }, MMXMLRast_14, 13, "MMX ml14" },
  35. {{ 0x00003003, 0x00000000, 0x00000100 }, MMXMLRast_15, 14, "MMX ml15" },
  36. {{ 0x00003003, 0x00000000, 0x00000102 }, MMXMLRast_1, 0, "MMX ml1 " },
  37. {{ 0x00003003, 0x00001100, 0x00000100 }, MMXMLRast_16, 15, "MMX ml16" },
  38. {{ 0x00003003, 0x00001102, 0x00000102 }, MMXMLRast_2, 1, "MMX ml2 " },
  39. {{ 0x00003003, 0x00003100, 0x00000100 }, MMXMLRast_19, 18, "MMX ml19" },
  40. {{ 0x00003003, 0x00003102, 0x00000102 }, MMXMLRast_5, 4, "MMX ml5 " },
  41. {{ 0x00003003, 0x00101200, 0x00000100 }, MMXMLRast_17, 16, "MMX ml17" },
  42. {{ 0x00003003, 0x00101202, 0x00000102 }, MMXMLRast_3, 2, "MMX ml3 " },
  43. {{ 0x00003003, 0x00103200, 0x00000100 }, MMXMLRast_20, 19, "MMX ml20" },
  44. {{ 0x00003003, 0x00103202, 0x00000102 }, MMXMLRast_6, 5, "MMX ml6 " },
  45. {{ 0x00003003, 0x00111200, 0x00000100 }, MMXMLRast_18, 17, "MMX ml18" },
  46. {{ 0x00003003, 0x00111202, 0x00000102 }, MMXMLRast_4, 3, "MMX ml4 " },
  47. {{ 0x00003003, 0x00113200, 0x00000100 }, MMXMLRast_21, 20, "MMX ml21" },
  48. {{ 0x00003003, 0x00113202, 0x00000102 }, MMXMLRast_7, 6, "MMX ml7 " },
  49. };
  50. #endif // _X86_
  51. // table containing rasterizer capability bit vectors and
  52. // pointers to functions implementing monolithic
  53. // rasterizers with those capabilities.
  54. //
  55. // note that table is sorted numerically by
  56. // capability bit vector, this is essential for the
  57. // search through the table.
  58. //
  59. static RASTFNREC s_RastListNormal[] = {
  60. // Don't select these until we are sure they work
  61. // {{ 0x00113003, 0x00000000, 0x00000100 }, CMLRast_1, 0, "CML 1" },
  62. // {{ 0x00113003, 0x00000000, 0x00000103 }, CMLRast_2, 1, "CML 2" }
  63. {{ 0xffffffff, 0xffffffff, 0xffffffff }, CMLRast_1, 0, "CML 1" },
  64. {{ 0xffffffff, 0xffffffff, 0xffffffff }, CMLRast_2, 1, "CML 2" }
  65. };
  66. int RastCapCompare(DWORD* pdwCap1, DWORD* pdwCap2)
  67. {
  68. for (int i = 0; i < RASTCAPRECORD_SIZE; i++) {
  69. if (pdwCap1[i] < pdwCap2[i]) {
  70. return -1;
  71. } else if (pdwCap1[i] > pdwCap2[i]) {
  72. return 1;
  73. }
  74. }
  75. return 0;
  76. }
  77. RASTFNREC*
  78. CRastCollection::RastFnLookup(
  79. CRastCapRecord* pRastCapRec,
  80. RASTFNREC* pRastFnTbl,
  81. int iSize)
  82. {
  83. int iLow = 0,
  84. iHigh = iSize - 1,
  85. iMid;
  86. RASTFNREC* pfnRastFnRec = NULL;
  87. // all MMX monolithics can handle either shade mode
  88. pRastCapRec->m_rgdwData[SHADEMODE_POS/32] &= ~(((1<<SHADEMODE_LEN)-1)<<SHADEMODE_POS);
  89. do
  90. {
  91. iMid = (iLow + iHigh) / 2;
  92. switch (RastCapCompare(pRastCapRec->
  93. m_rgdwData,pRastFnTbl[iMid].rgdwRastCap))
  94. {
  95. case -1 :
  96. iHigh = iMid - 1;
  97. break;
  98. case 0 :
  99. // found match
  100. pfnRastFnRec = &pRastFnTbl[iMid];
  101. iLow = iHigh + 1; // exits while loop
  102. break;
  103. case 1 :
  104. iLow = iMid + 1;
  105. break;
  106. }
  107. } while (iLow <= iHigh);
  108. return pfnRastFnRec;
  109. }
  110. RASTFNREC*
  111. CRastCollection::Search(PD3DI_RASTCTX pCtx,
  112. CRastCapRecord* pRastCapRec)
  113. {
  114. RASTFNREC* pfnRastFnRec = NULL;
  115. #ifdef _X86_
  116. // if we're on an MMX machine, is there an MMX rasterizer to use?
  117. if ((pCtx->BeadSet == D3DIBS_MMX)||(pCtx->BeadSet == D3DIBS_MMXASRGB)) {
  118. pfnRastFnRec = RastFnLookup(pRastCapRec,s_RastListMMX,
  119. sizeof(s_RastListMMX) /
  120. sizeof(s_RastListMMX[0]));
  121. if (pfnRastFnRec)
  122. {
  123. // only code up looking at one mask, for now
  124. // DDASSERT(MMX_FP_DISABLE_MASK_NUM == 1);
  125. int iIndex = pfnRastFnRec->iIndex;
  126. // DDASSERT((iIndex < 32) && (iIndex >= 0));
  127. if ((pCtx->dwMMXFPDisableMask[0]>>iIndex) & 1)
  128. {
  129. // oops, don't choose this one, it is on the disable list
  130. pfnRastFnRec = NULL;
  131. }
  132. }
  133. } else {
  134. #endif //_X86_
  135. // no MMX or on ALPHA, so look in the normal list
  136. pfnRastFnRec = RastFnLookup(pRastCapRec,s_RastListNormal,
  137. sizeof(s_RastListNormal) /
  138. sizeof(s_RastListNormal[0]));
  139. #ifdef _X86_
  140. }
  141. #endif //_X86_
  142. return pfnRastFnRec;
  143. }