Setup
- macOS on Apple Silicon (M4 Pro, arm64)
- Branch: master
- Build:
python3 waf configure && python3 waf build works fine
- Tried with Half-Life 2 + Source SDK Base 2013 Singleplayer assets
What happens
Build succeeds, engine boots, OpenGL initializes, VPK files load,
BSP loads and qhull starts processing collisions. Then it crashes
with SIGTRAP or SIGBUS during CreateGameWindow -> DrawStartupGraphic.
Found four separate issues while debugging. Worked around the first
three but stuck on the fourth. Sharing in case it helps.
1. IsOSX() macro returns false at runtime on macOS
File: public/tier0/platform.h:113-166
The macro depends on OSX being defined at compile time. waf doesn't
define it for game-code modules, so IsOSX() returns false on macOS.
This makes gameui/VGuiSystemModuleLoader.cpp:178 (and other places)
try to load .dll files instead of .dylib.
Worked around it by hardcoding servers/serverbrowser.dylib in
platform/steam/games/PlatformMenu.vdf.
Probably worth either defining OSX everywhere on macOS in the build,
or switching to #ifdef __APPLE__ for runtime detection.
2. togl stubs trigger DXABSTRACT_BREAK_ON_ERROR()
File: togl/linuxwin/dxabstract.cpp (53 occurrences)
A bunch of unimplemented DX9 functions call DXABSTRACT_BREAK_ON_ERROR()
which raises SIGTRAP. Several of them are on the normal startup path:
- Line 5751:
IDirect3DDevice9::SetTransform, called by
CommitPerPassStateChanges during DrawStartupGraphic
SetMaterial nearby (around line 5775) already has its assert
commented out, so it looks like these were meant to be silenced too.
Worked around it by commenting out all DXABSTRACT_BREAK_ON_ERROR() lines.
3. shaderapidx9 calls fixed-function wrappers that hit togl stubs
File: materialsystem/shaderapidx9/shaderapidx8.cpp:1458-1480
Three FORCEINLINE wrappers (SetTransform, SetLight, LightEnable)
call into togl's fixed-function API. With Source 2013's shader pipeline
these calls don't really do anything useful on macOS, but they hit the
togl stubs.
After silencing the asserts in #2, SetTransform started returning S_OK
without actually doing anything, which seems to have caused later draw
calls to read garbage and crash anyway.
Worked around by commenting out the Dx9Device()->... lines inside
the wrappers. Probably cleaner to wrap with #ifndef PLATFORM_OSX.
4. SIGBUS in vphysics qhull during BSP collision (still stuck)
After fixing 1-3 the engine gets further: BSP loads, qhull starts.
Then SIGBUS. qhull complains about denormal floats in vertex data:
Setup
python3 waf configure && python3 waf buildworks fineWhat happens
Build succeeds, engine boots, OpenGL initializes, VPK files load,
BSP loads and qhull starts processing collisions. Then it crashes
with SIGTRAP or SIGBUS during
CreateGameWindow->DrawStartupGraphic.Found four separate issues while debugging. Worked around the first
three but stuck on the fourth. Sharing in case it helps.
1. IsOSX() macro returns false at runtime on macOS
File:
public/tier0/platform.h:113-166The macro depends on
OSXbeing defined at compile time. waf doesn'tdefine it for game-code modules, so
IsOSX()returns false on macOS.This makes
gameui/VGuiSystemModuleLoader.cpp:178(and other places)try to load
.dllfiles instead of.dylib.Worked around it by hardcoding
servers/serverbrowser.dylibinplatform/steam/games/PlatformMenu.vdf.Probably worth either defining
OSXeverywhere on macOS in the build,or switching to
#ifdef __APPLE__for runtime detection.2. togl stubs trigger DXABSTRACT_BREAK_ON_ERROR()
File:
togl/linuxwin/dxabstract.cpp(53 occurrences)A bunch of unimplemented DX9 functions call
DXABSTRACT_BREAK_ON_ERROR()which raises SIGTRAP. Several of them are on the normal startup path:
IDirect3DDevice9::SetTransform, called byCommitPerPassStateChangesduringDrawStartupGraphicSetMaterialnearby (around line 5775) already has its assertcommented out, so it looks like these were meant to be silenced too.
Worked around it by commenting out all
DXABSTRACT_BREAK_ON_ERROR()lines.3. shaderapidx9 calls fixed-function wrappers that hit togl stubs
File:
materialsystem/shaderapidx9/shaderapidx8.cpp:1458-1480Three FORCEINLINE wrappers (
SetTransform,SetLight,LightEnable)call into togl's fixed-function API. With Source 2013's shader pipeline
these calls don't really do anything useful on macOS, but they hit the
togl stubs.
After silencing the asserts in #2,
SetTransformstarted returning S_OKwithout actually doing anything, which seems to have caused later draw
calls to read garbage and crash anyway.
Worked around by commenting out the
Dx9Device()->...lines insidethe wrappers. Probably cleaner to wrap with
#ifndef PLATFORM_OSX.4. SIGBUS in vphysics qhull during BSP collision (still stuck)
After fixing 1-3 the engine gets further: BSP loads, qhull starts.
Then SIGBUS. qhull complains about denormal floats in vertex data: