dx8caps.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : DX8 Caps *
  23. * *
  24. * $Archive:: /Commando/Code/ww3d2/dx8caps.h $*
  25. * *
  26. * Original Author:: Hector Yee *
  27. * *
  28. * $Author:: Jani_p $*
  29. * *
  30. * $Modtime:: 2/06/02 8:47p $*
  31. * *
  32. * $Revision:: 24 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if _MSC_VER >= 1000
  38. #pragma once
  39. #endif // _MSC_VER >= 1000
  40. #ifndef DX8CAPS_H
  41. #define DX8CAPS_H
  42. #include "always.h"
  43. #include "ww3dformat.h"
  44. #include <d3d8.h>
  45. class DX8Caps
  46. {
  47. public:
  48. enum DriverVersionStatusType {
  49. DRIVER_STATUS_UNKNOWN,
  50. DRIVER_STATUS_GOOD,
  51. DRIVER_STATUS_OK,
  52. DRIVER_STATUS_BAD
  53. };
  54. enum VendorIdType {
  55. VENDOR_UNKNOWN,
  56. VENDOR_NVIDIA,
  57. VENDOR_ATI,
  58. VENDOR_INTEL,
  59. VENDOR_S3,
  60. VENDOR_POWERVR,
  61. VENDOR_MATROX,
  62. VENDOR_3DFX,
  63. VENDOR_3DLABS,
  64. VENDOR_CIRRUSLOGIC,
  65. VENDOR_RENDITION
  66. };
  67. enum DeviceTypeATI {
  68. DEVICE_ATI_UNKNOWN,
  69. DEVICE_ATI_RAGE_II,
  70. DEVICE_ATI_RAGE_II_PLUS,
  71. DEVICE_ATI_RAGE_IIC_PCI,
  72. DEVICE_ATI_RAGE_IIC_AGP,
  73. DEVICE_ATI_RAGE_128_MOBILITY,
  74. DEVICE_ATI_RAGE_128_MOBILITY_M3,
  75. DEVICE_ATI_RAGE_128_MOBILITY_M4,
  76. DEVICE_ATI_RAGE_128_PRO_ULTRA,
  77. DEVICE_ATI_RAGE_128_4X,
  78. DEVICE_ATI_RAGE_128_PRO_GL,
  79. DEVICE_ATI_RAGE_128_PRO_VR,
  80. DEVICE_ATI_RAGE_128_GL,
  81. DEVICE_ATI_RAGE_128_VR,
  82. DEVICE_ATI_RAGE_PRO,
  83. DEVICE_ATI_RAGE_PRO_MOBILITY,
  84. DEVICE_ATI_MOBILITY_RADEON,
  85. DEVICE_ATI_MOBILITY_RADEON_VE_M6,
  86. DEVICE_ATI_RADEON_VE,
  87. DEVICE_ATI_RADEON_DDR,
  88. DEVICE_ATI_RADEON,
  89. DEVICE_ATI_MOBILITY_R7500,
  90. DEVICE_ATI_R7500,
  91. DEVICE_ATI_R8500
  92. };
  93. enum DeviceType3DLabs {
  94. DEVICE_3DLABS_UNKNOWN,
  95. DEVICE_3DLABS_PERMEDIA,
  96. DEVICE_3DLABS_300SX,
  97. DEVICE_3DLABS_500TX,
  98. DEVICE_3DLABS_DELTA,
  99. DEVICE_3DLABS_MX,
  100. DEVICE_3DLABS_GAMMA,
  101. DEVICE_3DLABS_PERMEDIA2S_ST,
  102. DEVICE_3DLABS_PERMEDIA3,
  103. DEVICE_3DLABS_R3,
  104. DEVICE_3DLABS_PERMEDIA4,
  105. DEVICE_3DLABS_R4,
  106. DEVICE_3DLABS_G2,
  107. DEVICE_3DLABS_OXYGEN_VX1,
  108. DEVICE_3DLABS_TI_P1,
  109. DEVICE_3DLABS_PERMEDIA2
  110. };
  111. enum DeviceTypeNVidia {
  112. DEVICE_NVIDIA_UNKNOWN,
  113. DEVICE_NVIDIA_GEFORCE3,
  114. DEVICE_NVIDIA_QUADRO2_PRO,
  115. DEVICE_NVIDIA_GEFORCE2_GO,
  116. DEVICE_NVIDIA_GEFORCE2_ULTRA,
  117. DEVICE_NVIDIA_GEFORCE2_GTS,
  118. DEVICE_NVIDIA_QUADRO,
  119. DEVICE_NVIDIA_GEFORCE_DDR,
  120. DEVICE_NVIDIA_GEFORCE_256,
  121. DEVICE_NVIDIA_TNT2_ALADDIN,
  122. DEVICE_NVIDIA_TNT2,
  123. DEVICE_NVIDIA_TNT2_ULTRA,
  124. DEVICE_NVIDIA_TNT2_VANTA,
  125. DEVICE_NVIDIA_TNT2_M64,
  126. DEVICE_NVIDIA_TNT,
  127. DEVICE_NVIDIA_RIVA_128,
  128. DEVICE_NVIDIA_TNT_VANTA,
  129. DEVICE_NVIDIA_NV1,
  130. DEVICE_NVIDIA_GEFORCE2_MX,
  131. DEVICE_NVIDIA_GEFORCE4_TI_4600,
  132. DEVICE_NVIDIA_GEFORCE4_TI_4400,
  133. DEVICE_NVIDIA_GEFORCE4_TI,
  134. DEVICE_NVIDIA_GEFORCE4_TI_4200,
  135. DEVICE_NVIDIA_GEFORCE4_MX_460,
  136. DEVICE_NVIDIA_GEFORCE4_MX_440,
  137. DEVICE_NVIDIA_GEFORCE4_MX_420,
  138. DEVICE_NVIDIA_GEFORCE4,
  139. DEVICE_NVIDIA_GEFORCE4_GO_440,
  140. DEVICE_NVIDIA_GEFORCE4_GO_420,
  141. DEVICE_NVIDIA_GEFORCE4_GO_420_32M,
  142. DEVICE_NVIDIA_GEFORCE4_GO_440_64M,
  143. DEVICE_NVIDIA_GEFORCE4_GO,
  144. DEVICE_NVIDIA_GEFORCE3_TI_500,
  145. DEVICE_NVIDIA_GEFORCE3_TI_200,
  146. DEVICE_NVIDIA_GEFORCE2_INTEGRATED,
  147. DEVICE_NVIDIA_GEFORCE2_TI,
  148. DEVICE_NVIDIA_QUADRO2_MXR_EX_GO,
  149. DEVICE_NVIDIA_GEFORCE2_MX_100_200,
  150. DEVICE_NVIDIA_GEFORCE2_MX_400,
  151. DEVICE_NVIDIA_QUADRO_DCC
  152. };
  153. enum DeviceType3Dfx {
  154. DEVICE_3DFX_UNKNOWN,
  155. DEVICE_3DFX_VOODOO_5500_AGP,
  156. DEVICE_3DFX_VOODOO_3,
  157. DEVICE_3DFX_BANSHEE,
  158. DEVICE_3DFX_VOODOO_2,
  159. DEVICE_3DFX_VOODOO_GRAPHICS,
  160. DEVICE_3DFX_VOODOO_RUSH
  161. };
  162. enum DeviceTypeMatrox {
  163. DEVICE_MATROX_UNKNOWN,
  164. DEVICE_MATROX_G550,
  165. DEVICE_MATROX_G400,
  166. DEVICE_MATROX_G200_AGP,
  167. DEVICE_MATROX_G200_PCI,
  168. DEVICE_MATROX_G100_PCI,
  169. DEVICE_MATROX_G100_AGP,
  170. DEVICE_MATROX_MILLENNIUM_II_AGP,
  171. DEVICE_MATROX_MILLENNIUM_II_PCI,
  172. DEVICE_MATROX_MYSTIQUE,
  173. DEVICE_MATROX_MILLENNIUM
  174. };
  175. enum DeviceTypePowerVR {
  176. DEVICE_POWERVR_UNKNOWN,
  177. DEVICE_POWERVR_KYRO
  178. };
  179. enum DeviceTypeS3 {
  180. DEVICE_S3_UNKNOWN,
  181. DEVICE_S3_SAVAGE_MX,
  182. DEVICE_S3_SAVAGE_4,
  183. DEVICE_S3_SAVAGE_200
  184. };
  185. enum DeviceTypeIntel {
  186. DEVICE_INTEL_UNKNOWN,
  187. DEVICE_INTEL_810,
  188. DEVICE_INTEL_810E,
  189. DEVICE_INTEL_815
  190. };
  191. DX8Caps(IDirect3D8* direct3d, const D3DCAPS8& caps,WW3DFormat display_format, const D3DADAPTER_IDENTIFIER8& adapter_id);
  192. DX8Caps(IDirect3D8* direct3d, IDirect3DDevice8* D3DDevice,WW3DFormat display_format, const D3DADAPTER_IDENTIFIER8& adapter_id);
  193. void Compute_Caps(WW3DFormat display_format, const D3DADAPTER_IDENTIFIER8& adapter_id);
  194. bool Support_TnL() const { return SupportTnL; };
  195. bool Support_DXTC() const { return SupportDXTC; }
  196. bool Support_Gamma() const { return supportGamma; }
  197. bool Support_NPatches() const { return SupportNPatches; }
  198. bool Support_Bump_Envmap() const { return SupportBumpEnvmap; }
  199. bool Support_Bump_Envmap_Luminance() const { return SupportBumpEnvmapLuminance; }
  200. bool Support_ZBias() const { return SupportZBias; }
  201. bool Support_Anisotropic_Filtering() const { return SupportAnisotropicFiltering; }
  202. bool Can_Do_Multi_Pass() const { return CanDoMultiPass; }
  203. bool Is_Fog_Allowed() const { return IsFogAllowed; }
  204. bool Is_Valid_Display_Format(int width, int height, WW3DFormat format);
  205. int Get_Max_Textures_Per_Pass() const { return MaxTexturesPerPass; }
  206. // -------------------------------------------------------------------------
  207. //
  208. // Vertex shader support. Version number is split in major and minor, such that 1.0 would
  209. // have 1 as major and 0 as minor version number.
  210. //
  211. // -------------------------------------------------------------------------
  212. int Get_Vertex_Shader_Majon_Version() const { return 0xff&(VertexShaderVersion>>8); }
  213. int Get_Vertex_Shader_Minor_Version() const { return 0xff&(VertexShaderVersion); }
  214. int Get_Pixel_Shader_Majon_Version() const { return 0xff&(VertexShaderVersion>>8); }
  215. int Get_Pixel_Shader_Minor_Version() const { return 0xff&(VertexShaderVersion); }
  216. bool Support_Texture_Format(WW3DFormat format) const { return SupportTextureFormat[format]; }
  217. bool Support_Render_To_Texture_Format(WW3DFormat format) const { return SupportRenderToTextureFormat[format]; }
  218. D3DCAPS8 const & Get_DX8_Caps() const { return Caps; }
  219. const StringClass& Get_Log() const { return CapsLog; }
  220. const StringClass& Get_Compact_Log() const { return CompactLog; }
  221. unsigned Get_Vendor() const { return VendorId; }
  222. unsigned Get_Device() const { return DeviceId; }
  223. const StringClass& Get_Driver_Name() const { return DriverDLL; }
  224. unsigned Get_Driver_Build_Version() const { return DriverBuildVersion; }
  225. // This will return false if the driver version is known to have problems.
  226. DriverVersionStatusType Get_Driver_Version_Status() { return DriverVersionStatus; }
  227. private:
  228. static VendorIdType Define_Vendor(unsigned vendor_id);
  229. static DeviceTypeATI Get_ATI_Device(unsigned device_id);
  230. static DeviceType3DLabs Get_3DLabs_Device(unsigned device_id);
  231. static DeviceTypeNVidia Get_NVidia_Device(unsigned device_id);
  232. static DeviceType3Dfx Get_3Dfx_Device(unsigned device_id);
  233. static DeviceTypeMatrox Get_Matrox_Device(unsigned device_id);
  234. static DeviceTypePowerVR Get_PowerVR_Device(unsigned device_id);
  235. static DeviceTypeS3 Get_S3_Device(unsigned device_id);
  236. static DeviceTypeIntel Get_Intel_Device(unsigned device_id);
  237. void Init_Caps(IDirect3DDevice8* D3DDevice);
  238. void Check_Texture_Format_Support(WW3DFormat display_format,const D3DCAPS8& caps);
  239. void Check_Render_To_Texture_Support(WW3DFormat display_format,const D3DCAPS8& caps);
  240. void Check_Texture_Compression_Support(const D3DCAPS8& caps);
  241. void Check_Bumpmap_Support(const D3DCAPS8& caps);
  242. void Check_Shader_Support(const D3DCAPS8& caps);
  243. void Check_Driver_Version_Status();
  244. void Vendor_Specific_Hacks(const D3DADAPTER_IDENTIFIER8& adapter_id);
  245. int MaxDisplayWidth;
  246. int MaxDisplayHeight;
  247. D3DCAPS8 Caps;
  248. bool SupportTnL;
  249. bool SupportDXTC;
  250. bool supportGamma;
  251. bool SupportNPatches;
  252. bool SupportBumpEnvmap;
  253. bool SupportBumpEnvmapLuminance;
  254. bool SupportTextureFormat[WW3D_FORMAT_COUNT];
  255. bool SupportRenderToTextureFormat[WW3D_FORMAT_COUNT];
  256. bool SupportZBias;
  257. bool SupportAnisotropicFiltering;
  258. bool CanDoMultiPass;
  259. bool IsFogAllowed;
  260. int MaxTexturesPerPass;
  261. int VertexShaderVersion;
  262. int PixelShaderVersion;
  263. unsigned DeviceId;
  264. unsigned DriverBuildVersion;
  265. DriverVersionStatusType DriverVersionStatus;
  266. VendorIdType VendorId;
  267. StringClass DriverDLL;
  268. IDirect3D8* Direct3D;
  269. StringClass CapsLog;
  270. StringClass CompactLog;
  271. };
  272. #endif