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

34 lines
3.1 KiB
Plaintext

[video output=day343 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Saving and Restoring Dynamically Allocated Memory Pages" vod_platform=youtube id=MSDl5-akNLE annotator=Miblo]
[0:03][Recap and set the stage for the day]
[4:07][Run the game to demo the current situation with regards to the looped live code editing]
[6:11][win32_handmade.h: Introduce a win32_memory_block struct and add a MemorySentinel to win32_state to enable us to iterate over the memory blocks]
[10:07][win32_handmade.cpp: Enable PLATFORM_ALLOCATE_MEMORY() and PLATFORM_DEALLOCATE_MEMORY() to handle multiple linked memory blocks]
[21:20][Note a caveat: This linked list is not thread-safe]
[22:50][win32_handmade.cpp: Make PLATFORM_ALLOCATE_MEMORY() thread-safe]
[25:34][win32_handmade.cpp: Think through how to enable Win32BeginRecordingInput() and Win32BeginInputPlayBack() to handle multiple memory blocks]
[30:11][win32_handmade.cpp: Get rid of MapViewOfFile() and Win32GetReplayBuffer() and other cruft]
[35:48][win32_handmade.h: Introduce win32_saved_memory_block struct and enable Win32BeginInputPlayBack() to play from blocks of that type]
[41:05][win32_handmade.cpp: Enable Win32BeginRecordingInput() and Win32EndRecordingInput() to handle multiple blocks]
[47:03][Reflect on what we've done, run the game, crash in a Win32DeallocateMemory() call and investigate why]
[51:19][Reproduce the bug and investigate what's happening]
[53:23][win32_handmade.cpp: Make the linked list in PLATFORM_ALLOCATE_MEMORY() thread-safe]
[54:22][Run the game and try in vain to reproduce the bug, before describing what was happening]
[55:09][Run the game again and crash in inside KernelBase.dll in Win32BeginInputPlayBack()]
[56:25][win32_handmade.cpp: Make Win32BeginInputPlayBack() pass &BytesRead to ReadFile()]
[57:31][Run the game and find that that fixed it]
[58:55][win32_handmade.cpp: Make Win32BeginRecordingInput() pass &BytesWritten to WriteFile()]
[59:23][Run the game and determine that we're not quite reloading correctly]
[59:59][Q&A][:speech]
[1:00:51][@soysaucethekid][Could you explain the padding you used for the memory struct? I believe you said it was for cache-line stuff, so if you omitted it, would it just result in more cache line misses or would it crash the game?]
[1:03:15][@fangk20][How did you get to where you are today and how did you do it, in terms of coding knowledge?[ref
site="Molly Rocket"
page="Meet the Team: Casey Muratori"
url="https://mollyrocket.com/news_0003.html"]]
[1:04:04][@torgdor][It's a bit early to ask, but will there be a HandmadeCon 2017?]
[1:06:28][@jeemjam420][Would you recommend any specific resource for learning C++? So far I've been using the "learncpp" website]
[1:06:45][@zilarrezko][Have you ever used a rope to manipulate strings?]
[1:08:31][@randolfbat][Aren't you going to read in pages that have been deallocated?]
[1:11:51][@snoringtortoise][So with memory systems, do you always try to put extra bits of data at the end to ensure if they ask for memory from a specific address then it doesn't ruin their day?]
[1:13:22][Close it down with a glimpse into the future][:speech]
[/video]