Are there any special tricks to avoiding compiler screwups?
Here is one that is bothering me right now .... Using maximum optimization, ambient sounds aren't playing until pressing ALT-TAB and switching away or back. Both using GCC and using Visual Studio. Maybe even more than that. Of course the debug build works fine.
The most aggressive optimizations don't seem to add any fps or performance, but they sure do screw up small things in subtle ways.
I've had the compiler poorly round floats so that multiplying by 100 ends up being slightly short of x 100 in multiplication against an integer before. There is a block of original Quake source code in software I have wrapped with #pragma optimize ("off") / #pragma optimize ("on") to keep the compiler from foobaring it.
Sometimes I kind of wonder whether just to use slightly less than the best optimization to prevent this kind of subtle chaos.
Avoiding Compiler Screwups?
Avoiding Compiler Screwups?
The night is young. How else can I annoy the world before sunsrise? Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Re: Avoiding Compiler Screwups?
bugs like that suggest that you're not initialising something properly.
try valgrind.
try valgrind.
Re: Avoiding Compiler Screwups?
Pentium optimizations can have errors related to FP precision. Anything below P4/ss3 or thereabouts
Re: Avoiding Compiler Screwups?
I've used a few different tools like Very Sleep and Microsoft Application Verifier, nothing.
After further examination, the sound issue might not have been code related at all. I think one of the tabs in my web browser was responsible or something running in the background.
After further examination, the sound issue might not have been code related at all. I think one of the tabs in my web browser was responsible or something running in the background.
The night is young. How else can I annoy the world before sunsrise? Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Re: Avoiding Compiler Screwups?
UPDATE: I was running at maxfps set to 9999 and running 300 to 1200 fps can have an unexpected effect on sound, it seems.
At high frametimes, I think the funny business occurs here:
So at high frame rates, ambient sound level may never increment because the (int) rounds to zero.
The reason ALT-TAB fixed it for me is due to code that reduces the framerate if not the activate app, allowing the sound to progress in non-zero increments.
I was blaming the compiler because I happened to be trying to get MinGW going and that is when I noticed the issue. The debug build didn't experience the issue because the debug yielded a lower framerate.
At high frametimes, I think the funny business occurs here:
So at high frame rates, ambient sound level may never increment because the (int) rounds to zero.
Code: Select all
// don't adjust volume too fast
if (chan->master_vol < vol)
{
chan->master_vol += (int) (host_frametime * ambient_fade.value); <------------ high frame rate = very low number, (int) causes it to be zero.
if (chan->master_vol > vol)
chan->master_vol = vol;
}
else if (chan->master_vol > vol)
{
chan->master_vol -= (int) (host_frametime * ambient_fade.value);
if (chan->master_vol < vol)
chan->master_vol = vol;
}
I was blaming the compiler because I happened to be trying to get MinGW going and that is when I noticed the issue. The debug build didn't experience the issue because the debug yielded a lower framerate.
The night is young. How else can I annoy the world before sunsrise? Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Re: Avoiding Compiler Screwups?
fte just uses a float internally and just copies that over to the master_vol field, apparently.
well done finding it though, such things can be annoying (especially that ambient noise stuff anyway).
well done finding it though, such things can be annoying (especially that ambient noise stuff anyway).
Re: Avoiding Compiler Screwups?
Code is in snd_dma.c and in the original Quake.qbism wrote:Separate packet update rate from refresh rate?
To the best of my knowledge, certain ambient sounds like the sky noise are client-side only, and don't require any kind of server support.
Code: Select all
#define AMBIENT_WATER 0
#define AMBIENT_SKY 1
#define AMBIENT_SLIME 2
#define AMBIENT_LAVA 3
#define NUM_AMBIENTS 4 // automatic ambient sounds
Code: Select all
ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav");
ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav");
The night is young. How else can I annoy the world before sunsrise? Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Re: Avoiding Compiler Screwups?
One thing to also look out for are floating point precision when it comes to msvc.
Msvc from version 2012 and up have replaced floating point precision with SSE math so if you get weird behaviour ill look at that.
This was discovered because vanilla doom3's stencil shadows fucked up totally when compiled with msvc 2012, so stick to 2010 if you cannot fix the code.
Msvc from version 2012 and up have replaced floating point precision with SSE math so if you get weird behaviour ill look at that.
This was discovered because vanilla doom3's stencil shadows fucked up totally when compiled with msvc 2012, so stick to 2010 if you cannot fix the code.
Productivity is a state of mind.