CGFXSpec.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. #include "CGFXSpec.h"
  2. #include "AndroidApp.h"
  3. #include "CFE.h"
  4. #include "CFTTAndroidDevice.h"
  5. #include "CFTTDevice.h"
  6. #include "CFTTGraphicsDevice.h"
  7. #include "CXmlUtil.h"
  8. #include "STORY.h"
  9. char CGFXSpec::s_cDeviceReport[0x1000];
  10. //-------------------------------------------------------------------------------------------------
  11. const char *list_ResLimit_323204[4] = {
  12. "ResLimit_Phone", //手机
  13. "ResLimit_Phablet", //平板手机
  14. "ResLimit_Tablet", //平板电脑
  15. "ResLimit_Screen" //
  16. };
  17. //-------------------------------------------------------------------------------------------------
  18. GFXSPEC_Specification GFXSPEC_tSpecification_AndroidLow{
  19. 0x1e, // field_0
  20. 1.399999976158142, // fLODMultGame_4
  21. 1.200000047683716, // fLODMultNIS_8
  22. 0.75, // fRTTScaleFactorX_C
  23. 0.75, // fRTTScaleFactorY_10
  24. 256, // iAtlasWidth_14
  25. 256, // iAtlasHeight_18
  26. 2, // iKitTexFormat_1C
  27. 512, // iKitDims_20
  28. false, // bSoftShadows_24
  29. true, // bEnvObjectShadows_25
  30. false, // bGameplayStadium_26
  31. true, // bCrowdAnimated_27
  32. false, // bDropTexMips_28
  33. false, // field_29 unuse
  34. false, // field_2A unuse
  35. false, // field_2B unuse
  36. 0, // eEnableDOF_2C
  37. false, // bEnableDepthFog_30
  38. false, // bEnableReflection_31
  39. false, // bEnableGodRays_32
  40. false, // bHighQualityNet_33
  41. 0u,
  42. 0u,
  43. 1u,
  44. 0u,
  45. nullptr, // pVHSShader_38
  46. false, // bHighQualityGroundShadows_3C
  47. false, // b3DGrass_3D
  48. false, // bFloatEnvMap_3E
  49. false, // bDynNormMap_3F
  50. 0, // eAntiAliasing_40
  51. EPlayerShader_Quality_0, // ePlayerLightingQuality_44
  52. EPitchShader_Quality_0, // eHighQualityGrass_48
  53. 0, // eCrowdQuality_4C
  54. -1, // iMinMaxResolution_50
  55. false, // bForce16Bit_54
  56. };
  57. //-------------------------------------------------------------------------------------------------
  58. GFXSPEC_Specification GFXSPEC_tSpecification_AndroidMed{
  59. 0x1e, // field_0
  60. 1.200000047683716, // fLODMultGame_4
  61. 1.100000023841858, // fLODMultNIS_8
  62. 0.75, // fRTTScaleFactorX_C
  63. 0.75, // fRTTScaleFactorY_10
  64. 256, // iAtlasWidth_14
  65. 256, // iAtlasHeight_18
  66. 3, // iKitTexFormat_1C
  67. 256, // iKitDims_20
  68. false, // bSoftShadows_24
  69. true, // bEnvObjectShadows_25
  70. true, // bGameplayStadium_26
  71. true, // bCrowdAnimated_27
  72. false, // bDropTexMips_28
  73. false, // field_29 unuse
  74. false, // field_2A unuse
  75. false, // field_2B unuse
  76. 1, // eEnableDOF_2C
  77. true, // bEnableDepthFog_30
  78. true, // bEnableReflection_31
  79. true, // bEnableGodRays_32
  80. true, // bHighQualityNet_33
  81. 1u,
  82. 1u,
  83. 3u,
  84. 0u,
  85. "2d_vhsbasic", // pVHSShader_38
  86. false, // bHighQualityGroundShadows_3C
  87. false, // b3DGrass_3D
  88. false, // bFloatEnvMap_3E
  89. false, // bDynNormMap_3F
  90. 0, // eAntiAliasing_40
  91. EPlayerShader_Quality_1, // ePlayerLightingQuality_44
  92. EPitchShader_Quality_1, // eHighQualityGrass_48
  93. 0, // eCrowdQuality_4C
  94. -1, // iMinMaxResolution_50
  95. false, // bForce16Bit_54
  96. };
  97. //-------------------------------------------------------------------------------------------------
  98. GFXSPEC_Specification GFXSPEC_tSpecification_AndroidHigh{
  99. 0x3c, // field_0
  100. 0.875, // fLODMultGame_4
  101. 0.75, // fLODMultNIS_8
  102. 1.0, // fRTTScaleFactorX_C
  103. 1.0, // fRTTScaleFactorY_10
  104. 256, // iAtlasWidth_14
  105. 256, // iAtlasHeight_18
  106. 3, // iKitTexFormat_1C
  107. 512, // iKitDims_20
  108. true, // bSoftShadows_24
  109. true, // bEnvObjectShadows_25
  110. true, // bGameplayStadium_26
  111. true, // bCrowdAnimated_27
  112. false, // bDropTexMips_28
  113. false, // field_29 unuse
  114. false, // field_2A unuse
  115. false, // field_2B unuse
  116. 2, // eEnableDOF_2C
  117. true, // bEnableDepthFog_30
  118. true, // bEnableReflection_31
  119. true, // bEnableGodRays_32
  120. true, // bHighQualityNet_33
  121. 1u,
  122. 1u,
  123. 4u,
  124. 0u,
  125. "2d_vhsfancy", // pVHSShader_38
  126. true, // bHighQualityGroundShadows_3C
  127. true, // b3DGrass_3D
  128. true, // bFloatEnvMap_3E
  129. true, // bDynNormMap_3F
  130. 0, // eAntiAliasing_40
  131. EPlayerShader_Quality_1, // ePlayerLightingQuality_44
  132. EPitchShader_Quality_2, // eHighQualityGrass_48
  133. 2, // eCrowdQuality_4C
  134. -1, // iMinMaxResolution_50
  135. false, // bForce16Bit_54
  136. };
  137. //-------------------------------------------------------------------------------------------------
  138. GFXSPEC_Specification GFXSPEC_tSpecification_AndroidHighest{
  139. 0x3c, // field_0
  140. 0.75, // fLODMultGame_4
  141. 0.5, // fLODMultNIS_8
  142. 1.0, // fRTTScaleFactorX_C
  143. 1.0, // fRTTScaleFactorY_10
  144. 256, // iAtlasWidth_14
  145. 256, // iAtlasHeight_18
  146. 3, // iKitTexFormat_1C
  147. 512, // iKitDims_20
  148. true, // bSoftShadows_24
  149. true, // bEnvObjectShadows_25
  150. true, // bGameplayStadium_26
  151. true, // bCrowdAnimated_27
  152. false, // bDropTexMips_28
  153. false, // field_29 unuse
  154. false, // field_2A unuse
  155. false, // field_2B unuse
  156. 3, // eEnableDOF_2C
  157. true, // bEnableDepthFog_30
  158. true, // bEnableReflection_31
  159. true, // bEnableGodRays_32
  160. true, // bHighQualityNet_33
  161. 1u,
  162. 1u,
  163. 4u,
  164. 0u,
  165. "2d_vhsfancy", // pVHSShader_38
  166. true, // bHighQualityGroundShadows_3C
  167. true, // b3DGrass_3D
  168. true, // bFloatEnvMap_3E
  169. true, // bDynNormMap_3F
  170. 3, // eAntiAliasing_40
  171. EPlayerShader_Quality_2, // ePlayerLightingQuality_44
  172. EPitchShader_Quality_3, // eHighQualityGrass_48
  173. 3, // eCrowdQuality_4C
  174. -1, // iMinMaxResolution_50
  175. false, // bForce16Bit_54
  176. };
  177. //-------------------------------------------------------------------------------------------------
  178. GFXSPEC_Specification *list_Specification_323214[]{
  179. &GFXSPEC_tSpecification_AndroidLow, &GFXSPEC_tSpecification_AndroidLow,
  180. &GFXSPEC_tSpecification_AndroidMed, &GFXSPEC_tSpecification_AndroidHigh,
  181. &GFXSPEC_tSpecification_AndroidHighest,
  182. };
  183. //-------------------------------------------------------------------------------------------------
  184. GFXSPEC_Specification *GFXSPEC_pSpecification;
  185. char CGFXSpec::s_cDeviceAnalyticsString[512];
  186. //-------------------------------------------------------------------------------------------------
  187. // 0018F3F0
  188. extern "C" {
  189. // 0018F3F0
  190. extern "C" {
  191. bool sub_18F3F0(CFTTXmlReaderNode *pXmlNode0, const char *pName, int *pOut) {
  192. CFTTXmlReaderNode xmlnode_C = pXmlNode0->GetFirstChild(pName);
  193. if (!xmlnode_C.IsValid()) return false;
  194. char *r0_text = CXmlUtil::GetText(xmlnode_C);
  195. if (r0_text == nullptr) return false;
  196. *pOut = atoi(r0_text);
  197. return true;
  198. }
  199. }
  200. }
  201. //-------------------------------------------------------------------------------------------------
  202. // 0018E728 经过单元测试,功能正常
  203. void CGFXSpec::Initialise() {
  204. // 只保留android相关的代码,ios的忽略
  205. // SYS_GetHardwareType();
  206. // locret_18E80A return
  207. LOGI("CGFXSpec::Initialise End");
  208. }
  209. //-------------------------------------------------------------------------------------------------
  210. // 0018EEF4 //^_- 经过单元测试,功能正常
  211. void CGFXSpec::UpdateGraphicsFromConfig(CFTTXmlReaderNode *pXmlNode) {
  212. char pbuf_134[256];
  213. CFTTAndroidDevice::GetDeviceType(pbuf_134, 256, false);
  214. char pbuf_234[256];
  215. CFTTAndroidDevice::GetDeviceType(pbuf_234, 256, true); // 0018EF26
  216. float fs16 = 0.01;
  217. int dInt_240, dr1;
  218. for (CFTTXmlReaderNode xmlnode_238 = pXmlNode->GetFirstChild("Spec");
  219. xmlnode_238.IsValid();
  220. xmlnode_238 = xmlnode_238.GetNextSibling("Spec")) {
  221. // loc_18EF82
  222. CFTTXmlReaderNode xmlnode_23C = xmlnode_238.GetFirstChild("Model");
  223. bool r5_isvalid = xmlnode_23C.IsValid();
  224. if (!xmlnode_23C.IsValid()) //注意此处的逻辑与原始的汇编略有区别 loc_18F000
  225. continue;
  226. while (xmlnode_23C.IsValid()) {
  227. // 0018EFA8
  228. char *r8_text = CXmlUtil::GetText(xmlnode_23C);
  229. if (r8_text != nullptr &&
  230. (strcmp(r8_text, pbuf_134) == 0 || strcmp(r8_text, pbuf_234) == 0)) {
  231. // loc_18F006
  232. break;
  233. }
  234. xmlnode_23C = xmlnode_23C.GetNextSibling("Model");
  235. }
  236. // loc_18F000 此处的判断被我移到上去面了
  237. // loc_18F006
  238. if (sub_18F3F0(&xmlnode_238, "fLODMultGame", &dInt_240))
  239. GFXSPEC_pSpecification->fLODMultGame_4 = (float)dInt_240 * (float)0.01;
  240. if (sub_18F3F0(&xmlnode_238, "fLODMultNIS", &dInt_240))
  241. GFXSPEC_pSpecification->fLODMultNIS_8 = (float)dInt_240 * (float)0.01;
  242. if (sub_18F3F0(&xmlnode_238, "fRTTScaleFactorX", &dInt_240))
  243. GFXSPEC_pSpecification->fRTTScaleFactorX_C =
  244. (float)dInt_240 * (float)0.01;
  245. if (sub_18F3F0(&xmlnode_238, "fRTTScaleFactorY", &dInt_240))
  246. GFXSPEC_pSpecification->fRTTScaleFactorY_10 =
  247. (float)dInt_240 * (float)0.01;
  248. // loc_18F086
  249. if (sub_18F3F0(&xmlnode_238, "iAtlasWidth", &dInt_240)) {
  250. dr1 = 256;
  251. if (!dInt_240) dr1 = 128;
  252. GFXSPEC_pSpecification->iAtlasWidth_14 = dr1;
  253. }
  254. // loc_18F0A4
  255. if (sub_18F3F0(&xmlnode_238, "iAtlasHeight", &dInt_240)) {
  256. dr1 = 256;
  257. if (!dInt_240) dr1 = 128;
  258. GFXSPEC_pSpecification->iAtlasHeight_18 = dr1;
  259. }
  260. if (sub_18F3F0(&xmlnode_238, "iKitTexFormat", &dInt_240)) {
  261. dr1 = 3;
  262. if (!dInt_240) dr1 = 2;
  263. GFXSPEC_pSpecification->iKitTexFormat_1C = dr1;
  264. }
  265. if (sub_18F3F0(&xmlnode_238, "iKitDims", &dInt_240)) {
  266. dr1 = 512;
  267. if (!dInt_240) dr1 = 256;
  268. GFXSPEC_pSpecification->iKitDims_20 = dr1;
  269. }
  270. if (sub_18F3F0(&xmlnode_238, "bSoftShadows", &dInt_240)) {
  271. bool br1 = false;
  272. if (dInt_240) br1 = true;
  273. GFXSPEC_pSpecification->bSoftShadows_24 = br1;
  274. }
  275. if (sub_18F3F0(&xmlnode_238, "bEnvObjectShadows", &dInt_240)) {
  276. bool br1 = false;
  277. if (dInt_240) br1 = true;
  278. GFXSPEC_pSpecification->bEnvObjectShadows_25 = br1;
  279. }
  280. if (sub_18F3F0(&xmlnode_238, "bGameplayStadium", &dInt_240)) {
  281. bool br1 = false;
  282. if (dInt_240) br1 = true;
  283. GFXSPEC_pSpecification->bGameplayStadium_26 = br1;
  284. }
  285. if (sub_18F3F0(&xmlnode_238, "bCrowdAnimated", &dInt_240)) {
  286. bool br1 = false;
  287. if (dInt_240) br1 = true;
  288. GFXSPEC_pSpecification->bCrowdAnimated_27 = br1;
  289. }
  290. if (sub_18F3F0(&xmlnode_238, "bDropTexMips", &dInt_240)) {
  291. bool br1 = false;
  292. if (dInt_240) br1 = true;
  293. GFXSPEC_pSpecification->bDropTexMips_28 = br1;
  294. }
  295. if (sub_18F3F0(&xmlnode_238, "eEnableDOF", &dInt_240))
  296. GFXSPEC_pSpecification->eEnableDOF_2C = dInt_240;
  297. if (sub_18F3F0(&xmlnode_238, "bEnableDepthFog", &dInt_240)) {
  298. bool br1 = false;
  299. if (dInt_240) br1 = true;
  300. GFXSPEC_pSpecification->bEnableDepthFog_30 = br1;
  301. }
  302. if (sub_18F3F0(&xmlnode_238, "bEnableReflection", &dInt_240)) {
  303. bool br1 = false;
  304. if (dInt_240) br1 = true;
  305. GFXSPEC_pSpecification->bEnableReflection_31 = br1;
  306. }
  307. if (sub_18F3F0(&xmlnode_238, "bEnableGodRays", &dInt_240)) {
  308. bool br1 = false;
  309. if (dInt_240) br1 = 1;
  310. GFXSPEC_pSpecification->bEnableGodRays_32 = br1;
  311. }
  312. if (sub_18F3F0(&xmlnode_238, "bHighQualityNet", &dInt_240)) {
  313. bool br1 = false;
  314. if (dInt_240) br1 = true;
  315. GFXSPEC_pSpecification->bHighQualityNet_33 = br1;
  316. }
  317. if (sub_18F3F0(&xmlnode_238, "pVHSShader", &dInt_240)) {
  318. const char *r0_2d_vh = "2d_vhsbasic";
  319. if (dInt_240 != 1) r0_2d_vh = nullptr;
  320. if (dInt_240 == 2) r0_2d_vh = "2d_vhsfancy";
  321. GFXSPEC_pSpecification->pVHSShader_38 = r0_2d_vh;
  322. }
  323. if (sub_18F3F0(&xmlnode_238, "bHighQualityGroundShadows", &dInt_240)) {
  324. bool br1 = false;
  325. if (dInt_240) br1 = true;
  326. GFXSPEC_pSpecification->bHighQualityGroundShadows_3C = true;
  327. }
  328. if (sub_18F3F0(&xmlnode_238, "bFloatEnvMap", &dInt_240)) {
  329. bool br1 = false;
  330. if (dInt_240) br1 = true;
  331. GFXSPEC_pSpecification->bFloatEnvMap_3E = br1;
  332. }
  333. if (sub_18F3F0(&xmlnode_238, "bDynNormMap", &dInt_240)) {
  334. bool br1 = false;
  335. if (dInt_240) br1 = true;
  336. GFXSPEC_pSpecification->bDynNormMap_3F = br1;
  337. }
  338. if (sub_18F3F0(&xmlnode_238, "b3DGrass", &dInt_240)) {
  339. bool br1 = false;
  340. if (dInt_240) br1 = true;
  341. GFXSPEC_pSpecification->b3DGrass_3D = br1;
  342. }
  343. if (sub_18F3F0(&xmlnode_238, "eHighQualityGrass", &dInt_240))
  344. GFXSPEC_pSpecification->eHighQualityGrass_48 =
  345. (EPitchShader_Quality)dInt_240;
  346. if (sub_18F3F0(&xmlnode_238, "eAntiAliasing", &dInt_240))
  347. GFXSPEC_pSpecification->eAntiAliasing_40 = dInt_240;
  348. if (sub_18F3F0(&xmlnode_238, "eCrowdQuality", &dInt_240))
  349. GFXSPEC_pSpecification->eCrowdQuality_4C = dInt_240;
  350. if (sub_18F3F0(&xmlnode_238, "ePlayerLightingQuality", &dInt_240))
  351. GFXSPEC_pSpecification->ePlayerLightingQuality_44 =
  352. (EPlayerShader_Quality)dInt_240;
  353. if (sub_18F3F0(&xmlnode_238, "iMinMaxResolution", &dInt_240))
  354. GFXSPEC_pSpecification->iMinMaxResolution_50 = dInt_240;
  355. if (sub_18F3F0(&xmlnode_238, "bForce16Bit", &dInt_240)) {
  356. bool br1 = false;
  357. if (dInt_240) br1 = true;
  358. GFXSPEC_pSpecification->bForce16Bit_54 = br1;
  359. }
  360. }
  361. CGFXSpec::ApplyResolutionClamp(pXmlNode);
  362. }
  363. // 0018E878 经过单元测试,功能正常
  364. void CGFXSpec::Platform_InspectDevice() {
  365. bool bGL_OES_depth_texture_B58, bHighFloat_B60, bIsGLES3_B50;
  366. int r7_dCpuCoreCount = CFTTDevice::GetCPUCoreCount();
  367. int r0_dRendererType =
  368. g_pGraphicsDevice->GetRendererType(); // OGLES=0; OGLES3=4; Vulkan=3
  369. // 0018E8A2
  370. if (r0_dRendererType == 4) { // OGLES3
  371. // loc_18E8D0
  372. if (g_pGraphicsDevice->bGL_OES_depth_texture_D)
  373. bGL_OES_depth_texture_B58 = true;
  374. else
  375. bGL_OES_depth_texture_B58 = false;
  376. if (g_pGraphicsDevice->bHighFloat_C)
  377. bHighFloat_B60 = true;
  378. else
  379. bHighFloat_B60 = false;
  380. // loc_18E8F0
  381. bIsGLES3_B50 = true;
  382. } else if (r0_dRendererType == 3) { // 0018E8A8 Vulkan
  383. // loc_18E8E8
  384. bGL_OES_depth_texture_B58 = true;
  385. bHighFloat_B60 = true;
  386. bIsGLES3_B50 = true;
  387. } else if (r0_dRendererType != 0) {
  388. // loc_18E8F4
  389. bGL_OES_depth_texture_B58 = false;
  390. bHighFloat_B60 = false;
  391. bIsGLES3_B50 = false;
  392. } else {
  393. // 0018E8AE
  394. if (g_pGraphicsDevice->bGL_OES_depth_texture_D)
  395. bGL_OES_depth_texture_B58 = true;
  396. else
  397. bGL_OES_depth_texture_B58 = false;
  398. if (g_pGraphicsDevice->bHighFloat_C)
  399. bHighFloat_B60 = true;
  400. else
  401. bHighFloat_B60 = false;
  402. if (g_pGraphicsDevice->bIsGLES3_B)
  403. bIsGLES3_B50 = true;
  404. else
  405. bIsGLES3_B50 = false;
  406. }
  407. // loc_18E900
  408. int r5_dWidth = g_pGraphicsDevice->width(); // 0018E908
  409. int r8_dHeight = g_pGraphicsDevice->height(); // 0018E916
  410. int iRAMKb_B6C = AndroidApp_GetTotalRAMInKB(); // 0018E92A
  411. char buf_428[1024];
  412. memset(buf_428, 0, 1024);
  413. snprintf(buf_428, 1024, "Core Count: %d\n", r7_dCpuCoreCount); // 0018E93A
  414. strlcat(s_cDeviceReport, buf_428, 0x1000); // 0018E954
  415. const char *pr3 = "NO";
  416. if (bIsGLES3_B50) {
  417. pr3 = "YES";
  418. }
  419. memset(buf_428, 0, 1024);
  420. snprintf(buf_428, 1024, "GLES3: %s\n", pr3); // 0018E974
  421. strlcat(s_cDeviceReport, buf_428, 0x1000); // 0018E97E
  422. pr3 = "NO";
  423. if (bHighFloat_B60) {
  424. pr3 = "YES";
  425. }
  426. memset(buf_428, 0, 1024);
  427. snprintf(buf_428, 1024, "Highp in FS: %s\n", pr3); // 0018E994
  428. strlcat(s_cDeviceReport, buf_428, 0x1000); // 0018E99E
  429. // 0018E9A0
  430. if (r5_dWidth > r8_dHeight) r5_dWidth = r8_dHeight;
  431. memset(buf_428, 0, 1024);
  432. snprintf(buf_428, 1024, "Smaller Res: %d\n", r5_dWidth); // 0018E9B4
  433. strlcat(s_cDeviceReport, buf_428, 0x1000); // 0018E9BE
  434. memset(buf_428, 0, 1024);
  435. snprintf(buf_428, 1024, "RAM: %dKB\n", iRAMKb_B6C); // 0018E9D0
  436. strlcat(s_cDeviceReport, buf_428, 0x1000); // 0018E9DA
  437. pr3 = "NO";
  438. if (bGL_OES_depth_texture_B58) {
  439. pr3 = "YES";
  440. }
  441. memset(buf_428, 0, 1024);
  442. snprintf(buf_428, 1024, "Depth Texture Supported: %s\n", pr3); // 0018E9F0
  443. strlcat(s_cDeviceReport, buf_428, 0x1000); // 0018E9FA
  444. int dr0 = bGL_OES_depth_texture_B58 ^ 1; // 0018E9FE
  445. if (r7_dCpuCoreCount == 1) {
  446. dr0++;
  447. }
  448. int r4_dNegatives = dr0 + (bHighFloat_B60 ^ 1);
  449. if (iRAMKb_B6C < (600 * 1024)) // 0018EA0A
  450. r4_dNegatives++;
  451. if (iRAMKb_B6C < (900 * 1024)) // 0018EA1A
  452. r4_dNegatives++;
  453. if (r5_dWidth < 640) r4_dNegatives++;
  454. if (CFTTAndroidDevice::GetSDKVersion() < 20) // 0018EA30
  455. r4_dNegatives++;
  456. memset(buf_428, 0, 1024);
  457. snprintf(buf_428, 1024, "Negatives: %d\n", r4_dNegatives); // 0018EA42
  458. strlcat(s_cDeviceReport, buf_428, 0x1000); // 0018EA4C
  459. dr0 = 0;
  460. if (r7_dCpuCoreCount > 3) dr0 = 1; // 0018EA54
  461. // 0018EA56
  462. if (iRAMKb_B6C > (1536 * 1024)) dr0++;
  463. int r5_dPositives = dr0;
  464. if (dr0 < 2) r5_dPositives = 2;
  465. if (!bIsGLES3_B50) r5_dPositives = dr0;
  466. memset(buf_428, 0, 1024);
  467. snprintf(buf_428, 1024, "Positives: %d\n", r5_dPositives); // 0018EA7A
  468. strlcat(s_cDeviceReport, buf_428, 0x1000); // 0018EA84
  469. EAndroidGraphicsSettingsQuality r10_eQuality;
  470. if (r4_dNegatives >= 2) {
  471. // 0018EA8A
  472. memset(buf_428, 0, 1024);
  473. snprintf(buf_428, 1024, "AGS_QUALITY_SETTING_FAST auto-chosen\n");
  474. strlcat(s_cDeviceReport, buf_428, 0x1000);
  475. r10_eQuality = EAndroidGraphicsSettingsQuality_FAST; // 0018EAA8
  476. } else {
  477. // loc_18EAAE
  478. if (r5_dPositives >= 2 && r4_dNegatives != 1) {
  479. // 0018EAB6
  480. memset(buf_428, 0, 1024);
  481. snprintf(buf_428, 1024, "AGS_QUALITY_SETTING_HIGH auto-chosen");
  482. strlcat(s_cDeviceReport, buf_428, 0x1000);
  483. r10_eQuality = EAndroidGraphicsSettingsQuality_HIGH;
  484. } else {
  485. // loc_18EADA
  486. memset(buf_428, 0, 1024);
  487. snprintf(buf_428, 1024, "AGS_QUALITY_SETTING_BALANCED auto-chosen");
  488. strlcat(s_cDeviceReport, buf_428, 0x1000);
  489. r10_eQuality = EAndroidGraphicsSettingsQuality_BALANCED;
  490. }
  491. }
  492. // loc_18EAFC
  493. char buf_model_628[512];
  494. memset(buf_model_628, 0, 512);
  495. CFTTDevice::GetModel(buf_model_628, 512); // 0018EB06
  496. int var_92C = -1;
  497. char buf_728[256];
  498. memset(buf_728, 0, 256);
  499. CFTTAndroidDevice::GetDeviceType(buf_728, 256, false); // 0018EB1C
  500. char buf_828[256];
  501. memset(buf_828, 0, 256);
  502. CFTTAndroidDevice::GetDeviceType(buf_828, 256, true); // 0018EB2A
  503. wchar_t wgpuname_B2C[256];
  504. memset(wgpuname_B2C, 0, sizeof(wchar_t) * 256);
  505. g_pGraphicsDevice->GetGPUName(wgpuname_B2C, 256); // 0018EB3C
  506. char gpuname_928[256];
  507. memset(gpuname_928, 0, 256);
  508. UnicodeToAscii(gpuname_928, wgpuname_B2C, 256, '_'); // 0018EB4A
  509. CGPUDatabaseMode tGPUDatabase_B44;
  510. tGPUDatabase_B44.dEnabled_0 = 0;
  511. tGPUDatabase_B44.dMinSamples_4 = 5;
  512. tGPUDatabase_B44.dMetric_8 = 0;
  513. tGPUDatabase_B44.dMed_C = 1500;
  514. tGPUDatabase_B44.dHigh_10 = 3500;
  515. tGPUDatabase_B44.dVHigh_14 = 8000;
  516. EAndroidGraphicsSettingsQuality dr7;
  517. EAndroidGraphicsSettingsQuality var_B60;
  518. EAndroidGraphicsSettingsQuality r8_eQuality = STORY_GetGfxQualityOverride(
  519. buf_728, buf_828, gpuname_928, tGPUDatabase_B44);
  520. // 0018EB76
  521. if (r8_eQuality == EAndroidGraphicsSettingsQuality_FAST ||
  522. r8_eQuality == EAndroidGraphicsSettingsQuality_BALANCED ||
  523. r8_eQuality == EAndroidGraphicsSettingsQuality_HIGH) {
  524. // 0018EB84
  525. snprintf(
  526. buf_428, 1024,
  527. "Graphics quality auto choice overridden by config. Was %d, now %d.\n",
  528. r10_eQuality, r8_eQuality);
  529. strlcat(s_cDeviceReport, buf_428, 0x1000);
  530. dr7 = r8_eQuality;
  531. var_B60 = EAndroidGraphicsSettingsQuality_ERR;
  532. } else {
  533. // loc_18EBB2
  534. var_B60 = (EAndroidGraphicsSettingsQuality)
  535. CFTTAndroidGraphicsSettings::ApplyGPUDatabaseOverride(
  536. "PKG:data/x_android/gpu_db.dat", buf_model_628, tGPUDatabase_B44,
  537. r10_eQuality,
  538. var_92C); // 0018EBC2
  539. memset(buf_428, 0, 1024);
  540. // 0018EBCA
  541. if (var_92C != -1) {
  542. // 0018EBCE
  543. if (var_B60 == r10_eQuality) {
  544. // 0018EBD4
  545. snprintf(buf_428, 1024,
  546. "Graphics quality unchanged by GPU Database. Score %d, "
  547. "Quality %d.\n",
  548. var_92C, r10_eQuality);
  549. strlcat(s_cDeviceReport, buf_428, 0x1000);
  550. r8_eQuality = EAndroidGraphicsSettingsQuality_ERR;
  551. var_B60 = r10_eQuality;
  552. // MOV R7, R10
  553. dr7 = r10_eQuality;
  554. } else {
  555. // loc_18EC74
  556. snprintf(buf_428, 1024,
  557. "Graphics quality auto choice overridden by GPU Database. Was "
  558. "%d, now %d. Score=%d.\n",
  559. r10_eQuality, var_B60, var_92C);
  560. strlcat(s_cDeviceReport, buf_428, 0x1000);
  561. r8_eQuality = EAndroidGraphicsSettingsQuality_ERR;
  562. }
  563. } else {
  564. // loc_18EC00 未知设备
  565. snprintf(buf_428, 1024,
  566. "Device %s not present in Android database or insufficient "
  567. "samples.\n",
  568. buf_model_628);
  569. strlcat(s_cDeviceReport, buf_428, 0x1000);
  570. r8_eQuality = EAndroidGraphicsSettingsQuality_ERR;
  571. var_B60 = EAndroidGraphicsSettingsQuality_ERR;
  572. dr7 = r10_eQuality;
  573. }
  574. }
  575. // loc_18EC9E
  576. EAndroidGraphicsSettingsFPS r6_eFPS = EAndroidGraphicsSettingsFPS_2;
  577. GFXSPEC_pSpecification = list_Specification_323214[dr7];
  578. if (GFXSPEC_pSpecification->dFPS_0 == 30) {
  579. r6_eFPS = EAndroidGraphicsSettingsFPS_1;
  580. }
  581. CFTTAndroidGraphicsSettings::SetFPSAutoChoice(r6_eFPS); // 0018ECBE
  582. bool var_B49[5];
  583. var_B49[0] = var_B49[1] = var_B49[2] = true;
  584. var_B49[3] = dr7 > EAndroidGraphicsSettingsQuality_FAST;
  585. var_B49[4] = dr7 > EAndroidGraphicsSettingsQuality_BALANCED;
  586. CFTTAndroidGraphicsSettings::SetQualityChoice(dr7, &var_B49[0]);
  587. bool r10_bFPS = GFXSPEC_pSpecification->dFPS_0 == 30; // 0018ECFC
  588. EAndroidGraphicsSettingsQuality dUS_dr11 = (EAndroidGraphicsSettingsQuality)
  589. CFTTAndroidGraphicsSettings::GetUserSetting(
  590. EAndroidGraphicsSettingsOption_1);
  591. EAndroidGraphicsSettingsQuality dUS_dr4 = (EAndroidGraphicsSettingsQuality)
  592. CFTTAndroidGraphicsSettings::GetUserSetting(
  593. EAndroidGraphicsSettingsOption_0);
  594. EAndroidGraphicsSettingsQuality dUS_dr5 = (EAndroidGraphicsSettingsQuality)
  595. CFTTAndroidGraphicsSettings::GetUserSetting(
  596. EAndroidGraphicsSettingsOption_2);
  597. // 0018ED1C
  598. if (dUS_dr11 && dUS_dr11 != dr7) {
  599. // 0018ED28
  600. memset(buf_428, 0, 1024);
  601. snprintf(buf_428, 0x400, "User overridden quality choice. Was %d, now %d",
  602. dr7, dUS_dr11);
  603. strlcat(s_cDeviceReport, buf_428, 0x1000);
  604. GFXSPEC_pSpecification = list_Specification_323214[dUS_dr11];
  605. }
  606. // loc_18ED5A //??? eFPS 及dUS_dr4
  607. // 类型都应该没有错,但是在这儿却做了比较,暂时只能这么写了
  608. if (dUS_dr4 && dUS_dr4 != (EAndroidGraphicsSettingsQuality)r6_eFPS) {
  609. // 0018ED60
  610. memset(buf_428, 0, 1024);
  611. snprintf(buf_428, 0x400, "User overridden fps choice. Was %d, now %d",
  612. r6_eFPS, dUS_dr4);
  613. strlcat(s_cDeviceReport, buf_428, 0x1000);
  614. r10_bFPS = dUS_dr4 == EAndroidGraphicsSettingsQuality_FAST;
  615. }
  616. // loc_18ED8C
  617. int dr3 = 60;
  618. if (r10_bFPS) dr3 = 30;
  619. GFXSPEC_pSpecification->dFPS_0 = dr3;
  620. snprintf(s_cDeviceAnalyticsString, 512, "%s,%d,%d,%d,%d,%d,%d,%d",
  621. buf_model_628, r10_eQuality, r8_eQuality, var_B60, var_92C, dUS_dr11,
  622. dUS_dr4,
  623. dUS_dr5); // 0018EDC4
  624. // 0018EDD8
  625. memset(buf_428, 0, 1024);
  626. snprintf(buf_428, 0x400u, "Analytics String:%s\n", s_cDeviceAnalyticsString);
  627. strlcat(s_cDeviceReport, buf_428, 0x1000);
  628. // 0018EDE8
  629. if (!bGL_OES_depth_texture_B58) {
  630. GFXSPEC_pSpecification->bEnableDepthFog_30 = false;
  631. GFXSPEC_pSpecification->eEnableDOF_2C = 1;
  632. GFXSPEC_pSpecification->bEnableGodRays_32 = false;
  633. }
  634. // loc_18EDFE
  635. if (g_pGraphicsDevice->GetRendererType() == 0 ||
  636. g_pGraphicsDevice->GetRendererType() == 4) {
  637. // loc_18EE1A
  638. if (!g_pGraphicsDevice->field_24) {
  639. GFXSPEC_pSpecification->eEnableDOF_2C = true;
  640. GFXSPEC_pSpecification->bSoftShadows_24 = false;
  641. GFXSPEC_pSpecification->bEnableDepthFog_30 = false;
  642. GFXSPEC_pSpecification->bEnableReflection_31 = false;
  643. GFXSPEC_pSpecification->bEnableGodRays_32 = false;
  644. GFXSPEC_pSpecification->pVHSShader_38 = "2d_vhsbasic";
  645. }
  646. // loc_18EE3C &&
  647. if (g_pGraphicsDevice->bMapbuffer_9) {
  648. // 0018EE42
  649. if (g_pGraphicsDevice->field_20) {
  650. if (g_pGraphicsDevice->field_20 == 1) {
  651. GFXSPEC_pSpecification->fLODMultGame_4 = 1.8f;
  652. GFXSPEC_pSpecification->fLODMultNIS_8 = 1.2f;
  653. } else {
  654. return;
  655. }
  656. } else {
  657. // loc_18EE60
  658. GFXSPEC_pSpecification->fLODMultGame_4 = 3.0f;
  659. GFXSPEC_pSpecification->fLODMultNIS_8 = 1.5f;
  660. }
  661. } else {
  662. // loc_18EE50
  663. if (g_pGraphicsDevice->field_20) {
  664. // 0018EE52
  665. if (g_pGraphicsDevice->field_20 == 1) {
  666. // 0018EE48
  667. GFXSPEC_pSpecification->fLODMultGame_4 = 2.3f;
  668. GFXSPEC_pSpecification->fLODMultNIS_8 = 2.0f;
  669. } else {
  670. return;
  671. }
  672. } else {
  673. // loc_18EE6A
  674. GFXSPEC_pSpecification->fLODMultGame_4 = 4.3f;
  675. GFXSPEC_pSpecification->fLODMultNIS_8 = 3.0f;
  676. }
  677. }
  678. // loc_18EE70
  679. }
  680. // loc_18EE76
  681. }
  682. //-------------------------------------------------------------------------------------------------
  683. // 0018F41C //^_^
  684. void CGFXSpec::ApplyResolutionClamp(CFTTXmlReaderNode *pXmlNode) {
  685. // locret_18F4C6
  686. LOGE(" CGFXSpec::ApplyResolutionClamp%p",pXmlNode);
  687. }
  688. //-------------------------------------------------------------------------------------------------