[video output=day575 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Generalizing Code Reloading" vod_platform=youtube id=Pax5jIz6m_Q annotator=Miblo]
[0:02][Welcome to the stream with an apparently successful build of TensorFlow][:admin :ai]
[2:05][Recap the current state of our :lighting][:speech]
[2:28][Demo our current :lighting][:run]
[3:45][Determine to hook up the in-game :audio recording][:run]
[4:13][Consider going over the :lighting with a fine tooth comb for some weeks, before leaving it with a view to maybe coming back to it at the end][:run]
[6:12][Note that our :lighting hierarchy and ray caster are working okay, but the summation and frame-to-frame persistence needs work][:research]
[7:54][Consider giving our :lighting values some real-world meaning, adding an exposure function, and creating :"debug visualisation"][:lighting :run]
[10:01][Set up to make the renderer hot reloadable][:"hot reloading" :library :research]
[13:53][Begin to generalise code reloading, introducing win32_loaded_code for win32_game_code to contain, and win32_renderer_code][:"hot reloading" :library]
[17:36][Introduce WIN32_LOADED_CODE_ENTRY_POINT and win32_game_function_table][:"hot reloading" :library]
[20:59][Remove win32_game_code with a view to switching Win32LoadGameCode() over to use our new win32_game_function_table and win32_loaded_code structs][:"hot reloading" :library]
[22:02][Introduce Win32GameFunctionTableNames\[\] for Win32LoadGameCode() to lookup into for its GetProcAddress() calls, augmenting win32_loaded_code with FunctionCount, FunctionNames, Functions and TempDLLNumber][:"hot reloading" :library]
[31:39][Update Win32UnloadGameCode() and WinMainCRTStartup() to use our new win32_loaded_code and Win32LoadCode()][:"hot reloading" :library]
[35:02][Consider welding win32_state into win32_loaded_code][:"hot reloading" :library :research]
[37:35][Augment win32_loaded_code with FullPath and LockFullPath][:"hot reloading" :library]
[38:54][Introduce Win32CheckForCodeChange() and Win32ReloadCode() for WinMainCRTStartup() to call, renaming win32_loaded_code.FullPath to DLLFullPath][:"hot reloading" :library]
[44:55][Fix compile errors][:"hot reloading" :library]
[45:59][The code loading works][:"hot reloading" :library :run]
[46:19][Make UpdateAndRenderWorld() position the DebugLightP higher up][:lighting]
[46:52][Verify that the code reloading works][:"hot reloading" :library :run]
[46:59][Make UpdateAndRenderWorld() position the DebugLightP as before][:lighting]
[47:04][Verify that the code reloading works][:"hot reloading" :library :run]
[47:15][Move onto making the renderer hot reloadable][:"hot reloading" :library :research]
[49:19][Introduce Win32RendererFunctionNames\[\] in the renderer, move Win32InitDefaultRenderer() into win32_renderer_test.cpp and weld Win32LoadRendererDLL() into it][:library]
[52:41][Introduce win32_renderer_function_table][:"hot reloading" :library]
[54:29][@sagian2005][Q: You can turn off the "assign with conditional expression" warning / error]
[54:49][Make WinMainCRTStartup() push win32_handmade_opengl.dll and lock.tmp through Win32BuildEXEPathFileName(), updating build.bat for renderer :"hot reloading"][:library]
[1:00:42][Update WinMainCRTStartup() to load the renderer using Win32LoadCode()][:"hot reloading" :library]
[1:04:05][The renderer code loading works][:"hot reloading" :library :run]
[1:04:11][Set up to reload the renderer][:"hot reloading" :library :research]
[1:06:51][Augment win32_renderer_function_table with BeginFrame and EndFrame, making build.bat export Win32BeginFrame() and Win32EndFrame(), and WinMainCRTStartup() operate on RendererFunctions][:"hot reloading" :library]
[1:10:30][Weld Win32InitDefaultRenderer() into RenderLoop()][:"hot reloading" :library]
[1:12:50][Verify that the renderer test loads][:"hot reloading" :library :run]
[1:13:19][Verify that [~hero Handmade Hero] loads][:"hot reloading" :library :run]
[1:13:43][Enable WinMainCRTStartup() to reload the renderer][:"hot reloading" :library]
[1:16:14][:Run the game][:"hot reloading" :library]
[1:16:34][Make OpenGLEndFrame() set the glClearColor to 1, 0, 1, 1][:rendering :"hot reloading" :library]
[1:17:12][Hit a "User-mode data execution prevention (DEP) violation"][:"hot reloading" :library :run]
[1:18:19][Make WinMainCRTStartup() handle not-loaded renderer, checking that RendererCode.IsValid before calling RendererCode.EndFrame(), and also issuing an "Unable to load renderer" fatal error][:"error handling" :"hot reloading" :library]
[1:27:02][Crash on OutputPlayingSounds()][:"hot reloading" :library :run]
[1:27:27][Fix WinMainCRTStartup() to correctly set the Frame][:"hot reloading" :library :rendering]
[1:27:55][:Run the game][:"hot reloading" :library]
[1:28:02][Recompile][:"hot reloading" :library]
[1:28:06][Hit a "User-mode data execution prevention (DEP) violation"][:"hot reloading" :library :run]
[1:28:46][Try to step in to Win32ReloadCode()][:"hot reloading" :library :run]
[1:29:53][:Run in debug mode, recompile and break on the RenderCode Win32ReloadCode() call, to find that the problem is in OpenGLEndFrame()][:"hot reloading" :library]
[1:33:17][Try unsuccessfully to break on Win32ReloadCode()][:"hot reloading" :library :run]
[1:35:18][Recompile and break on Win32ReloadCode(), then hit our "User-mode data execution prevention (DEP) violation" before entering OpenGLEndFrame()][:"hot reloading" :library :run]
[1:36:15][Rerun and find that our breakpoint no longer works][:"hot reloading" :library :run]
[1:36:45][Check build.bat for buggy reloading][:"hot reloading" :library :research]
[1:37:40][Recompile without ~RemedyBG running, step on to OpenGLEndFrame() and find the Renderer to be invalid][:"hot reloading" :library :run]
[1:40:47][Build afresh, :run the game and rebuild, and step to Win32ReloadCode() to find that the Platform pointer is already NULL][:"hot reloading" :library]
[1:42:25][platform_renderer.TotalFramebufferMemory // TODO(casey): Reenable this!][:rendering]
[1:43:04][Continue to step through Win32LoadCode() to find that it pushes handmade_temp.dll through Win32BuildEXEPathFileName()][:"hot reloading" :library]
[1:43:36][Augment win32_loaded_code with TransientDLLName for Win32LoadCode() to use][:"hot reloading" :library]
[1:47:29][Build afresh, :run the game and rebuild, to still hit the "User-mode data execution prevention (DEP) violation"][:"hot reloading" :library]
[1:48:12][Continue to step through Win32LoadCode(), inspect the TempDLLName and realise that it always fails to copy once][:"hot reloading" :library]
[1:50:16][Fix Win32LoadCode() to increment TempDLLNumber before every attempt to Copy][:"hot reloading" :library]
[1:51:44][Continue to step through Win32LoadCode() and on through OpenGLEndFrame(), to hit our "User-mode data execution prevention (DEP) violation" on glBindBuffer()][:"hot reloading" :library]
[1:53:40][Find that our ~RemedyBG breakpoint issue is unresolved][:"hot reloading" :library :run]
[1:54:19][Remove the *temp.dll files][:admin :"hot reloading" :library]
[1:54:38][:Run and rebuild the game, watching the *temp.dll files be created][:"hot reloading" :library]
[1:55:52][Get a new dotahero][:admin]
[1:56:43][Ponder ~RemedyBG's breakpoint confusion][:"hot reloading" :library :speech]
[1:57:46][Wonder why we're jumping to an unknown function][:"hot reloading" :library :speech]
[1:58:17][:Run, rebuild, step in to OpenGLEndFrame() and inspect the OpenGL struct][:"hot reloading" :library]
[1:59:51][Remember that our OpenGL functions reside in a dll-local table, and must be reinitialised][:"hot reloading" :library :speech]
[2:01:32][Augment open_gl with our OpenGL functions, renaming OpenGLGlobalFunction() to OpenGLFunction()][:library :rendering]
[2:08:23][Make our OpenGL context available to all OpenGL-calling functions, and Win32InitOpenGL() initialise our OpenGL functions][:library :rendering]
[2:17:04][Make PlatformOpenGLSetVSync() initialise wglSwapIntervalEXT specially][:library :rendering]
[2:19:27][:Run and rebuild the game successfully][:"hot reloading" :library]
[2:20:21][Prevent OpenGLEndFrame() from setting the glClearColor to 1, 0, 1, 1][:rendering :"hot reloading" :library]
[2:20:43][Hot-reload the game successfully][:"hot reloading" :library :run]
[2:20:57][Make OpenGLEndFrame() halve the RenderWidth][:rendering]
[2:21:16][Hot-reload the game successfully][:"hot reloading" :library :run]
[2:21:25][Prevent OpenGLEndFrame() from halving the RenderWidth][:rendering]
[2:21:30][Hot-reload the game successfully][:"hot reloading" :library :run]
[2:21:53][Q&A][:speech]
[2:22:46][@longboolean][Q: A :lighting question (but it also has applications in :meteorology): Do you know of any algorithms to compute "shadow" or "no shadow" for all future February 2nds (assuming Gregorian calendar), or are we simply stuck with the Punxsutawney Phil algorithm, the current but rather limited state of the art?]
[2:23:28][@alexkelbo][Q: Sorry, I missed it. What did you use TensorFlow for?]
[2:23:44][@vaualbus][Q: Is not faster to load shader from file and change them on the fly when the file is modified?][:"hot reloading" :library]
[2:24:16][@internationalizationist][Q: Khronos org says that we should load procs by wglGetProcAddress and, if it fails, then load :library opengl32.dll and GetProcAddress. In which situations is it relevant? Or I missed something?][:"hot reloading"]
[2:24:46][@maliusarth][Q: Would you recommend the OpenGL struct function table for versioned C libs?][:library]
[2:25:16][@kniffel5][Q: If you wanted to implement Stereoscopic 3D, are there OpenGL functions specifically for that (making it easier) or would you have to do everything manually?][:rendering]
[2:27:09][@thetamiel][Q: You mentioned there being no standard way to interface with graphics and the politics behind it. Do you see a specific reason why console manufacturers couldn't push hardware vendors for standardisation and have that standard bleed out into general computing?]
[2:28:19][@the_8th_mage][Q: If it matters, I once implemented a network in C++ from TensorFlow and it was faster single threaded by order of magnitude compared to the 28 core multithreaded TensorFlow implementation][:performance]
[2:28:57][@said6289][@handmade_hero Is the same OpenGL context being used after renderer reload?][:"hot reloading" :library]
[2:29:54][@maliusarth][Q: For APIs with the requirement of being downwards compatible and introducing breaking changes is only allowed in a second API struct][:api]
[2:32:03][@ormone88][Q: Tomorrow is my first day of work at a AAA company. How do I jump into a huge codebase (UE4) that I know very little of? I am a little bit intimidated also by the "object-orientedness" of the engine]
[2:37:21][@shredz7][Q: Have you heard of IPFS? I know you don’t like web stuff, but IPFS seems to be redesigning the web to be content-addressed and simpler... It doesn't get rid of HTML and all that crap but I think it’s a step forward. What do you think of it?][:"file system" :networking]
[2:38:12][@geekpanther][IPFS: Interplanetary :"file system". A decentralized file system which is Hash Based Mapping on the Nodes on the network for file lookup rather than the location of a file][:networking]
[2:41:46][@geekpanther][Take a look: IPFS[ref
    site="IPFS Powers the Distributed Web"
    url=https://ipfs.io/#how]][:"file system" :networking]
[2:43:49][@geekpanther][Yeah, There's more to it. Take a look at the Whitepaper.[ref
    author="Juan Benet"
    title="IPFS - Content Addressed, Versioned, P2P File System (DRAFT 3)"
    url=https://github.com/ipfs/papers/raw/master/ipfs-cap2pfs/ipfs-p2p-file-system.pdf] It is cool][:"file system" :networking]
[2:47:40][@ginger_bill][@handmade_hero Are they even trying to solve that problem? It appears they are trying to make an extremely public :"file system"][:networking]
[2:48:26][@ambiguous_panda][Q: I think that no single node on the network has 100% of a file, so you can only request an incomplete fragment, which will make it harder for the node hosting it to guess what it is][:"file system" :networking]
[2:50:56][@internationalizationist][Q: (Again off-topic) Do you know some (good) resources that explains how the internet works? You said that it cannot be used as a backbone of internet, but I don't understand why][:"file system" :networking]
[2:54:54][Close it down][:speech]
[/video]
