Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VK Out of memory on MacBook Pro M1 #970

Open
bigianb opened this issue Jan 17, 2025 · 5 comments
Open

VK Out of memory on MacBook Pro M1 #970

bigianb opened this issue Jan 17, 2025 · 5 comments

Comments

@bigianb
Copy link

bigianb commented Jan 17, 2025

Running on MacBook Pro M1 (16Gb) - compiled using Xcode from latest.
Copied base dir over from GOG version and then copied the base folder in GitHub over that.

All is good until starting a new campaign. The first map loads but then I hit an out of memory error with Vulkan. I can dig into it more but first wanted to know if this is unexpected. Also, am I missing a step somewhere? I seem to be missing env maps but I didn't see them in the download from moddb - I don't think that would cause the error though.

Tail of the output looks like:

151 warnings
  3267 msec to load game/mars_city1
Sending networkSync cvars:
pm_staminathreshold = 4
pm_noclipspeed = 300
pm_runspeed = 275
pm_walkspeed = 175
pm_crouchspeed = 100
Execution of the command buffer was aborted due to an error during execution. Caused GPU Address Fault Error (0000000b:kIOGPUCommandBufferCallbackErrorPageFault)
[mvk-error] VK_ERROR_OUT_OF_DEVICE_MEMORY: MTLCommandBuffer "vkQueueSubmit MTLCommandBuffer on Queue 0-0" execution failed (code 3): Caused GPU Address Fault Error (0000000b:kIOGPUCommandBufferCallbackErrorPageFault)
libc++abi: terminating due to uncaught exception of type vk::DeviceLostError: vk::Device::getSemaphoreCounterValue: ErrorDeviceLost
Message from debugger: killed
Program ended with exit code: 9

Full log is as follows (I removed some repetitive lines ... and noted where).

QA Timing INIT: 000779ms
RBDOOM 3 BFG 1.6.0.1403 osx-aarch64 Jan 16 2025 22:45:13
loopback
192.168.1.238/255.255.255.0
no 'base' directory in exe path /Users/ian/doom/RBDOOM-3-BFG/xcode-release/Release/RBDoom3BFG.app/Contents/MacOS, skipping
------ Initializing File System ------
Loaded resource file _common.resources

< removed lines >

file system initialized.
--------------------------------------
WARNING: Unable to open resource file maps/_startup.resources
WARNING: Unable to open resource file maps/_startup.resources
----- Initializing Decls -----
------------------------------
Couldn't open journal files
CPU processors: 10
CPU logical cores: 10
execing default.cfg
execing D3BFGConfig.cfg
couldn't exec autoexec.cfg
----- R_InitOpenGL -----
Initializing Vulkan subsystem
Enabled Vulkan instance extensions:
    VK_EXT_metal_surface
    VK_KHR_surface
    VK_EXT_debug_report
    VK_KHR_get_physical_device_properties2
Enabled Vulkan layers:
Disabled MoltenVK's synchronous queue submits...
Enabled MoltenVK's Metal argument buffers...
Enabled Vulkan device extensions:
    VK_EXT_memory_budget
    VK_EXT_descriptor_indexing
    VK_EXT_debug_marker
    VK_KHR_synchronization2
    VK_KHR_buffer_device_address
    VK_KHR_portability_subset
    VK_KHR_maintenance1
    VK_KHR_swapchain
Created Vulkan device: Apple M1 Pro
----- Initializing Render Shaders -----
Loading shader program builtin/gui
Loading shader program builtin/color
Loading shader program builtin/color
Loading shader program builtin/vertex_color

< removed some lines >

sound system initialized.
--------------------------------------
------- Initializing renderSystem --------
renderSystem initialized.
--------------------------------------
Skipping Intro Videos!
Reading strings/english.lang as UTF-8
9104 strings read
--------- Initializing Game ----------
gamename: baseDOOM-1
gamedate: Jan 16 2025
WARNING: file def/_tb_models.def, line 5230: entityDef 'genmodel_mapobjects_monitors_hangingmonitor' previously defined at def/_tb_models.def:5216
Initializing event system
...543 event definitions
Initializing class hierarchy
...159 classes, 1016496 bytes for event callbacks
Initializing scripts
couldn't read systclbyname
measured CPU frequency: 1001.06 MHz
Compiled 'script/doom_main.script': 3043879662 ms
---------- Compile stats ----------

