diff --git a/cmuratori/hero/code/code623.hmml b/cmuratori/hero/code/code623.hmml new file mode 100644 index 0000000..dc22453 --- /dev/null +++ b/cmuratori/hero/code/code623.hmml @@ -0,0 +1,122 @@ +[video output=day623 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Investigating a Lighting Bug" vod_platform=youtube id=Jmqh6zkd7j0 annotator=Miblo] +[0:01][Recap and set the stage for the day][:speech] +[1:22][Reacquaint ourselves with the :lighting bug][:run] +[2:11][The :lighting works in -Od][:run] +[2:41][Check out the :lighting and asset bugs manifested in -O2][:"asset system" :run] +[4:20][Investigate the monstar asset absence][:"asset system" :research] +[7:16][Make PlaceSnake() add the Undead tag][:"asset system"] +[7:32][Our monstar's head asset now appears][:"asset system" :run] +[8:11][Our downward-facing asset direction is not working][:"asset system" :run] +[9:09][Refamiliarise ourselves with the facing direction code in GetAsetFrom()][:"asset system" :research] +[11:30][We are unexpectedly in power mode][:admin] +[12:15][@ryanfleury][@handmade_hero Hahaha sorry, probably a bug. You can disallow it if you want to turn it off] +[13:28][Continue to reacquaint ourselves with GetAssetFrom()][:"asset system" :research] +[15:24][Make GetAssetFrom() set D1 equal to D0][:"asset system"] +[15:47][See no difference in the asset picking][:"asset system" :run] +[16:33][Remove the tag range mapping from GetAssetFrom() and game_assets][:"asset system" :"data structure"] +[17:43][Our asset picking is still fine][:"asset system" :run] +[17:55][False alarm with our tau-based facing direction computation][:"asset system" :research] +[21:09][~4coder feature request: Line overflow indicators][:admin] +[21:31][Plug the circle stuff in Star Code Galaxy[ref + site="Star Code Galaxy" + url=https://starcodegalaxy.com]][:mathematics :speech] +[21:48][Map the facing direction to 0–1 when adding the asset tags][:"asset system"] +[24:54][Change base_game.hht to try and trigger a rebuild][:admin :"asset system"] +[25:03][:Run the game][:"asset system"] +[25:16][Make UpdateAndRenderEntities() import the facing directions in the correct tau space][:"asset system"] +[25:45][Our facing directions are now remapped, still without downward][:"asset system" :run] +[26:09][Pushing Alt provokes a flash][:run] +[26:52][Reacquaint ourselves with the facing directions :art][:admin :"asset system"] +[27:57][@vaualbus][@handmade_hero There are some "big" codegen bug reported and fixed lately] +[28:13][Consider our possible problems causing the downward facing bug][:"asset system" :research] +[31:00][The downward facing bug exists in -Od][:"asset system" :run] +[31:28][Add a BreakHere in UpdateAndRenderEntities() for facing direction > 0.6][:"asset system"] +[32:11][Try to break in to UpdateAndRenderEntities()][:"asset system" :run] +[33:30][@vaualbus][Then they broke old vs new version ability to debug programs because they fucked the pdb somehow. That has been fixed in preview 4 after I reported it] +[33:46][A few words on not updating MSVC][:speech] +[34:10][@x13pixels][This one seems like a ~RemedyBG bug. Probably not MSVC this time!] +[34:31][@x13pixels][Should be able to, yes] +[34:49][Update ~RemedyBG to v0.3.3.3][:admin] +[39:19][Try unsuccessfully to break in to UpdateAndRenderEntities()][:"asset system" :run] +[40:03][Try adding a __debugbreak() in UpdateAndRenderEntities()][:"asset system"] +[40:48][Weird things are happening, and the __debugbreak() did not trigger][:"asset system" :run] +[41:33][Add a more general __debugbreak() in UpdateAndRenderEntities()][:"asset system"] +[41:44][Successfully break in to UpdateAndRenderEntities()][:"asset system" :run] +[42:04][Investigate our settings of FacingDirection][:"asset system" :research] +[43:31][Our orphans are not drawn][:"asset system" :run] +[44:13][PlaceOrphan() sets FacingDirection to 0.75*Tau32, and ExecuteBrainHero() uses ATan2()][:"asset system" :research] +[46:48][Make UpdateAndRenderEntities() shift negative facing directions to the 0.5–1.0 range][:"asset system"] +[48:50][Our hero's downward facing direction now works][:"asset system" :run] +[49:29][Investigate our orphan absence][:"asset system" :research] +[52:46][Tag the orphan bodies in line with the heads in base_game.hht][:admin :"asset system"] +[54:55][Our orphans are back, but facing the wrong direction][:"asset system" :run] +[57:18][See if our orphans' facing direction may be overwritten][:"asset system" :research] +[1:01:14][Break in to PlaceOrphan()][:"asset system" :run] +[1:02:30][Add a __debugbreak() in UpdateAndRenderEntities() if Facing > 0.5][:"asset system"] +[1:03:11][Break in to UpdateAndRenderEntities() on Facing > 0.5][:"asset system" :run] +[1:04:03][Break in to PlaceOrphan() and add a data break point on FacingDirection][:"asset system" :run] +[1:05:12][Recall the Clear in entity][:"data structure" :"entity system"] +[1:05:44][Our orphan's original entity :memory is being reclaimed][:"asset system" :run] +[1:06:45][Consult EnsureRegionIsUnpacked() for bugs][:"asset system" :research] +[1:07:51][Each orphan is not a full entity, but a gen_entity][:"entity system" :research] +[1:10:46][Fix GenerateRoom() to copy the FacingDirection of pending entities][:"entity system"] +[1:11:40][Break in to UpdateAndRenderEntities() on Facing > 0.5][:"asset system" :run] +[1:12:38][Check out our orphans in -O2][:"asset system" :run] +[1:13:26][Align our orphans' head and body][:"asset system" :run :ui] +[1:23:08][Our :lighting now appears to work in -O2][:run] +[1:24:52][Provoke our :lighting bug][:run] +[1:27:07][@redunlocked][Q: If I remember correctly, this bug was introduced when you added the fade on load. Maybe it's a race condition with that on-load fade?][:lighting] +[1:27:32][Traverse the orphanage][:lighting :run] +[1:28:19][Scour the :"entity system" for our :lighting bug][:research] +[1:30:16][Scour the :lighting system itself for our bug][:research] +[1:33:16][Make UpdateLighting() single-thread the :lighting][:threading] +[1:33:24][Provoke our :lighting bug single-threaded][:run :threading] +[1:35:04][~insobot feature request: Auto-timeout on mentioning rust][:language] +[1:35:30][Continue to investigate our :lighting bug][:research] +[1:38:32][Introduce ValidateAtlas()][:lighting] +[1:44:33][Trigger ValidateAtlas()][:lighting :run] +[1:45:06][Change ValidateAtlas() to return a bool, so that UpdateLighting() may continue despite invalidation][:lighting] +[1:49:00][Our SpecValid and DiffuseValid values do not align with the actual bug][:lighting :run] +[1:49:22][Why our validation and the bug may not align: 1) Too tight bounds; 2) Invalid values that don't normally contaminate things][:lighting :research] +[1:50:03][Widen the bounds in ValidateTexelComponent()][:lighting] +[1:50:24][Our :lighting atlases still fail validation][:run] +[1:51:42][Tighten the bounds in ValidateTexelComponent()][:lighting] +[1:51:57][Watch our :lighting validation][:run] +[1:53:35][Our intro cutscene doesn't work][:run] +[1:54:25][Q&A][:speech] +[1:55:13][@mextroxtm][Q: Do you render the computed light bounces into a texture?][:lighting] +[1:58:51][@guybru5h_vi][Q: Do you ever suffer from decision paralysis when making a new feature?] +[2:01:08][@stuntcoder][Q: When do you plan on releasing Star Code Galaxy[ref + site="Star Code Galaxy" + url=https://starcodegalaxy.com]?] +[2:01:14][@rooctag][Q: Was the bug mostly in the start area? Once you start walking it was better][:lighting] +[2:01:32][@x13pixels][Q: For the breakpoint at handmade_entity.cpp line 295 I believe what we were seeing was that the DLL wasn't yet loaded and the breakpoint wasn't yet resolved (hence the "?" icon). I think letting [~hero Handmade Hero] run will eventually resolve the breakpoint and hit it. At least that is what I'm seeing here] +[2:02:04][Break successfully in to UpdateAndRenderEntities()][:"asset system" :run] +[2:02:49][@xamolxix][Q: Can you please go into more detail about the :lighting floating point and cache inefficiency?] +[2:04:47][@centhusiast][Q: What is the best game sound track you have ever listened to?] +[2:05:46][@vironacorus][Q: Hey, you mentioned programs used to debug port usage. Could you name some, so I can check them out? Also, can you explain execution port "notation" on uops, e.g. 1*p06 for CMOVL (conditional move)? Thanks!] +[2:06:15][Understanding uops.info[ref + site=uops.info + url=https://uops.info/table.html]][:research] +[2:12:52][Understanding uops analysis in Compiler Explorer[ref + site="Compiler Explorer" + url=https://godbolt.org]][:research] +[2:19:03][Example loop uops analysis in Compiler Explorer[ref + site="LLVM 10 Documentation" + page="llvm-mca - LLVM Machine Code Analyzer" + url=https://www.llvm.org/docs/CommandGuide/llvm-mca.html][ref + site="Compiler Explorer" + url=https://godbolt.org]][:research] +[2:26:58][@peterfors][Q: Has to be inside the scope] +[2:27:22][Example manual goto loop uops analysis in Compiler Explorer[ref + site="Compiler Explorer" + url=https://godbolt.org][ref + site=uops.info + url=https://uops.info/table.html]][:research] +[2:39:01][@internationalizationist][Q: So what tool do you use on your projects? IACA?] +[2:40:00][@gnarlyquack][Looks like there's an open-source tool called OSACA[ref + site="Georg Hager's Blog" + page="Open Source Architecture Code Analyzer (OSACA) has been released" + url=https://blogs.fau.de/hager/archives/8045] that's meant to be a replacement for IACA] +[2:41:22][Wrap it up][:speech] +[/video]