mirror of
https://github.com/open-goal/jak-project
synced 2026-05-27 08:09:29 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
175 lines
4.2 KiB
Common Lisp
175 lines
4.2 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: memory-usage-h.gc
|
|
;; name in dgo: memory-usage-h
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
;; this file is debug only
|
|
(declare-file (debug))
|
|
|
|
;; The memory-usage system is used to track how much memory is used by tracking statistics for categories.
|
|
;; It can be used in different ways for different objects.
|
|
;; - DMA memory usage per renderer
|
|
;; - static level data memory usage
|
|
;; - actor heap memory usage
|
|
;; All basics have a mem-usage method that will add its memory usage to
|
|
;; a memory-usage-block. It also takes some flags that are currently unknown.
|
|
|
|
;; Information for a single category.
|
|
(deftype memory-usage-info (structure)
|
|
((name string)
|
|
(count int32)
|
|
(used int32)
|
|
(total int32)
|
|
)
|
|
)
|
|
|
|
;; Memory info for all categories
|
|
(deftype memory-usage-block (basic)
|
|
((work-bsp basic)
|
|
(length int32)
|
|
(data memory-usage-info 109 :inline)
|
|
)
|
|
(:methods
|
|
(reset! (_type_) _type_)
|
|
(calculate-total (_type_) int)
|
|
(print-mem-usage (_type_ level object) none)
|
|
)
|
|
)
|
|
|
|
|
|
;; The main RAM usage memory info
|
|
(define *mem-usage* (new 'debug 'memory-usage-block))
|
|
|
|
;; The DMA memory usage info
|
|
(define *dma-mem-usage* (new 'debug 'memory-usage-block))
|
|
|
|
;; Used internally for computing memory info
|
|
(define *temp-mem-usage* (the-as memory-usage-block #f))
|
|
|
|
;; TODO: flags.
|
|
;; bit 0 : count as a prototype definition.
|
|
;; bit 1 : count as an instance of a prototype.
|
|
;; bit 2 : count tie colors 1 (geom 1)
|
|
;; bit 3 : count tie colors 2 (geom 2)
|
|
;; bit 4 : ?? (geom 3)
|
|
|
|
;; Memory usage stats are organized by the type of object.
|
|
;; This enum allows you to go from type to the index in the memory-usage-block's data array.
|
|
(defenum mem-usage-id
|
|
:bitfield #f
|
|
:type uint32
|
|
(drawable-group 0)
|
|
(tfragment 1)
|
|
(tfragment-base 2)
|
|
(tfragment-common 3)
|
|
(tfragment-level0 4)
|
|
(tfragment-level1 5)
|
|
(tfragment-color 6)
|
|
(tfragment-debug 7)
|
|
(tfragment-pal 8)
|
|
(tie-fragment 9)
|
|
(tie-gif 10)
|
|
(tie-points 11)
|
|
(tie-colors 12)
|
|
(tie-draw-points 13)
|
|
(tie-debug 14)
|
|
(tie-near 15)
|
|
(tie-pal 16)
|
|
(tie-generic 17)
|
|
(instance-tie 18)
|
|
(instance-tie-colors0 19)
|
|
(instance-tie-colors1 20)
|
|
(instance-tie-colors2 21)
|
|
(instance-tie-colors3 22)
|
|
(instance-tie-colors* 23)
|
|
(prototype-bucket-shrub 24)
|
|
(generic-shrub 25)
|
|
(generic-shrub-data 26)
|
|
(shrubbery 27)
|
|
(shrubbery-object 28)
|
|
(shrubbery-vertex 29)
|
|
(shrubbery-color 30)
|
|
(shrubbery-stq 31)
|
|
(shrubbery-pal 32)
|
|
(billboard 33)
|
|
(instance-shrubbery 34)
|
|
(pris-fragment 35)
|
|
;; ??
|
|
(entity 43)
|
|
(camera 44)
|
|
(nav-mesh 45)
|
|
;; ??
|
|
(res 48)
|
|
(ambient 49)
|
|
(collide-fragment-0 50)
|
|
(collision-poly-0 51)
|
|
(collision-vertex-0 52)
|
|
(collide-fragment-1 53)
|
|
(collision-poly-1 54)
|
|
(collision-vertex-1 55)
|
|
(bsp-main 56)
|
|
(bsp-misc 57)
|
|
(bsp-node 58)
|
|
(bsp-leaf-vis-self 59)
|
|
(bsp-leaf-vis-adj 60)
|
|
(draw-node 61)
|
|
(pat 62)
|
|
(level-code 63)
|
|
(entity-links 64) ;; or ambient links, its messed up
|
|
(joint 65)
|
|
(joint-anim-compressed 66)
|
|
(joint-anim-compressed-control 67)
|
|
(joint-anim-fixed 68)
|
|
(joint-anim-frame 69)
|
|
(art-group 70)
|
|
(art-mesh-anim 71)
|
|
(art-mesh-geo 72)
|
|
(art-joint-geo 73)
|
|
(art-joint-anim 74)
|
|
(merc-ctrl 75)
|
|
(joint-anim-drawable 76)
|
|
(blend-shape 77)
|
|
(collide-mesh 78)
|
|
(texture 79)
|
|
(string 80)
|
|
(array 81)
|
|
(sprite 82)
|
|
(depth-cue 83)
|
|
(debug-dma 84) ;; maybe
|
|
(sky-dma 85) ;; maybe
|
|
(pris-generic)
|
|
(4k-dead-pool 87)
|
|
(8k-dead-pool 88)
|
|
(16k-dead-pool 89)
|
|
(nk-dead-pool 90)
|
|
(target-dead-pool 91)
|
|
(camera-dead-pool 92)
|
|
(debug-dead-pool 93)
|
|
(process-active 94)
|
|
(heap-total 95)
|
|
(heap-process 96)
|
|
(heap-header 97)
|
|
(heap-thread 98)
|
|
(heap-root 99)
|
|
(heap-draw-control 100)
|
|
(heap-joint-control 101)
|
|
(heap-cspace 102)
|
|
(heap-bone 103)
|
|
(heap-part 104)
|
|
(heap-collide-prim 105)
|
|
(heap-misc 106)
|
|
(shadow-geo 107)
|
|
(eye-anim 108)
|
|
)
|
|
|
|
;; get a memory usage id as an integer.
|
|
(defmacro mem-usage-id-int (kind)
|
|
`(the int (mem-usage-id ,kind))
|
|
)
|
|
|
|
(defun-extern mem-size basic symbol int int)
|