[decompiler] More inline vector functions (#3861)

This adds more recognition for inlined vector functions to the
decompiler, which can clean up a bunch of ugly looking code/`rlet`s.


![image](https://github.com/user-attachments/assets/1f7b4627-81bd-481b-b828-76b9f7ba13b3)

Unfortunately, this changes the numbering of ops in the decomp, since
all the vector instructions get combined in a single "operation" by the
decompiler. I really tried to avoid having this ever happen in the
decompiler and this is one of the few cases where it has. So I had to
update a bunch of type casts.

For that reason I haven't turned this on in Jak 2 yet, although I am
planning to do that at some point. (probably at the same time as porting
back a bunch of jak 3 improvements to jak 2)

---------

Co-authored-by: water111 <awaterford1111445@gmail.com>
This commit is contained in:
water111
2025-02-16 15:59:17 -05:00
committed by GitHub
parent b07d0d9ced
commit 2a4d3d7a4a
340 changed files with 22771 additions and 36134 deletions
+25 -46
View File
@@ -1466,56 +1466,35 @@
;; definition (debug) for function add-debug-light
;; INFO: Used lq/sq
(defun-debug add-debug-light ((arg0 symbol) (arg1 bucket-id) (arg2 light) (arg3 vector) (arg4 string))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf7 :class vf)
)
(init-vf0-vector)
(if (not (or arg0 *display-capture-mode*))
(return #f)
)
(when (!= (-> arg2 extra x) 0.0)
(add-debug-vector
arg0
arg1
arg3
(-> arg2 direction)
(meters 3)
(new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
)
(let ((s2-0 (new-stack-vector0)))
(let ((v1-4 (-> arg2 direction)))
(let ((a0-3 (* 12288.0 (-> arg2 extra x))))
(.mov vf7 a0-3)
)
(.lvf vf5 (&-> v1-4 quad))
)
(.lvf vf4 (&-> arg3 quad))
(.add.x.vf.w vf6 vf0 vf0)
(.mul.x.vf.xyz acc vf5 vf7)
(.add.mul.w.vf.xyz vf6 vf4 vf0 acc)
(.svf (&-> s2-0 quad) vf6)
(let ((s1-1 (logior (logior (logior (shr (shl (the int (* 128.0 (-> arg2 color w))) 56) 32)
(shr (shl (the int (* 128.0 (-> arg2 color z))) 56) 40)
)
(shr (shl (the int (* 128.0 (-> arg2 color y))) 56) 48)
)
(shr (shl (the int (* 128.0 (-> arg2 color x))) 56) 56)
)
)
)
(format (clear *temp-string*) "~S ~,,2f" arg4 (-> arg2 extra x))
(let ((t0-2 *temp-string*))
(add-debug-text-sphere arg0 arg1 s2-0 (* 2048.0 (-> arg2 extra x)) t0-2 (the-as rgba s1-1))
)
(if (not (or arg0 *display-capture-mode*))
(return #f)
)
(when (!= (-> arg2 extra x) 0.0)
(add-debug-vector
arg0
arg1
arg3
(-> arg2 direction)
(meters 3)
(new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
)
(let ((s2-1 (vector+*! (new-stack-vector0) arg3 (-> arg2 direction) (* 12288.0 (-> arg2 extra x))))
(s1-1 (logior (logior (logior (shr (shl (the int (* 128.0 (-> arg2 color w))) 56) 32)
(shr (shl (the int (* 128.0 (-> arg2 color z))) 56) 40)
)
(shr (shl (the int (* 128.0 (-> arg2 color y))) 56) 48)
)
(shr (shl (the int (* 128.0 (-> arg2 color x))) 56) 56)
)
)
)
(format (clear *temp-string*) "~S ~,,2f" arg4 (-> arg2 extra x))
(let ((t0-2 *temp-string*))
(add-debug-text-sphere arg0 arg1 s2-1 (* 2048.0 (-> arg2 extra x)) t0-2 (the-as rgba s1-1))
)
)
#f
)
#f
)
;; definition (debug) for function add-debug-lights