From 83937bb2ee8243cda21d6c58f587dfa0c2a97234 Mon Sep 17 00:00:00 2001 From: Veikko Sariola Date: Sat, 5 Dec 2020 14:21:53 +0200 Subject: [PATCH] fix(sointulib): Reset the FPU on each call to render, seems to take away the undeterministic behaviour. --- render.asm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/render.asm b/render.asm index 3523384..d59a999 100644 --- a/render.asm +++ b/render.asm @@ -137,6 +137,8 @@ EXPORT MANGLE_FUNC(su_render,16) mov rcx, rdi ; rcx = &Synthstate %endif %endif + sub _SP,108 ; allocate space on stack for the FPU state + fsave [_SP] ; save the FPU state to stack & reset the FPU push _SI ; push the pointer to samples push _BX ; push the pointer to time xor eax, eax ; samplenumber starts at 0 @@ -208,6 +210,8 @@ su_render_samples_time_finish: mov dword [_SI], edx ; *samples = samples rendered mov dword [_BX], eax ; *time = time ticks rendered xor eax, eax ; TODO: set eax to possible error code, now just 0 + frstor [_SP] ; restore fpu state + add _SP,108 ; rewind the stack allocate for FPU state %if BITS == 32 ; stdcall mov [_SP + 28],eax ; we want to return eax, but popad pops everything, so put eax to stack for popad to pop popad