jak-project/goal_src/jak3/engine/debug/stats-h.gc
water111 b1b5cbb143
[jak3] More headers again (#3352)
joint-mod-h
collide-frag-h
projectile-h
stats-h
bsp-h
chain-physics-h
ragdoll-h
collide-hash-h
2024-02-01 18:46:54 -05:00

368 lines
7.7 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: stats-h.gc
;; name in dgo: stats-h
;; dgos: GAME
(defenum perf-stat-bucket
:type uint32 ;; guess
(all-code)
(spatial-hash-build)
(spatial-hash-search)
(collide)
(collide-list)
(collide-fill)
(actor-hash)
(nav)
(nav-dma-all)
(nav-dma-read)
(nav-dma-write)
(nav-dma-work)
(nav-part1)
(nav-part2)
(nav-part3)
(nav-part4)
(nav-part5)
(nav-part6)
(nav-part7)
(nav-part8)
(nav-part9)
(nav-part10)
(add-to-translation)
(update-current-poly)
(clamp-vector-to-mesh)
(ray-step)
(update-spheres)
(travel-around-spheres)
(avoid-spheres)
(check-vector-collision-with-nav-spheres)
(find-nearest-poly)
(find-containing-poly)
(generate-velocity)
(apply-rotation)
(apply-velocity)
(travel-post)
(common-post)
(misc)
(mercneric)
(tie-generic)
(background)
(drawable)
(tfrag)
(tfrag-scissor)
(inst-shrub)
(proto-shrub)
(inst-tie)
(proto-tie)
(bones)
(camera)
(foreground)
(hover-path)
(hover-spheres)
(hover-update)
(hover-move)
(hover-find-closest)
(update-los)
)
(define *pc-perf-stat-counter* (the-as uint 0))
;; DECOMP BEGINS
(deftype tr-stat (structure)
"triangle stats for a renderer. This can apply to a lot of different renderer types."
((groups uint16)
(fragments uint16)
(tris uint32)
(dverts uint32)
(instances uint16)
(pad uint16)
)
)
(deftype merc-global-stats (structure)
"Triangle stats for all merc renderers."
((merc tr-stat :inline)
(emerc tr-stat :inline)
(mercneric tr-stat :inline)
)
)
(deftype perf-stat (structure)
"Performance statistics for a single 'bucket' or category. Unlike the more general profile-bars,
this records statistics like cache hits/instruction counts."
((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)
(start-profiling! (_type_) none)
(stop-profiling! (_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 hover-update))
"hover-update"
)
(((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 hover-path))
"hover-path"
)
(((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 update-los))
"update-los"
)
(((perf-stat-bucket proto-tie))
"proto-tie"
)
(((perf-stat-bucket hover-move))
"hover-move"
)
(((perf-stat-bucket nav-part4))
"nav-part4"
)
(((perf-stat-bucket ray-step))
"ray-step"
)
(((perf-stat-bucket hover-find-closest))
"hover-find-closest"
)
(((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 hover-spheres))
"hover-spheres"
)
(((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)
"Array of all stats for all buckets."
((data perf-stat :inline :dynamic)
)
)
(set! (-> perf-stat-array heap-base) (the-as uint 52))
(defmethod start-profiling! ((this perf-stat))
(+! (-> this count) 1)
(when (nonzero? (-> this ctrl))
(set! *pc-perf-stat-counter* (get-cpu-clock))
)
; (let ((v1-0 (-> this ctrl)))
; (+! (-> this count) 1)
; (b! (zero? v1-0) cfg-2 :delay (nop!))
; (.mtc0 Perf 0)
; (.sync.l)
; (.sync.p)
; (.mtpc pcr0 0)
; (.mtpc pcr1 0)
; (.sync.l)
; (.sync.p)
; (.mtc0 Perf v1-0)
; )
; (.sync.l)
; (.sync.p)
; (label cfg-2)
; 0
(none)
)
(defmethod stop-profiling! ((this perf-stat))
; (local-vars (v1-1 int) (v1-3 int))
; (b! (zero? (-> this ctrl)) cfg-2 :delay (nop!))
; (.mtc0 Perf 0)
; (.sync.l)
; (.sync.p)
; (.mfpc v1-1 pcr0)
; (+! (-> this accum0) v1-1)
; (.mfpc v1-3 pcr1)
; (+! (-> this accum1) v1-3)
; (label cfg-2)
; 0
(when (nonzero? (-> this ctrl))
(+! (-> this accum0) (- (get-cpu-clock) *pc-perf-stat-counter*))
(set! (-> this accum1) 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)
)