Memory usage:
     Strings: 120, 15840 bytes
  Statements: 95386, 3052352 bytes
   Functions: 3070, 496728 bytes
   Variables: 239712 bytes
    Mem used: 5818032 bytes
 Static data: 5811160 bytes
   Allocated: 8111952 bytes
 Thread size: 14064 bytes

...6 aas types
game initialized.
--------------------------------------
OpenAL Error: Invalid Enum (0xa002), @ /Users/ian/doom/RBDOOM-3-BFG/neo/sound/OpenAL/AL_SoundSample.cpp 631
WARNING: Couldn't load image: } : }#__0200
Loaded Bink file: 'video/intro/introloop.bik', looping=1, 512x512, 30.00 FPS, 12.0 sec
Loaded Bink file: 'video/mars1.bik', looping=0, 512x512, 30.00 FPS, 32.2 sec
Loaded Bink file: 'video/mars_rotation.bik', looping=1, 1567x406, 30.00 FPS, 100.0 sec
----- idRenderModelManagerLocal::EndLevelLoad -----
    0 models purged from previous level,     3 models kept.
---------------------------------------------------
----- idImageManager::EndLevelLoad -----
WARNING: Couldn't load image: } : }#__0200
WARNING: Couldn't load image: _cinematicY : _cinematicY#__0200
WARNING: Couldn't load image: _cinematicCr : _cinematicCr#__0200
WARNING: Couldn't load image: _cinematicCb : _cinematicCb#__0200
WARNING: Couldn't load image: _cinematic : _cinematic#__0200
WARNING: Couldn't load image: _cinematicY : _cinematicY#__0200
WARNING: Couldn't load image: _cinematicCr : _cinematicCr#__0200
WARNING: Couldn't load image: _cinematicCb : _cinematicCb#__0200
WARNING: Couldn't load image: _cinematic : _cinematic#__0200
WARNING: Couldn't load image: _cinematicY : _cinematicY#__0200
WARNING: Couldn't load image: _cinematicCr : _cinematicCr#__0200
WARNING: Couldn't load image: _cinematicCb : _cinematicCb#__0200
WARNING: Couldn't load image: _cinematic : _cinematic#__0200
   29 images loaded in   0.0 seconds
----------------------------------------
----- idSoundSystemLocal::EndLevelLoad -----
    7 sounds loaded in   0.0 seconds
----------------------------------------
------------- Warnings ---------------
during DOOM 3: BFG Edition initialization...
WARNING: Unable to open resource file maps/_startup.resources
WARNING: file def/_tb_models.def, line 5230: entityDef 'genmodel_mapobjects_monitors_hangingmonitor' previously defined at def/_tb_models.def:5216
WARNING: Couldn't load image: } : }#__0200
WARNING: Couldn't load image: _cinematicY : _cinematicY#__0200
WARNING: Couldn't load image: _cinematicCr : _cinematicCr#__0200
WARNING: Couldn't load image: _cinematicCb : _cinematicCb#__0200
WARNING: Couldn't load image: _cinematic : _cinematic#__0200
7 warnings
Preloading images...
00362 images preloaded ( or were already loaded ) in   0.1 seconds
----------------------------------------
00259 sounds preloaded in   0.1 seconds
----------------------------------------
WARNING: Couldn't load image: _doomclassic : _doomclassic#__0200
WARNING: Couldn't load image: _doomclassic : _doomclassic#__0200
--- Common Initialization Complete ---
QA Timing IIS: 004109ms
WARNING: terminal type 'dumb' is unknown. terminal support may not work correctly
terminal support enabled ( use +set in_tty 0 to disabled )
pid: 44095
ViewBridge to RemoteViewService Terminated: Error Domain=com.apple.ViewBridge Code=18 "(null)" UserInfo={com.apple.ViewBridge.error.hint=this process disconnected remote view controller -- benign unless unexpected, com.apple.ViewBridge.error.description=NSViewBridgeErrorCanceled}
Added local user: Ians-MBP
Opening IP socket: localhost:27015
execing joy_righty.cfg
execing joy_360_0.cfg
NET: PartyToken is 31299 (seed = 94538)
--------- Execute Map Change ---------
Map: game/mars_city1
--------- Game Map Shutdown ----------
--------------------------------------
     1 msec to unload map
    51 msec to free assets
