flush file streamer after each write

This commit is contained in:
Samuliak 2024-12-01 18:57:57 +01:00
parent f71046333d
commit 1752126f5c
No known key found for this signature in database
4 changed files with 18 additions and 5 deletions

View File

@ -1,17 +1,17 @@
#include "Cafe/HW/Latte/Renderer/Metal/MetalPipelineCache.h"
#include "Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h"
#include "Cafe/HW/Latte/Renderer/Metal/LatteToMtl.h"
#include "Cafe/HW/Latte/Renderer/Metal/MetalPipelineCompiler.h"
#include "Cafe/HW/Latte/Core/FetchShader.h"
#include "Cafe/HW/Latte/ISA/RegDefines.h"
#include "Cafe/HW/Latte/Core/LatteConst.h"
#include "Cafe/HW/Latte/Common/RegisterSerializer.h"
#include "Cafe/HW/Latte/Core/LatteShaderCache.h"
#include "Cemu/FileCache/FileCache.h"
#include "Common/precompiled.h"
#include "Cafe/HW/Latte/Core/LatteShader.h"
#include "Cafe/HW/Latte/ISA/LatteReg.h"
#include "HW/Latte/Renderer/Metal/MetalPipelineCompiler.h"
#include "Cemu/FileCache/FileCache.h"
#include "Common/precompiled.h"
#include "util/helpers/helpers.h"
#include "config/ActiveSettings.h"

View File

@ -111,7 +111,7 @@ FileCache* FileCache::Create(const fs::path& path, uint32 extraVersion)
fileCache->fileTableEntries[0].fileOffset = fileCache->fileTableOffset;
fileCache->fileTableEntries[0].fileSize = fileCache->fileTableSize;
// write header
fs->writeU32(FILECACHE_MAGIC_V3);
fs->writeU32(fileCache->extraVersion);
fs->writeU64(fileCache->dataOffset);
@ -316,7 +316,7 @@ bool _uncompressFileData(const uint8* rawData, size_t rawSize, std::vector<uint8
Bytef* compressedInput = (Bytef*)rawData + 4;
uLongf compressedLen = (uLongf)(rawSize - 4);
uLongf uncompressedLen = fileSize;
dataOut.resize(fileSize);
dataOut.resize(fileSize);
int zret = uncompress2(dataOut.data(), &uncompressedLen, compressedInput, &compressedLen);
if (zret != Z_OK)
{
@ -462,9 +462,15 @@ void FileCache::_addFileInternal(uint64 name1, uint64 name2, const uint8* fileDa
// write file data
fileStream->SetPosition(this->dataOffset + currentStartOffset);
fileStream->writeData(rawData, rawSize);
#ifdef __APPLE__
fileStream->Flush();
#endif
// write file table entry
fileStream->SetPosition(this->dataOffset + this->fileTableOffset + (uint64)(sizeof(FileTableEntry)*entryIndex));
fileStream->writeData(this->fileTableEntries + entryIndex, sizeof(FileTableEntry));
#ifdef __APPLE__
fileStream->Flush();
#endif
if (isCompressed)
free(rawData);
}

View File

@ -116,6 +116,11 @@ void FileStream::extract(std::vector<uint8>& data)
readData(data.data(), fileSize);
}
void FileStream::Flush()
{
m_fileStream.flush();
}
uint32 FileStream::readData(void* data, uint32 length)
{
SyncReadWriteSeek(false);

View File

@ -22,6 +22,8 @@ class FileStream
bool SetEndOfFile();
void extract(std::vector<uint8>& data);
void Flush();
// reading
uint32 readData(void* data, uint32 length);
bool readU64(uint64& v);