mirror of https://github.com/stella-emu/stella.git
Removed '-Wno-double-promotion' from the build flags.
This necessitated fixing float -> double promotions in several places in the code. In most cases, double was never being utilized anyway, so there was a slight performance hit for casting when not required.
This commit is contained in:
parent
9d287666f9
commit
32d90c1935
4
Makefile
4
Makefile
|
@ -61,8 +61,8 @@ ifdef HAVE_CLANG
|
|||
endif
|
||||
|
||||
ifdef CLANG_WARNINGS
|
||||
CXXFLAGS+= -Weverything -Wno-c++17-extensions -Wno-c++98-compat -Wno-c++98-compat-pedantic \
|
||||
-Wno-double-promotion -Wno-switch-enum -Wno-conversion -Wno-covered-switch-default \
|
||||
CXXFLAGS+= -Weverything -Wno-c++17-extensions -Wno-c++98-compat-pedantic \
|
||||
-Wno-switch-enum -Wno-conversion -Wno-covered-switch-default \
|
||||
-Wno-inconsistent-missing-destructor-override -Wno-float-equal \
|
||||
-Wno-exit-time-destructors -Wno-global-constructors -Wno-weak-vtables \
|
||||
-Wno-four-char-constants -Wno-padded
|
||||
|
|
|
@ -15,19 +15,16 @@
|
|||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//============================================================================
|
||||
|
||||
#include <cmath>
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#endif
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "HighPass.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
HighPass::HighPass(float cutOffFrequency, float frequency)
|
||||
: myLastValueIn(0),
|
||||
myLastValueOut(0),
|
||||
myAlpha(1.f / (1.f + 2.f*M_PI*cutOffFrequency/frequency))
|
||||
{}
|
||||
myAlpha(1.f / (1.f + 2.f*BSPF::PI_f*cutOffFrequency/frequency))
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
float HighPass::apply(float valueIn)
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
//============================================================================
|
||||
|
||||
#include <cmath>
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#endif
|
||||
|
||||
#include "LanczosResampler.hxx"
|
||||
|
||||
|
@ -45,7 +42,7 @@ namespace {
|
|||
// We calculate the sinc with double precision in order to compensate for precision loss
|
||||
// around zero
|
||||
return x == 0.f ? 1 : static_cast<float>(
|
||||
sin(M_PI * static_cast<double>(x)) / M_PI / static_cast<double>(x)
|
||||
sin(BSPF::PI_d * static_cast<double>(x)) / BSPF::PI_d / static_cast<double>(x)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,9 @@ static const string EmptyString("");
|
|||
|
||||
namespace BSPF
|
||||
{
|
||||
static constexpr float PI_f = 3.141592653589793238462643383279502884f;
|
||||
static constexpr double PI_d = 3.141592653589793238462643383279502884;
|
||||
|
||||
// CPU architecture type
|
||||
// This isn't complete yet, but takes care of all the major platforms
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
|
|
|
@ -318,15 +318,15 @@ inline uInt32 AtariNTSC::getRGBPhosphor(const uInt32 c, const uInt32 p) const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AtariNTSC::init(init_t& impl, const Setup& setup)
|
||||
{
|
||||
impl.brightness = float(setup.brightness) * (0.5f * rgb_unit) + rgb_offset;
|
||||
impl.contrast = float(setup.contrast) * (0.5f * rgb_unit) + rgb_unit;
|
||||
impl.brightness = setup.brightness * (0.5f * rgb_unit) + rgb_offset;
|
||||
impl.contrast = setup.contrast * (0.5f * rgb_unit) + rgb_unit;
|
||||
|
||||
impl.artifacts = float(setup.artifacts);
|
||||
impl.artifacts = setup.artifacts;
|
||||
if ( impl.artifacts > 0 )
|
||||
impl.artifacts *= artifacts_max - artifacts_mid;
|
||||
impl.artifacts = impl.artifacts * artifacts_mid + artifacts_mid;
|
||||
|
||||
impl.fringing = float(setup.fringing);
|
||||
impl.fringing = setup.fringing;
|
||||
if ( impl.fringing > 0 )
|
||||
impl.fringing *= fringing_max - fringing_mid;
|
||||
impl.fringing = impl.fringing * fringing_mid + fringing_mid;
|
||||
|
@ -337,22 +337,22 @@ void AtariNTSC::init(init_t& impl, const Setup& setup)
|
|||
if (true) /* was (gamma_size > 1) */
|
||||
{
|
||||
float const to_float = 1.0f / (gamma_size - 1/*(gamma_size > 1)*/);
|
||||
float const gamma = 1.1333f - float(setup.gamma) * 0.5f;
|
||||
float const gamma = 1.1333f - setup.gamma * 0.5f;
|
||||
/* match common PC's 2.2 gamma to TV's 2.65 gamma */
|
||||
int i;
|
||||
for ( i = 0; i < gamma_size; i++ )
|
||||
impl.to_float [i] =
|
||||
float(pow( i * to_float, gamma )) * impl.contrast + impl.brightness;
|
||||
powf( i * to_float, gamma ) * impl.contrast + impl.brightness;
|
||||
}
|
||||
|
||||
/* setup decoder matricies */
|
||||
{
|
||||
float hue = float(setup.hue) * PI + PI / 180 * ext_decoder_hue;
|
||||
float sat = float(setup.saturation) + 1;
|
||||
hue += PI / 180 * (std_decoder_hue - ext_decoder_hue);
|
||||
float hue = setup.hue * BSPF::PI_f + BSPF::PI_f / 180 * ext_decoder_hue;
|
||||
float sat = setup.saturation + 1;
|
||||
hue += BSPF::PI_f / 180 * (std_decoder_hue - ext_decoder_hue);
|
||||
|
||||
float s = float(sin( hue )) * sat;
|
||||
float c = float(cos( hue )) * sat;
|
||||
float s = sinf( hue ) * sat;
|
||||
float c = cosf( hue ) * sat;
|
||||
float* out = impl.to_rgb;
|
||||
int n;
|
||||
|
||||
|
@ -386,27 +386,26 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
|
|||
/* generate luma (y) filter using sinc kernel */
|
||||
{
|
||||
/* sinc with rolloff (dsf) */
|
||||
float const rolloff = 1 + float(setup.sharpness) * 0.032f;
|
||||
float const maxh = 32;
|
||||
float const pow_a_n = float(pow( rolloff, maxh ));
|
||||
float const rolloff = 1 + setup.sharpness * 0.032f;
|
||||
constexpr float maxh = 32;
|
||||
float const pow_a_n = powf( rolloff, maxh );
|
||||
float sum;
|
||||
int i;
|
||||
/* quadratic mapping to reduce negative (blurring) range */
|
||||
float to_angle = float(setup.resolution) + 1;
|
||||
to_angle = PI / maxh * float(LUMA_CUTOFF) * (to_angle * to_angle + 1);
|
||||
float to_angle = setup.resolution + 1;
|
||||
to_angle = BSPF::PI_f / maxh * LUMA_CUTOFF * (to_angle * to_angle + 1.f);
|
||||
|
||||
kernels [kernel_size * 3 / 2] = maxh; /* default center value */
|
||||
for ( i = 0; i < kernel_half * 2 + 1; i++ )
|
||||
for ( int i = 0; i < kernel_half * 2 + 1; i++ )
|
||||
{
|
||||
int x = i - kernel_half;
|
||||
float angle = x * to_angle;
|
||||
/* instability occurs at center point with rolloff very close to 1.0 */
|
||||
if ( x || pow_a_n > 1.056 || pow_a_n < 0.981 )
|
||||
if ( x || pow_a_n > 1.056f || pow_a_n < 0.981f )
|
||||
{
|
||||
float rolloff_cos_a = rolloff * float(cos( angle ));
|
||||
float rolloff_cos_a = rolloff * cosf( angle );
|
||||
float num = 1 - rolloff_cos_a -
|
||||
pow_a_n * float(cos( maxh * angle )) +
|
||||
pow_a_n * rolloff * float(cos( (maxh - 1) * angle ));
|
||||
pow_a_n * cosf( maxh * angle ) +
|
||||
pow_a_n * rolloff * cosf( (maxh - 1) * angle );
|
||||
float den = 1 - rolloff_cos_a - rolloff_cos_a + rolloff * rolloff;
|
||||
float dsf = num / den;
|
||||
kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - 0.5f;
|
||||
|
@ -415,16 +414,16 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
|
|||
|
||||
/* apply blackman window and find sum */
|
||||
sum = 0;
|
||||
for ( i = 0; i < kernel_half * 2 + 1; i++ )
|
||||
for ( int i = 0; i < kernel_half * 2 + 1; i++ )
|
||||
{
|
||||
float x = PI * 2 / (kernel_half * 2) * i;
|
||||
float blackman = 0.42f - 0.5f * float(cos( x )) + 0.08f * float(cos( x * 2 ));
|
||||
float x = BSPF::PI_f * 2 / (kernel_half * 2) * i;
|
||||
float blackman = 0.42f - 0.5f * cosf( x ) + 0.08f * cosf( x * 2 );
|
||||
sum += (kernels [kernel_size * 3 / 2 - kernel_half + i] *= blackman);
|
||||
}
|
||||
|
||||
/* normalize kernel */
|
||||
sum = 1.0f / sum;
|
||||
for ( i = 0; i < kernel_half * 2 + 1; i++ )
|
||||
for ( int i = 0; i < kernel_half * 2 + 1; i++ )
|
||||
{
|
||||
int x = kernel_size * 3 / 2 - kernel_half + i;
|
||||
kernels [x] *= sum;
|
||||
|
@ -433,9 +432,8 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
|
|||
|
||||
/* generate chroma (iq) filter using gaussian kernel */
|
||||
{
|
||||
float const cutoff_factor = -0.03125f;
|
||||
float cutoff = float(setup.bleed);
|
||||
int i;
|
||||
constexpr float cutoff_factor = -0.03125f;
|
||||
float cutoff = setup.bleed;
|
||||
|
||||
if ( cutoff < 0 )
|
||||
{
|
||||
|
@ -447,11 +445,11 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
|
|||
}
|
||||
cutoff = cutoff_factor - 0.65f * cutoff_factor * cutoff;
|
||||
|
||||
for ( i = -kernel_half; i <= kernel_half; i++ )
|
||||
kernels [kernel_size / 2 + i] = float(exp( i * i * cutoff ));
|
||||
for ( int i = -kernel_half; i <= kernel_half; i++ )
|
||||
kernels [kernel_size / 2 + i] = expf( i * i * cutoff );
|
||||
|
||||
/* normalize even and odd phases separately */
|
||||
for ( i = 0; i < 2; i++ )
|
||||
for ( int i = 0; i < 2; i++ )
|
||||
{
|
||||
float sum = 0;
|
||||
int x;
|
||||
|
@ -473,9 +471,8 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
|
|||
do
|
||||
{
|
||||
float remain = 0;
|
||||
int i;
|
||||
weight -= 1.0f / rescale_in;
|
||||
for ( i = 0; i < kernel_size * 2; i++ )
|
||||
for ( int i = 0; i < kernel_size * 2; i++ )
|
||||
{
|
||||
float cur = kernels [i];
|
||||
float m = cur * weight;
|
||||
|
|
|
@ -58,18 +58,18 @@ class AtariNTSC
|
|||
struct Setup
|
||||
{
|
||||
// Basic parameters
|
||||
double hue; // -1 = -180 degrees +1 = +180 degrees
|
||||
double saturation; // -1 = grayscale (0.0) +1 = oversaturated colors (2.0)
|
||||
double contrast; // -1 = dark (0.5) +1 = light (1.5)
|
||||
double brightness; // -1 = dark (0.5) +1 = light (1.5)
|
||||
double sharpness; // edge contrast enhancement/blurring
|
||||
float hue; // -1 = -180 degrees +1 = +180 degrees
|
||||
float saturation; // -1 = grayscale (0.0) +1 = oversaturated colors (2.0)
|
||||
float contrast; // -1 = dark (0.5) +1 = light (1.5)
|
||||
float brightness; // -1 = dark (0.5) +1 = light (1.5)
|
||||
float sharpness; // edge contrast enhancement/blurring
|
||||
|
||||
// Advanced parameters
|
||||
double gamma; // -1 = dark (1.5) +1 = light (0.5)
|
||||
double resolution; // image resolution
|
||||
double artifacts; // artifacts caused by color changes
|
||||
double fringing; // color artifacts caused by brightness changes
|
||||
double bleed; // color bleed (color resolution reduction)
|
||||
float gamma; // -1 = dark (1.5) +1 = light (0.5)
|
||||
float resolution; // image resolution
|
||||
float artifacts; // artifacts caused by color changes
|
||||
float fringing; // color artifacts caused by brightness changes
|
||||
float bleed; // color bleed (color resolution reduction)
|
||||
};
|
||||
|
||||
// Video format presets
|
||||
|
@ -160,9 +160,7 @@ class AtariNTSC
|
|||
#define fringing_max 2.0f
|
||||
#define rgb_offset (rgb_unit * 2 + 0.5f)
|
||||
|
||||
#undef PI
|
||||
#define PI 3.14159265358979323846f
|
||||
#define LUMA_CUTOFF 0.20
|
||||
#define LUMA_CUTOFF 0.20f
|
||||
|
||||
uInt32 myColorTable[palette_size][entry_size];
|
||||
uInt8 myPhosphorPalette[256][256];
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
#include "NTSCFilter.hxx"
|
||||
|
||||
constexpr double scaleFrom100(double x) { return (x/50.0) - 1.0; }
|
||||
constexpr uInt32 scaleTo100(double x) { return uInt32(50*(x+1.0)); }
|
||||
constexpr float scaleFrom100(float x) { return (x/50.f) - 1.f; }
|
||||
constexpr uInt32 scaleTo100(float x) { return uInt32(50*(x+1.f)); }
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
NTSCFilter::NTSCFilter()
|
||||
|
|
|
@ -153,7 +153,7 @@ class NTSCFilter
|
|||
|
||||
struct AdjustableTag {
|
||||
const char* const type;
|
||||
double* value;
|
||||
float* value;
|
||||
};
|
||||
uInt32 myCurrentAdjustable;
|
||||
static const AdjustableTag ourCustomAdjustables[10];
|
||||
|
|
|
@ -98,7 +98,7 @@ EmulationTiming& EmulationTiming::updateAudioQueueHeadroom(uInt32 audioQueueHead
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EmulationTiming& EmulationTiming::updateSpeedFactor(float speedFactor)
|
||||
{
|
||||
mySpeedFactor = speedFactor;
|
||||
mySpeedFactor = static_cast<double>(speedFactor);
|
||||
recalculate();
|
||||
|
||||
return *this;
|
||||
|
|
|
@ -83,7 +83,7 @@ class EmulationTiming {
|
|||
uInt32 myAudioQueueCapacity;
|
||||
uInt32 myPrebufferFragmentCount;
|
||||
|
||||
float mySpeedFactor;
|
||||
double mySpeedFactor;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -354,9 +354,9 @@ void Paddles::update()
|
|||
|
||||
// Only change state if the charge has actually changed
|
||||
if(myCharge[1] != myLastCharge[1])
|
||||
setPin(AnalogPin::Five, Int32(MAX_RESISTANCE * (myCharge[1] / float(TRIGMAX))));
|
||||
setPin(AnalogPin::Five, Int32(MAX_RESISTANCE * (myCharge[1] / double(TRIGMAX))));
|
||||
if(myCharge[0] != myLastCharge[0])
|
||||
setPin(AnalogPin::Nine, Int32(MAX_RESISTANCE * (myCharge[0] / float(TRIGMAX))));
|
||||
setPin(AnalogPin::Nine, Int32(MAX_RESISTANCE * (myCharge[0] / double(TRIGMAX))));
|
||||
|
||||
myLastCharge[1] = myCharge[1];
|
||||
myLastCharge[0] = myCharge[0];
|
||||
|
|
|
@ -98,7 +98,7 @@ void TIASurface::initialize(const Console& console,
|
|||
// This won't be 100% accurate, but non-integral scaling isn't 100%
|
||||
// accurate anyway
|
||||
mySLineSurface->setSrcSize(1, 2 * int(float(mode.image.height()) /
|
||||
floor((float(mode.image.height()) / myTIA->height()) + 0.5)));
|
||||
floorf((float(mode.image.height()) / myTIA->height()) + 0.5f)));
|
||||
|
||||
#if 0
|
||||
cerr << "INITIALIZE:\n"
|
||||
|
|
Loading…
Reference in New Issue