[video output=day189 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Incremental Debug Frame Processing" vod_platform=youtube id=87V4GNfqTpY annotator=Miblo annotator=debiatan]
[0:10][Recap and plan for today]
[1:53][Current features of the debug display]
[2:49][We want to be able to expand the top-level debug bars]
[3:17][Should the debug bars be horizontal?]
[4:04][Turning the chart sideways]
[9:12][Fixing the height of the bars]
[10:00][The debug rectangles don't fit in the screen even running an optimized build]
[11:01][Reviewing FrameRateWait]
[13:06][Turning FrameRateWait off]
[13:39][DebugCollation is very expensive]
[15:24][Processing frames incrementally to reduce collation time]
[16:45][We want to avoid restarting the collation on each new frame]
[18:12][We will restart the collation when we run out of frame storage]
[18:30][Implementing RestartCollation]
[19:25][Testing. It works]
[19:38][Collating events in sweeps]
[20:12][Restarting at the last event array index we used]
[22:02][Storing the collation array index inside debug_state]
[22:48][Testing that the game still runs]
[23:00][Restarting collation when we run out of frames]
[24:44][Adding CollationFrame to the debug_state]
[25:38][Testing. It still takes a lot of time to run the event collation. Where is it spent?]
[27:39][Are we hitting the debug event limit and restarting every frame?]
[28:16][Testing. Collation still takes a lot of time]
[29:18][Optimization makes it tolerable]
[30:00][Why does right-clicking turn the debug display off?]
[31:46][It happens both in optimized and non-optimized mode...]
[32:10][Let's step through the code to debug this issue]
[33:17][Why is DebugState not initialized?]
[34:15][We never DebugState->initialized to true!]
[34:50][And that solves the collation slowness problem]
[36:03][Let's expand the timing bars]
[37:07][Right now, we are throwing away all timing blocks under the top level]
[37:34][Instead of showing the descendants of the top-level block, we will show the timing blocks whose source is a particular debug_record]
[40:45][Implementing GetRecordFrom]
[41:27][ScopeToRecord will allow us to move down the hierarchy of debug records]
[42:38][When the left mouse button is pressed over a debug block, we'll set ScopeToRecord]
[43:20][Testing it. It does nothing]
[44:40][We need to recollate the events when we select a time block]
[46:20][Implementing RefreshCollation]
[46:34][Testing. It crashes]
[46:56][Performing the collation refresh at the end of DEBUGOverlay]
[49:10][Testing. It works now but sometimes we still hit the maximum limit of regions per frame]
[51:20][Implementing TextOutAt, a DEBUGTextLine with explicit positioning]
[54:12][Moving the time block debug information next to the mouse pointer]
[56:36][Q&A][:speech]
[57:00][@insofaras][Are the events keeping the same colors across frames? The long one looks like it keeps changing]
[57:32][handmade_debug.cpp: Make the colors persist across frames]
[1:00:04][handmade_debug.h: Add ColorIndex to debug_frame_region]
[1:01:48][@elxenoaizd][Does the 0.5 pixel error in yesterday's stream matter a lot? I mean, it seemed a pretty easy thing to overlook. Would it make some calculations erroneous?]
[1:02:41][@SoysauceTheKid][Why are there blank gaps on some of the bars? And why are the collated frames not flush with the other lines?]
[1:03:13][@elxenoaizd][Is there a reason why we have many different starting points for coordinate systems (center vs top-left vs top-right corners; windows vs Direct3D vs OpenGL)? Wouldn't our lives be easier if there was a standard for them?]
[1:04:09][@ChronalDragon][With handling sorting here, will we finally handle sorting of the other sprites in the game? Or will we just push that off further?]
[1:04:26][@elxenoaizd][Why do we have both bool32 and int32?]
[1:04:41][@JamesWidman][Pretty cool! It does seem like a lot of calls take very different amounts of time even though they're probably not doing anything different. Is that due to other active processes? Is it usually worthwhile to try to get more consistent timings?]
[1:05:05][@elxenoaizd][How 'valuable' do you think C++ operator overloading actually is? I'm thinking of fully moving to just pure C. Do you think it would be inconvenient / a hassle to program without them? (Vector operations, etc.)]
[1:05:40][@cubercaleb][Will you show us how to do hit detection for obscure shapes that may or may not exist in the debug UI?]
[1:06:07][@RacerNA][Have you seen the UE4 GDC Trailer and what are your opinions on it? I understand we are all indies, but just in general, from a player standpoint]
[1:06:34][@SoysauceTheKid][The longer bars (which I assumed was when the collation was happening) are farther left on the screen, than the shorter bars]
[1:07:10][@cubercaleb][By obscure shapes, I mean a slice in a pie-chart[ref
    site="Darel Rex Finley"
    page="Point-In-Polygon Algorithm — Determining Whether A Point Is Inside A Complex Polygon"
    url="http://alienryderflex.com/polygon/"]]
[1:09:10][@SoysauceTheKid][Yes]
[1:11:04][@RacerNA][Yes the graphics. Check it out whenever[ref
    site="YouTube"
    page="Unreal Engine 4 - GDC 2015 Features Demo Trailer"
    url="https://www.youtube.com/watch?v=APegUrDjP3E"]]
[1:12:47][@JamesWidman][\[re functions taking different amounts of time\] I mean, if we don't send any input and essentially the same image keeps getting rendered repeatedly, we still see a lot of fluctuation in the amount of time being consumed per frame. We have a lot of chop where I would have expected relatively calm waters (unless we're losing time to other processes on the machine)]
[1:15:12][@garryjohanson][Curious what point represents the amount of time it takes the operating system to set up the parallelism, if parallelism is the right word]
[1:16:26][@cubercaleb][Do you know why one of the worker threads started after the others?]
[1:17:16][@AlephAnt][Every once in a while it seems like a frame gets missed; I've noticed that happens in things I do as well. Is there a way to get around that reliably?]
[1:18:36][@elxenoaizd][What do you think of the theory that says we already know everything, all the knowledge there is, but we just don't remember it? So when we study, etc. we start remembering things...]
[1:20:17][Announce an announcement and sign off][:speech]
[/video]
