Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global resource tracking #7191

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Global resource tracking #7191

wants to merge 2 commits into from

Conversation

glebm
Copy link
Collaborator

@glebm glebm commented Jul 14, 2024

Keeps track of all the currently loaded sprites. Can be extended in the future to also keep track of sounds.

This does introduce some overhead (timedemo goes from 6.4s to 6.9s on my machine), so we currently only enable it in debug builds.

If we ever want to revert this, it's as simple as removing all the /#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED.*?#endif/ blocks.

Screenshot from 2024-08-06 00-27-23

Sprites from the screenshot above (dev.resources.listLoaded()):

1. ctrlpan\golddrop (sprite) 14,484
2. ctrlpan\panel8bu (sprite list with 9 sprites) 8,651
3. data\charbut (sprite list with 9 sprites) 8,486
4. data\hf_logo3 (sprite list with 16 sprites) 117,457
5. data\hintbox (sprite) 411
6. data\hintboxbackground (sprite) 1,330
7. data\hinticons (sprite list with 6 sprites) 2,746
8. data\inv\inv (sprite) 74,114
9. data\inv\objcurs (sprite list with 179 sprites) 185,372
10. data\inv\objcurs2 (sprite list with 61 sprites) 52,751
11. data\optbar (sprite) 1,236
12. data\option (sprite) 571
13. data\pentspin (sprite list with 8 sprites) 6,550
14. data\pentspn2 (sprite list with 8 sprites) 782
15. data\quest (sprite) 28,542
16. data\spelicon (sprite list with 60 sprites) 136,865
17. data\spellbk (sprite) 27,980
18. data\spellbkb (sprite list with 5 sprites) 7,056
19. data\spelli2 (sprite list with 52 sprites) 66,000
20. data\square (sprite) 246
21. data\textbox (sprite) 6,080
22. data\textbox2 (sprite) 4,293
23. data\textslid (sprite list with 14 sprites) 1,396
24. fonts\12-00 (sprite list with 256 sprites) 18,407
25. fonts\22-00 (sprite list with 256 sprites) 20,320
26. items\armor2 (sprite list with 15 sprites) 11,130
27. items\axe (sprite list with 13 sprites) 4,111
28. items\bldstn (sprite list with 13 sprites) 3,232
29. items\bombs1 (sprite list with 11 sprites) 4,115
30. items\bow (sprite list with 13 sprites) 3,084
31. items\cleaver (sprite list with 13 sprites) 3,563
32. items\cows1 (sprite list with 15 sprites) 19,758
33. items\crownf (sprite list with 13 sprites) 3,468
34. items\donkys1 (sprite list with 15 sprites) 11,535
35. items\duricons (sprite list with 16 sprites) 6,766
36. items\fanvil (sprite list with 13 sprites) 7,420
37. items\fbook (sprite list with 13 sprites) 3,981
38. items\fbrain (sprite list with 12 sprites) 2,584
39. items\fbttle (sprite list with 16 sprites) 3,969
40. items\fbttlebb (sprite list with 16 sprites) 3,968
41. items\fbttlebl (sprite list with 16 sprites) 3,966
42. items\fbttlebr (sprite list with 16 sprites) 3,969
43. items\fbttleby (sprite list with 16 sprites) 3,969
44. items\fbttledb (sprite list with 16 sprites) 3,968
45. items\fbttledy (sprite list with 16 sprites) 3,967
46. items\fbttleor (sprite list with 16 sprites) 3,969
47. items\fbttlewh (sprite list with 16 sprites) 3,969
48. items\fear (sprite list with 13 sprites) 3,821
49. items\flazstaf (sprite list with 8 sprites) 3,701
50. items\fmush (sprite list with 12 sprites) 2,654
51. items\food (sprite) 343
52. items\fplatear (sprite list with 13 sprites) 6,726
53. items\goldflip (sprite list with 10 sprites) 9,872
54. items\halfps1 (sprite list with 16 sprites) 3,534
55. items\helmut (sprite list with 13 sprites) 3,464
56. items\innsign (sprite list with 13 sprites) 10,519
57. items\larmor (sprite list with 13 sprites) 6,846
58. items\mace (sprite list with 13 sprites) 4,097
59. items\mooses1 (sprite list with 15 sprites) 7,715
60. items\ring (sprite list with 13 sprites) 2,402
61. items\rock (sprite list with 20 sprites) 6,913
62. items\runes1 (sprite list with 11 sprites) 3,046
63. items\scroll (sprite list with 13 sprites) 3,121
64. items\shield (sprite list with 13 sprites) 3,338
65. items\staff (sprite list with 13 sprites) 3,570
66. items\swrdflip (sprite list with 13 sprites) 3,098
67. items\teddys1 (sprite list with 11 sprites) 3,934
68. items\wholeps1 (sprite list with 16 sprites) 4,349
69. items\wshield (sprite list with 13 sprites) 6,683
70. levels\l2data\l2s (sprite list with 6 sprites) 13,203
71. missiles\arrows (sprite list with 16 sprites) 2,229
72. missiles\bigexp (sprite list with 16 sprites) 39,038
73. missiles\bluexbk (sprite list with 19 sprites) 13,768
74. missiles\bluexfr (sprite list with 19 sprites) 21,143
75. missiles\farrow (sprite sheet with 16 lists) 11,104
76. missiles\fireba (sprite sheet with 16 lists) 118,192
77. missiles\firerun (sprite sheet with 8 lists) 114,702
78. missiles\firewal (sprite sheet with 2 lists) 80,806
79. missiles\flare (sprite list with 16 sprites) 13,659
80. missiles\flareexp (sprite list with 7 sprites) 11,761
81. missiles\guard (sprite sheet with 3 lists) 56,878
82. missiles\holy (sprite sheet with 16 lists) 112,731
83. missiles\holyexpl (sprite list with 8 sprites) 10,430
84. missiles\inferno (sprite list with 20 sprites) 30,045
85. missiles\larrow (sprite sheet with 16 lists) 11,820
86. missiles\lghning (sprite list with 8 sprites) 9,413
87. missiles\magblos (sprite list with 10 sprites) 5,251
88. missiles\manashld (sprite) 497
89. missiles\miniltng (sprite list with 8 sprites) 2,694
90. missiles\newexp (sprite list with 15 sprites) 58,037
91. missiles\portal (sprite sheet with 2 lists) 70,516
92. missiles\reflect (sprite) 652
93. missiles\ressur1 (sprite list with 16 sprites) 30,955
94. missiles\rglows1 (sprite list with 10 sprites) 2,888
95. missiles\rportal (sprite sheet with 2 lists) 64,858
96. missiles\shatter1 (sprite list with 12 sprites) 14,644
97. missiles\sklball (sprite sheet with 9 lists) 104,265
98. monsters\golem\golema (sprite sheet with 8 lists) 116,781
99. monsters\golem\golemd (sprite list with 12 sprites) 13,886
100. monsters\golem\golems (sprite list with 20 sprites) 27,657
101. monsters\golem\golemw (sprite sheet with 8 lists) 147,049
102. monsters\mega\megaa mega\vtexl (sprite sheet with 8 lists) 460,402
103. monsters\mega\megad mega\vtexl (sprite sheet with 8 lists) 747,396
104. monsters\mega\megah mega\vtexl (sprite sheet with 8 lists) 35,440
105. monsters\mega\megan mega\vtexl (sprite sheet with 8 lists) 196,575
106. monsters\mega\megas mega\vtexl (sprite sheet with 8 lists) 148,191
107. monsters\mega\megaw mega\vtexl (sprite sheet with 8 lists) 234,079
108. monsters\snake\snakea snake\snakr (sprite sheet with 8 lists) 210,851
109. monsters\snake\snaked snake\snakr (sprite sheet with 8 lists) 353,388
110. monsters\snake\snakeh snake\snakr (sprite sheet with 8 lists) 118,210
111. monsters\snake\snaken snake\snakr (sprite sheet with 8 lists) 237,981
112. monsters\snake\snakew snake\snakr (sprite sheet with 8 lists) 175,559
113. objects\barrel (sprite list with 9 sprites) 12,605
114. objects\barrelex (sprite list with 10 sprites) 22,696
115. objects\cauldren (sprite list with 3 sprites) 4,116
116. objects\chest1 (sprite list with 6 sprites) 4,585
117. objects\chest2 (sprite list with 6 sprites) 5,585
118. objects\chest3 (sprite list with 6 sprites) 8,895
119. objects\decap (sprite list with 8 sprites) 5,650
120. objects\tnudem (sprite list with 4 sprites) 5,584
121. objects\tnudew (sprite list with 3 sprites) 4,469
122. objects\tsoul (sprite list with 6 sprites) 7,014
123. plrgfx\warrior\whd\whdas (sprite sheet with 8 lists) 125,682
124. plrgfx\warrior\whd\whdat (sprite sheet with 8 lists) 197,166
125. plrgfx\warrior\whd\whdaw (sprite sheet with 8 lists) 92,856
126. plrgfx\warrior\whd\whdbl (sprite sheet with 8 lists) 25,395
127. plrgfx\warrior\whd\whdfm (sprite sheet with 8 lists) 423,063
128. plrgfx\warrior\whd\whdht (sprite sheet with 8 lists) 71,478
129. plrgfx\warrior\whd\whdlm (sprite sheet with 8 lists) 293,418
130. plrgfx\warrior\whd\whdqm (sprite sheet with 8 lists) 512,581
131. runtime\char_panel (sprite) 92,860
132. runtime\panel_button_down (sprite list with 6 sprites) 5,491
132 resources, total size: 7,187,146 bytes

