cinera_handmade.network/cmuratori/hero/code/code216.hmml

58 lines
5.1 KiB
Plaintext

[video output=day216 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="On-demand Deallocation" vod_platform=youtube id=lPnPNaC-KJg annotator=Miblo]
[0:34][On easing the burden of returning to code after a break]
[2:43][Recap and set the stage for the day]
[3:05][build.bat: Turn the debug system back on and assess our situation]
[4:28][Run the game and note that the Last frame time looks weird]
[5:41][handmade_debug.cpp: Consider making FreeFrame work and be called]
[7:55][handmade_debug_interface.h: Talk through the debug system]
[15:23][handmade_debug.cpp: Consider looking at elements over multiple frames]
[20:35][handmade_debug.cpp: Consider implementing FreeFrame]
[21:47]["You'll have to excuse me if I yawn during this frame"][quote 295]
[21:58][handmade_debug.h: Look at debug_frame]
[23:53][Blackboard: "Debug Element"]
[30:50][handmade_debug_interface.h: Consider making the debug_table be a giant buffer]
[33:39][Blackboard: Using a giant 64 MiB buffer]
[41:01][handmade.h: Consider providing the ability to allocate memory on demand]
[42:57][Yawn][quote 296]
[43:45][handmade.h: Pass the entire AllocationCode to FREELIST_ALLOCATE]
[46:40][handmade_debug.cpp: Consider proving a way to free on demand or give memory_arena the ability to handle memory allocation]
[47:58][handmade.h: Introduce ArenaHasRoomFor and GetEffectiveSizeFor]
[51:22][handmade_debug.cpp: Introduce PushSizeWithDeallocation]
[56:48][handmade_debug.cpp #define DebugPushStruct]
[57:24][handmade.h: Fix compile errors]
[58:32][handmade_debug.cpp: Replace PushStruct with DebugPushStruct]
[59:05][handmade_debug.cpp: Pass the correct values to DebugPushStruct]
[59:48][handmade_debug.cpp: #define DebugPushCopy]
[1:00:51][handmade_debug.cpp: Continue fixing compile errors]
[1:01:23][handmade_debug.cpp: #define DebugPushStruct and consider building in the Push functions to the arenas proper]
[1:02:52][Compile and run the game, run out of memory and hit our "Not implemented"]
[1:03:48][Q&A][:speech]
[1:04:15][@m1el][Have you heard of the DTrace tool? It allows dynamic tracing on running binaries and also kernel! (Not available on windows, though)]
[1:04:38][@elxenoaizd][You mentioned in the prestream a 'dynamic' memory_arena. How does that actually work since we allocate memory only once? What happens when the arena is full?]
[1:05:45][@mojo123X][You've mentioned the term "Collation" on this episode and several previous episodes. What exactly do you mean when you use that term?]
[1:06:37][@Mpact][What keyboard do you use?]
[1:06:54][@elxenoaizd][Could you elaborate a bit more on what 'memory alignment' means?[ref
site="Handmade Hero Episode Guide"
page="Handmade Hero Day 127: Aligning Rendering Memory"
url="https://hero.handmadedev.org/videos/game-architecture/day127.html"]]
[1:08:37][@elxenoaizd][But wouldn't asking the OS for more memory expose more failure points thus be against Handmade Hero memory philosophy? Since the whole point of our scheme was that we're sure once we run the game we can't crash]
[1:10:39][@elxenoaizd][I'm always hesitant when using Linked Lists in engine and gameplay code (debug code is fine) because of their cache unfriendliness, random access of memory and difficulty in debugging (you'd have to dig down a node to find what you're looking for). Do you think it's not that big of a deal and I'm worrying too much?]
[1:15:02][@jim0_o][I'm debugging on Day 121. Do you used int instead of int32 for any reason?]
[1:15:24][handmade.cpp and handmade_debug.cpp: Replace int with u32]
[1:16:56][@andsz_][libs like the stb libs let you specify a custom malloc / free function. How would you integrate that into an arena-based system?]
[1:17:54][@elxenoaizd][Have you heard of VMem?]
[1:18:03][@elxenoaizd][If we wanted to use object pools (reusable / recyclable objects for enemies, for example), where would be the best place to store them? Permanent or transient memory? I guess they wouldn't be in transient cause the whole game shares the same pool, so I guess permanent?]
[1:18:54][@elxenoaizd][reinterpret_cast, static_cast and dynamic_cast: are they of any good use?]
[1:19:33][@andsz_][There are libs that allow allocating and freeing multiple chunks of memory during runtime. How would you specify malloc / free for them in an arena-based game like Handmade Hero?]
[1:21:26][@jim0_o][The int use in question was a lot in SIMD'ing DrawRectangle -> DrawRectangleQuickly, and my version of the code is crashing on "Access violation reading location" when casting Pixel to __m128i at the start. Could iterating with int vs int32 be the reason?]
[1:22:11][@elxenoaizd][What do you think of pass by reference and references? I think they obfuscate the code because it's harder now to see from the calling site to find out if an object is passed by value (copy) or we are actually passing an address of it to modify it]
[1:25:47][Wind it down][:speech]
[1:26:54][Announcement: Handmade Hero Forums are now hosted on HandmadeDev.org[ref
site="HandmadeDev"
page="Handmade Hero Central"
url="https://hero.handmadedev.org/jace/schedule/"]][:speech]
[1:28:04][Announcement: HandmadeCon 2015[ref
site="HandmadeCon"
url="http://handmadecon.org/"]][:speech]
[/video]