mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -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>
353 lines
7.6 KiB
Common Lisp
353 lines
7.6 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: stats-h.gc
|
|
;; name in dgo: stats-h
|
|
;; dgos: ENGINE, GAME
|
|
|
|
(defenum perf-stat-bucket
|
|
:type uint32 ;; guess
|
|
|
|
(all-code 0)
|
|
(spatial-hash-build 1)
|
|
(spatial-hash-search 2)
|
|
(collide 3)
|
|
(collide-list 4)
|
|
(collide-fill 5)
|
|
(actor-hash 6)
|
|
(nav 7)
|
|
(nav-dma-all 8)
|
|
(nav-dma-read 9)
|
|
(nav-dma-write 10)
|
|
(nav-dma-work 11)
|
|
(nav-part1 12)
|
|
(nav-part2 13)
|
|
(nav-part3 14)
|
|
(nav-part4 15)
|
|
(nav-part5 16)
|
|
(nav-part6 17)
|
|
(nav-part7 18)
|
|
(nav-part8 19)
|
|
(nav-part9 20)
|
|
(nav-part10 21)
|
|
(add-to-translation 22)
|
|
(update-current-poly 23)
|
|
(clamp-vector-to-mesh 24)
|
|
(ray-step 25)
|
|
(update-spheres 26)
|
|
(travel-around-spheres 27)
|
|
(avoid-spheres 28)
|
|
(check-vector-collision-with-nav-spheres 29)
|
|
(find-nearest-poly 30)
|
|
(find-containing-poly 31)
|
|
(generate-velocity 32)
|
|
(apply-rotation 33)
|
|
(apply-velocity 34)
|
|
(travel-post 35)
|
|
(common-post 36)
|
|
(misc 37)
|
|
(mercneric 38)
|
|
(tie-generic 39)
|
|
(background 40)
|
|
(drawable 41)
|
|
(tfrag 42)
|
|
(tfrag-scissor 43)
|
|
(inst-shrub 44)
|
|
(proto-shrub 45)
|
|
(inst-tie 46)
|
|
(proto-tie 47)
|
|
(bones 48)
|
|
(camera 49)
|
|
(foreground 50)
|
|
)
|
|
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype tr-stat (structure)
|
|
((groups uint16)
|
|
(fragments uint16)
|
|
(tris uint32)
|
|
(dverts uint32)
|
|
(instances uint16)
|
|
(pad uint16)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-global-stats (structure)
|
|
((merc tr-stat :inline)
|
|
(emerc tr-stat :inline)
|
|
(mercneric tr-stat :inline)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype perf-stat (structure)
|
|
((frame-number uint32)
|
|
(count uint32)
|
|
(cycles uint32)
|
|
(instructions uint32)
|
|
(icache uint32)
|
|
(dcache uint32)
|
|
(select uint32)
|
|
(ctrl uint32)
|
|
(accum0 uint32)
|
|
(accum1 uint32)
|
|
(to-vu0-waits uint32)
|
|
(to-spr-waits uint32)
|
|
(from-spr-waits uint32)
|
|
)
|
|
:pack-me
|
|
(:methods
|
|
(perf-stat-method-9 () none)
|
|
(print-to-stream (_type_ string basic) none)
|
|
(reset! (_type_) none)
|
|
(read! (_type_) none)
|
|
(update-wait-stats (_type_ uint uint uint) none)
|
|
)
|
|
)
|
|
|
|
|
|
(defun-debug perf-stat-bucket->string ((arg0 perf-stat-bucket))
|
|
(case arg0
|
|
(((perf-stat-bucket collide-fill))
|
|
"collide-fill"
|
|
)
|
|
(((perf-stat-bucket nav))
|
|
"nav"
|
|
)
|
|
(((perf-stat-bucket bones))
|
|
"bones"
|
|
)
|
|
(((perf-stat-bucket foreground))
|
|
"foreground"
|
|
)
|
|
(((perf-stat-bucket inst-tie))
|
|
"inst-tie"
|
|
)
|
|
(((perf-stat-bucket common-post))
|
|
"common-post"
|
|
)
|
|
(((perf-stat-bucket nav-dma-write))
|
|
"nav-dma-write"
|
|
)
|
|
(((perf-stat-bucket collide-list))
|
|
"collide-list"
|
|
)
|
|
(((perf-stat-bucket clamp-vector-to-mesh))
|
|
"clamp-vector-to-mesh"
|
|
)
|
|
(((perf-stat-bucket nav-part3))
|
|
"nav-part3"
|
|
)
|
|
(((perf-stat-bucket mercneric))
|
|
"mercneric"
|
|
)
|
|
(((perf-stat-bucket apply-velocity))
|
|
"apply-velocity"
|
|
)
|
|
(((perf-stat-bucket tfrag-scissor))
|
|
"tfrag-scissor"
|
|
)
|
|
(((perf-stat-bucket misc))
|
|
"misc"
|
|
)
|
|
(((perf-stat-bucket find-nearest-poly))
|
|
"find-nearest-poly"
|
|
)
|
|
(((perf-stat-bucket nav-part6))
|
|
"nav-part6"
|
|
)
|
|
(((perf-stat-bucket nav-part2))
|
|
"nav-part2"
|
|
)
|
|
(((perf-stat-bucket generate-velocity))
|
|
"generate-velocity"
|
|
)
|
|
(((perf-stat-bucket inst-shrub))
|
|
"inst-shrub"
|
|
)
|
|
(((perf-stat-bucket avoid-spheres))
|
|
"avoid-spheres"
|
|
)
|
|
(((perf-stat-bucket proto-shrub))
|
|
"proto-shrub"
|
|
)
|
|
(((perf-stat-bucket drawable))
|
|
"drawable"
|
|
)
|
|
(((perf-stat-bucket nav-part9))
|
|
"nav-part9"
|
|
)
|
|
(((perf-stat-bucket all-code))
|
|
"all-code"
|
|
)
|
|
(((perf-stat-bucket actor-hash))
|
|
"actor-hash"
|
|
)
|
|
(((perf-stat-bucket nav-dma-all))
|
|
"nav-dma-all"
|
|
)
|
|
(((perf-stat-bucket travel-post))
|
|
"travel-post"
|
|
)
|
|
(((perf-stat-bucket travel-around-spheres))
|
|
"travel-around-spheres"
|
|
)
|
|
(((perf-stat-bucket nav-part10))
|
|
"nav-part10"
|
|
)
|
|
(((perf-stat-bucket nav-dma-work))
|
|
"nav-dma-work"
|
|
)
|
|
(((perf-stat-bucket proto-tie))
|
|
"proto-tie"
|
|
)
|
|
(((perf-stat-bucket nav-part4))
|
|
"nav-part4"
|
|
)
|
|
(((perf-stat-bucket ray-step))
|
|
"ray-step"
|
|
)
|
|
(((perf-stat-bucket spatial-hash-search))
|
|
"spatial-hash-search"
|
|
)
|
|
(((perf-stat-bucket apply-rotation))
|
|
"apply-rotation"
|
|
)
|
|
(((perf-stat-bucket find-containing-poly))
|
|
"find-containing-poly"
|
|
)
|
|
(((perf-stat-bucket update-spheres))
|
|
"update-spheres"
|
|
)
|
|
(((perf-stat-bucket nav-part7))
|
|
"nav-part7"
|
|
)
|
|
(((perf-stat-bucket tfrag))
|
|
"tfrag"
|
|
)
|
|
(((perf-stat-bucket collide))
|
|
"collide"
|
|
)
|
|
(((perf-stat-bucket update-current-poly))
|
|
"update-current-poly"
|
|
)
|
|
(((perf-stat-bucket nav-dma-read))
|
|
"nav-dma-read"
|
|
)
|
|
(((perf-stat-bucket spatial-hash-build))
|
|
"spatial-hash-build"
|
|
)
|
|
(((perf-stat-bucket tie-generic))
|
|
"tie-generic"
|
|
)
|
|
(((perf-stat-bucket camera))
|
|
"camera"
|
|
)
|
|
(((perf-stat-bucket background))
|
|
"background"
|
|
)
|
|
(((perf-stat-bucket nav-part5))
|
|
"nav-part5"
|
|
)
|
|
(((perf-stat-bucket nav-part1))
|
|
"nav-part1"
|
|
)
|
|
(((perf-stat-bucket check-vector-collision-with-nav-spheres))
|
|
"check-vector-collision-with-nav-spheres"
|
|
)
|
|
(((perf-stat-bucket add-to-translation))
|
|
"add-to-translation"
|
|
)
|
|
(((perf-stat-bucket nav-part8))
|
|
"nav-part8"
|
|
)
|
|
(else
|
|
"*unknown*"
|
|
)
|
|
)
|
|
)
|
|
|
|
(deftype perf-stat-array (inline-array-class)
|
|
((data perf-stat :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type perf-stat-array
|
|
(defmethod inspect perf-stat-array ((this perf-stat-array))
|
|
(when (not this)
|
|
(set! this this)
|
|
(goto cfg-4)
|
|
)
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~1Tlength: ~D~%" (-> this length))
|
|
(format #t "~1Tallocated-length: ~D~%" (-> this allocated-length))
|
|
(format #t "~1Tdata[0] @ #x~X~%" (-> this data))
|
|
(label cfg-4)
|
|
this
|
|
)
|
|
(set! (-> perf-stat-array heap-base) (the-as uint 52))
|
|
|
|
;; og:preserve-this
|
|
(define *pc-perf-stat-counter* (the-as uint 0))
|
|
|
|
(defmethod reset! ((this perf-stat))
|
|
; (let ((v1-0 (-> this ctrl)))
|
|
(+! (-> this count) 1)
|
|
(when (nonzero? (-> this ctrl))
|
|
(set! *pc-perf-stat-counter* (get-cpu-clock))
|
|
)
|
|
; (b! (zero? v1-0) cfg-2 :delay (nop!))
|
|
; (.mtc0 Perf r0)
|
|
; (.sync.l)
|
|
; (.sync.p)
|
|
; (.mtpc pcr0 r0)
|
|
; (.mtpc pcr1 r0)
|
|
; (.sync.l)
|
|
; (.sync.p)
|
|
; (.mtc0 Perf v1-0)
|
|
; )
|
|
; (.sync.l)
|
|
; (.sync.p)
|
|
; (label cfg-2)
|
|
; 0
|
|
(none)
|
|
)
|
|
|
|
|
|
(defmethod read! ((this perf-stat))
|
|
; (local-vars (v1-1 int) (v1-3 int))
|
|
; (b! (zero? (-> this ctrl)) cfg-2 :delay (nop!))
|
|
(when (nonzero? (-> this ctrl))
|
|
; (.mtc0 Perf r0)
|
|
; (.sync.l)
|
|
; (.sync.p)
|
|
; (.mfpc v1-1 pcr0)
|
|
(+! (-> this accum0) (- (get-cpu-clock) *pc-perf-stat-counter*))
|
|
; (.mfpc v1-3 pcr1)
|
|
; (+! (-> this accum1) v1-3)
|
|
(set! (-> this accum1) 0)
|
|
)
|
|
; (label cfg-2)
|
|
; 0
|
|
(none)
|
|
)
|
|
|
|
(defmethod update-wait-stats ((this perf-stat) (arg0 uint) (arg1 uint) (arg2 uint))
|
|
(when (nonzero? (-> this ctrl))
|
|
(+! (-> this to-vu0-waits) arg0)
|
|
(+! (-> this to-spr-waits) arg1)
|
|
(+! (-> this from-spr-waits) arg2)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(when (not *debug-segment*)
|
|
(set! (-> perf-stat method-table 11) nothing)
|
|
(set! (-> perf-stat method-table 12) nothing)
|
|
(set! (-> perf-stat method-table 13) nothing)
|
|
)
|