turns out that __builtin_alloca_with_align() might releases the
allocated memory at the end of the block it was allocated in, instead
of the end of the function (which is the behavior of regular alloca()
and __builtin_alloca()): "The lifetime of the allocated object ends at
the end of the block in which the function was called. The allocated
storage is released no later than just before the calling function
returns to its caller, but may be released at the end of the block in
which the function was called."
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005falloca_005fwith_005falign
Clang also supports __builtin_alloca_with_align(), but always releases
the memory at the end of the function.
And it seems that newer GCC versions also tend to release it at the
end of the function, but GCC 4.7.2 (that I use for the official Linux
release binaries) didn't, and that caused weird graphical glitches.
But as I don't want to rely on newer GCC versions behaving like this
(and the documentation explicitly says that it *may* be released at
the end of the block, but will definitely be released at the end of
the function), I removed all usage of __builtin_alloca_with_align().
(Side-Note: GCC only started documenting the behavior of
__builtin_alloca and __builtin_alloca_with_align at all with GCC 6.1.0)
The only change really is adding SE_MOUSE_ABS to sysEventType_t.
In theory this breaks the ABI, but in practice I don't think mods use
sysEventType_t, and certainly not the ones above SE_MOUSE
(SE_JOYSTICK_AXIS doesn't make sense as Doom3 never supported Joysticks,
SE_CONSOLE is for input from TTY or whatever, and doesn't make sense
for mods to use in any way)
The change in Stub_SDL_endian.h is just me being paranoid.
(side-note: it *might* make sense to replace all that inline-asm in
Stub_SDL_endian.h with compiler intrinsics like GCC/clangs
__builtin_bswap* and MSVCs _byteswap_* - if they are supported in
all relevant compiler versions. GCC supports 32 and 64 bit swaps since
4.3, 16bit since 4.8 and 128bit since 11.x; clang supports 32 and
64 bit swaps at least since 3.0 and 16bit swaps since 3.2;
VS introduced _byteswap_ushort, .._ulong and .._uint64 in VS2003)
On Windows, ID_INLINE does __forceinline, which is bad if the function
calls alloca() and is called in a loop..
So use just __inline there so the compiler can choose not to inline
(if called in a loop).
This didn't cause actual stack overflows as far as I know, but it could
(and MSVC warns about it).
(This includes "Fix ID_MAYBE_INLINE on non-Windows platforms")
I created this repo from the original dhewm3 repo, but I used
git filter-branch to kill all the files that are not needed to just
build base.dll and d3xp.dll (or .so or .dylib or whatever).
So this is basically just the files the original Doom3 SDK had, but
taken from dhewm3 instead (and thus GPL licensed and patched for
64bit-support etc) + some dhewm3 specific stuff + CMakeLists.txt
to build them.
The git filter-branch details:
filter-branch -f --prune-empty --tree-filter /tmp/killkill.sh @
## /tmp/killkill.sh:
#!/bin/sh
find . -exec /tmp/removeothers.sh {} \;
exit 0
## /tmp/removeothers.sh:
#!/bin/bash
FNAME="$1"
if [[ $FNAME == \./\.git* ]] || [[ $FNAME == \./d3xp/* ]] || [[ $FNAME == \./game/* ]]
then
#echo "ignoring $FNAME"
exit 0
fi
if ! grep -Fxq "$FNAME" /tmp/d3sdklist.txt
then
#echo "REMOVING $FNAME"
rm -rf "$FNAME"
fi
exit 0
## /tmp/d3sdklist.txt was is just a textfile with one path per line with
all the files (and directories!) I wanted to keep, like:
.
..
./sys/platform.h
./framework/Game.h
./config.h.in
./CMakeLists.txt
## ... and all the relevant files from the SDK
This was only implemented with MSVC style asm.
Comments suggest that it was used to help catch invalid FOV calculations,
which were probably only happening with ancient compiler bugs.
Split fs_savepath for config files. This is in preparation for
moving the writable paths on *nix to $XDG_DATA_HOME and
$XDG_CONFIG_HOME.
Affected files: config.spec, *.cfg, doomkey, xpkey.
Sys_GetScanTable() and MapKey() are only used by the Windows backend
or the Windows-only tools.
Rename to Win_GetScanTable() and move MapKey() as Win_MapKey() to
win_input.cpp.
Get rid of the 2 CPUID flags and combine them with SSE in one
implementation.
SSE flags can now be set on all x86 and x86_64 platforms -
independent of -ffast-math.
Helper defines borrowed from STREFLOP.