[jak 2] ETIE (#2326)

Definitely needs a clean up pass, but I think the functionality is very
close.

There's a few "hacks" still:
- I am using the emerc logic for environment mapping, which doesn't care
about the length of the normals. I can't figure out how the normal
scaling worked in etie. I want to do a little bit more experimentation
with this before merging.
- There is some part about adgifs for TIE and ETIE that I don't
understand. The clearly correct behavior of TIE/ETIE is that the alpha
settings from the adgif shader are overwritten by the settings from the
renderer. But I can't figure out how this happens in all cases.
- Fade out is completely disabled. I think this is fine because the
performance difference isn't bad. But if you are comparing screenshots
with PCSX2, it will make things look a tiny bit different.
This commit is contained in:
water111
2023-03-17 20:35:26 -04:00
committed by GitHub
parent 6670124296
commit 2fa4a23ea1
41 changed files with 9101 additions and 858 deletions
+23 -14
View File
@@ -37,7 +37,7 @@
(defmethod mem-usage tfragment ((obj tfragment) (arg0 memory-usage-block) (arg1 int))
"Compute the memory usage of a tfragment"
;; seems like this flag does colors?
(when (logtest? arg1 2)
(+! (-> arg0 data 19 count) 1)
@@ -47,18 +47,18 @@
)
(return obj)
)
(let ((s4-0 1))
(set! (-> arg0 length) (max (-> arg0 length) (+ s4-0 8)))
(set! (-> arg0 data s4-0 name) (symbol->string 'tfragment))
(+! (-> arg0 data s4-0 count) 1)
;; the size of the actual tfragment
(let ((v1-22 (asize-of obj)))
(+! (-> arg0 data s4-0 used) v1-22)
(+! (-> arg0 data s4-0 total) (logand -16 (+ v1-22 15)))
)
;; the size of the "base" DMA
(set! (-> arg0 data (+ s4-0 1) name) "tfragment-base")
(+! (-> arg0 data (+ s4-0 1) count) 1)
@@ -66,7 +66,7 @@
(+! (-> arg0 data (+ s4-0 1) used) v1-33)
(+! (-> arg0 data (+ s4-0 1) total) v1-33)
)
;; the size of the "common" DMA
(set! (-> arg0 data (+ s4-0 2) name) "tfragment-common")
(+! (-> arg0 data (+ s4-0 2) count) 1)
@@ -74,7 +74,7 @@
(+! (-> arg0 data (+ s4-0 2) used) v1-43)
(+! (-> arg0 data (+ s4-0 2) total) v1-43)
)
;; the size of the "level0" DMA
(set! (-> arg0 data (+ s4-0 3) name) "tfragment-level0")
(when (nonzero? (-> obj num-level0-colors))
@@ -84,7 +84,7 @@
(+! (-> arg0 data (+ s4-0 3) total) v1-55)
)
)
;; The size of the "level0" DMA. Note that the dma chains can overlap, so this is a bit weird.
(set! (-> arg0 data (+ s4-0 4) name) "tfragment-level1")
(when (not (or (= (-> obj dma-level-1) (-> obj dma-common))
@@ -104,7 +104,7 @@
(+! (-> arg0 data (+ s4-0 4) total) v1-70)
)
)
;; colors
(set! (-> arg0 data (+ s4-0 5) name) "tfragment-color")
(+! (-> arg0 data (+ s4-0 5) count) 1)
@@ -117,11 +117,11 @@
(+! (-> arg0 data (+ s4-0 5) used) v1-79)
(+! (-> arg0 data (+ s4-0 5) total) (logand -16 (+ v1-79 15)))
)
;; debug (unused)
(set! (-> arg0 data (+ s4-0 6) name) "tfragment-debug")
)
obj
)
@@ -322,12 +322,12 @@
(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 16))
(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))))
(set! (-> data-ptr 0) (-> *math-camera* plane 0 quad))
@@ -349,9 +349,18 @@
(set! (-> vec z) (-> *math-camera* fog-max))
)
(set! (-> data-ptr 14) (-> (math-camera-pos) quad))
(charp<-string (the (pointer uint8) (&-> data-ptr 15)) (symbol->string (-> lev nickname)))
(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 16))
(&+! (-> dma-buf base) (* 16 24))
)
;;;;;;;;;;;;;;;;;;;;;
@@ -607,7 +607,7 @@
(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 16))
(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)))
@@ -638,6 +638,17 @@
(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))
@@ -659,10 +670,20 @@
(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 15)) (symbol->string (-> lev nickname)))
(charp<-string (the (pointer uint8) (&-> data-ptr 23)) (symbol->string (-> lev nickname)))
)
(&+! (-> dma-buf base) (* 16 16))
(&+! (-> dma-buf base) (* 16 24))
)
+36 -6
View File
@@ -110,6 +110,23 @@
)
)
(defun pc-add-tie-envmap-info ((dma-buf dma-buffer))
(let ((packet (the-as dma-packet (-> dma-buf base))))
(set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc 1))
(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)))
(set! (-> (the (pointer uint128) (-> dma-buf base)))
(if (and *time-of-day-context*
(nonzero? *time-of-day-context*))
(-> *time-of-day-context* current-env-color quad)
(the uint128 0)
)
)
(set! (-> dma-buf base) (the pointer (&+ packet 32)))
)
)
(defun instance-tie-patch-buckets ((arg0 dma-buffer) (arg1 level))
; (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask tie))
; (when (nonzero? (-> *prototype-tie-work* scissor-count))
@@ -220,6 +237,7 @@
; (&+! (-> v1-42 base) 16)
(add-pc-tfrag3-data v1-42 arg1)
(pc-add-tie-vis-mask arg1 v1-42)
(pc-add-tie-envmap-info v1-42)
(let ((a3-16 (-> v1-42 base)))
(let ((a0-20 (the-as dma-packet (-> v1-42 base))))
(set! (-> a0-20 dma) (new 'static 'dma-tag :id (dma-tag-id next)))
@@ -1442,14 +1460,14 @@
(none)
)
(defun tie-init-envmap-buf ((arg0 bucket-id) (arg1 gs-alpha) (arg2 int) (arg3 int))
;; nothing yet
(defun tie-init-envmap-buf ((arg0 bucket-id) (arg1 gs-alpha) (arg2 gs-test))
;; PC doesn't need this, skip it.
; (let ((s5-0 (-> *display* frames (-> *display* on-screen) bucket-group arg0)))
; (when (!= s5-0 (-> s5-0 last))
; (let* ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))
; (s3-1 (-> s4-0 base))
; )
; (etie-init-engine s4-0)
; (etie-init-engine s4-0 arg1 arg2)
; (let ((v1-12 (the-as dma-packet (-> s4-0 base))))
; (set! (-> v1-12 dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> s5-0 next)))
; (set! (-> v1-12 vif0) (new 'static 'vif-tag))
@@ -1632,7 +1650,11 @@
(a3-1 #x50000)
)
(t9-1 a0-3 (the-as gs-alpha a1-2) (the-as gs-test a2-1) (the-as gs-test a3-1))
(tie-init-envmap-buf (-> s2-0 tie-envmap-bucket) (the-as gs-alpha gp-0) #x50000 a3-1)
(tie-init-envmap-buf
(-> s2-0 tie-envmap-bucket)
(the-as gs-alpha gp-0)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
)
(tie-init-envmap-scissor-buf (-> s2-0 tie-envmap-scissor-bucket) (the-as gs-alpha gp-0) #x50000 a3-1)
)
(tie-init-buf
@@ -1666,7 +1688,11 @@
(a3-4 #x50000)
)
(t9-6 a0-8 (the-as gs-alpha a1-7) (the-as gs-test a2-6) (the-as gs-test a3-4))
(tie-init-envmap-buf (-> s2-0 tie-envmap-trans-bucket) (the-as gs-alpha s4-0) #x50000 a3-4)
(tie-init-envmap-buf
(-> s2-0 tie-envmap-trans-bucket)
(the-as gs-alpha s4-0)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
)
(tie-init-envmap-scissor-buf (-> s2-0 tie-envmap-scissor-trans-bucket) (the-as gs-alpha s4-0) #x50000 a3-4)
)
(tie-init-buf
@@ -1682,7 +1708,11 @@
(a3-6 #x51001)
)
(t9-10 a0-12 (the-as gs-alpha a1-11) (the-as gs-test a2-10) (the-as gs-test a3-6))
(tie-init-envmap-buf (-> s2-0 tie-envmap-water-bucket) (the-as gs-alpha s4-0) #x51001 a3-6)
(tie-init-envmap-buf
(-> s2-0 tie-envmap-water-bucket)
(the-as gs-alpha s4-0)
(new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest greater-equal))
)
(tie-init-envmap-scissor-buf (-> s2-0 tie-envmap-scissor-water-bucket) (the-as gs-alpha s4-0) #x51001 a3-6)
)
)