fix(vm): x87 native filter unit was denormalizing and eating up CPU

When voice was silent, the exponential decays in the filter unit
were causing the high pass component to eventually denormalize,
causing high CPU loads. The solution is the same as in the delay
unit: add and subtract a small number from the value, causing
essentially a flush to zero.
https://en.wikipedia.org/wiki/Subnormal_number

Fixes #68.
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-06-19 18:58:20 +03:00
parent a14e21dff6
commit db2d9cac9d
2 changed files with 5 additions and 0 deletions

View File

@ -156,6 +156,9 @@ su_op_dbgain_mono:
fsubp st2, st0 ; r x-l'
fmul dword [{{.WRK}}+8] ; r*b x-l'
fsubp st1, st0 ; x-l'-r*b
{{- .Float 0.5 | .Prepare | indent 4}}
fadd dword [{{.Float 0.5 | .Use}}] ; add and sub small offset to prevent denormalization
fsub dword [{{.Float 0.5 | .Use}}] ; See for example: https://stackoverflow.com/questions/36781881/why-denormalized-floats-are-so-much-slower-than-other-floats-from-hardware-arch
fst dword [{{.WRK}}+4] ; h'=x-l'-r*b
fmul dword [{{.WRK}}+12] ; f2*h'
fadd dword [{{.WRK}}+8] ; f2*h'+b