Avoid static constexpr for arrays iterated over at run-time

This commit is contained in:
Chris Robinson
2019-10-25 01:43:23 -07:00
parent 5ac1f19241
commit 0cba99ed1b
9 changed files with 26 additions and 28 deletions
+1 -1
View File
@@ -557,7 +557,7 @@ al::optional<DecompResult> DecomposeUserFormat(ALenum format)
UserFmtChannels channels;
UserFmtType type;
};
static constexpr std::array<FormatMap,46> UserFmtList{{
static const std::array<FormatMap,46> UserFmtList{{
{ AL_FORMAT_MONO8, UserFmtMono, UserFmtUByte },
{ AL_FORMAT_MONO16, UserFmtMono, UserFmtShort },
{ AL_FORMAT_MONO_FLOAT32, UserFmtMono, UserFmtFloat },
+5 -7
View File
@@ -2808,20 +2808,18 @@ START_API_FUNC
const ALuint *OrderFromChan;
if(voice->mFmtChannels == FmtBFormat2D)
{
static constexpr ALuint Order2DFromChan[MAX_AMBI2D_CHANNELS]{
0, 1,1, 2,2, 3,3
};
static const ALuint Order2DFromChan[MAX_AMBI2D_CHANNELS]{
0, 1,1, 2,2, 3,3,};
OrderFromChan = Order2DFromChan;
}
else
{
static constexpr ALuint Order3DFromChan[MAX_AMBI_CHANNELS]{
0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,
};
static const ALuint Order3DFromChan[MAX_AMBI_CHANNELS]{
0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,};
OrderFromChan = Order3DFromChan;
}
BandSplitter splitter{400.0f / static_cast<ALfloat>(device->Frequency)};
BandSplitter splitter{400.0f / static_cast<float>(device->Frequency)};
const auto scales = BFormatDec::GetHFOrderScales(1, device->mAmbiOrder);
auto init_ambi = [scales,&OrderFromChan,&splitter](ALvoice::ChannelData &chandata) -> void
+1 -1
View File
@@ -742,7 +742,7 @@ START_API_FUNC
ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_relaxed)};
if((enabledevts&EventType_Deprecated) && context->mEventCb)
{
static constexpr ALCchar msg[] =
static const char msg[] =
"alDopplerVelocity is deprecated in AL1.1, use alSpeedOfSound";
const ALsizei msglen{sizeof(msg)-1};
(*context->mEventCb)(AL_EVENT_TYPE_DEPRECATED_SOFT, 0, 0, msglen, msg,
+3 -3
View File
@@ -1988,7 +1988,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
* constexpr variable to avoid a reference on
* FrontStablizer::DelayLength...
*/
static constexpr size_t StablizerDelay{FrontStablizer::DelayLength};
constexpr size_t StablizerDelay{FrontStablizer::DelayLength};
device->FixedLatency += nanoseconds{seconds{StablizerDelay}} / device->Frequency;
}
break;
@@ -3568,7 +3568,7 @@ START_API_FUNC
deviceName = device->DeviceName.c_str();
if(auto chanopt = ConfigValueStr(deviceName, nullptr, "channels"))
{
static constexpr struct ChannelMap {
static const struct ChannelMap {
const char name[16];
DevFmtChannels chans;
ALuint order;
@@ -3601,7 +3601,7 @@ START_API_FUNC
}
if(auto typeopt = ConfigValueStr(deviceName, nullptr, "sample-type"))
{
static constexpr struct TypeMap {
static const struct TypeMap {
const char name[16];
DevFmtType type;
} typelist[] = {
+1 -1
View File
@@ -509,7 +509,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
ALeffectslot *(&SendSlots)[MAX_SENDS], const ALvoicePropsBase *props,
const ALlistener &Listener, const ALCdevice *Device)
{
static constexpr ChanMap MonoMap[1]{
static const ChanMap MonoMap[1]{
{ FrontCenter, 0.0f, 0.0f }
}, RearMap[2]{
{ BackLeft, Deg2Rad(-150.0f), Deg2Rad(0.0f) },
+1 -1
View File
@@ -385,7 +385,7 @@ al::vector<std::string> SearchDataFiles(const char *ext, const char *subdir)
DirectorySearch(path.c_str(), ext, &results);
/* Search the local and global data dirs. */
static constexpr int ids[2]{ CSIDL_APPDATA, CSIDL_COMMON_APPDATA };
static const int ids[2]{ CSIDL_APPDATA, CSIDL_COMMON_APPDATA };
for(int id : ids)
{
WCHAR buffer[MAX_PATH];
+3 -3
View File
@@ -300,7 +300,7 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state,
ALuint ldelay, rdelay;
};
static constexpr int OrderFromChan[MAX_AMBI_CHANNELS]{
static const int OrderFromChan[MAX_AMBI_CHANNELS]{
0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,
};
/* Set this to true for dual-band HRTF processing. May require better
@@ -718,7 +718,7 @@ std::unique_ptr<HrtfEntry> LoadHrtf00(std::istream &data, const char *filename)
}
}
static constexpr ALfloat distance{0.0f};
static const ALfloat distance{0.0f};
return CreateHrtfStore(rate, irSize, 1, &evCount, &distance, azCount.data(), evOffset.data(),
irCount, &reinterpret_cast<ALfloat(&)[2]>(coeffs[0]),
&reinterpret_cast<ALubyte(&)[2]>(delays[0]), filename);
@@ -817,7 +817,7 @@ std::unique_ptr<HrtfEntry> LoadHrtf01(std::istream &data, const char *filename)
}
}
static constexpr ALfloat distance{0.0f};
static const ALfloat distance{0.0f};
return CreateHrtfStore(rate, irSize, 1, &evCount, &distance, azCount.data(), evOffset.data(),
irCount, &reinterpret_cast<ALfloat(&)[2]>(coeffs[0]),
&reinterpret_cast<ALubyte(&)[2]>(delays[0]), filename);
+10 -10
View File
@@ -423,7 +423,7 @@ void InitPanning(ALCdevice *device)
ALfloat nfc_delay{ConfigValueFloat(devname, "decoder", "nfc-ref-delay").value_or(0.0f)};
if(nfc_delay > 0.0f)
{
static constexpr ALuint chans_per_order[MAX_AMBI_ORDER+1]{ 1, 3, 5, 7 };
static const ALuint chans_per_order[MAX_AMBI_ORDER+1]{ 1, 3, 5, 7 };
InitNearFieldCtrl(device, nfc_delay * SPEEDOFSOUNDMETRESPERSEC, device->mAmbiOrder,
chans_per_order);
}
@@ -470,8 +470,8 @@ void InitPanning(ALCdevice *device)
void InitCustomPanning(ALCdevice *device, bool hqdec, const AmbDecConf *conf,
const ALuint (&speakermap)[MAX_OUTPUT_CHANNELS])
{
static constexpr ALuint chans_per_order2d[MAX_AMBI_ORDER+1] = { 1, 2, 2, 2 };
static constexpr ALuint chans_per_order3d[MAX_AMBI_ORDER+1] = { 1, 3, 5, 7 };
static const ALuint chans_per_order2d[MAX_AMBI_ORDER+1] = { 1, 2, 2, 2 };
static const ALuint chans_per_order3d[MAX_AMBI_ORDER+1] = { 1, 3, 5, 7 };
if(!hqdec && conf->FreqBands != 1)
ERR("Basic renderer uses the high-frequency matrix as single-band (xover_freq = %.0fhz)\n",
@@ -522,7 +522,7 @@ void InitCustomPanning(ALCdevice *device, bool hqdec, const AmbDecConf *conf,
void InitHrtfPanning(ALCdevice *device)
{
static constexpr AngularPoint AmbiPoints[]{
static const AngularPoint AmbiPoints[]{
{ Deg2Rad( 0.000000f), Deg2Rad( 0.000000f) },
{ Deg2Rad( 0.000000f), Deg2Rad( 180.000000f) },
{ Deg2Rad( 0.000000f), Deg2Rad( -90.000000f) },
@@ -550,7 +550,7 @@ void InitHrtfPanning(ALCdevice *device)
{ Deg2Rad( 35.264390f), Deg2Rad( 135.000000f) },
{ Deg2Rad(-35.264390f), Deg2Rad( 135.000000f) },
};
static constexpr ALfloat AmbiMatrix[][MAX_AMBI_CHANNELS]{
static const float AmbiMatrix[][MAX_AMBI_CHANNELS]{
{ 3.84615387e-02f, 0.00000000e+00f, 0.00000000e+00f, 8.33950391e-02f, 0.00000000e+00f, 0.00000000e+00f, -4.96903997e-02f, 0.00000000e+00f, 8.60662966e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -7.49473409e-02f, 0.00000000e+00f, 9.67566016e-02f },
{ 3.84615387e-02f, 0.00000000e+00f, 0.00000000e+00f, -8.33950391e-02f, 0.00000000e+00f, 0.00000000e+00f, -4.96903997e-02f, 0.00000000e+00f, 8.60662966e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 7.49473409e-02f, 0.00000000e+00f, -9.67566016e-02f },
{ 3.84615387e-02f, 8.33950391e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -4.96903997e-02f, 0.00000000e+00f, -8.60662966e-02f, -9.67566016e-02f, 0.00000000e+00f, -7.49473409e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f },
@@ -578,15 +578,15 @@ void InitHrtfPanning(ALCdevice *device)
{ 3.84615385e-02f, -3.33333332e-02f, 3.33333335e-02f, -3.33333332e-02f, 4.55645099e-02f, -4.55645100e-02f, 5.38752428e-10f, -4.55645100e-02f, 0.00000000e+00f, -2.95742381e-02f, 6.33865691e-02f, -2.29081068e-02f, -3.74087810e-02f, -2.29081068e-02f, 0.00000000e+00f, 2.95742381e-02f },
{ 3.84615385e-02f, -3.33333332e-02f, -3.33333335e-02f, -3.33333332e-02f, 4.55645099e-02f, 4.55645100e-02f, 5.38752429e-10f, 4.55645100e-02f, 0.00000000e+00f, -2.95742381e-02f, -6.33865691e-02f, -2.29081068e-02f, 3.74087810e-02f, -2.29081068e-02f, 0.00000000e+00f, 2.95742381e-02f },
};
static constexpr ALfloat AmbiOrderHFGain1O[MAX_AMBI_ORDER+1]{
static const float AmbiOrderHFGain1O[MAX_AMBI_ORDER+1]{
3.60555128e+00f, 2.08166600e+00f
}, AmbiOrderHFGain2O[MAX_AMBI_ORDER+1]{
2.68741925e+00f, 2.08166600e+00f, 1.07496770e+00f
}, AmbiOrderHFGain3O[MAX_AMBI_ORDER+1]{
2.12652604e+00f, 1.83122879e+00f, 1.30214339e+00f, 6.48052398e-01f
};
static constexpr ALuint ChansPerOrder[MAX_AMBI_ORDER+1]{ 1, 3, 5, 7 };
const ALfloat *AmbiOrderHFGain{AmbiOrderHFGain1O};
static const ALuint ChansPerOrder[MAX_AMBI_ORDER+1]{ 1, 3, 5, 7 };
const float *AmbiOrderHFGain{AmbiOrderHFGain1O};
static_assert(al::size(AmbiPoints) == al::size(AmbiMatrix), "Ambisonic HRTF mismatch");
@@ -602,7 +602,7 @@ void InitHrtfPanning(ALCdevice *device)
RenderMode mode;
ALuint order;
};
static constexpr HrtfModeEntry hrtf_modes[]{
static const HrtfModeEntry hrtf_modes[]{
{ "full", HrtfRender, 1 },
{ "ambi1", NormalRender, 1 },
{ "ambi2", NormalRender, 2 },
@@ -662,7 +662,7 @@ void InitHrtfPanning(ALCdevice *device)
void InitUhjPanning(ALCdevice *device)
{
/* UHJ is always 2D first-order. */
static constexpr size_t count{Ambi2DChannelsFromOrder(1)};
constexpr size_t count{Ambi2DChannelsFromOrder(1)};
device->mAmbiOrder = 1;
+1 -1
View File
@@ -308,7 +308,7 @@ inline float fast_roundf(float f) noexcept
/* Integral limit, where sub-integral precision is not available for
* floats.
*/
static constexpr float ilim[2] = {
static const float ilim[2]{
8388608.0f /* 0x1.0p+23 */,
-8388608.0f /* -0x1.0p+23 */
};