Preloading images...
02180 images preloaded ( or were already loaded ) in   0.4 seconds
----------------------------------------
00305 models preloaded ( or were already loaded ) in   0.1 seconds
----------------------------------------
00551 sounds preloaded in   0.3 seconds
----------------------------------------
Preloading anims...
00630 anims preloaded ( or were already loaded ) in   0.1 seconds
----------------------------------------
----- SetupLightGrid -----

area 0 of 56 (21 x 18 x 5) = 1890 grid points 
area 0 grid size (64 64 128)
area 0 grid bounds (21 18 5)
area 0: 0 of 1890 grid points in empty space (0.00%)

area 1 of 56 (17 x 17 x 55) = 15895 grid points 
area 1 grid size (160 144 208)
area 1 grid bounds (17 17 55)
area 1: 1011 of 15895 grid points in empty space (6.36%)

< removed similar logs >

area 55 of 56 (3 x 3 x 1) = 9 grid points 
area 55 grid size (64 64 128)
area 55 grid bounds (3 3 1)
area 55: 0 of 9 grid points in empty space (0.00%)
----------------------------------
Total valid light grid points 53655
------- Game Map Init SaveGame -------
collision data:
   425 models
 30834 vertices (722 KB)
 54572 edges (1918 KB)
 44488 polygons (3300 KB)
  8144 brushes (1145 KB)
 12573 nodes (589 KB)
 43839 polygon refs (684 KB)
 14455 brush refs (225 KB)
 18344 internal edges
  1463 sharp edges
     0 contained polygons removed
     0 polygons merged
  8587 KB total memory used
9 msec to load collision data.
Preloading collision models...
00183 collision models preloaded ( or were already loaded ) in   0.0 seconds
----------------------------------------
map bounds are (19640.0, 22168.0, 29496.0)
max clip sector is (1227.5, 1385.5, 1843.5)
    2 KB passage memory used to build PVS
    0 msec to calculate PVS
   56 areas
  110 portals
    9 areas visible on average
  448 bytes PVS data
[Load AAS]
loading maps/game/mars_city1.aas48
done.
[Load AAS]
loading maps/game/mars_city1.aas96
[Load AAS]
loading maps/game/mars_city1.aas_guardian
[Load AAS]
loading maps/game/mars_city1.aas_mancubus
[Load AAS]
loading maps/game/mars_city1.aas_sabaoth
[Load AAS]
loading maps/game/mars_city1.aas_cyberdemon
Loaded Bink file: 'sound/vo/video/mfs.bik', looping=0, 256x256, 30.00 FPS, 88.8 sec
Loaded Bink file: 'video/marscity/monoflyby.bik', looping=0, 256x256, 31.25 FPS,  2.7 sec
Loaded Bink file: 'video/marscity/dropship.bik', looping=0, 256x256, 31.25 FPS,  6.8 sec
Loaded Bink file: 'video/marscity/ship.bik', looping=0, 256x256, 30.00 FPS,  4.7 sec
Loaded Bink file: 'video/marscity/decom.bik', looping=1, 128x128, 30.00 FPS,  4.3 sec
Loaded Bink file: 'video/marscity/sci_team_request.bik', looping=0, 256x256, 30.00 FPS,  8.8 sec
Loaded Bink file: 'sound/VO/video/video_ipn_news.bik', looping=0, 256x256, 30.00 FPS, 187.4 sec
Loaded Bink file: 'sound/VO/video/video_marine_sops.bik', looping=0, 256x256, 30.00 FPS, 72.9 sec
Loaded Bink file: 'sound/VO/video/video_plasmagun.bik', looping=0, 256x256, 30.00 FPS, 47.8 sec
Loaded Bink file: 'sound/VO/video/video_uac_welcome.bik', looping=0, 256x256, 30.00 FPS, 80.4 sec
WARNING: marscity_cinematic_sarge_1 has no AAS file
WARNING: marscity_cinematic_sarge2_1 has no AAS file
WARNING: marscity_cinematic_player_sarge has no AAS file
--------------------------------------
----- idRenderModelManagerLocal::EndLevelLoad -----
    0 models purged from previous level,  1037 models kept.
---------------------------------------------------
----- idImageManager::EndLevelLoad -----
WARNING: Couldn't load image: _emptyname : _emptyname#__0200
WARNING: Couldn't load image: env/maps/game/mars_city1/area1_envprobe_1131__1293_75_amb : env/maps/game/mars_city1/area1_envprobe_1131__1293_75_amb#__2105
WARNING: Couldn't load image: env/maps/game/mars_city1/area1_envprobe_1131__1293_75_spec : env/maps/game/mars_city1/area1_envprobe_1131__1293_75_spec#__2105
WARNING: Couldn't load image: env/maps/game/mars_city1/area1_envprobe_1297__1645_49_amb : env/maps/game/mars_city1/area1_envprobe_1297__1645_49_amb#__2105
WARNING: Couldn't load image: env/maps/game/mars_city1/area1_envprobe_1297__1645_49_spec : 

< removed many similar warnings about env maps >

env/maps/game/mars_city1/area55_envprobe__3392__3072_264_amb#__2105
WARNING: Couldn't load image: env/maps/game/mars_city1/area55_envprobe__3392__3072_264_spec : env/maps/game/mars_city1/area55_envprobe__3392__3072_264_spec#__2105
WARNING: Couldn't load image: _cinematicY : _cinematicY#__0200
WARNING: Couldn't load image: _cinematicCr : _cinematicCr#__0200
WARNING: Couldn't load image: _cinematicCb : _cinematicCb#__0200
WARNING: Couldn't load image: _cinematic : _cinematic#__0200
WARNING: Couldn't load image: _cinematicY : _cinematicY#__0200
WARNING: Couldn't load image: _cinematicCr : _cinematicCr#__0200
WARNING: Couldn't load image: _cinematicCb : _cinematicCb#__0200

< removed repeated warnings about cinematic >

 4137 images loaded in   0.7 seconds
----------------------------------------
----- idSoundSystemLocal::EndLevelLoad -----
  160 sounds loaded in   0.2 seconds
----------------------------------------
----- Generating Interactions -----
idRenderWorld::GenerateAllInteractions, msec = 31
interactionTable size: 5871152 bytes
31865 interactions take 2294280 bytes
Used 4667kb of static vertex memory (3%)
Used 3566kb of static index memory (2%)
------------- Warnings ---------------
during game/mars_city1...
WARNING: Couldn't load image: _emptyname : _emptyname#__0200
WARNING: Couldn't load image: env/maps/game/mars_city1/area1_envprobe_1131__1293_75_amb : env/maps/game/mars_city1/area1_envprobe_1131__1293_75_amb#__2105
WARNING: Couldn't load image: env/maps/game/mars_city1/area1_envprobe_1131__1293_75_spec : env/maps/game/mars_city1/area1_envprobe_1131__1293_75_spec#__2105

< removed lots of similar env maps warnings >

WARNING: Couldn't load image: env/maps/game/mars_city1/area55_envprobe__3392__3072_264_spec : env/maps/game/mars_city1/area55_envprobe__3392__3072_264_spec#__2105
WARNING: Couldn't load image: _cinematicY : _cinematicY#__0200
WARNING: Couldn't load image: _cinematicCr : _cinematicCr#__0200
WARNING: Couldn't load image: _cinematicCb : _cinematicCb#__0200
WARNING: Couldn't load image: _cinematic : _cinematic#__0200
151 warnings
  3267 msec to load game/mars_city1
Sending networkSync cvars:
pm_staminathreshold = 4
pm_noclipspeed = 300
pm_runspeed = 275
pm_walkspeed = 175
pm_crouchspeed = 100
Execution of the command buffer was aborted due to an error during execution. Caused GPU Address Fault Error (0000000b:kIOGPUCommandBufferCallbackErrorPageFault)
[mvk-error] VK_ERROR_OUT_OF_DEVICE_MEMORY: MTLCommandBuffer "vkQueueSubmit MTLCommandBuffer on Queue 0-0" execution failed (code 3): Caused GPU Address Fault Error (0000000b:kIOGPUCommandBufferCallbackErrorPageFault)
libc++abi: terminating due to uncaught exception of type vk::DeviceLostError: vk::Device::getSemaphoreCounterValue: ErrorDeviceLost
Message from debugger: killed

@bigianb
Copy link
Author

bigianb commented Jan 17, 2025

Could be a dupe of #940. I’m just running a vanilla compile of latest master. Not set any options.

@SRSaunders
Copy link

SRSaunders commented Jan 19, 2025

Yes, quite possibly a dup of #940. You could verify by testing with the following cvar change:

+set r_useHierarchicalDepthBuffer 0 (on the command line, in the console, or in autoexec.cfg).

I am also experimenting with a better fix for Apple Silicon by disabling the use of MoltenVK's Metal Argument Buffers. This would allow blood reflections to continue working (which requires the HiZ Depth Buffer). You could test this as an alternative:

+set r_mvkUseMetalArgumentBuffers 0 (must be on the command line or in autoexec.cfg, cannot change in console).

Please let me know if either of these things work for you.

(@RobertBeckebans I believe the root cause may be a driver limitation where shader subgroups do not work properly in all circumstances on macOS/MoltenVK and possibly on linux for iGPUs - note this feature is used in the hiz compute shader. I am playing around with MoltenVK settings to see if I can overcome the problem for Apple Silicon. I currently don't have a solution for linux iGPUs other than disabling HiZ).

@bigianb
Copy link
Author

bigianb commented Jan 19, 2025

with +set r_useHierarchicalDepthBuffer 0 on command line

-[MTLDebugDevice notifyExternalReferencesNonZeroOnDealloc:]:3347: failed assertion `The following Metal object is being destroyed while still required to be alive by the command buffer 0x1549fec00 (label: vkQueueSubmit MTLCommandBuffer on Queue 0-0):
<MTLToolsObject: 0x600005e301c0> -> <AGXG13XFamilyBuffer: 0x120e2a040>
    label = Argument buffer 
    length = 40 
    cpuCacheMode = MTLCPUCacheModeDefaultCache 
    storageMode = MTLStorageModeShared 
    hazardTrackingMode = MTLHazardTrackingModeTracked 
    resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked  
    purgeableState = MTLPurgeableStateNonVolatile'

So different in not a memory issue. Looks like a synchronisation issue.

with +set r_mvkUseMetalArgumentBuffers 0 on command line

pm_crouchspeed = 100
Sys_Error: setComputeState: 
pipeline is NULL.

shutdown terminal support

With both of them - it works ... but it really slow. I can't remember how to show the FPS but I guess it was running at around 10 FPS

@SRSaunders
Copy link

SRSaunders commented Jan 20, 2025

@bigianb thanks for trying out those settings. However, I am a bit confused about needing both. When I test on my M1 Air, all I need is +set r_mvkUseMetalArgumentBuffers 0. Note your first error actually points to the argument buffer issue. Without this cvar setting (and Metal Validation set to off in Xcode) I get:

[mvk-error] VK_ERROR_OUT_OF_DEVICE_MEMORY: Lost VkDevice after MTLCommandBuffer "vkQueueSubmit MTLCommandBuffer on Queue 0-0" execution failed (code 3): Caused GPU Address Fault Error (0000000b:kIOGPUCommandBufferCallbackErrorPageFault)
Sys_Error: Device Removed!
shutdown terminal support

With Metal Validation set to on in Xcode I get the same Metal Debug error as you indicate above. In any case, with the r_mvkUseMetalArgumentBuffers cvar set to 0, the game launches and loads levels properly, albeit with slow performance as you note above.

The more important issue now becomes the macOS+M1 performance limitation that exists on the master branch. This is due to the way the game pushes shader parameters to MoltenVK and the M1 GPU. To solve this, I am maintaining a parallel branch that changes the way this is done and is more performant on macOS in general and especially on Apple Silicon. This branch is up to date with master and you can test it at #855. However, until I submit a more permanent fix for the Metal Argument Buffers issue to master (and rebase my branch), you will still have to +set r_mvkUseMetalArgumentBuffers 0, or put this in autoexec.cfg.

Please try out my custom branch and let me know how it goes for your machine.

FYI - to show FPS, first enable the console (set com_allowConsole 1 on cmd line or autoexec.cfg). Drop it down using "~", and then enter com_showFPS 1 (simple), 2 (more stats), 3 (tons of detail).

@bigianb
Copy link
Author

bigianb commented Jan 20, 2025

cool. I'll give that a go in the next day or so and let you know..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants