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

72 lines
8.2 KiB
Plaintext
Raw Normal View History

2018-02-05 22:20:13 +00:00
[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Entity-based Lighting Storage" vod_platform=youtube id=NX-tdvLd0RA annotator=Miblo]
[0:07][Recap and set the stage for the day, improving the runtime performance of the :lighting][:optimisation :rendering :speech]
[0:56][:Run the game to show our whole world, only excepting the trees, lit][:lighting :rendering]
[4:43][Consider the two ways of optimising the :lighting solution to only process the necessary elements][:optimisation :rendering :speech]
[6:11][Prevent PushCube() from pushing on elements outside the bounds of the :lighting solution, using a new LightBounds in render_group][:optimisation :rendering]
[10:58][:Run the game and hit the assert in GetHashFromID()]
[11:18][Make PushCube() clear the first LightIndexStore][:lighting :rendering]
[11:33][:Run the game to see no :lighting on anything][:rendering]
[12:06][Make EnableLighting() take a rectangle3 LightingBounds, and UpdateAndRenderWorld() pass the entire SimBounds to it][:lighting :optimisation :rendering]
[13:24][:Run the game to see the whole world lit][:lighting :optimisation :rendering]
[13:49][Introduce smaller LightBounds in UpdateAndRenderWorld() to pass to EnableLighting()][:lighting :optimisation :rendering]
[15:00][:Run the game to see a speed increase because some of the world is not participating in the :lighting solution][:optimisation :rendering]
[15:26][Further shrink the LightBounds in UpdateAndRenderWorld()][:lighting :optimisation :rendering]
[15:38][:Run the game to see yet more speedup, but buggy behaviour with the light apparently wrapping][:lighting :optimisation :rendering]
[20:01][Consider how to visualise the :lighting solution][:"debug visualisation" :rendering :speech]
[23:41][Potential bugs - correctness and :performance - in the :lighting solution][:blackboard :rendering]
[32:08][:Run the game and note the impossibility of diagnosing our :lighting bug without visualising lighting elements][:"debug visualisation" :rendering]
[34:58][Read carefully through PushCube() for potential bugs][:lighting :rendering :research]
[36:14][Determine to allocate :lighting elements responsibly][:memory :rendering]
[38:02][Introduce a free list for the :lighting solution, replacing LightPointCount in game_render_commands with a u16 FirstFreeLightingChunk, adding NextFree to lighting_point and making PushCube() free and reuse light chunks][:memory :rendering]
[53:36][Consider how to determine when an entity holding light indices no longer needs them][:lighting :memory :rendering :speech]
[54:24][Add a LightPointUsed array to game_render_commands for PushCube() to store light point usage][:lighting :memory :rendering]
[55:53][Implement FreeLightChunk() and LightChunkFrameSweep()][:lighting :memory :rendering]
[1:00:17][Make WinMain() clear the :lighting :memory every frame before :rendering, and fix compile errors][:"platform layer"]
[1:03:58][Encounter the problem of handling lights scattered about the array, and avoiding processing stuff that doesn't exist][:lighting :optimisation :rendering :speech]
[1:10:37][Replace Solution->PointCount with LIGHT_POINTS_PER_CHUNK in OutputLightingPoints() and OutputLightingTextures()][:lighting :memory :rendering]
[1:13:45][Prevent LightingTest() from setting the PointCount, and make it copy the whole set of :lighting indices][:memory :optimisation :rendering]
[1:15:28][Note that we are doing everything on an allocation basis][:lighting :memory :rendering :speech]
[1:16:05][Make DefaultRenderCommands() take and initialise LightChunkUsed][:lighting :memory :rendering]
[1:17:25][Note that LightChunkFrameSweep() skips Chunk 0 and builds the free list backwards][:lighting :memory :rendering :speech]
[1:19:44][Replace Solution->PointCount with LIGHT_POINTS_PER_CHUNK in ComputeLightPropagation()][:lighting :memory :rendering]
[1:24:23][Add u8 *LightChunkUsed to lighting_solution][:lighting :rendering]
[1:25:03][:Run the game and hit the assert in FreeLightChunk()][:lighting :memory :rendering]
[1:26:28][Consider how to confirm which entity occupied a light chunk][:lighting :memory :rendering :speech]
[1:28:48][Temporarily make PushCube() take a u32 EntityID][:lighting :memory :rendering]
[1:30:20][Consider making entities store their previous :lighting information, and use a hot list of regions rather than a free list][:"entity system" :optimisation :rendering]
[1:32:01][Make PushCube() instead take a lighting_point *LightStore and u32 LightCount]
[1:34:29][Add an array of lighting_point Points to the entity struct][:"entity system" :lighting :memory :rendering]
[1:37:40][The problem of sharing :lighting points between entities][:blackboard :"entity system" :rendering]
[1:41:43][Large sets of :lighting points][:blackboard :"entity system" :rendering]
[1:45:55][Spatially merging :lighting points][:blackboard :"entity system" :rendering]
[1:47:55][Prevent PushCube() from taking LightCount and managing a free list][:lighting :memory :rendering]
[1:48:52][Replace EmitC0 from game_render_commands with Emission in lighting_box, and add lighting_point *Storage to lighting_box][:lighting :rendering]
[1:55:22][Remove FreeLightChunk() and LightChunkFrameSweep()][:lighting :memory :rendering][quote 611]
[1:55:55][Restore PointCount to lighting_solution and move the light point generation code from PushCube() into LightingTest()][:lighting :memory :rendering]
[1:59:18][Store full arrays rather than pointers in lighting_solution, and introduce lighting_point_state for lighting_box to store][:lighting :memory :rendering]
[2:01:47][Make LightingTest() copy out the :lighting solution per element][:memory :rendering]
[2:03:14][Replace LastIsValid in lighting_solution with StorageContentsAreValid in lighting_box and propagate this change to LightingTest()][:lighting :memory :rendering]
[2:11:37][Move the finalisation code from ComputeLightPropagation() to LightingTest()][:memory :rendering]
[2:13:08][Consider a better way to solve the :lighting across frames][:rendering :speech]
[2:16:18][Begin to enable LightingTest() to handle both cases of storage contents validity][:lighting :memory :rendering]
[2:18:39][Consider packing the :lighting data tighter][:memory :rendering :speech]
[2:22:37][Make LightingTest() use alternate storage if the storage contents are not valid, and prevent OutputLightingTextures() from looping over the chunks][:lighting :memory :rendering]
[2:26:05][Finish enabling LightingTest() to blend the :lighting if the storage contents are valid, and fix compile errors][:memory :rendering]
[2:37:25][Remove StorageContentsAreValid from lighting_box and instead make LightingTest() check if the normal of the first :lighting point is valid][:rendering]
[2:39:34][:Run the game and crash in LightingTest()][:lighting :rendering]
[2:39:57][Try to make LightingTest() correctly set the FirstPoint][:lighting :memory :rendering]
[2:40:29][:Run the game, crash in LightingTest() and inspect the values to find that Box->Storage is not valid][:lighting :memory :rendering]
[2:41:36][Assert in LightingTest() that LightPointIndex <= LIGHT_DATA_WIDTH, and temporarily try hard setting the LightStore->Direction to 1, 1, 1][:lighting :memory :rendering]
[2:42:14][:Run the game to determine that the pulling out, rather than pushing on, of boxes is the problem][:lighting :memory :rendering]
[2:42:55][Step in to LightingTest() and inspect the Solution->Boxes to find that they are all garbage][:lighting :memory :rendering :run]
[2:43:29][Make UpdateAndRenderWorld() run the :lighting solution before EndSim()][:rendering]
[2:44:19][:Run the game to see that the Boxes look valid, but that the LightBoxCount is greater than expected, and investigate why][:lighting :memory :rendering]
[2:46:09][Step in to LightingTest() and realise that it is erroneously operating on the new set of boxes][:lighting :memory :rendering :run]
[2:46:46][Make LightingTest() store and iterate over the OriginalBoxCount][:lighting :memory :rendering]
[2:47:04][:Run the game to see that we're at least running but totally wrong][:lighting :rendering]
[2:48:16][Q&A][:speech]
[2:49:58][@billdstrong][Q: The 148 Mil was the number of cycles the :lighting took][:performance :rendering]
[2:50:18][@mallesbixie][Q: Is this your usual design process, a bit ad hoc?]
[2:52:14][Wrap it up][:speech]
[/video]