[video output=day498 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Finishing Asset System Cleanup" vod_platform=youtube id=aQyYn_y2Tcg annotator=Miblo]
[0:00][Recap and set the stage for the day finishing our :"asset system" cleanup][:speech]
[0:49][Reacquaint ourselves with the renderer_texture queueing / dequeuing code][:"asset system" :rendering :research]
[5:00][Split AddOp() into newly introduced functions CompleteTextureOp() and BeginTextureOp()][:rendering]
[12:36][Texture transfer buffer size and circularity][:"asset system" :memory :rendering :speech]
[16:05][Implement the texture transfer buffer as an in-order circular buffer, augmenting texture_op_list with TransferMemory and related data][:"asset system" :memory :rendering]
[33:28][Determining the available space in a circular buffer, in both the wrapped and unwrapped cases][:blackboard :"data structure"]
[34:40][Make BeginTextureOp() compute the SizeAvailable in both cases][:"asset system" :memory :rendering]
[40:03][Switch InitTextureQueue() to our new TransferMemory circular buffer scheme][:"asset system" :memory :rendering]
[43:27][Tie the game's :"platform layer" and OpenGL renderer in to our TransferMemory][:hardware :memory :rendering]
[51:22][Switch the Renderer Test to use our TransferMemory][:memory :"platform layer" :rendering]
[53:37][Switch OpenGLAllocateTextures() to our TransferMemory][:hardware :memory :rendering]
[1:10:16][Introduce platform_renderer_limits][:rendering]
[1:13:37][Make the Renderer Test use our TransferMemory everywhere necessary][:memory :"platform layer" :rendering]
[1:20:12][Step in to LoadBMP() in the Renderer Test to see what we're getting][:memory :rendering :run]
[1:24:06][Fix BeginTextureOp() to increase the TransferMemoryUsedCount][:memory :rendering]
[1:25:31][Step through LoadBMP() in the Renderer Test into BeginTextureOp() to see what it does][:memory :rendering :run]
[1:27:39][Fix BeginTextureOp() to enqueue an op when there is enough space available][:memory :rendering]
[1:27:59][Continue to step through BeginTextureOp() into OpenGLManageTextures() to find that it all works][:memory :rendering :run]
[1:31:24][:Run the Renderer Test in release mode, and consider stress testing our TransferMemory wrapping][:memory :rendering]
[1:32:33][Switch the game's :"asset system" over to our TransferMemory][:memory :rendering]
[1:35:41][Break][:speech]
[1:36:35][Make LoadFont() acquire its own :memory specially, introducing KeepTemporaryMemory()][:"asset system" :font]
[1:42:19][Switch OutputPlayingSounds() over to use its special sliding window sample buffer][:audio :memory]
[1:49:08][Switch the whole game to use our new platform_renderer_limits, and AllocateGameAssets() to use our TransferMemory][:"asset system" :"data structure" :memory]
[1:53:51][Hit an assertion in OpenGLManageTextures()][:hardware :rendering :run]
[1:54:30][Fix that assertion in OpenGLManageTextures()][:hardware :rendering]
[1:54:45][Hit the assertion in GetBitmap()][:hardware :rendering :run]
[1:55:50][Permit GetBitmap(), GetSoundSamples() and GetFont() to handle any asset with ID 0][:"asset system"]
[1:56:34][:Run the game okay, see only grey, and step through LoadBitmap() and LoadAssetWork() to see what's going on][:"asset system"]
[2:00:38][Make LoadAssetWork() clear the work :memory up front][:"asset system"]
[2:02:44][Step through LoadAssetWork() and then on to OpenGLManageTextures() to see what happens with our bitmaps][:"asset system" :memory]
[2:05:38][Fix LoadBMP() to set the Asset->TextureHandle][:"asset system" :memory]
[2:06:55][Find that everything except the white texture loaded correctly][:"asset system" :run]
[2:07:29][Fix AllocateGameAssets() to set the Op->Texture for our white texture][:"asset system"]
[2:08:08][Find that everything works fine][:"asset system" :run]
[2:09:19][Implement texture flushing for our "Import & Save" button, introducing UnloadBitmap()][:"asset system"]
[2:14:32][Try out our "Import & Save" button, totally successfully][:"asset system" :run]
[2:15:54][Q&A][:speech]
[2:16:44][@b3zman41][Q: What is going on in your optimized build?]
[2:17:23][@b3zman41][Q: Are you optimizing assets or something? I just wanted to know what it looks like]
[2:19:49][@gg_nate][Q: Why don't you have any moderators for twitch chat?[ref
    site="Handmade Network"
    page="\[Tutorial\] Handmade Network IRC"
    url=https://handmade.network/blogs/p/1138-%5Btutorial%5D_handmade_network_irc]]
[2:20:30][@b3zman41][Q: So MSVC just doesn't do all the inlining stuff by default? Sorry, I'm more of a web dev and don't get this low-level stuff]
[2:21:03][Walk through ComputeLightPropagation() and its disassembly in a debug build][:asm :run]
[2:23:57][Compare the ComputeLightPropagation() assembly in optimised build][:asm :run]
[2:25:51][@blamebauer][Q: Newbie question: Wouldn't inlining every function call speed things up? Does the compiler do that when you turn optimizations on?[ref
    site=WikiChip
    page="Core i7-7700K - Intel"
    url=https://en.wikichip.org/wiki/intel/core_i7/i7-7700k]][:performance]
[2:33:41][Understanding the "inline" keyword as an advisory to the compiler][:language :performance :speech]
[2:36:09][Close it down][:speech]
[/video]
