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

81 lines
8.5 KiB
Plaintext

[video output=day460 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Providing Platform File Information to the Game" vod_platform=youtube id=1hsgCZShc9Q annotator=Miblo]
[0:00][Recap and set the stage for the day][:speech]
[1:18][Determine to enable the PNG loader to use :memory from an arena][:speech]
[5:16][Switch the PNG loader over to use a memory_arena][:memory]
[17:00][Note the need to emulate a :"platform layer" in test_png.cpp][:speech]
[18:46][Initialise a platform_api and introduce CRTAllocateMemory and CRTDeallocateMemory callbacks in test_png.cpp][:memory :"platform layer"]
[23:36][:Run it to see that it still works][:memory :"platform layer"]
[24:08][Begin to implement Outf_() based on our existing FormatString()][:"error handling"]
[27:11][A few thoughts on null-terminated strings][:speech]
[29:21][Proceed with Outf_() pushing non null-terminated strings into the error stream][:"error handling"]
[32:41][:Run it to see no errors, but busted info printout][:"error handling"]
[33:24][Change AppendChunk() to return a stream_chunk for Outf_() to print the File and LineNumber][:"error handling"]
[34:29][:Run it to see our complete info printout][:"error handling"]
[36:06][#include "handmade_png.h" and "handmade_stream.h" in the game]
[37:58][Determine to augment the asset storage format with the concept of on-demand asset addition][:"asset loading" :speech]
[41:42][Check out the current asset system with a view to enabling it to load PNG spritesheets into permanent storage, and expanding the platform_api with information on when that PNG loading needs to happen][:"asset loading" :"platform layer" :research]
[44:41][Determine to watch a directory for changes to PNG files][:"file io" :speech]
[47:49][Add a PlatformFileType_PNG and PlatformFileType_WAV for Win32GetAllFilesOfTypeBegin to understand][:"asset loading" :"platform layer"]
[48:45][Check out what file information the :"asset loading" system currently contains][:"platform layer" :research]
[51:10][Introduce platform_file_info struct containing the FileDate and BaseName][:"asset loading" :"platform layer"]
[54:10][Consider the need for additional information not included in the PNG files][:"asset loading" :"platform layer" :speech]
[57:22][Augment platform_file_group with an array of platform_file_info, and make PLATFORM_OPEN_FILE take an Index to open a particular file][:"asset loading" :"platform layer"]
[59:43][Consider how the file info will be gathered and used in the :"asset loading" system, and the directory structure of our assets][:"platform layer" :speech]
[1:02:51][Establish the directory structure from where Win32GetAllFilesOfTypeBegin gets files][:"asset loading" :"platform layer"]
[1:06:20][Remove win32_platform_file_handle and change win32_platform_file_group to only contain a memory_arena for Win32GetAllFilesOfTypeBegin to store a linked list of platform_file_info[ref
site=MSDN
page="_WIN32_FIND_DATAA structure"
url=https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-_win32_find_dataa]][:"asset loading" :memory :"platform layer"]
[1:16:47][Consult MSDN for a filename :parsing function][:research]
[1:21:55][Enable Win32GetAllFilesOfTypeBegin to pull out the BaseName from the file path[ref
site=MSDN
page="_WIN32_FIND_DATAA structure"
url=https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-_win32_find_dataa] and Win32GetAllFilesOfTypeEnd to Clear the :memory][:"string manipulation"]
[1:26:39][Trim down Win32OpenFile, preventing it from allocating :memory for the Win32Handle][:"platform layer"]
[1:31:12][Change Win32GetAllFilesOfTypeEnd and Win32GetAllFilesOfTypeBegin to use wchar_t characters]
[1:34:43][Search MSDN for a UTF-16 to ASCII converter][:research]
[1:36:13][Read MSDN on the WideCharToMultiByte function[ref
site=MSDN
page="WideCharToMultiByte function"
url=https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-widechartomultibyte]][:research :"string manipulation"]
[1:36:41][Enable Win32GetAllFilesOfTypeBegin to pass ASCII base filenames to the game using WideCharToMultiByte()][:"string manipulation"]
[1:41:17][Enable Win32OpenFile to open our file handle, and implement Win32CloseFile][:"file io"]
[1:45:09][Enable Win32GetAllFilesOfTypeBegin to fill out all the platform_file_info[ref
site=MSDN
page="FILETIME structure"
url=https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284] and fix up compile errors][:"asset loading"]
[1:49:07][Step through Win32GetAllFilesOfTypeBegin to watch it fill out the Info][:"asset loading" :run]
[1:53:18][Begin to enable Win32GetAllFilesOfTypeBegin to include the file path stem and extension in the info][:memory :"string manipulation"]
[1:56:49][][:speech][quote 618]
[1:56:57][Continue enabling Win32GetAllFilesOfTypeBegin to fill out the file path stem and extension, introducing CopyArray()][:memory :"string manipulation"]
[2:01:17][Jump into Win32GetAllFilesOfTypeBegin and through Win32OpenFile until hitting the InvalidCodePath in BeginWorldChange()][:"asset loading" :run]
[2:04:58][:Run the game in -O2 to determine that that part of the system is ready to do dynamic loading][:"asset loading"]
[2:05:37][Q&A][:speech]
[2:06:10][@Rounin][Q: Where will the assets be stored when they're not reloaded from the PNGs, WAVs etc?][:"asset loading" :memory]
[2:07:28][@sopvop][Q: I thought asset system allocates based on headers read from asset files. That means you can replace resources with dynamic reload but not add new ones. And you can't add tags. Or am I missing something?][:"asset loading"]
[2:08:01][@uniquealphanumerics][Q: How will we handle the switch between .hha and loose asset files?][:"asset loading"]
[2:08:27][@frostyninja][Q: For future reference, since you might be looking at it in the next few episodes - GetFileAttributesEx() with a GetFileExInfoStandard flag comes out the fastest out of all the ways to get the file size from the win32 API; vs GetFileSize and FindFirstFile etc.][:"file io"]
[2:08:59][@tavqua][Q: Will you do my comp sci homework for me?]
[2:09:05][@frostyninja][Q: Sorry, meant file mod time][:"file io"]
[2:09:54][@puremouron][Q: Do you intend to allow hot reload of things like metadata (hotspots, etc.). You sort of mentioned it but I didn't follow what you were thinking][:"asset loading"]
[2:10:20][@dantemort][Q: Which :language is better in game industry? C, C++, or even C#? So much way to programming, it's confusing]
[2:11:35][@vaualbus][Q: In my system I have a thing that you can register a file name and when it changes a callback function is invoked, then for every file I have to load I add an entry in that table. What do you think of add callbacks?]
[2:12:28][@puremouron][Q: If the artist changes the :art, then the hotspot might change, so it could be tricky][:"asset loading"]
[2:12:48][@sopvop][Q: How often people in chat suggest you to Rewrite In Rust?][:language]
[2:14:49][@uniquealphanumerics][Q: IO completion ports vs :"asset loading" thread?][:threading]
[2:16:45][@mrjalapenobomber][Q: A little off-topic: There's been a lot of talk about the deprecation of OpenGL and using a lower level API to talk to the GPU. My question is, does Nvidia's CUDA satisfy this lower level API requirements for games, in your opinion?]
[2:18:28][Ask @Miblo how you ban people from HexChat][:speech]
[2:19:12][@kurufu][Use .b <name>]
[2:19:54][@Brian][Q: Forgive me for I did not watch the entire episode, but instead of iterating over the entire directory, could you not use functions like ReadDirectoryChangesW and FindFirstChangeNotificationW? Or will the number of files be so small and this is for debug only that not worth it?[ref
site=MSDN
page="ReadDirectoryChangesW function"
url=https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw]][:"file io"]
[2:25:43][@sopvop][Q: Would it be good idea to abstract render push buffer? That way you can use Vulkan command buffers or whatever Metal has with less memory copying][:hardware :rendering]
[2:26:26][@master_potato_][Q: More :hardware related: Will your code have to be different when coding for different video cards (i.e. AMD vs Nvidia)?]
[2:27:54][@vaualbus][Q: Why sometimes do the MSDN functions require buffers to be aligned?][:memory]
[2:29:54][That's it, with a mention of the Watch page[ref
site="Handmade Hero"
page=Watch
url=https://handmadehero.org/watch] and a glimpse into the future moving PNG files through a runtime pipeline into the .hha files][:"asset loading" :speech]
[/video]