Source code of Windows XP (NT5)
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.

348 lines
11 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // d3dflt.cpp
  4. //
  5. // Supporting data and routines for general FP header.
  6. //
  7. // Copyright (C) Microsoft Corporation, 1997.
  8. //
  9. //----------------------------------------------------------------------------
  10. #include "pch.cpp"
  11. #pragma hdrstop
  12. #ifdef _X86_
  13. FLOAT g_fE = FLOAT_E;
  14. FLOAT g_fZero = 0.0f;
  15. FLOAT g_fNearZero = FLOAT_NEARZERO;
  16. FLOAT g_fHalf = 0.5f;
  17. FLOAT g_fp95 = 0.95f;
  18. FLOAT g_fOne = 1.0f;
  19. FLOAT g_fOneMinusEps = 1.0f - FLT_EPSILON;
  20. FLOAT g_fExpScale = FLOAT_EXPSCALE;
  21. FLOAT g_fOoExpScale = (FLOAT)(1.0 / (double)FLOAT_EXPSCALE);
  22. FLOAT g_f255oTwoPow15 = (FLOAT)(255.0 / (double)CONST_TWOPOW15);
  23. FLOAT g_fOo255 = (FLOAT)(1.0 / 255.0);
  24. FLOAT g_fOo256 = (FLOAT)(1.0 / 256.0);
  25. FLOAT g_fTwoPow7 = FLOAT_TWOPOW7;
  26. FLOAT g_fTwoPow8 = FLOAT_TWOPOW8;
  27. FLOAT g_fTwoPow11 = FLOAT_TWOPOW11;
  28. FLOAT g_fTwoPow15 = FLOAT_TWOPOW15;
  29. FLOAT g_fOoTwoPow15 = (FLOAT)(1.0 / (double)CONST_TWOPOW15);
  30. FLOAT g_fTwoPow16 = FLOAT_TWOPOW16;
  31. FLOAT g_fOoTwoPow16 = (FLOAT)(1.0 / (double)CONST_TWOPOW16);
  32. FLOAT g_fTwoPow20 = FLOAT_TWOPOW20;
  33. FLOAT g_fOoTwoPow20 = (FLOAT)(1.0 / (double)CONST_TWOPOW20);
  34. FLOAT g_fTwoPow27 = FLOAT_TWOPOW27;
  35. FLOAT g_fOoTwoPow27 = (FLOAT)(1.0 / (double)CONST_TWOPOW27);
  36. FLOAT g_fTwoPow30 = FLOAT_TWOPOW30;
  37. FLOAT g_fTwoPow31 = FLOAT_TWOPOW31;
  38. FLOAT g_fNearTwoPow31 = FLOAT_NEARTWOPOW31;
  39. FLOAT g_fOoTwoPow31 = (FLOAT)(1.0 / (double)CONST_TWOPOW31);
  40. FLOAT g_fOoNearTwoPow31 = (FLOAT)(1.0 / (double)FLOAT_NEARTWOPOW31);
  41. FLOAT g_fTwoPow32 = FLOAT_TWOPOW32;
  42. FLOAT g_fNearTwoPow32 = FLOAT_NEARTWOPOW32;
  43. FLOAT g_fTwoPow39 = FLOAT_TWOPOW39;
  44. FLOAT g_fTwoPow47 = FLOAT_TWOPOW47;
  45. #endif // _X86_
  46. FLOAT g_fUInt8ToFloat[257] =
  47. {
  48. 0.0f,
  49. (FLOAT)(1.0 / 255.0),
  50. (FLOAT)(2.0 / 255.0),
  51. (FLOAT)(3.0 / 255.0),
  52. (FLOAT)(4.0 / 255.0),
  53. (FLOAT)(5.0 / 255.0),
  54. (FLOAT)(6.0 / 255.0),
  55. (FLOAT)(7.0 / 255.0),
  56. (FLOAT)(8.0 / 255.0),
  57. (FLOAT)(9.0 / 255.0),
  58. (FLOAT)(10.0 / 255.0),
  59. (FLOAT)(11.0 / 255.0),
  60. (FLOAT)(12.0 / 255.0),
  61. (FLOAT)(13.0 / 255.0),
  62. (FLOAT)(14.0 / 255.0),
  63. (FLOAT)(15.0 / 255.0),
  64. (FLOAT)(16.0 / 255.0),
  65. (FLOAT)(17.0 / 255.0),
  66. (FLOAT)(18.0 / 255.0),
  67. (FLOAT)(19.0 / 255.0),
  68. (FLOAT)(20.0 / 255.0),
  69. (FLOAT)(21.0 / 255.0),
  70. (FLOAT)(22.0 / 255.0),
  71. (FLOAT)(23.0 / 255.0),
  72. (FLOAT)(24.0 / 255.0),
  73. (FLOAT)(25.0 / 255.0),
  74. (FLOAT)(26.0 / 255.0),
  75. (FLOAT)(27.0 / 255.0),
  76. (FLOAT)(28.0 / 255.0),
  77. (FLOAT)(29.0 / 255.0),
  78. (FLOAT)(30.0 / 255.0),
  79. (FLOAT)(31.0 / 255.0),
  80. (FLOAT)(32.0 / 255.0),
  81. (FLOAT)(33.0 / 255.0),
  82. (FLOAT)(34.0 / 255.0),
  83. (FLOAT)(35.0 / 255.0),
  84. (FLOAT)(36.0 / 255.0),
  85. (FLOAT)(37.0 / 255.0),
  86. (FLOAT)(38.0 / 255.0),
  87. (FLOAT)(39.0 / 255.0),
  88. (FLOAT)(40.0 / 255.0),
  89. (FLOAT)(41.0 / 255.0),
  90. (FLOAT)(42.0 / 255.0),
  91. (FLOAT)(43.0 / 255.0),
  92. (FLOAT)(44.0 / 255.0),
  93. (FLOAT)(45.0 / 255.0),
  94. (FLOAT)(46.0 / 255.0),
  95. (FLOAT)(47.0 / 255.0),
  96. (FLOAT)(48.0 / 255.0),
  97. (FLOAT)(49.0 / 255.0),
  98. (FLOAT)(50.0 / 255.0),
  99. (FLOAT)(51.0 / 255.0),
  100. (FLOAT)(52.0 / 255.0),
  101. (FLOAT)(53.0 / 255.0),
  102. (FLOAT)(54.0 / 255.0),
  103. (FLOAT)(55.0 / 255.0),
  104. (FLOAT)(56.0 / 255.0),
  105. (FLOAT)(57.0 / 255.0),
  106. (FLOAT)(58.0 / 255.0),
  107. (FLOAT)(59.0 / 255.0),
  108. (FLOAT)(60.0 / 255.0),
  109. (FLOAT)(61.0 / 255.0),
  110. (FLOAT)(62.0 / 255.0),
  111. (FLOAT)(63.0 / 255.0),
  112. (FLOAT)(64.0 / 255.0),
  113. (FLOAT)(65.0 / 255.0),
  114. (FLOAT)(66.0 / 255.0),
  115. (FLOAT)(67.0 / 255.0),
  116. (FLOAT)(68.0 / 255.0),
  117. (FLOAT)(69.0 / 255.0),
  118. (FLOAT)(70.0 / 255.0),
  119. (FLOAT)(71.0 / 255.0),
  120. (FLOAT)(72.0 / 255.0),
  121. (FLOAT)(73.0 / 255.0),
  122. (FLOAT)(74.0 / 255.0),
  123. (FLOAT)(75.0 / 255.0),
  124. (FLOAT)(76.0 / 255.0),
  125. (FLOAT)(77.0 / 255.0),
  126. (FLOAT)(78.0 / 255.0),
  127. (FLOAT)(79.0 / 255.0),
  128. (FLOAT)(80.0 / 255.0),
  129. (FLOAT)(81.0 / 255.0),
  130. (FLOAT)(82.0 / 255.0),
  131. (FLOAT)(83.0 / 255.0),
  132. (FLOAT)(84.0 / 255.0),
  133. (FLOAT)(85.0 / 255.0),
  134. (FLOAT)(86.0 / 255.0),
  135. (FLOAT)(87.0 / 255.0),
  136. (FLOAT)(88.0 / 255.0),
  137. (FLOAT)(89.0 / 255.0),
  138. (FLOAT)(90.0 / 255.0),
  139. (FLOAT)(91.0 / 255.0),
  140. (FLOAT)(92.0 / 255.0),
  141. (FLOAT)(93.0 / 255.0),
  142. (FLOAT)(94.0 / 255.0),
  143. (FLOAT)(95.0 / 255.0),
  144. (FLOAT)(96.0 / 255.0),
  145. (FLOAT)(97.0 / 255.0),
  146. (FLOAT)(98.0 / 255.0),
  147. (FLOAT)(99.0 / 255.0),
  148. (FLOAT)(100.0 / 255.0),
  149. (FLOAT)(101.0 / 255.0),
  150. (FLOAT)(102.0 / 255.0),
  151. (FLOAT)(103.0 / 255.0),
  152. (FLOAT)(104.0 / 255.0),
  153. (FLOAT)(105.0 / 255.0),
  154. (FLOAT)(106.0 / 255.0),
  155. (FLOAT)(107.0 / 255.0),
  156. (FLOAT)(108.0 / 255.0),
  157. (FLOAT)(109.0 / 255.0),
  158. (FLOAT)(110.0 / 255.0),
  159. (FLOAT)(111.0 / 255.0),
  160. (FLOAT)(112.0 / 255.0),
  161. (FLOAT)(113.0 / 255.0),
  162. (FLOAT)(114.0 / 255.0),
  163. (FLOAT)(115.0 / 255.0),
  164. (FLOAT)(116.0 / 255.0),
  165. (FLOAT)(117.0 / 255.0),
  166. (FLOAT)(118.0 / 255.0),
  167. (FLOAT)(119.0 / 255.0),
  168. (FLOAT)(120.0 / 255.0),
  169. (FLOAT)(121.0 / 255.0),
  170. (FLOAT)(122.0 / 255.0),
  171. (FLOAT)(123.0 / 255.0),
  172. (FLOAT)(124.0 / 255.0),
  173. (FLOAT)(125.0 / 255.0),
  174. (FLOAT)(126.0 / 255.0),
  175. (FLOAT)(127.0 / 255.0),
  176. (FLOAT)(128.0 / 255.0),
  177. (FLOAT)(129.0 / 255.0),
  178. (FLOAT)(130.0 / 255.0),
  179. (FLOAT)(131.0 / 255.0),
  180. (FLOAT)(132.0 / 255.0),
  181. (FLOAT)(133.0 / 255.0),
  182. (FLOAT)(134.0 / 255.0),
  183. (FLOAT)(135.0 / 255.0),
  184. (FLOAT)(136.0 / 255.0),
  185. (FLOAT)(137.0 / 255.0),
  186. (FLOAT)(138.0 / 255.0),
  187. (FLOAT)(139.0 / 255.0),
  188. (FLOAT)(140.0 / 255.0),
  189. (FLOAT)(141.0 / 255.0),
  190. (FLOAT)(142.0 / 255.0),
  191. (FLOAT)(143.0 / 255.0),
  192. (FLOAT)(144.0 / 255.0),
  193. (FLOAT)(145.0 / 255.0),
  194. (FLOAT)(146.0 / 255.0),
  195. (FLOAT)(147.0 / 255.0),
  196. (FLOAT)(148.0 / 255.0),
  197. (FLOAT)(149.0 / 255.0),
  198. (FLOAT)(150.0 / 255.0),
  199. (FLOAT)(151.0 / 255.0),
  200. (FLOAT)(152.0 / 255.0),
  201. (FLOAT)(153.0 / 255.0),
  202. (FLOAT)(154.0 / 255.0),
  203. (FLOAT)(155.0 / 255.0),
  204. (FLOAT)(156.0 / 255.0),
  205. (FLOAT)(157.0 / 255.0),
  206. (FLOAT)(158.0 / 255.0),
  207. (FLOAT)(159.0 / 255.0),
  208. (FLOAT)(160.0 / 255.0),
  209. (FLOAT)(161.0 / 255.0),
  210. (FLOAT)(162.0 / 255.0),
  211. (FLOAT)(163.0 / 255.0),
  212. (FLOAT)(164.0 / 255.0),
  213. (FLOAT)(165.0 / 255.0),
  214. (FLOAT)(166.0 / 255.0),
  215. (FLOAT)(167.0 / 255.0),
  216. (FLOAT)(168.0 / 255.0),
  217. (FLOAT)(169.0 / 255.0),
  218. (FLOAT)(170.0 / 255.0),
  219. (FLOAT)(171.0 / 255.0),
  220. (FLOAT)(172.0 / 255.0),
  221. (FLOAT)(173.0 / 255.0),
  222. (FLOAT)(174.0 / 255.0),
  223. (FLOAT)(175.0 / 255.0),
  224. (FLOAT)(176.0 / 255.0),
  225. (FLOAT)(177.0 / 255.0),
  226. (FLOAT)(178.0 / 255.0),
  227. (FLOAT)(179.0 / 255.0),
  228. (FLOAT)(180.0 / 255.0),
  229. (FLOAT)(181.0 / 255.0),
  230. (FLOAT)(182.0 / 255.0),
  231. (FLOAT)(183.0 / 255.0),
  232. (FLOAT)(184.0 / 255.0),
  233. (FLOAT)(185.0 / 255.0),
  234. (FLOAT)(186.0 / 255.0),
  235. (FLOAT)(187.0 / 255.0),
  236. (FLOAT)(188.0 / 255.0),
  237. (FLOAT)(189.0 / 255.0),
  238. (FLOAT)(190.0 / 255.0),
  239. (FLOAT)(191.0 / 255.0),
  240. (FLOAT)(192.0 / 255.0),
  241. (FLOAT)(193.0 / 255.0),
  242. (FLOAT)(194.0 / 255.0),
  243. (FLOAT)(195.0 / 255.0),
  244. (FLOAT)(196.0 / 255.0),
  245. (FLOAT)(197.0 / 255.0),
  246. (FLOAT)(198.0 / 255.0),
  247. (FLOAT)(199.0 / 255.0),
  248. (FLOAT)(200.0 / 255.0),
  249. (FLOAT)(201.0 / 255.0),
  250. (FLOAT)(202.0 / 255.0),
  251. (FLOAT)(203.0 / 255.0),
  252. (FLOAT)(204.0 / 255.0),
  253. (FLOAT)(205.0 / 255.0),
  254. (FLOAT)(206.0 / 255.0),
  255. (FLOAT)(207.0 / 255.0),
  256. (FLOAT)(208.0 / 255.0),
  257. (FLOAT)(209.0 / 255.0),
  258. (FLOAT)(210.0 / 255.0),
  259. (FLOAT)(211.0 / 255.0),
  260. (FLOAT)(212.0 / 255.0),
  261. (FLOAT)(213.0 / 255.0),
  262. (FLOAT)(214.0 / 255.0),
  263. (FLOAT)(215.0 / 255.0),
  264. (FLOAT)(216.0 / 255.0),
  265. (FLOAT)(217.0 / 255.0),
  266. (FLOAT)(218.0 / 255.0),
  267. (FLOAT)(219.0 / 255.0),
  268. (FLOAT)(220.0 / 255.0),
  269. (FLOAT)(221.0 / 255.0),
  270. (FLOAT)(222.0 / 255.0),
  271. (FLOAT)(223.0 / 255.0),
  272. (FLOAT)(224.0 / 255.0),
  273. (FLOAT)(225.0 / 255.0),
  274. (FLOAT)(226.0 / 255.0),
  275. (FLOAT)(227.0 / 255.0),
  276. (FLOAT)(228.0 / 255.0),
  277. (FLOAT)(229.0 / 255.0),
  278. (FLOAT)(230.0 / 255.0),
  279. (FLOAT)(231.0 / 255.0),
  280. (FLOAT)(232.0 / 255.0),
  281. (FLOAT)(233.0 / 255.0),
  282. (FLOAT)(234.0 / 255.0),
  283. (FLOAT)(235.0 / 255.0),
  284. (FLOAT)(236.0 / 255.0),
  285. (FLOAT)(237.0 / 255.0),
  286. (FLOAT)(238.0 / 255.0),
  287. (FLOAT)(239.0 / 255.0),
  288. (FLOAT)(240.0 / 255.0),
  289. (FLOAT)(241.0 / 255.0),
  290. (FLOAT)(242.0 / 255.0),
  291. (FLOAT)(243.0 / 255.0),
  292. (FLOAT)(244.0 / 255.0),
  293. (FLOAT)(245.0 / 255.0),
  294. (FLOAT)(246.0 / 255.0),
  295. (FLOAT)(247.0 / 255.0),
  296. (FLOAT)(248.0 / 255.0),
  297. (FLOAT)(249.0 / 255.0),
  298. (FLOAT)(250.0 / 255.0),
  299. (FLOAT)(251.0 / 255.0),
  300. (FLOAT)(252.0 / 255.0),
  301. (FLOAT)(253.0 / 255.0),
  302. (FLOAT)(254.0 / 255.0),
  303. 1.0f,
  304. // Extra entry to allow for overflow.
  305. 1.0f,
  306. };
  307. DOUBLE g_dSnap[33] =
  308. {
  309. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW52,
  310. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW51,
  311. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW50,
  312. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW49,
  313. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW48,
  314. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW47,
  315. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW46,
  316. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW45,
  317. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW44,
  318. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW43,
  319. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW42,
  320. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW41,
  321. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW40,
  322. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW39,
  323. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW38,
  324. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW37,
  325. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW36,
  326. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW35,
  327. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW34,
  328. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW33,
  329. (DOUBLE)CONST_TWOPOW32 + (DOUBLE)CONST_TWOPOW31,
  330. (DOUBLE)CONST_TWOPOW31 + (DOUBLE)CONST_TWOPOW30,
  331. (DOUBLE)CONST_TWOPOW30 + (DOUBLE)CONST_TWOPOW29,
  332. (DOUBLE)CONST_TWOPOW29 + (DOUBLE)CONST_TWOPOW28,
  333. (DOUBLE)CONST_TWOPOW28 + (DOUBLE)CONST_TWOPOW27,
  334. (DOUBLE)CONST_TWOPOW27 + (DOUBLE)CONST_TWOPOW26,
  335. (DOUBLE)CONST_TWOPOW26 + (DOUBLE)CONST_TWOPOW25,
  336. (DOUBLE)CONST_TWOPOW25 + (DOUBLE)CONST_TWOPOW24,
  337. (DOUBLE)CONST_TWOPOW24 + (DOUBLE)CONST_TWOPOW23,
  338. (DOUBLE)CONST_TWOPOW23 + (DOUBLE)CONST_TWOPOW22,
  339. (DOUBLE)CONST_TWOPOW22 + (DOUBLE)CONST_TWOPOW21,
  340. (DOUBLE)CONST_TWOPOW21 + (DOUBLE)CONST_TWOPOW20,
  341. (DOUBLE)CONST_TWOPOW20 + (DOUBLE)CONST_TWOPOW19,
  342. };