fix some decomp types and get rid of in-game frame time perception (#2535)

This commit is contained in:
ManDude 2023-04-24 00:21:12 +01:00 committed by GitHub
parent c44256144e
commit 4cc3430073
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 35 additions and 53 deletions

View file

@ -4433,8 +4433,8 @@
(global-buf dma-buffer :offset 40)
(bucket-group (inline-array dma-bucket) :offset 44)
(profile-array profile-array :inline :offset-assert 48)
(start-time time-frame :offset-assert 56)
(run-time time-frame :offset-assert 64) ;; int64
(start-time int64 :offset-assert 56)
(run-time int64 :offset-assert 64)
)
(:methods
(new (symbol type) _type_ 0)
@ -4466,8 +4466,8 @@
(total-game-clock clock :offset 88)
(time-factor float :offset-assert 92)
(dog-ratio float :offset-assert 96)
(vblank-start-time time-frame 2 :offset-assert 104)
(total-run-time time-frame :offset-assert 120)
(vblank-start-time int64 2 :offset-assert 104)
(total-run-time int64 :offset-assert 120)
(run-half-speed basic :offset-assert 128)
(dog-count float :offset-assert 132)
(vu1-enable-user vu1-renderer-mask :offset-assert 136)

View file

@ -115,20 +115,8 @@ void CollideMeshRenderer::render(SharedRenderState* render_state, ScopedProfiler
settings.planes[i] = render_state->camera_planes[i];
}
auto shader = render_state->shaders[ShaderId::COLLISION].id();
// Get a free binding point
GLuint bind_loc = 0;
GLint bind_max;
glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &bind_max);
for (int i = 0; i < bind_max; i++) {
GLint params;
glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, i, &params);
if (params == 0) {
bind_loc = i;
break;
}
}
glUniformBlockBinding(shader, glGetUniformBlockIndex(shader, "PatColors"), bind_loc);
glBindBufferBase(GL_UNIFORM_BUFFER, bind_loc, m_ubo);
glUniformBlockBinding(shader, glGetUniformBlockIndex(shader, "PatColors"), 0);
glBindBufferBase(GL_UNIFORM_BUFFER, 0, m_ubo);
glUniformMatrix4fv(glGetUniformLocation(shader, "camera"), 1, GL_FALSE,
settings.math_camera.data());
glUniform4f(glGetUniformLocation(shader, "hvdf_offset"), settings.hvdf_offset[0],

View file

@ -1859,7 +1859,11 @@
;; the "lag ratio" of the frame that was just drawn.
(last-dog (fmax 1.0 (fmin 4.0 (-> *display* dog-ratio))))
)
(set! (-> arg0 frames just-rendered-frame run-time) (the-as time-frame (the int frame-duration)))
;; store the amount of ticks that the frame took.
;; PC PORT NOTE : the originaly game reads this field in places to check if frames are taking too long and avoid doing potentially laggy things.
;; those numbers are hardcoded for 60fps, they would be a pain to adjust, and the effects in the pc port are negligible.
;; so, we just pretend frames rendered in planck time.
(set! (-> arg0 frames just-rendered-frame run-time) (#if PC_PORT 0 (the int frame-duration)))
;; next, we'll compute this "lag" ratio (will become dog-ratio of the next frame).
;; higher numbers = game running slower = bigger timesteps
@ -1986,10 +1990,10 @@
;; measure time again, after waiting/vsyncing.
(let ((time-after-vsync (timer1-time)))
(+! (-> arg0 total-run-time)
(the-as time-frame (sar (- (shl time-after-vsync 48) (the-as uint just-rendered-frame-start-time)) 48))
(sar (- (shl time-after-vsync 48) (the-as uint just-rendered-frame-start-time)) 48)
)
;; and use this as the start time for the frame we're about to render.
(set! (-> arg0 frames frame-to-render start-time) (the-as time-frame time-after-vsync))
(set! (-> arg0 frames frame-to-render start-time) (the-as int time-after-vsync))
)
;; while nothing is drawing, update GS/video/magic stuff.
;; (set-graphics-mode)

View file

@ -2111,12 +2111,7 @@
(update-actor-hash)
(when (not (paused?))
(let ((s5-1 (-> *display* frames (-> *display* last-screen) run-time)))
(let ((f0-5 (fmax
327680.0
(fmin (+ 327680.0 (* 204.8 (the float (- (seconds 23.335) s5-1)))) (-> *ACTOR-bank* birth-dist))
)
)
)
(let ((f0-5 (fmax 327680.0 (fmin (+ 327680.0 (* 204.8 (the float (- 7000 s5-1)))) (-> *ACTOR-bank* birth-dist)))))
(seek! (-> *ACTOR-bank* pause-dist) f0-5 (* 81920.0 (-> pp clock seconds-per-frame)))
)
(seekl! (-> *ACTOR-bank* birth-max) (the int (lerp-scale 25.0 2.0 (the float s5-1) 2000.0 7000.0)) 10)

View file

@ -585,10 +585,10 @@
)
(let ((a2-37 (-> *display* frames (-> *display* last-screen) run-time)))
(cond
((< (seconds 30) a2-37)
((< 9000 a2-37)
(set! a1-51 (* a1-51 4))
)
((< (seconds 23.335) a2-37)
((< 7000 a2-37)
(set! a1-51 (* a1-51 2))
)
)

View file

@ -1736,8 +1736,8 @@
; )
(suspend)
(set! (-> *setting-control* user-default bg-a) 0.0)
(set! (-> gp-1 frames 0 start-time) (the-as time-frame (timer-count (the-as timer-bank #x10000800))))
(set! (-> gp-1 frames 1 start-time) (the-as time-frame (timer-count (the-as timer-bank #x10000800))))
(set! (-> gp-1 frames 0 start-time) (the-as int (timer-count (the-as timer-bank #x10000800))))
(set! (-> gp-1 frames 1 start-time) (the-as int (timer-count (the-as timer-bank #x10000800))))
(set! (-> gp-1 dog-ratio) 1.0)
(while *run*
(display-loop-main gp-1)

View file

@ -27,8 +27,8 @@ At any point in time, there are 3 frames in progress:
(global-buf dma-buffer :offset 40)
(bucket-group (inline-array dma-bucket) :offset 44)
(profile-array profile-array :inline :offset-assert 48)
(start-time time-frame :offset-assert 56)
(run-time time-frame :offset-assert 64)
(start-time int64 :offset-assert 56)
(run-time int64 :offset-assert 64)
)
:method-count-assert 9
:size-assert #x48
@ -77,8 +77,8 @@ At any point in time, there are 3 frames in progress:
(total-game-clock clock :offset 88)
(time-factor float :offset-assert 92)
(dog-ratio float :offset-assert 96)
(vblank-start-time time-frame 2 :offset-assert 104)
(total-run-time time-frame :offset-assert 120)
(vblank-start-time int64 2 :offset-assert 104)
(total-run-time int64 :offset-assert 120)
(run-half-speed basic :offset-assert 128)
(dog-count float :offset-assert 132)
(vu1-enable-user vu1-renderer-mask :offset-assert 136)

View file

@ -389,7 +389,7 @@ additionally, some texture pages have a chunk system that allows more specific c
;; internally, the texture-pool has a bump allocator for vram. This assigns vram to various boot textures/segments
;; at boot time and isn't used at run-time. VRAM is often resued for multiple textures in a single frame,
;; at boot time and isn't used at runtime. VRAM is often resued for multiple textures in a single frame,
;; and the common segment does more complicated management at runtime.
(defmethod allocate-vram-words! texture-pool ((obj texture-pool) (num-words int))

View file

@ -2114,7 +2114,7 @@
(let ((vysnc-progress (/ (the float (sar (- current-time (the-as uint prev-vblank-time-2)) 48)) ticks-per-frame-f))
(last-dog (fmax 1.0 (fmin 4.0 (-> *display* dog-ratio))))
)
(set! (-> arg0 frames just-rendered-frame run-time) (the-as time-frame (the int frame-duration)))
(set! (-> arg0 frames just-rendered-frame run-time) (the int frame-duration))
(set! frame-time-ratio
(cond
((-> arg0 run-half-speed)
@ -2191,9 +2191,9 @@
)
(let ((time-after-vsync (timer-count (the-as timer-bank #x10000800))))
(+! (-> arg0 total-run-time)
(the-as time-frame (sar (- (shl time-after-vsync 48) (the-as uint just-rendered-frame-start-time)) 48))
(sar (- (shl time-after-vsync 48) (the-as uint just-rendered-frame-start-time)) 48)
)
(set! (-> arg0 frames frame-to-render start-time) (the-as time-frame time-after-vsync))
(set! (-> arg0 frames frame-to-render start-time) (the-as int time-after-vsync))
)
(set-graphics-mode)
(let ((next-dma-buf (-> arg0 frames frame-to-render calc-buf)))

View file

@ -2346,12 +2346,7 @@
(update-actor-hash)
(when (not (paused?))
(let ((s5-1 (-> *display* frames (-> *display* last-screen) run-time)))
(let ((f0-5 (fmax
327680.0
(fmin (+ 327680.0 (* 204.8 (the float (- (seconds 23.335) s5-1)))) (-> *ACTOR-bank* birth-dist))
)
)
)
(let ((f0-5 (fmax 327680.0 (fmin (+ 327680.0 (* 204.8 (the float (- 7000 s5-1)))) (-> *ACTOR-bank* birth-dist)))))
(seek! (-> *ACTOR-bank* pause-dist) f0-5 (* 81920.0 (-> pp clock seconds-per-frame)))
)
(seekl! (-> *ACTOR-bank* birth-max) (the int (lerp-scale 25.0 2.0 (the float s5-1) 2000.0 7000.0)) 10)

View file

@ -590,10 +590,10 @@
)
(let ((a2-37 (-> *display* frames (-> *display* last-screen) run-time)))
(cond
((< (seconds 30) a2-37)
((< 9000 a2-37)
(set! a1-51 (* a1-51 4))
)
((< (seconds 23.335) a2-37)
((< 7000 a2-37)
(set! a1-51 (* a1-51 2))
)
)

View file

@ -1793,8 +1793,8 @@
)
(suspend)
(set! (-> *setting-control* user-default bg-a) 0.0)
(set! (-> gp-1 frames 0 start-time) (the-as time-frame (timer-count (the-as timer-bank #x10000800))))
(set! (-> gp-1 frames 1 start-time) (the-as time-frame (timer-count (the-as timer-bank #x10000800))))
(set! (-> gp-1 frames 0 start-time) (the-as int (timer-count (the-as timer-bank #x10000800))))
(set! (-> gp-1 frames 1 start-time) (the-as int (timer-count (the-as timer-bank #x10000800))))
(set! (-> gp-1 dog-ratio) 1.0)
(while *run*
(display-loop-main gp-1)

View file

@ -10,8 +10,8 @@
(global-buf dma-buffer :offset 40)
(bucket-group (inline-array dma-bucket) :offset 44)
(profile-array profile-array :inline :offset-assert 48)
(start-time time-frame :offset-assert 56)
(run-time time-frame :offset-assert 64)
(start-time int64 :offset-assert 56)
(run-time int64 :offset-assert 64)
)
:method-count-assert 9
:size-assert #x48
@ -78,8 +78,8 @@
(total-game-clock clock :offset 88)
(time-factor float :offset-assert 92)
(dog-ratio float :offset-assert 96)
(vblank-start-time time-frame 2 :offset-assert 104)
(total-run-time time-frame :offset-assert 120)
(vblank-start-time int64 2 :offset-assert 104)
(total-run-time int64 :offset-assert 120)
(run-half-speed basic :offset-assert 128)
(dog-count float :offset-assert 132)
(vu1-enable-user vu1-renderer-mask :offset-assert 136)