@glebm glebm changed the title Global sprite storage Global sprite tracing Jul 14, 2024
@glebm glebm changed the title Global sprite tracing Global sprite tracking Jul 14, 2024
@glebm glebm marked this pull request as ready for review July 14, 2024 12:36
@glebm glebm marked this pull request as draft July 14, 2024 12:46
@glebm glebm marked this pull request as ready for review July 14, 2024 14:22
@glebm glebm enabled auto-merge (rebase) July 14, 2024 14:28
@glebm glebm force-pushed the clx-store branch 4 times, most recently from 34e83f8 to ad38d72 Compare August 5, 2024 20:59
@glebm glebm marked this pull request as draft August 5, 2024 21:03
auto-merge was automatically disabled August 5, 2024 21:03

Pull request was converted to draft

@glebm glebm force-pushed the clx-store branch 10 times, most recently from c661fb6 to eae7353 Compare August 6, 2024 08:33
glebm added a commit to glebm/devilutionX that referenced this pull request Aug 6, 2024
glebm added a commit that referenced this pull request Aug 6, 2024
Keeps track of all the currently loaded resources (currently only
sprites but can be extended to sounds).
This should eventually allow Lua to access them by name.

Not sure if name-based access to currently-loaded sprites
is something that we'll ever want (might be too unstructured),
but at least this is useful for debugging sprite issues.

If this only ends up useful for debugging, we can add a couple
of `ifdefs` to only keep track of the sprites in debug mode.
@glebm glebm marked this pull request as ready for review August 9, 2024 14:59
@glebm glebm enabled auto-merge (rebase) August 9, 2024 15:01
@glebm glebm changed the title Global sprite tracking Global resource tracking Aug 9, 2024
@glebm glebm marked this pull request as draft August 10, 2024 07:55
auto-merge was automatically disabled August 10, 2024 07:55

Pull request was converted to draft

@glebm
Copy link
Collaborator Author

glebm commented Oct 12, 2024

This is neat to have in debug builds and is easy to get rid of if we want to in the future, so I'm marking this a ready for review.

@glebm glebm marked this pull request as ready for review October 12, 2024 10:16
@glebm glebm enabled auto-merge (rebase) October 12, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant