Merge pull request #21613 from hrydgard/misc-changes

Misc changes by GermanAizek
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-04-28 12:08:20 +02:00
commit b0f5db81aa
9 files changed
+42 -35

No files matched your search

+1
View File
@@ -96,6 +96,7 @@ const u8 *ParamSFOData::GetValueData(std::string_view key, unsigned int *size) c
std::vector<std::string> ParamSFOData::GetKeys() const {
std::vector<std::string> result;
result.reserve(values.size());
for (const auto &pair : values) {
result.push_back(pair.first);
}
+1 -1
View File
@@ -125,7 +125,7 @@ allocate:
// That means it's free. Grab it, and load the value into it (if requested).
ar[reg].isDirty = (mapFlags & MAP_DIRTY) ? true : false;
if ((mapFlags & MAP_NOINIT) != MAP_NOINIT) {
if (mr[mipsReg].loc == ML_MEM && mipsReg < TEMP0) {
if (mipsReg < TEMP0 && mr[mipsReg].loc == ML_MEM) {
emit_->VLDR((ARMReg)(reg + S0), CTXREG, GetMipsRegOffset(mipsReg));
}
}
+2 -1
View File
@@ -253,6 +253,7 @@ void IRFrontend::DoJit(u32 em_address, std::vector<IRInst> &instructions, u32 &m
js.inDelaySlot = false;
js.PrefixStart();
ir.Clear();
ir.Reserve(64); // Estimate a reasonable number of IR instructions per block
js.numInstructions = 0;
while (js.compiling) {
@@ -305,7 +306,7 @@ void IRFrontend::DoJit(u32 em_address, std::vector<IRInst> &instructions, u32 &m
}
else {
std::vector<IRInst> block_instructions = code->GetInstructions();
instructions.reserve(block_instructions.capacity());
instructions.reserve(block_instructions.size() + 2); // +2 for Downcount and LogIRBlock
// The first instruction is "Downcount"
instructions.push_back(block_instructions.front());
instructions.push_back({ IROp::LogIRBlock, {0}, 0, 0, 0 });
+4 -4
View File
@@ -445,7 +445,7 @@ bool IRNativeRegCacheBase::IsRegClobbered(MIPSLoc type, IRReg r) const {
if (usage == IRUsage::CLOBBERED) {
// If multiple mips regs use this native reg (i.e. vector, HI/LO), check each.
bool canClobber = true;
for (IRReg m = first + 1; mr[m].nReg == mr[first].nReg && m < IRREG_INVALID && canClobber; ++m)
for (IRReg m = first + 1; m < IRREG_INVALID && mr[m].nReg == mr[first].nReg && canClobber; ++m)
canClobber = GetNextRegUsage(info, type, m) == IRUsage::CLOBBERED;
return canClobber;
@@ -497,7 +497,7 @@ IRNativeReg IRNativeRegCacheBase::FindBestToSpill(MIPSLoc type, MIPSMap flags, b
// If multiple mips regs use this native reg (i.e. vector, HI/LO), check each.
// Note: mipsReg points to the lowest numbered IRReg.
bool canClobber = true;
for (IRReg m = mipsReg + 1; mr[m].nReg == nreg && m < IRREG_INVALID && canClobber; ++m)
for (IRReg m = mipsReg + 1; m < IRREG_INVALID && mr[m].nReg == nreg && canClobber; ++m)
canClobber = GetNextRegUsage(info, type, m) == IRUsage::CLOBBERED;
// Okay, if all can be clobbered, we're good to go.
@@ -541,7 +541,7 @@ void IRNativeRegCacheBase::DiscardNativeReg(IRNativeReg nreg) {
_assert_msg_(nreg >= 0 && nreg < config_.totalNativeRegs, "DiscardNativeReg on invalid register %d", nreg);
if (nr[nreg].mipsReg != IRREG_INVALID) {
int8_t lanes = 0;
for (IRReg m = nr[nreg].mipsReg; mr[m].nReg == nreg && m < IRREG_INVALID; ++m)
for (IRReg m = nr[nreg].mipsReg; m < IRREG_INVALID && mr[m].nReg == nreg; ++m)
lanes++;
if (mr[nr[nreg].mipsReg].isStatic) {
@@ -1002,7 +1002,7 @@ void IRNativeRegCacheBase::MapNativeReg(MIPSLoc type, IRNativeReg nreg, IRReg fi
if (mreg.nReg != -1) {
// How many lanes is it currently in?
int oldlanes = 0;
for (IRReg m = nr[mreg.nReg].mipsReg; mr[m].nReg == mreg.nReg && m < IRREG_INVALID; ++m)
for (IRReg m = nr[mreg.nReg].mipsReg; m < IRREG_INVALID && mr[m].nReg == mreg.nReg; ++m)
oldlanes++;
// We may need to flush if it goes outside or we're initing.
+2 -1
View File
@@ -1212,7 +1212,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int
} else {
// The hacky way to get the display layout config (normally we pass it down, but it would require a lot of plumbing here).
// This is only for non-buffered rendering.
auto config = g_Config.GetDisplayLayoutConfig(g_display.GetDeviceOrientation());
const auto& config = g_Config.GetDisplayLayoutConfig(g_display.GetDeviceOrientation());
// Here config is valid.
_dbg_assert_(channel == RASTER_COLOR);
// We are drawing directly to the back buffer so need to flip.
@@ -3381,6 +3381,7 @@ void FramebufferManagerCommon::RebindFramebuffer(const char *tag) {
std::vector<const VirtualFramebuffer *> FramebufferManagerCommon::GetFramebufferList() const {
std::vector<const VirtualFramebuffer *> list;
list.reserve(vfbs_.size());
for (auto vfb : vfbs_) {
list.push_back(vfb);
}
+1
View File
@@ -1595,6 +1595,7 @@ int GPUCommon::GetCurrentPrimCount() {
std::vector<DisplayList> GPUCommon::ActiveDisplayLists() {
std::vector<DisplayList> result;
result.reserve(dlQueue.size());
for (int it : dlQueue) {
result.push_back(dls[it]);
+3
View File
@@ -246,6 +246,9 @@ void ShaderManagerVulkan::Clear() {
lastFSID_.set_invalid();
lastVSID_.set_invalid();
lastGSID_.set_invalid();
lastVShader_ = nullptr;
lastFShader_ = nullptr;
lastGShader_ = nullptr;
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE);
}
+24 -24
View File
@@ -75,7 +75,7 @@ GameInfo::~GameInfo() {
fileLoader.reset();
}
bool IsReasonableEbootDirectory(Path path) {
bool IsReasonableEbootDirectory(const Path& path) {
// First some sanity checks.
if (path == Path("/")) {
return false;
@@ -250,7 +250,7 @@ std::string GameInfo::GetMTime() const {
// Not too meaningful if the object itself is a savedata directory...
// Call this under lock.
std::vector<Path> GameInfo::GetSaveDataDirectories() {
std::vector<Path> GameInfo::GetSaveDataDirectories() const {
if (!(hasFlags & GameInfoFlags::PARAM_SFO)) {
ERROR_LOG(Log::UI, "Can't get savedata directories if we don't have PARAM_SFO.");
return std::vector<Path>();
@@ -268,14 +268,14 @@ std::vector<Path> GameInfo::GetSaveDataDirectories() {
const std::string &prefix = id;
File::GetFilesInDir(memc, &dirs, nullptr, 0, prefix);
for (size_t i = 0; i < dirs.size(); i++) {
directories.push_back(dirs[i].fullName);
for (const auto& dir : dirs) {
directories.push_back(dir.fullName);
}
return directories;
}
u64 GameInfo::GetGameSavedataSizeInBytes() {
u64 GameInfo::GetGameSavedataSizeInBytes() const {
if (fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY || fileType == IdentifiedFileType::PPSSPP_SAVESTATE) {
return 0;
}
@@ -283,9 +283,9 @@ u64 GameInfo::GetGameSavedataSizeInBytes() {
u64 totalSize = 0;
u64 filesSizeInDir = 0;
for (size_t j = 0; j < saveDataDir.size(); j++) {
for (const auto& dir : saveDataDir) {
std::vector<File::FileInfo> fileInfo;
File::GetFilesInDir(saveDataDir[j], &fileInfo);
File::GetFilesInDir(dir, &fileInfo);
for (auto const &file : fileInfo) {
if (!file.isDirectory)
filesSizeInDir += file.size;
@@ -299,7 +299,7 @@ u64 GameInfo::GetGameSavedataSizeInBytes() {
return totalSize;
}
u64 GameInfo::GetInstallDataSizeInBytes() {
u64 GameInfo::GetInstallDataSizeInBytes() const {
if (fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY || fileType == IdentifiedFileType::PPSSPP_SAVESTATE) {
return 0;
}
@@ -307,9 +307,9 @@ u64 GameInfo::GetInstallDataSizeInBytes() {
u64 totalSize = 0;
u64 filesSizeInDir = 0;
for (size_t j = 0; j < saveDataDir.size(); j++) {
for (const auto& dir : saveDataDir) {
std::vector<File::FileInfo> fileInfo;
File::GetFilesInDir(saveDataDir[j], &fileInfo);
File::GetFilesInDir(dir, &fileInfo);
for (auto const &file : fileInfo) {
// TODO: Might want to recurse here? Don't know games that use directories
// for install-data though.
@@ -357,12 +357,12 @@ void GameInfo::DisposeFileLoader() {
fileLoader.reset();
}
bool GameInfo::DeleteAllSaveData() {
bool GameInfo::DeleteAllSaveData() const {
std::vector<Path> saveDataDir = GetSaveDataDirectories();
for (size_t j = 0; j < saveDataDir.size(); j++) {
INFO_LOG(Log::System, "Deleting savedata from %s", saveDataDir[j].c_str());
if (!MoveDirectoryTreeToTrashOrDelete(saveDataDir[j])) {
ERROR_LOG(Log::System, "Failed to delete savedata %s", saveDataDir[j].c_str());
for (const auto& dir : saveDataDir) {
INFO_LOG(Log::System, "Deleting savedata from %s", dir.c_str());
if (!MoveDirectoryTreeToTrashOrDelete(dir)) {
ERROR_LOG(Log::System, "Failed to delete savedata %s", dir.c_str());
}
}
return true;
@@ -994,7 +994,7 @@ void GameInfoCache::Clear() {
void GameInfoCache::CancelAll() {
std::lock_guard<std::mutex> lock(mapLock_);
for (auto info : info_) {
for (const auto& info : info_) {
// GetFileLoader will create one if there isn't one already.
// Avoid that by checking.
if (info.second->HasFileLoader()) {
@@ -1008,15 +1008,15 @@ void GameInfoCache::CancelAll() {
void GameInfoCache::FlushBGs() {
std::lock_guard<std::mutex> lock(mapLock_);
for (auto iter = info_.begin(); iter != info_.end(); iter++) {
std::lock_guard<std::mutex> lock(iter->second->lock);
iter->second->pic0.Clear();
iter->second->pic1.Clear();
if (!iter->second->sndFileData.empty()) {
iter->second->sndFileData.clear();
iter->second->sndDataLoaded = false;
for (const auto& iter : info_) {
std::lock_guard<std::mutex> lock(iter.second->lock);
iter.second->pic0.Clear();
iter.second->pic1.Clear();
if (!iter.second->sndFileData.empty()) {
iter.second->sndFileData.clear();
iter.second->sndDataLoaded = false;
}
iter->second->hasFlags &= ~(GameInfoFlags::PIC0 | GameInfoFlags::PIC1 | GameInfoFlags::SND);
iter.second->hasFlags &= ~(GameInfoFlags::PIC0 | GameInfoFlags::PIC1 | GameInfoFlags::SND);
}
}
+4 -4
View File
@@ -78,7 +78,7 @@ public:
~GameInfo();
bool Delete(); // Better be sure what you're doing when calling this. Will move to trash if available on the system, though.
bool DeleteAllSaveData();
bool DeleteAllSaveData() const;
bool CreateLoader();
bool HasFileLoader() const {
@@ -90,8 +90,8 @@ public:
u64 GetSizeUncompressedInBytes(); // NOTE: More expensive than GetGameSizeOnDiskInBytes().
u64 GetSizeOnDiskInBytes();
u64 GetGameSavedataSizeInBytes(); // For games
u64 GetInstallDataSizeInBytes();
u64 GetGameSavedataSizeInBytes() const; // For games
u64 GetInstallDataSizeInBytes() const;
// For various kinds of savedata, mainly.
// NOTE: This one actually performs I/O directly, not cached.
@@ -104,7 +104,7 @@ public:
}
void FinishPendingTextureLoads(Draw::DrawContext *draw);
std::vector<Path> GetSaveDataDirectories();
std::vector<Path> GetSaveDataDirectories() const;
std::string GetTitle();
std::string GetDBTitle(); // Falls back to GetTitle if not in the DB.