Added flush to zero
This commit is contained in:
parent
35ad102a6a
commit
a885bf0c72
2 changed files with 44 additions and 1 deletions
|
|
@ -1,7 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <bits/stdint-uintn.h>
|
||||||
|
#include <cstdint>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#ifdef HAVE_X86INTRIN_H
|
||||||
|
#include <x86intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_INTRIN_H
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
inline void trimInPlace(std::string_view& s)
|
inline void trimInPlace(std::string_view& s)
|
||||||
{
|
{
|
||||||
|
|
@ -169,3 +178,35 @@ private:
|
||||||
#else
|
#else
|
||||||
#define LEAK_DETECTOR(Class)
|
#define LEAK_DETECTOR(Class)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class ScopedFTZ {
|
||||||
|
|
||||||
|
public:
|
||||||
|
ScopedFTZ()
|
||||||
|
{
|
||||||
|
#if (HAVE_X86INTRIN_H || HAVE_INTRIN_H)
|
||||||
|
unsigned mask = _MM_DENORMALS_ZERO_MASK | _MM_FLUSH_ZERO_MASK;
|
||||||
|
registerState = _mm_getcsr();
|
||||||
|
_mm_setcsr((registerState & (~mask)) | mask);
|
||||||
|
#elif HAVE_ARM_NEON_H
|
||||||
|
intptr_t mask = (1 << 24);
|
||||||
|
asm volatile("vmrs %0, fpscr"
|
||||||
|
: "=r"(registerState));
|
||||||
|
asm volatile("vmsr fpscr, %0"
|
||||||
|
:
|
||||||
|
: "ri"((registerState & (~mask)) | mask));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
~ScopedFTZ()
|
||||||
|
{
|
||||||
|
#if (HAVE_X86INTRIN_H || HAVE_INTRIN_H)
|
||||||
|
_mm_setcsr(registerState);
|
||||||
|
#elif HAVE_ARM_NEON_H
|
||||||
|
asm volatile("vmsr %0, fpscr"
|
||||||
|
: "=r"(registerState));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned registerState;
|
||||||
|
};
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
#include "SfzHelpers.h"
|
#include "SfzHelpers.h"
|
||||||
|
#include "Helpers.h"
|
||||||
#include "StereoSpan.h"
|
#include "StereoSpan.h"
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
@ -59,6 +60,7 @@ public:
|
||||||
|
|
||||||
void renderBlock(StereoSpan<float> buffer)
|
void renderBlock(StereoSpan<float> buffer)
|
||||||
{
|
{
|
||||||
|
ScopedFTZ ftz;
|
||||||
buffer.fill(0.0f);
|
buffer.fill(0.0f);
|
||||||
|
|
||||||
StereoSpan<float> tempSpan { tempBuffer, buffer.size() };
|
StereoSpan<float> tempSpan { tempBuffer, buffer.size() };
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue