mirror of
https://github.com/open-goal/jak-project
synced 2026-06-30 11:51:55 -04:00
[graphics] tie generic (#1341)
* [gtie] tie inst and proto functions * first chain input to generic ee looks good * m * works * ugh * add tie generic * rm debug print * rm generic ties from fr3
This commit is contained in:
@@ -507,7 +507,7 @@
|
||||
(new 'static 'rgba :r #x80 :g #x20 :b #x60 :a #x80)
|
||||
)
|
||||
)
|
||||
#|
|
||||
|
||||
;; TIE Generic
|
||||
(dotimes (gp-2 (-> *background-work* tie-tree-count))
|
||||
(when (nonzero? (-> *background-work* tie-generic gp-2))
|
||||
@@ -533,7 +533,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
|#
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
@@ -104,6 +104,14 @@
|
||||
)
|
||||
|
||||
(defun upload-vu0-program ((func vu-function) (wait-ptr pointer))
|
||||
"Upload and block until done.
|
||||
Generating the DMA is highly optimized."
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun generic-upload-vu0 ()
|
||||
"Start upload, but don't sync yet.
|
||||
Generating the DMA chain is not as optimized."
|
||||
(none)
|
||||
)
|
||||
|
||||
@@ -137,11 +145,35 @@
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun generic-initialize ((arg0 generic-dma-foreground-sink) (arg1 matrix) (arg2 vu-lights))
|
||||
(generic-work-init arg0)
|
||||
(generic-upload-vu0)
|
||||
;;(let ((a2-1 (+ #x2e20 (the-as int #x70000000)))
|
||||
(let ((a2-1 (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work consts matrix))
|
||||
(v1-1 (-> arg1 vector 0 quad))
|
||||
(a0-2 (-> arg1 vector 1 quad))
|
||||
(a1-1 (-> arg1 vector 2 quad))
|
||||
(a3-0 (-> arg1 vector 3 quad))
|
||||
)
|
||||
(set! (-> a2-1 vector 0 quad) v1-1)
|
||||
(set! (-> a2-1 vector 1 quad) a0-2)
|
||||
(set! (-> a2-1 vector 2 quad) a1-1)
|
||||
(set! (-> a2-1 vector 3 quad) a3-0)
|
||||
)
|
||||
(if arg2
|
||||
(quad-copy! (the-as pointer (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work lights)) (the-as pointer arg2) 7)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun generic-wrapup ((arg0 generic-dma-foreground-sink))
|
||||
(set! (-> arg0 state gifbuf-adr) (-> (scratchpad-object terrain-context) work foreground generic-work saves gifbuf-adr))
|
||||
(set! (-> arg0 state inbuf-adr) (-> (scratchpad-object terrain-context) work foreground generic-work saves inbuf-adr))
|
||||
(none)
|
||||
)
|
||||
|
||||
(def-mips2c generic-prepare-dma-single function)
|
||||
|
||||
|
||||
(def-mips2c generic-prepare-dma-double function)
|
||||
|
||||
(def-mips2c generic-light-proc function)
|
||||
|
||||
(def-mips2c generic-envmap-proc function)
|
||||
@@ -166,7 +166,7 @@
|
||||
(gifbuf-adr uint32 :offset-assert 68)
|
||||
(inbuf-adr uint32 :offset-assert 72)
|
||||
(fade-val uint32 :offset-assert 76)
|
||||
(time-of-day-color uint32 :offset-assert 80)
|
||||
(time-of-day-color rgba :offset-assert 80)
|
||||
(to-vu0-waits uint32 :offset-assert 84)
|
||||
(to-spr-waits uint32 :offset-assert 88)
|
||||
(from-spr-waits uint32 :offset-assert 92)
|
||||
|
||||
@@ -5,3 +5,109 @@
|
||||
;; name in dgo: generic-tie
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(define *generic-tie* #t)
|
||||
|
||||
(def-mips2c generic-tie-dma-to-spad-sync (function object object none))
|
||||
(def-mips2c generic-envmap-dproc function)
|
||||
(def-mips2c generic-interp-dproc function)
|
||||
(def-mips2c generic-no-light-dproc function)
|
||||
(def-mips2c generic-tie-convert (function none))
|
||||
|
||||
|
||||
(defun generic-tie-execute ((arg0 generic-dma-foreground-sink) (arg1 dma-buffer) (arg2 basic))
|
||||
;; (local-vars (v1-28 uint128) (v1-29 uint128) (v1-30 uint128) (a0-33 int) (a0-35 int))
|
||||
;; (rlet ((vf1 :class vf))
|
||||
(when (logtest? *vu1-enable-user* (vu1-renderer-mask generic))
|
||||
(when *generic-tie*
|
||||
(if *debug-segment*
|
||||
(add-frame
|
||||
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
|
||||
'draw
|
||||
(new 'static 'rgba :r #x40 :b #x40 :a #x80)
|
||||
)
|
||||
)
|
||||
(reset! (-> *perf-stats* data 2))
|
||||
|
||||
(when (nonzero? arg2)
|
||||
(let ((s4-0 (-> arg1 base)))
|
||||
(set! (-> (scratchpad-object terrain-context) work foreground generic-work saves basep) (the-as uint (-> arg1 base)))
|
||||
(generic-initialize arg0 (-> *math-camera* perspective) *default-lights*)
|
||||
(generic-tie-dma-to-spad-sync arg2 (-> (scratchpad-object terrain-context) work foreground generic-work in-buf tie input-a))
|
||||
; (let ((v1-24 (+ 716 (the-as int #x70000000))))
|
||||
|
||||
;; set up tie memory layout.
|
||||
(let ((v1-24 (-> (scratchpad-object terrain-context) work foreground generic-work in-buf tie shadow)))
|
||||
(set! (-> v1-24 end-of-chain) (the-as uint 0))
|
||||
(set! (-> v1-24 tie-type) 0)
|
||||
(set! (-> v1-24 out-buf) *gsf-buffer*)
|
||||
(set! (-> v1-24 ptr-buf) (the-as uint (+ 768 (scratchpad-object int))))
|
||||
(set! (-> v1-24 ptr-inst) (the-as uint (+ 3648 (scratchpad-object int))))
|
||||
(set! (-> v1-24 inst-xor) 4640)
|
||||
(set! (-> v1-24 write-limit) (the-as uint (&+ (-> arg1 end) -65536)))
|
||||
)
|
||||
;;(let ((v1-26 (+ 748 (the-as int #x70000000))))
|
||||
(let ((v1-26 (-> (scratchpad-object terrain-context) work foreground generic-work in-buf tie shadow calls)))
|
||||
(set! (-> v1-26 generic-prepare-dma-double) generic-prepare-dma-double)
|
||||
(set! (-> v1-26 generic-envmap-dproc) generic-envmap-dproc) ;; todo
|
||||
(set! (-> v1-26 generic-interp-dproc) generic-interp-dproc) ;; todo
|
||||
(set! (-> v1-26 generic-no-light-dproc) generic-no-light-dproc) ;; todo
|
||||
)
|
||||
|
||||
(set! (-> (scratchpad-object terrain-context) work foreground generic-work saves time-of-day-color r)
|
||||
(the int (-> *time-of-day-context* current-sun env-color x)))
|
||||
(set! (-> (scratchpad-object terrain-context) work foreground generic-work saves time-of-day-color g)
|
||||
(the int (-> *time-of-day-context* current-sun env-color y)))
|
||||
(set! (-> (scratchpad-object terrain-context) work foreground generic-work saves time-of-day-color b)
|
||||
(the int (-> *time-of-day-context* current-sun env-color z)))
|
||||
(set! (-> (scratchpad-object terrain-context) work foreground generic-work saves time-of-day-color a)
|
||||
(the int (-> *time-of-day-context* current-sun env-color w)))
|
||||
|
||||
; (let ((v1-27 *time-of-day-context*))
|
||||
; (let ((a0-26 (+ 16 (the-as int #x70000000))))
|
||||
; (.lvf vf1 (&-> v1-27 current-sun env-color quad))
|
||||
; (.ftoi.vf vf1 vf1)
|
||||
; (.mov v1-28 vf1)
|
||||
; (.ppach v1-29 (the-as uint128 0) v1-28)
|
||||
; (.ppacb v1-30 r0 (the-as int v1-29))
|
||||
; (set! (-> a0-26 foreground generic-work saves time-of-day-color) (the-as uint v1-30))
|
||||
; )
|
||||
; )
|
||||
(generic-tie-convert)
|
||||
(set! (-> arg1 base)
|
||||
(the-as pointer (-> (scratchpad-object terrain-context) work foreground generic-work saves basep))
|
||||
)
|
||||
(generic-wrapup arg0)
|
||||
(set! (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work consts mscal-tag)
|
||||
(logior (logand (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work consts mscal-tag)
|
||||
-65536
|
||||
)
|
||||
6
|
||||
)
|
||||
)
|
||||
; (dma-sync (the-as pointer #x1000d000) 0 0)
|
||||
(let ((v1-37 *dma-mem-usage*))
|
||||
(when (nonzero? v1-37)
|
||||
(set! (-> v1-37 length) (max 18 (-> v1-37 length)))
|
||||
(set! (-> v1-37 data 17 name) "tie-generic")
|
||||
(+! (-> v1-37 data 17 count) 1)
|
||||
(+! (-> v1-37 data 17 used) (&- (-> arg1 base) (the-as uint s4-0)))
|
||||
(set! (-> v1-37 data 17 total) (-> v1-37 data 17 used))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(read! (-> *perf-stats* data 2))
|
||||
(if *debug-segment*
|
||||
(add-frame
|
||||
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
|
||||
'draw
|
||||
(new 'static 'rgba :r #xd2 :g #xd2 :b #x50 :a #x80)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
)
|
||||
0
|
||||
(none)
|
||||
;)
|
||||
)
|
||||
@@ -5,6 +5,9 @@
|
||||
;; name in dgo: tie-methods
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(def-mips2c draw-inline-array-instance-tie (function pointer (inline-array instance-tie) int dma-buffer none))
|
||||
(def-mips2c draw-inline-array-prototype-tie-generic-asm (function dma-buffer int prototype-array-tie none))
|
||||
|
||||
(defun tie-init-buffers ((arg0 dma-buffer))
|
||||
"Initialize the TIE buckets.
|
||||
Note: the buffer passed in here is _not_ used.
|
||||
@@ -296,7 +299,11 @@
|
||||
;;
|
||||
(let ((s4-0 (+ (-> arg0 length) -1))) ;; number of arrays of draw-nodes (depth of the BVH tree, not counting instance leaves)
|
||||
|
||||
;; perform draw node culling. TODO
|
||||
;; perform draw node culling.
|
||||
;; Note: It's okay to skip this. The visible list right now will just be the occlusion string
|
||||
;; The PC renderer won't see this (and has its own version of culling that's plenty fast)
|
||||
;; The instance drawing will end up looking at too many instances, but this is fine - it
|
||||
;; should reject those, and it plenty fast.
|
||||
#|
|
||||
(when (nonzero? s4-0)
|
||||
(dotimes (s3-0 s4-0)
|
||||
@@ -363,7 +370,10 @@
|
||||
(reset! (-> *perf-stats* data 9))
|
||||
|
||||
;; DRAW!
|
||||
;;(draw-inline-array-instance-tie s0-0 s1-0 sv-16 s3-1)
|
||||
;; note: this is a bit wasteful because we only care about generic ties.
|
||||
;; non-generics are drawn fully in C++, but we're computing unused stuff here.
|
||||
;; This ends up being so fast it's probably not worth worrying about yet.
|
||||
(with-profiler "tie-instance" (draw-inline-array-instance-tie s0-0 s1-0 sv-16 s3-1))
|
||||
;; finish perf stats
|
||||
(read! (-> *perf-stats* data 9))
|
||||
(update-wait-stats (-> *perf-stats* data 9) (the-as uint 0)
|
||||
@@ -398,8 +408,10 @@
|
||||
(set! (-> *prototype-tie-work* generic-wait-from-spr) (the-as uint 0))
|
||||
(set! (-> *instance-tie-work* first-generic-prototype) (the-as uint (-> s3-1 base)))
|
||||
|
||||
;; hack, I expect this to overwrite this.
|
||||
(set! (-> (the (pointer uint64) (-> s3-1 base))) #xdeadbeefdeadbeef)
|
||||
(reset! (-> *perf-stats* data 10))
|
||||
;;(draw-inline-array-prototype-tie-generic-asm s3-1 s5-1 s4-1)
|
||||
(with-profiler "tie-generic-protos" (draw-inline-array-prototype-tie-generic-asm s3-1 s5-1 s4-1))
|
||||
(read! (-> *perf-stats* data 10))
|
||||
(update-wait-stats (-> *perf-stats* data 10) (the-as uint 0)
|
||||
(-> *prototype-tie-work* generic-wait-to-spr)
|
||||
|
||||
@@ -755,6 +755,16 @@
|
||||
(when (< current-login-pos (-> s1-2 length))
|
||||
(set! sv-16 (-> s1-2 array-data (the-as uint current-login-pos)))
|
||||
(set! sv-32 0)
|
||||
(when (!= (-> sv-16 envmap-fade-far) 0.0)
|
||||
(format 0 "proto: ~A: ~f ~f~%" (-> sv-16 name) (-> sv-16 envmap-rfade) (-> sv-16 envmap-fade-far))
|
||||
(format 0 " d: ~`vector`P~%" (-> sv-16 dists))
|
||||
(format 0 " d: ~`vector`P~%" (-> sv-16 rdists))
|
||||
;(set! (-> sv-16 dists x) 1.)
|
||||
;(set! (-> sv-16 dists y) 100000000.)
|
||||
(*! (-> sv-16 envmap-fade-far) 10000.)
|
||||
|
||||
)
|
||||
|
||||
(while (< sv-32 4)
|
||||
(let ((a0-28 (-> sv-16 geometry sv-32)))
|
||||
;;(load-dbg " login geom: ~A~%" a0-28)
|
||||
|
||||
@@ -121,9 +121,9 @@
|
||||
(PC_PORT
|
||||
|
||||
;; make sure the scratchpad is 16kb aligned, and make it 32 kB so we can big stacks on it.
|
||||
(let* ((mem (new 'global 'array 'uint8 (* (+ 16 32) 1024)))
|
||||
(let* ((mem (new 'global 'array 'uint8 (* 128 1024)))
|
||||
)
|
||||
(define *fake-scratchpad-data* (the pointer (align-n mem (* 16 1024))))
|
||||
(define *fake-scratchpad-data* (the pointer (align-n mem (* 64 1024))))
|
||||
)
|
||||
|
||||
;; We will move stacks on the scratchpad to here.
|
||||
|
||||
Reference in New Issue
Block a user