diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 854301d324..ea491a2dba 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -10904,6 +10904,28 @@ (debug 88) + (other-pool 91) + (8k-dead-pool 92) + (16k-dead-pool 93) + (nk-dead-pool 94) + (target-dead-pool 95) + (camera-dead-pool 96) + (debug-dead-pool 97) + + (process-active 98) + (heap-total 99) + (heap-process 100) + (heap-header 101) + (head-thread 102) + (heap-root 103) + (heap-draw-control 104) + (heap-joint-control 105) + (heap-cspace 106) + (heap-bone 107) + (heap-part 108) + (heap-collide-prim 109) + (heap-mis 110) + (eye-anim 112) ) @@ -37429,7 +37451,7 @@ ;; memory-usage-block is already defined! (define-extern mem-size (function basic symbol int int)) -;; (define-extern *max-dma* object) ;; int +(define-extern *max-dma* int) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; entity ;; diff --git a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc index 52405d4c07..6ddd10cdc2 100644 --- a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc @@ -209,5 +209,9 @@ [8, "(function string object :behavior process)"], [12, "(function object :behavior target)"] ], - "gun-yellow-shot": [[59, "(function handle object :behavior process)"]] + "gun-yellow-shot": [[59, "(function handle object :behavior process)"]], + "memory-usage": [ + [2, "(function process-drawable symbol)"], + [3, "(function basic symbol)"] + ] } diff --git a/decompiler/config/jak3/ntsc_v1/inputs.jsonc b/decompiler/config/jak3/ntsc_v1/inputs.jsonc index ca35bc6117..dad6fb044e 100644 --- a/decompiler/config/jak3/ntsc_v1/inputs.jsonc +++ b/decompiler/config/jak3/ntsc_v1/inputs.jsonc @@ -188,7 +188,7 @@ // "DGO/DESC.DGO", // "DGO/LDAMPECK.DGO", // "DGO/LJAKSIG.DGO", - "DGO/HALFPIPE.DGO" + "DGO/HALFPIPE.DGO", // "DGO/DESRACE1.DGO", // "DGO/SEN.DGO", // "DGO/TEMP.DGO", @@ -260,7 +260,7 @@ // "DGO/WASPALA.DGO", // "DGO/LJAKNDAX.DGO", // "DGO/WASSEEM.DGO", - // "DGO/WASALL.DGO", + "DGO/WASALL.DGO" // "DGO/WCASEEM.DGO", // "DGO/LSIG.DGO", // "DGO/LFACTORY.DGO", diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index 574e670fd6..5db1093120 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -3567,5 +3567,11 @@ ], "command-get-int": [ [17, "gp", "bfloat"] - ] + ], + "(anon-function 2 memory-usage)": [[211, "v1", "collide-shape-moving"]], + "(method 8 process-tree)": [ + [33, "v1", "symbol"] + // [6, "a3", "symbol"] + ], + "(method 11 memory-usage-block)": [[112, "v1", "int"]] } diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 403ff3eea9..87c18f2516 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -143,10 +143,16 @@ void OpenGLRenderer::init_bucket_renderers_jak3() { // 10 for (int i = 0; i < LEVEL_MAX; i++) { #define GET_BUCKET_ID_FOR_LIST(bkt1, bkt2, idx) ((int)(bkt1) + ((int)(bkt2) - (int)(bkt1)) * (idx)) + // 10 init_bucket_renderer( fmt::format("tex-l{}-tfrag", i), BucketCategory::TEX, GET_BUCKET_ID_FOR_LIST(BucketId::TEX_L0_TFRAG, BucketId::TEX_L1_TFRAG, i), texture_animator); + // 11 + init_bucket_renderer( + fmt::format("tfrag-l{}-tfrag", i), BucketCategory::TFRAG, + GET_BUCKET_ID_FOR_LIST(BucketId::TFRAG_L0_TFRAG, BucketId::TFRAG_L1_TFRAG, i), + std::vector{tfrag3::TFragmentTreeKind::NORMAL}, false, i, anim_slot_array()); } // 340 @@ -175,10 +181,16 @@ void OpenGLRenderer::init_bucket_renderers_jak3() { // 463 for (int i = 0; i < LEVEL_MAX; i++) { #define GET_BUCKET_ID_FOR_LIST(bkt1, bkt2, idx) ((int)(bkt1) + ((int)(bkt2) - (int)(bkt1)) * (idx)) + // 463 init_bucket_renderer( fmt::format("tex-l{}-water", i), BucketCategory::TEX, GET_BUCKET_ID_FOR_LIST(BucketId::TEX_L0_WATER, BucketId::TEX_L1_WATER, i), texture_animator); + // 466 + init_bucket_renderer( + fmt::format("tfrag-l{}-water", i), BucketCategory::TFRAG, + GET_BUCKET_ID_FOR_LIST(BucketId::TFRAG_L0_WATER, BucketId::TFRAG_L1_WATER, i), + std::vector{tfrag3::TFragmentTreeKind::WATER}, false, i, anim_slot_array()); } // 563 @@ -200,8 +212,7 @@ void OpenGLRenderer::init_bucket_renderers_jak3() { // BucketId::TEX_HUD_HUD_ALPHA, texture_animator); // 583 - init_bucket_renderer("debug", BucketCategory::OTHER, - BucketId::DEBUG, 0x8000); + init_bucket_renderer("debug", BucketCategory::OTHER, BucketId::DEBUG, 0x8000); // 584 init_bucket_renderer("debug-no-zbuf2", BucketCategory::OTHER, BucketId::DEBUG_NO_ZBUF2, 0x8000); diff --git a/game/graphics/opengl_renderer/background/TFragment.cpp b/game/graphics/opengl_renderer/background/TFragment.cpp index a4efc78286..73260e0d65 100644 --- a/game/graphics/opengl_renderer/background/TFragment.cpp +++ b/game/graphics/opengl_renderer/background/TFragment.cpp @@ -99,7 +99,6 @@ void TFragment::render(DmaFollower& dma, if (m_my_id == render_state->bucket_for_vis_copy && dma.current_tag_vifcode1().kind == VifCode::Kind::PC_PORT) { DmaTransfer transfers[20]; - for (int i = 0; i < render_state->num_vis_to_copy; i++) { transfers[i] = dma.read_and_advance(); auto next0 = dma.read_and_advance(); diff --git a/game/graphics/opengl_renderer/buckets.h b/game/graphics/opengl_renderer/buckets.h index c858690bce..bff243fddb 100644 --- a/game/graphics/opengl_renderer/buckets.h +++ b/game/graphics/opengl_renderer/buckets.h @@ -419,8 +419,10 @@ enum class BucketId { TEX_LCOM_SKY_PRE = 4, TEX_L0_TFRAG = 10, + TFRAG_L0_TFRAG = 11, TEX_L1_TFRAG = 22, + TFRAG_L1_TFRAG = 23, TEX_LCOM_TFRAG = 340, @@ -436,8 +438,12 @@ enum class BucketId { TEX_L0_WATER = 463, + TFRAG_L0_WATER = 466, + TEX_L1_WATER = 473, + TFRAG_L1_WATER = 476, + TEX_LCOM_WATER = 563, TEX_SPRITE = 568, diff --git a/goal_src/jak3/engine/debug/memory-usage.gc b/goal_src/jak3/engine/debug/memory-usage.gc index 6f485c785d..57b603b9f7 100644 --- a/goal_src/jak3/engine/debug/memory-usage.gc +++ b/goal_src/jak3/engine/debug/memory-usage.gc @@ -7,3 +7,568 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + + +(defmethod mem-usage ((this object) (usage memory-usage-block) (flags int)) + this + ) + +(defmethod calculate-total ((this memory-usage-block)) + (let ((v0-0 0)) + (dotimes (v1-0 (-> this length)) + (+! v0-0 (-> this data v1-0 total)) + ) + v0-0 + ) + ) + +(defmethod reset! ((this memory-usage-block)) + (set! (-> this length) 0) + (dotimes (v1-0 113) + (set! (-> this data v1-0 used) 0) + (set! (-> this data v1-0 total) 0) + (set! (-> this data v1-0 count) 0) + ) + this + ) + +(defun mem-size ((arg0 basic) (arg1 symbol) (arg2 int)) + (let ((gp-0 (new 'stack 'memory-usage-block))) + (mem-usage arg0 gp-0 arg2) + (if arg1 + (inspect gp-0) + ) + (calculate-total gp-0) + ) + ) + +(defmethod compute-memory-usage! ((this level) (arg0 symbol)) + (if (zero? (-> this mem-usage-block)) + (set! (-> this mem-usage-block) (new 'debug 'memory-usage-block)) + ) + (set! arg0 (or (zero? (-> this mem-usage-block length)) arg0)) + (when arg0 + (mem-usage this (reset! (-> this mem-usage-block)) 0) + (set! (-> this mem-usage) (calculate-total (-> this mem-usage-block))) + 0 + ) + (-> this mem-usage-block) + ) + +(defmethod mem-usage ((this process-tree) (usage memory-usage-block) (flags int)) + (let ((s3-0 91)) + (let* ((s2-0 *dead-pool-list*) + (a0-1 (car s2-0)) + ) + (while (not (null? s2-0)) + (set! (-> usage data s3-0 name) (symbol->string-debug (the-as symbol a0-1))) + (+! s3-0 1) + (set! s2-0 (cdr s2-0)) + (set! a0-1 (car s2-0)) + ) + ) + (set! (-> usage length) (max (-> usage length) s3-0)) + ) + (set! (-> usage data 97 name) "*debug-dead-pool*") + (set! *temp-mem-usage* usage) + (when (logtest? flags 32) + (let* ((s5-1 91) + (s4-1 *dead-pool-list*) + (v1-10 (car s4-1)) + ) + (while (not (null? s4-1)) + (let ((a0-4 (-> (the-as symbol v1-10) value))) + (set! *global-search-count* s5-1) + (iterate-process-tree + (the-as process-tree a0-4) + (lambda ((arg0 basic)) + (let ((gp-0 *temp-mem-usage*) + (s5-0 *global-search-count*) + ) + (+! (-> gp-0 data s5-0 used) 1) + (+! (-> gp-0 data s5-0 total) (logand -16 (+ (asize-of arg0) 15))) + ) + #t + ) + *null-kernel-context* + ) + ) + (+! s5-1 1) + (set! s4-1 (cdr s4-1)) + (set! v1-10 (car s4-1)) + ) + ) + ) + (iterate-process-tree + this + (lambda ((arg0 process-drawable)) + (let ((gp-0 *temp-mem-usage*)) + (let ((s4-0 (cond + ((= (-> arg0 pool) *8k-dead-pool*) + 92 + ) + ((= (-> arg0 pool) *16k-dead-pool*) + 93 + ) + ((= (-> arg0 pool) *nk-dead-pool*) + 94 + ) + ((= (-> arg0 pool) *target-dead-pool*) + 95 + ) + ((= (-> arg0 pool) *camera-dead-pool*) + 96 + ) + ((= (-> arg0 pool) *debug-dead-pool*) + 97 + ) + (else + 91 + ) + ) + ) + ) + (+! (-> gp-0 data s4-0 count) 1) + (+! (-> gp-0 data s4-0 total) (logand -16 (+ (asize-of arg0) 15))) + ) + (set! (-> gp-0 length) (max 99 (-> gp-0 length))) + (set! (-> gp-0 data 98 name) "process-active") + (+! (-> gp-0 data 98 count) 1) + (let ((v1-23 (asize-of arg0))) + (+! (-> gp-0 data 98 used) v1-23) + (+! (-> gp-0 data 98 total) (logand -16 (+ v1-23 15))) + ) + (set! (-> gp-0 length) (max 100 (-> gp-0 length))) + (set! (-> gp-0 data 99 name) "heap-total") + (+! (-> gp-0 data 99 count) 1) + (let ((v1-34 (+ (- -4 (the-as int arg0)) (the-as int (-> arg0 heap-cur))))) + (+! (-> gp-0 data 99 used) v1-34) + (+! (-> gp-0 data 99 total) (logand -16 (+ v1-34 15))) + ) + (set! (-> gp-0 length) (max 101 (-> gp-0 length))) + (set! (-> gp-0 data 100 name) "heap-process") + (+! (-> gp-0 data 100 count) 1) + (let ((v1-45 (- (-> arg0 type size) (-> arg0 type heap-base)))) + (+! (-> gp-0 data 100 used) v1-45) + (+! (-> gp-0 data 100 total) (logand -16 (+ v1-45 15))) + ) + (set! (-> gp-0 length) (max 102 (-> gp-0 length))) + (set! (-> gp-0 data 101 name) "heap-header") + (+! (-> gp-0 data 101 count) 1) + (let ((v1-55 (-> arg0 type heap-base))) + (+! (-> gp-0 data 101 used) v1-55) + (+! (-> gp-0 data 101 total) (logand -16 (+ v1-55 15))) + ) + (set! (-> gp-0 length) (max 103 (-> gp-0 length))) + (set! (-> gp-0 data 102 name) "heap-thread") + (+! (-> gp-0 data 102 count) 1) + (let ((v1-65 (asize-of (-> arg0 main-thread)))) + (+! (-> gp-0 data 102 used) v1-65) + (+! (-> gp-0 data 102 total) (logand -16 (+ v1-65 15))) + ) + (when (type? arg0 process-drawable) + (when (nonzero? (-> arg0 root)) + (set! (-> gp-0 length) (max 104 (-> gp-0 length))) + (set! (-> gp-0 data 103 name) "heap-root") + (+! (-> gp-0 data 103 count) 1) + (let ((v1-78 (asize-of (-> arg0 root)))) + (+! (-> gp-0 data 103 used) v1-78) + (+! (-> gp-0 data 103 total) (logand -16 (+ v1-78 15))) + ) + (when (type? (-> arg0 root) collide-shape) + (set! (-> gp-0 length) (max 110 (-> gp-0 length))) + (set! (-> gp-0 data 109 name) "heap-collide-prim") + (+! (-> gp-0 data 109 count) 1) + (let ((v1-90 (asize-of (-> (the-as collide-shape-moving (-> arg0 root)) root-prim)))) + (+! (-> gp-0 data 109 used) v1-90) + (+! (-> gp-0 data 109 total) (logand -16 (+ v1-90 15))) + ) + ) + ) + (when (nonzero? (-> arg0 node-list)) + (set! (-> gp-0 length) (max 107 (-> gp-0 length))) + (set! (-> gp-0 data 106 name) "heap-cspace") + (+! (-> gp-0 data 106 count) 1) + (let ((v1-102 (asize-of (-> arg0 node-list)))) + (+! (-> gp-0 data 106 used) v1-102) + (+! (-> gp-0 data 106 total) (logand -16 (+ v1-102 15))) + ) + ) + (when (nonzero? (-> arg0 draw)) + (set! (-> gp-0 length) (max 105 (-> gp-0 length))) + (set! (-> gp-0 data 104 name) "heap-draw-control") + (+! (-> gp-0 data 104 count) 1) + (let ((v1-114 (asize-of (-> arg0 draw)))) + (+! (-> gp-0 data 104 used) v1-114) + (+! (-> gp-0 data 104 total) (logand -16 (+ v1-114 15))) + ) + (when (nonzero? (-> arg0 draw skeleton)) + (set! (-> gp-0 length) (max 108 (-> gp-0 length))) + (set! (-> gp-0 data 107 name) "heap-bone") + (+! (-> gp-0 data 107 count) 1) + (let ((v1-128 (asize-of (-> arg0 draw skeleton)))) + (+! (-> gp-0 data 107 used) v1-128) + (+! (-> gp-0 data 107 total) (logand -16 (+ v1-128 15))) + ) + ) + ) + (when (nonzero? (-> arg0 skel)) + (set! (-> gp-0 length) (max 106 (-> gp-0 length))) + (set! (-> gp-0 data 105 name) "heap-joint-control") + (+! (-> gp-0 data 105 count) 1) + (let ((v1-140 (asize-of (-> arg0 skel)))) + (+! (-> gp-0 data 105 used) v1-140) + (+! (-> gp-0 data 105 total) (logand -16 (+ v1-140 15))) + ) + ) + (when (nonzero? (-> arg0 part)) + (set! (-> gp-0 length) (max 109 (-> gp-0 length))) + (set! (-> gp-0 data 108 name) "heap-part") + (+! (-> gp-0 data 108 count) 1) + (let ((v1-152 (asize-of (-> arg0 part)))) + (+! (-> gp-0 data 108 used) v1-152) + (+! (-> gp-0 data 108 total) (logand -16 (+ v1-152 15))) + ) + ) + (when (nonzero? (-> arg0 nav)) + (set! (-> gp-0 length) (max 111 (-> gp-0 length))) + (set! (-> gp-0 data 110 name) "heap-misc") + (+! (-> gp-0 data 110 count) 1) + (let ((v1-164 (asize-of (-> arg0 nav)))) + (+! (-> gp-0 data 110 used) v1-164) + (+! (-> gp-0 data 110 total) (logand -16 (+ v1-164 15))) + ) + ) + (when (nonzero? (-> arg0 path)) + (set! (-> gp-0 length) (max 111 (-> gp-0 length))) + (set! (-> gp-0 data 110 name) "heap-misc") + (+! (-> gp-0 data 110 count) 1) + (let ((v1-176 (asize-of (-> arg0 path)))) + (+! (-> gp-0 data 110 used) v1-176) + (+! (-> gp-0 data 110 total) (logand -16 (+ v1-176 15))) + ) + ) + (when (nonzero? (-> arg0 vol)) + (set! (-> gp-0 length) (max 111 (-> gp-0 length))) + (set! (-> gp-0 data 110 name) "heap-misc") + (+! (-> gp-0 data 110 count) 1) + (let ((v1-188 (asize-of (-> arg0 vol)))) + (+! (-> gp-0 data 110 used) v1-188) + (+! (-> gp-0 data 110 total) (logand -16 (+ v1-188 15))) + ) + ) + ) + ) + #t + ) + *null-kernel-context* + ) + this + ) + +(define *max-dma* 0) + +(defmethod print-mem-usage ((this memory-usage-block) (arg0 level) (arg1 object)) + (local-vars (sv-16 object) (sv-32 string) (sv-48 symbol)) + (let ((s3-0 (&- (-> arg0 heap current) (the-as uint (-> arg0 heap base))))) + (let ((v1-2 (+ (-> this data 62 total) (-> this data 63 total)))) + (< #x10000 v1-2) + ) + (let* ((v1-4 (-> arg0 info memory-mode)) + (v1-5 + (cond + ((= v1-4 (level-memory-mode large)) + #xbd0000 + ) + ((= v1-4 (level-memory-mode medium)) + #x8fb800 + ) + ((or (= v1-4 (level-memory-mode small-center)) (= v1-4 (level-memory-mode city-center))) + #x627000 + ) + ((or (= v1-4 (level-memory-mode borrow)) + (= v1-4 (level-memory-mode borrow0)) + (= v1-4 (level-memory-mode borrow1)) + (= v1-4 (level-memory-mode borrow2)) + (= v1-4 (level-memory-mode borrow3)) + (= v1-4 (level-memory-mode borrow4)) + (= v1-4 (level-memory-mode borrow-city-small)) + ) + (+ (- #xc000 (the-as int (-> arg0 heap base))) (the-as int (-> arg0 heap top-base))) + ) + ((or (= v1-4 (level-memory-mode tiny-center)) + (= v1-4 (level-memory-mode tiny-edge)) + (= v1-4 (level-memory-mode city-tiny-edge)) + (= v1-4 (level-memory-mode tiny)) + ) + #x3f0000 + ) + ((= v1-4 (level-memory-mode micro)) + #x1f8000 + ) + ((= v1-4 (level-memory-mode tiny-center-micro)) + #x2f4000 + ) + ((= v1-4 (level-memory-mode tiny-center-small)) + #x4ec000 + ) + (else + #x5e8000 + ) + ) + ) + (a0-25 (-> arg0 info memory-mode)) + (v1-8 + (- (the-as int v1-5) + (the-as + uint + (if (or (= a0-25 (level-memory-mode tiny-center)) (or (= a0-25 (level-memory-mode tiny-edge)) + (= a0-25 (level-memory-mode city-tiny-edge)) + (= a0-25 (level-memory-mode tiny)) + ) + ) + #x24000 + #xc000 + ) + ) + ) + ) + (a0-28 0) + ) + (when (-> arg0 info borrow) + (dotimes (a1-21 5) + (+! a0-28 (-> arg0 info borrow borrow-size a1-21)) + ) + ) + (let ((s1-0 (- v1-8 (shl a0-28 10))) + (s2-0 (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16)) + ) + (set! *max-dma* (max s2-0 *max-dma*)) + (if (< (- s1-0 (the-as int (shl (-> arg0 info buffer-size) 10))) s3-0) + (format arg1 "~3L") + ) + (let ((s0-0 format)) + (set! sv-16 arg1) + (set! sv-32 "~0K~10,'-S--~5,'-DK-of-~5,'-DK--~5,'-DK-of-~5,'-DK--") + (set! sv-48 (-> arg0 name)) + (let* ((s3-1 (sar s3-0 10)) + (s4-1 (- (sar s1-0 10) (the-as int (-> arg0 info buffer-size)))) + (s1-1 (sar (memory-used *nk-dead-pool*) 10)) + (t2-0 (sar (memory-total *nk-dead-pool*) 10)) + (t0-0 s4-1) + (t1-0 s1-1) + ) + (s0-0 sv-16 sv-32 sv-48 s3-1 t0-0 t1-0 t2-0) + (format arg1 "~5,'-DK/~5,'-DK--~%" (shr s2-0 10) (sar *max-dma* 10)) + (when *stats-memory-short* + (let ((s3-2 (if (cpad-hold? 1 l3) + #t + arg1 + ) + ) + (s4-2 format) + (s2-1 "heap-~5,'-DK/~5,'-DK----~D---~D/~D~%") + (s1-2 (sar (memory-used *nk-dead-pool*) 10)) + (s0-1 (sar (memory-total *nk-dead-pool*) 10)) + ) + (set! t0-0 (the-as int (compact-time *nk-dead-pool*))) + (set! t1-0 (the-as int (-> *nk-dead-pool* compact-count))) + (set! t2-0 (the-as int (-> *nk-dead-pool* compact-count-targ))) + (s4-2 s3-2 s2-1 s1-2 s0-1 (the-as uint t0-0) (the-as uint t1-0) (the-as uint t2-0)) + ) + ) + (when (not *stats-memory-short*) + (set! (-> *dma-mem-usage* data 88 total) + (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) debug-buf)) 16) + ) + (let ((t9-11 format) + (a0-47 arg1) + (a1-28 " bsp ~192H~5DK ~280Hdebug~456H~5DK~%") + (a2-12 (sar (+ (-> this data 59 total) (-> this data 60 total) (-> this data 61 total)) 10)) + (a3-5 (sar (-> *dma-mem-usage* data 88 total) 10)) + ) + (t9-11 a0-47 a1-28 a2-12 a3-5 (the-as none t0-0) (the-as none t1-0) (the-as none t2-0)) + (format + arg1 + " bsp-leaf-vis ~192H~5DK~%" + (sar (+ (-> this data 62 total) (-> this data 63 total)) 10) + (the-as none a3-5) + ) + (format arg1 " level-code ~192H~5DK~%" (sar (-> this data 66 total) 10) (the-as none a3-5)) + ) + (format + arg1 + " tfrag ~192H~5DK ~280Htfragment~456H~5DK~%" + (sar + (+ (-> this data 1 total) + (-> this data 2 total) + (-> this data 3 total) + (-> this data 4 total) + (-> this data 5 total) + (-> this data 6 total) + (-> this data 7 total) + (-> this data 8 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 1 total) 10) + ) + (format + arg1 + " tie-proto ~192H~5DK ~280Hsky~456H~5DK~%" + (sar + (+ (-> this data 9 total) + (-> this data 10 total) + (-> this data 11 total) + (-> this data 12 total) + (-> this data 13 total) + (-> this data 14 total) + (-> this data 16 total) + (-> this data 17 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 89 total) 10) + ) + (format + arg1 + " tie-instance ~192H~5DK ~280Htie-fragment~456H~5DK~%" + (sar (+ (-> this data 18 total) (-> this data 20 total) (-> this data 21 total) (-> this data 22 total)) 10) + (sar (-> *dma-mem-usage* data 9 total) 10) + ) + (format + arg1 + " shrub-proto ~192H~5DK ~280Htie-scissor~456H~5DK~%" + (sar + (+ (-> this data 25 total) + (-> this data 26 total) + (-> this data 27 total) + (-> this data 28 total) + (-> this data 29 total) + (-> this data 30 total) + (-> this data 31 total) + (-> this data 32 total) + (-> this data 33 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 15 total) 10) + ) + (format + arg1 + " shrub-instance ~192H~5DK ~280Hshrubbery~456H~5DK~%" + (sar (-> this data 34 total) 10) + (sar (-> *dma-mem-usage* data 27 total) 10) + ) + (format + arg1 + " hfragment ~192H~5DK ~280Hhfragment~456H~5DK~%" + (sar (-> this data 43 total) 10) + (sar (-> *dma-mem-usage* data 43 total) 10) + (the-as none t0-0) + (the-as none t1-0) + (the-as none t2-0) + ) + (format + arg1 + " collision ~192H~5DK ~280Htie-generic~456H~5DK~%" + (sar + (+ (-> this data 51 total) + (-> this data 52 total) + (-> this data 53 total) + (-> this data 54 total) + (-> this data 55 total) + (-> this data 56 total) + (-> this data 57 total) + (-> this data 58 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 17 total) 10) + ) + (format + arg1 + " pris-geo ~192H~5DK ~280Hpris-fragment~456H~5DK~%" + (sar + (+ (-> this data 35 total) + (-> this data 36 total) + (-> this data 37 total) + (-> this data 38 total) + (-> this data 39 total) + (-> this data 40 total) + (-> this data 41 total) + (-> this data 42 total) + (-> this data 74 total) + (-> this data 75 total) + (-> this data 76 total) + (-> this data 77 total) + (-> this data 79 total) + (-> this data 82 total) + (-> this data 81 total) + (-> this data 112 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 35 total) 10) + ) + (format + arg1 + " pris-anim ~192H~5DK ~280Hpris-generic~456H~5DK~%" + (sar + (+ (-> this data 68 total) + (-> this data 69 total) + (-> this data 70 total) + (-> this data 71 total) + (-> this data 72 total) + (-> this data 78 total) + (-> this data 80 total) + (-> this data 73 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 90 total) 10) + ) + (format + arg1 + " textures ~192H~5DK ~280Htextures~456H~5DK~%" + (sar (-> this data 83 total) 10) + (sar (-> *dma-mem-usage* data 83 total) 10) + ) + (format arg1 " entity ~192H~5DK~%" (sar + (+ (-> this data 67 total) + (-> this data 44 total) + (-> this data 45 total) + (-> this data 46 total) + (-> this data 50 total) + (-> this data 49 total) + (-> this data 47 total) + (-> this data 48 total) + ) + 10 + ) + ) + (format + arg1 + " misc ~192H~5DK ~280Hsprite~456H~5DK~%" + (sar + (+ (-> this data 0 total) + (-> this data 64 total) + (-> this data 65 total) + (-> this data 84 total) + (-> this data 85 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 86 total) 10) + ) + ) + ) + ) + ) + ) + ) + (format arg1 "~1K~0L") + this + ) diff --git a/goal_src/jak3/engine/dma/dma-buffer.gc b/goal_src/jak3/engine/dma/dma-buffer.gc index c8afef49f7..8786f2a2f6 100644 --- a/goal_src/jak3/engine/dma/dma-buffer.gc +++ b/goal_src/jak3/engine/dma/dma-buffer.gc @@ -297,7 +297,7 @@ (let ((,bucket-edge (the (pointer dma-tag) (-> ,buf base)))) ;; if nothing was added, skip the tag entirely. - (when (!= ,bucket-edge ,buf-start) + ;;(when (!= ,bucket-edge ,buf-start) (let ((,pkt (the-as dma-packet (-> ,buf base)))) (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id next))) @@ -311,7 +311,7 @@ ,buf-start ;; the first thing in this chain, bucket will patch previous to this ,bucket-edge ;; end of this chain (ptr to next tag) ) - ) + ;; ) ) ) ) diff --git a/goal_src/jak3/engine/draw/drawable.gc b/goal_src/jak3/engine/draw/drawable.gc index d42bd48ca1..41c08ef982 100644 --- a/goal_src/jak3/engine/draw/drawable.gc +++ b/goal_src/jak3/engine/draw/drawable.gc @@ -192,7 +192,7 @@ (when (sphere-cull (-> arg0 bsphere)) (add-debug-sphere #t - (bucket-id bucket583) + (bucket-id debug) (-> arg0 bsphere) (-> arg0 bsphere w) (new 'static 'rgba :r #x80 :a #x80) @@ -1493,103 +1493,103 @@ (reset! *dma-mem-usage*) ) - ;; reset foreground - (foreground-initialize-engines) - (reset! *prim-work*) + ; ;; reset foreground + ; (foreground-initialize-engines) + ; (reset! *prim-work*) - ;; update wind/time of day prior to drawing. - (let ((gp-2 (-> pp clock))) - (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) - (set! (-> pp clock) (-> *display* bg-clock)) - (set! (-> pp clock) (-> *display* real-clock)) - ) - (if (not (paused?)) - (update-wind *wind-work* *wind-scales*) - ) - (update-time-of-day *time-of-day-context*) - (set! (-> pp clock) gp-2) - ) + ; ;; update wind/time of day prior to drawing. + ; (let ((gp-2 (-> pp clock))) + ; (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + ; (set! (-> pp clock) (-> *display* bg-clock)) + ; (set! (-> pp clock) (-> *display* real-clock)) + ; ) + ; (if (not (paused?)) + ; (update-wind *wind-work* *wind-scales*) + ; ) + ; (update-time-of-day *time-of-day-context*) + ; (set! (-> pp clock) gp-2) + ; ) - ;; draw sky - (with-profiler 'sky *profile-sky-color* - (if (-> *sky-work* draw-vortex) - (draw-vortex) - (draw *sky-work*) - ) - (flush-cache 0) - ) + ; ;; draw sky + ; (with-profiler 'sky *profile-sky-color* + ; (if (-> *sky-work* draw-vortex) + ; (draw-vortex) + ; (draw *sky-work*) + ; ) + ; (flush-cache 0) + ; ) - ;; draw ocean - (let ((gp-5 (-> pp clock))) - (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) - (set! (-> pp clock) (-> *display* bg-clock)) - (set! (-> pp clock) (-> *display* real-clock)) - ) - (with-profiler 'ocean *profile-ocean-color* - (draw! *ocean*) - (if *ocean-map* - (update-map *ocean*) - ) - ) - (set! (-> pp clock) gp-5) - ) + ; ;; draw ocean + ; (let ((gp-5 (-> pp clock))) + ; (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + ; (set! (-> pp clock) (-> *display* bg-clock)) + ; (set! (-> pp clock) (-> *display* real-clock)) + ; ) + ; (with-profiler 'ocean *profile-ocean-color* + ; (draw! *ocean*) + ; (if *ocean-map* + ; (update-map *ocean*) + ; ) + ; ) + ; (set! (-> pp clock) gp-5) + ; ) - ;; draw foreground - (foreground-engine-execute *foreground-draw-engine*) + ; ;; draw foreground + ; (foreground-engine-execute *foreground-draw-engine*) - ;; do VU0/EE part of foreground drawing - (let ((gp-6 (-> pp clock))) - (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) - (set! (-> pp clock) (-> *display* bg-clock)) - (set! (-> pp clock) (-> *display* real-clock)) - ) - (foreground-execute-cpu-vu0-engines) - (set! (-> pp clock) gp-6) - ) + ; ;; do VU0/EE part of foreground drawing + ; (let ((gp-6 (-> pp clock))) + ; (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + ; (set! (-> pp clock) (-> *display* bg-clock)) + ; (set! (-> pp clock) (-> *display* real-clock)) + ; ) + ; (foreground-execute-cpu-vu0-engines) + ; (set! (-> pp clock) gp-6) + ; ) - (when *add-sphere* - ) + ; (when *add-sphere* + ; ) - ;; sprites/particles - (if (not (paused?)) - (execute-part-engine) - ) - (when (logtest? (vu1-renderer-mask sprite) (-> *display* vu1-enable-user)) - (if (not (get-screen-copied *blit-displays-work*)) - (sprite-draw *display*) - ) - ) + ; ;; sprites/particles + ; (if (not (paused?)) + ; (execute-part-engine) + ; ) + ; (when (logtest? (vu1-renderer-mask sprite) (-> *display* vu1-enable-user)) + ; (if (not (get-screen-copied *blit-displays-work*)) + ; (sprite-draw *display*) + ; ) + ; ) - ;; debug drawing - (when *debug-segment* - (debug-draw-actors *level* *display-actor-marks*) - (collide-shape-draw-debug-marks) - ) - (when *display-trail-graph* - (let ((a0-67 *trail-graph*)) - (if a0-67 - (debug-draw a0-67) - ) - ) - ) + ; ;; debug drawing + ; (when *debug-segment* + ; (debug-draw-actors *level* *display-actor-marks*) + ; (collide-shape-draw-debug-marks) + ; ) + ; (when *display-trail-graph* + ; (let ((a0-67 *trail-graph*)) + ; (if a0-67 + ; (debug-draw a0-67) + ; ) + ; ) + ; ) - ;; dispatch collision events - (send-events-for-touching-shapes *touching-list*) - (free-nodes *touching-list*) - (prepare *collide-rider-pool*) - (send-all! *event-queue*) + ; ;; dispatch collision events + ; (send-events-for-touching-shapes *touching-list*) + ; (free-nodes *touching-list*) + ; (prepare *collide-rider-pool*) + ; (send-all! *event-queue*) - ;; level update actors: - (with-profiler 'actors *profile-actors-color* - (actors-update *level*) - ) + ; ;; level update actors: + ; (with-profiler 'actors *profile-actors-color* + ; (actors-update *level*) + ; ) - ;; do navigation math - (with-profiler 'nav *profile-nav-color* - (update-nav-meshes-method *level*) - ) + ; ;; do navigation math + ; (with-profiler 'nav *profile-nav-color* + ; (update-nav-meshes-method *level*) + ; ) ;; draw the backgroun (with-profiler 'background *profile-background-color* diff --git a/goal_src/jak3/engine/gfx/background/background.gc b/goal_src/jak3/engine/gfx/background/background.gc index b5a826e95c..d09c72fb29 100644 --- a/goal_src/jak3/engine/gfx/background/background.gc +++ b/goal_src/jak3/engine/gfx/background/background.gc @@ -5,6 +5,97 @@ ;; name in dgo: background ;; dgos: GAME +(defun add-pc-tfrag3-data ((dma-buf dma-buffer) (lev level)) + "Add PC-port specific tfrag data" + (let ((packet (the-as dma-packet (-> dma-buf base)))) + (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc 24)) + (set! (-> packet vif0) (new 'static 'vif-tag)) + (set! (-> packet vif1) (new 'static 'vif-tag :cmd (vif-cmd pc-port))) + (set! (-> dma-buf base) (the pointer (&+ packet 16))) + ) + + ;; first 4 quadwords are planes, then itimes + (let ((data-ptr (the-as (pointer uint128) (-> dma-buf base)))) + ;; the "use-camera-other" flag is set to "move" entire levels, + ;; like the rotating city below in the throne room. + (cond + ((logtest? (-> lev info level-flags) (level-flags use-camera-other)) + (set! (-> data-ptr 0) (-> *math-camera* plane-other 0 quad)) + (set! (-> data-ptr 1) (-> *math-camera* plane-other 1 quad)) + (set! (-> data-ptr 2) (-> *math-camera* plane-other 2 quad)) + (set! (-> data-ptr 3) (-> *math-camera* plane-other 3 quad)) + (set! (-> data-ptr 4) (-> lev mood-context itimes 0 quad)) + (set! (-> data-ptr 5) (-> lev mood-context itimes 1 quad)) + (set! (-> data-ptr 6) (-> lev mood-context itimes 2 quad)) + (set! (-> data-ptr 7) (-> lev mood-context itimes 3 quad)) + (set! (-> data-ptr 8) (-> *math-camera* camera-temp-other vector 0 quad)) + (set! (-> data-ptr 9) (-> *math-camera* camera-temp-other vector 1 quad)) + (set! (-> data-ptr 10) (-> *math-camera* camera-temp-other vector 2 quad)) + (set! (-> data-ptr 11) (-> *math-camera* camera-temp-other vector 3 quad)) + (set! (-> data-ptr 12) (-> *math-camera* hvdf-off quad)) + (let ((vec (-> (the (inline-array vector) data-ptr) 13))) + (set! (-> vec x) (-> *math-camera* pfog0)) + (set! (-> vec y) (-> *math-camera* fog-min)) + (set! (-> vec z) (-> *math-camera* fog-max)) + ) + (set! (-> data-ptr 14) (-> *math-camera* trans-other quad)) + + (set! (-> data-ptr 15) (-> *math-camera* camera-rot-other vector 0 quad)) + (set! (-> data-ptr 16) (-> *math-camera* camera-rot-other vector 1 quad)) + (set! (-> data-ptr 17) (-> *math-camera* camera-rot-other vector 2 quad)) + (set! (-> data-ptr 18) (-> *math-camera* camera-rot-other vector 3 quad)) + + (set! (-> data-ptr 19) (-> *math-camera* perspective vector 0 quad)) + (set! (-> data-ptr 20) (-> *math-camera* perspective vector 1 quad)) + (set! (-> data-ptr 21) (-> *math-camera* perspective vector 2 quad)) + (set! (-> data-ptr 22) (-> *math-camera* perspective vector 3 quad)) + + ) + (else + (set! (-> data-ptr 0) (-> *math-camera* plane 0 quad)) + (set! (-> data-ptr 1) (-> *math-camera* plane 1 quad)) + (set! (-> data-ptr 2) (-> *math-camera* plane 2 quad)) + (set! (-> data-ptr 3) (-> *math-camera* plane 3 quad)) + (set! (-> data-ptr 4) (-> lev mood-context itimes 0 quad)) + (set! (-> data-ptr 5) (-> lev mood-context itimes 1 quad)) + (set! (-> data-ptr 6) (-> lev mood-context itimes 2 quad)) + (set! (-> data-ptr 7) (-> lev mood-context itimes 3 quad)) + ;; HACK: + (let ((vec (new 'static 'vector4w :x #x70707070 :y #x70707070 :z #x70707070 :w #x70707070))) + (set! (-> data-ptr 4) (-> vec quad)) + (set! (-> data-ptr 5) (-> vec quad)) + (set! (-> data-ptr 6) (-> vec quad)) + (set! (-> data-ptr 7) (-> vec quad)) + ) + (set! (-> data-ptr 8) (-> *math-camera* camera-temp vector 0 quad)) + (set! (-> data-ptr 9) (-> *math-camera* camera-temp vector 1 quad)) + (set! (-> data-ptr 10) (-> *math-camera* camera-temp vector 2 quad)) + (set! (-> data-ptr 11) (-> *math-camera* camera-temp vector 3 quad)) + (set! (-> data-ptr 12) (-> *math-camera* hvdf-off quad)) + (let ((vec (-> (the (inline-array vector) data-ptr) 13))) + (set! (-> vec x) (-> *math-camera* pfog0)) + (set! (-> vec y) (-> *math-camera* fog-min)) + (set! (-> vec z) (-> *math-camera* fog-max)) + ) + (set! (-> data-ptr 14) (-> *math-camera* trans quad)) + + (set! (-> data-ptr 15) (-> *math-camera* camera-rot vector 0 quad)) + (set! (-> data-ptr 16) (-> *math-camera* camera-rot vector 1 quad)) + (set! (-> data-ptr 17) (-> *math-camera* camera-rot vector 2 quad)) + (set! (-> data-ptr 18) (-> *math-camera* camera-rot vector 3 quad)) + + (set! (-> data-ptr 19) (-> *math-camera* perspective vector 0 quad)) + (set! (-> data-ptr 20) (-> *math-camera* perspective vector 1 quad)) + (set! (-> data-ptr 21) (-> *math-camera* perspective vector 2 quad)) + (set! (-> data-ptr 22) (-> *math-camera* perspective vector 3 quad)) + ) + ) + + (charp<-string (the (pointer uint8) (&-> data-ptr 23)) (symbol->string (-> lev nickname))) + ) + (&+! (-> dma-buf base) (* 16 24)) + ) + ;; DECOMP BEGINS (define *background-work* (new 'global 'background-work)) @@ -194,13 +285,13 @@ (let ((s5-1 (-> *background-work* shrub-trees gp-2)) (s4-1 (-> *background-work* shrub-levels gp-2)) ) - (if (nonzero? (-> s5-1 colors-added)) - (time-of-day-interp-colors - (-> *instance-shrub-work* colors) - (the-as uint (-> s5-1 colors-added)) - (-> s4-1 mood-context) - ) - ) + ; (if (nonzero? (-> s5-1 colors-added)) + ; (time-of-day-interp-colors + ; (-> *instance-shrub-work* colors) + ; (the-as uint (-> s5-1 colors-added)) + ; (-> s4-1 mood-context) + ; ) + ; ) (set-background-regs! s4-1) (set-shrub-quard-planes! s4-1) (draw-drawable-tree-instance-shrub s5-1 s4-1) @@ -232,7 +323,7 @@ (set-subdivide-settings! s1-1) (when (not (or (zero? s0-1) (= s4-3 s0-1))) (flush-cache 0) - (time-of-day-interp-colors-scratch (the-as (pointer rgba) (+ 6144 #x70000000)) s0-1 (-> s1-1 mood-context)) + ;; (time-of-day-interp-colors-scratch (the-as (pointer rgba) (+ 6144 #x70000000)) s0-1 (-> s1-1 mood-context)) (set! s4-3 s0-1) ) ) @@ -254,7 +345,7 @@ (set-subdivide-settings! s1-2) (when (not (or (zero? s0-2) (= s4-3 s0-2))) (flush-cache 0) - (time-of-day-interp-colors-scratch (the-as (pointer rgba) (+ 6144 #x70000000)) s0-2 (-> s1-2 mood-context)) + ;; (time-of-day-interp-colors-scratch (the-as (pointer rgba) (+ 6144 #x70000000)) s0-2 (-> s1-2 mood-context)) (set! s4-3 s0-2) ) ) @@ -276,7 +367,7 @@ (set-subdivide-settings! s1-3) (when (not (or (zero? s0-3) (= s4-3 s0-3))) (flush-cache 0) - (time-of-day-interp-colors-scratch (the-as (pointer rgba) (+ 6144 #x70000000)) s0-3 (-> s1-3 mood-context)) + ;; (time-of-day-interp-colors-scratch (the-as (pointer rgba) (+ 6144 #x70000000)) s0-3 (-> s1-3 mood-context)) (set! s4-3 s0-3) ) ) diff --git a/goal_src/jak3/engine/gfx/background/tfrag/tfrag-h.gc b/goal_src/jak3/engine/gfx/background/tfrag/tfrag-h.gc index c4d5b2ec41..2f332da2eb 100644 --- a/goal_src/jak3/engine/gfx/background/tfrag/tfrag-h.gc +++ b/goal_src/jak3/engine/gfx/background/tfrag/tfrag-h.gc @@ -11,6 +11,7 @@ (define-extern draw-drawable-tree-tfrag (function drawable-tree-tfrag none)) (define-extern draw-drawable-tree-tfrag-trans (function drawable-tree-tfrag none)) (define-extern draw-drawable-tree-tfrag-water (function drawable-tree-tfrag none)) +(define-extern *pc-tfrag-draw-level* level) ;; added ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/background/tfrag/tfrag-methods.gc b/goal_src/jak3/engine/gfx/background/tfrag/tfrag-methods.gc index 4579d60b17..1b4de11e38 100644 --- a/goal_src/jak3/engine/gfx/background/tfrag/tfrag-methods.gc +++ b/goal_src/jak3/engine/gfx/background/tfrag/tfrag-methods.gc @@ -39,22 +39,22 @@ (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask tfrag)) (let ((s5-0 (+ (-> arg0 length) -1))) (when (nonzero? s5-0) - (dotimes (s4-0 s5-0) - (let* ((v1-8 (-> arg0 arrays s4-0)) - (a0-4 (-> arg0 arrays (+ s4-0 1))) - (a1-1 (/ (-> (the-as drawable-inline-array-node v1-8) data 0 id) 8)) - (a0-6 (/ (-> (the-as drawable-inline-array-node a0-4) data 0 id) 8)) - (a1-3 (+ a1-1 #x3800 #x70000000)) - (a0-8 (+ a0-6 #x3800 #x70000000)) - ) - (draw-node-cull - (the-as pointer a0-8) - (the-as pointer a1-3) - (the-as (inline-array draw-node) (&+ v1-8 32)) - (-> v1-8 length) - ) - ) - ) + ; (dotimes (s4-0 s5-0) + ; (let* ((v1-8 (-> arg0 arrays s4-0)) + ; (a0-4 (-> arg0 arrays (+ s4-0 1))) + ; (a1-1 (/ (-> (the-as drawable-inline-array-node v1-8) data 0 id) 8)) + ; (a0-6 (/ (-> (the-as drawable-inline-array-node a0-4) data 0 id) 8)) + ; (a1-3 (+ a1-1 #x3800 #x70000000)) + ; (a0-8 (+ a0-6 #x3800 #x70000000)) + ; ) + ; (draw-node-cull + ; (the-as pointer a0-8) + ; (the-as pointer a1-3) + ; (the-as (inline-array draw-node) (&+ v1-8 32)) + ; (-> v1-8 length) + ; ) + ; ) + ; ) ) (let* ((v1-14 (-> arg0 arrays s5-0)) (s4-1 (&+ v1-14 32)) @@ -82,7 +82,7 @@ (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) (set! (-> *tfrag-work* texture-dists) (the-as uint (-> *level* draw-level *draw-index* bsp tfrag-closest))) (set! (-> *tfrag-work* last-call) (the-as uint 0)) - (draw-inline-array-tfrag (the-as pointer sv-16) s4-1 s3-0 s1-0) + ;; (draw-inline-array-tfrag (the-as pointer sv-16) s4-1 s3-0 s1-0) (set! (-> *level* draw-level *draw-index* tfrag-last-calls 0) (-> *tfrag-work* last-call)) (update-wait-stats (-> *perf-stats* data 42) @@ -91,34 +91,34 @@ (-> *tfrag-work* wait-from-spr) ) ) - (with-dma-buffer-add-bucket ((s1-1 (-> *display* frames (-> *display* on-screen) global-buf)) - (-> (new 'static 'array bucket-id 10 - (bucket-id tfrag-scissor-l0-tfrag) - (bucket-id tfrag-scissor-l1-tfrag) - (bucket-id tfrag-scissor-l2-tfrag) - (bucket-id tfrag-scissor-l3-tfrag) - (bucket-id tfrag-scissor-l4-tfrag) - (bucket-id tfrag-scissor-l5-tfrag) - (bucket-id tfrag-scissor-l6-tfrag) - (bucket-id tfrag-scissor-l7-tfrag) - (bucket-id tfrag-scissor-l8-tfrag) - (bucket-id tfrag-scissor-l9-tfrag) - ) - *draw-index* - ) - ) - (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) - (set! (-> *tfrag-work* near-wait-from-spr) (the-as uint 0)) - (set! (-> *tfrag-work* last-call) (the-as uint 0)) - (draw-inline-array-tfrag-scissor (the-as pointer sv-16) s4-1 s3-0 s1-1) - (set! (-> *level* draw-level *draw-index* tfrag-last-calls 1) (-> *tfrag-work* last-call)) - (update-wait-stats - (-> *perf-stats* data 43) - (the-as uint 0) - (-> *tfrag-work* near-wait-to-spr) - (-> *tfrag-work* near-wait-from-spr) - ) - ) + ; (with-dma-buffer-add-bucket ((s1-1 (-> *display* frames (-> *display* on-screen) global-buf)) + ; (-> (new 'static 'array bucket-id 10 + ; (bucket-id tfrag-scissor-l0-tfrag) + ; (bucket-id tfrag-scissor-l1-tfrag) + ; (bucket-id tfrag-scissor-l2-tfrag) + ; (bucket-id tfrag-scissor-l3-tfrag) + ; (bucket-id tfrag-scissor-l4-tfrag) + ; (bucket-id tfrag-scissor-l5-tfrag) + ; (bucket-id tfrag-scissor-l6-tfrag) + ; (bucket-id tfrag-scissor-l7-tfrag) + ; (bucket-id tfrag-scissor-l8-tfrag) + ; (bucket-id tfrag-scissor-l9-tfrag) + ; ) + ; *draw-index* + ; ) + ; ) + ; (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) + ; (set! (-> *tfrag-work* near-wait-from-spr) (the-as uint 0)) + ; (set! (-> *tfrag-work* last-call) (the-as uint 0)) + ; ;; (draw-inline-array-tfrag-scissor (the-as pointer sv-16) s4-1 s3-0 s1-1) + ; (set! (-> *level* draw-level *draw-index* tfrag-last-calls 1) (-> *tfrag-work* last-call)) + ; (update-wait-stats + ; (-> *perf-stats* data 43) + ; (the-as uint 0) + ; (-> *tfrag-work* near-wait-to-spr) + ; (-> *tfrag-work* near-wait-from-spr) + ; ) + ; ) (let ((a0-33 *dma-mem-usage*)) (when (nonzero? a0-33) (set! (-> a0-33 length) (max 2 (-> a0-33 length))) @@ -144,22 +144,22 @@ (when (logtest? (vu1-renderer-mask tfrag-trans) (-> *display* vu1-enable-user)) (let ((s5-0 (+ (-> arg0 length) -1))) (when (nonzero? s5-0) - (dotimes (s4-0 s5-0) - (let* ((v1-7 (-> arg0 arrays s4-0)) - (a0-6 (-> arg0 arrays (+ s4-0 1))) - (a1-1 (/ (-> (the-as drawable-inline-array-node v1-7) data 0 id) 8)) - (a0-8 (/ (-> (the-as drawable-inline-array-node a0-6) data 0 id) 8)) - (a1-3 (+ a1-1 #x3800 #x70000000)) - (a0-10 (+ a0-8 #x3800 #x70000000)) - ) - (draw-node-cull - (the-as pointer a0-10) - (the-as pointer a1-3) - (the-as (inline-array draw-node) (&+ v1-7 32)) - (-> v1-7 length) - ) - ) - ) + ; (dotimes (s4-0 s5-0) + ; (let* ((v1-7 (-> arg0 arrays s4-0)) + ; (a0-6 (-> arg0 arrays (+ s4-0 1))) + ; (a1-1 (/ (-> (the-as drawable-inline-array-node v1-7) data 0 id) 8)) + ; (a0-8 (/ (-> (the-as drawable-inline-array-node a0-6) data 0 id) 8)) + ; (a1-3 (+ a1-1 #x3800 #x70000000)) + ; (a0-10 (+ a0-8 #x3800 #x70000000)) + ; ) + ; (draw-node-cull + ; (the-as pointer a0-10) + ; (the-as pointer a1-3) + ; (the-as (inline-array draw-node) (&+ v1-7 32)) + ; (-> v1-7 length) + ; ) + ; ) + ; ) ) (let* ((v1-13 (-> arg0 arrays s5-0)) (s5-1 (&+ v1-13 32)) @@ -188,7 +188,7 @@ (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) (set! (-> *tfrag-work* texture-dists) (the-as uint (-> *level* draw-level *draw-index* bsp alpha-closest))) (set! (-> *tfrag-work* last-call) (the-as uint 0)) - (draw-inline-array-tfrag (the-as pointer sv-16) s5-1 s4-1 s2-0) + ;; (draw-inline-array-tfrag (the-as pointer sv-16) s5-1 s4-1 s2-0) (set! (-> *level* draw-level *draw-index* tfrag-last-calls 2) (-> *tfrag-work* last-call)) (update-wait-stats (-> *perf-stats* data 42) @@ -197,36 +197,36 @@ (-> *tfrag-work* wait-from-spr) ) ) - (with-dma-buffer-add-bucket ((s2-1 (-> *display* frames (-> *display* on-screen) global-buf)) - (-> (new 'static 'array bucket-id 12 - (bucket-id tfrag-scissor-l0-alpha) - (bucket-id tfrag-scissor-l1-alpha) - (bucket-id tfrag-scissor-l2-alpha) - (bucket-id tfrag-scissor-l3-alpha) - (bucket-id tfrag-scissor-l4-alpha) - (bucket-id tfrag-scissor-l5-alpha) - (bucket-id tfrag-scissor-l6-alpha) - (bucket-id tfrag-scissor-l7-alpha) - (bucket-id tfrag-scissor-l8-alpha) - (bucket-id tfrag-scissor-l9-alpha) - (bucket-id bucket0) - (bucket-id bucket0) - ) - *draw-index* - ) - ) - (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) - (set! (-> *tfrag-work* near-wait-from-spr) (the-as uint 0)) - (set! (-> *tfrag-work* last-call) (the-as uint 0)) - (draw-inline-array-tfrag-scissor (the-as pointer sv-16) s5-1 s4-1 s2-1) - (set! (-> *level* draw-level *draw-index* tfrag-last-calls 3) (-> *tfrag-work* last-call)) - (update-wait-stats - (-> *perf-stats* data 43) - (the-as uint 0) - (-> *tfrag-work* near-wait-to-spr) - (-> *tfrag-work* near-wait-from-spr) - ) - ) + ; (with-dma-buffer-add-bucket ((s2-1 (-> *display* frames (-> *display* on-screen) global-buf)) + ; (-> (new 'static 'array bucket-id 12 + ; (bucket-id tfrag-scissor-l0-alpha) + ; (bucket-id tfrag-scissor-l1-alpha) + ; (bucket-id tfrag-scissor-l2-alpha) + ; (bucket-id tfrag-scissor-l3-alpha) + ; (bucket-id tfrag-scissor-l4-alpha) + ; (bucket-id tfrag-scissor-l5-alpha) + ; (bucket-id tfrag-scissor-l6-alpha) + ; (bucket-id tfrag-scissor-l7-alpha) + ; (bucket-id tfrag-scissor-l8-alpha) + ; (bucket-id tfrag-scissor-l9-alpha) + ; (bucket-id bucket0) + ; (bucket-id bucket0) + ; ) + ; *draw-index* + ; ) + ; ) + ; (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) + ; (set! (-> *tfrag-work* near-wait-from-spr) (the-as uint 0)) + ; (set! (-> *tfrag-work* last-call) (the-as uint 0)) + ; ;; (draw-inline-array-tfrag-scissor (the-as pointer sv-16) s5-1 s4-1 s2-1) + ; (set! (-> *level* draw-level *draw-index* tfrag-last-calls 3) (-> *tfrag-work* last-call)) + ; (update-wait-stats + ; (-> *perf-stats* data 43) + ; (the-as uint 0) + ; (-> *tfrag-work* near-wait-to-spr) + ; (-> *tfrag-work* near-wait-from-spr) + ; ) + ; ) ) ) ) @@ -240,22 +240,22 @@ (when (logtest? (vu1-renderer-mask tfrag-water) (-> *display* vu1-enable-user)) (let ((s5-0 (+ (-> arg0 length) -1))) (when (nonzero? s5-0) - (dotimes (s4-0 s5-0) - (let* ((v1-7 (-> arg0 arrays s4-0)) - (a0-6 (-> arg0 arrays (+ s4-0 1))) - (a1-1 (/ (-> (the-as drawable-inline-array-node v1-7) data 0 id) 8)) - (a0-8 (/ (-> (the-as drawable-inline-array-node a0-6) data 0 id) 8)) - (a1-3 (+ a1-1 #x3800 #x70000000)) - (a0-10 (+ a0-8 #x3800 #x70000000)) - ) - (draw-node-cull - (the-as pointer a0-10) - (the-as pointer a1-3) - (the-as (inline-array draw-node) (&+ v1-7 32)) - (-> v1-7 length) - ) - ) - ) + ; (dotimes (s4-0 s5-0) + ; (let* ((v1-7 (-> arg0 arrays s4-0)) + ; (a0-6 (-> arg0 arrays (+ s4-0 1))) + ; (a1-1 (/ (-> (the-as drawable-inline-array-node v1-7) data 0 id) 8)) + ; (a0-8 (/ (-> (the-as drawable-inline-array-node a0-6) data 0 id) 8)) + ; (a1-3 (+ a1-1 #x3800 #x70000000)) + ; (a0-10 (+ a0-8 #x3800 #x70000000)) + ; ) + ; (draw-node-cull + ; (the-as pointer a0-10) + ; (the-as pointer a1-3) + ; (the-as (inline-array draw-node) (&+ v1-7 32)) + ; (-> v1-7 length) + ; ) + ; ) + ; ) ) (let* ((v1-13 (-> arg0 arrays s5-0)) (s5-1 (&+ v1-13 32)) @@ -284,7 +284,7 @@ (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) (set! (-> *tfrag-work* texture-dists) (the-as uint (-> *level* draw-level *draw-index* bsp water-closest))) (set! (-> *tfrag-work* last-call) (the-as uint 0)) - (draw-inline-array-tfrag (the-as pointer sv-16) s5-1 s4-1 s2-0) + ;; (draw-inline-array-tfrag (the-as pointer sv-16) s5-1 s4-1 s2-0) (set! (-> *level* draw-level *draw-index* tfrag-last-calls 4) (-> *tfrag-work* last-call)) (update-wait-stats (-> *perf-stats* data 42) @@ -293,36 +293,36 @@ (-> *tfrag-work* wait-from-spr) ) ) - (with-dma-buffer-add-bucket ((s2-1 (-> *display* frames (-> *display* on-screen) global-buf)) - (-> (new 'static 'array bucket-id 12 - (bucket-id tfrag-scissor-l0-water) - (bucket-id tfrag-scissor-l1-water) - (bucket-id tfrag-scissor-l2-water) - (bucket-id tfrag-scissor-l3-water) - (bucket-id tfrag-scissor-l4-water) - (bucket-id tfrag-scissor-l5-water) - (bucket-id tfrag-scissor-l6-water) - (bucket-id tfrag-scissor-l7-water) - (bucket-id tfrag-scissor-l8-water) - (bucket-id tfrag-scissor-l9-water) - (bucket-id bucket0) - (bucket-id bucket0) - ) - *draw-index* - ) - ) - (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) - (set! (-> *tfrag-work* near-wait-from-spr) (the-as uint 0)) - (set! (-> *tfrag-work* last-call) (the-as uint 0)) - (draw-inline-array-tfrag-scissor (the-as pointer sv-16) s5-1 s4-1 s2-1) - (set! (-> *level* draw-level *draw-index* tfrag-last-calls 5) (-> *tfrag-work* last-call)) - (update-wait-stats - (-> *perf-stats* data 43) - (the-as uint 0) - (-> *tfrag-work* near-wait-to-spr) - (-> *tfrag-work* near-wait-from-spr) - ) - ) + ; (with-dma-buffer-add-bucket ((s2-1 (-> *display* frames (-> *display* on-screen) global-buf)) + ; (-> (new 'static 'array bucket-id 12 + ; (bucket-id tfrag-scissor-l0-water) + ; (bucket-id tfrag-scissor-l1-water) + ; (bucket-id tfrag-scissor-l2-water) + ; (bucket-id tfrag-scissor-l3-water) + ; (bucket-id tfrag-scissor-l4-water) + ; (bucket-id tfrag-scissor-l5-water) + ; (bucket-id tfrag-scissor-l6-water) + ; (bucket-id tfrag-scissor-l7-water) + ; (bucket-id tfrag-scissor-l8-water) + ; (bucket-id tfrag-scissor-l9-water) + ; (bucket-id bucket0) + ; (bucket-id bucket0) + ; ) + ; *draw-index* + ; ) + ; ) + ; (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) + ; (set! (-> *tfrag-work* near-wait-from-spr) (the-as uint 0)) + ; (set! (-> *tfrag-work* last-call) (the-as uint 0)) + ; (draw-inline-array-tfrag-scissor (the-as pointer sv-16) s5-1 s4-1 s2-1) + ; (set! (-> *level* draw-level *draw-index* tfrag-last-calls 5) (-> *tfrag-work* last-call)) + ; (update-wait-stats + ; (-> *perf-stats* data 43) + ; (the-as uint 0) + ; (-> *tfrag-work* near-wait-to-spr) + ; (-> *tfrag-work* near-wait-from-spr) + ; ) + ; ) ) ) ) @@ -343,8 +343,11 @@ ) ) (when (not (-> v1-0 dma-buffer-overflow)) + (let ((s4-0 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) (when (!= s4-0 (-> s4-0 last)) + (format 0 "hello init buf (~D)~%" arg0) + (let* ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf)) (s2-1 (-> s3-0 base)) ) @@ -489,13 +492,15 @@ ) ) -;; WARN: Return type mismatch symbol vs none. +(define *pc-tfrag-draw-level* (the level #f)) + (defun tfrag-vu1-init-buffers () "Initialize all tfrag buckets." (dotimes (gp-0 10) (let ((s5-0 (-> *level* draw-level gp-0)) (s4-0 (-> *tfrag-init-table* gp-0)) ) + (set! *pc-tfrag-draw-level* s5-0) (when s5-0 (set-subdivide-settings! s5-0) (let ((s3-0 (-> s5-0 tfrag-gs-test))) diff --git a/goal_src/jak3/engine/gfx/background/tfrag/tfrag.gc b/goal_src/jak3/engine/gfx/background/tfrag/tfrag.gc index 41a26d9f50..aa5756576c 100644 --- a/goal_src/jak3/engine/gfx/background/tfrag/tfrag.gc +++ b/goal_src/jak3/engine/gfx/background/tfrag/tfrag.gc @@ -181,7 +181,7 @@ (define *tfrag-display-stats* #f) -(define tfrag-vu1-block (new 'static 'vu-function :length #x74b :qlength #x3a6)) +(define tfrag-vu1-block (new 'static 'vu-function)) ;; og:preserve-this ;; WARN: Return type mismatch tfrag-data vs none. (defun tfrag-data-setup ((arg0 tfrag-data) (arg1 int) (arg2 int)) @@ -415,6 +415,9 @@ (add-tfrag-mtx-0 arg0 arg3) (add-tfrag-mtx-1 arg0 arg3) (add-tfrag-data arg0 arg2 (the-as int *subdivide-draw-mode*)) + (#when PC_PORT + (add-pc-tfrag3-data arg0 *pc-tfrag-draw-level*) + ) (let ((v1-5 (the-as dma-packet (-> arg0 base)))) (set! (-> v1-5 dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) (set! (-> v1-5 vif0) (new 'static 'vif-tag :cmd (vif-cmd base)))