I've realized something that helped the playback file go to the KB range and the loading times become almost instant.
We've been writing the entire State->GameMemoryBlock (more than 1 GB) every time we enabled the loop in our BeginInputPlayback and BeginRecordingInput functions. But we don't use allot of that memory. So I tried instead doing this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | internal void Win32BeginRecordingInput(win32_state *State, int InputRecordingIndex) { State->InputRecordingIndex = InputRecordingIndex; char Filename[WIN32_STATE_FILENAME_COUNT]; Win32GetInputFileLocation(State, InputRecordingIndex, sizeof(Filename), Filename); State->RecordingHandle = CreateFileA(Filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); DWORD BytesToWrite = (DWORD)State->TotalSize; Assert(State->TotalSize == BytesToWrite); DWORD BytesWritten; WriteFile(State->RecordingHandle, (game_state *)State->GameMemoryBlock, sizeof(game_state), &BytesWritten, 0); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | internal void Win32BeginInputPlayback(win32_state *State, int InputPlayingIndex) { State->InputPlayingIndex = InputPlayingIndex; char Filename[WIN32_STATE_FILENAME_COUNT]; Win32GetInputFileLocation(State, InputPlayingIndex, sizeof(Filename), Filename); State->PlaybackHandle = CreateFileA(Filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); DWORD BytesToRead = (DWORD)State->TotalSize; Assert(BytesToRead == State->TotalSize); DWORD BytesRead; ReadFile(State->PlaybackHandle, (game_state *)State->GameMemoryBlock, sizeof(game_state), &BytesRead, 0); } |
And it solved all my storage woes on my SSD and it was really fast! I'm not sure if later on when the game becomes more complex we will need more than the game state?