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

114 lines
11 KiB
Plaintext
Raw Permalink Normal View History

[video output=day590 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Starting Raycast Optimizations" vod_platform=youtube id=cprFjrly3BU annotator=Miblo]
[0:02][Welcome to the stream with a plug of the post-stream stream on [@naysayer88 Jon Blow]'s channel[ref
site=twitch
page=naysayer88
url=https://twitch.tv/naysayer88]]
[1:45][Demo our stochastically sampled :lighting, with the determination to optimise the ray caster][:optimisation :run :sampling]
[4:28][Check the :lighting :performance :statistics][:run]
[6:53][Calculate our ray casting cycle budget: 2000 cycles per cast][:admin :lighting :performance]
[9:06][Consider our scope for optimising RayCast()][:lighting :optimisation :performance :research]
[11:04][Comment out two unwanted ifs from RayCast()][:lighting :optimisation]
[11:23][\~350k cycles (70% frame time) spent in 6144 calls to FullCast()][:lighting :performance :run]
[14:09][Make ComputeLightPropagationWork() call the ray caster in a checkerboard pattern][:lighting :optimisation]
[16:48][Check out our :lighting][:run]
[17:19][Toggle on the light maps viewers in OpenGLEndFrame()][:"debug visualisation" :lighting]
[17:41][Check out the light maps][:"debug visualisation" :lighting :run]
[18:00][Make OpenGLChangeToSettings() zoom out of the light maps][:"debug visualisation" :lighting]
[18:44][Check out the light maps][:"debug visualisation" :lighting :run]
[19:09][Double-check out checkerboard code in ComputeLightPropagationWork()][:lighting :optimisation :research]
[20:01][Consider our checkerboard to be correct][:lighting :run]
[20:26][Make ComputeLightPropagationWork() checkerboard the ray caster calls in X][:lighting :optimisation]
[21:06][Check out the checkerboard light maps][:"debug visualisation" :lighting :run]
[21:34][Make ComputeLightPropagationWork() flip the checkerboard mode each frame][:lighting :optimisation]
[23:03][\~175k cycles (62% frame time) spent in 3072 calls to FullCast()][:lighting :performance :run]
[23:59][Make OpenGLChangeToSettings() zoom in to the light maps, and toggle them off in OpenGLEndFrame()][:"debug visualisation" :lighting]
[24:19][Admire our :lighting][:run]
[24:46][@xxthebigfoxx][This makes the propagation twice as slow, though, right?][:lighting]
[26:03][Consider our scope for optimising RayCast(): Casting against bundles of boxes][:lighting :optimisation :performance :research]
[31:42][Ray cast against bundles of boxes, respecifying RayCast() as BoxWiseRayCast() and introducing lighting_box_4x][:"data structure" :lighting :optimisation :performance]
[36:29][Consider how best to determine whether to push a box onto the stack or record a hit][:lighting :optimisation :research]
[40:27][Spec out the box bundle pushing in BoxWiseRayCast(), written to hopefully generate a conditional move][:lighting :optimisation]
[44:46][Consider approaching box-bundle ray casting another way][:lighting :optimisation :research]
[46:48][Consider turning this into a codex-style problem: Writing what we can do, then encoding a hierarchy that accommodates what we've written][:lighting :optimisation :research]
[51:10][Try making BoxWiseRayCast() always load 4-wide, and set a mask as it descends the box hierarchy, introducing light_box_stack_entry][:"data structure" :lighting :optimisation]
[55:12][Consider what the mask gains us][:lighting :optimisation :research]
[56:40][Write our dream version of box-bundle ray casting][:lighting :optimisation]
[57:30][Consider how to push the boxes most efficiently][:lighting :optimisation :research]
[58:43][Work through efficient box bundle pushing in BoxWiseRayCast(), removing light_box_stack_entry and augmenting lighting_box with IsLight_IsLeafContainer][:"data structure" :lighting :optimisation]
[1:08:11][20ms per frame, without ray casting][:lighting :optimisation :performance :run]
[1:08:41][Make SplitBox() set IsLight_IsLeafContainer][:lighting :optimisation]
[1:11:58][The ray casting doesn't fully happen][:lighting :optimisation :run]
[1:12:25][Scour SplitBox() for possible bugs][:lighting :optimisation :research]
[1:14:07][Check the :lighting :performance :statistics: 0 TotalPartitionsTested, 0 TotalPartitionLeavesUsed][:run]
[1:14:25][Scour RayCast() for possible bugs][:lighting :optimisation :research]
[1:15:50][Step in to RayCast(), wondering if ~RemedyBG can freeze threads][:lighting :optimisation :run]
[1:16:35][Disable multithreading in EndLightingComputation()][:threading]
[1:17:00][Step in to RayCast(), see TotalPartitionsTested increment on the first frame, but not on subsequent frames][:lighting :optimisation :run]
[1:21:14][Enable SplitBox() to unset LightBox_IsLeafContainer if it did split][:lighting :optimisation]
[1:22:30][50ms per frame, single-threaded, with a correctly lit world][:lighting :optimisation :performance :run]
[1:23:08][Enable multithreading in EndLightingComputation()][:threading]
[1:23:18][20ms per frame, with a correctly lit world][:lighting :optimisation :performance :run]
[1:25:25][Stop timing FullCast() and ComputeLightPropagationWork()][:"debug system" :lighting :optimisation :performance]
[1:26:11][20ms per frame, EndLightingComputation and Frame Display vying for the top consumer spot][:lighting :optimisation :performance :run]
[1:27:10][Disable the checkerboard in ComputeLightPropagationWork()][:lighting :optimisation]
[1:27:28][30ms per frame, 50% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:28:07][Toggle off the speculardiffuse transform in ComputeLightPropagationWork()][:lighting :optimisation]
[1:28:33][30ms per frame, 47% frame time in Frame Display, 40% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:28:44][Toggle on the speculardiffuse transform in ComputeLightPropagationWork()][:lighting :optimisation]
[1:28:51][2230ms per frame, up to 5070% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:29:36][Try making SplitBox() split boxes into eight][:lighting :optimisation]
[1:29:50][24ms per frame, 67% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:29:58][Try making SplitBox() split boxes into two][:lighting :optimisation]
[1:30:03][24ms per frame, 67% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:30:07][Try making SplitBox() split boxes into four][:lighting :optimisation]
[1:30:11][24ms per frame, 67% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:30:23][Consider casting more rays, four out of the same slot][:lighting :optimisation :research]
[1:31:46][30ms per frame, 48% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:31:56][Toggle off the speculardiffuse transform in ComputeLightPropagationWork()][:lighting :optimisation]
[1:31:58][30ms per frame, 44% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:32:08][Toggle on the speculardiffuse transform in ComputeLightPropagationWork()][:lighting :optimisation]
[1:32:10][30ms per frame, 48% frame time in EndLightingComputation][:lighting :optimisation :performance :run]
[1:32:26][Toggle off the speculardiffuse transform in ComputeLightPropagationWork()][:lighting :optimisation]
[1:32:29][24ms per frame][:lighting :optimisation :performance :run]
[1:32:40][Toggle on the speculardiffuse transform in ComputeLightPropagationWork()][:lighting :optimisation]
[1:32:44][26ms per frame][:lighting :optimisation :performance :run]
[1:33:17][Decrease tUpdateBlend from 8/60 to 4/60 in EndLightingComputation()][:lighting :optimisation]
[1:33:29][Check out the :lighting flicker][:optimisation :performance :run]
[1:33:42][Decrease tUpdateBlend from 4/60 to 1/60 in EndLightingComputation()][:lighting :optimisation]
[1:33:46][Check out the :lighting flicker][:optimisation :performance :run]
[1:33:56][Increase tUpdateBlend from 1/60 to 2/60 in EndLightingComputation()][:lighting :optimisation]
[1:33:58][Check out the :lighting flicker, looking for a stable solution][:optimisation :performance :run]
[1:34:36][Increase tUpdateBlend from 2/60 to 4/60 in EndLightingComputation()][:lighting :optimisation]
[1:34:44][Check out the :lighting flicker][:optimisation :performance :run]
[1:34:48][Decrease tUpdateBlend from 4/60 to 2/60 in EndLightingComputation()][:lighting :optimisation]
[1:34:51][Check out the :lighting flicker, and consider basing the tUpdateBlend on the light's contribution][:optimisation :performance :run]
[1:36:00][Increase tUpdateBlend from 2/60 to 8/60 in EndLightingComputation()][:lighting :optimisation]
[1:36:09][Check out the :lighting flicker][:optimisation :performance :run]
[1:36:52][Try making FullCast() oversample by 4×, modifying the EntropyIndex each loop][:lighting :optimisation :sampling]
[1:38:05][Check out the :lighting flicker][:optimisation :performance :run :sampling]
[1:38:48][Set tUpdateBlend to 2/60 in FullCast()][:lighting :optimisation]
[1:39:05][Admire the flicker-free :lighting][:optimisation :performance :run]
[1:39:43][Remove the oversampling from FullCast()][:optimisation :performance :run :sampling]
[1:42:23][Admire the :lighting][:optimisation :run]
[1:42:37][Q&A][:speech]
[1:43:04][@jim0_o][Q: Did you notice the instability in :timing was connected to the hovering text in the debug UI? The dip seemed correlated with the cursor being on the bar indicating the dip in the debug UI. (When you left the cursor on the same bar it had the dip every time it was passed over, not sure how logical that is.)]
[1:44:20][@srekel][Damn, the scrolling in your editor is just silky smooth, @cmuratori. Is it Emacs, ~4coder?]
[1:44:30][@elegacorp][Q: What do you think causes the flickering in these :lighting calculations? Folks in the chat were discussing it: Do you want the flicker that exists to be more intentional or is it there as a strange side effect of how the lighting is implemented?][:sampling]
[1:46:09][Integration Over Spatial Samples][:blackboard :lighting :sampling]
[1:50:03][@coder_gimmic][Q: As previously mentioned in chat, both isLight and IsLeafContainer were 0x1]
[1:50:17][Fix LightBox_IsLight to be 0x2][:lighting]
[1:51:05][@philoez98][Q: Talking about character :movement, will we implement a transaction system, something like [@naysayer88 Jon]'s?]
[1:52:45][Check [@naysayer88 Jon]'s status[ref
author="Jonathan Blow"
publisher=Twitter
title="People liked the discussion I did with Casey last week about character animation. So we're doing another one, about writing parsers for programming languages. This will happen tomorrow (Sunday) at 2:30pm PST!
I'll post the link when the time comes."
url=https://twitter.com/Jonathan_Blow/status/1244108520133292032]]
[1:53:47][@fcatalan][Q: Is this already the best lit 2-but-3D game in the whole history of gaming?][:lighting]
[1:54:06][@emperormetallix][Q: Are you using a diffusion / heat model to average the texture samples over space / time?][:lighting]
[1:58:52][@star_prankster][Q: Is it okay to use some features from later versions of C++ I may find useful, e.g. lambdas, templates?][:language]
[2:03:52][@jim0_o][Q: Would you mind explaining Transactional and vs. What?]
[2:08:08][Stop the recording now][:speech]
[/video]