is presently its sole maintainer,
You can support him:
Recap and plan for today
Packing a tiny monospaced font into the asset file
Supporting font selection
Adding the debug font
Testing the packing of multiple fonts
The AssetCount is wrong. Let's debug that
We're missing one entire character set
Are TypeIDs not initialized?
Let's see if it's the asset processor's fault
The way the code is structured, we can't BeginAssetType twice for the same AssetType...
... but we can group all the font packing calls inside WriteFonts to sidestep that issue
Tagging the fonts
Testing the new font packing
Picking a different font
Specifying the size of the font
Adding some extra TIMED_BLOCK calls
There are still two problems that we need to solve:
1) The timing of anything that encloses the render process is wrong
2) The access to the timers is not thread-safe
The first problem can be solved by displaying the counters with one frame of delay...
... but we'll first solve the threading problem
(Blackboard) Thread-safe performance counters
Review of implementation of performance counters. Using Record->CycleCount as temporary storage is problematic, because it should contain the end result
Using a separate value to keep track of the StartCycles
The concurrent access to HitCount and CycleCount is also a problem
Consulting the _InterlockedExchangeAdd docs
The result does not look correct yet
Resetting the counters atomically
Correcting the _snprintf_s format specifiers of the time counters
Updating CycleCount and HitCount atomically together by merging them into a single U64
Making the reading and resetting of the counters also atomic using an unconditional atomic exchange
It seems to be working
We are now thread-safe
Reporting both DebugRecordsMain and DebugRecordsOptimized
Reporting also the line number of TIMED_BLOCKs
Adding some more TIMED_BLOCKs
The path of least resistance should be the right path, so that doing the right thing is never drudge work
andsz_ Q: This was, again, pretty awesome! Thank you
TheBuzzSaw Q: Wouldn't a union be helpful for that HitCount_CycleCount? It just seems unnecessary having to remember their offsets and / or lengths
elxenoaizd Q: Yesterday I asked about preprocessor constants other than __FILE__, __LINE__ etc. I did some searching and found out about __TIME__ and __DATE__. Maybe it's useful for us to include a date-time stamp in some of our logs?
insofaras Q: Can you align the text into columns with %32s in the sprintf or something?
handmade.cpp: Align the text into columns
elxenoaizd Q: You mentioned yesterday that destructors are called when the scope of the object ends. I just wanted to note it seems that if you use it to exit a function instead of 'return' then the destructors won't get called!
dandymcgee Q: Will you marry me?
panic00 Q: Won't rtdsc give wrong results if your thread is pre-empted and scheduled onto a different CPU between the constructor and destructor calls?
MannySlain Q: Are you working on any games other than Handmade Hero?
twitch_makes_me_itch Q: General Programming Question: Do you have any general advice for optimizing code performance, e.g. multithreading, algorithm complexity analysis, etc.)?
elxenoaizd Q: Sorry I made a typo in the previous question: You mentioned yesterday that destructors are called when the scope of the object ends. I just wanted to note it seems that if you use "exit" to exit a function instead of 'return' then the destructors won't get called!
Wisteso Q: The values are pretty hard to read when they're changing literally every frame. Wouldn't it be better to average them?
panic00 Q: Have you considered keeping the timers in thread-local storage instead of using atomics every time you write to them?
cubercaleb Q: Are lock-free data structures worth the time they take to write?
teryrorDS Q: Do you think it would be worthwhile to make the time records hierarchical (like a call tree), and how would you go about it?
SeaOfSorrows Q: Can you explain the difference between mutexes and interlocks?
Blackboard: Interlocks and Mutexes
ijustwantfood Q: Wait, about the values, can you draw a graph out of them?
elxenoaizd Q: NOOO! Save the Cherry MX Blues
ttbjm Q: Will you be able to fix the click bug at the end of sounds with the debug system?
guit4rfreak Q: Can you still time a smaller section inside the code or does it just work for whole functions now?
elxenoaizd Q: I noticed you prefer to keep things on the stack and return by value. 0) This helps with locality of reference and is more cache friendly, am I right? 1) Is the stack size something to be concerned about? 2) When returning by value, is the time taken to copy the object and return it something to be worried about? Maybe when the struct is large? In that case, do you prefer to return a pointer to the object?
sparklyguy Q: How do threads wait on lock-free structures? Do they? [see Resources]
gasto5 Q: What's wrong with pointers to inline functions?
elxenoaizd Q: Why you skips my questions?
BIurberry Q: Did you get a degree in CS? What's your background on programming?
Wind it down